@itwin/ecschema-rpcinterface-common 4.0.0-dev.99 → 4.1.0-dev.11

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,4 +1,4 @@
1
- import { ISchemaLocater, Schema, SchemaContext, SchemaKey, SchemaMatchType } from "@itwin/ecschema-metadata";
1
+ import { ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType } from "@itwin/ecschema-metadata";
2
2
  import { IModelRpcProps } from "@itwin/core-common";
3
3
  /**
4
4
  * Defines a schema locater that retrieves schemas using an RPC interface.
@@ -13,13 +13,20 @@ export declare class ECSchemaRpcLocater implements ISchemaLocater {
13
13
  * @param matchType How to match key against candidate schemas
14
14
  * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
15
15
  */
16
- getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;
16
+ getSchema<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;
17
+ /**
18
+ * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
19
+ * The fully loaded schema can be accessed via the schema context using the getCachedSchema method.
20
+ * @param schemaKey The SchemaKey describing the schema to get from the cache.
21
+ * @param matchType The match type to use when locating the schema
22
+ */
23
+ getSchemaInfo(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined>;
17
24
  /**
18
25
  * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
19
26
  * @param schemaKey Key to look up
20
27
  * @param matchType How to match key against candidate schemas
21
28
  * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
22
29
  */
23
- getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined;
30
+ getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): T | undefined;
24
31
  }
25
32
  //# sourceMappingURL=ECSchemaRpcLocater.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcLocater.d.ts","sourceRoot":"","sources":["../../src/ECSchemaRpcLocater.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAe,MAAM,0BAA0B,CAAC;AAC1H,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACvD,SAAgB,KAAK,EAAE,cAAc,CAAC;gBAE1B,KAAK,EAAE,cAAc;IAEjC;;;;;MAKE;IACW,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAS1I;;;;;MAKE;IACK,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS;CAUhI"}
