@itwin/presentation-testing 3.4.0-dev.9 → 3.4.1

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +52 -1
  2. package/lib/cjs/presentation-testing/ContentBuilder.d.ts +87 -87
  3. package/lib/cjs/presentation-testing/ContentBuilder.js +147 -147
  4. package/lib/cjs/presentation-testing/ContentBuilder.js.map +1 -1
  5. package/lib/cjs/presentation-testing/Helpers.d.ts +38 -35
  6. package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
  7. package/lib/cjs/presentation-testing/Helpers.js +125 -125
  8. package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
  9. package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts +66 -66
  10. package/lib/cjs/presentation-testing/HierarchyBuilder.js +68 -68
  11. package/lib/cjs/presentation-testing/HierarchyBuilder.js.map +1 -1
  12. package/lib/cjs/presentation-testing/IModelBuilder.d.ts +46 -0
  13. package/lib/cjs/presentation-testing/IModelBuilder.d.ts.map +1 -0
  14. package/lib/cjs/presentation-testing/IModelBuilder.js +171 -0
  15. package/lib/cjs/presentation-testing/IModelBuilder.js.map +1 -0
  16. package/lib/cjs/presentation-testing/IModelTestUtility.d.ts +25 -0
  17. package/lib/cjs/presentation-testing/IModelTestUtility.d.ts.map +1 -0
  18. package/lib/cjs/presentation-testing/IModelTestUtility.js +63 -0
  19. package/lib/cjs/presentation-testing/IModelTestUtility.js.map +1 -0
  20. package/lib/cjs/presentation-testing.d.ts +28 -21
  21. package/lib/cjs/presentation-testing.d.ts.map +1 -1
  22. package/lib/cjs/presentation-testing.js +44 -37
  23. package/lib/cjs/presentation-testing.js.map +1 -1
  24. package/lib/esm/presentation-testing/ContentBuilder.d.ts +87 -87
  25. package/lib/esm/presentation-testing/ContentBuilder.js +143 -143
  26. package/lib/esm/presentation-testing/ContentBuilder.js.map +1 -1
  27. package/lib/esm/presentation-testing/Helpers.d.ts +38 -35
  28. package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
  29. package/lib/esm/presentation-testing/Helpers.js +100 -100
  30. package/lib/esm/presentation-testing/Helpers.js.map +1 -1
  31. package/lib/esm/presentation-testing/HierarchyBuilder.d.ts +66 -66
  32. package/lib/esm/presentation-testing/HierarchyBuilder.js +63 -63
  33. package/lib/esm/presentation-testing/HierarchyBuilder.js.map +1 -1
  34. package/lib/esm/presentation-testing/IModelBuilder.d.ts +46 -0
  35. package/lib/esm/presentation-testing/IModelBuilder.d.ts.map +1 -0
  36. package/lib/esm/presentation-testing/IModelBuilder.js +147 -0
  37. package/lib/esm/presentation-testing/IModelBuilder.js.map +1 -0
  38. package/lib/esm/presentation-testing/IModelTestUtility.d.ts +25 -0
  39. package/lib/esm/presentation-testing/IModelTestUtility.d.ts.map +1 -0
  40. package/lib/esm/presentation-testing/IModelTestUtility.js +59 -0
  41. package/lib/esm/presentation-testing/IModelTestUtility.js.map +1 -0
  42. package/lib/esm/presentation-testing.d.ts +28 -21
  43. package/lib/esm/presentation-testing.d.ts.map +1 -1
  44. package/lib/esm/presentation-testing.js +32 -25
  45. package/lib/esm/presentation-testing.js.map +1 -1
  46. package/package.json +13 -13
