@itwin/ecschema-rpcinterface-common 4.0.0-dev.22 → 4.0.0-dev.23

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,35 +1,35 @@
1
- import { IModelRpcProps, RpcInterface } from "@itwin/core-common";
2
- import { SchemaKeyProps, SchemaProps } from "@itwin/ecschema-metadata";
3
- /***
4
- * Defines an RPC interface to get schema information from a given iModel context.
5
- * Method @see getSchemaNames will return the names of schemas that live in this iModel.
6
- * The actual schemas can be downloaded using @see getSchemaJSON to get the schema as JSON props.
7
- * @internal
8
- */
9
- export declare abstract class ECSchemaRpcInterface extends RpcInterface {
10
- /** The version of the RPC Interface. */
11
- static version: string;
12
- static readonly interfaceName = "ECSchemaRpcInterface";
13
- static interfaceVersion: string;
14
- /**
15
- * Returns the RPC client instance for the frontend.
16
- * @returns A client to communicate with the RPC Interface.
17
- */
18
- static getClient(): ECSchemaRpcInterface;
19
- /**
20
- * Returns an array of SchemaKeyProps that exists in the current iModel context. The client can call
21
- * SchemaKey.fromJson() to parse the props to a SchemaKey.
22
- * @param tokenProps The iModelToken props that hold the information which iModel is used.
23
- * @returns An array of SchemaKeyProps.
24
- */
25
- getSchemaKeys(_tokenProps: IModelRpcProps): Promise<SchemaKeyProps[]>;
26
- /**
27
- * Gets the schema JSON for the current iModel context and returns the schema as a SchemaProps which
28
- * the client can call Schema.fromJson() to return a Schema.
29
- * @param tokenProps The iModelToken props that hold the information which iModel is used.
30
- * @param schemaName The name of the schema that shall be returned.
31
- * @returns The SchemaProps.
32
- */
33
- getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps>;
34
- }
1
+ import { IModelRpcProps, RpcInterface } from "@itwin/core-common";
2
+ import { SchemaKeyProps, SchemaProps } from "@itwin/ecschema-metadata";
3
+ /***
4
+ * Defines an RPC interface to get schema information from a given iModel context.
5
+ * Method @see getSchemaNames will return the names of schemas that live in this iModel.
6
+ * The actual schemas can be downloaded using @see getSchemaJSON to get the schema as JSON props.
7
+ * @internal
8
+ */
9
+ export declare abstract class ECSchemaRpcInterface extends RpcInterface {
10
+ /** The version of the RPC Interface. */
11
+ static version: string;
12
+ static readonly interfaceName = "ECSchemaRpcInterface";
13
+ static interfaceVersion: string;
14
+ /**
15
+ * Returns the RPC client instance for the frontend.
16
+ * @returns A client to communicate with the RPC Interface.
17
+ */
18
+ static getClient(): ECSchemaRpcInterface;
19
+ /**
20
+ * Returns an array of SchemaKeyProps that exists in the current iModel context. The client can call
21
+ * SchemaKey.fromJson() to parse the props to a SchemaKey.
22
+ * @param tokenProps The iModelToken props that hold the information which iModel is used.
23
+ * @returns An array of SchemaKeyProps.
24
+ */
25
+ getSchemaKeys(_tokenProps: IModelRpcProps): Promise<SchemaKeyProps[]>;
26
+ /**
27
+ * Gets the schema JSON for the current iModel context and returns the schema as a SchemaProps which
28
+ * the client can call Schema.fromJson() to return a Schema.
29
+ * @param tokenProps The iModelToken props that hold the information which iModel is used.
30
+ * @param schemaName The name of the schema that shall be returned.
31
+ * @returns The SchemaProps.
32
+ */
33
+ getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps>;
34
+ }
35
35
  //# sourceMappingURL=ECSchemaRpcInterface.d.ts.map
