@itwin/ecschema-rpcinterface-tests 3.0.0-dev.177 → 3.0.0-dev.181

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,13 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  /*---------------------------------------------------------------------------------------------
4
3
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
5
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
6
5
  *--------------------------------------------------------------------------------------------*/
7
- const chai = require("chai");
6
+ Object.defineProperty(exports, "__esModule", { value: true });
8
7
  const chai_1 = require("chai");
9
- const chaiAsPromised = require("chai-as-promised");
10
- chai.use(chaiAsPromised);
11
8
  const ecschema_rpcinterface_common_1 = require("@itwin/ecschema-rpcinterface-common");
12
9
  const TestContext_1 = require("./setup/TestContext");
13
10
  const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaRpcInterface.test.js","sourceRoot":"","sources":["../../src/frontend/SchemaRpcInterface.test.ts"],"names":[],"mappings":";;AAAA;;;+FAG+F;AAC/F,6BAA8B;AAC9B,+BAA8B;AAE9B,mDAAoD;AACpD,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAGzB,sFAA2E;AAC3E,qDAAkD;AAClD,gEAAkF;AAElF,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAEpC,IAAI,MAAwB,CAAC;IAC7B,IAAI,WAAwB,CAAC;IAE7B,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,WAAW,GAAG,MAAM,yBAAW,CAAC,QAAQ,EAAE,CAAC;QAC3C,MAAM,GAAG,MAAM,WAAW,CAAC,oBAAqB,CAAC,aAAa,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC,MAAM,KAAK,GAAqB,MAAM,mDAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3G,KAAK,CAAC,OAAO,CAAC,CAAC,IAAoB,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,6BAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnF,IAAA,aAAM,EAAC,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC,MAAM,KAAK,GAAqB,MAAM,mDAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3G,KAAK,CAAC,OAAO,CAAC,CAAC,IAAoB,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,6BAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnF,MAAM,UAAU,GAAgB,MAAM,mDAAoB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/H,IAAA,aAAM,EAAC,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,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\nimport chai = require(\"chai\");\r\nimport { expect } from \"chai\";\r\n\r\nimport chaiAsPromised = require(\"chai-as-promised\");\r\nchai.use(chaiAsPromised);\r\n\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { ECSchemaRpcInterface } from \"@itwin/ecschema-rpcinterface-common\";\r\nimport { TestContext } from \"./setup/TestContext\";\r\nimport { SchemaKey, SchemaKeyProps, SchemaProps } from \"@itwin/ecschema-metadata\";\r\n\r\ndescribe(\"Schema RPC Interface\", () => {\r\n\r\n let iModel: IModelConnection;\r\n let testContext: TestContext;\r\n\r\n before(async () => {\r\n testContext = await TestContext.instance();\r\n iModel = await testContext.iModelWithChangesets!.getConnection();\r\n });\r\n\r\n it(\"should get schema keys\", async () => {\r\n const schemaKeys: SchemaKey[] = [];\r\n const props: SchemaKeyProps[] = await ECSchemaRpcInterface.getClient().getSchemaKeys(iModel.getRpcProps());\r\n props.forEach((prop: SchemaKeyProps) => schemaKeys.push(SchemaKey.fromJSON(prop)));\r\n expect(schemaKeys).to.not.be.undefined;\r\n });\r\n\r\n it(\"should get schema JSON\", async () => {\r\n const schemaKeys: SchemaKey[] = [];\r\n const props: SchemaKeyProps[] = await ECSchemaRpcInterface.getClient().getSchemaKeys(iModel.getRpcProps());\r\n props.forEach((prop: SchemaKeyProps) => schemaKeys.push(SchemaKey.fromJSON(prop)));\r\n const schemaJSON: SchemaProps = await ECSchemaRpcInterface.getClient().getSchemaJSON(iModel.getRpcProps(), schemaKeys[0].name);\r\n expect(schemaJSON).to.not.be.undefined;\r\n });\r\n});\r\n"]}
