@itwin/ecschema-rpcinterface-common 5.5.0-dev.2 → 5.5.0-dev.5

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @itwin/ecschema-rpcinterface-common
2
2
 
3
- This log was last generated on Thu, 20 Nov 2025 22:31:49 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 02 Dec 2025 23:11:57 GMT and should not be manually modified.
4
+
5
+ ## 5.4.0
6
+ Tue, 02 Dec 2025 21:22:25 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 5.3.3
6
11
  Thu, 20 Nov 2025 22:30:37 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcInterface.js","sourceRoot":"","sources":["../../src/ECSchemaRpcInterface.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;+FAG+F;AAC/F,oDAAqH;AAGrH;;;;;GAKG;AACH,MAAsB,oBAAqB,SAAQ,0BAAY;IAC7D,wCAAwC;IACjC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IAEzB,MAAM,CAAU,aAAa,GAAG,sBAAsB,CAAC;IACvD,MAAM,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;IAE9D;;;OAGG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,wBAAU,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAA8B,CAAC;IAC5E,CAAC;IAED;;;;;;OAMG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B,EAAE,WAAmB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAqC,CAAC;IACnF,CAAC;;AApCH,oDAsCC;AAhBc;IADZ,0BAAY,CAAC,oBAAoB,CAAC,qCAAuB,CAAC,SAAS,CAAC;yDAGpE;AAUY;IADZ,0BAAY,CAAC,oBAAoB,CAAC,qCAAuB,CAAC,SAAS,CAAC;yDAGpE","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, RpcResponseCacheControl } 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 {\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 @RpcOperation.allowResponseCaching(RpcResponseCacheControl.Immutable)\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.allowResponseCaching(RpcResponseCacheControl.Immutable)\n public async getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps | undefined> {\n return this.forward.apply(this, [arguments]) as Promise<SchemaProps | undefined>;\n }\n\n}\n"]}
