@itwin/imodel-transformer 2.0.0-dev.47 → 2.0.0-dev.48

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 (48) hide show
  1. package/lib/cjs/Algo.js.map +1 -1
  2. package/lib/cjs/BigMap.d.ts.map +1 -1
  3. package/lib/cjs/BigMap.js.map +1 -1
  4. package/lib/cjs/BranchProvenanceInitializer.js.map +1 -1
  5. package/lib/cjs/ChangesetScanner.d.ts.map +1 -1
  6. package/lib/cjs/ChangesetScanner.js.map +1 -1
  7. package/lib/cjs/ECReferenceTypesCache.d.ts.map +1 -1
  8. package/lib/cjs/ECReferenceTypesCache.js.map +1 -1
  9. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.d.ts.map +1 -1
  10. package/lib/cjs/ECSqlReaderAsyncIterableIteratorAdapter.js.map +1 -1
  11. package/lib/cjs/ElementAspectCleanup.d.ts.map +1 -1
  12. package/lib/cjs/ElementAspectCleanup.js.map +1 -1
  13. package/lib/cjs/ElementAspectExportCoordinator.d.ts.map +1 -1
  14. package/lib/cjs/ElementAspectExportCoordinator.js.map +1 -1
  15. package/lib/cjs/ElementAspectExportProcessor.d.ts.map +1 -1
  16. package/lib/cjs/ElementAspectExportProcessor.js.map +1 -1
  17. package/lib/cjs/ElementCascadingDeleter.d.ts.map +1 -1
  18. package/lib/cjs/ElementCascadingDeleter.js.map +1 -1
  19. package/lib/cjs/EntityMap.d.ts.map +1 -1
  20. package/lib/cjs/EntityMap.js.map +1 -1
  21. package/lib/cjs/EntityUnifier.js.map +1 -1
  22. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  23. package/lib/cjs/IModelCloneContext.js.map +1 -1
  24. package/lib/cjs/IModelExporter.d.ts.map +1 -1
  25. package/lib/cjs/IModelExporter.js.map +1 -1
  26. package/lib/cjs/IModelImporter.d.ts.map +1 -1
  27. package/lib/cjs/IModelImporter.js.map +1 -1
  28. package/lib/cjs/IModelTransformer.d.ts.map +1 -1
  29. package/lib/cjs/IModelTransformer.js +37 -4
  30. package/lib/cjs/IModelTransformer.js.map +1 -1
  31. package/lib/cjs/IModelTransformerError.js.map +1 -1
  32. package/lib/cjs/ProvenanceManager.d.ts.map +1 -1
  33. package/lib/cjs/ProvenanceManager.js.map +1 -1
  34. package/lib/cjs/SyncTypeResolver.d.ts.map +1 -1
  35. package/lib/cjs/SyncTypeResolver.js.map +1 -1
  36. package/lib/cjs/TransformerLoggerCategory.js.map +1 -1
  37. package/lib/cjs/TransformerPackageMetadata.js +34 -1
  38. package/lib/cjs/TransformerPackageMetadata.js.map +1 -1
  39. package/lib/cjs/imodel-transformer.js +23 -1
  40. package/lib/cjs/imodel-transformer.js.map +1 -1
  41. package/lib/cjs/schema-processing/DynamicSchemaUnionStrategy.d.ts.map +1 -1
  42. package/lib/cjs/schema-processing/DynamicSchemaUnionStrategy.js.map +1 -1
  43. package/lib/cjs/schema-processing/SchemaProcessingCoordinator.d.ts.map +1 -1
  44. package/lib/cjs/schema-processing/SchemaProcessingCoordinator.js +35 -2
  45. package/lib/cjs/schema-processing/SchemaProcessingCoordinator.js.map +1 -1
  46. package/lib/cjs/schema-processing/SchemaProcessingStrategy.d.ts.map +1 -1
  47. package/lib/cjs/schema-processing/SchemaProcessingStrategy.js.map +1 -1
  48. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicSchemaUnionStrategy.js","sourceRoot":"","sources":["../../../src/schema-processing/DynamicSchemaUnionStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAiD;AACjD,8DAOiC;AACjC,gEAKkC;AAClC,sEAGmC;AA4BnC;;;;;GAKG;AACH,MAAa,0BAA0B;IACrC;;;;;;;;;OASG;IACO,KAAK,CAAC,mBAAmB,CACjC,aAAqB,EACrB,aAAqB,EACrB,WAAmC;QAEnC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,+EAA+E;IACxE,KAAK,CAAC,cAA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,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,uBAAuB,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAc,EACd,UAAwC;IAExC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,uBAAuB,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;AACH,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/** @packageDocumentation\n * @module iModels\n */\n\nimport { ITwinError } from \"@itwin/core-bentley\";\nimport {\n AnySchemaDifferenceConflict,\n ConflictCode,\n getSchemaDifferences,\n SchemaConflictsError,\n SchemaDifferenceResult,\n SchemaMerger,\n} from \"@itwin/ecschema-editing\";\nimport {\n ECVersion,\n Schema,\n SchemaContext,\n SchemaKey,\n} from \"@itwin/ecschema-metadata\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"../IModelTransformerError\";\nimport {\n ReadonlySchemaAccessor,\n SchemaProcessingContext,\n SchemaProcessingResult,\n SchemaProcessingStrategy,\n} from \"./SchemaProcessingStrategy\";\n\ntype SchemaPlan =\n | { kind: \"new\"; source: Schema }\n | { kind: \"ordinary\"; source: Schema; target: Schema }\n | { kind: \"dynamic-noop\"; source: Schema; target: Schema }\n | {\n kind: \"dynamic-merge\";\n source: Schema;\n target: Schema;\n differences: SchemaDifferenceResult;\n };\n\ninterface SchemaCandidate {\n schema: Schema;\n isTargetRoot: boolean;\n}\n\ninterface SchemaConflictError extends ITwinError {\n schemaKey: string;\n}\n\n/**\n * Processes ordinary schemas with newer-version selection and unions compatible\n * differences for existing dynamic schemas. Dynamic schema root read and write\n * versions must match; only the minor version may differ.\n * @beta\n */\nexport class DynamicSchemaUnionStrategy implements SchemaProcessingStrategy {\n /**\n * Transform schema differences before conflict validation and merging.\n * A subclass that changes the differencing result is responsible for ensuring\n * that its changes are safe for the source and target schemas.\n * @param sourceSchema The source schema being processed.\n * @param targetSchema The existing target schema.\n * @param differences The complete result from [[getSchemaDifferences]].\n * @returns The differencing result to validate and merge.\n * @beta\n */\n protected async onSchemaDifferences(\n _sourceSchema: Schema,\n _targetSchema: Schema,\n differences: SchemaDifferenceResult\n ): Promise<SchemaDifferenceResult> {\n return differences;\n }\n\n /** Select ordinary schemas and union compatible dynamic schema differences. */\n public async processSchemas(\n context: SchemaProcessingContext\n ): Promise<SchemaProcessingResult[]> {\n const plans: SchemaPlan[] = [];\n const conflicts: Error[] = [];\n for (const sourceSchema of context.sourceSchemas) {\n try {\n plans.push(await this.createPlan(sourceSchema, context.targetSchemas));\n } catch (error: unknown) {\n if (\n ITwinError.isError(\n error,\n IModelTransformerErrorScope,\n IModelTransformerError.SchemaConflict\n )\n ) {\n conflicts.push(error);\n continue;\n }\n throw error;\n }\n }\n throwSchemaConflicts(conflicts);\n\n const schemaEditingContext = new SchemaContext();\n const schemaCandidates = new Map<string, SchemaCandidate>();\n for (const plan of plans) {\n if (plan.kind === \"dynamic-merge\") {\n collectSchemaCandidates(plan.target, schemaCandidates, true);\n collectSchemaReferences(plan.source, schemaCandidates);\n } else if (plan.kind === \"dynamic-noop\") {\n collectSchemaCandidates(plan.source, schemaCandidates, false);\n collectSchemaReferences(plan.source, schemaCandidates);\n }\n }\n for (const { schema } of schemaCandidates.values()) {\n await schemaEditingContext.addSchema(schema);\n }\n\n const schemaMerger = new SchemaMerger(schemaEditingContext);\n const results: SchemaProcessingResult[] = [];\n for (const plan of plans) {\n switch (plan.kind) {\n case \"new\":\n if (\n plan.source.isDynamic ||\n (await context.shouldExportSchema(plan.source.schemaKey))\n ) {\n results.push({ kind: \"source\", schema: plan.source });\n }\n break;\n case \"ordinary\":\n if (await context.shouldExportSchema(plan.source.schemaKey)) {\n results.push({ kind: \"source\", schema: plan.source });\n }\n break;\n case \"dynamic-noop\":\n break;\n case \"dynamic-merge\": {\n const mergedSchema = await schemaMerger.merge({\n ...plan.differences,\n conflicts: undefined,\n });\n const sourceVersion = plan.source.schemaKey.version;\n mergedSchema.setVersion(\n sourceVersion.read,\n sourceVersion.write,\n incrementMinorVersion(sourceVersion, plan.target.schemaKey.version)\n );\n results.push({ kind: \"generated\", schema: mergedSchema });\n break;\n }\n }\n }\n\n appendRequiredNoOpSchemas(results, plans);\n return results;\n }\n\n private async createPlan(\n source: Schema,\n targetSchemas: ReadonlySchemaAccessor\n ): Promise<SchemaPlan> {\n const target = await targetSchemas.getSchema(source.name);\n if (target === undefined) return { kind: \"new\", source };\n\n if (source.isDynamic !== target.isDynamic) {\n throw createSchemaConflictError(\n source,\n \"Schema DynamicSchema marker changed\",\n new Error(\"The source and target DynamicSchema markers differ.\")\n );\n }\n if (!source.isDynamic) return { kind: \"ordinary\", source, target };\n\n const sourceVersion = source.schemaKey.version;\n const targetVersion = target.schemaKey.version;\n if (\n sourceVersion.read !== targetVersion.read ||\n sourceVersion.write !== targetVersion.write\n ) {\n throw createSchemaConflictError(\n source,\n \"Dynamic schema has incompatible root versions\",\n new Error(\n `source ${sourceVersion.toString(false)}, target ${targetVersion.toString(false)}`\n )\n );\n }\n\n const differences = await this.onSchemaDifferences(\n source,\n target,\n await getSchemaDifferences(target, source)\n );\n const unresolvedConflicts = (differences.conflicts ?? []).filter(\n (conflict) => !isCompatibleReferenceVersionConflict(conflict)\n );\n if (unresolvedConflicts.length > 0) {\n throw createSchemaConflictError(\n source,\n \"Schema conflict\",\n new SchemaConflictsError(\n `Schema '${source.name}' has unresolved conflicts`,\n unresolvedConflicts,\n source.schemaKey,\n target.schemaKey\n )\n );\n }\n\n return differences.differences.length === 0\n ? { kind: \"dynamic-noop\", source, target }\n : { kind: \"dynamic-merge\", source, target, differences };\n }\n}\n\nfunction createSchemaConflictError(\n schema: Schema,\n operation: string,\n cause: Error\n): Error {\n return ITwinError.create<SchemaConflictError>({\n message: `${operation} for '${schema.schemaKey.toString(false)}': ${cause.message}`,\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.SchemaConflict,\n },\n cause,\n schemaKey: schema.schemaKey.toString(false),\n });\n}\n\nfunction throwSchemaConflicts(conflicts: Error[]): void {\n if (conflicts.length === 1) throw conflicts[0];\n if (conflicts.length > 1)\n throw new AggregateError(conflicts, \"Schema processing failed\");\n}\n\nfunction appendRequiredNoOpSchemas(\n results: SchemaProcessingResult[],\n plans: SchemaPlan[]\n): void {\n const noOpSchemas = new Map(\n plans\n .filter((plan) => plan.kind === \"dynamic-noop\")\n .map((plan) => [plan.source.name.toLowerCase(), plan.source])\n );\n const requiredNoOpSchemas = new Set<string>();\n const schemasToVisit = results.map((result) => result.schema);\n for (const schema of schemasToVisit) {\n for (const reference of schema.references) {\n const schemaName = reference.name.toLowerCase();\n const noOpSchema = noOpSchemas.get(schemaName);\n if (noOpSchema === undefined || requiredNoOpSchemas.has(schemaName))\n continue;\n\n requiredNoOpSchemas.add(schemaName);\n schemasToVisit.push(noOpSchema);\n }\n }\n for (const schemaName of requiredNoOpSchemas) {\n const schema = noOpSchemas.get(schemaName);\n if (schema !== undefined) results.push({ kind: \"source\", schema });\n }\n}\n\nfunction incrementMinorVersion(\n sourceVersion: ECVersion,\n targetVersion: ECVersion\n): number {\n const maximumVersion =\n sourceVersion.compare(targetVersion) >= 0 ? sourceVersion : targetVersion;\n if (maximumVersion.minor >= 9_999_999) {\n throw new Error(\n `Cannot increment schema version ${maximumVersion.toString(false)}`\n );\n }\n return maximumVersion.minor + 1;\n}\n\nfunction isCompatibleReferenceVersionConflict(\n conflict: AnySchemaDifferenceConflict\n): boolean {\n if (conflict.code !== ConflictCode.ConflictingReferenceVersion) return false;\n if (\n typeof conflict.source !== \"string\" ||\n typeof conflict.target !== \"string\"\n )\n return false;\n\n const sourceVersion = SchemaKey.parseString(conflict.source).version;\n const targetVersion = SchemaKey.parseString(conflict.target).version;\n return (\n sourceVersion.read === targetVersion.read &&\n sourceVersion.write === targetVersion.write\n );\n}\n\nfunction collectSchemaCandidates(\n schema: Schema,\n candidates: Map<string, SchemaCandidate>,\n isTargetRoot: boolean,\n visited: Set<string> = new Set<string>()\n): void {\n const traversalKey = schema.schemaKey.toString();\n if (visited.has(traversalKey)) return;\n visited.add(traversalKey);\n\n const schemaName = schema.name.toLowerCase();\n const existing = candidates.get(schemaName);\n if (existing === undefined) {\n candidates.set(schemaName, { schema, isTargetRoot });\n } else if (\n existing.schema.schemaKey.version.read !== schema.schemaKey.version.read ||\n existing.schema.schemaKey.version.write !== schema.schemaKey.version.write\n ) {\n throw createSchemaConflictError(\n schema,\n \"Schema reference has incompatible read/write versions\",\n new Error(\n `${existing.schema.schemaKey.version.read}.${existing.schema.schemaKey.version.write} ` +\n `and ${schema.schemaKey.version.read}.${schema.schemaKey.version.write} differ. ` +\n \"Only minor-version reference differences are supported.\"\n )\n );\n } else if (\n isTargetRoot ||\n (!existing.isTargetRoot &&\n schema.schemaKey.version.compare(existing.schema.schemaKey.version) > 0)\n ) {\n candidates.set(schemaName, { schema, isTargetRoot });\n }\n\n for (const reference of schema.references) {\n collectSchemaCandidates(reference, candidates, false, visited);\n }\n}\n\nfunction collectSchemaReferences(\n schema: Schema,\n candidates: Map<string, SchemaCandidate>\n): void {\n for (const reference of schema.references) {\n collectSchemaCandidates(reference, candidates, false);\n }\n}\n"]}
