@itwin/presentation-backend 5.1.0-dev.37 → 5.1.0-dev.39

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 (24) hide show
  1. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +9 -9
  2. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts.map +1 -1
  3. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +9 -9
  4. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  5. package/lib/cjs/presentation-backend/Presentation.d.ts +3 -3
  6. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  7. package/lib/cjs/presentation-backend/PresentationManager.d.ts +3 -3
  8. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  9. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  10. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  11. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  12. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts +9 -9
  13. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts.map +1 -1
  14. package/lib/esm/presentation-backend/BackendLoggerCategory.js +9 -9
  15. package/lib/esm/presentation-backend/BackendLoggerCategory.js.map +1 -1
  16. package/lib/esm/presentation-backend/Presentation.d.ts +3 -3
  17. package/lib/esm/presentation-backend/Presentation.js.map +1 -1
  18. package/lib/esm/presentation-backend/PresentationManager.d.ts +3 -3
  19. package/lib/esm/presentation-backend/PresentationManager.js.map +1 -1
  20. package/lib/esm/presentation-backend/SelectionScopesHelper.js.map +1 -1
  21. package/lib/esm/presentation-backend/Utils.d.ts.map +1 -1
  22. package/lib/esm/presentation-backend/Utils.js +2 -2
  23. package/lib/esm/presentation-backend/Utils.js.map +1 -1
  24. package/package.json +15 -15
@@ -40,23 +40,23 @@ export declare enum PresentationBackendNativeLoggerCategory {
40
40
  ECPresentation_RulesetVariables = "ECPresentation.RulesetVariables",
41
41
  ECPresentation_ECExpressions = "ECPresentation.ECExpressions",
42
42
  ECPresentation_Serialization = "ECPresentation.Serialization",
43
- /** @deprecated in 4.0. The logging namespace is not used anymore. */
43
+ /** @deprecated in 4.0 - might be removed in next major version. The logging namespace is not used anymore. */
44
44
  ECPresentation_Localization = "ECPresentation.Localization",
45
- /** @deprecated in 4.0. Use [[ECPresentation]] */
45
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation]] */
46
46
  ECPresentation_RulesEngine = "ECPresentation.RulesEngine",
47
- /** @deprecated in 4.0. Use [[ECPresentation_Content]] */
47
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Content]] */
48
48
  ECPresentation_RulesEngine_Content = "ECPresentation.Content",
49
- /** @deprecated in 4.0. The logging namespace is not used anymore. */
49
+ /** @deprecated in 4.0 - might be removed in next major version. The logging namespace is not used anymore. */
50
50
  ECPresentation_RulesEngine_Localization = "ECPresentation.Localization",
51
- /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies]] */
51
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Hierarchies]] */
52
52
  ECPresentation_RulesEngine_Navigation = "ECPresentation.Navigation",
53
- /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies_Cache]] */
53
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Hierarchies_Cache]] */
54
54
  ECPresentation_RulesEngine_Navigation_Cache = "ECPresentation.Navigation.Cache",
55
- /** @deprecated in 4.0. Use [[ECPresentation_Tasks]] */
55
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Tasks]] */
56
56
  ECPresentation_RulesEngine_Threads = "ECPresentation.Tasks",
57
- /** @deprecated in 4.0. Use [[ECPresentation_Update]] */
57
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Update]] */
58
58
  ECPresentation_RulesEngine_Update = "ECPresentation.Update",
59
- /** @deprecated in 4.0. Use [[ECPresentation_RulesetVariables]] */
59
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_RulesetVariables]] */
60
60
  ECPresentation_RulesEngine_RulesetVariables = "ECPresentation.RulesetVariables"
61
61
  }
62
62
  //# sourceMappingURL=BackendLoggerCategory.d.ts.map
@@ -1 +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,oBAAoB,yBAAyB;IAC7C,0BAA0B,8BAA8B;IACxD,gCAAgC,oCAAoC;IACpE,sBAAsB,2BAA2B;IACjD,qBAAqB,0BAA0B;IAC/C,iCAAiC,sCAAsC;IACvE,6BAA6B,kCAAkC;IAC/D,oBAAoB,yBAAyB;IAC7C,+BAA+B,oCAAoC;IACnE,4BAA4B,iCAAiC;IAC7D,4BAA4B,iCAAiC;IAG7D,qEAAqE;IACrE,2BAA2B,gCAAgC;IAC3D,iDAAiD;IACjD,0BAA0B,+BAA+B;IACzD,yDAAyD;IACzD,kCAAkC,2BAA2B;IAC7D,qEAAqE;IACrE,uCAAuC,gCAAgC;IACvE,6DAA6D;IAC7D,qCAAqC,8BAA8B;IACnE,mEAAmE;IACnE,2CAA2C,oCAAoC;IAC/E,uDAAuD;IACvD,kCAAkC,yBAAyB;IAC3D,wDAAwD;IACxD,iCAAiC,0BAA0B;IAC3D,kEAAkE;IAClE,2CAA2C,oCAAoC;CAChF"}
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,oBAAoB,yBAAyB;IAC7C,0BAA0B,8BAA8B;IACxD,gCAAgC,oCAAoC;IACpE,sBAAsB,2BAA2B;IACjD,qBAAqB,0BAA0B;IAC/C,iCAAiC,sCAAsC;IACvE,6BAA6B,kCAAkC;IAC/D,oBAAoB,yBAAyB;IAC7C,+BAA+B,oCAAoC;IACnE,4BAA4B,iCAAiC;IAC7D,4BAA4B,iCAAiC;IAG7D,8GAA8G;IAC9G,2BAA2B,gCAAgC;IAC3D,0FAA0F;IAC1F,0BAA0B,+BAA+B;IACzD,kGAAkG;IAClG,kCAAkC,2BAA2B;IAC7D,8GAA8G;IAC9G,uCAAuC,gCAAgC;IACvE,sGAAsG;IACtG,qCAAqC,8BAA8B;IACnE,4GAA4G;IAC5G,2CAA2C,oCAAoC;IAC/E,gGAAgG;IAChG,kCAAkC,yBAAyB;IAC3D,iGAAiG;IACjG,iCAAiC,0BAA0B;IAC3D,2GAA2G;IAC3G,2CAA2C,oCAAoC;CAChF"}
@@ -50,23 +50,23 @@ var PresentationBackendNativeLoggerCategory;
50
50
  PresentationBackendNativeLoggerCategory["ECPresentation_ECExpressions"] = "ECPresentation.ECExpressions";
51
51
  PresentationBackendNativeLoggerCategory["ECPresentation_Serialization"] = "ECPresentation.Serialization";
52
52
  /* eslint-disable @typescript-eslint/no-duplicate-enum-values */
53
- /** @deprecated in 4.0. The logging namespace is not used anymore. */
53
+ /** @deprecated in 4.0 - might be removed in next major version. The logging namespace is not used anymore. */
54
54
  PresentationBackendNativeLoggerCategory["ECPresentation_Localization"] = "ECPresentation.Localization";
55
- /** @deprecated in 4.0. Use [[ECPresentation]] */
55
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation]] */
56
56
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine"] = "ECPresentation.RulesEngine";
57
- /** @deprecated in 4.0. Use [[ECPresentation_Content]] */
57
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Content]] */
58
58
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Content"] = "ECPresentation.Content";
59
- /** @deprecated in 4.0. The logging namespace is not used anymore. */
59
+ /** @deprecated in 4.0 - might be removed in next major version. The logging namespace is not used anymore. */
60
60
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Localization"] = "ECPresentation.Localization";
61
- /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies]] */
61
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Hierarchies]] */
62
62
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Navigation"] = "ECPresentation.Navigation";
63
- /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies_Cache]] */
63
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Hierarchies_Cache]] */
64
64
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Navigation_Cache"] = "ECPresentation.Navigation.Cache";
65
- /** @deprecated in 4.0. Use [[ECPresentation_Tasks]] */
65
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Tasks]] */
66
66
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Threads"] = "ECPresentation.Tasks";
67
- /** @deprecated in 4.0. Use [[ECPresentation_Update]] */
67
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Update]] */
68
68
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_Update"] = "ECPresentation.Update";
69
- /** @deprecated in 4.0. Use [[ECPresentation_RulesetVariables]] */
69
+ /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_RulesetVariables]] */
70
70
  PresentationBackendNativeLoggerCategory["ECPresentation_RulesEngine_RulesetVariables"] = "ECPresentation.RulesetVariables";
71
71
  })(PresentationBackendNativeLoggerCategory || (exports.PresentationBackendNativeLoggerCategory = PresentationBackendNativeLoggerCategory = {}));
72
72
  //# sourceMappingURL=BackendLoggerCategory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BackendLoggerCategory.js","sourceRoot":"","sources":["../../../src/presentation-backend/BackendLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;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,iDAAjC,iCAAiC,QAW5C;AAED;;;;;GAKG;AACH,IAAY,uCAuCX;AAvCD,WAAY,uCAAuC;IACjD,kEAAuB,CAAA;IACvB,8FAAmD,CAAA;IACnD,0GAA+D,CAAA;IAC/D,gHAAqE,CAAA;IAErE,4EAAiC,CAAA;IACjC,oGAAyD,CAAA;IACzD,wFAA6C,CAAA;IAC7C,mGAAwD,CAAA;IACxD,+GAAoE,CAAA;IACpE,4FAAiD,CAAA;IACjD,0FAA+C,CAAA;IAC/C,kHAAuE,CAAA;IACvE,0GAA+D,CAAA;IAC/D,wFAA6C,CAAA;IAC7C,8GAAmE,CAAA;IACnE,wGAA6D,CAAA;IAC7D,wGAA6D,CAAA;IAE7D,gEAAgE;IAChE,qEAAqE;IACrE,sGAA2D,CAAA;IAC3D,iDAAiD;IACjD,oGAAyD,CAAA;IACzD,yDAAyD;IACzD,wGAA6D,CAAA;IAC7D,qEAAqE;IACrE,kHAAuE,CAAA;IACvE,6DAA6D;IAC7D,8GAAmE,CAAA;IACnE,mEAAmE;IACnE,0HAA+E,CAAA;IAC/E,uDAAuD;IACvD,sGAA2D,CAAA;IAC3D,wDAAwD;IACxD,sGAA2D,CAAA;IAC3D,kEAAkE;IAClE,0HAA+E,CAAA;AACjF,CAAC,EAvCW,uCAAuC,uDAAvC,uCAAuC,QAuClD","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 Logging\n */\n\n/**\n * Logger categories used by this package\n * @note All logger categories in this package start with the `presentation-backend` prefix.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum PresentationBackendLoggerCategory {\n Package = \"presentation-backend\",\n\n /** The logger category used by the [[PresentationManager]] class and other related classes. */\n PresentationManager = \"presentation-backend.PresentationManager\",\n\n /** The logger category used by Presentation RPC implementation. */\n Rpc = \"presentation-backend.Rpc\",\n\n /** The logger category used by Presentation IPC implementation. */\n Ipc = \"presentation-backend.Ipc\",\n}\n\n/**\n * Logger categories used by this package\n * @note Logger categories used by the [[PresentationManager]] native addon.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum PresentationBackendNativeLoggerCategory {\n ECObjects = \"ECObjects\",\n ECObjects_ECExpressions = \"ECObjects.ECExpressions\",\n ECObjects_ECExpressions_Parse = \"ECObjects.ECExpressions.Parse\",\n ECObjects_ECExpressions_Evaluate = \"ECObjects.ECExpressions.Evaluate\",\n\n ECPresentation = \"ECPresentation\",\n ECPresentation_Connections = \"ECPresentation.Connections\",\n ECPresentation_Tasks = \"ECPresentation.Tasks\",\n ECPresentation_Hierarchies = \"ECPresentation.Navigation\",\n ECPresentation_Hierarchies_Cache = \"ECPresentation.Navigation.Cache\",\n ECPresentation_Content = \"ECPresentation.Content\",\n ECPresentation_Update = \"ECPresentation.Update\",\n ECPresentation_Update_Hierarchies = \"ECPresentation.Update.Hierarchies\",\n ECPresentation_Update_Content = \"ECPresentation.Update.Content\",\n ECPresentation_Rules = \"ECPresentation.Rules\",\n ECPresentation_RulesetVariables = \"ECPresentation.RulesetVariables\",\n ECPresentation_ECExpressions = \"ECPresentation.ECExpressions\",\n ECPresentation_Serialization = \"ECPresentation.Serialization\",\n\n /* eslint-disable @typescript-eslint/no-duplicate-enum-values */\n /** @deprecated in 4.0. The logging namespace is not used anymore. */\n ECPresentation_Localization = \"ECPresentation.Localization\",\n /** @deprecated in 4.0. Use [[ECPresentation]] */\n ECPresentation_RulesEngine = \"ECPresentation.RulesEngine\",\n /** @deprecated in 4.0. Use [[ECPresentation_Content]] */\n ECPresentation_RulesEngine_Content = \"ECPresentation.Content\",\n /** @deprecated in 4.0. The logging namespace is not used anymore. */\n ECPresentation_RulesEngine_Localization = \"ECPresentation.Localization\",\n /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies]] */\n ECPresentation_RulesEngine_Navigation = \"ECPresentation.Navigation\",\n /** @deprecated in 4.0. Use [[ECPresentation_Hierarchies_Cache]] */\n ECPresentation_RulesEngine_Navigation_Cache = \"ECPresentation.Navigation.Cache\",\n /** @deprecated in 4.0. Use [[ECPresentation_Tasks]] */\n ECPresentation_RulesEngine_Threads = \"ECPresentation.Tasks\",\n /** @deprecated in 4.0. Use [[ECPresentation_Update]] */\n ECPresentation_RulesEngine_Update = \"ECPresentation.Update\",\n /** @deprecated in 4.0. Use [[ECPresentation_RulesetVariables]] */\n ECPresentation_RulesEngine_RulesetVariables = \"ECPresentation.RulesetVariables\",\n}\n"]}
