@itwin/ecschema-editing 4.7.0-dev.15 → 4.7.0-dev.17
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/Editing/Constants.d.ts +6 -6
- package/lib/cjs/Editing/Constants.d.ts.map +1 -1
- package/lib/cjs/Editing/Constants.js +26 -31
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +3 -3
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +18 -28
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +24 -23
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +126 -156
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +10 -31
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +59 -43
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +9 -9
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +65 -85
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +6 -6
- package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
- package/lib/cjs/Editing/Enumerations.js +57 -55
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- package/lib/cjs/Editing/Exception.d.ts +257 -0
- package/lib/cjs/Editing/Exception.d.ts.map +1 -0
- package/lib/cjs/Editing/Exception.js +426 -0
- package/lib/cjs/Editing/Exception.js.map +1 -0
- package/lib/cjs/Editing/Formats.d.ts +6 -6
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +28 -33
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +6 -6
- package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js +41 -56
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +6 -6
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +50 -57
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +5 -5
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +43 -58
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +1 -5
- package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js +1 -45
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.d.ts +7 -7
- package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
- package/lib/cjs/Editing/Phenomena.js +23 -23
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/Properties.d.ts +7 -6
- package/lib/cjs/Editing/Properties.d.ts.map +1 -1
- package/lib/cjs/Editing/Properties.js +99 -46
- package/lib/cjs/Editing/Properties.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts +6 -6
- package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js +29 -27
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +15 -17
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +97 -101
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/SchemaItems.d.ts +13 -5
- package/lib/cjs/Editing/SchemaItems.d.ts.map +1 -1
- package/lib/cjs/Editing/SchemaItems.js +58 -6
- package/lib/cjs/Editing/SchemaItems.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +3 -3
- package/lib/cjs/Editing/Structs.d.ts.map +1 -1
- package/lib/cjs/Editing/Structs.js +17 -27
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.d.ts +7 -7
- package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js +22 -20
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- package/lib/cjs/Editing/Units.d.ts +6 -6
- package/lib/cjs/Editing/Units.d.ts.map +1 -1
- package/lib/cjs/Editing/Units.js +26 -35
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Merging/CAClassMerger.js +2 -2
- package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ClassMerger.d.ts +1 -2
- package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ClassMerger.js +15 -39
- package/lib/cjs/Merging/ClassMerger.js.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/ConstantMerger.js +2 -3
- package/lib/cjs/Merging/ConstantMerger.js.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts +4 -5
- package/lib/cjs/Merging/CustomAttributeMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/CustomAttributeMerger.js +8 -18
- package/lib/cjs/Merging/CustomAttributeMerger.js.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.d.ts +1 -2
- package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EntityClassMerger.js +3 -10
- package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/EnumerationMerger.js +8 -10
- package/lib/cjs/Merging/EnumerationMerger.js.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/KindOfQuantityMerger.js +2 -3
- package/lib/cjs/Merging/KindOfQuantityMerger.js.map +1 -1
- package/lib/cjs/Merging/MixinMerger.js +2 -2
- package/lib/cjs/Merging/MixinMerger.js.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PhenomenonMerger.js +1 -2
- package/lib/cjs/Merging/PhenomenonMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyCategoryMerger.js +1 -2
- package/lib/cjs/Merging/PropertyCategoryMerger.js.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.d.ts +2 -3
- package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/PropertyMerger.js +21 -42
- package/lib/cjs/Merging/PropertyMerger.js.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts +5 -3
- package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/RelationshipClassMerger.js +19 -31
- package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.d.ts +3 -4
- package/lib/cjs/Merging/SchemaItemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaItemMerger.js +3 -2
- package/lib/cjs/Merging/SchemaItemMerger.js.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/SchemaMerger.js +2 -8
- package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.d.ts.map +1 -1
- package/lib/cjs/Merging/UnitSystemMerger.js +1 -2
- package/lib/cjs/Merging/UnitSystemMerger.js.map +1 -1
- package/package.json +9 -9
|
@@ -9,19 +9,71 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.SchemaItems = void 0;
|
|
11
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const Exception_1 = require("./Exception");
|
|
12
13
|
/**
|
|
13
14
|
* @internal
|
|
14
15
|
* A class allowing you to edit the schema item base class.
|
|
15
16
|
*/
|
|
16
17
|
class SchemaItems {
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
18
|
+
constructor(schemaItemType, schemaEditor) {
|
|
19
|
+
this.schemaItemType = schemaItemType;
|
|
20
|
+
this.schemaEditor = schemaEditor;
|
|
19
21
|
}
|
|
20
|
-
async
|
|
21
|
-
const
|
|
22
|
+
async getSchema(schemaKey) {
|
|
23
|
+
const schema = await this.schemaEditor.getSchema(schemaKey);
|
|
24
|
+
if (schema === undefined)
|
|
25
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaNotFound, new Exception_1.SchemaId(schemaKey));
|
|
26
|
+
return schema;
|
|
27
|
+
}
|
|
28
|
+
async getSchemaItem(schemaItemKey, schemaItemType) {
|
|
29
|
+
const schemaItem = await this.schemaEditor.schemaContext.getSchemaItem(schemaItemKey);
|
|
30
|
+
schemaItemType = schemaItemType === null ? undefined : schemaItemType ?? this.schemaItemType;
|
|
31
|
+
if (!schemaItem) {
|
|
32
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNotFoundInContext, new Exception_1.SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));
|
|
33
|
+
}
|
|
34
|
+
if (schemaItemType && schemaItemType !== schemaItem.schemaItemType) {
|
|
35
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidSchemaItemType, new Exception_1.SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));
|
|
36
|
+
}
|
|
37
|
+
return schemaItem;
|
|
38
|
+
}
|
|
39
|
+
async lookupSchemaItem(schemaOrKey, schemaItemKey, schemaItemType) {
|
|
40
|
+
schemaItemType = schemaItemType === null ? undefined : schemaItemType ?? this.schemaItemType;
|
|
41
|
+
let schema;
|
|
42
|
+
if (schemaOrKey instanceof ecschema_metadata_1.SchemaKey) {
|
|
43
|
+
schema = await this.getSchema(schemaOrKey);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
schema = schemaOrKey;
|
|
47
|
+
}
|
|
48
|
+
const schemaItem = await schema.lookupItem(schemaItemKey);
|
|
22
49
|
if (schemaItem === undefined)
|
|
23
|
-
throw new
|
|
24
|
-
|
|
50
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNotFound, new Exception_1.SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));
|
|
51
|
+
if (schemaItemType && schemaItemType !== schemaItem.schemaItemType) {
|
|
52
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.InvalidSchemaItemType, new Exception_1.SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));
|
|
53
|
+
}
|
|
54
|
+
return schemaItem;
|
|
55
|
+
}
|
|
56
|
+
async createSchemaItem(schemaKey, type, create, name, ...args) {
|
|
57
|
+
const schema = await this.getSchema(schemaKey);
|
|
58
|
+
try {
|
|
59
|
+
const boundCreate = create(schema);
|
|
60
|
+
return await boundCreate(name, ...args);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
if (e instanceof ecschema_metadata_1.ECObjectsError && e.errorNumber === ecschema_metadata_1.ECObjectsStatus.DuplicateItem) {
|
|
64
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNameAlreadyExists, new Exception_1.SchemaItemId(type, name, schema.schemaKey));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async createSchemaItemFromProps(schemaKey, type, create, props) {
|
|
72
|
+
if (props.name === undefined)
|
|
73
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.SchemaItemNameNotSpecified, new Exception_1.SchemaItemId(type, "", schemaKey));
|
|
74
|
+
const newItem = await this.createSchemaItem(schemaKey, type, create, props.name);
|
|
75
|
+
await newItem.fromJSON(props);
|
|
76
|
+
return newItem;
|
|
25
77
|
}
|
|
26
78
|
}
|
|
27
79
|
exports.SchemaItems = SchemaItems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"SchemaItems.js","sourceRoot":"","sources":["../../../src/Editing/SchemaItems.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\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { ECObjectsError, ECObjectsStatus, Schema, SchemaItem, SchemaItemKey, SchemaItemProps, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaId, SchemaItemId } from \"./Exception\";\r\nimport { MutableSchema } from \"./Mutable/MutableSchema\";\r\n\r\nexport type CreateSchemaItem<T extends SchemaItem> = (schema: MutableSchema) => (name: string, ...args: any[]) => Promise<T>;\r\nexport type CreateSchemaItemFromProps<T extends SchemaItem> = (props: SchemaItemProps, ...args: any[]) => Promise<T>;\r\n\r\n/**\r\n * @internal\r\n * A class allowing you to edit the schema item base class.\r\n */\r\nexport abstract class SchemaItems {\r\n protected schemaItemType: SchemaItemType;\r\n protected schemaEditor: SchemaContextEditor;\r\n\r\n public constructor(schemaItemType: SchemaItemType, schemaEditor: SchemaContextEditor) {\r\n this.schemaItemType = schemaItemType;\r\n this.schemaEditor = schemaEditor;\r\n }\r\n\r\n protected async getSchema(schemaKey: SchemaKey): Promise<MutableSchema> {\r\n const schema = await this.schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaNotFound, new SchemaId(schemaKey));\r\n\r\n return schema;\r\n }\r\n\r\n protected async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType | null): Promise<T>{\r\n const schemaItem = await this.schemaEditor.schemaContext.getSchemaItem<T>(schemaItemKey);\r\n schemaItemType = schemaItemType === null ? undefined : schemaItemType ?? this.schemaItemType;\r\n\r\n if (!schemaItem) {\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFoundInContext, new SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));\r\n }\r\n\r\n if (schemaItemType && schemaItemType !== schemaItem.schemaItemType) {\r\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));\r\n }\r\n\r\n return schemaItem;\r\n }\r\n\r\n protected async lookupSchemaItem<T extends SchemaItem>(schemaOrKey: MutableSchema | SchemaKey, schemaItemKey: SchemaItemKey, schemaItemType?: SchemaItemType | null): Promise<T>{\r\n schemaItemType = schemaItemType === null ? undefined : schemaItemType ?? this.schemaItemType;\r\n\r\n let schema: Schema;\r\n if (schemaOrKey instanceof SchemaKey) {\r\n schema = await this.getSchema(schemaOrKey);\r\n } else {\r\n schema = schemaOrKey;\r\n }\r\n\r\n const schemaItem = await schema.lookupItem<T>(schemaItemKey);\r\n if (schemaItem === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNotFound, new SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));\r\n\r\n if (schemaItemType && schemaItemType !== schemaItem.schemaItemType) {\r\n throw new SchemaEditingError(ECEditingStatus.InvalidSchemaItemType, new SchemaItemId(schemaItemType ?? this.schemaItemType, schemaItemKey));\r\n }\r\n\r\n return schemaItem;\r\n }\r\n\r\n protected async createSchemaItem<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, name: string, ...args: any[]): Promise<T> {\r\n const schema = await this.getSchema(schemaKey);\r\n try {\r\n const boundCreate = create(schema);\r\n return await boundCreate(name, ...args);\r\n } catch (e) {\r\n if (e instanceof ECObjectsError && e.errorNumber === ECObjectsStatus.DuplicateItem) {\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameAlreadyExists, new SchemaItemId(type, name, schema.schemaKey));\r\n } else {\r\n throw new Error(`Failed to create class ${name} in schema ${schema.fullName}.`);\r\n }\r\n }\r\n }\r\n\r\n protected async createSchemaItemFromProps<T extends SchemaItem>(schemaKey: SchemaKey, type: SchemaItemType, create: CreateSchemaItem<T>, props: SchemaItemProps): Promise<T> {\r\n if (props.name === undefined)\r\n throw new SchemaEditingError(ECEditingStatus.SchemaItemNameNotSpecified, new SchemaItemId(type, \"\", schemaKey));\r\n\r\n const newItem = await this.createSchemaItem<T>(schemaKey, type, create, props.name);\r\n await newItem.fromJSON(props);\r\n\r\n return newItem;\r\n }\r\n}\r\n"]}
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
4
|
import { SchemaItemKey, SchemaKey, StructClassProps } from "@itwin/ecschema-metadata";
|
|
5
|
-
import { SchemaContextEditor
|
|
5
|
+
import { SchemaContextEditor } from "./Editor";
|
|
6
6
|
import { ECClasses } from "./ECClasses";
|
|
7
7
|
/**
|
|
8
8
|
* @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
|
|
9
9
|
*/
|
|
10
10
|
export declare class Structs extends ECClasses {
|
|
11
11
|
constructor(schemaEditor: SchemaContextEditor);
|
|
12
|
-
create(schemaKey: SchemaKey, name: string, displayLabel?: string,
|
|
12
|
+
create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey>;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a StructClass through a StructClassProps.
|
|
15
15
|
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
16
16
|
* @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.
|
|
17
17
|
*/
|
|
18
|
-
createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<
|
|
18
|
+
createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemKey>;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=Structs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Structs.d.ts","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"Structs.d.ts","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAe,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;GAEG;AACH,qBAAa,OAAQ,SAAQ,SAAS;gBACjB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAapI;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ1G"}
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.Structs = void 0;
|
|
11
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
12
|
const ECClasses_1 = require("./ECClasses");
|
|
13
|
+
const Exception_1 = require("./Exception");
|
|
13
14
|
/**
|
|
14
15
|
* @alpha A class extending ECClasses allowing you to create schema items of type StructClass.
|
|
15
16
|
*/
|
|
@@ -17,24 +18,16 @@ class Structs extends ECClasses_1.ECClasses {
|
|
|
17
18
|
constructor(schemaEditor) {
|
|
18
19
|
super(ecschema_metadata_1.SchemaItemType.StructClass, schemaEditor);
|
|
19
20
|
}
|
|
20
|
-
async create(schemaKey, name, displayLabel,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (baseClassItem === undefined)
|
|
30
|
-
return { errorMessage: `Unable to locate base class ${baseClass.fullName} in schema ${schema.fullName}.` };
|
|
31
|
-
if (baseClassItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.StructClass)
|
|
32
|
-
return { errorMessage: `${baseClassItem.fullName} is not of type Struct Class.` };
|
|
33
|
-
newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
|
|
21
|
+
async create(schemaKey, name, displayLabel, baseClassKey) {
|
|
22
|
+
try {
|
|
23
|
+
const newClass = await this.createClass(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey);
|
|
24
|
+
if (displayLabel)
|
|
25
|
+
newClass.setDisplayLabel(displayLabel);
|
|
26
|
+
return newClass.key;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFailed, new Exception_1.ClassId(this.schemaItemType, name, schemaKey), e);
|
|
34
30
|
}
|
|
35
|
-
if (displayLabel)
|
|
36
|
-
newClass.setDisplayLabel(displayLabel);
|
|
37
|
-
return { itemKey: newClass.key };
|
|
38
31
|
}
|
|
39
32
|
/**
|
|
40
33
|
* Creates a StructClass through a StructClassProps.
|
|
@@ -42,16 +35,13 @@ class Structs extends ECClasses_1.ECClasses {
|
|
|
42
35
|
* @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.
|
|
43
36
|
*/
|
|
44
37
|
async createFromProps(schemaKey, structProps) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return { errorMessage: `Failed to create class ${structProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
53
|
-
await newClass.fromJSON(structProps);
|
|
54
|
-
return { itemKey: newClass.key };
|
|
38
|
+
try {
|
|
39
|
+
const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);
|
|
40
|
+
return newClass.key;
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFromProps, new Exception_1.ClassId(this.schemaItemType, structProps.name, schemaKey), e);
|
|
44
|
+
}
|
|
55
45
|
}
|
|
56
46
|
}
|
|
57
47
|
exports.Structs = Structs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"Structs.js","sourceRoot":"","sources":["../../../src/Editing/Structs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAmH;AAEnH,2CAAwC;AAExC,2CAA2E;AAE3E;;GAEG;AACH,MAAa,OAAQ,SAAQ,qBAAS;IACpC,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB,EAAE,YAA4B;QACzG,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAc,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,YAAY,CAAuB,CAAC;YAElL,IAAI,YAAY;gBACd,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAEzC,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAA6B;QAC9E,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;YACtJ,OAAO,QAAQ,CAAC,GAAG,CAAC;QACtB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,mBAAO,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;CACF;AA/BD,0BA+BC","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\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { SchemaItemKey, SchemaItemType, SchemaKey, StructClass, StructClassProps } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { ECClasses } from \"./ECClasses\";\r\nimport { MutableStructClass } from \"./Mutable/MutableClass\";\r\nimport { ClassId, ECEditingStatus, SchemaEditingError } from \"./Exception\";\r\n\r\n/**\r\n * @alpha A class extending ECClasses allowing you to create schema items of type StructClass.\r\n */\r\nexport class Structs extends ECClasses {\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.StructClass, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string, baseClassKey?: SchemaItemKey): Promise<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createClass<StructClass>(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), name, baseClassKey) as MutableStructClass;\r\n\r\n if (displayLabel)\r\n newClass.setDisplayLabel(displayLabel);\r\n\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new ClassId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n /**\r\n * Creates a StructClass through a StructClassProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param structProps a json object that will be used to populate the new StructClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, structProps: StructClassProps): Promise<SchemaItemKey> {\r\n try {\r\n const newClass = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createStructClass.bind(schema), structProps);\r\n return newClass.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new ClassId(this.schemaItemType, structProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
|
-
import { SchemaKey, UnitSystemProps } from "@itwin/ecschema-metadata";
|
|
5
|
-
import { SchemaContextEditor
|
|
4
|
+
import { SchemaItemKey, SchemaKey, UnitSystemProps } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { SchemaContextEditor } from "./Editor";
|
|
6
|
+
import { SchemaItems } from "./SchemaItems";
|
|
6
7
|
/**
|
|
7
8
|
* @alpha
|
|
8
9
|
* A class allowing you to create schema items of type UnitSystems.
|
|
9
10
|
*/
|
|
10
|
-
export declare class UnitSystems {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemEditResults>;
|
|
11
|
+
export declare class UnitSystems extends SchemaItems {
|
|
12
|
+
constructor(schemaEditor: SchemaContextEditor);
|
|
13
|
+
create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey>;
|
|
14
|
+
createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey>;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=UnitSystems.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystems.d.ts","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"UnitSystems.d.ts","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAkB,SAAS,EAAc,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAY,SAAQ,WAAW;gBACvB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAczF,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ7G"}
|
|
@@ -8,34 +8,36 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.UnitSystems = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const Exception_1 = require("./Exception");
|
|
13
|
+
const SchemaItems_1 = require("./SchemaItems");
|
|
11
14
|
/**
|
|
12
15
|
* @alpha
|
|
13
16
|
* A class allowing you to create schema items of type UnitSystems.
|
|
14
17
|
*/
|
|
15
|
-
class UnitSystems {
|
|
16
|
-
constructor(
|
|
17
|
-
|
|
18
|
+
class UnitSystems extends SchemaItems_1.SchemaItems {
|
|
19
|
+
constructor(schemaEditor) {
|
|
20
|
+
super(ecschema_metadata_1.SchemaItemType.UnitSystem, schemaEditor);
|
|
18
21
|
}
|
|
19
22
|
async create(schemaKey, name, displayLabel) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
try {
|
|
24
|
+
const newUnitSystem = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name);
|
|
25
|
+
if (displayLabel)
|
|
26
|
+
newUnitSystem.setDisplayLabel(displayLabel);
|
|
27
|
+
return newUnitSystem.key;
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFailed, new Exception_1.SchemaItemId(this.schemaItemType, name, schemaKey), e);
|
|
31
|
+
}
|
|
27
32
|
}
|
|
28
33
|
async createFromProps(schemaKey, unitSystemProps) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return { errorMessage: `Failed to create class ${unitSystemProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
37
|
-
await newUnitSystem.fromJSON(unitSystemProps);
|
|
38
|
-
return { itemKey: newUnitSystem.key };
|
|
34
|
+
try {
|
|
35
|
+
const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);
|
|
36
|
+
return newUnitSystem.key;
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFromProps, new Exception_1.SchemaItemId(this.schemaItemType, unitSystemProps.name, schemaKey), e);
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
exports.UnitSystems = UnitSystems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"UnitSystems.js","sourceRoot":"","sources":["../../../src/Editing/UnitSystems.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAiH;AAGjH,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,WAAY,SAAQ,yBAAW;IAC1C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,YAAqB;QAE3E,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAsB,CAAC;YAE3K,IAAI,YAAY;gBACd,aAAa,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAE9C,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,eAAgC;QACjF,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC;YAC9J,OAAO,aAAa,CAAC,GAAG,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QACtJ,CAAC;IACH,CAAC;CACF;AA3BD,kCA2BC","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\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { SchemaItemKey, SchemaItemType, SchemaKey, UnitSystem, UnitSystemProps } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutableUnitSystem } from \"./Mutable/MutableUnitSystem\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type UnitSystems.\r\n */\r\nexport class UnitSystems extends SchemaItems {\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.UnitSystem, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, displayLabel?: string): Promise<SchemaItemKey> {\r\n\r\n try {\r\n const newUnitSystem = await this.createSchemaItem<UnitSystem>(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), name) as MutableUnitSystem;\r\n\r\n if (displayLabel)\r\n newUnitSystem.setDisplayLabel(displayLabel);\r\n\r\n return newUnitSystem.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, unitSystemProps: UnitSystemProps): Promise<SchemaItemKey> {\r\n try {\r\n const newUnitSystem = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnitSystem.bind(schema), unitSystemProps);\r\n return newUnitSystem.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitSystemProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* @module Editing
|
|
3
3
|
*/
|
|
4
4
|
import { SchemaItemKey, SchemaItemUnitProps, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
|
-
import { SchemaContextEditor
|
|
5
|
+
import { SchemaContextEditor } from "./Editor";
|
|
6
|
+
import { SchemaItems } from "./SchemaItems";
|
|
6
7
|
/**
|
|
7
8
|
* @alpha
|
|
8
9
|
* A class allowing you to create schema items of type Unit.
|
|
9
10
|
*/
|
|
10
|
-
export declare class Units {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemEditResults>;
|
|
11
|
+
export declare class Units extends SchemaItems {
|
|
12
|
+
constructor(schemaEditor: SchemaContextEditor);
|
|
13
|
+
create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey>;
|
|
14
|
+
createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey>;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=Units.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Units.d.ts","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuC,aAAa,EAAkB,mBAAmB,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"Units.d.ts","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuC,aAAa,EAAkB,mBAAmB,EAAE,SAAS,EAAoB,MAAM,0BAA0B,CAAC;AAChK,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,KAAM,SAAQ,WAAW;gBAEjB,YAAY,EAAE,mBAAmB;IAIvC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBnK,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ3G"}
|
package/lib/cjs/Editing/Units.js
CHANGED
|
@@ -9,50 +9,41 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.Units = void 0;
|
|
11
11
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const Exception_1 = require("./Exception");
|
|
13
|
+
const SchemaItems_1 = require("./SchemaItems");
|
|
12
14
|
/**
|
|
13
15
|
* @alpha
|
|
14
16
|
* A class allowing you to create schema items of type Unit.
|
|
15
17
|
*/
|
|
16
|
-
class Units {
|
|
18
|
+
class Units extends SchemaItems_1.SchemaItems {
|
|
17
19
|
// TODO: Add more setters for all attributes.
|
|
18
|
-
constructor(
|
|
19
|
-
|
|
20
|
+
constructor(schemaEditor) {
|
|
21
|
+
super(ecschema_metadata_1.SchemaItemType.Unit, schemaEditor);
|
|
20
22
|
}
|
|
21
23
|
async create(schemaKey, name, definition, phenomenon, unitSystem, displayLabel) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return { errorMessage: `Unable to locate unit system ${unitSystem.fullName} in schema ${schema.fullName}.` };
|
|
37
|
-
if (unitSystemItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
|
|
38
|
-
return { errorMessage: `${unitSystem.fullName} is not of type UnitSystem.` };
|
|
39
|
-
await newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystem, async () => unitSystemItem));
|
|
40
|
-
await newUnit.setDefinition(definition);
|
|
41
|
-
if (displayLabel)
|
|
42
|
-
newUnit.setDisplayLabel(displayLabel);
|
|
43
|
-
return { itemKey: newUnit.key };
|
|
24
|
+
try {
|
|
25
|
+
const newUnit = await this.createSchemaItem(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name);
|
|
26
|
+
const phenomenonItem = await this.lookupSchemaItem(newUnit.schema.schemaKey, phenomenon, ecschema_metadata_1.SchemaItemType.Phenomenon);
|
|
27
|
+
await newUnit.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(phenomenon, async () => phenomenonItem));
|
|
28
|
+
const unitSystemItem = await this.lookupSchemaItem(newUnit.schema.schemaKey, unitSystem, ecschema_metadata_1.SchemaItemType.UnitSystem);
|
|
29
|
+
await newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystem, async () => unitSystemItem));
|
|
30
|
+
await newUnit.setDefinition(definition);
|
|
31
|
+
if (displayLabel)
|
|
32
|
+
newUnit.setDisplayLabel(displayLabel);
|
|
33
|
+
return newUnit.key;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFailed, new Exception_1.SchemaItemId(this.schemaItemType, name, schemaKey), e);
|
|
37
|
+
}
|
|
44
38
|
}
|
|
45
39
|
async createFromProps(schemaKey, unitProps) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return { errorMessage: `Failed to create class ${unitProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
54
|
-
await newUnit.fromJSON(unitProps);
|
|
55
|
-
return { itemKey: newUnit.key };
|
|
40
|
+
try {
|
|
41
|
+
const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);
|
|
42
|
+
return newUnit.key;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
throw new Exception_1.SchemaEditingError(Exception_1.ECEditingStatus.CreateSchemaItemFromProps, new Exception_1.SchemaItemId(this.schemaItemType, unitProps.name, schemaKey), e);
|
|
46
|
+
}
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
49
|
exports.Units = Units;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"Units.js","sourceRoot":"","sources":["../../../src/Editing/Units.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAgK;AAGhK,2CAAgF;AAChF,+CAA4C;AAE5C;;;GAGG;AACH,MAAa,KAAM,SAAQ,yBAAW;IACpC,6CAA6C;IAC7C,YAAmB,YAAiC;QAClD,KAAK,CAAC,kCAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAkB,EAAE,UAAyB,EAAE,UAAyB,EAAE,YAAqB;QACrJ,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAO,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAgB,CAAC;YAEnJ,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,kCAAc,CAAC,UAAU,CAAC,CAAC;YAChI,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAa,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,kCAAc,CAAC,UAAU,CAAC,CAAC;YAChI,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,2CAAuB,CAA4B,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;YAE5H,MAAM,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAExC,IAAI,YAAY;gBACd,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YAExC,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,sBAAsB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAClI,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,SAA8B;QAC/E,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5I,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,8BAAkB,CAAC,2BAAe,CAAC,yBAAyB,EAAE,IAAI,wBAAY,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,IAAK,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC;QAChJ,CAAC;IACH,CAAC;CACF;AAnCD,sBAmCC","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\n/** @packageDocumentation\r\n * @module Editing\r\n */\r\n\r\nimport { DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaItemUnitProps, SchemaKey, Unit, UnitSystem } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaContextEditor } from \"./Editor\";\r\nimport { MutableUnit } from \"./Mutable/MutableUnit\";\r\nimport { ECEditingStatus, SchemaEditingError, SchemaItemId } from \"./Exception\";\r\nimport { SchemaItems } from \"./SchemaItems\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Unit.\r\n */\r\nexport class Units extends SchemaItems {\r\n // TODO: Add more setters for all attributes.\r\n public constructor(schemaEditor: SchemaContextEditor) {\r\n super(SchemaItemType.Unit, schemaEditor);\r\n }\r\n\r\n public async create(schemaKey: SchemaKey, name: string, definition: string, phenomenon: SchemaItemKey, unitSystem: SchemaItemKey, displayLabel?: string): Promise<SchemaItemKey> {\r\n try {\r\n const newUnit = await this.createSchemaItem<Unit>(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), name) as MutableUnit;\r\n\r\n const phenomenonItem = await this.lookupSchemaItem<Phenomenon>(newUnit.schema.schemaKey, phenomenon, SchemaItemType.Phenomenon);\r\n await newUnit.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(phenomenon, async () => phenomenonItem));\r\n\r\n const unitSystemItem = await this.lookupSchemaItem<UnitSystem>(newUnit.schema.schemaKey, unitSystem, SchemaItemType.UnitSystem);\r\n await newUnit.setUnitSystem(new DelayedPromiseWithProps<SchemaItemKey, UnitSystem>(unitSystem, async () => unitSystemItem));\r\n\r\n await newUnit.setDefinition(definition);\r\n\r\n if (displayLabel)\r\n newUnit.setDisplayLabel(displayLabel);\r\n\r\n return newUnit.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFailed, new SchemaItemId(this.schemaItemType, name, schemaKey), e);\r\n }\r\n }\r\n\r\n public async createFromProps(schemaKey: SchemaKey, unitProps: SchemaItemUnitProps): Promise<SchemaItemKey> {\r\n try {\r\n const newUnit = await this.createSchemaItemFromProps(schemaKey, this.schemaItemType, (schema) => schema.createUnit.bind(schema), unitProps);\r\n return newUnit.key;\r\n } catch (e: any) {\r\n throw new SchemaEditingError(ECEditingStatus.CreateSchemaItemFromProps, new SchemaItemId(this.schemaItemType, unitProps.name!, schemaKey), e);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -10,7 +10,7 @@ const ClassMerger_1 = require("./ClassMerger");
|
|
|
10
10
|
exports.customAttributeClassMerger = {
|
|
11
11
|
async add(context, change) {
|
|
12
12
|
if (change.difference.appliesTo === undefined) {
|
|
13
|
-
|
|
13
|
+
throw new Error("appliesTo is a required property of a CustomAttributeClass but it is not set");
|
|
14
14
|
}
|
|
15
15
|
return context.editor.customAttributes.createFromProps(context.targetSchemaKey, {
|
|
16
16
|
...change.difference,
|
|
@@ -25,7 +25,7 @@ exports.customAttributeClassMerger = {
|
|
|
25
25
|
if (currentValue !== "" && change.difference.appliesTo !== currentValue) {
|
|
26
26
|
const containerType = (0, ecschema_metadata_1.parseCustomAttributeContainerType)(`${currentValue}, ${change.difference.appliesTo}`);
|
|
27
27
|
if (containerType === undefined) {
|
|
28
|
-
|
|
28
|
+
throw new Error("An invalid custom attribute class containerType has been provided.");
|
|
29
29
|
}
|
|
30
30
|
item.setContainerType(containerType);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,aAAa,CAAC,CAAC;YAC/D,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,gBAAgB,CAAC,aAAa,CAAC,CAAC;YACvC,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.containerType);\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.setContainerType(containerType);\r\n }\r\n }\r\n return modifyClass(context, change, itemKey, item);\r\n },\r\n};\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type SchemaMergeContext } from "./SchemaMerger";
|
|
2
2
|
import { AnySchemaDifference, ClassItemDifference } from "../Differencing/SchemaDifference";
|
|
3
3
|
import { ECClass, SchemaItemKey } from "@itwin/ecschema-metadata";
|
|
4
|
-
import { SchemaEditResults } from "../Editing/Editor";
|
|
5
4
|
/**
|
|
6
5
|
* @internal
|
|
7
6
|
*/
|
|
@@ -10,5 +9,5 @@ export declare function mergeClassItems(context: SchemaMergeContext, classChange
|
|
|
10
9
|
* Shared modify merger of all ECClass based items.
|
|
11
10
|
* @internal
|
|
12
11
|
*/
|
|
13
|
-
export declare function modifyClass(context: SchemaMergeContext, change: ClassItemDifference, itemKey: SchemaItemKey, item: ECClass): Promise<
|
|
12
|
+
export declare function modifyClass(context: SchemaMergeContext, change: ClassItemDifference, itemKey: SchemaItemKey, item: ECClass): Promise<void>;
|
|
14
13
|
//# sourceMappingURL=ClassMerger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAwD,mBAAmB,EAA2C,MAAM,kCAAkC,CAAC;AAG3L,OAAO,EAAmB,OAAO,EAAuC,aAAa,EAAkB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ClassMerger.d.ts","sourceRoot":"","sources":["../../../src/Merging/ClassMerger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAwD,mBAAmB,EAA2C,MAAM,kCAAkC,CAAC;AAG3L,OAAO,EAAmB,OAAO,EAAuC,aAAa,EAAkB,MAAM,0BAA0B,CAAC;AAUxI;;GAEG;AACH,wBAAuB,eAAe,CAAC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,wCA6CtG;AAwBD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhJ"}
|