@itwin/ecschema-metadata 4.2.0-dev.8 → 4.2.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,59 @@
1
1
  # Change Log - @itwin/ecschema-metadata
2
2
 
3
- This log was last generated on Tue, 15 Aug 2023 19:39:59 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 17 Oct 2023 15:14:32 GMT and should not be manually modified.
4
+
5
+ ## 4.2.0
6
+ Tue, 17 Oct 2023 15:14:32 GMT
7
+
8
+ ### Updates
9
+
10
+ - Make SchemaLoader, SchemaJsonLocater and SchemaPropsGetter beta
11
+ - Added the ability to rename an ECProperty via the setName method.
12
+
13
+ ## 4.1.9
14
+ Tue, 10 Oct 2023 18:48:12 GMT
15
+
16
+ _Version update only_
17
+
18
+ ## 4.1.8
19
+ Fri, 06 Oct 2023 04:00:18 GMT
20
+
21
+ _Version update only_
22
+
23
+ ## 4.1.7
24
+ Thu, 28 Sep 2023 21:41:33 GMT
25
+
26
+ _Version update only_
27
+
28
+ ## 4.1.6
29
+ Tue, 12 Sep 2023 15:38:52 GMT
30
+
31
+ _Version update only_
32
+
33
+ ## 4.1.5
34
+ Fri, 08 Sep 2023 13:37:23 GMT
35
+
36
+ _Version update only_
37
+
38
+ ## 4.1.4
39
+ Thu, 07 Sep 2023 18:26:02 GMT
40
+
41
+ _Version update only_
42
+
43
+ ## 4.1.3
44
+ Wed, 30 Aug 2023 15:35:27 GMT
45
+
46
+ _Version update only_
47
+
48
+ ## 4.1.2
49
+ Wed, 23 Aug 2023 15:25:29 GMT
50
+
51
+ _Version update only_
52
+
53
+ ## 4.1.1
54
+ Fri, 18 Aug 2023 13:02:53 GMT
55
+
56
+ _Version update only_
4
57
 
5
58
  ## 4.1.0
6
59
  Mon, 14 Aug 2023 14:36:34 GMT
@@ -55,6 +108,31 @@ Mon, 22 May 2023 15:34:14 GMT
55
108
  - Update to eslint@8
56
109
  - Replaced UnitProps interface with SchemaItemUnitProps type.
57
110
 
111
+ ## 3.7.16
112
+ Mon, 16 Oct 2023 12:49:08 GMT
113
+
114
+ _Version update only_
115
+
116
+ ## 3.7.15
117
+ Tue, 10 Oct 2023 19:58:35 GMT
118
+
119
+ _Version update only_
120
+
121
+ ## 3.7.14
122
+ Fri, 29 Sep 2023 16:57:16 GMT
123
+
124
+ _Version update only_
125
+
126
+ ## 3.7.13
127
+ Tue, 08 Aug 2023 19:49:18 GMT
128
+
129
+ _Version update only_
130
+
131
+ ## 3.7.12
132
+ Thu, 27 Jul 2023 21:50:57 GMT
133
+
134
+ _Version update only_
135
+
58
136
  ## 3.7.11
59
137
  Tue, 11 Jul 2023 17:17:22 GMT
60
138
 
@@ -7,13 +7,13 @@ import { SchemaKey } from "./SchemaKey";
7
7
  /**
8
8
  * Gets the full schema Json for the input schema name or undefined if not found
9
9
  * @throws [Error] if the schema is found but json cannot be returned
10
- * @alpha
10
+ * @beta
11
11
  */
12
12
  export type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;
13
13
  /**
14
14
  * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function
15
15
  * that returns the Schema Json for a given schema name
16
- * @alpha
16
+ * @beta
17
17
  */
