@itwin/ecschema-rpcinterface-impl 3.0.0-dev.80 → 3.0.0-dev.84

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,6 +1,6 @@
1
- import { ECSchemaRpcInterface } from "@itwin/ecschema-rpcinterface-common";
2
1
  import { IModelRpcProps } from "@itwin/core-common";
3
2
  import { SchemaKeyProps, SchemaProps } from "@itwin/ecschema-metadata";
3
+ import { ECSchemaRpcInterface } from "@itwin/ecschema-rpcinterface-common";
4
4
  /**
5
5
  * Implementation of the SchemaRpcInterface.
6
6
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"ECSchemaRpcImpl.d.ts","sourceRoot":"","sources":["../../src/ECSchemaRpcImpl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAc,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAYvE;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,oBAAoB;IACvD;;OAEG;WACW,QAAQ;IAItB;;;;;OAKG;YACW,iBAAiB;IAM/B;;;;;OAKG;IACmB,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAkB1F;;;;;;OAMG;IACmB,aAAa,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAkB1G"}
1
+ {"version":3,"file":"ECSchemaRpcImpl.d.ts","sourceRoot":"","sources":["../../src/ECSchemaRpcImpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAA8B,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAKvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAY3E;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,oBAAoB;IACvD;;OAEG;WACW,QAAQ;IAItB;;;;;OAKG;YACW,iBAAiB;IAM/B;;;;;OAKG;IACmB,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAmB1F;;;;;;OAMG;IACmB,aAAa,CAAC,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAkB1G"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ECSchemaRpcImpl = void 0;
4
+ const backend = require("@itwin/core-backend");
5
+ const core_common_1 = require("@itwin/core-common");
4
6
  /*---------------------------------------------------------------------------------------------
5
7
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
8
  * See LICENSE.md in the project root for license terms and full copyright notice.
7
9
  *--------------------------------------------------------------------------------------------*/
8
10
  const ecschema_rpcinterface_common_1 = require("@itwin/ecschema-rpcinterface-common");
