@itwin/presentation-testing 5.4.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/lib/cjs/presentation-testing/ContentBuilder.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/ContentBuilder.js +5 -3
- package/lib/cjs/presentation-testing/ContentBuilder.js.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.d.ts +6 -0
- package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.js +29 -9
- package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
- package/lib/cjs/presentation-testing.d.ts +18 -3
- package/lib/cjs/presentation-testing.d.ts.map +1 -1
- package/lib/cjs/presentation-testing.js +24 -4
- package/lib/cjs/presentation-testing.js.map +1 -1
- package/lib/esm/presentation-testing/ContentBuilder.d.ts.map +1 -1
- package/lib/esm/presentation-testing/ContentBuilder.js +6 -4
- package/lib/esm/presentation-testing/ContentBuilder.js.map +1 -1
- package/lib/esm/presentation-testing/Helpers.d.ts +6 -0
- package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/esm/presentation-testing/Helpers.js +11 -2
- package/lib/esm/presentation-testing/Helpers.js.map +1 -1
- package/lib/esm/presentation-testing.d.ts +18 -3
- package/lib/esm/presentation-testing.d.ts.map +1 -1
- package/lib/esm/presentation-testing.js +20 -3
- package/lib/esm/presentation-testing.js.map +1 -1
- package/package.json +20 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log - @itwin/presentation-testing
|
|
2
2
|
|
|
3
|
+
## 5.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#886](https://github.com/iTwin/presentation/pull/886): Fix package compatibility with `itwinjs-core` peer dependencies at version `4.x`.
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- @itwin/presentation-components@5.12.0
|
|
10
|
+
|
|
3
11
|
## 5.4.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,OAAO,EAGP,WAAW,EACX,MAAM,EACN,WAAW,EAEX,OAAO,EAIR,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ContentBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,OAAO,EAGP,WAAW,EACX,MAAM,EACN,WAAW,EAEX,OAAO,EAIR,MAAM,4BAA4B,CAAC;AAKpC;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qDAAqD;IACrD,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvB,yCAAyC;IACzC,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,sBAAsB;IACtB,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;CAC/E;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,MAAM,EAAE,gBAAgB,CAAC;IAEzB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,2BAA2B,CAAC;IAE3C;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,aAAa,CAA0C;IAC/D,OAAO,CAAC,iBAAiB,CAAC,CAAS;IAEnC;;;;OAIG;gBACS,KAAK,EAAE,mBAAmB;YAMxB,eAAe;IAc7B;;;;;;OAMG;IACU,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,WAAW,GAAE,MAAgD;YAStI,eAAe;YAcf,uBAAuB;IAgCrC;;;;;;;OAOG;IACU,4BAA4B,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,EAAE,WAAW,GAAE,MAAgD;IAItI;;;;;;;OAOG;IACU,gCAAgC,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,EAAE,WAAW,GAAE,MAAgD;CAG3I"}
|
|
@@ -64,6 +64,7 @@ const core_common_1 = require("@itwin/core-common");
|
|
|
64
64
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
65
65
|
const presentation_components_1 = require("@itwin/presentation-components");
|
|
66
66
|
const presentation_frontend_1 = require("@itwin/presentation-frontend");
|
|
67
|
+
const Helpers_js_1 = require("./Helpers.js");
|
|
67
68
|
/**
|
|
68
69
|
* A class that constructs content from specified imodel and ruleset.
|
|
69
70
|
* @public
|
|
@@ -106,7 +107,8 @@ class ContentBuilder {
|
|
|
106
107
|
if (typeof rulesetOrId === "string") {
|
|
107
108
|
return this.doCreateContent(rulesetOrId, instanceKeys, displayType);
|
|
108
109
|
}
|
|
109
|
-
const ruleset =
|
|
110
|
+
const ruleset = await presentation_frontend_1.Presentation.presentation.rulesets().add(rulesetOrId);
|
|
111
|
+
const _ = __addDisposableResource(env_1, { [Symbol.dispose]: () => (0, Helpers_js_1.safeDispose)(ruleset) }, false);
|
|
110
112
|
return await this.doCreateContent(ruleset.id, instanceKeys, displayType);
|
|
111
113
|
}
|
|
112
114
|
catch (e_1) {
|
|
@@ -190,10 +192,10 @@ class PropertyRecordsAccumulator extends presentation_components_1.PropertyRecor
|
|
|
190
192
|
if (typeof value === "number") {
|
|
191
193
|
return +Number(value).toFixed(this._decimalPrecision);
|
|
192
194
|
}
|
|
193
|
-
if (
|
|
195
|
+
if (presentation_common_1.Value.isArray(value)) {
|
|
194
196
|
return value.map((item) => this.processRawValue(item));
|
|
195
197
|
}
|
|
196
|
-
if (value
|
|
198
|
+
if (presentation_common_1.Value.isMap(value)) {
|
|
197
199
|
const res = {};
|
|
198
200
|
Object.entries(value).forEach(([key, memberValue]) => {
|
|
199
201
|
res[key] = this.processRawValue(memberValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,oDAAoD;AAEpD,oEAYoC;AACpC,4EAA6F;AAC7F,wEAA4D;AAiD5D;;;GAGG;AACH,MAAa,cAAc;IACR,OAAO,CAAmB;IACnC,aAAa,CAA0C;IACvD,iBAAiB,CAAU;IAEnC;;;;OAIG;IACH,YAAY,KAA0B;QACpC,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,CA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C,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 { 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\";\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\n /**\n * Constructor\n * @param iModel\n * @param dataProvider\n */\n constructor(props: ContentBuilderProps) {\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 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 using ruleset = await Presentation.presentation.rulesets().add(rulesetOrId);\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 },\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 // try {\n const reader = this._iModel.createQueryReader(\n `\n SELECT ECInstanceId FROM ONLY \"${nameEntry.schemaName}\".\"${nameEntry.className}\"\n ORDER BY ECInstanceId\n `,\n undefined,\n { rowFormat: QueryRowFormat.UseJsPropertyNames, limit: { count: limitInstances ? 1 : 4000 } },\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 (Array.isArray(value)) {\n return value.map((item) => this.processRawValue(item));\n }\n\n if (value instanceof Object) {\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,oDAAoD;AAEpD,oEAYoC;AACpC,4EAA6F;AAC7F,wEAA4D;AAC5D,6CAA2C;AAiD3C;;;GAGG;AACH,MAAa,cAAc;IACR,OAAO,CAAmB;IACnC,aAAa,CAA0C;IACvD,iBAAiB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,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACxD,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 { 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\n /**\n * Constructor\n * @param iModel\n * @param dataProvider\n */\n constructor(props: ContentBuilderProps) {\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 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 },\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 // try {\n const reader = this._iModel.createQueryReader(\n `\n SELECT ECInstanceId FROM ONLY \"${nameEntry.schemaName}\".\"${nameEntry.className}\"\n ORDER BY ECInstanceId\n `,\n undefined,\n { rowFormat: QueryRowFormat.UseJsPropertyNames, limit: { count: limitInstances ? 1 : 4000 } },\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"]}
|
|
@@ -48,4 +48,10 @@ export declare const initialize: (props?: PresentationTestingInitProps) => Promi
|
|
|
48
48
|
* @public
|
|
49
49
|
*/
|
|
50
50
|
export declare const terminate: (frontendApp?: typeof IModelApp) => Promise<void>;
|
|
51
|
+
/** @internal */
|
|
52
|
+
export declare function safeDispose(disposable: {} | {
|
|
53
|
+
[Symbol.dispose]: () => void;
|
|
54
|
+
} | {
|
|
55
|
+
dispose: () => void;
|
|
56
|
+
}): void;
|
|
51
57
|
//# sourceMappingURL=Helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAGlB,wBAAwB,IAAI,wBAAwB,EACrD,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AA2BpI,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IACtE,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,WAAkB,4BAA4B,kBA8CpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDA2BrB,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"}
|
|
@@ -22,17 +22,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
22
22
|
}) : function(o, v) {
|
|
23
23
|
o["default"] = v;
|
|
24
24
|
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
32
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
43
|
exports.terminate = exports.initialize = exports.HierarchyCacheMode = void 0;
|
|
44
|
+
exports.safeDispose = safeDispose;
|
|
34
45
|
const path_1 = require("path");
|
|
35
|
-
const rimraf = __importStar(require("rimraf"));
|
|
36
46
|
const core_backend_1 = require("@itwin/core-backend");
|
|
37
47
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
38
48
|
const core_common_1 = require("@itwin/core-common");
|
|
@@ -136,7 +146,8 @@ const terminate = async (frontendApp = core_frontend_1.IModelApp) => {
|
|
|
136
146
|
presentation_backend_1.Presentation.terminate();
|
|
137
147
|
await core_backend_1.IModelHost.shutdown();
|
|
138
148
|
if (hierarchiesCacheDirectory) {
|
|
139
|
-
|
|
149
|
+
const { sync: rimrafSync } = await Promise.resolve().then(() => __importStar(require("rimraf")));
|
|
150
|
+
rimrafSync(hierarchiesCacheDirectory);
|
|
140
151
|
}
|
|
141
152
|
// terminate frontend
|
|
142
153
|
presentation_frontend_1.Presentation.terminate();
|
|
@@ -144,4 +155,13 @@ const terminate = async (frontendApp = core_frontend_1.IModelApp) => {
|
|
|
144
155
|
isInitialized = false;
|
|
145
156
|
};
|
|
146
157
|
exports.terminate = terminate;
|
|
158
|
+
/** @internal */
|
|
159
|
+
function safeDispose(disposable) {
|
|
160
|
+
if ("dispose" in disposable) {
|
|
161
|
+
disposable.dispose();
|
|
162
|
+
}
|
|
163
|
+
else if (Symbol.dispose in disposable) {
|
|
164
|
+
disposable[Symbol.dispose]();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
147
167
|
//# sourceMappingURL=Helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+JH,kCAMC;AAnKD,+BAA4B;AAC5B,sDAAoE;AACpE,sDAA6D;AAC7D,oDAA+H;AAC/H,wDAAgF;AAChF,sEAKqC;AA6B5B,mGAjCP,yCAAkB,OAiCO;AA5B3B,oEAAsE;AACtE,wEAAoI;AACpI,yDAAwE;AAExE,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,qCAAuB;QAClC,UAAU,GAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;KACpD,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE,CAAC;QACpC,8CAA8C;QAC9C,8BAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,QAAQ,GAAG,8BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI,CAAC;QACH,8BAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAChD,qBAAqB;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,kFAAkF;QAClF,yDAAyD;IAC3D,CAAC;IACD,mBAAmB;AACrB,CAAC;AAED,IAAI,aAAa,GAAG,KAAK,CAAC;AA0B1B;;;;;;;GAOG;AACI,MAAM,UAAU,GAAG,KAAK,EAAE,KAAoC,EAAE,EAAE;IACvE,IAAI,aAAa,EAAE,CAAC;QA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AAC;IAED,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AA3BW,QAAA,SAAS,aA2BpB;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\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;\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 // eslint-disable-next-line @itwin/no-internal\n if (!props.backendProps.id) {\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n }\n await IModelHost.startup({\n cacheDir: join(getTestOutputDir(), \".cache\", `${process.pid}`),\n ...props.backendHostProps,\n });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp) {\n props.frontendApp = NoRenderApp;\n }\n await props.frontendApp.startup(props.frontendAppOptions);\n const defaultFrontendProps: PresentationFrontendProps = {\n presentation: {\n activeLocale: IModelApp.localization.getLanguageList()[0],\n },\n };\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\n setTestOutputDir(props.testOutputDir);\n\n isInitialized = true;\n};\n\n/**\n * Undoes the setup made by `initialize`.\n * @param frontendApp IModelApp implementation\n *\n * @see `initialize`\n *\n * @public\n */\nexport const terminate = async (frontendApp = IModelApp) => {\n if (!isInitialized) {\n return;\n }\n\n // store directory that needs to be cleaned-up\n let hierarchiesCacheDirectory: string | undefined;\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n } else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\n }\n\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory) {\n 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,4 +1,3 @@
|
|
|
1
|
-
import { PresentationManagerMode } from "@itwin/presentation-backend";
|
|
2
1
|
/**
|
|
3
2
|
* @module Hierarchies
|
|
4
3
|
*
|
|
@@ -19,7 +18,7 @@ export * from "./presentation-testing/ContentBuilder.js";
|
|
|
19
18
|
* @docs-group-description Helpers
|
|
20
19
|
* Various test helpers.
|
|
21
20
|
*/
|
|
22
|
-
export
|
|
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
|
|
@@ -28,5 +27,21 @@ export { createFileNameFromString, getTestOutputDir, limitFilePathLength, setTes
|
|
|
28
27
|
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
29
28
|
*/
|
|
30
29
|
export * from "./presentation-testing/IModelUtilities.js";
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Presentation manager working mode.
|
|
32
|
+
* @public
|
|
33
|
+
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
34
|
+
*/
|
|
35
|
+
export declare enum PresentationManagerMode {
|
|
36
|
+
/**
|
|
37
|
+
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
38
|
+
* related to reacting to changes in iModels.
|
|
39
|
+
*/
|
|
40
|
+
ReadOnly = 0,
|
|
41
|
+
/**
|
|
42
|
+
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
43
|
+
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
44
|
+
*/
|
|
45
|
+
ReadWrite = 1
|
|
46
|
+
}
|
|
32
47
|
//# sourceMappingURL=presentation-testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA
|
|
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;AACH,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"}
|
|
@@ -18,9 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.PresentationManagerMode = exports.setupOutputFileLocation = exports.setTestOutputDir = exports.limitFilePathLength = exports.getTestOutputDir = exports.createFileNameFromString = void 0;
|
|
22
|
-
const presentation_backend_1 = require("@itwin/presentation-backend");
|
|
23
|
-
Object.defineProperty(exports, "PresentationManagerMode", { enumerable: true, get: function () { return presentation_backend_1.PresentationManagerMode; } });
|
|
21
|
+
exports.PresentationManagerMode = exports.setupOutputFileLocation = exports.setTestOutputDir = exports.limitFilePathLength = exports.getTestOutputDir = exports.createFileNameFromString = exports.terminate = exports.initialize = exports.HierarchyCacheMode = void 0;
|
|
24
22
|
/**
|
|
25
23
|
* @module Hierarchies
|
|
26
24
|
*
|
|
@@ -41,7 +39,10 @@ __exportStar(require("./presentation-testing/ContentBuilder.js"), exports);
|
|
|
41
39
|
* @docs-group-description Helpers
|
|
42
40
|
* Various test helpers.
|
|
43
41
|
*/
|
|
44
|
-
|
|
42
|
+
var Helpers_js_1 = require("./presentation-testing/Helpers.js");
|
|
43
|
+
Object.defineProperty(exports, "HierarchyCacheMode", { enumerable: true, get: function () { return Helpers_js_1.HierarchyCacheMode; } });
|
|
44
|
+
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return Helpers_js_1.initialize; } });
|
|
45
|
+
Object.defineProperty(exports, "terminate", { enumerable: true, get: function () { return Helpers_js_1.terminate; } });
|
|
45
46
|
var FilenameUtils_js_1 = require("./presentation-testing/FilenameUtils.js");
|
|
46
47
|
Object.defineProperty(exports, "createFileNameFromString", { enumerable: true, get: function () { return FilenameUtils_js_1.createFileNameFromString; } });
|
|
47
48
|
Object.defineProperty(exports, "getTestOutputDir", { enumerable: true, get: function () { return FilenameUtils_js_1.getTestOutputDir; } });
|
|
@@ -55,4 +56,23 @@ Object.defineProperty(exports, "setupOutputFileLocation", { enumerable: true, ge
|
|
|
55
56
|
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
56
57
|
*/
|
|
57
58
|
__exportStar(require("./presentation-testing/IModelUtilities.js"), exports);
|
|
59
|
+
// TODO: remove when itwinjs-core 4.x is dropped.
|
|
60
|
+
/**
|
|
61
|
+
* Presentation manager working mode.
|
|
62
|
+
* @public
|
|
63
|
+
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
64
|
+
*/
|
|
65
|
+
var PresentationManagerMode;
|
|
66
|
+
(function (PresentationManagerMode) {
|
|
67
|
+
/**
|
|
68
|
+
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
69
|
+
* related to reacting to changes in iModels.
|
|
70
|
+
*/
|
|
71
|
+
PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
|
|
72
|
+
/**
|
|
73
|
+
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
74
|
+
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
75
|
+
*/
|
|
76
|
+
PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
|
|
77
|
+
})(PresentationManagerMode || (exports.PresentationManagerMode = PresentationManagerMode = {}));
|
|
58
78
|
//# sourceMappingURL=presentation-testing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;AAEhG
|
|
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,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 */\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,OAAO,EAGP,WAAW,EACX,MAAM,EACN,WAAW,EAEX,OAAO,EAIR,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ContentBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,gB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MAAgD;IAItI;;;;;;;OAOG;IACU,gCAAgC,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,EAAE,WAAW,GAAE,MAAgD;CAG3I"}
|
|
@@ -58,9 +58,10 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
58
58
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
59
59
|
});
|
|
60
60
|
import { QueryRowFormat } from "@itwin/core-common";
|
|
61
|
-
import { DefaultContentDisplayTypes, KeySet, traverseContent, } from "@itwin/presentation-common";
|
|
61
|
+
import { DefaultContentDisplayTypes, KeySet, traverseContent, Value, } from "@itwin/presentation-common";
|
|
62
62
|
import { ContentDataProvider, PropertyRecordsBuilder } from "@itwin/presentation-components";
|
|
63
63
|
import { Presentation } from "@itwin/presentation-frontend";
|
|
64
|
+
import { safeDispose } from "./Helpers.js";
|
|
64
65
|
/**
|
|
65
66
|
* A class that constructs content from specified imodel and ruleset.
|
|
66
67
|
* @public
|
|
@@ -103,7 +104,8 @@ export class ContentBuilder {
|
|
|
103
104
|
if (typeof rulesetOrId === "string") {
|
|
104
105
|
return this.doCreateContent(rulesetOrId, instanceKeys, displayType);
|
|
105
106
|
}
|
|
106
|
-
const ruleset =
|
|
107
|
+
const ruleset = await Presentation.presentation.rulesets().add(rulesetOrId);
|
|
108
|
+
const _ = __addDisposableResource(env_1, { [Symbol.dispose]: () => safeDispose(ruleset) }, false);
|
|
107
109
|
return await this.doCreateContent(ruleset.id, instanceKeys, displayType);
|
|
108
110
|
}
|
|
109
111
|
catch (e_1) {
|
|
@@ -186,10 +188,10 @@ class PropertyRecordsAccumulator extends PropertyRecordsBuilder {
|
|
|
186
188
|
if (typeof value === "number") {
|
|
187
189
|
return +Number(value).toFixed(this._decimalPrecision);
|
|
188
190
|
}
|
|
189
|
-
if (
|
|
191
|
+
if (Value.isArray(value)) {
|
|
190
192
|
return value.map((item) => this.processRawValue(item));
|
|
191
193
|
}
|
|
192
|
-
if (value
|
|
194
|
+
if (Value.isMap(value)) {
|
|
193
195
|
const res = {};
|
|
194
196
|
Object.entries(value).forEach(([key, memberValue]) => {
|
|
195
197
|
res[key] = this.processRawValue(memberValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/ContentBuilder.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,0BAA0B,EAG1B,MAAM,EAIN,eAAe,GAGhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAiD5D;;;GAGG;AACH,MAAM,OAAO,cAAc;IACR,OAAO,CAAmB;IACnC,aAAa,CAA0C;IACvD,iBAAiB,CAAU;IAEnC;;;;OAIG;IACH,YAAY,KAA0B;QACpC,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,CAAC,IAAI,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;QAClJ,YAAY,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;QAE7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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 { 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\";\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\n /**\n * Constructor\n * @param iModel\n * @param dataProvider\n */\n constructor(props: ContentBuilderProps) {\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 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 using ruleset = await Presentation.presentation.rulesets().add(rulesetOrId);\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 },\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 // try {\n const reader = this._iModel.createQueryReader(\n `\n SELECT ECInstanceId FROM ONLY \"${nameEntry.schemaName}\".\"${nameEntry.className}\"\n ORDER BY ECInstanceId\n `,\n undefined,\n { rowFormat: QueryRowFormat.UseJsPropertyNames, limit: { count: limitInstances ? 1 : 4000 } },\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 (Array.isArray(value)) {\n return value.map((item) => this.processRawValue(item));\n }\n\n if (value instanceof Object) {\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,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,0BAA0B,EAG1B,MAAM,EAIN,eAAe,EACf,KAAK,GAEN,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiD3C;;;GAGG;AACH,MAAM,OAAO,cAAc;IACR,OAAO,CAAmB;IACnC,aAAa,CAA0C;IACvD,iBAAiB,CAAU;IAEnC;;;;OAIG;I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AC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,KAAK,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,KAAK,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 { 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\n /**\n * Constructor\n * @param iModel\n * @param dataProvider\n */\n constructor(props: ContentBuilderProps) {\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 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 },\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 // try {\n const reader = this._iModel.createQueryReader(\n `\n SELECT ECInstanceId FROM ONLY \"${nameEntry.schemaName}\".\"${nameEntry.className}\"\n ORDER BY ECInstanceId\n `,\n undefined,\n { rowFormat: QueryRowFormat.UseJsPropertyNames, limit: { count: limitInstances ? 1 : 4000 } },\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"]}
|
|
@@ -48,4 +48,10 @@ export declare const initialize: (props?: PresentationTestingInitProps) => Promi
|
|
|
48
48
|
* @public
|
|
49
49
|
*/
|
|
50
50
|
export declare const terminate: (frontendApp?: typeof IModelApp) => Promise<void>;
|
|
51
|
+
/** @internal */
|
|
52
|
+
export declare function safeDispose(disposable: {} | {
|
|
53
|
+
[Symbol.dispose]: () => void;
|
|
54
|
+
} | {
|
|
55
|
+
dispose: () => void;
|
|
56
|
+
}): void;
|
|
51
57
|
//# sourceMappingURL=Helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAGlB,wBAAwB,IAAI,wBAAwB,EACrD,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AA2BpI,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IACtE,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,WAAkB,4BAA4B,kBA8CpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDA2BrB,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"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* @module Helpers
|
|
7
7
|
*/
|
|
8
8
|
import { join } from "path";
|
|
9
|
-
import * as rimraf from "rimraf";
|
|
10
9
|
import { IModelHost } from "@itwin/core-backend";
|
|
11
10
|
import { Guid, Logger, LogLevel } from "@itwin/core-bentley";
|
|
12
11
|
import { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration } from "@itwin/core-common";
|
|
@@ -109,11 +108,21 @@ export const terminate = async (frontendApp = IModelApp) => {
|
|
|
109
108
|
PresentationBackend.terminate();
|
|
110
109
|
await IModelHost.shutdown();
|
|
111
110
|
if (hierarchiesCacheDirectory) {
|
|
112
|
-
|
|
111
|
+
const { sync: rimrafSync } = await import("rimraf");
|
|
112
|
+
rimrafSync(hierarchiesCacheDirectory);
|
|
113
113
|
}
|
|
114
114
|
// terminate frontend
|
|
115
115
|
PresentationFrontend.terminate();
|
|
116
116
|
await frontendApp.shutdown();
|
|
117
117
|
isInitialized = false;
|
|
118
118
|
};
|
|
119
|
+
/** @internal */
|
|
120
|
+
export function safeDispose(disposable) {
|
|
121
|
+
if ("dispose" in disposable) {
|
|
122
|
+
disposable.dispose();
|
|
123
|
+
}
|
|
124
|
+
else if (Symbol.dispose in disposable) {
|
|
125
|
+
disposable[Symbol.dispose]();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
119
128
|
//# sourceMappingURL=Helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAqB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAA0B,MAAM,oBAAoB,CAAC;AAC/H,OAAO,EAAE,SAAS,EAAoB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,YAAY,IAAI,mBAAmB,EACnC,uCAAuC,GAExC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAkD,MAAM,8BAA8B,CAAC;AACpI,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM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GAAG,SAAS,EAAE,EAAE;IACzD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IAED,8CAA8C;IAC9C,IAAI,yBAA6C,CAAC;IAClD,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC;IACnF,IAAI,sBAAsB,EAAE,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAE,CAAC;QAC7D,yBAAyB,GAAG,sBAAsB,EAAE,SAAS,CAAC;IAChE,CAAC;SAAM,IAAI,sBAAsB,EAAE,IAAI,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;QACtE,yBAAyB,GAAG,sBAAsB,EAAE,IAAI,EAAE,SAAS,CAAC;IACtE,CAAC;IAED,oBAAoB;IACpB,mBAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB,EAAE,CAAC;QAC9B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpD,UAAU,CAAC,yBAAyB,CAAC,CAAC;IACxC,CAAC;IAED,qBAAqB;IACrB,oBAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AAEF,gBAAgB;AAChB,MAAM,UAAU,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\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;\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 // eslint-disable-next-line @itwin/no-internal\n if (!props.backendProps.id) {\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n }\n await IModelHost.startup({\n cacheDir: join(getTestOutputDir(), \".cache\", `${process.pid}`),\n ...props.backendHostProps,\n });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp) {\n props.frontendApp = NoRenderApp;\n }\n await props.frontendApp.startup(props.frontendAppOptions);\n const defaultFrontendProps: PresentationFrontendProps = {\n presentation: {\n activeLocale: IModelApp.localization.getLanguageList()[0],\n },\n };\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\n setTestOutputDir(props.testOutputDir);\n\n isInitialized = true;\n};\n\n/**\n * Undoes the setup made by `initialize`.\n * @param frontendApp IModelApp implementation\n *\n * @see `initialize`\n *\n * @public\n */\nexport const terminate = async (frontendApp = IModelApp) => {\n if (!isInitialized) {\n return;\n }\n\n // store directory that needs to be cleaned-up\n let hierarchiesCacheDirectory: string | undefined;\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n } else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\n }\n\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory) {\n 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,4 +1,3 @@
|
|
|
1
|
-
import { PresentationManagerMode } from "@itwin/presentation-backend";
|
|
2
1
|
/**
|
|
3
2
|
* @module Hierarchies
|
|
4
3
|
*
|
|
@@ -19,7 +18,7 @@ export * from "./presentation-testing/ContentBuilder.js";
|
|
|
19
18
|
* @docs-group-description Helpers
|
|
20
19
|
* Various test helpers.
|
|
21
20
|
*/
|
|
22
|
-
export
|
|
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
|
|
@@ -28,5 +27,21 @@ export { createFileNameFromString, getTestOutputDir, limitFilePathLength, setTes
|
|
|
28
27
|
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
29
28
|
*/
|
|
30
29
|
export * from "./presentation-testing/IModelUtilities.js";
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Presentation manager working mode.
|
|
32
|
+
* @public
|
|
33
|
+
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
34
|
+
*/
|
|
35
|
+
export declare enum PresentationManagerMode {
|
|
36
|
+
/**
|
|
37
|
+
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
38
|
+
* related to reacting to changes in iModels.
|
|
39
|
+
*/
|
|
40
|
+
ReadOnly = 0,
|
|
41
|
+
/**
|
|
42
|
+
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
43
|
+
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
44
|
+
*/
|
|
45
|
+
ReadWrite = 1
|
|
46
|
+
}
|
|
32
47
|
//# sourceMappingURL=presentation-testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA
|
|
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;AACH,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"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { PresentationManagerMode } from "@itwin/presentation-backend";
|
|
6
5
|
/**
|
|
7
6
|
* @module Hierarchies
|
|
8
7
|
*
|
|
@@ -23,7 +22,7 @@ export * from "./presentation-testing/ContentBuilder.js";
|
|
|
23
22
|
* @docs-group-description Helpers
|
|
24
23
|
* Various test helpers.
|
|
25
24
|
*/
|
|
26
|
-
export
|
|
25
|
+
export { HierarchyCacheMode, initialize, terminate } from "./presentation-testing/Helpers.js";
|
|
27
26
|
export { createFileNameFromString, getTestOutputDir, limitFilePathLength, setTestOutputDir, setupOutputFileLocation, } from "./presentation-testing/FilenameUtils.js";
|
|
28
27
|
/**
|
|
29
28
|
* @module IModel
|
|
@@ -32,5 +31,23 @@ export { createFileNameFromString, getTestOutputDir, limitFilePathLength, setTes
|
|
|
32
31
|
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
33
32
|
*/
|
|
34
33
|
export * from "./presentation-testing/IModelUtilities.js";
|
|
35
|
-
|
|
34
|
+
// TODO: remove when itwinjs-core 4.x is dropped.
|
|
35
|
+
/**
|
|
36
|
+
* Presentation manager working mode.
|
|
37
|
+
* @public
|
|
38
|
+
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
39
|
+
*/
|
|
40
|
+
export var PresentationManagerMode;
|
|
41
|
+
(function (PresentationManagerMode) {
|
|
42
|
+
/**
|
|
43
|
+
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
44
|
+
* related to reacting to changes in iModels.
|
|
45
|
+
*/
|
|
46
|
+
PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
|
|
47
|
+
/**
|
|
48
|
+
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
49
|
+
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
50
|
+
*/
|
|
51
|
+
PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
|
|
52
|
+
})(PresentationManagerMode || (PresentationManagerMode = {}));
|
|
36
53
|
//# sourceMappingURL=presentation-testing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG
|
|
1
|
+
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;;;;GAKG;AACH,cAAc,4CAA4C,CAAC;AAE3D;;;;;GAKG;AACH,cAAc,0CAA0C,CAAC;AAEzD;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAA0D,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;AAE1D,iDAAiD;AACjD;;;;GAIG;AACH,MAAM,CAAN,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,KAAvB,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 */\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"description": "Testing utilities for iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"rimraf": "^6.0.1",
|
|
34
34
|
"sanitize-filename": "^1.6.3",
|
|
35
|
-
"@itwin/presentation-components": "^5.
|
|
35
|
+
"@itwin/presentation-components": "^5.12.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@itwin/appui-abstract": "^4.1.0 || ^5.0.0",
|
|
@@ -46,29 +46,29 @@
|
|
|
46
46
|
"@itwin/presentation-frontend": "^4.1.0 || ^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@itwin/appui-abstract": "^5.0.0-dev.
|
|
50
|
-
"@itwin/build-tools": "
|
|
49
|
+
"@itwin/appui-abstract": "^5.0.0-dev.78",
|
|
50
|
+
"@itwin/build-tools": "5.0.0-dev.67",
|
|
51
51
|
"@itwin/components-react": "^5.1.0",
|
|
52
|
-
"@itwin/core-backend": "^5.0.0-dev.
|
|
53
|
-
"@itwin/core-bentley": "^5.0.0-dev.
|
|
54
|
-
"@itwin/core-common": "^5.0.0-dev.
|
|
55
|
-
"@itwin/core-frontend": "^5.0.0-dev.
|
|
56
|
-
"@itwin/core-geometry": "^5.0.0-dev.
|
|
57
|
-
"@itwin/core-orbitgt": "^5.0.0-dev.
|
|
58
|
-
"@itwin/core-quantity": "^5.0.0-dev.
|
|
52
|
+
"@itwin/core-backend": "^5.0.0-dev.78",
|
|
53
|
+
"@itwin/core-bentley": "^5.0.0-dev.78",
|
|
54
|
+
"@itwin/core-common": "^5.0.0-dev.78",
|
|
55
|
+
"@itwin/core-frontend": "^5.0.0-dev.78",
|
|
56
|
+
"@itwin/core-geometry": "^5.0.0-dev.78",
|
|
57
|
+
"@itwin/core-orbitgt": "^5.0.0-dev.78",
|
|
58
|
+
"@itwin/core-quantity": "^5.0.0-dev.78",
|
|
59
59
|
"@itwin/core-react": "^5.1.0",
|
|
60
|
-
"@itwin/ecschema-metadata": "^5.0.0-dev.
|
|
60
|
+
"@itwin/ecschema-metadata": "^5.0.0-dev.78",
|
|
61
61
|
"@itwin/eslint-plugin": "5.0.0-dev.1",
|
|
62
|
-
"@itwin/presentation-backend": "^5.0.0-dev.
|
|
63
|
-
"@itwin/presentation-common": "^5.0.0-dev.
|
|
64
|
-
"@itwin/presentation-frontend": "^5.0.0-dev.
|
|
65
|
-
"@itwin/webgl-compatibility": "^5.0.0-dev.
|
|
62
|
+
"@itwin/presentation-backend": "^5.0.0-dev.78",
|
|
63
|
+
"@itwin/presentation-common": "^5.0.0-dev.78",
|
|
64
|
+
"@itwin/presentation-frontend": "^5.0.0-dev.78",
|
|
65
|
+
"@itwin/webgl-compatibility": "^5.0.0-dev.78",
|
|
66
66
|
"@opentelemetry/api": "^1.9.0",
|
|
67
67
|
"@types/chai": "^4.3.16",
|
|
68
68
|
"@types/chai-as-promised": "^7.1.8",
|
|
69
69
|
"@types/chai-jest-snapshot": "^1.3.8",
|
|
70
70
|
"@types/mocha": "^10.0.7",
|
|
71
|
-
"@types/node": "^
|
|
71
|
+
"@types/node": "^22.13.9",
|
|
72
72
|
"@types/sinon": "^17.0.3",
|
|
73
73
|
"@types/sinon-chai": "^3.2.12",
|
|
74
74
|
"c8": "^10.1.2",
|
|
@@ -88,9 +88,7 @@
|
|
|
88
88
|
"reflect-metadata": "^0.1.14",
|
|
89
89
|
"sinon": "^18.0.0",
|
|
90
90
|
"sinon-chai": "^3.7.0",
|
|
91
|
-
"
|
|
92
|
-
"typescript": "~5.6.3",
|
|
93
|
-
"presentation-build-tools": "^0.0.0",
|
|
91
|
+
"typescript": "~5.7.3",
|
|
94
92
|
"presentation-test-utilities": "^0.0.0"
|
|
95
93
|
},
|
|
96
94
|
"scripts": {
|
|
@@ -103,9 +101,9 @@
|
|
|
103
101
|
"docs:changelog": "cpx ./CHANGELOG.md ./build/docs/reference/presentation-testing",
|
|
104
102
|
"docs:reference": "cross-env NODE_PROJECT_ROOT_DIRECTORY=../../ betools docs --json=./build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
|
|
105
103
|
"lint": "eslint ./src/**/*.ts",
|
|
106
|
-
"test:dev": "
|
|
104
|
+
"test:dev": "node --experimental-test-module-mocks --enable-source-maps --import presentation-test-utilities/node-hooks/ignore-styles ./node_modules/mocha/bin/mocha.js --config ./.mocharc.json",
|
|
107
105
|
"test": "npm run test:dev",
|
|
108
|
-
"extract-api": "extract-api --entry=presentation-testing --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api",
|
|
106
|
+
"extract-api": "betools extract-api --entry=lib/esm/presentation-testing --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api --includeUnexportedApis",
|
|
109
107
|
"check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/presentation-testing.api.md"
|
|
110
108
|
}
|
|
111
109
|
}
|