@itwin/ecschema-metadata 5.4.0-dev.7 → 5.5.0-dev.2

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,16 @@
1
1
  # Change Log - @itwin/ecschema-metadata
2
2
 
3
- This log was last generated on Thu, 06 Nov 2025 20:30:21 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 20 Nov 2025 22:31:49 GMT and should not be manually modified.
4
+
5
+ ## 5.3.3
6
+ Thu, 20 Nov 2025 22:30:37 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 5.3.2
11
+ Thu, 13 Nov 2025 23:23:23 GMT
12
+
13
+ _Version update only_
4
14
 
5
15
  ## 5.3.1
6
16
  Thu, 06 Nov 2025 20:29:06 GMT
@@ -14,6 +24,16 @@ Mon, 03 Nov 2025 19:02:35 GMT
14
24
 
15
25
  - Update `FormatSet` interface, `FormatSetFormatsProvider` to support format referencing
16
26
 
27
+ ## 5.2.6
28
+ Thu, 13 Nov 2025 21:13:51 GMT
29
+
30
+ _Version update only_
31
+
32
+ ## 5.2.5
33
+ Thu, 13 Nov 2025 07:45:14 GMT
34
+
35
+ _Version update only_
36
+
17
37
  ## 5.2.4
18
38
  Fri, 24 Oct 2025 16:20:38 GMT
19
39
 
@@ -151,6 +171,11 @@ Fri, 13 Jun 2025 20:25:38 GMT
151
171
  - EC Schemas getItems was using a generic to specify the type of item to be removed, the items were never validated though if the schema items really match the given type. With this change, callers can make sure that if they use the overload with the item type (analog to getItem) only items of that type get's returned.
152
172
  - Change core peer dependencies to strict version.
153
173
 
174
+ ## 4.11.7
175
+ Thu, 13 Nov 2025 20:49:33 GMT
176
+
177
+ _Version update only_
178
+
154
179
  ## 4.11.6
155
180
  Mon, 16 Jun 2025 15:00:15 GMT
156
181
 
@@ -16,8 +16,8 @@ export type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;
16
16
  * @public @preview
17
17
  */
