@itwin/ecschema-metadata 4.7.0-dev.15 → 4.7.0-dev.17

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.
@@ -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,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAIpJ;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAI/I;;;;;OAKG;IACI,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS;CAS3I"}
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,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAKpJ;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAY/I;;;;;OAKG;IACI,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS;CAS3I"}
@@ -23,7 +23,8 @@ class SchemaJsonLocater {
23
23
  * @throws [ECObjectsError]($ecschema-metadata) if the schema exists, but cannot be loaded.
24
24
  */
25
25
  async getSchema(schemaKey, matchType, context) {
26
- return this.getSchemaSync(schemaKey, matchType, context);
26
+ await this.getSchemaInfo(schemaKey, matchType, context);
27
+ return await context.getCachedSchema(schemaKey, matchType);
27
28
  }
28
29
  /**
29
30
  * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
@@ -31,7 +32,13 @@ class SchemaJsonLocater {
31
32
  * @param matchType The match type to use when locating the schema
32
33
  */
33
34
  async getSchemaInfo(schemaKey, matchType, context) {
34
- return this.getSchema(schemaKey, matchType, context);
35
+ const schemaProps = this._getSchema(schemaKey.name);
36
+ if (!schemaProps)
37
+ return undefined;
38
+ const schemaInfo = await Schema_1.Schema.startLoadingFromJson(schemaProps, context);
39
+ if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))
40
+ return schemaInfo;
41
+ return undefined;
35
42
  }
36
43
  /** Get a schema by [SchemaKey] synchronously.
37
44
  * @param schemaKey The [SchemaKey] that identifies the schema.
@@ -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 * @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
+ {"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,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,MAAM,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAM,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,aAAa,CAAC,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QAC3G,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,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;AA9CD,8CA8CC","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 await this.getSchemaInfo(schemaKey, matchType, context);\r\n return await context.getCachedSchema(schemaKey, matchType) 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 const schemaProps = this._getSchema(schemaKey.name);\r\n if (!schemaProps)\r\n return undefined;\r\n\r\n const schemaInfo = await Schema.startLoadingFromJson(schemaProps, context);\r\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType))\r\n return schemaInfo;\r\n\r\n return undefined;\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-metadata",
3
- "version": "4.7.0-dev.15",
3
+ "version": "4.7.0-dev.17",
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": "^17.0.1",
44
44
  "typescript": "~5.3.3",
45
- "@itwin/build-tools": "4.7.0-dev.15",
46
- "@itwin/core-bentley": "4.7.0-dev.15",
47
- "@itwin/core-quantity": "4.7.0-dev.15"
45
+ "@itwin/build-tools": "4.7.0-dev.17",
46
+ "@itwin/core-bentley": "4.7.0-dev.17",
47
+ "@itwin/core-quantity": "4.7.0-dev.17"
48
48
  },
49
49
  "peerDependencies": {
50
- "@itwin/core-bentley": "^4.7.0-dev.15",
51
- "@itwin/core-quantity": "^4.7.0-dev.15"
50
+ "@itwin/core-bentley": "^4.7.0-dev.17",
51
+ "@itwin/core-quantity": "^4.7.0-dev.17"
52
52
  },
53
53
  "dependencies": {
54
54
  "almost-equal": "^1.1.0"