@itwin/ecschema-editing 4.7.0-dev.13 → 4.7.0-dev.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,qCAAqC,EAAE,KAAK,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEvK,OAAO,EAAoB,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"RelationshipClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,qCAAqC,EAAE,KAAK,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEvK,OAAO,EAAoB,KAAK,uBAAuB,EAAiD,MAAM,oBAAoB,CAAC;AAEnI,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBAAuB,CAAC,2BAA2B,CA4BxF,CAAC;AAgCF;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,gCAAgC,kCAsCtH;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,qCAAqC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAmBjK"}
|
|
@@ -28,8 +28,8 @@ exports.relationshipClassMerger = {
|
|
|
28
28
|
schemaItemType: change.schemaType,
|
|
29
29
|
strength: change.difference.strength,
|
|
30
30
|
strengthDirection: change.difference.strengthDirection,
|
|
31
|
-
source: change.difference.source,
|
|
32
|
-
target: change.difference.target,
|
|
31
|
+
source: await updateRelationshipConstraintKey(context, change.difference.source),
|
|
32
|
+
target: await updateRelationshipConstraintKey(context, change.difference.target),
|
|
33
33
|
});
|
|
34
34
|
},
|
|
35
35
|
async modify(context, change, itemKey, item) {
|
|
@@ -138,4 +138,18 @@ function parseConstraint(path) {
|
|
|
138
138
|
? "source"
|
|
139
139
|
: "target";
|
|
140
140
|
}
|
|
141
|
+
async function updateRelationshipConstraintKey(context, props) {
|
|
142
|
+
let abstractConstraint = props.abstractConstraint;
|
|
143
|
+
if (abstractConstraint !== undefined)
|
|
144
|
+
abstractConstraint = await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, abstractConstraint);
|
|
145
|
+
const constraintClasses = [];
|
|
146
|
+
for (const ecClass of props.constraintClasses) {
|
|
147
|
+
constraintClasses.push(await (0, SchemaItemMerger_1.updateSchemaItemFullName)(context, ecClass));
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
...props,
|
|
151
|
+
abstractConstraint,
|
|
152
|
+
constraintClasses,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
141
155
|
//# sourceMappingURL=RelationshipClassMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":";;;AAMA,yDAAyG;AACzG,+CAA4C;AAE5C,gEAAiL;AAKjL;;;GAGG;AACU,QAAA,uBAAuB,GAAyD;IAC3F,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC7C,OAAO,EAAE,YAAY,EAAE,wCAAwC,EAAE,CAAC;QACpE,CAAC;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACtD,OAAO,EAAE,YAAY,EAAE,iDAAiD,EAA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AU,EAAE,CAAC;QAC9C,MAAM,kBAAkB,GAAG,MAAM,IAAA,sCAAmB,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC9E,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAuB,kBAAkB,CAAC,CAAC;QACnH,IAAG,eAAe,KAAK,SAAS,EAAE,CAAC;YACjC,OAAO,EAAE,YAAY,EAAE,kDAAkD,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC;QACvG,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAClG,IAAG,MAAM,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;AACvD,CAAC;AAnBD,4EAmBC;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","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type RelationshipClassDifference, type RelationshipConstraintClassDifference, type RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\r\nimport { locateSchemaItem, type SchemaItemMergerHandler, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\n\r\ntype ConstraintClassTypes = EntityClass | Mixin | RelationshipClass;\r\n\r\n/**\r\n * Defines a merge handler to merge RelationshipClass schema items.\r\n * @internal\r\n */\r\nexport const relationshipClassMerger: SchemaItemMergerHandler<RelationshipClassDifference> = {\r\n async add(context, change) {\r\n if (change.difference.strength === undefined) {\r\n return { errorMessage: \"RelationshipClass must define strength\" };\r\n }\r\n if (change.difference.strengthDirection === undefined) {\r\n return { errorMessage: \"RelationshipClass must define strengthDirection\" };\r\n }\r\n if (change.difference.source === undefined) {\r\n return { errorMessage: \"RelationshipClass must define a source constraint\" };\r\n }\r\n if (change.difference.target === undefined) {\r\n return { errorMessage: \"RelationshipClass must define a target constraint\" };\r\n }\r\n\r\n return context.editor.relationships.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n strength: change.difference.strength,\r\n strengthDirection: change.difference.strengthDirection,\r\n source: change.difference.source,\r\n target: change.difference.target,\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableRelationshipClass) {\r\n return modifyRelationshipClass(context, change, itemKey, item);\r\n },\r\n};\r\n\r\nasync function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey, item: MutableRelationshipClass) {\r\n // The following modifications will only be applied if the items gets modified\r\n // and not the 2nd pass when adding a RelationshipClass.\r\n if(change.changeType === \"modify\") {\r\n if(change.difference.strength !== undefined) {\r\n if (item.strength === undefined) {\r\n const strength = parseStrength(change.difference.strength);\r\n if (strength === undefined) {\r\n return { itemKey, errorMessage: `An invalid relationship class strength value '${change.difference.strength}' has been provided.` };\r\n }\r\n item.setStrength(strength);\r\n return { itemKey };\r\n }\r\n return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strength is not supported.` };\r\n }\r\n if(change.difference.strengthDirection !== undefined) {\r\n if (item.strengthDirection === undefined) {\r\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\r\n if (strengthDirection === undefined) {\r\n return { itemKey, errorMessage: `An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.` };\r\n }\r\n item.setStrengthDirection(strengthDirection);\r\n return { itemKey };\r\n }\r\n return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strengthDirection is not supported.` };\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint.\r\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\r\n if(change.changeType !== \"modify\") {\r\n return { errorMessage: \"RelationshipConstraints can only be modified.\" };\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n if(change.difference.roleLabel !== undefined) {\r\n constraint.roleLabel = change.difference.roleLabel;\r\n }\r\n if(change.difference.polymorphic !== undefined) {\r\n const result = await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\r\n if(result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n if(change.difference.multiplicity !== undefined) {\r\n if (constraint.multiplicity === undefined) {\r\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\r\n if (multiplicity === undefined) {\r\n return { errorMessage: `An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.` };\r\n }\r\n const result = await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\r\n if(result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };\r\n }\r\n if(change.difference.abstractConstraint !== undefined) {\r\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\r\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem<ConstraintClassTypes>(itemKey);\r\n if (abstractConstraint === undefined) {\r\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`};\r\n }\r\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\r\n }\r\n return { itemKey: constraint.relationshipClass.key };\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<SchemaItemEditResults> {\r\n if(change.changeType !== \"add\") {\r\n return { errorMessage: `Change type ${change.changeType} is not supported for Relationship constraint classes.` };\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n for(const constraintName of change.difference) {\r\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\r\n const constraintClass = await context.editor.schemaContext.getSchemaItem<ConstraintClassTypes>(constraintClassKey);\r\n if(constraintClass === undefined) {\r\n return { errorMessage: `Could not locate relationship constraint class ${constraintClassKey.name}` };\r\n }\r\n const result = await context.editor.relationships.addConstraintClass(constraint, constraintClass);\r\n if(result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n return { itemKey: constraint.relationshipClass.key };\r\n}\r\n\r\nfunction parseConstraint(path: string): \"source\" | \"target\" {\r\n return path.startsWith(\"$source\")\r\n ? \"source\"\r\n : \"target\";\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RelationshipClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/RelationshipClassMerger.ts"],"names":[],"mappings":";;;AAMA,yDAAmI;AACnI,+CAA4C;AAE5C,gEAA8M;AAK9M;;;GAGG;AACU,QAAA,uBAAuB,GAAyD;IAC3F,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CA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2CAAwB,EAAC,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,IAAA,2CAAwB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { type RelationshipClassDifference, type RelationshipConstraintClassDifference, type RelationshipConstraintDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type MutableRelationshipClass } from \"../Editing/Mutable/MutableRelationshipClass\";\r\nimport { locateSchemaItem, type SchemaItemMergerHandler, updateSchemaItemFullName, updateSchemaItemKey } from \"./SchemaItemMerger\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\nimport { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { EntityClass, Mixin, parseStrength, parseStrengthDirection, RelationshipClass, RelationshipConstraintProps, RelationshipMultiplicity, SchemaItemKey, SchemaItemType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaItemEditResults } from \"../Editing/Editor\";\r\n\r\ntype ConstraintClassTypes = EntityClass | Mixin | RelationshipClass;\r\n\r\n/**\r\n * Defines a merge handler to merge RelationshipClass schema items.\r\n * @internal\r\n */\r\nexport const relationshipClassMerger: SchemaItemMergerHandler<RelationshipClassDifference> = {\r\n async add(context, change) {\r\n if (change.difference.strength === undefined) {\r\n return { errorMessage: \"RelationshipClass must define strength\" };\r\n }\r\n if (change.difference.strengthDirection === undefined) {\r\n return { errorMessage: \"RelationshipClass must define strengthDirection\" };\r\n }\r\n if (change.difference.source === undefined) {\r\n return { errorMessage: \"RelationshipClass must define a source constraint\" };\r\n }\r\n if (change.difference.target === undefined) {\r\n return { errorMessage: \"RelationshipClass must define a target constraint\" };\r\n }\r\n\r\n return context.editor.relationships.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n strength: change.difference.strength,\r\n strengthDirection: change.difference.strengthDirection,\r\n source: await updateRelationshipConstraintKey(context, change.difference.source),\r\n target: await updateRelationshipConstraintKey(context, change.difference.target),\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableRelationshipClass) {\r\n return modifyRelationshipClass(context, change, itemKey, item);\r\n },\r\n};\r\n\r\nasync function modifyRelationshipClass(context: SchemaMergeContext, change: RelationshipClassDifference, itemKey: SchemaItemKey, item: MutableRelationshipClass) {\r\n // The following modifications will only be applied if the items gets modified\r\n // and not the 2nd pass when adding a RelationshipClass.\r\n if(change.changeType === \"modify\") {\r\n if(change.difference.strength !== undefined) {\r\n if (item.strength === undefined) {\r\n const strength = parseStrength(change.difference.strength);\r\n if (strength === undefined) {\r\n return { itemKey, errorMessage: `An invalid relationship class strength value '${change.difference.strength}' has been provided.` };\r\n }\r\n item.setStrength(strength);\r\n return { itemKey };\r\n }\r\n return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strength is not supported.` };\r\n }\r\n if(change.difference.strengthDirection !== undefined) {\r\n if (item.strengthDirection === undefined) {\r\n const strengthDirection = parseStrengthDirection(change.difference.strengthDirection);\r\n if (strengthDirection === undefined) {\r\n return { itemKey, errorMessage: `An invalid relationship class strengthDirection value '${change.difference.strengthDirection}' has been provided.` };\r\n }\r\n item.setStrengthDirection(strengthDirection);\r\n return { itemKey };\r\n }\r\n return { itemKey, errorMessage: `Changing the relationship '${itemKey.name}' strengthDirection is not supported.` };\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint.\r\n * This only supports modify as the RelationshipConstraints are always set on the Relationship classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipConstraint(context: SchemaMergeContext, change: RelationshipConstraintDifference) {\r\n if(change.changeType !== \"modify\") {\r\n return { errorMessage: \"RelationshipConstraints can only be modified.\" };\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n if(change.difference.roleLabel !== undefined) {\r\n constraint.roleLabel = change.difference.roleLabel;\r\n }\r\n if(change.difference.polymorphic !== undefined) {\r\n const result = await context.editor.relationships.setConstraintPolymorphic(constraint, change.difference.polymorphic);\r\n if(result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n if(change.difference.multiplicity !== undefined) {\r\n if (constraint.multiplicity === undefined) {\r\n const multiplicity = RelationshipMultiplicity.fromString(change.difference.multiplicity);\r\n if (multiplicity === undefined) {\r\n return { errorMessage: `An invalid relationship constraint multiplicity value '${change.difference.multiplicity}' has been provided.` };\r\n }\r\n const result = await context.editor.relationships.setConstraintMultiplicity(constraint, multiplicity);\r\n if(result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n return { errorMessage: `Changing the relationship constraint '${constraint.fullName}' multiplicity is not supported.` };\r\n }\r\n if(change.difference.abstractConstraint !== undefined) {\r\n const itemKey = await updateSchemaItemKey(context, change.difference.abstractConstraint);\r\n const abstractConstraint = await context.editor.schemaContext.getSchemaItem<ConstraintClassTypes>(itemKey);\r\n if (abstractConstraint === undefined) {\r\n return { itemKey: constraint.relationshipClass.key, errorMessage: `Unable to locate the abstract constraint class ${change.difference.abstractConstraint} in the context schema.`};\r\n }\r\n return context.editor.relationships.setAbstractConstraint(constraint, abstractConstraint);\r\n }\r\n return { itemKey: constraint.relationshipClass.key };\r\n}\r\n\r\n/**\r\n * Merges differences of a Relationship constraint classes.\r\n * @internal\r\n */\r\nexport async function mergeRelationshipClassConstraint(context: SchemaMergeContext, change: RelationshipConstraintClassDifference): Promise<SchemaItemEditResults> {\r\n if(change.changeType !== \"add\") {\r\n return { errorMessage: `Change type ${change.changeType} is not supported for Relationship constraint classes.` };\r\n }\r\n\r\n const item = await locateSchemaItem(context, change.itemName, SchemaItemType.RelationshipClass) as MutableRelationshipClass;\r\n const constraint = item[parseConstraint(change.path)];\r\n for(const constraintName of change.difference) {\r\n const constraintClassKey = await updateSchemaItemKey(context, constraintName);\r\n const constraintClass = await context.editor.schemaContext.getSchemaItem<ConstraintClassTypes>(constraintClassKey);\r\n if(constraintClass === undefined) {\r\n return { errorMessage: `Could not locate relationship constraint class ${constraintClassKey.name}` };\r\n }\r\n const result = await context.editor.relationships.addConstraintClass(constraint, constraintClass);\r\n if(result.errorMessage) {\r\n return result;\r\n }\r\n }\r\n return { itemKey: constraint.relationshipClass.key };\r\n}\r\n\r\nfunction parseConstraint(path: string): \"source\" | \"target\" {\r\n return path.startsWith(\"$source\")\r\n ? \"source\"\r\n : \"target\";\r\n}\r\n\r\nasync function updateRelationshipConstraintKey(context: SchemaMergeContext, props: RelationshipConstraintProps): Promise<RelationshipConstraintProps> {\r\n let abstractConstraint = props.abstractConstraint;\r\n if (abstractConstraint !== undefined)\r\n abstractConstraint = await updateSchemaItemFullName(context, abstractConstraint);\r\n\r\n const constraintClasses: string[] = [];\r\n for (const ecClass of props.constraintClasses) {\r\n constraintClasses.push(await updateSchemaItemFullName(context, ecClass));\r\n }\r\n\r\n return {\r\n ...props,\r\n abstractConstraint,\r\n constraintClasses,\r\n };\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/ecschema-editing",
|
|
3
|
-
"version": "4.7.0-dev.
|
|
3
|
+
"version": "4.7.0-dev.15",
|
|
4
4
|
"description": "ECSchema editing and validation API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/cjs/ecschema-editing.js",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
43
|
"sinon": "^17.0.1",
|
|
44
44
|
"typescript": "~5.3.3",
|
|
45
|
-
"@itwin/build-tools": "4.7.0-dev.
|
|
46
|
-
"@itwin/core-
|
|
47
|
-
"@itwin/
|
|
48
|
-
"@itwin/core-
|
|
49
|
-
"@itwin/
|
|
45
|
+
"@itwin/build-tools": "4.7.0-dev.15",
|
|
46
|
+
"@itwin/core-quantity": "4.7.0-dev.15",
|
|
47
|
+
"@itwin/core-bentley": "4.7.0-dev.15",
|
|
48
|
+
"@itwin/core-common": "4.7.0-dev.15",
|
|
49
|
+
"@itwin/ecschema-metadata": "4.7.0-dev.15"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@itwin/core-bentley": "^4.7.0-dev.
|
|
53
|
-
"@itwin/core-quantity": "^4.7.0-dev.
|
|
54
|
-
"@itwin/ecschema-metadata": "^4.7.0-dev.
|
|
52
|
+
"@itwin/core-bentley": "^4.7.0-dev.15",
|
|
53
|
+
"@itwin/core-quantity": "^4.7.0-dev.15",
|
|
54
|
+
"@itwin/ecschema-metadata": "^4.7.0-dev.15"
|
|
55
55
|
},
|
|
56
56
|
"nyc": {
|
|
57
57
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|