mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-03 12:02:53 +00:00
fix: change removeReferences() to also remove origin
In addition remove unwanted side effects from the function
This commit is contained in:
committed by
Rainer Killinger
parent
24f28346bf
commit
ded221c175
@@ -26,6 +26,7 @@
|
||||
"@types/uuid": "3.4.5",
|
||||
"cli-progress": "2.1.1",
|
||||
"commander": "2.20.0",
|
||||
"fast-clone": "1.5.13",
|
||||
"moment": "2.24.0",
|
||||
"request": "2.88.0",
|
||||
"traverse": "0.6.6",
|
||||
|
||||
@@ -25,12 +25,13 @@ import {
|
||||
SCThingUpdateResponse,
|
||||
SCThingUpdateRoute,
|
||||
} from '@openstapps/core';
|
||||
import clone = require('fast-clone');
|
||||
import * as moment from 'moment';
|
||||
import {Bulk} from './bulk';
|
||||
import {Client} from './client';
|
||||
import {EmptyBulkError, NamespaceNotDefinedError} from './errors';
|
||||
|
||||
const V5_VERSION = 0x50;
|
||||
const V5_VERSION = 0x50;
|
||||
|
||||
/* tslint:disable:no-var-requires */
|
||||
/**
|
||||
@@ -91,15 +92,15 @@ export class ConnectorClient extends Client {
|
||||
* @param thing Thing to remove references from
|
||||
*/
|
||||
static removeReferences<THING extends SCThings>(thing: THING): SCAssociatedThingWithoutReferences<THING> {
|
||||
/* tslint:disable:no-any */
|
||||
const thingWithoutReferences: any = {
|
||||
...{},
|
||||
...thing,
|
||||
};
|
||||
/* tslint:enable:no-any */
|
||||
|
||||
// tslint:disable-next-line:no-any
|
||||
const thingWithoutReferences = clone<any>(thing);
|
||||
|
||||
delete thingWithoutReferences.origin;
|
||||
|
||||
// iterate over all properties
|
||||
for (const key in thingWithoutReferences) {
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (!thingWithoutReferences.hasOwnProperty(key)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user