@itwin/tree-widget-react 3.16.0 → 3.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/lib/cjs/tree-widget-react/components/SelectableTree.js.map +1 -1
  3. package/lib/cjs/tree-widget-react/components/TreeSelector.js.map +1 -1
  4. package/lib/cjs/tree-widget-react/components/TreeWidgetUiItemsProvider.js +1 -1
  5. package/lib/cjs/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
  6. package/lib/cjs/tree-widget-react/components/tree-header/TreeHeader.js.map +1 -1
  7. package/lib/cjs/tree-widget-react/components/tree-header/TreeWithHeader.js.map +1 -1
  8. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +2 -2
  9. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -1
  10. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  11. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  12. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -1
  13. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  14. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +13 -0
  15. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +90 -73
  16. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  17. package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +3 -1
  18. package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +21 -8
  19. package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  20. package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +21 -9
  21. package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +290 -242
  22. package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
  23. package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +2 -0
  24. package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +16 -7
  25. package/lib/cjs/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
  26. package/lib/cjs/tree-widget-react/components/trees/common/UseActiveViewport.js.map +1 -1
  27. package/lib/cjs/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  28. package/lib/cjs/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
  29. package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.d.ts +2 -2
  30. package/lib/cjs/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
  31. package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +1 -1
  32. package/lib/cjs/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
  33. package/lib/cjs/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +1 -1
  34. package/lib/cjs/tree-widget-react/components/trees/common/components/TreeRenderer.js +2 -2
  35. package/lib/cjs/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
  36. package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +3 -3
  37. package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
  38. package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +1 -1
  39. package/lib/cjs/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
  40. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
  41. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  42. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  43. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  44. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +8 -5
  45. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  46. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +2 -1
  47. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  48. package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.d.ts +1 -4
  49. package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js +1 -4
  50. package/lib/cjs/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
  51. package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +13 -12
  52. package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +252 -275
  53. package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
  54. package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.d.ts +1 -1
  55. package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
  56. package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +47 -35
  57. package/lib/cjs/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  58. package/lib/cjs/tree-widget-react-internal.d.ts +2 -1
  59. package/lib/cjs/tree-widget-react-internal.js +4 -1
  60. package/lib/cjs/tree-widget-react-internal.js.map +1 -1
  61. package/lib/esm/tree-widget-react/components/SelectableTree.js.map +1 -1
  62. package/lib/esm/tree-widget-react/components/TreeSelector.js.map +1 -1
  63. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +1 -1
  64. package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
  65. package/lib/esm/tree-widget-react/components/tree-header/TreeHeader.js.map +1 -1
  66. package/lib/esm/tree-widget-react/components/tree-header/TreeWithHeader.js.map +1 -1
  67. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.d.ts +2 -2
  68. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js +2 -1
  69. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTree.js.map +1 -1
  70. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
  71. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.d.ts +1 -1
  72. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeComponent.js.map +1 -1
  73. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +13 -0
  74. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +90 -73
  75. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  76. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.d.ts +3 -1
  77. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +22 -9
  78. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  79. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +21 -9
  80. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +290 -242
  81. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -1
  82. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.d.ts +2 -0
  83. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +16 -7
  84. package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -1
  85. package/lib/esm/tree-widget-react/components/trees/common/UseActiveViewport.js.map +1 -1
  86. package/lib/esm/tree-widget-react/components/trees/common/UseHierarchyVisibility.js.map +1 -1
  87. package/lib/esm/tree-widget-react/components/trees/common/components/ProgressOverlay.js.map +1 -1
  88. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +2 -2
  89. package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
  90. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.d.ts +1 -1
  91. package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeCheckbox.js.map +1 -1
  92. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.d.ts +1 -1
  93. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js +2 -2
  94. package/lib/esm/tree-widget-react/components/trees/common/components/TreeRenderer.js.map +1 -1
  95. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.d.ts +3 -3
  96. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTree.js.map +1 -1
  97. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.d.ts +1 -1
  98. package/lib/esm/tree-widget-react/components/trees/common/components/VisibilityTreeRenderer.js.map +1 -1
  99. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
  100. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  101. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
  102. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  103. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +9 -6
  104. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  105. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +2 -1
  106. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  107. package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.d.ts +1 -4
  108. package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js +1 -4
  109. package/lib/esm/tree-widget-react/components/trees/models-tree/Utils.js.map +1 -1
  110. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +13 -12
  111. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +253 -276
  112. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
  113. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.d.ts +1 -1
  114. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeNode.js.map +1 -1
  115. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +47 -35
  116. package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
  117. package/lib/esm/tree-widget-react-internal.d.ts +2 -1
  118. package/lib/esm/tree-widget-react-internal.js +2 -1
  119. package/lib/esm/tree-widget-react-internal.js.map +1 -1
  120. package/package.json +1 -1
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.CategoriesTreeIdsCache = void 0;
8
8
  exports.getClassesByView = getClassesByView;
