@itwin/imodel-transformer 0.4.4-dev.1 → 0.4.18-dev.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +1 -9
  2. package/lib/cjs/Algo.d.ts +7 -0
  3. package/lib/cjs/Algo.d.ts.map +1 -0
  4. package/lib/cjs/Algo.js +65 -0
  5. package/lib/cjs/Algo.js.map +1 -0
  6. package/lib/cjs/BigMap.d.ts +1 -6
  7. package/lib/cjs/BigMap.d.ts.map +1 -1
  8. package/lib/cjs/BigMap.js +3 -29
  9. package/lib/cjs/BigMap.js.map +1 -1
  10. package/lib/cjs/BranchProvenanceInitializer.d.ts +10 -3
  11. package/lib/cjs/BranchProvenanceInitializer.d.ts.map +1 -1
  12. package/lib/cjs/BranchProvenanceInitializer.js +101 -10
  13. package/lib/cjs/BranchProvenanceInitializer.js.map +1 -1
  14. package/lib/cjs/DetachedExportElementAspectsStrategy.d.ts.map +1 -1
  15. package/lib/cjs/DetachedExportElementAspectsStrategy.js +12 -5
  16. package/lib/cjs/DetachedExportElementAspectsStrategy.js.map +1 -1
  17. package/lib/cjs/ECReferenceTypesCache.d.ts.map +1 -1
  18. package/lib/cjs/ECReferenceTypesCache.js +32 -18
  19. package/lib/cjs/ECReferenceTypesCache.js.map +1 -1
  20. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.d.ts +1 -1
  21. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.d.ts.map +1 -1
  22. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.js +7 -5
  23. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.js.map +1 -1
  24. package/lib/cjs/ElementCascadingDeleter.d.ts +3 -3
  25. package/lib/cjs/ElementCascadingDeleter.d.ts.map +1 -1
  26. package/lib/cjs/ElementCascadingDeleter.js +9 -7
  27. package/lib/cjs/ElementCascadingDeleter.js.map +1 -1
  28. package/lib/cjs/EntityMap.d.ts.map +1 -1
  29. package/lib/cjs/EntityMap.js.map +1 -1
  30. package/lib/cjs/EntityUnifier.d.ts +5 -0
  31. package/lib/cjs/EntityUnifier.d.ts.map +1 -1
  32. package/lib/cjs/EntityUnifier.js +22 -35
  33. package/lib/cjs/EntityUnifier.js.map +1 -1
  34. package/lib/cjs/ExportElementAspectsStrategy.d.ts.map +1 -1
  35. package/lib/cjs/ExportElementAspectsStrategy.js +5 -4
  36. package/lib/cjs/ExportElementAspectsStrategy.js.map +1 -1
  37. package/lib/cjs/ExportElementAspectsWithElementsStrategy.d.ts.map +1 -1
  38. package/lib/cjs/ExportElementAspectsWithElementsStrategy.js +9 -5
  39. package/lib/cjs/ExportElementAspectsWithElementsStrategy.js.map +1 -1
  40. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  41. package/lib/cjs/IModelCloneContext.js +23 -14
  42. package/lib/cjs/IModelCloneContext.js.map +1 -1
  43. package/lib/cjs/IModelExporter.d.ts +87 -21
  44. package/lib/cjs/IModelExporter.d.ts.map +1 -1
  45. package/lib/cjs/IModelExporter.js +279 -114
  46. package/lib/cjs/IModelExporter.js.map +1 -1
  47. package/lib/cjs/IModelImporter.d.ts +29 -21
  48. package/lib/cjs/IModelImporter.d.ts.map +1 -1
  49. package/lib/cjs/IModelImporter.js +115 -62
  50. package/lib/cjs/IModelImporter.js.map +1 -1
  51. package/lib/cjs/IModelTransformer.d.ts +285 -48
  52. package/lib/cjs/IModelTransformer.d.ts.map +1 -1
  53. package/lib/cjs/IModelTransformer.js +1273 -337
  54. package/lib/cjs/IModelTransformer.js.map +1 -1
  55. package/lib/cjs/PendingReferenceMap.d.ts.map +1 -1
  56. package/lib/cjs/PendingReferenceMap.js +12 -6
  57. package/lib/cjs/PendingReferenceMap.js.map +1 -1
  58. package/lib/cjs/TransformerLoggerCategory.d.ts +2 -2
  59. package/lib/cjs/TransformerLoggerCategory.d.ts.map +1 -1
  60. package/lib/cjs/TransformerLoggerCategory.js +5 -5
  61. package/lib/cjs/TransformerLoggerCategory.js.map +1 -1
  62. package/lib/cjs/transformer.d.ts.map +1 -1
  63. package/lib/cjs/transformer.js +14 -10
  64. package/lib/cjs/transformer.js.map +1 -1
  65. package/package.json +20 -17
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  /** @packageDocumentation
7
7
  * @module iModels
8
8
  */
@@ -16,7 +16,9 @@ const assert = require("assert");
16
16
  * @internal
17
17
  */
18
18
  class SchemaNotInCacheErr extends Error {
19
- constructor() { super("Schema was not in cache, initialize that schema"); }
19
+ constructor() {
20
+ super("Schema was not in cache, initialize that schema");
21
+ }
20
22
  }
21
23
  exports.SchemaNotInCacheErr = SchemaNotInCacheErr;
22
24
  /**
@@ -57,7 +59,8 @@ class ECReferenceTypesCache {
57
59
  }
58
60
  async getAbstractConstraintClass(constraint) {
59
61
  // constraint classes must share a base so we can get the root from any of them, just use the first
60
- const ecclass = await (constraint.constraintClasses?.[0] || constraint.abstractConstraint);
62
+ const ecclass = await (constraint.constraintClasses?.[0] ||
63
+ constraint.abstractConstraint);
61
64
  assert(ecclass !== undefined, "At least one constraint class or an abstract constraint must have been defined, the constraint is not valid");
62
65
  return ecclass;
63
66
  }
@@ -108,8 +111,14 @@ class ECReferenceTypesCache {
108
111
  const relInfo = await this.relInfoFromRelClass(relClass);
109
112
  if (relInfo === undefined)
110
113
  continue;
111
- const navPropRefType = prop.direction === ecschema_metadata_1.StrengthDirection.Forward ? relInfo.target : relInfo.source;
112
- this._propQualifierToRefType.set([schema.name.toLowerCase(), ecclass.name.toLowerCase(), prop.name.toLowerCase()], navPropRefType);
114
+ const navPropRefType = prop.direction === ecschema_metadata_1.StrengthDirection.Forward
115
+ ? relInfo.target
116
+ : relInfo.source;
117
+ this._propQualifierToRefType.set([
118
+ schema.name.toLowerCase(),
119
+ ecclass.name.toLowerCase(),
120
+ prop.name.toLowerCase(),
121
+ ], navPropRefType);
113
122
  }
114
123
  if (ecclass instanceof ecschema_metadata_1.RelationshipClass) {
115
124
  const relInfo = await this.relInfoFromRelClass(ecclass);
@@ -122,13 +131,18 @@ class ECReferenceTypesCache {
122
131
  async relInfoFromRelClass(ecclass) {
123
132
  assert(ecclass.source.constraintClasses !== undefined);
124
133
  assert(ecclass.target.constraintClasses !== undefined);
125
- const [[sourceClass, sourceRootBisClass], [targetClass, targetRootBisClass]] = await Promise.all([
126
- this.getAbstractConstraintClass(ecclass.source)
127
- .then(async (constraintClass) => [constraintClass, await this.getRootBisClass(constraintClass)]),
128
- this.getAbstractConstraintClass(ecclass.target)
129
- .then(async (constraintClass) => [constraintClass, await this.getRootBisClass(constraintClass)]),
134
+ const [[sourceClass, sourceRootBisClass], [targetClass, targetRootBisClass],] = await Promise.all([
135
+ this.getAbstractConstraintClass(ecclass.source).then(async (constraintClass) => [
136
+ constraintClass,
137
+ await this.getRootBisClass(constraintClass),
138
+ ]),
139
+ this.getAbstractConstraintClass(ecclass.target).then(async (constraintClass) => [
140
+ constraintClass,
141
+ await this.getRootBisClass(constraintClass),
142
+ ]),
130
143
  ]);
131
- if (sourceRootBisClass.name === "CodeSpec" || targetRootBisClass.name === "CodeSpec")
144
+ if (sourceRootBisClass.name === "CodeSpec" ||
145
+ targetRootBisClass.name === "CodeSpec")
132
146
  return undefined;
133
147
  const sourceType = ECReferenceTypesCache.bisRootClassToRefType[sourceRootBisClass.name];
134
148
  const targetType = ECReferenceTypesCache.bisRootClassToRefType[targetRootBisClass.name];
@@ -166,11 +180,11 @@ class ECReferenceTypesCache {
166
180
  exports.ECReferenceTypesCache = ECReferenceTypesCache;
167
181
  ECReferenceTypesCache.bisRootClassToRefType = {
168
182
  /* eslint-disable quote-props, @typescript-eslint/naming-convention */
169
- "Element": core_common_1.ConcreteEntityTypes.Element,
170
- "Model": core_common_1.ConcreteEntityTypes.Model,
171
- "ElementAspect": core_common_1.ConcreteEntityTypes.ElementAspect,
172
- "ElementRefersToElements": core_common_1.ConcreteEntityTypes.Relationship,
173
- "ElementDrivesElement": core_common_1.ConcreteEntityTypes.Relationship,
183
+ Element: core_common_1.ConcreteEntityTypes.Element,
184
+ Model: core_common_1.ConcreteEntityTypes.Model,
185
+ ElementAspect: core_common_1.ConcreteEntityTypes.ElementAspect,
186
+ ElementRefersToElements: core_common_1.ConcreteEntityTypes.Relationship,
187
+ ElementDrivesElement: core_common_1.ConcreteEntityTypes.Relationship,
174
188
  // code spec is technically a potential root class but it is ignored currently
175
189
  // see [ConcreteEntityTypes]($common)
176
190
  /* eslint-enable quote-props, @typescript-eslint/naming-convention */
