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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +52 -1
  2. package/lib/cjs/presentation-testing/ContentBuilder.d.ts +87 -87
  3. package/lib/cjs/presentation-testing/ContentBuilder.js +147 -147
  4. package/lib/cjs/presentation-testing/ContentBuilder.js.map +1 -1
  5. package/lib/cjs/presentation-testing/Helpers.d.ts +38 -35
  6. package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
  7. package/lib/cjs/presentation-testing/Helpers.js +125 -125
  8. package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
  9. package/lib/cjs/presentation-testing/HierarchyBuilder.d.ts +66 -66
  10. package/lib/cjs/presentation-testing/HierarchyBuilder.js +68 -68
  11. package/lib/cjs/presentation-testing/HierarchyBuilder.js.map +1 -1
  12. package/lib/cjs/presentation-testing/IModelBuilder.d.ts +46 -0
  13. package/lib/cjs/presentation-testing/IModelBuilder.d.ts.map +1 -0
  14. package/lib/cjs/presentation-testing/IModelBuilder.js +171 -0
  15. package/lib/cjs/presentation-testing/IModelBuilder.js.map +1 -0
  16. package/lib/cjs/presentation-testing/IModelTestUtility.d.ts +25 -0
  17. package/lib/cjs/presentation-testing/IModelTestUtility.d.ts.map +1 -0
  18. package/lib/cjs/presentation-testing/IModelTestUtility.js +63 -0
  19. package/lib/cjs/presentation-testing/IModelTestUtility.js.map +1 -0
  20. package/lib/cjs/presentation-testing.d.ts +28 -21
  21. package/lib/cjs/presentation-testing.d.ts.map +1 -1
  22. package/lib/cjs/presentation-testing.js +44 -37
  23. package/lib/cjs/presentation-testing.js.map +1 -1
  24. package/lib/esm/presentation-testing/ContentBuilder.d.ts +87 -87
  25. package/lib/esm/presentation-testing/ContentBuilder.js +143 -143
  26. package/lib/esm/presentation-testing/ContentBuilder.js.map +1 -1
  27. package/lib/esm/presentation-testing/Helpers.d.ts +38 -35
  28. package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
  29. package/lib/esm/presentation-testing/Helpers.js +100 -100
  30. package/lib/esm/presentation-testing/Helpers.js.map +1 -1
  31. package/lib/esm/presentation-testing/HierarchyBuilder.d.ts +66 -66
  32. package/lib/esm/presentation-testing/HierarchyBuilder.js +63 -63
  33. package/lib/esm/presentation-testing/HierarchyBuilder.js.map +1 -1
  34. package/lib/esm/presentation-testing/IModelBuilder.d.ts +46 -0
  35. package/lib/esm/presentation-testing/IModelBuilder.d.ts.map +1 -0
  36. package/lib/esm/presentation-testing/IModelBuilder.js +147 -0
  37. package/lib/esm/presentation-testing/IModelBuilder.js.map +1 -0
  38. package/lib/esm/presentation-testing/IModelTestUtility.d.ts +25 -0
  39. package/lib/esm/presentation-testing/IModelTestUtility.d.ts.map +1 -0
  40. package/lib/esm/presentation-testing/IModelTestUtility.js +59 -0
  41. package/lib/esm/presentation-testing/IModelTestUtility.js.map +1 -0
  42. package/lib/esm/presentation-testing.d.ts +28 -21
  43. package/lib/esm/presentation-testing.d.ts.map +1 -1
  44. package/lib/esm/presentation-testing.js +32 -25
  45. package/lib/esm/presentation-testing.js.map +1 -1
  46. package/package.json +13 -13