9
+ const rxjs_1 = require("rxjs");
9
10
  const core_bentley_1 = require("@itwin/core-bentley");
10
11
  const ClassNameDefinitions_js_1 = require("./ClassNameDefinitions.js");
11
12
  /** @internal */
@@ -31,311 +32,355 @@ class CategoriesTreeIdsCache {
31
32
  this.#componentName = "CategoriesTreeIdsCache";
32
33
  }
33
34
  [Symbol.dispose]() { }
34
- async *queryElementModelCategories() {
35
- const query = `
36
- SELECT this.Model.Id modelId, this.Category.Id categoryId
37
- FROM ${this.#categoryModelClass} m
38
- JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id
39
- WHERE m.IsPrivate = false
40
- GROUP BY modelId, categoryId
41
- `;
42
- for await (const row of this.#queryExecutor.createQueryReader({ ecsql: query }, {
43
- rowFormat: "ECSqlPropertyNames",
44
- limit: "unbounded",
45
- restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories`,
46
- })) {
47
- yield { modelId: row.modelId, categoryId: row.categoryId };
48
- }
35
+ queryElementModelCategories() {
36
+ return (0, rxjs_1.defer)(() => {
37
+ const query = `
38
+ SELECT this.Model.Id modelId, this.Category.Id categoryId
39
+ FROM ${this.#categoryModelClass} m
40
+ JOIN ${this.#categoryElementClass} this ON m.ECInstanceId = this.Model.Id
41
+ WHERE m.IsPrivate = false
42
+ GROUP BY modelId, categoryId
43
+ `;
44
+ return this.#queryExecutor.createQueryReader({ ecsql: query }, {
45
+ rowFormat: "ECSqlPropertyNames",
46
+ limit: "unbounded",
47
+ restartToken: `${this.#componentName}/${this.#componentId}/element-models-and-categories`,
48
+ });
49
+ }).pipe((0, rxjs_1.map)((row) => {
50
+ return { modelId: row.modelId, categoryId: row.categoryId };
51
+ }));
49
52
  }
50
- async *queryCategories() {
51
- const isDefinitionContainerSupported = await this.getIsDefinitionContainerSupported();
52
- const categoriesQuery = `
53
- SELECT
54
- this.ECInstanceId id,
55
- COUNT(sc.ECInstanceId) childCount,
56
- this.Model.Id modelId,
57
- ${isDefinitionContainerSupported
58
- ? `
59
- IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS} dc),
60
- true,
61
- false
62
- )`
63
- : "false"} parentDefinitionContainerExists
64
- FROM
65
- ${this.#categoryClass} this
66
- JOIN ${ClassNameDefinitions_js_1.SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId
67
- JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id
68
- WHERE
69
- NOT this.IsPrivate
70
- AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))
71
- AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId)
72
- GROUP BY this.ECInstanceId
73
- `;
74
- for await (const row of this.#queryExecutor.createQueryReader({ ecsql: categoriesQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/categories` })) {
75
- yield { id: row.id, modelId: row.modelId, parentDefinitionContainerExists: row.parentDefinitionContainerExists, childCount: row.childCount };
76
- }
53
+ queryCategories() {
54
+ return this.getIsDefinitionContainerSupported().pipe((0, rxjs_1.mergeMap)((isDefinitionContainerSupported) => (0, rxjs_1.defer)(() => {
55
+ const categoriesQuery = `
56
+ SELECT
57
+ this.ECInstanceId id,
58
+ COUNT(sc.ECInstanceId) childCount,
59
+ this.Model.Id modelId,
60
+ ${isDefinitionContainerSupported
61
+ ? `
62
+ IIF(this.Model.Id IN (SELECT dc.ECInstanceId FROM ${ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS} dc),
63
+ true,
64
+ false
65
+ )`
66
+ : "false"} parentDefinitionContainerExists,
67
+ IFNULL(
68
+ (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = this.ECInstanceId LIMIT 1),
69
+ 0
70
+ ) hasElements
71
+ FROM
72
+ ${this.#categoryClass} this
73
+ JOIN ${ClassNameDefinitions_js_1.SUB_CATEGORY_CLASS} sc ON sc.Parent.Id = this.ECInstanceId
74
+ JOIN BisCore.Model m ON m.ECInstanceId = this.Model.Id
75
+ WHERE
76
+ NOT this.IsPrivate
77
+ AND (NOT m.IsPrivate OR m.ECClassId IS (BisCore.DictionaryModel))
78
+ GROUP BY this.ECInstanceId
79
+ `;
80
+ return this.#queryExecutor.createQueryReader({ ecsql: categoriesQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/categories` });
81
+ }).pipe((0, rxjs_1.map)((row) => {
82
+ return {
83
+ id: row.id,
84
+ modelId: row.modelId,
85
+ parentDefinitionContainerExists: row.parentDefinitionContainerExists,
86
+ childCount: row.childCount,
87
+ hasElements: !!row.hasElements,
88
+ };
89
+ }))));
77
90
  }
