@itwin/ecschema-metadata 5.1.0-dev.12 → 5.1.0-dev.13

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,11 +7,14 @@ import { SchemaPropsGetter } from "./SchemaJsonLocater";
7
7
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
8
8
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
9
9
  *
10
+ * Since the development of this class, the IModelDb class has been enhanced to include a schema context.
11
+ * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
12
+ *
10
13
  * ** Example **
11
14
  * ```ts
12
15
  * [[include:IModelSchemas.loadFromDb]]
13
16
  * ```
14
- * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
17
+ * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
15
18
  */
16
19
  export declare class SchemaLoader {
17
20
  private _context;
@@ -1 +1 @@
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,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ5C;;;OAGG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAO3D,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
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;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgB;gBAEb,SAAS,EAAE,iBAAiB;IAM/C;;;OAGG;IACI,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ5C;;;OAGG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAO3D,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
@@ -16,11 +16,14 @@ const SchemaKey_1 = require("./SchemaKey");
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
18
  *
19
+ * Since the development of this class, the IModelDb class has been enhanced to include a schema context.
20
+ * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
21
+ *
19
22
  * ** Example **
20
23
  * ```ts
21
24
  * [[include:IModelSchemas.loadFromDb]]
22
25
  * ```
23
- * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
26
+ * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
24
27
  */
25
28
  class SchemaLoader {
26
29
  _context;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0C;AAC1C,2CAA8C;AAC9C,2CAA4D;AAE5D,2DAA2E;AAC3E,2CAAmD;AAEnD;;;;;;;;;;;GAWG;AACH,MAAa,YAAY;IACf,QAAQ,CAAgB;IAEhC,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,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,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,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AApCD,oCAoCC","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 { SchemaContext } from \"./Context\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\n\n/**\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\n *\n * ** Example **\n * ```ts\n * [[include:IModelSchemas.loadFromDb]]\n * ```\n * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?\n */\nexport class SchemaLoader {\n private _context: SchemaContext;\n\n public constructor(getSchema: SchemaPropsGetter) {\n this._context = new SchemaContext();\n const locater = new SchemaJsonLocater(getSchema);\n this._context.addLocater(locater);\n }\n\n /** Get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.\n */\n public getSchema(schemaName: string): Schema {\n const schema = this.tryGetSchema(schemaName);\n if (!schema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\n\n return schema;\n }\n\n /** Attempts to get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public tryGetSchema(schemaName: string): Schema | undefined {\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n\n /** Gets the SchemaContext used by the loader. */\n public get context(): SchemaContext {\n return this._context;\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,uCAA0C;AAC1C,2CAA8C;AAC9C,2CAA4D;AAE5D,2DAA2E;AAC3E,2CAAmD;AAEnD;;;;;;;;;;;;;;GAcG;AACH,MAAa,YAAY;IACf,QAAQ,CAAgB;IAEhC,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,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,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,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AApCD,oCAoCC","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 { SchemaContext } from \"./Context\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\n\n/**\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\n *\n * Since the development of this class, the IModelDb class has been enhanced to include a schema context.\n * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.\n *\n * ** Example **\n * ```ts\n * [[include:IModelSchemas.loadFromDb]]\n * ```\n * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.\n */\nexport class SchemaLoader {\n private _context: SchemaContext;\n\n public constructor(getSchema: SchemaPropsGetter) {\n this._context = new SchemaContext();\n const locater = new SchemaJsonLocater(getSchema);\n this._context.addLocater(locater);\n }\n\n /** Get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.\n */\n public getSchema(schemaName: string): Schema {\n const schema = this.tryGetSchema(schemaName);\n if (!schema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\n\n return schema;\n }\n\n /** Attempts to get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public tryGetSchema(schemaName: string): Schema | undefined {\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n\n /** Gets the SchemaContext used by the loader. */\n public get context(): SchemaContext {\n return this._context;\n }\n}\n"]}
@@ -7,11 +7,14 @@ import { SchemaPropsGetter } from "./SchemaJsonLocater";
7
7
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
8
8
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
9
9
  *
10
+ * Since the development of this class, the IModelDb class has been enhanced to include a schema context.
11
+ * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
12
+ *
10
13
  * ** Example **
11
14
  * ```ts
12
15
  * [[include:IModelSchemas.loadFromDb]]
13
16
  * ```
14
- * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
17
+ * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
15
18
  */
16
19
  export declare class SchemaLoader {
17
20
  private _context;
@@ -1 +1 @@
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,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ5C;;;OAGG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAO3D,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
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;;;;;;;;;;;;;;GAcG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAgB;gBAEb,SAAS,EAAE,iBAAiB;IAM/C;;;OAGG;IACI,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAQ5C;;;OAGG;IACI,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAO3D,iDAAiD;IACjD,IAAW,OAAO,IAAI,aAAa,CAElC;CACF"}
@@ -13,11 +13,14 @@ import { ECVersion, SchemaKey } from "./SchemaKey";
13
13
  * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]
14
14
  * is a possibility, thereby avoiding unnecessary schema retrievals from the function.