@@ -1,69 +1,69 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HierarchyBuilder = exports.defaultNodeMappingFunc = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- /** @packageDocumentation
9
- * @module Hierarchies
10
- */
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const presentation_components_1 = require("@itwin/presentation-components");
13
- const presentation_frontend_1 = require("@itwin/presentation-frontend");
14
- /**
15
- * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
16
- * @public
17
- */
18
- const defaultNodeMappingFunc = (node) => {
19
- // Skip properties 'id', 'parentId' as they contain internal stuff
20
- // that callers are most likely not interested in. Otherwise they can supply
21
- // a custom `NodeMappingFunc` that does return those properties as well.
22
- const { id, parentId, ...resultNode } = node; // eslint-disable-line @typescript-eslint/no-unused-vars
23
- return resultNode;
24
- };
25
- exports.defaultNodeMappingFunc = defaultNodeMappingFunc;
26
- /**
27
- * A class that constructs simple node hierarchy from specified
28
- * imodel and ruleset.
29
- *
30
- * @public
31
- */
32
- class HierarchyBuilder {
33
- /** Constructor */
34
- constructor(props) {
35
- var _a;
36
- this._iModel = props.imodel;
37
- this._nodeMappingFunc = (_a = props.nodeMappingFunc) !== null && _a !== void 0 ? _a : exports.defaultNodeMappingFunc;
38
- }
39
- async createSubHierarchy(nodes, dataProvider) {
40
- const hierarchy = [];
41
- for (const node of nodes) {
42
- // istanbul ignore next: for some reason coverage tool thinks the below statement is conditional and one of branches is not covered...
43
- const { [presentation_components_1.PRESENTATION_TREE_NODE_KEY]: key, ...nodeNoKey } = node; // eslint-disable-line @typescript-eslint/no-unused-vars
44
- const nodeIndex = hierarchy.push(this._nodeMappingFunc(nodeNoKey)) - 1;
45
- const childNodes = await dataProvider.getNodes(node);
46
- if (childNodes.length > 0)
47
- hierarchy[nodeIndex].children = await this.createSubHierarchy(childNodes, dataProvider);
48
- }
49
- return hierarchy;
50
- }
51
- async doCreateHierarchy(rulesetId) {
52
- const dataProvider = new presentation_components_1.PresentationTreeDataProvider({ imodel: this._iModel, ruleset: rulesetId });
53
- const rootNodes = await dataProvider.getNodes();
54
- return this.createSubHierarchy(rootNodes, dataProvider);
55
- }
56
- /**
57
- * Create a hierarchy using the supplied presentation ruleset.
58
- * @param rulesetOrId Either a [[Ruleset]] object or a ruleset id.
59
- */
60
- async createHierarchy(rulesetOrId) {
61
- if (typeof rulesetOrId === "string")
62
- return this.doCreateHierarchy(rulesetOrId);
63
- return (0, core_bentley_1.using)(await presentation_frontend_1.Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset) => {
64
- return this.doCreateHierarchy(ruleset.id);
65
- });
66
- }
67
- }
68
- exports.HierarchyBuilder = HierarchyBuilder;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HierarchyBuilder = exports.defaultNodeMappingFunc = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ /** @packageDocumentation
9
+ * @module Hierarchies
10
+ */
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const presentation_components_1 = require("@itwin/presentation-components");
13
+ const presentation_frontend_1 = require("@itwin/presentation-frontend");
14
+ /**
15
+ * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.
16
+ * @public
17
+ */
18
+ const defaultNodeMappingFunc = (node) => {
19
+ // Skip properties 'id', 'parentId' as they contain internal stuff
20
+ // that callers are most likely not interested in. Otherwise they can supply
21
+ // a custom `NodeMappingFunc` that does return those properties as well.
22
+ const { id, parentId, ...resultNode } = node; // eslint-disable-line @typescript-eslint/no-unused-vars
23
+ return resultNode;
24
+ };
25
+ exports.defaultNodeMappingFunc = defaultNodeMappingFunc;
26
+ /**
27
+ * A class that constructs simple node hierarchy from specified
28
+ * imodel and ruleset.
29
+ *
30
+ * @public
31
+ */
32
+ class HierarchyBuilder {
33
+ /** Constructor */
34
+ constructor(props) {
35
+ var _a;
36
+ this._iModel = props.imodel;
37
+ this._nodeMappingFunc = (_a = props.nodeMappingFunc) !== null && _a !== void 0 ? _a : exports.defaultNodeMappingFunc;
38
+ }
39
+ async createSubHierarchy(nodes, dataProvider) {
40
+ const hierarchy = [];
41
+ for (const node of nodes) {
42
+ // istanbul ignore next: for some reason coverage tool thinks the below statement is conditional and one of branches is not covered...
43
+ const { [presentation_components_1.PRESENTATION_TREE_NODE_KEY]: key, ...nodeNoKey } = node; // eslint-disable-line @typescript-eslint/no-unused-vars
44
+ const nodeIndex = hierarchy.push(this._nodeMappingFunc(nodeNoKey)) - 1;
45
+ const childNodes = await dataProvider.getNodes(node);
46
+ if (childNodes.length > 0)
47
+ hierarchy[nodeIndex].children = await this.createSubHierarchy(childNodes, dataProvider);
48
+ }
49
+ return hierarchy;
50
+ }
51
+ async doCreateHierarchy(rulesetId) {
52
+ const dataProvider = new presentation_components_1.PresentationTreeDataProvider({ imodel: this._iModel, ruleset: rulesetId });
53
+ const rootNodes = await dataProvider.getNodes();
54
+ return this.createSubHierarchy(rootNodes, dataProvider);
55
+ }
56
+ /**
57
+ * Create a hierarchy using the supplied presentation ruleset.
58
+ * @param rulesetOrId Either a [[Ruleset]] object or a ruleset id.
59
+ */
60
+ async createHierarchy(rulesetOrId) {
61
+ if (typeof rulesetOrId === "string")
62
+ return this.doCreateHierarchy(rulesetOrId);
63
+ return (0, core_bentley_1.using)(await presentation_frontend_1.Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset) => {
64
+ return this.doCreateHierarchy(ruleset.id);
65
+ });
66
+ }
67
+ }
68
+ exports.HierarchyBuilder = HierarchyBuilder;
69
69
  //# sourceMappingURL=HierarchyBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAA4C;AAG5C,4EAA0G;AAC1G,wEAA4D;AA+B5D;;;GAGG;AACI,MAAM,sBAAsB,GAAoB,CAAC,IAAkB,EAAE,EAAE;IAC5E,mEAAmE;IACnE,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC,wDAAwD;IACtG,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC;AAiBF;;;;;GAKG;AACH,MAAa,gBAAgB;IAI3B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BAAiB,CAAC,WAAW,CAAC,CAAC;QAE7C,OAAO,IAAA,oBAAK,EAAC,MAAM,oCAAY,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,OAA0B,EAAE,EAAE;YAC7G,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzCD,4CAyCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Hierarchies\r\n */\r\nimport { using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { Omit, RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\r\nimport { PRESENTATION_TREE_NODE_KEY, PresentationTreeDataProvider } from \"@itwin/presentation-components\";\r\nimport { Presentation } from \"@itwin/presentation-frontend\";\r\nimport { TreeNodeItem } from \"@itwin/components-react\";\r\n\r\n/**\r\n * Structure that describes a Node with any indexed properties\r\n * except `children`.\r\n *\r\n * @public\r\n */\r\nexport interface MappedNode {\r\n /** Indexer for all properties in this data structure */\r\n [index: string]: any;\r\n /** Prohibited property */\r\n children?: never;\r\n}\r\n\r\n/**\r\n * Node in a hierarchy.\r\n * @public\r\n */\r\nexport interface HierarchyNode extends Omit<MappedNode, \"children\"> {\r\n /** Children of this node */\r\n children?: HierarchyNode[];\r\n}\r\n\r\n/**\r\n * A function that converts `TreeNodeItem` into a new custom object.\r\n * @public\r\n */\r\nexport type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;\r\n\r\n/**\r\n * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.\r\n * @public\r\n */\r\nexport const defaultNodeMappingFunc: NodeMappingFunc = (node: TreeNodeItem) => {\r\n // Skip properties 'id', 'parentId' as they contain internal stuff\r\n // that callers are most likely not interested in. Otherwise they can supply\r\n // a custom `NodeMappingFunc` that does return those properties as well.\r\n const { id, parentId, ...resultNode } = node; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return resultNode;\r\n};\r\n\r\n/**\r\n * Properties for creating a `HierarchyBuilder` instance.\r\n * @public\r\n */\r\nexport interface HierarchyBuilderProps {\r\n /** The iModel to pull data from */\r\n imodel: IModelConnection;\r\n /**\r\n * A function that maps node to something that the user of\r\n * this API is interested in. E.g. custom implementation may skip some unimportant\r\n * node properties to make resulting object smaller and easier to read.\r\n */\r\n nodeMappingFunc?: NodeMappingFunc;\r\n}\r\n\r\n/**\r\n * A class that constructs simple node hierarchy from specified\r\n * imodel and ruleset.\r\n *\r\n * @public\r\n */\r\nexport class HierarchyBuilder {\r\n private readonly _iModel: IModelConnection;\r\n private readonly _nodeMappingFunc: NodeMappingFunc;\r\n\r\n /** Constructor */\r\n constructor(props: HierarchyBuilderProps) {\r\n this._iModel = props.imodel;\r\n this._nodeMappingFunc = props.nodeMappingFunc ?? defaultNodeMappingFunc;\r\n }\r\n\r\n private async createSubHierarchy(nodes: TreeNodeItem[], dataProvider: PresentationTreeDataProvider) {\r\n const hierarchy: HierarchyNode[] = [];\r\n for (const node of nodes) {\r\n // istanbul ignore next: for some reason coverage tool thinks the below statement is conditional and one of branches is not covered...\r\n const { [PRESENTATION_TREE_NODE_KEY]: key, ...nodeNoKey } = (node as TreeNodeItem & { [PRESENTATION_TREE_NODE_KEY]: any }); // eslint-disable-line @typescript-eslint/no-unused-vars\r\n const nodeIndex = hierarchy.push(this._nodeMappingFunc(nodeNoKey)) - 1;\r\n const childNodes = await dataProvider.getNodes(node);\r\n if (childNodes.length > 0)\r\n hierarchy[nodeIndex].children = await this.createSubHierarchy(childNodes, dataProvider);\r\n }\r\n return hierarchy;\r\n }\r\n\r\n private async doCreateHierarchy(rulesetId: string): Promise<HierarchyNode[]> {\r\n const dataProvider = new PresentationTreeDataProvider({ imodel: this._iModel, ruleset: rulesetId });\r\n const rootNodes = await dataProvider.getNodes();\r\n return this.createSubHierarchy(rootNodes, dataProvider);\r\n }\r\n\r\n /**\r\n * Create a hierarchy using the supplied presentation ruleset.\r\n * @param rulesetOrId Either a [[Ruleset]] object or a ruleset id.\r\n */\r\n public async createHierarchy(rulesetOrId: Ruleset | string): Promise<HierarchyNode[]> {\r\n if (typeof rulesetOrId === \"string\")\r\n return this.doCreateHierarchy(rulesetOrId);\r\n\r\n return using(await Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset: RegisteredRuleset) => {\r\n return this.doCreateHierarchy(ruleset.id);\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"HierarchyBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/HierarchyBuilder.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAA4C;AAG5C,4EAA0G;AAC1G,wEAA4D;AA+B5D;;;GAGG;AACI,MAAM,sBAAsB,GAAoB,CAAC,IAAkB,EAAE,EAAE;IAC5E,mEAAmE;IACnE,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC,wDAAwD;IACtG,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC;AAiBF;;;;;GAKG;AACH,MAAa,gBAAgB;IAI3B,kBAAkB;IAClB,YAAY,KAA4B;;QACtC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,MAAA,KAAK,CAAC,eAAe,mCAAI,8BAAsB,CAAC;IAC1E,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,KAAqB,EAAE,YAA0C;QAChG,MAAM,SAAS,GAAoB,EAAE,CAAC;QACtC,KAAK,MAAM,IAAI,IAAI,K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CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Hierarchies\n */\nimport { using } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { Omit, RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\nimport { PRESENTATION_TREE_NODE_KEY, PresentationTreeDataProvider } from \"@itwin/presentation-components\";\nimport { Presentation } from \"@itwin/presentation-frontend\";\nimport { TreeNodeItem } from \"@itwin/components-react\";\n\n/**\n * Structure that describes a Node with any indexed properties\n * except `children`.\n *\n * @public\n */\nexport interface MappedNode {\n /** Indexer for all properties in this data structure */\n [index: string]: any;\n /** Prohibited property */\n children?: never;\n}\n\n/**\n * Node in a hierarchy.\n * @public\n */\nexport interface HierarchyNode extends Omit<MappedNode, \"children\"> {\n /** Children of this node */\n children?: HierarchyNode[];\n}\n\n/**\n * A function that converts `TreeNodeItem` into a new custom object.\n * @public\n */\nexport type NodeMappingFunc = (node: TreeNodeItem) => MappedNode;\n\n/**\n * Default [[NodeMappingFunc]] implementation that outputs the whole `TreeNodeItem` object.\n * @public\n */\nexport const defaultNodeMappingFunc: NodeMappingFunc = (node: TreeNodeItem) => {\n // Skip properties 'id', 'parentId' as they contain internal stuff\n // that callers are most likely not interested in. Otherwise they can supply\n // a custom `NodeMappingFunc` that does return those properties as well.\n const { id, parentId, ...resultNode } = node; // eslint-disable-line @typescript-eslint/no-unused-vars\n return resultNode;\n};\n\n/**\n * Properties for creating a `HierarchyBuilder` instance.\n * @public\n */\nexport interface HierarchyBuilderProps {\n /** The iModel to pull data from */\n imodel: IModelConnection;\n /**\n * A function that maps node to something that the user of\n * this API is interested in. E.g. custom implementation may skip some unimportant\n * node properties to make resulting object smaller and easier to read.\n */\n nodeMappingFunc?: NodeMappingFunc;\n}\n\n/**\n * A class that constructs simple node hierarchy from specified\n * imodel and ruleset.\n *\n * @public\n */\nexport class HierarchyBuilder {\n private readonly _iModel: IModelConnection;\n private readonly _nodeMappingFunc: NodeMappingFunc;\n\n /** Constructor */\n constructor(props: HierarchyBuilderProps) {\n this._iModel = props.imodel;\n this._nodeMappingFunc = props.nodeMappingFunc ?? defaultNodeMappingFunc;\n }\n\n private async createSubHierarchy(nodes: TreeNodeItem[], dataProvider: PresentationTreeDataProvider) {\n const hierarchy: HierarchyNode[] = [];\n for (const node of nodes) {\n // istanbul ignore next: for some reason coverage tool thinks the below statement is conditional and one of branches is not covered...\n const { [PRESENTATION_TREE_NODE_KEY]: key, ...nodeNoKey } = (node as TreeNodeItem & { [PRESENTATION_TREE_NODE_KEY]: any }); // eslint-disable-line @typescript-eslint/no-unused-vars\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 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]] 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 return using(await Presentation.presentation.rulesets().add(rulesetOrId), async (ruleset: RegisteredRuleset) => {\n return this.doCreateHierarchy(ruleset.id);\n });\n }\n}\n"]}