78
- async queryIsDefinitionContainersSupported() {
79
- const query = `
80
- SELECT
81
- 1
82
- FROM
83
- ECDbMeta.ECSchemaDef s
84
- JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId
85
- WHERE
86
- s.Name = 'BisCore'
87
- AND c.Name = 'DefinitionContainer'
88
- `;
89
- for await (const _row of this.#queryExecutor.createQueryReader({ ecsql: query }, { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` })) {
90
- return true;
91
- }
92
- return false;
91
+ queryIsDefinitionContainersSupported() {
92
+ return (0, rxjs_1.defer)(() => {
93
+ const query = `
94
+ SELECT
95
+ 1
96
+ FROM
97
+ ECDbMeta.ECSchemaDef s
98
+ JOIN ECDbMeta.ECClassDef c ON c.Schema.Id = s.ECInstanceId
99
+ WHERE
100
+ s.Name = 'BisCore'
101
+ AND c.Name = 'DefinitionContainer'
102
+ LIMIT 1
103
+ `;
104
+ return this.#queryExecutor.createQueryReader({ ecsql: query }, { restartToken: `${this.#componentName}/${this.#componentId}/is-definition-container-supported` });
105
+ }).pipe((0, rxjs_1.toArray)(), (0, rxjs_1.map)((rows) => rows.length > 0));
93
106
  }
94
- async *queryDefinitionContainers() {
95
- // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:
96
- // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}
97
- // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId
98
- // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId
99
- const DEFINITION_CONTAINERS_CTE = "DefinitionContainers";
100
- const ctes = [
101
- `
102
- ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId) AS (
107
+ queryDefinitionContainers() {
108
+ return (0, rxjs_1.defer)(() => {
109
+ // DefinitionModel ECInstanceId will always be the same as modeled DefinitionContainer ECInstanceId, if this wasn't the case, we would need to do something like:
110
+ // JOIN BisCore.DefinitionModel dm ON dm.ECInstanceId = ${modelIdAccessor}
111
+ // JOIN BisCore.DefinitionModelBreaksDownDefinitionContainer dr ON dr.SourceECInstanceId = dm.ECInstanceId
112
+ // JOIN BisCore.DefinitionContainer dc ON dc.ECInstanceId = dr.TargetECInstanceId
113
+ const DEFINITION_CONTAINERS_CTE = "DefinitionContainers";
114
+ const CATEGORIES_MODELS_CTE = "CategoriesModels";
115
+ const ctes = [
116
+ `${CATEGORIES_MODELS_CTE}(ModelId, HasElements) AS (
103
117
  SELECT
104
- dc.ECInstanceId,
105
- dc.Model.Id
118
+ c.Model.Id,
119
+ IFNULL((
120
+ SELECT 1
121
+ FROM ${this.#categoryElementClass} e
122
+ WHERE e.Category.Id = c.ECInstanceId
123
+ LIMIT 1
124
+ ), 0)
106
125
  FROM
107
- ${ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS} dc
126
+ ${this.#categoryClass} c
108
127
  WHERE
109
- dc.ECInstanceId IN (SELECT c.Model.Id FROM ${this.#categoryClass} c WHERE NOT c.IsPrivate AND EXISTS (SELECT 1 FROM ${this.#categoryElementClass} e WHERE e.Category.Id = c.ECInstanceId))
110
- AND NOT dc.IsPrivate
128
+ NOT c.IsPrivate
129
+ )`,
130
+ `
131
+ ${DEFINITION_CONTAINERS_CTE}(ECInstanceId, ModelId, HasElements) AS (
132
+ SELECT
133
+ dc.ECInstanceId,
134
+ dc.Model.Id,
135
+ c.HasElements
136
+ FROM ${ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS} dc
137
+ JOIN ${CATEGORIES_MODELS_CTE} c ON dc.ECInstanceId = c.ModelId
138
+ WHERE NOT dc.IsPrivate
111
139
 
112
- UNION ALL
140
+ UNION ALL
113
141
 
114
- SELECT
115
- pdc.ECInstanceId,
116
- pdc.Model.Id
117
- FROM
118
- ${DEFINITION_CONTAINERS_CTE} cdc
119
- JOIN ${ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS} pdc ON pdc.ECInstanceId = cdc.ModelId
120
- WHERE
121
- NOT pdc.IsPrivate
122
- )
123
- `,
124
- ];
125
- const definitionsQuery = `
126
- SELECT dc.ECInstanceId id, dc.ModelId modelId FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId
127
- `;
128
- for await (const row of this.#queryExecutor.createQueryReader({ ctes, ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` })) {
129
- yield { id: row.id, modelId: row.modelId };
130
- }
142
+ SELECT
143
+ pdc.ECInstanceId,
144
+ pdc.Model.Id,
145
+ cdc.HasElements
146
+ FROM
147
+ ${DEFINITION_CONTAINERS_CTE} cdc
148
+ JOIN ${ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS} pdc ON pdc.ECInstanceId = cdc.ModelId
149
+ WHERE NOT pdc.IsPrivate
150
+ )
151
+ `,
152
+ ];
153
+ const definitionsQuery = `
154
+ SELECT dc.ECInstanceId id, dc.ModelId modelId, MAX(dc.HasElements) hasElements FROM ${DEFINITION_CONTAINERS_CTE} dc GROUP BY dc.ECInstanceId
155
+ `;
156
+ return this.#queryExecutor.createQueryReader({ ctes, ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/definition-containers` });
157
+ }).pipe((0, rxjs_1.map)((row) => {
158
+ return { id: row.id, modelId: row.modelId, hasElements: !!row.hasElements };
159
+ }));
131
160
  }
