@itwin/imodel-transformer 2.0.0-dev.10 → 2.0.0-dev.12

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.
@@ -26,7 +26,7 @@ class IModelExportHandler {
26
26
  /** If `true` is returned, then the CodeSpec will be exported.
27
27
  * @note This method can optionally be overridden to exclude an individual CodeSpec from the export. The base implementation always returns `true`.
28
28
  */
29
- shouldExportCodeSpec(_codeSpec) {
29
+ async shouldExportCodeSpec(_codeSpec) {
30
30
  return true;
31
31
  }
32
32
  /** Called when a CodeSpec should be exported.
@@ -34,31 +34,31 @@ class IModelExportHandler {
34
34
  * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.
35
35
  * @note This should be overridden to actually do the export.
36
36
  */
37
- onExportCodeSpec(_codeSpec, _isUpdate) { }
37
+ async onExportCodeSpec(_codeSpec, _isUpdate) { }
38
38
  /** Called when a font should be exported.
39
39
  * @param font The font to export
40
40
  * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.
41
41
  * @note This should be overridden to actually do the export.
42
42
  */
43
- onExportFont(_font, _isUpdate) { }
43
+ async onExportFont(_font, _isUpdate) { }
44
44
  /** Called when a model should be exported.
45
45
  * @param model The model to export
46
46
  * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.
47
47
  * @note This should be overridden to actually do the export.
48
48
  */
49
- onExportModel(_model, _isUpdate) { }
49
+ async onExportModel(_model, _isUpdate) { }
50
50
  /** Called when a model should be deleted. */
51
51
  async onDeleteModel(_modelId) { }
52
52
  /** If `true` is returned, then the element will be exported.
53
53
  * @note This method can optionally be overridden to exclude an individual Element (and its children and ElementAspects) from the export. The base implementation always returns `true`.
54
54
  */
55
- shouldExportElement(_element) {
55
+ async shouldExportElement(_element) {
56
56
  return true;
57
57
  }
58
58
  /** Called when element is skipped instead of exported.
59
59
  * @note When an element is skipped, exporter will not export any of its child elements. Because of this, [[onSkipElement]] will not be invoked for any children of a "skipped" element.
60
60
  */
61
- onSkipElement(_elementId) { }
61
+ async onSkipElement(_elementId) { }
62
62
  /** Called when an element should be exported.
63
63
  * @param element The element to export
64
64
  * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.
@@ -73,11 +73,11 @@ class IModelExportHandler {
73
73
  */
74
74
  async preExportElement(_element) { }
75
75
  /** Called when an element should be deleted. */
76
- onDeleteElement(_elementId) { }
76
+ async onDeleteElement(_elementId) { }
77
77
  /** If `true` is returned, then the ElementAspect will be exported.
78
78
  * @note This method can optionally be overridden to exclude an individual ElementAspect from the export. The base implementation always returns `true`.
79
79
  */
80
- shouldExportElementAspect(_aspect) {
80
+ async shouldExportElementAspect(_aspect) {
81
81
  return true;
82
82
  }
83
83
  /** Called when an ElementUniqueAspect should be exported.
@@ -93,7 +93,7 @@ class IModelExportHandler {
93
93
  /** If `true` is returned, then the relationship will be exported.
94
94
  * @note This method can optionally be overridden to exclude an individual CodeSpec from the export. The base implementation always returns `true`.
95
95
  */
96
- shouldExportRelationship(_relationship) {
96
+ async shouldExportRelationship(_relationship) {
97
97
  return true;
98
98
  }
99
99
  /** Called when a Relationship should be exported.
@@ -103,11 +103,11 @@ class IModelExportHandler {
103
103
  */
104
104
  async onExportRelationship(_relationship, _isUpdate) { }
105
105
  /** Called when a relationship should be deleted. */
106
- onDeleteRelationship(_relInstanceId) { }
106
+ async onDeleteRelationship(_relInstanceId) { }
107
107
  /** If `true` is returned, then the schema will be exported.
108
108
  * @note This method can optionally be overridden to exclude an individual schema from the export. The base implementation always returns `true`.
109
109
  */
110
- shouldExportSchema(_schemaKey) {
110
+ async shouldExportSchema(_schemaKey) {
111
111
  return true;
112
112
  }
113
113
  /** Called when a schema should be exported.
@@ -200,7 +200,7 @@ class IModelExporter {
200
200
  this._exportElementAspectsStrategy = new elementAspectsStrategy(this.sourceDb, {
201
201
  onExportElementMultiAspects: async (aspects) => this.handler.onExportElementMultiAspects(aspects),
202
202
  onExportElementUniqueAspect: async (aspect, isUpdate) => this.handler.onExportElementUniqueAspect(aspect, isUpdate),
203
- shouldExportElementAspect: (aspect) => this.handler.shouldExportElementAspect(aspect),
203
+ shouldExportElementAspect: async (aspect) => this.handler.shouldExportElementAspect(aspect),
204
204
  trackProgress: async () => this.trackProgress(),
205
205
  });
206
206
  }
@@ -307,7 +307,7 @@ class IModelExporter {
307
307
  // In the future, the handler may be responsible for doing the work of finding out which elements were cascade deleted,
308
308
  // and returning them for the exporter to use to avoid double-deleting with error ignoring
309
309
  try {
310
- this.handler.onDeleteElement(elementId);
310
+ await this.handler.onDeleteElement(elementId);
311
311
  }
312
312
  catch (err) {
313
313
  const isMissingErr = err instanceof core_common_1.IModelError &&
@@ -320,7 +320,7 @@ class IModelExporter {
320
320
  if (this.visitRelationships) {
321
321
  for (const relInstanceId of this._sourceDbChanges.relationship
322
322
  .deleteIds) {
323
- this.handler.onDeleteRelationship(relInstanceId);
323
+ await this.handler.onDeleteRelationship(relInstanceId);
324
324
  }
325
325
  }
326
326
  // Enable consecutive exportChanges runs without the need to re-instantiate the exporter.
@@ -354,7 +354,7 @@ class IModelExporter {
354
354
  const versionWrite = row[2];
355
355
  const versionMinor = row[3];
356
356
  const schemaKey = new ecschema_metadata_1.SchemaKey(schemaName, new ecschema_metadata_1.ECVersion(versionMajor, versionWrite, versionMinor));
357
- if (this.handler.shouldExportSchema(schemaKey)) {
357
+ if (await this.handler.shouldExportSchema(schemaKey)) {
358
358
  schemaKeysToExport.push(schemaKey);
359
359
  }
360
360
  }
@@ -409,9 +409,9 @@ class IModelExporter {
409
409
  return;
410
410
  }
411
411
  // CodeSpec has passed standard exclusion rules, now give handler a chance to accept/reject export
412
- if (this.handler.shouldExportCodeSpec(codeSpec)) {
412
+ if (await this.handler.shouldExportCodeSpec(codeSpec)) {
413
413
  core_bentley_1.Logger.logTrace(loggerCategory, `exportCodeSpec(${codeSpecName})${this.getChangeOpSuffix(isUpdate)}`);
414
- this.handler.onExportCodeSpec(codeSpec, isUpdate);
414
+ await this.handler.onExportCodeSpec(codeSpec, isUpdate);
415
415
  return this.trackProgress();
416
416
  }
417
417
  }
@@ -449,7 +449,7 @@ class IModelExporter {
449
449
  */
450
450
  async exportFontByFontProps(fontProps) {
451
451
  core_bentley_1.Logger.logTrace(loggerCategory, `exportFontByFamily(${fontProps.name}, ${fontProps.type})`);
452
- this.handler.onExportFont(fontProps, true);
452
+ await this.handler.onExportFont(fontProps, true);
453
453
  return this.trackProgress();
454
454
  }
455
455
  /** Export a single font from the source iModel.
@@ -491,7 +491,7 @@ class IModelExporter {
491
491
  wantBRepData: this.wantGeometry,
492
492
  });
493
493
  core_bentley_1.Logger.logTrace(loggerCategory, `exportModel(${modeledElementId})`);
494
- if (this.shouldExportElement(modeledElement)) {
494
+ if (await this.shouldExportElement(modeledElement)) {
495
495
  await this.exportModelContainer(model);
496
496
  if (this.visitElements) {
497
497
  await this.exportModelContents(modeledElementId);
@@ -514,7 +514,7 @@ class IModelExporter {
514
514
  return; // not in changeset, don't export
515
515
  }
516
516
  }
517
- this.handler.onExportModel(model, isUpdate);
517
+ await this.handler.onExportModel(model, isUpdate);
518
518
  return this.trackProgress();
519
519
  }
520
520
  _yieldManager = new core_bentley_1.YieldManager();
@@ -593,7 +593,7 @@ class IModelExporter {
593
593
  * This considers the standard IModelExporter exclusion rules plus calls [IModelExportHandler.shouldExportElement]($transformer) for any custom exclusion rules.
594
594
  * @note This method is called from within [[exportChanges]] and [[exportAll]], so usually does not need to be called directly.
595
595
  */
596
- shouldExportElement(element) {
596
+ async shouldExportElement(element) {
597
597
  if (this._excludedElementIds.has(element.id)) {
598
598
  core_bentley_1.Logger.logInfo(loggerCategory, `Excluded element ${element.id} by Id`);
599
599
  return false;
@@ -629,7 +629,7 @@ class IModelExporter {
629
629
  // Return early if the elementId is already in the excludedElementIds, that way we don't need to load the element from the db.
630
630
  if (this._excludedElementIds.has(elementId)) {
631
631
  core_bentley_1.Logger.logInfo(loggerCategory, `Excluded element ${elementId} by Id`);
632
- this.handler.onSkipElement(elementId);
632
+ await this.handler.onSkipElement(elementId);
633
633
  return;
634
634
  }
635
635
  // are we processing changes?
@@ -645,7 +645,7 @@ class IModelExporter {
645
645
  });
646
646
  core_bentley_1.Logger.logTrace(loggerCategory, `exportElement(${element.id}, "${element.getDisplayLabel()}")${this.getChangeOpSuffix(isUpdate)}`);
647
647
  // the order and `await`ing of calls beyond here is depended upon by the IModelTransformer for a current bug workaround
648
- if (this.shouldExportElement(element)) {
648
+ if (await this.shouldExportElement(element)) {
649
649
  await this.handler.preExportElement(element);
650
650
  await this.handler.onExportElement(element, isUpdate);
651
651
  await this.trackProgress();
@@ -653,7 +653,7 @@ class IModelExporter {
653
653
  return this.exportChildElements(elementId);
654
654
  }
655
655
  else {
656
- this.handler.onSkipElement(element.id);
656
+ await this.handler.onSkipElement(element.id);
657
657
  }
658
658
  }
659
659
  /** Export the child elements of the specified element from the source iModel.
@@ -728,7 +728,7 @@ class IModelExporter {
728
728
  }
729
729
  }
730
730
  // relationship has passed standard exclusion rules, now give handler a chance to accept/reject export
731
- if (this.handler.shouldExportRelationship(relationship)) {
731
+ if (await this.handler.shouldExportRelationship(relationship)) {
732
732
  await this.handler.onExportRelationship(relationship, isUpdate);
733
733
  await this.trackProgress();
734
734
  }