@@ -0,0 +1,46 @@
1
+ /** @packageDocumentation
2
+ * @module IModel
3
+ */
4
+ import { Element, IModelDb } from "@itwin/core-backend";
5
+ import { Id64String } from "@itwin/core-bentley";
6
+ import { Code, CodeProps, LocalFileName, RelatedElement } from "@itwin/core-common";
7
+ export declare class IModelBuilder {
8
+ /**
9
+ * Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.
10
+ * @return [modeledElementId, modelId]
11
+ */
12
+ static createAndInsertPhysicalPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel?: boolean, parent?: Id64String): Id64String[];
13
+ /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
14
+ static createAndInsertPhysicalPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String;
15
+ /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
16
+ static createAndInsertPhysicalModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel?: boolean): Id64String;
17
+ /**
18
+ * Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.
19
+ * @return [modeledElementId, modelId]
20
+ */
21
+ static createAndInsertDrawingPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel?: boolean, parent?: Id64String): Id64String[];
22
+ /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
23
+ static createAndInsertDrawingPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String;
24
+ /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
25
+ static createAndInsertDrawingModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel?: boolean): Id64String;
26
+ static createDrawingGraphic(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element;
27
+ static createPhysicalObject(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element;
28
+ static getUniqueModelCode(testDb: IModelDb, newModelCodeBase: string): Code;
29
+ /** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */
30
+ static generateUniqueName(baseName: string): string;
31
+ /** Prepare for an output file by:
32
+ * - Resolving the output file name under the known test output directory
33
+ * - Making directories as necessary
34
+ * - Removing a previous copy of the output file
35
+ * @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.
36
+ * @param fileName Name of output fille
37
+ */
38
+ static prepareOutputFile(subDirName: string, fileName: string): LocalFileName;
39
+ }
40
+ export declare class KnownTestLocations {
41
+ /** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */
42
+ static get assetsDir(): string;
43
+ /** The directory where tests can write. */
44
+ static get outputDir(): string;
45
+ }
46
+ //# sourceMappingURL=IModelBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAyB,OAAO,EAAE,QAAQ,EAA2G,MAAM,qBAAqB,CAAC;AACxL,OAAO,EAAc,UAAU,EAAmB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAiD,aAAa,EAAwB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKzJ,qBAAa,aAAa;IACxB;;;OAGG;WACW,wCAAwC,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,GAAE,OAAe,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE;IAOvK,8GAA8G;WAChG,gCAAgC,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU;IAc5H,8GAA8G;WAChG,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,GAAE,OAAe,GAAG,UAAU;IAS1I;;;OAGG;WACW,uCAAuC,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,GAAE,OAAe,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE;IAOtK,4GAA4G;WAC9F,+BAA+B,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU;IAc3H,4GAA4G;WAC9F,2BAA2B,CAAC,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,GAAE,OAAe,GAAG,UAAU;WAU3H,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,OAAO;WAWjH,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,OAAO;WAUjH,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAalF,yGAAyG;WAC3F,kBAAkB,CAAC,QAAQ,EAAE,MAAM;IAIjD;;;;;;OAMG;WACW,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa;CAcrF;AAED,qBAAa,kBAAkB;IAE7B,6GAA6G;IAC7G,WAAkB,SAAS,IAAI,MAAM,CAEpC;IAED,2CAA2C;IAC3C,WAAkB,SAAS,IAAI,MAAM,CAOpC;CACF"}
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module IModel
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.KnownTestLocations = exports.IModelBuilder = void 0;
30
+ const core_backend_1 = require("@itwin/core-backend");
31
+ const core_bentley_1 = require("@itwin/core-bentley");
32
+ const core_common_1 = require("@itwin/core-common");
33
+ const chai_1 = require("chai");
34
+ const os_1 = require("os");
35
+ const path_1 = __importStar(require("path"));
36
+ class IModelBuilder {
37
+ /**
38
+ * Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.
39
+ * @return [modeledElementId, modelId]
40
+ */
41
+ static createAndInsertPhysicalPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
42
+ const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);
43
+ const modeledElementRef = new core_common_1.RelatedElement({ id: eid });
44
+ const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);
45
+ return [eid, mid];
46
+ }
47
+ /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
48
+ static createAndInsertPhysicalPartition(testDb, newModelCode, parentId) {
49
+ const model = parentId ? testDb.elements.getElement(parentId).model : core_common_1.IModel.repositoryModelId;
50
+ const parent = new core_backend_1.SubjectOwnsPartitionElements(parentId || core_common_1.IModel.rootSubjectId);
51
+ const modeledElementProps = {
52
+ classFullName: core_backend_1.PhysicalPartition.classFullName,
53
+ parent,
54
+ model,
55
+ code: newModelCode,
56
+ };
57
+ const modeledElement = testDb.elements.createElement(modeledElementProps);
58
+ return testDb.elements.insertElement(modeledElement.toJSON());
59
+ }
60
+ /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
61
+ static createAndInsertPhysicalModel(testDb, modeledElementRef, privateModel = false) {
62
+ const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: core_backend_1.PhysicalModel.classFullName, isPrivate: privateModel });
63
+ const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
64
+ chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModelId));
65
+ chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModel.id));
66
+ chai_1.assert.deepEqual(newModelId, newModel.id);
67
+ return newModelId;
68
+ }
69
+ /**
70
+ * Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.
71
+ * @return [modeledElementId, modelId]
72
+ */
73
+ static createAndInsertDrawingPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
74
+ const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);
75
+ const modeledElementRef = new core_common_1.RelatedElement({ id: eid });
76
+ const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);
77
+ return [eid, mid];
78
+ }
79
+ /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
80
+ static createAndInsertDrawingPartition(testDb, newModelCode, parentId) {
81
+ const model = parentId ? testDb.elements.getElement(parentId).model : core_common_1.IModel.repositoryModelId;
82
+ const parent = new core_backend_1.SubjectOwnsPartitionElements(parentId || core_common_1.IModel.rootSubjectId);
83
+ const modeledElementProps = {
84
+ classFullName: core_backend_1.Drawing.classFullName,
85
+ parent,
86
+ model,
87
+ code: newModelCode,
88
+ };
89
+ const modeledElement = testDb.elements.createElement(modeledElementProps);
90
+ return testDb.elements.insertElement(modeledElement.toJSON());
91
+ }
92
+ /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
93
+ static createAndInsertDrawingModel(testDb, modeledElementRef, privateModel = false) {
94
+ const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: core_backend_1.DrawingModel.classFullName, isPrivate: privateModel });
95
+ const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
96
+ chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModelId));
97
+ chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModel.id));
98
+ chai_1.assert.deepEqual(newModelId, newModel.id);
99
+ return newModelId;
100
+ }
101
+ // Create a DrawingObject. (Does not insert it.)
102
+ static createDrawingGraphic(testImodel, modelId, categoryId, elemCode) {
103
+ const elementProps = {
104
+ classFullName: "BisCore:DrawingGraphic",
105
+ model: modelId,
106
+ category: categoryId,
107
+ code: elemCode ? elemCode : core_common_1.Code.createEmpty(),
108
+ };
109
+ return testImodel.elements.createElement(elementProps);
110
+ }
111
+ // Create a PhysicalObject. (Does not insert it.)
112
+ static createPhysicalObject(testImodel, modelId, categoryId, elemCode) {
113
+ const elementProps = {
114
+ classFullName: "Generic:PhysicalObject",
115
+ model: modelId,
116
+ category: categoryId,
117
+ code: elemCode ? elemCode : core_common_1.Code.createEmpty(),
118
+ };
119
+ return testImodel.elements.createElement(elementProps);
120
+ }
121
+ static getUniqueModelCode(testDb, newModelCodeBase) {
122
+ let newModelCode = newModelCodeBase;
123
+ let iter = 0;
124
+ while (true) {
125
+ const modelCode = core_backend_1.InformationPartitionElement.createCode(testDb, core_common_1.IModel.rootSubjectId, newModelCode);
126
+ if (testDb.elements.queryElementIdByCode(modelCode) === undefined)
127
+ return modelCode;
128
+ newModelCode = newModelCodeBase + iter;
129
+ ++iter;
130
+ }
131
+ }
132
+ /** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */
133
+ static generateUniqueName(baseName) {
134
+ return `${baseName} - ${core_bentley_1.Guid.createValue()}`;
135
+ }
136
+ /** Prepare for an output file by:
137
+ * - Resolving the output file name under the known test output directory
138
+ * - Making directories as necessary
139
+ * - Removing a previous copy of the output file
140
+ * @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.
141
+ * @param fileName Name of output fille
142
+ */
143
+ static prepareOutputFile(subDirName, fileName) {
144
+ if (!core_backend_1.IModelJsFs.existsSync(KnownTestLocations.outputDir))
145
+ core_backend_1.IModelJsFs.mkdirSync(KnownTestLocations.outputDir);
146
+ const outputDir = path_1.default.join(KnownTestLocations.outputDir, subDirName);
147
+ if (!core_backend_1.IModelJsFs.existsSync(outputDir))
148
+ core_backend_1.IModelJsFs.mkdirSync(outputDir);
149
+ const outputFile = path_1.default.join(outputDir, fileName);
150
+ if (core_backend_1.IModelJsFs.existsSync(outputFile))
151
+ core_backend_1.IModelJsFs.unlinkSync(outputFile);
152
+ return outputFile;
153
+ }
154
+ }
155
+ exports.IModelBuilder = IModelBuilder;
156
+ class KnownTestLocations {
157
+ /** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */
158
+ static get assetsDir() {
159
+ return (0, path_1.join)(__dirname, "assets");
160
+ }
161
+ /** The directory where tests can write. */
162
+ static get outputDir() {
163
+ if (core_bentley_1.ProcessDetector.isMobileAppBackend) {
164
+ return (0, path_1.join)((0, os_1.tmpdir)(), "output");
165
+ }
166
+ // Assume that we are running in nodejs
167
+ return (0, path_1.join)(__dirname, "output");
168
+ }
169
+ }
170
+ exports.KnownTestLocations = KnownTestLocations;
171
+ //# sourceMappingURL=IModelBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilder.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAAwL;AACxL,sDAA8E;AAC9E,oDAAyJ;AACzJ,+BAA8B;AAC9B,2BAA4B;AAC5B,6CAAkC;AAElC,MAAa,aAAa;IACxB;;;OAGG;IACI,MAAM,CAAC,wCAAwC,CAAC,UAAo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kB,CAAC,SAAS,CAAC,CAAC;QAErD,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtE,IAAI,CAAC,yBAAU,CAAC,UAAU,CAAC,SAAS,CAAC;YACnC,yBAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAElC,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,yBAAU,CAAC,UAAU,CAAC,UAAU,CAAC;YACnC,yBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAEpC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAtID,sCAsIC;AAED,MAAa,kBAAkB;IAE7B,6GAA6G;IACtG,MAAM,KAAK,SAAS;QACzB,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,2CAA2C;IACpC,MAAM,KAAK,SAAS;QACzB,IAAI,8BAAe,CAAC,kBAAkB,EAAE;YACtC,OAAO,IAAA,WAAI,EAAC,IAAA,WAAM,GAAE,EAAE,QAAQ,CAAC,CAAC;SACjC;QAED,uCAAuC;QACvC,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF;AAhBD,gDAgBC","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 { Drawing, DrawingModel, Element, IModelDb, IModelJsFs, InformationPartitionElement, PhysicalModel, PhysicalPartition, SubjectOwnsPartitionElements } from \"@itwin/core-backend\";\nimport { Guid, Id64, Id64String, ProcessDetector } from \"@itwin/core-bentley\";\nimport { Code, CodeProps, ElementProps, GeometricElement2dProps, IModel, LocalFileName, PhysicalElementProps, RelatedElement } from \"@itwin/core-common\";\nimport { assert } from \"chai\";\nimport { tmpdir } from \"os\";\nimport path, { join } from \"path\";\n\nexport class IModelBuilder {\n /**\n * Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.\n * @return [modeledElementId, modelId]\n */\n public static createAndInsertPhysicalPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\n const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);\n const modeledElementRef = new RelatedElement({ id: eid });\n const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);\n return [eid, mid];\n }\n\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\n public static createAndInsertPhysicalPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\n\n const modeledElementProps: ElementProps = {\n classFullName: PhysicalPartition.classFullName,\n parent,\n model,\n code: newModelCode,\n };\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\n return testDb.elements.insertElement(modeledElement.toJSON());\n }\n\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\n public static createAndInsertPhysicalModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: PhysicalModel.classFullName, isPrivate: privateModel });\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\n assert.isTrue(Id64.isValidId64(newModelId));\n assert.isTrue(Id64.isValidId64(newModel.id));\n assert.deepEqual(newModelId, newModel.id);\n return newModelId;\n }\n\n /**\n * Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.\n * @return [modeledElementId, modelId]\n */\n public static createAndInsertDrawingPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\n const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);\n const modeledElementRef = new RelatedElement({ id: eid });\n const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);\n return [eid, mid];\n }\n\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\n public static createAndInsertDrawingPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\n\n const modeledElementProps: ElementProps = {\n classFullName: Drawing.classFullName,\n parent,\n model,\n code: newModelCode,\n };\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\n return testDb.elements.insertElement(modeledElement.toJSON());\n }\n\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\n public static createAndInsertDrawingModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: DrawingModel.classFullName, isPrivate: privateModel });\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\n assert.isTrue(Id64.isValidId64(newModelId));\n assert.isTrue(Id64.isValidId64(newModel.id));\n assert.deepEqual(newModelId, newModel.id);\n return newModelId;\n }\n\n // Create a DrawingObject. (Does not insert it.)\n public static createDrawingGraphic(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\n const elementProps: GeometricElement2dProps = {\n classFullName: \"BisCore:DrawingGraphic\",\n model: modelId,\n category: categoryId,\n code: elemCode ? elemCode : Code.createEmpty(),\n };\n return testImodel.elements.createElement(elementProps);\n }\n\n // Create a PhysicalObject. (Does not insert it.)\n public static createPhysicalObject(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\n const elementProps: PhysicalElementProps = {\n classFullName: \"Generic:PhysicalObject\",\n model: modelId,\n category: categoryId,\n code: elemCode ? elemCode : Code.createEmpty(),\n };\n return testImodel.elements.createElement(elementProps);\n }\n\n public static getUniqueModelCode(testDb: IModelDb, newModelCodeBase: string): Code {\n let newModelCode: string = newModelCodeBase;\n let iter: number = 0;\n while (true) {\n const modelCode = InformationPartitionElement.createCode(testDb, IModel.rootSubjectId, newModelCode);\n if (testDb.elements.queryElementIdByCode(modelCode) === undefined)\n return modelCode;\n\n newModelCode = newModelCodeBase + iter;\n ++iter;\n }\n }\n\n /** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */\n public static generateUniqueName(baseName: string) {\n return `${baseName} - ${Guid.createValue()}`;\n }\n\n /** Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.\n * @param fileName Name of output fille\n */\n public static prepareOutputFile(subDirName: string, fileName: string): LocalFileName {\n if (!IModelJsFs.existsSync(KnownTestLocations.outputDir))\n IModelJsFs.mkdirSync(KnownTestLocations.outputDir);\n\n const outputDir = path.join(KnownTestLocations.outputDir, subDirName);\n if (!IModelJsFs.existsSync(outputDir))\n IModelJsFs.mkdirSync(outputDir);\n\n const outputFile = path.join(outputDir, fileName);\n if (IModelJsFs.existsSync(outputFile))\n IModelJsFs.unlinkSync(outputFile);\n\n return outputFile;\n }\n}\n\nexport class KnownTestLocations {\n\n /** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */\n public static get assetsDir(): string {\n return join(__dirname, \"assets\");\n }\n\n /** The directory where tests can write. */\n public static get outputDir(): string {\n if (ProcessDetector.isMobileAppBackend) {\n return join(tmpdir(), \"output\");\n }\n\n // Assume that we are running in nodejs\n return join(__dirname, \"output\");\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { GuidString } from "@itwin/core-bentley";
2
+ import { Code, ElementProps } from "@itwin/core-common";
3
+ /**
4
+ * Test utility to push an iModel.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare class IModelTestUtility {
9
+ iTwinId: GuidString;
10
+ iModelId: string;
11
+ outputFile: string;
12
+ private _iModel;
13
+ private _modelId;
14
+ createIModel(): void;
15
+ addPhysicalModel(): string;
16
+ addDrawingModel(): string;
17
+ addSpatialCategory(elementProps: ElementProps): string;
18
+ addDrawingCategory(elementProps: ElementProps): string;
19
+ addPhysicalObject(categoryId: string): void;
20
+ addDrawingGraphic(categoryId: string): void;
21
+ getSpatialCategoryCode(codeValue: string): Code;
22
+ getDrawingCategoryCode(codeValue: string): Code;
23
+ closeIModel(): void;
24
+ }
25
+ //# sourceMappingURL=IModelTestUtility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelTestUtility.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelTestUtility.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;GAIG;AACH,qBAAa,iBAAiB;IACrB,OAAO,EAAG,UAAU,CAAC;IACrB,QAAQ,EAAG,MAAM,CAAC;IAClB,UAAU,EAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,QAAQ,CAAU;IAEnB,YAAY,IAAI,IAAI;IAMpB,gBAAgB,IAAI,MAAM;IAM1B,eAAe,IAAI,MAAM;IAMzB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,WAAW,IAAI,IAAI;CAG3B"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IModelTestUtility = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ /** @packageDocumentation
9
+ * @module TestUtilities
10
+ */
11
+ const core_backend_1 = require("@itwin/core-backend");
12
+ const IModelBuilder_1 = require("./IModelBuilder");
13
+ /**
14
+ * Test utility to push an iModel.
15
+ *
16
+ * @internal
17
+ */
18
+ class IModelTestUtility {
19
+ createIModel() {
20
+ this.outputFile = IModelBuilder_1.IModelBuilder.prepareOutputFile("IModelTest", IModelBuilder_1.IModelBuilder.generateUniqueName("IModelTest.bim"));
21
+ this._iModel = core_backend_1.SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: "IModelTest" } });
22
+ this.iModelId = this._iModel.iModelId;
23
+ }
24
+ addPhysicalModel() {
25
+ [, this._modelId] = IModelBuilder_1.IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder_1.IModelBuilder.getUniqueModelCode(this._iModel, "TestPhysicalModel"), false);
26
+ this._iModel.saveChanges("Added test model");
27
+ return this._modelId;
28
+ }
29
+ addDrawingModel() {
30
+ [, this._modelId] = IModelBuilder_1.IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder_1.IModelBuilder.getUniqueModelCode(this._iModel, "TestDrawingModel"), false);
31
+ this._iModel.saveChanges("Added test model");
32
+ return this._modelId;
33
+ }
34
+ addSpatialCategory(elementProps) {
35
+ const categoryId = this._iModel.elements.insertElement(new core_backend_1.SpatialCategory(elementProps, this._iModel).toJSON());
36
+ this._iModel.saveChanges("Added spatial category");
37
+ return categoryId;
38
+ }
39
+ addDrawingCategory(elementProps) {
40
+ const categoryId = this._iModel.elements.insertElement(new core_backend_1.DrawingCategory(elementProps, this._iModel).toJSON());
41
+ this._iModel.saveChanges("Added drawing category");
42
+ return categoryId;
43
+ }
44
+ addPhysicalObject(categoryId) {
45
+ this._iModel.elements.insertElement(IModelBuilder_1.IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());
46
+ this._iModel.saveChanges("Added physical object");
47
+ }
48
+ addDrawingGraphic(categoryId) {
49
+ this._iModel.elements.insertElement(IModelBuilder_1.IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());
50
+ this._iModel.saveChanges("Added drawing graphic");
51
+ }
52
+ getSpatialCategoryCode(codeValue) {
53
+ return core_backend_1.SpatialCategory.createCode(this._iModel, this._modelId, codeValue);
54
+ }
55
+ getDrawingCategoryCode(codeValue) {
56
+ return core_backend_1.DrawingCategory.createCode(this._iModel, this._modelId, codeValue);
57
+ }
58
+ closeIModel() {
59
+ this._iModel.close();
60
+ }
61
+ }
62
+ exports.IModelTestUtility = IModelTestUtility;
63
+ //# sourceMappingURL=IModelTestUtility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelTestUtility.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelTestUtility.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAA6F;AAG7F,mDAAgD;AAEhD;;;;GAIG;AACH,MAAa,iBAAiB;IAOrB,YAAY;QACjB,IAAI,CAAC,UAAU,GAAG,6BAAa,CAAC,iBAAiB,CAAC,YAAY,EAAE,6BAAa,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACpH,IAAI,CAAC,OAAO,GAAG,yBAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CA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iB,CAAC,UAAkB;QACzC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,6BAAa,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1H,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAEM,iBAAiB,CAAC,UAAkB;QACzC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,6BAAa,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1H,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAEM,sBAAsB,CAAC,SAAiB;QAC7C,OAAO,8BAAe,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEM,sBAAsB,CAAC,SAAiB;QAC7C,OAAO,8BAAe,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AA1DD,8CA0DC","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 TestUtilities\n */\nimport { DrawingCategory, IModelDb, SnapshotDb, SpatialCategory } from \"@itwin/core-backend\";\nimport { GuidString } from \"@itwin/core-bentley\";\nimport { Code, ElementProps } from \"@itwin/core-common\";\nimport { IModelBuilder } from \"./IModelBuilder\";\n\n/**\n * Test utility to push an iModel.\n *\n * @internal\n */\nexport class IModelTestUtility {\n public iTwinId!: GuidString;\n public iModelId!: string;\n public outputFile!: string;\n private _iModel!: IModelDb;\n private _modelId!: string;\n\n public createIModel(): void {\n this.outputFile = IModelBuilder.prepareOutputFile(\"IModelTest\", IModelBuilder.generateUniqueName(\"IModelTest.bim\"));\n this._iModel = SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: \"IModelTest\" } });\n this.iModelId = this._iModel.iModelId;\n }\n\n public addPhysicalModel(): string {\n [, this._modelId] = IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestPhysicalModel\"), false);\n this._iModel.saveChanges(\"Added test model\");\n return this._modelId;\n }\n\n public addDrawingModel(): string {\n [, this._modelId] = IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestDrawingModel\"), false);\n this._iModel.saveChanges(\"Added test model\");\n return this._modelId;\n }\n\n public addSpatialCategory(elementProps: ElementProps): string {\n const categoryId = this._iModel.elements.insertElement(new SpatialCategory(elementProps, this._iModel).toJSON());\n this._iModel.saveChanges(\"Added spatial category\");\n return categoryId;\n }\n\n public addDrawingCategory(elementProps: ElementProps): string {\n const categoryId = this._iModel.elements.insertElement(new DrawingCategory(elementProps, this._iModel).toJSON());\n this._iModel.saveChanges(\"Added drawing category\");\n return categoryId;\n }\n\n public addPhysicalObject(categoryId: string): void {\n this._iModel.elements.insertElement(IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());\n this._iModel.saveChanges(\"Added physical object\");\n }\n\n public addDrawingGraphic(categoryId: string): void {\n this._iModel.elements.insertElement(IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());\n this._iModel.saveChanges(\"Added drawing graphic\");\n }\n\n public getSpatialCategoryCode(codeValue: string): Code {\n return SpatialCategory.createCode(this._iModel, this._modelId, codeValue);\n }\n\n public getDrawingCategoryCode(codeValue: string): Code {\n return DrawingCategory.createCode(this._iModel, this._modelId, codeValue);\n }\n\n public closeIModel(): void {\n this._iModel.close();\n }\n}\n"]}
@@ -1,22 +1,29 @@
1
- /**
2
- * @module Hierarchies
3
- *
4
- * @docs-group-description Hierarchies
5
- * Types for testing hierarchies.
6
- */
7
- export * from "./presentation-testing/HierarchyBuilder";
8
- /**
9
- * @module Content
10
- *
11
- * @docs-group-description Content
12
- * Types for testing content.
13
- */
14
- export * from "./presentation-testing/ContentBuilder";
15
- /**
16
- * @module Helpers
17
- *
18
- * @docs-group-description Helpers
19
- * Various test helpers.
20
- */
21
- export * from "./presentation-testing/Helpers";
1
+ /**
2
+ * @module Hierarchies
3
+ *
4
+ * @docs-group-description Hierarchies
5
+ * Types for testing hierarchies.
6
+ */
7
+ export * from "./presentation-testing/HierarchyBuilder";
8
+ /**
9
+ * @module Content
10
+ *
11
+ * @docs-group-description Content
12
+ * Types for testing content.
13
+ */
14
+ export * from "./presentation-testing/ContentBuilder";
15
+ /**
16
+ * @module Helpers
17
+ *
18
+ * @docs-group-description Helpers
19
+ * Various test helpers.
20
+ */
21
+ export * from "./presentation-testing/Helpers";
22
+ /**
23
+ * @module TestUtilities
24
+ *
25
+ * @docs-group-description TestUtilities
26
+ * Various test helpers.
27
+ */
28
+ export * from "./presentation-testing/IModelTestUtility";
22
29
  //# sourceMappingURL=presentation-testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,0CAA0C,CAAC"}