132
- async *queryVisibleSubCategories(categoriesInfo) {
133
- const definitionsQuery = `
134
- SELECT
135
- sc.ECInstanceId id,
136
- sc.Parent.Id categoryId
137
- FROM
138
- ${ClassNameDefinitions_js_1.SUB_CATEGORY_CLASS} sc
139
- WHERE
140
- NOT sc.IsPrivate
141
- AND sc.Parent.Id IN (${categoriesInfo.join(",")})
142
- `;
143
- for await (const row of this.#queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` })) {
144
- yield { id: row.id, parentId: row.categoryId };
145
- }
161
+ queryVisibleSubCategories(categoriesInfo) {
162
+ return (0, rxjs_1.defer)(() => {
163
+ const definitionsQuery = `
164
+ SELECT
165
+ sc.ECInstanceId id,
166
+ sc.Parent.Id categoryId
167
+ FROM
168
+ ${ClassNameDefinitions_js_1.SUB_CATEGORY_CLASS} sc
169
+ WHERE
170
+ NOT sc.IsPrivate
171
+ AND sc.Parent.Id IN (${categoriesInfo.join(",")})
172
+ `;
173
+ return this.#queryExecutor.createQueryReader({ ecsql: definitionsQuery }, { rowFormat: "ECSqlPropertyNames", limit: "unbounded", restartToken: `${this.#componentName}/${this.#componentId}/visible-sub-categories` });
174
+ }).pipe((0, rxjs_1.map)((row) => {
175
+ return { id: row.id, parentId: row.categoryId };
176
+ }));
146
177
  }
147
- async getModelsCategoriesInfo() {
148
- this.#modelsCategoriesInfo ??= (async () => {
149
- const allModelsCategories = new Map();
150
- for await (const queriedCategory of this.queryCategories()) {
151
- let modelCategories = allModelsCategories.get(queriedCategory.modelId);
152
- if (modelCategories === undefined) {
153
- modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };
154
- allModelsCategories.set(queriedCategory.modelId, modelCategories);
155
- }
156
- modelCategories.childCategories.push({ id: queriedCategory.id, childCount: queriedCategory.childCount });
178
+ getModelsCategoriesInfo() {
179
+ this.#modelsCategoriesInfo ??= this.queryCategories()
180
+ .pipe((0, rxjs_1.reduce)((acc, queriedCategory) => {
181
+ let modelCategories = acc.get(queriedCategory.modelId);
182
+ if (modelCategories === undefined) {
183
+ modelCategories = { parentDefinitionContainerExists: queriedCategory.parentDefinitionContainerExists, childCategories: [] };
184
+ acc.set(queriedCategory.modelId, modelCategories);
157
185
  }
158
- return allModelsCategories;
159
- })();
186
+ modelCategories.childCategories.push({ id: queriedCategory.id, childCount: queriedCategory.childCount, hasElements: queriedCategory.hasElements });
187
+ return acc;
188
+ }, new Map()))
189
+ .pipe((0, rxjs_1.shareReplay)());
160
190
  return this.#modelsCategoriesInfo;
161
191
  }
162
- async getElementModelsCategories() {
163
- this.#elementModelsCategories ??= (async () => {
164
- const elementModelsCategories = new Map();
165
- for await (const queriedCategory of this.queryElementModelCategories()) {
166
- let modelEntry = elementModelsCategories.get(queriedCategory.modelId);
167
- if (modelEntry === undefined) {
168
- modelEntry = new Set();
169
- elementModelsCategories.set(queriedCategory.modelId, modelEntry);
170
- }
171
- modelEntry.add(queriedCategory.categoryId);
192
+ getElementModelsCategories() {
193
+ this.#elementModelsCategories ??= this.queryElementModelCategories()
194
+ .pipe((0, rxjs_1.reduce)((acc, queriedCategory) => {
195
+ let modelEntry = acc.get(queriedCategory.modelId);
196
+ if (modelEntry === undefined) {
197
+ modelEntry = new Set();
198
+ acc.set(queriedCategory.modelId, modelEntry);
172
199
  }
173
- return elementModelsCategories;
174
- })();
200
+ modelEntry.add(queriedCategory.categoryId);
201
+ return acc;
202
+ }, new Map()))
203
+ .pipe((0, rxjs_1.shareReplay)());
175
204
  return this.#elementModelsCategories;
176
205
  }