@@ -1 +1 @@
1
- {"version":3,"file":"ECReferenceTypesCache.js","sourceRoot":"","sources":["../../src/ECReferenceTypesCache.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA8D;AAC9D,oDAAmF;AACnF,gEAAyJ;AACzJ,iCAAiC;AAGjC;;GAEG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,gBAAuB,KAAK,CAAC,iDAAiD,CAAC,CAAC,CAAC,CAAC;CACnF;AAFD,kDAEC;AAED;;;;;;;GAOG;AACH,MAAa,qBAAqB;IAAlC;QACE,uGAAuG;QAC/F,4BAAuB,GAAG,IAAI,4BAAa,EAAiD,CAAC;QAC7F,+BAA0B,GAAG,IAAI,4BAAa,EAAiC,CAAC;QAChF,mBAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;IAyJxD,CAAC;IA3IS,KAAK,CAAC,eAAe,CAAC,OAAgB;QAC5C,IAAI,oBAAoB,GAAY,OAAO,CAAC;QAC5C,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,EAAE,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mB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC;YACtC,UAAU,CAAC,WAAW,EAAE;YACxB,SAAS,CAAC,WAAW,EAAE;YACvB,QAAQ,CAAC,WAAW,EAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAEM,sBAAsB,CAAC,UAAkB,EAAE,SAAiB;QACjE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;YACtC,MAAM,IAAI,mBAAmB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC;YACzC,UAAU,CAAC,WAAW,EAAE;YACxB,SAAS,CAAC,WAAW,EAAE;SACxB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;;AA5JH,sDA6JC;AAvJgB,2CAAqB,GAAoD;IACtF,sEAAsE;IACtE,SAAS,EAAE,iCAAmB,CAAC,OAAO;IACtC,OAAO,EAAE,iCAAmB,CAAC,KAAK;IAClC,eAAe,EAAE,iCAAmB,CAAC,aAAa;IAClD,yBAAyB,EAAE,iCAAmB,CAAC,YAAY;IAC3D,sBAAsB,EAAE,iCAAmB,CAAC,YAAY;IACxD,8EAA8E;IAC9E,qCAAqC;IACrC,qEAAqE;CACtE,AAVmC,CAUlC","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/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbResult, TupleKeyedMap } from \"@itwin/core-bentley\";\nimport { ConcreteEntityTypes, IModelError, RelTypeInfo } from \"@itwin/core-common\";\nimport { ECClass, Mixin, RelationshipClass, RelationshipConstraint, Schema, SchemaKey, SchemaLoader, StrengthDirection } from \"@itwin/ecschema-metadata\";\nimport * as assert from \"assert\";\nimport { IModelDb } from \"@itwin/core-backend\";\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @internal\n */\nexport class SchemaNotInCacheErr extends Error {\n public constructor() { super(\"Schema was not in cache, initialize that schema\"); }\n}\n\n/**\n * A cache of the entity types referenced by navprops in ecchemas, as well as the source and target entity types of\n * The transformer needs the referenced type to determine how to resolve references.\n *\n * Using multiple of these usually performs redundant computation, for static schemas at least. A possible future optimization\n * would be to seed the computation from a global cache of non-dynamic schemas, but dynamic schemas can collide willy-nilly\n * @internal\n */\nexport class ECReferenceTypesCache {\n /** nesting based tuple map keyed by qualified property path tuple [schemaName, className, propName] */\n private _propQualifierToRefType = new TupleKeyedMap<[string, string, string], ConcreteEntityTypes>();\n private _relClassNameEndToRefTypes = new TupleKeyedMap<[string, string], RelTypeInfo>();\n private _initedSchemas = new Map<string, SchemaKey>();\n\n private static bisRootClassToRefType: Record<string, ConcreteEntityTypes | undefined> = {\n /* eslint-disable quote-props, @typescript-eslint/naming-convention */\n \"Element\": ConcreteEntityTypes.Element,\n \"Model\": ConcreteEntityTypes.Model,\n \"ElementAspect\": ConcreteEntityTypes.ElementAspect,\n \"ElementRefersToElements\": ConcreteEntityTypes.Relationship,\n \"ElementDrivesElement\": ConcreteEntityTypes.Relationship,\n // code spec is technically a potential root class but it is ignored currently\n // see [ConcreteEntityTypes]($common)\n /* eslint-enable quote-props, @typescript-eslint/naming-convention */\n };\n\n private async getRootBisClass(ecclass: ECClass) {\n let bisRootForConstraint: ECClass = ecclass;\n await ecclass.traverseBaseClasses((baseClass) => {\n // The depth first traversal will descend all the way to the root class before making any lateral traversal\n // of mixin hierarchies, (or if the constraint is a mixin, it will traverse to the root of the mixin hierarchy)\n // Once we see that we've moved laterally, we can terminate early\n const isFirstTest = bisRootForConstraint === ecclass;\n const traversalSwitchedRootPath = baseClass.name !== bisRootForConstraint.baseClass?.name;\n const stillTraversingRootPath = isFirstTest || !traversalSwitchedRootPath;\n if (!stillTraversingRootPath)\n return true; // stop traversal early\n bisRootForConstraint = baseClass;\n return false;\n });\n // if the root class of the constraint was a mixin, use its AppliesToEntityClass\n if (bisRootForConstraint instanceof Mixin) {\n assert(bisRootForConstraint.appliesTo !== undefined, \"The referenced AppliesToEntityClass could not be found, how did it pass schema validation?\");\n bisRootForConstraint = await this.getRootBisClass(await bisRootForConstraint.appliesTo);\n }\n return bisRootForConstraint;\n }\n\n private async getAbstractConstraintClass(constraint: RelationshipConstraint): Promise<ECClass> {\n // constraint classes must share a base so we can get the root from any of them, just use the first\n const ecclass = await (constraint.constraintClasses?.[0] || constraint.abstractConstraint);\n assert(ecclass !== undefined, \"At least one constraint class or an abstract constraint must have been defined, the constraint is not valid\");\n return ecclass;\n }\n\n /** initialize from an imodel with metadata */\n public async initAllSchemasInIModel(imodel: IModelDb): Promise<void> {\n const schemaLoader = new SchemaLoader((name: string) => imodel.getSchemaProps(name));\n await imodel.withPreparedStatement(`\n WITH RECURSIVE refs(SchemaId) AS (\n SELECT ECInstanceId FROM ECDbMeta.ECSchemaDef WHERE Name='BisCore'\n UNION ALL\n SELECT sr.SourceECInstanceId\n FROM ECDbMeta.SchemaHasSchemaReferences sr\n JOIN refs ON sr.TargetECInstanceId = refs.SchemaId\n )\n SELECT s.Name\n FROM refs\n JOIN ECDbMeta.ECSchemaDef s ON refs.SchemaId=s.ECInstanceId\n -- ensure schema dependency order\n ORDER BY ECInstanceId\n `, async (stmt) => {\n let status: DbResult;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const schemaName = stmt.getValue(0).getString();\n const schema = schemaLoader.getSchema(schemaName);\n await this.considerInitSchema(schema);\n }\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n });\n }\n\n private async considerInitSchema(schema: Schema): Promise<void> {\n if (this._initedSchemas.has(schema.name)) {\n const cachedSchemaKey = this._initedSchemas.get(schema.name);\n assert(cachedSchemaKey !== undefined);\n const incomingSchemaIsEqualOrOlder = schema.schemaKey.compareByVersion(cachedSchemaKey) <= 0;\n if (incomingSchemaIsEqualOrOlder) {\n return;\n }\n }\n return this.initSchema(schema);\n }\n\n private async initSchema(schema: Schema): Promise<void> {\n for (const ecclass of schema.getClasses()) {\n for (const prop of await ecclass.getProperties()) {\n if (!prop.isNavigation())\n continue;\n const relClass = await prop.relationshipClass;\n const relInfo = await this.relInfoFromRelClass(relClass);\n if (relInfo === undefined)\n continue;\n const navPropRefType = prop.direction === StrengthDirection.Forward ? relInfo.target : relInfo.source;\n this._propQualifierToRefType.set([schema.name.toLowerCase(), ecclass.name.toLowerCase(), prop.name.toLowerCase()], navPropRefType);\n }\n\n if (ecclass instanceof RelationshipClass) {\n const relInfo = await this.relInfoFromRelClass(ecclass);\n if (relInfo)\n this._relClassNameEndToRefTypes.set([schema.name.toLowerCase(), ecclass.name.toLowerCase()], relInfo);\n }\n }\n\n this._initedSchemas.set(schema.name, schema.schemaKey);\n }\n\n private async relInfoFromRelClass(ecclass: RelationshipClass): Promise<RelTypeInfo | undefined> {\n assert(ecclass.source.constraintClasses !== undefined);\n assert(ecclass.target.constraintClasses !== undefined);\n const [[sourceClass, sourceRootBisClass], [targetClass, targetRootBisClass]] = await Promise.all([\n this.getAbstractConstraintClass(ecclass.source)\n .then(async (constraintClass) => [constraintClass, await this.getRootBisClass(constraintClass)]),\n this.getAbstractConstraintClass(ecclass.target)\n .then(async (constraintClass) => [constraintClass, await this.getRootBisClass(constraintClass)]),\n ]);\n\n if (sourceRootBisClass.name === \"CodeSpec\" || targetRootBisClass.name === \"CodeSpec\")\n return undefined;\n const sourceType = ECReferenceTypesCache.bisRootClassToRefType[sourceRootBisClass.name];\n const targetType = ECReferenceTypesCache.bisRootClassToRefType[targetRootBisClass.name];\n const makeAssertMsg = (root: ECClass, cls: ECClass) => [\n `An unknown root class '${root.fullName}' was encountered while populating`,\n `the nav prop reference type cache for ${cls.fullName}.`,\n \"This is a bug.\",\n ].join(\"\\n\");\n assert(sourceType !== undefined, makeAssertMsg(sourceRootBisClass, sourceClass));\n assert(targetType !== undefined, makeAssertMsg(targetRootBisClass, targetClass));\n return { source: sourceType, target: targetType };\n }\n\n public getNavPropRefType(schemaName: string, className: string, propName: string): undefined | ConcreteEntityTypes {\n if (!this._initedSchemas.has(schemaName))\n throw new SchemaNotInCacheErr();\n return this._propQualifierToRefType.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n propName.toLowerCase(),\n ]);\n }\n\n public getRelationshipEndType(schemaName: string, className: string): undefined | RelTypeInfo {\n if (!this._initedSchemas.has(schemaName))\n throw new SchemaNotInCacheErr();\n return this._relClassNameEndToRefTypes.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n ]);\n }\n\n public clear() {\n this._initedSchemas.clear();\n this._propQualifierToRefType.clear();\n }\n}\n"]}
1
+ {"version":3,"file":"ECReferenceTypesCache.js","sourceRoot":"","sources":["../../src/ECReferenceTypesCache.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA8D;AAC9D,oDAI4B;AAC5B,gEASkC;AAClC,iCAAiC;AAGjC;;GAEG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAC5C;QACE,KAAK,CAAC,iDAAiD,CAAC,CAAC;IAC3D,CAAC;CACF;AAJD,kDAIC;AAED;;;;;;;GAOG;AACH,MAAa,qBAAqB;IAAlC;QACE,uGAAuG;QAC/F,4BAAuB,GAAG,IAAI,4BAAa,EAGhD,CAAC;QACI,+BAA0B,GAAG,IAAI,4BAAa,EAGnD,CAAC;QACI,mBAAc,GAAG,IAAI,GAAG,EAAqB,CAAC;IAsNxD,CAAC;IArMS,KAAK,CAAC,eAAe,CAAC,OAAgB;QAC5C,IAAI,oBAAoB,GAAY,OAAO,CAAC;QAC5C,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,EAAE,EAAE;YAC9C,2GAA2G;YAC3G,+GAA+G;YAC/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CAAC,GAAG,CAAC;YACtC,UAAU,CAAC,WAAW,EAAE;YACxB,SAAS,CAAC,WAAW,EAAE;YACvB,QAAQ,CAAC,WAAW,EAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAEM,sBAAsB,CAC3B,UAAkB,EAClB,SAAiB;QAEjB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,MAAM,IAAI,mBAAmB,EAAE,CAAC;QAC1E,OAAO,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC;YACzC,UAAU,CAAC,WAAW,EAAE;YACxB,SAAS,CAAC,WAAW,EAAE;SACxB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;;AA/NH,sDAgOC;AApNgB,2CAAqB,GAGhC;IACF,sEAAsE;IACtE,OAAO,EAAE,iCAAmB,CAAC,OAAO;IACpC,KAAK,EAAE,iCAAmB,CAAC,KAAK;IAChC,aAAa,EAAE,iCAAmB,CAAC,aAAa;IAChD,uBAAuB,EAAE,iCAAmB,CAAC,YAAY;IACzD,oBAAoB,EAAE,iCAAmB,CAAC,YAAY;IACtD,8EAA8E;IAC9E,qCAAqC;IACrC,qEAAqE;CACtE,AAbmC,CAalC","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/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbResult, TupleKeyedMap } from \"@itwin/core-bentley\";\nimport {\n ConcreteEntityTypes,\n IModelError,\n RelTypeInfo,\n} from \"@itwin/core-common\";\nimport {\n ECClass,\n Mixin,\n RelationshipClass,\n RelationshipConstraint,\n Schema,\n SchemaKey,\n SchemaLoader,\n StrengthDirection,\n} from \"@itwin/ecschema-metadata\";\nimport * as assert from \"assert\";\nimport { IModelDb } from \"@itwin/core-backend\";\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @internal\n */\nexport class SchemaNotInCacheErr extends Error {\n public constructor() {\n super(\"Schema was not in cache, initialize that schema\");\n }\n}\n\n/**\n * A cache of the entity types referenced by navprops in ecchemas, as well as the source and target entity types of\n * The transformer needs the referenced type to determine how to resolve references.\n *\n * Using multiple of these usually performs redundant computation, for static schemas at least. A possible future optimization\n * would be to seed the computation from a global cache of non-dynamic schemas, but dynamic schemas can collide willy-nilly\n * @internal\n */\nexport class ECReferenceTypesCache {\n /** nesting based tuple map keyed by qualified property path tuple [schemaName, className, propName] */\n private _propQualifierToRefType = new TupleKeyedMap<\n [string, string, string],\n ConcreteEntityTypes\n >();\n private _relClassNameEndToRefTypes = new TupleKeyedMap<\n [string, string],\n RelTypeInfo\n >();\n private _initedSchemas = new Map<string, SchemaKey>();\n\n private static bisRootClassToRefType: Record<\n string,\n ConcreteEntityTypes | undefined\n > = {\n /* eslint-disable quote-props, @typescript-eslint/naming-convention */\n Element: ConcreteEntityTypes.Element,\n Model: ConcreteEntityTypes.Model,\n ElementAspect: ConcreteEntityTypes.ElementAspect,\n ElementRefersToElements: ConcreteEntityTypes.Relationship,\n ElementDrivesElement: ConcreteEntityTypes.Relationship,\n // code spec is technically a potential root class but it is ignored currently\n // see [ConcreteEntityTypes]($common)\n /* eslint-enable quote-props, @typescript-eslint/naming-convention */\n };\n\n private async getRootBisClass(ecclass: ECClass) {\n let bisRootForConstraint: ECClass = ecclass;\n await ecclass.traverseBaseClasses((baseClass) => {\n // The depth first traversal will descend all the way to the root class before making any lateral traversal\n // of mixin hierarchies, (or if the constraint is a mixin, it will traverse to the root of the mixin hierarchy)\n // Once we see that we've moved laterally, we can terminate early\n const isFirstTest = bisRootForConstraint === ecclass;\n const traversalSwitchedRootPath =\n baseClass.name !== bisRootForConstraint.baseClass?.name;\n const stillTraversingRootPath = isFirstTest || !traversalSwitchedRootPath;\n if (!stillTraversingRootPath) return true; // stop traversal early\n bisRootForConstraint = baseClass;\n return false;\n });\n // if the root class of the constraint was a mixin, use its AppliesToEntityClass\n if (bisRootForConstraint instanceof Mixin) {\n assert(\n bisRootForConstraint.appliesTo !== undefined,\n \"The referenced AppliesToEntityClass could not be found, how did it pass schema validation?\"\n );\n bisRootForConstraint = await this.getRootBisClass(\n await bisRootForConstraint.appliesTo\n );\n }\n return bisRootForConstraint;\n }\n\n private async getAbstractConstraintClass(\n constraint: RelationshipConstraint\n ): Promise<ECClass> {\n // constraint classes must share a base so we can get the root from any of them, just use the first\n const ecclass = await (constraint.constraintClasses?.[0] ||\n constraint.abstractConstraint);\n assert(\n ecclass !== undefined,\n \"At least one constraint class or an abstract constraint must have been defined, the constraint is not valid\"\n );\n return ecclass;\n }\n\n /** initialize from an imodel with metadata */\n public async initAllSchemasInIModel(imodel: IModelDb): Promise<void> {\n const schemaLoader = new SchemaLoader((name: string) =>\n imodel.getSchemaProps(name)\n );\n await imodel.withPreparedStatement(\n `\n WITH RECURSIVE refs(SchemaId) AS (\n SELECT ECInstanceId FROM ECDbMeta.ECSchemaDef WHERE Name='BisCore'\n UNION ALL\n SELECT sr.SourceECInstanceId\n FROM ECDbMeta.SchemaHasSchemaReferences sr\n JOIN refs ON sr.TargetECInstanceId = refs.SchemaId\n )\n SELECT s.Name\n FROM refs\n JOIN ECDbMeta.ECSchemaDef s ON refs.SchemaId=s.ECInstanceId\n -- ensure schema dependency order\n ORDER BY ECInstanceId\n `,\n async (stmt) => {\n let status: DbResult;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const schemaName = stmt.getValue(0).getString();\n const schema = schemaLoader.getSchema(schemaName);\n await this.considerInitSchema(schema);\n }\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n }\n );\n }\n\n private async considerInitSchema(schema: Schema): Promise<void> {\n if (this._initedSchemas.has(schema.name)) {\n const cachedSchemaKey = this._initedSchemas.get(schema.name);\n assert(cachedSchemaKey !== undefined);\n const incomingSchemaIsEqualOrOlder =\n schema.schemaKey.compareByVersion(cachedSchemaKey) <= 0;\n if (incomingSchemaIsEqualOrOlder) {\n return;\n }\n }\n return this.initSchema(schema);\n }\n\n private async initSchema(schema: Schema): Promise<void> {\n for (const ecclass of schema.getClasses()) {\n for (const prop of await ecclass.getProperties()) {\n if (!prop.isNavigation()) continue;\n const relClass = await prop.relationshipClass;\n const relInfo = await this.relInfoFromRelClass(relClass);\n if (relInfo === undefined) continue;\n const navPropRefType =\n prop.direction === StrengthDirection.Forward\n ? relInfo.target\n : relInfo.source;\n this._propQualifierToRefType.set(\n [\n schema.name.toLowerCase(),\n ecclass.name.toLowerCase(),\n prop.name.toLowerCase(),\n ],\n navPropRefType\n );\n }\n\n if (ecclass instanceof RelationshipClass) {\n const relInfo = await this.relInfoFromRelClass(ecclass);\n if (relInfo)\n this._relClassNameEndToRefTypes.set(\n [schema.name.toLowerCase(), ecclass.name.toLowerCase()],\n relInfo\n );\n }\n }\n\n this._initedSchemas.set(schema.name, schema.schemaKey);\n }\n\n private async relInfoFromRelClass(\n ecclass: RelationshipClass\n ): Promise<RelTypeInfo | undefined> {\n assert(ecclass.source.constraintClasses !== undefined);\n assert(ecclass.target.constraintClasses !== undefined);\n const [\n [sourceClass, sourceRootBisClass],\n [targetClass, targetRootBisClass],\n ] = await Promise.all([\n this.getAbstractConstraintClass(ecclass.source).then(\n async (constraintClass) => [\n constraintClass,\n await this.getRootBisClass(constraintClass),\n ]\n ),\n this.getAbstractConstraintClass(ecclass.target).then(\n async (constraintClass) => [\n constraintClass,\n await this.getRootBisClass(constraintClass),\n ]\n ),\n ]);\n\n if (\n sourceRootBisClass.name === \"CodeSpec\" ||\n targetRootBisClass.name === \"CodeSpec\"\n )\n return undefined;\n const sourceType =\n ECReferenceTypesCache.bisRootClassToRefType[sourceRootBisClass.name];\n const targetType =\n ECReferenceTypesCache.bisRootClassToRefType[targetRootBisClass.name];\n const makeAssertMsg = (root: ECClass, cls: ECClass) =>\n [\n `An unknown root class '${root.fullName}' was encountered while populating`,\n `the nav prop reference type cache for ${cls.fullName}.`,\n \"This is a bug.\",\n ].join(\"\\n\");\n assert(\n sourceType !== undefined,\n makeAssertMsg(sourceRootBisClass, sourceClass)\n );\n assert(\n targetType !== undefined,\n makeAssertMsg(targetRootBisClass, targetClass)\n );\n return { source: sourceType, target: targetType };\n }\n\n public getNavPropRefType(\n schemaName: string,\n className: string,\n propName: string\n ): undefined | ConcreteEntityTypes {\n if (!this._initedSchemas.has(schemaName)) throw new SchemaNotInCacheErr();\n return this._propQualifierToRefType.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n propName.toLowerCase(),\n ]);\n }\n\n public getRelationshipEndType(\n schemaName: string,\n className: string\n ): undefined | RelTypeInfo {\n if (!this._initedSchemas.has(schemaName)) throw new SchemaNotInCacheErr();\n return this._relClassNameEndToRefTypes.get([\n schemaName.toLowerCase(),\n className.toLowerCase(),\n ]);\n }\n\n public clear() {\n this._initedSchemas.clear();\n this._propQualifierToRefType.clear();\n }\n}\n"]}
@@ -15,5 +15,5 @@ export declare class ECSqlReaderAsyncIterableIteratorAdapter implements AsyncIte
15
15
  * @param ecSqlReader ECSqlReader isntance from itwin 3.x or 4.x version
