@itwin/ecschema-metadata 4.2.0-dev.26 → 4.2.0-dev.28

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.
@@ -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.26",
3
+ "version": "4.2.0-dev.28",
4
4
  "description": "ECObjects core concepts in typescript",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-metadata.js",
@@ -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.26",
46
- "@itwin/core-bentley": "4.2.0-dev.26",
47
- "@itwin/core-quantity": "4.2.0-dev.26"
45
+ "@itwin/build-tools": "4.2.0-dev.28",
46
+ "@itwin/core-bentley": "4.2.0-dev.28",
47
+ "@itwin/core-quantity": "4.2.0-dev.28"
48
48
  },
49
49
  "peerDependencies": {
50
- "@itwin/core-bentley": "^4.2.0-dev.26",
51
- "@itwin/core-quantity": "^4.2.0-dev.26"
50
+ "@itwin/core-bentley": "^4.2.0-dev.28",
51
+ "@itwin/core-quantity": "^4.2.0-dev.28"
52
52
  },
53
53
  "dependencies": {
54
54
  "almost-equal": "^1.1.0"