@itwin/ecschema-editing 4.10.0-dev.1 → 4.10.0-dev.2
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/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.d.ts +2 -2
- package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifference.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceValidator.js.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts +7 -4
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.d.ts.map +1 -1
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js +28 -25
- package/lib/cjs/Differencing/SchemaDifferenceVisitor.js.map +1 -1
- package/lib/cjs/Differencing/Utils.d.ts +2 -2
- package/lib/cjs/Differencing/Utils.d.ts.map +1 -1
- package/lib/cjs/Differencing/Utils.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +2 -6
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +12 -82
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.d.ts +10 -4
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +58 -54
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeClassMerger.d.ts +14 -0
- package/lib/cjs/Merging/CustomAttributeClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/CustomAttributeClassMerger.js +41 -0
- package/lib/cjs/Merging/CustomAttributeClassMerger.js.map +1 -0
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +2 -6
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +39 -48
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.d.ts.map +1 -1
- package/lib/cjs/Merging/Edits/RenameEditHandler.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +11 -6
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +32 -32
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.d.ts +7 -6
- package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +39 -67
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumeratorMerger.d.ts +14 -0
- package/lib/cjs/Merging/EnumeratorMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/EnumeratorMerger.js +41 -0
- package/lib/cjs/Merging/EnumeratorMerger.js.map +1 -0
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts +10 -4
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +51 -46
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.d.ts +10 -4
- package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +30 -25
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.d.ts +10 -4
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +34 -29
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts +10 -4
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js +30 -27
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts +2 -2
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +7 -7
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +8 -4
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +40 -40
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +7 -42
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts +138 -0
- package/lib/cjs/Merging/SchemaMergingVisitor.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaMergingVisitor.js +309 -0
- package/lib/cjs/Merging/SchemaMergingVisitor.js.map +1 -0
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts +19 -0
- package/lib/cjs/Merging/SchemaMergingWalker.d.ts.map +1 -0
- package/lib/cjs/Merging/SchemaMergingWalker.js +62 -0
- package/lib/cjs/Merging/SchemaMergingWalker.js.map +1 -0
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts +9 -6
- package/lib/cjs/Merging/SchemaReferenceMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaReferenceMerger.js +28 -37
- package/lib/cjs/Merging/SchemaReferenceMerger.js.map +1 -1
- package/lib/cjs/Merging/StructClassMerger.d.ts +14 -0
- package/lib/cjs/Merging/StructClassMerger.d.ts.map +1 -0
- package/lib/cjs/Merging/StructClassMerger.js +25 -0
- package/lib/cjs/Merging/StructClassMerger.js.map +1 -0
- package/lib/cjs/Merging/UnitSystemMerger.d.ts +10 -4
- package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js +23 -19
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/lib/cjs/Merging/Utils.d.ts +18 -0
- package/lib/cjs/Merging/Utils.d.ts.map +1 -0
- package/lib/cjs/Merging/Utils.js +56 -0
- package/lib/cjs/Merging/Utils.js.map +1 -0
- package/package.json +9 -9
- package/lib/cjs/Merging/CAClassMerger.d.ts +0 -8
- package/lib/cjs/Merging/CAClassMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/CAClassMerger.js +0 -36
- package/lib/cjs/Merging/CAClassMerger.js.map +0 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +0 -35
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +0 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +0 -121
- package/lib/cjs/Merging/SchemaItemMerger.js.map +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
2
|
+
import type { SchemaReferenceDifference } from "../Differencing/SchemaDifference";
|
|
3
3
|
/**
|
|
4
|
-
* Merges
|
|
5
|
-
* @param context current merge context
|
|
6
|
-
* @param change schema changes.
|
|
4
|
+
* Merges a new reference to an external schema into the target schema.
|
|
7
5
|
* @internal
|
|
8
6
|
*/
|
|
9
|
-
export declare function
|
|
7
|
+
export declare function addSchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Merges differences to an existing schema references in the target schema.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare function modifySchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference): Promise<void>;
|
|
10
13
|
//# sourceMappingURL=SchemaReferenceMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaReferenceMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SchemaReferenceMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAIlF;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,iBAGvG;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,yBAAyB,iBAgB1G"}
|
|
@@ -1,44 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
/*---------------------------------------------------------------------------------------------
|
|
5
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3
|
+
exports.modifySchemaReferences = exports.addSchemaReferences = void 0;
|
|
8
4
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
9
5
|
/**
|
|
10
|
-
* Merges
|
|
11
|
-
* @param context current merge context
|
|
12
|
-
* @param change schema changes.
|
|
6
|
+
* Merges a new reference to an external schema into the target schema.
|
|
13
7
|
* @internal
|
|
14
8
|
*/
|
|
15
|
-
async function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
async function addSchemaReferences(context, change) {
|
|
10
|
+
const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);
|
|
11
|
+
await context.editor.addSchemaReference(context.targetSchemaKey, referencedSchema);
|
|
12
|
+
}
|
|
13
|
+
exports.addSchemaReferences = addSchemaReferences;
|
|
14
|
+
/**
|
|
15
|
+
* Merges differences to an existing schema references in the target schema.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
async function modifySchemaReferences(context, change) {
|
|
19
|
+
const existingSchema = await context.targetSchema.getReference(change.difference.name);
|
|
20
|
+
const [older, latest] = sortSchemas(existingSchema.schemaKey, new ecschema_metadata_1.SchemaKey(change.difference.name, ecschema_metadata_1.ECVersion.fromString(change.difference.version)));
|
|
21
|
+
if (latest === existingSchema.schemaKey) {
|
|
22
|
+
return;
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// the source schema is compatible to the existing one. This is not be checked by the
|
|
25
|
-
// schema instance when added.
|
|
26
|
-
if (change.changeType === "modify") {
|
|
27
|
-
const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);
|
|
28
|
-
const existingSchema = (await context.targetSchema.getReference(referencedSchema.name));
|
|
29
|
-
const [older, latest] = compareSchemas(existingSchema, referencedSchema);
|
|
30
|
-
if (!latest.schemaKey.matches(older.schemaKey, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible)) {
|
|
31
|
-
throw new Error(`Schemas references of ${referencedSchema.name} have incompatible versions: ${older.schemaKey.version} and ${latest.schemaKey.version}`);
|
|
32
|
-
}
|
|
33
|
-
if (latest === existingSchema) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const index = context.targetSchema.references.findIndex((reference) => reference === existingSchema);
|
|
37
|
-
context.targetSchema.references.splice(index, 1);
|
|
38
|
-
await context.editor.addSchemaReference(context.targetSchema.schemaKey, referencedSchema);
|
|
24
|
+
if (!latest.matches(older, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible)) {
|
|
25
|
+
throw new Error(`Schemas references of ${change.difference.name} have incompatible versions: ${older.version} and ${latest.version}`);
|
|
39
26
|
}
|
|
27
|
+
const index = context.targetSchema.references.findIndex((reference) => reference === existingSchema);
|
|
28
|
+
context.targetSchema.references.splice(index, 1);
|
|
29
|
+
const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);
|
|
30
|
+
await context.editor.addSchemaReference(context.targetSchema.schemaKey, referencedSchema);
|
|
40
31
|
}
|
|
41
|
-
exports.
|
|
32
|
+
exports.modifySchemaReferences = modifySchemaReferences;
|
|
42
33
|
/**
|
|
43
34
|
* Tries to locate the Schema in the current Context
|
|
44
35
|
* @param editor Current editor context.
|
|
@@ -58,13 +49,13 @@ async function locateSchema(editor, schemaName, version) {
|
|
|
58
49
|
return schema;
|
|
59
50
|
}
|
|
60
51
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @param left The first schema to be added.
|
|
63
|
-
* @param right The second schema to be added.
|
|
52
|
+
* Sorts the schemas and return them in order of their versions [older, latest].
|
|
53
|
+
* @param left The first schema key to be added.
|
|
54
|
+
* @param right The second schema key to be added.
|
|
64
55
|
* @returns The schemas in order.
|
|
65
56
|
*/
|
|
66
|
-
function
|
|
67
|
-
return left.
|
|
57
|
+
function sortSchemas(left, right) {
|
|
58
|
+
return left.compareByVersion(right) < 0
|
|
68
59
|
? [left, right]
|
|
69
60
|
: [right, left];
|
|
70
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaReferenceMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SchemaReferenceMerger.js","sourceRoot":"","sources":["../../../src/Merging/SchemaReferenceMerger.ts"],"names":[],"mappings":"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","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 { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaReferenceDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaContextEditor } from \"../Editing/Editor\";\r\nimport { ECVersion, Schema, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new reference to an external schema into the target schema.\r\n * @internal\r\n */\r\nexport async function addSchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\r\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\r\n await context.editor.addSchemaReference(context.targetSchemaKey, referencedSchema);\r\n}\r\n\r\n/**\r\n * Merges differences to an existing schema references in the target schema.\r\n * @internal\r\n */\r\nexport async function modifySchemaReferences(context: SchemaMergeContext, change: SchemaReferenceDifference) {\r\n const existingSchema = await context.targetSchema.getReference(change.difference.name) as Schema;\r\n const [older, latest] = sortSchemas(existingSchema.schemaKey, new SchemaKey(change.difference.name, ECVersion.fromString(change.difference.version)));\r\n if(latest === existingSchema.schemaKey) {\r\n return;\r\n }\r\n\r\n if(!latest.matches(older, SchemaMatchType.LatestWriteCompatible)) {\r\n throw new Error(`Schemas references of ${change.difference.name} have incompatible versions: ${older.version} and ${latest.version}`);\r\n }\r\n\r\n const index = context.targetSchema.references.findIndex((reference) => reference === existingSchema);\r\n context.targetSchema.references.splice(index, 1);\r\n\r\n const referencedSchema = await locateSchema(context.editor, change.difference.name, change.difference.version);\r\n await context.editor.addSchemaReference(context.targetSchema.schemaKey, referencedSchema);\r\n}\r\n\r\n/**\r\n * Tries to locate the Schema in the current Context\r\n * @param editor Current editor context.\r\n * @param schemaName The schema name to be looked up.\r\n * @param version The schemas version to beo looked up.\r\n * @returns The schema found in the context.\r\n */\r\nasync function locateSchema(editor: SchemaContextEditor, schemaName?: string, version?: string): Promise<Schema> {\r\n if(schemaName === undefined || version === undefined) {\r\n throw new Error(\"Schema name and version must not be undefined.\");\r\n }\r\n\r\n const schemaKey = new SchemaKey(schemaName, ECVersion.fromString(version));\r\n const schema = await editor.schemaContext.getSchema(schemaKey, SchemaMatchType.LatestWriteCompatible);\r\n if(schema === undefined) {\r\n throw new Error(`Referenced schema ${schemaKey.toString()} could not be found in target context`);\r\n }\r\n return schema;\r\n}\r\n\r\n/**\r\n * Sorts the schemas and return them in order of their versions [older, latest].\r\n * @param left The first schema key to be added.\r\n * @param right The second schema key to be added.\r\n * @returns The schemas in order.\r\n */\r\nfunction sortSchemas(left: SchemaKey, right: SchemaKey): [SchemaKey, SchemaKey] {\r\n return left.compareByVersion(right) < 0\r\n ? [left, right]\r\n : [right, left];\r\n}\r\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StructClassDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import type { SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
4
|
+
/**
|
|
5
|
+
* Merges a new StructClass into the target schema.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare function addStructClass(context: SchemaMergeContext, change: StructClassDifference): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Merges differences to an existing StructClass in the target schema.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function modifyStructClass(context: SchemaMergeContext, change: StructClassDifference, itemKey: SchemaItemKey): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=StructClassMerger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,qBAAqB,iBAK9F;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,qBAAqB,EAAE,OAAO,EAAE,aAAa,iBAGzH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modifyStructClass = exports.addStructClass = void 0;
|
|
4
|
+
const ClassMerger_1 = require("./ClassMerger");
|
|
5
|
+
/**
|
|
6
|
+
* Merges a new StructClass into the target schema.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
async function addStructClass(context, change) {
|
|
10
|
+
await context.editor.structs.createFromProps(context.targetSchemaKey, {
|
|
11
|
+
name: change.itemName,
|
|
12
|
+
...change.difference,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.addStructClass = addStructClass;
|
|
16
|
+
/**
|
|
17
|
+
* Merges differences to an existing StructClass in the target schema.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
async function modifyStructClass(context, change, itemKey) {
|
|
21
|
+
const item = await context.targetSchema.lookupItem(itemKey);
|
|
22
|
+
return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
|
|
23
|
+
}
|
|
24
|
+
exports.modifyStructClass = modifyStructClass;
|
|
25
|
+
//# sourceMappingURL=StructClassMerger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StructClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/StructClassMerger.ts"],"names":[],"mappings":";;;AAQA,+CAA4C;AAE5C;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,OAA2B,EAAE,MAA6B;IAC7F,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACpE,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,GAAG,MAAM,CAAC,UAAU;KACrB,CAAC,CAAC;AACL,CAAC;AALD,wCAKC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,OAA2B,EAAE,MAA6B,EAAE,OAAsB;IACxH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAiB,CAAC;IAC5E,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAHD,8CAGC","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 { StructClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { MutableClass } from \"../Editing/Mutable/MutableClass\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Merges a new StructClass into the target schema.\r\n * @internal\r\n */\r\nexport async function addStructClass(context: SchemaMergeContext, change: StructClassDifference) {\r\n await context.editor.structs.createFromProps(context.targetSchemaKey, {\r\n name: change.itemName,\r\n ...change.difference,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing StructClass in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyStructClass(context: SchemaMergeContext, change: StructClassDifference, itemKey: SchemaItemKey) {\r\n const item = await context.targetSchema.lookupItem(itemKey) as MutableClass;\r\n return modifyClass(context, change, itemKey, item);\r\n}\r\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { UnitSystemDifference } from "../Differencing/SchemaDifference";
|
|
2
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
3
|
+
import type { SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Merges a new UnitSystem into the target schema.
|
|
5
6
|
* @internal
|
|
6
7
|
*/
|
|
7
|
-
export declare
|
|
8
|
+
export declare function addUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Merges differences to an existing UnitSystem in the target schema.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function modifyUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference, itemKey: SchemaItemKey): Promise<void>;
|
|
8
14
|
//# sourceMappingURL=UnitSystemMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UnitSystemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,iBAM5F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,iBAOvH"}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.modifyUnitSystem = exports.addUnitSystem = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Merges a new UnitSystem into the target schema.
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
8
|
+
async function addUnitSystem(context, change) {
|
|
9
|
+
await context.editor.unitSystems.createFromProps(context.targetSchemaKey, {
|
|
10
|
+
...change.difference,
|
|
11
|
+
name: change.itemName,
|
|
12
|
+
schemaItemType: change.schemaType,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.addUnitSystem = addUnitSystem;
|
|
16
|
+
/**
|
|
17
|
+
* Merges differences to an existing UnitSystem in the target schema.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
async function modifyUnitSystem(context, change, itemKey) {
|
|
21
|
+
if (change.difference.label !== undefined) {
|
|
22
|
+
await context.editor.unitSystems.setDisplayLabel(itemKey, change.difference.label);
|
|
23
|
+
}
|
|
24
|
+
if (change.difference.description !== undefined) {
|
|
25
|
+
await context.editor.unitSystems.setDescription(itemKey, change.difference.description);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.modifyUnitSystem = modifyUnitSystem;
|
|
25
29
|
//# sourceMappingURL=UnitSystemMerger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"UnitSystemMerger.js","sourceRoot":"","sources":["../../../src/Merging/UnitSystemMerger.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,OAA2B,EAAE,MAA4B;IAC3F,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;QACxE,GAAG,MAAM,CAAC,UAAU;QACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;QACrB,cAAc,EAAE,MAAM,CAAC,UAAU;KAClC,CAAC,CAAC;AACL,CAAC;AAND,sCAMC;AAED;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,MAA4B,EAAE,OAAsB;IACtH,IAAG,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrF,CAAC;IACD,IAAG,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAPD,4CAOC","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 { UnitSystemDifference } from \"../Differencing/SchemaDifference\";\r\nimport type { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport type { SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Merges a new UnitSystem into the target schema.\r\n * @internal\r\n */\r\nexport async function addUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference) {\r\n await context.editor.unitSystems.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n });\r\n}\r\n\r\n/**\r\n * Merges differences to an existing UnitSystem in the target schema.\r\n * @internal\r\n */\r\nexport async function modifyUnitSystem(context: SchemaMergeContext, change: UnitSystemDifference, itemKey: SchemaItemKey) {\r\n if(change.difference.label !== undefined) {\r\n await context.editor.unitSystems.setDisplayLabel(itemKey, change.difference.label);\r\n }\r\n if(change.difference.description !== undefined) {\r\n await context.editor.unitSystems.setDescription(itemKey, change.difference.description);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
2
|
+
import { SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
3
|
+
/**
|
|
4
|
+
* Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function updateSchemaItemFullName(context: SchemaMergeContext, reference: string): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Updates the given reference if it refers to a SchemaItem in the source Schema and
|
|
10
|
+
* returns a SchemaItemKey. If any other schema is referred the reference is not change.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function updateSchemaItemKey(context: SchemaMergeContext, reference: string): Promise<SchemaItemKey>;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string): Promise<SchemaItem>;
|
|
18
|
+
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAkD,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAErH;;;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,0BAYvF;AAgBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAQvG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.locateSchemaItem = exports.updateSchemaItemKey = exports.updateSchemaItemFullName = void 0;
|
|
4
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
|
+
/**
|
|
6
|
+
* Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
async function updateSchemaItemFullName(context, reference) {
|
|
10
|
+
const schemaItemKey = await updateSchemaItemKey(context, reference);
|
|
11
|
+
return schemaItemKey.fullName;
|
|
12
|
+
}
|
|
13
|
+
exports.updateSchemaItemFullName = updateSchemaItemFullName;
|
|
14
|
+
/**
|
|
15
|
+
* Updates the given reference if it refers to a SchemaItem in the source Schema and
|
|
16
|
+
* returns a SchemaItemKey. If any other schema is referred the reference is not change.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
async function updateSchemaItemKey(context, reference) {
|
|
20
|
+
const [schemaName, itemName] = ecschema_metadata_1.SchemaItem.parseFullName(reference);
|
|
21
|
+
if (context.sourceSchemaKey.compareByName(schemaName)) {
|
|
22
|
+
return resolveSchemaItemKey(context.editor.schemaContext, new ecschema_metadata_1.SchemaItemKey(itemName, context.targetSchemaKey));
|
|
23
|
+
}
|
|
24
|
+
const referencedSchema = await context.targetSchema.getReference(schemaName);
|
|
25
|
+
if (referencedSchema !== undefined) {
|
|
26
|
+
return resolveSchemaItemKey(context.editor.schemaContext, new ecschema_metadata_1.SchemaItemKey(itemName, referencedSchema.schemaKey));
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Cannot locate referenced schema item ${reference}`);
|
|
29
|
+
}
|
|
30
|
+
exports.updateSchemaItemKey = updateSchemaItemKey;
|
|
31
|
+
/**
|
|
32
|
+
* To support case insensitivity for schema items, the given key is checked if there
|
|
33
|
+
* exists an item for it.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
async function resolveSchemaItemKey(schemaContext, itemKey) {
|
|
37
|
+
const item = await schemaContext.getSchemaItem(itemKey);
|
|
38
|
+
if (item === undefined) {
|
|
39
|
+
// If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.
|
|
40
|
+
return itemKey;
|
|
41
|
+
}
|
|
42
|
+
return item.key;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
async function locateSchemaItem(context, itemName, schemaType) {
|
|
48
|
+
const schemaItemKey = new ecschema_metadata_1.SchemaItemKey(itemName, context.targetSchemaKey);
|
|
49
|
+
const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);
|
|
50
|
+
if (schemaItem === undefined) {
|
|
51
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);
|
|
52
|
+
}
|
|
53
|
+
return schemaItem;
|
|
54
|
+
}
|
|
55
|
+
exports.locateSchemaItem = locateSchemaItem;
|
|
56
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/Merging/Utils.ts"],"names":[],"mappings":";;;AAKA,gEAAqH;AAErH;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA2B,EAAE,SAAiB;IAC3F,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpE,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChC,CAAC;AAHD,4DAGC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CAAC,OAA2B,EAAE,SAAiB;IACtF,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,8BAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACnE,IAAI,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,OAAO,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAClH,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC7E,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,iCAAa,CAAC,QAAQ,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IACrH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wCAAwC,SAAS,EAAE,CAAC,CAAC;AACvE,CAAC;AAZD,kDAYC;AAED;;;;GAIG;AACH,KAAK,UAAU,oBAAoB,CAAC,aAA4B,EAAE,OAAsB;IACtF,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACxD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,mGAAmG;QACnG,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC;AAClB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAA2B,EAAE,QAAgB,EAAE,UAAkB;IACtG,MAAM,aAAa,GAAG,IAAI,iCAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IACnF,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,GAAG,UAAU,IAAI,aAAa,CAAC,QAAQ,+BAA+B,CAAC,CAAC;IAClI,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AARD,4CAQC","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 { SchemaMergeContext } from \"./SchemaMerger\";\r\nimport { ECObjectsError, ECObjectsStatus, SchemaContext, SchemaItem, SchemaItemKey } from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.\r\n * @internal\r\n */\r\nexport async function updateSchemaItemFullName(context: SchemaMergeContext, reference: string) {\r\n const schemaItemKey = await updateSchemaItemKey(context, reference);\r\n return schemaItemKey.fullName;\r\n}\r\n\r\n/**\r\n * Updates the given reference if it refers to a SchemaItem in the source Schema and\r\n * returns a SchemaItemKey. If any other schema is referred the reference is not change.\r\n * @internal\r\n */\r\nexport async function updateSchemaItemKey(context: SchemaMergeContext, reference: string) {\r\n const [schemaName, itemName] = SchemaItem.parseFullName(reference);\r\n if (context.sourceSchemaKey.compareByName(schemaName)) {\r\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, context.targetSchemaKey));\r\n }\r\n\r\n const referencedSchema = await context.targetSchema.getReference(schemaName);\r\n if (referencedSchema !== undefined) {\r\n return resolveSchemaItemKey(context.editor.schemaContext, new SchemaItemKey(itemName, referencedSchema.schemaKey));\r\n }\r\n\r\n throw new Error(`Cannot locate referenced schema item ${reference}`);\r\n}\r\n\r\n/**\r\n * To support case insensitivity for schema items, the given key is checked if there\r\n * exists an item for it.\r\n * @internal\r\n */\r\nasync function resolveSchemaItemKey(schemaContext: SchemaContext, itemKey: SchemaItemKey): Promise<SchemaItemKey> {\r\n const item = await schemaContext.getSchemaItem(itemKey);\r\n if (item === undefined) {\r\n // If the schema item hasn't been created yet, we have to trust the given key is correctly spelled.\r\n return itemKey;\r\n }\r\n return item.key;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport async function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string) {\r\n const schemaItemKey = new SchemaItemKey(itemName, context.targetSchemaKey);\r\n const schemaItem = await context.editor.schemaContext.getSchemaItem(schemaItemKey);\r\n if (schemaItem === undefined) {\r\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `${schemaType} ${schemaItemKey.fullName} not found in schema context.`);\r\n }\r\n\r\n return schemaItem;\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/ecschema-editing",
|
|
3
|
-
"version": "4.10.0-dev.
|
|
3
|
+
"version": "4.10.0-dev.2",
|
|
4
4
|
"description": "ECSchema editing and validation API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/cjs/ecschema-editing.js",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"rimraf": "^3.0.2",
|
|
42
42
|
"sinon": "^17.0.2",
|
|
43
43
|
"typescript": "~5.3.3",
|
|
44
|
-
"@itwin/
|
|
45
|
-
"@itwin/
|
|
46
|
-
"@itwin/core-
|
|
47
|
-
"@itwin/
|
|
48
|
-
"@itwin/
|
|
44
|
+
"@itwin/build-tools": "4.10.0-dev.2",
|
|
45
|
+
"@itwin/core-common": "4.10.0-dev.2",
|
|
46
|
+
"@itwin/core-bentley": "4.10.0-dev.2",
|
|
47
|
+
"@itwin/core-quantity": "4.10.0-dev.2",
|
|
48
|
+
"@itwin/ecschema-metadata": "4.10.0-dev.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@itwin/core-bentley": "^4.10.0-dev.
|
|
52
|
-
"@itwin/core-quantity": "^4.10.0-dev.
|
|
53
|
-
"@itwin/ecschema-metadata": "^4.10.0-dev.
|
|
51
|
+
"@itwin/core-bentley": "^4.10.0-dev.2",
|
|
52
|
+
"@itwin/core-quantity": "^4.10.0-dev.2",
|
|
53
|
+
"@itwin/ecschema-metadata": "^4.10.0-dev.2"
|
|
54
54
|
},
|
|
55
55
|
"nyc": {
|
|
56
56
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type CustomAttributeClassDifference } from "../Differencing/SchemaDifference";
|
|
2
|
-
import { type SchemaItemMergerHandler } from "./SchemaItemMerger";
|
|
3
|
-
/**
|
|
4
|
-
* Defines a merge handler to merge Custom Attribute Class schema items.
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare const customAttributeClassMerger: SchemaItemMergerHandler<CustomAttributeClassDifference>;
|
|
8
|
-
//# sourceMappingURL=CAClassMerger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CAClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AACvF,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAKlE;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,uBAAuB,CAAC,8BAA8B,CA0B9F,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customAttributeClassMerger = void 0;
|
|
4
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
5
|
-
const ClassMerger_1 = require("./ClassMerger");
|
|
6
|
-
/**
|
|
7
|
-
* Defines a merge handler to merge Custom Attribute Class schema items.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
exports.customAttributeClassMerger = {
|
|
11
|
-
async add(context, change) {
|
|
12
|
-
if (change.difference.appliesTo === undefined) {
|
|
13
|
-
throw new Error("appliesTo is a required property of a CustomAttributeClass but it is not set");
|
|
14
|
-
}
|
|
15
|
-
return context.editor.customAttributes.createFromProps(context.targetSchemaKey, {
|
|
16
|
-
...change.difference,
|
|
17
|
-
name: change.itemName,
|
|
18
|
-
schemaItemType: change.schemaType,
|
|
19
|
-
appliesTo: change.difference.appliesTo,
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
async modify(context, change, itemKey, item) {
|
|
23
|
-
if (change.difference.appliesTo !== undefined) {
|
|
24
|
-
const currentValue = (0, ecschema_metadata_1.containerTypeToString)(item.appliesTo);
|
|
25
|
-
if (currentValue !== "" && change.difference.appliesTo !== currentValue) {
|
|
26
|
-
const containerType = (0, ecschema_metadata_1.parseCustomAttributeContainerType)(`${currentValue}, ${change.difference.appliesTo}`);
|
|
27
|
-
if (containerType === undefined) {
|
|
28
|
-
throw new Error("An invalid custom attribute class containerType has been provided.");
|
|
29
|
-
}
|
|
30
|
-
item.setAppliesTo(containerType);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return (0, ClassMerger_1.modifyClass)(context, change, itemKey, item);
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=CAClassMerger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CAClassMerger.js","sourceRoot":"","sources":["../../../src/Merging/CAClassMerger.ts"],"names":[],"mappings":";;;AAOA,gEAAoG;AACpG,+CAA4C;AAE5C;;;GAGG;AACU,QAAA,0BAA0B,GAA4D;IACjG,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM;QACvB,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;QAClG,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,eAAe,EAAE;YAC9E,GAAG,MAAM,CAAC,UAAU;YACpB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,cAAc,EAAE,MAAM,CAAC,UAAU;YACjC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;SACvC,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAoB;QACzD,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC9C,MAAM,YAAY,GAAG,IAAA,yCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3D,IAAI,YAAY,KAAK,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;gBACxE,MAAM,aAAa,GAAG,IAAA,qDAAiC,EAAC,GAAG,YAAY,KAAK,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;gBAC3G,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;oBAChC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;gBACxF,CAAC;gBACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,IAAA,yBAAW,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;CACF,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 CustomAttributeClassDifference } from \"../Differencing/SchemaDifference\";\r\nimport { type SchemaItemMergerHandler } from \"./SchemaItemMerger\";\r\nimport { type MutableCAClass } from \"../Editing/Mutable/MutableCAClass\";\r\nimport { containerTypeToString, parseCustomAttributeContainerType } from \"@itwin/ecschema-metadata\";\r\nimport { modifyClass } from \"./ClassMerger\";\r\n\r\n/**\r\n * Defines a merge handler to merge Custom Attribute Class schema items.\r\n * @internal\r\n */\r\nexport const customAttributeClassMerger: SchemaItemMergerHandler<CustomAttributeClassDifference> = {\r\n async add(context, change) {\r\n if (change.difference.appliesTo === undefined) {\r\n throw new Error(\"appliesTo is a required property of a CustomAttributeClass but it is not set\");\r\n }\r\n\r\n return context.editor.customAttributes.createFromProps(context.targetSchemaKey, {\r\n ...change.difference,\r\n name: change.itemName,\r\n schemaItemType: change.schemaType,\r\n appliesTo: change.difference.appliesTo,\r\n });\r\n },\r\n async modify(context, change, itemKey, item: MutableCAClass) {\r\n if (change.difference.appliesTo !== undefined) {\r\n const currentValue = containerTypeToString(item.appliesTo);\r\n if (currentValue !== \"\" && change.difference.appliesTo !== currentValue) {\r\n const containerType = parseCustomAttributeContainerType(`${currentValue}, ${change.difference.appliesTo}`);\r\n if (containerType === undefined) {\r\n throw new Error(\"An invalid custom attribute class containerType has been provided.\");\r\n }\r\n item.setAppliesTo(containerType);\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n },\r\n};\r\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { SchemaMergeContext } from "./SchemaMerger";
|
|
2
|
-
import { AnySchemaDifference, AnySchemaItemDifference, AnySchemaItemPathDifference } from "../Differencing/SchemaDifference";
|
|
3
|
-
import { SchemaItem, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export interface SchemaItemMergerHandler<T extends AnySchemaItemDifference | AnySchemaItemPathDifference> {
|
|
8
|
-
add: (context: SchemaMergeContext, difference: T) => Promise<SchemaItemKey>;
|
|
9
|
-
modify: (context: SchemaMergeContext, difference: T, itemKey: SchemaItemKey, item: any) => Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare function locateSchemaItem(context: SchemaMergeContext, itemName: string, schemaType: string): Promise<SchemaItem>;
|
|
15
|
-
/**
|
|
16
|
-
* Merges the given set of schema items. As schema items may depend or relate with other
|
|
17
|
-
* schema items, the list gets filtered to ensure the items get merged in a certain order.
|
|
18
|
-
* @param context The current merging context.
|
|
19
|
-
* @param differences Set of schema item that differed.
|
|
20
|
-
* @returns An async iterable with the merge result for each schema item.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare function mergeSchemaItems(context: SchemaMergeContext, differences: AnySchemaDifference[]): AsyncGenerator<void, void, unknown>;
|
|
24
|
-
/**
|
|
25
|
-
* Convenience-method around updateSchemaItemKey that returns the full name instead of a SchemaItemKey.
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare function updateSchemaItemFullName(context: SchemaMergeContext, reference: string): Promise<string>;
|
|
29
|
-
/**
|
|
30
|
-
* Updates the given reference if it refers to a SchemaItem in the source Schema and
|
|
31
|
-
* returns a SchemaItemKey. If any other schema is referred the reference is not change.
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
export declare function updateSchemaItemKey(context: SchemaMergeContext, reference: string): Promise<SchemaItemKey>;
|
|
35
|
-
//# sourceMappingURL=SchemaItemMerger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItemMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/SchemaItemMerger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC7H,OAAO,EAAkD,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAUrH;;GAEG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,uBAAuB,GAAG,2BAA2B;IACtG,GAAG,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5E,MAAM,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1G;AAoBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAQvG;AAED;;;;;;;GAOG;AACH,wBAAuB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,uCAwCtG;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,0BAYvF"}
|