@@ -1,57 +1,57 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ECSchemaRpcInterface = void 0;
10
- /*---------------------------------------------------------------------------------------------
11
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
12
- * See LICENSE.md in the project root for license terms and full copyright notice.
13
- *--------------------------------------------------------------------------------------------*/
14
- const core_common_1 = require("@itwin/core-common");
15
- /***
16
- * Defines an RPC interface to get schema information from a given iModel context.
17
- * Method @see getSchemaNames will return the names of schemas that live in this iModel.
18
- * The actual schemas can be downloaded using @see getSchemaJSON to get the schema as JSON props.
19
- * @internal
20
- */
21
- class ECSchemaRpcInterface extends core_common_1.RpcInterface {
22
- /**
23
- * Returns the RPC client instance for the frontend.
24
- * @returns A client to communicate with the RPC Interface.
25
- */
26
- static getClient() {
27
- return core_common_1.RpcManager.getClientForInterface(ECSchemaRpcInterface);
28
- }
29
- /**
30
- * Returns an array of SchemaKeyProps that exists in the current iModel context. The client can call
31
- * SchemaKey.fromJson() to parse the props to a SchemaKey.
32
- * @param tokenProps The iModelToken props that hold the information which iModel is used.
33
- * @returns An array of SchemaKeyProps.
34
- */
35
- async getSchemaKeys(_tokenProps) {
36
- return this.forward.apply(this, [arguments]);
37
- }
38
- /**
39
- * Gets the schema JSON for the current iModel context and returns the schema as a SchemaProps which
40
- * the client can call Schema.fromJson() to return a Schema.
41
- * @param tokenProps The iModelToken props that hold the information which iModel is used.
42
- * @param schemaName The name of the schema that shall be returned.
43
- * @returns The SchemaProps.
44
- */
45
- async getSchemaJSON(_tokenProps, _schemaName) {
46
- return this.forward.apply(this, [arguments]);
47
- }
48
- }
49
- /** The version of the RPC Interface. */
50
- ECSchemaRpcInterface.version = "2.0.0";
51
- ECSchemaRpcInterface.interfaceName = "ECSchemaRpcInterface";
52
- ECSchemaRpcInterface.interfaceVersion = ECSchemaRpcInterface.version;
53
- __decorate([
54
- core_common_1.RpcOperation.setPolicy({ allowResponseCompression: true })
55
- ], ECSchemaRpcInterface.prototype, "getSchemaJSON", null);
56
- exports.ECSchemaRpcInterface = ECSchemaRpcInterface;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ECSchemaRpcInterface = void 0;
10
+ /*---------------------------------------------------------------------------------------------
11
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
12
+ * See LICENSE.md in the project root for license terms and full copyright notice.
13
+ *--------------------------------------------------------------------------------------------*/
14
+ const core_common_1 = require("@itwin/core-common");
15
+ /***
16
+ * Defines an RPC interface to get schema information from a given iModel context.
17
+ * Method @see getSchemaNames will return the names of schemas that live in this iModel.
18
+ * The actual schemas can be downloaded using @see getSchemaJSON to get the schema as JSON props.
19
+ * @internal
20
+ */
21
+ class ECSchemaRpcInterface extends core_common_1.RpcInterface {
22
+ /**
23
+ * Returns the RPC client instance for the frontend.
24
+ * @returns A client to communicate with the RPC Interface.
25
+ */
26
+ static getClient() {
27
+ return core_common_1.RpcManager.getClientForInterface(ECSchemaRpcInterface);
28
+ }
29
+ /**
30
+ * Returns an array of SchemaKeyProps that exists in the current iModel context. The client can call
31
+ * SchemaKey.fromJson() to parse the props to a SchemaKey.
32
+ * @param tokenProps The iModelToken props that hold the information which iModel is used.
33
+ * @returns An array of SchemaKeyProps.
34
+ */
35
+ async getSchemaKeys(_tokenProps) {
36
+ return this.forward.apply(this, [arguments]);
37
+ }
38
+ /**
39
+ * Gets the schema JSON for the current iModel context and returns the schema as a SchemaProps which
40
+ * the client can call Schema.fromJson() to return a Schema.
41
+ * @param tokenProps The iModelToken props that hold the information which iModel is used.
42
+ * @param schemaName The name of the schema that shall be returned.
43
+ * @returns The SchemaProps.
44
+ */
45
+ async getSchemaJSON(_tokenProps, _schemaName) {
46
+ return this.forward.apply(this, [arguments]);
47
+ }
48
+ }
49
+ /** The version of the RPC Interface. */
50
+ ECSchemaRpcInterface.version = "2.0.0";
51
+ ECSchemaRpcInterface.interfaceName = "ECSchemaRpcInterface";
52
+ ECSchemaRpcInterface.interfaceVersion = ECSchemaRpcInterface.version;
53
+ __decorate([
54
+ core_common_1.RpcOperation.setPolicy({ allowResponseCompression: true })
55
+ ], ECSchemaRpcInterface.prototype, "getSchemaJSON", null);
56
+ exports.ECSchemaRpcInterface = ECSchemaRpcInterface;
57
57
  //# sourceMappingURL=ECSchemaRpcInterface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcInterface.js","sourceRoot":"","sources":["../../src/ECSchemaRpcInterface.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;+FAG+F;AAC/F,oDAA4F;AAG5F;;;;;GAKG;AACH,MAAsB,oBAAqB,SAAQ,0BAAY;IAO7D;;;OAGG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,wBAAU,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CAAC,WAA2B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAA8B,CAAC;IAC5E,CAAC;IAED;;;;;;OAMG;IAEI,KAAK,CAAC,aAAa,CAAC,WAA2B,EAAE,WAAmB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAyB,CAAC;IACvE,CAAC;;AAlCD,wCAAwC;AAC1B,4BAAO,GAAG,OAAO,CAAC;AAET,kCAAa,GAAG,sBAAsB,CAAC;AAChD,qCAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;AA4B9D;IADC,0BAAY,CAAC,SAAS,CAAC,EAAE,wBAAwB,EAAE,IAAI,EAAE,CAAC;yDAG1D;AAnCH,oDAqCC","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 { IModelRpcProps, RpcInterface, RpcManager, RpcOperation } from \"@itwin/core-common\";\r\nimport { SchemaKeyProps, SchemaProps } from \"@itwin/ecschema-metadata\";\r\n\r\n/***\r\n * Defines an RPC interface to get schema information from a given iModel context.\r\n * Method @see getSchemaNames will return the names of schemas that live in this iModel.\r\n * The actual schemas can be downloaded using @see getSchemaJSON to get the schema as JSON props.\r\n * @internal\r\n */\r\nexport abstract class ECSchemaRpcInterface extends RpcInterface { // eslint-disable-line deprecation/deprecation\r\n /** The version of the RPC Interface. */\r\n public static version = \"2.0.0\";\r\n\r\n public static readonly interfaceName = \"ECSchemaRpcInterface\";\r\n public static interfaceVersion = ECSchemaRpcInterface.version;\r\n\r\n /**\r\n * Returns the RPC client instance for the frontend.\r\n * @returns A client to communicate with the RPC Interface.\r\n */\r\n public static getClient(): ECSchemaRpcInterface {\r\n return RpcManager.getClientForInterface(ECSchemaRpcInterface);\r\n }\r\n\r\n /**\r\n * Returns an array of SchemaKeyProps that exists in the current iModel context. The client can call\r\n * SchemaKey.fromJson() to parse the props to a SchemaKey.\r\n * @param tokenProps The iModelToken props that hold the information which iModel is used.\r\n * @returns An array of SchemaKeyProps.\r\n */\r\n public async getSchemaKeys(_tokenProps: IModelRpcProps): Promise<SchemaKeyProps[]> {\r\n return this.forward.apply(this, [arguments]) as Promise<SchemaKeyProps[]>;\r\n }\r\n\r\n /**\r\n * Gets the schema JSON for the current iModel context and returns the schema as a SchemaProps which\r\n * the client can call Schema.fromJson() to return a Schema.\r\n * @param tokenProps The iModelToken props that hold the information which iModel is used.\r\n * @param schemaName The name of the schema that shall be returned.\r\n * @returns The SchemaProps.\r\n */\r\n @RpcOperation.setPolicy({ allowResponseCompression: true })\r\n public async getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps> {\r\n return this.forward.apply(this, [arguments]) as Promise<SchemaProps>;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"ECSchemaRpcInterface.js","sourceRoot":"","sources":["../../src/ECSchemaRpcInterface.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;+FAG+F;AAC/F,oDAA4F;AAG5F;;;;;GAKG;AACH,MAAsB,oBAAqB,SAAQ,0BAAY;IAO7D;;;OAGG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,wBAAU,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CAAC,WAA2B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAA8B,CAAC;IAC5E,CAAC;IAED;;;;;;OAMG;IAEI,KAAK,CAAC,aAAa,CAAC,WAA2B,EAAE,WAAmB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAyB,CAAC;IACvE,CAAC;;AAlCD,wCAAwC;AAC1B,4BAAO,GAAG,OAAO,CAAC;AAET,kCAAa,GAAG,sBAAsB,CAAC;AAChD,qCAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;AA4B9D;IADC,0BAAY,CAAC,SAAS,CAAC,EAAE,wBAAwB,EAAE,IAAI,EAAE,CAAC;yDAG1D;AAnCH,oDAqCC","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 { IModelRpcProps, RpcInterface, RpcManager, RpcOperation } from \"@itwin/core-common\";\nimport { SchemaKeyProps, SchemaProps } from \"@itwin/ecschema-metadata\";\n\n/***\n * Defines an RPC interface to get schema information from a given iModel context.\n * Method @see getSchemaNames will return the names of schemas that live in this iModel.\n * The actual schemas can be downloaded using @see getSchemaJSON to get the schema as JSON props.\n * @internal\n */\nexport abstract class ECSchemaRpcInterface extends RpcInterface { // eslint-disable-line deprecation/deprecation\n /** The version of the RPC Interface. */\n public static version = \"2.0.0\";\n\n public static readonly interfaceName = \"ECSchemaRpcInterface\";\n public static interfaceVersion = ECSchemaRpcInterface.version;\n\n /**\n * Returns the RPC client instance for the frontend.\n * @returns A client to communicate with the RPC Interface.\n */\n public static getClient(): ECSchemaRpcInterface {\n return RpcManager.getClientForInterface(ECSchemaRpcInterface);\n }\n\n /**\n * Returns an array of SchemaKeyProps that exists in the current iModel context. The client can call\n * SchemaKey.fromJson() to parse the props to a SchemaKey.\n * @param tokenProps The iModelToken props that hold the information which iModel is used.\n * @returns An array of SchemaKeyProps.\n */\n public async getSchemaKeys(_tokenProps: IModelRpcProps): Promise<SchemaKeyProps[]> {\n return this.forward.apply(this, [arguments]) as Promise<SchemaKeyProps[]>;\n }\n\n /**\n * Gets the schema JSON for the current iModel context and returns the schema as a SchemaProps which\n * the client can call Schema.fromJson() to return a Schema.\n * @param tokenProps The iModelToken props that hold the information which iModel is used.\n * @param schemaName The name of the schema that shall be returned.\n * @returns The SchemaProps.\n */\n @RpcOperation.setPolicy({ allowResponseCompression: true })\n public async getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps> {\n return this.forward.apply(this, [arguments]) as Promise<SchemaProps>;\n }\n\n}\n"]}
