@itwin/ecschema-editing 4.0.0-dev.1 → 4.0.0-dev.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -1
- package/lib/cjs/Editing/Constants.d.ts +20 -20
- package/lib/cjs/Editing/Constants.js +60 -60
- package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
- package/lib/cjs/Editing/CustomAttributes.js +59 -59
- package/lib/cjs/Editing/ECClasses.d.ts +54 -54
- package/lib/cjs/Editing/ECClasses.js +269 -269
- package/lib/cjs/Editing/Editor.d.ts +112 -112
- package/lib/cjs/Editing/Editor.js +166 -166
- package/lib/cjs/Editing/Entities.d.ts +25 -25
- package/lib/cjs/Editing/Entities.js +116 -116
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +21 -21
- package/lib/cjs/Editing/Enumerations.js +66 -66
- package/lib/cjs/Editing/Formats.d.ts +21 -21
- package/lib/cjs/Editing/Formats.d.ts.map +1 -1
- package/lib/cjs/Editing/Formats.js +61 -61
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
- package/lib/cjs/Editing/InvertedUnits.js +82 -82
- package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
- package/lib/cjs/Editing/KindOfQuantities.js +78 -78
- package/lib/cjs/Editing/Mixins.d.ts +22 -22
- package/lib/cjs/Editing/Mixins.js +84 -84
- package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
- package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
- package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
- package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
- package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
- package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
- package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
- package/lib/cjs/Editing/Phenomena.d.ts +15 -15
- package/lib/cjs/Editing/Phenomena.js +44 -44
- package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
- package/lib/cjs/Editing/PropertyCategories.js +51 -51
- package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
- package/lib/cjs/Editing/RelationshipClasses.js +68 -68
- package/lib/cjs/Editing/Structs.d.ts +19 -19
- package/lib/cjs/Editing/Structs.js +57 -57
- package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
- package/lib/cjs/Editing/UnitSystems.js +41 -41
- package/lib/cjs/Editing/Units.d.ts +15 -15
- package/lib/cjs/Editing/Units.d.ts.map +1 -1
- package/lib/cjs/Editing/Units.js +58 -58
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
- package/lib/cjs/Validation/Diagnostic.d.ts.map +1 -1
- package/lib/cjs/Validation/Diagnostic.js +310 -310
- package/lib/cjs/Validation/Diagnostic.js.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.d.ts +96 -96
- package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
- package/lib/cjs/Validation/ECRules.d.ts +443 -448
- package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
- package/lib/cjs/Validation/ECRules.js +579 -593
- package/lib/cjs/Validation/ECRules.js.map +1 -1
- package/lib/cjs/Validation/LoggingDiagnosticReporter.d.ts +13 -13
- package/lib/cjs/Validation/LoggingDiagnosticReporter.js +40 -40
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -59
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
- package/lib/cjs/Validation/Rules.d.ts +64 -64
- package/lib/cjs/Validation/Rules.d.ts.map +1 -1
- package/lib/cjs/Validation/Rules.js +9 -9
- package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
- package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
- package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
- package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
- package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
- package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
- package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
- package/lib/cjs/Validation/SchemaComparer.js +666 -666
- package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
- package/lib/cjs/Validation/SchemaValidater.js +61 -61
- package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
- package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -492
- package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
- package/lib/cjs/Validation/SchemaWalker.js +51 -51
- package/lib/cjs/ecschema-editing.d.ts +33 -33
- package/lib/cjs/ecschema-editing.js +58 -54
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +16 -17
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Editing
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.Formats = void 0;
|
|
11
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
-
/**
|
|
13
|
-
* @alpha
|
|
14
|
-
* A class allowing you to create schema items of type Format.
|
|
15
|
-
*/
|
|
16
|
-
class Formats {
|
|
17
|
-
constructor(_schemaEditor) {
|
|
18
|
-
this._schemaEditor = _schemaEditor;
|
|
19
|
-
}
|
|
20
|
-
async create(schemaKey, name, formatType, displayLabel, units) {
|
|
21
|
-
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
22
|
-
const newFormat = (await schema.createFormat(name));
|
|
23
|
-
if (newFormat === undefined) {
|
|
24
|
-
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
25
|
-
}
|
|
26
|
-
if (units !== undefined) {
|
|
27
|
-
for (const unit of units) {
|
|
28
|
-
const unitItem = await this._schemaEditor.schemaContext.getSchemaItem(unit);
|
|
29
|
-
if (unitItem === undefined) {
|
|
30
|
-
return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };
|
|
31
|
-
}
|
|
32
|
-
if (unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit && unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
|
|
33
|
-
return { errorMessage: `${unitItem.fullName} is not of type Unit or InvertedUnit.` };
|
|
34
|
-
newFormat.addUnit(unitItem);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (displayLabel)
|
|
38
|
-
newFormat.setDisplayLabel(displayLabel);
|
|
39
|
-
// TODO: Handle the setting of format traits, separators, etc....
|
|
40
|
-
newFormat.setFormatType(formatType);
|
|
41
|
-
return { itemKey: newFormat.key };
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Creates a format through a
|
|
45
|
-
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
46
|
-
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
47
|
-
*/
|
|
48
|
-
async createFromProps(schemaKey, formatProps) {
|
|
49
|
-
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
50
|
-
if (schema === undefined)
|
|
51
|
-
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
52
|
-
if (formatProps.name === undefined)
|
|
53
|
-
return { errorMessage: `No name was supplied within props.` };
|
|
54
|
-
const newFormat = (await schema.createFormat(formatProps.name));
|
|
55
|
-
if (newFormat === undefined)
|
|
56
|
-
return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
57
|
-
await newFormat.fromJSON(formatProps);
|
|
58
|
-
return { itemKey: newFormat.key };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.Formats = Formats;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Editing
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Formats = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
/**
|
|
13
|
+
* @alpha
|
|
14
|
+
* A class allowing you to create schema items of type Format.
|
|
15
|
+
*/
|
|
16
|
+
class Formats {
|
|
17
|
+
constructor(_schemaEditor) {
|
|
18
|
+
this._schemaEditor = _schemaEditor;
|
|
19
|
+
}
|
|
20
|
+
async create(schemaKey, name, formatType, displayLabel, units) {
|
|
21
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
22
|
+
const newFormat = (await schema.createFormat(name));
|
|
23
|
+
if (newFormat === undefined) {
|
|
24
|
+
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
25
|
+
}
|
|
26
|
+
if (units !== undefined) {
|
|
27
|
+
for (const unit of units) {
|
|
28
|
+
const unitItem = await this._schemaEditor.schemaContext.getSchemaItem(unit);
|
|
29
|
+
if (unitItem === undefined) {
|
|
30
|
+
return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };
|
|
31
|
+
}
|
|
32
|
+
if (unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit && unitItem.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
|
|
33
|
+
return { errorMessage: `${unitItem.fullName} is not of type Unit or InvertedUnit.` };
|
|
34
|
+
newFormat.addUnit(unitItem);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (displayLabel)
|
|
38
|
+
newFormat.setDisplayLabel(displayLabel);
|
|
39
|
+
// TODO: Handle the setting of format traits, separators, etc....
|
|
40
|
+
newFormat.setFormatType(formatType);
|
|
41
|
+
return { itemKey: newFormat.key };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a format through a SchemaItemFormatProps.
|
|
45
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
46
|
+
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
47
|
+
*/
|
|
48
|
+
async createFromProps(schemaKey, formatProps) {
|
|
49
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
50
|
+
if (schema === undefined)
|
|
51
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
52
|
+
if (formatProps.name === undefined)
|
|
53
|
+
return { errorMessage: `No name was supplied within props.` };
|
|
54
|
+
const newFormat = (await schema.createFormat(formatProps.name));
|
|
55
|
+
if (newFormat === undefined)
|
|
56
|
+
return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
57
|
+
await newFormat.fromJSON(formatProps);
|
|
58
|
+
return { itemKey: newFormat.key };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Formats = Formats;
|
|
62
62
|
//# sourceMappingURL=Formats.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"Formats.js","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAA2I;AAK3I;;;GAGG;AACH,MAAa,OAAO;IAClB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAC7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAsB,EAAE,YAAqB,EAAE,KAAuB;QAC5H,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAkB,CAAC;QACrE,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SAClG;QAED,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAsB,IAAI,CAAC,CAAC;gBACjG,IAAI,QAAQ,KAAK,SAAS,EAAE;oBAC1B,OAAO,EAAE,YAAY,EAAE,yBAAyB,IAAI,CAAC,IAAI,qBAAqB,EAAE,CAAC;iBAClF;gBAED,IAAI,QAAQ,CAAC,cAAc,KAAK,kCAAc,CAAC,IAAI,IAAI,QAAQ,CAAC,cAAc,KAAK,kCAAc,CAAC,YAAY;oBAC5G,OAAO,EAAE,YAAY,EAAE,GAAI,QAAuB,CAAC,QAAQ,uCAAuC,EAAE,CAAC;gBACvG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;aAC7B;SACF;QACD,IAAI,YAAY;YACd,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAE1C,iEAAiE;QACjE,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACpC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,SAAoB,EAAE,WAAkC;QACnF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEzF,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS;YAChC,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QAEhE,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAkB,CAAC;QACjF,IAAI,SAAS,KAAK,SAAS;YACzB,OAAO,EAAE,YAAY,EAAE,0BAA0B,WAAW,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAE/G,MAAM,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC;IACpC,CAAC;CACF;AAjDD,0BAiDC","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 { InvertedUnit, SchemaItem, SchemaItemFormatProps, SchemaItemKey, SchemaItemType, SchemaKey, Unit } from \"@itwin/ecschema-metadata\";\r\nimport { FormatType } from \"@itwin/core-quantity\";\r\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\r\nimport { MutableFormat } from \"./Mutable/MutableFormat\";\r\n\r\n/**\r\n * @alpha\r\n * A class allowing you to create schema items of type Format.\r\n */\r\nexport class Formats {\r\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\r\n public async create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n const newFormat = (await schema.createFormat(name)) as MutableFormat;\r\n if (newFormat === undefined) {\r\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\r\n }\r\n\r\n if (units !== undefined) {\r\n for (const unit of units) {\r\n const unitItem = await this._schemaEditor.schemaContext.getSchemaItem<Unit | InvertedUnit>(unit);\r\n if (unitItem === undefined) {\r\n return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };\r\n }\r\n\r\n if (unitItem.schemaItemType !== SchemaItemType.Unit && unitItem.schemaItemType !== SchemaItemType.InvertedUnit)\r\n return { errorMessage: `${(unitItem as SchemaItem).fullName} is not of type Unit or InvertedUnit.` };\r\n newFormat.addUnit(unitItem);\r\n }\r\n }\r\n if (displayLabel)\r\n newFormat.setDisplayLabel(displayLabel);\r\n\r\n // TODO: Handle the setting of format traits, separators, etc....\r\n newFormat.setFormatType(formatType);\r\n return { itemKey: newFormat.key };\r\n }\r\n\r\n /**\r\n * Creates a format through a SchemaItemFormatProps.\r\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\r\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\r\n */\r\n public async createFromProps(schemaKey: SchemaKey, formatProps: SchemaItemFormatProps): Promise<SchemaItemEditResults> {\r\n const schema = await this._schemaEditor.getSchema(schemaKey);\r\n if (schema === undefined)\r\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\r\n\r\n if (formatProps.name === undefined)\r\n return { errorMessage: `No name was supplied within props.` };\r\n\r\n const newFormat = (await schema.createFormat(formatProps.name)) as MutableFormat;\r\n if (newFormat === undefined)\r\n return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };\r\n\r\n await newFormat.fromJSON(formatProps);\r\n return { itemKey: newFormat.key };\r\n }\r\n}\r\n"]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Editing
|
|
3
|
-
*/
|
|
4
|
-
import { InvertedUnitProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
|
-
import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
|
-
/**
|
|
7
|
-
* @alpha
|
|
8
|
-
* A class allowing you to create schema items of type Inverted Unit.
|
|
9
|
-
*/
|
|
10
|
-
export declare class InvertedUnits {
|
|
11
|
-
protected _schemaEditor: SchemaContextEditor;
|
|
12
|
-
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
-
create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults>;
|
|
14
|
-
createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemEditResults>;
|
|
15
|
-
setInvertsUnit(invertedUnitKey: SchemaItemKey, invertsUnitKey: SchemaItemKey): Promise<void>;
|
|
16
|
-
setUnitSystem(invertedUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey): Promise<void>;
|
|
17
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Editing
|
|
3
|
+
*/
|
|
4
|
+
import { InvertedUnitProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
* A class allowing you to create schema items of type Inverted Unit.
|
|
9
|
+
*/
|
|
10
|
+
export declare class InvertedUnits {
|
|
11
|
+
protected _schemaEditor: SchemaContextEditor;
|
|
12
|
+
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
+
create(schemaKey: SchemaKey, name: string, invertsUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey, displayLabel?: string): Promise<SchemaItemEditResults>;
|
|
14
|
+
createFromProps(schemaKey: SchemaKey, invertedUnitProps: InvertedUnitProps): Promise<SchemaItemEditResults>;
|
|
15
|
+
setInvertsUnit(invertedUnitKey: SchemaItemKey, invertsUnitKey: SchemaItemKey): Promise<void>;
|
|
16
|
+
setUnitSystem(invertedUnitKey: SchemaItemKey, unitSystemKey: SchemaItemKey): Promise<void>;
|
|
17
|
+
}
|
|
18
18
|
//# sourceMappingURL=InvertedUnits.d.ts.map
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Editing
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.InvertedUnits = void 0;
|
|
11
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
-
/**
|
|
13
|
-
* @alpha
|
|
14
|
-
* A class allowing you to create schema items of type Inverted Unit.
|
|
15
|
-
*/
|
|
16
|
-
class InvertedUnits {
|
|
17
|
-
constructor(_schemaEditor) {
|
|
18
|
-
this._schemaEditor = _schemaEditor;
|
|
19
|
-
}
|
|
20
|
-
async create(schemaKey, name, invertsUnitKey, unitSystemKey, displayLabel) {
|
|
21
|
-
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
22
|
-
if (schema === undefined)
|
|
23
|
-
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
24
|
-
const newUnit = (await schema.createInvertedUnit(name));
|
|
25
|
-
if (newUnit === undefined)
|
|
26
|
-
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
27
|
-
const invertsUnit = await schema.lookupItem(invertsUnitKey);
|
|
28
|
-
if (invertsUnit === undefined)
|
|
29
|
-
return { errorMessage: `Unable to locate unit ${invertsUnitKey.fullName} in schema ${schema.fullName}.` };
|
|
30
|
-
if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
|
|
31
|
-
return { errorMessage: `${invertsUnit.fullName} is not of type Unit.` };
|
|
32
|
-
newUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
|
|
33
|
-
const unitSystem = await schema.lookupItem(unitSystemKey);
|
|
34
|
-
if (unitSystem === undefined)
|
|
35
|
-
return { errorMessage: `Unable to locate unit system ${unitSystemKey.fullName} in schema ${schema.fullName}.` };
|
|
36
|
-
if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
|
|
37
|
-
return { errorMessage: `${unitSystemKey.fullName} is not of type Unit System.` };
|
|
38
|
-
newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
|
|
39
|
-
if (displayLabel)
|
|
40
|
-
newUnit.setDisplayLabel(displayLabel);
|
|
41
|
-
return { itemKey: newUnit.key };
|
|
42
|
-
}
|
|
43
|
-
async createFromProps(schemaKey, invertedUnitProps) {
|
|
44
|
-
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
45
|
-
if (schema === undefined)
|
|
46
|
-
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
47
|
-
if (invertedUnitProps.name === undefined)
|
|
48
|
-
return { errorMessage: `No name was supplied within props.` };
|
|
49
|
-
const newUnit = (await schema.createInvertedUnit(invertedUnitProps.name));
|
|
50
|
-
if (newUnit === undefined)
|
|
51
|
-
return { errorMessage: `Failed to create class ${invertedUnitProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
52
|
-
await newUnit.fromJSON(invertedUnitProps);
|
|
53
|
-
return { itemKey: newUnit.key };
|
|
54
|
-
}
|
|
55
|
-
async setInvertsUnit(invertedUnitKey, invertsUnitKey) {
|
|
56
|
-
const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
|
|
57
|
-
if (invertedUnit === undefined)
|
|
58
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
|
|
59
|
-
if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
|
|
60
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
|
|
61
|
-
const invertsUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertsUnitKey);
|
|
62
|
-
if (invertsUnit === undefined)
|
|
63
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${invertsUnitKey.fullName} not found in schema context.`);
|
|
64
|
-
if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
|
|
65
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertsUnitKey.fullName} to be of type Unit.`);
|
|
66
|
-
invertedUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
|
|
67
|
-
}
|
|
68
|
-
async setUnitSystem(invertedUnitKey, unitSystemKey) {
|
|
69
|
-
const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
|
|
70
|
-
if (invertedUnit === undefined)
|
|
71
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
|
|
72
|
-
if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
|
|
73
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
|
|
74
|
-
const unitSystem = await this._schemaEditor.schemaContext.getSchemaItem(unitSystemKey);
|
|
75
|
-
if (unitSystem === undefined)
|
|
76
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${unitSystemKey.fullName} not found in schema context.`);
|
|
77
|
-
if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
|
|
78
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${unitSystemKey.fullName} to be of type Unit System.`);
|
|
79
|
-
invertedUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.InvertedUnits = InvertedUnits;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Editing
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.InvertedUnits = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
/**
|
|
13
|
+
* @alpha
|
|
14
|
+
* A class allowing you to create schema items of type Inverted Unit.
|
|
15
|
+
*/
|
|
16
|
+
class InvertedUnits {
|
|
17
|
+
constructor(_schemaEditor) {
|
|
18
|
+
this._schemaEditor = _schemaEditor;
|
|
19
|
+
}
|
|
20
|
+
async create(schemaKey, name, invertsUnitKey, unitSystemKey, displayLabel) {
|
|
21
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
22
|
+
if (schema === undefined)
|
|
23
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
24
|
+
const newUnit = (await schema.createInvertedUnit(name));
|
|
25
|
+
if (newUnit === undefined)
|
|
26
|
+
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
27
|
+
const invertsUnit = await schema.lookupItem(invertsUnitKey);
|
|
28
|
+
if (invertsUnit === undefined)
|
|
29
|
+
return { errorMessage: `Unable to locate unit ${invertsUnitKey.fullName} in schema ${schema.fullName}.` };
|
|
30
|
+
if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
|
|
31
|
+
return { errorMessage: `${invertsUnit.fullName} is not of type Unit.` };
|
|
32
|
+
newUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
|
|
33
|
+
const unitSystem = await schema.lookupItem(unitSystemKey);
|
|
34
|
+
if (unitSystem === undefined)
|
|
35
|
+
return { errorMessage: `Unable to locate unit system ${unitSystemKey.fullName} in schema ${schema.fullName}.` };
|
|
36
|
+
if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
|
|
37
|
+
return { errorMessage: `${unitSystemKey.fullName} is not of type Unit System.` };
|
|
38
|
+
newUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
|
|
39
|
+
if (displayLabel)
|
|
40
|
+
newUnit.setDisplayLabel(displayLabel);
|
|
41
|
+
return { itemKey: newUnit.key };
|
|
42
|
+
}
|
|
43
|
+
async createFromProps(schemaKey, invertedUnitProps) {
|
|
44
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
45
|
+
if (schema === undefined)
|
|
46
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
47
|
+
if (invertedUnitProps.name === undefined)
|
|
48
|
+
return { errorMessage: `No name was supplied within props.` };
|
|
49
|
+
const newUnit = (await schema.createInvertedUnit(invertedUnitProps.name));
|
|
50
|
+
if (newUnit === undefined)
|
|
51
|
+
return { errorMessage: `Failed to create class ${invertedUnitProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
52
|
+
await newUnit.fromJSON(invertedUnitProps);
|
|
53
|
+
return { itemKey: newUnit.key };
|
|
54
|
+
}
|
|
55
|
+
async setInvertsUnit(invertedUnitKey, invertsUnitKey) {
|
|
56
|
+
const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
|
|
57
|
+
if (invertedUnit === undefined)
|
|
58
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
|
|
59
|
+
if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
|
|
60
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
|
|
61
|
+
const invertsUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertsUnitKey);
|
|
62
|
+
if (invertsUnit === undefined)
|
|
63
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${invertsUnitKey.fullName} not found in schema context.`);
|
|
64
|
+
if (invertsUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.Unit)
|
|
65
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertsUnitKey.fullName} to be of type Unit.`);
|
|
66
|
+
invertedUnit.setInvertsUnit(new ecschema_metadata_1.DelayedPromiseWithProps(invertsUnitKey, async () => invertsUnit));
|
|
67
|
+
}
|
|
68
|
+
async setUnitSystem(invertedUnitKey, unitSystemKey) {
|
|
69
|
+
const invertedUnit = await this._schemaEditor.schemaContext.getSchemaItem(invertedUnitKey);
|
|
70
|
+
if (invertedUnit === undefined)
|
|
71
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Inverted Unit ${invertedUnitKey.fullName} not found in schema context.`);
|
|
72
|
+
if (invertedUnit.schemaItemType !== ecschema_metadata_1.SchemaItemType.InvertedUnit)
|
|
73
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${invertedUnitKey.fullName} to be of type Inverted Unit.`);
|
|
74
|
+
const unitSystem = await this._schemaEditor.schemaContext.getSchemaItem(unitSystemKey);
|
|
75
|
+
if (unitSystem === undefined)
|
|
76
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unit ${unitSystemKey.fullName} not found in schema context.`);
|
|
77
|
+
if (unitSystem.schemaItemType !== ecschema_metadata_1.SchemaItemType.UnitSystem)
|
|
78
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${unitSystemKey.fullName} to be of type Unit System.`);
|
|
79
|
+
invertedUnit.setUnitSystem(new ecschema_metadata_1.DelayedPromiseWithProps(unitSystemKey, async () => unitSystem));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.InvertedUnits = InvertedUnits;
|
|
83
83
|
//# sourceMappingURL=InvertedUnits.js.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Editing
|
|
3
|
-
*/
|
|
4
|
-
import { InvertedUnit, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
|
|
5
|
-
import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
|
-
/**
|
|
7
|
-
* @alpha
|
|
8
|
-
* A class allowing you to create schema items of type KindOfQuantity.
|
|
9
|
-
*/
|
|
10
|
-
export declare class KindOfQuantities {
|
|
11
|
-
protected _schemaEditor: SchemaContextEditor;
|
|
12
|
-
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
-
createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults>;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
17
|
-
* @param format A schemaItemKey of a Format.
|
|
18
|
-
* @param isDefault .is set to false when not explicitly passed.
|
|
19
|
-
*/
|
|
20
|
-
addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault?: boolean): Promise<void>;
|
|
21
|
-
addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault?: boolean): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
24
|
-
* @param parent A SchemaItemKey of the parent Format.
|
|
25
|
-
* @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
|
|
26
|
-
*/
|
|
27
|
-
createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat>;
|
|
28
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Editing
|
|
3
|
+
*/
|
|
4
|
+
import { InvertedUnit, KindOfQuantityProps, OverrideFormat, SchemaItemKey, SchemaKey, Unit } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
* A class allowing you to create schema items of type KindOfQuantity.
|
|
9
|
+
*/
|
|
10
|
+
export declare class KindOfQuantities {
|
|
11
|
+
protected _schemaEditor: SchemaContextEditor;
|
|
12
|
+
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
+
createFromProps(schemaKey: SchemaKey, koqProps: KindOfQuantityProps): Promise<SchemaItemEditResults>;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
17
|
+
* @param format A schemaItemKey of a Format.
|
|
18
|
+
* @param isDefault .is set to false when not explicitly passed.
|
|
19
|
+
*/
|
|
20
|
+
addPresentationFormat(koqKey: SchemaItemKey, format: SchemaItemKey, isDefault?: boolean): Promise<void>;
|
|
21
|
+
addPresentationOverrideFormat(koqKey: SchemaItemKey, overrideFormat: OverrideFormat, isDefault?: boolean): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
24
|
+
* @param parent A SchemaItemKey of the parent Format.
|
|
25
|
+
* @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
|
|
26
|
+
*/
|
|
27
|
+
createFormatOverride(koqKey: SchemaItemKey, parent: SchemaItemKey, precision?: number, unitLabelOverrides?: Array<[Unit | InvertedUnit, string | undefined]>): Promise<OverrideFormat>;
|
|
28
|
+
}
|
|
29
29
|
//# sourceMappingURL=KindOfQuantities.d.ts.map
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Editing
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.KindOfQuantities = void 0;
|
|
11
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
-
/**
|
|
13
|
-
* @alpha
|
|
14
|
-
* A class allowing you to create schema items of type KindOfQuantity.
|
|
15
|
-
*/
|
|
16
|
-
class KindOfQuantities {
|
|
17
|
-
constructor(_schemaEditor) {
|
|
18
|
-
this._schemaEditor = _schemaEditor;
|
|
19
|
-
}
|
|
20
|
-
async createFromProps(schemaKey, koqProps) {
|
|
21
|
-
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
22
|
-
if (schema === undefined)
|
|
23
|
-
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
24
|
-
if (koqProps.name === undefined)
|
|
25
|
-
return { errorMessage: `No name was supplied within props.` };
|
|
26
|
-
const newKoQ = (await schema.createKindOfQuantity(koqProps.name));
|
|
27
|
-
if (newKoQ === undefined)
|
|
28
|
-
return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
29
|
-
await newKoQ.fromJSON(koqProps);
|
|
30
|
-
return { itemKey: newKoQ.key };
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
35
|
-
* @param format A schemaItemKey of a Format.
|
|
36
|
-
* @param isDefault .is set to false when not explicitly passed.
|
|
37
|
-
*/
|
|
38
|
-
async addPresentationFormat(koqKey, format, isDefault = false) {
|
|
39
|
-
const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
|
|
40
|
-
if (kindOfQuantity === undefined)
|
|
41
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
|
|
42
|
-
if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
|
|
43
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
|
|
44
|
-
const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem(format));
|
|
45
|
-
if (undefined === presentationFormat)
|
|
46
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
|
|
47
|
-
if (presentationFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
|
|
48
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);
|
|
49
|
-
kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
|
|
50
|
-
}
|
|
51
|
-
async addPresentationOverrideFormat(koqKey, overrideFormat, isDefault = false) {
|
|
52
|
-
const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
|
|
53
|
-
if (kindOfQuantity === undefined)
|
|
54
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
|
|
55
|
-
if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
|
|
56
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
|
|
57
|
-
kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
61
|
-
* @param parent A SchemaItemKey of the parent Format.
|
|
62
|
-
* @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
|
|
63
|
-
*/
|
|
64
|
-
async createFormatOverride(koqKey, parent, precision, unitLabelOverrides) {
|
|
65
|
-
const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
|
|
66
|
-
if (kindOfQuantity === undefined)
|
|
67
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
|
|
68
|
-
if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
|
|
69
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
|
|
70
|
-
const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem(parent));
|
|
71
|
-
if (undefined === parentFormat)
|
|
72
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
|
|
73
|
-
if (parentFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
|
|
74
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);
|
|
75
|
-
return new ecschema_metadata_1.OverrideFormat(parentFormat, precision, unitLabelOverrides);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.KindOfQuantities = KindOfQuantities;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Editing
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.KindOfQuantities = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
/**
|
|
13
|
+
* @alpha
|
|
14
|
+
* A class allowing you to create schema items of type KindOfQuantity.
|
|
15
|
+
*/
|
|
16
|
+
class KindOfQuantities {
|
|
17
|
+
constructor(_schemaEditor) {
|
|
18
|
+
this._schemaEditor = _schemaEditor;
|
|
19
|
+
}
|
|
20
|
+
async createFromProps(schemaKey, koqProps) {
|
|
21
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
22
|
+
if (schema === undefined)
|
|
23
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
24
|
+
if (koqProps.name === undefined)
|
|
25
|
+
return { errorMessage: `No name was supplied within props.` };
|
|
26
|
+
const newKoQ = (await schema.createKindOfQuantity(koqProps.name));
|
|
27
|
+
if (newKoQ === undefined)
|
|
28
|
+
return { errorMessage: `Failed to create class ${koqProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
29
|
+
await newKoQ.fromJSON(koqProps);
|
|
30
|
+
return { itemKey: newKoQ.key };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
35
|
+
* @param format A schemaItemKey of a Format.
|
|
36
|
+
* @param isDefault .is set to false when not explicitly passed.
|
|
37
|
+
*/
|
|
38
|
+
async addPresentationFormat(koqKey, format, isDefault = false) {
|
|
39
|
+
const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
|
|
40
|
+
if (kindOfQuantity === undefined)
|
|
41
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
|
|
42
|
+
if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
|
|
43
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
|
|
44
|
+
const presentationFormat = await (this._schemaEditor.schemaContext.getSchemaItem(format));
|
|
45
|
+
if (undefined === presentationFormat)
|
|
46
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${format.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
|
|
47
|
+
if (presentationFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
|
|
48
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${presentationFormat.fullName} to be of type Format.`);
|
|
49
|
+
kindOfQuantity.addPresentationFormat(presentationFormat, isDefault);
|
|
50
|
+
}
|
|
51
|
+
async addPresentationOverrideFormat(koqKey, overrideFormat, isDefault = false) {
|
|
52
|
+
const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
|
|
53
|
+
if (kindOfQuantity === undefined)
|
|
54
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
|
|
55
|
+
if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
|
|
56
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
|
|
57
|
+
kindOfQuantity.addPresentationFormat(overrideFormat, isDefault);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @param koqKey A schemaItemKey of the editing KindOfQuantity.
|
|
61
|
+
* @param parent A SchemaItemKey of the parent Format.
|
|
62
|
+
* @param unitLabelOverrides The list of Unit (or InvertedUnit) and label overrides. The length of list should be equal to the number of units in the parent Format.
|
|
63
|
+
*/
|
|
64
|
+
async createFormatOverride(koqKey, parent, precision, unitLabelOverrides) {
|
|
65
|
+
const kindOfQuantity = (await this._schemaEditor.schemaContext.getSchemaItem(koqKey));
|
|
66
|
+
if (kindOfQuantity === undefined)
|
|
67
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${koqKey.fullName} not found in schema context.`);
|
|
68
|
+
if (kindOfQuantity.schemaItemType !== ecschema_metadata_1.SchemaItemType.KindOfQuantity)
|
|
69
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${koqKey.fullName} to be of type Kind Of Quantity.`);
|
|
70
|
+
const parentFormat = await (this._schemaEditor.schemaContext.getSchemaItem(parent));
|
|
71
|
+
if (undefined === parentFormat)
|
|
72
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate format '${parent.fullName}' for the presentation unit on KindOfQuantity ${koqKey.fullName}.`);
|
|
73
|
+
if (parentFormat.schemaItemType !== ecschema_metadata_1.SchemaItemType.Format)
|
|
74
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaItemType, `Expected ${parentFormat.fullName} to be of type Format.`);
|
|
75
|
+
return new ecschema_metadata_1.OverrideFormat(parentFormat, precision, unitLabelOverrides);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.KindOfQuantities = KindOfQuantities;
|
|
79
79
|
//# sourceMappingURL=KindOfQuantities.js.map
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Editing
|
|
3
|
-
*/
|
|
4
|
-
import { MixinProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
|
|
5
|
-
import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
|
-
import { ECClasses } from "./ECClasses";
|
|
7
|
-
/**
|
|
8
|
-
* @alpha
|
|
9
|
-
* A class extending ECClasses allowing you to create schema items of type Mixin.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Mixins extends ECClasses {
|
|
12
|
-
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
-
create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a MixinClass through a MixinProps.
|
|
16
|
-
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
17
|
-
* @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
|
|
18
|
-
*/
|
|
19
|
-
createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): Promise<SchemaItemEditResults>;
|
|
20
|
-
addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
|
|
21
|
-
createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
|
|
22
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Editing
|
|
3
|
+
*/
|
|
4
|
+
import { MixinProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
|
+
import { ECClasses } from "./ECClasses";
|
|
7
|
+
/**
|
|
8
|
+
* @alpha
|
|
9
|
+
* A class extending ECClasses allowing you to create schema items of type Mixin.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Mixins extends ECClasses {
|
|
12
|
+
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
+
create(schemaKey: SchemaKey, name: string, appliesTo: SchemaItemKey, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a MixinClass through a MixinProps.
|
|
16
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
17
|
+
* @param mixinProps a json object that will be used to populate the new MixinClass. Needs a name value passed in.
|
|
18
|
+
*/
|
|
19
|
+
createFromProps(schemaKey: SchemaKey, mixinProps: MixinProps): Promise<SchemaItemEditResults>;
|
|
20
|
+
addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
|
|
21
|
+
createNavigationProperty(mixinKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
|
|
22
|
+
}
|
|
23
23
|
//# sourceMappingURL=Mixins.d.ts.map
|