diff --git a/package.json b/package.json index 15f89ad6..565c402d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/connector-client.ts b/src/connector-client.ts index ec6e3d9f..d376ad45 100644 --- a/src/connector-client.ts +++ b/src/connector-client.ts @@ -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: THING): SCAssociatedThingWithoutReferences { - /* tslint:disable:no-any */ - const thingWithoutReferences: any = { - ...{}, - ...thing, - }; - /* tslint:enable:no-any */ + + // tslint:disable-next-line:no-any + const thingWithoutReferences = clone(thing); + + delete thingWithoutReferences.origin; // iterate over all properties for (const key in thingWithoutReferences) { + /* istanbul ignore if */ if (!thingWithoutReferences.hasOwnProperty(key)) { continue;