@itwin/presentation-backend 3.0.0-dev.100

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 (79) hide show
  1. package/CHANGELOG.md +936 -0
  2. package/LICENSE.md +9 -0
  3. package/README.md +12 -0
  4. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -0
  5. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +739 -0
  6. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -0
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +42 -0
  8. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts.map +1 -0
  9. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +51 -0
  10. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -0
  11. package/lib/cjs/presentation-backend/Constants.d.ts +14 -0
  12. package/lib/cjs/presentation-backend/Constants.d.ts.map +1 -0
  13. package/lib/cjs/presentation-backend/Constants.js +44 -0
  14. package/lib/cjs/presentation-backend/Constants.js.map +1 -0
  15. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +12 -0
  16. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -0
  17. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +256 -0
  18. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -0
  19. package/lib/cjs/presentation-backend/NativePlatform.d.ts +86 -0
  20. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -0
  21. package/lib/cjs/presentation-backend/NativePlatform.js +153 -0
  22. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -0
  23. package/lib/cjs/presentation-backend/Presentation.d.ts +98 -0
  24. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -0
  25. package/lib/cjs/presentation-backend/Presentation.js +135 -0
  26. package/lib/cjs/presentation-backend/Presentation.js.map +1 -0
  27. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +13 -0
  28. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -0
  29. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -0
  30. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -0
  31. package/lib/cjs/presentation-backend/PresentationManager.d.ts +379 -0
  32. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -0
  33. package/lib/cjs/presentation-backend/PresentationManager.js +635 -0
  34. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -0
  35. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +58 -0
  36. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -0
  37. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +271 -0
  38. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -0
  39. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +105 -0
  40. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -0
  41. package/lib/cjs/presentation-backend/RulesetEmbedder.js +283 -0
  42. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -0
  43. package/lib/cjs/presentation-backend/RulesetManager.d.ts +54 -0
  44. package/lib/cjs/presentation-backend/RulesetManager.d.ts.map +1 -0
  45. package/lib/cjs/presentation-backend/RulesetManager.js +74 -0
  46. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -0
  47. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +141 -0
  48. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts.map +1 -0
  49. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +130 -0
  50. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -0
  51. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +38 -0
  52. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -0
  53. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +257 -0
  54. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -0
  55. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +73 -0
  56. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -0
  57. package/lib/cjs/presentation-backend/TemporaryStorage.js +92 -0
  58. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -0
  59. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +28 -0
  60. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts.map +1 -0
  61. package/lib/cjs/presentation-backend/UpdatesTracker.js +55 -0
  62. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -0
  63. package/lib/cjs/presentation-backend/Utils.d.ts +11 -0
  64. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -0
  65. package/lib/cjs/presentation-backend/Utils.js +39 -0
  66. package/lib/cjs/presentation-backend/Utils.js.map +1 -0
  67. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +17 -0
  68. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts.map +1 -0
  69. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +52 -0
  70. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -0
  71. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +22 -0
  72. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts.map +1 -0
  73. package/lib/cjs/presentation-backend/domain/RulesetElements.js +39 -0
  74. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -0
  75. package/lib/cjs/presentation-backend.d.ts +20 -0
  76. package/lib/cjs/presentation-backend.d.ts.map +1 -0
  77. package/lib/cjs/presentation-backend.js +36 -0
  78. package/lib/cjs/presentation-backend.js.map +1 -0
  79. package/package.json +99 -0
