UNPKG

@itwin/ecschema-rpcinterface-common

Version:

Schema RPC Interface common interface

55 lines 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RpcIncrementalSchemaLocater = void 0; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ const core_common_1 = require("@itwin/core-common"); const ecschema_metadata_1 = require("@itwin/ecschema-metadata"); const ECSchemaRpcInterface_1 = require("./ECSchemaRpcInterface"); /** * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally. * @beta */ class RpcIncrementalSchemaLocater extends ecschema_metadata_1.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 = core_common_1.IModelReadRpcInterface.getClient(); const queryExecutor = { execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request), }; const queryOptions = { limit: { count: options?.limit }, rowFormat: core_common_1.QueryRowFormat.UseECSqlPropertyNames, }; const queryParameters = options && options.parameters ? core_common_1.QueryBinder.from(options.parameters) : undefined; const queryReader = new core_common_1.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_1.ECSchemaRpcInterface.getClient(); return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name); } ; } exports.RpcIncrementalSchemaLocater = RpcIncrementalSchemaLocater; //# sourceMappingURL=RpcIncrementalSchemaLocater.js.map