@itwin/presentation-testing 5.1.2 → 5.2.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.
- package/CHANGELOG.md +21 -0
- package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.js +6 -2
- package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
- package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts +12 -0
- package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/HierarchyBuilder.js +5 -0
- package/lib/cjs/presentation-testing/HierarchyBuilder.js.map +1 -1
- package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/esm/presentation-testing/Helpers.js +9 -5
- package/lib/esm/presentation-testing/Helpers.js.map +1 -1
- package/lib/esm/presentation-testing/HierarchyBuilder.d.ts +12 -0
- package/lib/esm/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
- package/lib/esm/presentation-testing/HierarchyBuilder.js +5 -0
- package/lib/esm/presentation-testing/HierarchyBuilder.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Change Log - @itwin/presentation-testing
|
|
2
2
|
|
|
3
|
+
## 5.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#810](https://github.com/iTwin/presentation/pull/810): Fix the package not being usable in `cjs` builds due to usage of `import.meta`.
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- @itwin/presentation-components@5.8.0
|
|
10
|
+
|
|
11
|
+
## 5.2.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#804](https://github.com/iTwin/presentation/pull/804): Deprecated all tree-related APIs.
|
|
16
|
+
|
|
17
|
+
As the new generation hierarchy building APIs are now available, the old tree-related APIs are now deprecated. See reasoning and migration guide [here](https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/packages/hierarchies/learning/PresentationRulesMigrationGuide.md).
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies:
|
|
22
|
+
- @itwin/presentation-components@5.7.0
|
|
23
|
+
|
|
3
24
|
## 5.1.2
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAA8B,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAA8B,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAGlB,wBAAwB,IAAI,wBAAwB,EACrD,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AA2BpI,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChC,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;IACtC,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,WAAkB,4BAA4B,kBA6CpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDA0BrB,CAAC"}
|
|
@@ -77,6 +77,11 @@ const initialize = async (props) => {
|
|
|
77
77
|
if (!props) {
|
|
78
78
|
props = {};
|
|
79
79
|
}
|
|
80
|
+
core_bentley_1.Logger.initializeToConsole();
|
|
81
|
+
core_bentley_1.Logger.setLevelDefault(core_bentley_1.LogLevel.Warning);
|
|
82
|
+
core_bentley_1.Logger.setLevel("i18n", core_bentley_1.LogLevel.Error);
|
|
83
|
+
core_bentley_1.Logger.setLevel("SQLite", core_bentley_1.LogLevel.Error);
|
|
84
|
+
core_bentley_1.Logger.setLevel(presentation_backend_1.PresentationBackendNativeLoggerCategory.ECObjects, core_bentley_1.LogLevel.Warning);
|
|
80
85
|
// set up rpc interfaces
|
|
81
86
|
initializeRpcInterfaces(props.rpcs ?? [core_common_1.SnapshotIModelRpcInterface, core_common_1.IModelReadRpcInterface, presentation_common_1.PresentationRpcInterface]);
|
|
82
87
|
// init backend
|
|
@@ -87,8 +92,7 @@ const initialize = async (props) => {
|
|
|
87
92
|
props.backendProps.id = `test-${core_bentley_1.Guid.createValue()}`; // eslint-disable-line @itwin/no-internal
|
|
88
93
|
}
|
|
89
94
|
await core_backend_1.IModelHost.startup({
|
|
90
|
-
|
|
91
|
-
cacheDir: (0, path_1.join)(typeof __dirname !== "undefined" ? __dirname : import.meta.url, ".cache", `${process.pid}`),
|
|
95
|
+
cacheDir: (0, path_1.join)((0, FilenameUtils_js_1.getTestOutputDir)(), ".cache", `${process.pid}`),
|
|
92
96
|
...props.backendHostProps,
|
|
93
97
|
});
|
|
94
98
|
presentation_backend_1.Presentation.initialize(props.backendProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+BAA4B;AAC5B,+CAAiC;AACjC,sDAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+BAA4B;AAC5B,+CAAiC;AACjC,sDAAoE;AACpE,sDAA6D;AAC7D,oDAA2J;AAC3J,wDAAgF;AAChF,sEAKqC;AA6B5B,mGAjCP,yCAAkB,OAiCO;AA5B3B,oEAAsE;AACtE,wEAAoI;AACpI,yDAAwE;AAExE,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,qCAAuB;QAClC,UAAU,GAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;KACpD,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE,CAAC;QACpC,8CAA8C;QAC9C,8BAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,QAAQ,GAAG,8BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI,CAAC;QACH,8BAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAChD,qB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E,CAAC;IAED,oBAAoB;IACpB,mCAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,yBAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACzC,CAAC;IAED,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AA1BW,QAAA,SAAS,aA0BpB","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 */\n\nimport { join } from \"path\";\nimport * as rimraf from \"rimraf\";\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface } from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\nimport {\n HierarchyCacheMode,\n Presentation as PresentationBackend,\n PresentationBackendNativeLoggerCategory,\n PresentationManagerProps as PresentationBackendProps,\n} from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\nimport { getTestOutputDir, setTestOutputDir } from \"./FilenameUtils.js\";\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 // eslint-disable-next-line @itwin/no-internal\n RpcConfiguration.assign(definition, /* istanbul ignore next */ () => config);\n }\n\n const instance = RpcConfiguration.obtain(config);\n\n try {\n RpcConfiguration.initializeInterfaces(instance);\n /* c8 ignore start */\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 /* c8 ignore end */\n}\n\nlet isInitialized = false;\n\nexport { HierarchyCacheMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /**\n * RPC interfaces to enable. Defaults to `[SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]`.\n *\n * Note: Implementations for these interfaces are **not** automatically registered on the backend - that has to be done manually.\n */\n rpcs?: RpcInterfaceDefinition[];\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 /** Custom test output directory. Defaults to temporary directory provided by the OS. */\n testOutputDir?: string;\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\n if (!props) {\n props = {};\n }\n\n Logger.initializeToConsole();\n Logger.setLevelDefault(LogLevel.Warning);\n Logger.setLevel(\"i18n\", LogLevel.Error);\n Logger.setLevel(\"SQLite\", LogLevel.Error);\n Logger.setLevel(PresentationBackendNativeLoggerCategory.ECObjects, LogLevel.Warning);\n\n // set up rpc interfaces\n initializeRpcInterfaces(props.rpcs ?? [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 // eslint-disable-next-line @itwin/no-internal\n if (!props.backendProps.id) {\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n }\n await IModelHost.startup({\n cacheDir: join(getTestOutputDir(), \".cache\", `${process.pid}`),\n ...props.backendHostProps,\n });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp) {\n props.frontendApp = NoRenderApp;\n }\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 setTestOutputDir(props.testOutputDir);\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\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\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory) {\n rimraf.sync(hierarchiesCacheDirectory);\n }\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n"]}
|
|
@@ -9,6 +9,8 @@ import { Omit, Ruleset } from "@itwin/presentation-common";
|
|
|
9
9
|
* except `children`.
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
13
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
12
14
|
*/
|
|
13
15
|
export interface MappedNode {
|
|
14
16
|
/** Indexer for all properties in this data structure */
|
|
@@ -19,6 +21,8 @@ export interface MappedNode {
|
|
|
19
21
|
/**
|
|
20
22
|
* Node in a hierarchy.
|
|
21
23
|
* @public
|
|
24
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
25
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
22
26
|
*/
|
|
23
27
|
export interface HierarchyNode extends Omit<MappedNode, "children"> {
|
|
24
28
|
/** Children of this node */
|
|
@@ -27,16 +31,22 @@ export interface HierarchyNode extends Omit<MappedNode, "children"> {
|
|
|
27
31
|
/**
|
|
28
32
|
* A function that converts `TreeNodeItem` into a new custom object.
|
|
29
33
|
* @public
|
|
34
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
35
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
30
36
|
*/
|
|
31
37
|
export type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;
|
|
32
38
|
/**
|
|
33
39
|
* Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
|
|
34
40
|
* @public
|
|
41
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
42
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
35
43
|
*/
|
|
36
44
|
export declare const defaultNodeMappingFunc: NodeMappingFunc;
|
|
37
45
|
/**
|
|
38
46
|
* Properties for creating a `HierarchyBuilder` instance.
|
|
39
47
|
* @public
|
|
48
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
49
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
40
50
|
*/
|
|
41
51
|
export interface HierarchyBuilderProps {
|
|
42
52
|
/** The iModel to pull data from */
|
|
@@ -53,6 +63,8 @@ export interface HierarchyBuilderProps {
|
|
|
53
63
|
* imodel and ruleset.
|
|
54
64
|
*
|
|
55
65
|
* @public
|
|
66
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
67
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
56
68
|
*/
|
|
57
69
|
export declare class HierarchyBuilder {
|
|
58
70
|
private readonly _iModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HierarchyBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAqB,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAI9E;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;IACjE,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,UAAU,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,eAMpC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IAEnD,kBAAkB;gBACN,KAAK,EAAE,qBAAqB;YAK1B,kBAAkB;YAalB,iBAAiB;IAM/B;;;OAGG;IACU,eAAe,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAStF"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
6
7
|
/** @packageDocumentation
|
|
7
8
|
* @module Hierarchies
|
|
8
9
|
*/
|
|
@@ -14,6 +15,8 @@ const presentation_frontend_1 = require("@itwin/presentation-frontend");
|
|
|
14
15
|
/**
|
|
15
16
|
* Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
|
|
16
17
|
* @public
|
|
18
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
19
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
17
20
|
*/
|
|
18
21
|
const defaultNodeMappingFunc = (node) => {
|
|
19
22
|
// Skip properties 'id', 'parentId' as they contain internal stuff
|
|
@@ -28,6 +31,8 @@ exports.defaultNodeMappingFunc = defaultNodeMappingFunc;
|
|
|
28
31
|
* imodel and ruleset.
|
|
29
32
|
*
|
|
30
33
|
* @public
|
|
34
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
35
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
31
36
|
*/
|
|
32
37
|
class HierarchyBuilder {
|
|
33
38
|
_iModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAGH,sDAA4C;AAG5C,4EAAwG;AACxG,wEAA4D;
|
|
1
|
+
{"version":3,"file":"HierarchyBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;;;AAGH,sDAA4C;AAG5C,4EAAwG;AACxG,wEAA4D;AAoC5D;;;;;GAKG;AACI,MAAM,sBAAsB,GAAoB,CAAC,IAAkB,EAAE,EAAE;IAC5E,mEAAmE;IACnE,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC,wDAAwD;IACtG,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC;AAmBF;;;;;;;GAOG;AACH,MAAa,gBAAgB;IACV,OAAO,CAAmB;IAC1B,gBAAgB,CAAkB;IAEnD,kBAAkB;IAClB,YAAY,KAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,eAAe,IAAI,8BAAsB,CAAC;IAC1E,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAA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AI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1CD,4CA0CC","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/* eslint-disable @typescript-eslint/no-deprecated */\n/** @packageDocumentation\n * @module Hierarchies\n */\n\nimport { TreeNodeItem } from \"@itwin/components-react\";\nimport { using } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { Omit, RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\nimport { PresentationTreeDataProvider, PresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\n\n/**\n * Structure that describes a Node with any indexed properties\n * except `children`.\n *\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport interface MappedNode {\n /** Indexer for all properties in this data structure */\n [index: string]: any;\n /** Prohibited property */\n children?: never;\n}\n\n/**\n * Node in a hierarchy.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport interface HierarchyNode extends Omit<MappedNode, \"children\"> {\n /** Children of this node */\n children?: HierarchyNode[];\n}\n\n/**\n * A function that converts `TreeNodeItem` into a new custom object.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;\n\n/**\n * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport const defaultNodeMappingFunc: NodeMappingFunc = (node: TreeNodeItem) => {\n // Skip properties 'id', 'parentId' as they contain internal stuff\n // that callers are most likely not interested in. Otherwise they can supply\n // a custom `NodeMappingFunc` that does return those properties as well.\n const { id, parentId, ...resultNode } = node; // eslint-disable-line @typescript-eslint/no-unused-vars\n return resultNode;\n};\n\n/**\n * Properties for creating a `HierarchyBuilder` instance.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport interface HierarchyBuilderProps {\n /** The iModel to pull data from */\n imodel: IModelConnection;\n /**\n * A function that maps node to something that the user of\n * this API is interested in. E.g. custom implementation may skip some unimportant\n * node properties to make resulting object smaller and easier to read.\n */\n nodeMappingFunc?: NodeMappingFunc;\n}\n\n/**\n * A class that constructs simple node hierarchy from specified\n * imodel and ruleset.\n *\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport class HierarchyBuilder {\n private readonly _iModel: IModelConnection;\n private readonly _nodeMappingFunc: NodeMappingFunc;\n\n /** Constructor */\n constructor(props: HierarchyBuilderProps) {\n this._iModel = props.imodel;\n this._nodeMappingFunc = props.nodeMappingFunc ?? defaultNodeMappingFunc;\n }\n\n private async createSubHierarchy(nodes: TreeNodeItem[], dataProvider: PresentationTreeDataProvider) {\n const hierarchy: HierarchyNode[] = [];\n for (const node of nodes) {\n const { key: _key, ...nodeNoKey } = node as PresentationTreeNodeItem;\n const nodeIndex = hierarchy.push(this._nodeMappingFunc(nodeNoKey)) - 1;\n const childNodes = await dataProvider.getNodes(node);\n if (childNodes.length > 0) {\n hierarchy[nodeIndex].children = await this.createSubHierarchy(childNodes, dataProvider);\n }\n }\n return hierarchy;\n }\n\n private async doCreateHierarchy(rulesetId: string): Promise<HierarchyNode[]> {\n const dataProvider = new PresentationTreeDataProvider({ imodel: this._iModel, ruleset: rulesetId });\n const rootNodes = await dataProvider.getNodes();\n return this.createSubHierarchy(rootNodes, dataProvider);\n }\n\n /**\n * Create a hierarchy using the supplied presentation ruleset.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n */\n public async createHierarchy(rulesetOrId: Ruleset | string): Promise<HierarchyNode[]> {\n if (typeof rulesetOrId === \"string\") {\n return this.doCreateHierarchy(rulesetOrId);\n }\n\n return using(await Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset: RegisteredRuleset) => {\n return this.doCreateHierarchy(ruleset.id);\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAA8B,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAA8B,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAGlB,wBAAwB,IAAI,wBAAwB,EACrD,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AA2BpI,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChC,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;IACtC,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,WAAkB,4BAA4B,kBA6CpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDA0BrB,CAAC"}
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
import { join } from "path";
|
|
9
9
|
import * as rimraf from "rimraf";
|
|
10
10
|
import { IModelHost } from "@itwin/core-backend";
|
|
11
|
-
import { Guid } from "@itwin/core-bentley";
|
|
11
|
+
import { Guid, Logger, LogLevel } from "@itwin/core-bentley";
|
|
12
12
|
import { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, SnapshotIModelRpcInterface } from "@itwin/core-common";
|
|
13
13
|
import { IModelApp, NoRenderApp } from "@itwin/core-frontend";
|
|
14
|
-
import { HierarchyCacheMode, Presentation as PresentationBackend } from "@itwin/presentation-backend";
|
|
14
|
+
import { HierarchyCacheMode, Presentation as PresentationBackend, PresentationBackendNativeLoggerCategory, } from "@itwin/presentation-backend";
|
|
15
15
|
import { PresentationRpcInterface } from "@itwin/presentation-common";
|
|
16
16
|
import { Presentation as PresentationFrontend } from "@itwin/presentation-frontend";
|
|
17
|
-
import { setTestOutputDir } from "./FilenameUtils.js";
|
|
17
|
+
import { getTestOutputDir, setTestOutputDir } from "./FilenameUtils.js";
|
|
18
18
|
function initializeRpcInterfaces(interfaces) {
|
|
19
19
|
const config = class extends RpcDefaultConfiguration {
|
|
20
20
|
interfaces = () => interfaces;
|
|
@@ -51,6 +51,11 @@ export const initialize = async (props) => {
|
|
|
51
51
|
if (!props) {
|
|
52
52
|
props = {};
|
|
53
53
|
}
|
|
54
|
+
Logger.initializeToConsole();
|
|
55
|
+
Logger.setLevelDefault(LogLevel.Warning);
|
|
56
|
+
Logger.setLevel("i18n", LogLevel.Error);
|
|
57
|
+
Logger.setLevel("SQLite", LogLevel.Error);
|
|
58
|
+
Logger.setLevel(PresentationBackendNativeLoggerCategory.ECObjects, LogLevel.Warning);
|
|
54
59
|
// set up rpc interfaces
|
|
55
60
|
initializeRpcInterfaces(props.rpcs ?? [SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);
|
|
56
61
|
// init backend
|
|
@@ -61,8 +66,7 @@ export const initialize = async (props) => {
|
|
|
61
66
|
props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal
|
|
62
67
|
}
|
|
63
68
|
await IModelHost.startup({
|
|
64
|
-
|
|
65
|
-
cacheDir: join(typeof __dirname !== "undefined" ? __dirname : import.meta.url, ".cache", `${process.pid}`),
|
|
69
|
+
cacheDir: join(getTestOutputDir(), ".cache", `${process.pid}`),
|
|
66
70
|
...props.backendHostProps,
|
|
67
71
|
});
|
|
68
72
|
PresentationBackend.initialize(props.backendProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,UAAU,EAAqB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,UAAU,EAAqB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAA0B,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAoB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,YAAY,IAAI,mBAAmB,EACnC,uCAAuC,GAExC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAkD,MAAM,8BAA8B,CAAC;AACpI,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAExE,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,uBAAuB;QAClC,UAAU,GAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;KACpD,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE,C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AE,WAAW,CAAC;IACnF,IAAI,sBAAsB,EAAE,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAE,CAAC;QAC7D,yBAAyB,GAAG,sBAAsB,EAAE,SAAS,CAAC;IAChE,CAAC;SAAM,IAAI,sBAAsB,EAAE,IAAI,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;QACtE,yBAAyB,GAAG,sBAAsB,EAAE,IAAI,EAAE,SAAS,CAAC;IACtE,CAAC;IAED,oBAAoB;IACpB,mBAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACzC,CAAC;IAED,qBAAqB;IACrB,oBAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC","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 */\n\nimport { join } from \"path\";\nimport * as rimraf from \"rimraf\";\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface } from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\nimport {\n HierarchyCacheMode,\n Presentation as PresentationBackend,\n PresentationBackendNativeLoggerCategory,\n PresentationManagerProps as PresentationBackendProps,\n} from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\nimport { getTestOutputDir, setTestOutputDir } from \"./FilenameUtils.js\";\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 // eslint-disable-next-line @itwin/no-internal\n RpcConfiguration.assign(definition, /* istanbul ignore next */ () => config);\n }\n\n const instance = RpcConfiguration.obtain(config);\n\n try {\n RpcConfiguration.initializeInterfaces(instance);\n /* c8 ignore start */\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 /* c8 ignore end */\n}\n\nlet isInitialized = false;\n\nexport { HierarchyCacheMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /**\n * RPC interfaces to enable. Defaults to `[SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]`.\n *\n * Note: Implementations for these interfaces are **not** automatically registered on the backend - that has to be done manually.\n */\n rpcs?: RpcInterfaceDefinition[];\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 /** Custom test output directory. Defaults to temporary directory provided by the OS. */\n testOutputDir?: string;\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\n if (!props) {\n props = {};\n }\n\n Logger.initializeToConsole();\n Logger.setLevelDefault(LogLevel.Warning);\n Logger.setLevel(\"i18n\", LogLevel.Error);\n Logger.setLevel(\"SQLite\", LogLevel.Error);\n Logger.setLevel(PresentationBackendNativeLoggerCategory.ECObjects, LogLevel.Warning);\n\n // set up rpc interfaces\n initializeRpcInterfaces(props.rpcs ?? [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 // eslint-disable-next-line @itwin/no-internal\n if (!props.backendProps.id) {\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n }\n await IModelHost.startup({\n cacheDir: join(getTestOutputDir(), \".cache\", `${process.pid}`),\n ...props.backendHostProps,\n });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp) {\n props.frontendApp = NoRenderApp;\n }\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 setTestOutputDir(props.testOutputDir);\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\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\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory) {\n rimraf.sync(hierarchiesCacheDirectory);\n }\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n"]}
|
|
@@ -9,6 +9,8 @@ import { Omit, Ruleset } from "@itwin/presentation-common";
|
|
|
9
9
|
* except `children`.
|
|
10
10
|
*
|
|
11
11
|
* @public
|
|
12
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
13
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
12
14
|
*/
|
|
13
15
|
export interface MappedNode {
|
|
14
16
|
/** Indexer for all properties in this data structure */
|
|
@@ -19,6 +21,8 @@ export interface MappedNode {
|
|
|
19
21
|
/**
|
|
20
22
|
* Node in a hierarchy.
|
|
21
23
|
* @public
|
|
24
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
25
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
22
26
|
*/
|
|
23
27
|
export interface HierarchyNode extends Omit<MappedNode, "children"> {
|
|
24
28
|
/** Children of this node */
|
|
@@ -27,16 +31,22 @@ export interface HierarchyNode extends Omit<MappedNode, "children"> {
|
|
|
27
31
|
/**
|
|
28
32
|
* A function that converts `TreeNodeItem` into a new custom object.
|
|
29
33
|
* @public
|
|
34
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
35
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
30
36
|
*/
|
|
31
37
|
export type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;
|
|
32
38
|
/**
|
|
33
39
|
* Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
|
|
34
40
|
* @public
|
|
41
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
42
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
35
43
|
*/
|
|
36
44
|
export declare const defaultNodeMappingFunc: NodeMappingFunc;
|
|
37
45
|
/**
|
|
38
46
|
* Properties for creating a `HierarchyBuilder` instance.
|
|
39
47
|
* @public
|
|
48
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
49
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
40
50
|
*/
|
|
41
51
|
export interface HierarchyBuilderProps {
|
|
42
52
|
/** The iModel to pull data from */
|
|
@@ -53,6 +63,8 @@ export interface HierarchyBuilderProps {
|
|
|
53
63
|
* imodel and ruleset.
|
|
54
64
|
*
|
|
55
65
|
* @public
|
|
66
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
67
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
56
68
|
*/
|
|
57
69
|
export declare class HierarchyBuilder {
|
|
58
70
|
private readonly _iModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HierarchyBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAqB,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAI9E;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;IACjE,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,UAAU,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,eAMpC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IAEnD,kBAAkB;gBACN,KAAK,EAAE,qBAAqB;YAK1B,kBAAkB;YAalB,iBAAiB;IAM/B;;;OAGG;IACU,eAAe,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAStF"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
5
6
|
/** @packageDocumentation
|
|
6
7
|
* @module Hierarchies
|
|
7
8
|
*/
|
|
@@ -11,6 +12,8 @@ import { Presentation } from "@itwin/presentation-frontend";
|
|
|
11
12
|
/**
|
|
12
13
|
* Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
|
|
13
14
|
* @public
|
|
15
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
16
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
14
17
|
*/
|
|
15
18
|
export const defaultNodeMappingFunc = (node) => {
|
|
16
19
|
// Skip properties 'id', 'parentId' as they contain internal stuff
|
|
@@ -24,6 +27,8 @@ export const defaultNodeMappingFunc = (node) => {
|
|
|
24
27
|
* imodel and ruleset.
|
|
25
28
|
*
|
|
26
29
|
* @public
|
|
30
|
+
* @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy
|
|
31
|
+
* building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).
|
|
27
32
|
*/
|
|
28
33
|
export class HierarchyBuilder {
|
|
29
34
|
_iModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchyBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EAAE,4BAA4B,EAA4B,MAAM,gCAAgC,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"HierarchyBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C,OAAO,EAAE,4BAA4B,EAA4B,MAAM,gCAAgC,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAoC5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAoB,CAAC,IAAkB,EAAE,EAAE;IAC5E,mEAAmE;IACnE,4EAA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,MAAM,YAAY,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,WAA6B;QACxD,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,OAA0B,EAAE,EAAE;YAC7G,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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/* eslint-disable @typescript-eslint/no-deprecated */\n/** @packageDocumentation\n * @module Hierarchies\n */\n\nimport { TreeNodeItem } from \"@itwin/components-react\";\nimport { using } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { Omit, RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\nimport { PresentationTreeDataProvider, PresentationTreeNodeItem } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\n\n/**\n * Structure that describes a Node with any indexed properties\n * except `children`.\n *\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport interface MappedNode {\n /** Indexer for all properties in this data structure */\n [index: string]: any;\n /** Prohibited property */\n children?: never;\n}\n\n/**\n * Node in a hierarchy.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport interface HierarchyNode extends Omit<MappedNode, \"children\"> {\n /** Children of this node */\n children?: HierarchyNode[];\n}\n\n/**\n * A function that converts `TreeNodeItem` into a new custom object.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;\n\n/**\n * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport const defaultNodeMappingFunc: NodeMappingFunc = (node: TreeNodeItem) => {\n // Skip properties 'id', 'parentId' as they contain internal stuff\n // that callers are most likely not interested in. Otherwise they can supply\n // a custom `NodeMappingFunc` that does return those properties as well.\n const { id, parentId, ...resultNode } = node; // eslint-disable-line @typescript-eslint/no-unused-vars\n return resultNode;\n};\n\n/**\n * Properties for creating a `HierarchyBuilder` instance.\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport interface HierarchyBuilderProps {\n /** The iModel to pull data from */\n imodel: IModelConnection;\n /**\n * A function that maps node to something that the user of\n * this API is interested in. E.g. custom implementation may skip some unimportant\n * node properties to make resulting object smaller and easier to read.\n */\n nodeMappingFunc?: NodeMappingFunc;\n}\n\n/**\n * A class that constructs simple node hierarchy from specified\n * imodel and ruleset.\n *\n * @public\n * @deprecated in 5.2. All tree-related APIs have been deprecated in favor of the new generation hierarchy\n * building APIs (see https://github.com/iTwin/presentation/blob/33e79ee8d77f30580a9bab81a72884bda008db25/README.md#the-packages).\n */\nexport class HierarchyBuilder {\n private readonly _iModel: IModelConnection;\n private readonly _nodeMappingFunc: NodeMappingFunc;\n\n /** Constructor */\n constructor(props: HierarchyBuilderProps) {\n this._iModel = props.imodel;\n this._nodeMappingFunc = props.nodeMappingFunc ?? defaultNodeMappingFunc;\n }\n\n private async createSubHierarchy(nodes: TreeNodeItem[], dataProvider: PresentationTreeDataProvider) {\n const hierarchy: HierarchyNode[] = [];\n for (const node of nodes) {\n const { key: _key, ...nodeNoKey } = node as PresentationTreeNodeItem;\n const nodeIndex = hierarchy.push(this._nodeMappingFunc(nodeNoKey)) - 1;\n const childNodes = await dataProvider.getNodes(node);\n if (childNodes.length > 0) {\n hierarchy[nodeIndex].children = await this.createSubHierarchy(childNodes, dataProvider);\n }\n }\n return hierarchy;\n }\n\n private async doCreateHierarchy(rulesetId: string): Promise<HierarchyNode[]> {\n const dataProvider = new PresentationTreeDataProvider({ imodel: this._iModel, ruleset: rulesetId });\n const rootNodes = await dataProvider.getNodes();\n return this.createSubHierarchy(rootNodes, dataProvider);\n }\n\n /**\n * Create a hierarchy using the supplied presentation ruleset.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n */\n public async createHierarchy(rulesetOrId: Ruleset | string): Promise<HierarchyNode[]> {\n if (typeof rulesetOrId === \"string\") {\n return this.doCreateHierarchy(rulesetOrId);\n }\n\n return using(await Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset: RegisteredRuleset) => {\n return this.doCreateHierarchy(ruleset.id);\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "Testing utilities for iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"rimraf": "^6.0.1",
|
|
34
34
|
"sanitize-filename": "^1.6.3",
|
|
35
|
-
"@itwin/presentation-components": "^5.
|
|
35
|
+
"@itwin/presentation-components": "^5.8.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@itwin/appui-abstract": "^4.1.0",
|