1
+ {"version":3,"file":"DynamicSchemaUnionStrategy.js","sourceRoot":"","sources":["../../../src/schema-processing/DynamicSchemaUnionStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAiD;AACjD,8DAOiC;AACjC,gEAKkC;AAClC,sEAGmC;AA4BnC;;;;;GAKG;AACH;IACE;;;;;;;;;OASG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AQ,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAC1E,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,uBAAuB,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAc,EACd,UAAwC;IAExC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,uBAAuB,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;AACH,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/** @packageDocumentation\n * @module iModels\n */\n\nimport { ITwinError } from \"@itwin/core-bentley\";\nimport {\n AnySchemaDifferenceConflict,\n ConflictCode,\n getSchemaDifferences,\n SchemaConflictsError,\n SchemaDifferenceResult,\n SchemaMerger,\n} from \"@itwin/ecschema-editing\";\nimport {\n ECVersion,\n Schema,\n SchemaContext,\n SchemaKey,\n} from \"@itwin/ecschema-metadata\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"../IModelTransformerError\";\nimport {\n ReadonlySchemaAccessor,\n SchemaProcessingContext,\n SchemaProcessingResult,\n SchemaProcessingStrategy,\n} from \"./SchemaProcessingStrategy\";\n\ntype SchemaPlan =\n | { kind: \"new\"; source: Schema }\n | { kind: \"ordinary\"; source: Schema; target: Schema }\n | { kind: \"dynamic-noop\"; source: Schema; target: Schema }\n | {\n kind: \"dynamic-merge\";\n source: Schema;\n target: Schema;\n differences: SchemaDifferenceResult;\n };\n\ninterface SchemaCandidate {\n schema: Schema;\n isTargetRoot: boolean;\n}\n\ninterface SchemaConflictError extends ITwinError {\n schemaKey: string;\n}\n\n/**\n * Processes ordinary schemas with newer-version selection and unions compatible\n * differences for existing dynamic schemas. Dynamic schema root read and write\n * versions must match; only the minor version may differ.\n * @beta\n */\nexport class DynamicSchemaUnionStrategy implements SchemaProcessingStrategy {\n /**\n * Transform schema differences before conflict validation and merging.\n * A subclass that changes the differencing result is responsible for ensuring\n * that its changes are safe for the source and target schemas.\n * @param sourceSchema The source schema being processed.\n * @param targetSchema The existing target schema.\n * @param differences The complete result from [[getSchemaDifferences]].\n * @returns The differencing result to validate and merge.\n * @beta\n */\n protected async onSchemaDifferences(\n _sourceSchema: Schema,\n _targetSchema: Schema,\n differences: SchemaDifferenceResult\n ): Promise<SchemaDifferenceResult> {\n return differences;\n }\n\n /** Select ordinary schemas and union compatible dynamic schema differences. */\n public async processSchemas(\n context: SchemaProcessingContext\n ): Promise<SchemaProcessingResult[]> {\n const plans: SchemaPlan[] = [];\n const conflicts: Error[] = [];\n for (const sourceSchema of context.sourceSchemas) {\n try {\n plans.push(await this.createPlan(sourceSchema, context.targetSchemas));\n } catch (error: unknown) {\n if (\n ITwinError.isError(\n error,\n IModelTransformerErrorScope,\n IModelTransformerError.SchemaConflict\n )\n ) {\n conflicts.push(error);\n continue;\n }\n throw error;\n }\n }\n throwSchemaConflicts(conflicts);\n\n const schemaEditingContext = new SchemaContext();\n const schemaCandidates = new Map<string, SchemaCandidate>();\n for (const plan of plans) {\n if (plan.kind === \"dynamic-merge\") {\n collectSchemaCandidates(plan.target, schemaCandidates, true);\n collectSchemaReferences(plan.source, schemaCandidates);\n } else if (plan.kind === \"dynamic-noop\") {\n collectSchemaCandidates(plan.source, schemaCandidates, false);\n collectSchemaReferences(plan.source, schemaCandidates);\n }\n }\n for (const { schema } of schemaCandidates.values()) {\n await schemaEditingContext.addSchema(schema);\n }\n\n const schemaMerger = new SchemaMerger(schemaEditingContext);\n const results: SchemaProcessingResult[] = [];\n for (const plan of plans) {\n switch (plan.kind) {\n case \"new\":\n if (\n plan.source.isDynamic ||\n (await context.shouldExportSchema(plan.source.schemaKey))\n ) {\n results.push({ kind: \"source\", schema: plan.source });\n }\n break;\n case \"ordinary\":\n if (await context.shouldExportSchema(plan.source.schemaKey)) {\n results.push({ kind: \"source\", schema: plan.source });\n }\n break;\n case \"dynamic-noop\":\n break;\n case \"dynamic-merge\": {\n const mergedSchema = await schemaMerger.merge({\n ...plan.differences,\n conflicts: undefined,\n });\n const sourceVersion = plan.source.schemaKey.version;\n mergedSchema.setVersion(\n sourceVersion.read,\n sourceVersion.write,\n incrementMinorVersion(sourceVersion, plan.target.schemaKey.version)\n );\n results.push({ kind: \"generated\", schema: mergedSchema });\n break;\n }\n }\n }\n\n appendRequiredNoOpSchemas(results, plans);\n return results;\n }\n\n private async createPlan(\n source: Schema,\n targetSchemas: ReadonlySchemaAccessor\n ): Promise<SchemaPlan> {\n const target = await targetSchemas.getSchema(source.name);\n if (target === undefined) return { kind: \"new\", source };\n\n if (source.isDynamic !== target.isDynamic) {\n throw createSchemaConflictError(\n source,\n \"Schema DynamicSchema marker changed\",\n new Error(\"The source and target DynamicSchema markers differ.\")\n );\n }\n if (!source.isDynamic) return { kind: \"ordinary\", source, target };\n\n const sourceVersion = source.schemaKey.version;\n const targetVersion = target.schemaKey.version;\n if (\n sourceVersion.read !== targetVersion.read ||\n sourceVersion.write !== targetVersion.write\n ) {\n throw createSchemaConflictError(\n source,\n \"Dynamic schema has incompatible root versions\",\n new Error(\n `source ${sourceVersion.toString(false)}, target ${targetVersion.toString(false)}`\n )\n );\n }\n\n const differences = await this.onSchemaDifferences(\n source,\n target,\n await getSchemaDifferences(target, source)\n );\n const unresolvedConflicts = (differences.conflicts ?? []).filter(\n (conflict) => !isCompatibleReferenceVersionConflict(conflict)\n );\n if (unresolvedConflicts.length > 0) {\n throw createSchemaConflictError(\n source,\n \"Schema conflict\",\n new SchemaConflictsError(\n `Schema '${source.name}' has unresolved conflicts`,\n unresolvedConflicts,\n source.schemaKey,\n target.schemaKey\n )\n );\n }\n\n return differences.differences.length === 0\n ? { kind: \"dynamic-noop\", source, target }\n : { kind: \"dynamic-merge\", source, target, differences };\n }\n}\n\nfunction createSchemaConflictError(\n schema: Schema,\n operation: string,\n cause: Error\n): Error {\n return ITwinError.create<SchemaConflictError>({\n message: `${operation} for '${schema.schemaKey.toString(false)}': ${cause.message}`,\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.SchemaConflict,\n },\n cause,\n schemaKey: schema.schemaKey.toString(false),\n });\n}\n\nfunction throwSchemaConflicts(conflicts: Error[]): void {\n if (conflicts.length === 1) throw conflicts[0];\n if (conflicts.length > 1)\n throw new AggregateError(conflicts, \"Schema processing failed\");\n}\n\nfunction appendRequiredNoOpSchemas(\n results: SchemaProcessingResult[],\n plans: SchemaPlan[]\n): void {\n const noOpSchemas = new Map(\n plans\n .filter((plan) => plan.kind === \"dynamic-noop\")\n .map((plan) => [plan.source.name.toLowerCase(), plan.source])\n );\n const requiredNoOpSchemas = new Set<string>();\n const schemasToVisit = results.map((result) => result.schema);\n for (const schema of schemasToVisit) {\n for (const reference of schema.references) {\n const schemaName = reference.name.toLowerCase();\n const noOpSchema = noOpSchemas.get(schemaName);\n if (noOpSchema === undefined || requiredNoOpSchemas.has(schemaName))\n continue;\n\n requiredNoOpSchemas.add(schemaName);\n schemasToVisit.push(noOpSchema);\n }\n }\n for (const schemaName of requiredNoOpSchemas) {\n const schema = noOpSchemas.get(schemaName);\n if (schema !== undefined) results.push({ kind: \"source\", schema });\n }\n}\n\nfunction incrementMinorVersion(\n sourceVersion: ECVersion,\n targetVersion: ECVersion\n): number {\n const maximumVersion =\n sourceVersion.compare(targetVersion) >= 0 ? sourceVersion : targetVersion;\n if (maximumVersion.minor >= 9_999_999) {\n throw new Error(\n `Cannot increment schema version ${maximumVersion.toString(false)}`\n );\n }\n return maximumVersion.minor + 1;\n}\n\nfunction isCompatibleReferenceVersionConflict(\n conflict: AnySchemaDifferenceConflict\n): boolean {\n if (conflict.code !== ConflictCode.ConflictingReferenceVersion) return false;\n if (\n typeof conflict.source !== \"string\" ||\n typeof conflict.target !== \"string\"\n )\n return false;\n\n const sourceVersion = SchemaKey.parseString(conflict.source).version;\n const targetVersion = SchemaKey.parseString(conflict.target).version;\n return (\n sourceVersion.read === targetVersion.read &&\n sourceVersion.write === targetVersion.write\n );\n}\n\nfunction collectSchemaCandidates(\n schema: Schema,\n candidates: Map<string, SchemaCandidate>,\n isTargetRoot: boolean,\n visited: Set<string> = new Set<string>()\n): void {\n const traversalKey = schema.schemaKey.toString();\n if (visited.has(traversalKey)) return;\n visited.add(traversalKey);\n\n const schemaName = schema.name.toLowerCase();\n const existing = candidates.get(schemaName);\n if (existing === undefined) {\n candidates.set(schemaName, { schema, isTargetRoot });\n } else if (\n existing.schema.schemaKey.version.read !== schema.schemaKey.version.read ||\n existing.schema.schemaKey.version.write !== schema.schemaKey.version.write\n ) {\n throw createSchemaConflictError(\n schema,\n \"Schema reference has incompatible read/write versions\",\n new Error(\n `${existing.schema.schemaKey.version.read}.${existing.schema.schemaKey.version.write} ` +\n `and ${schema.schemaKey.version.read}.${schema.schemaKey.version.write} differ. ` +\n \"Only minor-version reference differences are supported.\"\n )\n );\n } else if (\n isTargetRoot ||\n (!existing.isTargetRoot &&\n schema.schemaKey.version.compare(existing.schema.schemaKey.version) > 0)\n ) {\n candidates.set(schemaName, { schema, isTargetRoot });\n }\n\n for (const reference of schema.references) {\n collectSchemaCandidates(reference, candidates, false, visited);\n }\n}\n\nfunction collectSchemaReferences(\n schema: Schema,\n candidates: Map<string, SchemaCandidate>\n): void {\n for (const reference of schema.references) {\n collectSchemaCandidates(reference, candidates, false);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaProcessingCoordinator.d.ts","sourceRoot":"","sources":["../../../src/schema-processing/SchemaProcessingCoordinator.ts"],"names":[],"mapp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AAmB,CAAC;AAKvE,OAAO,EAGL,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,UAAU,+BAA+B;IACvC,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,wBAAwB,EAAE,MAAM,MAAM,CAAC;IACvC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D,qBAAqB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAC,CAAC;CAC/E;AAED,gBAAgB;AAChB,qBAAa,2BAA2B;IAGnB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFzC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAE/D,YAAoC,KAAK,EAAE,+BAA+B,EAAI;IAEjE,OAAO,CAAC,QAAQ,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEtE;IAEY,qBAAqB,CAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,kBAAkB,CAAC,CAU7B;IAED,OAAO,KAAK,sBAAsB,GAEjC;YAEa,eAAe;IAe7B,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,oCAAoC;CAU7C"}
@@ -3,9 +3,42 @@
3
3
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
6
39
  Object.defineProperty(exports, "__esModule", { value: true });
7
40
  exports.SchemaProcessingCoordinator = void 0;
8
- const path = require("node:path");
41
+ const path = __importStar(require("node:path"));
9
42
  const core_bentley_1 = require("@itwin/core-bentley");
10
43
  const core_backend_1 = require("@itwin/core-backend");
11
44
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
@@ -90,7 +123,7 @@ class SchemaProcessingCoordinator {
90
123
  await this._args.serializeSourceSchema(result.schema);
91
124
  return;
92
125
  }
93
- const schemaLocaters = await Promise.resolve().then(() => require("@itwin/ecschema-locaters"));
126
+ const schemaLocaters = await import("@itwin/ecschema-locaters");
94
127
  const schemaFileName = this.getSchemaExportFileName(result.schema.name);
95
128
  const schemaXml = await schemaLocaters.SchemaXml.writeString(result.schema);
96
129
  core_backend_1.IModelJsFs.writeFileSync(path.join(this._schemaExportDirectory, schemaFileName), schemaXml);
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaProcessingCoordinator.js","sourceRoot":"","sources":["../../../src/schema-processing/SchemaProcessingCoordinator.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,kCAAkC;AAClC,sD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Ac,CAAC;AACxB,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 * as path from \"node:path\";\nimport { ITwinError } from \"@itwin/core-bentley\";\nimport { ECSchemaXmlContext, IModelDb, IModelJsFs } from \"@itwin/core-backend\";\nimport { Schema, SchemaKey, SchemaLoader } from \"@itwin/ecschema-metadata\";\nimport { ExportSchemaResult, IModelExporter } from \"../IModelExporter\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"../IModelTransformerError\";\nimport {\n ReadonlySchemaAccessor,\n SchemaProcessingResult,\n SchemaProcessingStrategy,\n} from \"./SchemaProcessingStrategy\";\n\ninterface SchemaProcessingCoordinatorArgs {\n exporter: IModelExporter;\n targetDb: IModelDb;\n getSchemaExportDirectory: () => string;\n shouldExportSchema: (schemaKey: SchemaKey) => Promise<boolean>;\n serializeSourceSchema: (schema: Schema) => Promise<void | ExportSchemaResult>;\n}\n\n/** @internal */\nexport class SchemaProcessingCoordinator {\n private readonly _longNamedSchemas = new Map<string, string>();\n\n public constructor(private readonly _args: SchemaProcessingCoordinatorArgs) {}\n\n public async process(strategy: SchemaProcessingStrategy): Promise<void> {\n let processingFailure: unknown;\n try {\n IModelJsFs.mkdirSync(this._schemaExportDirectory);\n this._longNamedSchemas.clear();\n\n const sourceSchemas: Schema[] = [];\n for await (const schema of this._args.exporter.enumerateSchemas()) {\n sourceSchemas.push(schema);\n }\n const targetSchemaLoader = new SchemaLoader((name) =>\n this._args.targetDb.getSchemaProps(name)\n );\n const targetSchemas: ReadonlySchemaAccessor = {\n getSchema: async (schemaName) =>\n targetSchemaLoader.tryGetSchema(schemaName),\n };\n const processedSchemas = await strategy.processSchemas({\n sourceSchemas: orderSchemasByDependencies(sourceSchemas),\n targetSchemas,\n shouldExportSchema: this._args.shouldExportSchema,\n });\n\n for (const result of processedSchemas) {\n await this.serializeSchema(result);\n }\n const exportedSchemaFiles = IModelJsFs.readdirSync(\n this._schemaExportDirectory\n );\n if (exportedSchemaFiles.length > 0) {\n await this._args.targetDb.importSchemas(\n exportedSchemaFiles.map((fileName) =>\n path.join(this._schemaExportDirectory, fileName)\n ),\n {\n ecSchemaXmlContext:\n this._longNamedSchemas.size > 0\n ? this.createLongNameResolvingSchemaContext()\n : undefined,\n }\n );\n }\n } catch (error: unknown) {\n processingFailure = error;\n }\n\n let cleanupFailure: unknown;\n try {\n IModelJsFs.removeSync(this._schemaExportDirectory);\n } catch (error: unknown) {\n cleanupFailure = error;\n } finally {\n this._longNamedSchemas.clear();\n }\n\n if (processingFailure !== undefined && cleanupFailure !== undefined) {\n throw new AggregateError(\n [processingFailure, cleanupFailure],\n \"Schema processing and cleanup failed\",\n { cause: processingFailure }\n );\n }\n // Preserve failures from custom strategies and upstream libraries exactly.\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n if (processingFailure !== undefined) throw processingFailure;\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n if (cleanupFailure !== undefined) throw cleanupFailure;\n }\n\n public async serializeSourceSchema(\n schema: Schema\n ): Promise<ExportSchemaResult> {\n const schemaFileName = this.getSchemaExportFileName(schema.name);\n this._args.exporter.sourceDb.exportSchema({\n schemaName: schema.name,\n outputDirectory: this._schemaExportDirectory,\n outputFileName: schemaFileName,\n });\n return {\n schemaPath: path.join(this._schemaExportDirectory, schemaFileName),\n };\n }\n\n private get _schemaExportDirectory(): string {\n return this._args.getSchemaExportDirectory();\n }\n\n private async serializeSchema(result: SchemaProcessingResult): Promise<void> {\n if (result.kind === \"source\") {\n await this._args.serializeSourceSchema(result.schema);\n return;\n }\n\n const schemaLocaters = await import(\"@itwin/ecschema-locaters\");\n const schemaFileName = this.getSchemaExportFileName(result.schema.name);\n const schemaXml = await schemaLocaters.SchemaXml.writeString(result.schema);\n IModelJsFs.writeFileSync(\n path.join(this._schemaExportDirectory, schemaFileName),\n schemaXml\n );\n }\n\n private getSchemaExportFileName(schemaName: string): string {\n const extension = \".ecschema.xml\";\n let schemaFileName = schemaName + extension;\n const systemMaxPathSegmentSize = 255;\n const windowsMaxPathLimit = 260;\n if (\n schemaFileName.length > systemMaxPathSegmentSize ||\n path.join(this._schemaExportDirectory, schemaFileName).length >=\n windowsMaxPathLimit\n ) {\n schemaFileName = `${schemaName.slice(0, 100)}${\n this._longNamedSchemas.size\n }${extension}`;\n this._longNamedSchemas.set(schemaName, schemaFileName);\n }\n return schemaFileName;\n }\n\n private createLongNameResolvingSchemaContext(): ECSchemaXmlContext {\n const context = new ECSchemaXmlContext();\n context.setSchemaLocater((key) => {\n const schemaFileName = this._longNamedSchemas.get(key.name);\n return schemaFileName === undefined\n ? undefined\n : path.join(this._schemaExportDirectory, schemaFileName);\n });\n return context;\n }\n}\n\ninterface SchemaDependencyCycleError extends ITwinError {\n schemaNames: readonly string[];\n}\n\nfunction orderSchemasByDependencies(schemas: Schema[]): Schema[] {\n const schemasByName = new Map(\n schemas.map((schema) => [schema.name.toLowerCase(), schema])\n );\n const state = new Map<string, \"visiting\" | \"visited\">();\n const orderedSchemas: Schema[] = [];\n const stack: string[] = [];\n\n const visit = (schema: Schema): void => {\n const schemaName = schema.name.toLowerCase();\n const currentState = state.get(schemaName);\n if (currentState === \"visited\") return;\n if (currentState === \"visiting\") {\n const cycleStart = stack.indexOf(schemaName);\n const schemaNames = stack.slice(cycleStart);\n throw ITwinError.create<SchemaDependencyCycleError>({\n message: `Schema dependency cycle detected: ${[\n ...schemaNames,\n schemaName,\n ].join(\" -> \")}`,\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.SchemaDependencyCycle,\n },\n schemaNames,\n });\n }\n\n state.set(schemaName, \"visiting\");\n stack.push(schemaName);\n for (const reference of schema.references) {\n const referencedSchema = schemasByName.get(reference.name.toLowerCase());\n if (referencedSchema !== undefined) visit(referencedSchema);\n }\n stack.pop();\n state.set(schemaName, \"visited\");\n orderedSchemas.push(schema);\n };\n\n for (const schema of schemas) visit(schema);\n return orderedSchemas;\n}\n"]}
1
+ {"version":3,"file":"SchemaProcessingCoordinator.js","sourceRoot":"","sources":["../../../src/schema-processing/SchemaProcessingCoordinator.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhG,MAAY,IAAI,sCAAkB;AAClC,sDAAiD;AACjD,sDAA+E;AAC/E,gEAA2E;AAE3E,sEAGmC;AAenC,gBAAgB;AAChB;IAGsC,KAAK;IAFxB,iBAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE/D,YAAoC,KAAsC;qBAAtC,KAAK;IAAoC,CAAC;IAEvE,KAAK,CAAC,OAAO,CAAC,QAAkC;QACrD,IAAI,iBAA0B,CAAC;QAC/B,IAAI,CAAC;YACH,yBAAU,CAAC,SAAS,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAClD,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAE/B,MAAM,aAAa,GAAa,EAAE,CAAC;YACnC,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC;gBAClE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YACD,MAAM,kBAAkB,GAAG,IAAI,gCAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CACnD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CACzC,CAAC;YACF,MAAM,aAAa,GAA2B;gBAC5C,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAC9B,kBAAkB,CAAC,YAAY,CAAC,UAAU,CAAC;aAC9C,CAAC;YACF,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,cAAc,CAAC;gBACrD,aAAa,EAAE,0BAA0B,CAAC,aAAa,CAAC;gBACxD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AG,EAAE,CAAC;QACZ,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACjC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,cAAc,CAAC;AACxB,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 * as path from \"node:path\";\nimport { ITwinError } from \"@itwin/core-bentley\";\nimport { ECSchemaXmlContext, IModelDb, IModelJsFs } from \"@itwin/core-backend\";\nimport { Schema, SchemaKey, SchemaLoader } from \"@itwin/ecschema-metadata\";\nimport { ExportSchemaResult, IModelExporter } from \"../IModelExporter\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"../IModelTransformerError\";\nimport {\n ReadonlySchemaAccessor,\n SchemaProcessingResult,\n SchemaProcessingStrategy,\n} from \"./SchemaProcessingStrategy\";\n\ninterface SchemaProcessingCoordinatorArgs {\n exporter: IModelExporter;\n targetDb: IModelDb;\n getSchemaExportDirectory: () => string;\n shouldExportSchema: (schemaKey: SchemaKey) => Promise<boolean>;\n serializeSourceSchema: (schema: Schema) => Promise<void | ExportSchemaResult>;\n}\n\n/** @internal */\nexport class SchemaProcessingCoordinator {\n private readonly _longNamedSchemas = new Map<string, string>();\n\n public constructor(private readonly _args: SchemaProcessingCoordinatorArgs) {}\n\n public async process(strategy: SchemaProcessingStrategy): Promise<void> {\n let processingFailure: unknown;\n try {\n IModelJsFs.mkdirSync(this._schemaExportDirectory);\n this._longNamedSchemas.clear();\n\n const sourceSchemas: Schema[] = [];\n for await (const schema of this._args.exporter.enumerateSchemas()) {\n sourceSchemas.push(schema);\n }\n const targetSchemaLoader = new SchemaLoader((name) =>\n this._args.targetDb.getSchemaProps(name)\n );\n const targetSchemas: ReadonlySchemaAccessor = {\n getSchema: async (schemaName) =>\n targetSchemaLoader.tryGetSchema(schemaName),\n };\n const processedSchemas = await strategy.processSchemas({\n sourceSchemas: orderSchemasByDependencies(sourceSchemas),\n targetSchemas,\n shouldExportSchema: this._args.shouldExportSchema,\n });\n\n for (const result of processedSchemas) {\n await this.serializeSchema(result);\n }\n const exportedSchemaFiles = IModelJsFs.readdirSync(\n this._schemaExportDirectory\n );\n if (exportedSchemaFiles.length > 0) {\n await this._args.targetDb.importSchemas(\n exportedSchemaFiles.map((fileName) =>\n path.join(this._schemaExportDirectory, fileName)\n ),\n {\n ecSchemaXmlContext:\n this._longNamedSchemas.size > 0\n ? this.createLongNameResolvingSchemaContext()\n : undefined,\n }\n );\n }\n } catch (error: unknown) {\n processingFailure = error;\n }\n\n let cleanupFailure: unknown;\n try {\n IModelJsFs.removeSync(this._schemaExportDirectory);\n } catch (error: unknown) {\n cleanupFailure = error;\n } finally {\n this._longNamedSchemas.clear();\n }\n\n if (processingFailure !== undefined && cleanupFailure !== undefined) {\n throw new AggregateError(\n [processingFailure, cleanupFailure],\n \"Schema processing and cleanup failed\",\n { cause: processingFailure }\n );\n }\n // Preserve failures from custom strategies and upstream libraries exactly.\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n if (processingFailure !== undefined) throw processingFailure;\n // eslint-disable-next-line @typescript-eslint/only-throw-error\n if (cleanupFailure !== undefined) throw cleanupFailure;\n }\n\n public async serializeSourceSchema(\n schema: Schema\n ): Promise<ExportSchemaResult> {\n const schemaFileName = this.getSchemaExportFileName(schema.name);\n this._args.exporter.sourceDb.exportSchema({\n schemaName: schema.name,\n outputDirectory: this._schemaExportDirectory,\n outputFileName: schemaFileName,\n });\n return {\n schemaPath: path.join(this._schemaExportDirectory, schemaFileName),\n };\n }\n\n private get _schemaExportDirectory(): string {\n return this._args.getSchemaExportDirectory();\n }\n\n private async serializeSchema(result: SchemaProcessingResult): Promise<void> {\n if (result.kind === \"source\") {\n await this._args.serializeSourceSchema(result.schema);\n return;\n }\n\n const schemaLocaters = await import(\"@itwin/ecschema-locaters\");\n const schemaFileName = this.getSchemaExportFileName(result.schema.name);\n const schemaXml = await schemaLocaters.SchemaXml.writeString(result.schema);\n IModelJsFs.writeFileSync(\n path.join(this._schemaExportDirectory, schemaFileName),\n schemaXml\n );\n }\n\n private getSchemaExportFileName(schemaName: string): string {\n const extension = \".ecschema.xml\";\n let schemaFileName = schemaName + extension;\n const systemMaxPathSegmentSize = 255;\n const windowsMaxPathLimit = 260;\n if (\n schemaFileName.length > systemMaxPathSegmentSize ||\n path.join(this._schemaExportDirectory, schemaFileName).length >=\n windowsMaxPathLimit\n ) {\n schemaFileName = `${schemaName.slice(0, 100)}${\n this._longNamedSchemas.size\n }${extension}`;\n this._longNamedSchemas.set(schemaName, schemaFileName);\n }\n return schemaFileName;\n }\n\n private createLongNameResolvingSchemaContext(): ECSchemaXmlContext {\n const context = new ECSchemaXmlContext();\n context.setSchemaLocater((key) => {\n const schemaFileName = this._longNamedSchemas.get(key.name);\n return schemaFileName === undefined\n ? undefined\n : path.join(this._schemaExportDirectory, schemaFileName);\n });\n return context;\n }\n}\n\ninterface SchemaDependencyCycleError extends ITwinError {\n schemaNames: readonly string[];\n}\n\nfunction orderSchemasByDependencies(schemas: Schema[]): Schema[] {\n const schemasByName = new Map(\n schemas.map((schema) => [schema.name.toLowerCase(), schema])\n );\n const state = new Map<string, \"visiting\" | \"visited\">();\n const orderedSchemas: Schema[] = [];\n const stack: string[] = [];\n\n const visit = (schema: Schema): void => {\n const schemaName = schema.name.toLowerCase();\n const currentState = state.get(schemaName);\n if (currentState === \"visited\") return;\n if (currentState === \"visiting\") {\n const cycleStart = stack.indexOf(schemaName);\n const schemaNames = stack.slice(cycleStart);\n throw ITwinError.create<SchemaDependencyCycleError>({\n message: `Schema dependency cycle detected: ${[\n ...schemaNames,\n schemaName,\n ].join(\" -> \")}`,\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.SchemaDependencyCycle,\n },\n schemaNames,\n });\n }\n\n state.set(schemaName, \"visiting\");\n stack.push(schemaName);\n for (const reference of schema.references) {\n const referencedSchema = schemasByName.get(reference.name.toLowerCase());\n if (referencedSchema !== undefined) visit(referencedSchema);\n }\n stack.pop();\n state.set(schemaName, \"visited\");\n orderedSchemas.push(schema);\n };\n\n for (const schema of schemas) visit(schema);\n return orderedSchemas;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaProcessingStrategy.d.ts","sourceRoot":"","sources":["../../../src/schema-processing/SchemaProcessingStrategy.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5D;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,iEAAiE;IACjE,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAC/C,sEAAsE;IACtE,QAAQ,CAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,uFAAuF;IACvF,cAAc,CACZ,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,wBAAwB,CAAC;CACrC;AAED;;;GAGG;AACH,qBAAa,gCACX,YAAW,wBAAwB;IAEnC,8EAA8E;IACjE,cAAc,CACzB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;CASrC"}
1
+ {"version":3,"file":"SchemaProcessingStrategy.d.ts","sourceRoot":"","sources":["../../../src/schema-processing/SchemaProcessingStrategy.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5D;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,iEAAiE;IACjE,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAC/C,sEAAsE;IACtE,QAAQ,CAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,uFAAuF;IACvF,cAAc,CACZ,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,wBAAwB,CAAC;CACrC;AAED;;;GAGG;AACH,qBAAa,gCACX,YAAW,wBAAwB;IAEnC,8EAA8E;IACjE,cAAc,CACzB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAQnC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaProcessingStrategy.js","sourceRoot":"","sources":["../../../src/schema-processing/SchemaProcessingStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAqDH;;;GAGG;AACH,MAAa,gCAAgC;IAG3C,8EAA8E;IACvE,KAAK,CAAC,cAAc,CACzB,OAAgC;QAEhC,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC3C,IAAI,MAAM,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBACvD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAfD,4EAeC","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 { Schema, SchemaKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * The result of processing one schema.\n * @beta\n */\nexport type SchemaProcessingResult =\n | { kind: \"source\"; schema: Schema }\n | { kind: \"generated\"; schema: Schema };\n\n/** Read-only access to schemas already present in the target iModel.\n * @beta\n */\nexport interface ReadonlySchemaAccessor {\n /** Load a target schema by name, or return `undefined` when it is absent. */\n getSchema(schemaName: string): Promise<Schema | undefined>;\n}\n\n/**\n * Context supplied to a [[SchemaProcessingStrategy]].\n * @beta\n */\nexport interface SchemaProcessingContext {\n /** Source schemas in dependency order. */\n readonly sourceSchemas: readonly Schema[];\n /** Read-only access to schemas already present in the target. */\n readonly targetSchemas: ReadonlySchemaAccessor;\n /** The schema-selection hook used by the default transformer path. */\n readonly shouldExportSchema: (schemaKey: SchemaKey) => Promise<boolean>;\n}\n\n/**\n * Selects source schemas and produces definitions for import into a target iModel.\n * @beta\n */\nexport interface SchemaProcessingStrategy {\n /** Select source schemas and produce definitions for import into the target iModel. */\n processSchemas(\n context: SchemaProcessingContext\n ): Promise<SchemaProcessingResult[]>;\n}\n\n/**\n * Options for [[IModelTransformer.processSchemas]].\n * @beta\n */\nexport interface ProcessSchemasOptions {\n /** Strategy used to select and process source schemas. */\n strategy?: SchemaProcessingStrategy;\n}\n\n/**\n * Selects source schemas that are absent from the target or have a newer version.\n * @beta\n */\nexport class NewerVersionSchemaImportStrategy\n implements SchemaProcessingStrategy\n{\n /** Select schemas that are absent from the target or have a newer version. */\n public async processSchemas(\n context: SchemaProcessingContext\n ): Promise<SchemaProcessingResult[]> {\n const results: SchemaProcessingResult[] = [];\n for (const schema of context.sourceSchemas) {\n if (await context.shouldExportSchema(schema.schemaKey)) {\n results.push({ kind: \"source\", schema });\n }\n }\n return results;\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaProcessingStrategy.js","sourceRoot":"","sources":["../../../src/schema-processing/SchemaProcessingStrategy.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAqDH;;;GAGG;AACH;IAGE,8EAA8E;IACvE,KAAK,CAAC,cAAc,CACzB,OAAgC;QAEhC,MAAM,OAAO,GAA6B,EAAE,CAAC;QAC7C,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC3C,IAAI,MAAM,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBACvD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,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/** @packageDocumentation\n * @module iModels\n */\n\nimport { Schema, SchemaKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * The result of processing one schema.\n * @beta\n */\nexport type SchemaProcessingResult =\n | { kind: \"source\"; schema: Schema }\n | { kind: \"generated\"; schema: Schema };\n\n/** Read-only access to schemas already present in the target iModel.\n * @beta\n */\nexport interface ReadonlySchemaAccessor {\n /** Load a target schema by name, or return `undefined` when it is absent. */\n getSchema(schemaName: string): Promise<Schema | undefined>;\n}\n\n/**\n * Context supplied to a [[SchemaProcessingStrategy]].\n * @beta\n */\nexport interface SchemaProcessingContext {\n /** Source schemas in dependency order. */\n readonly sourceSchemas: readonly Schema[];\n /** Read-only access to schemas already present in the target. */\n readonly targetSchemas: ReadonlySchemaAccessor;\n /** The schema-selection hook used by the default transformer path. */\n readonly shouldExportSchema: (schemaKey: SchemaKey) => Promise<boolean>;\n}\n\n/**\n * Selects source schemas and produces definitions for import into a target iModel.\n * @beta\n */\nexport interface SchemaProcessingStrategy {\n /** Select source schemas and produce definitions for import into the target iModel. */\n processSchemas(\n context: SchemaProcessingContext\n ): Promise<SchemaProcessingResult[]>;\n}\n\n/**\n * Options for [[IModelTransformer.processSchemas]].\n * @beta\n */\nexport interface ProcessSchemasOptions {\n /** Strategy used to select and process source schemas. */\n strategy?: SchemaProcessingStrategy;\n}\n\n/**\n * Selects source schemas that are absent from the target or have a newer version.\n * @beta\n */\nexport class NewerVersionSchemaImportStrategy\n implements SchemaProcessingStrategy\n{\n /** Select schemas that are absent from the target or have a newer version. */\n public async processSchemas(\n context: SchemaProcessingContext\n ): Promise<SchemaProcessingResult[]> {\n const results: SchemaProcessingResult[] = [];\n for (const schema of context.sourceSchemas) {\n if (await context.shouldExportSchema(schema.schemaKey)) {\n results.push({ kind: \"source\", schema });\n }\n }\n return results;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/imodel-transformer",
3
- "version": "2.0.0-dev.47",
3
+ "version": "2.0.0-dev.48",
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",
@@ -105,12 +105,12 @@
105
105
  "@itwin/ecschema-editing": "5.10.3",
106
106
  "@itwin/ecschema-locaters": "5.10.3",
107
107
  "@itwin/ecschema-metadata": "^5.10.3",
108
- "@itwin/eslint-plugin": "^5.2.1",
108
+ "@itwin/eslint-plugin": "^6.1.0",
109
109
  "@itwin/imodel-transformer-test-utils": "0.0.0",
110
110
  "@types/node": "^22.18.8",
111
111
  "@types/node-fetch": "^2.6.13",
112
112
  "@types/semver": "^7.7.1",
113
- "@typescript-eslint/parser": "^8.45.0",
113
+ "@typescript-eslint/parser": "^8.64.0",
114
114
  "@vitest/coverage-v8": "4.1.10",
115
115
  "cross-env": "^5.2.1",
116
116
  "eslint": "^9.36.0",
@@ -119,7 +119,8 @@
119
119
  "npm-run-all": "^4.1.5",
120
120
  "prettier": "^3.6.2",
121
121
  "rimraf": "^3.0.2",
122
- "typescript": "^5.9.3",
122
+ "@typescript/native": "npm:typescript@~7.0.2",
123
+ "typescript": "npm:@typescript/typescript6@~6.0.2",
123
124
  "vitest": "4.1.10"
124
125
  },
125
126
  "dependencies": {