@@ -1,36 +1,39 @@
1
- import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
2
- import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from "@itwin/presentation-backend";
3
- import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
4
- export { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };
5
- /** @public */
6
- export interface PresentationTestingInitProps {
7
- /** Properties for backend initialization */
8
- backendProps?: PresentationBackendProps;
9
- /** Properties for frontend initialization */
10
- frontendProps?: PresentationFrontendProps;
11
- /** IModelApp implementation */
12
- frontendApp?: {
13
- startup: (opts?: IModelAppOptions) => Promise<void>;
14
- };
15
- /** IModelApp options */
16
- frontendAppOptions?: IModelAppOptions;
17
- }
18
- /**
19
- * Initialize the framework for presentation testing. The function sets up backend,
20
- * frontend and RPC communication between them.
21
- *
22
- * @see `terminate`
23
- *
24
- * @public
25
- */
26
- export declare const initialize: (props?: PresentationTestingInitProps | undefined) => Promise<void>;
27
- /**
28
- * Undoes the setup made by `initialize`.
29
- * @param frontendApp IModelApp implementation
30
- *
31
- * @see `initialize`
32
- *
33
- * @public
34
- */
35
- export declare const terminate: (frontendApp?: typeof IModelApp) => Promise<void>;
1
+ import { IModelHostOptions } from "@itwin/core-backend";
2
+ import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
3
+ import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from "@itwin/presentation-backend";
4
+ import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
5
+ export { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };
6
+ /** @public */
7
+ export interface PresentationTestingInitProps {
8
+ /** Properties for backend initialization */
9
+ backendProps?: PresentationBackendProps;
10
+ /** Properties for `IModelHost` */
11
+ backendHostProps?: IModelHostOptions;
12
+ /** Properties for frontend initialization */
13
+ frontendProps?: PresentationFrontendProps;
14
+ /** IModelApp implementation */
15
+ frontendApp?: {
16
+ startup: (opts?: IModelAppOptions) => Promise<void>;
17
+ };
18
+ /** `IModelApp` options */
19
+ frontendAppOptions?: IModelAppOptions;
20
+ }
21
+ /**
22
+ * Initialize the framework for presentation testing. The function sets up backend,
23
+ * frontend and RPC communication between them.
24
+ *
25
+ * @see `terminate`
26
+ *
27
+ * @public
28
+ */
29
+ export declare const initialize: (props?: PresentationTestingInitProps | undefined) => Promise<void>;
30
+ /**
31
+ * Undoes the setup made by `initialize`.
32
+ * @param frontendApp IModelApp implementation
33
+ *
34
+ * @see `initialize`
35
+ *
36
+ * @public
37
+ */
38
+ export declare const terminate: (frontendApp?: typeof IModelApp) => Promise<void>;
36
39
  //# sourceMappingURL=Helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAErL,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAuBpI,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAEjF,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C,4CAA4C;IAC5C,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IACtE,wBAAwB;IACxB,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,qEA8BtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDAuBrB,CAAC"}