18
18
  export declare class SchemaJsonLocater implements ISchemaLocater {
19
- private _getSchema;
20
- constructor(_getSchema: SchemaPropsGetter);
19
+ private _getSchemaProps;
20
+ constructor(getSchemaProps: SchemaPropsGetter);
21
21
  /** Get a schema by [SchemaKey]
22
22
  * @param schemaKey The [SchemaKey] that identifies the schema.
23
23
  * @param matchType The [SchemaMatchType] to used for comparing schema versions.
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACnC,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,iBAAiB;IAExD;;;;;OAKG;IACU,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK7H;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAYrI;;;;;OAKG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAOpH"}
1
+ {"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,eAAe,CAAoB;gBAExB,cAAc,EAAE,iBAAiB;IAcpD;;;;;OAKG;IACU,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK7H;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAYrI;;;;;OAKG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAOpH"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaJsonLocater = void 0;
2
4
  /*---------------------------------------------------------------------------------------------
3
5
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
6
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
7
  *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.SchemaJsonLocater = void 0;
8
8
  const Context_1 = require("./Context");
9
9
  const Schema_1 = require("./Metadata/Schema");
10
10
  /**
@@ -13,9 +13,20 @@ const Schema_1 = require("./Metadata/Schema");
13
13
  * @public @preview
14
14
  */
15
15
  class SchemaJsonLocater {
16
- _getSchema;
17
- constructor(_getSchema) {
18
- this._getSchema = _getSchema;
16
+ _getSchemaProps;
17
+ constructor(getSchemaProps) {
18
+ // Since the getSchemaProps may throw an error, but the locater contract defines that
19
+ // getSchema should return undefined if the schema could not be located, we wrap the provided
20
+ // lookup function in a safe block.
21
+ this._getSchemaProps = (schemaName) => {
22
+ try {
23
+ return getSchemaProps(schemaName);
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ }
26
+ catch (error) {
27
+ return undefined;
28
+ }
29
+ };
19
30
  }
20
31
  /** Get a schema by [SchemaKey]
21
32
  * @param schemaKey The [SchemaKey] that identifies the schema.
@@ -33,7 +44,7 @@ class SchemaJsonLocater {
33
44
  * @param matchType The match type to use when locating the schema
34
45
  */
35
46
  async getSchemaInfo(schemaKey, matchType, context) {
36
- const schemaProps = this._getSchema(schemaKey.name);
47
+ const schemaProps = this._getSchemaProps(schemaKey.name);
37
48
  if (!schemaProps)
38
49
  return undefined;
39
50
  const schemaInfo = await Schema_1.Schema.startLoadingFromJson(schemaProps, context);
@@ -48,7 +59,7 @@ class SchemaJsonLocater {
48
59
  * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.
49
60
  */
50
61
  getSchemaSync(schemaKey, _matchType, context) {
51
- const schemaProps = this._getSchema(schemaKey.name);
62
+ const schemaProps = this._getSchemaProps(schemaKey.name);
52
63
  if (!schemaProps)
53
64
  return undefined;
54
65
  return Schema_1.Schema.fromJsonSync(schemaProps, context || new Context_1.SchemaContext());
@@ -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;IACD;IAA3B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,eAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;YAChF,OAAO,UAAU,CAAC;QAEpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAoB,EAAE,UAA2B,EAAE,OAAsB;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,eAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,uBAAa,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF;AA5CD,8CA4CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { SchemaInfo } from \"./Interfaces\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaKey } from \"./SchemaKey\";\n\n/**\n * Gets the full schema Json for the input schema name or undefined if not found\n * @throws [Error] if the schema is found but json cannot be returned\n * @public @preview\n */\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\n\n/**\n * An ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\n * that returns the Schema Json for a given schema name\n * @public @preview\n */\nexport class SchemaJsonLocater implements ISchemaLocater {\n public constructor(private _getSchema: SchemaPropsGetter) { }\n\n /** Get a schema by [SchemaKey]\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n return context.getCachedSchema(schemaKey, matchType);\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\n return schemaInfo;\n\n return undefined;\n }\n\n /** Get a schema by [SchemaKey] synchronously.\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n return Schema.fromJsonSync(schemaProps, context || new SchemaContext());\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,uCAA0D;AAI1D,8CAA2C;AAU3C;;;;GAIG;AACH,MAAa,iBAAiB;IACpB,eAAe,CAAoB;IAE3C,YAAmB,cAAiC;QAClD,qFAAqF;QACrF,6FAA6F;QAC7F,mCAAmC;QACnC,IAAI,CAAC,eAAe,GAAG,CAAC,UAAU,EAAE,EAAE;YACpC,IAAI,CAAC;gBACH,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC;gBACpC,6DAA6D;YAC7D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,eAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;YAChF,OAAO,UAAU,CAAC;QAEpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAoB,EAAE,UAA2B,EAAE,OAAsB;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,eAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,uBAAa,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF;AA1DD,8CA0DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { SchemaInfo } from \"./Interfaces\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaKey } from \"./SchemaKey\";\n\n/**\n * Gets the full schema Json for the input schema name or undefined if not found\n * @throws [Error] if the schema is found but json cannot be returned\n * @public @preview\n */\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\n\n/**\n * An ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\n * that returns the Schema Json for a given schema name\n * @public @preview\n */\nexport class SchemaJsonLocater implements ISchemaLocater {\n private _getSchemaProps: SchemaPropsGetter;\n\n public constructor(getSchemaProps: SchemaPropsGetter) {\n // Since the getSchemaProps may throw an error, but the locater contract defines that\n // getSchema should return undefined if the schema could not be located, we wrap the provided\n // lookup function in a safe block.\n this._getSchemaProps = (schemaName) => {\n try {\n return getSchemaProps(schemaName);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (error) {\n return undefined;\n }\n };\n }\n\n /** Get a schema by [SchemaKey]\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n return context.getCachedSchema(schemaKey, matchType);\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaProps = this._getSchemaProps(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\n return schemaInfo;\n\n return undefined;\n }\n\n /** Get a schema by [SchemaKey] synchronously.\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const schemaProps = this._getSchemaProps(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n return Schema.fromJsonSync(schemaProps, context || new SchemaContext());\n }\n}\n"]}
@@ -16,8 +16,8 @@ export type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;
16
16
  * @public @preview
17
17
  */
18
18
  export declare class SchemaJsonLocater implements ISchemaLocater {
19
- private _getSchema;
20
- constructor(_getSchema: SchemaPropsGetter);
19
+ private _getSchemaProps;
20
+ constructor(getSchemaProps: SchemaPropsGetter);
21
21
  /** Get a schema by [SchemaKey]
22
22
  * @param schemaKey The [SchemaKey] that identifies the schema.
23
23
  * @param matchType The [SchemaMatchType] to used for comparing schema versions.
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACnC,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,iBAAiB;IAExD;;;;;OAKG;IACU,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK7H;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAYrI;;;;;OAKG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAOpH"}
1
+ {"version":3,"file":"SchemaJsonLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,eAAe,CAAoB;gBAExB,cAAc,EAAE,iBAAiB;IAcpD;;;;;OAKG;IACU,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK7H;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAYrI;;;;;OAKG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAOpH"}
@@ -10,9 +10,20 @@ import { Schema } from "./Metadata/Schema";
10
10
  * @public @preview
11
11
  */
12
12
  export class SchemaJsonLocater {
13
- _getSchema;
14
- constructor(_getSchema) {
15
- this._getSchema = _getSchema;
13
+ _getSchemaProps;
14
+ constructor(getSchemaProps) {
15
+ // Since the getSchemaProps may throw an error, but the locater contract defines that
16
+ // getSchema should return undefined if the schema could not be located, we wrap the provided
17
+ // lookup function in a safe block.
18
+ this._getSchemaProps = (schemaName) => {
19
+ try {
20
+ return getSchemaProps(schemaName);
21
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
+ }
23
+ catch (error) {
24
+ return undefined;
25
+ }
26
+ };
16
27
  }
17
28
  /** Get a schema by [SchemaKey]
18
29
  * @param schemaKey The [SchemaKey] that identifies the schema.
@@ -30,7 +41,7 @@ export class SchemaJsonLocater {
30
41
  * @param matchType The match type to use when locating the schema
31
42
  */
32
43
  async getSchemaInfo(schemaKey, matchType, context) {
33
- const schemaProps = this._getSchema(schemaKey.name);
44
+ const schemaProps = this._getSchemaProps(schemaKey.name);
34
45
  if (!schemaProps)
35
46
  return undefined;
36
47
  const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);
@@ -45,7 +56,7 @@ export class SchemaJsonLocater {
45
56
  * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.
46
57
  */
47
58
  getSchemaSync(schemaKey, _matchType, context) {
48
- const schemaProps = this._getSchema(schemaKey.name);
59
+ const schemaProps = this._getSchemaProps(schemaKey.name);
49
60
  if (!schemaProps)
50
61
  return undefined;
51
62
  return Schema.fromJsonSync(schemaProps, context || new SchemaContext());
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACD;IAA3B,YAA2B,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;IAAI,CAAC;IAE7D;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;YAChF,OAAO,UAAU,CAAC;QAEpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAoB,EAAE,UAA2B,EAAE,OAAsB;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { SchemaInfo } from \"./Interfaces\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaKey } from \"./SchemaKey\";\n\n/**\n * Gets the full schema Json for the input schema name or undefined if not found\n * @throws [Error] if the schema is found but json cannot be returned\n * @public @preview\n */\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\n\n/**\n * An ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\n * that returns the Schema Json for a given schema name\n * @public @preview\n */\nexport class SchemaJsonLocater implements ISchemaLocater {\n public constructor(private _getSchema: SchemaPropsGetter) { }\n\n /** Get a schema by [SchemaKey]\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n return context.getCachedSchema(schemaKey, matchType);\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\n return schemaInfo;\n\n return undefined;\n }\n\n /** Get a schema by [SchemaKey] synchronously.\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const schemaProps = this._getSchema(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n return Schema.fromJsonSync(schemaProps, context || new SchemaContext());\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaJsonLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonLocater.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAkB,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACpB,eAAe,CAAoB;IAE3C,YAAmB,cAAiC;QAClD,qFAAqF;QACrF,6FAA6F;QAC7F,mCAAmC;QACnC,IAAI,CAAC,eAAe,GAAG,CAAC,UAAU,EAAE,EAAE;YACpC,IAAI,CAAC;gBACH,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC;gBACpC,6DAA6D;YAC7D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;YAChF,OAAO,UAAU,CAAC;QAEpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAoB,EAAE,UAA2B,EAAE,OAAsB;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW;YACd,OAAO,SAAS,CAAC;QAEnB,OAAO,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { ISchemaLocater, SchemaContext } from \"./Context\";\nimport { SchemaProps } from \"./Deserialization/JsonProps\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { SchemaInfo } from \"./Interfaces\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaKey } from \"./SchemaKey\";\n\n/**\n * Gets the full schema Json for the input schema name or undefined if not found\n * @throws [Error] if the schema is found but json cannot be returned\n * @public @preview\n */\nexport type SchemaPropsGetter = (schemaName: string) => SchemaProps | undefined;\n\n/**\n * An ISchemaLocater implementation for locating and retrieving EC Schema objects using a function\n * that returns the Schema Json for a given schema name\n * @public @preview\n */\nexport class SchemaJsonLocater implements ISchemaLocater {\n private _getSchemaProps: SchemaPropsGetter;\n\n public constructor(getSchemaProps: SchemaPropsGetter) {\n // Since the getSchemaProps may throw an error, but the locater contract defines that\n // getSchema should return undefined if the schema could not be located, we wrap the provided\n // lookup function in a safe block.\n this._getSchemaProps = (schemaName) => {\n try {\n return getSchemaProps(schemaName);\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (error) {\n return undefined;\n }\n };\n }\n\n /** Get a schema by [SchemaKey]\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n return context.getCachedSchema(schemaKey, matchType);\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaProps = this._getSchemaProps(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\n return schemaInfo;\n\n return undefined;\n }\n\n /** Get a schema by [SchemaKey] synchronously.\n * @param schemaKey The [SchemaKey] that identifies the schema.\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\n * @param context The [SchemaContext] used to facilitate schema location.\n * @throws [Error]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public getSchemaSync(schemaKey: SchemaKey, _matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const schemaProps = this._getSchemaProps(schemaKey.name);\n if (!schemaProps)\n return undefined;\n\n return Schema.fromJsonSync(schemaProps, context || new SchemaContext());\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-metadata",
3
- "version": "5.4.0-dev.7",
3
+ "version": "5.5.0-dev.2",
4
4
  "description": "ECObjects core concepts in typescript",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-metadata.js",
@@ -48,13 +48,13 @@
48
48
  "rimraf": "^6.0.1",
49
49
  "sinon": "^17.0.2",
50
50
  "typescript": "~5.6.2",
51
- "@itwin/build-tools": "5.4.0-dev.7",
52
- "@itwin/core-quantity": "5.4.0-dev.7",
53
- "@itwin/core-bentley": "5.4.0-dev.7"
51
+ "@itwin/build-tools": "5.5.0-dev.2",
52
+ "@itwin/core-quantity": "5.5.0-dev.2",
53
+ "@itwin/core-bentley": "5.5.0-dev.2"
54
54
  },
55
55
  "peerDependencies": {
56
- "@itwin/core-bentley": "5.4.0-dev.7",
57
- "@itwin/core-quantity": "5.4.0-dev.7"
56
+ "@itwin/core-bentley": "5.5.0-dev.2",
57
+ "@itwin/core-quantity": "5.5.0-dev.2"
58
58
  },
59
59
  "nyc": {
60
60
  "extends": "./node_modules/@itwin/build-tools/.nycrc"