177
- async getSubCategoriesInfo() {
178
- this.#subCategoriesInfo ??= (async () => {
206
+ getSubCategoriesInfo() {
207
+ this.#subCategoriesInfo ??= this.getModelsCategoriesInfo()
208
+ .pipe((0, rxjs_1.mergeMap)((modelsCategoriesInfo) => (0, rxjs_1.from)(modelsCategoriesInfo.values())), (0, rxjs_1.reduce)((acc, modelCategoriesInfo) => {
209
+ acc.push(...modelCategoriesInfo.childCategories.filter((categoryInfo) => categoryInfo.childCount > 1).map((categoryInfo) => categoryInfo.id));
210
+ return acc;
211
+ }, new Array()), (0, rxjs_1.mergeMap)((categoriesWithMoreThanOneSubCategory) => {
179
212
  const allSubCategories = new Map();
180
- const modelsCategoriesInfo = await this.getModelsCategoriesInfo();
181
- const categoriesWithMoreThanOneSubCategory = new Array();
182
- for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {
183
- categoriesWithMoreThanOneSubCategory.push(...modelCategoriesInfo.childCategories.filter((categoryInfo) => categoryInfo.childCount > 1).map((categoryInfo) => categoryInfo.id));
184
- }
185
213
  if (categoriesWithMoreThanOneSubCategory.length === 0) {
186
- return allSubCategories;
214
+ return (0, rxjs_1.of)(allSubCategories);
187
215
  }
188
- for await (const queriedSubCategory of this.queryVisibleSubCategories(categoriesWithMoreThanOneSubCategory)) {
189
- allSubCategories.set(queriedSubCategory.id, { categoryId: queriedSubCategory.parentId });
190
- }
191
- return allSubCategories;
192
- })();
216
+ return this.queryVisibleSubCategories(categoriesWithMoreThanOneSubCategory).pipe((0, rxjs_1.reduce)((acc, queriedSubCategory) => {
217
+ acc.set(queriedSubCategory.id, { categoryId: queriedSubCategory.parentId });
218
+ return acc;
219
+ }, allSubCategories));
220
+ }))
221
+ .pipe((0, rxjs_1.shareReplay)());
193
222
  return this.#subCategoriesInfo;
194
223
  }
195
- async getDefinitionContainersInfo() {
196
- this.#definitionContainersInfo ??= (async () => {
224
+ getDefinitionContainersInfo() {
225
+ this.#definitionContainersInfo ??= (0, rxjs_1.forkJoin)({
226
+ isDefinitionContainerSupported: this.getIsDefinitionContainerSupported(),
227
+ modelsCategoriesInfo: this.getModelsCategoriesInfo(),
228
+ })
229
+ .pipe((0, rxjs_1.mergeMap)(({ isDefinitionContainerSupported, modelsCategoriesInfo }) => {
197
230
  const definitionContainersInfo = new Map();
198
- const [isDefinitionContainerSupported, modelsCategoriesInfo] = await Promise.all([
199
- this.getIsDefinitionContainerSupported(),
200
- this.getModelsCategoriesInfo(),
201
- ]);
202
231
  if (!isDefinitionContainerSupported || modelsCategoriesInfo.size === 0) {
203
- return definitionContainersInfo;
232
+ return (0, rxjs_1.of)(definitionContainersInfo);
204
233
  }
205
- for await (const queriedDefinitionContainer of this.queryDefinitionContainers()) {
234
+ return this.queryDefinitionContainers().pipe((0, rxjs_1.reduce)((acc, queriedDefinitionContainer) => {
206
235
  const modelCategoriesInfo = modelsCategoriesInfo.get(queriedDefinitionContainer.id);
207
- definitionContainersInfo.set(queriedDefinitionContainer.id, {
236
+ acc.set(queriedDefinitionContainer.id, {
208
237
  childCategories: modelCategoriesInfo?.childCategories ?? [],
209
238
  modelId: queriedDefinitionContainer.modelId,
210
239
  childDefinitionContainers: [],
211
240
  parentDefinitionContainerExists: false,
241
+ hasElements: queriedDefinitionContainer.hasElements,
212
242
  });
213
- }
214
- for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {
215
- const parentDefinitionContainer = definitionContainersInfo.get(definitionContainerInfo.modelId);
216
- if (parentDefinitionContainer !== undefined) {
217
- parentDefinitionContainer.childDefinitionContainers.push(definitionContainerId);
218
- definitionContainerInfo.parentDefinitionContainerExists = true;
243
+ return acc;
244
+ }, definitionContainersInfo), (0, rxjs_1.map)((result) => {
245
+ for (const [definitionContainerId, definitionContainerInfo] of result) {
246
+ const parentDefinitionContainer = result.get(definitionContainerInfo.modelId);
247
+ if (parentDefinitionContainer !== undefined) {
248
+ parentDefinitionContainer.childDefinitionContainers.push({ id: definitionContainerId, hasElements: definitionContainerInfo.hasElements });
249
+ definitionContainerInfo.parentDefinitionContainerExists = true;
250
+ parentDefinitionContainer.hasElements = parentDefinitionContainer.hasElements || definitionContainerInfo.hasElements;
251
+ }
219
252
  }
220
- }
221
- return definitionContainersInfo;
222
- })();
253
+ return result;
254
+ }));
255
+ }))
256
+ .pipe((0, rxjs_1.shareReplay)());
223
257
  return this.#definitionContainersInfo;
224
258
  }