16
16
  * @internal
17
17
  */
18
- export declare function ensureECSqlReaderIsAsyncIterableIterator(ecSqlReader: ECSqlReader & AsyncIterableIterator<QueryRowProxy> | Omit<ECSqlReader, keyof AsyncIterableIterator<QueryRowProxy>>): AsyncIterableIterator<QueryRowProxy>;
18
+ export declare function ensureECSqlReaderIsAsyncIterableIterator(ecSqlReader: (ECSqlReader & AsyncIterableIterator<QueryRowProxy>) | Omit<ECSqlReader, keyof AsyncIterableIterator<QueryRowProxy>>): AsyncIterableIterator<QueryRowProxy>;
19
19
  //# sourceMappingURL=ECSqlReaderAsyncIterableIteratorAdapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ECSqlReaderAsyncIterableIteratorAdapter.d.ts","sourceRoot":"","sources":["../../src/ECSqlReaderAsyncIterableIteratorAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;;;GAIG;AACH,qBAAa,uCAAwC,YAAW,qBAAqB,CAAC,aAAa,CAAC;IAE/E,OAAO,CAAC,YAAY;gBAAZ,YAAY,EAAE,WAAW;IAE7C,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,aAAa,CAAC;IAIxD,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;CAOjE;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,WAAW,EAAE,WAAW,GAAG,qBAAqB,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,qBAAqB,CAAC,aAAa,CAAC,CAAC,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAM9N"}