@@ -1,25 +1,25 @@
1
- import { ISchemaLocater, Schema, SchemaContext, SchemaKey, SchemaMatchType } from "@itwin/ecschema-metadata";
2
- import { IModelRpcProps } from "@itwin/core-common";
3
- /**
4
- * Defines a schema locater that retrieves schemas using an RPC interface.
5
- * @alpha
6
- */
7
- export declare class ECSchemaRpcLocater implements ISchemaLocater {
8
- readonly token: IModelRpcProps;
9
- constructor(token: IModelRpcProps);
10
- /**
11
- * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
12
- * @param schemaKey Key to look up
13
- * @param matchType How to match key against candidate schemas
14
- * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
15
- */
16
- getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;
17
- /**
18
- * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
19
- * @param schemaKey Key to look up
20
- * @param matchType How to match key against candidate schemas
21
- * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
22
- */
23
- getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined;
24
- }
1
+ import { ISchemaLocater, Schema, SchemaContext, SchemaKey, SchemaMatchType } from "@itwin/ecschema-metadata";
2
+ import { IModelRpcProps } from "@itwin/core-common";
3
+ /**
4
+ * Defines a schema locater that retrieves schemas using an RPC interface.
5
+ * @alpha
6
+ */
7
+ export declare class ECSchemaRpcLocater implements ISchemaLocater {
8
+ readonly token: IModelRpcProps;
9
+ constructor(token: IModelRpcProps);
10
+ /**
11
+ * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
12
+ * @param schemaKey Key to look up
13
+ * @param matchType How to match key against candidate schemas
14
+ * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
15
+ */
16
+ getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;
17
+ /**
18
+ * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
19
+ * @param schemaKey Key to look up
20
+ * @param matchType How to match key against candidate schemas
21
+ * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
22
+ */
23
+ getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined;
24
+ }
25
25
  //# sourceMappingURL=ECSchemaRpcLocater.d.ts.map