9
- const core_common_1 = require("@itwin/core-common");
10
- const backend = require("@itwin/core-backend");
11
11
  /**
12
12
  * Implementation of the SchemaRpcInterface.
13
13
  * @internal
@@ -42,7 +42,8 @@ class ECSchemaRpcImpl extends ecschema_rpcinterface_common_1.ECSchemaRpcInterfac
42
42
  // Iterate over the rows returned from AsyncIterableIterator. The custom Query overload returns
43
43
  // a typed row instance instead of any.
44
44
  const schemaNameQuery = `SELECT Name as schemaName, VersionMajor as read, VersionWrite as write, VersionMinor as minor FROM main.meta.ECSchemaDef`;
45
- for await (const schemaDefinitionRow of iModelDb.query(schemaNameQuery)) {
45
+ for await (const row of iModelDb.query(schemaNameQuery, undefined, core_common_1.QueryRowFormat.UseJsPropertyNames)) {
46
+ const schemaDefinitionRow = row;
46
47
  const schemaFullName = schemaDefinitionRow.schemaName;
47
48
  const read = Number(schemaDefinitionRow.read);
48
49
  const write = Number(schemaDefinitionR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AAK,EAAE,KAAK,EAAE,CAAC,CAAC;SACnE;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACa,KAAK,CAAC,aAAa,CAAC,UAA0B,EAAE,UAAkB;QAChF,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAChE;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAE7D,IAAI,YAAY,CAAC,KAAK,KAAK,SAAS,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC7C;QAED,IAAI,YAAY,CAAC,MAAM,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;CACF;AArED,0CAqEC","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 { ECSchemaRpcInterface } from \"@itwin/ecschema-rpcinterface-common\";\nimport { IModelRpcProps, RpcManager } from \"@itwin/core-common\";\nimport * as backend from \"@itwin/core-backend\";\nimport { SchemaKeyProps, SchemaProps } from \"@itwin/ecschema-metadata\";\n\n/**\n * Defines the interface how the rows of the iModel query look like.\n */\ninterface SchemaNameRow {\n schemaName: string;\n read: string;\n write: string;\n minor: string;\n}\n\n/**\n * Implementation of the SchemaRpcInterface.\n * @internal\n */\nexport class ECSchemaRpcImpl extends ECSchemaRpcInterface {\n /**\n * Registers the RPC interface with its corresponding implementation class.\n */\n public static register() {\n RpcManager.registerImpl(ECSchemaRpcInterface, ECSchemaRpcImpl);\n }\n\n /**\n * Gets an iModelDb instance. It is important that the database has been opened before\n * otherwise it can't be found.\n * @param tokenProps The iModelToken props that hold the information which iModel is used.\n * @returns Instance of IModelDb.\n */\n private async getIModelDatabase(tokenProps: IModelRpcProps): Promise<backend.IModelDb> {\n return new Promise<backend.IModelDb>((resolve) => {\n resolve(backend.IModelDb.findByKey(tokenProps.key));\n });\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 override async getSchemaKeys(tokenProps: IModelRpcProps): Promise<SchemaKeyProps[]> {\n\n const schemaKeyProps: SchemaKeyProps[] = [];\n const iModelDb = await this.getIModelDatabase(tokenProps);\n\n // Iterate over the rows returned from AsyncIterableIterator. The custom Query overload returns\n // a typed row instance instead of any.\n const schemaNameQuery = `SELECT Name as schemaName, VersionMajor as read, VersionWrite as write, VersionMinor as minor FROM main.meta.ECSchemaDef`;\n for await (const schemaDefinitionRow of iModelDb.query(schemaNameQuery) as AsyncIterableIterator<SchemaNameRow>) {\n const schemaFullName = schemaDefinitionRow.schemaName;\n const read = Number(schemaDefinitionRow.read);\n const write = Number(schemaDefinitionRow.write);\n const minor = Number(schemaDefinitionRow.minor);\n schemaKeyProps.push({ name: schemaFullName, read, write, minor });\n }\n return 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 public override async getSchemaJSON(tokenProps: IModelRpcProps, schemaName: string): Promise<SchemaProps> {\n if (schemaName === undefined || schemaName.length < 1) {\n throw new Error(`Schema name must not be undefined or empty.`);\n }\n\n const iModelDb = await this.getIModelDatabase(tokenProps);\n const schemaResult = iModelDb.nativeDb.getSchema(schemaName);\n\n if (schemaResult.error !== undefined) {\n throw new Error(schemaResult.error.message);\n }\n\n if (schemaResult.result === undefined) {\n throw new Error(\"Schema does not exists\");\n }\n\n return JSON.parse(schemaResult.result);\n }\n}\n"]}
1
+ {"version":3,"file":"ECSchemaRpcImpl.js","sourceRoot":"","sources":["../../src/ECSchemaRpcImpl.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,oDAAgF;AAEhF;;;+FAG+F;AAC/F,sFAA2E;AAY3E;;;GAGG;AACH,MAAa,eAAgB,SAAQ,mDAAoB;IACvD;;OAEG;IACI,MAAM,CAAC,QAAQ;QACpB,wBAAU,CAAC,YAAY,CAAC,mDAAoB,EAAE,eAAe,CAAC,CAAC;IACjE,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,iBAAiB,CAAC,UAA0B;QACxD,OAAO,IAAI,OAAO,CAAmB,CAAC,OAAO,EAAE,EAAE;YAC/C,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACa,KAAK,CAAC,aAAa,CAAC,UAA0B;QAE5D,MAAM,cAAc,GAAqB,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAE1D,+FAA+F;QAC/F,uCAAuC;QACvC,MAAM,eAAe,GAAG,0HAA0H,CAAC;QACnJ,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,eAAe,EAAE,SAAS,EAAE,4BAAc,CAAC,kBAAkB,CAAC,EAAE;YACrG,MAAM,mBAAmB,GAAG,GAAoB,CAAC;YACjD,MAAM,cAAc,GAAG,mBAAmB,CAAC,UAAU,CAAC;YACtD,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAChD,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;SACnE;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED;;;;;;OAMG;IACa,KAAK,CAAC,aAAa,CAAC,UAA0B,EAAE,UAAkB;QAChF,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAChE;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAE7D,IAAI,YAAY,CAAC,KAAK,KAAK,SAAS,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;SAC7C;QAED,IAAI,YAAY,CAAC,MAAM,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;CACF;AAtED,0CAsEC","sourcesContent":["import * as backend from \"@itwin/core-backend\";\nimport { IModelRpcProps, QueryRowFormat, RpcManager } from \"@itwin/core-common\";\nimport { SchemaKeyProps, SchemaProps } from \"@itwin/ecschema-metadata\";\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 { ECSchemaRpcInterface } from \"@itwin/ecschema-rpcinterface-common\";\n\n/**\n * Defines the interface how the rows of the iModel query look like.\n */\ninterface SchemaNameRow {\n schemaName: string;\n read: string;\n write: string;\n minor: string;\n}\n\n/**\n * Implementation of the SchemaRpcInterface.\n * @internal\n */\nexport class ECSchemaRpcImpl extends ECSchemaRpcInterface {\n /**\n * Registers the RPC interface with its corresponding implementation class.\n */\n public static register() {\n RpcManager.registerImpl(ECSchemaRpcInterface, ECSchemaRpcImpl);\n }\n\n /**\n * Gets an iModelDb instance. It is important that the database has been opened before\n * otherwise it can't be found.\n * @param tokenProps The iModelToken props that hold the information which iModel is used.\n * @returns Instance of IModelDb.\n */\n private async getIModelDatabase(tokenProps: IModelRpcProps): Promise<backend.IModelDb> {\n return new Promise<backend.IModelDb>((resolve) => {\n resolve(backend.IModelDb.findByKey(tokenProps.key));\n });\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 override async getSchemaKeys(tokenProps: IModelRpcProps): Promise<SchemaKeyProps[]> {\n\n const schemaKeyProps: SchemaKeyProps[] = [];\n const iModelDb = await this.getIModelDatabase(tokenProps);\n\n // Iterate over the rows returned from AsyncIterableIterator. The custom Query overload returns\n // a typed row instance instead of any.\n const schemaNameQuery = `SELECT Name as schemaName, VersionMajor as read, VersionWrite as write, VersionMinor as minor FROM main.meta.ECSchemaDef`;\n for await (const row of iModelDb.query(schemaNameQuery, undefined, QueryRowFormat.UseJsPropertyNames)) {\n const schemaDefinitionRow = row as SchemaNameRow;\n const schemaFullName = schemaDefinitionRow.schemaName;\n const read = Number(schemaDefinitionRow.read);\n const write = Number(schemaDefinitionRow.write);\n const minor = Number(schemaDefinitionRow.minor);\n schemaKeyProps.push({ name: schemaFullName, read, write, minor });\n }\n return 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 public override async getSchemaJSON(tokenProps: IModelRpcProps, schemaName: string): Promise<SchemaProps> {\n if (schemaName === undefined || schemaName.length < 1) {\n throw new Error(`Schema name must not be undefined or empty.`);\n }\n\n const iModelDb = await this.getIModelDatabase(tokenProps);\n const schemaResult = iModelDb.nativeDb.getSchema(schemaName);\n\n if (schemaResult.error !== undefined) {\n throw new Error(schemaResult.error.message);\n }\n\n if (schemaResult.result === undefined) {\n throw new Error(\"Schema does not exists\");\n }\n\n return JSON.parse(schemaResult.result);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-rpcinterface-impl",
3
- "version": "3.0.0-dev.80",
3
+ "version": "3.0.0-dev.84",
4
4
  "description": "Schema RPC Interface backend implementation",
5
5
  "main": "lib/cjs/ecschema-rpc-impl.js",
6
6
  "typings": "lib/cjs/ecschema-rpc-impl",
@@ -20,24 +20,24 @@
20
20
  "url": "http://www.bentley.com"
21
21
  },
22
22
  "peerDependencies": {
23
- "@itwin/core-bentley": "3.0.0-dev.80",
24
- "@itwin/ecschema-metadata": "3.0.0-dev.80",
25
- "@itwin/ecschema-rpcinterface-common": "3.0.0-dev.80",
26
- "@itwin/core-geometry": "3.0.0-dev.80",
27
- "@itwin/core-backend": "3.0.0-dev.80",
28
- "@itwin/core-common": "3.0.0-dev.80",
29
- "@bentley/itwin-client": "3.0.0-dev.80"
23
+ "@itwin/core-bentley": "3.0.0-dev.84",
24
+ "@itwin/ecschema-metadata": "3.0.0-dev.84",
25
+ "@itwin/ecschema-rpcinterface-common": "3.0.0-dev.84",
26
+ "@itwin/core-geometry": "3.0.0-dev.84",
27
+ "@itwin/core-backend": "3.0.0-dev.84",
28
+ "@itwin/core-common": "3.0.0-dev.84",
29
+ "@bentley/itwin-client": "3.0.0-dev.84"
30
30
  },
31
31
  "devDependencies": {
32
- "@bentley/itwin-client": "3.0.0-dev.80",
33
- "@itwin/core-bentley": "3.0.0-dev.80",
34
- "@itwin/build-tools": "3.0.0-dev.80",
35
- "@itwin/ecschema-metadata": "3.0.0-dev.80",
36
- "@itwin/ecschema-rpcinterface-common": "3.0.0-dev.80",
37
- "@itwin/eslint-plugin": "3.0.0-dev.80",
38
- "@itwin/core-geometry": "3.0.0-dev.80",
39
- "@itwin/core-backend": "3.0.0-dev.80",
40
- "@itwin/core-common": "3.0.0-dev.80",
32
+ "@bentley/itwin-client": "3.0.0-dev.84",
33
+ "@itwin/core-bentley": "3.0.0-dev.84",
34
+ "@itwin/build-tools": "3.0.0-dev.84",
35
+ "@itwin/ecschema-metadata": "3.0.0-dev.84",
36
+ "@itwin/ecschema-rpcinterface-common": "3.0.0-dev.84",
37
+ "@itwin/eslint-plugin": "3.0.0-dev.84",
38
+ "@itwin/core-geometry": "3.0.0-dev.84",
39
+ "@itwin/core-backend": "3.0.0-dev.84",
40
+ "@itwin/core-common": "3.0.0-dev.84",
41
41
  "eslint": "^7.11.0",
42
42
  "rimraf": "^3.0.2",
43
43
  "typescript": "~4.4.0"