1
+ {"version":3,"file":"SchemaRpcInterface.test.js","sourceRoot":"","sources":["../../src/frontend/SchemaRpcInterface.test.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;AAE/F,+BAA8B;AAG9B,sFAA2E;AAC3E,qDAAkD;AAClD,gEAAkF;AAElF,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAEpC,IAAI,MAAwB,CAAC;IAC7B,IAAI,WAAwB,CAAC;IAE7B,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,WAAW,GAAG,MAAM,yBAAW,CAAC,QAAQ,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\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\n\r\nimport { expect } from \"chai\";\r\n\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { ECSchemaRpcInterface } from \"@itwin/ecschema-rpcinterface-common\";\r\nimport { TestContext } from \"./setup/TestContext\";\r\nimport { SchemaKey, SchemaKeyProps, SchemaProps } from \"@itwin/ecschema-metadata\";\r\n\r\ndescribe(\"Schema RPC Interface\", () => {\r\n\r\n let iModel: IModelConnection;\r\n let testContext: TestContext;\r\n\r\n before(async () => {\r\n testContext = await TestContext.instance();\r\n iModel = await testContext.iModelWithChangesets!.getConnection();\r\n });\r\n\r\n it(\"should get schema keys\", async () => {\r\n const schemaKeys: SchemaKey[] = [];\r\n const props: SchemaKeyProps[] = await ECSchemaRpcInterface.getClient().getSchemaKeys(iModel.getRpcProps());\r\n props.forEach((prop: SchemaKeyProps) => schemaKeys.push(SchemaKey.fromJSON(prop)));\r\n expect(schemaKeys).to.not.be.undefined;\r\n });\r\n\r\n it(\"should get schema JSON\", async () => {\r\n const schemaKeys: SchemaKey[] = [];\r\n const props: SchemaKeyProps[] = await ECSchemaRpcInterface.getClient().getSchemaKeys(iModel.getRpcProps());\r\n props.forEach((prop: SchemaKeyProps) => schemaKeys.push(SchemaKey.fromJSON(prop)));\r\n const schemaJSON: SchemaProps = await ECSchemaRpcInterface.getClient().getSchemaJSON(iModel.getRpcProps(), schemaKeys[0].name);\r\n expect(schemaJSON).to.not.be.undefined;\r\n });\r\n});\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IModelSession.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/IModelSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,qBAAa,aAAa;IAEjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IAE5B,OAAO,CAAC,OAAO,CAAC,CAAuB;gBAEpB,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;WAMtD,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAsC1F,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI9C,IAAI,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAYnD"}
1
+ {"version":3,"file":"IModelSession.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/IModelSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAa,MAAM,sBAAsB,CAAC;AAGvE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,qBAAa,aAAa;IAEjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IAE5B,OAAO,CAAC,OAAO,CAAC,CAAuB;gBAEpB,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;WAMtD,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IA+C1F,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI9C,IAAI,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAYnD"}
@@ -7,8 +7,9 @@ exports.IModelSession = void 0;
7
7
  *--------------------------------------------------------------------------------------------*/
8
8
  const chai_1 = require("chai");
9
9
  const core_frontend_1 = require("@itwin/core-frontend");
10
- const imodelhub_client_1 = require("@bentley/imodelhub-client");
10
+ const imodels_client_management_1 = require("@itwin/imodels-client-management");
11
11
  const projects_client_1 = require("@itwin/projects-client");
12
+ const imodels_access_frontend_1 = require("@itwin/imodels-access-frontend");
12
13
  class IModelSession {
13
14
  constructor(iModelId, iTwinId, changesetId) {
14
15
  this.iTwinId = iTwinId;
@@ -16,7 +17,8 @@ class IModelSession {
16
17
  this.changesetId = changesetId;
17
18
  }
18
19
  static async create(requestContext, iModelData) {
19
- let contextId;
20
+ var _a;
21
+ let iTwinId;
20
22
  let imodelId;
21
23
  // Turn the iTwin name into an id
22
24
  if (iModelData.useITwinName && iModelData.iTwinName) {
@@ -32,21 +34,30 @@ class IModelSession {
32
34
  throw new Error(`ITwin ${iModelData.iTwinName} was not found for the user.`);
33
35
  else if (iTwinList.length > 1)
34
36
  throw new Error(`Multiple iTwins named ${iModelData.iTwinName} were found for the user.`);
35
- contextId = iTwinList[0].id;
37
+ iTwinId = iTwinList[0].id;
36
38
  }
37
39
  else
38
- contextId = iModelData.iTwinId;
40
+ iTwinId = iModelData.iTwinId;
39
41
  if (iModelData.useName) {
40
- const imodelClient = new imodelhub_client_1.IModelHubClient();
41
- const imodels = await imodelClient.iModels.get(requestContext, contextId, new imodelhub_client_1.IModelQuery().byName(iModelData.name));
42
- if (undefined === imodels || imodels.length === 0)
43
- throw new Error(`The iModel ${iModelData.name} does not exist in project ${contextId}.`);
44
- imodelId = imodels[0].wsgId;
42
+ const imodelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${(_a = process.env.IMJS_URL_PREFIX) !== null && _a !== void 0 ? _a : ""}api.bentley.com/imodels` } });
43
+ const iModels = imodelClient.iModels.getRepresentationList({
44
+ authorization: imodels_access_frontend_1.AccessTokenAdapter.toAuthorizationCallback(await core_frontend_1.IModelApp.getAccessToken()),
45
+ urlParams: {
46
+ projectId: iTwinId,
47
+ name: iModelData.name,
48
+ },
49
+ });
50
+ for await (const iModel of iModels) {
51
+ imodelId = iModel.id;
52
+ break;
53
+ }
54
+ if (!imodelId)
55
+ throw new Error(`The iModel ${iModelData.name} does not exist in iTwin ${iTwinId}.`);
45
56
  }
46
57
  else
47
58
  imodelId = iModelData.id;
48
- console.log(`Using iModel { name:${iModelData.name}, id:${imodelId}, iTwinId:${contextId}, changesetId:${iModelData.changesetId} }`); // eslint-disable-line no-console
49
- return new IModelSession(imodelId, contextId, iModelData.changesetId);
59
+ console.log(`Using iModel { name:${iModelData.name}, id:${imodelId}, iTwinId:${iTwinId}, changesetId:${iModelData.changesetId} }`); // eslint-disable-line no-console
60
+ return new IModelSession(imodelId, iTwinId, iModelData.changesetId);
50
61
  }
51
62
  async getConnection() {
52
63
  return undefined === this._iModel ? this.open() : this._iModel;
@@ -1 +1 @@
1
- {"version":3,"file":"IModelSession.js","sourceRoot":"","sources":["../../../src/frontend/setup/IModelSession.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA8B;AAC9B,wDAA4D;AAC5D,gEAAyE;AACzE,4DAA4G;AAI5G,MAAa,aAAa;IAQxB,YAAmB,QAAgB,EAAE,OAAe,EAAE,WAAoB;QACxE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,cAA2B,EAAE,UAAsB;QAC5E,IAAI,SAAS,CAAC;QACd,IAAI,QAAQ,CAAC;QAEb,iCAAiC;QACjC,IAAI,UAAU,CAAC,YAAY,IAAI,UAAU,CAAC,SAAS,EAAE;YACnD,MAAM,MAAM,GAAG,IAAI,sCAAoB,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAY,MAAM,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE;gBAC7D,MAAM,EAAE;oBACN,YAAY,EAAE,UAAU,CAAC,SAAS;oBA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AAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI;YACF,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;YAC3D,IAAI,CAAC,OAAO,GAAG,MAAM,oCAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClF,IAAA,aAAM,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;SAC/B;QAAC,OAAO,CAAM,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;SACpE;QAED,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AApED,sCAoEC","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 { expect } from \"chai\";\r\nimport { CheckpointConnection } from \"@itwin/core-frontend\";\r\nimport { IModelHubClient, IModelQuery } from \"@bentley/imodelhub-client\";\r\nimport { Project as ITwin, ProjectsAccessClient, ProjectsSearchableProperty } from \"@itwin/projects-client\";\r\nimport { IModelData } from \"../../common/Settings\";\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\n\r\nexport class IModelSession {\r\n\r\n public iTwinId: string;\r\n public iModelId: string;\r\n public changesetId?: string;\r\n\r\n private _iModel?: CheckpointConnection;\r\n\r\n public constructor(iModelId: string, iTwinId: string, changesetId?: string) {\r\n this.iTwinId = iTwinId;\r\n this.iModelId = iModelId;\r\n this.changesetId = changesetId;\r\n }\r\n\r\n public static async create(requestContext: AccessToken, iModelData: IModelData): Promise<IModelSession> {\r\n let contextId;\r\n let imodelId;\r\n\r\n // Turn the iTwin name into an id\r\n if (iModelData.useITwinName && iModelData.iTwinName) {\r\n const client = new ProjectsAccessClient();\r\n const iTwinList: ITwin[] = await client.getAll(requestContext, {\r\n search: {\r\n searchString: iModelData.iTwinName,\r\n propertyName: ProjectsSearchableProperty.Name,\r\n exactMatch: true,\r\n },\r\n });\r\n\r\n if (iTwinList.length === 0)\r\n throw new Error(`ITwin ${iModelData.iTwinName} was not found for the user.`);\r\n else if (iTwinList.length > 1)\r\n throw new Error(`Multiple iTwins named ${iModelData.iTwinName} were found for the user.`);\r\n\r\n contextId = iTwinList[0].id;\r\n } else\r\n contextId = iModelData.iTwinId!;\r\n\r\n if (iModelData.useName) {\r\n const imodelClient = new IModelHubClient();\r\n const imodels = await imodelClient.iModels.get(requestContext, contextId, new IModelQuery().byName(iModelData.name!));\r\n if (undefined === imodels || imodels.length === 0)\r\n throw new Error(`The iModel ${iModelData.name} does not exist in project ${contextId}.`);\r\n imodelId = imodels[0].wsgId;\r\n } else\r\n imodelId = iModelData.id!;\r\n\r\n console.log(`Using iModel { name:${iModelData.name}, id:${imodelId}, iTwinId:${contextId}, changesetId:${iModelData.changesetId} }`); // eslint-disable-line no-console\r\n\r\n return new IModelSession(imodelId, contextId, iModelData.changesetId);\r\n }\r\n\r\n public async getConnection(): Promise<CheckpointConnection> {\r\n return undefined === this._iModel ? this.open() : this._iModel;\r\n }\r\n\r\n public async open(): Promise<CheckpointConnection> {\r\n try {\r\n // eslint-disable-next-line no-console\r\n console.log(`Environment: ${process.env.IMJS_URL_PREFIX}`);\r\n this._iModel = await CheckpointConnection.openRemote(this.iTwinId, this.iModelId);\r\n expect(this._iModel).to.exist;\r\n } catch (e: any) {\r\n throw new Error(`Failed to open test iModel. Error: ${e.message}`);\r\n }\r\n\r\n return this._iModel;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelSession.js","sourceRoot":"","s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AAoB,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClF,IAAA,aAAM,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;SAC/B;QAAC,OAAO,CAAM,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;SACpE;QAED,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AA7ED,sCA6EC","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 { expect } from \"chai\";\r\nimport { CheckpointConnection, IModelApp } from \"@itwin/core-frontend\";\r\nimport { IModelsClient } from \"@itwin/imodels-client-management\";\r\nimport { Project as ITwin, ProjectsAccessClient, ProjectsSearchableProperty } from \"@itwin/projects-client\";\r\nimport { IModelData } from \"../../common/Settings\";\r\nimport { AccessToken } from \"@itwin/core-bentley\";\r\nimport { AccessTokenAdapter } from \"@itwin/imodels-access-frontend\";\r\n\r\nexport class IModelSession {\r\n\r\n public iTwinId: string;\r\n public iModelId: string;\r\n public changesetId?: string;\r\n\r\n private _iModel?: CheckpointConnection;\r\n\r\n public constructor(iModelId: string, iTwinId: string, changesetId?: string) {\r\n this.iTwinId = iTwinId;\r\n this.iModelId = iModelId;\r\n this.changesetId = changesetId;\r\n }\r\n\r\n public static async create(requestContext: AccessToken, iModelData: IModelData): Promise<IModelSession> {\r\n let iTwinId;\r\n let imodelId;\r\n\r\n // Turn the iTwin name into an id\r\n if (iModelData.useITwinName && iModelData.iTwinName) {\r\n const client = new ProjectsAccessClient();\r\n const iTwinList: ITwin[] = await client.getAll(requestContext, {\r\n search: {\r\n searchString: iModelData.iTwinName,\r\n propertyName: ProjectsSearchableProperty.Name,\r\n exactMatch: true,\r\n },\r\n });\r\n\r\n if (iTwinList.length === 0)\r\n throw new Error(`ITwin ${iModelData.iTwinName} was not found for the user.`);\r\n else if (iTwinList.length > 1)\r\n throw new Error(`Multiple iTwins named ${iModelData.iTwinName} were found for the user.`);\r\n\r\n iTwinId = iTwinList[0].id;\r\n } else\r\n iTwinId = iModelData.iTwinId!;\r\n\r\n if (iModelData.useName) {\r\n const imodelClient = new IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? \"\"}api.bentley.com/imodels`}});\r\n const iModels = imodelClient.iModels.getRepresentationList({\r\n authorization: AccessTokenAdapter.toAuthorizationCallback(await IModelApp.getAccessToken()),\r\n urlParams: {\r\n projectId: iTwinId,\r\n name: iModelData.name,\r\n },\r\n });\r\n for await (const iModel of iModels) {\r\n imodelId = iModel.id;\r\n break;\r\n }\r\n if (!imodelId)\r\n throw new Error(`The iModel ${iModelData.name} does not exist in iTwin ${iTwinId}.`);\r\n } else\r\n imodelId = iModelData.id!;\r\n\r\n console.log(`Using iModel { name:${iModelData.name}, id:${imodelId}, iTwinId:${iTwinId}, changesetId:${iModelData.changesetId} }`); // eslint-disable-line no-console\r\n\r\n return new IModelSession(imodelId, iTwinId, iModelData.changesetId);\r\n }\r\n\r\n public async getConnection(): Promise<CheckpointConnection> {\r\n return undefined === this._iModel ? this.open() : this._iModel;\r\n }\r\n\r\n public async open(): Promise<CheckpointConnection> {\r\n try {\r\n // eslint-disable-next-line no-console\r\n console.log(`Environment: ${process.env.IMJS_URL_PREFIX}`);\r\n this._iModel = await CheckpointConnection.openRemote(this.iTwinId, this.iModelId);\r\n expect(this._iModel).to.exist;\r\n } catch (e: any) {\r\n throw new Error(`Failed to open test iModel. Error: ${e.message}`);\r\n }\r\n\r\n return this._iModel;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TestContext.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AAKpE,OAAO,EAAoB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,qBAAa,WAAW;IACf,oBAAoB,EAAG,WAAW,CAAC;IAEnC,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,EAAE,QAAQ,CAAC;IAE1B,OAAO;IAGP,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAA0B;WAE/B,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAQpD,+EAA+E;IAC/E,OAAO,CAAC,uBAAuB;YAMjB,UAAU;CAqCzB"}
1
+ {"version":3,"file":"TestContext.d.ts","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAoB,MAAM,qBAAqB,CAAC;AAKpE,OAAO,EAAoB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,qBAAa,WAAW;IACf,oBAAoB,EAAG,WAAW,CAAC;IAEnC,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,EAAE,QAAQ,CAAC;IAE1B,OAAO;IAGP,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAA0B;WAE/B,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAQpD,+EAA+E;IAC/E,OAAO,CAAC,uBAAuB;YAMjB,UAAU;CAuCzB"}
@@ -13,7 +13,8 @@ const Settings_1 = require("../../common/Settings");
13
13
  const SideChannels_1 = require("../../common/SideChannels");
14
14
  const IModelSession_1 = require("./IModelSession");
15
15
  const core_common_1 = require("@itwin/core-common");
16
- const imodelhub_client_1 = require("@bentley/imodelhub-client");
16
+ const imodels_access_frontend_1 = require("@itwin/imodels-access-frontend");
17
+ const imodels_client_management_1 = require("@itwin/imodels-client-management");
17
18
  class TestContext {
18
19
  constructor(env) {
19
20
  this.settings = new Settings_1.Settings(env);
@@ -32,6 +33,7 @@ class TestContext {
32
33
  core_common_1.BentleyCloudRpcManager.initializeClient({ info, uriPrefix }, (0, Settings_1.getRpcInterfaces)());
33
34
  }
34
35
  async initialize() {
36
+ var _a;
35
37
  (0, chai_1.expect)(this.settings.users.length).to.be.gte(1, `Unexpected number of users found in settings - got ${this.settings.users.length}, expected at least 2`);
36
38
  // Print out the configuration
37
39
  console.log(this.settings.toString()); // eslint-disable-line
@@ -53,10 +55,11 @@ class TestContext {
53
55
  this.iModelWithChangesets = await IModelSession_1.IModelSession.create(this.adminUserAccessToken, iModelData);
54
56
  this.iTwinId = this.iModelWithChangesets.iTwinId;
55
57
  this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
58
+ const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${(_a = process.env.IMJS_URL_PREFIX) !== null && _a !== void 0 ? _a : ""}api.bentley.com/imodels` } });
56
59
  await core_frontend_1.NoRenderApp.startup({
57
60
  applicationId: this.settings.gprid,
58
61
  authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.adminUserAccessToken),
59
- hubAccess: new imodelhub_client_1.IModelHubFrontend(),
62
+ hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
60
63
  });
61
64
  console.log("TestSetup: Done"); // eslint-disable-line
62
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TestContext.js","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA8B;AAC9B,sDAAoE;AACpE,wDAAmD;AACnD,uEAEkD;AAClD,oDAAmE;AACnE,4DAAqE;AACrE,mDAAgD;AAChD,oDAAyE;AACzE,gEAA8D;AAE9D,MAAa,WAAW;IAQtB,YAAo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;AAhEH,kCAiEC;AAtDgB,qBAAS,GAAiB,SAAS,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\n\r\nimport { expect } from \"chai\";\r\nimport { AccessToken, Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { NoRenderApp } from \"@itwin/core-frontend\";\r\nimport {\r\n getAccessTokenFromBackend, TestBrowserAuthorizationClientConfiguration, TestFrontendAuthorizationClient, TestUserCredentials,\r\n} from \"@itwin/oidc-signin-tool/lib/cjs/frontend\";\r\nimport { getRpcInterfaces, Settings } from \"../../common/Settings\";\r\nimport { getProcessEnvFromBackend } from \"../../common/SideChannels\";\r\nimport { IModelSession } from \"./IModelSession\";\r\nimport { BentleyCloudRpcManager, OpenAPIInfo } from \"@itwin/core-common\";\r\nimport { IModelHubFrontend } from \"@bentley/imodelhub-client\";\r\n\r\nexport class TestContext {\r\n public adminUserAccessToken!: AccessToken;\r\n\r\n public iModelWithChangesets?: IModelSession;\r\n public iTwinId?: string;\r\n\r\n public settings: Settings;\r\n\r\n private constructor(env: NodeJS.ProcessEnv) {\r\n this.settings = new Settings(env);\r\n }\r\n private static _instance?: TestContext = undefined;\r\n\r\n public static async instance(): Promise<TestContext> {\r\n if (this._instance === undefined) {\r\n this._instance = new TestContext(await getProcessEnvFromBackend());\r\n await this._instance.initialize();\r\n }\r\n return this._instance;\r\n }\r\n\r\n /** Initialize configuration for the rpc interfaces used by the application. */\r\n private initializeRpcInterfaces(info: OpenAPIInfo) {\r\n // Url without trailing slash\r\n const uriPrefix: string = this.settings.Backend.location.replace(/\\/$/, \"\");\r\n BentleyCloudRpcManager.initializeClient({ info, uriPrefix }, getRpcInterfaces());\r\n }\r\n\r\n private async initialize() {\r\n expect(this.settings.users.length).to.be.gte(1, `Unexpected number of users found in settings - got ${this.settings.users.length}, expected at least 2`);\r\n\r\n // Print out the configuration\r\n console.log(this.settings.toString()); // eslint-disable-line\r\n\r\n // Configure iTwin.js frontend logging to go to the console\r\n Logger.initializeToConsole();\r\n Logger.setLevelDefault(this.settings.logLevel === undefined ? LogLevel.Warning : this.settings.logLevel);\r\n\r\n if (undefined !== this.settings.oidcClientId) {\r\n this.adminUserAccessToken = await getAccessTokenFromBackend({\r\n email: this.settings.users[0].email,\r\n password: this.settings.users[0].password,\r\n } as TestUserCredentials, {\r\n clientId: this.settings.oidcClientId,\r\n redirectUri: this.settings.oidcRedirect,\r\n scope: this.settings.oidcScopes,\r\n authority: this.settings.oidcAuthority,\r\n } as TestBrowserAuthorizationClientConfiguration);\r\n }\r\n\r\n const iModelData = this.settings.iModel;\r\n\r\n this.iModelWithChangesets = await IModelSession.create(this.adminUserAccessToken, iModelData);\r\n this.iTwinId = this.iModelWithChangesets.iTwinId;\r\n\r\n this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });\r\n\r\n await NoRenderApp.startup({\r\n applicationId: this.settings.gprid,\r\n authorizationClient: new TestFrontendAuthorizationClient(this.adminUserAccessToken),\r\n hubAccess: new IModelHubFrontend(),\r\n });\r\n\r\n console.log(\"TestSetup: Done\"); // eslint-disable-line\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"TestContext.js","sourceRoot":"","sources":["../../../src/frontend/setup/TestContext.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA8B;AAC9B,sDAAoE;AACpE,wDAAmD;AACnD,uEAEkD;AAClD,oDAAmE;AACnE,4DAAqE;AACrE,mDAAgD;AAChD,oDAAyE;AACzE,4EAAuE;AACvE,gFAAiE;AAEjE,MAAa,WAAW;IAQtB,YAAoB,GAAsB;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAGM,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,IAAI,IAAI,CAAC,SAAS,KA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AAsB;IACzD,CAAC;;AAlEH,kCAmEC;AAxDgB,qBAAS,GAAiB,SAAS,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\n\r\nimport { expect } from \"chai\";\r\nimport { AccessToken, Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { NoRenderApp } from \"@itwin/core-frontend\";\r\nimport {\r\n getAccessTokenFromBackend, TestBrowserAuthorizationClientConfiguration, TestFrontendAuthorizationClient, TestUserCredentials,\r\n} from \"@itwin/oidc-signin-tool/lib/cjs/frontend\";\r\nimport { getRpcInterfaces, Settings } from \"../../common/Settings\";\r\nimport { getProcessEnvFromBackend } from \"../../common/SideChannels\";\r\nimport { IModelSession } from \"./IModelSession\";\r\nimport { BentleyCloudRpcManager, OpenAPIInfo } from \"@itwin/core-common\";\r\nimport { FrontendIModelsAccess } from \"@itwin/imodels-access-frontend\";\r\nimport { IModelsClient } from \"@itwin/imodels-client-management\";\r\n\r\nexport class TestContext {\r\n public adminUserAccessToken!: AccessToken;\r\n\r\n public iModelWithChangesets?: IModelSession;\r\n public iTwinId?: string;\r\n\r\n public settings: Settings;\r\n\r\n private constructor(env: NodeJS.ProcessEnv) {\r\n this.settings = new Settings(env);\r\n }\r\n private static _instance?: TestContext = undefined;\r\n\r\n public static async instance(): Promise<TestContext> {\r\n if (this._instance === undefined) {\r\n this._instance = new TestContext(await getProcessEnvFromBackend());\r\n await this._instance.initialize();\r\n }\r\n return this._instance;\r\n }\r\n\r\n /** Initialize configuration for the rpc interfaces used by the application. */\r\n private initializeRpcInterfaces(info: OpenAPIInfo) {\r\n // Url without trailing slash\r\n const uriPrefix: string = this.settings.Backend.location.replace(/\\/$/, \"\");\r\n BentleyCloudRpcManager.initializeClient({ info, uriPrefix }, getRpcInterfaces());\r\n }\r\n\r\n private async initialize() {\r\n expect(this.settings.users.length).to.be.gte(1, `Unexpected number of users found in settings - got ${this.settings.users.length}, expected at least 2`);\r\n\r\n // Print out the configuration\r\n console.log(this.settings.toString()); // eslint-disable-line\r\n\r\n // Configure iTwin.js frontend logging to go to the console\r\n Logger.initializeToConsole();\r\n Logger.setLevelDefault(this.settings.logLevel === undefined ? LogLevel.Warning : this.settings.logLevel);\r\n\r\n if (undefined !== this.settings.oidcClientId) {\r\n this.adminUserAccessToken = await getAccessTokenFromBackend({\r\n email: this.settings.users[0].email,\r\n password: this.settings.users[0].password,\r\n } as TestUserCredentials, {\r\n clientId: this.settings.oidcClientId,\r\n redirectUri: this.settings.oidcRedirect,\r\n scope: this.settings.oidcScopes,\r\n authority: this.settings.oidcAuthority,\r\n } as TestBrowserAuthorizationClientConfiguration);\r\n }\r\n\r\n const iModelData = this.settings.iModel;\r\n\r\n this.iModelWithChangesets = await IModelSession.create(this.adminUserAccessToken, iModelData);\r\n this.iTwinId = this.iModelWithChangesets.iTwinId;\r\n\r\n this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });\r\n\r\n const iModelClient = new IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? \"\"}api.bentley.com/imodels`}});\r\n\r\n await NoRenderApp.startup({\r\n applicationId: this.settings.gprid,\r\n authorizationClient: new TestFrontendAuthorizationClient(this.adminUserAccessToken),\r\n hubAccess: new FrontendIModelsAccess(iModelClient),\r\n });\r\n\r\n console.log(\"TestSetup: Done\"); // eslint-disable-line\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-rpcinterface-tests",
3
- "version": "3.0.0-dev.177",
3
+ "version": "3.0.0-dev.181",
4
4
  "description": "Integration tests for the Schema RPC Interface",
5
5
  "author": {
6
6
  "name": "Bentley Systems, Inc.",
@@ -11,20 +11,22 @@
11
11
  "url": "https://github.com/iTwin/itwinjs-core/tree/master/full-stack-tests/ecschema-rpc-interface"
12
12
  },
13
13
  "dependencies": {
14
- "@bentley/imodelhub-client": "3.0.0-dev.177",
15
- "@bentley/itwin-client": "3.0.0-dev.177",
16
- "@itwin/build-tools": "3.0.0-dev.177",
17
- "@itwin/certa": "3.0.0-dev.177",
18
- "@itwin/core-bentley": "3.0.0-dev.177",
19
- "@itwin/core-common": "3.0.0-dev.177",
20
- "@itwin/core-frontend": "3.0.0-dev.177",
21
- "@itwin/core-geometry": "3.0.0-dev.177",
22
- "@itwin/core-quantity": "3.0.0-dev.177",
23
- "@itwin/ecschema-metadata": "3.0.0-dev.177",
24
- "@itwin/ecschema-rpcinterface-common": "3.0.0-dev.177",
14
+ "@bentley/itwin-client": "3.0.0-dev.181",
15
+ "@itwin/build-tools": "3.0.0-dev.181",
16
+ "@itwin/certa": "3.0.0-dev.181",
17
+ "@itwin/core-bentley": "3.0.0-dev.181",
18
+ "@itwin/core-common": "3.0.0-dev.181",
19
+ "@itwin/core-frontend": "3.0.0-dev.181",
20
+ "@itwin/core-geometry": "3.0.0-dev.181",
21
+ "@itwin/core-quantity": "3.0.0-dev.181",
22
+ "@itwin/ecschema-metadata": "3.0.0-dev.181",
23
+ "@itwin/ecschema-rpcinterface-common": "3.0.0-dev.181",
24
+ "@itwin/imodels-access-backend": "~0.3.0",
25
+ "@itwin/imodels-access-frontend": "~0.3.0",
26
+ "@itwin/imodels-client-management": "~0.3.0",
25
27
  "@itwin/oidc-signin-tool": "3.0.0",
26
- "@itwin/presentation-common": "3.0.0-dev.177",
27
- "@itwin/presentation-frontend": "3.0.0-dev.177",
28
+ "@itwin/presentation-common": "3.0.0-dev.181",
29
+ "@itwin/presentation-frontend": "3.0.0-dev.181",
28
30
  "chai": "^4.1.2",
29
31
  "chai-as-promised": "^7",
30
32
  "dotenv": "^10.0.0",
@@ -34,9 +36,9 @@
34
36
  "puppeteer": "chrome-86"
35
37
  },
36
38
  "devDependencies": {
37
- "@itwin/core-backend": "3.0.0-dev.177",
38
- "@itwin/eslint-plugin": "3.0.0-dev.177",
39
- "@itwin/express-server": "3.0.0-dev.177",
39
+ "@itwin/core-backend": "3.0.0-dev.181",
40
+ "@itwin/eslint-plugin": "3.0.0-dev.181",
41
+ "@itwin/express-server": "3.0.0-dev.181",
40
42
  "@itwin/projects-client": "^0.3.0",
41
43
  "@types/chai": "^4.1.4",
42
44
  "@types/chai-as-promised": "^7",