1
+ {"version":3,"file":"ECSqlReaderAsyncIterableIteratorAdapter.d.ts","sourceRoot":"","sources":["../../src/ECSqlReaderAsyncIterableIteratorAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;;;GAIG;AACH,qBAAa,uCACX,YAAW,qBAAqB,CAAC,aAAa,CAAC;IAE5B,OAAO,CAAC,YAAY;gBAAZ,YAAY,EAAE,WAAW;IAE7C,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,aAAa,CAAC;IAIxD,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;CAOjE;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CACtD,WAAW,EACP,CAAC,WAAW,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC,GACpD,IAAI,CAAC,WAAW,EAAE,MAAM,qBAAqB,CAAC,aAAa,CAAC,CAAC,GAChE,qBAAqB,CAAC,aAAa,CAAC,CAUtC"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ensureECSqlReaderIsAsyncIterableIterator = exports.ECSqlReaderAsyncIterableIteratorAdapter = void 0;
8
8
  /**
@@ -32,10 +32,12 @@ exports.ECSqlReaderAsyncIterableIteratorAdapter = ECSqlReaderAsyncIterableIterat
32
32
  * @internal
33
33
  */
34
34
  function ensureECSqlReaderIsAsyncIterableIterator(ecSqlReader) {
35
- if (Symbol.asyncIterator in ecSqlReader) { // using itwin 4.x
35
+ if (Symbol.asyncIterator in ecSqlReader) {
36
+ // using itwin 4.x
36
37
  return ecSqlReader;
37
38
  }
38
- else { // using itwin 3.x
39
+ else {
40
+ // using itwin 3.x
39
41
  return new ECSqlReaderAsyncIterableIteratorAdapter(ecSqlReader);
40
42
  }
41
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ECSqlReaderAsyncIterableIteratorAdapter.js","sourceRoot":"","sources":["../../src/ECSqlReaderAsyncIterableIteratorAdapter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAI/F;;;;GAIG;AACH,MAAa,uCAAuC;IAElD,YAA2B,YAAyB;QAAzB,iBAAY,GAAZ,YAAY,CAAa;IAAI,CAAC;IAElD,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO;SACjC,CAAC;IACJ,CAAC;CACF;AAfD,0FAeC;AAED;;;;GAIG;AACH,SAAgB,wCAAwC,CAAC,WAA+H;IACtL,IAAI,MAAM,CAAC,aAAa,IAAI,WAAW,EAAE,EAAE,kBAAkB;QAC3D,OAAO,WAAW,CAAC;KACpB;SAAM,EAAE,kBAAkB;QACzB,OAAO,IAAI,uCAAuC,CAAC,WAA0B,CAAC,CAAC;KAChF;AACH,CAAC;AAND,4FAMC","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 { ECSqlReader, QueryRowProxy } from \"@itwin/core-common\";\n\n/**\n * Adapter class for ECSqlReader for AsyncIterableIterator interface.\n * It allows to iterate through query results in itwin 3.x using for await() syntax like using itwin 4.x version.\n * @internal\n */\nexport class ECSqlReaderAsyncIterableIteratorAdapter implements AsyncIterableIterator<QueryRowProxy> {\n\n public constructor(private _ecSqlReader: ECSqlReader) { }\n\n public [Symbol.asyncIterator](): AsyncIterableIterator<QueryRowProxy> {\n return this;\n }\n\n public async next(): Promise<IteratorResult<QueryRowProxy, any>> {\n const done = !(await this._ecSqlReader.step());\n return {\n done,\n value: this._ecSqlReader.current,\n };\n }\n}\n\n/**\n * Wraps ECSqlReader with ECSqlReaderAsyncIterableIteratorAdapter if it's needed.\n * @param ecSqlReader ECSqlReader isntance from itwin 3.x or 4.x version\n * @internal\n */\nexport function ensureECSqlReaderIsAsyncIterableIterator(ecSqlReader: ECSqlReader & AsyncIterableIterator<QueryRowProxy> | Omit<ECSqlReader, keyof AsyncIterableIterator<QueryRowProxy>>): AsyncIterableIterator<QueryRowProxy> {\n if (Symbol.asyncIterator in ecSqlReader) { // using itwin 4.x\n return ecSqlReader;\n } else { // using itwin 3.x\n return new ECSqlReaderAsyncIterableIteratorAdapter(ecSqlReader as ECSqlReader);\n }\n}\n"]}
1
+ {"version":3,"file":"ECSqlReaderAsyncIterableIteratorAdapter.js","sourceRoot":"","sources":["../../src/ECSqlReaderAsyncIterableIteratorAdapter.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAIhG;;;;GAIG;AACH,MAAa,uCAAuC;IAGlD,YAA2B,YAAyB;QAAzB,iBAAY,GAAZ,YAAY,CAAa;IAAG,CAAC;IAEjD,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO;SACjC,CAAC;IACJ,CAAC;CACF;AAhBD,0FAgBC;AAED;;;;GAIG;AACH,SAAgB,wCAAwC,CACtD,WAEiE;IAEjE,IAAI,MAAM,CAAC,aAAa,IAAI,WAAW,EAAE;QACvC,kBAAkB;QAClB,OAAO,WAAW,CAAC;KACpB;SAAM;QACL,kBAAkB;QAClB,OAAO,IAAI,uCAAuC,CAChD,WAA0B,CAC3B,CAAC;KACH;AACH,CAAC;AAdD,4FAcC","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 { ECSqlReader, QueryRowProxy } from \"@itwin/core-common\";\n\n/**\n * Adapter class for ECSqlReader for AsyncIterableIterator interface.\n * It allows to iterate through query results in itwin 3.x using for await() syntax like using itwin 4.x version.\n * @internal\n */\nexport class ECSqlReaderAsyncIterableIteratorAdapter\n implements AsyncIterableIterator<QueryRowProxy>\n{\n public constructor(private _ecSqlReader: ECSqlReader) {}\n\n public [Symbol.asyncIterator](): AsyncIterableIterator<QueryRowProxy> {\n return this;\n }\n\n public async next(): Promise<IteratorResult<QueryRowProxy, any>> {\n const done = !(await this._ecSqlReader.step());\n return {\n done,\n value: this._ecSqlReader.current,\n };\n }\n}\n\n/**\n * Wraps ECSqlReader with ECSqlReaderAsyncIterableIteratorAdapter if it's needed.\n * @param ecSqlReader ECSqlReader isntance from itwin 3.x or 4.x version\n * @internal\n */\nexport function ensureECSqlReaderIsAsyncIterableIterator(\n ecSqlReader:\n | (ECSqlReader & AsyncIterableIterator<QueryRowProxy>)\n | Omit<ECSqlReader, keyof AsyncIterableIterator<QueryRowProxy>>\n): AsyncIterableIterator<QueryRowProxy> {\n if (Symbol.asyncIterator in ecSqlReader) {\n // using itwin 4.x\n return ecSqlReader;\n } else {\n // using itwin 3.x\n return new ECSqlReaderAsyncIterableIteratorAdapter(\n ecSqlReader as ECSqlReader\n );\n }\n}\n"]}
@@ -9,9 +9,9 @@ import { Id64String } from "@itwin/core-bentley";
9
9
  */
10
10
  export declare function deleteElementTreeCascade(iModel: IModelDb, topElement: Id64String): void;
11
11
  /** Deletes an entire element tree, including sub-models, child elements and code scope references.
12
- * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.
13
- * Call deleteNormalElements on each tree. Then call deleteSpecialElements.
14
- */
12
+ * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.
13
+ * Call deleteNormalElements on each tree. Then call deleteSpecialElements.
14
+ */
15
15
  export declare class ElementCascadingDeleter extends ElementTreeDeleter {
16
16
  protected shouldVisitCodeScopes(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean;
17
17
  /** The main tree-walking function */
@@ -1 +1 @@
1
- {"version":3,"file":"ElementCascadingDeleter.d.ts","sourceRoot":"","sources":["../../src/ElementCascadingDeleter.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAY,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAIvF;AAED;;;IAGI;AACJ,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,SAAS,CAAC,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,sBAAsB;IAEtF,qCAAqC;cAClB,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAM/F,oCAAoC;IACpC,OAAO,CAAC,kBAAkB;CAe3B"}
1
+ {"version":3,"file":"ElementCascadingDeleter.d.ts","sourceRoot":"","sources":["../../src/ElementCascadingDeleter.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAY,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,UAAU,GACrB,IAAI,CAIN;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D,SAAS,CAAC,qBAAqB,CAC7B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,sBAAsB;IAKhC,qCAAqC;cAClB,kBAAkB,CACnC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,sBAAsB,GAC5B,IAAI;IAMP,oCAAoC;IACpC,OAAO,CAAC,kBAAkB;CAqB3B"}
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ElementCascadingDeleter = exports.deleteElementTreeCascade = void 0;
4
4
  /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
8
  /** @packageDocumentation
9
9
  * @module iModels
10
10
  */
@@ -21,11 +21,13 @@ function deleteElementTreeCascade(iModel, topElement) {
21
21
  }
22
22
  exports.deleteElementTreeCascade = deleteElementTreeCascade;
23
23
  /** Deletes an entire element tree, including sub-models, child elements and code scope references.
24
- * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.
25
- * Call deleteNormalElements on each tree. Then call deleteSpecialElements.
26
- */
24
+ * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.
25
+ * Call deleteNormalElements on each tree. Then call deleteSpecialElements.
26
+ */
27
27
  class ElementCascadingDeleter extends core_backend_1.ElementTreeDeleter {
28
- shouldVisitCodeScopes(_elementId, _scope) { return true; }
28
+ shouldVisitCodeScopes(_elementId, _scope) {
29
+ return true;
30
+ }
29
31
  /** The main tree-walking function */
30
32
  processElementTree(element, scope) {
31
33
  if (this.shouldVisitCodeScopes(element, scope)) {
@@ -1 +1 @@
1
- {"version":3,"file":"ElementCascadingDeleter.js","sourceRoot":"","sources":["../../src/ElementCascadingDeleter.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAA2F;AAC3F,sDAA2D;AAE3D;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,MAAgB,EAAE,UAAsB;IAC/E,MAAM,GAAG,GAAG,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChD,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACrC,GAAG,CAAC,qBAAqB,EAAE,CAAC;AAC9B,CAAC;AAJD,4DAIC;AAED;;;IAGI;AACJ,MAAa,uBAAwB,SAAQ,iCAAkB;IACnD,qBAAqB,CAAC,UAAsB,EAAE,MAA8B,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC;IAExG,qCAAqC;IAClB,kBAAkB,CAAC,OAAmB,EAAE,KAA6B;QACtF,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;YAC9C,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SACzC;QACD,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,oCAAoC;IAC5B,kBAAkB,CAAC,OAAmB,EAAE,KAA6B;QAC3E,MAAM,QAAQ,GAAG,IAAI,qCAAsB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;;;;;KAKlC,EAAE,CAAC,IAAI,EAAE,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,uBAAQ,CAAC,aAAa,EAAE;gBAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC3C,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1BD,0DA0BC","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/** @packageDocumentation\n * @module iModels\n */\nimport { ElementTreeDeleter, ElementTreeWalkerScope, IModelDb } from \"@itwin/core-backend\";\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\n\n/** Deletes an element tree and code scope references starting with the specified top element. The top element is also deleted. Uses ElementCascadeDeleter.\n * @param iModel The iModel\n * @param topElement The parent of the sub-tree\n */\nexport function deleteElementTreeCascade(iModel: IModelDb, topElement: Id64String): void {\n const del = new ElementCascadingDeleter(iModel);\n del.deleteNormalElements(topElement);\n del.deleteSpecialElements();\n}\n\n/** Deletes an entire element tree, including sub-models, child elements and code scope references.\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\n */\nexport class ElementCascadingDeleter extends ElementTreeDeleter {\n protected shouldVisitCodeScopes(_elementId: Id64String, _scope: ElementTreeWalkerScope) { return true; }\n\n /** The main tree-walking function */\n protected override processElementTree(element: Id64String, scope: ElementTreeWalkerScope): void {\n if (this.shouldVisitCodeScopes(element, scope)) {\n this._processCodeScopes(element, scope);\n }\n super.processElementTree(element, scope);\n }\n /** Process code scope references */\n private _processCodeScopes(element: Id64String, scope: ElementTreeWalkerScope) {\n const newScope = new ElementTreeWalkerScope(scope, element);\n this._iModel.withPreparedStatement(`\n SELECT ECInstanceId\n FROM bis.Element\n WHERE CodeScope.id=?\n AND Parent.id IS NULL\n `, (stmt) => {\n stmt.bindId(1, element);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, newScope);\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ElementCascadingDeleter.js","sourceRoot":"","sources":["../../src/ElementCascadingDeleter.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,sDAI6B;AAC7B,sDAA2D;AAE3D;;;GAGG;AACH,SAAgB,wBAAwB,CACtC,MAAgB,EAChB,UAAsB;IAEtB,MAAM,GAAG,GAAG,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChD,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACrC,GAAG,CAAC,qBAAqB,EAAE,CAAC;AAC9B,CAAC;AAPD,4DAOC;AAED;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,iCAAkB;IACnD,qBAAqB,CAC7B,UAAsB,EACtB,MAA8B;QAE9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qCAAqC;IAClB,kBAAkB,CACnC,OAAmB,EACnB,KAA6B;QAE7B,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;YAC9C,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SACzC;QACD,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,oCAAoC;IAC5B,kBAAkB,CACxB,OAAmB,EACnB,KAA6B;QAE7B,MAAM,QAAQ,GAAG,IAAI,qCAAsB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAChC;;;;;KAKD,EACC,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,uBAAQ,CAAC,aAAa,EAAE;gBAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC3C,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;aAC9C;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAxCD,0DAwCC","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/** @packageDocumentation\n * @module iModels\n */\nimport {\n ElementTreeDeleter,\n ElementTreeWalkerScope,\n IModelDb,\n} from \"@itwin/core-backend\";\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\n\n/** Deletes an element tree and code scope references starting with the specified top element. The top element is also deleted. Uses ElementCascadeDeleter.\n * @param iModel The iModel\n * @param topElement The parent of the sub-tree\n */\nexport function deleteElementTreeCascade(\n iModel: IModelDb,\n topElement: Id64String\n): void {\n const del = new ElementCascadingDeleter(iModel);\n del.deleteNormalElements(topElement);\n del.deleteSpecialElements();\n}\n\n/** Deletes an entire element tree, including sub-models, child elements and code scope references.\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\n */\nexport class ElementCascadingDeleter extends ElementTreeDeleter {\n protected shouldVisitCodeScopes(\n _elementId: Id64String,\n _scope: ElementTreeWalkerScope\n ) {\n return true;\n }\n\n /** The main tree-walking function */\n protected override processElementTree(\n element: Id64String,\n scope: ElementTreeWalkerScope\n ): void {\n if (this.shouldVisitCodeScopes(element, scope)) {\n this._processCodeScopes(element, scope);\n }\n super.processElementTree(element, scope);\n }\n /** Process code scope references */\n private _processCodeScopes(\n element: Id64String,\n scope: ElementTreeWalkerScope\n ) {\n const newScope = new ElementTreeWalkerScope(scope, element);\n this._iModel.withPreparedStatement(\n `\n SELECT ECInstanceId\n FROM bis.Element\n WHERE CodeScope.id=?\n AND Parent.id IS NULL\n `,\n (stmt) => {\n stmt.bindId(1, element);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, newScope);\n }\n }\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityMap.d.ts","sourceRoot":"","sources":["../../src/EntityMap.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAoB,MAAM,qBAAqB,CAAC;AAGvE,gBAAgB;AAChB,MAAM,MAAM,SAAS,GAAG,eAAe,CAAC;AAExC,gBAAgB;AAChB,qBAAa,SAAS,CAAC,CAAC;IACtB,OAAO,CAAC,IAAI,CAAmB;WAEjB,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS;IAIjD,KAAK,I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IAEM,QAAQ,CAAC,CAAY;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,MAAsB;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,CAAC;IAEM,WAAW,CAAC,CAAY;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACtC,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;CACF;AA5DD,8BA4DC","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/** @packageDocumentation\n * @module Utils\n */\nimport { EntityReference } from \"@itwin/core-common\";\nimport { ConcreteEntity, EntityReferences } from \"@itwin/core-backend\";\nimport { BigMap } from \"./BigMap\";\n\n/** @internal */\nexport type EntityKey = EntityReference;\n\n/** @internal */\nexport class EntityMap<V> {\n private _map = new BigMap<V>();\n\n public static makeKey(entity: ConcreteEntity): EntityKey {\n return EntityReferences.from(entity);\n }\n\n public clear(): void {\n return this._map.clear();\n }\n\n public has(entity: ConcreteEntity) {\n return this._map.has(EntityMap.makeKey(entity)\n );\n }\n\n public set(entity: ConcreteEntity, val: V): EntityMap<V> {\n return this.setByKey(EntityMap.makeKey(entity), val);\n }\n\n public setByKey(k: EntityKey, val: V): EntityMap<V> {\n this._map.set(k, val);\n return this;\n }\n\n public get(entity: ConcreteEntity): V | undefined {\n return this.getByKey(EntityMap.makeKey(entity));\n }\n\n public getByKey(k: EntityKey): V | undefined {\n return this._map.get(k);\n }\n\n public delete(entity: ConcreteEntity): boolean {\n return this.deleteByKey(EntityMap.makeKey(entity));\n }\n\n public deleteByKey(k: EntityKey): boolean {\n return this._map.delete(k);\n }\n\n public keys() {\n return this._map.keys();\n }\n\n public values() {\n return this._map.values();\n }\n\n public entries() {\n return this._map.entries();\n }\n\n public [Symbol.iterator]() {\n return this._map[Symbol.iterator]();\n }\n\n public get size() {\n return this._map.size;\n }\n}\n\n"]}
1
+ {"version":3,"file":"EntityMap.js","sourceRoot":"","sources":["../../src/EntityMap.ts"],"names":[],"mappings":";;;AAQA,sDAAuE;AACvE,qCAAkC;AAKlC,gBAAgB;AAChB,MAAa,SAAS;IAAtB;QACU,SAAI,GAAG,IAAI,eAAM,EAAK,CAAC;IA0DjC,CAAC;IAxDQ,MAAM,CAAC,OAAO,CAAC,MAAsB;QAC1C,OAAO,+BAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEM,GAAG,CAAC,MAAsB;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAEM,GAAG,CAAC,MAAsB,EAAE,GAAM;QACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IAEM,QAAQ,CAAC,CAAY,EAAE,GAAM;QAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,MAAsB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAEM,QAAQ,CAAC,CAAY;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,MAAsB;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,CAAC;IAEM,WAAW,CAAC,CAAY;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACtC,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;CACF;AA3DD,8BA2DC","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/** @packageDocumentation\n * @module Utils\n */\nimport { EntityReference } from \"@itwin/core-common\";\nimport { ConcreteEntity, EntityReferences } from \"@itwin/core-backend\";\nimport { BigMap } from \"./BigMap\";\n\n/** @internal */\nexport type EntityKey = EntityReference;\n\n/** @internal */\nexport class EntityMap<V> {\n private _map = new BigMap<V>();\n\n public static makeKey(entity: ConcreteEntity): EntityKey {\n return EntityReferences.from(entity);\n }\n\n public clear(): void {\n return this._map.clear();\n }\n\n public has(entity: ConcreteEntity) {\n return this._map.has(EntityMap.makeKey(entity));\n }\n\n public set(entity: ConcreteEntity, val: V): EntityMap<V> {\n return this.setByKey(EntityMap.makeKey(entity), val);\n }\n\n public setByKey(k: EntityKey, val: V): EntityMap<V> {\n this._map.set(k, val);\n return this;\n }\n\n public get(entity: ConcreteEntity): V | undefined {\n return this.getByKey(EntityMap.makeKey(entity));\n }\n\n public getByKey(k: EntityKey): V | undefined {\n return this._map.get(k);\n }\n\n public delete(entity: ConcreteEntity): boolean {\n return this.deleteByKey(EntityMap.makeKey(entity));\n }\n\n public deleteByKey(k: EntityKey): boolean {\n return this._map.delete(k);\n }\n\n public keys() {\n return this._map.keys();\n }\n\n public values() {\n return this._map.values();\n }\n\n public entries() {\n return this._map.entries();\n }\n\n public [Symbol.iterator]() {\n return this._map[Symbol.iterator]();\n }\n\n public get size() {\n return this._map.size;\n }\n}\n"]}
@@ -1,3 +1,8 @@
1
+ /** @packageDocumentation
2
+ * @module Utils
3
+ * utilities that unify operations, especially CRUD operations, on entities
4
+ * for entity-generic operations in the transformer
5
+ */
1
6
  import { EntityReference } from "@itwin/core-common";
2
7
  import { ConcreteEntity, ConcreteEntityProps, IModelDb } from "@itwin/core-backend";
3
8
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"EntityUnifier.d.ts","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAA4C,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAG5I,gBAAgB;AAChB,yBAAiB,aAAa,CAAC;IAC7B,MAAM,UAAU,eAAe,CAAC,MAAM,EAAE,cAAc,yEASrD;IAED,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEhE,2GAA2G;IAC3G,MAAM,UAAU,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,iBAS9D;IAED,MAAM,UAAU,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG;QAAE,eAAe,EAAE,eAAe,CAAA;KAAE,WA+B1G;;CACF"}
1
+ {"version":3,"file":"EntityUnifier.d.ts","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AAGH,OAAO,EAGL,eAAe,EAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,mBAAmB,EAInB,QAAQ,EAET,MAAM,qBAAqB,CAAC;AAG7B,gBAAgB;AAChB,yBAAiB,aAAa,CAAC;IAC7B,MAAM,UAAU,eAAe,CAAC,MAAM,EAAE,cAAc,yEAKrD;IAED,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEhE,2GAA2G;IAC3G,MAAM,UAAU,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,iBAc9D;IAED,MAAM,UAAU,MAAM,CACpB,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG;QAAE,eAAe,EAAE,eAAe,CAAA;KAAE,WAuBvE;;CACF"}
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityUnifier = void 0;
4
2
  /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
8
6
  /** @packageDocumentation
9
7
  * @module Utils
10
8
  * utilities that unify operations, especially CRUD operations, on entities
11
9
  * for entity-generic operations in the transformer
12
10
  */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EntityUnifier = void 0;
13
13
  const assert = require("assert");
14
14
  const core_common_1 = require("@itwin/core-common");
15
15
  const core_backend_1 = require("@itwin/core-backend");
@@ -41,37 +41,24 @@ var EntityUnifier;
41
41
  }
42
42
  EntityUnifier.updaterFor = updaterFor;
43
43
  function exists(db, arg) {
44
- if ("entityReference" in arg) {
45
- const [type, id] = core_backend_1.EntityReferences.split(arg.entityReference);
46
- // FIXME: add a test with a deleted reference that triggers this
47
- if (id === undefined || core_bentley_1.Id64.isInvalid(id))
48
- return false;
49
- const bisCoreRootClassName = core_common_1.ConcreteEntityTypes.toBisCoreRootClassFullName(type);
50
- return db.withPreparedStatement(`SELECT 1 FROM ${bisCoreRootClassName} WHERE ECInstanceId=?`, (stmt) => {
51
- stmt.bindId(1, id);
52
- const matchesResult = stmt.step();
53
- if (matchesResult === core_common_1.DbResult.BE_SQLITE_ROW)
54
- return true;
55
- if (matchesResult === core_common_1.DbResult.BE_SQLITE_DONE)
56
- return false;
57
- else
58
- throw new core_common_1.IModelError(matchesResult, "query failed");
59
- });
60
- }
61
- else {
62
- if (arg.entity.id === undefined || core_bentley_1.Id64.isInvalid(arg.entity.id))
44
+ const [type, id] = "entityReference" in arg
45
+ ? core_backend_1.EntityReferences.split(arg.entityReference)
46
+ : [undefined, arg.entity.id];
47
+ const classFullName = "entityReference" in arg
48
+ ? core_common_1.ConcreteEntityTypes.toBisCoreRootClassFullName(type)
49
+ : `[${arg.entity.schemaName}].[${arg.entity.className}]`;
50
+ if (id === undefined || core_bentley_1.Id64.isInvalid(id))
51
+ return false;
52
+ return db.withPreparedStatement(`SELECT 1 FROM ${classFullName} WHERE ECInstanceId=?`, (stmt) => {
53
+ stmt.bindId(1, id);
54
+ const matchesResult = stmt.step();
55
+ if (matchesResult === core_common_1.DbResult.BE_SQLITE_ROW)
56
+ return true;
57
+ if (matchesResult === core_common_1.DbResult.BE_SQLITE_DONE)
63
58
  return false;
64
- return db.withPreparedStatement(`SELECT 1 FROM [${arg.entity.schemaName}].[${arg.entity.className}] WHERE ECInstanceId=?`, (stmt) => {
65
- stmt.bindId(1, arg.entity.id);
66
- const matchesResult = stmt.step();
67
- if (matchesResult === core_common_1.DbResult.BE_SQLITE_ROW)
68
- return true;
69
- if (matchesResult === core_common_1.DbResult.BE_SQLITE_DONE)
70
- return false;
71
- else
72
- throw new core_common_1.IModelError(matchesResult, "query failed");
73
- });
74
- }
59
+ else
60
+ throw new core_common_1.IModelError(matchesResult, "query failed");
61
+ });
75
62
  }
76
63
  EntityUnifier.exists = exists;
77
64
  })(EntityUnifier || (exports.EntityUnifier = EntityUnifier = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"EntityUnifier.js","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;;;GAIG;AACH,iCAAiC;AACjC,oDAAkG;AAClG,sDAA4I;AAC5I,sDAA2C;AAE3C,gBAAgB;AAChB,IAAiB,aAAa,CA0D7B;AA1DD,WAAiB,aAAa;IAC5B,SAAgB,eAAe,CAAC,MAAsB;QACpD,IAAI,MAAM,YAAY,sBAAO;YAC3B,OAAO,SAAS,CAAC;aACd,IAAI,MAAM,YAAY,4BAAa;YACtC,OAAO,gBAAgB,CAAC;aACrB,IAAI,MAAM,YAAY,2BAAY;YACrC,OAAO,cAAc,CAAC;;YAEtB,OAAO,qBAAqB,CAAC;IACjC,CAAC;IATe,6BAAe,kBAS9B,CAAA;IAID,2GAA2G;IAC3G,SAAgB,UAAU,CAA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3C,OAAO,KAAK,CAAC;;oBAEb,MAAM,IAAI,yBAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,SAAS,IAAI,mBAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9D,OAAO,KAAK,CAAC;YACf,OAAO,EAAE,CAAC,qBAAqB,CAAC,kBAAkB,GAAG,CAAC,MAAM,CAAC,UAAU,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,wBAAwB,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBAC9B,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClC,IAAI,aAAa,KAAK,sBAAQ,CAAC,aAAa;oBAC1C,OAAO,IAAI,CAAC;gBACd,IAAI,aAAa,KAAK,sBAAQ,CAAC,cAAc;oBAC3C,OAAO,KAAK,CAAC;;oBAEb,MAAM,IAAI,yBAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IA/Be,oBAAM,SA+BrB,CAAA;AACH,CAAC,EA1DgB,aAAa,6BAAb,aAAa,QA0D7B","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/** @packageDocumentation\n * @module Utils\n * utilities that unify operations, especially CRUD operations, on entities\n * for entity-generic operations in the transformer\n */\nimport * as assert from \"assert\";\nimport { ConcreteEntityTypes, DbResult, EntityReference, IModelError } from \"@itwin/core-common\";\nimport { ConcreteEntity, ConcreteEntityProps, Element, ElementAspect, EntityReferences, IModelDb, Relationship } from \"@itwin/core-backend\";\nimport { Id64 } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport namespace EntityUnifier {\n export function getReadableType(entity: ConcreteEntity) {\n if (entity instanceof Element)\n return \"element\";\n else if (entity instanceof ElementAspect)\n return \"element aspect\";\n else if (entity instanceof Relationship)\n return \"relationship\";\n else\n return \"unknown entity type\";\n }\n\n type EntityUpdater = (entityProps: ConcreteEntityProps) => void;\n\n /** needs to return a widened type otherwise typescript complains when result is used with a narrow type */\n export function updaterFor(db: IModelDb, entity: ConcreteEntity) {\n if (entity instanceof Element)\n return db.elements.updateElement.bind(db.elements) as EntityUpdater;\n else if (entity instanceof Relationship)\n return db.relationships.updateInstance.bind(db.relationships) as EntityUpdater;\n else if (entity instanceof ElementAspect)\n return db.elements.updateAspect.bind(db.elements) as EntityUpdater;\n else\n assert(false, `unreachable; entity was '${entity.constructor.name}' not an Element, Relationship, or ElementAspect`);\n }\n\n export function exists(db: IModelDb, arg: { entity: ConcreteEntity } | { entityReference: EntityReference }) {\n if (\"entityReference\" in arg) {\n const [type, id] = EntityReferences.split(arg.entityReference);\n // FIXME: add a test with a deleted reference that triggers this\n if (id === undefined || Id64.isInvalid(id))\n return false;\n const bisCoreRootClassName = ConcreteEntityTypes.toBisCoreRootClassFullName(type);\n return db.withPreparedStatement(`SELECT 1 FROM ${bisCoreRootClassName} WHERE ECInstanceId=?`, (stmt) => {\n stmt.bindId(1, id);\n const matchesResult = stmt.step();\n if (matchesResult === DbResult.BE_SQLITE_ROW)\n return true;\n if (matchesResult === DbResult.BE_SQLITE_DONE)\n return false;\n else\n throw new IModelError(matchesResult, \"query failed\");\n });\n } else {\n if (arg.entity.id === undefined || Id64.isInvalid(arg.entity.id))\n return false;\n return db.withPreparedStatement(`SELECT 1 FROM [${arg.entity.schemaName}].[${arg.entity.className}] WHERE ECInstanceId=?`, (stmt) => {\n stmt.bindId(1, arg.entity.id);\n const matchesResult = stmt.step();\n if (matchesResult === DbResult.BE_SQLITE_ROW)\n return true;\n if (matchesResult === DbResult.BE_SQLITE_DONE)\n return false;\n else\n throw new IModelError(matchesResult, \"query failed\");\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"EntityUnifier.js","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;;;GAIG;;;AAEH,iCAAiC;AACjC,oDAK4B;AAC5B,sDAQ6B;AAC7B,sDAA2C;AAE3C,gBAAgB;AAChB,IAAiB,aAAa,CAqD7B;AArDD,WAAiB,aAAa;IAC5B,SAAgB,eAAe,CAAC,MAAsB;QACpD,IAAI,MAAM,YAAY,sBAAO;YAAE,OAAO,SAAS,CAAC;aAC3C,IAAI,MAAM,YAAY,4BAAa;YAAE,OAAO,gBAAgB,CAAC;aAC7D,IAAI,MAAM,YAAY,2BAAY;YAAE,OAAO,cAAc,CAAC;;YAC1D,OAAO,qBAAqB,CAAC;IACpC,CAAC;IALe,6BAAe,kBAK9B,CAAA;IAID,2GAA2G;IAC3G,SAAgB,UAAU,CAAC,EAAY,EAAE,MAAsB;QAC7D,IAAI,MAAM,YAAY,sBAAO;YAC3B,OAAO,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAkB,CAAC;aACjE,IAAI,MAAM,YAAY,2BAAY;YACrC,OAAO,EAAE,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CACzC,EAAE,CAAC,aAAa,CACA,CAAC;aAChB,IAAI,MAAM,YAAY,4BAAa;YACtC,OAAO,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAkB,CAAC;;YAEnE,MAAM,CACJ,KAAK,EACL,4BAA4B,MAAM,CAAC,WAAW,CAAC,IAAI,kDAAkD,CACtG,CAAC;IACN,CAAC;IAde,wBAAU,aAczB,CAAA;IAED,SAAgB,MAAM,CACpB,EAAY,EACZ,GAAsE;QAEtE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,GACd,iBAAiB,IAAI,GAAG;YACtB,CAAC,CAAC,+BAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC;YAC7C,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjC,MAAM,aAAa,GACjB,iBAAiB,IAAI,GAAG;YACtB,CAAC,CAAC,iCAAmB,CAAC,0BAA0B,CAAC,IAAK,CAAC;YACvD,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC;QAE7D,IAAI,EAAE,KAAK,SAAS,IAAI,mBAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC;QAEzD,OAAO,EAAE,CAAC,qBAAqB,CAC7B,iBAAiB,aAAa,uBAAuB,EACrD,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAClC,IAAI,aAAa,KAAK,sBAAQ,CAAC,aAAa;gBAAE,OAAO,IAAI,CAAC;YAC1D,IAAI,aAAa,KAAK,sBAAQ,CAAC,cAAc;gBAAE,OAAO,KAAK,CAAC;;gBACvD,MAAM,IAAI,yBAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAC5D,CAAC,CACF,CAAC;IACJ,CAAC;IAzBe,oBAAM,SAyBrB,CAAA;AACH,CAAC,EArDgB,aAAa,6BAAb,aAAa,QAqD7B","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/** @packageDocumentation\n * @module Utils\n * utilities that unify operations, especially CRUD operations, on entities\n * for entity-generic operations in the transformer\n */\n\nimport * as assert from \"assert\";\nimport {\n ConcreteEntityTypes,\n DbResult,\n EntityReference,\n IModelError,\n} from \"@itwin/core-common\";\nimport {\n ConcreteEntity,\n ConcreteEntityProps,\n Element,\n ElementAspect,\n EntityReferences,\n IModelDb,\n Relationship,\n} from \"@itwin/core-backend\";\nimport { Id64 } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport namespace EntityUnifier {\n export function getReadableType(entity: ConcreteEntity) {\n if (entity instanceof Element) return \"element\";\n else if (entity instanceof ElementAspect) return \"element aspect\";\n else if (entity instanceof Relationship) return \"relationship\";\n else return \"unknown entity type\";\n }\n\n type EntityUpdater = (entityProps: ConcreteEntityProps) => void;\n\n /** needs to return a widened type otherwise typescript complains when result is used with a narrow type */\n export function updaterFor(db: IModelDb, entity: ConcreteEntity) {\n if (entity instanceof Element)\n return db.elements.updateElement.bind(db.elements) as EntityUpdater;\n else if (entity instanceof Relationship)\n return db.relationships.updateInstance.bind(\n db.relationships\n ) as EntityUpdater;\n else if (entity instanceof ElementAspect)\n return db.elements.updateAspect.bind(db.elements) as EntityUpdater;\n else\n assert(\n false,\n `unreachable; entity was '${entity.constructor.name}' not an Element, Relationship, or ElementAspect`\n );\n }\n\n export function exists(\n db: IModelDb,\n arg: { entity: ConcreteEntity } | { entityReference: EntityReference }\n ) {\n const [type, id] =\n \"entityReference\" in arg\n ? EntityReferences.split(arg.entityReference)\n : [undefined, arg.entity.id];\n const classFullName =\n \"entityReference\" in arg\n ? ConcreteEntityTypes.toBisCoreRootClassFullName(type!)\n : `[${arg.entity.schemaName}].[${arg.entity.className}]`;\n\n if (id === undefined || Id64.isInvalid(id)) return false;\n\n return db.withPreparedStatement(\n `SELECT 1 FROM ${classFullName} WHERE ECInstanceId=?`,\n (stmt) => {\n stmt.bindId(1, id);\n const matchesResult = stmt.step();\n if (matchesResult === DbResult.BE_SQLITE_ROW) return true;\n if (matchesResult === DbResult.BE_SQLITE_DONE) return false;\n else throw new IModelError(matchesResult, \"query failed\");\n }\n );\n }\n}\n"]}
@@ -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AAE,kBAAkB;IAInD,gCAAgC,CACrC,mCAAmC,EAAE,MAAM,EAAE,GAC5C,IAAI;IAWA,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;CAM9D"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ExportElementAspectsStrategy = void 0;
8
8
  const core_bentley_1 = require("@itwin/core-bentley");
@@ -23,7 +23,8 @@ class ExportElementAspectsStrategy {
23
23
  this.handler = handler;
24
24
  }
25
25
  shouldExportElementAspect(aspect) {
26
- for (const excludedElementAspectClass of this._excludedElementAspectClasses) {
26
+ for (const excludedElementAspectClass of this
27
+ ._excludedElementAspectClasses) {
27
28
  if (aspect instanceof excludedElementAspectClass) {
28
29
  core_bentley_1.Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);
29
30
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"ExportElementAspectsStrategy.js","sourceRoot":"","sources":["../../src/ExportElementAspectsStrategy.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,sDAAyD;AACzD,2EAAwE;AAGxE,MAAM,cAAc,GAAG,qDAAyB,CAAC,cAAc,CAAC;AAahE;;;;GAIG;AACH,MAAsB,4BAA4B;IAYhD,YAAmB,QAAkB,EAAE,OAA8B;QAXrE,6HAA6H;QACnH,kCAA6B,GAAG,IAAI,GAAG,EAAwB,CAAC;QAC1E,mHAAmH;QACnG,wCAAmC,GAAG,IAAI,GAAG,EAAU,CAAC;QAStE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAKS,yBAAyB,CAAC,MAAqB;QACvD,KAAK,MAAM,0BAA0B,IAAI,IAAI,CAAC,6BAA6B,EAAE;YAC3E,IAAI,MAAM,YAAY,0BAA0B,EAAE;gBAChD,qBAAM,CAAC,OAAO,CAAC,cAAc,EAAE,oCAAoC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;gBAC3F,OAAO,KAAK,CAAC;aACd;SACF;QACD,gGAAgG;QAChG,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAEM,gBAAgB,CAAC,aAAkC;QACxD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEM,gCAAgC,CAAC,mCAA6C;QAClF,IAAI,CAAC,mCAA2C,GAAG,IAAI,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjG,IAAI,CAAC,6BAA6B,GAAG,IAAI,GAAG,CAAC,mCAAmC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5H,CAAC;IAEM,yBAAyB,CAAC,aAAqB;QACpD,IAAI,CAAC,mCAAmC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,gDAAgD;QAC7G,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAuB,aAAa,CAAC,CAAC,CAAC,CAAC,gDAAgD;IACzJ,CAAC;CACF;AA5CD,oEA4CC","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 { ElementAspect, ElementMultiAspect, ElementUniqueAspect, IModelDb } from \"@itwin/core-backend\";\nimport { Id64String, Logger } from \"@itwin/core-bentley\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\nimport { ChangedInstanceOps } from \"./IModelExporter\";\n\nconst loggerCategory = TransformerLoggerCategory.IModelExporter;\n\n/**\n * Handler for [[ExportElementAspectsStrategy]]\n * @internal\n */\nexport interface ElementAspectsHandler {\n shouldExportElementAspect(aspect: ElementAspect): boolean;\n onExportElementUniqueAspect(uniqueAspect: ElementUniqueAspect, isUpdate?: boolean | undefined): void;\n onExportElementMultiAspects(multiAspects: ElementMultiAspect[]): void;\n trackProgress: () => Promise<void>;\n}\n\n/**\n * Base ElementAspect export strategy. Base export strategy includes state saving and loading and\n * ElementAspect filtering.\n * @internal\n */\nexport abstract class ExportElementAspectsStrategy {\n /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */\n protected _excludedElementAspectClasses = new Set<typeof ElementAspect>();\n /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */\n public readonly excludedElementAspectClassFullNames = new Set<string>();\n\n protected sourceDb: IModelDb;\n\n protected aspectChanges: ChangedInstanceOps | undefined;\n\n protected handler: ElementAspectsHandler;\n\n public constructor(sourceDb: IModelDb, handler: ElementAspectsHandler) {\n this.sourceDb = sourceDb;\n this.handler = handler;\n }\n\n public abstract exportElementAspectsForElement(_elementId: Id64String): Promise<void>;\n public abstract exportAllElementAspects(): Promise<void>;\n\n protected shouldExportElementAspect(aspect: ElementAspect): boolean {\n for (const excludedElementAspectClass of this._excludedElementAspectClasses) {\n if (aspect instanceof excludedElementAspectClass) {\n Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);\n return false;\n }\n }\n // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject\n return this.handler.shouldExportElementAspect(aspect);\n }\n\n public setAspectChanges(aspectChanges?: ChangedInstanceOps) {\n this.aspectChanges = aspectChanges;\n }\n\n public loadExcludedElementAspectClasses(excludedElementAspectClassFullNames: string[]): void {\n (this.excludedElementAspectClassFullNames as any) = new Set(excludedElementAspectClassFullNames);\n this._excludedElementAspectClasses = new Set(excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));\n }\n\n public excludeElementAspectClass(classFullName: string): void {\n this.excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query\n this._excludedElementAspectClasses.add(this.sourceDb.getJsClass<typeof ElementAspect>(classFullName)); // allows polymorphic exclusion after query/load\n }\n}\n"]}
1
+ {"version":3,"file":"ExportElementAspectsStrategy.js","sourceRoot":"","sources":["../../src/ExportElementAspectsStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAQhG,sDAAyD;AACzD,2EAAwE;AAGxE,MAAM,cAAc,GAAG,qDAAyB,CAAC,cAAc,CAAC;AAgBhE;;;;GAIG;AACH,MAAsB,4BAA4B;IAYhD,YAAmB,QAAkB,EAAE,OAA8B;QAXrE,6HAA6H;QACnH,kCAA6B,GAAG,IAAI,GAAG,EAAwB,CAAC;QAC1E,mHAAmH;QACnG,wCAAmC,GAAG,IAAI,GAAG,EAAU,CAAC;QAStE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAOS,yBAAyB,CAAC,MAAqB;QACvD,KAAK,MAAM,0BAA0B,IAAI,IAAI;aAC1C,6BAA6B,EAAE;YAChC,IAAI,MAAM,YAAY,0BAA0B,EAAE;gBAChD,qBAAM,CAAC,OAAO,CACZ,cAAc,EACd,oCAAoC,MAAM,CAAC,aAAa,EAAE,CAC3D,CAAC;gBACF,OAAO,KAAK,CAAC;aACd;SACF;QACD,gGAAgG;QAChG,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAEM,gBAAgB,CAAC,aAAkC;QACxD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEM,gCAAgC,CACrC,mCAA6C;QAE5C,IAAI,CAAC,mCAA2C,GAAG,IAAI,GAAG,CACzD,mCAAmC,CACpC,CAAC;QACF,IAAI,CAAC,6BAA6B,GAAG,IAAI,GAAG,CAC1C,mCAAmC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAC5B,CACF,CAAC;IACJ,CAAC;IAEM,yBAAyB,CAAC,aAAqB;QACpD,IAAI,CAAC,mCAAmC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,gDAAgD;QAC7G,IAAI,CAAC,6BAA6B,CAAC,GAAG,CACpC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAuB,aAAa,CAAC,CAC9D,CAAC,CAAC,gDAAgD;IACrD,CAAC;CACF;AA5DD,oEA4DC","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 ElementAspect,\n ElementMultiAspect,\n ElementUniqueAspect,\n IModelDb,\n} from \"@itwin/core-backend\";\nimport { Id64String, Logger } from \"@itwin/core-bentley\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\nimport { ChangedInstanceOps } from \"./IModelExporter\";\n\nconst loggerCategory = TransformerLoggerCategory.IModelExporter;\n\n/**\n * Handler for [[ExportElementAspectsStrategy]]\n * @internal\n */\nexport interface ElementAspectsHandler {\n shouldExportElementAspect(aspect: ElementAspect): boolean;\n onExportElementUniqueAspect(\n uniqueAspect: ElementUniqueAspect,\n isUpdate?: boolean | undefined\n ): void;\n onExportElementMultiAspects(multiAspects: ElementMultiAspect[]): void;\n trackProgress: () => Promise<void>;\n}\n\n/**\n * Base ElementAspect export strategy. Base export strategy includes state saving and loading and\n * ElementAspect filtering.\n * @internal\n */\nexport abstract class ExportElementAspectsStrategy {\n /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */\n protected _excludedElementAspectClasses = new Set<typeof ElementAspect>();\n /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */\n public readonly excludedElementAspectClassFullNames = new Set<string>();\n\n protected sourceDb: IModelDb;\n\n protected aspectChanges: ChangedInstanceOps | undefined;\n\n protected handler: ElementAspectsHandler;\n\n public constructor(sourceDb: IModelDb, handler: ElementAspectsHandler) {\n this.sourceDb = sourceDb;\n this.handler = handler;\n }\n\n public abstract exportElementAspectsForElement(\n _elementId: Id64String\n ): Promise<void>;\n public abstract exportAllElementAspects(): Promise<void>;\n\n protected shouldExportElementAspect(aspect: ElementAspect): boolean {\n for (const excludedElementAspectClass of this\n ._excludedElementAspectClasses) {\n if (aspect instanceof excludedElementAspectClass) {\n Logger.logInfo(\n loggerCategory,\n `Excluded ElementAspect by class: ${aspect.classFullName}`\n );\n return false;\n }\n }\n // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject\n return this.handler.shouldExportElementAspect(aspect);\n }\n\n public setAspectChanges(aspectChanges?: ChangedInstanceOps) {\n this.aspectChanges = aspectChanges;\n }\n\n public loadExcludedElementAspectClasses(\n excludedElementAspectClassFullNames: string[]\n ): void {\n (this.excludedElementAspectClassFullNames as any) = new Set(\n excludedElementAspectClassFullNames\n );\n this._excludedElementAspectClasses = new Set(\n excludedElementAspectClassFullNames.map((c) =>\n this.sourceDb.getJsClass(c)\n )\n );\n }\n\n public excludeElementAspectClass(classFullName: string): void {\n this.excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query\n this._excludedElementAspectClasses.add(\n this.sourceDb.getJsClass<typeof ElementAspect>(classFullName)\n ); // allows polymorphic exclusion after query/load\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExportElementAspectsWithElementsStrategy.d.ts","sourceRoot":"","sources":["../../src/ExportElementAspectsWithElementsStrategy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E;;;;GAIG;AACH,qBAAa,wCAAyC,SAAQ,4BAA4B;IAClE,8BAA8B,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBpE,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/D"}
1
+ {"version":3,"file":"ExportElementAspectsWithElementsStrategy.d.ts","sourceRoot":"","sources":["../../src/ExportElementAspectsWithElementsStrategy.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E;;;;GAIG;AACH,qBAAa,wCAAyC,SAAQ,4BAA4B;IAClE,8BAA8B,CAClD,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC,IAAI,CAAC;IA6CM,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/D"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ExportElementAspectsWithElementsStrategy = void 0;
8
8
  const core_backend_1 = require("@itwin/core-backend");
@@ -20,9 +20,13 @@ class ExportElementAspectsWithElementsStrategy extends ExportElementAspectsStrat
20
20
  .map(async (uniqueAspect) => {
21
21
  const isInsertChange = this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;
22
22
  const isUpdateChange = this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;
23
- const doExport = this.aspectChanges === undefined || isInsertChange || isUpdateChange;
23
+ const doExport = this.aspectChanges === undefined ||
24
+ isInsertChange ||
25
+ isUpdateChange;
24
26
  if (doExport) {
25
- const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;
27
+ const isKnownUpdate = this.aspectChanges
28
+ ? isUpdateChange
29
+ : undefined;
26
30
  this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);
27
31
  await this.handler.trackProgress();
28
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExportElementAspectsWithElementsStrategy.js","sourceRoot":"","sources":["../../src/ExportElementAspectsWithElementsStrategy.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAA8E;AAE9E,iFAA8E;AAE9E;;;;GAIG;AACH,MAAa,wCAAyC,SAAQ,2DAA4B;IACxE,KAAK,CAAC,8BAA8B,CAAC,SAAqB;QACxE,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ;aAC5D,aAAa,CAAC,SAAS,EAAE,kCAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,mCAAmC,CAAC;aACrG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;aAChD,GAAG,CAAC,KAAK,EAAE,YAAiC,EAAE,EAAE;YAC/C,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YACnF,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YACnF,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,cAAc,IAAI,cAAc,CAAC;YACtF,IAAI,QAAQ,EAAE;gBACZ,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;gBACtE,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;gBACtE,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;aACpC;QACH,CAAC,CAAC,CAAC,CAAC;QAEN,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ;aACxC,aAAa,CAAC,SAAS,EAAE,iCAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,mCAAmC,CAAC;aACpG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;SACrC;IACH,CAAC;IAEe,KAAK,CAAC,uBAAuB;QAC3C,gGAAgG;IAClG,CAAC;CACF;AA7BD,4FA6BC","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 { ElementMultiAspect, ElementUniqueAspect } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ExportElementAspectsStrategy } from \"./ExportElementAspectsStrategy\";\n\n/**\n * ElementAspect export strategy for [[IModelExporter]].\n * This strategy exports ElementAspects together with their Elements.\n * @internal\n */\nexport class ExportElementAspectsWithElementsStrategy extends ExportElementAspectsStrategy {\n public override async exportElementAspectsForElement(elementId: Id64String): Promise<void> {\n const _uniqueAspects = await Promise.all(this.sourceDb.elements\n ._queryAspects(elementId, ElementUniqueAspect.classFullName, this.excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a))\n .map(async (uniqueAspect: ElementUniqueAspect) => {\n const isInsertChange = this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange = this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;\n const doExport = this.aspectChanges === undefined || isInsertChange || isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this.aspectChanges ? isUpdateChange : undefined;\n this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);\n await this.handler.trackProgress();\n }\n }));\n\n const multiAspects = this.sourceDb.elements\n ._queryAspects(elementId, ElementMultiAspect.classFullName, this.excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a));\n\n if (multiAspects.length > 0) {\n this.handler.onExportElementMultiAspects(multiAspects);\n return this.handler.trackProgress();\n }\n }\n\n public override async exportAllElementAspects(): Promise<void> {\n // All aspects are exported with their owning elements and don't need to be exported separately.\n }\n}\n"]}
1
+ {"version":3,"file":"ExportElementAspectsWithElementsStrategy.js","sourceRoot":"","sources":["../../src/ExportElementAspectsWithElementsStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAA8E;AAE9E,iFAA8E;AAE9E;;;;GAIG;AACH,MAAa,wCAAyC,SAAQ,2DAA4B;IACxE,KAAK,CAAC,8BAA8B,CAClD,SAAqB;QAErB,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACtC,IAAI,CAAC,QAAQ,CAAC,QAAQ;aACnB,aAAa,CACZ,SAAS,EACT,kCAAmB,CAAC,aAAa,EACjC,IAAI,CAAC,mCAAmC,CACzC;aACA,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;aAChD,GAAG,CAAC,KAAK,EAAE,YAAiC,EAAE,EAAE;YAC/C,MAAM,cAAc,GAClB,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YAC9D,MAAM,cAAc,GAClB,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;YAC9D,MAAM,QAAQ,GACZ,IAAI,CAAC,aAAa,KAAK,SAAS;gBAChC,cAAc;gBACd,cAAc,CAAC;YACjB,IAAI,QAAQ,EAAE;gBACZ,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa;oBACtC,CAAC,CAAC,cAAc;oBAChB,CAAC,CAAC,SAAS,CAAC;gBACd,IAAI,CAAC,OAAO,CAAC,2BAA2B,CACtC,YAAY,EACZ,aAAa,CACd,CAAC;gBACF,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;aACpC;QACH,CAAC,CAAC,CACL,CAAC;QAEF,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ;aACxC,aAAa,CACZ,SAAS,EACT,iCAAkB,CAAC,aAAa,EAChC,IAAI,CAAC,mCAAmC,CACzC;aACA,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;SACrC;IACH,CAAC;IAEe,KAAK,CAAC,uBAAuB;QAC3C,gGAAgG;IAClG,CAAC;CACF;AAnDD,4FAmDC","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 { ElementMultiAspect, ElementUniqueAspect } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ExportElementAspectsStrategy } from \"./ExportElementAspectsStrategy\";\n\n/**\n * ElementAspect export strategy for [[IModelExporter]].\n * This strategy exports ElementAspects together with their Elements.\n * @internal\n */\nexport class ExportElementAspectsWithElementsStrategy extends ExportElementAspectsStrategy {\n public override async exportElementAspectsForElement(\n elementId: Id64String\n ): Promise<void> {\n const _uniqueAspects = await Promise.all(\n this.sourceDb.elements\n ._queryAspects(\n elementId,\n ElementUniqueAspect.classFullName,\n this.excludedElementAspectClassFullNames\n )\n .filter((a) => this.shouldExportElementAspect(a))\n .map(async (uniqueAspect: ElementUniqueAspect) => {\n const isInsertChange =\n this.aspectChanges?.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange =\n this.aspectChanges?.updateIds.has(uniqueAspect.id) ?? false;\n const doExport =\n this.aspectChanges === undefined ||\n isInsertChange ||\n isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this.aspectChanges\n ? isUpdateChange\n : undefined;\n this.handler.onExportElementUniqueAspect(\n uniqueAspect,\n isKnownUpdate\n );\n await this.handler.trackProgress();\n }\n })\n );\n\n const multiAspects = this.sourceDb.elements\n ._queryAspects(\n elementId,\n ElementMultiAspect.classFullName,\n this.excludedElementAspectClassFullNames\n )\n .filter((a) => this.shouldExportElementAspect(a));\n\n if (multiAspects.length > 0) {\n this.handler.onExportElementMultiAspects(multiAspects);\n return this.handler.trackProgress();\n }\n }\n\n public override async exportAllElementAspects(): Promise<void> {\n // All aspects are exported with their owning elements and don't need to be exported separately.\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IModelCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkB,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAGgB,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAEvE,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,OAAO,EAAE,aAAa,EAAoB,yBAAyB,EAAE,cAAc,EAAE,QAAQ,EAC9F,MAAM,qBAA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