@itwin/presentation-testing 5.4.16-alpha.0 → 5.4.16

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 (51) hide show
  1. package/CHANGELOG.md +2 -68
  2. package/lib/cjs/presentation-testing/ContentBuilder.d.ts +3 -4
  3. package/lib/cjs/presentation-testing/ContentBuilder.d.ts.map +1 -1
  4. package/lib/cjs/presentation-testing/ContentBuilder.js.map +1 -1
  5. package/lib/cjs/presentation-testing/FilenameUtils.d.ts +1 -1
  6. package/lib/cjs/presentation-testing/FilenameUtils.d.ts.map +1 -1
  7. package/lib/cjs/presentation-testing/FilenameUtils.js.map +1 -1
  8. package/lib/cjs/presentation-testing/Helpers.d.ts +6 -9
  9. package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
  10. package/lib/cjs/presentation-testing/Helpers.js +2 -2
  11. package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
  12. package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts +3 -3
  13. package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
  14. package/lib/cjs/presentation-testing/HierarchyBuilder.js.map +1 -1
  15. package/lib/cjs/presentation-testing/IModelBuilderImpl.d.ts +4 -5
  16. package/lib/cjs/presentation-testing/IModelBuilderImpl.d.ts.map +1 -1
  17. package/lib/cjs/presentation-testing/IModelBuilderImpl.js.map +1 -1
  18. package/lib/cjs/presentation-testing/IModelUtilities.d.ts +3 -3
  19. package/lib/cjs/presentation-testing/IModelUtilities.d.ts.map +1 -1
  20. package/lib/cjs/presentation-testing/IModelUtilities.js +2 -0
  21. package/lib/cjs/presentation-testing/IModelUtilities.js.map +1 -1
  22. package/lib/cjs/presentation-testing.d.ts +1 -2
  23. package/lib/cjs/presentation-testing.d.ts.map +1 -1
  24. package/lib/cjs/presentation-testing.js +6 -0
  25. package/lib/cjs/presentation-testing.js.map +1 -1
  26. package/lib/esm/presentation-testing/ContentBuilder.d.ts +3 -4
  27. package/lib/esm/presentation-testing/ContentBuilder.d.ts.map +1 -1
  28. package/lib/esm/presentation-testing/ContentBuilder.js +1 -1
  29. package/lib/esm/presentation-testing/ContentBuilder.js.map +1 -1
  30. package/lib/esm/presentation-testing/FilenameUtils.d.ts +1 -1
  31. package/lib/esm/presentation-testing/FilenameUtils.d.ts.map +1 -1
  32. package/lib/esm/presentation-testing/FilenameUtils.js.map +1 -1
  33. package/lib/esm/presentation-testing/Helpers.d.ts +6 -9
  34. package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
  35. package/lib/esm/presentation-testing/Helpers.js +3 -3
  36. package/lib/esm/presentation-testing/Helpers.js.map +1 -1
  37. package/lib/esm/presentation-testing/HierarchyBuilder.d.ts +3 -3
  38. package/lib/esm/presentation-testing/HierarchyBuilder.d.ts.map +1 -1
  39. package/lib/esm/presentation-testing/HierarchyBuilder.js.map +1 -1
  40. package/lib/esm/presentation-testing/IModelBuilderImpl.d.ts +4 -5
  41. package/lib/esm/presentation-testing/IModelBuilderImpl.d.ts.map +1 -1
  42. package/lib/esm/presentation-testing/IModelBuilderImpl.js.map +1 -1
  43. package/lib/esm/presentation-testing/IModelUtilities.d.ts +3 -3
  44. package/lib/esm/presentation-testing/IModelUtilities.d.ts.map +1 -1
  45. package/lib/esm/presentation-testing/IModelUtilities.js +2 -0
  46. package/lib/esm/presentation-testing/IModelUtilities.js.map +1 -1
  47. package/lib/esm/presentation-testing.d.ts +1 -2
  48. package/lib/esm/presentation-testing.d.ts.map +1 -1
  49. package/lib/esm/presentation-testing.js +6 -0
  50. package/lib/esm/presentation-testing.js.map +1 -1
  51. package/package.json +3 -4
package/CHANGELOG.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # Change Log - @itwin/presentation-testing
2
2
 
