@itwin/ecschema-metadata 3.4.0-dev.9 → 3.5.0-dev.5

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.
Files changed (153) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/lib/cjs/Constants.d.ts +23 -23
  3. package/lib/cjs/Constants.js +33 -33
  4. package/lib/cjs/Constants.js.map +1 -1
  5. package/lib/cjs/Context.d.ts +139 -139
  6. package/lib/cjs/Context.js +204 -204
  7. package/lib/cjs/DelayedPromise.d.ts +88 -88
  8. package/lib/cjs/DelayedPromise.js +91 -91
  9. package/lib/cjs/DelayedPromise.js.map +1 -1
  10. package/lib/cjs/Deserialization/AbstractParser.d.ts +45 -45
  11. package/lib/cjs/Deserialization/AbstractParser.js +11 -11
  12. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  13. package/lib/cjs/Deserialization/Helper.d.ts +251 -251
  14. package/lib/cjs/Deserialization/Helper.js +843 -843
  15. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  16. package/lib/cjs/Deserialization/JsonParser.d.ts +165 -165
  17. package/lib/cjs/Deserialization/JsonParser.js +680 -680
  18. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  19. package/lib/cjs/Deserialization/JsonProps.d.ts +282 -282
  20. package/lib/cjs/Deserialization/JsonProps.js +9 -9
  21. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  22. package/lib/cjs/Deserialization/SchemaGraphUtil.d.ts +34 -34
  23. package/lib/cjs/Deserialization/SchemaGraphUtil.js +77 -77
  24. package/lib/cjs/Deserialization/SchemaGraphUtil.js.map +1 -1
  25. package/lib/cjs/Deserialization/XmlParser.d.ts +85 -85
  26. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  27. package/lib/cjs/Deserialization/XmlParser.js +973 -973
  28. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  29. package/lib/cjs/Deserialization/XmlSerializationUtils.d.ts +54 -54
  30. package/lib/cjs/Deserialization/XmlSerializationUtils.js +174 -174
  31. package/lib/cjs/Deserialization/XmlSerializationUtils.js.map +1 -1
  32. package/lib/cjs/ECName.d.ts +30 -30
  33. package/lib/cjs/ECName.js +85 -85
  34. package/lib/cjs/ECName.js.map +1 -1
  35. package/lib/cjs/ECObjects.d.ts +162 -162
  36. package/lib/cjs/ECObjects.js +453 -453
  37. package/lib/cjs/ECObjects.js.map +1 -1
  38. package/lib/cjs/Exception.d.ts +43 -43
  39. package/lib/cjs/Exception.js +86 -86
  40. package/lib/cjs/Exception.js.map +1 -1
  41. package/lib/cjs/Interfaces.d.ts +66 -66
  42. package/lib/cjs/Interfaces.js +9 -9
  43. package/lib/cjs/Interfaces.js.map +1 -1
  44. package/lib/cjs/Metadata/Class.d.ts +243 -243
  45. package/lib/cjs/Metadata/Class.js +558 -558
  46. package/lib/cjs/Metadata/Class.js.map +1 -1
  47. package/lib/cjs/Metadata/Constant.d.ts +64 -64
  48. package/lib/cjs/Metadata/Constant.js +123 -123
  49. package/lib/cjs/Metadata/Constant.js.map +1 -1
  50. package/lib/cjs/Metadata/CustomAttribute.d.ts +23 -23
  51. package/lib/cjs/Metadata/CustomAttribute.d.ts.map +1 -1
  52. package/lib/cjs/Metadata/CustomAttribute.js +27 -27
  53. package/lib/cjs/Metadata/CustomAttribute.js.map +1 -1
  54. package/lib/cjs/Metadata/CustomAttributeClass.d.ts +39 -39
  55. package/lib/cjs/Metadata/CustomAttributeClass.js +68 -68
  56. package/lib/cjs/Metadata/CustomAttributeClass.js.map +1 -1
  57. package/lib/cjs/Metadata/EntityClass.d.ts +77 -77
  58. package/lib/cjs/Metadata/EntityClass.js +230 -230
  59. package/lib/cjs/Metadata/EntityClass.js.map +1 -1
  60. package/lib/cjs/Metadata/Enumeration.d.ts +86 -86
  61. package/lib/cjs/Metadata/Enumeration.js +159 -159
  62. package/lib/cjs/Metadata/Enumeration.js.map +1 -1
  63. package/lib/cjs/Metadata/Format.d.ts +98 -98
  64. package/lib/cjs/Metadata/Format.d.ts.map +1 -1
  65. package/lib/cjs/Metadata/Format.js +242 -242
  66. package/lib/cjs/Metadata/Format.js.map +1 -1
  67. package/lib/cjs/Metadata/InvertedUnit.d.ts +49 -49
  68. package/lib/cjs/Metadata/InvertedUnit.js +97 -97
  69. package/lib/cjs/Metadata/InvertedUnit.js.map +1 -1
  70. package/lib/cjs/Metadata/KindOfQuantity.d.ts +65 -65
  71. package/lib/cjs/Metadata/KindOfQuantity.js +225 -225
  72. package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
  73. package/lib/cjs/Metadata/Mixin.d.ts +54 -54
  74. package/lib/cjs/Metadata/Mixin.js +113 -113
  75. package/lib/cjs/Metadata/Mixin.js.map +1 -1
  76. package/lib/cjs/Metadata/OverrideFormat.d.ts +55 -55
  77. package/lib/cjs/Metadata/OverrideFormat.js +88 -88
  78. package/lib/cjs/Metadata/OverrideFormat.js.map +1 -1
  79. package/lib/cjs/Metadata/Phenomenon.d.ts +33 -33
  80. package/lib/cjs/Metadata/Phenomenon.js +59 -59
  81. package/lib/cjs/Metadata/Phenomenon.js.map +1 -1
  82. package/lib/cjs/Metadata/Property.d.ts +197 -197
  83. package/lib/cjs/Metadata/Property.js +491 -491
  84. package/lib/cjs/Metadata/Property.js.map +1 -1
  85. package/lib/cjs/Metadata/PropertyCategory.d.ts +39 -39
  86. package/lib/cjs/Metadata/PropertyCategory.js +61 -61
  87. package/lib/cjs/Metadata/PropertyCategory.js.map +1 -1
  88. package/lib/cjs/Metadata/RelationshipClass.d.ts +152 -152
  89. package/lib/cjs/Metadata/RelationshipClass.js +349 -349
  90. package/lib/cjs/Metadata/RelationshipClass.js.map +1 -1
  91. package/lib/cjs/Metadata/Schema.d.ts +291 -291
  92. package/lib/cjs/Metadata/Schema.js +520 -520
  93. package/lib/cjs/Metadata/Schema.js.map +1 -1
  94. package/lib/cjs/Metadata/SchemaItem.d.ts +61 -61
  95. package/lib/cjs/Metadata/SchemaItem.js +136 -136
  96. package/lib/cjs/Metadata/SchemaItem.js.map +1 -1
  97. package/lib/cjs/Metadata/Unit.d.ts +76 -76
  98. package/lib/cjs/Metadata/Unit.js +162 -162
  99. package/lib/cjs/Metadata/UnitSystem.d.ts +20 -20
  100. package/lib/cjs/Metadata/UnitSystem.js +29 -29
  101. package/lib/cjs/Metadata/UnitSystem.js.map +1 -1
  102. package/lib/cjs/PropertyTypes.d.ts +49 -49
  103. package/lib/cjs/PropertyTypes.d.ts.map +1 -1
  104. package/lib/cjs/PropertyTypes.js +91 -75
  105. package/lib/cjs/PropertyTypes.js.map +1 -1
  106. package/lib/cjs/SchemaJsonLocater.d.ts +35 -0
  107. package/lib/cjs/SchemaJsonLocater.d.ts.map +1 -0
  108. package/lib/cjs/SchemaJsonLocater.js +43 -0
  109. package/lib/cjs/SchemaJsonLocater.js.map +1 -0
  110. package/lib/cjs/SchemaKey.d.ts +110 -110
  111. package/lib/cjs/SchemaKey.d.ts.map +1 -1
  112. package/lib/cjs/SchemaKey.js +219 -220
  113. package/lib/cjs/SchemaKey.js.map +1 -1
  114. package/lib/cjs/SchemaLoader.d.ts +24 -0
  115. package/lib/cjs/SchemaLoader.d.ts.map +1 -0
  116. package/lib/cjs/SchemaLoader.js +48 -0
  117. package/lib/cjs/SchemaLoader.js.map +1 -0
  118. package/lib/cjs/SchemaPartVisitorDelegate.d.ts +274 -274
  119. package/lib/cjs/SchemaPartVisitorDelegate.js +212 -212
  120. package/lib/cjs/SchemaPartVisitorDelegate.js.map +1 -1
  121. package/lib/cjs/UnitConversion/Graph.d.ts +34 -34
  122. package/lib/cjs/UnitConversion/Graph.js +83 -83
  123. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  124. package/lib/cjs/UnitConversion/Parser.d.ts +8 -8
  125. package/lib/cjs/UnitConversion/Parser.d.ts.map +1 -1
  126. package/lib/cjs/UnitConversion/Parser.js +42 -41
  127. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  128. package/lib/cjs/UnitConversion/UnitConversion.d.ts +45 -45
  129. package/lib/cjs/UnitConversion/UnitConversion.js +77 -77
  130. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  131. package/lib/cjs/UnitConversion/UnitConverter.d.ts +39 -39
  132. package/lib/cjs/UnitConversion/UnitConverter.d.ts.map +1 -1
  133. package/lib/cjs/UnitConversion/UnitConverter.js +116 -116
  134. package/lib/cjs/UnitConversion/UnitConverter.js.map +1 -1
  135. package/lib/cjs/UnitConversion/UnitTree.d.ts +43 -43
  136. package/lib/cjs/UnitConversion/UnitTree.d.ts.map +1 -1
  137. package/lib/cjs/UnitConversion/UnitTree.js +169 -169
  138. package/lib/cjs/UnitConversion/UnitTree.js.map +1 -1
  139. package/lib/cjs/UnitProvider/SchemaUnitProvider.d.ts +77 -77
  140. package/lib/cjs/UnitProvider/SchemaUnitProvider.js +236 -236
  141. package/lib/cjs/UnitProvider/SchemaUnitProvider.js.map +1 -1
  142. package/lib/cjs/Validation/SchemaWalker.d.ts +23 -23
  143. package/lib/cjs/Validation/SchemaWalker.js +53 -53
  144. package/lib/cjs/Validation/SchemaWalker.js.map +1 -1
  145. package/lib/cjs/ecschema-metadata.d.ts +51 -49
  146. package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
  147. package/lib/cjs/ecschema-metadata.js +96 -94
  148. package/lib/cjs/ecschema-metadata.js.map +1 -1
  149. package/lib/cjs/utils/SchemaGraph.d.ts +25 -25
  150. package/lib/cjs/utils/SchemaGraph.d.ts.map +1 -1
  151. package/lib/cjs/utils/SchemaGraph.js +65 -65
  152. package/lib/cjs/utils/SchemaGraph.js.map +1 -1
  153. package/package.json +8 -8