1
+ {"version":3,"file":"BackendLoggerCategory.js","sourceRoot":"","sources":["../../../src/presentation-backend/BackendLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;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,iDAAjC,iCAAiC,QAW5C;AAED;;;;;GAKG;AACH,IAAY,uCAuCX;AAvCD,WAAY,uCAAuC;IACjD,kEAAuB,CAAA;IACvB,8FAAmD,CAAA;IACnD,0GAA+D,CAAA;IAC/D,gHAAqE,CAAA;IAErE,4EAAiC,CAAA;IACjC,oGAAyD,CAAA;IACzD,wFAA6C,CAAA;IAC7C,mGAAwD,CAAA;IACxD,+GAAoE,CAAA;IACpE,4FAAiD,CAAA;IACjD,0FAA+C,CAAA;IAC/C,kHAAuE,CAAA;IACvE,0GAA+D,CAAA;IAC/D,wFAA6C,CAAA;IAC7C,8GAAmE,CAAA;IACnE,wGAA6D,CAAA;IAC7D,wGAA6D,CAAA;IAE7D,gEAAgE;IAChE,8GAA8G;IAC9G,sGAA2D,CAAA;IAC3D,0FAA0F;IAC1F,oGAAyD,CAAA;IACzD,kGAAkG;IAClG,wGAA6D,CAAA;IAC7D,8GAA8G;IAC9G,kHAAuE,CAAA;IACvE,sGAAsG;IACtG,8GAAmE,CAAA;IACnE,4GAA4G;IAC5G,0HAA+E,CAAA;IAC/E,gGAAgG;IAChG,sGAA2D,CAAA;IAC3D,iGAAiG;IACjG,sGAA2D,CAAA;IAC3D,2GAA2G;IAC3G,0HAA+E,CAAA;AACjF,CAAC,EAvCW,uCAAuC,uDAAvC,uCAAuC,QAuClD","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 Logging\n */\n\n/**\n * Logger categories used by this package\n * @note All logger categories in this package start with the `presentation-backend` prefix.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum PresentationBackendLoggerCategory {\n Package = \"presentation-backend\",\n\n /** The logger category used by the [[PresentationManager]] class and other related classes. */\n PresentationManager = \"presentation-backend.PresentationManager\",\n\n /** The logger category used by Presentation RPC implementation. */\n Rpc = \"presentation-backend.Rpc\",\n\n /** The logger category used by Presentation IPC implementation. */\n Ipc = \"presentation-backend.Ipc\",\n}\n\n/**\n * Logger categories used by this package\n * @note Logger categories used by the [[PresentationManager]] native addon.\n * @see [Logger]($bentley)\n * @public\n */\nexport enum PresentationBackendNativeLoggerCategory {\n ECObjects = \"ECObjects\",\n ECObjects_ECExpressions = \"ECObjects.ECExpressions\",\n ECObjects_ECExpressions_Parse = \"ECObjects.ECExpressions.Parse\",\n ECObjects_ECExpressions_Evaluate = \"ECObjects.ECExpressions.Evaluate\",\n\n ECPresentation = \"ECPresentation\",\n ECPresentation_Connections = \"ECPresentation.Connections\",\n ECPresentation_Tasks = \"ECPresentation.Tasks\",\n ECPresentation_Hierarchies = \"ECPresentation.Navigation\",\n ECPresentation_Hierarchies_Cache = \"ECPresentation.Navigation.Cache\",\n ECPresentation_Content = \"ECPresentation.Content\",\n ECPresentation_Update = \"ECPresentation.Update\",\n ECPresentation_Update_Hierarchies = \"ECPresentation.Update.Hierarchies\",\n ECPresentation_Update_Content = \"ECPresentation.Update.Content\",\n ECPresentation_Rules = \"ECPresentation.Rules\",\n ECPresentation_RulesetVariables = \"ECPresentation.RulesetVariables\",\n ECPresentation_ECExpressions = \"ECPresentation.ECExpressions\",\n ECPresentation_Serialization = \"ECPresentation.Serialization\",\n\n /* eslint-disable @typescript-eslint/no-duplicate-enum-values */\n /** @deprecated in 4.0 - might be removed in next major version. The logging namespace is not used anymore. */\n ECPresentation_Localization = \"ECPresentation.Localization\",\n /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation]] */\n ECPresentation_RulesEngine = \"ECPresentation.RulesEngine\",\n /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Content]] */\n ECPresentation_RulesEngine_Content = \"ECPresentation.Content\",\n /** @deprecated in 4.0 - might be removed in next major version. The logging namespace is not used anymore. */\n ECPresentation_RulesEngine_Localization = \"ECPresentation.Localization\",\n /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Hierarchies]] */\n ECPresentation_RulesEngine_Navigation = \"ECPresentation.Navigation\",\n /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Hierarchies_Cache]] */\n ECPresentation_RulesEngine_Navigation_Cache = \"ECPresentation.Navigation.Cache\",\n /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Tasks]] */\n ECPresentation_RulesEngine_Threads = \"ECPresentation.Tasks\",\n /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_Update]] */\n ECPresentation_RulesEngine_Update = \"ECPresentation.Update\",\n /** @deprecated in 4.0 - might be removed in next major version. Use [[ECPresentation_RulesetVariables]] */\n ECPresentation_RulesEngine_RulesetVariables = \"ECPresentation.RulesetVariables\",\n}\n"]}
@@ -27,14 +27,14 @@ export interface PresentationProps extends Omit<PresentationManagerProps, "enabl
27
27
  * instances, one for each frontend.
28
28
  *
29
29
  * @public
30
- * @deprecated in 4.8 - use [[PresentationProps]] instead.
30
+ * @deprecated in 4.8 - might be removed in next major version. Use [[PresentationProps]] instead.
31
31
  */
32
32
  export type MultiManagerPresentationProps = PresentationProps;
33
33
  /**
34
34
  * Base props for initializing the [[Presentation]] library.
35
35
  *
36
36
  * @public
37
- * @deprecated in 4.8 - use [[PresentationProps]] instead.
37
+ * @deprecated in 4.8 - might be removed in next major version. Use [[PresentationProps]] instead.
38
38
  */
39
39
  export type PresentationPropsBase = PresentationProps;
40
40
  /**
@@ -42,7 +42,7 @@ export type PresentationPropsBase = PresentationProps;
42
42
  * [[PresentationManager]] instance for handling all requests.
43
43
  *
44
44
  * @public
45
- * @deprecated in 4.8 - use [[PresentationProps]] instead.
45
+ * @deprecated in 4.8 - might be removed in next major version. Use [[PresentationProps]] instead.
46
46
  */
47
47
  export type SingleManagerPresentationProps = Omit<PresentationProps, "unusedClientLifetime">;
