@itwin/ecschema-editing 3.4.0-dev.9 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -1
- package/lib/cjs/Editing/Constants.d.ts +20 -20
- package/lib/cjs/Editing/Constants.d.ts.map +1 -1
- package/lib/cjs/Editing/Constants.js +60 -64
- package/lib/cjs/Editing/Constants.js.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.d.ts +20 -20
- package/lib/cjs/Editing/CustomAttributes.d.ts.map +1 -1
- package/lib/cjs/Editing/CustomAttributes.js +59 -62
- package/lib/cjs/Editing/CustomAttributes.js.map +1 -1
- package/lib/cjs/Editing/ECClasses.d.ts +54 -54
- package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/ECClasses.js +269 -269
- package/lib/cjs/Editing/ECClasses.js.map +1 -1
- package/lib/cjs/Editing/Editor.d.ts +112 -112
- package/lib/cjs/Editing/Editor.d.ts.map +1 -1
- package/lib/cjs/Editing/Editor.js +166 -166
- package/lib/cjs/Editing/Editor.js.map +1 -1
- package/lib/cjs/Editing/Entities.d.ts +25 -25
- package/lib/cjs/Editing/Entities.d.ts.map +1 -1
- package/lib/cjs/Editing/Entities.js +116 -124
- package/lib/cjs/Editing/Entities.js.map +1 -1
- package/lib/cjs/Editing/Enumerations.d.ts +21 -21
- package/lib/cjs/Editing/Enumerations.d.ts.map +1 -1
- package/lib/cjs/Editing/Enumerations.js +66 -76
- package/lib/cjs/Editing/Enumerations.js.map +1 -1
- 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 -63
- package/lib/cjs/Editing/Formats.js.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.d.ts +17 -17
- package/lib/cjs/Editing/InvertedUnits.d.ts.map +1 -1
- package/lib/cjs/Editing/InvertedUnits.js +82 -85
- package/lib/cjs/Editing/InvertedUnits.js.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.d.ts +28 -28
- package/lib/cjs/Editing/KindOfQuantities.d.ts.map +1 -1
- package/lib/cjs/Editing/KindOfQuantities.js +78 -79
- package/lib/cjs/Editing/KindOfQuantities.js.map +1 -1
- package/lib/cjs/Editing/Mixins.d.ts +22 -22
- package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
- package/lib/cjs/Editing/Mixins.js +84 -88
- package/lib/cjs/Editing/Mixins.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableCAClass.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableCAClass.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableCAClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableClass.d.ts +34 -34
- package/lib/cjs/Editing/Mutable/MutableClass.js +22 -22
- package/lib/cjs/Editing/Mutable/MutableClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableConstant.d.ts +12 -12
- package/lib/cjs/Editing/Mutable/MutableConstant.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableConstant.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEntityClass.d.ts +15 -15
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js +59 -59
- package/lib/cjs/Editing/Mutable/MutableEntityClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableEnumeration.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js +14 -14
- package/lib/cjs/Editing/Mutable/MutableEnumeration.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableFormat.d.ts +18 -18
- package/lib/cjs/Editing/Mutable/MutableFormat.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableFormat.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableInvertedUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.d.ts +10 -10
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableKindOfQuantity.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableMixin.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableMixin.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableMixin.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePhenomenon.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableProperty.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableProperty.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableProperty.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.d.ts +9 -9
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js +15 -15
- package/lib/cjs/Editing/Mutable/MutablePropertyCategory.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.d.ts +21 -21
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js +24 -24
- package/lib/cjs/Editing/Mutable/MutableRelationshipClass.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableSchema.d.ts +45 -45
- package/lib/cjs/Editing/Mutable/MutableSchema.js +17 -17
- package/lib/cjs/Editing/Mutable/MutableSchema.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnit.d.ts +11 -11
- package/lib/cjs/Editing/Mutable/MutableUnit.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableUnit.js.map +1 -1
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.d.ts +8 -8
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js +15 -15
- package/lib/cjs/Editing/Mutable/MutableUnitSystem.js.map +1 -1
- package/lib/cjs/Editing/Phenomena.d.ts +15 -15
- package/lib/cjs/Editing/Phenomena.d.ts.map +1 -1
- package/lib/cjs/Editing/Phenomena.js +44 -47
- package/lib/cjs/Editing/Phenomena.js.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.d.ts +16 -16
- package/lib/cjs/Editing/PropertyCategories.d.ts.map +1 -1
- package/lib/cjs/Editing/PropertyCategories.js +51 -53
- package/lib/cjs/Editing/PropertyCategories.js.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.d.ts +21 -21
- package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
- package/lib/cjs/Editing/RelationshipClasses.js +68 -69
- package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
- package/lib/cjs/Editing/Structs.d.ts +19 -19
- package/lib/cjs/Editing/Structs.d.ts.map +1 -1
- package/lib/cjs/Editing/Structs.js +57 -60
- package/lib/cjs/Editing/Structs.js.map +1 -1
- package/lib/cjs/Editing/UnitSystems.d.ts +15 -15
- package/lib/cjs/Editing/UnitSystems.d.ts.map +1 -1
- package/lib/cjs/Editing/UnitSystems.js +41 -43
- package/lib/cjs/Editing/UnitSystems.js.map +1 -1
- 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 -61
- package/lib/cjs/Editing/Units.js.map +1 -1
- package/lib/cjs/Validation/Diagnostic.d.ts +321 -321
- 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.d.ts.map +1 -1
- package/lib/cjs/Validation/DiagnosticReporter.js +106 -106
- package/lib/cjs/Validation/DiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/ECRules.d.ts +448 -438
- package/lib/cjs/Validation/ECRules.d.ts.map +1 -1
- package/lib/cjs/Validation/ECRules.js +593 -583
- 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/LoggingDiagnosticReporter.js.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts +59 -58
- package/lib/cjs/Validation/RuleSuppressionSet.d.ts.map +1 -1
- package/lib/cjs/Validation/RuleSuppressionSet.js +9 -9
- package/lib/cjs/Validation/RuleSuppressionSet.js.map +1 -1
- package/lib/cjs/Validation/Rules.d.ts +64 -64
- package/lib/cjs/Validation/Rules.js +9 -9
- package/lib/cjs/Validation/Rules.js.map +1 -1
- package/lib/cjs/Validation/SchemaChanges.d.ts +607 -607
- package/lib/cjs/Validation/SchemaChanges.js +1135 -1135
- package/lib/cjs/Validation/SchemaChanges.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareDiagnostics.d.ts +422 -422
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js +111 -111
- package/lib/cjs/Validation/SchemaCompareDiagnostics.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareReporter.d.ts +11 -11
- package/lib/cjs/Validation/SchemaCompareReporter.js +9 -9
- package/lib/cjs/Validation/SchemaCompareReporter.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareResultDelegate.d.ts +236 -236
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js +348 -348
- package/lib/cjs/Validation/SchemaCompareResultDelegate.js.map +1 -1
- package/lib/cjs/Validation/SchemaCompareVisitor.d.ts +119 -119
- package/lib/cjs/Validation/SchemaCompareVisitor.js +206 -206
- package/lib/cjs/Validation/SchemaCompareVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaComparer.d.ts +171 -171
- package/lib/cjs/Validation/SchemaComparer.js +666 -666
- package/lib/cjs/Validation/SchemaComparer.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidater.d.ts +19 -19
- package/lib/cjs/Validation/SchemaValidater.js +61 -61
- package/lib/cjs/Validation/SchemaValidater.js.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.d.ts +170 -170
- package/lib/cjs/Validation/SchemaValidationVisitor.d.ts.map +1 -1
- package/lib/cjs/Validation/SchemaValidationVisitor.js +492 -490
- package/lib/cjs/Validation/SchemaValidationVisitor.js.map +1 -1
- package/lib/cjs/Validation/SchemaWalker.d.ts +22 -22
- package/lib/cjs/Validation/SchemaWalker.js +51 -51
- package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
- package/lib/cjs/ecschema-editing.d.ts +33 -33
- package/lib/cjs/ecschema-editing.js +54 -54
- package/lib/cjs/ecschema-editing.js.map +1 -1
- package/package.json +11 -11
- package/public/locales/en/ECSchemaEditing.json +26 -26
|
@@ -1,77 +1,67 @@
|
|
|
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.Enumerations = 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 Enumeration.
|
|
15
|
-
*/
|
|
16
|
-
class Enumerations {
|
|
17
|
-
constructor(_schemaEditor) {
|
|
18
|
-
this._schemaEditor = _schemaEditor;
|
|
19
|
-
}
|
|
20
|
-
async create(schemaKey, name, type, displayLabel, isStrict, enumerators) {
|
|
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 newEnum = (await schema.createEnumeration(name, type));
|
|
25
|
-
if (newEnum === undefined)
|
|
26
|
-
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
return { errorMessage: `
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (enumeration
|
|
62
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (enumeration.isInt && typeof (enumerator.value) !== "number") {
|
|
68
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidPrimitiveType, `The Enumeration ${enumeration.name} has type integer, while ${enumerator.name} has type ${typeof (enumerator.value)}.`);
|
|
69
|
-
}
|
|
70
|
-
if (enumeration.isString && typeof (enumerator.value) !== "string") {
|
|
71
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidPrimitiveType, `The Enumeration ${enumeration.name} has type string, while ${enumerator.name} has type ${typeof (enumerator.value)}.`);
|
|
72
|
-
}
|
|
73
|
-
enumeration.addEnumerator(enumerator);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.Enumerations = Enumerations;
|
|
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.Enumerations = 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 Enumeration.
|
|
15
|
+
*/
|
|
16
|
+
class Enumerations {
|
|
17
|
+
constructor(_schemaEditor) {
|
|
18
|
+
this._schemaEditor = _schemaEditor;
|
|
19
|
+
}
|
|
20
|
+
async create(schemaKey, name, type, displayLabel, isStrict, enumerators) {
|
|
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 newEnum = (await schema.createEnumeration(name, type));
|
|
25
|
+
if (newEnum === undefined)
|
|
26
|
+
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
27
|
+
if (undefined !== isStrict)
|
|
28
|
+
newEnum.setIsStrict(isStrict);
|
|
29
|
+
if (undefined !== enumerators)
|
|
30
|
+
for (const enumerator of enumerators)
|
|
31
|
+
await this.addEnumerator(newEnum.key, enumerator);
|
|
32
|
+
if (displayLabel)
|
|
33
|
+
newEnum.setDisplayLabel(displayLabel);
|
|
34
|
+
return { itemKey: newEnum.key };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates an Enumeration through an EnumeratorProps.
|
|
38
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
39
|
+
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
40
|
+
*/
|
|
41
|
+
async createFromProps(schemaKey, enumProps) {
|
|
42
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
43
|
+
if (schema === undefined)
|
|
44
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
45
|
+
if (enumProps.name === undefined)
|
|
46
|
+
return { errorMessage: `No name was supplied within props.` };
|
|
47
|
+
const newEnum = (await schema.createEnumeration(enumProps.name));
|
|
48
|
+
if (newEnum === undefined)
|
|
49
|
+
return { errorMessage: `Failed to create class ${enumProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
50
|
+
await newEnum.fromJSON(enumProps);
|
|
51
|
+
return { itemKey: newEnum.key };
|
|
52
|
+
}
|
|
53
|
+
async addEnumerator(enumerationKey, enumerator) {
|
|
54
|
+
const enumeration = (await this._schemaEditor.schemaContext.getSchemaItem(enumerationKey));
|
|
55
|
+
if (enumeration === undefined)
|
|
56
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Unable to locate Enumeration class ${enumerationKey.fullName}.`);
|
|
57
|
+
if (enumeration.schemaItemType !== ecschema_metadata_1.SchemaItemType.Enumeration)
|
|
58
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidType, `${enumeration.fullName} is not of type Enumerator class.`);
|
|
59
|
+
if (enumeration.isInt && typeof (enumerator.value) !== "number")
|
|
60
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidPrimitiveType, `The Enumeration ${enumeration.name} has type integer, while ${enumerator.name} has type ${typeof (enumerator.value)}.`);
|
|
61
|
+
if (enumeration.isString && typeof (enumerator.value) !== "string")
|
|
62
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidPrimitiveType, `The Enumeration ${enumeration.name} has type string, while ${enumerator.name} has type ${typeof (enumerator.value)}.`);
|
|
63
|
+
enumeration.addEnumerator(enumerator);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Enumerations = Enumerations;
|
|
77
67
|
//# sourceMappingURL=Enumerations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enumerations.js","sourceRoot":"","sources":["../../../src/Editing/Enumerations.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkL;AAIlL;;;GAGG;AACH,MAAa,YAAY;IACvB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,IAAkD,EAAE,YAAqB,EAAE,QAAkB,EAAE,WAA6B;QAClL,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;
|
|
1
|
+
{"version":3,"file":"Enumerations.js","sourceRoot":"","sources":["../../../src/Editing/Enumerations.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAkL;AAIlL;;;GAGG;AACH,MAAa,YAAY;IACvB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,IAAkD,EAAE,YAAqB,EAAE,QAAkB,EAAE,WAA6B;QAClL,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,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC7D,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,EAAE,YAAY,EAAE,0BAA0B,IAAI,cAAc,S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,WAAW,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAc,cAAc,CAAC,CAAC,CAAC;QAExG,IAAI,WAAW,KAAK,SAAS;YAC3B,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,aAAa,EAAE,sCAAsC,cAAc,CAAC,QAAQ,GAAG,CAAC,CAAC;QAE5H,IAAI,WAAW,CAAC,cAAc,KAAK,kCAAc,CAAC,WAAW;YAC3D,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,WAAW,EAAE,GAAG,WAAW,CAAC,QAAQ,mCAAmC,CAAC,CAAC;QAEpH,IAAI,WAAW,CAAC,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,QAAQ;YAC7D,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,oBAAoB,EAAE,mBAAmB,WAAW,CAAC,IAAI,4BAA4B,UAAU,CAAC,IAAI,aAAa,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE1L,IAAI,WAAW,CAAC,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,QAAQ;YAChE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,oBAAoB,EAAE,mBAAmB,WAAW,CAAC,IAAI,2BAA2B,UAAU,CAAC,IAAI,aAAa,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAExL,WAAkC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAChE,CAAC;CACF;AA/DD,oCA+DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { AnyEnumerator, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationProps, PrimitiveType, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableEnumeration } from \"./Mutable/MutableEnumeration\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Enumeration.\n */\nexport class Enumerations {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, type: PrimitiveType.Integer | PrimitiveType.String, displayLabel?: string, isStrict?: boolean, enumerators?: AnyEnumerator[]): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newEnum = (await schema.createEnumeration(name, type));\n if (newEnum === undefined)\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n\n if (undefined !== isStrict)\n (newEnum as MutableEnumeration).setIsStrict(isStrict);\n\n if (undefined !== enumerators)\n for (const enumerator of enumerators)\n await this.addEnumerator(newEnum.key, enumerator);\n\n if (displayLabel)\n (newEnum as MutableEnumeration).setDisplayLabel(displayLabel);\n\n return { itemKey: newEnum.key };\n }\n\n /**\n * Creates an Enumeration through an EnumeratorProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, enumProps: EnumerationProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (enumProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newEnum = (await schema.createEnumeration(enumProps.name));\n if (newEnum === undefined)\n return { errorMessage: `Failed to create class ${enumProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newEnum.fromJSON(enumProps);\n return { itemKey: newEnum.key };\n }\n\n public async addEnumerator(enumerationKey: SchemaItemKey, enumerator: AnyEnumerator): Promise<void> {\n const enumeration = (await this._schemaEditor.schemaContext.getSchemaItem<Enumeration>(enumerationKey));\n\n if (enumeration === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Unable to locate Enumeration class ${enumerationKey.fullName}.`);\n\n if (enumeration.schemaItemType !== SchemaItemType.Enumeration)\n throw new ECObjectsError(ECObjectsStatus.InvalidType, `${enumeration.fullName} is not of type Enumerator class.`);\n\n if (enumeration.isInt && typeof (enumerator.value) !== \"number\")\n throw new ECObjectsError(ECObjectsStatus.InvalidPrimitiveType, `The Enumeration ${enumeration.name} has type integer, while ${enumerator.name} has type ${typeof (enumerator.value)}.`);\n\n if (enumeration.isString && typeof (enumerator.value) !== \"string\")\n throw new ECObjectsError(ECObjectsStatus.InvalidPrimitiveType, `The Enumeration ${enumeration.name} has type string, while ${enumerator.name} has type ${typeof (enumerator.value)}.`);\n\n (enumeration as MutableEnumeration).addEnumerator(enumerator);\n }\n}\n"]}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Editing
|
|
3
|
-
*/
|
|
4
|
-
import { FormatProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
|
-
import { FormatType } from "@itwin/core-quantity";
|
|
6
|
-
import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
7
|
-
/**
|
|
8
|
-
* @alpha
|
|
9
|
-
* A class allowing you to create schema items of type Format.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Formats {
|
|
12
|
-
protected _schemaEditor: SchemaContextEditor;
|
|
13
|
-
constructor(_schemaEditor: SchemaContextEditor);
|
|
14
|
-
create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemEditResults>;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a format through a FormatProps.
|
|
17
|
-
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
18
|
-
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
19
|
-
*/
|
|
20
|
-
createFromProps(schemaKey: SchemaKey, formatProps: FormatProps): Promise<SchemaItemEditResults>;
|
|
21
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Editing
|
|
3
|
+
*/
|
|
4
|
+
import { FormatProps, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { FormatType } from "@itwin/core-quantity";
|
|
6
|
+
import { SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
7
|
+
/**
|
|
8
|
+
* @alpha
|
|
9
|
+
* A class allowing you to create schema items of type Format.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Formats {
|
|
12
|
+
protected _schemaEditor: SchemaContextEditor;
|
|
13
|
+
constructor(_schemaEditor: SchemaContextEditor);
|
|
14
|
+
create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemEditResults>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a format through a FormatProps.
|
|
17
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
18
|
+
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
19
|
+
*/
|
|
20
|
+
createFromProps(schemaKey: SchemaKey, formatProps: FormatProps): Promise<SchemaItemEditResults>;
|
|
21
|
+
}
|
|
22
22
|
//# sourceMappingURL=Formats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Formats.d.ts","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAA4B,aAAa,EAAkB,SAAS,EAAQ,MAAM,0BAA0B,CAAC;AACjI,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,OAAO;IACC,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Formats.d.ts","sourceRoot":"","sources":["../../../src/Editing/Formats.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAA4B,aAAa,EAAkB,SAAS,EAAQ,MAAM,0BAA0B,CAAC;AACjI,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,OAAO;IACC,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA2B/J;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAe7G"}
|
|
@@ -1,64 +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
|
-
|
|
40
|
-
|
|
41
|
-
newFormat.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
* @param
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
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 FormatProps.
|
|
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;
|
|
64
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,gEAAiI;AAKjI;;;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,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M,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Editing\n */\n\nimport { FormatProps, InvertedUnit, SchemaItem, SchemaItemKey, SchemaItemType, SchemaKey, Unit } from \"@itwin/ecschema-metadata\";\nimport { FormatType } from \"@itwin/core-quantity\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableFormat } from \"./Mutable/MutableFormat\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Format.\n */\nexport class Formats {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n public async create(schemaKey: SchemaKey, name: string, formatType: FormatType, displayLabel?: string, units?: SchemaItemKey[]): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n const newFormat = (await schema.createFormat(name)) as MutableFormat;\n if (newFormat === undefined) {\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n }\n\n if (units !== undefined) {\n for (const unit of units) {\n const unitItem = await this._schemaEditor.schemaContext.getSchemaItem<Unit | InvertedUnit>(unit);\n if (unitItem === undefined) {\n return { errorMessage: `Failed to locate unit ${unit.name} in Schema Context.` };\n }\n\n if (unitItem.schemaItemType !== SchemaItemType.Unit && unitItem.schemaItemType !== SchemaItemType.InvertedUnit)\n return { errorMessage: `${(unitItem as SchemaItem).fullName} is not of type Unit or InvertedUnit.` };\n newFormat.addUnit(unitItem);\n }\n }\n if (displayLabel)\n newFormat.setDisplayLabel(displayLabel);\n\n // TODO: Handle the setting of format traits, separators, etc....\n newFormat.setFormatType(formatType);\n return { itemKey: newFormat.key };\n }\n\n /**\n * Creates a format through a FormatProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, formatProps: FormatProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (formatProps.name === undefined)\n return { errorMessage: `No name was supplied within props.` };\n\n const newFormat = (await schema.createFormat(formatProps.name)) as MutableFormat;\n if (newFormat === undefined)\n return { errorMessage: `Failed to create class ${formatProps.name} in schema ${schemaKey.toString(true)}.` };\n\n await newFormat.fromJSON(formatProps);\n return { itemKey: newFormat.key };\n }\n}\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedUnits.d.ts","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACqD,iBAAiB,EAAE,aAAa,EAC1E,SAAS,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,aAAa;IACL,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"InvertedUnits.d.ts","sourceRoot":"","sources":["../../../src/Editing/InvertedUnits.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACqD,iBAAiB,EAAE,aAAa,EAC1E,SAAS,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,aAAa;IACL,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAClD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAiC9J,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgB3G,cAAc,CAAC,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI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