@@ -1,205 +1,205 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.SchemaContext = exports.SchemaCache = exports.SchemaMap = void 0;
8
- const ECObjects_1 = require("./ECObjects");
9
- const Exception_1 = require("./Exception");
10
- /**
11
- * @beta
12
- */
13
- class SchemaMap extends Array {
14
- }
15
- exports.SchemaMap = SchemaMap;
16
- /**
17
- * @beta
18
- */
19
- class SchemaCache {
20
- constructor() {
21
- this._schema = new SchemaMap();
22
- }
23
- get count() { return this._schema.length; }
24
- /**
25
- * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
26
- * @param schema The schema to add to the cache.
27
- */
28
- async addSchema(schema) {
29
- if (await this.getSchema(schema.schemaKey))
30
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
31
- this._schema.push(schema);
32
- }
33
- /**
34
- * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
35
- * @param schema The schema to add to the cache.
36
- */
37
- addSchemaSync(schema) {
38
- if (this.getSchemaSync(schema.schemaKey))
39
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
40
- this._schema.push(schema);
41
- }
42
- /**
43
- * Gets the schema which matches the provided SchemaKey.
44
- * @param schemaKey The SchemaKey describing the schema to get from the cache.
45
- * @param matchType The match type to use when locating the schema
46
- */
47
- async getSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
48
- if (this.count === 0)
49
- return undefined;
50
- const findFunc = (schema) => {
51
- return schema.schemaKey.matches(schemaKey, matchType);
52
- };
53
- const foundSchema = this._schema.find(findFunc);
54
- if (!foundSchema)
55
- return undefined;
56
- return foundSchema;
57
- }
58
- /**
59
- *
60
- * @param schemaKey
61
- * @param matchType
62
- */
63
- getSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
64
- if (this.count === 0)
65
- return undefined;
66
- const findFunc = (schema) => {
67
- return schema.schemaKey.matches(schemaKey, matchType);
68
- };
69
- const foundSchema = this._schema.find(findFunc);
70
- if (!foundSchema)
71
- return foundSchema;
72
- return foundSchema;
73
- }
74
- /**
75
- * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema
76
- */
77
- *getSchemaItems() {
78
- for (const schema of this._schema) {
79
- for (const schemaItem of schema.getItems()) {
80
- yield schemaItem;
81
- }
82
- }
83
- }
84
- /**
85
- * Gets all the schemas from the schema cache.
86
- * @returns An array of Schema objects.
87
- */
88
- getAllSchemas() {
89
- return this._schema;
90
- }
91
- }
92
- exports.SchemaCache = SchemaCache;
93
- /**
94
- * The SchemaContext, context object is used to facilitate schema and schema item location.
95
- *
96
- * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.
97
- *
98
- * The context is made up of a group of Schema Locators.
99
- * @beta
100
- */
101
- class SchemaContext {
102
- constructor() {
103
- this._locaters = [];
104
- this._knownSchemas = new SchemaCache();
105
- this._locaters.push(this._knownSchemas);
106
- }
107
- addLocater(locater) {
108
- this._locaters.push(locater);
109
- }
110
- /**
111
- * Adds the schema to this context
112
- * @param schema The schema to add to this context
113
- */
114
- async addSchema(schema) {
115
- this.addSchemaSync(schema);
116
- }
117
- /**
118
- * Adds the schema to this context
119
- * @param schema The schema to add to this context
120
- */
121
- addSchemaSync(schema) {
122
- this._knownSchemas.addSchemaSync(schema);
123
- }
124
- /**
125
- * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and
126
- * @param schemaItem The SchemaItem to add
127
- */
128
- async addSchemaItem(schemaItem) {
129
- const schema = await this.getSchema(schemaItem.key.schemaKey, ECObjects_1.SchemaMatchType.Exact);
130
- if (!schema)
131
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);
132
- schema.addItem(schemaItem);
133
- }
134
- /**
135
- *
136
- * @param schemaKey
137
- */
138
- async getSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
139
- // the first locater is _knownSchemas, so we don't have to check the cache explicitly here
140
- for (const locater of this._locaters) {
141
- const schema = await locater.getSchema(schemaKey, matchType, this);
142
- if (undefined !== schema)
143
- return schema;
144
- }
145
- return undefined;
146
- }
147
- /**
148
- *
149
- * @param schemaKey
150
- */
151
- getSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
152
- // the first locater is _knownSchemas, so we don't have to check the cache explicitly here
153
- for (const locater of this._locaters) {
154
- const schema = locater.getSchemaSync(schemaKey, matchType, this);
155
- if (undefined !== schema)
156
- return schema;
157
- }
158
- return undefined;
159
- }
160
- /**
161
- * Attempts to get a Schema from the context's cache.
162
- * @param schemaKey The SchemaKey to identify the Schema.
163
- * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
164
- * @internal
165
- */
166
- async getCachedSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
167
- return this.getCachedSchemaSync(schemaKey, matchType);
168
- }
169
- /**
170
- * Attempts to get a Schema from the context's cache.
171
- * @param schemaKey The SchemaKey to identify the Schema.
172
- * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
173
- * @internal
174
- */
175
- getCachedSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
176
- const schema = this._knownSchemas.getSchemaSync(schemaKey, matchType);
177
- return schema;
178
- }
179
- async getSchemaItem(schemaItemKey) {
180
- const schema = await this.getSchema(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
181
- if (undefined === schema)
182
- return undefined;
183
- return schema.getItem(schemaItemKey.name);
184
- }
185
- getSchemaItemSync(schemaItemKey) {
186
- const schema = this.getSchemaSync(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
187
- if (undefined === schema)
188
- return undefined;
189
- return schema.getItemSync(schemaItemKey.name);
190
- }
191
- getSchemaItems() {
192
- return this._knownSchemas.getSchemaItems();
193
- }
194
- /**
195
- * Gets all the Schemas known by the context. This includes schemas added to the
196
- * context using [[SchemaContext.addSchema]]. This does not include schemas that
197
- * can be located by an ISchemaLocater instance added to the context.
198
- * @returns An array of Schema objects.
199
- */
200
- getKnownSchemas() {
201
- return this._knownSchemas.getAllSchemas();
202
- }
203
- }
204
- exports.SchemaContext = SchemaContext;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SchemaContext = exports.SchemaCache = exports.SchemaMap = void 0;
8
+ const ECObjects_1 = require("./ECObjects");
9
+ const Exception_1 = require("./Exception");
10
+ /**
11
+ * @beta
12
+ */
13
+ class SchemaMap extends Array {
14
+ }
15
+ exports.SchemaMap = SchemaMap;
16
+ /**
17
+ * @beta
18
+ */
19
+ class SchemaCache {
20
+ constructor() {
21
+ this._schema = new SchemaMap();
22
+ }
23
+ get count() { return this._schema.length; }
24
+ /**
25
+ * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
26
+ * @param schema The schema to add to the cache.
27
+ */
28
+ async addSchema(schema) {
29
+ if (await this.getSchema(schema.schemaKey))
30
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
31
+ this._schema.push(schema);
32
+ }
33
+ /**
34
+ * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
35
+ * @param schema The schema to add to the cache.
36
+ */
37
+ addSchemaSync(schema) {
38
+ if (this.getSchemaSync(schema.schemaKey))
39
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
40
+ this._schema.push(schema);
41
+ }
42
+ /**
43
+ * Gets the schema which matches the provided SchemaKey.
44
+ * @param schemaKey The SchemaKey describing the schema to get from the cache.
45
+ * @param matchType The match type to use when locating the schema
46
+ */
47
+ async getSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
48
+ if (this.count === 0)
49
+ return undefined;
50
+ const findFunc = (schema) => {
51
+ return schema.schemaKey.matches(schemaKey, matchType);
52
+ };
53
+ const foundSchema = this._schema.find(findFunc);
54
+ if (!foundSchema)
55
+ return undefined;
56
+ return foundSchema;
57
+ }
58
+ /**
59
+ *
60
+ * @param schemaKey
61
+ * @param matchType
62
+ */
63
+ getSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
64
+ if (this.count === 0)
65
+ return undefined;
66
+ const findFunc = (schema) => {
67
+ return schema.schemaKey.matches(schemaKey, matchType);
68
+ };
69
+ const foundSchema = this._schema.find(findFunc);
70
+ if (!foundSchema)
71
+ return foundSchema;
72
+ return foundSchema;
73
+ }
74
+ /**
75
+ * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema
76
+ */
77
+ *getSchemaItems() {
78
+ for (const schema of this._schema) {
79
+ for (const schemaItem of schema.getItems()) {
80
+ yield schemaItem;
81
+ }
82
+ }
83
+ }
84
+ /**
85
+ * Gets all the schemas from the schema cache.
86
+ * @returns An array of Schema objects.
87
+ */
88
+ getAllSchemas() {
89
+ return this._schema;
90
+ }
91
+ }
92
+ exports.SchemaCache = SchemaCache;
93
+ /**
94
+ * The SchemaContext, context object is used to facilitate schema and schema item location.
95
+ *
96
+ * The context controls the lifetime of each schema that it knows about. It has to be explicitly removed from the context to delete a schema object.
97
+ *
98
+ * The context is made up of a group of Schema Locators.
99
+ * @beta
100
+ */
101
+ class SchemaContext {
102
+ constructor() {
103
+ this._locaters = [];
104
+ this._knownSchemas = new SchemaCache();
105
+ this._locaters.push(this._knownSchemas);
106
+ }
107
+ addLocater(locater) {
108
+ this._locaters.push(locater);
109
+ }
110
+ /**
111
+ * Adds the schema to this context
112
+ * @param schema The schema to add to this context
113
+ */
114
+ async addSchema(schema) {
115
+ this.addSchemaSync(schema);
116
+ }
117
+ /**
118
+ * Adds the schema to this context
119
+ * @param schema The schema to add to this context
120
+ */
121
+ addSchemaSync(schema) {
122
+ this._knownSchemas.addSchemaSync(schema);
123
+ }
124
+ /**
125
+ * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and
126
+ * @param schemaItem The SchemaItem to add
127
+ */
128
+ async addSchemaItem(schemaItem) {
129
+ const schema = await this.getSchema(schemaItem.key.schemaKey, ECObjects_1.SchemaMatchType.Exact);
130
+ if (!schema)
131
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);
132
+ schema.addItem(schemaItem);
133
+ }
134
+ /**
135
+ *
136
+ * @param schemaKey
137
+ */
138
+ async getSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
139
+ // the first locater is _knownSchemas, so we don't have to check the cache explicitly here
140
+ for (const locater of this._locaters) {
141
+ const schema = await locater.getSchema(schemaKey, matchType, this);
142
+ if (undefined !== schema)
143
+ return schema;
144
+ }
145
+ return undefined;
146
+ }
147
+ /**
148
+ *
149
+ * @param schemaKey
150
+ */
151
+ getSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
152
+ // the first locater is _knownSchemas, so we don't have to check the cache explicitly here
153
+ for (const locater of this._locaters) {
154
+ const schema = locater.getSchemaSync(schemaKey, matchType, this);
155
+ if (undefined !== schema)
156
+ return schema;
157
+ }
158
+ return undefined;
159
+ }
160
+ /**
161
+ * Attempts to get a Schema from the context's cache.
162
+ * @param schemaKey The SchemaKey to identify the Schema.
163
+ * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
164
+ * @internal
165
+ */
166
+ async getCachedSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
167
+ return this.getCachedSchemaSync(schemaKey, matchType);
168
+ }
169
+ /**
170
+ * Attempts to get a Schema from the context's cache.
171
+ * @param schemaKey The SchemaKey to identify the Schema.
172
+ * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
173
+ * @internal
174
+ */
175
+ getCachedSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
176
+ const schema = this._knownSchemas.getSchemaSync(schemaKey, matchType);
177
+ return schema;
178
+ }
179
+ async getSchemaItem(schemaItemKey) {
180
+ const schema = await this.getSchema(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
181
+ if (undefined === schema)
182
+ return undefined;
183
+ return schema.getItem(schemaItemKey.name);
184
+ }
185
+ getSchemaItemSync(schemaItemKey) {
186
+ const schema = this.getSchemaSync(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
187
+ if (undefined === schema)
188
+ return undefined;
189
+ return schema.getItemSync(schemaItemKey.name);
190
+ }
191
+ getSchemaItems() {
192
+ return this._knownSchemas.getSchemaItems();
193
+ }
194
+ /**
195
+ * Gets all the Schemas known by the context. This includes schemas added to the
196
+ * context using [[SchemaContext.addSchema]]. This does not include schemas that
197
+ * can be located by an ISchemaLocater instance added to the context.
198
+ * @returns An array of Schema objects.
199
+ */
200
+ getKnownSchemas() {
201
+ return this._knownSchemas.getAllSchemas();
202
+ }
203
+ }
204
+ exports.SchemaContext = SchemaContext;
205
205
  //# sourceMappingURL=Context.js.map
@@ -1,89 +1,89 @@
1
- /** @packageDocumentation
2
- * @module Utils
3
- */
4
- /**
5
- * Similar to a normal Promise, a DelayedPromise represents the eventual completion (or failure)
6
- * and resulting value of an asynchronous operation ***that has not yet started***.
7
- *
8
- * The asynchronous operation behind a DelayedPromise will start when any of the following occurs:
9
- * - The DelayedPromise is `await`ed.
10
- * - A callback is attached via `.then()` or `.catch(() => { })`.
11
- * - The asynchronous operation is explicitly started via `.start()`
12
- *
13
- * Just as normal Promises will never return to their pending state once fulfilled or rejected,
14
- * a DelayedPromise will never re-execute its asynchronous operation more than **once**.
15
- *
16
- * Ultimately, a DelayedPromise is nothing more than some syntactic sugar that allows you to
17
- * represent an (asynchronously) lazily-loaded value as an instance property instead of a method.
18
- * You could also accomplish something similar by defining an async function as a property getter.
19
- * However, since a property defined as a DelayedPromise will not start simply by being accessed,
20
- * additional (non-lazily-loaded) "nested" properties can be added.
21
- *
22
- * [!alert text="*Remember:* Unlike regular Promises in JavaScript, DelayedPromises represent processes that **may not** already be happening." kind="warning"]
23
- * @beta
24
- */
25
- export declare class DelayedPromise<T> implements Promise<T> {
26
- /**
27
- * Constructs a DelayedPromise object.
28
- * @param startCallback The asynchronous callback to execute when this DelayedPromise should be "started".
29
- */
30
- constructor(startCallback: () => Promise<T>);
31
- readonly [Symbol.toStringTag]: "Promise";
32
- /**
33
- * Explicitly starts the asynchronous operation behind this DelayedPromise (if it hasn't started already).
34
- */
35
- start: () => Promise<T>;
36
- /**
37
- * Attaches callbacks for the resolution and/or rejection of the Promise.
38
- * @param onfulfilled The callback to execute when the Promise is resolved.
39
- * @param onrejected The callback to execute when the Promise is rejected.
40
- * @return A Promise for the completion of which ever callback is executed.
41
- */
42
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
43
- /**
44
- * Attaches a callback for only the rejection of the Promise.
45
- * @param onrejected The callback to execute when the Promise is rejected.
46
- * @return A Promise for the completion of the callback.
47
- */
48
- catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
49
- /**
50
- * Attaches a callback for only the finally clause of the Promise.
51
- * @param onrejected The callback to execute when the Promise is finalized.
52
- * @return A Promise for the completion of the callback.
53
- */
54
- finally(onFinally?: (() => void) | undefined | null): Promise<T>;
55
- }
56
- /**
57
- * @beta
58
- */
59
- export interface NoDelayedPromiseMethods {
60
- [propName: string]: any;
61
- start?: never;
62
- then?: never;
63
- catch?: never;
64
- }
65
- /**
66
- * @beta
67
- */
68
- export interface DelayedPromiseWithPropsConstructor {
69
- /**
70
- * Constructs a DelayedPromiseWithProps object, which is at once both:
71
- * - A DelayedPromise object representing the eventual completion (or failure)
72
- * of an asynchronous operation returning a value of type `TPayload`
73
- * - _and_ a readonly "wrapper" around an instance of type `TProps`
74
- *
75
- * @param props An object with properties and methods that will be accessible
76
- * as if they were readonly properties of the DelayedPromiseWithProps object being constructed.
77
- * @param startCallback The asynchronous callback to execute when as soon as this DelayedPromise should be "started".
78
- */
79
- new <TProps extends NoDelayedPromiseMethods, TPayload>(props: TProps, startCallback: () => Promise<TPayload>): Readonly<TProps> & DelayedPromise<TPayload>;
80
- }
81
- /**
82
- * @beta
83
- */
84
- export declare const DelayedPromiseWithProps: DelayedPromiseWithPropsConstructor;
85
- /** Define the type of a DelayedPromiseWithProps instance
86
- * @beta
87
- */
88
- export declare type DelayedPromiseWithProps<TProps, TPayload> = Readonly<TProps> & DelayedPromise<TPayload>;
1
+ /** @packageDocumentation
2
+ * @module Utils
3
+ */
4
+ /**
5
+ * Similar to a normal Promise, a DelayedPromise represents the eventual completion (or failure)
6
+ * and resulting value of an asynchronous operation ***that has not yet started***.
7
+ *
8
+ * The asynchronous operation behind a DelayedPromise will start when any of the following occurs:
9
+ * - The DelayedPromise is `await`ed.
10
+ * - A callback is attached via `.then()` or `.catch(() => { })`.
11
+ * - The asynchronous operation is explicitly started via `.start()`
12
+ *
13
+ * Just as normal Promises will never return to their pending state once fulfilled or rejected,
14
+ * a DelayedPromise will never re-execute its asynchronous operation more than **once**.
15
+ *
16
+ * Ultimately, a DelayedPromise is nothing more than some syntactic sugar that allows you to
17
+ * represent an (asynchronously) lazily-loaded value as an instance property instead of a method.
18
+ * You could also accomplish something similar by defining an async function as a property getter.
19
+ * However, since a property defined as a DelayedPromise will not start simply by being accessed,
20
+ * additional (non-lazily-loaded) "nested" properties can be added.
21
+ *
22
+ * [!alert text="*Remember:* Unlike regular Promises in JavaScript, DelayedPromises represent processes that **may not** already be happening." kind="warning"]
23
+ * @beta
24
+ */
25
+ export declare class DelayedPromise<T> implements Promise<T> {
26
+ /**
27
+ * Constructs a DelayedPromise object.
28
+ * @param startCallback The asynchronous callback to execute when this DelayedPromise should be "started".
29
+ */
30
+ constructor(startCallback: () => Promise<T>);
31
+ readonly [Symbol.toStringTag]: "Promise";
32
+ /**
33
+ * Explicitly starts the asynchronous operation behind this DelayedPromise (if it hasn't started already).
34
+ */
35
+ start: () => Promise<T>;
36
+ /**
37
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
38
+ * @param onfulfilled The callback to execute when the Promise is resolved.
39
+ * @param onrejected The callback to execute when the Promise is rejected.
40
+ * @return A Promise for the completion of which ever callback is executed.
41
+ */
42
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
43
+ /**
44
+ * Attaches a callback for only the rejection of the Promise.
45
+ * @param onrejected The callback to execute when the Promise is rejected.
46
+ * @return A Promise for the completion of the callback.
47
+ */
48
+ catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
49
+ /**
50
+ * Attaches a callback for only the finally clause of the Promise.
51
+ * @param onrejected The callback to execute when the Promise is finalized.
52
+ * @return A Promise for the completion of the callback.
53
+ */
54
+ finally(onFinally?: (() => void) | undefined | null): Promise<T>;
55
+ }
56
+ /**
57
+ * @beta
58
+ */
59
+ export interface NoDelayedPromiseMethods {
60
+ [propName: string]: any;
61
+ start?: never;
62
+ then?: never;
63
+ catch?: never;
64
+ }
65
+ /**
66
+ * @beta
67
+ */
68
+ export interface DelayedPromiseWithPropsConstructor {
69
+ /**
70
+ * Constructs a DelayedPromiseWithProps object, which is at once both:
71
+ * - A DelayedPromise object representing the eventual completion (or failure)
72
+ * of an asynchronous operation returning a value of type `TPayload`
73
+ * - _and_ a readonly "wrapper" around an instance of type `TProps`
74
+ *
75
+ * @param props An object with properties and methods that will be accessible
76
+ * as if they were readonly properties of the DelayedPromiseWithProps object being constructed.
77
+ * @param startCallback The asynchronous callback to execute when as soon as this DelayedPromise should be "started".
78
+ */
79
+ new <TProps extends NoDelayedPromiseMethods, TPayload>(props: TProps, startCallback: () => Promise<TPayload>): Readonly<TProps> & DelayedPromise<TPayload>;
80
+ }
81
+ /**
82
+ * @beta
83
+ */
84
+ export declare const DelayedPromiseWithProps: DelayedPromiseWithPropsConstructor;
85
+ /** Define the type of a DelayedPromiseWithProps instance
86
+ * @beta
87
+ */
88
+ export declare type DelayedPromiseWithProps<TProps, TPayload> = Readonly<TProps> & DelayedPromise<TPayload>;
89
89
  //# sourceMappingURL=DelayedPromise.d.ts.map