@@ -1,48 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ECSchemaRpcLocater = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
- const ECSchemaRpcInterface_1 = require("./ECSchemaRpcInterface");
10
- /**
11
- * Defines a schema locater that retrieves schemas using an RPC interface.
12
- * @alpha
13
- */
14
- class ECSchemaRpcLocater {
15
- constructor(token) { this.token = token; }
16
- /**
17
- * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
18
- * @param schemaKey Key to look up
19
- * @param matchType How to match key against candidate schemas
20
- * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
21
- */
22
- async getSchema(schemaKey, matchType, context) {
23
- 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;
27
- }
28
- return undefined;
29
- }
30
- /**
31
- * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
32
- * @param schemaKey Key to look up
33
- * @param matchType How to match key against candidate schemas
34
- * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
35
- */
36
- getSchemaSync(schemaKey, matchType, context) {
37
- const schemaJson = ECSchemaRpcInterface_1.ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name).then((props) => {
38
- return props;
39
- });
40
- const schema = ecschema_metadata_1.Schema.fromJsonSync(schemaJson, context || new ecschema_metadata_1.SchemaContext());
41
- if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {
42
- return schema;
43
- }
44
- return undefined;
45
- }
46
- }
47
- exports.ECSchemaRpcLocater = ECSchemaRpcLocater;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ECSchemaRpcLocater = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
9
+ const ECSchemaRpcInterface_1 = require("./ECSchemaRpcInterface");
10
+ /**
11
+ * Defines a schema locater that retrieves schemas using an RPC interface.
12
+ * @alpha
13
+ */
14
+ class ECSchemaRpcLocater {
15
+ constructor(token) { this.token = token; }
16
+ /**
17
+ * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
18
+ * @param schemaKey Key to look up
19
+ * @param matchType How to match key against candidate schemas
20
+ * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
21
+ */
22
+ async getSchema(schemaKey, matchType, context) {
23
+ 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;
27
+ }
28
+ return undefined;
29
+ }
30
+ /**
31
+ * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.
32
+ * @param schemaKey Key to look up
33
+ * @param matchType How to match key against candidate schemas
34
+ * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
35
+ */
36
+ getSchemaSync(schemaKey, matchType, context) {
37
+ const schemaJson = ECSchemaRpcInterface_1.ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name).then((props) => {
38
+ return props;
39
+ });
40
+ const schema = ecschema_metadata_1.Schema.fromJsonSync(schemaJson, context || new ecschema_metadata_1.SchemaContext());
41
+ if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {
42
+ return schema;
43
+ }
44
+ return undefined;
45
+ }
46
+ }
47
+ exports.ECSchemaRpcLocater = ECSchemaRpcLocater;
48
48
  //# sourceMappingURL=ECSchemaRpcLocater.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcLocater.js","sourceRoot":"","sources":["../../src/ECSchemaRpcLocater.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAA0H;AAE1H,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,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC/G,MAAM,UAAU,GAAG,MAAM,2CAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACpG,MAAM,MAAM,GAAG,MAAM,0BAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,IAAI,IAAI,iCAAa,EAAE,CAAC,CAAC;QACjF,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;IAED;;;;;MAKE;IACK,aAAa,CAAmB,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7G,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;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,gEAA0H;AAE1H,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,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC/G,MAAM,UAAU,GAAG,MAAM,2CAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACpG,MAAM,MAAM,GAAG,MAAM,0BAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,IAAI,IAAI,iCAAa,EAAE,CAAC,CAAC;QACjF,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;IAED;;;;;MAKE;IACK,aAAa,CAAmB,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7G,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;AApCD,gDAoCC","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, Schema, SchemaContext, SchemaKey, SchemaMatchType, SchemaProps } from \"@itwin/ecschema-metadata\";\nimport { IModelRpcProps } from \"@itwin/core-common\";\nimport { ECSchemaRpcInterface } from \"./ECSchemaRpcInterface\";\n\n/**\n * Defines a schema locater that retrieves schemas using an RPC interface.\n * @alpha\n */\nexport class ECSchemaRpcLocater implements ISchemaLocater {\n public readonly token: IModelRpcProps;\n\n constructor(token: IModelRpcProps) { this.token = token; }\n\n /**\n * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.\n * @param schemaKey Key to look up\n * @param matchType How to match key against candidate schemas\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\n */\n public async getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\n const schemaJson = await ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);\n const schema = await Schema.fromJson(schemaJson, context || new SchemaContext());\n if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {\n return schema as T;\n }\n return undefined;\n }\n\n /**\n * Attempts to get a schema from the schema rpc locater. Yields undefined if no matching schema is found.\n * @param schemaKey Key to look up\n * @param matchType How to match key against candidate schemas\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\n */\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined {\n const schemaJson = ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name).then((props: SchemaProps) => {\n return props;\n });\n const schema = Schema.fromJsonSync(schemaJson, context || new SchemaContext());\n if (schema !== undefined && schema.schemaKey.matches(schemaKey, matchType)) {\n return schema as T;\n }\n return undefined;\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- export * from "./ECSchemaRpcInterface";
