@itwin/ecschema-metadata 3.3.0-dev.9 → 3.4.0-dev.0

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 (32) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/lib/cjs/Context.d.ts +12 -0
  3. package/lib/cjs/Context.d.ts.map +1 -1
  4. package/lib/cjs/Context.js +16 -0
  5. package/lib/cjs/Context.js.map +1 -1
  6. package/lib/cjs/Deserialization/AbstractParser.d.ts +1 -1
  7. package/lib/cjs/Deserialization/AbstractParser.d.ts.map +1 -1
  8. package/lib/cjs/Deserialization/AbstractParser.js.map +1 -1
  9. package/lib/cjs/Deserialization/Helper.js +2 -2
  10. package/lib/cjs/Deserialization/Helper.js.map +1 -1
  11. package/lib/cjs/Deserialization/JsonParser.d.ts +1 -1
  12. package/lib/cjs/Deserialization/JsonParser.d.ts.map +1 -1
  13. package/lib/cjs/Deserialization/JsonParser.js +8 -8
  14. package/lib/cjs/Deserialization/JsonParser.js.map +1 -1
  15. package/lib/cjs/Deserialization/JsonProps.d.ts +1 -1
  16. package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
  17. package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
  18. package/lib/cjs/Deserialization/XmlParser.d.ts +1 -1
  19. package/lib/cjs/Deserialization/XmlParser.d.ts.map +1 -1
  20. package/lib/cjs/Deserialization/XmlParser.js +3 -3
  21. package/lib/cjs/Deserialization/XmlParser.js.map +1 -1
  22. package/lib/cjs/Metadata/Constant.d.ts +4 -2
  23. package/lib/cjs/Metadata/Constant.d.ts.map +1 -1
  24. package/lib/cjs/Metadata/Constant.js +9 -8
  25. package/lib/cjs/Metadata/Constant.js.map +1 -1
  26. package/lib/cjs/Metadata/Schema.js +1 -1
  27. package/lib/cjs/Metadata/Schema.js.map +1 -1
  28. package/lib/cjs/Metadata/Unit.d.ts +6 -3
  29. package/lib/cjs/Metadata/Unit.d.ts.map +1 -1
  30. package/lib/cjs/Metadata/Unit.js +15 -12
  31. package/lib/cjs/Metadata/Unit.js.map +1 -1
  32. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,6 +1,31 @@
1
1
  # Change Log - @itwin/ecschema-metadata
2
2
 
3
- This log was last generated on Fri, 20 May 2022 13:10:54 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 13 Jul 2022 15:45:52 GMT and should not be manually modified.
4
+
5
+ ## 3.2.5
6
+ Wed, 13 Jul 2022 15:45:52 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.2.4
11
+ Tue, 21 Jun 2022 18:06:33 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 3.2.3
16
+ Fri, 17 Jun 2022 15:18:39 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 3.2.2
21
+ Fri, 10 Jun 2022 16:11:36 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 3.2.1
26
+ Tue, 07 Jun 2022 15:02:56 GMT
27
+
28
+ _Version update only_
4
29
 
5
30
  ## 3.2.0
6
31
  Fri, 20 May 2022 13:10:54 GMT
@@ -68,6 +68,11 @@ export declare class SchemaCache implements ISchemaLocater {
68
68
  * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema
69
69
  */
70
70
  getSchemaItems(): IterableIterator<SchemaItem>;
71
+ /**
72
+ * Gets all the schemas from the schema cache.
73
+ * @returns An array of Schema objects.
74
+ */
75
+ getAllSchemas(): Schema[];
71
76
  }