1
+ {"version":3,"file":"ECSchemaRpcLocater.d.ts","sourceRoot":"","sources":["../../src/ECSchemaRpcLocater.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAe,MAAM,0BAA0B,CAAC;AACtI,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IACvD,SAAgB,KAAK,EAAE,cAAc,CAAC;gBAE1B,KAAK,EAAE,cAAc;IAEjC;;;;;MAKE;IACW,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;IAOpJ;;;;;QAKI;IACS,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAS/I;;;;;MAKE;IACK,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,CAAC,GAAG,SAAS;CAU1I"}
@@ -20,10 +20,21 @@ class ECSchemaRpcLocater {
20
20
  * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
21
21
  */
22
22
  async getSchema(schemaKey, matchType, context) {
23
+ await this.getSchemaInfo(schemaKey, matchType, context);
24
+ const schema = await context.getCachedSchema(schemaKey, matchType);
25
+ return schema;
26
+ }
27
+ /**
28
+ * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
29
+ * The fully loaded schema can be accessed via the schema context using the getCachedSchema method.
30
+ * @param schemaKey The SchemaKey describing the schema to get from the cache.
31
+ * @param matchType The match type to use when locating the schema
32
+ */
33
+ async getSchemaInfo(schemaKey, matchType, context) {
23
34
  const schemaJson = await ECSchemaRpcInterface_1.ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);
24
- const schema = await ecschema_metadata_1.Schema.fromJson(schemaJson, context || new ecschema_metadata_1.SchemaContext());
25
- if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {
26
- return schema;
35
+ const schemaInfo = await ecschema_metadata_1.Schema.startLoadingFromJson(schemaJson, context || new ecschema_metadata_1.SchemaContext());
36
+ if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType)) {
37
+ return schemaInfo;
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AAC,SAAS,EAAE,SAAS,CAAC,EAAE;YAC1E,OAAO,MAAW,CAAC;SACpB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AApCD,gDAoCC","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\nimport { ISchemaLocater, Schema, SchemaContext, SchemaKey, SchemaMatchType, SchemaProps } from \"@itwin/ecschema-metadata\";\r\nimport { IModelRpcProps } from \"@itwin/core-common\";\r\nimport { ECSchemaRpcInterface } from \"./ECSchemaRpcInterface\";\r\n\r\n/**\r\n * Defines a schema locater that retrieves schemas using an RPC interface.\r\n * @alpha\r\n */\r\nexport class ECSchemaRpcLocater implements ISchemaLocater {\r\n public readonly token: IModelRpcProps;\r\n\r\n constructor(token: IModelRpcProps) { this.token = token; }\r\n\r\n /**\r\n * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.\r\n * @param schemaKey Key to look up\r\n * @param matchType How to match key against candidate schemas\r\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\r\n const schemaJson = await ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);\r\n const schema = await Schema.fromJson(schemaJson, context || new SchemaContext());\r\n if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {\r\n return schema as T;\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.\r\n * @param schemaKey Key to look up\r\n * @param matchType How to match key against candidate schemas\r\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const schemaJson = ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name).then((props: SchemaProps) => {\r\n return props;\r\n });\r\n const schema = Schema.fromJsonSync(schemaJson, context || new SchemaContext());\r\n if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {\r\n return schema as T;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ECSchemaRpcLocater.js","sourceRoot":"","sources":["../../src/ECSchemaRpcLocater.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAsI;AAEtI,iEAA8D;AAE9D;;;GAGG;AACH,MAAa,kBAAkB;IAG7B,YAAY,KAAqB,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IAE1D;;;;;MAKE;IACK,KAAK,CAAC,SAAS,CAAmB,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QACzH,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAExD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACnE,OAAO,MAAW,CAAC;IACrB,CAAC;IAED;;;;;QAKI;IACG,KAAK,CAAC,aAAa,CAAC,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QAC3G,MAAM,UAAU,GAAG,MAAM,2CAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACpG,MAAM,UAAU,GAAG,MAAM,0BAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,OAAO,IAAI,IAAI,iCAAa,EAAE,CAAC,CAAC;QACjG,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE;YAClF,OAAO,UAAU,CAAC;SACnB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;MAKE;IACK,aAAa,CAAmB,SAA8B,EAAE,SAA0B,EAAE,OAAsB;QACvH,MAAM,UAAU,GAAG,2CAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAkB,EAAE,EAAE;YACxH,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,0BAAM,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,IAAI,IAAI,iCAAa,EAAE,CAAC,CAAC;QAC/E,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE;YAC1E,OAAO,MAAW,CAAC;SACpB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAjDD,gDAiDC","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\nimport { ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType, SchemaProps } from \"@itwin/ecschema-metadata\";\r\nimport { IModelRpcProps } from \"@itwin/core-common\";\r\nimport { ECSchemaRpcInterface } from \"./ECSchemaRpcInterface\";\r\n\r\n/**\r\n * Defines a schema locater that retrieves schemas using an RPC interface.\r\n * @alpha\r\n */\r\nexport class ECSchemaRpcLocater implements ISchemaLocater {\r\n public readonly token: IModelRpcProps;\r\n\r\n constructor(token: IModelRpcProps) { this.token = token; }\r\n\r\n /**\r\n * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.\r\n * @param schemaKey Key to look up\r\n * @param matchType How to match key against candidate schemas\r\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\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\r\n const schema = await context.getCachedSchema(schemaKey, matchType);\r\n return schema 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 * The fully loaded schema can be accessed via the schema context using the getCachedSchema method.\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 schemaJson = await ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);\r\n const schemaInfo = await Schema.startLoadingFromJson(schemaJson, context || new SchemaContext());\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 /**\r\n * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.\r\n * @param schemaKey Key to look up\r\n * @param matchType How to match key against candidate schemas\r\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: Readonly<SchemaKey>, matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const schemaJson = ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name).then((props: SchemaProps) => {\r\n return props;\r\n });\r\n const schema = Schema.fromJsonSync(schemaJson, context || new SchemaContext());\r\n if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {\r\n return schema as T;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-rpcinterface-common",
3
- "version": "4.0.0-dev.99",
3
+ "version": "4.1.0-dev.11",
4
4
  "description": "Schema RPC Interface common interface",
5
5
  "main": "lib/cjs/ecschema-rpc-interface.js",
6
6
  "typings": "lib/cjs/ecschema-rpc-interface",
@@ -21,21 +21,21 @@
21
21
  "url": "http://www.bentley.com"
22
22
  },
23
23
  "peerDependencies": {
24
- "@itwin/core-bentley": "4.0.0-dev.99",
25
- "@itwin/core-common": "4.0.0-dev.99",
26
- "@itwin/core-geometry": "4.0.0-dev.99",
27
- "@itwin/ecschema-metadata": "4.0.0-dev.99"
24
+ "@itwin/core-bentley": "4.1.0-dev.11",
25
+ "@itwin/core-common": "4.1.0-dev.11",
26
+ "@itwin/core-geometry": "4.1.0-dev.11",
27
+ "@itwin/ecschema-metadata": "4.1.0-dev.11"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@itwin/eslint-plugin": "^4.0.0-dev.33",
31
31
  "eslint": "^8.36.0",
32
32
  "rimraf": "^3.0.2",
33
33
  "typescript": "~5.0.2",
34
- "@itwin/build-tools": "4.0.0-dev.99",
35
- "@itwin/core-common": "4.0.0-dev.99",
36
- "@itwin/ecschema-metadata": "4.0.0-dev.99",
37
- "@itwin/core-bentley": "4.0.0-dev.99",
38
- "@itwin/core-geometry": "4.0.0-dev.99"
34
+ "@itwin/build-tools": "4.1.0-dev.11",
35
+ "@itwin/core-bentley": "4.1.0-dev.11",
36
+ "@itwin/core-common": "4.1.0-dev.11",
37
+ "@itwin/core-geometry": "4.1.0-dev.11",
38
+ "@itwin/ecschema-metadata": "4.1.0-dev.11"
39
39
  },
40
40
  "eslintConfig": {
41
41
  "plugins": [