UNPKG

@itwin/ecschema-rpcinterface-common

Version:

Schema RPC Interface common interface

51 lines 2.46 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ import { ECSqlReader, IModelReadRpcInterface, QueryBinder, QueryRowFormat } from "@itwin/core-common"; import { ECSqlSchemaLocater } from "@itwin/ecschema-metadata"; import { ECSchemaRpcInterface } from "./ECSchemaRpcInterface"; /** * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally. * @beta */ export class RpcIncrementalSchemaLocater extends ECSqlSchemaLocater { _iModelProps; /** * Initializes a new instance of the RpcIncrementalSchemaLocater class. */ constructor(iModelProps, options) { super(options); this._iModelProps = iModelProps; } /** * Executes the given ECSql query and returns the resulting rows. * @param query The ECSql query to execute. * @param options Optional arguments to control the query result. * @returns A promise that resolves to the resulting rows. */ async executeQuery(query, options) { const ecSqlQueryClient = IModelReadRpcInterface.getClient(); const queryExecutor = { execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request), }; const queryOptions = { limit: { count: options?.limit }, rowFormat: QueryRowFormat.UseECSqlPropertyNames, }; const queryParameters = options && options.parameters ? QueryBinder.from(options.parameters) : undefined; const queryReader = new ECSqlReader(queryExecutor, query, queryParameters, queryOptions); return queryReader.toArray(); } /** * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata). * This is the full schema json with all elements that are defined in the schema. * @param schemaKey The schema key of the schema to be resolved. */ async getSchemaProps(schemaKey) { const rpcSchemaClient = ECSchemaRpcInterface.getClient(); return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name); } ; } //# sourceMappingURL=RpcIncrementalSchemaLocater.js.map