72
77
  /**
73
78
  * The SchemaContext, context object is used to facilitate schema and schema item location.
@@ -124,5 +129,12 @@ export declare class SchemaContext implements ISchemaLocater, ISchemaItemLocater
124
129
  getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined>;
125
130
  getSchemaItemSync<T extends SchemaItem>(schemaItemKey: SchemaItemKey): T | undefined;
126
131
  getSchemaItems(): IterableIterator<SchemaItem>;
132
+ /**
133
+ * Gets all the Schemas known by the context. This includes schemas added to the
134
+ * context using [[SchemaContext.addSchema]]. This does not include schemas that
135
+ * can be located by an ISchemaLocater instance added to the context.
136
+ * @returns An array of Schema objects.
137
+ */
138
+ getKnownSchemas(): Schema[];
127
139
  }
128
140
  //# sourceMappingURL=Context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAiB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK,CAAC,MAAM,CAAC;CAAI;AAEhD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAE7B;;;;;;OAMG;IACH,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAE/H;;;;;;OAMG;IACH,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS,CAAC;CAC3H;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,CAAC,SAAS,UAAU,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CAC3F;AAED;;GAEG;AACH,qBAAa,WAAY,YAAW,cAAc;IAChD,OAAO,CAAC,OAAO,CAAY;;IAM3B,IAAW,KAAK,WAAkC;IAElD;;;OAGG;IACU,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC;IAOlD;;;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,eAAwC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIjJ;;;;;OAKG;IACI,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAE,eAAwC,GAAG,MAAM,GAAG,SAAS;IAK9H,aAAa,CAAC,CAAC,SAAS,UAAU,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAO/F,iBAAiB,CAAC,CAAC,SAAS,UAAU,EAAE,aAAa,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS;IAOpF,cAAc,IAAI,gBAAgB,CAAC,UAAU,CAAC;IAIrD;;;;;OAKG;IACI,eAAe,IAAI,MAAM,EAAG;CAGpC"}
@@ -81,6 +81,13 @@ class SchemaCache {
81
81
  }
82
82
  }
83
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
+ }
84
91
  }
85
92
  exports.SchemaCache = SchemaCache;