1
+ {"version":3,"file":"ECSchemaRpcInterface.js","sourceRoot":"","sources":["../../src/ECSchemaRpcInterface.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;+FAG+F;AAC/F,oDAAqH;AAGrH;;;;;GAKG;AACH,MAAsB,oBAAqB,SAAQ,0BAAY;IAC7D,wCAAwC;IACjC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IAEzB,MAAM,CAAU,aAAa,GAAG,sBAAsB,CAAC;IACvD,MAAM,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;IAE9D;;;OAGG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,wBAAU,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAA8B,CAAC;IAC5E,CAAC;IAED;;;;;;OAMG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B,EAAE,WAAmB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAqC,CAAC;IACnF,CAAC;;AApCH,oDAsCC;AAhBc;IADZ,0BAAY,CAAC,oBAAoB,CAAC,qCAAuB,CAAC,SAAS,CAAC;yDAGpE;AAUY;IADZ,0BAAY,CAAC,oBAAoB,CAAC,qCAAuB,CAAC,SAAS,CAAC;yDAGpE","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, RpcResponseCacheControl } 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 {\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 @RpcOperation.allowResponseCaching(RpcResponseCacheControl.Immutable)\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.allowResponseCaching(RpcResponseCacheControl.Immutable)\r\n public async getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps | undefined> {\r\n return this.forward.apply(this, [arguments]) as Promise<SchemaProps | undefined>;\r\n }\r\n\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcLocater.js","sourceRoot":"","sources":["../../src/ECSchemaRpcLocater.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAyH;AAEzH,iEAA8D;AAE9D;;;GAGG;AACH,MAAa,kBAAkB;IAC7B,gBAAgB;IACA,KAAK,CAAiB;IAEtC,YAAY,KAAqB,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IAE1D;;;;;MAKE;IACK,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,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,MAAM,CAAC;IAChB,CAAC;IAED;;;;;QAKI;IACG,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,UAAU,GAAG,MAAM,2CAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACpG,IAAI,CAAC,UAAU;YACb,OAAO,SAAS,CAAC;QAEnB,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,CAAC;YACnF,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;MAQE;IACK,aAAa,CAAC,UAAqB,EAAE,UAA2B,EAAE,QAAuB;QAC9F,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,CAAC;CACF;AAjDD,gDAiDC","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, SchemaInfo, SchemaKey, SchemaMatchType } 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 * @public @preview\n */\nexport class ECSchemaRpcLocater implements ISchemaLocater {\n /** @internal */\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(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n\n const schema = await context.getCachedSchema(schemaKey, matchType);\n return schema;\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * The fully loaded schema can be accessed via the schema context using the getCachedSchema method.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaJson = await ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);\n if (!schemaJson)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaJson, context || new SchemaContext());\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType)) {\n return schemaInfo;\n }\n return undefined;\n }\n\n /**\n * This method is not supported for locating schemas over RPC/HTTP.\n * Use the asynchronous `getSchema` method instead.\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 * @throws Error Always throws an error indicating this method is not supported.\n * @deprecated in 5.0 - will not be removed until after 2026-08-08. Use the asynchronous `getSchema` method for schema retrieval.\n */\n public getSchemaSync(_schemaKey: SchemaKey, _matchType: SchemaMatchType, _context: SchemaContext): Schema | undefined {\n throw new Error(\"getSchemaSync is not supported. Use the asynchronous getSchema method instead.\");\n }\n}\n"]}
1
+ {"version":3,"file":"ECSchemaRpcLocater.js","sourceRoot":"","sources":["../../src/ECSchemaRpcLocater.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,gEAAyH;AAEzH,iEAA8D;AAE9D;;;GAGG;AACH,MAAa,kBAAkB;IAC7B,gBAAgB;IACA,KAAK,CAAiB;IAEtC,YAAY,KAAqB,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IAE1D;;;;;MAKE;IACK,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,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,MAAM,CAAC;IAChB,CAAC;IAED;;;;;QAKI;IACG,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,UAAU,GAAG,MAAM,2CAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACpG,IAAI,CAAC,UAAU;YACb,OAAO,SAAS,CAAC;QAEnB,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,CAAC;YACnF,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;MAQE;IACK,aAAa,CAAC,UAAqB,EAAE,UAA2B,EAAE,QAAuB;QAC9F,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,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 } 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 * @public @preview\r\n */\r\nexport class ECSchemaRpcLocater implements ISchemaLocater {\r\n /** @internal */\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(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\r\n await this.getSchemaInfo(schemaKey, matchType, context);\r\n\r\n const schema = await context.getCachedSchema(schemaKey, matchType);\r\n return schema;\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: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\r\n const schemaJson = await ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);\r\n if (!schemaJson)\r\n return undefined;\r\n\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 * This method is not supported for locating schemas over RPC/HTTP.\r\n * Use the asynchronous `getSchema` method instead.\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 * @throws Error Always throws an error indicating this method is not supported.\r\n * @deprecated in 5.0 - will not be removed until after 2026-08-08. Use the asynchronous `getSchema` method for schema retrieval.\r\n */\r\n public getSchemaSync(_schemaKey: SchemaKey, _matchType: SchemaMatchType, _context: SchemaContext): Schema | undefined {\r\n throw new Error(\"getSchemaSync is not supported. Use the asynchronous getSchema method instead.\");\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcIncrementalSchemaLocater.js","sourceRoot":"","sources":["../../src/RpcIncrementalSchemaLocater.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,oDAA6L;AAC7L,gEAAoI;AACpI,iEAA8D;AAE9D;;;GAGG;AACH,MAAa,2BAA4B,SAAQ,sCAAkB;IAChD,YAAY,CAAiB;IAE9C;;OAEG;IACH,YAAY,WAA2B,EAAE,OAAmC;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACgB,KAAK,CAAC,YAAY,CAAO,KAAa,EAAE,OAA2B;QACpF,MAAM,gBAAgB,GAAG,oCAAsB,CAAC,SAAS,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAuD;YACxE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;SACnF,CAAC;QAEF,MAAM,YAAY,GAAiB;YACjC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;YAChC,SAAS,EAAE,4BAAc,CAAC,qBAAqB;SAChD,CAAC;QAEF,MAAM,eAAe,GAAG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzG,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAEzF,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,cAAc,CAAC,SAAoB;QACjD,MAAM,eAAe,GAAG,2CAAoB,CAAC,SAAS,EAAE,CAAC;QACzD,OAAO,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAAA,CAAC;CACH;AA3CD,kEA2CC","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 { DbQueryRequest, DbQueryResponse, DbRequestExecutor, ECSqlReader, IModelReadRpcInterface, type IModelRpcProps, QueryBinder, QueryOptions, QueryRowFormat } from \"@itwin/core-common\";\nimport { ECSqlQueryOptions, ECSqlSchemaLocater, ECSqlSchemaLocaterOptions, SchemaKey, SchemaProps } from \"@itwin/ecschema-metadata\";\nimport { ECSchemaRpcInterface } from \"./ECSchemaRpcInterface\";\n\n/**\n * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally.\n * @beta\n */\nexport class RpcIncrementalSchemaLocater extends ECSqlSchemaLocater {\n private readonly _iModelProps: IModelRpcProps;\n\n /**\n * Initializes a new instance of the RpcIncrementalSchemaLocater class.\n */\n constructor(iModelProps: IModelRpcProps, options?: ECSqlSchemaLocaterOptions) {\n super(options);\n this._iModelProps = iModelProps;\n }\n\n /**\n * Executes the given ECSql query and returns the resulting rows.\n * @param query The ECSql query to execute.\n * @param options Optional arguments to control the query result.\n * @returns A promise that resolves to the resulting rows.\n */\n protected override async executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>> {\n const ecSqlQueryClient = IModelReadRpcInterface.getClient();\n const queryExecutor: DbRequestExecutor<DbQueryRequest, DbQueryResponse> = {\n execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request),\n };\n\n const queryOptions: QueryOptions = {\n limit: { count: options?.limit },\n rowFormat: QueryRowFormat.UseECSqlPropertyNames,\n };\n\n const queryParameters = options && options.parameters ? QueryBinder.from(options.parameters) : undefined;\n const queryReader = new ECSqlReader(queryExecutor, query, queryParameters, queryOptions);\n\n return queryReader.toArray();\n }\n\n /**\n * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata).\n * This is the full schema json with all elements that are defined in the schema.\n * @param schemaKey The schema key of the schema to be resolved.\n */\n protected async getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined> {\n const rpcSchemaClient = ECSchemaRpcInterface.getClient();\n return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name);\n };\n}\n"]}
1
+ {"version":3,"file":"RpcIncrementalSchemaLocater.js","sourceRoot":"","sources":["../../src/RpcIncrementalSchemaLocater.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,oDAA6L;AAC7L,gEAAoI;AACpI,iEAA8D;AAE9D;;;GAGG;AACH,MAAa,2BAA4B,SAAQ,sCAAkB;IAChD,YAAY,CAAiB;IAE9C;;OAEG;IACH,YAAY,WAA2B,EAAE,OAAmC;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACgB,KAAK,CAAC,YAAY,CAAO,KAAa,EAAE,OAA2B;QACpF,MAAM,gBAAgB,GAAG,oCAAsB,CAAC,SAAS,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAuD;YACxE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;SACnF,CAAC;QAEF,MAAM,YAAY,GAAiB;YACjC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;YAChC,SAAS,EAAE,4BAAc,CAAC,qBAAqB;SAChD,CAAC;QAEF,MAAM,eAAe,GAAG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzG,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAEzF,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,cAAc,CAAC,SAAoB;QACjD,MAAM,eAAe,GAAG,2CAAoB,CAAC,SAAS,EAAE,CAAC;QACzD,OAAO,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAAA,CAAC;CACH;AA3CD,kEA2CC","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 { DbQueryRequest, DbQueryResponse, DbRequestExecutor, ECSqlReader, IModelReadRpcInterface, type IModelRpcProps, QueryBinder, QueryOptions, QueryRowFormat } from \"@itwin/core-common\";\r\nimport { ECSqlQueryOptions, ECSqlSchemaLocater, ECSqlSchemaLocaterOptions, SchemaKey, SchemaProps } from \"@itwin/ecschema-metadata\";\r\nimport { ECSchemaRpcInterface } from \"./ECSchemaRpcInterface\";\r\n\r\n/**\r\n * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally.\r\n * @beta\r\n */\r\nexport class RpcIncrementalSchemaLocater extends ECSqlSchemaLocater {\r\n private readonly _iModelProps: IModelRpcProps;\r\n\r\n /**\r\n * Initializes a new instance of the RpcIncrementalSchemaLocater class.\r\n */\r\n constructor(iModelProps: IModelRpcProps, options?: ECSqlSchemaLocaterOptions) {\r\n super(options);\r\n this._iModelProps = iModelProps;\r\n }\r\n\r\n /**\r\n * Executes the given ECSql query and returns the resulting rows.\r\n * @param query The ECSql query to execute.\r\n * @param options Optional arguments to control the query result.\r\n * @returns A promise that resolves to the resulting rows.\r\n */\r\n protected override async executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>> {\r\n const ecSqlQueryClient = IModelReadRpcInterface.getClient();\r\n const queryExecutor: DbRequestExecutor<DbQueryRequest, DbQueryResponse> = {\r\n execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request),\r\n };\r\n\r\n const queryOptions: QueryOptions = {\r\n limit: { count: options?.limit },\r\n rowFormat: QueryRowFormat.UseECSqlPropertyNames,\r\n };\r\n\r\n const queryParameters = options && options.parameters ? QueryBinder.from(options.parameters) : undefined;\r\n const queryReader = new ECSqlReader(queryExecutor, query, queryParameters, queryOptions);\r\n\r\n return queryReader.toArray();\r\n }\r\n\r\n /**\r\n * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata).\r\n * This is the full schema json with all elements that are defined in the schema.\r\n * @param schemaKey The schema key of the schema to be resolved.\r\n */\r\n protected async getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined> {\r\n const rpcSchemaClient = ECSchemaRpcInterface.getClient();\r\n return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name);\r\n };\r\n}\r\n"]}
@@ -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;AACrC,gEAA8C","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\";\nexport * from \"./RpcIncrementalSchemaLocater\";"]}
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;AACrC,gEAA8C","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\nexport * from \"./RpcIncrementalSchemaLocater\";"]}
@@ -68,12 +68,12 @@ describe("RpcIncrementalSchemaLocater Tests", () => {
68
68
  ]))