18
18
  export declare class SchemaJsonLocater implements ISchemaLocater {
19
19
  private _getSchema;
@@ -10,7 +10,7 @@ const Schema_1 = require("./Metadata/Schema");
10
10
  /**
11
11
  * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function
12
12
  * that returns the Schema Json for a given schema name
13
- * @alpha
13
+ * @beta
14
14
  */
15
15
  class SchemaJsonLocater {
16
16
  constructor(_getSchema) {
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0D;AAI1D,8CAA2C;AAU3C;;;;GAIG;AACH,MAAa,iBAAiB;IAC5B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAmB,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QACzH,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAM,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QAC3G,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAmB,SAA8B,EAAE,UAA2B,EAAE,OAAsB;QACxH,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,uBAAa,EAAE,CAAC;QAClD,OAAO,eAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAM,CAAC;IACxD,CAAC;CAEF;AArCD,8CAqCC","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 { ISchemaLocater, SchemaContext } from \"./Context\";\r\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * Gets the full schema Json for the input schema name or undefined if not found\r\n * @throws [Error] if the schema is found but json cannot be returned\r\n * @alpha\r\n */\r\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\r\n\r\n/**\r\n * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\r\n * that returns the Schema Json for a given schema name\r\n * @alpha\r\n */\r\nexport class SchemaJsonLocater implements ISchemaLocater {\r\n public constructor(private _getSchema: SchemaPropsGetter) { }\r\n\r\n /** Get a schema by [SchemaKey]\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\r\n return this.getSchemaSync(schemaKey, matchType, context) as T;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\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 getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\r\n return this.getSchema(schemaKey, matchType, context);\r\n }\r\n\r\n /** Get a schema by [SchemaKey] synchronously.\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, _matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const schemaProps = this._getSchema(schemaKey.name);\r\n if (!schemaProps)\r\n return undefined;\r\n\r\n context = context ? context : new SchemaContext();\r\n return Schema.fromJsonSync(schemaProps, context) as T;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0D;AAI1D,8CAA2C;AAU3C;;;;GAIG;AACH,MAAa,iBAAiB;IAC5B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAmB,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QACzH,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAM,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QAC3G,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAmB,SAA8B,EAAE,UAA2B,EAAE,OAAsB;QACxH,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,uBAAa,EAAE,CAAC;QAClD,OAAO,eAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAM,CAAC;IACxD,CAAC;CAEF;AArCD,8CAqCC","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 { ISchemaLocater, SchemaContext } from \"./Context\";\r\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { SchemaInfo } from \"./Interfaces\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * Gets the full schema Json for the input schema name or undefined if not found\r\n * @throws [Error] if the schema is found but json cannot be returned\r\n * @beta\r\n */\r\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\r\n\r\n/**\r\n * A ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\r\n * that returns the Schema Json for a given schema name\r\n * @beta\r\n */\r\nexport class SchemaJsonLocater implements ISchemaLocater {\r\n public constructor(private _getSchema: SchemaPropsGetter) { }\r\n\r\n /** Get a schema by [SchemaKey]\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\r\n return this.getSchemaSync(schemaKey, matchType, context) as T;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\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 getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\r\n return this.getSchema(schemaKey, matchType, context);\r\n }\r\n\r\n /** Get a schema by [SchemaKey] synchronously.\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, _matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const schemaProps = this._getSchema(schemaKey.name);\r\n if (!schemaProps)\r\n return undefined;\r\n\r\n context = context ? context : new SchemaContext();\r\n return Schema.fromJsonSync(schemaProps, context) as T;\r\n }\r\n\r\n}\r\n"]}
@@ -1,3 +1,4 @@
1
+ import { SchemaContext } from "./Context";
1
2
  import { Schema } from "./Metadata/Schema";
2
3
  import { SchemaPropsGetter } from "./SchemaJsonLocater";
3
4
  /**
@@ -5,7 +6,12 @@ import { SchemaPropsGetter } from "./SchemaJsonLocater";
5
6
  * Loaded schemas are held in memory within a schema context managed by SchemaLoader.
6
7
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
7
8
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
8
- * @alpha
9
+ *
10
+ * ** Example **
11
+ * ```ts
12
+ * [[include:IModelSchemas.loadFromDb]]
13
+ * ```
14
+ * @beta
9
15
  */
10
16
  export declare class SchemaLoader {
11
17
  private _context;
@@ -20,5 +26,7 @@ export declare class SchemaLoader {
20
26
  * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
21
27
  */
22
28
  tryGetSchema<T extends Schema>(schemaName: string): T | undefined;
29
+ /** Gets the SchemaContext used by the loader. */
30
+ get context(): SchemaContext;
23
31
  }
24
32
  //# sourceMappingURL=SchemaLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.d.ts","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;;;GAMG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgB;gBAEb,SAAS,EAAE,iBAAiB;IAM/C;;;OAGG;IACI,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;IAQzD;;;OAGG;IACI,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;CAMzE"}
1
+ {"version":3,"file":"SchemaLoader.d.ts","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgB;gBAEb,SAAS,EAAE,iBAAiB;IAM/C;;;OAGG;IACI,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;IAQzD;;;OAGG;IACI,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAOxE,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
@@ -15,7 +15,12 @@ const SchemaKey_1 = require("./SchemaKey");
15
15
  * Loaded schemas are held in memory within a schema context managed by SchemaLoader.
16
16
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
17
17
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
18
- * @alpha
18
+ *
19
+ * ** Example **
20
+ * ```ts
21
+ * [[include:IModelSchemas.loadFromDb]]
22
+ * ```
23
+ * @beta
19
24
  */
20
25
  class SchemaLoader {
21
26
  constructor(getSchema) {
@@ -43,6 +48,10 @@ class SchemaLoader {
43
48
  const schema = this._context.getSchemaSync(key, ECObjects_1.SchemaMatchType.Latest);
44
49
  return schema;
45
50
  }
51
+ /** Gets the SchemaContext used by the loader. */
52
+ get context() {
53
+ return this._context;
54
+ }
46
55
  }
47
56
  exports.SchemaLoader = SchemaLoader;
48
57
  //# sourceMappingURL=SchemaLoader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0C;AAC1C,2CAA8C;AAC9C,2CAA8D;AAE9D,2DAA2E;AAC3E,2CAAmD;AAEnD;;;;;;GAMG;AACH,MAAa,YAAY;IAGvB,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAmB,UAAkB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAEjG,OAAO,MAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAmB,UAAkB;QACtD,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,qBAAS,CAAC,UAAU,EAAE,IAAI,qBAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAW,CAAC;IACrB,CAAC;CACF;AA/BD,oCA+BC","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 { SchemaContext } from \"./Context\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\r\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\r\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\r\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\r\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\r\n * @alpha\r\n */\r\nexport class SchemaLoader {\r\n private _context: SchemaContext;\r\n\r\n public constructor(getSchema: SchemaPropsGetter) {\r\n this._context = new SchemaContext();\r\n const locater = new SchemaJsonLocater(getSchema);\r\n this._context.addLocater(locater);\r\n }\r\n\r\n /** Get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.\r\n */\r\n public getSchema<T extends Schema>(schemaName: string): T {\r\n const schema = this.tryGetSchema(schemaName);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\r\n\r\n return schema as T;\r\n }\r\n\r\n /** Attempts to get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public tryGetSchema<T extends Schema>(schemaName: string): T | undefined {\r\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\r\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\r\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema as T;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0C;AAC1C,2CAA8C;AAC9C,2CAA8D;AAE9D,2DAA2E;AAC3E,2CAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,MAAa,YAAY;IAGvB,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAmB,UAAkB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,0BAAc,CAAC,2BAAe,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAEjG,OAAO,MAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAmB,UAAkB;QACtD,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,qBAAS,CAAC,UAAU,EAAE,IAAI,qBAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,2BAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAW,CAAC;IACrB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AApCD,oCAoCC","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 { SchemaContext } from \"./Context\";\r\nimport { SchemaMatchType } from \"./ECObjects\";\r\nimport { ECObjectsError, ECObjectsStatus } from \"./Exception\";\r\nimport { Schema } from \"./Metadata/Schema\";\r\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\r\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\r\n\r\n/**\r\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\r\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\r\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\r\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\r\n *\r\n * ** Example **\r\n * ```ts\r\n * [[include:IModelSchemas.loadFromDb]]\r\n * ```\r\n * @beta\r\n */\r\nexport class SchemaLoader {\r\n private _context: SchemaContext;\r\n\r\n public constructor(getSchema: SchemaPropsGetter) {\r\n this._context = new SchemaContext();\r\n const locater = new SchemaJsonLocater(getSchema);\r\n this._context.addLocater(locater);\r\n }\r\n\r\n /** Get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema is not found or cannot be loaded.\r\n */\r\n public getSchema<T extends Schema>(schemaName: string): T {\r\n const schema = this.tryGetSchema(schemaName);\r\n if (!schema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\r\n\r\n return schema as T;\r\n }\r\n\r\n /** Attempts to get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.\r\n */\r\n public tryGetSchema<T extends Schema>(schemaName: string): T | undefined {\r\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\r\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\r\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema as T;\r\n }\r\n\r\n /** Gets the SchemaContext used by the loader. */\r\n public get context(): SchemaContext {\r\n return this._context;\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-metadata",
3
- "version": "4.2.0-dev.8",
3
+ "version": "4.2.0",
4
4
  "description": "ECObjects core concepts in typescript",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-metadata.js",
@@ -33,7 +33,7 @@
33
33
  "@types/sinon": "^10.0.15",
34
34
  "@xmldom/xmldom": "~0.8.5",
35
35
  "benchmark": "^2.1.4",
36
- "chai": "^4.1.2",
36
+ "chai": "^4.3.10",
37
37
  "chai-as-promised": "^7",
38
38
  "cpx2": "^3.0.0",
39
39
  "eslint": "^8.44.0",
@@ -42,13 +42,13 @@
42
42
  "rimraf": "^3.0.2",
43
43
  "sinon": "^15.0.4",
44
44
  "typescript": "~5.0.2",
45
- "@itwin/build-tools": "4.2.0-dev.8",
46
- "@itwin/core-quantity": "4.2.0-dev.8",
47
- "@itwin/core-bentley": "4.2.0-dev.8"
45
+ "@itwin/build-tools": "4.2.0",
46
+ "@itwin/core-bentley": "4.2.0",
47
+ "@itwin/core-quantity": "4.2.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "@itwin/core-bentley": "^4.2.0-dev.8",
51
- "@itwin/core-quantity": "^4.2.0-dev.8"
50
+ "@itwin/core-bentley": "^4.2.0",
51
+ "@itwin/core-quantity": "^4.2.0"
52
52
  },
53
53
  "dependencies": {
54
54
  "almost-equal": "^1.1.0"