86
93
  /**
@@ -184,6 +191,15 @@ class SchemaContext {
184
191
  getSchemaItems() {
185
192
  return this._knownSchemas.getSchemaItems();
186
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
+ }
187
203
  }
188
204
  exports.SchemaContext = SchemaContext;
189
205
  //# sourceMappingURL=Context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2CAA8C;AAC9C,2CAA8D;AAK9D;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAa;CAAI;AAAhD,8BAAgD;AAkChD;;GAEG;AACH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AAC;IAED;;;;;OAKG;IACI,mBAAmB,CAAmB,SAAoB,EAAE,YAA6B,2BAAe,CAAC,MAAM;QACpH,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACtE,OAAO,MAAW,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAuB,aAA4B;QAC3E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACrF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,OAAO,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEM,iBAAiB,CAAuB,aAA4B;QACzE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACnF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,WAAW,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;CACF;AAhHD,sCAgHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class SchemaMap extends Array<Schema> { }\r\n\r\n/**\r\n * The interface defines what is needed to be a ISchemaLocater, which are used in a SchemaContext.\r\n * @beta\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context optional context for loading schema references\r\n */\r\n getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context?: SchemaContext): Promise<T | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context optional context for loading schema references\r\n */\r\n getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context?: SchemaContext): T | undefined;\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface ISchemaItemLocater {\r\n getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined>;\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema<T extends Schema>(schema: T) {\r\n if (await this.getSchema<T>(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push(schema);\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync<T extends Schema>(schema: T) {\r\n if (this.getSchemaSync<T>(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push(schema);\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return undefined;\r\n\r\n return foundSchema as T;\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n * @param matchType\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return foundSchema;\r\n\r\n return foundSchema as T;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema\r\n */\r\n public* getSchemaItems(): IterableIterator<SchemaItem> {\r\n for (const schema of this._schema) {\r\n for (const schemaItem of schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * 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.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @beta\r\n */\r\nexport class SchemaContext implements ISchemaLocater, ISchemaItemLocater {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n }\r\n\r\n public addLocater(locater: ISchemaLocater) {\r\n this._locaters.push(locater);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n return this.getCachedSchemaSync(schemaKey, matchType) as T;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n const schema = this._knownSchemas.getSchemaSync(schemaKey, matchType);\r\n return schema as T;\r\n }\r\n\r\n public async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined> {\r\n const schema = await this.getSchema(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItem<T>(schemaItemKey.name);\r\n }\r\n\r\n public getSchemaItemSync<T extends SchemaItem>(schemaItemKey: SchemaItemKey): T | undefined {\r\n const schema = this.getSchemaSync(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItemSync<T>(schemaItemKey.name);\r\n }\r\n\r\n public getSchemaItems(): IterableIterator<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/Context.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2CAA8C;AAC9C,2CAA8D;AAK9D;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAa;CAAI;AAAh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A6B,2BAAe,CAAC,MAAM;QACtH,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAM,CAAC;IAC7D,CAAC;IAED;;;;;OAKG;IACI,mBAAmB,CAAmB,SAAoB,EAAE,YAA6B,2BAAe,CAAC,MAAM;QACpH,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACtE,OAAO,MAAW,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAuB,aAA4B;QAC3E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACrF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,OAAO,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEM,iBAAiB,CAAuB,aAA4B;QACzE,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,SAAS,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACnF,IAAI,SAAS,KAAK,MAAM;YACtB,OAAO,SAAS,CAAC;QACnB,OAAO,MAAM,CAAC,WAAW,CAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACI,eAAe;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;CACF;AA1HD,sCA0HC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { MutableSchema, Schema } from \"./Metadata/Schema\";\r\nimport { SchemaItem } from \"./Metadata/SchemaItem\";\r\nimport { SchemaItemKey, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class SchemaMap extends Array<Schema> { }\r\n\r\n/**\r\n * The interface defines what is needed to be a ISchemaLocater, which are used in a SchemaContext.\r\n * @beta\r\n */\r\nexport interface ISchemaLocater {\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context optional context for loading schema references\r\n */\r\n getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context?: SchemaContext): Promise<T | undefined>;\r\n\r\n /**\r\n * Attempts to get a schema from the locater. Yields undefined if no matching schema is found.\r\n * For schemas that may have references, construct and call through a SchemaContext instead.\r\n * @param schemaKey key to look up\r\n * @param matchType how to match key against candidate schemas\r\n * @param context optional context for loading schema references\r\n */\r\n getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context?: SchemaContext): T | undefined;\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport interface ISchemaItemLocater {\r\n getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined>;\r\n}\r\n\r\n/**\r\n * @beta\r\n */\r\nexport class SchemaCache implements ISchemaLocater {\r\n private _schema: SchemaMap;\r\n\r\n constructor() {\r\n this._schema = new SchemaMap();\r\n }\r\n\r\n public get count() { return this._schema.length; }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public async addSchema<T extends Schema>(schema: T) {\r\n if (await this.getSchema<T>(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push(schema);\r\n }\r\n\r\n /**\r\n * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.\r\n * @param schema The schema to add to the cache.\r\n */\r\n public addSchemaSync<T extends Schema>(schema: T) {\r\n if (this.getSchemaSync<T>(schema.schemaKey))\r\n throw new ECObjectsError(ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);\r\n\r\n this._schema.push(schema);\r\n }\r\n\r\n /**\r\n * Gets the schema which matches the provided SchemaKey.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return undefined;\r\n\r\n return foundSchema as T;\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n * @param matchType\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n if (this.count === 0)\r\n return undefined;\r\n\r\n const findFunc = (schema: Schema) => {\r\n return schema.schemaKey.matches(schemaKey, matchType);\r\n };\r\n\r\n const foundSchema = this._schema.find(findFunc);\r\n\r\n if (!foundSchema)\r\n return foundSchema;\r\n\r\n return foundSchema as T;\r\n }\r\n\r\n /**\r\n * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema\r\n */\r\n public* getSchemaItems(): IterableIterator<SchemaItem> {\r\n for (const schema of this._schema) {\r\n for (const schemaItem of schema.getItems()) {\r\n yield schemaItem;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets all the schemas from the schema cache.\r\n * @returns An array of Schema objects.\r\n */\r\n public getAllSchemas(): Schema [] {\r\n return this._schema;\r\n }\r\n}\r\n\r\n/**\r\n * The SchemaContext, context object is used to facilitate schema and schema item location.\r\n *\r\n * 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.\r\n *\r\n * The context is made up of a group of Schema Locators.\r\n * @beta\r\n */\r\nexport class SchemaContext implements ISchemaLocater, ISchemaItemLocater {\r\n private _locaters: ISchemaLocater[];\r\n\r\n private _knownSchemas: SchemaCache;\r\n\r\n constructor() {\r\n this._locaters = [];\r\n\r\n this._knownSchemas = new SchemaCache();\r\n this._locaters.push(this._knownSchemas);\r\n }\r\n\r\n public addLocater(locater: ISchemaLocater) {\r\n this._locaters.push(locater);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public async addSchema(schema: Schema) {\r\n this.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the schema to this context\r\n * @param schema The schema to add to this context\r\n */\r\n public addSchemaSync(schema: Schema) {\r\n this._knownSchemas.addSchemaSync(schema);\r\n }\r\n\r\n /**\r\n * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and\r\n * @param schemaItem The SchemaItem to add\r\n */\r\n public async addSchemaItem(schemaItem: SchemaItem) {\r\n const schema = await this.getSchema(schemaItem.key.schemaKey, SchemaMatchType.Exact);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);\r\n\r\n (schema as MutableSchema).addItem(schemaItem);\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = await locater.getSchema<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n *\r\n * @param schemaKey\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): T | undefined {\r\n // the first locater is _knownSchemas, so we don't have to check the cache explicitly here\r\n for (const locater of this._locaters) {\r\n const schema = locater.getSchemaSync<T>(schemaKey, matchType, this);\r\n if (undefined !== schema)\r\n return schema;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public async getCachedSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Promise<T | undefined> {\r\n return this.getCachedSchemaSync(schemaKey, matchType) as T;\r\n }\r\n\r\n /**\r\n * Attempts to get a Schema from the context's cache.\r\n * @param schemaKey The SchemaKey to identify the Schema.\r\n * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.\r\n * @internal\r\n */\r\n public getCachedSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType = SchemaMatchType.Latest): Schema | undefined {\r\n const schema = this._knownSchemas.getSchemaSync(schemaKey, matchType);\r\n return schema as T;\r\n }\r\n\r\n public async getSchemaItem<T extends SchemaItem>(schemaItemKey: SchemaItemKey): Promise<T | undefined> {\r\n const schema = await this.getSchema(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItem<T>(schemaItemKey.name);\r\n }\r\n\r\n public getSchemaItemSync<T extends SchemaItem>(schemaItemKey: SchemaItemKey): T | undefined {\r\n const schema = this.getSchemaSync(schemaItemKey.schemaKey, SchemaMatchType.Latest);\r\n if (undefined === schema)\r\n return undefined;\r\n return schema.getItemSync<T>(schemaItemKey.name);\r\n }\r\n\r\n public getSchemaItems(): IterableIterator<SchemaItem> {\r\n return this._knownSchemas.getSchemaItems();\r\n }\r\n\r\n /**\r\n * Gets all the Schemas known by the context. This includes schemas added to the\r\n * context using [[SchemaContext.addSchema]]. This does not include schemas that\r\n * can be located by an ISchemaLocater instance added to the context.\r\n * @returns An array of Schema objects.\r\n */\r\n public getKnownSchemas(): Schema [] {\r\n return this._knownSchemas.getAllSchemas();\r\n }\r\n}\r\n"]}
@@ -27,7 +27,7 @@ export declare abstract class AbstractParser<TItem = any, TProperty = TItem> {
27
27
  abstract parsePhenomenon(data: Readonly<TItem>): PhenomenonProps;
28
28
  abstract parseFormat(data: Readonly<TItem>): FormatProps;
29
29
  abstract parseUnitSystem(data: Readonly<TItem>): UnitSystemProps;
30
- abstract getProperties(data: Readonly<TItem>): Iterable<PropertyTuple<TProperty>>;
30
+ abstract getProperties(data: Readonly<TItem>, itemName: string): Iterable<PropertyTuple<TProperty>>;
31
31
  abstract parsePrimitiveProperty(data: Readonly<TProperty>): PrimitivePropertyProps;
32
32
  abstract parseStructProperty(data: Readonly<TProperty>): StructPropertyProps;
33
33
  abstract parsePrimitiveArrayProperty(data: Readonly<TProperty>): PrimitiveArrayPropertyProps;
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractParser.d.ts","sourceRoot":"","sources":["../../../src/Deserialization/AbstractParser.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,UAAU,EAC7I,uBAAuB,EAAE,eAAe,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,sBAAsB,EAC5I,WAAW,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,SAAS,EAAE,eAAe,EAC/H,MAAM,8BAA8B,CAAC;AACtC,OA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G,GAAG,EAAE,SAAS,GAAG,KAAK;IAAI,KAAI,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;CAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractParser.js","sourceRoot":"","sources":["../../../src/Deserialization/AbstractParser.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAmB/F,gBAAgB;AAChB,MAAsB,cAAc;CAiCnC;AAjCD,wCAiCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, FormatProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\r\n NavigationPropertyProps, PhenomenonProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PropertyCategoryProps, RelationshipClassProps,\r\n SchemaProps, SchemaReferenceProps, StructArrayPropertyProps, StructClassProps, StructPropertyProps, UnitProps, UnitSystemProps,\r\n} from \"../Deserialization/JsonProps\";\r\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\n\r\ntype SchemaItemTuple<T> = Readonly<[string /** Name */, string /** SchemaItemType */, Readonly<T>]>;\r\ntype PropertyTuple<T> = Readonly<[string /** Name */, string /** Property */, Readonly<T>]>;\r\n\r\n/** @internal */\r\nexport type CustomAttributeProvider = (caClass: CustomAttributeClass) => CustomAttribute;\r\n\r\n/** @internal */\r\nexport type CAProviderTuple = Readonly<[string /** Full Name */, CustomAttributeProvider]>;\r\n\r\n/** @internal */\r\nexport abstract class AbstractParser<TItem = any, TProperty = TItem> {\r\n public abstract parseSchema(): SchemaProps;\r\n public abstract getReferences(): Iterable<SchemaReferenceProps>;\r\n\r\n public abstract getItems(): Iterable<SchemaItemTuple<TItem>>;\r\n public abstract findItem(itemName: string): SchemaItemTuple<TItem> | undefined;\r\n\r\n public abstract parseEntityClass(data: Readonly<TItem>): EntityClassProps;\r\n public abstract parseMixin(data: Readonly<TItem>): MixinProps;\r\n public abstract parseStructClass(data: Readonly<TItem>): StructClassProps;\r\n public abstract parseCustomAttributeClass(data: Readonly<TItem>): CustomAttributeClassProps;\r\n public abstract parseRelationshipClass(data: Readonly<TItem>): RelationshipClassProps;\r\n public abstract parseEnumeration(data: Readonly<TItem>): EnumerationProps;\r\n public abstract parseKindOfQuantity(data: Readonly<TItem>): KindOfQuantityProps;\r\n public abstract parsePropertyCategory(data: Readonly<TItem>): PropertyCategoryProps;\r\n public abstract parseUnit(data: Readonly<TItem>): UnitProps;\r\n public abstract parseInvertedUnit(data: Readonly<TItem>): InvertedUnitProps;\r\n public abstract parseConstant(data: Readonly<TItem>): ConstantProps;\r\n public abstract parsePhenomenon(data: Readonly<TItem>): PhenomenonProps;\r\n public abstract parseFormat(data: Readonly<TItem>): FormatProps;\r\n public abstract parseUnitSystem(data: Readonly<TItem>): UnitSystemProps;\r\n\r\n public abstract getProperties(data: Readonly<TItem>): Iterable<PropertyTuple<TProperty>>;\r\n public abstract parsePrimitiveProperty(data: Readonly<TProperty>): PrimitivePropertyProps;\r\n public abstract parseStructProperty(data: Readonly<TProperty>): StructPropertyProps;\r\n public abstract parsePrimitiveArrayProperty(data: Readonly<TProperty>): PrimitiveArrayPropertyProps;\r\n public abstract parseStructArrayProperty(data: Readonly<TProperty>): StructArrayPropertyProps;\r\n public abstract parseNavigationProperty(data: Readonly<TProperty>): NavigationPropertyProps;\r\n\r\n public abstract getSchemaCustomAttributeProviders(): Iterable<CAProviderTuple>;\r\n public abstract getClassCustomAttributeProviders(data: Readonly<TItem>): Iterable<CAProviderTuple>;\r\n public abstract getPropertyCustomAttributeProviders(data: Readonly<TProperty>): Iterable<CAProviderTuple>;\r\n public abstract getRelationshipConstraintCustomAttributeProviders(data: Readonly<TItem>): [Iterable<CAProviderTuple> /* source */, Iterable<CAProviderTuple> /* target */];\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/prefer-function-type\r\nexport interface AbstractParserConstructor<TSchema, TItem = any, TProperty = TItem> { new(obj: Readonly<TSchema>): AbstractParser<TItem, TProperty> }\r\n"]}
1
+ {"version":3,"file":"AbstractParser.js","sourceRoot":"","sources":["../../../src/Deserialization/AbstractParser.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAmB/F,gBAAgB;AAChB,MAAsB,cAAc;CAiCnC;AAjCD,wCAiCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, FormatProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\r\n NavigationPropertyProps, PhenomenonProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PropertyCategoryProps, RelationshipClassProps,\r\n SchemaProps, SchemaReferenceProps, StructArrayPropertyProps, StructClassProps, StructPropertyProps, UnitProps, UnitSystemProps,\r\n} from \"../Deserialization/JsonProps\";\r\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\r\nimport { CustomAttributeClass } from \"../Metadata/CustomAttributeClass\";\r\n\r\ntype SchemaItemTuple<T> = Readonly<[string /** Name */, string /** SchemaItemType */, Readonly<T>]>;\r\ntype PropertyTuple<T> = Readonly<[string /** Name */, string /** Property */, Readonly<T>]>;\r\n\r\n/** @internal */\r\nexport type CustomAttributeProvider = (caClass: CustomAttributeClass) => CustomAttribute;\r\n\r\n/** @internal */\r\nexport type CAProviderTuple = Readonly<[string /** Full Name */, CustomAttributeProvider]>;\r\n\r\n/** @internal */\r\nexport abstract class AbstractParser<TItem = any, TProperty = TItem> {\r\n public abstract parseSchema(): SchemaProps;\r\n public abstract getReferences(): Iterable<SchemaReferenceProps>;\r\n\r\n public abstract getItems(): Iterable<SchemaItemTuple<TItem>>;\r\n public abstract findItem(itemName: string): SchemaItemTuple<TItem> | undefined;\r\n\r\n public abstract parseEntityClass(data: Readonly<TItem>): EntityClassProps;\r\n public abstract parseMixin(data: Readonly<TItem>): MixinProps;\r\n public abstract parseStructClass(data: Readonly<TItem>): StructClassProps;\r\n public abstract parseCustomAttributeClass(data: Readonly<TItem>): CustomAttributeClassProps;\r\n public abstract parseRelationshipClass(data: Readonly<TItem>): RelationshipClassProps;\r\n public abstract parseEnumeration(data: Readonly<TItem>): EnumerationProps;\r\n public abstract parseKindOfQuantity(data: Readonly<TItem>): KindOfQuantityProps;\r\n public abstract parsePropertyCategory(data: Readonly<TItem>): PropertyCategoryProps;\r\n public abstract parseUnit(data: Readonly<TItem>): UnitProps;\r\n public abstract parseInvertedUnit(data: Readonly<TItem>): InvertedUnitProps;\r\n public abstract parseConstant(data: Readonly<TItem>): ConstantProps;\r\n public abstract parsePhenomenon(data: Readonly<TItem>): PhenomenonProps;\r\n public abstract parseFormat(data: Readonly<TItem>): FormatProps;\r\n public abstract parseUnitSystem(data: Readonly<TItem>): UnitSystemProps;\r\n\r\n public abstract getProperties(data: Readonly<TItem>, itemName: string): Iterable<PropertyTuple<TProperty>>;\r\n public abstract parsePrimitiveProperty(data: Readonly<TProperty>): PrimitivePropertyProps;\r\n public abstract parseStructProperty(data: Readonly<TProperty>): StructPropertyProps;\r\n public abstract parsePrimitiveArrayProperty(data: Readonly<TProperty>): PrimitiveArrayPropertyProps;\r\n public abstract parseStructArrayProperty(data: Readonly<TProperty>): StructArrayPropertyProps;\r\n public abstract parseNavigationProperty(data: Readonly<TProperty>): NavigationPropertyProps;\r\n\r\n public abstract getSchemaCustomAttributeProviders(): Iterable<CAProviderTuple>;\r\n public abstract getClassCustomAttributeProviders(data: Readonly<TItem>): Iterable<CAProviderTuple>;\r\n public abstract getPropertyCustomAttributeProviders(data: Readonly<TProperty>): Iterable<CAProviderTuple>;\r\n public abstract getRelationshipConstraintCustomAttributeProviders(data: Readonly<TItem>): [Iterable<CAProviderTuple> /* source */, Iterable<CAProviderTuple> /* target */];\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/prefer-function-type\r\nexport interface AbstractParserConstructor<TSchema, TItem = any, TProperty = TItem> { new(obj: Readonly<TSchema>): AbstractParser<TItem, TProperty> }\r\n"]}
@@ -546,7 +546,7 @@ class SchemaReadHelper {
546
546
  // Now deserialize the class itself, *before* any properties
547
547
  // (We need to do this to break Entity -navProp-> Relationship -constraint-> Entity cycle.)
548
548
  await classObj.fromJSON(classProps);
549
- for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass)) {
549
+ for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass, classObj.fullName)) {
550
550
  await this.loadPropertyTypes(classObj, propName, propType, rawProp);
551
551
  }
552
552
  await this.loadCustomAttributes(classObj, this._parser.getClassCustomAttributeProviders(rawClass));
@@ -569,7 +569,7 @@ class SchemaReadHelper {
569
569
  // Now deserialize the class itself, *before* any properties
570
570
  // (We need to do this to break Entity -navProp-> Relationship -constraint-> Entity cycle.)
571
571
  classObj.fromJSONSync(classProps);
572
- for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass)) {
572
+ for (const [propName, propType, rawProp] of this._parser.getProperties(rawClass, classObj.fullName)) {
573
573
  this.loadPropertyTypesSync(classObj, propName, propType, rawProp);
574
574
  }
575
575
  this.loadCustomAttributesSync(classObj, this._parser.getClassCustomAttributeProviders(rawClass));