225
- async getDirectChildDefinitionContainersAndCategories(parentDefinitionContainerIds) {
226
- const definitionContainersInfo = await this.getDefinitionContainersInfo();
227
- const result = { definitionContainers: new Array(), categories: new Array() };
228
- parentDefinitionContainerIds.forEach((parentDefinitionContainerId) => {
259
+ getDirectChildDefinitionContainersAndCategories({ parentDefinitionContainerIds, includeEmpty, }) {
260
+ return this.getDefinitionContainersInfo().pipe((0, rxjs_1.mergeMap)((definitionContainersInfo) => (0, rxjs_1.from)(parentDefinitionContainerIds).pipe((0, rxjs_1.reduce)((acc, parentDefinitionContainerId) => {
229
261
  const parentDefinitionContainerInfo = definitionContainersInfo.get(parentDefinitionContainerId);
230
262
  if (parentDefinitionContainerInfo !== undefined) {
231
- result.definitionContainers.push(...parentDefinitionContainerInfo.childDefinitionContainers);
232
- result.categories.push(...parentDefinitionContainerInfo.childCategories);
263
+ acc.definitionContainers.push(...applyElementsFilter(parentDefinitionContainerInfo.childDefinitionContainers, includeEmpty).map((dc) => dc.id));
264
+ acc.categories.push(...applyElementsFilter(parentDefinitionContainerInfo.childCategories, includeEmpty));
233
265
  }
234
- });
235
- return result;
266
+ return acc;
267
+ }, { definitionContainers: new Array(), categories: new Array() }))));
236
268
  }
237
- async getCategoriesElementModels(categoryIds) {
238
- const elementModelsCategories = await this.getElementModelsCategories();
239
- const result = new Map();
240
- for (const categoryId of categoryIds) {
269
+ getCategoriesElementModels(categoryIds) {
270
+ return this.getElementModelsCategories().pipe((0, rxjs_1.mergeMap)((elementModelsCategories) => (0, rxjs_1.from)(categoryIds).pipe((0, rxjs_1.reduce)((acc, categoryId) => {
241
271
  for (const [modelId, categories] of elementModelsCategories) {
242
272
  if (categories.has(categoryId)) {
243
- let categoryModels = result.get(categoryId);
273
+ let categoryModels = acc.get(categoryId);
244
274
  if (!categoryModels) {
245
275
  categoryModels = new Array();
246
- result.set(categoryId, categoryModels);
276
+ acc.set(categoryId, categoryModels);
247
277
  }
248
278
  categoryModels.push(modelId);
249
279
  }
250
280
  }
251
- }
252
- return result;
281
+ return acc;
282
+ }, new Map()))));
253
283
  }
254
- async getAllContainedCategories(definitionContainerIds) {
255
- const result = new Array();
256
- const definitionContainersInfo = await this.getDefinitionContainersInfo();
257
- const indirectCategories = await Promise.all(definitionContainerIds.map(async (definitionContainerId) => {
284
+ getAllContainedCategories({ definitionContainerIds, includeEmptyCategories, }) {
285
+ return this.getDefinitionContainersInfo().pipe((0, rxjs_1.mergeMap)((definitionContainersInfo) => (0, rxjs_1.from)(definitionContainerIds).pipe((0, rxjs_1.mergeMap)((definitionContainerId) => {
258
286
  const definitionContainerInfo = definitionContainersInfo.get(definitionContainerId);
259
287
  if (definitionContainerInfo === undefined) {
260
- return [];
288
+ return (0, rxjs_1.of)({ directCategories: undefined, indirectCategories: undefined });
261
289
  }
262
- result.push(...definitionContainerInfo.childCategories.map((category) => category.id));
263
- return this.getAllContainedCategories(definitionContainerInfo.childDefinitionContainers);
264
- }));
265
- for (const categories of indirectCategories) {
266
- result.push(...categories);
267
- }
268
- return result;
290
+ const childDefinitionContainerIds = definitionContainerInfo.childDefinitionContainers.map(({ id }) => id);
291
+ return (childDefinitionContainerIds.length > 0
292
+ ? this.getAllContainedCategories({
293
+ definitionContainerIds: childDefinitionContainerIds,
294
+ includeEmptyCategories,
295
+ })
296
+ : (0, rxjs_1.of)(new Set())).pipe((0, rxjs_1.map)((indirectCategories) => {
297
+ return {
298
+ directCategories: applyElementsFilter(definitionContainerInfo.childCategories, includeEmptyCategories).map((category) => category.id),
299
+ indirectCategories,
300
+ };
301
+ }));
302
+ }), (0, rxjs_1.reduce)((acc, { directCategories, indirectCategories }) => {
303
+ directCategories?.forEach((categoryId) => acc.add(categoryId));
304
+ indirectCategories?.forEach((categoryId) => acc.add(categoryId));
305
+ return acc;
306
+ }, new Set()))));
269
307
  }
270
- async getInstanceKeyPaths(props) {
308
+ getInstanceKeyPaths(props) {
271
309
  if ("subCategoryId" in props) {
272
- const subCategoriesInfo = await this.getSubCategoriesInfo();
273
- const subCategoryInfo = subCategoriesInfo.get(props.subCategoryId);
274
- if (subCategoryInfo === undefined) {
275
- return [];
276
- }
277
- return [...(await this.getInstanceKeyPaths({ categoryId: subCategoryInfo.categoryId })), { id: props.subCategoryId, className: ClassNameDefinitions_js_1.SUB_CATEGORY_CLASS }];
310
+ return this.getSubCategoriesInfo().pipe((0, rxjs_1.mergeMap)((subCategoriesInfo) => {
311
+ const subCategoryInfo = subCategoriesInfo.get(props.subCategoryId);
312
+ if (subCategoryInfo === undefined) {
313
+ return (0, rxjs_1.of)([]);
314
+ }
315
+ return this.getInstanceKeyPaths({ categoryId: subCategoryInfo.categoryId }).pipe((0, rxjs_1.map)((pathToCategory) => [...pathToCategory, { id: props.subCategoryId, className: ClassNameDefinitions_js_1.SUB_CATEGORY_CLASS }]));
316
+ }));
278
317
  }
279
318
  if ("categoryId" in props) {
280
- const modelsCategoriesInfo = await this.getModelsCategoriesInfo();
281
- for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {
282
- if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {
283
- if (!modelCategoriesInfo.parentDefinitionContainerExists) {
284
- return [{ id: props.categoryId, className: this.#categoryClass }];
319
+ return this.getModelsCategoriesInfo().pipe((0, rxjs_1.mergeMap)((modelsCategoriesInfo) => {
320
+ for (const [modelId, modelCategoriesInfo] of modelsCategoriesInfo) {
321
+ if (modelCategoriesInfo.childCategories.find((childCategory) => childCategory.id === props.categoryId)) {
322
+ const instanceKey = { id: props.categoryId, className: this.#categoryClass };
323
+ if (!modelCategoriesInfo.parentDefinitionContainerExists) {
324
+ return (0, rxjs_1.of)([instanceKey]);
325
+ }
326
+ return this.getInstanceKeyPaths({ definitionContainerId: modelId }).pipe((0, rxjs_1.map)((pathToDefinitionContainer) => [...pathToDefinitionContainer, instanceKey]));
285
327
  }
286
- return [...(await this.getInstanceKeyPaths({ definitionContainerId: modelId })), { id: props.categoryId, className: this.#categoryClass }];
287
328
  }
288
- }
289
- return [];
329
+ return (0, rxjs_1.of)([]);
330
+ }));
290
331
  }
291
- const definitionContainersInfo = await this.getDefinitionContainersInfo();
292
- const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);
293
- if (definitionContainerInfo === undefined) {
294
- return [];
295
- }
296
- if (!definitionContainerInfo.parentDefinitionContainerExists) {
297
- return [{ id: props.definitionContainerId, className: ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS }];
298
- }
299
- return [
300
- ...(await this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId })),
301
- { id: props.definitionContainerId, className: ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS },
302
- ];
303
- }
304
- async getAllDefinitionContainersAndCategories() {
305
- const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);
306
- const result = { definitionContainers: [...definitionContainersInfo.keys()], categories: new Array() };
307
- for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {
308
- result.categories.push(...modelCategoriesInfo.childCategories.map((childCategory) => childCategory.id));
309
- }
310
- return result;
311
- }
312
- async getRootDefinitionContainersAndCategories() {
313
- const [modelsCategoriesInfo, definitionContainersInfo] = await Promise.all([this.getModelsCategoriesInfo(), this.getDefinitionContainersInfo()]);
314
- const result = { definitionContainers: new Array(), categories: new Array() };
315
- for (const modelCategoriesInfo of modelsCategoriesInfo.values()) {
316
- if (!modelCategoriesInfo.parentDefinitionContainerExists) {
317
- result.categories.push(...modelCategoriesInfo.childCategories);
332
+ return this.getDefinitionContainersInfo().pipe((0, rxjs_1.mergeMap)((definitionContainersInfo) => {
333
+ const definitionContainerInfo = definitionContainersInfo.get(props.definitionContainerId);
334
+ if (definitionContainerInfo === undefined) {
335
+ return (0, rxjs_1.of)([]);
318
336
  }
319
- }
320
- for (const [definitionContainerId, definitionContainerInfo] of definitionContainersInfo) {
337
+ const instanceKey = { id: props.definitionContainerId, className: ClassNameDefinitions_js_1.DEFINITION_CONTAINER_CLASS };
321
338
  if (!definitionContainerInfo.parentDefinitionContainerExists) {
322
- result.definitionContainers.push(definitionContainerId);
339
+ return (0, rxjs_1.of)([instanceKey]);
323
340
  }
324
- }
325
- return result;
341
+ return this.getInstanceKeyPaths({ definitionContainerId: definitionContainerInfo.modelId }).pipe((0, rxjs_1.map)((pathToParentDefinitionContainer) => [...pathToParentDefinitionContainer, instanceKey]));
342
+ }));
343
+ }
344
+ getAllDefinitionContainersAndCategories(props) {
345
+ return (0, rxjs_1.forkJoin)({
346
+ categories: this.getModelsCategoriesInfo().pipe((0, rxjs_1.mergeMap)((modelsCategoriesInfo) => modelsCategoriesInfo.values()), (0, rxjs_1.reduce)((acc, modelCategoriesInfo) => {
347
+ applyElementsFilter(modelCategoriesInfo.childCategories, props?.includeEmpty).forEach((categoryInfo) => acc.push(categoryInfo.id));
348
+ return acc;
349
+ }, new Array())),
350
+ definitionContainers: this.getDefinitionContainersInfo().pipe((0, rxjs_1.mergeMap)((definitionContainersInfo) => definitionContainersInfo.entries()), (0, rxjs_1.reduce)((acc, [definitionContainerId, definitionContainerInfo]) => {
351
+ if (definitionContainerInfo.hasElements || !!props?.includeEmpty) {
352
+ acc.push(definitionContainerId);
353
+ }
354
+ return acc;
355
+ }, new Array())),
356
+ });
357
+ }
358
+ getRootDefinitionContainersAndCategories(props) {
359
+ return (0, rxjs_1.forkJoin)({
360
+ categories: this.getModelsCategoriesInfo().pipe((0, rxjs_1.mergeMap)((modelsCategoriesInfo) => modelsCategoriesInfo.values()), (0, rxjs_1.reduce)((acc, modelCategoriesInfo) => {
361
+ if (!modelCategoriesInfo.parentDefinitionContainerExists) {
362
+ applyElementsFilter(modelCategoriesInfo.childCategories, props?.includeEmpty).forEach((categoryInfo) => acc.push(categoryInfo));
363
+ }
364
+ return acc;
365
+ }, new Array())),
366
+ definitionContainers: this.getDefinitionContainersInfo().pipe((0, rxjs_1.mergeMap)((definitionContainersInfo) => definitionContainersInfo.entries()), (0, rxjs_1.reduce)((acc, [definitionContainerId, definitionContainerInfo]) => {
367
+ if (!definitionContainerInfo.parentDefinitionContainerExists && (definitionContainerInfo.hasElements || !!props?.includeEmpty)) {
368
+ acc.push(definitionContainerId);
369
+ }
370
+ return acc;
371
+ }, new Array())),
372
+ });
326
373
  }
327
- async getSubCategories(categoryId) {
328
- const subCategoriesInfo = await this.getSubCategoriesInfo();
329
- const result = new Array();
330
- for (const [subCategoryId, subCategoryInfo] of subCategoriesInfo) {
374
+ getSubCategories(categoryId) {
375
+ return this.getSubCategoriesInfo().pipe((0, rxjs_1.mergeMap)((subCategoriesInfo) => subCategoriesInfo.entries()), (0, rxjs_1.reduce)((acc, [subCategoryId, subCategoryInfo]) => {
331
376
  if (subCategoryInfo.categoryId === categoryId) {
332
- result.push(subCategoryId);
377
+ acc.push(subCategoryId);
333
378
  }
334
- }
335
- return result;
379
+ return acc;
380
+ }, new Array()));
336
381
  }
337
- async getIsDefinitionContainerSupported() {
338
- this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported();
382
+ getIsDefinitionContainerSupported() {
383
+ this.#isDefinitionContainerSupported ??= this.queryIsDefinitionContainersSupported().pipe((0, rxjs_1.shareReplay)());
339
384
  return this.#isDefinitionContainerSupported;
340
385
  }
341
386
  }
@@ -346,4 +391,7 @@ function getClassesByView(viewType) {
346
391
  ? { categoryClass: "BisCore.DrawingCategory", categoryElementClass: "BisCore.GeometricElement2d", categoryModelClass: "BisCore.GeometricModel2d" }
347
392
  : { categoryClass: "BisCore.SpatialCategory", categoryElementClass: "BisCore.GeometricElement3d", categoryModelClass: "BisCore.GeometricModel3d" };
348
393
  }
394
+ function applyElementsFilter(list, includeEmpty) {
395
+ return includeEmpty ? list : list.filter(({ hasElements }) => !!hasElements);
396
+ }
349
397
  //# sourceMappingURL=CategoriesTreeIdsCache.js.map