@itwin/imodel-transformer 2.0.0-dev.55 → 2.0.0-dev.57

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ElementAspectCleanup.d.ts","sourceRoot":"","sources":["../../src/ElementAspectCleanup.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,OAAO,EACP,aAAa,EAIb,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD;;GAEG;AACH,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAHhC,YACmB,SAAS,EAAE,QAAQ,EACnB,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,EACtE;IAEJ;;OAEG;IACU,MAAM,CACjB,gBAAgB,EAAE,WAAW,CAAC,UAAU,CAAC,EACzC,mCAAmC,EAAE,WAAW,CAAC,MAAM,CAAC,EACxD,iBAAiB,CAAC,EAAE,UAAU,EAC9B,QAAQ,SAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC,CA+Df;CACF"}
1
+ {"version":3,"file":"ElementAspectCleanup.d.ts","sourceRoot":"","sources":["../../src/ElementAspectCleanup.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,OAAO,EACP,aAAa,EAIb,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD;;GAEG;AACH,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAHhC,YACmB,SAAS,EAAE,QAAQ,EACnB,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,EACtE;IAEJ;;OAEG;IACU,MAAM,CACjB,gBAAgB,EAAE,WAAW,CAAC,UAAU,CAAC,EACzC,mCAAmC,EAAE,WAAW,CAAC,MAAM,CAAC,EACxD,iBAAiB,CAAC,EAAE,UAAU,EAC9B,QAAQ,SAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC,CA8Cf;CACF"}
@@ -31,7 +31,6 @@ class ElementAspectCleanup {
31
31
  }
32
32
  if (targetElementIds.size === 0)
33
33
  return;
34
- const ids = new Set(targetElementIds);
35
34
  const targetExcludedElementAspectClassFullNames = [
36
35
  ...excludedElementAspectClassFullNames,
37
36
  ].filter((classFullName) => this._targetDb.containsClass(classFullName));
@@ -39,33 +38,12 @@ class ElementAspectCleanup {
39
38
  core_backend_1.ElementUniqueAspect.classFullName,
40
39
  core_backend_1.ElementMultiAspect.classFullName,
41
40
  ]) {
41
+ const { ecsql, params } = replaceableAspectQuery(aspectClassFullName, targetElementIds, targetExcludedElementAspectClassFullNames, provenanceScopeId, pageSize);
42
42
  while (true) {
43
- const params = new core_common_1.QueryBinder().bindIdSet("elementIds", ids);
44
- let whereClause = "TRUE";
45
- if (provenanceScopeId !== undefined) {
46
- params.bindId("provenanceScopeId", provenanceScopeId);
47
- whereClause += ` AND ECInstanceId NOT IN (
48
- SELECT ECInstanceId FROM ${core_backend_1.ExternalSourceAspect.classFullName}
49
- WHERE Element.Id = :provenanceScopeId OR Scope.Id = :provenanceScopeId
50
- )`;
51
- }
52
- if (targetExcludedElementAspectClassFullNames.length > 0) {
53
- whereClause += ` AND ECInstanceId NOT IN (
54
- SELECT ECInstanceId FROM ${aspectClassFullName}
55
- WHERE ECClassId IS (${[
56
- ...targetExcludedElementAspectClassFullNames,
57
- ].join(", ")})
58
- )`;
59
- }
60
- const query = `SELECT aspect.ECInstanceId as id
61
- FROM ${aspectClassFullName} aspect
62
- INNER JOIN IdSet(:elementIds) ids ON ids.id = aspect.Element.Id
63
- WHERE ${whereClause}
64
- LIMIT ${pageSize}`;
65
43
  // Drain the full page before deleting: mutating a table while a reader is still
66
44
  // scanning it is unsafe.
67
45
  const candidateIds = [];
68
- for await (const row of this._targetDb.createQueryReader(query, params, { usePrimaryConn: true })) {
46
+ for await (const row of this._targetDb.createQueryReader(ecsql, params, { usePrimaryConn: true })) {
69
47
  candidateIds.push(row.id);
70
48
  }
71
49
  if (candidateIds.length === 0)
@@ -79,4 +57,31 @@ class ElementAspectCleanup {
79
57
  }
80
58
  }
81
59
  exports.ElementAspectCleanup = ElementAspectCleanup;
60
+ /** Builds the page query for aspects of `aspectClassFullName` owned by `elementIds`, skipping excluded classes and provenance aspects for `provenanceScopeId`. */
61
+ function replaceableAspectQuery(aspectClassFullName, elementIds, excludedClassFullNames, provenanceScopeId, pageSize) {
62
+ const params = new core_common_1.QueryBinder().bindIdSet("elementIds", elementIds);
63
+ const conditions = [];
64
+ if (excludedClassFullNames.length > 0) {
65
+ conditions.push(`aspect.ECClassId IS NOT (${excludedClassFullNames.join(", ")})`);
66
+ }
67
+ // ExternalSourceAspect is a multi-aspect, so provenance aspects are only found
68
+ // when querying ElementMultiAspect. For each candidate, check whether it is a
69
+ // provenance aspect rather than listing every provenance aspect on each page.
70
+ if (provenanceScopeId !== undefined &&
71
+ aspectClassFullName === core_backend_1.ElementMultiAspect.classFullName) {
72
+ params.bindId("provenanceScopeId", provenanceScopeId);
73
+ conditions.push(`NOT EXISTS (
74
+ SELECT 1 FROM ${core_backend_1.ExternalSourceAspect.classFullName} esa
75
+ WHERE esa.ECInstanceId = aspect.ECInstanceId
76
+ AND (esa.Element.Id = :provenanceScopeId OR esa.Scope.Id = :provenanceScopeId)
77
+ )`);
78
+ }
79
+ const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
80
+ const ecsql = `SELECT aspect.ECInstanceId as id
81
+ FROM ${aspectClassFullName} aspect
82
+ INNER JOIN IdSet(:elementIds) ids ON ids.id = aspect.Element.Id
83
+ ${whereClause}
84
+ LIMIT ${pageSize}`;
85
+ return { ecsql, params };
86
+ }
82
87
  //# sourceMappingURL=ElementAspectCleanup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElementAspectCleanup.js","sourceRoot":"","sources":["../../src/ElementAspectCleanup.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAO6B;AAE7B,oDAAiD;AAEjD;;GAEG;AACH;IAEqB,SAAS;IACT,QAAQ;IACR,aAAa;IAHhC,YACmB,SAAmB,EACnB,QAAiB,EACjB,aAAuD;yBAFvD,SAAS;wBACT,QAAQ;6BACR,aAAa;IAC7B,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,MAAM,CACjB,gBAAyC,EACzC,mCAAwD,EACxD,iBAA8B,EAC9B,QAAQ,GAAG,uBAAQ,CAAC,QAAQ,GAAG,CAAC;QAEhC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QACJ,CAAC;QACD,IAAI,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;QACJ,CAAC;QACD,IAAI,gBAAgB,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO;QAExC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAa,gBAAgB,CAAC,CAAC;QAClD,MAAM,yCAAyC,GAAG;YAChD,GAAG,mCAAmC;SACvC,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;QACzE,KAAK,MAAM,mBAAmB,IAAI;YAChC,kCAAmB,CAAC,aAAa;YACjC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ACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport {\n EditTxn,\n ElementAspect,\n ElementMultiAspect,\n ElementUniqueAspect,\n ExternalSourceAspect,\n IModelDb,\n} from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { QueryBinder } from \"@itwin/core-common\";\n\n/** Deletes replaceable ElementAspects for target owners while preserving excluded classes and transformer provenance aspects.\n * @internal\n */\nexport class ElementAspectCleanup {\n public constructor(\n private readonly _targetDb: IModelDb,\n private readonly _editTxn: EditTxn,\n private readonly _deleteAspect: (aspect: ElementAspect) => Promise<void>\n ) {}\n\n /** Deletes replaceable unique and multi-aspects owned by the supplied target elements.\n * Excluded classes and transformer provenance aspects for `provenanceScopeId` are preserved. Each deletion is performed through the configured callback and requires the target `EditTxn` to be active.\n */\n public async delete(\n targetElementIds: ReadonlySet<Id64String>,\n excludedElementAspectClassFullNames: ReadonlySet<string>,\n provenanceScopeId?: Id64String,\n pageSize = IModelDb.maxLimit - 1\n ): Promise<void> {\n if (!this._editTxn.isActive) {\n throw new Error(\n \"The target EditTxn must be active when deleting ElementAspects.\"\n );\n }\n if (pageSize <= 0 || !Number.isSafeInteger(pageSize)) {\n throw new Error(\n \"ElementAspect deletion pageSize must be a positive integer.\"\n );\n }\n if (targetElementIds.size === 0) return;\n\n const ids = new Set<Id64String>(targetElementIds);\n const targetExcludedElementAspectClassFullNames = [\n ...excludedElementAspectClassFullNames,\n ].filter((classFullName) => this._targetDb.containsClass(classFullName));\n for (const aspectClassFullName of [\n ElementUniqueAspect.classFullName,\n ElementMultiAspect.classFullName,\n ]) {\n while (true) {\n const params = new QueryBinder().bindIdSet(\"elementIds\", ids);\n let whereClause = \"TRUE\";\n if (provenanceScopeId !== undefined) {\n params.bindId(\"provenanceScopeId\", provenanceScopeId);\n whereClause += ` AND ECInstanceId NOT IN (\n SELECT ECInstanceId FROM ${ExternalSourceAspect.classFullName}\n WHERE Element.Id = :provenanceScopeId OR Scope.Id = :provenanceScopeId\n )`;\n }\n if (targetExcludedElementAspectClassFullNames.length > 0) {\n whereClause += ` AND ECInstanceId NOT IN (\n SELECT ECInstanceId FROM ${aspectClassFullName}\n WHERE ECClassId IS (${[\n ...targetExcludedElementAspectClassFullNames,\n ].join(\", \")})\n )`;\n }\n\n const query = `SELECT aspect.ECInstanceId as id\n FROM ${aspectClassFullName} aspect\n INNER JOIN IdSet(:elementIds) ids ON ids.id = aspect.Element.Id\n WHERE ${whereClause}\n LIMIT ${pageSize}`;\n // Drain the full page before deleting: mutating a table while a reader is still\n // scanning it is unsafe.\n const candidateIds: Id64String[] = [];\n for await (const row of this._targetDb.createQueryReader(\n query,\n params,\n { usePrimaryConn: true }\n )) {\n candidateIds.push(row.id);\n }\n if (candidateIds.length === 0) break;\n\n for (const aspectId of candidateIds) {\n const aspect = this._targetDb.elements.getAspect(aspectId);\n await this._deleteAspect(aspect);\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ElementAspectCleanup.js","sourceRoot":"","sources":["../../src/ElementAspectCleanup.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAO6B;AAE7B,oDAAiD;AAEjD;;GAEG;AACH;IAEqB,SAAS;IACT,QAAQ;IACR,aAAa;IAHhC,YACmB,SAAmB,EACnB,QAAiB,EACjB,aAAuD;yBAFvD,SAAS;wBACT,QAAQ;6BACR,aAAa;IAC7B,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,MAAM,CACjB,gBAAyC,EACzC,mCAAwD,EACxD,iBAA8B,EAC9B,QAAQ,GAAG,uBAAQ,CAAC,QAAQ,GAAG,CAAC;QAEhC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QACJ,CAA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ACH,CAAC;CACF;;AAED,kKAAkK;AAClK,SAAS,sBAAsB,CAC7B,mBAA2B,EAC3B,UAAmC,EACnC,sBAAyC,EACzC,iBAAyC,EACzC,QAAgB;IAEhB,MAAM,MAAM,GAAG,IAAI,yBAAW,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACrE,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,UAAU,CAAC,IAAI,CACb,4BAA4B,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjE,CAAC;IACJ,CAAC;IACD,+EAA+E;IAC/E,8EAA8E;IAC9E,8EAA8E;IAC9E,IACE,iBAAiB,KAAK,SAAS;QAC/B,mBAAmB,KAAK,iCAAkB,CAAC,aAAa,EACxD,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;QACtD,UAAU,CAAC,IAAI,CAAC;sBACE,mCAAoB,CAAC,aAAa;;;MAGlD,CAAC,CAAC;IACN,CAAC;IACD,MAAM,WAAW,GACf,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,MAAM,KAAK,GAAG;WACL,mBAAmB;;MAExB,WAAW;YACL,QAAQ,EAAE,CAAC;IACrB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport {\n EditTxn,\n ElementAspect,\n ElementMultiAspect,\n ElementUniqueAspect,\n ExternalSourceAspect,\n IModelDb,\n} from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { QueryBinder } from \"@itwin/core-common\";\n\n/** Deletes replaceable ElementAspects for target owners while preserving excluded classes and transformer provenance aspects.\n * @internal\n */\nexport class ElementAspectCleanup {\n public constructor(\n private readonly _targetDb: IModelDb,\n private readonly _editTxn: EditTxn,\n private readonly _deleteAspect: (aspect: ElementAspect) => Promise<void>\n ) {}\n\n /** Deletes replaceable unique and multi-aspects owned by the supplied target elements.\n * Excluded classes and transformer provenance aspects for `provenanceScopeId` are preserved. Each deletion is performed through the configured callback and requires the target `EditTxn` to be active.\n */\n public async delete(\n targetElementIds: ReadonlySet<Id64String>,\n excludedElementAspectClassFullNames: ReadonlySet<string>,\n provenanceScopeId?: Id64String,\n pageSize = IModelDb.maxLimit - 1\n ): Promise<void> {\n if (!this._editTxn.isActive) {\n throw new Error(\n \"The target EditTxn must be active when deleting ElementAspects.\"\n );\n }\n if (pageSize <= 0 || !Number.isSafeInteger(pageSize)) {\n throw new Error(\n \"ElementAspect deletion pageSize must be a positive integer.\"\n );\n }\n if (targetElementIds.size === 0) return;\n\n const targetExcludedElementAspectClassFullNames = [\n ...excludedElementAspectClassFullNames,\n ].filter((classFullName) => this._targetDb.containsClass(classFullName));\n for (const aspectClassFullName of [\n ElementUniqueAspect.classFullName,\n ElementMultiAspect.classFullName,\n ]) {\n const { ecsql, params } = replaceableAspectQuery(\n aspectClassFullName,\n targetElementIds,\n targetExcludedElementAspectClassFullNames,\n provenanceScopeId,\n pageSize\n );\n while (true) {\n // Drain the full page before deleting: mutating a table while a reader is still\n // scanning it is unsafe.\n const candidateIds: Id64String[] = [];\n for await (const row of this._targetDb.createQueryReader(\n ecsql,\n params,\n { usePrimaryConn: true }\n )) {\n candidateIds.push(row.id);\n }\n if (candidateIds.length === 0) break;\n\n for (const aspectId of candidateIds) {\n const aspect = this._targetDb.elements.getAspect(aspectId);\n await this._deleteAspect(aspect);\n }\n }\n }\n }\n}\n\n/** Builds the page query for aspects of `aspectClassFullName` owned by `elementIds`, skipping excluded classes and provenance aspects for `provenanceScopeId`. */\nfunction replaceableAspectQuery(\n aspectClassFullName: string,\n elementIds: ReadonlySet<Id64String>,\n excludedClassFullNames: readonly string[],\n provenanceScopeId: Id64String | undefined,\n pageSize: number\n): { ecsql: string; params: QueryBinder } {\n const params = new QueryBinder().bindIdSet(\"elementIds\", elementIds);\n const conditions: string[] = [];\n if (excludedClassFullNames.length > 0) {\n conditions.push(\n `aspect.ECClassId IS NOT (${excludedClassFullNames.join(\", \")})`\n );\n }\n // ExternalSourceAspect is a multi-aspect, so provenance aspects are only found\n // when querying ElementMultiAspect. For each candidate, check whether it is a\n // provenance aspect rather than listing every provenance aspect on each page.\n if (\n provenanceScopeId !== undefined &&\n aspectClassFullName === ElementMultiAspect.classFullName\n ) {\n params.bindId(\"provenanceScopeId\", provenanceScopeId);\n conditions.push(`NOT EXISTS (\n SELECT 1 FROM ${ExternalSourceAspect.classFullName} esa\n WHERE esa.ECInstanceId = aspect.ECInstanceId\n AND (esa.Element.Id = :provenanceScopeId OR esa.Scope.Id = :provenanceScopeId)\n )`);\n }\n const whereClause =\n conditions.length > 0 ? `WHERE ${conditions.join(\" AND \")}` : \"\";\n const ecsql = `SELECT aspect.ECInstanceId as id\n FROM ${aspectClassFullName} aspect\n INNER JOIN IdSet(:elementIds) ids ON ids.id = aspect.Element.Id\n ${whereClause}\n LIMIT ${pageSize}`;\n return { ecsql, params };\n}\n"]}
@@ -26,6 +26,10 @@ export * from "./BranchProvenanceInitializer";
26
26
  * @docs-group-description Logging
27
27
  * Logger categories used by this package.
28
28
  */
29
+ /**
30
+ * @docs-group-description ChangedElementForest
31
+ * Internal indexing of changed elements and their ancestors for incremental export traversal.
32
+ */
29
33
  /**
30
34
  * @docs-group-description ElementAspectExportCoordinator
31
35
  * Internal coordination for scoped, owner-batched ElementAspect export.
@@ -1 +1 @@
1
- {"version":3,"file":"imodel-transformer.d.ts","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":"AAIA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAmD9C;;;;;;GAMG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
1
+ {"version":3,"file":"imodel-transformer.d.ts","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":"AAIA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAmD9C;;;;;;GAMG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
@@ -98,6 +98,10 @@ if (process.env[noStrictDepCheckEnvVar] !== "1" &&
98
98
  * @docs-group-description Logging
99
99
  * Logger categories used by this package.
100
100
  */
101
+ /**
102
+ * @docs-group-description ChangedElementForest
103
+ * Internal indexing of changed elements and their ancestors for incremental export traversal.
104
+ */
101
105
  /**
102
106
  * @docs-group-description ElementAspectExportCoordinator
103
107
  * Internal coordination for scoped, owner-batched ElementAspect export.
@@ -1 +1 @@
1
- {"version":3,"file":"imodel-transformer.js","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,8DAA4C;AAC5C,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,2DAAyC;AACzC,+EAA6D;AAC7D,2DAAyC;AACzC,gEAA8C;AAE9C,MAAY,MAAM,mCAAe;AACjC,sDAAiD;AACjD,mEAAsF;AACtF,qEAGkC;AAClC,6EAA0E;AAE1E,MAAM,EACJ,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,EACb,gBAAgB,GACjB,GAAG,uDAA0B,CAAC;AAE/B,MAAM,2BAA2B,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;AAE5E,MAAM,sBAAsB,GAAG,iCAAiC,CAAC;AAEjE,4CAA4C;AAC5C,IAAI,MAAM,CAAC,UAAU,CAAC,sBAAuB,CAAC,EAAE,CAAC;IAC/C,sCAAsC;IACtC,OAAO,CAAC,IAAI,CACV,kCAAkC,sBAAuB,KAAK;QAC5D,uFAAuF;QACvF,+FAA+F,CAClG,CAAC;AACJ,CAAC;AAED,IACE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,GAAG;IAC3C,CAAC,MAAM,CAAC,SAAS,CAAC,sBAAuB,EAAE,2BAA2B,EAAE;QACtE,iBAAiB,EAAE,IAAI;KACxB,CAAC,EACF,CAAC;IACD,MAAM,SAAS,GACb,GAAG,OAAO,IAAI,UAAU,sCAAsC,2BAA2B,IAAI;QAC7F,0BAA0B,sBAAuB,uDAAuD;QACxG,iFAAiF,sBAAsB,yBAAyB,CAAC;IAEnI,yBAAU,CAAC,UAAU,CAAC;QACpB,YAAY,EAAE;YACZ,KAAK,EAAE,oDAA2B;YAClC,GAAG,EAAE,+CAAsB,CAAC,yBAAyB;SACtD;QACD,OAAO,EAAE,SAAS;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nexport * from \"./TransformerLoggerCategory\";\nexport * from \"./IModelExporter\";\nexport * from \"./IModelImporter\";\nexport * from \"./IModelTransformer\";\nexport * from \"./IModelTransformContext\";\nexport * from \"./schema-processing/SchemaProcessingStrategy\";\nexport * from \"./IModelTransformerError\";\nexport * from \"./BranchProvenanceInitializer\";\n\nimport * as semver from \"semver\";\nimport { ITwinError } from \"@itwin/core-bentley\";\nimport { version as iTwinCoreBackendVersion } from \"@itwin/core-backend/package.json\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"./IModelTransformerError\";\nimport { transformerPackageMetadata } from \"./TransformerPackageMetadata\";\n\nconst {\n version: ourVersion,\n name: ourName,\n peerDependencies,\n} = transformerPackageMetadata;\n\nconst ourITwinCoreBackendDepRange = peerDependencies[\"@itwin/core-backend\"];\n\nconst noStrictDepCheckEnvVar = \"TRANSFORMER_NO_STRICT_DEP_CHECK\";\n\n// warn if using a prerelease or dev version\nif (semver.prerelease(iTwinCoreBackendVersion)) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: dev version detected (${iTwinCoreBackendVersion}). ` +\n \"This version is most likely fine, but it may introduce new behavior that could cause \" +\n \"unexpected issues or changes in the transformer's functionality. Please proceed with caution.\"\n );\n}\n\nif (\n process.env[noStrictDepCheckEnvVar] !== \"1\" &&\n !semver.satisfies(iTwinCoreBackendVersion, ourITwinCoreBackendDepRange, {\n includePrerelease: true,\n })\n) {\n const errHeader =\n `${ourName}@${ourVersion} only supports @itwin/core-backend@${ourITwinCoreBackendDepRange}, ` +\n `but @itwin/core-backend${iTwinCoreBackendVersion} was resolved when looking for the peer dependency.\\n` +\n `If you know exactly what you are doing, you can disable this check by setting ${noStrictDepCheckEnvVar}=1 in the environment\\n`;\n\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.DependencyVersionMismatch,\n },\n message: errHeader,\n });\n}\n\n/** @docs-package-description\n * The @itwin/imodel-transformer package contains classes that [backend code]($docs/learning/backend/index.md) can use to\n * traverse iModels, as well as *transform* an iModel into another existing or empty one, by exporting elements from one during\n * traversal and importing them into another.\n *\n * You can read further in [iModelTransformation and Data Exchange]($docs/learning/transformer/index.md) here.\n */\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n/**\n * @docs-group-description ElementAspectExportCoordinator\n * Internal coordination for scoped, owner-batched ElementAspect export.\n */\n/**\n * @docs-group-description ElementAspectExportProcessor\n * Internal source queries, filtering, and export callbacks for ElementAspects owned by accepted elements.\n */\n/**\n * @docs-group-description ChangedElementForest\n * Internal index of changed elements and their ancestors for incremental traversal.\n */\n/**\n * @docs-group-description IModelTransformerError\n * Stable identifiers for errors originating from this package.\n */\n/**\n * @docs-group-description TransformerPackageMetadata\n * Internal metadata describing this package and its peer dependencies.\n */\n"]}
1
+ {"version":3,"file":"imodel-transformer.js","sourceRoot":"","sources":["../../src/imodel-transformer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,8DAA4C;AAC5C,mDAAiC;AACjC,mDAAiC;AACjC,sDAAoC;AACpC,2DAAyC;AACzC,+EAA6D;AAC7D,2DAAyC;AACzC,gEAA8C;AAE9C,MAAY,MAAM,mCAAe;AACjC,sDAAiD;AACjD,mEAAsF;AACtF,qEAGkC;AAClC,6EAA0E;AAE1E,MAAM,EACJ,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,EACb,gBAAgB,GACjB,GAAG,uDAA0B,CAAC;AAE/B,MAAM,2BAA2B,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;AAE5E,MAAM,sBAAsB,GAAG,iCAAiC,CAAC;AAEjE,4CAA4C;AAC5C,IAAI,MAAM,CAAC,UAAU,CAAC,sBAAuB,CAAC,EAAE,CAAC;IAC/C,sCAAsC;IACtC,OAAO,CAAC,IAAI,CACV,kCAAkC,sBAAuB,KAAK;QAC5D,uFAAuF;QACvF,+FAA+F,CAClG,CAAC;AACJ,CAAC;AAED,IACE,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,KAAK,GAAG;IAC3C,CAAC,MAAM,CAAC,SAAS,CAAC,sBAAuB,EAAE,2BAA2B,EAAE;QACtE,iBAAiB,EAAE,IAAI;KACxB,CAAC,EACF,CAAC;IACD,MAAM,SAAS,GACb,GAAG,OAAO,IAAI,UAAU,sCAAsC,2BAA2B,IAAI;QAC7F,0BAA0B,sBAAuB,uDAAuD;QACxG,iFAAiF,sBAAsB,yBAAyB,CAAC;IAEnI,yBAAU,CAAC,UAAU,CAAC;QACpB,YAAY,EAAE;YACZ,KAAK,EAAE,oDAA2B;YAClC,GAAG,EAAE,+CAAsB,CAAC,yBAAyB;SACtD;QACD,OAAO,EAAE,SAAS;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nexport * from \"./TransformerLoggerCategory\";\nexport * from \"./IModelExporter\";\nexport * from \"./IModelImporter\";\nexport * from \"./IModelTransformer\";\nexport * from \"./IModelTransformContext\";\nexport * from \"./schema-processing/SchemaProcessingStrategy\";\nexport * from \"./IModelTransformerError\";\nexport * from \"./BranchProvenanceInitializer\";\n\nimport * as semver from \"semver\";\nimport { ITwinError } from \"@itwin/core-bentley\";\nimport { version as iTwinCoreBackendVersion } from \"@itwin/core-backend/package.json\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"./IModelTransformerError\";\nimport { transformerPackageMetadata } from \"./TransformerPackageMetadata\";\n\nconst {\n version: ourVersion,\n name: ourName,\n peerDependencies,\n} = transformerPackageMetadata;\n\nconst ourITwinCoreBackendDepRange = peerDependencies[\"@itwin/core-backend\"];\n\nconst noStrictDepCheckEnvVar = \"TRANSFORMER_NO_STRICT_DEP_CHECK\";\n\n// warn if using a prerelease or dev version\nif (semver.prerelease(iTwinCoreBackendVersion)) {\n // eslint-disable-next-line no-console\n console.warn(\n `Warning: dev version detected (${iTwinCoreBackendVersion}). ` +\n \"This version is most likely fine, but it may introduce new behavior that could cause \" +\n \"unexpected issues or changes in the transformer's functionality. Please proceed with caution.\"\n );\n}\n\nif (\n process.env[noStrictDepCheckEnvVar] !== \"1\" &&\n !semver.satisfies(iTwinCoreBackendVersion, ourITwinCoreBackendDepRange, {\n includePrerelease: true,\n })\n) {\n const errHeader =\n `${ourName}@${ourVersion} only supports @itwin/core-backend@${ourITwinCoreBackendDepRange}, ` +\n `but @itwin/core-backend${iTwinCoreBackendVersion} was resolved when looking for the peer dependency.\\n` +\n `If you know exactly what you are doing, you can disable this check by setting ${noStrictDepCheckEnvVar}=1 in the environment\\n`;\n\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.DependencyVersionMismatch,\n },\n message: errHeader,\n });\n}\n\n/** @docs-package-description\n * The @itwin/imodel-transformer package contains classes that [backend code]($docs/learning/backend/index.md) can use to\n * traverse iModels, as well as *transform* an iModel into another existing or empty one, by exporting elements from one during\n * traversal and importing them into another.\n *\n * You can read further in [iModelTransformation and Data Exchange]($docs/learning/transformer/index.md) here.\n */\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n/**\n * @docs-group-description ChangedElementForest\n * Internal indexing of changed elements and their ancestors for incremental export traversal.\n */\n/**\n * @docs-group-description ElementAspectExportCoordinator\n * Internal coordination for scoped, owner-batched ElementAspect export.\n */\n/**\n * @docs-group-description ElementAspectExportProcessor\n * Internal source queries, filtering, and export callbacks for ElementAspects owned by accepted elements.\n */\n/**\n * @docs-group-description ChangedElementForest\n * Internal index of changed elements and their ancestors for incremental traversal.\n */\n/**\n * @docs-group-description IModelTransformerError\n * Stable identifiers for errors originating from this package.\n */\n/**\n * @docs-group-description TransformerPackageMetadata\n * Internal metadata describing this package and its peer dependencies.\n */\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/imodel-transformer",
3
- "version": "2.0.0-dev.55",
3
+ "version": "2.0.0-dev.57",
4
4
  "description": "API for exporting an iModel's parts and also importing them into another iModel",
5
5
  "main": "lib/cjs/imodel-transformer.js",
6
6
  "typings": "lib/cjs/imodel-transformer.d.ts",