69
69
  .returns(toQueryResult(["schema", "items"], [
70
70
  {
71
- schema: `{
72
- "name": "${schemaKey.name}",
73
- "version": "${schemaKey.version.toString()}",
74
- "alias": "ts",
75
- "label": "Test Schema",
76
- "description": "This is a test schema."
71
+ schema: `{
72
+ "name": "${schemaKey.name}",
73
+ "version": "${schemaKey.version.toString()}",
74
+ "alias": "ts",
75
+ "label": "Test Schema",
76
+ "description": "This is a test schema."
77
77
  }`,
78
78
  }
79
79
  ]));
@@ -1 +1 @@
1
- {"version":3,"file":"RpcIncrementalSchemaLocater.test.js","sourceRoot":"","sources":["../../../src/test/RpcIncrementalSchemaLocater.test.ts"],"names":[],"mappings":";;AACA;;;+FAG+F;AAC/F,gEAA4G;AAC5G,gFAA6E;AAC7E,oDAA+G;AAC/G,kEAA+D;AAC/D,+BAA8B;AAC9B,+BAA+B;AAE/B,+FAA+F;AAC/F,kGAAkG;AAClG,gDAAgD;AAChD,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAEjD,IAAI,mBAA2C,CAAC;IAChD,IAAI,oBAA0C,CAAC;IAE/C,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAErE,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,CAAC,IAAI,CAAC,oCAAsB,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,mBAAmB,GAAG;YAC5E,SAAS,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,CAAC,CAAC;SACjF,CAAC,CAAC;QACV,KAAK,CAAC,IAAI,CAAC,2CAAoB,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,oBAAoB,GAAG;YAC3E,aAAa,EAAE,KAAK,IAAI,EAA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S,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACH,KAAK,UAAU,aAAa,CAAC,OAAsB,EAAE,IAAsC;IACzF,OAAO;QACL,IAAI,EAAE,4BAAc,CAAC,KAAK;QAC1B,MAAM,EAAE,8BAAgB,CAAC,IAAI;QAC7B,KAAK,EAAE,EAAS;QAChB,QAAQ,EAAE,IAAI,CAAC,MAAM;QACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAU,CAAA,CAAC;QACvF,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC","sourcesContent":["\n/*---------------------------------------------------------------------------------------------\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 { ECSchemaNamespaceUris, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { RpcIncrementalSchemaLocater } from \"../RpcIncrementalSchemaLocater\";\nimport { DbQueryResponse, DbResponseKind, DbResponseStatus, IModelReadRpcInterface } from \"@itwin/core-common\";\nimport { ECSchemaRpcInterface } from \"../ECSchemaRpcInterface\";\nimport { expect } from \"chai\";\nimport * as sinon from \"sinon\";\n\n// RpcIncrementalSchemaLocater derives from IncrementalSchemaLocater and ECSqlSchemaLocater, so\n// the basic functionality is already tested in their tests. This test suite verifies the expected\n// behaviour of the RPC specific implementation.\ndescribe(\"RpcIncrementalSchemaLocater Tests\", () => {\n\n let imodelReadInterface: IModelReadRpcInterface;\n let ecschemaRpcInterface: ECSchemaRpcInterface;\n\n const schemaInfoColumns = [\"name\", \"version\", \"references\", \"alias\"];\n\n beforeEach(() => {\n sinon.stub(IModelReadRpcInterface, \"getClient\").returns(imodelReadInterface = {\n queryRows: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\n } as any);\n sinon.stub(ECSchemaRpcInterface, \"getClient\").returns(ecschemaRpcInterface = {\n getSchemaJSON: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\n } as any);\n });\n\n afterEach(() => {\n sinon.restore();\n });\n\n it(\"get schema info, schema found\", async () => {\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" }\n ]));\n\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schemaInfo).is.not.undefined;\n expect(schemaInfo).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\n expect(schemaInfo).has.property(\"alias\").that.equals(\"ts\");\n expect(schemaInfo).has.property(\"references\").that.is.empty;\n });\n\n it(\"get schema info, schema not found, return undefined\", async () => {\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\n\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schemaInfo).to.be.undefined;\n });\n\n it(\"get schema, incrementally\", async () => {\n const context = new SchemaContext();\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n context.addLocater(locater);\n\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\")\n .onCall(0).returns(toQueryResult(schemaInfoColumns, [\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\n { name: \"ECDbMeta\", version: \"4.0.3\", references: \"[]\", alias: \"ecdb\" },\n ]))\n .onCall(1).returns(toQueryResult([\"name\", \"version\", \"alias\", \"references\", \"items\"], [\n {\n name: schemaKey.name,\n version: schemaKey.version.toString(),\n alias: \"ts\",\n references: \"[]\",\n items: \"[]\",\n }\n ]))\n .returns(toQueryResult([\"schema\", \"items\"], [\n {\n schema: `{\n \"name\": \"${schemaKey.name}\",\n \"version\": \"${schemaKey.version.toString()}\",\n \"alias\": \"ts\",\n \"label\": \"Test Schema\",\n \"description\": \"This is a test schema.\"\n }`,\n }\n ]));\n\n const schema = await context.getSchema(schemaKey, SchemaMatchType.Latest);\n\n expect(schema).is.not.undefined;\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\n\n expect(schema).has.property(\"loadingController\").that.is.not.undefined;\n expect(schema).has.a.nested.property(\"loadingController.inProgress\").that.is.true;\n await schema!.loadingController?.wait();\n\n expect(schema).has.property(\"label\", \"Test Schema\");\n expect(schema).has.property(\"description\", \"This is a test schema.\");\n });\n\n it(\"get schema, unsupported metaschema\", async () => {\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\n { name: \"ECDbMeta\", version: \"4.0.1\", references: \"[]\", alias: \"ecdb\" },\n ]));\n\n sinon.stub(ecschemaRpcInterface, \"getSchemaJSON\").returns(Promise.resolve({\n $schema: ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n name: schemaKey.name,\n version: schemaKey.version.toString(),\n alias: \"ts\"\n }));\n\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schema).is.not.undefined;\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\n });\n\n it(\"get schema, schema not found, return undefined\", async () => {\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\n\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schema).is.undefined;\n });\n});\n\n/**\n * This is a very simple helper function to translate a set of rows into a DbQueryResponse.\n * It does not handle different row formats or property order.\n */\nasync function toQueryResult(columns: Array<string>, rows: Array<{ [column: string]: any }>): Promise<DbQueryResponse> {\n return {\n kind: DbResponseKind.ECSql,\n status: DbResponseStatus.Done,\n stats: {} as any,\n rowCount: rows.length,\n meta: columns.map((column, i) => ({ name: column, jsonName: column, index: i } as any)),\n data: rows.map(row => columns.map(k => row[k])),\n };\n}"]}
1
+ {"version":3,"file":"RpcIncrementalSchemaLocater.test.js","sourceRoot":"","sources":["../../../src/test/RpcIncrementalSchemaLocater.test.ts"],"names":[],"mappings":";;AACA;;;+FAG+F;AAC/F,gEAA4G;AAC5G,gFAA6E;AAC7E,oDAA+G;AAC/G,kEAA+D;AAC/D,+BAA8B;AAC9B,+BAA+B;AAE/B,+FAA+F;AAC/F,kGAAkG;AAClG,gDAAgD;AAChD,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAEjD,IAAI,mBAA2C,CAAC;IAChD,IAAI,oBAA0C,CAAC;IAE/C,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAErE,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,CAAC,IAAI,CAA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AAE,EAAE,CAAC,CAAC,CAAC;QAE3F,MAAM,OAAO,GAAG,IAAI,yDAA2B,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAC5E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,mCAAe,CAAC,MAAM,EAAE,IAAI,iCAAa,EAAE,CAAC,CAAC;QAE/F,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACH,KAAK,UAAU,aAAa,CAAC,OAAsB,EAAE,IAAsC;IACzF,OAAO;QACL,IAAI,EAAE,4BAAc,CAAC,KAAK;QAC1B,MAAM,EAAE,8BAAgB,CAAC,IAAI;QAC7B,KAAK,EAAE,EAAS;QAChB,QAAQ,EAAE,IAAI,CAAC,MAAM;QACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAU,CAAA,CAAC;QACvF,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC","sourcesContent":["\r\n/*---------------------------------------------------------------------------------------------\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 { ECSchemaNamespaceUris, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { RpcIncrementalSchemaLocater } from \"../RpcIncrementalSchemaLocater\";\r\nimport { DbQueryResponse, DbResponseKind, DbResponseStatus, IModelReadRpcInterface } from \"@itwin/core-common\";\r\nimport { ECSchemaRpcInterface } from \"../ECSchemaRpcInterface\";\r\nimport { expect } from \"chai\";\r\nimport * as sinon from \"sinon\";\r\n\r\n// RpcIncrementalSchemaLocater derives from IncrementalSchemaLocater and ECSqlSchemaLocater, so\r\n// the basic functionality is already tested in their tests. This test suite verifies the expected\r\n// behaviour of the RPC specific implementation.\r\ndescribe(\"RpcIncrementalSchemaLocater Tests\", () => {\r\n\r\n let imodelReadInterface: IModelReadRpcInterface;\r\n let ecschemaRpcInterface: ECSchemaRpcInterface;\r\n\r\n const schemaInfoColumns = [\"name\", \"version\", \"references\", \"alias\"];\r\n\r\n beforeEach(() => {\r\n sinon.stub(IModelReadRpcInterface, \"getClient\").returns(imodelReadInterface = {\r\n queryRows: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\r\n } as any);\r\n sinon.stub(ECSchemaRpcInterface, \"getClient\").returns(ecschemaRpcInterface = {\r\n getSchemaJSON: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\r\n } as any);\r\n });\r\n\r\n afterEach(() => {\r\n sinon.restore();\r\n });\r\n\r\n it(\"get schema info, schema found\", async () => {\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\r\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" }\r\n ]));\r\n\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schemaInfo).is.not.undefined;\r\n expect(schemaInfo).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\r\n expect(schemaInfo).has.property(\"alias\").that.equals(\"ts\");\r\n expect(schemaInfo).has.property(\"references\").that.is.empty;\r\n });\r\n\r\n it(\"get schema info, schema not found, return undefined\", async () => {\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\r\n\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schemaInfo).to.be.undefined;\r\n });\r\n\r\n it(\"get schema, incrementally\", async () => {\r\n const context = new SchemaContext();\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n context.addLocater(locater);\r\n\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\")\r\n .onCall(0).returns(toQueryResult(schemaInfoColumns, [\r\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\r\n { name: \"ECDbMeta\", version: \"4.0.3\", references: \"[]\", alias: \"ecdb\" },\r\n ]))\r\n .onCall(1).returns(toQueryResult([\"name\", \"version\", \"alias\", \"references\", \"items\"], [\r\n {\r\n name: schemaKey.name,\r\n version: schemaKey.version.toString(),\r\n alias: \"ts\",\r\n references: \"[]\",\r\n items: \"[]\",\r\n }\r\n ]))\r\n .returns(toQueryResult([\"schema\", \"items\"], [\r\n {\r\n schema: `{\r\n \"name\": \"${schemaKey.name}\",\r\n \"version\": \"${schemaKey.version.toString()}\",\r\n \"alias\": \"ts\",\r\n \"label\": \"Test Schema\",\r\n \"description\": \"This is a test schema.\"\r\n }`,\r\n }\r\n ]));\r\n\r\n const schema = await context.getSchema(schemaKey, SchemaMatchType.Latest);\r\n\r\n expect(schema).is.not.undefined;\r\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\r\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\r\n\r\n expect(schema).has.property(\"loadingController\").that.is.not.undefined;\r\n expect(schema).has.a.nested.property(\"loadingController.inProgress\").that.is.true;\r\n await schema!.loadingController?.wait();\r\n\r\n expect(schema).has.property(\"label\", \"Test Schema\");\r\n expect(schema).has.property(\"description\", \"This is a test schema.\");\r\n });\r\n\r\n it(\"get schema, unsupported metaschema\", async () => {\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\r\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\r\n { name: \"ECDbMeta\", version: \"4.0.1\", references: \"[]\", alias: \"ecdb\" },\r\n ]));\r\n\r\n sinon.stub(ecschemaRpcInterface, \"getSchemaJSON\").returns(Promise.resolve({\r\n $schema: ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\r\n name: schemaKey.name,\r\n version: schemaKey.version.toString(),\r\n alias: \"ts\"\r\n }));\r\n\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schema).is.not.undefined;\r\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\r\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\r\n });\r\n\r\n it(\"get schema, schema not found, return undefined\", async () => {\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\r\n\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schema).is.undefined;\r\n });\r\n});\r\n\r\n/**\r\n * This is a very simple helper function to translate a set of rows into a DbQueryResponse.\r\n * It does not handle different row formats or property order.\r\n */\r\nasync function toQueryResult(columns: Array<string>, rows: Array<{ [column: string]: any }>): Promise<DbQueryResponse> {\r\n return {\r\n kind: DbResponseKind.ECSql,\r\n status: DbResponseStatus.Done,\r\n stats: {} as any,\r\n rowCount: rows.length,\r\n meta: columns.map((column, i) => ({ name: column, jsonName: column, index: i } as any)),\r\n data: rows.map(row => columns.map(k => row[k])),\r\n };\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcInterface.js","sourceRoot":"","sources":["../../src/ECSchemaRpcInterface.ts"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,OAAO,EAAkB,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGrH;;;;;GAKG;AACH,MAAM,OAAgB,oBAAqB,SAAQ,YAAY;IAC7D,wCAAwC;IACjC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IAEzB,MAAM,CAAU,aAAa,GAAG,sBAAsB,CAAC;IACvD,MAAM,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;IAE9D;;;OAGG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,UAAU,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAA8B,CAAC;IAC5E,CAAC;IAED;;;;;;OAMG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B,EAAE,WAAmB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAqC,CAAC;IACnF,CAAC;;AAdY;IADZ,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC;yDAGpE;AAUY;IADZ,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC;yDAGpE","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, RpcResponseCacheControl } 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 {\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 @RpcOperation.allowResponseCaching(RpcResponseCacheControl.Immutable)\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.allowResponseCaching(RpcResponseCacheControl.Immutable)\n public async getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps | undefined> {\n return this.forward.apply(this, [arguments]) as Promise<SchemaProps | undefined>;\n }\n\n}\n"]}
1
+ {"version":3,"file":"ECSchemaRpcInterface.js","sourceRoot":"","sources":["../../src/ECSchemaRpcInterface.ts"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,OAAO,EAAkB,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGrH;;;;;GAKG;AACH,MAAM,OAAgB,oBAAqB,SAAQ,YAAY;IAC7D,wCAAwC;IACjC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IAEzB,MAAM,CAAU,aAAa,GAAG,sBAAsB,CAAC;IACvD,MAAM,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;IAE9D;;;OAGG;IACI,MAAM,CAAC,SAAS;QACrB,OAAO,UAAU,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAA8B,CAAC;IAC5E,CAAC;IAED;;;;;;OAMG;IAEU,AAAN,KAAK,CAAC,aAAa,CAAC,WAA2B,EAAE,WAAmB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAqC,CAAC;IACnF,CAAC;;AAdY;IADZ,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC;yDAGpE;AAUY;IADZ,YAAY,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,SAAS,CAAC;yDAGpE","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, RpcResponseCacheControl } 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 {\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 @RpcOperation.allowResponseCaching(RpcResponseCacheControl.Immutable)\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.allowResponseCaching(RpcResponseCacheControl.Immutable)\r\n public async getSchemaJSON(_tokenProps: IModelRpcProps, _schemaName: string): Promise<SchemaProps | undefined> {\r\n return this.forward.apply(this, [arguments]) as Promise<SchemaProps | undefined>;\r\n }\r\n\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcLocater.js","sourceRoot":"","sources":["../../src/ECS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AAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,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*--------------------------------------------------------------------------------------------*/\nimport { ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType } 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 * @public @preview\n */\nexport class ECSchemaRpcLocater implements ISchemaLocater {\n /** @internal */\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(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n\n const schema = await context.getCachedSchema(schemaKey, matchType);\n return schema;\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * The fully loaded schema can be accessed via the schema context using the getCachedSchema method.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const schemaJson = await ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);\n if (!schemaJson)\n return undefined;\n\n const schemaInfo = await Schema.startLoadingFromJson(schemaJson, context || new SchemaContext());\n if (schemaInfo !== undefined && schemaInfo.schemaKey.matches(schemaKey, matchType)) {\n return schemaInfo;\n }\n return undefined;\n }\n\n /**\n * This method is not supported for locating schemas over RPC/HTTP.\n * Use the asynchronous `getSchema` method instead.\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 * @throws Error Always throws an error indicating this method is not supported.\n * @deprecated in 5.0 - will not be removed until after 2026-08-08. Use the asynchronous `getSchema` method for schema retrieval.\n */\n public getSchemaSync(_schemaKey: SchemaKey, _matchType: SchemaMatchType, _context: SchemaContext): Schema | undefined {\n throw new Error(\"getSchemaSync is not supported. Use the asynchronous getSchema method instead.\");\n }\n}\n"]}
1
+ {"version":3,"file":"ECSchemaRpcLocater.js","sourceRoot":"","sources":["../../src/ECSchemaRpcLocater.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAkB,MAAM,EAAE,aAAa,EAA0C,MAAM,0BAA0B,CAAC;AAEzH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAC7B,gBAAgB;IACA,KAAK,CAAiB;IAEtC,YAAY,KAAqB,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IAE1D;;;;;MAKE;IACK,KAAK,CAAC,SAAS,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC7F,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,MAAM,CAAC;IAChB,CAAC;IAED;;;;;QAKI;IACG,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACpG,IAAI,CAAC,UAAU;YACb,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,OAAO,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC;QACjG,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC;YACnF,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;MAQE;IACK,aAAa,CAAC,UAAqB,EAAE,UAA2B,EAAE,QAAuB;QAC9F,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,CAAC;CACF","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 } 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 * @public @preview\r\n */\r\nexport class ECSchemaRpcLocater implements ISchemaLocater {\r\n /** @internal */\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(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\r\n await this.getSchemaInfo(schemaKey, matchType, context);\r\n\r\n const schema = await context.getCachedSchema(schemaKey, matchType);\r\n return schema;\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: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\r\n const schemaJson = await ECSchemaRpcInterface.getClient().getSchemaJSON(this.token, schemaKey.name);\r\n if (!schemaJson)\r\n return undefined;\r\n\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 * This method is not supported for locating schemas over RPC/HTTP.\r\n * Use the asynchronous `getSchema` method instead.\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 * @throws Error Always throws an error indicating this method is not supported.\r\n * @deprecated in 5.0 - will not be removed until after 2026-08-08. Use the asynchronous `getSchema` method for schema retrieval.\r\n */\r\n public getSchemaSync(_schemaKey: SchemaKey, _matchType: SchemaMatchType, _context: SchemaContext): Schema | undefined {\r\n throw new Error(\"getSchemaSync is not supported. Use the asynchronous getSchema method instead.\");\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RpcIncrementalSchemaLocater.js","sourceRoot":"","sources":["../../src/RpcIncrementalSchemaLocater.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAsD,WAAW,EAAE,sBAAsB,EAAuB,WAAW,EAAgB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC7L,OAAO,EAAqB,kBAAkB,EAAqD,MAAM,0BAA0B,CAAC;AACpI,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,kBAAkB;IAChD,YAAY,CAAiB;IAE9C;;OAEG;IACH,YAAY,WAA2B,EAAE,OAAmC;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACgB,KAAK,CAAC,YAAY,CAAO,KAAa,EAAE,OAA2B;QACpF,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,SAAS,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAuD;YACxE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;SACnF,CAAC;QAEF,MAAM,YAAY,GAAiB;YACjC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;YAChC,SAAS,EAAE,cAAc,CAAC,qBAAqB;SAChD,CAAC;QAEF,MAAM,eAAe,GAAG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzG,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAEzF,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,cAAc,CAAC,SAAoB;QACjD,MAAM,eAAe,GAAG,oBAAoB,CAAC,SAAS,EAAE,CAAC;QACzD,OAAO,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAAA,CAAC;CACH","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 { DbQueryRequest, DbQueryResponse, DbRequestExecutor, ECSqlReader, IModelReadRpcInterface, type IModelRpcProps, QueryBinder, QueryOptions, QueryRowFormat } from \"@itwin/core-common\";\nimport { ECSqlQueryOptions, ECSqlSchemaLocater, ECSqlSchemaLocaterOptions, SchemaKey, SchemaProps } from \"@itwin/ecschema-metadata\";\nimport { ECSchemaRpcInterface } from \"./ECSchemaRpcInterface\";\n\n/**\n * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally.\n * @beta\n */\nexport class RpcIncrementalSchemaLocater extends ECSqlSchemaLocater {\n private readonly _iModelProps: IModelRpcProps;\n\n /**\n * Initializes a new instance of the RpcIncrementalSchemaLocater class.\n */\n constructor(iModelProps: IModelRpcProps, options?: ECSqlSchemaLocaterOptions) {\n super(options);\n this._iModelProps = iModelProps;\n }\n\n /**\n * Executes the given ECSql query and returns the resulting rows.\n * @param query The ECSql query to execute.\n * @param options Optional arguments to control the query result.\n * @returns A promise that resolves to the resulting rows.\n */\n protected override async executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>> {\n const ecSqlQueryClient = IModelReadRpcInterface.getClient();\n const queryExecutor: DbRequestExecutor<DbQueryRequest, DbQueryResponse> = {\n execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request),\n };\n\n const queryOptions: QueryOptions = {\n limit: { count: options?.limit },\n rowFormat: QueryRowFormat.UseECSqlPropertyNames,\n };\n\n const queryParameters = options && options.parameters ? QueryBinder.from(options.parameters) : undefined;\n const queryReader = new ECSqlReader(queryExecutor, query, queryParameters, queryOptions);\n\n return queryReader.toArray();\n }\n\n /**\n * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata).\n * This is the full schema json with all elements that are defined in the schema.\n * @param schemaKey The schema key of the schema to be resolved.\n */\n protected async getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined> {\n const rpcSchemaClient = ECSchemaRpcInterface.getClient();\n return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name);\n };\n}\n"]}
1
+ {"version":3,"file":"RpcIncrementalSchemaLocater.js","sourceRoot":"","sources":["../../src/RpcIncrementalSchemaLocater.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAsD,WAAW,EAAE,sBAAsB,EAAuB,WAAW,EAAgB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC7L,OAAO,EAAqB,kBAAkB,EAAqD,MAAM,0BAA0B,CAAC;AACpI,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,kBAAkB;IAChD,YAAY,CAAiB;IAE9C;;OAEG;IACH,YAAY,WAA2B,EAAE,OAAmC;QAC1E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACgB,KAAK,CAAC,YAAY,CAAO,KAAa,EAAE,OAA2B;QACpF,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,SAAS,EAAE,CAAC;QAC5D,MAAM,aAAa,GAAuD;YACxE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;SACnF,CAAC;QAEF,MAAM,YAAY,GAAiB;YACjC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;YAChC,SAAS,EAAE,cAAc,CAAC,qBAAqB;SAChD,CAAC;QAEF,MAAM,eAAe,GAAG,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzG,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC;QAEzF,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,cAAc,CAAC,SAAoB;QACjD,MAAM,eAAe,GAAG,oBAAoB,CAAC,SAAS,EAAE,CAAC;QACzD,OAAO,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAAA,CAAC;CACH","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 { DbQueryRequest, DbQueryResponse, DbRequestExecutor, ECSqlReader, IModelReadRpcInterface, type IModelRpcProps, QueryBinder, QueryOptions, QueryRowFormat } from \"@itwin/core-common\";\r\nimport { ECSqlQueryOptions, ECSqlSchemaLocater, ECSqlSchemaLocaterOptions, SchemaKey, SchemaProps } from \"@itwin/ecschema-metadata\";\r\nimport { ECSchemaRpcInterface } from \"./ECSchemaRpcInterface\";\r\n\r\n/**\r\n * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally.\r\n * @beta\r\n */\r\nexport class RpcIncrementalSchemaLocater extends ECSqlSchemaLocater {\r\n private readonly _iModelProps: IModelRpcProps;\r\n\r\n /**\r\n * Initializes a new instance of the RpcIncrementalSchemaLocater class.\r\n */\r\n constructor(iModelProps: IModelRpcProps, options?: ECSqlSchemaLocaterOptions) {\r\n super(options);\r\n this._iModelProps = iModelProps;\r\n }\r\n\r\n /**\r\n * Executes the given ECSql query and returns the resulting rows.\r\n * @param query The ECSql query to execute.\r\n * @param options Optional arguments to control the query result.\r\n * @returns A promise that resolves to the resulting rows.\r\n */\r\n protected override async executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>> {\r\n const ecSqlQueryClient = IModelReadRpcInterface.getClient();\r\n const queryExecutor: DbRequestExecutor<DbQueryRequest, DbQueryResponse> = {\r\n execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request),\r\n };\r\n\r\n const queryOptions: QueryOptions = {\r\n limit: { count: options?.limit },\r\n rowFormat: QueryRowFormat.UseECSqlPropertyNames,\r\n };\r\n\r\n const queryParameters = options && options.parameters ? QueryBinder.from(options.parameters) : undefined;\r\n const queryReader = new ECSqlReader(queryExecutor, query, queryParameters, queryOptions);\r\n\r\n return queryReader.toArray();\r\n }\r\n\r\n /**\r\n * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata).\r\n * This is the full schema json with all elements that are defined in the schema.\r\n * @param schemaKey The schema key of the schema to be resolved.\r\n */\r\n protected async getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined> {\r\n const rpcSchemaClient = ECSchemaRpcInterface.getClient();\r\n return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name);\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ecschema-rpc-interface.js","sourceRoot":"","sources":["../../src/ecschema-rpc-interface.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC","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\";\nexport * from \"./RpcIncrementalSchemaLocater\";"]}
1
+ {"version":3,"file":"ecschema-rpc-interface.js","sourceRoot":"","sources":["../../src/ecschema-rpc-interface.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC","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\nexport * from \"./RpcIncrementalSchemaLocater\";"]}
@@ -66,12 +66,12 @@ describe("RpcIncrementalSchemaLocater Tests", () => {
66
66
  ]))
67
67
  .returns(toQueryResult(["schema", "items"], [
68
68
  {
69
- schema: `{
70
- "name": "${schemaKey.name}",
71
- "version": "${schemaKey.version.toString()}",
72
- "alias": "ts",
73
- "label": "Test Schema",
74
- "description": "This is a test schema."
69
+ schema: `{
70
+ "name": "${schemaKey.name}",
71
+ "version": "${schemaKey.version.toString()}",
72
+ "alias": "ts",
73
+ "label": "Test Schema",
74
+ "description": "This is a test schema."
75
75
  }`,
76
76
  }
77
77
  ]));
@@ -1 +1 @@
1
- {"version":3,"file":"RpcIncrementalSchemaLocater.test.js","sourceRoot":"","sources":["../../../src/test/RpcIncrementalSchemaLocater.test.ts"],"names":[],"mappings":"AACA;;;+FAG+F;AAC/F,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAmB,cAAc,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/G,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,+FAA+F;AAC/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9D,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QAC5D,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,CAAC;QAE3F,MAAM,OAAO,GAAG,IAAI,2BAA2B,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAC5E,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC,CAAC;QAE/F,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH;;;GAGG;AACH,KAAK,UAAU,aAAa,CAAC,OAAsB,EAAE,IAAsC;IACzF,OAAO;QACL,IAAI,EAAE,cAAc,CAAC,KAAK;QAC1B,MAAM,EAAE,gBAAgB,CAAC,IAAI;QAC7B,KAAK,EAAE,EAAS;QAChB,QAAQ,EAAE,IAAI,CAAC,MAAM;QACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAU,CAAA,CAAC;QACvF,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC","sourcesContent":["\n/*---------------------------------------------------------------------------------------------\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 { ECSchemaNamespaceUris, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { RpcIncrementalSchemaLocater } from \"../RpcIncrementalSchemaLocater\";\nimport { DbQueryResponse, DbResponseKind, DbResponseStatus, IModelReadRpcInterface } from \"@itwin/core-common\";\nimport { ECSchemaRpcInterface } from \"../ECSchemaRpcInterface\";\nimport { expect } from \"chai\";\nimport * as sinon from \"sinon\";\n\n// RpcIncrementalSchemaLocater derives from IncrementalSchemaLocater and ECSqlSchemaLocater, so\n// the basic functionality is already tested in their tests. This test suite verifies the expected\n// behaviour of the RPC specific implementation.\ndescribe(\"RpcIncrementalSchemaLocater Tests\", () => {\n\n let imodelReadInterface: IModelReadRpcInterface;\n let ecschemaRpcInterface: ECSchemaRpcInterface;\n\n const schemaInfoColumns = [\"name\", \"version\", \"references\", \"alias\"];\n\n beforeEach(() => {\n sinon.stub(IModelReadRpcInterface, \"getClient\").returns(imodelReadInterface = {\n queryRows: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\n } as any);\n sinon.stub(ECSchemaRpcInterface, \"getClient\").returns(ecschemaRpcInterface = {\n getSchemaJSON: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\n } as any);\n });\n\n afterEach(() => {\n sinon.restore();\n });\n\n it(\"get schema info, schema found\", async () => {\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" }\n ]));\n\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schemaInfo).is.not.undefined;\n expect(schemaInfo).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\n expect(schemaInfo).has.property(\"alias\").that.equals(\"ts\");\n expect(schemaInfo).has.property(\"references\").that.is.empty;\n });\n\n it(\"get schema info, schema not found, return undefined\", async () => {\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\n\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schemaInfo).to.be.undefined;\n });\n\n it(\"get schema, incrementally\", async () => {\n const context = new SchemaContext();\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n context.addLocater(locater);\n\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\")\n .onCall(0).returns(toQueryResult(schemaInfoColumns, [\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\n { name: \"ECDbMeta\", version: \"4.0.3\", references: \"[]\", alias: \"ecdb\" },\n ]))\n .onCall(1).returns(toQueryResult([\"name\", \"version\", \"alias\", \"references\", \"items\"], [\n {\n name: schemaKey.name,\n version: schemaKey.version.toString(),\n alias: \"ts\",\n references: \"[]\",\n items: \"[]\",\n }\n ]))\n .returns(toQueryResult([\"schema\", \"items\"], [\n {\n schema: `{\n \"name\": \"${schemaKey.name}\",\n \"version\": \"${schemaKey.version.toString()}\",\n \"alias\": \"ts\",\n \"label\": \"Test Schema\",\n \"description\": \"This is a test schema.\"\n }`,\n }\n ]));\n\n const schema = await context.getSchema(schemaKey, SchemaMatchType.Latest);\n\n expect(schema).is.not.undefined;\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\n\n expect(schema).has.property(\"loadingController\").that.is.not.undefined;\n expect(schema).has.a.nested.property(\"loadingController.inProgress\").that.is.true;\n await schema!.loadingController?.wait();\n\n expect(schema).has.property(\"label\", \"Test Schema\");\n expect(schema).has.property(\"description\", \"This is a test schema.\");\n });\n\n it(\"get schema, unsupported metaschema\", async () => {\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\n { name: \"ECDbMeta\", version: \"4.0.1\", references: \"[]\", alias: \"ecdb\" },\n ]));\n\n sinon.stub(ecschemaRpcInterface, \"getSchemaJSON\").returns(Promise.resolve({\n $schema: ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n name: schemaKey.name,\n version: schemaKey.version.toString(),\n alias: \"ts\"\n }));\n\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schema).is.not.undefined;\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\n });\n\n it(\"get schema, schema not found, return undefined\", async () => {\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\n\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\n\n expect(schema).is.undefined;\n });\n});\n\n/**\n * This is a very simple helper function to translate a set of rows into a DbQueryResponse.\n * It does not handle different row formats or property order.\n */\nasync function toQueryResult(columns: Array<string>, rows: Array<{ [column: string]: any }>): Promise<DbQueryResponse> {\n return {\n kind: DbResponseKind.ECSql,\n status: DbResponseStatus.Done,\n stats: {} as any,\n rowCount: rows.length,\n meta: columns.map((column, i) => ({ name: column, jsonName: column, index: i } as any)),\n data: rows.map(row => columns.map(k => row[k])),\n };\n}"]}
1
+ {"version":3,"file":"RpcIncrementalSchemaLocater.test.js","sourceRoot":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,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAU,CAAA,CAAC;QACvF,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC","sourcesContent":["\r\n/*---------------------------------------------------------------------------------------------\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 { ECSchemaNamespaceUris, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { RpcIncrementalSchemaLocater } from \"../RpcIncrementalSchemaLocater\";\r\nimport { DbQueryResponse, DbResponseKind, DbResponseStatus, IModelReadRpcInterface } from \"@itwin/core-common\";\r\nimport { ECSchemaRpcInterface } from \"../ECSchemaRpcInterface\";\r\nimport { expect } from \"chai\";\r\nimport * as sinon from \"sinon\";\r\n\r\n// RpcIncrementalSchemaLocater derives from IncrementalSchemaLocater and ECSqlSchemaLocater, so\r\n// the basic functionality is already tested in their tests. This test suite verifies the expected\r\n// behaviour of the RPC specific implementation.\r\ndescribe(\"RpcIncrementalSchemaLocater Tests\", () => {\r\n\r\n let imodelReadInterface: IModelReadRpcInterface;\r\n let ecschemaRpcInterface: ECSchemaRpcInterface;\r\n\r\n const schemaInfoColumns = [\"name\", \"version\", \"references\", \"alias\"];\r\n\r\n beforeEach(() => {\r\n sinon.stub(IModelReadRpcInterface, \"getClient\").returns(imodelReadInterface = {\r\n queryRows: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\r\n } as any);\r\n sinon.stub(ECSchemaRpcInterface, \"getClient\").returns(ecschemaRpcInterface = {\r\n getSchemaJSON: async () => { throw new Error(\"Method must be implemented in the tests.\"); },\r\n } as any);\r\n });\r\n\r\n afterEach(() => {\r\n sinon.restore();\r\n });\r\n\r\n it(\"get schema info, schema found\", async () => {\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\r\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" }\r\n ]));\r\n\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schemaInfo).is.not.undefined;\r\n expect(schemaInfo).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\r\n expect(schemaInfo).has.property(\"alias\").that.equals(\"ts\");\r\n expect(schemaInfo).has.property(\"references\").that.is.empty;\r\n });\r\n\r\n it(\"get schema info, schema not found, return undefined\", async () => {\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\r\n\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schemaInfo = await locater.getSchemaInfo(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schemaInfo).to.be.undefined;\r\n });\r\n\r\n it(\"get schema, incrementally\", async () => {\r\n const context = new SchemaContext();\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n context.addLocater(locater);\r\n\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\")\r\n .onCall(0).returns(toQueryResult(schemaInfoColumns, [\r\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\r\n { name: \"ECDbMeta\", version: \"4.0.3\", references: \"[]\", alias: \"ecdb\" },\r\n ]))\r\n .onCall(1).returns(toQueryResult([\"name\", \"version\", \"alias\", \"references\", \"items\"], [\r\n {\r\n name: schemaKey.name,\r\n version: schemaKey.version.toString(),\r\n alias: \"ts\",\r\n references: \"[]\",\r\n items: \"[]\",\r\n }\r\n ]))\r\n .returns(toQueryResult([\"schema\", \"items\"], [\r\n {\r\n schema: `{\r\n \"name\": \"${schemaKey.name}\",\r\n \"version\": \"${schemaKey.version.toString()}\",\r\n \"alias\": \"ts\",\r\n \"label\": \"Test Schema\",\r\n \"description\": \"This is a test schema.\"\r\n }`,\r\n }\r\n ]));\r\n\r\n const schema = await context.getSchema(schemaKey, SchemaMatchType.Latest);\r\n\r\n expect(schema).is.not.undefined;\r\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\r\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\r\n\r\n expect(schema).has.property(\"loadingController\").that.is.not.undefined;\r\n expect(schema).has.a.nested.property(\"loadingController.inProgress\").that.is.true;\r\n await schema!.loadingController?.wait();\r\n\r\n expect(schema).has.property(\"label\", \"Test Schema\");\r\n expect(schema).has.property(\"description\", \"This is a test schema.\");\r\n });\r\n\r\n it(\"get schema, unsupported metaschema\", async () => {\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, [\r\n { name: schemaKey.name, version: schemaKey.version.toString(), references: \"[]\", alias: \"ts\" },\r\n { name: \"ECDbMeta\", version: \"4.0.1\", references: \"[]\", alias: \"ecdb\" },\r\n ]));\r\n\r\n sinon.stub(ecschemaRpcInterface, \"getSchemaJSON\").returns(Promise.resolve({\r\n $schema: ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\r\n name: schemaKey.name,\r\n version: schemaKey.version.toString(),\r\n alias: \"ts\"\r\n }));\r\n\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schema).is.not.undefined;\r\n expect(schema).has.property(\"schemaKey\").that.satisfies((key: SchemaKey) => key.matches(schemaKey));\r\n expect(schema).has.property(\"alias\").that.equals(\"ts\");\r\n });\r\n\r\n it(\"get schema, schema not found, return undefined\", async () => {\r\n const schemaKey = SchemaKey.parseString(\"TestSchema.1.0.0\");\r\n sinon.stub(imodelReadInterface, \"queryRows\").returns(toQueryResult(schemaInfoColumns, []));\r\n\r\n const locater = new RpcIncrementalSchemaLocater({ key: \"rpc-test-imodel\" });\r\n const schema = await locater.getSchema(schemaKey, SchemaMatchType.Latest, new SchemaContext());\r\n\r\n expect(schema).is.undefined;\r\n });\r\n});\r\n\r\n/**\r\n * This is a very simple helper function to translate a set of rows into a DbQueryResponse.\r\n * It does not handle different row formats or property order.\r\n */\r\nasync function toQueryResult(columns: Array<string>, rows: Array<{ [column: string]: any }>): Promise<DbQueryResponse> {\r\n return {\r\n kind: DbResponseKind.ECSql,\r\n status: DbResponseStatus.Done,\r\n stats: {} as any,\r\n rowCount: rows.length,\r\n meta: columns.map((column, i) => ({ name: column, jsonName: column, index: i } as any)),\r\n data: rows.map(row => columns.map(k => row[k])),\r\n };\r\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-rpcinterface-common",
3
- "version": "5.5.0-dev.2",
3
+ "version": "5.5.0-dev.5",
4
4
  "description": "Schema RPC Interface common interface",
5
5
  "main": "lib/cjs/ecschema-rpc-interface.js",
6
6
  "module": "lib/esm/ecschema-rpc-interface.js",
@@ -22,10 +22,10 @@
22
22
  "url": "http://www.bentley.com"
23
23
  },
24
24
  "peerDependencies": {
25
- "@itwin/core-bentley": "5.5.0-dev.2",
26
- "@itwin/core-common": "5.5.0-dev.2",
27
- "@itwin/ecschema-metadata": "5.5.0-dev.2",
28
- "@itwin/core-geometry": "5.5.0-dev.2"
25
+ "@itwin/core-bentley": "5.5.0-dev.5",
26
+ "@itwin/core-geometry": "5.5.0-dev.5",
27
+ "@itwin/core-common": "5.5.0-dev.5",
28
+ "@itwin/ecschema-metadata": "5.5.0-dev.5"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@itwin/eslint-plugin": "5.2.2-dev.2",
@@ -38,11 +38,11 @@
38
38
  "sinon": "^17.0.2",
39
39
  "rimraf": "^6.0.1",
40
40
  "typescript": "~5.6.2",
41
- "@itwin/core-geometry": "5.5.0-dev.2",
42
- "@itwin/build-tools": "5.5.0-dev.2",
43
- "@itwin/core-bentley": "5.5.0-dev.2",
44
- "@itwin/ecschema-metadata": "5.5.0-dev.2",
45
- "@itwin/core-common": "5.5.0-dev.2"
41
+ "@itwin/build-tools": "5.5.0-dev.5",
42
+ "@itwin/core-bentley": "5.5.0-dev.5",
43
+ "@itwin/core-geometry": "5.5.0-dev.5",
44
+ "@itwin/ecschema-metadata": "5.5.0-dev.5",
45
+ "@itwin/core-common": "5.5.0-dev.5"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "npm run -s build:cjs && npm run -s build:esm",