1
+ {"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AASA,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKpE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,uBAAuB,EACvI,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAsBpI,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAEjF,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C,4CAA4C;IAC5C,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IACtE,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,qEA8BtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDAuBrB,CAAC"}
@@ -1,126 +1,126 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.terminate = exports.initialize = exports.PresentationManagerMode = exports.HierarchyCacheMode = void 0;
23
- /*---------------------------------------------------------------------------------------------
24
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
- * See LICENSE.md in the project root for license terms and full copyright notice.
26
- *--------------------------------------------------------------------------------------------*/
27
- /** @packageDocumentation
28
- * @module Helpers
29
- */
30
- const rimraf = __importStar(require("rimraf"));
31
- const core_bentley_1 = require("@itwin/core-bentley");
32
- const core_backend_1 = require("@itwin/core-backend");
33
- const core_common_1 = require("@itwin/core-common");
34
- const core_frontend_1 = require("@itwin/core-frontend");
35
- const presentation_backend_1 = require("@itwin/presentation-backend");
36
- Object.defineProperty(exports, "HierarchyCacheMode", { enumerable: true, get: function () { return presentation_backend_1.HierarchyCacheMode; } });
37
- Object.defineProperty(exports, "PresentationManagerMode", { enumerable: true, get: function () { return presentation_backend_1.PresentationManagerMode; } });
38
- const presentation_common_1 = require("@itwin/presentation-common");
39
- const presentation_frontend_1 = require("@itwin/presentation-frontend");
40
- const path_1 = require("path");
41
- function initializeRpcInterfaces(interfaces) {
42
- const config = class extends core_common_1.RpcDefaultConfiguration {
43
- constructor() {
44
- super(...arguments);
45
- this.interfaces = () => interfaces;
46
- }
47
- };
48
- for (const definition of interfaces)
49
- core_common_1.RpcConfiguration.assign(definition, () => config);
50
- const instance = core_common_1.RpcConfiguration.obtain(config);
51
- try {
52
- core_common_1.RpcConfiguration.initializeInterfaces(instance);
53
- }
54
- catch {
55
- // this may fail with "Error: RPC interface "xxx" is already initialized." because
56
- // multiple different tests want to set up rpc interfaces
57
- }
58
- }
59
- let isInitialized = false;
60
- /**
61
- * Initialize the framework for presentation testing. The function sets up backend,
62
- * frontend and RPC communication between them.
63
- *
64
- * @see `terminate`
65
- *
66
- * @public
67
- */
68
- const initialize = async (props) => {
69
- var _a;
70
- if (isInitialized)
71
- return;
72
- if (!props)
73
- props = {};
74
- // set up rpc interfaces
75
- initializeRpcInterfaces([core_common_1.SnapshotIModelRpcInterface, core_common_1.IModelReadRpcInterface, presentation_common_1.PresentationRpcInterface]);
76
- // init backend
77
- // make sure backend gets assigned an id which puts its resources into a unique directory
78
- props.backendProps = (_a = props.backendProps) !== null && _a !== void 0 ? _a : {};
79
- if (!props.backendProps.id)
80
- props.backendProps.id = `test-${core_bentley_1.Guid.createValue()}`;
81
- await core_backend_1.IModelHost.startup({ cacheDir: (0, path_1.join)(__dirname, ".cache") });
82
- presentation_backend_1.Presentation.initialize(props.backendProps);
83
- // init frontend
84
- if (!props.frontendApp)
85
- props.frontendApp = core_frontend_1.NoRenderApp;
86
- await props.frontendApp.startup(props.frontendAppOptions);
87
- const defaultFrontendProps = {
88
- presentation: {
89
- activeLocale: core_frontend_1.IModelApp.localization.getLanguageList()[0],
90
- },
91
- };
92
- await presentation_frontend_1.Presentation.initialize({ ...defaultFrontendProps, ...props.frontendProps });
93
- isInitialized = true;
94
- };
95
- exports.initialize = initialize;
96
- /**
97
- * Undoes the setup made by `initialize`.
98
- * @param frontendApp IModelApp implementation
99
- *
100
- * @see `initialize`
101
- *
102
- * @public
103
- */
104
- const terminate = async (frontendApp = core_frontend_1.IModelApp) => {
105
- var _a, _b, _c;
106
- if (!isInitialized)
107
- return;
108
- // store directory that needs to be cleaned-up
109
- let hierarchiesCacheDirectory;
110
- const hierarchiesCacheConfig = (_b = (_a = presentation_backend_1.Presentation.initProps) === null || _a === void 0 ? void 0 : _a.caching) === null || _b === void 0 ? void 0 : _b.hierarchies;
111
- if ((hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.mode) === presentation_backend_1.HierarchyCacheMode.Disk)
112
- hierarchiesCacheDirectory = hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.directory;
113
- else if ((hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.mode) === presentation_backend_1.HierarchyCacheMode.Hybrid)
114
- hierarchiesCacheDirectory = (_c = hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.disk) === null || _c === void 0 ? void 0 : _c.directory;
115
- // terminate backend
116
- presentation_backend_1.Presentation.terminate();
117
- await core_backend_1.IModelHost.shutdown();
118
- if (hierarchiesCacheDirectory)
119
- rimraf.sync(hierarchiesCacheDirectory);
120
- // terminate frontend
121
- presentation_frontend_1.Presentation.terminate();
122
- await frontendApp.shutdown();
123
- isInitialized = false;
124
- };
125
- exports.terminate = terminate;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.terminate = exports.initialize = exports.PresentationManagerMode = exports.HierarchyCacheMode = void 0;
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ /** @packageDocumentation
28
+ * @module Helpers
29
+ */
30
+ const path_1 = require("path");
31
+ const rimraf = __importStar(require("rimraf"));
32
+ const core_backend_1 = require("@itwin/core-backend");
33
+ const core_bentley_1 = require("@itwin/core-bentley");
34
+ const core_common_1 = require("@itwin/core-common");
35
+ const core_frontend_1 = require("@itwin/core-frontend");
36
+ const presentation_backend_1 = require("@itwin/presentation-backend");
37
+ Object.defineProperty(exports, "HierarchyCacheMode", { enumerable: true, get: function () { return presentation_backend_1.HierarchyCacheMode; } });
38
+ Object.defineProperty(exports, "PresentationManagerMode", { enumerable: true, get: function () { return presentation_backend_1.PresentationManagerMode; } });
39
+ const presentation_common_1 = require("@itwin/presentation-common");
40
+ const presentation_frontend_1 = require("@itwin/presentation-frontend");
41
+ function initializeRpcInterfaces(interfaces) {
42
+ const config = class extends core_common_1.RpcDefaultConfiguration {
43
+ constructor() {
44
+ super(...arguments);
45
+ this.interfaces = () => interfaces;
46
+ }
47
+ };
48
+ for (const definition of interfaces)
49
+ core_common_1.RpcConfiguration.assign(definition, () => config);
50
+ const instance = core_common_1.RpcConfiguration.obtain(config);
51
+ try {
52
+ core_common_1.RpcConfiguration.initializeInterfaces(instance);
53
+ }
54
+ catch {
55
+ // this may fail with "Error: RPC interface "xxx" is already initialized." because
56
+ // multiple different tests want to set up rpc interfaces
57
+ }
58
+ }
59
+ let isInitialized = false;
60
+ /**
61
+ * Initialize the framework for presentation testing. The function sets up backend,
62
+ * frontend and RPC communication between them.
63
+ *
64
+ * @see `terminate`
65
+ *
66
+ * @public
67
+ */
68
+ const initialize = async (props) => {
69
+ var _a;
70
+ if (isInitialized)
71
+ return;
72
+ if (!props)
73
+ props = {};
74
+ // set up rpc interfaces
75
+ initializeRpcInterfaces([core_common_1.SnapshotIModelRpcInterface, core_common_1.IModelReadRpcInterface, presentation_common_1.PresentationRpcInterface]);
76
+ // init backend
77
+ // make sure backend gets assigned an id which puts its resources into a unique directory
78
+ props.backendProps = (_a = props.backendProps) !== null && _a !== void 0 ? _a : {};
79
+ if (!props.backendProps.id)
80
+ props.backendProps.id = `test-${core_bentley_1.Guid.createValue()}`;
81
+ await core_backend_1.IModelHost.startup({ cacheDir: (0, path_1.join)(__dirname, ".cache"), ...props.backendHostProps });
82
+ presentation_backend_1.Presentation.initialize(props.backendProps);
83
+ // init frontend
84
+ if (!props.frontendApp)
85
+ props.frontendApp = core_frontend_1.NoRenderApp;
86
+ await props.frontendApp.startup(props.frontendAppOptions);
87
+ const defaultFrontendProps = {
88
+ presentation: {
89
+ activeLocale: core_frontend_1.IModelApp.localization.getLanguageList()[0],
90
+ },
91
+ };
92
+ await presentation_frontend_1.Presentation.initialize({ ...defaultFrontendProps, ...props.frontendProps });
93
+ isInitialized = true;
94
+ };
95
+ exports.initialize = initialize;
96
+ /**
97
+ * Undoes the setup made by `initialize`.
98
+ * @param frontendApp IModelApp implementation
99
+ *
100
+ * @see `initialize`
101
+ *
102
+ * @public
103
+ */
104
+ const terminate = async (frontendApp = core_frontend_1.IModelApp) => {
105
+ var _a, _b, _c;
106
+ if (!isInitialized)
107
+ return;
108
+ // store directory that needs to be cleaned-up
109
+ let hierarchiesCacheDirectory;
110
+ const hierarchiesCacheConfig = (_b = (_a = presentation_backend_1.Presentation.initProps) === null || _a === void 0 ? void 0 : _a.caching) === null || _b === void 0 ? void 0 : _b.hierarchies;
111
+ if ((hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.mode) === presentation_backend_1.HierarchyCacheMode.Disk)
112
+ hierarchiesCacheDirectory = hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.directory;
113
+ else if ((hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.mode) === presentation_backend_1.HierarchyCacheMode.Hybrid)
114
+ hierarchiesCacheDirectory = (_c = hierarchiesCacheConfig === null || hierarchiesCacheConfig === void 0 ? void 0 : hierarchiesCacheConfig.disk) === null || _c === void 0 ? void 0 : _c.directory;
115
+ // terminate backend
116
+ presentation_backend_1.Presentation.terminate();
117
+ await core_backend_1.IModelHost.shutdown();
118
+ if (hierarchiesCacheDirectory)
119
+ rimraf.sync(hierarchiesCacheDirectory);
120
+ // terminate frontend
121
+ presentation_frontend_1.Presentation.terminate();
122
+ await frontendApp.shutdown();
123
+ isInitialized = false;
124
+ };
125
+ exports.terminate = terminate;
126
126
  //# sourceMappingURL=Helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,+CAAiC;AACjC,sDAA2C;AAC3C,sDAAiD;AACjD,oDAE4B;AAC5B,wDAAgF;AAChF,sEAAqL;AAyB5K,mGAzBA,yCAAkB,OAyBA;AAAE,wGAzB2F,8CAAuB,OAyB3F;AAxBpD,oEAAsE;AACtE,wEAAoI;AACpI,+BAA4B;AAE5B,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,qCAAuB;QAArC;;YACG,eAAU,GAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;QACrD,CAAC;KAAA,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,UAAU;QACjC,8BAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAEpD,MAAM,QAAQ,GAAG,8BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI;QACF,8BAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;KACjD;IAAC,MAAM;QACN,kFAAkF;QAClF,yDAAyD;KAC1D;AACH,CAAC;AAED,IAAI,aAAa,GAAG,KAAK,CAAC;AAgB1B;;;;;;;GAOG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,KAAoC,EAAE,EAAE;;IACvE,IAAI,aAAa;QACf,OAAO;IAET,IAAI,CAAC,KAAK;QACR,KAAK,GAAG,EAAE,CAAC;IAEb,wBAAwB;IACxB,uBAAuB,CAAC,CAAC,wCAA0B,EAAE,oCAAsB,EAAE,8CAAwB,CAAC,CAAC,CAAC;IAExG,eAAe;IACf,yFAAyF;IACzF,KAAK,CAAC,YAAY,GAAG,MAAA,KAAK,CAAC,YAAY,mCAAI,E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BAAsB,CAAE,SAAS,CAAC;SAC3D,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,yCAAkB,CAAC,MAAM;QACjE,yBAAyB,GAAG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,0CAAE,SAAS,CAAC;IAEtE,oBAAoB;IACpB,mCAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,yBAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB;QAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEzC,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB","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/** @packageDocumentation\r\n * @module Helpers\r\n */\r\nimport * as rimraf from \"rimraf\";\r\nimport { Guid } from \"@itwin/core-bentley\";\r\nimport { IModelHost } from \"@itwin/core-backend\";\r\nimport {\r\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\r\nimport { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from \"@itwin/presentation-backend\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\r\nimport { join } from \"path\";\r\n\r\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\r\n const config = class extends RpcDefaultConfiguration {\r\n public override interfaces: any = () => interfaces;\r\n };\r\n\r\n for (const definition of interfaces)\r\n RpcConfiguration.assign(definition, () => config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n try {\r\n RpcConfiguration.initializeInterfaces(instance);\r\n } catch {\r\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\r\n // multiple different tests want to set up rpc interfaces\r\n }\r\n}\r\n\r\nlet isInitialized = false;\r\n\r\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\r\n\r\n/** @public */\r\nexport interface PresentationTestingInitProps {\r\n /** Properties for backend initialization */\r\n backendProps?: PresentationBackendProps;\r\n /** Properties for frontend initialization */\r\n frontendProps?: PresentationFrontendProps;\r\n /** IModelApp implementation */\r\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\r\n /** IModelApp options */\r\n frontendAppOptions?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * Initialize the framework for presentation testing. The function sets up backend,\r\n * frontend and RPC communication between them.\r\n *\r\n * @see `terminate`\r\n *\r\n * @public\r\n */\r\nexport const initialize = async (props?: PresentationTestingInitProps) => {\r\n if (isInitialized)\r\n return;\r\n\r\n if (!props)\r\n props = {};\r\n\r\n // set up rpc interfaces\r\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\r\n\r\n // init backend\r\n // make sure backend gets assigned an id which puts its resources into a unique directory\r\n props.backendProps = props.backendProps ?? {};\r\n if (!props.backendProps.id)\r\n props.backendProps.id = `test-${Guid.createValue()}`;\r\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\") });\r\n PresentationBackend.initialize(props.backendProps);\r\n\r\n // init frontend\r\n if (!props.frontendApp)\r\n props.frontendApp = NoRenderApp;\r\n await props.frontendApp.startup(props.frontendAppOptions);\r\n const defaultFrontendProps: PresentationFrontendProps = {\r\n presentation: {\r\n activeLocale: IModelApp.localization.getLanguageList()[0],\r\n },\r\n };\r\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\r\n\r\n isInitialized = true;\r\n};\r\n\r\n/**\r\n * Undoes the setup made by `initialize`.\r\n * @param frontendApp IModelApp implementation\r\n *\r\n * @see `initialize`\r\n *\r\n * @public\r\n */\r\nexport const terminate = async (frontendApp = IModelApp) => {\r\n if (!isInitialized)\r\n return;\r\n\r\n // store directory that needs to be cleaned-up\r\n let hierarchiesCacheDirectory: string | undefined;\r\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\r\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\r\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\r\n\r\n // terminate backend\r\n PresentationBackend.terminate();\r\n await IModelHost.shutdown();\r\n if (hierarchiesCacheDirectory)\r\n rimraf.sync(hierarchiesCacheDirectory);\r\n\r\n // terminate frontend\r\n PresentationFrontend.terminate();\r\n await frontendApp.shutdown();\r\n\r\n isInitialized = false;\r\n};\r\n"]}
