@itwin/presentation-testing 5.1.1 → 5.2.0

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log - @itwin/presentation-testing
2
2
 
3
+ ## 5.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#804](https://github.com/iTwin/presentation/pull/804): Deprecated all tree-related APIs.
8
+
9
+ 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).
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies:
14
+ - @itwin/presentation-components@5.7.0
15
+
16
+ ## 5.1.2
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies:
21
+ - @itwin/presentation-components@5.6.1
22
+
3
23
  ## 5.1.1
4
24
 
5
25
  ### Patch Changes
@@ -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":"AAIA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,IAAI,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;;;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;AA8B5D;;;GAGG;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;AAiBF;;;;;GAKG;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,CAAC,KAA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AC,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/** @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 */\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 */\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 */\nexport type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;\n\n/**\n * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.\n * @public\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 */\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 */\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
+ {"version":3,"file":"HierarchyBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;;;AAGH,sDAA4C;AAG5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C/C,MAAM,YAAY,GAAG,IAAI,sDAA4B,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;QACpG,MAAM,SAAS,GAAG,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,IAAA,oBAAK,EAAC,MAAM,oCAAY,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;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"]}
@@ -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":"AAIA;;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;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;IACjE,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,UAAU,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,eAMpC,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;;GAKG;AACH,qBAAa,gB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C,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,OAA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;IACnB,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,SAAiB;QAC/C,MAAM,YAAY,GAAG,IAAI,4BAA4B,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;QACpG,MAAM,SAAS,GAAG,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/** @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 */\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 */\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 */\nexport type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;\n\n/**\n * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.\n * @public\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 */\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 */\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
+ {"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,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;AAmBF;;;;;;;GAOG;AACH,MAAM,OAAO,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,G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,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.1",
3
+ "version": "5.2.0",
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.6.0"
35
+ "@itwin/presentation-components": "^5.7.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@itwin/appui-abstract": "^4.1.0",
@@ -46,24 +46,24 @@
46
46
  "@itwin/presentation-frontend": "^4.1.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@itwin/appui-abstract": "^4.9.0",
50
- "@itwin/build-tools": "^4.10.0-dev.33",
51
- "@itwin/components-react": "^4.17.0",
52
- "@itwin/core-backend": "^4.9.0",
53
- "@itwin/core-bentley": "^4.9.0",
54
- "@itwin/core-common": "^4.9.0",
55
- "@itwin/core-frontend": "^4.9.0",
56
- "@itwin/core-geometry": "^4.9.0",
57
- "@itwin/core-orbitgt": "^4.9.0",
58
- "@itwin/core-quantity": "^4.9.0",
59
- "@itwin/core-react": "^4.17.0",
60
- "@itwin/ecschema-metadata": "^4.9.0",
49
+ "@itwin/appui-abstract": "^4.10.1",
50
+ "@itwin/build-tools": "^4.10.1",
51
+ "@itwin/components-react": "^4.17.5",
52
+ "@itwin/core-backend": "^4.10.1",
53
+ "@itwin/core-bentley": "^4.10.1",
54
+ "@itwin/core-common": "^4.10.1",
55
+ "@itwin/core-frontend": "^4.10.1",
56
+ "@itwin/core-geometry": "^4.10.1",
57
+ "@itwin/core-orbitgt": "^4.10.1",
58
+ "@itwin/core-quantity": "^4.10.1",
59
+ "@itwin/core-react": "^4.17.5",
60
+ "@itwin/ecschema-metadata": "^4.10.1",
61
61
  "@itwin/eslint-plugin": "5.0.0-dev.1",
62
- "@itwin/presentation-backend": "^4.9.0",
63
- "@itwin/presentation-common": "^4.9.0",
64
- "@itwin/presentation-frontend": "^4.9.0",
65
- "@itwin/webgl-compatibility": "^4.9.0",
66
- "@opentelemetry/api": "^1.8.0",
62
+ "@itwin/presentation-backend": "^4.10.1",
63
+ "@itwin/presentation-common": "^4.10.1",
64
+ "@itwin/presentation-frontend": "^4.10.1",
65
+ "@itwin/webgl-compatibility": "^4.10.1",
66
+ "@opentelemetry/api": "^1.9.0",
67
67
  "@types/chai": "^4.3.16",
68
68
  "@types/chai-as-promised": "^7.1.8",
69
69
  "@types/chai-jest-snapshot": "^1.3.8",
@@ -80,7 +80,7 @@
80
80
  "eslint": "^9.13.0",
81
81
  "global-jsdom": "^25.0.0",
82
82
  "ignore-styles": "^5.0.1",
83
- "inversify": "^6.0.2",
83
+ "inversify": "~6.0.2",
84
84
  "jsdom": "^25.0.1",
85
85
  "mocha": "^10.7.3",
86
86
  "react": "^18.3.1",
@@ -101,7 +101,7 @@
101
101
  "cover": "c8 npm -s test",
102
102
  "docs": "npm run -s docs:reference && npm run -s docs:changelog",
103
103
  "docs:changelog": "cpx ./CHANGELOG.md ./build/docs/reference/presentation-testing",
104
- "docs:reference": "cross-env NODE_PROJECT_ROOT_DIRECTORY=../../ betools docs --includes=./build/docs/extract --json=./build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
104
+ "docs:reference": "cross-env NODE_PROJECT_ROOT_DIRECTORY=../../ betools docs --json=./build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
105
105
  "lint": "eslint ./src/**/*.ts",
106
106
  "test:dev": "cross-env NODE_OPTIONS=\"--import presentation-test-utilities/node-hooks/ignore-styles\" mocha --enable-source-maps --config ./.mocharc.json",
107
107
  "test": "npm run test:dev",