@itwin/imodel-transformer 1.0.1-customchanges.0 → 1.0.1-customchanges.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ import { EntityReference } from "@itwin/core-common";
7
7
  import { ConcreteEntity, ConcreteEntityProps, IModelDb } from "@itwin/core-backend";
8
8
  /** @internal */
9
9
  export declare namespace EntityUnifier {
10
- export function getReadableType(entity: ConcreteEntity): "element" | "relationship" | "element aspect" | "unknown entity type";
10
+ export function getReadableType(entity: ConcreteEntity): "element" | "element aspect" | "relationship" | "unknown entity type";
11
11
  type EntityUpdater = (entityProps: ConcreteEntityProps) => void;
12
12
  /** needs to return a widened type otherwise typescript complains when result is used with a narrow type */
13
13
  export function updaterFor(db: IModelDb, entity: ConcreteEntity): EntityUpdater;
@@ -2,7 +2,7 @@
2
2
  * @module iModels
3
3
  */
4
4
  import { BriefcaseDb, ChangedECInstance, Element, ElementAspect, ElementMultiAspect, ElementUniqueAspect, IModelDb, IModelJsNative, Model, Relationship, SqliteChangeOp } from "@itwin/core-backend";
5
- import { Id64String } from "@itwin/core-bentley";
5
+ import { Id64Arg, Id64String } from "@itwin/core-bentley";
6
6
  import { ChangesetFileProps, CodeSpec, FontProps } from "@itwin/core-common";
7
7
  import { Schema, SchemaKey } from "@itwin/ecschema-metadata";
8
8
  import { ElementAspectsHandler, ExportElementAspectsStrategy } from "./ExportElementAspectsStrategy";
@@ -230,16 +230,6 @@ export declare class IModelExporter {
230
230
  * you pass to [[IModelExporter.exportChanges]]
231
231
  */
232
232
  initialize(options: ExporterInitOptions): Promise<void>;
233
- /**
234
- * This function is called by the transformer as it is about to process the changesets passed to it in [[IModelTransformOptions.argsForProcessChanges]].
235
- * This would be after the exporter has already processed the same set of changesets passed to the transformer in [[IModelTransformOptions.argsForProcessChanges]].
236
- * This function should be used to modify the exporter's sourceDbChanges, if necessary, using [[ChangedInstanceIds.addCustomChange]]. See [[ChangedInstanceIds.addCustomChange]] for more information.
237
- * @note [[IModelExporter.sourceDbChanges]] will only be defined if the transformer was called with [[IModelTransformOptions.argsForProcessChanges]].
238
- * @note If defined, sourceDbChanges will already be populated with the changesets passed to the transformer, if any when this function is called by the transformer.
239
- * @note The transformer will have built up the remap table between the source and target iModels before calling this function. This means that functions like [[IModelTransformer.context.findTargetElementId]] will return meaningful results.
240
- * @note Its expected that this function be overridden by a subclass of exporter if it needs to modify sourceDbChanges.
241
- */
242
- addCustomChanges(): void;
243
233
  /** Register the handler that will be called by IModelExporter. */
244
234
  registerHandler(handler: IModelExportHandler): void;
245
235
  /** Add a rule to exclude a CodeSpec */
@@ -264,6 +254,7 @@ export declare class IModelExporter {
264
254
  * range and open the source iModel as of the end (inclusive) of the desired range.
265
255
  * @note the changedInstanceIds are just for this call to exportChanges, so you must continue to pass it in
266
256
  * for consecutive calls
257
+ * @note Passing {} or undefined to exportChanges will result in the current changeset of the source iModel being exported.
267
258
  */
268
259
  exportChanges(args?: ExportChangesOptions): Promise<void>;
269
260
  private _resetChangeDataOnExport;
@@ -358,10 +349,10 @@ export declare class ChangedInstanceOps {
358
349
  addFromJson(val: IModelJsNative.ChangedInstanceOpsProps | undefined): void;
359
350
  get isEmpty(): boolean;
360
351
  }
361
- export type ChangedInstanceType = "codeSpec" | "model" | "element" | "aspect" | "relationship" | "font";
362
352
  /**
363
353
  * Interface to describe a 'custom' change. A custom change is one which isn't found by reading changesets, but instead added by a user calling the 'addCustomChange' API on the ChangedInstanceIds instance.
364
354
  * The purpose a custom change would serve is to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
355
+ * @beta
365
356
  */
366
357
  export interface ChangedInstanceCustomRelationshipData {
367
358
  sourceIdOfRelationship: Id64String;
@@ -389,7 +380,7 @@ export declare class ChangedInstanceIds {
389
380
  private _ecClassIdsToClassFullNames?;
390
381
  /** c${string} is used to represent codeSpecs since they do not currently have a representation in the EntityReference class. This map holds information passed to the 'addCustom' functions. */
391
382
  private _entityReferenceToCustomDataMap;
392
- private _hasCustomChanges;
383
+ private _hasCustomRelationshipChanges;
393
384
  private _db;
394
385
  constructor(db: IModelDb);
395
386
  private setupECClassIds;
@@ -399,8 +390,8 @@ export declare class ChangedInstanceIds {
399
390
  private isAspect;
400
391
  private isModel;
401
392
  private isElement;
402
- get hasCustomChanges(): boolean;
403
- get isEmpty(): boolean;
393
+ get hasCustomRelationshipChanges(): boolean;
394
+ get hasChanges(): boolean;
404
395
  /**
405
396
  * Adds the provided [[ChangedECInstance]] to the appropriate set of changes by class type (codeSpec, model, element, aspect, or relationship) maintained by this instance of ChangedInstanceIds.
406
397
  * If the same ECInstanceId is seen multiple times, the changedInstanceIds will be modified accordingly, i.e. if an id 'x' was updated but now we see 'x' was deleted, we will remove 'x'
@@ -415,32 +406,37 @@ export declare class ChangedInstanceIds {
415
406
  * @note element changes will also cause the element's model to be marked as updated in [[ChangedInstanceIds.model]], so that the element does not get skipped by the transformer.
416
407
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact an element.
417
408
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
409
+ * @beta
418
410
  */
419
- addCustomElementChange(changeType: SqliteChangeOp, id: Id64String): void;
411
+ addCustomElementChange(changeType: SqliteChangeOp, ids: Id64Arg): Promise<void>;
420
412
  /**
421
413
  * Adds the provided change to the codespec changes maintained by this instance of ChangedInstanceIds
422
414
  * If the same ECInstanceId is seen multiple times, the changedInstanceIds will be modified accordingly, i.e. if an id 'x' was updated but now we see 'x' was deleted, we will remove 'x'
423
415
  * from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
424
416
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact a codespec.
425
417
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
418
+ * @beta
426
419
  */
427
- addCustomCodeSpecChange(changeType: SqliteChangeOp, id: Id64String): void;
420
+ addCustomCodeSpecChange(changeType: SqliteChangeOp, ids: Id64Arg): void;
428
421
  /**
429
- * Adds the provided change to the model changes maintained by this instance of ChangedInstanceIds
422
+ * Adds the provided change to the model changes maintained by this instance of ChangedInstanceIds.
423
+ * Also adds the model's modeledElement to the element changes. This is to ensure the changes from the model and its modeledElement get exported together.
430
424
  * If the same ECInstanceId is seen multiple times, the changedInstanceIds will be modified accordingly, i.e. if an id 'x' was updated but now we see 'x' was deleted, we will remove 'x'
431
425
  * from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
432
426
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact a model.
433
427
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
428
+ * @beta
434
429
  */
435
- addCustomModelChange(changeType: SqliteChangeOp, id: Id64String): void;
430
+ addCustomModelChange(changeType: SqliteChangeOp, ids: Id64Arg): Promise<void>;
436
431
  /**
437
432
  * Adds the provided change to the aspect changes maintained by this instance of ChangedInstanceIds
438
433
  * If the same ECInstanceId is seen multiple times, the changedInstanceIds will be modified accordingly, i.e. if an id 'x' was updated but now we see 'x' was deleted, we will remove 'x'
439
434
  * from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
440
435
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact an aspect.
441
436
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
437
+ * @beta
442
438
  */
443
- addCustomAspectChange(changeType: SqliteChangeOp, id: Id64String): void;
439
+ addCustomAspectChange(changeType: SqliteChangeOp, ids: Id64Arg): void;
444
440
  /**
445
441
  * TODO: Think more about permutations of model updated / inserted / deleted. Can you delete a model without deleting its elements?
446
442
  * What if model delete but custom change si to insert element into target?
@@ -451,9 +447,11 @@ export declare class ChangedInstanceIds {
451
447
  * There is an optimization in [IModelExporter.exportModelContents] which doesn't try to export elements within a model unless the model itself is part of
452
448
  * the sourceDbChanges. This method is used in addCustomChange to add the model to the updatedIds set so that the custom element changes are exported.
453
449
  */
454
- private addModelToUpdated;
455
- /** TODO: Maybe relationships only? maybe not. */
456
- getCustomRelationshipDataFromId(id: Id64String, type: ChangedInstanceType): ChangedInstanceCustomRelationshipData | undefined;
450
+ private addModelsToUpdated;
451
+ /** TODO: Maybe relationships only? maybe not.
452
+ * @beta
453
+ */
454
+ getCustomRelationshipDataFromId(id: Id64String): ChangedInstanceCustomRelationshipData | undefined;
457
455
  /**
458
456
  * Adds the provided change to the set of relationship changes maintained by this instance of ChangedInstanceIds.
459
457
  * If the same ECInstanceId is seen multiple times, the changedInstanceIds will be modified accordingly, i.e. if an id 'x' was updated but now we see 'x' was deleted, we will remove 'x'
@@ -465,9 +463,9 @@ export declare class ChangedInstanceIds {
465
463
  * @param id ECInstanceID of the custom change
466
464
  * @param sourceECInstanceId source ECInstanceId of the relationship
467
465
  * @param targetECInstanceId target ECInstanceId of the relationship
466
+ * @beta
468
467
  */
469
468
  addCustomRelationshipChange(ecClassId: string, changeType: SqliteChangeOp, id: Id64String, sourceECInstanceId: Id64String, targetECInstanceId: Id64String): Promise<void>;
470
- private getClassFullNameFromECClassId;
471
469
  private handleChange;
472
470
  /**
473
471
  * Initializes a new ChangedInstanceIds object with information taken from a range of changesets.
@@ -1 +1 @@
1
- {"version":3,"file":"IModelExporter.d.ts","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,WAAW,EAEX,iBAAiB,EAKjB,OAAO,EACP,aAAa,EACb,kBAAkB,EAElB,mBAAmB,EAGnB,QAAQ,EAER,cAAc,EACd,KAAK,EAGL,YAAY,EACZ,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,UAAU,EAIX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAC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CAAC;IAuBhB,OAAO,CAAC,YAAY;IAyBpB;;;OAGG;WACiB,UAAU,CAC5B,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;CAyE3C"}
@@ -216,16 +216,6 @@ class IModelExporter {
216
216
  return;
217
217
  this._exportElementAspectsStrategy.setAspectChanges(this._sourceDbChanges.aspect);
218
218
  }
219
- /**
220
- * This function is called by the transformer as it is about to process the changesets passed to it in [[IModelTransformOptions.argsForProcessChanges]].
221
- * This would be after the exporter has already processed the same set of changesets passed to the transformer in [[IModelTransformOptions.argsForProcessChanges]].
222
- * This function should be used to modify the exporter's sourceDbChanges, if necessary, using [[ChangedInstanceIds.addCustomChange]]. See [[ChangedInstanceIds.addCustomChange]] for more information.
223
- * @note [[IModelExporter.sourceDbChanges]] will only be defined if the transformer was called with [[IModelTransformOptions.argsForProcessChanges]].
224
- * @note If defined, sourceDbChanges will already be populated with the changesets passed to the transformer, if any when this function is called by the transformer.
225
- * @note The transformer will have built up the remap table between the source and target iModels before calling this function. This means that functions like [[IModelTransformer.context.findTargetElementId]] will return meaningful results.
226
- * @note Its expected that this function be overridden by a subclass of exporter if it needs to modify sourceDbChanges.
227
- */
228
- addCustomChanges() { }
229
219
  /** Register the handler that will be called by IModelExporter. */
230
220
  registerHandler(handler) {
231
221
  this._handler = handler;
@@ -270,6 +260,7 @@ class IModelExporter {
270
260
  * range and open the source iModel as of the end (inclusive) of the desired range.
271
261
  * @note the changedInstanceIds are just for this call to exportChanges, so you must continue to pass it in
272
262
  * for consecutive calls
263
+ * @note Passing {} or undefined to exportChanges will result in the current changeset of the source iModel being exported.
273
264
  */
274
265
  async exportChanges(args) {
275
266
  if (!this.sourceDb.isBriefcaseDb())
@@ -278,11 +269,17 @@ class IModelExporter {
278
269
  await this.exportAll(); // no changesets, so revert to exportAll
279
270
  return;
280
271
  }
281
- const startChangeset = // TODO: This is weird.. why is this needed? I suspect we can remove this and just pass args to initialize?
282
- args && "startChangeset" in args ? args.startChangeset : undefined;
283
- const initOpts = {
284
- startChangeset: { id: startChangeset?.id },
285
- };
272
+ const isEmptyObject = (obj) => Object.keys(obj).length === 0;
273
+ let initOpts;
274
+ if (args === undefined || isEmptyObject(args)) {
275
+ // Fallback behavior for exportChanges with no args / empty object, this.initialize will process the current changeset of the source iModel being exported when startChangeset.id is undefined.
276
+ initOpts = {
277
+ startChangeset: { id: undefined },
278
+ };
279
+ }
280
+ else {
281
+ initOpts = args;
282
+ }
286
283
  await this.initialize(initOpts);
287
284
  // _sourceDbChanges are initialized in this.initialize
288
285
  nodeAssert(this._sourceDbChanges !== undefined, "sourceDbChanges must be initialized.");
@@ -768,7 +765,7 @@ class ChangedInstanceIds {
768
765
  this.relationship = new ChangedInstanceOps();
769
766
  this.font = new ChangedInstanceOps();
770
767
  this._db = db;
771
- this._hasCustomChanges = false;
768
+ this._hasCustomRelationshipChanges = false;
772
769
  this._entityReferenceToCustomDataMap = new Map();
773
770
  }
774
771
  async setupECClassIds() {
@@ -819,16 +816,16 @@ class ChangedInstanceIds {
819
816
  isElement(ecClassId) {
820
817
  return this._elementSubclassIds?.has(ecClassId);
821
818
  }
822
- get hasCustomChanges() {
823
- return this._hasCustomChanges;
819
+ get hasCustomRelationshipChanges() {
820
+ return this._hasCustomRelationshipChanges;
824
821
  }
825
- get isEmpty() {
826
- return (this.codeSpec.isEmpty &&
827
- this.model.isEmpty &&
828
- this.element.isEmpty &&
829
- this.aspect.isEmpty &&
830
- this.relationship.isEmpty &&
831
- this.font.isEmpty);
822
+ get hasChanges() {
823
+ return (!this.codeSpec.isEmpty ||
824
+ !this.model.isEmpty ||
825
+ !this.element.isEmpty ||
826
+ !this.aspect.isEmpty ||
827
+ !this.relationship.isEmpty ||
828
+ !this.font.isEmpty);
832
829
  }
833
830
  /**
834
831
  * Adds the provided [[ChangedECInstance]] to the appropriate set of changes by class type (codeSpec, model, element, aspect, or relationship) maintained by this instance of ChangedInstanceIds.
@@ -865,12 +862,14 @@ class ChangedInstanceIds {
865
862
  * @note element changes will also cause the element's model to be marked as updated in [[ChangedInstanceIds.model]], so that the element does not get skipped by the transformer.
866
863
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact an element.
867
864
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
865
+ * @beta
868
866
  */
869
- addCustomElementChange(changeType, id // TODO: Support bulk adds
870
- ) {
867
+ async addCustomElementChange(changeType, ids) {
871
868
  // if delete unnecessary?
872
- this.addModelToUpdated(id);
873
- this.handleChange(this.element, changeType, id);
869
+ await this.addModelsToUpdated(ids);
870
+ for (const id of core_bentley_1.Id64.iterable(ids)) {
871
+ this.handleChange(this.element, changeType, id);
872
+ }
874
873
  }
875
874
  /**
876
875
  * Adds the provided change to the codespec changes maintained by this instance of ChangedInstanceIds
@@ -878,19 +877,28 @@ class ChangedInstanceIds {
878
877
  * from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
879
878
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact a codespec.
880
879
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
880
+ * @beta
881
881
  */
882
- addCustomCodeSpecChange(changeType, id) {
883
- this.handleChange(this.codeSpec, changeType, id);
882
+ addCustomCodeSpecChange(changeType, ids) {
883
+ for (const id of core_bentley_1.Id64.iterable(ids)) {
884
+ this.handleChange(this.codeSpec, changeType, id);
885
+ }
884
886
  }
885
887
  /**
886
- * Adds the provided change to the model changes maintained by this instance of ChangedInstanceIds
888
+ * Adds the provided change to the model changes maintained by this instance of ChangedInstanceIds.
889
+ * Also adds the model's modeledElement to the element changes. This is to ensure the changes from the model and its modeledElement get exported together.
887
890
  * If the same ECInstanceId is seen multiple times, the changedInstanceIds will be modified accordingly, i.e. if an id 'x' was updated but now we see 'x' was deleted, we will remove 'x'
888
891
  * from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
889
892
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact a model.
890
893
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
894
+ * @beta
891
895
  */
892
- addCustomModelChange(changeType, id) {
893
- this.handleChange(this.model, changeType, id);
896
+ async addCustomModelChange(changeType, ids) {
897
+ // Also add the model's modeledElement to the element changes. The modeledElement and model go hand in hand and have the same id.
898
+ await this.addCustomElementChange(changeType, ids);
899
+ for (const id of core_bentley_1.Id64.iterable(ids)) {
900
+ this.handleChange(this.model, changeType, id);
901
+ }
894
902
  }
895
903
  /**
896
904
  * Adds the provided change to the aspect changes maintained by this instance of ChangedInstanceIds
@@ -898,9 +906,12 @@ class ChangedInstanceIds {
898
906
  * from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
899
907
  * @note It is the responsibility of the caller to ensure that the provided id is, in fact an aspect.
900
908
  * @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
909
+ * @beta
901
910
  */
902
- addCustomAspectChange(changeType, id) {
903
- this.handleChange(this.aspect, changeType, id);
911
+ addCustomAspectChange(changeType, ids) {
912
+ for (const id of core_bentley_1.Id64.iterable(ids)) {
913
+ this.handleChange(this.aspect, changeType, id);
914
+ }
904
915
  }
905
916
  /**
906
917
  * TODO: Think more about permutations of model updated / inserted / deleted. Can you delete a model without deleting its elements?
@@ -912,16 +923,18 @@ class ChangedInstanceIds {
912
923
  * There is an optimization in [IModelExporter.exportModelContents] which doesn't try to export elements within a model unless the model itself is part of
913
924
  * the sourceDbChanges. This method is used in addCustomChange to add the model to the updatedIds set so that the custom element changes are exported.
914
925
  */
915
- addModelToUpdated(elementId) {
916
- const modelId = this._db.elements.getElement(elementId).model;
917
- this.handleChange(this.model, "Updated", modelId);
918
- }
919
- /** TODO: Maybe relationships only? maybe not. */
920
- getCustomRelationshipDataFromId(id, type) {
921
- if (type === "relationship") {
922
- return this._entityReferenceToCustomDataMap.get(core_backend_1.EntityReferences.fromEntityType(id, core_common_1.ConcreteEntityTypes.Relationship));
926
+ async addModelsToUpdated(elementIds) {
927
+ const compressedIds = core_bentley_1.CompressedId64Set.sortAndCompress(core_bentley_1.Id64.iterable(elementIds));
928
+ const params = new core_common_1.QueryBinder().bindIdSet("elementIds", core_bentley_1.CompressedId64Set.iterable(compressedIds));
929
+ for await (const row of this._db.createQueryReader("SELECT Model.Id FROM BisCore.Element WHERE InVirtualSet(:elementIds, ECInstanceId)", params)) {
930
+ this.handleChange(this.model, "Updated", row.id);
923
931
  }
924
- return undefined;
932
+ }
933
+ /** TODO: Maybe relationships only? maybe not.
934
+ * @beta
935
+ */
936
+ getCustomRelationshipDataFromId(id) {
937
+ return this._entityReferenceToCustomDataMap.get(core_backend_1.EntityReferences.fromEntityType(id, core_common_1.ConcreteEntityTypes.Relationship));
925
938
  }
926
939
  /**
927
940
  * Adds the provided change to the set of relationship changes maintained by this instance of ChangedInstanceIds.
@@ -934,6 +947,7 @@ class ChangedInstanceIds {
934
947
  * @param id ECInstanceID of the custom change
935
948
  * @param sourceECInstanceId source ECInstanceId of the relationship
936
949
  * @param targetECInstanceId target ECInstanceId of the relationship
950
+ * @beta
937
951
  */
938
952
  async addCustomRelationshipChange(ecClassId, changeType, id, sourceECInstanceId, targetECInstanceId) {
939
953
  if (!this._ecClassIdsInitialized)
@@ -942,7 +956,7 @@ class ChangedInstanceIds {
942
956
  return;
943
957
  if (!this._relationshipSubclassIds?.has(ecClassId))
944
958
  throw new Error(`Misuse. id: ${id}, ecClassId: ${ecClassId} is not a relationship class. Use 'addCustomChange' instead.`);
945
- this._hasCustomChanges = true;
959
+ this._hasCustomRelationshipChanges = true;
946
960
  const classFullName = this._ecClassIdsToClassFullNames?.get(ecClassId);
947
961
  (0, core_bentley_1.assert)(classFullName !== undefined); // setupECClassIds adds an entry to the above map for every single ECClassId.
948
962
  this._entityReferenceToCustomDataMap.set(core_backend_1.EntityReferences.fromEntityType(id, core_common_1.ConcreteEntityTypes.Relationship), {
@@ -953,9 +967,6 @@ class ChangedInstanceIds {
953
967
  });
954
968
  this.handleChange(this.relationship, changeType, id);
955
969
  }
956
- getClassFullNameFromECClassId(ecClassid) {
957
- return this._ecClassIdsToClassFullNames?.get(ecClassid);
958
- }
959
970
  handleChange(changedInstanceOps, changeType, id) {
960
971
  // if changeType is a delete and we already have the id in the inserts then we can remove the id from the inserts.
961
972
  // if changeType is a delete and we already have the id in the updates then we can remove the id from the updates AND add it to the deletes.