1
+ {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,+BAA4B;AAC5B,+CAAiC;AACjC,sDAAoE;AACpE,sDAA2C;AAC3C,oDAE4B;AAC5B,wDAAgF;AAChF,sEAEqC;AAwB5B,mGAzBP,yCAAkB,OAyBO;AAAE,wGAzBoF,8CAAuB,OAyBpF;AAvBpD,oEAAsE;AACtE,wEAAoI;AAEpI,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,qCAAuB;QAArC;;YACG,eAAU,GAAQ,GAAG,EAAE,CAAC,UAAU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QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB","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*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Helpers\n */\nimport { join } from \"path\";\nimport * as rimraf from \"rimraf\";\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport {\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\n} from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\nimport {\n HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode,\n} from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\n\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\n const config = class extends RpcDefaultConfiguration {\n public override interfaces: any = () => interfaces;\n };\n\n for (const definition of interfaces)\n RpcConfiguration.assign(definition, () => config);\n\n const instance = RpcConfiguration.obtain(config);\n\n try {\n RpcConfiguration.initializeInterfaces(instance);\n } catch {\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\n // multiple different tests want to set up rpc interfaces\n }\n}\n\nlet isInitialized = false;\n\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /** Properties for backend initialization */\n backendProps?: PresentationBackendProps;\n /** Properties for `IModelHost` */\n backendHostProps?: IModelHostOptions;\n /** Properties for frontend initialization */\n frontendProps?: PresentationFrontendProps;\n /** IModelApp implementation */\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\n /** `IModelApp` options */\n frontendAppOptions?: IModelAppOptions;\n}\n\n/**\n * Initialize the framework for presentation testing. The function sets up backend,\n * frontend and RPC communication between them.\n *\n * @see `terminate`\n *\n * @public\n */\nexport const initialize = async (props?: PresentationTestingInitProps) => {\n if (isInitialized)\n return;\n\n if (!props)\n props = {};\n\n // set up rpc interfaces\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\n\n // init backend\n // make sure backend gets assigned an id which puts its resources into a unique directory\n props.backendProps = props.backendProps ?? {};\n if (!props.backendProps.id)\n props.backendProps.id = `test-${Guid.createValue()}`;\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp)\n props.frontendApp = NoRenderApp;\n await props.frontendApp.startup(props.frontendAppOptions);\n const defaultFrontendProps: PresentationFrontendProps = {\n presentation: {\n activeLocale: IModelApp.localization.getLanguageList()[0],\n },\n };\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\n\n isInitialized = true;\n};\n\n/**\n * Undoes the setup made by `initialize`.\n * @param frontendApp IModelApp implementation\n *\n * @see `initialize`\n *\n * @public\n */\nexport const terminate = async (frontendApp = IModelApp) => {\n if (!isInitialized)\n return;\n\n // store directory that needs to be cleaned-up\n let hierarchiesCacheDirectory: string | undefined;\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\n\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory)\n rimraf.sync(hierarchiesCacheDirectory);\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n"]}
@@ -1,67 +1,67 @@
1
- import { IModelConnection } from "@itwin/core-frontend";
2
- import { Omit, Ruleset } from "@itwin/presentation-common";
3
- import { TreeNodeItem } from "@itwin/components-react";
4
- /**
5
- * Structure that describes a Node with any indexed properties
6
- * except `children`.
7
- *
8
- * @public
9
- */
10
- export interface MappedNode {
11
- /** Indexer for all properties in this data structure */
12
- [index: string]: any;
13
- /** Prohibited property */
14
- children?: never;
15
- }
16
- /**
17
- * Node in a hierarchy.
18
- * @public
19
- */
20
- export interface HierarchyNode extends Omit<MappedNode, "children"> {
21
- /** Children of this node */
22
- children?: HierarchyNode[];
23
- }
24
- /**
25
- * A function that converts `TreeNodeItem` into a new custom object.
26
- * @public
27
- */
28
- export declare type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;
29
- /**
30
- * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
31
- * @public
32
- */
33
- export declare const defaultNodeMappingFunc: NodeMappingFunc;
34
- /**
35
- * Properties for creating a `HierarchyBuilder` instance.
36
- * @public
37
- */
38
- export interface HierarchyBuilderProps {
39
- /** The iModel to pull data from */
40
- imodel: IModelConnection;
41
- /**
42
- * A function that maps node to something that the user of
43
- * this API is interested in. E.g. custom implementation may skip some unimportant
44
- * node properties to make resulting object smaller and easier to read.
45
- */
46
- nodeMappingFunc?: NodeMappingFunc;
47
- }
48
- /**
49
- * A class that constructs simple node hierarchy from specified
50
- * imodel and ruleset.
51
- *
52
- * @public
53
- */
54
- export declare class HierarchyBuilder {
55
- private readonly _iModel;
56
- private readonly _nodeMappingFunc;
57
- /** Constructor */
58
- constructor(props: HierarchyBuilderProps);
59
- private createSubHierarchy;
60
- private doCreateHierarchy;
61
- /**
62
- * Create a hierarchy using the supplied presentation ruleset.
63
- * @param rulesetOrId Either a [[Ruleset]] object or a ruleset id.
64
- */
65
- createHierarchy(rulesetOrId: Ruleset | string): Promise<HierarchyNode[]>;
66
- }
1
+ import { IModelConnection } from "@itwin/core-frontend";
2
+ import { Omit, Ruleset } from "@itwin/presentation-common";
3
+ import { TreeNodeItem } from "@itwin/components-react";
4
+ /**
5
+ * Structure that describes a Node with any indexed properties
6
+ * except `children`.
7
+ *
8
+ * @public
9
+ */
10
+ export interface MappedNode {
11
+ /** Indexer for all properties in this data structure */
12
+ [index: string]: any;
13
+ /** Prohibited property */
14
+ children?: never;
15
+ }
16
+ /**
17
+ * Node in a hierarchy.
18
+ * @public
19
+ */
20
+ export interface HierarchyNode extends Omit<MappedNode, "children"> {
21
+ /** Children of this node */
22
+ children?: HierarchyNode[];
23
+ }
24
+ /**
25
+ * A function that converts `TreeNodeItem` into a new custom object.
26
+ * @public
27
+ */
28
+ export declare type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;
29
+ /**
30
+ * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
31
+ * @public
32
+ */
33
+ export declare const defaultNodeMappingFunc: NodeMappingFunc;
34
+ /**
35
+ * Properties for creating a `HierarchyBuilder` instance.
36
+ * @public
37
+ */
38
+ export interface HierarchyBuilderProps {
39
+ /** The iModel to pull data from */
40
+ imodel: IModelConnection;
41
+ /**
42
+ * A function that maps node to something that the user of
43
+ * this API is interested in. E.g. custom implementation may skip some unimportant
44
+ * node properties to make resulting object smaller and easier to read.
45
+ */
46
+ nodeMappingFunc?: NodeMappingFunc;
47
+ }
48
+ /**
49
+ * A class that constructs simple node hierarchy from specified
50
+ * imodel and ruleset.
51
+ *
52
+ * @public
53
+ */
54
+ export declare class HierarchyBuilder {
55
+ private readonly _iModel;
56
+ private readonly _nodeMappingFunc;
57
+ /** Constructor */
58
+ constructor(props: HierarchyBuilderProps);
59
+ private createSubHierarchy;
60
+ private doCreateHierarchy;
61
+ /**
62
+ * Create a hierarchy using the supplied presentation ruleset.
63
+ * @param rulesetOrId Either a [[Ruleset]] object or a ruleset id.
64
+ */
65
+ createHierarchy(rulesetOrId: Ruleset | string): Promise<HierarchyNode[]>;
66
+ }
67
67
  //# sourceMappingURL=HierarchyBuilder.d.ts.map