48
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAuE;AACvE,sDAA0D;AAC1D,oDAAgD;AAChD,oEAA6G;AAC7G,yEAA+E;AAC/E,2EAAqE;AACrE,qEAAyF;AACzF,qEAA+D;AAC/D,+DAAqE;AACrE,6DAAoE;AA8DpE;;;;;;;;;GASG;AACH,MAAa,YAAY;IACf,MAAM,CAAC,UAAU,CAA8D;IAC/E,MAAM,CAAC,eAAe,CAA4D;IAClF,MAAM,CAAC,kBAAkB,CAA0B;IACnD,MAAM,CAAC,iBAAiB,CAA0B;IAClD,MAAM,CAAC,4BAA4B,CAA0B;IAC7D,MAAM,CAAC,QAAQ,CAAkC;IAEzD,oBAAoB;IACpB,gBAAuB,CAAC;IAExB,+DAA+D;IACxD,MAAM,KAAK,SAAS;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,UAAU,CAAC,KAAyB;QAChD,IAAI,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,yBAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;QAEjG,IAAI,CAAC,QAAQ,GAAG,IAAI,4CAAmB,CAAC;YACtC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc;SAC/C,CAAC,CAAC;QACH,wBAAU,CAAC,YAAY,CAAC,8CAAwB,EAAE,4CAAmB,CAAC,CAAC;QACvE,wBAAU,CAAC,kBAAkB,CAAC,8CAAwB,EAAE,IA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GAAG,CACxH,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,CAAC;IACrB,CAAC;IAEO,MAAM,CAAC,oBAAoB,CAAC,GAAW,EAAE,SAA0B;QACzE,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,QAAiB;QACxC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;QAC/D,CAAC;QACD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,cAAc,EAAE,2EAA2E,CAAC,CAAC;IAC9I,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB;QAC7B,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,cAAc,EAAE,2EAA2E,CAAC,CAAC;QAC9I,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IACtC,CAAC;IAEO,MAAM,CAAC,cAAc,GAAG,CAAC,MAAmB,EAAE,EAAE;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,OAAO,CAAC,iDAA4B,CAAC,CAAC,iBAAiB,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACrG,mEAAmE;QACnE,OAAO,CAAC,iDAA4B,CAAC,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC,CAAC;;AA1IJ,oCA2IC","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 Core\n */\n\nimport { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\nimport { RpcManager } from \"@itwin/core-common\";\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory.js\";\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler.js\";\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager.js\";\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl.js\";\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage.js\";\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\n\n/**\n * Properties that can be used to configure [[Presentation]] API.\n * @public\n */\nexport interface PresentationProps extends Omit<PresentationManagerProps, \"enableSchemasPreload\"> {\n /**\n * Time in milliseconds after which the request will timeout.\n */\n requestTimeout?: number;\n\n /**\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n */\n enableSchemasPreload?: boolean;\n\n /**\n * How much time should an unused client manager be stored in memory\n * before it's disposed.\n */\n unusedClientLifetime?: number;\n}\n\ninterface PresentationInternalProps {\n /**\n * Factory method for creating separate managers for each client\n */\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\n}\n\n/**\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\n * instances, one for each frontend.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type MultiManagerPresentationProps = PresentationProps;\n\n/**\n * Base props for initializing the [[Presentation]] library.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type PresentationPropsBase = PresentationProps;\n\n/**\n * Props for initializing the [[Presentation]] library with ability to use a single\n * [[PresentationManager]] instance for handling all requests.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type SingleManagerPresentationProps = Omit<PresentationProps, \"unusedClientLifetime\">;\n\ninterface ClientStoreItem {\n manager: PresentationManager;\n}\n\n/**\n * Static class used to statically set up Presentation library for the backend.\n * Basically what it does is:\n * - Register a RPC implementation\n * - Create a singleton [[PresentationManager]] instance\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\n * the presentation manager when that happens.\n *\n * @public\n */\nexport class Presentation {\n private static _initProps: (PresentationProps & PresentationInternalProps) | undefined;\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\n private static _disposeIpcHandler: DisposeFunc | undefined;\n private static _shutdownListener: DisposeFunc | undefined;\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\n private static _rpcImpl: PresentationRpcImpl | undefined;\n\n /* c8 ignore next */\n private constructor() {}\n\n /** Properties used to initialize the presentation framework */\n public static get initProps(): PresentationProps | undefined {\n return this._initProps;\n }\n\n /**\n * Initializes Presentation library for the backend.\n *\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\n *\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\n *\n * @param props Optional properties for [[PresentationManager]]\n */\n public static initialize(props?: PresentationProps): void {\n this._initProps = props || {};\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\n\n this._rpcImpl = new PresentationRpcImpl({\n requestTimeout: this._initProps.requestTimeout,\n });\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\n\n if (IpcHost.isValid) {\n this._disposeIpcHandler = PresentationIpcHandler.register();\n }\n\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\n factory: this.createClientManager.bind(this),\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\n // cleanup unused managers every minute\n cleanupInterval: 60 * 1000,\n // by default, manager is disposed after 1 hour of being unused\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\n // add some logging\n /* c8 ignore next 5 */\n onDisposedSingle: (id: string) =>\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`,\n ),\n /* c8 ignore next */\n onDisposedAll: () => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\n });\n\n if (this._initProps.enableSchemasPreload) {\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\n }\n }\n\n /**\n * Terminates Presentation. Consumers don't need to call this as it's automatically\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\n */\n public static terminate(): void {\n if (this._clientsStorage) {\n this._clientsStorage[Symbol.dispose]();\n this._clientsStorage = undefined;\n }\n if (this._disposeIModelOpenedListener) {\n this._disposeIModelOpenedListener();\n this._disposeIModelOpenedListener = undefined;\n }\n if (this._shutdownListener) {\n this._shutdownListener();\n this._shutdownListener = undefined;\n }\n RpcManager.unregisterImpl(PresentationRpcInterface);\n if (this._rpcImpl) {\n this._rpcImpl[Symbol.dispose]();\n this._rpcImpl = undefined;\n }\n if (this._disposeIpcHandler) {\n this._disposeIpcHandler();\n }\n this._initProps = undefined;\n }\n\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\n const manager =\n Presentation._initProps && Presentation._initProps.clientManagerFactory\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\n : new PresentationManager({\n ...Presentation._initProps,\n // @ts-expect-error internal prop\n id: clientId,\n });\n manager.onUsed.addListener(onManagerUsed);\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`,\n );\n return { manager };\n }\n\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\n storeItem.manager[Symbol.dispose]();\n }\n\n /**\n * Get an instance of [[PresentationManager]] for specific client\n * @param clientId ID of the client requesting presentation data. If no\n * ID is provided, the default [[PresentationManager]] is returned.\n */\n public static getManager(clientId?: string): PresentationManager {\n if (this._clientsStorage) {\n return this._clientsStorage.getValue(clientId || \"\").manager;\n }\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n\n /**\n * Get the time in milliseconds that backend should respond in .\n */\n public static getRequestTimeout(): number {\n if (this._rpcImpl === undefined) {\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n return this._rpcImpl.requestTimeout;\n }\n\n private static onIModelOpened = (imodel: BriefcaseDb) => {\n const manager = this.getManager();\n const imodelAddon = manager[_presentation_manager_detail].getNativePlatform().getImodelAddon(imodel);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n manager[_presentation_manager_detail].getNativePlatform().forceLoadSchemas(imodelAddon);\n };\n}\n"]}
1
+ {"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAuE;AACvE,sDAA0D;AAC1D,oDAAgD;AAChD,oEAA6G;AAC7G,yEAA+E;AAC/E,2EAAqE;AACrE,qEAAyF;AACzF,qEAA+D;AAC/D,+DAAqE;AACrE,6DAAoE;AA8DpE;;;;;;;;;GASG;AACH,MAAa,YAAY;IACf,MAAM,CAAC,UAAU,CAA8D;IAC/E,MAAM,CAAC,eAAe,CAA4D;IAClF,MAAM,CAAC,kBAAkB,CAA0B;IACnD,MAAM,CAAC,iBAAiB,CAA0B;IAClD,MAAM,CAAC,4BAA4B,CAA0B;IAC7D,MAAM,CAAC,QAAQ,CAAkC;IAEzD,oBAAoB;IACpB,gBAAuB,CAAC;IAExB,+DAA+D;IACxD,MAAM,KAAK,SAAS;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,UA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,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,OAAO,CAAC,iDAA4B,CAAC,CAAC,iBAAiB,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACrG,mEAAmE;QACnE,OAAO,CAAC,iDAA4B,CAAC,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC,CAAC;;AA1IJ,oCA2IC","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 Core\n */\n\nimport { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\nimport { RpcManager } from \"@itwin/core-common\";\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory.js\";\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler.js\";\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager.js\";\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl.js\";\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage.js\";\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\n\n/**\n * Properties that can be used to configure [[Presentation]] API.\n * @public\n */\nexport interface PresentationProps extends Omit<PresentationManagerProps, \"enableSchemasPreload\"> {\n /**\n * Time in milliseconds after which the request will timeout.\n */\n requestTimeout?: number;\n\n /**\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n */\n enableSchemasPreload?: boolean;\n\n /**\n * How much time should an unused client manager be stored in memory\n * before it's disposed.\n */\n unusedClientLifetime?: number;\n}\n\ninterface PresentationInternalProps {\n /**\n * Factory method for creating separate managers for each client\n */\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\n}\n\n/**\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\n * instances, one for each frontend.\n *\n * @public\n * @deprecated in 4.8 - might be removed in next major version. Use [[PresentationProps]] instead.\n */\nexport type MultiManagerPresentationProps = PresentationProps;\n\n/**\n * Base props for initializing the [[Presentation]] library.\n *\n * @public\n * @deprecated in 4.8 - might be removed in next major version. Use [[PresentationProps]] instead.\n */\nexport type PresentationPropsBase = PresentationProps;\n\n/**\n * Props for initializing the [[Presentation]] library with ability to use a single\n * [[PresentationManager]] instance for handling all requests.\n *\n * @public\n * @deprecated in 4.8 - might be removed in next major version. Use [[PresentationProps]] instead.\n */\nexport type SingleManagerPresentationProps = Omit<PresentationProps, \"unusedClientLifetime\">;\n\ninterface ClientStoreItem {\n manager: PresentationManager;\n}\n\n/**\n * Static class used to statically set up Presentation library for the backend.\n * Basically what it does is:\n * - Register a RPC implementation\n * - Create a singleton [[PresentationManager]] instance\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\n * the presentation manager when that happens.\n *\n * @public\n */\nexport class Presentation {\n private static _initProps: (PresentationProps & PresentationInternalProps) | undefined;\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\n private static _disposeIpcHandler: DisposeFunc | undefined;\n private static _shutdownListener: DisposeFunc | undefined;\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\n private static _rpcImpl: PresentationRpcImpl | undefined;\n\n /* c8 ignore next */\n private constructor() {}\n\n /** Properties used to initialize the presentation framework */\n public static get initProps(): PresentationProps | undefined {\n return this._initProps;\n }\n\n /**\n * Initializes Presentation library for the backend.\n *\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\n *\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\n *\n * @param props Optional properties for [[PresentationManager]]\n */\n public static initialize(props?: PresentationProps): void {\n this._initProps = props || {};\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\n\n this._rpcImpl = new PresentationRpcImpl({\n requestTimeout: this._initProps.requestTimeout,\n });\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\n\n if (IpcHost.isValid) {\n this._disposeIpcHandler = PresentationIpcHandler.register();\n }\n\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\n factory: this.createClientManager.bind(this),\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\n // cleanup unused managers every minute\n cleanupInterval: 60 * 1000,\n // by default, manager is disposed after 1 hour of being unused\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\n // add some logging\n /* c8 ignore next 5 */\n onDisposedSingle: (id: string) =>\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`,\n ),\n /* c8 ignore next */\n onDisposedAll: () => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\n });\n\n if (this._initProps.enableSchemasPreload) {\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\n }\n }\n\n /**\n * Terminates Presentation. Consumers don't need to call this as it's automatically\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\n */\n public static terminate(): void {\n if (this._clientsStorage) {\n this._clientsStorage[Symbol.dispose]();\n this._clientsStorage = undefined;\n }\n if (this._disposeIModelOpenedListener) {\n this._disposeIModelOpenedListener();\n this._disposeIModelOpenedListener = undefined;\n }\n if (this._shutdownListener) {\n this._shutdownListener();\n this._shutdownListener = undefined;\n }\n RpcManager.unregisterImpl(PresentationRpcInterface);\n if (this._rpcImpl) {\n this._rpcImpl[Symbol.dispose]();\n this._rpcImpl = undefined;\n }\n if (this._disposeIpcHandler) {\n this._disposeIpcHandler();\n }\n this._initProps = undefined;\n }\n\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\n const manager =\n Presentation._initProps && Presentation._initProps.clientManagerFactory\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\n : new PresentationManager({\n ...Presentation._initProps,\n // @ts-expect-error internal prop\n id: clientId,\n });\n manager.onUsed.addListener(onManagerUsed);\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`,\n );\n return { manager };\n }\n\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\n storeItem.manager[Symbol.dispose]();\n }\n\n /**\n * Get an instance of [[PresentationManager]] for specific client\n * @param clientId ID of the client requesting presentation data. If no\n * ID is provided, the default [[PresentationManager]] is returned.\n */\n public static getManager(clientId?: string): PresentationManager {\n if (this._clientsStorage) {\n return this._clientsStorage.getValue(clientId || \"\").manager;\n }\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n\n /**\n * Get the time in milliseconds that backend should respond in .\n */\n public static getRequestTimeout(): number {\n if (this._rpcImpl === undefined) {\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n return this._rpcImpl.requestTimeout;\n }\n\n private static onIModelOpened = (imodel: BriefcaseDb) => {\n const manager = this.getManager();\n const imodelAddon = manager[_presentation_manager_detail].getNativePlatform().getImodelAddon(imodel);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n manager[_presentation_manager_detail].getNativePlatform().forceLoadSchemas(imodelAddon);\n };\n}\n"]}
@@ -134,7 +134,7 @@ export interface PresentationManagerCachingConfig {
134
134
  * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).
135
135
  *
136
136
  * @public
137
- * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.
137
+ * @deprecated in 4.3 - might be removed in next major version. The type has been moved to `@itwin/presentation-common` package.
138
138
  */
139
139
  export type UnitSystemFormat = CommonUnitSystemFormat;
140
140
  /**
@@ -177,7 +177,7 @@ export interface PresentationManagerProps {
177
177
  *
178
178
  * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.
179
179
  *
180
- * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.
180
+ * @deprecated in 4.2 - might be removed in next major version. This attribute is not used anymore - the package is not using private assets anymore.
181
181
  */
182
182
  presentationAssetsRoot?: string | PresentationAssetsRootConfig;
183
183
  /**
@@ -215,7 +215,7 @@ export interface PresentationManagerProps {
215
215
  * data changes are not tracked at all.
216
216
  *
217
217
  * @beta
218
- * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.
218
+ * @deprecated in 4.4 - might be removed in next major version. The manager now always tracks for iModel data changes without polling.
219
219
  */
220
220
  updatesPollInterval?: number;
