@itwin/ecschema-editing 3.0.0-dev.72
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 +109 -0
- package/LICENSE.md +9 -0
- package/README.md +11 -0
- package/lib/Editing/Constants.d.ts +21 -0
- package/lib/Editing/Constants.d.ts.map +1 -0
- package/lib/Editing/Constants.js +65 -0
- package/lib/Editing/Constants.js.map +1 -0
- package/lib/Editing/CustomAttributes.d.ts +21 -0
- package/lib/Editing/CustomAttributes.d.ts.map +1 -0
- package/lib/Editing/CustomAttributes.js +59 -0
- package/lib/Editing/CustomAttributes.js.map +1 -0
- package/lib/Editing/ECClasses.d.ts +33 -0
- package/lib/Editing/ECClasses.d.ts.map +1 -0
- package/lib/Editing/ECClasses.js +186 -0
- package/lib/Editing/ECClasses.js.map +1 -0
- package/lib/Editing/Editor.d.ts +105 -0
- package/lib/Editing/Editor.d.ts.map +1 -0
- package/lib/Editing/Editor.js +175 -0
- package/lib/Editing/Editor.js.map +1 -0
- package/lib/Editing/Entities.d.ts +23 -0
- package/lib/Editing/Entities.d.ts.map +1 -0
- package/lib/Editing/Entities.js +89 -0
- package/lib/Editing/Entities.js.map +1 -0
- package/lib/Editing/Enumerations.d.ts +22 -0
- package/lib/Editing/Enumerations.d.ts.map +1 -0
- package/lib/Editing/Enumerations.js +71 -0
- package/lib/Editing/Enumerations.js.map +1 -0
- package/lib/Editing/Formats.d.ts +21 -0
- package/lib/Editing/Formats.d.ts.map +1 -0
- package/lib/Editing/Formats.js +61 -0
- package/lib/Editing/Formats.js.map +1 -0
- package/lib/Editing/InvertedUnits.d.ts +18 -0
- package/lib/Editing/InvertedUnits.d.ts.map +1 -0
- package/lib/Editing/InvertedUnits.js +86 -0
- package/lib/Editing/InvertedUnits.js.map +1 -0
- package/lib/Editing/KindOfQuantities.d.ts +29 -0
- package/lib/Editing/KindOfQuantities.d.ts.map +1 -0
- package/lib/Editing/KindOfQuantities.js +80 -0
- package/lib/Editing/KindOfQuantities.js.map +1 -0
- package/lib/Editing/Mixins.d.ts +23 -0
- package/lib/Editing/Mixins.d.ts.map +1 -0
- package/lib/Editing/Mixins.js +89 -0
- package/lib/Editing/Mixins.js.map +1 -0
- package/lib/Editing/Mutable/MutableCAClass.d.ts +10 -0
- package/lib/Editing/Mutable/MutableCAClass.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableCAClass.js +16 -0
- package/lib/Editing/Mutable/MutableCAClass.js.map +1 -0
- package/lib/Editing/Mutable/MutableClass.d.ts +35 -0
- package/lib/Editing/Mutable/MutableClass.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableClass.js +23 -0
- package/lib/Editing/Mutable/MutableClass.js.map +1 -0
- package/lib/Editing/Mutable/MutableConstant.d.ts +13 -0
- package/lib/Editing/Mutable/MutableConstant.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableConstant.js +16 -0
- package/lib/Editing/Mutable/MutableConstant.js.map +1 -0
- package/lib/Editing/Mutable/MutableEntityClass.d.ts +16 -0
- package/lib/Editing/Mutable/MutableEntityClass.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableEntityClass.js +60 -0
- package/lib/Editing/Mutable/MutableEntityClass.js.map +1 -0
- package/lib/Editing/Mutable/MutableEnumeration.d.ts +10 -0
- package/lib/Editing/Mutable/MutableEnumeration.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableEnumeration.js +15 -0
- package/lib/Editing/Mutable/MutableEnumeration.js.map +1 -0
- package/lib/Editing/Mutable/MutableFormat.d.ts +18 -0
- package/lib/Editing/Mutable/MutableFormat.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableFormat.js +16 -0
- package/lib/Editing/Mutable/MutableFormat.js.map +1 -0
- package/lib/Editing/Mutable/MutableInvertedUnit.d.ts +11 -0
- package/lib/Editing/Mutable/MutableInvertedUnit.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableInvertedUnit.js +16 -0
- package/lib/Editing/Mutable/MutableInvertedUnit.js.map +1 -0
- package/lib/Editing/Mutable/MutableKindOfQuantity.d.ts +11 -0
- package/lib/Editing/Mutable/MutableKindOfQuantity.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableKindOfQuantity.js +16 -0
- package/lib/Editing/Mutable/MutableKindOfQuantity.js.map +1 -0
- package/lib/Editing/Mutable/MutableMixin.d.ts +12 -0
- package/lib/Editing/Mutable/MutableMixin.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableMixin.js +16 -0
- package/lib/Editing/Mutable/MutableMixin.js.map +1 -0
- package/lib/Editing/Mutable/MutablePhenomenon.d.ts +10 -0
- package/lib/Editing/Mutable/MutablePhenomenon.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutablePhenomenon.js +16 -0
- package/lib/Editing/Mutable/MutablePhenomenon.js.map +1 -0
- package/lib/Editing/Mutable/MutableProperty.d.ts +9 -0
- package/lib/Editing/Mutable/MutableProperty.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableProperty.js +16 -0
- package/lib/Editing/Mutable/MutableProperty.js.map +1 -0
- package/lib/Editing/Mutable/MutablePropertyCategory.d.ts +10 -0
- package/lib/Editing/Mutable/MutablePropertyCategory.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutablePropertyCategory.js +16 -0
- package/lib/Editing/Mutable/MutablePropertyCategory.js.map +1 -0
- package/lib/Editing/Mutable/MutableRelationshipClass.d.ts +22 -0
- package/lib/Editing/Mutable/MutableRelationshipClass.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableRelationshipClass.js +25 -0
- package/lib/Editing/Mutable/MutableRelationshipClass.js.map +1 -0
- package/lib/Editing/Mutable/MutableSchema.d.ts +46 -0
- package/lib/Editing/Mutable/MutableSchema.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableSchema.js +18 -0
- package/lib/Editing/Mutable/MutableSchema.js.map +1 -0
- package/lib/Editing/Mutable/MutableUnit.d.ts +12 -0
- package/lib/Editing/Mutable/MutableUnit.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableUnit.js +16 -0
- package/lib/Editing/Mutable/MutableUnit.js.map +1 -0
- package/lib/Editing/Mutable/MutableUnitSystem.d.ts +9 -0
- package/lib/Editing/Mutable/MutableUnitSystem.d.ts.map +1 -0
- package/lib/Editing/Mutable/MutableUnitSystem.js +16 -0
- package/lib/Editing/Mutable/MutableUnitSystem.js.map +1 -0
- package/lib/Editing/Phenomena.d.ts +16 -0
- package/lib/Editing/Phenomena.d.ts.map +1 -0
- package/lib/Editing/Phenomena.js +48 -0
- package/lib/Editing/Phenomena.js.map +1 -0
- package/lib/Editing/PropertyCategories.d.ts +17 -0
- package/lib/Editing/PropertyCategories.d.ts.map +1 -0
- package/lib/Editing/PropertyCategories.js +54 -0
- package/lib/Editing/PropertyCategories.js.map +1 -0
- package/lib/Editing/RelationshipClasses.d.ts +22 -0
- package/lib/Editing/RelationshipClasses.d.ts.map +1 -0
- package/lib/Editing/RelationshipClasses.js +70 -0
- package/lib/Editing/RelationshipClasses.js.map +1 -0
- package/lib/Editing/Structs.d.ts +20 -0
- package/lib/Editing/Structs.d.ts.map +1 -0
- package/lib/Editing/Structs.js +57 -0
- package/lib/Editing/Structs.js.map +1 -0
- package/lib/Editing/UnitSystems.d.ts +16 -0
- package/lib/Editing/UnitSystems.d.ts.map +1 -0
- package/lib/Editing/UnitSystems.js +44 -0
- package/lib/Editing/UnitSystems.js.map +1 -0
- package/lib/Editing/Units.d.ts +16 -0
- package/lib/Editing/Units.d.ts.map +1 -0
- package/lib/Editing/Units.js +62 -0
- package/lib/Editing/Units.js.map +1 -0
- package/lib/Validation/Diagnostic.d.ts +322 -0
- package/lib/Validation/Diagnostic.d.ts.map +1 -0
- package/lib/Validation/Diagnostic.js +311 -0
- package/lib/Validation/Diagnostic.js.map +1 -0
- package/lib/Validation/DiagnosticReporter.d.ts +97 -0
- package/lib/Validation/DiagnosticReporter.d.ts.map +1 -0
- package/lib/Validation/DiagnosticReporter.js +107 -0
- package/lib/Validation/DiagnosticReporter.js.map +1 -0
- package/lib/Validation/ECRules.d.ts +439 -0
- package/lib/Validation/ECRules.d.ts.map +1 -0
- package/lib/Validation/ECRules.js +679 -0
- package/lib/Validation/ECRules.js.map +1 -0
- package/lib/Validation/LoggingDiagnosticReporter.d.ts +14 -0
- package/lib/Validation/LoggingDiagnosticReporter.d.ts.map +1 -0
- package/lib/Validation/LoggingDiagnosticReporter.js +41 -0
- package/lib/Validation/LoggingDiagnosticReporter.js.map +1 -0
- package/lib/Validation/RuleSuppressionSet.d.ts +59 -0
- package/lib/Validation/RuleSuppressionSet.d.ts.map +1 -0
- package/lib/Validation/RuleSuppressionSet.js +10 -0
- package/lib/Validation/RuleSuppressionSet.js.map +1 -0
- package/lib/Validation/Rules.d.ts +65 -0
- package/lib/Validation/Rules.d.ts.map +1 -0
- package/lib/Validation/Rules.js +10 -0
- package/lib/Validation/Rules.js.map +1 -0
- package/lib/Validation/SchemaChanges.d.ts +608 -0
- package/lib/Validation/SchemaChanges.d.ts.map +1 -0
- package/lib/Validation/SchemaChanges.js +1136 -0
- package/lib/Validation/SchemaChanges.js.map +1 -0
- package/lib/Validation/SchemaCompareDiagnostics.d.ts +423 -0
- package/lib/Validation/SchemaCompareDiagnostics.d.ts.map +1 -0
- package/lib/Validation/SchemaCompareDiagnostics.js +112 -0
- package/lib/Validation/SchemaCompareDiagnostics.js.map +1 -0
- package/lib/Validation/SchemaCompareReporter.d.ts +12 -0
- package/lib/Validation/SchemaCompareReporter.d.ts.map +1 -0
- package/lib/Validation/SchemaCompareReporter.js +10 -0
- package/lib/Validation/SchemaCompareReporter.js.map +1 -0
- package/lib/Validation/SchemaCompareResultDelegate.d.ts +237 -0
- package/lib/Validation/SchemaCompareResultDelegate.d.ts.map +1 -0
- package/lib/Validation/SchemaCompareResultDelegate.js +349 -0
- package/lib/Validation/SchemaCompareResultDelegate.js.map +1 -0
- package/lib/Validation/SchemaCompareVisitor.d.ts +120 -0
- package/lib/Validation/SchemaCompareVisitor.d.ts.map +1 -0
- package/lib/Validation/SchemaCompareVisitor.js +207 -0
- package/lib/Validation/SchemaCompareVisitor.js.map +1 -0
- package/lib/Validation/SchemaComparer.d.ts +172 -0
- package/lib/Validation/SchemaComparer.d.ts.map +1 -0
- package/lib/Validation/SchemaComparer.js +666 -0
- package/lib/Validation/SchemaComparer.js.map +1 -0
- package/lib/Validation/SchemaValidater.d.ts +20 -0
- package/lib/Validation/SchemaValidater.d.ts.map +1 -0
- package/lib/Validation/SchemaValidater.js +62 -0
- package/lib/Validation/SchemaValidater.js.map +1 -0
- package/lib/Validation/SchemaValidationVisitor.d.ts +171 -0
- package/lib/Validation/SchemaValidationVisitor.d.ts.map +1 -0
- package/lib/Validation/SchemaValidationVisitor.js +729 -0
- package/lib/Validation/SchemaValidationVisitor.js.map +1 -0
- package/lib/Validation/SchemaWalker.d.ts +23 -0
- package/lib/Validation/SchemaWalker.d.ts.map +1 -0
- package/lib/Validation/SchemaWalker.js +52 -0
- package/lib/Validation/SchemaWalker.js.map +1 -0
- package/lib/ecschema-editing.d.ts +34 -0
- package/lib/ecschema-editing.d.ts.map +1 -0
- package/lib/ecschema-editing.js +55 -0
- package/lib/ecschema-editing.js.map +1 -0
- package/package.json +85 -0
- package/public/locales/en/ECSchemaEditing.json +27 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Change Log - @itwin/ecschema-editing
|
|
2
|
+
|
|
3
|
+
This log was last generated on Tue, 21 Sep 2021 21:06:40 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 2.19.13
|
|
6
|
+
Tue, 21 Sep 2021 21:06:40 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 2.19.12
|
|
11
|
+
Wed, 15 Sep 2021 18:06:46 GMT
|
|
12
|
+
|
|
13
|
+
### Updates
|
|
14
|
+
|
|
15
|
+
- Bump xmldom@^0.6.0 -> @xmldom/xmldom@^0.7.0, and remove @types/xmldom, as typedefs are now delivered with their core pkg. This should resolve cve-2021-32796
|
|
16
|
+
|
|
17
|
+
## 2.19.11
|
|
18
|
+
Thu, 09 Sep 2021 21:04:57 GMT
|
|
19
|
+
|
|
20
|
+
_Version update only_
|
|
21
|
+
|
|
22
|
+
## 2.19.10
|
|
23
|
+
Wed, 08 Sep 2021 14:36:01 GMT
|
|
24
|
+
|
|
25
|
+
_Version update only_
|
|
26
|
+
|
|
27
|
+
## 2.19.9
|
|
28
|
+
Wed, 25 Aug 2021 15:36:01 GMT
|
|
29
|
+
|
|
30
|
+
_Version update only_
|
|
31
|
+
|
|
32
|
+
## 2.19.8
|
|
33
|
+
Mon, 23 Aug 2021 13:23:13 GMT
|
|
34
|
+
|
|
35
|
+
_Version update only_
|
|
36
|
+
|
|
37
|
+
## 2.19.7
|
|
38
|
+
Fri, 20 Aug 2021 17:47:22 GMT
|
|
39
|
+
|
|
40
|
+
_Version update only_
|
|
41
|
+
|
|
42
|
+
## 2.19.6
|
|
43
|
+
Tue, 17 Aug 2021 20:34:28 GMT
|
|
44
|
+
|
|
45
|
+
_Version update only_
|
|
46
|
+
|
|
47
|
+
## 2.19.5
|
|
48
|
+
Fri, 13 Aug 2021 21:48:08 GMT
|
|
49
|
+
|
|
50
|
+
_Version update only_
|
|
51
|
+
|
|
52
|
+
## 2.19.4
|
|
53
|
+
Thu, 12 Aug 2021 13:09:26 GMT
|
|
54
|
+
|
|
55
|
+
_Version update only_
|
|
56
|
+
|
|
57
|
+
## 2.19.3
|
|
58
|
+
Wed, 04 Aug 2021 20:29:34 GMT
|
|
59
|
+
|
|
60
|
+
### Updates
|
|
61
|
+
|
|
62
|
+
- switch to xmldom@0.6.0 which correctly escapes entities in attributes when serializing
|
|
63
|
+
|
|
64
|
+
## 2.19.2
|
|
65
|
+
Tue, 03 Aug 2021 18:26:23 GMT
|
|
66
|
+
|
|
67
|
+
_Version update only_
|
|
68
|
+
|
|
69
|
+
## 2.19.1
|
|
70
|
+
Thu, 29 Jul 2021 20:01:11 GMT
|
|
71
|
+
|
|
72
|
+
_Version update only_
|
|
73
|
+
|
|
74
|
+
## 2.19.0
|
|
75
|
+
Mon, 26 Jul 2021 12:21:25 GMT
|
|
76
|
+
|
|
77
|
+
### Updates
|
|
78
|
+
|
|
79
|
+
- Extracted editor classes to their own files and other alpha level changes.
|
|
80
|
+
- Split editing tests into different test files
|
|
81
|
+
|
|
82
|
+
## 2.18.4
|
|
83
|
+
Tue, 10 Aug 2021 19:35:13 GMT
|
|
84
|
+
|
|
85
|
+
_Version update only_
|
|
86
|
+
|
|
87
|
+
## 2.18.3
|
|
88
|
+
Wed, 28 Jul 2021 17:16:30 GMT
|
|
89
|
+
|
|
90
|
+
_Version update only_
|
|
91
|
+
|
|
92
|
+
## 2.18.2
|
|
93
|
+
Mon, 26 Jul 2021 16:18:31 GMT
|
|
94
|
+
|
|
95
|
+
_Version update only_
|
|
96
|
+
|
|
97
|
+
## 2.18.1
|
|
98
|
+
Fri, 16 Jul 2021 17:45:09 GMT
|
|
99
|
+
|
|
100
|
+
_Version update only_
|
|
101
|
+
|
|
102
|
+
## 2.18.0
|
|
103
|
+
Fri, 09 Jul 2021 18:11:24 GMT
|
|
104
|
+
|
|
105
|
+
### Updates
|
|
106
|
+
|
|
107
|
+
- ECSchema validation and editing APIs moved from the ecschema-metadata package to the ecschema-editing package.
|
|
108
|
+
- Added ability to increment minor version number via the schema editing API.
|
|
109
|
+
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2017-2021 Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @itwin/ecschema-editing
|
|
2
|
+
|
|
3
|
+
Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
The __@itwin/ecschema-editing__ package contains classes for editing and validating ECSchemas. This package is a work in progress consider everything in alpha.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
See the [iTwin.js](https://www.itwinjs.org) documentation for more information.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Editing
|
|
3
|
+
*/
|
|
4
|
+
import { ConstantProps, 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 Constant.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Constants {
|
|
11
|
+
protected _schemaEditor: SchemaContextEditor;
|
|
12
|
+
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
+
create(schemaKey: SchemaKey, name: string, phenomenon: SchemaItemKey, definition: string, displayLabel?: string, numerator?: number, denominator?: number): Promise<SchemaItemEditResults>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a Constant through a ConstantProps.
|
|
16
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
17
|
+
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
18
|
+
*/
|
|
19
|
+
createFromProps(schemaKey: SchemaKey, constantProps: ConstantProps): Promise<SchemaItemEditResults>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../src/Editing/Constants.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAuC,aAAa,EAAkB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACxI,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGtE;;;GAGG;AACH,qBAAa,SAAS;IACD,SAAS,CAAC,aAAa,EAAE,mBAAmB;gBAAlC,aAAa,EAAE,mBAAmB;IAElD,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAuBvM;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAajH"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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.Constants = 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 Constant.
|
|
15
|
+
*/
|
|
16
|
+
class Constants {
|
|
17
|
+
constructor(_schemaEditor) {
|
|
18
|
+
this._schemaEditor = _schemaEditor;
|
|
19
|
+
}
|
|
20
|
+
async create(schemaKey, name, phenomenon, definition, displayLabel, numerator, denominator) {
|
|
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 newConstant = (await schema.createConstant(name));
|
|
25
|
+
if (newConstant === undefined) {
|
|
26
|
+
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
27
|
+
}
|
|
28
|
+
const newPhenomenon = (await this._schemaEditor.schemaContext.getSchemaItem(phenomenon));
|
|
29
|
+
if (newPhenomenon === undefined || newPhenomenon.schemaItemType !== ecschema_metadata_1.SchemaItemType.Phenomenon) {
|
|
30
|
+
return { errorMessage: `Unable to locate phenomenon ${phenomenon.name}` };
|
|
31
|
+
}
|
|
32
|
+
newConstant.setPhenomenon(new ecschema_metadata_1.DelayedPromiseWithProps(newPhenomenon.key, async () => newPhenomenon));
|
|
33
|
+
newConstant.setDefinition(definition);
|
|
34
|
+
if (numerator) {
|
|
35
|
+
newConstant.setNumerator(numerator);
|
|
36
|
+
}
|
|
37
|
+
if (denominator) {
|
|
38
|
+
newConstant.setDenominator(denominator);
|
|
39
|
+
}
|
|
40
|
+
if (displayLabel) {
|
|
41
|
+
newConstant.setDisplayLabel(displayLabel);
|
|
42
|
+
}
|
|
43
|
+
return { itemKey: newConstant.key };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a Constant through a ConstantProps.
|
|
47
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
48
|
+
* @param relationshipProps a json object that will be used to populate the new RelationshipClass. Needs a name value passed in.
|
|
49
|
+
*/
|
|
50
|
+
async createFromProps(schemaKey, constantProps) {
|
|
51
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
52
|
+
if (schema === undefined)
|
|
53
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
54
|
+
if (constantProps.name === undefined)
|
|
55
|
+
return { errorMessage: `No name was supplied within props.` };
|
|
56
|
+
const newConstant = (await schema.createConstant(constantProps.name));
|
|
57
|
+
if (newConstant === undefined) {
|
|
58
|
+
return { errorMessage: `Failed to create class ${constantProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
59
|
+
}
|
|
60
|
+
await newConstant.fromJSON(constantProps);
|
|
61
|
+
return { itemKey: newConstant.key };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.Constants = Constants;
|
|
65
|
+
//# sourceMappingURL=Constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Editing/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAAwI;AAIxI;;;GAGG;AACH,MAAa,SAAS;IACpB,YAA6B,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAE7D,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,UAAyB,EAAE,UAAkB,EAAE,YAAqB,EAAE,SAAkB,EAAE,WAAoB;QACpK,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7D,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,E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AI,MAAM,KAAK,SAAS;YAAE,OAAO,EAAE,YAAY,EAAE,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEjH,IAAI,aAAa,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,EAAE,YAAY,EAAE,oCAAoC,EAAE,CAAC;QACpG,MAAM,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,CAAoB,CAAC;QACzF,IAAI,WAAW,KAAK,SAAS,EAAE;YAC7B,OAAO,EAAE,YAAY,EAAE,0BAA0B,aAAa,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SAChH;QAED,MAAM,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC1C,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;CACF;AA5CD,8BA4CC","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 { ConstantProps, DelayedPromiseWithProps, Phenomenon, SchemaItemKey, SchemaItemType, SchemaKey } from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableConstant } from \"./Mutable/MutableConstant\";\n\n/**\n * @alpha\n * A class allowing you to create schema items of type Constant.\n */\nexport class Constants {\n public constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n public async create(schemaKey: SchemaKey, name: string, phenomenon: SchemaItemKey, definition: string, displayLabel?: string, numerator?: number, denominator?: number): 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 newConstant = (await schema.createConstant(name)) as MutableConstant;\n if (newConstant === undefined) {\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n }\n\n const newPhenomenon = (await this._schemaEditor.schemaContext.getSchemaItem(phenomenon)) as Phenomenon;\n if (newPhenomenon === undefined || newPhenomenon.schemaItemType !== SchemaItemType.Phenomenon) {\n return { errorMessage: `Unable to locate phenomenon ${phenomenon.name}` };\n }\n newConstant.setPhenomenon(new DelayedPromiseWithProps<SchemaItemKey, Phenomenon>(newPhenomenon.key, async () => newPhenomenon));\n newConstant.setDefinition(definition);\n\n if (numerator) { newConstant.setNumerator(numerator); }\n if (denominator) { newConstant.setDenominator(denominator); }\n if (displayLabel) { newConstant.setDisplayLabel(displayLabel); }\n return { itemKey: newConstant.key };\n }\n\n /**\n * Creates a Constant through a ConstantProps.\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, constantProps: ConstantProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined) return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (constantProps.name === undefined) return { errorMessage: `No name was supplied within props.` };\n const newConstant = (await schema.createConstant(constantProps.name)) as MutableConstant;\n if (newConstant === undefined) {\n return { errorMessage: `Failed to create class ${constantProps.name} in schema ${schemaKey.toString(true)}.` };\n }\n\n await newConstant.fromJSON(constantProps);\n return { itemKey: newConstant.key };\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Editing
|
|
3
|
+
*/
|
|
4
|
+
import { CustomAttributeClassProps, CustomAttributeContainerType, SchemaItemKey, SchemaKey } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { 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 CustomAttributeClass.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CustomAttributes extends ECClasses {
|
|
12
|
+
constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
+
create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a CustomAttributeClass through a CustomAttributeClassProps.
|
|
16
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
17
|
+
* @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.
|
|
18
|
+
*/
|
|
19
|
+
createFromProps(schemaKey: SchemaKey, caProps: CustomAttributeClassProps): Promise<SchemaItemEditResults>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=CustomAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomAttributes.d.ts","sourceRoot":"","sources":["../../src/Editing/CustomAttributes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACiB,yBAAyB,EAAE,4BAA4B,EAC7E,aAAa,EAAE,SAAS,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBAC1B,aAAa,EAAE,mBAAmB;IAIxC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,4BAA4B,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoBtL;;;;OAIG;IACU,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAavH"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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.CustomAttributes = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
const ECClasses_1 = require("./ECClasses");
|
|
13
|
+
/**
|
|
14
|
+
* @alpha
|
|
15
|
+
* A class extending ECClasses allowing you to create schema items of type CustomAttributeClass.
|
|
16
|
+
*/
|
|
17
|
+
class CustomAttributes extends ECClasses_1.ECClasses {
|
|
18
|
+
constructor(_schemaEditor) {
|
|
19
|
+
super(_schemaEditor);
|
|
20
|
+
}
|
|
21
|
+
async create(schemaKey, name, containerType, displayLabel, baseClass) {
|
|
22
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
23
|
+
if (schema === undefined)
|
|
24
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
25
|
+
const newClass = (await schema.createCustomAttributeClass(name));
|
|
26
|
+
if (newClass === undefined) {
|
|
27
|
+
return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };
|
|
28
|
+
}
|
|
29
|
+
if (baseClass !== undefined) {
|
|
30
|
+
const baseClassItem = await schema.lookupItem(baseClass);
|
|
31
|
+
newClass.baseClass = new ecschema_metadata_1.DelayedPromiseWithProps(baseClass, async () => baseClassItem);
|
|
32
|
+
}
|
|
33
|
+
if (displayLabel) {
|
|
34
|
+
newClass.setDisplayLabel(displayLabel);
|
|
35
|
+
}
|
|
36
|
+
newClass.setContainerType(containerType);
|
|
37
|
+
return { itemKey: newClass.key };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a CustomAttributeClass through a CustomAttributeClassProps.
|
|
41
|
+
* @param schemaKey a SchemaKey of the Schema that will house the new object.
|
|
42
|
+
* @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.
|
|
43
|
+
*/
|
|
44
|
+
async createFromProps(schemaKey, caProps) {
|
|
45
|
+
const schema = await this._schemaEditor.getSchema(schemaKey);
|
|
46
|
+
if (schema === undefined)
|
|
47
|
+
return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };
|
|
48
|
+
if (caProps.name === undefined)
|
|
49
|
+
return { errorMessage: `No name was supplied within props.` };
|
|
50
|
+
const newClass = (await schema.createCustomAttributeClass(caProps.name));
|
|
51
|
+
if (newClass === undefined) {
|
|
52
|
+
return { errorMessage: `Failed to create class ${caProps.name} in schema ${schemaKey.toString(true)}.` };
|
|
53
|
+
}
|
|
54
|
+
await newClass.fromJSON(caProps);
|
|
55
|
+
return { itemKey: newClass.key };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.CustomAttributes = CustomAttributes;
|
|
59
|
+
//# sourceMappingURL=CustomAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomAttributes.js","sourceRoot":"","sources":["../../src/Editing/CustomAttributes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAGkC;AAElC,2CAAwC;AAGxC;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,qBAAS;IAC7C,YAAmB,aAAkC;QACnD,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,IAAY,EAAE,aAA2C,EAAE,YAAqB,EAAE,SAAyB;QACnJ,MAAM,MAAM,GAAG,MAAM,IAAI,CA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,CAAC,MAAM,MAAM,CAAC,0BAA0B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAmB,CAAC;QAC3F,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,OAAO,EAAE,YAAY,EAAE,0BAA0B,OAAO,CAAC,IAAI,cAAc,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;SAC1G;QACD,MAAM,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;IACnC,CAAC;CACF;AA3CD,4CA2CC","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 {\n CustomAttributeClass, CustomAttributeClassProps, CustomAttributeContainerType, DelayedPromiseWithProps, ECClass,\n SchemaItemKey, SchemaKey,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { ECClasses } from \"./ECClasses\";\nimport { MutableCAClass } from \"./Mutable/MutableCAClass\";\n\n/**\n * @alpha\n * A class extending ECClasses allowing you to create schema items of type CustomAttributeClass.\n */\nexport class CustomAttributes extends ECClasses {\n public constructor(_schemaEditor: SchemaContextEditor) {\n super(_schemaEditor);\n }\n\n public async create(schemaKey: SchemaKey, name: string, containerType: CustomAttributeContainerType, displayLabel?: string, baseClass?: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined) return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n const newClass = (await schema.createCustomAttributeClass(name)) as MutableCAClass;\n if (newClass === undefined) {\n return { errorMessage: `Failed to create class ${name} in schema ${schemaKey.toString(true)}.` };\n }\n\n if (baseClass !== undefined) {\n const baseClassItem = await schema.lookupItem(baseClass) as CustomAttributeClass;\n newClass.baseClass = new DelayedPromiseWithProps<SchemaItemKey, ECClass>(baseClass, async () => baseClassItem);\n }\n if (displayLabel) { newClass.setDisplayLabel(displayLabel); }\n\n newClass.setContainerType(containerType);\n\n return { itemKey: newClass.key };\n }\n\n /**\n * Creates a CustomAttributeClass through a CustomAttributeClassProps.\n * @param schemaKey a SchemaKey of the Schema that will house the new object.\n * @param caProps a json object that will be used to populate the new CustomAttributeClass. Needs a name value passed in.\n */\n public async createFromProps(schemaKey: SchemaKey, caProps: CustomAttributeClassProps): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(schemaKey);\n if (schema === undefined) return { errorMessage: `Schema Key ${schemaKey.toString(true)} not found in context` };\n\n if (caProps.name === undefined) return { errorMessage: `No name was supplied within props.` };\n const newClass = (await schema.createCustomAttributeClass(caProps.name)) as MutableCAClass;\n if (newClass === undefined) {\n return { errorMessage: `Failed to create class ${caProps.name} in schema ${schemaKey.toString(true)}.` };\n }\n await newClass.fromJSON(caProps);\n\n return { itemKey: newClass.key };\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Editing
|
|
3
|
+
*/
|
|
4
|
+
import { Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PrimitiveType, SchemaItemKey, StructArrayPropertyProps, StructClass, StructPropertyProps } from "@itwin/ecschema-metadata";
|
|
5
|
+
import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
* Acts as a base class for schema class creation. Enables property creation.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ECClasses {
|
|
11
|
+
protected _schemaEditor: SchemaContextEditor;
|
|
12
|
+
protected constructor(_schemaEditor: SchemaContextEditor);
|
|
13
|
+
/**
|
|
14
|
+
* Create a primitive property on class identified by the given SchemaItemKey.
|
|
15
|
+
* @param classKey The SchemaItemKey of the class.
|
|
16
|
+
* @param name The name of the new property.
|
|
17
|
+
* @param type The PrimitiveType assigned to the new property.
|
|
18
|
+
*/
|
|
19
|
+
createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults>;
|
|
20
|
+
createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults>;
|
|
21
|
+
createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults>;
|
|
22
|
+
createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults>;
|
|
23
|
+
createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults>;
|
|
24
|
+
createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults>;
|
|
25
|
+
createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults>;
|
|
26
|
+
createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults>;
|
|
27
|
+
createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults>;
|
|
28
|
+
createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults>;
|
|
29
|
+
deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults>;
|
|
30
|
+
delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults>;
|
|
31
|
+
private getClass;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=ECClasses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ECClasses.d.ts","sourceR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C;IAa5K,oBAAoB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAY5G,6BAA6B,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAavJ,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAYjH,kCAAkC,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAajK,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAYnF,MAAM,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAc9D,QAAQ;CAsBvB"}
|
|
@@ -0,0 +1,186 @@
|
|
|
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.ECClasses = void 0;
|
|
11
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
12
|
+
/**
|
|
13
|
+
* @alpha
|
|
14
|
+
* Acts as a base class for schema class creation. Enables property creation.
|
|
15
|
+
*/
|
|
16
|
+
class ECClasses {
|
|
17
|
+
constructor(_schemaEditor) {
|
|
18
|
+
this._schemaEditor = _schemaEditor;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a primitive property on class identified by the given SchemaItemKey.
|
|
22
|
+
* @param classKey The SchemaItemKey of the class.
|
|
23
|
+
* @param name The name of the new property.
|
|
24
|
+
* @param type The PrimitiveType assigned to the new property.
|
|
25
|
+
*/
|
|
26
|
+
async createPrimitiveProperty(classKey, name, type) {
|
|
27
|
+
let mutableClass;
|
|
28
|
+
try {
|
|
29
|
+
mutableClass = await this.getClass(classKey, name);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
return { errorMessage: e.message };
|
|
33
|
+
}
|
|
34
|
+
await mutableClass.createPrimitiveProperty(name, type);
|
|
35
|
+
return { itemKey: classKey, propertyName: name };
|
|
36
|
+
}
|
|
37
|
+
async createPrimitivePropertyFromProps(classKey, name, type, primitiveProps) {
|
|
38
|
+
let mutableClass;
|
|
39
|
+
try {
|
|
40
|
+
mutableClass = await this.getClass(classKey, name);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return { errorMessage: e.message };
|
|
44
|
+
}
|
|
45
|
+
const newProperty = await mutableClass.createPrimitiveProperty(name, type);
|
|
46
|
+
await newProperty.fromJSON(primitiveProps);
|
|
47
|
+
return { itemKey: classKey, propertyName: name };
|
|
48
|
+
}
|
|
49
|
+
async createEnumerationProperty(classKey, name, type) {
|
|
50
|
+
let mutableClass;
|
|
51
|
+
try {
|
|
52
|
+
mutableClass = await this.getClass(classKey, name);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
return { errorMessage: e.message };
|
|
56
|
+
}
|
|
57
|
+
const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);
|
|
58
|
+
if (enumSchemaItemKey === undefined)
|
|
59
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);
|
|
60
|
+
await mutableClass.createPrimitiveProperty(name, type);
|
|
61
|
+
return { itemKey: classKey, propertyName: name };
|
|
62
|
+
}
|
|
63
|
+
async createEnumerationPropertyFromProps(classKey, name, type, enumProps) {
|
|
64
|
+
let mutableClass;
|
|
65
|
+
try {
|
|
66
|
+
mutableClass = await this.getClass(classKey, name);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
return { errorMessage: e.message };
|
|
70
|
+
}
|
|
71
|
+
const newProperty = await mutableClass.createPrimitiveProperty(name, type);
|
|
72
|
+
await newProperty.fromJSON(enumProps);
|
|
73
|
+
return { itemKey: classKey, propertyName: name };
|
|
74
|
+
}
|
|
75
|
+
async createPrimitiveArrayProperty(classKey, name, type) {
|
|
76
|
+
let mutableClass;
|
|
77
|
+
try {
|
|
78
|
+
mutableClass = await this.getClass(classKey, name);
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
return { errorMessage: e.message };
|
|
82
|
+
}
|
|
83
|
+
await mutableClass.createPrimitiveArrayProperty(name, type);
|
|
84
|
+
return { itemKey: classKey, propertyName: name };
|
|
85
|
+
}
|
|
86
|
+
async createPrimitiveArrayPropertyFromProps(classKey, name, type, primitiveProps) {
|
|
87
|
+
let mutableClass;
|
|
88
|
+
try {
|
|
89
|
+
mutableClass = await this.getClass(classKey, name);
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
return { errorMessage: e.message };
|
|
93
|
+
}
|
|
94
|
+
const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);
|
|
95
|
+
await newProperty.fromJSON(primitiveProps);
|
|
96
|
+
return { itemKey: classKey, propertyName: name };
|
|
97
|
+
}
|
|
98
|
+
async createStructProperty(classKey, name, type) {
|
|
99
|
+
let mutableClass;
|
|
100
|
+
try {
|
|
101
|
+
mutableClass = await this.getClass(classKey, name);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
return { errorMessage: e.message };
|
|
105
|
+
}
|
|
106
|
+
await mutableClass.createStructProperty(name, type);
|
|
107
|
+
return { itemKey: classKey, propertyName: name };
|
|
108
|
+
}
|
|
109
|
+
async createStructPropertyFromProps(classKey, name, type, structProps) {
|
|
110
|
+
let mutableClass;
|
|
111
|
+
try {
|
|
112
|
+
mutableClass = await this.getClass(classKey, name);
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
return { errorMessage: e.message };
|
|
116
|
+
}
|
|
117
|
+
const newProperty = await mutableClass.createStructProperty(name, type);
|
|
118
|
+
await newProperty.fromJSON(structProps);
|
|
119
|
+
return { itemKey: classKey, propertyName: name };
|
|
120
|
+
}
|
|
121
|
+
async createStructArrayProperty(classKey, name, type) {
|
|
122
|
+
let mutableClass;
|
|
123
|
+
try {
|
|
124
|
+
mutableClass = await this.getClass(classKey, name);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
return { errorMessage: e.message };
|
|
128
|
+
}
|
|
129
|
+
await mutableClass.createStructArrayProperty(name, type);
|
|
130
|
+
return { itemKey: classKey, propertyName: name };
|
|
131
|
+
}
|
|
132
|
+
async createStructArrayPropertyFromProps(classKey, name, type, structProps) {
|
|
133
|
+
let mutableClass;
|
|
134
|
+
try {
|
|
135
|
+
mutableClass = await this.getClass(classKey, name);
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
return { errorMessage: e.message };
|
|
139
|
+
}
|
|
140
|
+
const newProperty = await mutableClass.createStructArrayProperty(name, type);
|
|
141
|
+
await newProperty.fromJSON(structProps);
|
|
142
|
+
return { itemKey: classKey, propertyName: name };
|
|
143
|
+
}
|
|
144
|
+
async deleteProperty(classKey, name) {
|
|
145
|
+
let mutableClass;
|
|
146
|
+
try {
|
|
147
|
+
mutableClass = await this.getClass(classKey, name);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
return { errorMessage: e.message };
|
|
151
|
+
}
|
|
152
|
+
await mutableClass.deleteProperty(name);
|
|
153
|
+
return { itemKey: classKey, propertyName: name };
|
|
154
|
+
}
|
|
155
|
+
async delete(classKey) {
|
|
156
|
+
const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
|
|
157
|
+
if (schema === undefined)
|
|
158
|
+
return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };
|
|
159
|
+
const ecClass = await schema.getItem(classKey.name);
|
|
160
|
+
if (ecClass === undefined)
|
|
161
|
+
return {};
|
|
162
|
+
await schema.deleteClass(ecClass.name);
|
|
163
|
+
return { itemKey: classKey };
|
|
164
|
+
}
|
|
165
|
+
async getClass(classKey, name) {
|
|
166
|
+
const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
|
|
167
|
+
if (schema === undefined)
|
|
168
|
+
throw new Error(`Failed to create property ${name} because the schema ${classKey.schemaKey.toString(true)} could not be found`);
|
|
169
|
+
const ecClass = await schema.getItem(classKey.name);
|
|
170
|
+
if (ecClass === undefined)
|
|
171
|
+
throw new Error(`Failed to create property ${name} because the class ${classKey.name} was not found in ${classKey.schemaKey.toString(true)}`);
|
|
172
|
+
switch (ecClass.schemaItemType) {
|
|
173
|
+
case ecschema_metadata_1.SchemaItemType.EntityClass:
|
|
174
|
+
case ecschema_metadata_1.SchemaItemType.Mixin:
|
|
175
|
+
case ecschema_metadata_1.SchemaItemType.StructClass:
|
|
176
|
+
case ecschema_metadata_1.SchemaItemType.CustomAttributeClass:
|
|
177
|
+
case ecschema_metadata_1.SchemaItemType.RelationshipClass:
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
throw new Error(`Schema item type not supported`);
|
|
181
|
+
}
|
|
182
|
+
return ecClass;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.ECClasses = ECClasses;
|
|
186
|
+
//# sourceMappingURL=ECClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAA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AM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtE,IAAI,MAAM,KAAK,SAAS;YACtB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,uBAAuB,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAElI,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAU,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,OAAO,KAAK,SAAS;YACvB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,sBAAsB,QAAQ,CAAC,IAAI,qBAAqB,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEhJ,QAAQ,OAAO,CAAC,cAAc,EAAE;YAC9B,KAAK,kCAAc,CAAC,WAAW,CAAC;YAChC,KAAK,kCAAc,CAAC,KAAK,CAAC;YAC1B,KAAK,kCAAc,CAAC,WAAW,CAAC;YAChC,KAAK,kCAAc,CAAC,oBAAoB,CAAC;YACzC,KAAK,kCAAc,CAAC,iBAAiB;gBACnC,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;SACrD;QAED,OAAO,OAAuB,CAAC;IACjC,CAAC;CACF;AAvLD,8BAuLC","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 {\n ECClass, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses {\n protected constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined) throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n return { itemKey: classKey, propertyName: name };\n }\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey, name);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.deleteProperty(name);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n\n const ecClass = await schema.getItem<ECClass>(classKey.name);\n if (ecClass === undefined)\n return {};\n\n await schema.deleteClass(ecClass.name);\n\n return { itemKey: classKey };\n }\n\n private async getClass(classKey: SchemaItemKey, name: string): Promise<MutableClass> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n throw new Error(`Failed to create property ${name} because the schema ${classKey.schemaKey.toString(true)} could not be found`);\n\n const ecClass = await schema.getItem<ECClass>(classKey.name);\n if (ecClass === undefined)\n throw new Error(`Failed to create property ${name} because the class ${classKey.name} was not found in ${classKey.schemaKey.toString(true)}`);\n\n switch (ecClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n case SchemaItemType.CustomAttributeClass:\n case SchemaItemType.RelationshipClass:\n break;\n default:\n throw new Error(`Schema item type not supported`);\n }\n\n return ecClass as MutableClass;\n }\n}\n\n"]}
|