3
- ## 5.4.16-alpha.0
3
+ ## 5.4.16
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies:
8
- - @itwin/presentation-components@5.13.1-alpha.0
7
+ - [#1237](https://github.com/iTwin/presentation/pull/1237): Raise `onClose` event when `buildTestIModel.close()` is called.
9
8
 
10
9
  ## 5.4.15
11
10
 
@@ -23,13 +22,6 @@
23
22
  - Updated dependencies:
24
23
  - @itwin/presentation-components@5.12.18
25
24
 
26
- ## 5.4.14-alpha.0
27
-
28
- ### Patch Changes
29
-
30
- - Updated dependencies:
31
- - @itwin/presentation-components@5.12.18-alpha.0
32
-
33
25
  ## 5.4.13
34
26
 
35
27
  ### Patch Changes
@@ -55,13 +47,6 @@
55
47
  - Updated dependencies:
56
48
  - @itwin/presentation-components@5.12.15
57
49
 
58
- ## 5.4.11-alpha.0
59
-
60
- ### Patch Changes
61
-
62
- - Updated dependencies:
63
- - @itwin/presentation-components@5.12.15-alpha.0
64
-
65
50
  ## 5.4.10
66
51
 
67
52
  ### Patch Changes
@@ -70,13 +55,6 @@
70
55
  - Updated dependencies:
71
56
  - @itwin/presentation-components@5.12.14
72
57
 
73
- ## 5.4.10-alpha.0
74
-
75
- ### Patch Changes
76
-
77
- - Updated dependencies:
78
- - @itwin/presentation-components@5.12.14-alpha.0
79
-
80
58
  ## 5.4.9
81
59
 
82
60
  ### Patch Changes
@@ -100,28 +78,6 @@
100
78
  - Updated dependencies:
101
79
  - @itwin/presentation-components@5.12.6
102
80
 
103
- ## 5.4.7-alpha.2
104
-
105
- ### Patch Changes
106
-
107
- - Updated dependencies:
108
- - @itwin/presentation-components@5.12.9-alpha.0
109
-
110
- ## 5.4.7-alpha.1
111
-
112
- ### Patch Changes
113
-
114
- - [#1042](https://github.com/iTwin/presentation/pull/1042): Version bump
115
- - Updated dependencies:
116
- - @itwin/presentation-components@5.12.6-alpha.1
117
-
118
- ## 5.4.7-alpha.0
119
-
120
- ### Patch Changes
121
-
122
- - Updated dependencies:
123
- - @itwin/presentation-components@5.12.6-alpha.0
124
-
125
81
  ## 5.4.6
126
82
 
127
83
  ### Patch Changes
@@ -129,13 +85,6 @@
129
85
  - Updated dependencies:
130
86
  - @itwin/presentation-components@5.12.5
131
87
 
132
- ## 5.4.6-alpha.0
133
-
134
- ### Patch Changes
135
-
136
- - Updated dependencies:
137
- - @itwin/presentation-components@5.12.5-alpha.0
138
-
139
88
  ## 5.4.5
140
89
 
141
90
  ### Patch Changes
@@ -151,21 +100,6 @@
151
100
  - Updated dependencies:
152
101
  - @itwin/presentation-components@5.12.3
153
102
 
154
- ## 5.4.3-alpha.1
155
-
156
- ### Patch Changes
157
-
158
- - [#963](https://github.com/iTwin/presentation/pull/963): Fix support for `itwinjs-core@5.0-rc`.
159
- - Updated dependencies:
160
- - @itwin/presentation-components@5.12.2-alpha.1
161
-
162
- ## 5.4.3-alpha.0
163
-
164
- ### Patch Changes
165
-
166
- - Updated dependencies:
167
- - @itwin/presentation-components@5.12.2-alpha.0
168
-
169
103
  ## 5.4.3
170
104
 
171
105
  ### Patch Changes
@@ -1,10 +1,9 @@
1
1
  /** @packageDocumentation
2
2
  * @module Content
3
3
  */
4
- import { KeySet } from "@itwin/presentation-common";
5
- import type { PropertyRecord } from "@itwin/appui-abstract";
6
- import type { IModelConnection } from "@itwin/core-frontend";
7
- import type { Content, InstanceKey, PageOptions, Ruleset } from "@itwin/presentation-common";
4
+ import { PropertyRecord } from "@itwin/appui-abstract";
5
+ import { IModelConnection } from "@itwin/core-frontend";
6
+ import { Content, InstanceKey, KeySet, PageOptions, Ruleset } from "@itwin/presentation-common";
8
7
  /**
9
8
  * Interface for a data provider, which is used by ContentBuilder.
10
9
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"ContentBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAA8B,MAAM,EAA0B,MAAM,4BAA4B,CAAC;AAKxG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAc,WAAW,EA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AAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,CAAC;QAED,IAAI,2BAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,GAAG,GAAc,EAAE,CAAC;YAC1B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE;gBACnD,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,CAAC;QACb,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEe,qBAAqB,CAAC,KAAiC;QACrE,KAAK,CAAC,qBAAqB,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC5F,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 Content\n */\n\nimport { Guid } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { DefaultContentDisplayTypes, KeySet, traverseContent, Value } from \"@itwin/presentation-common\";\nimport { ContentDataProvider, PropertyRecordsBuilder } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { safeDispose } from \"./Helpers.js\";\n\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { GuidString } from \"@itwin/core-bentley\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Content, InstanceId, InstanceKey, PageOptions, ProcessPrimitiveValueProps, Ruleset, ValuesMap } from \"@itwin/presentation-common\";\n\n/**\n * Interface for a data provider, which is used by ContentBuilder.\n * @public\n */\nexport interface IContentBuilderDataProvider {\n /** Keys the data provider is creating content for */\n keys: Readonly<KeySet>;\n /** Get the size of content result set */\n getContentSetSize: () => Promise<number>;\n /** Get the content */\n getContent: (options?: PageOptions) => Promise<Readonly<Content> | undefined>;\n}\n\n/**\n * Property records grouped under a single className\n * @public\n */\nexport interface ContentBuilderResult {\n /** Full name of ECClass whose records are contained in this data structure */\n className: string;\n /** Property records for the ECClass instance */\n records: PropertyRecord[];\n}\n\n/**\n * Properties for creating a `ContentBuilder` instance.\n * @public\n */\nexport interface ContentBuilderProps {\n /** The iModel to pull data from */\n imodel: IModelConnection;\n\n /** Custom data provider that allows mocking data ContentBuilder receives */\n dataProvider?: IContentBuilderDataProvider;\n\n /**\n * Decimal precision or numeric types.\n *\n * Raw numeric values with high precision may slightly differ from platform to platform due to\n * rounding differences on different platforms. This may be a problem when used with snapshot testing,\n * in which case this attribute may be set to supply the maximum precision of raw numeric values.\n *\n * By default no rounding is applied.\n */\n decimalPrecision?: number;\n}\n\n/**\n * A class that constructs content from specified imodel and ruleset.\n * @public\n */\nexport class ContentBuilder {\n private readonly _iModel: IModelConnection;\n private _dataProvider: IContentBuilderDataProvider | undefined;\n private _decimalPrecision?: number;\n #componentName: string;\n #componentId: GuidString;\n\n /**\n * Constructor\n * @param iModel\n * @param dataProvider\n */\n constructor(props: ContentBuilderProps) {\n this.#componentId = Guid.createValue();\n this.#componentName = \"ContentBuilder\";\n this._iModel = props.imodel;\n this._dataProvider = props.dataProvider;\n this._decimalPrecision = props.decimalPrecision;\n }\n\n private async doCreateContent(rulesetId: string, instanceKeys: InstanceKey[], displayType: string): Promise<PropertyRecord[]> {\n const dataProvider = this._dataProvider ? this._dataProvider : new ContentDataProvider({ imodel: this._iModel, ruleset: rulesetId, displayType });\n dataProvider.keys = new KeySet(instanceKeys);\n\n const content = await dataProvider.getContent();\n if (!content) {\n return [];\n }\n\n const accumulator = new PropertyRecordsAccumulator(this._decimalPrecision);\n // note: using deprecated `traverseContent`, because we can't use the replacement `createContentTraverser` due to our peer dep version\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n traverseContent(accumulator, content);\n return accumulator.records;\n }\n\n /**\n * Create a list of property records using the supplied presentation ruleset.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n * @param instanceKeys Keys of instances that should be queried.\n * @param displayType Type of content container display. For example:\n * \"PropertyPane\", \"Grid\", \"List\" etc.\n */\n public async createContent(rulesetOrId: Ruleset | string, instanceKeys: InstanceKey[], displayType: string = DefaultContentDisplayTypes.PropertyPane) {\n if (typeof rulesetOrId === \"string\") {\n return this.doCreateContent(rulesetOrId, instanceKeys, displayType);\n }\n const ruleset = await Presentation.presentation.rulesets().add(rulesetOrId);\n using _ = { [Symbol.dispose]: () => safeDispose(ruleset) };\n return await this.doCreateContent(ruleset.id, instanceKeys, displayType);\n }\n\n private async getECClassNames(): Promise<Array<{ schemaName: string; className: string }>> {\n const reader = this._iModel.createQueryReader(\n `\n SELECT s.Name schemaName, c.Name className FROM meta.ECClassDef c\n INNER JOIN meta.ECSchemaDef s ON c.Schema.id = s.ECInstanceId\n WHERE c.Modifier <> 1 AND c.Type = 0\n ORDER BY s.Name, c.Name\n `,\n undefined,\n { rowFormat: QueryRowFormat.UseJsPropertyNames, restartToken: `${this.#componentName}/${this.#componentId}/ec-class-names/${Guid.createValue()}` },\n );\n return reader.toArray();\n }\n\n private async createContentForClasses(rulesetOrId: Ruleset | string, limitInstances: boolean, displayType: string) {\n const classNameEntries = await this.getECClassNames();\n\n const contents: ContentBuilderResult[] = [];\n\n for (const nameEntry of classNameEntries) {\n const reader = this._iModel.createQueryReader(\n `\n SELECT ECInstanceId FROM ONLY \"${nameEntry.schemaName}\".\"${nameEntry.className}\"\n ORDER BY ECInstanceId\n `,\n undefined,\n {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n limit: { count: limitInstances ? 1 : 4000 },\n restartToken: `${this.#componentName}/${this.#componentId}/instance-id/${Guid.createValue()}`,\n },\n );\n const instanceIds: InstanceId[] = await reader.toArray();\n\n if (!instanceIds.length) {\n continue;\n }\n\n const instanceKeys = instanceIds.map((idEntry) => ({ className: `${nameEntry.schemaName}:${nameEntry.className}`, id: idEntry }) as InstanceKey);\n\n contents.push({\n className: `${nameEntry.schemaName}:${nameEntry.className}`,\n records: await this.createContent(rulesetOrId, instanceKeys, displayType),\n });\n }\n\n return contents;\n }\n\n /**\n * Create a list of grouped property records using the supplied presentation ruleset.\n * Each group includes all of the class instances.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n * @param displayType Type of content container display. For example:\n * \"PropertyPane\", \"Grid\", \"List\" etc.\n * @deprecated in 3.x. This method turned out to be useless as it creates content for too many instances. Should use [[createContent]] instead.\n */\n public async createContentForAllInstances(rulesetOrId: Ruleset | string, displayType: string = DefaultContentDisplayTypes.PropertyPane) {\n return this.createContentForClasses(rulesetOrId, false, displayType);\n }\n\n /**\n * Create a list of grouped property records using the supplied presentation ruleset.\n * Each group includes at most one class instance.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n * @param displayType Type of content container display. For example:\n * \"PropertyPane\", \"Grid\", \"List\" etc.\n * @deprecated in 3.x. This method turned out to be useless as it creates content for too many instances. Should use [[createContent]] instead.\n */\n public async createContentForInstancePerClass(rulesetOrId: Ruleset | string, displayType: string = DefaultContentDisplayTypes.PropertyPane) {\n return this.createContentForClasses(rulesetOrId, true, displayType);\n }\n}\n\nclass PropertyRecordsAccumulator extends PropertyRecordsBuilder {\n private _records: PropertyRecord[] = [];\n private _decimalPrecision?: number;\n\n public constructor(decimalPrecision?: number) {\n super((record) => {\n this._records.push(record);\n });\n this._decimalPrecision = decimalPrecision;\n }\n\n public get records(): PropertyRecord[] {\n return this._records;\n }\n\n private processRawValue(value: Value): Value {\n if (this._decimalPrecision === undefined) {\n return value;\n }\n\n if (typeof value === \"number\") {\n return +Number(value).toFixed(this._decimalPrecision);\n }\n\n if (Value.isArray(value)) {\n return value.map((item) => this.processRawValue(item));\n }\n\n if (Value.isMap(value)) {\n const res: ValuesMap = {};\n Object.entries(value).forEach(([key, memberValue]) => {\n res[key] = this.processRawValue(memberValue);\n });\n return res;\n }\n\n return value;\n }\n\n public override processPrimitiveValue(props: ProcessPrimitiveValueProps) {\n super.processPrimitiveValue({ ...props, rawValue: this.processRawValue(props.rawValue) });\n }\n}\n"]}
1
+ {"version":3,"file":"ContentBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,sDAAuD;AACvD,oDAAoD;AAEpD,oEAYoC;AACpC,4EAA6F;AAC7F,wEAA4D;AAC5D,6CAA2C;AAiD3C;;;GAGG;AACH,MAAa,cAAc;IACR,OAAO,CAAmB;IACnC,aAAa,CAA0C;IACvD,iBAAiB,CAAU;IACnC,cAAc,CAAS;IACvB,YAAY,CAAa;IAEzB;;;;OAIG;IACH,YAAY,KAA0B;QACpC,IAAI,CAAC,YAAY,GAAG,mBAAI,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IAClD,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,SAAiB,EAAE,YAA2B,EAAE,WAAmB;QAC/F,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC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D,CAAC;QAED,IAAI,2BAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,CAAC;QAED,IAAI,2BAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,GAAG,GAAc,EAAE,CAAC;YAC1B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE;gBACnD,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,CAAC;QACb,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEe,qBAAqB,CAAC,KAAiC;QACrE,KAAK,CAAC,qBAAqB,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC5F,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 Content\n */\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { Guid, GuidString } from \"@itwin/core-bentley\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport {\n Content,\n DefaultContentDisplayTypes,\n InstanceId,\n InstanceKey,\n KeySet,\n PageOptions,\n ProcessPrimitiveValueProps,\n Ruleset,\n traverseContent,\n Value,\n ValuesMap,\n} from \"@itwin/presentation-common\";\nimport { ContentDataProvider, PropertyRecordsBuilder } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { safeDispose } from \"./Helpers.js\";\n\n/**\n * Interface for a data provider, which is used by ContentBuilder.\n * @public\n */\nexport interface IContentBuilderDataProvider {\n /** Keys the data provider is creating content for */\n keys: Readonly<KeySet>;\n /** Get the size of content result set */\n getContentSetSize: () => Promise<number>;\n /** Get the content */\n getContent: (options?: PageOptions) => Promise<Readonly<Content> | undefined>;\n}\n\n/**\n * Property records grouped under a single className\n * @public\n */\nexport interface ContentBuilderResult {\n /** Full name of ECClass whose records are contained in this data structure */\n className: string;\n /** Property records for the ECClass instance */\n records: PropertyRecord[];\n}\n\n/**\n * Properties for creating a `ContentBuilder` instance.\n * @public\n */\nexport interface ContentBuilderProps {\n /** The iModel to pull data from */\n imodel: IModelConnection;\n\n /** Custom data provider that allows mocking data ContentBuilder receives */\n dataProvider?: IContentBuilderDataProvider;\n\n /**\n * Decimal precision or numeric types.\n *\n * Raw numeric values with high precision may slightly differ from platform to platform due to\n * rounding differences on different platforms. This may be a problem when used with snapshot testing,\n * in which case this attribute may be set to supply the maximum precision of raw numeric values.\n *\n * By default no rounding is applied.\n */\n decimalPrecision?: number;\n}\n\n/**\n * A class that constructs content from specified imodel and ruleset.\n * @public\n */\nexport class ContentBuilder {\n private readonly _iModel: IModelConnection;\n private _dataProvider: IContentBuilderDataProvider | undefined;\n private _decimalPrecision?: number;\n #componentName: string;\n #componentId: GuidString;\n\n /**\n * Constructor\n * @param iModel\n * @param dataProvider\n */\n constructor(props: ContentBuilderProps) {\n this.#componentId = Guid.createValue();\n this.#componentName = \"ContentBuilder\";\n this._iModel = props.imodel;\n this._dataProvider = props.dataProvider;\n this._decimalPrecision = props.decimalPrecision;\n }\n\n private async doCreateContent(rulesetId: string, instanceKeys: InstanceKey[], displayType: string): Promise<PropertyRecord[]> {\n const dataProvider = this._dataProvider ? this._dataProvider : new ContentDataProvider({ imodel: this._iModel, ruleset: rulesetId, displayType });\n dataProvider.keys = new KeySet(instanceKeys);\n\n const content = await dataProvider.getContent();\n if (!content) {\n return [];\n }\n\n const accumulator = new PropertyRecordsAccumulator(this._decimalPrecision);\n // note: using deprecated `traverseContent`, because we can't use the replacement `createContentTraverser` due to our peer dep version\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n traverseContent(accumulator, content);\n return accumulator.records;\n }\n\n /**\n * Create a list of property records using the supplied presentation ruleset.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n * @param instanceKeys Keys of instances that should be queried.\n * @param displayType Type of content container display. For example:\n * \"PropertyPane\", \"Grid\", \"List\" etc.\n */\n public async createContent(rulesetOrId: Ruleset | string, instanceKeys: InstanceKey[], displayType: string = DefaultContentDisplayTypes.PropertyPane) {\n if (typeof rulesetOrId === \"string\") {\n return this.doCreateContent(rulesetOrId, instanceKeys, displayType);\n }\n const ruleset = await Presentation.presentation.rulesets().add(rulesetOrId);\n using _ = { [Symbol.dispose]: () => safeDispose(ruleset) };\n return await this.doCreateContent(ruleset.id, instanceKeys, displayType);\n }\n\n private async getECClassNames(): Promise<Array<{ schemaName: string; className: string }>> {\n const reader = this._iModel.createQueryReader(\n `\n SELECT s.Name schemaName, c.Name className FROM meta.ECClassDef c\n INNER JOIN meta.ECSchemaDef s ON c.Schema.id = s.ECInstanceId\n WHERE c.Modifier <> 1 AND c.Type = 0\n ORDER BY s.Name, c.Name\n `,\n undefined,\n { rowFormat: QueryRowFormat.UseJsPropertyNames, restartToken: `${this.#componentName}/${this.#componentId}/ec-class-names/${Guid.createValue()}` },\n );\n return reader.toArray();\n }\n\n private async createContentForClasses(rulesetOrId: Ruleset | string, limitInstances: boolean, displayType: string) {\n const classNameEntries = await this.getECClassNames();\n\n const contents: ContentBuilderResult[] = [];\n\n for (const nameEntry of classNameEntries) {\n const reader = this._iModel.createQueryReader(\n `\n SELECT ECInstanceId FROM ONLY \"${nameEntry.schemaName}\".\"${nameEntry.className}\"\n ORDER BY ECInstanceId\n `,\n undefined,\n {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n limit: { count: limitInstances ? 1 : 4000 },\n restartToken: `${this.#componentName}/${this.#componentId}/instance-id/${Guid.createValue()}`,\n },\n );\n const instanceIds: InstanceId[] = await reader.toArray();\n\n if (!instanceIds.length) {\n continue;\n }\n\n const instanceKeys = instanceIds.map((idEntry) => ({ className: `${nameEntry.schemaName}:${nameEntry.className}`, id: idEntry }) as InstanceKey);\n\n contents.push({\n className: `${nameEntry.schemaName}:${nameEntry.className}`,\n records: await this.createContent(rulesetOrId, instanceKeys, displayType),\n });\n }\n\n return contents;\n }\n\n /**\n * Create a list of grouped property records using the supplied presentation ruleset.\n * Each group includes all of the class instances.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n * @param displayType Type of content container display. For example:\n * \"PropertyPane\", \"Grid\", \"List\" etc.\n * @deprecated in 3.x. This method turned out to be useless as it creates content for too many instances. Should use [[createContent]] instead.\n */\n public async createContentForAllInstances(rulesetOrId: Ruleset | string, displayType: string = DefaultContentDisplayTypes.PropertyPane) {\n return this.createContentForClasses(rulesetOrId, false, displayType);\n }\n\n /**\n * Create a list of grouped property records using the supplied presentation ruleset.\n * Each group includes at most one class instance.\n * @param rulesetOrId Either a [Ruleset]($presentation-common) object or a ruleset id.\n * @param displayType Type of content container display. For example:\n * \"PropertyPane\", \"Grid\", \"List\" etc.\n * @deprecated in 3.x. This method turned out to be useless as it creates content for too many instances. Should use [[createContent]] instead.\n */\n public async createContentForInstancePerClass(rulesetOrId: Ruleset | string, displayType: string = DefaultContentDisplayTypes.PropertyPane) {\n return this.createContentForClasses(rulesetOrId, true, displayType);\n }\n}\n\nclass PropertyRecordsAccumulator extends PropertyRecordsBuilder {\n private _records: PropertyRecord[] = [];\n private _decimalPrecision?: number;\n\n public constructor(decimalPrecision?: number) {\n super((record) => {\n this._records.push(record);\n });\n this._decimalPrecision = decimalPrecision;\n }\n\n public get records(): PropertyRecord[] {\n return this._records;\n }\n\n private processRawValue(value: Value): Value {\n if (this._decimalPrecision === undefined) {\n return value;\n }\n\n if (typeof value === \"number\") {\n return +Number(value).toFixed(this._decimalPrecision);\n }\n\n if (Value.isArray(value)) {\n return value.map((item) => this.processRawValue(item));\n }\n\n if (Value.isMap(value)) {\n const res: ValuesMap = {};\n Object.entries(value).forEach(([key, memberValue]) => {\n res[key] = this.processRawValue(memberValue);\n });\n return res;\n }\n\n return value;\n }\n\n public override processPrimitiveValue(props: ProcessPrimitiveValueProps) {\n super.processPrimitiveValue({ ...props, rawValue: this.processRawValue(props.rawValue) });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { LocalFileName } from "@itwin/core-common";
1
+ import { LocalFileName } from "@itwin/core-common";
2
2
  /**
3
3
  * Get the output directory used by `setupOutputFileLocation` utility.
4
4
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"FilenameUtils.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/FilenameUtils.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKxD;;;GAGG;AACH,wBAAgB,gBAAgB,WAE/B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,QAEjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAMvE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD;AAED;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAiBnD"}
1
+ {"version":3,"file":"FilenameUtils.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/FilenameUtils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD;;;GAGG;AACH,wBAAgB,gBAAg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CAAC;IACvH,OAAO,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC;AAClD,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\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelJsFs } from \"@itwin/core-backend\";\n\nimport type { LocalFileName } from \"@itwin/core-common\";\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/**\n * Get the output directory used by `setupOutputFileLocation` utility.\n * @public\n */\nexport function getTestOutputDir() {\n return testOutputDir ?? defaultTestOutputDir;\n}\n\n/**\n * Set the output directory used by `setupOutputFileLocation` utility.\n * @public\n */\nexport function setTestOutputDir(directoryPath: string | undefined) {\n testOutputDir = directoryPath;\n}\n\n/**\n * Prepare for an output file path by:\n * - Resolving the output file name under the known test output directory (see `getTestOutputDir` & `setTestOutputDir`).\n * - Making sure the output directories exist.\n * - Removing a previous copy of the output file.\n *\n * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.\n *\n * @public\n */\nexport function setupOutputFileLocation(fileName: string): LocalFileName {\n const outputDirectoryPath = getTestOutputDir();\n !IModelJsFs.existsSync(outputDirectoryPath) && IModelJsFs.mkdirSync(outputDirectoryPath);\n const outputFilePath = limitFilePathLength(path.join(outputDirectoryPath, fileName));\n IModelJsFs.existsSync(outputFilePath) && IModelJsFs.unlinkSync(outputFilePath);\n return outputFilePath;\n}\n\n/**\n * An utility to create a valid file name from any string. Sanitizes all invalid characters,\n * replaces spaces with `-`, makes everything lower case.\n *\n * @public\n */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\").replaceAll(\"`\", \"\").replaceAll(\"'\", \"\")).toLocaleLowerCase();\n}\n\n/**\n * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending\n * a suffix to iModel file name. This constant should account for the maximum suffix length.\n * @internal\n */\nexport const FILE_PATH_RESERVED_CHARACTERS = 13;\n\n/**\n * An utility to make sure file path is shorter than 260 characters.\n *\n * 1. Takes a full file path, splits into directory and file name parts.\n * 2. If the path is already short enough, returns it.\n * 3. Else, calculates tha max allowed file name length, and shortens the file name by replacing the middle part with `...`.\n * 4. Joins back the directory with the shortened file name and returns it.\n *\n * @public\n */\nexport function limitFilePathLength(filePath: string) {\n const { dir, name, ext } = path.parse(filePath);\n const THREE_DOTS_LENGTH = 3;\n\n let allowedFileNameLength = 260 - FILE_PATH_RESERVED_CHARACTERS - (dir.length + 1) - ext.length;\n if (name.length <= allowedFileNameLength) {\n return filePath;\n }\n\n allowedFileNameLength -= THREE_DOTS_LENGTH;\n if (allowedFileNameLength <= 0) {\n throw new Error(`File path \"${filePath}\" is too long.`);\n }\n\n const pieceLength = allowedFileNameLength / 2;\n const shortenedName = `${name.slice(0, Math.ceil(pieceLength))}...${name.slice(Math.ceil(name.length - pieceLength))}`;\n return path.join(dir, `${shortenedName}${ext}`);\n}\n"]}
1
+ {"version":3,"file":"FilenameUtils.js","sourceRoot":"","sources":["../../../src/presentation-testing/FilenameUtils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAehG,4CAEC;AAMD,4CAEC;AAYD,0DAMC;AAQD,4DAEC;AAmBD,kDAiBC;AAvFD,2BAA4B;AAC5B,gDAAwB;AACxB,0EAAyC;AACzC,sDAAiD;AAGjD,MAAM,oBAAoB,GAAG,IAAA,WAAM,GAAE,CAAC;AACtC,IAAI,aAAiC,CAAC;AAEtC;;;GAGG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,aAAa,IAAI,oBAAoB,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,aAAiC;IAChE,aAAa,GAAG,aAAa,CAAC;AAChC,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,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AAK,CAAC,cAAc,QAAQ,gBAAgB,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,qBAAqB,GAAG,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC;IACvH,OAAO,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC;AAClD,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\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelJsFs } from \"@itwin/core-backend\";\nimport { LocalFileName } from \"@itwin/core-common\";\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/**\n * Get the output directory used by `setupOutputFileLocation` utility.\n * @public\n */\nexport function getTestOutputDir() {\n return testOutputDir ?? defaultTestOutputDir;\n}\n\n/**\n * Set the output directory used by `setupOutputFileLocation` utility.\n * @public\n */\nexport function setTestOutputDir(directoryPath: string | undefined) {\n testOutputDir = directoryPath;\n}\n\n/**\n * Prepare for an output file path by:\n * - Resolving the output file name under the known test output directory (see `getTestOutputDir` & `setTestOutputDir`).\n * - Making sure the output directories exist.\n * - Removing a previous copy of the output file.\n *\n * @param fileName Name of output file. The actual file name may get modified to fit within the file system limits.\n *\n * @public\n */\nexport function setupOutputFileLocation(fileName: string): LocalFileName {\n const outputDirectoryPath = getTestOutputDir();\n !IModelJsFs.existsSync(outputDirectoryPath) && IModelJsFs.mkdirSync(outputDirectoryPath);\n const outputFilePath = limitFilePathLength(path.join(outputDirectoryPath, fileName));\n IModelJsFs.existsSync(outputFilePath) && IModelJsFs.unlinkSync(outputFilePath);\n return outputFilePath;\n}\n\n/**\n * An utility to create a valid file name from any string. Sanitizes all invalid characters,\n * replaces spaces with `-`, makes everything lower case.\n *\n * @public\n */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\").replaceAll(\"`\", \"\").replaceAll(\"'\", \"\")).toLocaleLowerCase();\n}\n\n/**\n * `itwinjs-core` creates some accompanying files for each iModels and their names are formed by appending\n * a suffix to iModel file name. This constant should account for the maximum suffix length.\n * @internal\n */\nexport const FILE_PATH_RESERVED_CHARACTERS = 13;\n\n/**\n * An utility to make sure file path is shorter than 260 characters.\n *\n * 1. Takes a full file path, splits into directory and file name parts.\n * 2. If the path is already short enough, returns it.\n * 3. Else, calculates tha max allowed file name length, and shortens the file name by replacing the middle part with `...`.\n * 4. Joins back the directory with the shortened file name and returns it.\n *\n * @public\n */\nexport function limitFilePathLength(filePath: string) {\n const { dir, name, ext } = path.parse(filePath);\n const THREE_DOTS_LENGTH = 3;\n\n let allowedFileNameLength = 260 - FILE_PATH_RESERVED_CHARACTERS - (dir.length + 1) - ext.length;\n if (name.length <= allowedFileNameLength) {\n return filePath;\n }\n\n allowedFileNameLength -= THREE_DOTS_LENGTH;\n if (allowedFileNameLength <= 0) {\n throw new Error(`File path \"${filePath}\" is too long.`);\n }\n\n const pieceLength = allowedFileNameLength / 2;\n const shortenedName = `${name.slice(0, Math.ceil(pieceLength))}...${name.slice(Math.ceil(name.length - pieceLength))}`;\n return path.join(dir, `${shortenedName}${ext}`);\n}\n"]}
@@ -1,15 +1,12 @@
1
1
  /** @packageDocumentation
2
2
  * @module Helpers
3
3
  */