@@ -0,0 +1,139 @@
1
+ {
2
+ "$schema": "../../../common/Ruleset.schema.json",
3
+ "id": "Functional",
4
+ "supplementationInfo": {
5
+ "supplementationPurpose": "Functional specific customization rules"
6
+ },
7
+ "requiredSchemas": [
8
+ {
9
+ "name": "BisCore"
10
+ },
11
+ {
12
+ "name": "Functional"
13
+ }
14
+ ],
15
+ "rules": [
16
+ {
17
+ "ruleType": "ContentModifier",
18
+ "class": {
19
+ "schemaName": "Functional",
20
+ "className": "FunctionalElement"
21
+ },
22
+ "relatedProperties": [
23
+ {
24
+ "propertiesSource": {
25
+ "relationship": {
26
+ "schemaName": "Functional",
27
+ "className": "FunctionalElementIsOfType"
28
+ },
29
+ "direction": "Forward"
30
+ },
31
+ "handleTargetClassPolymorphically": true,
32
+ "relationshipMeaning": "RelatedInstance",
33
+ "nestedRelatedProperties": [
34
+ {
35
+ "propertiesSource": {
36
+ "relationship": {
37
+ "schemaName": "BisCore",
38
+ "className": "ElementOwnsUniqueAspect"
39
+ },
40
+ "direction": "Forward"
41
+ },
42
+ "handleTargetClassPolymorphically": true,
43
+ "relationshipMeaning": "SameInstance"
44
+ },
45
+ {
46
+ "propertiesSource": {
47
+ "relationship": {
48
+ "schemaName": "BisCore",
49
+ "className": "ElementOwnsMultiAspects"
50
+ },
51
+ "direction": "Forward"
52
+ },
53
+ "handleTargetClassPolymorphically": true,
54
+ "relationshipMeaning": "SameInstance"
55
+ }
56
+ ]
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "ruleType": "Content",
62
+ "condition": "ContentDisplayType = \"Graphics\" ANDALSO SelectedNode.IsOfClass(\"FunctionalElement\", \"Functional\")",
63
+ "onlyIfNotHandled": true,
64
+ "specifications": [
65
+ {
66
+ "specType": "ContentRelatedInstances",
67
+ "relationshipPaths": [
68
+ [
69
+ {
70
+ "relationship": {
71
+ "schemaName": "BisCore",
72
+ "className": "ElementOwnsChildElements"
73
+ },
74
+ "direction": "Forward",
75
+ "targetClass": {
76
+ "schemaName": "Functional",
77
+ "className": "FunctionalElement"
78
+ },
79
+ "count": "*"
80
+ },
81
+ {
82
+ "relationship": {
83
+ "schemaName": "Functional",
84
+ "className": "PhysicalElementFulfillsFunction"
85
+ },
86
+ "direction": "Backward"
87
+ },
88
+ {
89
+ "relationship": {
90
+ "schemaName": "BisCore",
91
+ "className": "ElementOwnsChildElements"
92
+ },
93
+ "direction": "Forward",
94
+ "targetClass": {
95
+ "schemaName": "BisCore",
96
+ "className": "GeometricElement"
97
+ },
98
+ "count": "*"
99
+ }
100
+ ],
101
+ [
102
+ {
103
+ "relationship": {
104
+ "schemaName": "BisCore",
105
+ "className": "ElementOwnsChildElements"
106
+ },
107
+ "direction": "Forward",
108
+ "targetClass": {
109
+ "schemaName": "Functional",
110
+ "className": "FunctionalElement"
111
+ },
112
+ "count": "*"
113
+ },
114
+ {
115
+ "relationship": {
116
+ "schemaName": "Functional",
117
+ "className": "DrawingGraphicRepresentsFunctionalElement"
118
+ },
119
+ "direction": "Backward"
120
+ },
121
+ {
122
+ "relationship": {
123
+ "schemaName": "BisCore",
124
+ "className": "ElementOwnsChildElements"
125
+ },
126
+ "direction": "Forward",
127
+ "targetClass": {
128
+ "schemaName": "BisCore",
129
+ "className": "GeometricElement"
130
+ },
131
+ "count": "*"
132
+ }
133
+ ]
134
+ ]
135
+ }
136
+ ]
137
+ }
138
+ ]
139
+ }
@@ -0,0 +1,42 @@
1
+ /** @packageDocumentation
2
+ * @module Logging
3
+ */
4
+ /**
5
+ * Logger categories used by this package
6
+ * @note All logger categories in this package start with the `presentation-backend` prefix.
7
+ * @see [Logger]($bentley)
8
+ * @public
9
+ */
10
+ export declare enum PresentationBackendLoggerCategory {
11
+ Package = "presentation-backend",
12
+ /** The logger category used by the [[PresentationManager]] class and other related classes. */
13
+ PresentationManager = "presentation-backend.PresentationManager",
14
+ /** The logger category used by Presentation RPC implementation. */
15
+ Rpc = "presentation-backend.Rpc",
16
+ /** The logger category used by Presentation IPC implementation. */
17
+ Ipc = "presentation-backend.Ipc"
18
+ }
19
+ /**
20
+ * Logger categories used by this package
21
+ * @note Logger categories used by the [[PresentationManager]] native addon.
22
+ * @see [Logger]($bentley)
23
+ * @public
24
+ */
25
+ export declare enum PresentationBackendNativeLoggerCategory {
26
+ ECObjects = "ECObjects",
27
+ ECObjects_ECExpressions = "ECObjects.ECExpressions",
28
+ ECObjects_ECExpressions_Parse = "ECObjects.ECExpressions.Parse",
29
+ ECObjects_ECExpressions_Evaluate = "ECObjects.ECExpressions.Evaluate",
30
+ ECPresentation = "ECPresentation",
31
+ ECPresentation_Connections = "ECPresentation.Connections",
32
+ ECPresentation_Localization = "ECPresentation.Localization",
33
+ ECPresentation_RulesEngine = "ECPresentation.RulesEngine",
34
+ ECPresentation_RulesEngine_Content = "ECPresentation.RulesEngine.Content",
35
+ ECPresentation_RulesEngine_Localization = "ECPresentation.RulesEngine.Localization",
36
+ ECPresentation_RulesEngine_Navigation = "ECPresentation.RulesEngine.Navigation",
37
+ ECPresentation_RulesEngine_Navigation_Cache = "ECPresentation.RulesEngine.Navigation.Cache",
38
+ ECPresentation_RulesEngine_Threads = "ECPresentation.RulesEngine.Threads",
39
+ ECPresentation_RulesEngine_Update = "ECPresentation.RulesEngine.Update",
40
+ ECPresentation_RulesEngine_RulesetVariables = "ECPresentation.RulesEngine.RulesetVariables"
41
+ }
42
+ //# sourceMappingURL=BackendLoggerCategory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackendLoggerCategory.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/BackendLoggerCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;GAKG;AACH,oBAAY,iCAAiC;IAC3C,OAAO,yBAAyB;IAEhC,+FAA+F;IAC/F,mBAAmB,6CAA6C;IAEhE,mEAAmE;IACnE,GAAG,6BAA6B;IAEhC,mEAAmE;IACnE,GAAG,6BAA6B;CACjC;AAED;;;;;GAKG;AACH,oBAAY,uCAAuC;IACjD,SAAS,cAAc;IACvB,uBAAuB,4BAA4B;IACnD,6BAA6B,kCAAkC;IAC/D,gCAAgC,qCAAqC;IAErE,cAAc,mBAAmB;IACjC,0BAA0B,+BAA+B;IACzD,2BAA2B,gCAAgC;IAC3D,0BAA0B,+BAA+B;IACzD,kCAAkC,uCAAuC;IACzE,uCAAuC,4CAA4C;IACnF,qCAAqC,0CAA0C;IAC/E,2CAA2C,gDAAgD;IAC3F,kCAAkC,uCAAuC;IACzE,iCAAiC,sCAAsC;IACvE,2CAA2C,gDAAgD;CAC5F"}
@@ -0,0 +1,51 @@
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 Logging
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PresentationBackendNativeLoggerCategory = exports.PresentationBackendLoggerCategory = void 0;
11
+ /**
12
+ * Logger categories used by this package
13
+ * @note All logger categories in this package start with the `presentation-backend` prefix.
14
+ * @see [Logger]($bentley)
15
+ * @public
16
+ */
17
+ var PresentationBackendLoggerCategory;
18
+ (function (PresentationBackendLoggerCategory) {
19
+ PresentationBackendLoggerCategory["Package"] = "presentation-backend";
20
+ /** The logger category used by the [[PresentationManager]] class and other related classes. */
21
+ PresentationBackendLoggerCategory["PresentationManager"] = "presentation-backend.PresentationManager";
22
+ /** The logger category used by Presentation RPC implementation. */
23
+ PresentationBackendLoggerCategory["Rpc"] = "presentation-backend.Rpc";
24
+ /** The logger category used by Presentation IPC implementation. */
25
+ PresentationBackendLoggerCategory["Ipc"] = "presentation-backend.Ipc";
26
+ })(PresentationBackendLoggerCategory = exports.PresentationBackendLoggerCategory || (exports.PresentationBackendLoggerCategory = {}));
27
+ /**
28
+ * Logger categories used by this package
29
+ * @note Logger categories used by the [[PresentationManager]] native addon.
30
+ * @see [Logger]($bentley)
31
+ * @public
32
+ */
33
+ var PresentationBackendNativeLoggerCategory;
34
+ (function (PresentationBackendNativeLoggerCategory) {
35
+ PresentationBackendNativeLoggerCategory["ECObjects"] = "ECObjects";
36
+ PresentationBackendNativeLoggerCategory["ECObjects_ECExpressions"] = "ECObjects.ECExpressions";
37
+ PresentationBackendNativeLoggerCategory["ECObjects_ECExpressions_Parse"] = "ECObjects.ECExpressions.Parse";
38
+ PresentationBackendNativeLoggerCategory["ECObjects_ECExpressions_Evaluate"] = "ECObjects.ECExpressions.Evaluate";
39
+ PresentationBackendNativeLoggerCategory["ECPresentation"] = "ECPresentation";
40
+ PresentationBackendNativeLoggerCategory["ECPresentation_Connections"] = "ECPresentation.Connections";
41
+ PresentationBackendNativeLoggerCategory["ECPresentation_Localization"] = "ECPresentation.Localization";
42
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine"] = "ECPresentation.RulesEngine";
43
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Content"] = "ECPresentation.RulesEngine.Content";
44
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Localization"] = "ECPresentation.RulesEngine.Localization";
45
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Navigation"] = "ECPresentation.RulesEngine.Navigation";
46
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Navigation_Cache"] = "ECPresentation.RulesEngine.Navigation.Cache";
47
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Threads"] = "ECPresentation.RulesEngine.Threads";
48
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Update"] = "ECPresentation.RulesEngine.Update";
49
+ PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_RulesetVariables"] = "ECPresentation.RulesEngine.RulesetVariables";
50
+ })(PresentationBackendNativeLoggerCategory = exports.PresentationBackendNativeLoggerCategory || (exports.PresentationBackendNativeLoggerCategory = {}));
51
+ //# sourceMappingURL=BackendLoggerCategory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackendLoggerCategory.js","sourceRoot":"","sources":["../../../src/presentation-backend/BackendLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;;GAKG;AACH,IAAY,iCAWX;AAXD,WAAY,iCAAiC;IAC3C,qEAAgC,CAAA;IAEhC,+FAA+F;IAC/F,qGAAgE,CAAA;IAEhE,mEAAmE;IACnE,qEAAgC,CAAA;IAEhC,mEAAmE;IACnE,qEAAgC,CAAA;AAClC,CAAC,EAXW,iCAAiC,GAAjC,yCAAiC,KAAjC,yCAAiC,QAW5C;AAED;;;;;GAKG;AACH,IAAY,uCAiBX;AAjBD,WAAY,uCAAuC;IACjD,kEAAuB,CAAA;IACvB,8FAAmD,CAAA;IACnD,0GAA+D,CAAA;IAC/D,gHAAqE,CAAA;IAErE,4EAAiC,CAAA;IACjC,oGAAyD,CAAA;IACzD,sGAA2D,CAAA;IAC3D,oGAAyD,CAAA;IACzD,oHAAyE,CAAA;IACzE,8HAAmF,CAAA;IACnF,0HAA+E,CAAA;IAC/E,sIAA2F,CAAA;IAC3F,oHAAyE,CAAA;IACzE,kHAAuE,CAAA;IACvE,sIAA2F,CAAA;AAC7F,CAAC,EAjBW,uCAAuC,GAAvC,+CAAuC,KAAvC,+CAAuC,QAiBlD","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 Logging\r\n */\r\n\r\n/**\r\n * Logger categories used by this package\r\n * @note All logger categories in this package start with the `presentation-backend` prefix.\r\n * @see [Logger]($bentley)\r\n * @public\r\n */\r\nexport enum PresentationBackendLoggerCategory {\r\n Package = \"presentation-backend\",\r\n\r\n /** The logger category used by the [[PresentationManager]] class and other related classes. */\r\n PresentationManager = \"presentation-backend.PresentationManager\",\r\n\r\n /** The logger category used by Presentation RPC implementation. */\r\n Rpc = \"presentation-backend.Rpc\",\r\n\r\n /** The logger category used by Presentation IPC implementation. */\r\n Ipc = \"presentation-backend.Ipc\",\r\n}\r\n\r\n/**\r\n * Logger categories used by this package\r\n * @note Logger categories used by the [[PresentationManager]] native addon.\r\n * @see [Logger]($bentley)\r\n * @public\r\n */\r\nexport enum PresentationBackendNativeLoggerCategory {\r\n ECObjects = \"ECObjects\",\r\n ECObjects_ECExpressions = \"ECObjects.ECExpressions\",\r\n ECObjects_ECExpressions_Parse = \"ECObjects.ECExpressions.Parse\",\r\n ECObjects_ECExpressions_Evaluate = \"ECObjects.ECExpressions.Evaluate\",\r\n\r\n ECPresentation = \"ECPresentation\",\r\n ECPresentation_Connections = \"ECPresentation.Connections\",\r\n ECPresentation_Localization = \"ECPresentation.Localization\",\r\n ECPresentation_RulesEngine = \"ECPresentation.RulesEngine\",\r\n ECPresentation_RulesEngine_Content = \"ECPresentation.RulesEngine.Content\",\r\n ECPresentation_RulesEngine_Localization = \"ECPresentation.RulesEngine.Localization\",\r\n ECPresentation_RulesEngine_Navigation = \"ECPresentation.RulesEngine.Navigation\",\r\n ECPresentation_RulesEngine_Navigation_Cache = \"ECPresentation.RulesEngine.Navigation.Cache\",\r\n ECPresentation_RulesEngine_Threads = \"ECPresentation.RulesEngine.Threads\",\r\n ECPresentation_RulesEngine_Update = \"ECPresentation.RulesEngine.Update\",\r\n ECPresentation_RulesEngine_RulesetVariables = \"ECPresentation.RulesEngine.RulesetVariables\",\r\n}\r\n"]}
@@ -0,0 +1,14 @@
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ /**
5
+ * Path to presentation-backend assets root directory.
6
+ * @internal
7
+ */
8
+ export declare const PRESENTATION_BACKEND_ASSETS_ROOT: string;
9
+ /**
10
+ * Path to presentation-common assets root directory.
11
+ * @internal
12
+ */
13
+ export declare const PRESENTATION_COMMON_ASSETS_ROOT: string;
14
+ //# sourceMappingURL=Constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/Constants.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH;;;GAGG;AAEH,eAAO,MAAM,gCAAgC,QAA0H,CAAC;AAExK;;;GAGG;AAEH,eAAO,MAAM,+BAA+B,QAAuJ,CAAC"}
@@ -0,0 +1,44 @@
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 Core
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.PRESENTATION_COMMON_ASSETS_ROOT = exports.PRESENTATION_BACKEND_ASSETS_ROOT = void 0;
30
+ const path = __importStar(require("path"));
31
+ const presentation_common_1 = require("@itwin/presentation-common");
32
+ /**
33
+ * Path to presentation-backend assets root directory.
34
+ * @internal
35
+ */
36
+ // istanbul ignore next
37
+ exports.PRESENTATION_BACKEND_ASSETS_ROOT = (-1 !== __dirname.indexOf("presentation-backend")) ? path.join(__dirname, "../assets") : path.join(__dirname, "assets");
38
+ /**
39
+ * Path to presentation-common assets root directory.
40
+ * @internal
41
+ */
42
+ // istanbul ignore next
43
+ exports.PRESENTATION_COMMON_ASSETS_ROOT = (-1 !== presentation_common_1.PRESENTATION_COMMON_ROOT.indexOf("presentation-common")) ? path.join(presentation_common_1.PRESENTATION_COMMON_ROOT, "../assets") : path.join(__dirname, "assets");
44
+ //# sourceMappingURL=Constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/presentation-backend/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,oEAAsE;AAEtE;;;GAGG;AACH,uBAAuB;AACV,QAAA,gCAAgC,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAExK;;;GAGG;AACH,uBAAuB;AACV,QAAA,+BAA+B,GAAG,CAAC,CAAC,CAAC,KAAK,8CAAwB,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,8CAAwB,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC","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 Core\r\n */\r\n\r\nimport * as path from \"path\";\r\nimport { PRESENTATION_COMMON_ROOT } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Path to presentation-backend assets root directory.\r\n * @internal\r\n */\r\n// istanbul ignore next\r\nexport const PRESENTATION_BACKEND_ASSETS_ROOT = (-1 !== __dirname.indexOf(\"presentation-backend\")) ? path.join(__dirname, \"../assets\") : path.join(__dirname, \"assets\");\r\n\r\n/**\r\n * Path to presentation-common assets root directory.\r\n * @internal\r\n */\r\n// istanbul ignore next\r\nexport const PRESENTATION_COMMON_ASSETS_ROOT = (-1 !== PRESENTATION_COMMON_ROOT.indexOf(\"presentation-common\")) ? path.join(PRESENTATION_COMMON_ROOT, \"../assets\") : path.join(__dirname, \"assets\");\r\n"]}
@@ -0,0 +1,12 @@
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ import { IModelDb } from "@itwin/core-backend";
5
+ import { Content, ElementProperties, PageOptions } from "@itwin/presentation-common";
6
+ /** @internal */
7
+ export declare const buildElementsProperties: (content: Content | undefined) => ElementProperties[];
8
+ /** @internal */
9
+ export declare function getElementsCount(db: IModelDb, classNames?: string[]): number;
10
+ /** @internal */
11
+ export declare function getElementIdsByClass(db: IModelDb, classNames?: string[], pageOptions?: PageOptions): Map<string, string[]>;
12
+ //# sourceMappingURL=ElementPropertiesHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementPropertiesHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAkB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EACgB,OAAO,EAAE,iBAAiB,EACkB,WAAW,EAG7E,MAAM,4BAA4B,CAAC;AAEpC,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,YAAa,OAAO,GAAG,SAAS,KAAG,iBAAiB,EAOvF,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAUnE;AAED,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,WAAW,yBAkClG"}
@@ -0,0 +1,256 @@
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 Core
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getElementIdsByClass = exports.getElementsCount = exports.buildElementsProperties = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const presentation_common_1 = require("@itwin/presentation-common");
13
+ /** @internal */
14
+ const buildElementsProperties = (content) => {
15
+ if (!content || content.contentSet.length === 0)
16
+ return [];
17
+ const builder = new ElementPropertiesBuilder();
18
+ (0, presentation_common_1.traverseContent)(builder, content);
19
+ return builder.items;
20
+ };
21
+ exports.buildElementsProperties = buildElementsProperties;
22
+ /** @internal */
23
+ function getElementsCount(db, classNames) {
24
+ const query = `
25
+ SELECT COUNT(e.ECInstanceId)
26
+ FROM bis.Element e
27
+ ${createElementsFilterClause("e", classNames)}
28
+ `;
29
+ return db.withPreparedStatement(query, (stmt) => {
30
+ return stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;
31
+ });
32
+ }
33
+ exports.getElementsCount = getElementsCount;
34
+ /** @internal */
35
+ function getElementIdsByClass(db, classNames, pageOptions) {
36
+ const query = `
37
+ SELECT e.ECInstanceId elId, eSchemaDef.Name || ':' || eClassDef.Name elClassName
38
+ FROM bis.Element e
39
+ LEFT JOIN meta.ECClassDef eClassDef ON eClassDef.ECInstanceId = e.ECClassId
40
+ LEFT JOIN meta.ECSchemaDef eSchemaDef ON eSchemaDef.ECInstanceId = eClassDef.Schema.Id
41
+ ${createElementsFilterClause("e", classNames)}
42
+ ORDER BY e.ECClassId, e.ECInstanceId
43
+ ${createElementsLimitClause(pageOptions)}
44
+ `;
45
+ return db.withPreparedStatement(query, (stmt) => {
46
+ const ids = new Map();
47
+ let currentClassName = "";
48
+ let currentIds = [];
49
+ while (stmt.step() === core_bentley_1.DbResult.BE_SQLITE_ROW) {
50
+ const row = stmt.getRow();
51
+ if (!row.elId || !row.elClassName)
52
+ continue;
53
+ if (currentClassName !== row.elClassName) {
54
+ currentClassName = row.elClassName;
55
+ const existingIds = ids.get(row.elClassName);
56
+ if (!existingIds) {
57
+ currentIds = [];
58
+ ids.set(row.elClassName, currentIds);
59
+ }
60
+ else {
61
+ currentIds = existingIds;
62
+ }
63
+ }
64
+ currentIds.push(row.elId);
65
+ }
66
+ return ids;
67
+ });
68
+ }
69
+ exports.getElementIdsByClass = getElementIdsByClass;
70
+ function createElementsLimitClause(pageOptions) {
71
+ var _a, _b;
72
+ if (pageOptions === undefined || (pageOptions.size === undefined && pageOptions.start === undefined))
73
+ return "";
74
+ return `LIMIT ${(_a = pageOptions.size) !== null && _a !== void 0 ? _a : -1} OFFSET ${(_b = pageOptions.start) !== null && _b !== void 0 ? _b : 0}`;
75
+ }
76
+ function createElementsFilterClause(elementAlias, classNames) {
77
+ if (classNames === undefined || classNames.length === 0)
78
+ return "";
79
+ // check if list contains only valid class names
80
+ const classNameRegExp = new RegExp(/^[\w]+[.:][\w]+$/);
81
+ const invalidName = classNames.find((name) => !name.match(classNameRegExp));
82
+ if (invalidName) {
83
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.
84
+ Valid class name formats: "<schema name or alias>.<class name>", "<schema name or alias>:<class name>"`);
85
+ }
86
+ return `WHERE ${elementAlias}.ECClassId IS (${classNames.join(",")})`;
87
+ }
88
+ class ElementPropertiesAppender {
89
+ constructor(_item, _onItemFinished) {
90
+ this._item = _item;
91
+ this._onItemFinished = _onItemFinished;
92
+ this._propertyItems = {};
93
+ this._categoryItemAppenders = {};
94
+ }
95
+ append(label, item) {
96
+ this._propertyItems[label] = item;
97
+ }
98
+ finish() {
99
+ var _a, _b, _c, _d;
100
+ // eslint-disable-next-line guard-for-in
101
+ for (const categoryName in this._categoryItemAppenders) {
102
+ const appender = this._categoryItemAppenders[categoryName];
103
+ appender.finish();
104
+ }
105
+ this._onItemFinished({
106
+ class: (_b = (_a = this._item.classInfo) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : "",
107
+ id: (_d = (_c = this._item.primaryKeys[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : core_bentley_1.Id64.invalid,
108
+ label: this._item.label.displayValue,
109
+ items: this._propertyItems,
110
+ });
111
+ }
112
+ getCategoryAppender(parentAppender, category) {
113
+ let appender = this._categoryItemAppenders[category.name];
114
+ if (!appender) {
115
+ appender = new CategoryItemAppender(parentAppender, category);
116
+ this._categoryItemAppenders[category.name] = appender;
117
+ }
118
+ return appender;
119
+ }
120
+ }
121
+ class CategoryItemAppender {
122
+ constructor(_parentAppender, _category) {
123
+ this._parentAppender = _parentAppender;
124
+ this._category = _category;
125
+ this._items = {};
126
+ }
127
+ append(label, item) {
128
+ this._items[label] = item;
129
+ }
130
+ finish() {
131
+ if (Object.keys(this._items).length === 0)
132
+ return;
133
+ this._parentAppender.append(this._category.label, {
134
+ type: "category",
135
+ items: this._items,
136
+ });
137
+ }
138
+ }
139
+ class ArrayItemAppender {
140
+ constructor(_parentAppender, _props) {
141
+ this._parentAppender = _parentAppender;
142
+ this._props = _props;
143
+ this._items = [];
144
+ }
145
+ append(_label, item) {
146
+ (0, core_bentley_1.assert)(item.type !== "category");
147
+ this._items.push(item);
148
+ }
149
+ finish() {
150
+ (0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Array);
151
+ if (this._props.valueType.memberType.valueFormat === presentation_common_1.PropertyValueFormat.Primitive)
152
+ this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());
153
+ else
154
+ this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());
155
+ }
156
+ createPrimitivesArray() {
157
+ return {
158
+ type: "array",
159
+ valueType: "primitive",
160
+ values: this._items.map((item) => {
161
+ (0, core_bentley_1.assert)(item.type === "primitive");
162
+ return item.value;
163
+ }),
164
+ };
165
+ }
166
+ createStructsArray() {
167
+ return {
168
+ type: "array",
169
+ valueType: "struct",
170
+ values: this._items.map((item) => {
171
+ (0, core_bentley_1.assert)(item.type === "struct");
172
+ return item.members;
173
+ }),
174
+ };
175
+ }
176
+ }
177
+ class StructItemAppender {
178
+ constructor(_parentAppender, _props) {
179
+ this._parentAppender = _parentAppender;
180
+ this._props = _props;
181
+ this._members = {};
182
+ }
183
+ append(label, item) {
184
+ (0, core_bentley_1.assert)(item.type !== "category");
185
+ this._members[label] = item;
186
+ }
187
+ finish() {
188
+ (0, core_bentley_1.assert)(this._props.valueType.valueFormat === presentation_common_1.PropertyValueFormat.Struct);
189
+ this._parentAppender.append(this._props.hierarchy.field.label, {
190
+ type: "struct",
191
+ members: this._members,
192
+ });
193
+ }
194
+ }
195
+ class ElementPropertiesBuilder {
196
+ constructor() {
197
+ this._appendersStack = [];
198
+ this._items = [];
199
+ }
200
+ get items() {
201
+ return this._items;
202
+ }
203
+ get _currentAppender() {
204
+ const appender = this._appendersStack[this._appendersStack.length - 1];
205
+ (0, core_bentley_1.assert)(appender !== undefined);
206
+ return appender;
207
+ }
208
+ startContent(_props) { return true; }
209
+ finishContent() { }
210
+ processFieldHierarchies(_props) { }
211
+ startItem(props) {
212
+ this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => { this._items.push(item); });
213
+ this._appendersStack.push(this._elementPropertiesAppender);
214
+ return true;
215
+ }
216
+ finishItem() {
217
+ this._appendersStack.pop();
218
+ (0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
219
+ this._elementPropertiesAppender.finish();
220
+ this._elementPropertiesAppender = undefined;
221
+ }
222
+ startCategory(props) {
223
+ (0, core_bentley_1.assert)(this._elementPropertiesAppender !== undefined);
224
+ this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));
225
+ return true;
226
+ }
227
+ finishCategory() {
228
+ this._appendersStack.pop();
229
+ }
230
+ startField(_props) { return true; }
231
+ finishField() { }
232
+ startStruct(props) {
233
+ this._appendersStack.push(new StructItemAppender(this._currentAppender, props));
234
+ return true;
235
+ }
236
+ finishStruct() { this._appendersStack.pop().finish(); }
237
+ startArray(props) {
238
+ this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));
239
+ return true;
240
+ }
241
+ finishArray() { this._appendersStack.pop().finish(); }
242
+ processMergedValue(props) {
243
+ this._currentAppender.append(props.mergedField.label, {
244
+ type: "primitive",
245
+ value: "",
246
+ });
247
+ }
248
+ processPrimitiveValue(props) {
249
+ var _a, _b;
250
+ this._currentAppender.append(props.field.label, {
251
+ type: "primitive",
252
+ value: (_b = (_a = props.displayValue) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "",
253
+ });
254
+ }
255
+ }
256
+ //# sourceMappingURL=ElementPropertiesHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementPropertiesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/ElementPropertiesHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,sDAA6D;AAC7D,oEAKoC;AAEpC,gBAAgB;AACT,MAAM,uBAAuB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;QAC7C,OAAO,EAAE,CAAC;IAEZ,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC/C,IAAA,qCAAe,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC,CAAC;AAPW,QAAA,uBAAuB,2BAOlC;AAEF,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,EAAY,EAAE,UAAqB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C,YAAY,0CAAE,QAAQ,EAAE,mCAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF","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 Core\r\n */\r\n\r\nimport { ECSqlStatement, IModelDb } from \"@itwin/core-backend\";\r\nimport { assert, DbResult, Id64 } from \"@itwin/core-bentley\";\r\nimport {\r\n CategoryDescription, Content, ElementProperties, ElementPropertiesItem, ElementPropertiesPrimitiveArrayPropertyItem, ElementPropertiesPropertyItem,\r\n ElementPropertiesStructArrayPropertyItem, IContentVisitor, Item, PageOptions, PresentationError, PresentationStatus, ProcessFieldHierarchiesProps, ProcessMergedValueProps,\r\n ProcessPrimitiveValueProps, PropertyValueFormat, StartArrayProps, StartCategoryProps, StartContentProps, StartFieldProps, StartItemProps,\r\n StartStructProps, traverseContent,\r\n} from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport const buildElementsProperties = (content: Content | undefined): ElementProperties[] => {\r\n if (!content || content.contentSet.length === 0)\r\n return [];\r\n\r\n const builder = new ElementPropertiesBuilder();\r\n traverseContent(builder, content);\r\n return builder.items;\r\n};\r\n\r\n/** @internal */\r\nexport function getElementsCount(db: IModelDb, classNames?: string[]) {\r\n const query = `\r\n SELECT COUNT(e.ECInstanceId)\r\n FROM bis.Element e\r\n ${createElementsFilterClause(\"e\", classNames)}\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n return stmt.step() === DbResult.BE_SQLITE_ROW ? stmt.getValue(0).getInteger() : 0;\r\n });\r\n}\r\n\r\n/** @internal */\r\nexport function getElementIdsByClass(db: IModelDb, classNames?: string[], pageOptions?: PageOptions) {\r\n const query = `\r\n SELECT e.ECInstanceId elId, eSchemaDef.Name || ':' || eClassDef.Name elClassName\r\n FROM bis.Element e\r\n LEFT JOIN meta.ECClassDef eClassDef ON eClassDef.ECInstanceId = e.ECClassId\r\n LEFT JOIN meta.ECSchemaDef eSchemaDef ON eSchemaDef.ECInstanceId = eClassDef.Schema.Id\r\n ${createElementsFilterClause(\"e\", classNames)}\r\n ORDER BY e.ECClassId, e.ECInstanceId\r\n ${createElementsLimitClause(pageOptions)}\r\n `;\r\n\r\n return db.withPreparedStatement(query, (stmt: ECSqlStatement) => {\r\n const ids = new Map<string, string[]>();\r\n let currentClassName = \"\";\r\n let currentIds: string[] = [];\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const row = stmt.getRow();\r\n if (!row.elId || !row.elClassName)\r\n continue;\r\n\r\n if (currentClassName !== row.elClassName) {\r\n currentClassName = row.elClassName;\r\n const existingIds = ids.get(row.elClassName);\r\n if (!existingIds) {\r\n currentIds = [];\r\n ids.set(row.elClassName, currentIds);\r\n } else {\r\n currentIds = existingIds;\r\n }\r\n }\r\n currentIds.push(row.elId);\r\n }\r\n return ids;\r\n });\r\n}\r\n\r\nfunction createElementsLimitClause(pageOptions?: PageOptions) {\r\n if (pageOptions === undefined || (pageOptions.size === undefined && pageOptions.start === undefined))\r\n return \"\";\r\n\r\n return `LIMIT ${pageOptions.size ?? -1} OFFSET ${pageOptions.start ?? 0}`;\r\n}\r\n\r\nfunction createElementsFilterClause(elementAlias: string, classNames?: string[]) {\r\n if (classNames === undefined || classNames.length === 0)\r\n return \"\";\r\n\r\n // check if list contains only valid class names\r\n const classNameRegExp = new RegExp(/^[\\w]+[.:][\\w]+$/);\r\n const invalidName = classNames.find((name) => !name.match(classNameRegExp));\r\n if (invalidName) {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Encountered invalid class name - ${invalidName}.\r\n Valid class name formats: \"<schema name or alias>.<class name>\", \"<schema name or alias>:<class name>\"`);\r\n }\r\n\r\n return `WHERE ${elementAlias}.ECClassId IS (${classNames.join(\",\")})`;\r\n}\r\n\r\ninterface IPropertiesAppender {\r\n append(label: string, item: ElementPropertiesItem): void;\r\n finish(): void;\r\n}\r\n\r\nclass ElementPropertiesAppender implements IPropertiesAppender {\r\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\r\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\r\n constructor(private _item: Item, private _onItemFinished: (item: ElementProperties) => void) { }\r\n\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._propertyItems[label] = item;\r\n }\r\n\r\n public finish(): void {\r\n // eslint-disable-next-line guard-for-in\r\n for (const categoryName in this._categoryItemAppenders) {\r\n const appender = this._categoryItemAppenders[categoryName];\r\n appender.finish();\r\n }\r\n\r\n this._onItemFinished({\r\n class: this._item.classInfo?.label ?? \"\",\r\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\r\n label: this._item.label.displayValue,\r\n items: this._propertyItems,\r\n });\r\n }\r\n\r\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\r\n let appender = this._categoryItemAppenders[category.name];\r\n if (!appender) {\r\n appender = new CategoryItemAppender(parentAppender, category);\r\n this._categoryItemAppenders[category.name] = appender;\r\n }\r\n return appender;\r\n }\r\n}\r\n\r\nclass CategoryItemAppender implements IPropertiesAppender {\r\n private _items: { [label: string]: ElementPropertiesItem } = {};\r\n constructor(private _parentAppender: IPropertiesAppender, private _category: CategoryDescription) { }\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._items[label] = item;\r\n }\r\n public finish(): void {\r\n if (Object.keys(this._items).length === 0)\r\n return;\r\n\r\n this._parentAppender.append(this._category.label, {\r\n type: \"category\",\r\n items: this._items,\r\n });\r\n }\r\n}\r\n\r\nclass ArrayItemAppender implements IPropertiesAppender {\r\n private _items: ElementPropertiesPropertyItem[] = [];\r\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartArrayProps) { }\r\n public append(_label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._items.push(item);\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\r\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive)\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\r\n else\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\r\n }\r\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"primitive\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"primitive\");\r\n return item.value;\r\n }),\r\n };\r\n }\r\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"struct\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"struct\");\r\n return item.members;\r\n }),\r\n };\r\n }\r\n}\r\n\r\nclass StructItemAppender implements IPropertiesAppender {\r\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\r\n constructor(private _parentAppender: IPropertiesAppender, private _props: StartStructProps) { }\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._members[label] = item;\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\r\n this._parentAppender.append(this._props.hierarchy.field.label, {\r\n type: \"struct\",\r\n members: this._members,\r\n });\r\n }\r\n}\r\n\r\nclass ElementPropertiesBuilder implements IContentVisitor {\r\n private _appendersStack: IPropertiesAppender[] = [];\r\n private _items: ElementProperties[] = [];\r\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\r\n\r\n public get items(): ElementProperties[] {\r\n return this._items;\r\n }\r\n\r\n private get _currentAppender(): IPropertiesAppender {\r\n const appender = this._appendersStack[this._appendersStack.length - 1];\r\n assert(appender !== undefined);\r\n return appender;\r\n }\r\n\r\n public startContent(_props: StartContentProps): boolean { return true; }\r\n public finishContent(): void { }\r\n\r\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void { }\r\n\r\n public startItem(props: StartItemProps): boolean {\r\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => { this._items.push(item); });\r\n this._appendersStack.push(this._elementPropertiesAppender);\r\n return true;\r\n }\r\n public finishItem(): void {\r\n this._appendersStack.pop();\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._elementPropertiesAppender.finish();\r\n this._elementPropertiesAppender = undefined;\r\n }\r\n\r\n public startCategory(props: StartCategoryProps): boolean {\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\r\n return true;\r\n }\r\n public finishCategory(): void {\r\n this._appendersStack.pop();\r\n }\r\n\r\n public startField(_props: StartFieldProps): boolean { return true; }\r\n public finishField(): void { }\r\n\r\n public startStruct(props: StartStructProps): boolean {\r\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishStruct(): void { this._appendersStack.pop()!.finish(); }\r\n\r\n public startArray(props: StartArrayProps): boolean {\r\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishArray(): void { this._appendersStack.pop()!.finish(); }\r\n\r\n public processMergedValue(props: ProcessMergedValueProps): void {\r\n this._currentAppender.append(props.mergedField.label, {\r\n type: \"primitive\",\r\n value: \"\",\r\n });\r\n }\r\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\r\n this._currentAppender.append(props.field.label, {\r\n type: \"primitive\",\r\n value: props.displayValue?.toString() ?? \"\",\r\n });\r\n }\r\n}\r\n"]}