@itwin/ecschema-editing 5.0.0-dev.99 → 5.0.1
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.
- package/CHANGELOG.md +63 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +1 -1
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +7 -2
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +2 -2
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +3 -3
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +3 -3
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +4 -4
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +7 -7
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/cjs/Editing/Properties.js +6 -6
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +12 -12
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +3 -3
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +3 -3
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/FormatMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/FormatMerger.js +6 -4
- package/lib/cjs/Merging/FormatMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +4 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.d.ts.map +1 -1
- package/lib/cjs/Merging/Utils.js +1 -1
- package/lib/cjs/Merging/Utils.js.map +1 -1
- package/lib/cjs/Validation/ECRules.js +4 -4
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.js +2 -2
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.js +19 -8
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/esm/Differencing/SchemaDifferenceValidator.js +1 -1
- package/lib/esm/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/esm/Editing/Editor.d.ts.map +1 -1
- package/lib/esm/Editing/Editor.js +2 -2
- package/lib/esm/Editing/Editor.js.map +1 -1
- package/lib/esm/Editing/Formats.d.ts.map +1 -1
- package/lib/esm/Editing/Formats.js +8 -3
- package/lib/esm/Editing/Formats.js.map +1 -1
- package/lib/esm/Editing/KindOfQuantities.d.ts +2 -2
- package/lib/esm/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/esm/Editing/KindOfQuantities.js +3 -3
- package/lib/esm/Editing/KindOfQuantities.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableFormat.d.ts +3 -3
- package/lib/esm/Editing/Mutable/MutableFormat.d.ts.map +1 -1
- package/lib/esm/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableKindOfQuantity.d.ts +4 -4
- package/lib/esm/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/esm/Editing/Mutable/MutableRelationshipClass.d.ts +7 -7
- package/lib/esm/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -1
- package/lib/esm/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/esm/Editing/Properties.js +6 -6
- package/lib/esm/Editing/Properties.js.map +1 -1
- package/lib/esm/Editing/RelationshipClasses.js +12 -12
- package/lib/esm/Editing/RelationshipClasses.js.map +1 -1
- package/lib/esm/Editing/SchemaItems.d.ts +1 -1
- package/lib/esm/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/esm/Editing/SchemaItems.js +4 -4
- package/lib/esm/Editing/SchemaItems.js.map +1 -1
- package/lib/esm/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/esm/Merging/ConstantMerger.js +4 -4
- package/lib/esm/Merging/ConstantMerger.js.map +1 -1
- package/lib/esm/Merging/FormatMerger.d.ts.map +1 -1
- package/lib/esm/Merging/FormatMerger.js +7 -5
- package/lib/esm/Merging/FormatMerger.js.map +1 -1
- package/lib/esm/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/esm/Merging/KindOfQuantityMerger.js +5 -2
- package/lib/esm/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/esm/Merging/PhenomenonMerger.d.ts.map +1 -1
- package/lib/esm/Merging/PhenomenonMerger.js +2 -2
- package/lib/esm/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/esm/Merging/RelationshipClassMerger.js +1 -1
- package/lib/esm/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/esm/Merging/Utils.d.ts.map +1 -1
- package/lib/esm/Merging/Utils.js +2 -2
- package/lib/esm/Merging/Utils.js.map +1 -1
- package/lib/esm/Validation/ECRules.js +4 -4
- package/lib/esm/Validation/ECRules.js.map +1 -1
- package/lib/esm/Validation/SchemaChanges.js +3 -3
- package/lib/esm/Validation/SchemaChanges.js.map +1 -1
- package/lib/esm/Validation/SchemaComparer.d.ts.map +1 -1
- package/lib/esm/Validation/SchemaComparer.js +19 -8
- package/lib/esm/Validation/SchemaComparer.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,YAAY,EAAiB,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhH,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA2B,EAAE,MAAwB;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,S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AO,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAChE,qDAAqD;QACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,oBAAuC,EAAE,UAAkB;IACpF,IAAI,YAAY,GAAiB,YAAY,CAAC,aAAa,CAAC;IAC5D,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAC7D,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,MAAM,WAAW,GAAG,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;QACrE,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;IAC5C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,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*--------------------------------------------------------------------------------------------*/\nimport { InvertedUnit, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, parseFormatTrait, parseScientificType, parseShowSignOption } from \"@itwin/core-quantity\";\nimport { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from \"../Differencing/SchemaDifference\";\nimport { MutableFormat } from \"../Editing/Mutable/MutableFormat\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Format into the target schema.\n * @internal\n */\nexport async function addFormat(context: SchemaMergeContext, change: FormatDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Format must define type\");\n }\n\n if (change.difference.composite && change.difference.composite.units) {\n for (let index = 0; index < change.difference.composite.units.length; index++) {\n const compositeUnitName = await updateSchemaItemFullName(context, change.difference.composite.units[index].name);\n change.difference.composite.units[index] = {\n name: compositeUnitName,\n label: change.difference.composite.units[index].label,\n }\n }\n }\n\n await context.editor.formats.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n composite: change.difference.composite,\n });\n}\n\n/**\n * Merges differences to an existing Format in the target schema.\n * @internal\n */\nexport async function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n if (change.difference.type !== undefined) {\n throw new Error(`Changing the format '${change.itemName}' type is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.formats.setDescription(itemKey, change.difference.description);\n }\n if (change.difference.precision !== undefined) {\n format.setPrecision(change.difference.precision);\n }\n if (change.difference.roundFactor !== undefined) {\n format.setRoundFactor(change.difference.roundFactor);\n }\n if (change.difference.minWidth !== undefined) {\n format.setMinWidth(change.difference.minWidth);\n }\n if (change.difference.showSignOption !== undefined) {\n const showSignOption = parseShowSignOption(change.difference.showSignOption, change.itemName);\n format.setShowSignOption(showSignOption);\n }\n if (change.difference.formatTraits !== undefined) {\n const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);\n format.setFormatTraits(formatTraits);\n }\n if (change.difference.decimalSeparator !== undefined) {\n format.setDecimalSeparator(change.difference.decimalSeparator);\n }\n if (change.difference.thousandSeparator !== undefined) {\n format.setThousandSeparator(change.difference.thousandSeparator);\n }\n if (change.difference.uomSeparator !== undefined) {\n format.setUomSeparator(change.difference.uomSeparator);\n }\n if (change.difference.scientificType !== undefined) {\n const scientificType = parseScientificType(change.difference.scientificType, change.itemName);\n format.setScientificType(scientificType);\n }\n if (change.difference.stationOffsetSize !== undefined) {\n format.setStationOffsetSize(change.difference.stationOffsetSize);\n }\n if (change.difference.stationSeparator !== undefined) {\n format.setStationSeparator(change.difference.stationSeparator);\n }\n if (change.difference.composite !== undefined) {\n if (change.difference.composite.includeZero !== undefined) {\n format.setIncludeZero(change.difference.composite.includeZero);\n }\n if (change.difference.composite.spacer !== undefined) {\n format.setSpacer(change.difference.composite.spacer);\n }\n }\n}\n\n/**\n * Merges source format units into the target format\n * @internal\n*/\nexport async function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n const units: [Unit | InvertedUnit, string | undefined][] = [];\n for (const { name, label } of change.difference) {\n const lookupKey = await updateSchemaItemKey(context, name);\n const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);\n if (formatUnit === undefined || (!Unit.isUnit(formatUnit) && !InvertedUnit.isInvertedUnit(formatUnit))) {\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\n }\n units.push([formatUnit, label]);\n }\n format.setUnits(units);\n}\n\n/**\n * Overrides format unit label\n * @internal\n*/\nexport async function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n if (format.units !== undefined) {\n const unitKey = await updateSchemaItemKey(context, change.path);\n /* eslint-disable @typescript-eslint/prefer-for-of */\n for (let index = 0; index < format.units.length; index++) {\n if (format.units[index][0].key.matches(unitKey)) {\n format.units[index][1] = change.difference.label;\n }\n }\n }\n}\n\nfunction parseFormatTraits(formatTraitsFromJson: string | string[], formatName: string): FormatTraits {\n let formatTraits: FormatTraits = FormatTraits.Uninitialized;\n const formatTraitIterable = Array.isArray(formatTraitsFromJson)\n ? formatTraitsFromJson\n : formatTraitsFromJson.split(/,|;|\\|/);\n for (const formatTraitsString of formatTraitIterable) {\n const formatTrait = parseFormatTrait(formatTraitsString, formatName);\n formatTraits = formatTraits | formatTrait;\n }\n return formatTraits;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FormatMerger.js","sourceRoot":"","sources":["../../../src/Merging/FormatMerger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAyD,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAC9I,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhH,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA2B,EAAE,MAAwB;IACnF,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9E,MAAM,iBAAiB,GAAG,MAAM,wBAAwB,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,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AC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAChE,qDAAqD;QACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,oBAAuC,EAAE,UAAkB;IACpF,IAAI,YAAY,GAAiB,YAAY,CAAC,aAAa,CAAC;IAC5D,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAC7D,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,MAAM,WAAW,GAAG,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;QACrE,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;IAC5C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,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*--------------------------------------------------------------------------------------------*/\nimport { DelayedPromiseWithProps, InvertedUnit, LazyLoadedInvertedUnit, LazyLoadedUnit, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatTraits, parseFormatTrait, parseScientificType, parseShowSignOption } from \"@itwin/core-quantity\";\nimport { FormatDifference, FormatUnitDifference, FormatUnitLabelDifference } from \"../Differencing/SchemaDifference\";\nimport { MutableFormat } from \"../Editing/Mutable/MutableFormat\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new Format into the target schema.\n * @internal\n */\nexport async function addFormat(context: SchemaMergeContext, change: FormatDifference) {\n if (change.difference.type === undefined) {\n throw new Error(\"Format must define type\");\n }\n\n if (change.difference.composite && change.difference.composite.units) {\n for (let index = 0; index < change.difference.composite.units.length; index++) {\n const compositeUnitName = await updateSchemaItemFullName(context, change.difference.composite.units[index].name);\n change.difference.composite.units[index] = {\n name: compositeUnitName,\n label: change.difference.composite.units[index].label,\n }\n }\n }\n\n await context.editor.formats.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n type: change.difference.type,\n composite: change.difference.composite,\n });\n}\n\n/**\n * Merges differences to an existing Format in the target schema.\n * @internal\n */\nexport async function modifyFormat(context: SchemaMergeContext, change: FormatDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n if (change.difference.type !== undefined) {\n throw new Error(`Changing the format '${change.itemName}' type is not supported.`);\n }\n\n if (change.difference.label !== undefined) {\n await context.editor.formats.setDisplayLabel(itemKey, change.difference.label);\n }\n if (change.difference.description !== undefined) {\n await context.editor.formats.setDescription(itemKey, change.difference.description);\n }\n if (change.difference.precision !== undefined) {\n format.setPrecision(change.difference.precision);\n }\n if (change.difference.roundFactor !== undefined) {\n format.setRoundFactor(change.difference.roundFactor);\n }\n if (change.difference.minWidth !== undefined) {\n format.setMinWidth(change.difference.minWidth);\n }\n if (change.difference.showSignOption !== undefined) {\n const showSignOption = parseShowSignOption(change.difference.showSignOption, change.itemName);\n format.setShowSignOption(showSignOption);\n }\n if (change.difference.formatTraits !== undefined) {\n const formatTraits = parseFormatTraits(change.difference.formatTraits, change.itemName);\n format.setFormatTraits(formatTraits);\n }\n if (change.difference.decimalSeparator !== undefined) {\n format.setDecimalSeparator(change.difference.decimalSeparator);\n }\n if (change.difference.thousandSeparator !== undefined) {\n format.setThousandSeparator(change.difference.thousandSeparator);\n }\n if (change.difference.uomSeparator !== undefined) {\n format.setUomSeparator(change.difference.uomSeparator);\n }\n if (change.difference.scientificType !== undefined) {\n const scientificType = parseScientificType(change.difference.scientificType, change.itemName);\n format.setScientificType(scientificType);\n }\n if (change.difference.stationOffsetSize !== undefined) {\n format.setStationOffsetSize(change.difference.stationOffsetSize);\n }\n if (change.difference.stationSeparator !== undefined) {\n format.setStationSeparator(change.difference.stationSeparator);\n }\n if (change.difference.composite !== undefined) {\n if (change.difference.composite.includeZero !== undefined) {\n format.setIncludeZero(change.difference.composite.includeZero);\n }\n if (change.difference.composite.spacer !== undefined) {\n format.setSpacer(change.difference.composite.spacer);\n }\n }\n}\n\n/**\n * Merges source format units into the target format\n * @internal\n*/\nexport async function modifyFormatUnit(context: SchemaMergeContext, change: FormatUnitDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n const units: [LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined][] = [];\n for (const { name, label } of change.difference) {\n const lookupKey = await updateSchemaItemKey(context, name);\n const formatUnit = await context.editor.schemaContext.getSchemaItem(lookupKey);\n if (Unit.isUnit(formatUnit))\n units.push([new DelayedPromiseWithProps(formatUnit.key, async () => formatUnit), label]);\n else if (InvertedUnit.isInvertedUnit(formatUnit))\n units.push([new DelayedPromiseWithProps(formatUnit.key, async () => formatUnit), label]);\n else\n throw new Error(`Could not find format unit ${lookupKey.fullName} in the current context`);\n }\n format.setUnits(units);\n}\n\n/**\n * Overrides format unit label\n * @internal\n*/\nexport async function modifyFormatUnitLabel(context: SchemaMergeContext, change: FormatUnitLabelDifference, itemKey: SchemaItemKey) {\n const format = await context.targetSchema.lookupItem(itemKey) as MutableFormat;\n\n if (format.units !== undefined) {\n const unitKey = await updateSchemaItemKey(context, change.path);\n /* eslint-disable @typescript-eslint/prefer-for-of */\n for (let index = 0; index < format.units.length; index++) {\n if (format.units[index][0].matches(unitKey)) {\n format.units[index][1] = change.difference.label;\n }\n }\n }\n}\n\nfunction parseFormatTraits(formatTraitsFromJson: string | string[], formatName: string): FormatTraits {\n let formatTraits: FormatTraits = FormatTraits.Uninitialized;\n const formatTraitIterable = Array.isArray(formatTraitsFromJson)\n ? formatTraitsFromJson\n : formatTraitsFromJson.split(/,|;|\\|/);\n for (const formatTraitsString of formatTraitIterable) {\n const formatTrait = parseFormatTrait(formatTraitsString, formatName);\n formatTraits = formatTraits | formatTrait;\n }\n return formatTraits;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C,EAAE,MAAM,kCAAkC,CAAC;AAE7H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"KindOfQuantityMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C,EAAE,MAAM,kCAAkC,CAAC;AAE7H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAyG,aAAa,EAAQ,MAAM,0BAA0B,CAAC;AAGtK;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,wBAAwB,iBA4BpG;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,iBAe/H;AACD;;;EAGE;AACF,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,0CAA0C,EAAE,OAAO,EAAE,aAAa,iBASlJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OverrideFormat } from "@itwin/ecschema-metadata";
|
|
1
|
+
import { DelayedPromiseWithProps, InvertedUnit, OverrideFormat, Unit } from "@itwin/ecschema-metadata";
|
|
2
2
|
import { updateSchemaItemFullName, updateSchemaItemKey } from "./Utils";
|
|
3
3
|
/**
|
|
4
4
|
* Merges a new KindOfQuantity into the target schema.
|
|
@@ -81,7 +81,10 @@ async function updateOverrideFormat(context, formatString) {
|
|
|
81
81
|
for (const unitOverride of match.unitAndLabels) {
|
|
82
82
|
const unitKey = await updateSchemaItemKey(context, unitOverride[0]);
|
|
83
83
|
const unit = await context.targetSchema.lookupItem(unitKey);
|
|
84
|
-
|
|
84
|
+
if (Unit.isUnit(unit))
|
|
85
|
+
unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => unit), unitOverride[1]]);
|
|
86
|
+
else if (InvertedUnit.isInvertedUnit(unit))
|
|
87
|
+
unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => unit), unitOverride[1]]);
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
return context.editor.kindOfQuantities.createFormatOverride(formatKey, match.precision, unitAndLabels);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"KindOfQuantityMerger.js","sourceRoot":"","sources":["../../../src/Merging/KindOfQuantityMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAU,YAAY,EAA0C,cAAc,EAAiB,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACtK,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAExE;;;GAGG;AACH,MAAM,C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C,YAAY,CAAC,UAAU,CAAC,OAAO,CAAwB,CAAC;YACnF,IAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBAClB,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC5F,IAAG,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC;gBACvC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACzG,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*--------------------------------------------------------------------------------------------*/\nimport type { KindOfQuantityDifference, KindOfQuantityPresentationFormatDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableKindOfQuantity } from \"../Editing/Mutable/MutableKindOfQuantity\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { DelayedPromiseWithProps, Format, InvertedUnit, LazyLoadedInvertedUnit, LazyLoadedUnit, OverrideFormat, SchemaItemKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\n\n/**\n * Merges a new KindOfQuantity into the target schema.\n * @internal\n */\nexport async function addKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference) {\n if (change.difference.persistenceUnit === undefined) {\n throw new Error(\"KindOfQuantity must define persistenceUnit\");\n }\n if (change.difference.relativeError === undefined) {\n throw new Error(\"KindOfQuantity must define relativeError\");\n }\n change.difference.persistenceUnit = await updateSchemaItemFullName(context, change.difference.persistenceUnit);\n if(change.difference.presentationUnits) {\n if(Array.isArray(change.difference.presentationUnits)) {\n for(let index = 0; index < change.difference.presentationUnits.length; index++) {\n const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits[index]);\n change.difference.presentationUnits[index] = presentationFormat.fullName;\n }\n } else {\n const presentationFormat = await updateOverrideFormat(context, change.difference.presentationUnits);\n change.difference.presentationUnits = presentationFormat.name;\n }\n }\n\n await context.editor.kindOfQuantities.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n persistenceUnit: change.difference.persistenceUnit,\n presentationUnits: change.difference.presentationUnits,\n relativeError: change.difference.relativeError,\n });\n}\n\n/**\n * Merges differences to an existing KindOfQuantity in the target schema.\n * @internal\n */\nexport async function modifyKindOfQuantity(context: SchemaMergeContext, change: KindOfQuantityDifference, itemKey: SchemaItemKey) {\n const kindOfQuantity = await context.targetSchema.lookupItem(itemKey) as MutableKindOfQuantity;\n if(change.difference.label !== undefined) {\n await context.editor.kindOfQuantities.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.kindOfQuantities.setDescription(itemKey, change.difference.description);\n }\n if(change.difference.relativeError !== undefined) {\n kindOfQuantity.setRelativeError(change.difference.relativeError);\n }\n if(change.difference.persistenceUnit !== undefined) {\n // TODO: It should be checked if the unit is the same, but referring to the source schema.\n throw new Error(`Changing the kind of quantity '${change.itemName}' persistenceUnit is not supported.`);\n }\n}\n/**\n * Merges a new presentation format into the target kind of quantity\n * @internal\n*/\nexport async function addPresentationFormat(context: SchemaMergeContext, change: KindOfQuantityPresentationFormatDifference, itemKey: SchemaItemKey) {\n for (const formatString of change.difference) {\n const presentationFormat = await updateOverrideFormat(context, formatString);\n if (OverrideFormat.isOverrideFormat(presentationFormat)) {\n await context.editor.kindOfQuantities.addPresentationOverrideFormat(itemKey, presentationFormat);\n } else {\n await context.editor.kindOfQuantities.addPresentationFormat(itemKey, presentationFormat.key);\n }\n }\n}\n\nasync function updateOverrideFormat(context: SchemaMergeContext, formatString: string): Promise<Format | OverrideFormat> {\n // https://www.itwinjs.org/v1/bis/ec/kindofquantity/#format-string\n const match = OverrideFormat.parseFormatString(formatString);\n const formatKey = await updateSchemaItemKey(context, match.name);\n const format = await context.targetSchema.lookupItem(formatKey) as Format;\n\n if (undefined === match.precision && undefined === match.unitAndLabels)\n return format;\n\n let unitAndLabels: Array<[LazyLoadedUnit | LazyLoadedInvertedUnit, string | undefined]> | undefined;\n if (undefined !== match.unitAndLabels) {\n unitAndLabels = [];\n for (const unitOverride of match.unitAndLabels) {\n const unitKey = await updateSchemaItemKey(context, unitOverride[0]);\n const unit = await context.targetSchema.lookupItem(unitKey) as Unit | InvertedUnit;\n if(Unit.isUnit(unit))\n unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => unit), unitOverride[1]]);\n else if(InvertedUnit.isInvertedUnit(unit))\n unitAndLabels.push([new DelayedPromiseWithProps(unit.key, async () => unit), unitOverride[1]]);\n }\n }\n return context.editor.kindOfQuantities.createFormatOverride(formatKey, match.precision, unitAndLabels);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"PhenomenonMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAiC,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE7F;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAW5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAgBvH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ECSchemaError, ECSchemaStatus } from "@itwin/ecschema-metadata";
|
|
2
2
|
/**
|
|
3
3
|
* Merges a new Phenomenon into the target schema.
|
|
4
4
|
* @internal
|
|
@@ -29,7 +29,7 @@ export async function modifyPhenomenon(context, change, itemKey) {
|
|
|
29
29
|
if (change.difference.definition !== undefined) {
|
|
30
30
|
// It would be better if the validation would be part of phenomenon.setDefinition.
|
|
31
31
|
if (phenomenon.definition !== "" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())
|
|
32
|
-
throw new
|
|
32
|
+
throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Phenomenon ${change.itemName} has an invalid 'definition' attribute.`);
|
|
33
33
|
await phenomenon.setDefinition(change.difference.definition);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PhenomenonMerger.js","sourceRoot":"","sources":["../../../src/Merging/PhenomenonMerger.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,0BAA0B,CAAC;AAE7F;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,IAAI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CAAC,QAAQ,yCAAyC,CAAC,CAAC;QAEpI,MAAM,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/D,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*--------------------------------------------------------------------------------------------*/\nimport type { PhenomenonDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutablePhenomenon } from \"../Editing/Mutable/MutablePhenomenon\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECSchemaError, ECSchemaStatus, type SchemaItemKey } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new Phenomenon into the target schema.\n * @internal\n */\nexport async function addPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference) {\n if (change.difference.definition === undefined) {\n throw new Error(\"Phenomenon must define definition\");\n }\n\n await context.editor.phenomenons.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n definition: change.difference.definition,\n });\n}\n\n/**\n * Merges differences to an existing Phenomenon in the target schema.\n * @internal\n */\nexport async function modifyPhenomenon(context: SchemaMergeContext, change: PhenomenonDifference, itemKey: SchemaItemKey) {\n const phenomenon = await context.targetSchema.lookupItem(itemKey) as MutablePhenomenon;\n if(change.difference.label !== undefined) {\n await context.editor.phenomenons.setDisplayLabel(itemKey, change.difference.label);\n }\n if(change.difference.description !== undefined) {\n await context.editor.phenomenons.setDescription(itemKey, change.difference.description);\n }\n\n if(change.difference.definition !== undefined) {\n // It would be better if the validation would be part of phenomenon.setDefinition.\n if (phenomenon.definition !== \"\" && change.difference.definition.toLowerCase() !== phenomenon.definition.toLowerCase())\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `The Phenomenon ${change.itemName} has an invalid 'definition' attribute.`);\n\n await phenomenon.setDefinition(change.difference.definition);\n }\n}\n"]}
|
|
@@ -70,7 +70,7 @@ export async function mergeRelationshipConstraint(context, change) {
|
|
|
70
70
|
const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass);
|
|
71
71
|
const constraint = item[parseConstraint(change.path)];
|
|
72
72
|
if (change.difference.roleLabel !== undefined) {
|
|
73
|
-
constraint.
|
|
73
|
+
constraint.setRoleLabel(change.difference.roleLabel);
|
|
74
74
|
}
|
|
75
75
|
if (change.difference.polymorphic !== undefined) {
|
|
76
76
|
await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,iBAAiB,EAA+B,wBAAwB,EAAiB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEvN;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,MAAmC;IACzG,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU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AAC,kDAAkD,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/F,CAAC;QAED,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IACrF,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAC/B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC;AAED,KAAK,UAAU,+BAA+B,CAAC,OAA2B,EAAE,KAAkC;IAC5G,IAAI,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IAClD,IAAI,kBAAkB,KAAK,SAAS;QAClC,kBAAkB,GAAG,MAAM,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAEnF,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC9C,iBAAiB,CAAC,IAAI,CAAC,MAAM,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,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*--------------------------------------------------------------------------------------------*/\nimport type { RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\nimport { locateSchemaItem, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraintProps, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new RelationshipClass into the target schema.\n * @internal\n */\nexport async function addRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference) {\n if (change.difference.strength === undefined) {\n throw new Error(\"RelationshipClass must define strength\");\n }\n if (change.difference.strengthDirection === undefined) {\n throw new Error(\"RelationshipClass must define strengthDirection\");\n }\n if (change.difference.source === undefined) {\n throw new Error(\"RelationshipClass must define a source constraint\");\n }\n if (change.difference.target === undefined) {\n throw new Error(\"RelationshipClass must define a target constraint\");\n }\n\n await context.editor.relationships.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n strength: change.difference.strength,\n strengthDirection: change.difference.strengthDirection,\n source: await updateRelationshipConstraintKey(context, change.difference.source),\n target: await updateRelationshipConstraintKey(context, change.difference.target),\n });\n}\n\n/**\n * Merges differences to an existing RelationshipClass in the target schema.\n * @internal\n */\nexport async function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableRelationshipClass;\n if(change.changeType === \"modify\") {\n if(change.difference.strength !== undefined) {\n if (item.strength === undefined) {\n const strength = parseStrength(change.difference.strength);\n if (strength === undefined) {\n throw new Error(`An invalid relationship class strength value '${change.difference.strength}' has been provided.`);\n }\n item.setStrength(strength);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strength is not supported.`);\n }\n if(change.difference.strengthDirection !== undefined) {\n if (item.strengthDirection === undefined) {\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\n if (strengthDirection === undefined) {\n throw new Error(`An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.`);\n }\n item.setStrengthDirection(strengthDirection);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strengthDirection is not supported.`);\n }\n }\n await modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges differences of a Relationship constraint.\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\n * @internal\n */\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\n if(change.changeType !== \"modify\") {\n throw new Error(\"RelationshipConstraints can only be modified.\");\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n if(change.difference.roleLabel !== undefined) {\n constraint.roleLabel = change.difference.roleLabel;\n }\n if(change.difference.polymorphic !== undefined) {\n await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\n }\n if(change.difference.multiplicity !== undefined) {\n if (constraint.multiplicity === undefined) {\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\n if (multiplicity === undefined) {\n throw new Error(`An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.`);\n }\n await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\n }\n throw new Error(`Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.`);\n }\n if(change.difference.abstractConstraint !== undefined) {\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem(itemKey, ECClass);\n if (abstractConstraint === undefined || (!EntityClass.isEntityClass(abstractConstraint) && !Mixin.isMixin(abstractConstraint) && !RelationshipClass.isRelationshipClass(abstractConstraint))) {\n throw new Error(`Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`);\n }\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\n }\n return { itemKey: constraint.relationshipClass.key };\n}\n\n/**\n * Merges differences of a Relationship constraint classes.\n * @internal\n */\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<void> {\n if(change.changeType !== \"add\") {\n throw new Error(`Change type ${change.changeType} is not supported for Relationship constraint classes.`);\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n for(const constraintName of change.difference) {\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\n const constraintClass = await context.editor.schemaContext.getSchemaItem(constraintClassKey, ECClass);\n if(constraintClass === undefined || (!EntityClass.isEntityClass(constraintClass) && !Mixin.isMixin(constraintClass) && !RelationshipClass.isRelationshipClass(constraintClass))) {\n throw new Error(`Could not locate relationship constraint class ${constraintClassKey.name}`);\n }\n\n await context.editor.relationships.addConstraintClass(constraint, constraintClass);\n }\n}\n\nfunction parseConstraint(path: string): \"source\" | \"target\" {\n return path.startsWith(\"$source\")\n ? \"source\"\n : \"target\";\n}\n\nasync function updateRelationshipConstraintKey(context: SchemaMergeContext, props: RelationshipConstraintProps): Promise<RelationshipConstraintProps> {\n let abstractConstraint = props.abstractConstraint;\n if (abstractConstraint !== undefined)\n abstractConstraint = await updateSchemaItemFullName(context, abstractConstraint);\n\n const constraintClasses: string[] = [];\n for (const ecClass of props.constraintClasses) {\n constraintClasses.push(await updateSchemaItemFullName(context, ecClass));\n }\n\n return {\n ...props,\n abstractConstraint,\n constraintClasses,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,iBAAiB,EAA+B,wBAAwB,EAAiB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEvN;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAA2B,EAAE,MAAmC;IACzG,IAAI,MAAM,CAAC,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*---------------------------------------------------------------------------------------------\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*--------------------------------------------------------------------------------------------*/\nimport type { RelationshipClassDifference, RelationshipConstraintClassDifference, RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\nimport type { MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\nimport { locateSchemaItem, updateSchemaItemFullName, updateSchemaItemKey } from \"./Utils\";\nimport { modifyClass } from \"./ClassMerger\";\nimport { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraintProps, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Merges a new RelationshipClass into the target schema.\n * @internal\n */\nexport async function addRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference) {\n if (change.difference.strength === undefined) {\n throw new Error(\"RelationshipClass must define strength\");\n }\n if (change.difference.strengthDirection === undefined) {\n throw new Error(\"RelationshipClass must define strengthDirection\");\n }\n if (change.difference.source === undefined) {\n throw new Error(\"RelationshipClass must define a source constraint\");\n }\n if (change.difference.target === undefined) {\n throw new Error(\"RelationshipClass must define a target constraint\");\n }\n\n await context.editor.relationships.createFromProps(context.targetSchemaKey, {\n ...change.difference,\n name: change.itemName,\n schemaItemType: change.schemaType,\n strength: change.difference.strength,\n strengthDirection: change.difference.strengthDirection,\n source: await updateRelationshipConstraintKey(context, change.difference.source),\n target: await updateRelationshipConstraintKey(context, change.difference.target),\n });\n}\n\n/**\n * Merges differences to an existing RelationshipClass in the target schema.\n * @internal\n */\nexport async function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey) {\n const item = await context.targetSchema.lookupItem(itemKey) as MutableRelationshipClass;\n if(change.changeType === \"modify\") {\n if(change.difference.strength !== undefined) {\n if (item.strength === undefined) {\n const strength = parseStrength(change.difference.strength);\n if (strength === undefined) {\n throw new Error(`An invalid relationship class strength value '${change.difference.strength}' has been provided.`);\n }\n item.setStrength(strength);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strength is not supported.`);\n }\n if(change.difference.strengthDirection !== undefined) {\n if (item.strengthDirection === undefined) {\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\n if (strengthDirection === undefined) {\n throw new Error(`An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.`);\n }\n item.setStrengthDirection(strengthDirection);\n }\n throw new Error(`Changing the relationship '${itemKey.name}' strengthDirection is not supported.`);\n }\n }\n await modifyClass(context, change, itemKey, item);\n}\n\n/**\n * Merges differences of a Relationship constraint.\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\n * @internal\n */\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\n if(change.changeType !== \"modify\") {\n throw new Error(\"RelationshipConstraints can only be modified.\");\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n if(change.difference.roleLabel !== undefined) {\n constraint.setRoleLabel(change.difference.roleLabel);\n }\n if(change.difference.polymorphic !== undefined) {\n await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\n }\n if(change.difference.multiplicity !== undefined) {\n if (constraint.multiplicity === undefined) {\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\n if (multiplicity === undefined) {\n throw new Error(`An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.`);\n }\n await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\n }\n throw new Error(`Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.`);\n }\n if(change.difference.abstractConstraint !== undefined) {\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem(itemKey, ECClass);\n if (abstractConstraint === undefined || (!EntityClass.isEntityClass(abstractConstraint) && !Mixin.isMixin(abstractConstraint) && !RelationshipClass.isRelationshipClass(abstractConstraint))) {\n throw new Error(`Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`);\n }\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\n }\n return { itemKey: constraint.relationshipClass.key };\n}\n\n/**\n * Merges differences of a Relationship constraint classes.\n * @internal\n */\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<void> {\n if(change.changeType !== \"add\") {\n throw new Error(`Change type ${change.changeType} is not supported for Relationship constraint classes.`);\n }\n\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\n const constraint = item[parseConstraint(change.path)];\n for(const constraintName of change.difference) {\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\n const constraintClass = await context.editor.schemaContext.getSchemaItem(constraintClassKey, ECClass);\n if(constraintClass === undefined || (!EntityClass.isEntityClass(constraintClass) && !Mixin.isMixin(constraintClass) && !RelationshipClass.isRelationshipClass(constraintClass))) {\n throw new Error(`Could not locate relationship constraint class ${constraintClassKey.name}`);\n }\n\n await context.editor.relationships.addConstraintClass(constraint, constraintClass);\n }\n}\n\nfunction parseConstraint(path: string): \"source\" | \"target\" {\n return path.startsWith(\"$source\")\n ? \"source\"\n : \"target\";\n}\n\nasync function updateRelationshipConstraintKey(context: SchemaMergeContext, props: RelationshipConstraintProps): Promise<RelationshipConstraintProps> {\n let abstractConstraint = props.abstractConstraint;\n if (abstractConstraint !== undefined)\n abstractConstraint = await updateSchemaItemFullName(context, abstractConstraint);\n\n const constraintClasses: string[] = [];\n for (const ecClass of props.constraintClasses) {\n constraintClasses.push(await updateSchemaItemFullName(context, ecClass));\n }\n\n return {\n ...props,\n abstractConstraint,\n constraintClasses,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAgD,UAAU,EAAE,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AAE5I;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,CAGtF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,WAAW,CAG9G;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,mBAG5F;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,0BAavF;AAgBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAQvG;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAmBtH"}
|
package/lib/esm/Merging/Utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropertyKey } from "./Edits/NameMapping";
|
|
2
|
-
import { ECClass,
|
|
2
|
+
import { ECClass, ECSchemaError, ECSchemaStatus, SchemaItem, SchemaItemKey, SchemaItemType } from "@itwin/ecschema-metadata";
|
|
3
3
|
/**
|
|
4
4
|
* Resolves a SchemaItemKey for the given item name.
|
|
5
5
|
* @internal
|
|
@@ -61,7 +61,7 @@ export async function locateSchemaItem(context, itemName, schemaType) {
|
|
|
61
61
|
const schemaItemKey = toItemKey(context, itemName);
|
|
62
62
|
const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);
|
|
63
63
|
if (schemaItem === undefined) {
|
|
64
|
-
throw new
|
|
64
|
+
throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);
|
|
65
65
|
}
|
|
66
66
|
return schemaItem;
|
|
67
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAiB,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE5I;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,OAA2B,EAAE,QAAgB;IACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAC1G,OAAO,IAA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,KAAK,cAAc,CAAC,KAAK;YACvB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC/B,KAAK,cAAc,CAAC,WAAW;YAC7B,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,KAAK,cAAc,CAAC,oBAAoB;YACtC,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;QACzC,KAAK,cAAc,CAAC,iBAAiB;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;QACtC;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,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*--------------------------------------------------------------------------------------------*/\nimport { ECClasses } from \"../Editing/ECClasses\";\nimport { PropertyKey } from \"./Edits/NameMapping\";\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\nimport { ECClass, ECSchemaError, ECSchemaStatus, SchemaContext, SchemaItem, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\n\n/**\n * Resolves a SchemaItemKey for the given item name.\n * @internal\n */\nexport function toItemKey(context: SchemaMergeContext, itemName: string): SchemaItemKey {\n const classKey = context.nameMapping.resolveItemKey(new SchemaItemKey(itemName, context.sourceSchemaKey));\n return new SchemaItemKey(classKey.name, context.targetSchemaKey);\n}\n\n/**\n * Resolves a SchemaItemKey for the given class property name.\n * @internal\n */\nexport function toPropertyKey(context: SchemaMergeContext, itemName: string, propertyName: string): PropertyKey {\n const classKey = new SchemaItemKey(itemName, context.sourceSchemaKey);\n return context.nameMapping.resolvePropertyKey(new PropertyKey(propertyName, classKey));\n}\n\n/**\n * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.\n * @internal\n */\nexport async function updateSchemaItemFullName(context: SchemaMergeContext, reference: string) {\n const schemaItemKey = await updateSchemaItemKey(context, reference);\n return schemaItemKey.fullName;\n}\n\n/**\n * Updates the given reference if it refers to a SchemaItem in the source Schema and\n * returns a SchemaItemKey. If any other schema is referred the reference is not change.\n * @internal\n */\nexport async function updateSchemaItemKey(context: SchemaMergeContext, reference: string) {\n const [schemaName, itemName] = SchemaItem.parseFullName(reference);\n if (context.sourceSchemaKey.compareByName(schemaName)) {\n const schemaItemKey = toItemKey(context, itemName);\n return resolveSchemaItemKey(context.editor.schemaContext, schemaItemKey);\n }\n\n const referencedSchema = await context.targetSchema.getReference(schemaName);\n if (referencedSchema !== undefined) {\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, referencedSchema.schemaKey));\n }\n\n throw new Error(`Cannot locate referenced schema item ${reference}`);\n}\n\n/**\n * To support case insensitivity for schema items, the given key is checked if there\n * exists an item for it.\n * @internal\n */\nasync function resolveSchemaItemKey(schemaContext: SchemaContext, itemKey: SchemaItemKey): Promise<SchemaItemKey> {\n const item = await schemaContext.getSchemaItem(itemKey);\n if (item === undefined) {\n // If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.\n return itemKey;\n }\n return item.key;\n}\n\n/**\n * @internal\n */\nexport async function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string) {\n const schemaItemKey = toItemKey(context, itemName);\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\n if (schemaItem === undefined) {\n throw new ECSchemaError(ECSchemaStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);\n }\n\n return schemaItem;\n}\n\n/**\n * @internal\n */\nexport async function getClassEditor(context: SchemaMergeContext, ecClass: ECClass | SchemaItemKey): Promise<ECClasses> {\n const schemaItemType = ECClass.isECClass(ecClass)\n ? ecClass.schemaItemType\n : (await context.editor.schemaContext.getSchemaItem(ecClass, ECClass))?.schemaItemType;\n\n switch(schemaItemType) {\n case SchemaItemType.EntityClass:\n return context.editor.entities;\n case SchemaItemType.Mixin:\n return context.editor.mixins;\n case SchemaItemType.StructClass:\n return context.editor.structs;\n case SchemaItemType.CustomAttributeClass:\n return context.editor.customAttributes;\n case SchemaItemType.RelationshipClass:\n return context.editor.relationships;\n default:\n throw new Error(\"SchemaItemType not supported\");\n }\n}\n"]}
|
|
@@ -231,7 +231,7 @@ export async function* incompatibleValueTypePropertyOverride(property) {
|
|
|
231
231
|
if (!primitiveType)
|
|
232
232
|
return;
|
|
233
233
|
async function callback(baseClass) {
|
|
234
|
-
const baseProperty = await baseClass.getProperty(property.name);
|
|
234
|
+
const baseProperty = await baseClass.getProperty(property.name, true);
|
|
235
235
|
if (!baseProperty)
|
|
236
236
|
return;
|
|
237
237
|
// Other rules will catch this if false, but we need to make sure
|
|
@@ -258,7 +258,7 @@ export async function* incompatibleTypePropertyOverride(property) {
|
|
|
258
258
|
if (!property.class.baseClass)
|
|
259
259
|
return;
|
|
260
260
|
async function callback(baseClass) {
|
|
261
|
-
const baseProperty = await baseClass.getProperty(property.name);
|
|
261
|
+
const baseProperty = await baseClass.getProperty(property.name, true);
|
|
262
262
|
if (!baseProperty)
|
|
263
263
|
return;
|
|
264
264
|
// Return if rule passed
|
|
@@ -280,7 +280,7 @@ export async function* incompatibleUnitPropertyOverride(property) {
|
|
|
280
280
|
if (!property.kindOfQuantity || !property.class.baseClass)
|
|
281
281
|
return;
|
|
282
282
|
async function callback(baseClass) {
|
|
283
|
-
const baseProperty = await baseClass.getProperty(property.name);
|
|
283
|
+
const baseProperty = await baseClass.getProperty(property.name, true);
|
|
284
284
|
if (!baseProperty || !baseProperty.kindOfQuantity)
|
|
285
285
|
return;
|
|
286
286
|
// Other rules will catch this if false, but we need to make sure
|
|
@@ -343,7 +343,7 @@ export async function* validateNavigationProperty(property) {
|
|
|
343
343
|
yield new Diagnostics.NavigationRelationshipAbstractConstraintEntityOrMixin(property, [property.fullName, relationship.fullName]);
|
|
344
344
|
}
|
|
345
345
|
const isClassSupported = async (ecClass, propertyName, constraintName) => {
|
|
346
|
-
if (constraintName === ecClass.fullName && undefined !== await ecClass.getProperty(propertyName))
|
|
346
|
+
if (constraintName === ecClass.fullName && undefined !== await ecClass.getProperty(propertyName, true))
|
|
347
347
|
return true;
|
|
348
348
|
const inheritedProp = await ecClass.getInheritedProperty(propertyName);
|
|
349
349
|
if (inheritedProp && constraintName === inheritedProp.class.fullName)
|