4
- import { IModelApp } from "@itwin/core-frontend";
5
- import { HierarchyCacheMode } from "@itwin/presentation-backend";
6
- import type { IModelHostOptions } from "@itwin/core-backend";
7
- import type { RpcInterfaceDefinition } from "@itwin/core-common";
8
- import type { IModelAppOptions } from "@itwin/core-frontend";
9
- import type { PresentationManagerProps as PresentationBackendProps } from "@itwin/presentation-backend";
10
- import type { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
11
- export type { PresentationBackendProps };
12
- export { HierarchyCacheMode };
4
+ import { IModelHostOptions } from "@itwin/core-backend";
5
+ import { RpcInterfaceDefinition } from "@itwin/core-common";
6
+ import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
7
+ import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps } from "@itwin/presentation-backend";
8
+ import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
9
+ export { HierarchyCacheMode, PresentationBackendProps };
13
10
  /** @public */
14
11
  export interface PresentationTestingInitProps {
15
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EAAE,SAAS,EAAe,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAgF,MAAM,6BAA6B,CAAC;AAK/I,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,IAAI,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACxG,OAAO,KAAK,EAAE,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AA0BnG,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,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AE,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,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnF,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,mDA8BrB,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,WAAW,CAAC,UAAU,EAAE,EAAE,GAAG;IAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,QAMtG"}
@@ -138,11 +138,11 @@ const terminate = async (frontendApp = core_frontend_1.IModelApp) => {
138
138
  const hierarchiesCacheConfig = presentation_backend_1.Presentation.initProps?.caching?.hierarchies;
139
139
  // eslint-disable-next-line @typescript-eslint/no-deprecated
140
140
  if (hierarchiesCacheConfig?.mode === presentation_backend_1.HierarchyCacheMode.Disk) {
141
- hierarchiesCacheDirectory = hierarchiesCacheConfig.directory;
141
+ hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;
142
142
  // eslint-disable-next-line @typescript-eslint/no-deprecated
143
143
  }
144
144
  else if (hierarchiesCacheConfig?.mode === presentation_backend_1.HierarchyCacheMode.Hybrid) {
145
- hierarchiesCacheDirectory = hierarchiesCacheConfig.disk?.directory;
145
+ hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;
146
146
  }
147
147
  // terminate backend
148
148
  presentation_backend_1.Presentation.terminate();
@@ -1 +1 @@
1
- {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoKH,kCAMC;AAxKD,+BAA4B;AAC5B,sDAAiD;AACjD,sDAA6D;AAC7D,oDAAuG;AACvG,wDAA8D;AAC9D,sEAA+I;AAqCtI,mGArCA,yCAAkB,OAqCA;AApC3B,oEAAsE;AACtE,wEAAoF;AACpF,yDAAwE;AAQxE,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,qBAAqB;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,kFAAkF;QAClF,yDAAyD;IAC3D,CAAC;IACD,mBAAmB;AACrB,CAAC;AAED,IAAI,aAAa,GAAG,KAAK,CAAC;AA4B1B;;;;;;;GAOG;A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,IAAI,EAAE,UAAU,EAAE,GAAG,wDAAa,QAAQ,GAAC,CAAC;QACpD,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACxC,CAAC;IAED,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AA9BW,QAAA,SAAS,aA8BpB;AAEF,gBAAgB;AAChB,SAAgB,WAAW,CAAC,UAA2E;IACrG,IAAI,SAAS,IAAI,UAAU,EAAE,CAAC;QAC5B,UAAU,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;SAAM,IAAI,MAAM,CAAC,OAAO,IAAI,UAAU,EAAE,CAAC;QACxC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/B,CAAC;AACH,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 { IModelHost } from \"@itwin/core-backend\";\nimport { Guid, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration } from \"@itwin/core-common\";\nimport { IModelApp, NoRenderApp } from \"@itwin/core-frontend\";\nimport { HierarchyCacheMode, Presentation as PresentationBackend, PresentationBackendNativeLoggerCategory } from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend } from \"@itwin/presentation-frontend\";\nimport { getTestOutputDir, setTestOutputDir } from \"./FilenameUtils.js\";\n\nimport type { IModelHostOptions } from \"@itwin/core-backend\";\nimport type { RpcInterfaceDefinition } from \"@itwin/core-common\";\nimport type { IModelAppOptions } from \"@itwin/core-frontend\";\nimport type { PresentationManagerProps as PresentationBackendProps } from \"@itwin/presentation-backend\";\nimport type { 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 // 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 type { PresentationBackendProps };\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { HierarchyCacheMode };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /**\n * RPC interfaces to enable. Defaults to `[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 & { id?: string; requestTimeout?: number };\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\n initializeRpcInterfaces(props.rpcs ?? [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 }\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig.directory;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\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 const { sync: rimrafSync } = await import(\"rimraf\");\n rimrafSync(hierarchiesCacheDirectory);\n }\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n\n/** @internal */\nexport function safeDispose(disposable: {} | { [Symbol.dispose]: () => void } | { dispose: () => void }) {\n if (\"dispose\" in disposable) {\n disposable.dispose();\n } else if (Symbol.dispose in disposable) {\n disposable[Symbol.dispose]();\n }\n}\n"]}
1
+ {"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkKH,kCAMC;AAtKD,+BAA4B;AAC5B,sDAAoE;AACpE,sDAA6D;AAC7D,oDAA+H;AAC/H,wDAAgF;AAChF,sEAKqC;AA8B5B,mGAlCP,yCAAkB,OAkCO;AA7B3B,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,qBAAqB;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,kFAAkF;QAClF,yDAAyD;IAC3D,CAAC;IACD,mBAAmB;AACrB,CAAC;AAED,IAAI,aAAa,GAAG,KAAK,CAAC;AA2B1B;;;;;;;GAOG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AE,IAAI,EAAE,UAAU,EAAE,GAAG,wDAAa,QAAQ,GAAC,CAAC;QACpD,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACxC,CAAC;IAED,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AA9BW,QAAA,SAAS,aA8BpB;AAEF,gBAAgB;AAChB,SAAgB,WAAW,CAAC,UAA2E;IACrG,IAAI,SAAS,IAAI,UAAU,EAAE,CAAC;QAC5B,UAAU,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;SAAM,IAAI,MAAM,CAAC,OAAO,IAAI,UAAU,EAAE,CAAC;QACxC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/B,CAAC;AACH,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 { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition } 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\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { HierarchyCacheMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /**\n * RPC interfaces to enable. Defaults to `[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 & { id?: string; requestTimeout?: number };\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\n initializeRpcInterfaces(props.rpcs ?? [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 }\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\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 const { sync: rimrafSync } = await import(\"rimraf\");\n rimrafSync(hierarchiesCacheDirectory);\n }\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n\n/** @internal */\nexport function safeDispose(disposable: {} | { [Symbol.dispose]: () => void } | { dispose: () => void }) {\n if (\"dispose\" in disposable) {\n disposable.dispose();\n } else if (Symbol.dispose in disposable) {\n disposable[Symbol.dispose]();\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  /** @packageDocumentation
2
2
  * @module Hierarchies
3
3
  */
4
- import type { TreeNodeItem } from "@itwin/components-react";
5
- import type { IModelConnection } from "@itwin/core-frontend";
6
- import type { Omit, Ruleset } from "@itwin/presentation-common";
4
+ import { TreeNodeItem } from "@itwin/components-react";
5
+ import { IModelConnection } from "@itwin/core-frontend";
6
+ import { Omit, Ruleset } from "@itwin/presentation-common";
7
7
  /**
8
8
  * Structure that describes a Node with any indexed properties
9
9
  * except `children`.
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":"AAKA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAqB,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGnF;;;;;;;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,EA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AAC,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 { using } from \"@itwin/core-bentley\";\nimport { PresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\n\nimport type { TreeNodeItem } from \"@itwin/components-react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Omit, RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\nimport type { PresentationTreeNodeItem } from \"@itwin/presentation-components\";\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
+ {"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,C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AAC,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"]}
@@ -1,11 +1,10 @@
1
1
  /** @packageDocumentation
2
2
  * @module IModel
3
3
  */
4
- import { Code } from "@itwin/core-common";
5
- import type { IModelDb } from "@itwin/core-backend";
6
- import type { Id64String } from "@itwin/core-bentley";
7
- import type { BisCodeSpec, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from "@itwin/core-common";
8
- import type { TestIModelBuilder } from "./IModelUtilities.js";
4
+ import { IModelDb } from "@itwin/core-backend";
5
+ import { Id64String } from "@itwin/core-bentley";
6
+ import { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from "@itwin/core-common";
7
+ import { TestIModelBuilder } from "./IModelUtilities.js";
9
8
  /**
10
9
  * Default implementation of the IModel builder interface.
11
10
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"IModelBuilderImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilderImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAY,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACjJ,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,OAAO,CAAC,OAAO,CAAW;gBAEd,MAAM,EAAE,QAAQ;IAIrB,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIjE,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIrE,YAAY,CAAC,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI1E,kBAAkB,CAAC,MAAM,SAAS,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI/E,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtF,YAAY,CAAC,SAAS,EAAE,MAAM;CAG5C"}
1
+ {"version":3,"file":"IModelBuilderImpl.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilderImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAA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AAK,CAAC,CAAC;IACpD,CAAC;IAEM,YAAY,CAAoC,KAAa;QAClE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IAEM,kBAAkB,CAAmC,KAAa;QACvE,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU,CAAC,YAA4B,EAAE,YAAyB,EAAE,SAAiB;QAC1F,MAAM,QAAQ,GAAa,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1E,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,SAAiB;QACzC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,CAAC;CACF;AA/BD,sDA+BC","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 IModel\n */\n\nimport { Code } from \"@itwin/core-common\";\n\nimport type { IModelDb } from \"@itwin/core-backend\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { BisCodeSpec, CodeScopeProps, CodeSpec, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from \"@itwin/core-common\";\nimport type { TestIModelBuilder } from \"./IModelUtilities.js\";\n\n/**\n * Default implementation of the IModel builder interface.\n * @internal\n */\nexport class TestIModelBuilderImpl implements TestIModelBuilder {\n private _iModel: IModelDb;\n\n constructor(iModel: IModelDb) {\n this._iModel = iModel;\n }\n\n public insertModel<TProps extends ModelProps>(props: TProps): Id64String {\n return this._iModel.models.insertModel(props);\n }\n\n public insertElement<TProps extends ElementProps>(props: TProps): Id64String {\n return this._iModel.elements.insertElement(props);\n }\n\n public insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String {\n return this._iModel.elements.insertAspect(props);\n }\n\n public insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String {\n return this._iModel.relationships.insertInstance(props);\n }\n\n public createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code {\n const codeSpec: CodeSpec = this._iModel.codeSpecs.getByName(codeSpecName);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n public async importSchema(schemaXml: string) {\n await this._iModel.importSchemaStrings([schemaXml]);\n }\n}\n"]}
1
+ {"version":3,"file":"IModelBuilderImpl.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilderImpl.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAIH,oDAAkJ;AAGlJ;;;GAGG;AACH,MAAa,qBAAqB;IACxB,OAAO,CAAW;IAE1B,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,WAAW,CAA4B,KAAa;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAEM,aAAa,CAA8B,KAAa;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAEM,YAAY,CAAoC,KAAa;QAClE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IAEM,kBAAkB,CAAmC,KAAa;QACvE,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU,CAAC,YAA4B,EAAE,YAAyB,EAAE,SAAiB;QAC1F,MAAM,QAAQ,GAAa,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1E,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,SAAiB;QACzC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,CAAC;CACF;AA/BD,sDA+BC","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 IModel\n */\n\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { BisCodeSpec, Code, CodeScopeProps, CodeSpec, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from \"@itwin/core-common\";\nimport { TestIModelBuilder } from \"./IModelUtilities.js\";\n\n/**\n * Default implementation of the IModel builder interface.\n * @internal\n */\nexport class TestIModelBuilderImpl implements TestIModelBuilder {\n private _iModel: IModelDb;\n\n constructor(iModel: IModelDb) {\n this._iModel = iModel;\n }\n\n public insertModel<TProps extends ModelProps>(props: TProps): Id64String {\n return this._iModel.models.insertModel(props);\n }\n\n public insertElement<TProps extends ElementProps>(props: TProps): Id64String {\n return this._iModel.elements.insertElement(props);\n }\n\n public insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String {\n return this._iModel.elements.insertAspect(props);\n }\n\n public insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String {\n return this._iModel.relationships.insertInstance(props);\n }\n\n public createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code {\n const codeSpec: CodeSpec = this._iModel.codeSpecs.getByName(codeSpecName);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n public async importSchema(schemaXml: string) {\n await this._iModel.importSchemaStrings([schemaXml]);\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  /** @packageDocumentation
2
2
  * @module IModel
3
3
  */
4
+ import { IModelDb } from "@itwin/core-backend";
5
+ import { Id64String } from "@itwin/core-bentley";
6
+ import { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from "@itwin/core-common";
4
7
  import { IModelConnection } from "@itwin/core-frontend";
5
- import type { IModelDb } from "@itwin/core-backend";
6
- import type { Id64String } from "@itwin/core-bentley";
7
- import type { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from "@itwin/core-common";
8
8
  /**
9
9
  * Interface for IModel builder pattern. Used for building IModels to test rulesets.
10
10
  * @beta
@@ -1 +1 @@
1
- {"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE7I;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAClE,kDAAkD;IAClD,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KA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AE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACzH;;;;;GAKG;AAEH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAClI;;;;;;GAMG;AAEH,wBAAsB,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACxI;;;;;GAKG;AAEH,wBAAsB,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAejJ;;;GAGG;AAEH,qBAAa,oBAAqB,SAAQ,gBAAgB;IAE5C,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,QAAQ;IAM1C,IAAoB,QAAQ,IAAI,OAAO,CAGtC;IAEqB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;WAM9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;CAG3D"}
@@ -47,6 +47,8 @@ class TestIModelConnection extends core_frontend_1.IModelConnection {
47
47
  }
48
48
  async close() {
49
49
  this._db.close();
50
+ this.onClose.raiseEvent(this);
51
+ core_frontend_1.IModelConnection.onClose.raiseEvent(this);
50
52
  }
51
53
  static openFile(filePath) {
52
54
  return new TestIModelConnection(core_backend_1.SnapshotDb.openFile(filePath));
@@ -1 +1 @@
1
- {"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;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AAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,QAAgB;QACrC,OAAO,IAAI,oBAAoB,CAAC,yBAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AApBD,oDAoBC;AACD,mBAAmB","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 IModel\n */\n\nimport { SnapshotDb } from \"@itwin/core-backend\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { createFileNameFromString, setupOutputFileLocation } from \"./FilenameUtils.js\";\nimport { TestIModelBuilderImpl } from \"./IModelBuilderImpl.js\";\n\nimport type { IModelDb } from \"@itwin/core-backend\";\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from \"@itwin/core-common\";\n\n/**\n * Interface for IModel builder pattern. Used for building IModels to test rulesets.\n * @beta\n */\nexport interface TestIModelBuilder {\n /** Insert a model into the builder's iModel */\n insertModel<TProps extends ModelProps>(props: TProps): Id64String;\n /** Insert an element into the builder's iModel */\n insertElement<TProps extends ElementProps>(props: TProps): Id64String;\n /** Insert an element aspect into the specified element */\n insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;\n /**\n * Insert a relationship between two instances. The relationship is expected to be a subclass\n * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.\n */\n insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;\n /**\n * Create code for specified element.\n * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).\n */\n createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;\n /**\n * Import an ECSchema in a form of XML string into the builder's iModel.\n */\n importSchema(schemaXml: string): Promise<void>;\n}\n\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\nexport async function buildTestIModel(nameParam: string | Mocha.Context, cb: (builder: TestIModelBuilder) => void | Promise<void>): Promise<IModelConnection> {\n const name = typeof nameParam === \"string\" ? nameParam : createFileNameFromString(nameParam.test!.fullTitle());\n const outputFile = setupOutputFileLocation(`${name}.bim`);\n const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });\n const builder = new TestIModelBuilderImpl(db);\n try {\n await cb(builder);\n } finally {\n db.saveChanges(\"Created test IModel\");\n db.close();\n }\n return TestIModelConnection.openFile(outputFile);\n}\n\n/**\n * Implementation of `IModelConnection` that allows opening local files in tests.\n * @beta\n */\n/* c8 ignore start */\nexport class TestIModelConnection extends IModelConnection {\n // This was added based on this: https://github.com/iTwin/itwinjs-core/pull/7171/files#diff-9d26b04e7ae074b911fb87be3425360d7bd55a7c9f947f5aed1ba36d359f01eb\n constructor(private readonly _db: IModelDb) {\n // eslint-disable-next-line @itwin/no-internal\n super(_db.getConnectionProps());\n IModelConnection.onOpen.raiseEvent(this);\n }\n\n public override get isClosed(): boolean {\n // eslint-disable-next-line @itwin/no-internal\n return !this._db.isOpen;\n }\n\n public override async close(): Promise<void> {\n this._db.close();\n }\n\n public static openFile(filePath: string): IModelConnection {\n return new TestIModelConnection(SnapshotDb.openFile(filePath));\n }\n}\n/* c8 ignore end */\n"]}
1
+ {"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAqEH,0CAYC;AA/ED,sDAA2D;AAG3D,wDAAwD;AACxD,yDAAuF;AACvF,iEAA+D;AA8DxD,KAAK,UAAU,eAAe,CAAC,SAAiC,EAAE,EAAwD;IAC/H,MAAM,IAAI,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,2CAAwB,EAAC,SAAS,CAAC,IAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IAC/G,MAAM,UAAU,GAAG,IAAA,0CAAuB,EAAC,GAAG,IAAI,MAAM,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,yBAAU,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACzE,MAAM,OAAO,GAAG,IAAI,4CAAqB,CAAC,EAAE,CAAC,CAAC;IAC9C,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;QACtC,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;IACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,qBAAqB;AACrB,MAAa,oBAAqB,SAAQ,gCAAgB;IAE3B;IAD7B,4JAA4J;IAC5J,YAA6B,GAAa;QACxC,8CAA8C;QAC9C,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAFL,QAAG,GAAH,GAAG,CAAU;QAGxC,gCAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,IAAoB,QAAQ;QAC1B,8CAA8C;QAC9C,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IAC1B,CAAC;IAEe,KAAK,CAAC,KAAK;QACzB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACjB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9B,gCAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,QAAgB;QACrC,OAAO,IAAI,oBAAoB,CAAC,yBAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAtBD,oDAsBC;AACD,mBAAmB","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 IModel\n */\n\nimport { IModelDb, SnapshotDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { BisCodeSpec, Code, CodeScopeProps, ElementAspectProps, ElementProps, ModelProps, RelationshipProps } from \"@itwin/core-common\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { createFileNameFromString, setupOutputFileLocation } from \"./FilenameUtils.js\";\nimport { TestIModelBuilderImpl } from \"./IModelBuilderImpl.js\";\n\n/**\n * Interface for IModel builder pattern. Used for building IModels to test rulesets.\n * @beta\n */\nexport interface TestIModelBuilder {\n /** Insert a model into the builder's iModel */\n insertModel<TProps extends ModelProps>(props: TProps): Id64String;\n /** Insert an element into the builder's iModel */\n insertElement<TProps extends ElementProps>(props: TProps): Id64String;\n /** Insert an element aspect into the specified element */\n insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;\n /**\n * Insert a relationship between two instances. The relationship is expected to be a subclass\n * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.\n */\n insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;\n /**\n * Create code for specified element.\n * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).\n */\n createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;\n /**\n * Import an ECSchema in a form of XML string into the builder's iModel.\n */\n importSchema(schemaXml: string): Promise<void>;\n}\n\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\nexport async function buildTestIModel(nameParam: string | Mocha.Context, cb: (builder: TestIModelBuilder) => void | Promise<void>): Promise<IModelConnection> {\n const name = typeof nameParam === \"string\" ? nameParam : createFileNameFromString(nameParam.test!.fullTitle());\n const outputFile = setupOutputFileLocation(`${name}.bim`);\n const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });\n const builder = new TestIModelBuilderImpl(db);\n try {\n await cb(builder);\n } finally {\n db.saveChanges(\"Created test IModel\");\n db.close();\n }\n return TestIModelConnection.openFile(outputFile);\n}\n\n/**\n * Implementation of `IModelConnection` that allows opening local files in tests.\n * @beta\n */\n/* c8 ignore start */\nexport class TestIModelConnection extends IModelConnection {\n // This was added based on this: https://github.com/iTwin/itwinjs-core/pull/7171/files#diff-9d26b04e7ae074b911fb87be3425360d7bd55a7c9f947f5aed1ba36d359f01eb\n constructor(private readonly _db: IModelDb) {\n // eslint-disable-next-line @itwin/no-internal\n super(_db.getConnectionProps());\n IModelConnection.onOpen.raiseEvent(this);\n }\n\n public override get isClosed(): boolean {\n // eslint-disable-next-line @itwin/no-internal\n return !this._db.isOpen;\n }\n\n public override async close(): Promise<void> {\n this._db.close();\n this.onClose.raiseEvent(this);\n IModelConnection.onClose.raiseEvent(this);\n }\n\n public static openFile(filePath: string): IModelConnection {\n return new TestIModelConnection(SnapshotDb.openFile(filePath));\n }\n}\n/* c8 ignore end */\n"]}
@@ -18,8 +18,7 @@ export * from "./presentation-testing/ContentBuilder.js";
18
18
  * @docs-group-description Helpers
19
19
  * Various test helpers.
20
20
  */
21
- export type { PresentationBackendProps, PresentationTestingInitProps } from "./presentation-testing/Helpers.js";
22
- export { HierarchyCacheMode, initialize, terminate } from "./presentation-testing/Helpers.js";
21
+ export { HierarchyCacheMode, PresentationBackendProps, PresentationTestingInitProps, initialize, terminate } from "./presentation-testing/Helpers.js";
23
22
  export { createFileNameFromString, getTestOutputDir, limitFilePathLength, setTestOutputDir, setupOutputFileLocation, } from "./presentation-testing/FilenameUtils.js";
24
23
  /**
25
24
  * @module IModel
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,cAAc,4CAA4C,CAAC;AAE3D;;;;;GAKG;AACH,cAAc,0CAA0C,CAAC;AAEzD;;;;;GAKG;AAEH,YAAY,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEhH,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,yCAAyC,CAAC;AAEjD;;;;;GAKG;AACH,cAAc,2CAA2C,CAAC;AAG1D;;;;GAIG;AACH,oBAAY,uBAAuB;IACjC;;;OAGG;IACH,QAAQ,IAAA;IAER;;;OAGG;IACH,SAAS,IAAA;CACV"}
1
+ {"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,cAAc,4CAA4C,CAAC;AAE3D;;;;;GAKG;AACH,cAAc,0CAA0C,CAAC;AAEzD;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACtJ,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,yCAAyC,CAAC;AAEjD;;;;;GAKG;AACH,cAAc,2CAA2C,CAAC;AAG1D;;;;GAIG;AACH,oBAAY,uBAAuB;IACjC;;;OAGG;IACH,QAAQ,IAAA;IAER;;;OAGG;IACH,SAAS,IAAA;CACV"}
@@ -33,6 +33,12 @@ __exportStar(require("./presentation-testing/HierarchyBuilder.js"), exports);
33
33
  * Types for testing content.
34
34
  */
35
35
  __exportStar(require("./presentation-testing/ContentBuilder.js"), exports);
36
+ /**
37
+ * @module Helpers
38
+ *
39
+ * @docs-group-description Helpers
40
+ * Various test helpers.
41
+ */
36
42
  // eslint-disable-next-line @typescript-eslint/no-deprecated
37
43
  var Helpers_js_1 = require("./presentation-testing/Helpers.js");
38
44
  Object.defineProperty(exports, "HierarchyCacheMode", { enumerable: true, get: function () { return Helpers_js_1.HierarchyCacheMode; } });
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;AAEhG;;;;;GAKG;AACH,6EAA2D;AAE3D;;;;;GAKG;AACH,2EAAyD;AAUzD,4DAA4D;AAC5D,gEAA8F;AAArF,gHAAA,kBAAkB,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,uGAAA,SAAS,OAAA;AAClD,4EAMiD;AAL/C,4HAAA,wBAAwB,OAAA;AACxB,oHAAA,gBAAgB,OAAA;AAChB,uHAAA,mBAAmB,OAAA;AACnB,oHAAA,gBAAgB,OAAA;AAChB,2HAAA,uBAAuB,OAAA;AAGzB;;;;;GAKG;AACH,4EAA0D;AAE1D,iDAAiD;AACjD;;;;GAIG;AACH,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,uCAAvB,uBAAuB,QAYlC","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\n/**\n * @module Hierarchies\n *\n * @docs-group-description Hierarchies\n * Types for testing hierarchies.\n */\nexport * from \"./presentation-testing/HierarchyBuilder.js\";\n\n/**\n * @module Content\n *\n * @docs-group-description Content\n * Types for testing content.\n */\nexport * from \"./presentation-testing/ContentBuilder.js\";\n\n/**\n * @module Helpers\n *\n * @docs-group-description Helpers\n * Various test helpers.\n */\n\nexport type { PresentationBackendProps, PresentationTestingInitProps } from \"./presentation-testing/Helpers.js\";\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { HierarchyCacheMode, initialize, terminate } from \"./presentation-testing/Helpers.js\";\nexport {\n createFileNameFromString,\n getTestOutputDir,\n limitFilePathLength,\n setTestOutputDir,\n setupOutputFileLocation,\n} from \"./presentation-testing/FilenameUtils.js\";\n\n/**\n * @module IModel\n *\n * @docs-group-description IModel\n * Utilities for creating test iModels that can be used to exercise presentation rules.\n */\nexport * from \"./presentation-testing/IModelUtilities.js\";\n\n// TODO: remove when itwinjs-core 4.x is dropped.\n/**\n * Presentation manager working mode.\n * @public\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\n */\nexport enum PresentationManagerMode {\n /**\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\n * related to reacting to changes in iModels.\n */\n ReadOnly,\n\n /**\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\n * react to changes. This involves some additional work and gives slightly worse performance.\n */\n ReadWrite,\n}\n"]}
1
+ {"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;AAEhG;;;;;GAKG;AACH,6EAA2D;AAE3D;;;;;GAKG;AACH,2EAAyD;AAEzD;;;;;GAKG;AACH,4DAA4D;AAC5D,gEAAsJ;AAA7I,gHAAA,kBAAkB,OAAA;AAA0D,wGAAA,UAAU,OAAA;AAAE,uGAAA,SAAS,OAAA;AAC1G,4EAMiD;AAL/C,4HAAA,wBAAwB,OAAA;AACxB,oHAAA,gBAAgB,OAAA;AAChB,uHAAA,mBAAmB,OAAA;AACnB,oHAAA,gBAAgB,OAAA;AAChB,2HAAA,uBAAuB,OAAA;AAGzB;;;;;GAKG;AACH,4EAA0D;AAE1D,iDAAiD;AACjD;;;;GAIG;AACH,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,uCAAvB,uBAAuB,QAYlC","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\n/**\n * @module Hierarchies\n *\n * @docs-group-description Hierarchies\n * Types for testing hierarchies.\n */\nexport * from \"./presentation-testing/HierarchyBuilder.js\";\n\n/**\n * @module Content\n *\n * @docs-group-description Content\n * Types for testing content.\n */\nexport * from \"./presentation-testing/ContentBuilder.js\";\n\n/**\n * @module Helpers\n *\n * @docs-group-description Helpers\n * Various test helpers.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { HierarchyCacheMode, PresentationBackendProps, PresentationTestingInitProps, initialize, terminate } from \"./presentation-testing/Helpers.js\";\nexport {\n createFileNameFromString,\n getTestOutputDir,\n limitFilePathLength,\n setTestOutputDir,\n setupOutputFileLocation,\n} from \"./presentation-testing/FilenameUtils.js\";\n\n/**\n * @module IModel\n *\n * @docs-group-description IModel\n * Utilities for creating test iModels that can be used to exercise presentation rules.\n */\nexport * from \"./presentation-testing/IModelUtilities.js\";\n\n// TODO: remove when itwinjs-core 4.x is dropped.\n/**\n * Presentation manager working mode.\n * @public\n * @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore\n */\nexport enum PresentationManagerMode {\n /**\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\n * related to reacting to changes in iModels.\n */\n ReadOnly,\n\n /**\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\n * react to changes. This involves some additional work and gives slightly worse performance.\n */\n ReadWrite,\n}\n"]}