221
221
  /** Options for caching. */
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAsC;AACtC,mDAA+C;AAK/C,oEA6CoC;AACpC,kEAO6C;AAC7C,6EAAgI;AAChI,6DAAoE;AACpE,2DAAiE;AACjE,iFAA+F;AAE/F,6EAAoG;AACpG,yEAAmE;AACnE,yCAA0G;AAE1G;;;GAGG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IACjB;;;OAGG;IACH,mCAAa,CAAA;IACb;;;;;OAKG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAjBW,kBAAkB,kCAAlB,kBAAkB,QAiB7B;AAqPD;;;;;GAKG;AACH,MAAa,mBAAmB;IACtB,MAAM,CAA2B;IACjC,OAAO,CAA4B;IACnC,mBAAmB,CAAqB;IACxC,sBAAsB,CAAsC;IAEpE;;;OAGG;IACH,YAAY,KAAgC;QA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AC,aAAa,CAAC;QAC9F,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACtD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,2CAA2C,CAAC,CAAC;QAC/G,CAAC;QAED,MAAM,oBAAoB,GAAG,gBAAgB,IAAI,EAAE,CAAC;QACpD,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,IAAI,oBAAoB,CAAC;QAE3E,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,8CAA0B,CAAC,kBAAkB;YACxD,GAAG,OAAO;YACV,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;SACjE,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAraD,kDAqaC","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 Core\n */\n\nimport { firstValueFrom } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { BeEvent, Id64Array } from \"@itwin/core-bentley\";\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport {\n UnitSystemFormat as CommonUnitSystemFormat,\n ComputeSelectionRequestOptions,\n Content,\n ContentDescriptorRequestOptions,\n ContentFlags,\n ContentRequestOptions,\n ContentSourcesRequestOptions,\n DefaultContentDisplayTypes,\n Descriptor,\n DescriptorOverrides,\n DisplayLabelRequestOptions,\n DisplayLabelsRequestOptions,\n DisplayValueGroup,\n DistinctValuesRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRequestOptions,\n FilterByTextHierarchyRequestOptions,\n FormatsMap,\n HierarchyCompareInfo,\n HierarchyCompareOptions,\n HierarchyLevel,\n HierarchyLevelDescriptorRequestOptions,\n HierarchyRequestOptions,\n InstanceKey,\n Item,\n KeySet,\n KoqPropertyValueFormatter,\n LabelDefinition,\n MultiElementPropertiesRequestOptions,\n Node,\n NodeKey,\n NodePathElement,\n Paged,\n PagedResponse,\n PresentationError,\n PresentationStatus,\n Prioritized,\n Ruleset,\n RulesetVariable,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRequestOptions,\n SingleElementPropertiesRequestOptions,\n WithCancelEvent,\n} from \"@itwin/presentation-common\";\nimport {\n buildElementProperties,\n ContentFormatter,\n ContentPropertyValueFormatter,\n deepReplaceNullsToUndefined,\n isSingleElementPropertiesRequestOptions,\n LocalizationHelper,\n} from \"@itwin/presentation-common/internal\";\nimport { getContentItemsObservableFromClassNames, getContentItemsObservableFromElementIds } from \"./ElementPropertiesHelper.js\";\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\nimport { NativePlatformRequestTypes } from \"./NativePlatform.js\";\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail.js\";\nimport { RulesetManager } from \"./RulesetManager.js\";\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager.js\";\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper.js\";\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils.js\";\n\n/**\n * Presentation hierarchy cache mode.\n * @public\n */\nexport enum HierarchyCacheMode {\n /**\n * Hierarchy cache is created in memory.\n */\n Memory = \"memory\",\n /**\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\n * openings.\n */\n Disk = \"disk\",\n /**\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\n * and persisted in disk cache when whole hierarchy level is created.\n *\n * **Note:** This mode is still experimental.\n */\n Hybrid = \"hybrid\",\n}\n\n/**\n * Configuration for hierarchy cache.\n * @public\n */\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\n\n/**\n * Base interface for all [[HierarchyCacheConfig]] implementations.\n * @public\n */\nexport interface HierarchyCacheConfigBase {\n mode: HierarchyCacheMode;\n}\n\n/**\n * Configuration for in-memory hierarchy cache.\n *\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\n * @public\n */\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Memory;\n}\n\n/**\n * Configuration for persistent disk hierarchy cache.\n *\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\n * @public\n */\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Disk;\n\n /**\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\n *\n * The default directory depends on the iModel and the way it's opened.\n */\n directory?: string;\n\n /**\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\n */\n memoryCacheSize?: number;\n}\n\n/**\n * Configuration for the experimental hybrid hierarchy cache.\n *\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\n * alternative for cases when there are lots of simultaneous requests.\n *\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\n * @public\n */\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Hybrid;\n\n /** Configuration for disk cache used to persist hierarchies. */\n disk?: DiskHierarchyCacheConfig;\n}\n\n/**\n * Configuration for content cache.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n * @public\n */\nexport interface ContentCacheConfig {\n /**\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\n *\n * Defaults to `100`.\n */\n size?: number;\n}\n\n/**\n * Caching configuration options for [[PresentationManager]].\n * @public\n */\nexport interface PresentationManagerCachingConfig {\n /**\n * Hierarchies-related caching options.\n *\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\n */\n hierarchies?: HierarchyCacheConfig;\n\n /**\n * Content-related caching options.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n */\n content?: ContentCacheConfig;\n\n /**\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\n * cache. Defaults to `32768000` bytes (32 MB).\n *\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\n */\n workerConnectionCacheSize?: number;\n}\n\n/**\n * A data structure that associates unit systems with a format. The associations are used for\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\n *\n * @public\n * @deprecated in 4.3. The type has been moved to `@itwin/presentation-common` package.\n */\nexport type UnitSystemFormat = CommonUnitSystemFormat;\n\n/**\n * Data structure for multiple element properties request response.\n * @public\n */\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\n total: number;\n iterator: () => AsyncGenerator<TParsedContent[]>;\n}\n\n/**\n * Configuration options for supplying asset paths to [[PresentationManager]].\n * @public\n */\nexport interface PresentationAssetsRootConfig {\n /**\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\n */\n backend: string;\n}\n\n/**\n * Properties that can be used to configure [[PresentationManager]]\n * @public\n */\nexport interface PresentationManagerProps {\n /**\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\n *\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\n *\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\n * - `assets/*\\*\\/*`\n * - `presentation-backend/{presentation-backend source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\n *\n * - else, assume the backend is webpacked into a single file with assets next to it:\n * - `assets/*\\*\\/*`\n * - `{source file being executed}.js`\n *\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\n *\n * @deprecated in 4.2. This attribute is not used anymore - the package is not using private assets anymore.\n */\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\n\n /**\n * A list of directories containing application's presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n rulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's supplemental presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n supplementalRulesetDirectories?: string[];\n\n /**\n * Sets the active unit system to use for formatting property values with\n * units. Default presentation units are used if this is not specified. The active unit\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\n * through request options.\n */\n defaultUnitSystem?: UnitSystemKey;\n\n /**\n * A map of default unit formats to use for formatting properties that don't have a presentation format\n * in requested unit system.\n */\n defaultFormats?: FormatsMap;\n\n /**\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\n */\n workerThreadsCount?: number;\n\n /**\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\n * data changes are not tracked at all.\n *\n * @beta\n * @deprecated in 4.4. The manager now always tracks for iModel data changes without polling.\n */\n updatesPollInterval?: number;\n\n /** Options for caching. */\n caching?: PresentationManagerCachingConfig;\n\n /**\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\n *\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\n */\n useMmap?: boolean | number;\n\n /**\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\n * data is localized on the frontend). Defaults to English localization.\n *\n * @see [Localization]($docs/presentation/advanced/Localization)\n */\n getLocalizedString?: (key: string) => string;\n\n /**\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\n *\n * @deprecated in 5.1. [IModelDb.schemaContext]($core-backend) is now used by default instead.\n */\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\n\n /**\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\n * made through the manager.\n *\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/**\n * Backend Presentation manager which pulls the presentation data from\n * an iModel using native platform.\n *\n * @public\n */\nexport class PresentationManager {\n private _props: PresentationManagerProps;\n private _detail: PresentationManagerDetail;\n private _localizationHelper: LocalizationHelper;\n private _schemaContextProvider: (imodel: IModelDb) => SchemaContext;\n\n /**\n * Creates an instance of PresentationManager.\n * @param props Optional configuration properties.\n */\n constructor(props?: PresentationManagerProps) {\n this._props = props ?? {};\n this._detail = new PresentationManagerDetail(this._props);\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this._schemaContextProvider = props?.schemaContextProvider ?? ((imodel: IModelDb) => imodel.schemaContext);\n }\n\n /** Get / set active unit system used to format property values with units */\n public get activeUnitSystem(): UnitSystemKey | undefined {\n return this._detail.activeUnitSystem;\n }\n /* c8 ignore next 3 */\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\n this._detail.activeUnitSystem = value;\n }\n\n /** Dispose the presentation manager. Must be called to clean up native resources. */\n public [Symbol.dispose]() {\n this._detail[Symbol.dispose]();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n /* c8 ignore next 3 */\n public dispose() {\n this[Symbol.dispose]();\n }\n\n /** An event, that this manager raises whenever any request is made on it. */\n public get onUsed(): BeEvent<() => void> {\n return this._detail.onUsed;\n }\n\n /** Properties used to initialize the manager */\n public get props() {\n return this._props;\n }\n\n /** Get rulesets manager */\n public rulesets(): RulesetManager {\n return this._detail.rulesets;\n }\n\n /**\n * Get ruleset variables manager for specific ruleset\n * @param rulesetId Id of the ruleset to get variables manager for\n */\n public vars(rulesetId: string): RulesetVariablesManager {\n return new RulesetVariablesManagerImpl(() => this._detail.getNativePlatform(), rulesetId);\n }\n\n /** @internal */\n /* c8 ignore next 3 */\n public get [_presentation_manager_detail](): PresentationManagerDetail {\n return this._detail;\n }\n\n public getRulesetId(rulesetOrId: Ruleset | string) {\n return this._detail.getRulesetId(rulesetOrId);\n }\n\n /**\n * Retrieves nodes\n * @public\n */\n public async getNodes(\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Node[]> {\n const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\n return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);\n }\n\n /**\n * Retrieves nodes count\n * @public\n */\n public async getNodesCount(\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getNodesCount(requestOptions);\n }\n\n /**\n * Retrieves hierarchy level descriptor\n * @public\n */\n public async getNodesDescriptor(\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getNodesDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\n * TODO: Return results in pages\n * @public\n */\n public async getNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Retrieves paths from root nodes to nodes containing filter text in their label.\n * TODO: Return results in pages\n * @public\n */\n public async getFilteredNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getFilteredNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\n * its related instances for loading related and navigation properties.\n * @public\n */\n public async getContentSources(\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\n ): Promise<SelectClassInfo[]> {\n return this._detail.getContentSources(requestOptions);\n }\n\n /**\n * Retrieves the content descriptor which can be used to get content\n * @public\n */\n public async getContentDescriptor(\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getContentDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves the content set size based on the supplied content descriptor override\n * @public\n */\n public async getContentSetSize(\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getContentSetSize(requestOptions);\n }\n\n private createContentFormatter({ imodel, unitSystem }: { imodel: IModelDb; unitSystem?: UnitSystemKey }): ContentFormatter {\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(imodel), this.props.defaultFormats);\n return new ContentFormatter(new ContentPropertyValueFormatter(koqPropertyFormatter), unitSystem ?? this.props.defaultUnitSystem);\n }\n\n /**\n * Retrieves the content set based on the supplied content descriptor.\n * @public\n */\n public async getContentSet(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Item[]> {\n let items = await this._detail.getContentSet(requestOptions);\n\n if (!requestOptions.omitFormattedValues) {\n const formatter = this.createContentFormatter(requestOptions);\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\n }\n\n return this._localizationHelper.getLocalizedContentItems(items);\n }\n\n /**\n * Retrieves the content based on the supplied content descriptor override.\n * @public\n */\n public async getContent(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\n BackendDiagnosticsAttribute,\n ): Promise<Content | undefined> {\n const content = await this._detail.getContent(requestOptions);\n if (!content) {\n return undefined;\n }\n\n if (!requestOptions.omitFormattedValues) {\n const formatter = this.createContentFormatter(requestOptions);\n await formatter.formatContent(content);\n }\n\n return this._localizationHelper.getLocalizedContent(content);\n }\n\n /**\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\n * @param requestOptions Options for the request\n * @return A promise object that returns either distinct values on success or an error string on error.\n * @public\n */\n public async getPagedDistinctValues(\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<PagedResponse<DisplayValueGroup>> {\n const result = await this._detail.getPagedDistinctValues(requestOptions);\n return {\n ...result,\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\n };\n }\n\n /**\n * Retrieves property data in a simplified format for a single element specified by ID.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined>;\n /**\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\n > &\n BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\n }\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\n }\n\n private async getSingleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const content = await this.getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return parser(content.descriptor, content.contentSet[0]);\n }\n\n private async getMultipleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;\n\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\n\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\n // most `workerThreadsCount / 2` classes in parallel.\n /* c8 ignore next */\n const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;\n\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\n // To avoid that, we keep twice as much requests active.\n /* c8 ignore next */\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;\n\n /* c8 ignore next */\n const batchSize = batchSizeOption ?? 100;\n\n const elementsIdentifier = ((): { elementIds: Id64Array } | { elementClasses: string[] } => {\n if (\"elementIds\" in contentOptions && contentOptions.elementIds !== undefined) {\n const elementIds = contentOptions.elementIds;\n delete contentOptions.elementIds;\n return { elementIds };\n }\n if (\"elementClasses\" in contentOptions && contentOptions.elementClasses !== undefined) {\n const elementClasses = contentOptions.elementClasses;\n delete contentOptions.elementClasses;\n return { elementClasses };\n }\n /* c8 ignore next */\n return { elementClasses: [\"BisCore:Element\"] };\n })();\n\n const descriptorGetter = async (partialProps: Pick<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\">) =>\n this.getContentDescriptor({ ...contentOptions, displayType: DefaultContentDisplayTypes.Grid, contentFlags: ContentFlags.ShowLabels, ...partialProps });\n const contentSetGetter = async (\n partialProps: Pick<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\" | \"descriptor\">,\n ) => this.getContentSet({ ...contentOptions, ...partialProps });\n const { itemBatches, count } =\n \"elementIds\" in elementsIdentifier\n ? getContentItemsObservableFromElementIds(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementIds,\n classParallelism,\n batchesParallelism,\n batchSize,\n )\n : getContentItemsObservableFromClassNames(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementClasses,\n classParallelism,\n batchesParallelism,\n batchSize,\n );\n return {\n total: await firstValueFrom(count),\n async *iterator() {\n for await (const itemsBatch of eachValueFrom(itemBatches)) {\n const { descriptor, items } = itemsBatch;\n yield items.map((item) => parser(descriptor, item));\n }\n },\n };\n }\n\n /**\n * Retrieves display label definition of specific item\n * @public\n */\n public async getDisplayLabelDefinition(\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition> {\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\n }\n\n /**\n * Retrieves display label definitions of specific items\n * @public\n */\n public async getDisplayLabelDefinitions(\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition[]> {\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\n }\n\n /**\n * Retrieves available selection scopes.\n * @public\n * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\n return SelectionScopesHelper.getSelectionScopes();\n }\n\n /**\n * Computes selection based on provided element IDs and selection scope.\n * @public\n * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet> {\n return SelectionScopesHelper.computeSelection(requestOptions);\n }\n\n /**\n * Compares two hierarchies specified in the request options\n * @public\n */\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\n return { changes: [] };\n }\n\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\n this._detail.registerRuleset(rulesetOrId);\n\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\n }\n\n const currRulesetVariables = rulesetVariables ?? [];\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\n\n const params = {\n requestId: NativePlatformRequestTypes.CompareHierarchies,\n ...options,\n prevRulesetId: prevRulesetId.uniqueId,\n currRulesetId: currRulesetId.uniqueId,\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\n currRulesetVariables: JSON.stringify(currRulesetVariables),\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\n };\n return JSON.parse(await this._detail.request(params));\n }\n}\n"]}
1
+ {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAsC;AACtC,mDAA+C;AAK/C,oEA6CoC;AACpC,kEAO6C;AAC7C,6EAAgI;AAChI,6DAAoE;AACpE,2DAAiE;AACjE,iFAA+F;AAE/F,6EAAoG;AACpG,yEAAmE;AACnE,yCAA0G;AAE1G;;;GAGG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IACjB;;;OAGG;IACH,mCAAa,CAAA;IACb;;;;;OAKG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAjBW,kBAAkB,kCAAlB,kBAAkB,QAiB7B;AAqPD;;;;;GAKG;AACH,MAAa,mBAAmB;IACtB,MAAM,CAA2B;IACjC,OAAO,CAA4B;IACnC,mBAAmB,CAAqB;IACxC,sBAAsB,CAAsC;IAEpE;;;OAGG;IACH,YAAY,KAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,wDAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,mBAAmB,GAAG,IAAI,6BAAkB,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,IAAI,+BAAoB,EAAE,CAAC,CAAC;QAC7H,4DAA4D;QAC5D,IAAI,CAAC,sBAAsB,GAAG,KAAK,EAA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E3E,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,8CAA0B,CAAC,kBAAkB;YACxD,GAAG,OAAO;YACV,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,aAAa,EAAE,aAAa,CAAC,QAAQ;YACrC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;YAC1D,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;SACjE,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;CACF;AAraD,kDAqaC","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 Core\n */\n\nimport { firstValueFrom } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { BeEvent, Id64Array } from \"@itwin/core-bentley\";\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\nimport {\n UnitSystemFormat as CommonUnitSystemFormat,\n ComputeSelectionRequestOptions,\n Content,\n ContentDescriptorRequestOptions,\n ContentFlags,\n ContentRequestOptions,\n ContentSourcesRequestOptions,\n DefaultContentDisplayTypes,\n Descriptor,\n DescriptorOverrides,\n DisplayLabelRequestOptions,\n DisplayLabelsRequestOptions,\n DisplayValueGroup,\n DistinctValuesRequestOptions,\n ElementProperties,\n FilterByInstancePathsHierarchyRequestOptions,\n FilterByTextHierarchyRequestOptions,\n FormatsMap,\n HierarchyCompareInfo,\n HierarchyCompareOptions,\n HierarchyLevel,\n HierarchyLevelDescriptorRequestOptions,\n HierarchyRequestOptions,\n InstanceKey,\n Item,\n KeySet,\n KoqPropertyValueFormatter,\n LabelDefinition,\n MultiElementPropertiesRequestOptions,\n Node,\n NodeKey,\n NodePathElement,\n Paged,\n PagedResponse,\n PresentationError,\n PresentationStatus,\n Prioritized,\n Ruleset,\n RulesetVariable,\n SelectClassInfo,\n SelectionScope,\n SelectionScopeRequestOptions,\n SingleElementPropertiesRequestOptions,\n WithCancelEvent,\n} from \"@itwin/presentation-common\";\nimport {\n buildElementProperties,\n ContentFormatter,\n ContentPropertyValueFormatter,\n deepReplaceNullsToUndefined,\n isSingleElementPropertiesRequestOptions,\n LocalizationHelper,\n} from \"@itwin/presentation-common/internal\";\nimport { getContentItemsObservableFromClassNames, getContentItemsObservableFromElementIds } from \"./ElementPropertiesHelper.js\";\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\nimport { NativePlatformRequestTypes } from \"./NativePlatform.js\";\nimport { getRulesetIdObject, PresentationManagerDetail } from \"./PresentationManagerDetail.js\";\nimport { RulesetManager } from \"./RulesetManager.js\";\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager.js\";\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper.js\";\nimport { BackendDiagnosticsAttribute, BackendDiagnosticsOptions, getLocalizedStringEN } from \"./Utils.js\";\n\n/**\n * Presentation hierarchy cache mode.\n * @public\n */\nexport enum HierarchyCacheMode {\n /**\n * Hierarchy cache is created in memory.\n */\n Memory = \"memory\",\n /**\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\n * openings.\n */\n Disk = \"disk\",\n /**\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\n * and persisted in disk cache when whole hierarchy level is created.\n *\n * **Note:** This mode is still experimental.\n */\n Hybrid = \"hybrid\",\n}\n\n/**\n * Configuration for hierarchy cache.\n * @public\n */\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\n\n/**\n * Base interface for all [[HierarchyCacheConfig]] implementations.\n * @public\n */\nexport interface HierarchyCacheConfigBase {\n mode: HierarchyCacheMode;\n}\n\n/**\n * Configuration for in-memory hierarchy cache.\n *\n * @see [Memory cache documentation page]($docs/presentation/advanced/Caching.md#memory-cache)\n * @public\n */\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Memory;\n}\n\n/**\n * Configuration for persistent disk hierarchy cache.\n *\n * @see [Disk cache documentation page]($docs/presentation/advanced/Caching.md#disk-cache)\n * @public\n */\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Disk;\n\n /**\n * A directory for hierarchy caches. If set, the directory must exist. Relative paths start from `process.cwd()`.\n *\n * The default directory depends on the iModel and the way it's opened.\n */\n directory?: string;\n\n /**\n * While the cache itself is stored on a disk, there's still a required small in-memory cache.\n * The parameter allows controlling size of that cache. Defaults to `32768000` bytes (32 MB).\n */\n memoryCacheSize?: number;\n}\n\n/**\n * Configuration for the experimental hybrid hierarchy cache.\n *\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\n * alternative for cases when there are lots of simultaneous requests.\n *\n * @see [Hybrid cache documentation page]($docs/presentation/advanced/Caching.md#hybrid-cache)\n * @public\n */\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Hybrid;\n\n /** Configuration for disk cache used to persist hierarchies. */\n disk?: DiskHierarchyCacheConfig;\n}\n\n/**\n * Configuration for content cache.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n * @public\n */\nexport interface ContentCacheConfig {\n /**\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\n *\n * Defaults to `100`.\n */\n size?: number;\n}\n\n/**\n * Caching configuration options for [[PresentationManager]].\n * @public\n */\nexport interface PresentationManagerCachingConfig {\n /**\n * Hierarchies-related caching options.\n *\n * @see [Hierarchies cache documentation page]($docs/presentation/advanced/Caching.md#hierarchies-cache)\n */\n hierarchies?: HierarchyCacheConfig;\n\n /**\n * Content-related caching options.\n *\n * @see [Content cache documentation page]($docs/presentation/advanced/Caching.md#content-cache)\n */\n content?: ContentCacheConfig;\n\n /**\n * Each worker thread (see [[workerThreadsCount]]) opens a connection to an iModel used for a request. This\n * means there could be `{workerThreadsCount} * {iModels count}` number of connections. Each connection\n * uses a memory cache to increase iModel read performance. This parameter allows controlling the size of that\n * cache. Defaults to `32768000` bytes (32 MB).\n *\n * @see [Worker connections cache documentation page]($docs/presentation/advanced/Caching.md#worker-connections-cache)\n */\n workerConnectionCacheSize?: number;\n}\n\n/**\n * A data structure that associates unit systems with a format. The associations are used for\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\n *\n * @public\n * @deprecated in 4.3 - might be removed in next major version. The type has been moved to `@itwin/presentation-common` package.\n */\nexport type UnitSystemFormat = CommonUnitSystemFormat;\n\n/**\n * Data structure for multiple element properties request response.\n * @public\n */\nexport interface MultiElementPropertiesResponse<TParsedContent = ElementProperties> {\n total: number;\n iterator: () => AsyncGenerator<TParsedContent[]>;\n}\n\n/**\n * Configuration options for supplying asset paths to [[PresentationManager]].\n * @public\n */\nexport interface PresentationAssetsRootConfig {\n /**\n * Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.\n */\n backend: string;\n}\n\n/**\n * Properties that can be used to configure [[PresentationManager]]\n * @public\n */\nexport interface PresentationManagerProps {\n /**\n * Path overrides for presentation backend assets. Need to be overriden by application if it puts these assets someplace else than the default.\n *\n * By default the path to assets directory is determined during the call of [[Presentation.initialize]] using this algorithm:\n *\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\n * - `assets/*\\*\\/*`\n * - `presentation-backend/{presentation-backend source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\n *\n * - else, assume the backend is webpacked into a single file with assets next to it:\n * - `assets/*\\*\\/*`\n * - `{source file being executed}.js`\n *\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\n *\n * @deprecated in 4.2 - might be removed in next major version. This attribute is not used anymore - the package is not using private assets anymore.\n */\n presentationAssetsRoot?: string | PresentationAssetsRootConfig;\n\n /**\n * A list of directories containing application's presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n rulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's supplemental presentation rulesets. Relative\n * paths start from `process.cwd()`. The directories are traversed recursively.\n *\n * @note Only files with `.PresentationRuleSet.json` are read.\n */\n supplementalRulesetDirectories?: string[];\n\n /**\n * Sets the active unit system to use for formatting property values with\n * units. Default presentation units are used if this is not specified. The active unit\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\n * through request options.\n */\n defaultUnitSystem?: UnitSystemKey;\n\n /**\n * A map of default unit formats to use for formatting properties that don't have a presentation format\n * in requested unit system.\n */\n defaultFormats?: FormatsMap;\n\n /**\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\n */\n workerThreadsCount?: number;\n\n /**\n * The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation\n * data changes are not tracked at all.\n *\n * @beta\n * @deprecated in 4.4 - might be removed in next major version. The manager now always tracks for iModel data changes without polling.\n */\n updatesPollInterval?: number;\n\n /** Options for caching. */\n caching?: PresentationManagerCachingConfig;\n\n /**\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\n *\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\n */\n useMmap?: boolean | number;\n\n /**\n * Localization function to localize data returned by presentation manager when it's used directly on the backend (as opposed to when used through RPC, where\n * data is localized on the frontend). Defaults to English localization.\n *\n * @see [Localization]($docs/presentation/advanced/Localization)\n */\n getLocalizedString?: (key: string) => string;\n\n /**\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelDb]($core-backend).\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\n *\n * @deprecated in 5.1. [IModelDb.schemaContext]($core-backend) is now used by default instead.\n */\n schemaContextProvider?: (imodel: IModelDb) => SchemaContext;\n\n /**\n * Parameters for gathering diagnostics at the manager level. When supplied, they're used with every request\n * made through the manager.\n *\n * @see [Diagnostics documentation page]($docs/presentation/advanced/Diagnostics.md)\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/**\n * Backend Presentation manager which pulls the presentation data from\n * an iModel using native platform.\n *\n * @public\n */\nexport class PresentationManager {\n private _props: PresentationManagerProps;\n private _detail: PresentationManagerDetail;\n private _localizationHelper: LocalizationHelper;\n private _schemaContextProvider: (imodel: IModelDb) => SchemaContext;\n\n /**\n * Creates an instance of PresentationManager.\n * @param props Optional configuration properties.\n */\n constructor(props?: PresentationManagerProps) {\n this._props = props ?? {};\n this._detail = new PresentationManagerDetail(this._props);\n this._localizationHelper = new LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? getLocalizedStringEN });\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n this._schemaContextProvider = props?.schemaContextProvider ?? ((imodel: IModelDb) => imodel.schemaContext);\n }\n\n /** Get / set active unit system used to format property values with units */\n public get activeUnitSystem(): UnitSystemKey | undefined {\n return this._detail.activeUnitSystem;\n }\n /* c8 ignore next 3 */\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\n this._detail.activeUnitSystem = value;\n }\n\n /** Dispose the presentation manager. Must be called to clean up native resources. */\n public [Symbol.dispose]() {\n this._detail[Symbol.dispose]();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n /* c8 ignore next 3 */\n public dispose() {\n this[Symbol.dispose]();\n }\n\n /** An event, that this manager raises whenever any request is made on it. */\n public get onUsed(): BeEvent<() => void> {\n return this._detail.onUsed;\n }\n\n /** Properties used to initialize the manager */\n public get props() {\n return this._props;\n }\n\n /** Get rulesets manager */\n public rulesets(): RulesetManager {\n return this._detail.rulesets;\n }\n\n /**\n * Get ruleset variables manager for specific ruleset\n * @param rulesetId Id of the ruleset to get variables manager for\n */\n public vars(rulesetId: string): RulesetVariablesManager {\n return new RulesetVariablesManagerImpl(() => this._detail.getNativePlatform(), rulesetId);\n }\n\n /** @internal */\n /* c8 ignore next 3 */\n public get [_presentation_manager_detail](): PresentationManagerDetail {\n return this._detail;\n }\n\n public getRulesetId(rulesetOrId: Ruleset | string) {\n return this._detail.getRulesetId(rulesetOrId);\n }\n\n /**\n * Retrieves nodes\n * @public\n */\n public async getNodes(\n requestOptions: WithCancelEvent<Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Node[]> {\n const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);\n const hierarchyLevel: HierarchyLevel = deepReplaceNullsToUndefined(JSON.parse(serializedHierarchyLevel));\n return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);\n }\n\n /**\n * Retrieves nodes count\n * @public\n */\n public async getNodesCount(\n requestOptions: WithCancelEvent<Prioritized<HierarchyRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getNodesCount(requestOptions);\n }\n\n /**\n * Retrieves hierarchy level descriptor\n * @public\n */\n public async getNodesDescriptor(\n requestOptions: WithCancelEvent<Prioritized<HierarchyLevelDescriptorRequestOptions<IModelDb, NodeKey, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getNodesDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\n * TODO: Return results in pages\n * @public\n */\n public async getNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Retrieves paths from root nodes to nodes containing filter text in their label.\n * TODO: Return results in pages\n * @public\n */\n public async getFilteredNodePaths(\n requestOptions: WithCancelEvent<Prioritized<FilterByTextHierarchyRequestOptions<IModelDb, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<NodePathElement[]> {\n const result = await this._detail.getFilteredNodePaths(requestOptions);\n return result.map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\n }\n\n /**\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\n * its related instances for loading related and navigation properties.\n * @public\n */\n public async getContentSources(\n requestOptions: WithCancelEvent<Prioritized<ContentSourcesRequestOptions<IModelDb>>> & BackendDiagnosticsAttribute,\n ): Promise<SelectClassInfo[]> {\n return this._detail.getContentSources(requestOptions);\n }\n\n /**\n * Retrieves the content descriptor which can be used to get content\n * @public\n */\n public async getContentDescriptor(\n requestOptions: WithCancelEvent<Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>>> & BackendDiagnosticsAttribute,\n ): Promise<Descriptor | undefined> {\n const response = await this._detail.getContentDescriptor(requestOptions);\n const descriptor = Descriptor.fromJSON(JSON.parse(response));\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\n }\n\n /**\n * Retrieves the content set size based on the supplied content descriptor override\n * @public\n */\n public async getContentSetSize(\n requestOptions: WithCancelEvent<Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<number> {\n return this._detail.getContentSetSize(requestOptions);\n }\n\n private createContentFormatter({ imodel, unitSystem }: { imodel: IModelDb; unitSystem?: UnitSystemKey }): ContentFormatter {\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(imodel), this.props.defaultFormats);\n return new ContentFormatter(new ContentPropertyValueFormatter(koqPropertyFormatter), unitSystem ?? this.props.defaultUnitSystem);\n }\n\n /**\n * Retrieves the content set based on the supplied content descriptor.\n * @public\n */\n public async getContentSet(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>>>> & BackendDiagnosticsAttribute,\n ): Promise<Item[]> {\n let items = await this._detail.getContentSet(requestOptions);\n\n if (!requestOptions.omitFormattedValues) {\n const formatter = this.createContentFormatter(requestOptions);\n items = await formatter.formatContentItems(items, requestOptions.descriptor);\n }\n\n return this._localizationHelper.getLocalizedContentItems(items);\n }\n\n /**\n * Retrieves the content based on the supplied content descriptor override.\n * @public\n */\n public async getContent(\n requestOptions: WithCancelEvent<Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>>> &\n BackendDiagnosticsAttribute,\n ): Promise<Content | undefined> {\n const content = await this._detail.getContent(requestOptions);\n if (!content) {\n return undefined;\n }\n\n if (!requestOptions.omitFormattedValues) {\n const formatter = this.createContentFormatter(requestOptions);\n await formatter.formatContent(content);\n }\n\n return this._localizationHelper.getLocalizedContent(content);\n }\n\n /**\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\n * @param requestOptions Options for the request\n * @return A promise object that returns either distinct values on success or an error string on error.\n * @public\n */\n public async getPagedDistinctValues(\n requestOptions: WithCancelEvent<Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>>> &\n BackendDiagnosticsAttribute,\n ): Promise<PagedResponse<DisplayValueGroup>> {\n const result = await this._detail.getPagedDistinctValues(requestOptions);\n return {\n ...result,\n items: result.items.map((g) => this._localizationHelper.getLocalizedDisplayValueGroup(g)),\n };\n }\n\n /**\n * Retrieves property data in a simplified format for a single element specified by ID.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined>;\n /**\n * Retrieves property data in simplified format for multiple elements specified by class or all element.\n * @return An object that contains element count and AsyncGenerator to iterate over properties of those elements in batches of undefined size.\n * @public\n */\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>>;\n public async getElementProperties<TParsedContent = ElementProperties>(\n requestOptions: WithCancelEvent<\n Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent> | MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>\n > &\n BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined | MultiElementPropertiesResponse<TParsedContent>> {\n if (isSingleElementPropertiesRequestOptions(requestOptions)) {\n return this.getSingleElementProperties<TParsedContent>(requestOptions);\n }\n return this.getMultipleElementProperties<TParsedContent>(requestOptions);\n }\n\n private async getSingleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<SingleElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<TParsedContent | undefined> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const content = await this.getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n if (!content || content.contentSet.length === 0) {\n return undefined;\n }\n return parser(content.descriptor, content.contentSet[0]);\n }\n\n private async getMultipleElementProperties<TParsedContent>(\n requestOptions: WithCancelEvent<Prioritized<MultiElementPropertiesRequestOptions<IModelDb, TParsedContent>>> & BackendDiagnosticsAttribute,\n ): Promise<MultiElementPropertiesResponse<TParsedContent>> {\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\n const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;\n\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\n const workerThreadsCount = this._props.workerThreadsCount ?? 2;\n\n // We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory\n // and can be shared across all batch requests for that class. Handling multiple classes at the same time not only increases memory footprint,\n // but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at\n // most `workerThreadsCount / 2` classes in parallel.\n /* c8 ignore next */\n const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;\n\n // We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,\n // but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.\n // To avoid that, we keep twice as much requests active.\n /* c8 ignore next */\n const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;\n\n /* c8 ignore next */\n const batchSize = batchSizeOption ?? 100;\n\n const elementsIdentifier = ((): { elementIds: Id64Array } | { elementClasses: string[] } => {\n if (\"elementIds\" in contentOptions && contentOptions.elementIds !== undefined) {\n const elementIds = contentOptions.elementIds;\n delete contentOptions.elementIds;\n return { elementIds };\n }\n if (\"elementClasses\" in contentOptions && contentOptions.elementClasses !== undefined) {\n const elementClasses = contentOptions.elementClasses;\n delete contentOptions.elementClasses;\n return { elementClasses };\n }\n /* c8 ignore next */\n return { elementClasses: [\"BisCore:Element\"] };\n })();\n\n const descriptorGetter = async (partialProps: Pick<ContentDescriptorRequestOptions<IModelDb, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\">) =>\n this.getContentDescriptor({ ...contentOptions, displayType: DefaultContentDisplayTypes.Grid, contentFlags: ContentFlags.ShowLabels, ...partialProps });\n const contentSetGetter = async (\n partialProps: Pick<ContentRequestOptions<IModelDb, Descriptor, KeySet, RulesetVariable>, \"rulesetOrId\" | \"keys\" | \"descriptor\">,\n ) => this.getContentSet({ ...contentOptions, ...partialProps });\n const { itemBatches, count } =\n \"elementIds\" in elementsIdentifier\n ? getContentItemsObservableFromElementIds(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementIds,\n classParallelism,\n batchesParallelism,\n batchSize,\n )\n : getContentItemsObservableFromClassNames(\n requestOptions.imodel,\n descriptorGetter,\n contentSetGetter,\n elementsIdentifier.elementClasses,\n classParallelism,\n batchesParallelism,\n batchSize,\n );\n return {\n total: await firstValueFrom(count),\n async *iterator() {\n for await (const itemsBatch of eachValueFrom(itemBatches)) {\n const { descriptor, items } = itemsBatch;\n yield items.map((item) => parser(descriptor, item));\n }\n },\n };\n }\n\n /**\n * Retrieves display label definition of specific item\n * @public\n */\n public async getDisplayLabelDefinition(\n requestOptions: WithCancelEvent<Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition> {\n const labelDefinition = await this._detail.getDisplayLabelDefinition(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinition(labelDefinition);\n }\n\n /**\n * Retrieves display label definitions of specific items\n * @public\n */\n public async getDisplayLabelDefinitions(\n requestOptions: WithCancelEvent<Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>> & BackendDiagnosticsAttribute,\n ): Promise<LabelDefinition[]> {\n const labelDefinitions = await this._detail.getDisplayLabelDefinitions(requestOptions);\n return this._localizationHelper.getLocalizedLabelDefinitions(labelDefinitions);\n }\n\n /**\n * Retrieves available selection scopes.\n * @public\n * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]> {\n return SelectionScopesHelper.getSelectionScopes();\n }\n\n /**\n * Computes selection based on provided element IDs and selection scope.\n * @public\n * @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public async computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet> {\n return SelectionScopesHelper.computeSelection(requestOptions);\n }\n\n /**\n * Compares two hierarchies specified in the request options\n * @public\n */\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables) {\n return { changes: [] };\n }\n\n const { rulesetOrId, prev, rulesetVariables, ...options } = requestOptions;\n this._detail.registerRuleset(rulesetOrId);\n\n const currRulesetId = getRulesetIdObject(requestOptions.rulesetOrId);\n const prevRulesetId = prev.rulesetOrId ? getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\n if (prevRulesetId.parts.id !== currRulesetId.parts.id) {\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\n }\n\n const currRulesetVariables = rulesetVariables ?? [];\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\n\n const params = {\n requestId: NativePlatformRequestTypes.CompareHierarchies,\n ...options,\n prevRulesetId: prevRulesetId.uniqueId,\n currRulesetId: currRulesetId.uniqueId,\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\n currRulesetVariables: JSON.stringify(currRulesetVariables),\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\n };\n return JSON.parse(await this._detail.request(params));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionScopesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;;;AAGH,sDAAkE;AAClE,oDAAiD;AACjD,oEAQoC;AACpC,yCAA2C;AAE3C;;;;;GAKG;AACH,MAAa,qBAAqB;IAChC,oBAAoB;IACpB,gBAAwB,CAAC;IAElB,MAAM,CAAC,kBAAkB;QAC9B,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,KAAa,EAAE,WAAmB,EAAkB,EAAE,CAAC,CAAC;YACrG,EAAE,EAAE,OAAO;YACX,KAAK;YACL,WAAW;SACZ,CAAC,CAAC;QACH,OAAO;YACL,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,2BAA2B,CAAC;YACvE,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,qCAAqC,CAAC;YACnF,oBAAoB,CAAC,cAAc,EAAE,cAAc,EAAE,iDAAiD,CAAC;YACvG,gHAAgH;YAChH,wGAAwG;YACxG,+FAA+F;SAChG,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,MAAgB,EAAE,SAAqB,EAAE,aAAqB;QACzF,IAAI,MAAM,GAAG,SAAS,CAAC;QACvB,IAAI,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;QACtE,OAAO,QAAQ,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;YACvC,MAAM,GAAG,QAAQ,CAAC;YAClB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;YAClE,EAAE,aAAa,CAAC;QAClB,CAAC;QACD,OAAO,IAAA,wBAAa,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,u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ND,sDA4NC;AAED,KAAK,UAAU,qBAAqB,CAAC,GAAc,EAAE,QAA2C;IAC9F,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,mBAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/no-deprecated */\n/** @packageDocumentation\n * @module Core\n */\n\nimport { GeometricElement, IModelDb } from \"@itwin/core-backend\";\nimport { Id64, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { QueryBinder } from \"@itwin/core-common\";\nimport {\n ComputeSelectionRequestOptions,\n ElementSelectionScopeProps,\n InstanceKey,\n KeySet,\n PresentationError,\n PresentationStatus,\n SelectionScope,\n} from \"@itwin/presentation-common\";\nimport { getElementKey } from \"./Utils.js\";\n\n/**\n * Contains helper methods for computing selection scopes. Will get removed\n * once rules-driven scopes are implemented.\n *\n * @internal\n */\nexport class SelectionScopesHelper {\n /* c8 ignore next */\n private constructor() { }\n\n public static getSelectionScopes(): SelectionScope[] {\n const createSelectionScope = (scopeId: string, label: string, description: string): SelectionScope => ({\n id: scopeId,\n label,\n description,\n });\n return [\n createSelectionScope(\"element\", \"Element\", \"Select the picked element\"),\n createSelectionScope(\"assembly\", \"Assembly\", \"Select parent of the picked element\"),\n createSelectionScope(\"top-assembly\", \"Top Assembly\", \"Select the topmost parent of the picked element\"),\n // WIP: temporarily comment-out \"category\" and \"model\" scopes since we can't hilite contents of them fast enough\n // createSelectionScope(\"category\", \"Category\", \"Select all elements in the picked element's category\"),\n // createSelectionScope(\"model\", \"Model\", \"Select all elements in the picked element's model\"),\n ];\n }\n\n private static getElementKey(iModel: IModelDb, elementId: Id64String, ancestorLevel: number) {\n let currId = elementId;\n let parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n while (parentId && ancestorLevel !== 0) {\n currId = parentId;\n parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n --ancestorLevel;\n }\n return getElementKey(iModel, currId);\n }\n\n private static async computeElementSelection(iModel: IModelDb, elementIds: Id64String[], ancestorLevel: number) {\n const parentKeys = new KeySet();\n await forEachNonTransientId(elementIds, async (id) => {\n const key = this.getElementKey(iModel, id, ancestorLevel);\n key && parentKeys.add(key);\n });\n return parentKeys;\n }\n\n private static async computeCategorySelection(iModel: IModelDb, ids: Id64String[]) {\n const categoryKeys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n const el = iModel.elements.tryGetElement<GeometricElement>(id);\n const category = el?.category ? iModel.elements.tryGetElementProps(el.category) : undefined;\n if (category) {\n categoryKeys.add({ className: category.classFullName, id: category.id! });\n }\n });\n return categoryKeys;\n }\n\n private static async computeModelSelection(iModel: IModelDb, ids: Id64String[]) {\n const modelKeys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n const el = iModel.elements.tryGetElementProps(id);\n const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;\n if (model) {\n modelKeys.add({ className: model.classFullName, id: model.id! });\n }\n });\n return modelKeys;\n }\n\n private static async getRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): Promise<InstanceKey | undefined> {\n const query = `\n SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId\n FROM bis.Element e\n LEFT JOIN func.PhysicalElementFulfillsFunction rel1 ON rel1.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.DrawingGraphicRepresentsFunctionalElement rel2 ON rel2.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.FunctionalElement fe ON fe.ECInstanceId IN (rel1.TargetECInstanceId, rel2.TargetECInstanceId)\n INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId\n INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id\n WHERE e.ECInstanceId = ?\n `;\n\n const bindings = new QueryBinder();\n bindings.bindId(1, graphicalElementId);\n\n for await (const row of imodel.createQueryReader(query, bindings)) {\n if (row.funcElClassName && row.funcElId) {\n return { className: row.funcElClassName.replace(\".\", \":\"), id: row.funcElId };\n }\n }\n return undefined;\n }\n\n private static async findFirstRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): Promise<InstanceKey | undefined> {\n let currId: Id64String | undefined = graphicalElementId;\n while (currId) {\n const relatedFunctionalKey = await this.getRelatedFunctionalElementKey(imodel, currId);\n if (relatedFunctionalKey) {\n return relatedFunctionalKey;\n }\n currId = imodel.elements.tryGetElementProps(currId)?.parent?.id;\n }\n return undefined;\n }\n\n private static async elementClassDerivesFrom(imodel: IModelDb, elementId: Id64String, baseClassFullName: string): Promise<boolean> {\n const query = `\n SELECT 1\n FROM bis.Element e\n INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId\n INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\n INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\n WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?\n `;\n\n const bindings = new QueryBinder();\n bindings.bindId(1, elementId);\n bindings.bindString(2, baseClassFullName);\n\n for await (const _ of imodel.createQueryReader(query, bindings)) {\n return true;\n }\n return false;\n }\n\n private static async computeFunctionalElementSelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n const is3d = await this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = await this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n keys.add(firstFunctionalKey);\n return;\n }\n }\n let keyToAdd: InstanceKey | undefined;\n if (is3d) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n keyToAdd = await this.getRelatedFunctionalElementKey(iModel, id);\n }\n if (!keyToAdd) {\n keyToAdd = getElementKey(iModel, id);\n }\n keyToAdd && keys.add(keyToAdd);\n });\n return keys;\n }\n\n private static async computeFunctionalAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n let idToGetAssemblyFor = id;\n const is3d = await this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = await this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the assembly of either the given element or the functional element\n const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);\n let keyToAdd = assemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = await this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n });\n return keys;\n }\n\n private static async computeFunctionalTopAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n let idToGetAssemblyFor = id;\n const is3d = await this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = await this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the top assembly of either the given element or the functional element\n const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);\n let keyToAdd = topAssemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = await this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n });\n return keys;\n }\n\n public static async computeSelection({ imodel, scope, elementIds }: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet> {\n switch (scope.id) {\n case \"element\":\n return this.computeElementSelection(imodel, elementIds, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n case \"assembly\":\n return this.computeElementSelection(imodel, elementIds, 1);\n case \"top-assembly\":\n return this.computeElementSelection(imodel, elementIds, Number.MAX_SAFE_INTEGER);\n case \"category\":\n return this.computeCategorySelection(imodel, elementIds);\n case \"model\":\n return this.computeModelSelection(imodel, elementIds);\n case \"functional\":\n case \"functional-element\":\n return this.computeFunctionalElementSelection(imodel, elementIds);\n case \"functional-assembly\":\n return this.computeFunctionalAssemblySelection(imodel, elementIds);\n case \"functional-top-assembly\":\n return this.computeFunctionalTopAssemblySelection(imodel, elementIds);\n }\n throw new PresentationError(PresentationStatus.InvalidArgument, \"scopeId\");\n }\n}\n\nasync function forEachNonTransientId(ids: Id64Array, callback: (id: Id64String) => Promise<void>): Promise<void> {\n await Promise.all(ids.filter((id) => !Id64.isTransient(id)).map(callback));\n}\n"]}
1
+ {"version":3,"file":"SelectionScopesHelper.js","sourceRoot":"","sources":["../../../src/presentation-backend/SelectionScopesHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;;;AAGH,sDAAkE;AAClE,oDAAiD;AACjD,oEAQoC;AACpC,yCAA2C;AAE3C;;;;;GAKG;AACH,MAAa,qBAAqB;IAChC,oBAAoB;IACpB,gBAAuB,CAAC;IAEjB,MAAM,CAAC,kBAAkB;QAC9B,MAAM,oBA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AC;YACjB,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAG,KAAoC,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;YACpH,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YAC7D,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACnF,KAAK,UAAU;gBACb,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YAC3D,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACxD,KAAK,YAAY,CAAC;YAClB,KAAK,oBAAoB;gBACvB,OAAO,IAAI,CAAC,iCAAiC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACpE,KAAK,qBAAqB;gBACxB,OAAO,IAAI,CAAC,kCAAkC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACrE,KAAK,yBAAyB;gBAC5B,OAAO,IAAI,CAAC,qCAAqC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC7E,CAAC;CACF;AA5ND,sDA4NC;AAED,KAAK,UAAU,qBAAqB,CAAC,GAAc,EAAE,QAA2C;IAC9F,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,mBAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/no-deprecated */\n/** @packageDocumentation\n * @module Core\n */\n\nimport { GeometricElement, IModelDb } from \"@itwin/core-backend\";\nimport { Id64, Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport { QueryBinder } from \"@itwin/core-common\";\nimport {\n ComputeSelectionRequestOptions,\n ElementSelectionScopeProps,\n InstanceKey,\n KeySet,\n PresentationError,\n PresentationStatus,\n SelectionScope,\n} from \"@itwin/presentation-common\";\nimport { getElementKey } from \"./Utils.js\";\n\n/**\n * Contains helper methods for computing selection scopes. Will get removed\n * once rules-driven scopes are implemented.\n *\n * @internal\n */\nexport class SelectionScopesHelper {\n /* c8 ignore next */\n private constructor() {}\n\n public static getSelectionScopes(): SelectionScope[] {\n const createSelectionScope = (scopeId: string, label: string, description: string): SelectionScope => ({\n id: scopeId,\n label,\n description,\n });\n return [\n createSelectionScope(\"element\", \"Element\", \"Select the picked element\"),\n createSelectionScope(\"assembly\", \"Assembly\", \"Select parent of the picked element\"),\n createSelectionScope(\"top-assembly\", \"Top Assembly\", \"Select the topmost parent of the picked element\"),\n // WIP: temporarily comment-out \"category\" and \"model\" scopes since we can't hilite contents of them fast enough\n // createSelectionScope(\"category\", \"Category\", \"Select all elements in the picked element's category\"),\n // createSelectionScope(\"model\", \"Model\", \"Select all elements in the picked element's model\"),\n ];\n }\n\n private static getElementKey(iModel: IModelDb, elementId: Id64String, ancestorLevel: number) {\n let currId = elementId;\n let parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n while (parentId && ancestorLevel !== 0) {\n currId = parentId;\n parentId = iModel.elements.tryGetElementProps(currId)?.parent?.id;\n --ancestorLevel;\n }\n return getElementKey(iModel, currId);\n }\n\n private static async computeElementSelection(iModel: IModelDb, elementIds: Id64String[], ancestorLevel: number) {\n const parentKeys = new KeySet();\n await forEachNonTransientId(elementIds, async (id) => {\n const key = this.getElementKey(iModel, id, ancestorLevel);\n key && parentKeys.add(key);\n });\n return parentKeys;\n }\n\n private static async computeCategorySelection(iModel: IModelDb, ids: Id64String[]) {\n const categoryKeys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n const el = iModel.elements.tryGetElement<GeometricElement>(id);\n const category = el?.category ? iModel.elements.tryGetElementProps(el.category) : undefined;\n if (category) {\n categoryKeys.add({ className: category.classFullName, id: category.id! });\n }\n });\n return categoryKeys;\n }\n\n private static async computeModelSelection(iModel: IModelDb, ids: Id64String[]) {\n const modelKeys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n const el = iModel.elements.tryGetElementProps(id);\n const model = el ? iModel.models.tryGetModelProps(el.model) : undefined;\n if (model) {\n modelKeys.add({ className: model.classFullName, id: model.id! });\n }\n });\n return modelKeys;\n }\n\n private static async getRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): Promise<InstanceKey | undefined> {\n const query = `\n SELECT funcSchemaDef.Name || '.' || funcClassDef.Name funcElClassName, fe.ECInstanceId funcElId\n FROM bis.Element e\n LEFT JOIN func.PhysicalElementFulfillsFunction rel1 ON rel1.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.DrawingGraphicRepresentsFunctionalElement rel2 ON rel2.SourceECInstanceId = e.ECInstanceId\n LEFT JOIN func.FunctionalElement fe ON fe.ECInstanceId IN (rel1.TargetECInstanceId, rel2.TargetECInstanceId)\n INNER JOIN meta.ECClassDef funcClassDef ON funcClassDef.ECInstanceId = fe.ECClassId\n INNER JOIN meta.ECSchemaDef funcSchemaDef ON funcSchemaDef.ECInstanceId = funcClassDef.Schema.Id\n WHERE e.ECInstanceId = ?\n `;\n\n const bindings = new QueryBinder();\n bindings.bindId(1, graphicalElementId);\n\n for await (const row of imodel.createQueryReader(query, bindings)) {\n if (row.funcElClassName && row.funcElId) {\n return { className: row.funcElClassName.replace(\".\", \":\"), id: row.funcElId };\n }\n }\n return undefined;\n }\n\n private static async findFirstRelatedFunctionalElementKey(imodel: IModelDb, graphicalElementId: Id64String): Promise<InstanceKey | undefined> {\n let currId: Id64String | undefined = graphicalElementId;\n while (currId) {\n const relatedFunctionalKey = await this.getRelatedFunctionalElementKey(imodel, currId);\n if (relatedFunctionalKey) {\n return relatedFunctionalKey;\n }\n currId = imodel.elements.tryGetElementProps(currId)?.parent?.id;\n }\n return undefined;\n }\n\n private static async elementClassDerivesFrom(imodel: IModelDb, elementId: Id64String, baseClassFullName: string): Promise<boolean> {\n const query = `\n SELECT 1\n FROM bis.Element e\n INNER JOIN meta.ClassHasAllBaseClasses baseClassRels ON baseClassRels.SourceECInstanceId = e.ECClassId\n INNER JOIN meta.ECClassDef baseClass ON baseClass.ECInstanceId = baseClassRels.TargetECInstanceId\n INNER JOIN meta.ECSchemaDef baseSchema ON baseSchema.ECInstanceId = baseClass.Schema.Id\n WHERE e.ECInstanceId = ? AND (baseSchema.Name || ':' || baseClass.Name) = ?\n `;\n\n const bindings = new QueryBinder();\n bindings.bindId(1, elementId);\n bindings.bindString(2, baseClassFullName);\n\n for await (const _ of imodel.createQueryReader(query, bindings)) {\n return true;\n }\n return false;\n }\n\n private static async computeFunctionalElementSelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n const is3d = await this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = await this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n keys.add(firstFunctionalKey);\n return;\n }\n }\n let keyToAdd: InstanceKey | undefined;\n if (is3d) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n keyToAdd = await this.getRelatedFunctionalElementKey(iModel, id);\n }\n if (!keyToAdd) {\n keyToAdd = getElementKey(iModel, id);\n }\n keyToAdd && keys.add(keyToAdd);\n });\n return keys;\n }\n\n private static async computeFunctionalAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n let idToGetAssemblyFor = id;\n const is3d = await this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = await this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the assembly of either the given element or the functional element\n const assemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, 1);\n let keyToAdd = assemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = await this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n });\n return keys;\n }\n\n private static async computeFunctionalTopAssemblySelection(iModel: IModelDb, ids: Id64String[]) {\n const keys = new KeySet();\n await forEachNonTransientId(ids, async (id) => {\n let idToGetAssemblyFor = id;\n const is3d = await this.elementClassDerivesFrom(iModel, id, \"BisCore.GeometricElement3d\");\n if (!is3d) {\n // if the input is not a 3d element, we try to find the first related functional element\n const firstFunctionalKey = await this.findFirstRelatedFunctionalElementKey(iModel, id);\n if (firstFunctionalKey) {\n idToGetAssemblyFor = firstFunctionalKey.id;\n }\n }\n // find the top assembly of either the given element or the functional element\n const topAssemblyKey = this.getElementKey(iModel, idToGetAssemblyFor, Number.MAX_SAFE_INTEGER);\n let keyToAdd = topAssemblyKey;\n if (is3d && keyToAdd) {\n // if we're computing scope for a 3d element, try to switch to its related functional element\n const relatedFunctionalKey = await this.getRelatedFunctionalElementKey(iModel, keyToAdd.id);\n if (relatedFunctionalKey) {\n keyToAdd = relatedFunctionalKey;\n }\n }\n keyToAdd && keys.add(keyToAdd);\n });\n return keys;\n }\n\n public static async computeSelection({ imodel, scope, elementIds }: ComputeSelectionRequestOptions<IModelDb>): Promise<KeySet> {\n switch (scope.id) {\n case \"element\":\n return this.computeElementSelection(imodel, elementIds, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n case \"assembly\":\n return this.computeElementSelection(imodel, elementIds, 1);\n case \"top-assembly\":\n return this.computeElementSelection(imodel, elementIds, Number.MAX_SAFE_INTEGER);\n case \"category\":\n return this.computeCategorySelection(imodel, elementIds);\n case \"model\":\n return this.computeModelSelection(imodel, elementIds);\n case \"functional\":\n case \"functional-element\":\n return this.computeFunctionalElementSelection(imodel, elementIds);\n case \"functional-assembly\":\n return this.computeFunctionalAssemblySelection(imodel, elementIds);\n case \"functional-top-assembly\":\n return this.computeFunctionalTopAssemblySelection(imodel, elementIds);\n }\n throw new PresentationError(PresentationStatus.InvalidArgument, \"scopeId\");\n }\n}\n\nasync function forEachNonTransientId(ids: Id64Array, callback: (id: Id64String) => Promise<void>): Promise<void> {\n await Promise.all(ids.filter((id) => !Id64.isTransient(id)).map(callback));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,WAAW,EAEX,kBAAkB,EAClB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAQpC,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,UAc/C;AAED,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAGvF;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,UAQhD;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,QAAQ,GAAG,GAAG,IAAI,CAAC,IA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,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChI,IAAI,kBAAkB,IAAI,qBAAqB,EAAE,CAAC;gBAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n/** @packageDocumentation\n * @module Core\n */\n\nimport { parse as parseVersion } from \"semver\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n Diagnostics,\n DiagnosticsLogEntry,\n DiagnosticsOptions,\n InstanceKey,\n} from \"@itwin/presentation-common\";\nimport {\n combineDiagnosticsSeverities,\n compareDiagnosticsSeverities,\n} from \"@itwin/presentation-common/internal\";\n// @ts-ignore TS complains about `with` in CJS builds, but not ESM\nimport presentationStrings from \"@itwin/presentation-common/locales/en/Presentation.json\" with { type: \"json\" };\n\n/** @internal */\nexport function getLocalizedStringEN(key: string) {\n let result: object | string = presentationStrings;\n const [namespace, identifier] = key.split(\":\", 2);\n if (namespace !== \"Presentation\") {\n return key;\n }\n const keySteps = identifier.split(\".\");\n for (const keyStep of keySteps) {\n if (typeof result !== \"object\" || keyStep in result === false) {\n return key;\n }\n result = result[keyStep as keyof typeof result];\n }\n return typeof result === \"string\" ? result : key;\n}\n\n/** @internal */\nexport function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined {\n const className = imodel.elements.tryGetElementProps(id)?.classFullName;\n return className ? { className, id } : undefined;\n}\n\n/** @internal */\nexport function normalizeVersion(version?: string) {\n if (version) {\n const parsedVersion = parseVersion(version, true);\n if (parsedVersion) {\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;\n }\n }\n return \"0.0.0\";\n}\n\n/**\n * A function that received request diagnostics and, optionally, request context.\n * @public\n */\nexport type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;\n\n/**\n * Data structure for backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {\n /**\n * An optional function to supply request context that'll be passed to [[handler]] when\n * it's called after the request is fulfilled.\n */\n requestContextSupplier?: () => TContext;\n\n /**\n * Request diagnostics handler function that is called after the request is fulfilled. The handler\n * receives request diagnostics as the first argument and, optionally, request context as the\n * second (see [[requestContextSupplier]]).\n */\n handler: BackendDiagnosticsHandler<TContext>;\n}\n\n/**\n * Data structure which contains backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsAttribute {\n /**\n * Backend diagnostics options.\n * @public\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/** @internal */\nexport function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined {\n const combinedOptions: DiagnosticsOptions = {};\n options.forEach((d) => {\n if (!d) {\n return;\n }\n if (\n d.perf === true ||\n (typeof d.perf === \"object\" &&\n (!combinedOptions.perf || (typeof combinedOptions.perf === \"object\" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)))\n ) {\n combinedOptions.perf = d.perf;\n }\n const combinedDev = combineDiagnosticsSeverities(d.dev, combinedOptions.dev);\n if (combinedDev) {\n combinedOptions.dev = combinedDev;\n }\n const combinedEditor = combineDiagnosticsSeverities(d.editor, combinedOptions.editor);\n if (combinedEditor) {\n combinedOptions.editor = combinedEditor;\n }\n });\n return combinedOptions.dev || combinedOptions.editor || combinedOptions.perf ? combinedOptions : undefined;\n}\n\n/** @internal */\nexport function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext) {\n const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;\n stripped && options.handler({ logs: stripped }, context);\n}\nfunction stripDiagnostics<TEntry extends DiagnosticsLogEntry>(options: DiagnosticsOptions, diagnostics: TEntry[]) {\n const stripped: TEntry[] = [];\n diagnostics.forEach((entry) => {\n if (DiagnosticsLogEntry.isScope(entry)) {\n const scopeLogs = stripDiagnostics(options, entry.logs ?? []);\n const strippedScope = { ...entry, logs: scopeLogs };\n if (!strippedScope.logs) {\n delete strippedScope.logs;\n }\n if (entry.duration !== undefined && (options.perf === true || (typeof options.perf === \"object\" && entry.duration >= options.perf.minimumDuration))) {\n stripped.push(strippedScope);\n } else if (scopeLogs) {\n delete strippedScope.duration;\n delete strippedScope.scopeCreateTimestamp;\n stripped.push(strippedScope);\n }\n } else {\n const matchesDevSeverity = entry.severity.dev && compareDiagnosticsSeverities(entry.severity.dev, options.dev) >= 0;\n const matchesEditorSeverity = entry.severity.editor && compareDiagnosticsSeverities(entry.severity.editor, options.editor) >= 0;\n if (matchesDevSeverity || matchesEditorSeverity) {\n stripped.push({ ...entry });\n }\n }\n });\n return stripped.length > 0 ? stripped : undefined;\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/presentation-backend/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,sDAAsD;AACtD;;GAEG;;;;;AAWH,oDAcC;AAGD,sCAGC;AAGD,4CAQC;AAwCD,8DAuBC;AAGD,8CAGC;AA7GD,mCAA+C;AAG/C,oEAA+G;AAC/G,kEAAiH;AACjH,kEAAkE;AAClE,gHAAgH;AAEhH,gBAAgB;AAChB,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,IAAI,MAAM,GAAoB,2BAAmB,CAAC;IAClD,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;I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AAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChI,IAAI,kBAAkB,IAAI,qBAAqB,EAAE,CAAC;gBAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/* eslint-disable @typescript-eslint/ban-ts-comment */\n/** @packageDocumentation\n * @module Core\n */\n\nimport { parse as parseVersion } from \"semver\";\nimport { IModelDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { Diagnostics, DiagnosticsLogEntry, DiagnosticsOptions, InstanceKey } from \"@itwin/presentation-common\";\nimport { combineDiagnosticsSeverities, compareDiagnosticsSeverities } from \"@itwin/presentation-common/internal\";\n// @ts-ignore TS complains about `with` in CJS builds, but not ESM\nimport presentationStrings from \"@itwin/presentation-common/locales/en/Presentation.json\" with { type: \"json\" };\n\n/** @internal */\nexport function getLocalizedStringEN(key: string) {\n let result: object | string = presentationStrings;\n const [namespace, identifier] = key.split(\":\", 2);\n if (namespace !== \"Presentation\") {\n return key;\n }\n const keySteps = identifier.split(\".\");\n for (const keyStep of keySteps) {\n if (typeof result !== \"object\" || keyStep in result === false) {\n return key;\n }\n result = result[keyStep as keyof typeof result];\n }\n return typeof result === \"string\" ? result : key;\n}\n\n/** @internal */\nexport function getElementKey(imodel: IModelDb, id: Id64String): InstanceKey | undefined {\n const className = imodel.elements.tryGetElementProps(id)?.classFullName;\n return className ? { className, id } : undefined;\n}\n\n/** @internal */\nexport function normalizeVersion(version?: string) {\n if (version) {\n const parsedVersion = parseVersion(version, true);\n if (parsedVersion) {\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`;\n }\n }\n return \"0.0.0\";\n}\n\n/**\n * A function that received request diagnostics and, optionally, request context.\n * @public\n */\nexport type BackendDiagnosticsHandler<TContext = any> = (logs: Diagnostics, requestContext?: TContext) => void;\n\n/**\n * Data structure for backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsOptions<TContext = any> extends DiagnosticsOptions {\n /**\n * An optional function to supply request context that'll be passed to [[handler]] when\n * it's called after the request is fulfilled.\n */\n requestContextSupplier?: () => TContext;\n\n /**\n * Request diagnostics handler function that is called after the request is fulfilled. The handler\n * receives request diagnostics as the first argument and, optionally, request context as the\n * second (see [[requestContextSupplier]]).\n */\n handler: BackendDiagnosticsHandler<TContext>;\n}\n\n/**\n * Data structure which contains backend diagnostics options.\n * @public\n */\nexport interface BackendDiagnosticsAttribute {\n /**\n * Backend diagnostics options.\n * @public\n */\n diagnostics?: BackendDiagnosticsOptions;\n}\n\n/** @internal */\nexport function combineDiagnosticsOptions(...options: Array<BackendDiagnosticsOptions | undefined>): DiagnosticsOptions | undefined {\n const combinedOptions: DiagnosticsOptions = {};\n options.forEach((d) => {\n if (!d) {\n return;\n }\n if (\n d.perf === true ||\n (typeof d.perf === \"object\" &&\n (!combinedOptions.perf || (typeof combinedOptions.perf === \"object\" && d.perf.minimumDuration < combinedOptions.perf.minimumDuration)))\n ) {\n combinedOptions.perf = d.perf;\n }\n const combinedDev = combineDiagnosticsSeverities(d.dev, combinedOptions.dev);\n if (combinedDev) {\n combinedOptions.dev = combinedDev;\n }\n const combinedEditor = combineDiagnosticsSeverities(d.editor, combinedOptions.editor);\n if (combinedEditor) {\n combinedOptions.editor = combinedEditor;\n }\n });\n return combinedOptions.dev || combinedOptions.editor || combinedOptions.perf ? combinedOptions : undefined;\n}\n\n/** @internal */\nexport function reportDiagnostics<TContext>(diagnostics: Diagnostics, options: BackendDiagnosticsOptions<TContext>, context?: TContext) {\n const stripped = diagnostics.logs ? stripDiagnostics(options, diagnostics.logs) : undefined;\n stripped && options.handler({ logs: stripped }, context);\n}\nfunction stripDiagnostics<TEntry extends DiagnosticsLogEntry>(options: DiagnosticsOptions, diagnostics: TEntry[]) {\n const stripped: TEntry[] = [];\n diagnostics.forEach((entry) => {\n if (DiagnosticsLogEntry.isScope(entry)) {\n const scopeLogs = stripDiagnostics(options, entry.logs ?? []);\n const strippedScope = { ...entry, logs: scopeLogs };\n if (!strippedScope.logs) {\n delete strippedScope.logs;\n }\n if (entry.duration !== undefined && (options.perf === true || (typeof options.perf === \"object\" && entry.duration >= options.perf.minimumDuration))) {\n stripped.push(strippedScope);\n } else if (scopeLogs) {\n delete strippedScope.duration;\n delete strippedScope.scopeCreateTimestamp;\n stripped.push(strippedScope);\n }\n } else {\n const matchesDevSeverity = entry.severity.dev && compareDiagnosticsSeverities(entry.severity.dev, options.dev) >= 0;\n const matchesEditorSeverity = entry.severity.editor && compareDiagnosticsSeverities(entry.severity.editor, options.editor) >= 0;\n if (matchesDevSeverity || matchesEditorSeverity) {\n stripped.push({ ...entry });\n }\n }\n });\n return stripped.length > 0 ? stripped : undefined;\n}\n"]}