2
- export * from "./ECSchemaRpcLocater";
1
+ export * from "./ECSchemaRpcInterface";
2
+ export * from "./ECSchemaRpcLocater";
3
3
  //# sourceMappingURL=ecschema-rpc-interface.d.ts.map
@@ -1,19 +1,19 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- /*---------------------------------------------------------------------------------------------
14
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
15
- * See LICENSE.md in the project root for license terms and full copyright notice.
16
- *--------------------------------------------------------------------------------------------*/
17
- __exportStar(require("./ECSchemaRpcInterface"), exports);
18
- __exportStar(require("./ECSchemaRpcLocater"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ /*---------------------------------------------------------------------------------------------
14
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
15
+ * See LICENSE.md in the project root for license terms and full copyright notice.
16
+ *--------------------------------------------------------------------------------------------*/
17
+ __exportStar(require("./ECSchemaRpcInterface"), exports);
18
+ __exportStar(require("./ECSchemaRpcLocater"), exports);
19
19
  //# sourceMappingURL=ecschema-rpc-interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ecschema-rpc-interface.js","sourceRoot":"","sources":["../../src/ecschema-rpc-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,yDAAuC;AACvC,uDAAqC","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\nexport * from \"./ECSchemaRpcInterface\";\r\nexport * from \"./ECSchemaRpcLocater\";\r\n"]}
1
+ {"version":3,"file":"ecschema-rpc-interface.js","sourceRoot":"","sources":["../../src/ecschema-rpc-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,yDAAuC;AACvC,uDAAqC","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./ECSchemaRpcInterface\";\nexport * from \"./ECSchemaRpcLocater\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-rpcinterface-common",
3
- "version": "4.0.0-dev.22",
3
+ "version": "4.0.0-dev.23",
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",
@@ -20,18 +20,18 @@
20
20
  "url": "http://www.bentley.com"
21
21
  },
22
22
  "peerDependencies": {
23
- "@itwin/core-bentley": "4.0.0-dev.22",
24
- "@itwin/core-common": "4.0.0-dev.22",
25
- "@itwin/core-geometry": "4.0.0-dev.22",
26
- "@itwin/ecschema-metadata": "4.0.0-dev.22"
23
+ "@itwin/core-bentley": "4.0.0-dev.23",
24
+ "@itwin/core-common": "4.0.0-dev.23",
25
+ "@itwin/core-geometry": "4.0.0-dev.23",
26
+ "@itwin/ecschema-metadata": "4.0.0-dev.23"
27
27
  },
28
28
  "devDependencies": {
29
- "@itwin/build-tools": "4.0.0-dev.22",
30
- "@itwin/core-bentley": "4.0.0-dev.22",
31
- "@itwin/core-common": "4.0.0-dev.22",
32
- "@itwin/core-geometry": "4.0.0-dev.22",
33
- "@itwin/ecschema-metadata": "4.0.0-dev.22",
34
- "@itwin/eslint-plugin": "4.0.0-dev.22",
29
+ "@itwin/build-tools": "4.0.0-dev.23",
30
+ "@itwin/core-bentley": "4.0.0-dev.23",
31
+ "@itwin/core-common": "4.0.0-dev.23",
32
+ "@itwin/core-geometry": "4.0.0-dev.23",
33
+ "@itwin/ecschema-metadata": "4.0.0-dev.23",
34
+ "@itwin/eslint-plugin": "4.0.0-dev.23",
35
35
  "eslint": "^7.11.0",
36
36
  "rimraf": "^3.0.2",
37
37
  "typescript": "~4.4.0"