15
15
  *
16
+ * Since the development of this class, the IModelDb class has been enhanced to include a schema context.
17
+ * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.
18
+ *
16
19
  * ** Example **
17
20
  * ```ts
18
21
  * [[include:IModelSchemas.loadFromDb]]
19
22
  * ```
20
- * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?
23
+ * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.
21
24
  */
22
25
  export class SchemaLoader {
23
26
  _context;
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,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 { SchemaContext } from \"./Context\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\n\n/**\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\n *\n * ** Example **\n * ```ts\n * [[include:IModelSchemas.loadFromDb]]\n * ```\n * @beta Is this concept needed no that backend and frontend will have contexts cached on the iModel?\n */\nexport class SchemaLoader {\n private _context: SchemaContext;\n\n public constructor(getSchema: SchemaPropsGetter) {\n this._context = new SchemaContext();\n const locater = new SchemaJsonLocater(getSchema);\n this._context.addLocater(locater);\n }\n\n /** Get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.\n */\n public getSchema(schemaName: string): Schema {\n const schema = this.tryGetSchema(schemaName);\n if (!schema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\n\n return schema;\n }\n\n /** Attempts to get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public tryGetSchema(schemaName: string): Schema | undefined {\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n\n /** Gets the SchemaContext used by the loader. */\n public get context(): SchemaContext {\n return this._context;\n }\n}\n"]}
1
+ {"version":3,"file":"SchemaLoader.js","sourceRoot":"","sources":["../../src/SchemaLoader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,YAAY;IACf,QAAQ,CAAgB;IAEhC,YAAmB,SAA4B;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,UAAkB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/F,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,UAAkB;QACpC,gGAAgG;QAChG,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iDAAiD;IACjD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,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 { SchemaContext } from \"./Context\";\nimport { SchemaMatchType } from \"./ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"./Exception\";\nimport { Schema } from \"./Metadata/Schema\";\nimport { SchemaJsonLocater, SchemaPropsGetter } from \"./SchemaJsonLocater\";\nimport { ECVersion, SchemaKey } from \"./SchemaKey\";\n\n/**\n * A utility class for loading EC Schema objects using a function that returns schema json for a given schema name.\n * Loaded schemas are held in memory within a schema context managed by SchemaLoader.\n * The SchemaLoader object should be held in memory if multiple calls to [[getSchema]] or [[tryGetSchema]]\n * is a possibility, thereby avoiding unnecessary schema retrievals from the function.\n *\n * Since the development of this class, the IModelDb class has been enhanced to include a schema context.\n * In most cases, that is sufficient so a SchemaLoader is not needed. This class is likely to be removed in the future.\n *\n * ** Example **\n * ```ts\n * [[include:IModelSchemas.loadFromDb]]\n * ```\n * @beta This will no longer be needed as of 5.0.0 since IModelDb now has a schema context.\n */\nexport class SchemaLoader {\n private _context: SchemaContext;\n\n public constructor(getSchema: SchemaPropsGetter) {\n this._context = new SchemaContext();\n const locater = new SchemaJsonLocater(getSchema);\n this._context.addLocater(locater);\n }\n\n /** Get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema is not found or cannot be loaded.\n */\n public getSchema(schemaName: string): Schema {\n const schema = this.tryGetSchema(schemaName);\n if (!schema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `reading schema=${schemaName}`);\n\n return schema;\n }\n\n /** Attempts to get a schema by name\n * @param schemaName a string with the name of the schema to load.\n * @throws [ECSchemaError]($ecschema-metadata) if the schema exists, but cannot be loaded.\n */\n public tryGetSchema(schemaName: string): Schema | undefined {\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n\n /** Gets the SchemaContext used by the loader. */\n public get context(): SchemaContext {\n return this._context;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-metadata",
3
- "version": "5.1.0-dev.12",
3
+ "version": "5.1.0-dev.13",
4
4
  "description": "ECObjects core concepts in typescript",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-metadata.js",
@@ -44,13 +44,13 @@
44
44
  "rimraf": "^6.0.1",
45
45
  "sinon": "^17.0.2",
46
46
  "typescript": "~5.6.2",
47
- "@itwin/build-tools": "5.1.0-dev.12",
48
- "@itwin/core-bentley": "5.1.0-dev.12",
49
- "@itwin/core-quantity": "5.1.0-dev.12"
47
+ "@itwin/build-tools": "5.1.0-dev.13",
48
+ "@itwin/core-bentley": "5.1.0-dev.13",
49
+ "@itwin/core-quantity": "5.1.0-dev.13"
50
50
  },
51
51
  "peerDependencies": {
52
- "@itwin/core-bentley": "5.1.0-dev.12",
53
- "@itwin/core-quantity": "5.1.0-dev.12"
52
+ "@itwin/core-bentley": "5.1.0-dev.13",
53
+ "@itwin/core-quantity": "5.1.0-dev.13"
54
54
  },
55
55
  "nyc": {
56
56
  "extends": "./node_modules/@itwin/build-tools/.nycrc"