@itwin/presentation-common 5.15.0-dev.1 → 5.15.0-dev.10

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 (105) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/Ruleset.schema.json +18 -18
  3. package/lib/cjs/presentation-common/KeySet.d.ts +4 -4
  4. package/lib/cjs/presentation-common/KeySet.js +3 -3
  5. package/lib/cjs/presentation-common/KeySet.js.map +1 -1
  6. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts +11 -0
  7. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -1
  8. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js +26 -0
  9. package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
  10. package/lib/cjs/presentation-common/LocalizationHelper.d.ts +22 -16
  11. package/lib/cjs/presentation-common/LocalizationHelper.d.ts.map +1 -1
  12. package/lib/cjs/presentation-common/LocalizationHelper.js +85 -83
  13. package/lib/cjs/presentation-common/LocalizationHelper.js.map +1 -1
  14. package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts +5 -5
  15. package/lib/cjs/presentation-common/PresentationManagerOptions.js.map +1 -1
  16. package/lib/cjs/presentation-common/PresentationRpcInterface.d.ts +4 -4
  17. package/lib/cjs/presentation-common/PresentationRpcInterface.js.map +1 -1
  18. package/lib/cjs/presentation-common/Update.d.ts +7 -7
  19. package/lib/cjs/presentation-common/Update.js.map +1 -1
  20. package/lib/cjs/presentation-common/hierarchy/HierarchyLevel.d.ts +1 -1
  21. package/lib/cjs/presentation-common/hierarchy/HierarchyLevel.js.map +1 -1
  22. package/lib/cjs/presentation-common/hierarchy/Key.d.ts +10 -10
  23. package/lib/cjs/presentation-common/hierarchy/Key.js +2 -2
  24. package/lib/cjs/presentation-common/hierarchy/Key.js.map +1 -1
  25. package/lib/cjs/presentation-common/hierarchy/Node.d.ts +2 -2
  26. package/lib/cjs/presentation-common/hierarchy/Node.js.map +1 -1
  27. package/lib/cjs/presentation-common/hierarchy/NodePathElement.d.ts +2 -2
  28. package/lib/cjs/presentation-common/hierarchy/NodePathElement.js.map +1 -1
  29. package/lib/cjs/presentation-common/rules/customization/GroupingRule.d.ts +9 -9
  30. package/lib/cjs/presentation-common/rules/customization/GroupingRule.js +2 -2
  31. package/lib/cjs/presentation-common/rules/customization/GroupingRule.js.map +1 -1
  32. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeRule.d.ts +1 -1
  33. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeRule.js.map +1 -1
  34. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts +4 -4
  35. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.js +1 -1
  36. package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.js.map +1 -1
  37. package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.d.ts +1 -1
  38. package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
  39. package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.d.ts +6 -6
  40. package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js +1 -1
  41. package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js.map +1 -1
  42. package/lib/cjs/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.d.ts +1 -1
  43. package/lib/cjs/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js.map +1 -1
  44. package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.d.ts +2 -2
  45. package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.js.map +1 -1
  46. package/lib/cjs/presentation-common/rules/hierarchy/NodeArtifactsRule.d.ts +1 -1
  47. package/lib/cjs/presentation-common/rules/hierarchy/NodeArtifactsRule.js.map +1 -1
  48. package/lib/cjs/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.d.ts +1 -1
  49. package/lib/cjs/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js.map +1 -1
  50. package/lib/cjs/presentation-common/rules/hierarchy/RootNodeRule.d.ts +1 -1
  51. package/lib/cjs/presentation-common/rules/hierarchy/RootNodeRule.js.map +1 -1
  52. package/lib/cjs/presentation-common/rules/hierarchy/SubCondition.d.ts +1 -1
  53. package/lib/cjs/presentation-common/rules/hierarchy/SubCondition.js.map +1 -1
  54. package/lib/esm/presentation-common/KeySet.d.ts +4 -4
  55. package/lib/esm/presentation-common/KeySet.js +3 -3
  56. package/lib/esm/presentation-common/KeySet.js.map +1 -1
  57. package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts +11 -0
  58. package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -1
  59. package/lib/esm/presentation-common/KoqPropertyValueFormatter.js +26 -0
  60. package/lib/esm/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
  61. package/lib/esm/presentation-common/LocalizationHelper.d.ts +22 -16
  62. package/lib/esm/presentation-common/LocalizationHelper.d.ts.map +1 -1
  63. package/lib/esm/presentation-common/LocalizationHelper.js +85 -83
  64. package/lib/esm/presentation-common/LocalizationHelper.js.map +1 -1
  65. package/lib/esm/presentation-common/PresentationManagerOptions.d.ts +5 -5
  66. package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
  67. package/lib/esm/presentation-common/PresentationRpcInterface.d.ts +4 -4
  68. package/lib/esm/presentation-common/PresentationRpcInterface.js.map +1 -1
  69. package/lib/esm/presentation-common/Update.d.ts +7 -7
  70. package/lib/esm/presentation-common/Update.js.map +1 -1
  71. package/lib/esm/presentation-common/hierarchy/HierarchyLevel.d.ts +1 -1
  72. package/lib/esm/presentation-common/hierarchy/HierarchyLevel.js.map +1 -1
  73. package/lib/esm/presentation-common/hierarchy/Key.d.ts +10 -10
  74. package/lib/esm/presentation-common/hierarchy/Key.js +2 -2
  75. package/lib/esm/presentation-common/hierarchy/Key.js.map +1 -1
  76. package/lib/esm/presentation-common/hierarchy/Node.d.ts +2 -2
  77. package/lib/esm/presentation-common/hierarchy/Node.js.map +1 -1
  78. package/lib/esm/presentation-common/hierarchy/NodePathElement.d.ts +2 -2
  79. package/lib/esm/presentation-common/hierarchy/NodePathElement.js.map +1 -1
  80. package/lib/esm/presentation-common/rules/customization/GroupingRule.d.ts +9 -9
  81. package/lib/esm/presentation-common/rules/customization/GroupingRule.js +2 -2
  82. package/lib/esm/presentation-common/rules/customization/GroupingRule.js.map +1 -1
  83. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeRule.d.ts +1 -1
  84. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeRule.js.map +1 -1
  85. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts +4 -4
  86. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.js +1 -1
  87. package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.js.map +1 -1
  88. package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.d.ts +1 -1
  89. package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
  90. package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.d.ts +6 -6
  91. package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js +1 -1
  92. package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js.map +1 -1
  93. package/lib/esm/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.d.ts +1 -1
  94. package/lib/esm/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js.map +1 -1
  95. package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.d.ts +2 -2
  96. package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.js.map +1 -1
  97. package/lib/esm/presentation-common/rules/hierarchy/NodeArtifactsRule.d.ts +1 -1
  98. package/lib/esm/presentation-common/rules/hierarchy/NodeArtifactsRule.js.map +1 -1
  99. package/lib/esm/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.d.ts +1 -1
  100. package/lib/esm/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js.map +1 -1
  101. package/lib/esm/presentation-common/rules/hierarchy/RootNodeRule.d.ts +1 -1
  102. package/lib/esm/presentation-common/rules/hierarchy/RootNodeRule.js.map +1 -1
  103. package/lib/esm/presentation-common/rules/hierarchy/SubCondition.d.ts +1 -1
  104. package/lib/esm/presentation-common/rules/hierarchy/SubCondition.js.map +1 -1
  105. package/package.json +11 -11
@@ -12,26 +12,32 @@ import { LabelDefinition } from "./LabelDefinition.js";
12
12
  interface LocalizationHelperProps {
13
13
  getLocalizedString: (key: string) => string;
14
14
  }
15
- /** @internal */
15
+ /**
16
+ * Localizes presentation data structures **in place**. Callers must pass a mutable graph owned by the current
17
+ * operation and must not reuse it as untranslated data for another locale.
18
+ * @internal
19
+ */
16
20
  export declare class LocalizationHelper {
17
21
  private _getLocalizedString;
18
22
  constructor(props: LocalizationHelperProps);
19
23
  getLocalizedString(text: string): string;
20
- getLocalizedNodes(nodes: Node[]): Node[];
21
- getLocalizedNode(node: Node): Node;
22
- getLocalizedNodePathElement(npe: NodePathElement): NodePathElement;
23
- getLocalizedDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup;
24
- getLocalizedLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition;
25
- getLocalizedLabelDefinitions(labelDefinitions: LabelDefinition[]): LabelDefinition[];
26
- getLocalizedContentDescriptor(descriptor: Descriptor): Descriptor;
27
- getLocalizedContentItems(items: Item[]): Item[];
28
- getLocalizedContent(content: Content): Content;
29
- getLocalizedElementProperties(elem: ElementProperties): ElementProperties;
30
- private getLocalizedContentItem;
31
- private getLocalizedRawValue;
32
- private getLocalizedContentField;
33
- private getLocalizedCategoryDescription;
34
- private getLocalizedDisplayValue;
24
+ localizeNodes(nodes: Node[]): Node[];
25
+ localizeNode(node: Node): Node;
26
+ localizeNodePathElement(npe: NodePathElement): NodePathElement;
27
+ localizeDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup;
28
+ localizeLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition;
29
+ localizeLabelDefinitions(labelDefinitions: LabelDefinition[]): LabelDefinition[];
30
+ localizeContentDescriptor(descriptor: Descriptor): Descriptor;
31
+ localizeContentItems(items: Item[]): Item[];
32
+ localizeContent(content: Content): Content;
33
+ localizeElementProperties(elem: ElementProperties): ElementProperties;
34
+ private localizeContentItem;
35
+ private localizeRawValuesDictionary;
36
+ private localizeDisplayValuesDictionary;
37
+ private localizeRawValue;
38
+ private localizeContentField;
39
+ private localizeCategoryDescription;
40
+ private localizeDisplayValue;
35
41
  }
36
42
  export {};
37
43
  //# sourceMappingURL=LocalizationHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationHelper.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/LocalizationHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAgB,iBAAiB,EAAS,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAA4D,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIjH,UAAU,uBAAuB;IAC/B,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7C;AAED,gBAAgB;AAChB,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,mBAAmB,CAA0B;gBAEzC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eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIjH,UAAU,uBAAuB;IAC/B,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7C;AAED;;;;GAIG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,mBAAmB,CAA0B;gBAEzC,KAAK,EAAE,uBAAuB;IAInC,kBAAkB,CAAC,IAAI,EAAE,MAAM;IAK/B,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE;IAKpC,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAQ9B,uBAAuB,CAAC,GAAG,EAAE,eAAe,GAAG,eAAe;IAO9D,yBAAyB,CAAC,KAAK,EAAE,iBAAiB,GAAG,iBAAiB;IAKtE,uBAAuB,CAAC,eAAe,EAAE,eAAe,GAAG,eAAe;IAU1E,wBAAwB,CAAC,gBAAgB,EAAE,eAAe,EAAE;IAK5D,yBAAyB,CAAC,UAAU,EAAE,UAAU;IAMhD,oBAAoB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE;IAK3C,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAM1C,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB;IAK5E,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,2BAA2B;IAMnC,OAAO,CAAC,+BAA+B;IAMvC,OAAO,CAAC,gBAAgB;IA2BxB,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,2BAA2B;IAMnC,OAAO,CAAC,oBAAoB;CAgB7B"}
@@ -8,12 +8,14 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.LocalizationHelper = void 0;
11
- const Content_js_1 = require("./content/Content.js");
12
- const Descriptor_js_1 = require("./content/Descriptor.js");
13
11
  const Value_js_1 = require("./content/Value.js");
14
12
  const LabelDefinition_js_1 = require("./LabelDefinition.js");
15
13
  const KEY_PATTERN = /@[\w\d\-_]+:[\w\d\-\._]+?@/g;
16
- /** @internal */
14
+ /**
15
+ * Localizes presentation data structures **in place**. Callers must pass a mutable graph owned by the current
16
+ * operation and must not reuse it as untranslated data for another locale.
17
+ * @internal
18
+ */
17
19
  class LocalizationHelper {
18
20
  _getLocalizedString;
19
21
  constructor(props) {
@@ -23,126 +25,122 @@ class LocalizationHelper {
23
25
  return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, "")));
24
26
  }
25
27
  /* eslint-disable @typescript-eslint/no-deprecated */
26
- getLocalizedNodes(nodes) {
27
- return nodes.map((n) => this.getLocalizedNode(n));
28
- }
29
- getLocalizedNode(node) {
30
- return {
31
- ...node,
32
- label: this.getLocalizedLabelDefinition(node.label),
33
- ...(node.description ? { description: this.getLocalizedString(node.description) } : undefined),
34
- };
35
- }
36
- getLocalizedNodePathElement(npe) {
37
- return {
38
- ...npe,
39
- node: this.getLocalizedNode(npe.node),
40
- children: npe.children.map((c) => this.getLocalizedNodePathElement(c)),
41
- };
28
+ localizeNodes(nodes) {
29
+ nodes.forEach((n) => this.localizeNode(n));
30
+ return nodes;
31
+ }
32
+ localizeNode(node) {
33
+ this.localizeLabelDefinition(node.label);
34
+ if (node.description) {
35
+ node.description = this.getLocalizedString(node.description);
36
+ }
37
+ return node;
38
+ }
39
+ localizeNodePathElement(npe) {
40
+ this.localizeNode(npe.node);
41
+ npe.children.forEach((c) => this.localizeNodePathElement(c));
42
+ return npe;
42
43
  }
43
44
  /* eslint-enable @typescript-eslint/no-deprecated */
44
- getLocalizedDisplayValueGroup(group) {
45
- return {
46
- ...group,
47
- displayValue: this.getLocalizedDisplayValue(group.displayValue),
48
- };
49
- }
50
- getLocalizedLabelDefinition(labelDefinition) {
51
- const getLocalizedComposite = (compositeValue) => ({
52
- ...compositeValue,
53
- values: compositeValue.values.map((value) => this.getLocalizedLabelDefinition(value)),
54
- });
45
+ localizeDisplayValueGroup(group) {
46
+ group.displayValue = this.localizeDisplayValue(group.displayValue);
47
+ return group;
48
+ }
49
+ localizeLabelDefinition(labelDefinition) {
55
50
  if (labelDefinition.typeName === LabelDefinition_js_1.COMPOSITE_LABEL_DEFINITION_TYPENAME) {
56
- return {
57
- ...labelDefinition,
58
- rawValue: getLocalizedComposite(labelDefinition.rawValue),
59
- };
51
+ labelDefinition.rawValue.values.forEach((value) => this.localizeLabelDefinition(value));
60
52
  }
61
- if (labelDefinition.typeName === "string") {
62
- return {
63
- ...labelDefinition,
64
- rawValue: this.getLocalizedString(labelDefinition.rawValue),
65
- displayValue: this.getLocalizedString(labelDefinition.displayValue),
66
- };
53
+ else if (labelDefinition.typeName === "string") {
54
+ labelDefinition.rawValue = this.getLocalizedString(labelDefinition.rawValue);
55
+ labelDefinition.displayValue = this.getLocalizedString(labelDefinition.displayValue);
67
56
  }
68
57
  return labelDefinition;
69
58
  }
70
- getLocalizedLabelDefinitions(labelDefinitions) {
71
- return labelDefinitions.map((labelDefinition) => this.getLocalizedLabelDefinition(labelDefinition));
59
+ localizeLabelDefinitions(labelDefinitions) {
60
+ labelDefinitions.forEach((labelDefinition) => this.localizeLabelDefinition(labelDefinition));
61
+ return labelDefinitions;
72
62
  }
73
- getLocalizedContentDescriptor(descriptor) {
74
- const clone = new Descriptor_js_1.Descriptor(descriptor);
75
- clone.fields.forEach((field) => this.getLocalizedContentField(field));
76
- clone.categories.forEach((category) => this.getLocalizedCategoryDescription(category));
77
- return clone;
63
+ localizeContentDescriptor(descriptor) {
64
+ descriptor.fields.forEach((field) => this.localizeContentField(field));
65
+ descriptor.categories.forEach((category) => this.localizeCategoryDescription(category));
66
+ return descriptor;
78
67
  }
79
- getLocalizedContentItems(items) {
80
- return items.map((item) => this.getLocalizedContentItem(item));
68
+ localizeContentItems(items) {
69
+ items.forEach((item) => this.localizeContentItem(item));
70
+ return items;
81
71
  }
82
- getLocalizedContent(content) {
83
- return new Content_js_1.Content(this.getLocalizedContentDescriptor(content.descriptor), this.getLocalizedContentItems(content.contentSet));
72
+ localizeContent(content) {
73
+ this.localizeContentDescriptor(content.descriptor);
74
+ this.localizeContentItems(content.contentSet);
75
+ return content;
84
76
  }
85
- getLocalizedElementProperties(elem) {
86
- return {
87
- ...elem,
88
- label: this.getLocalizedString(elem.label),
89
- };
77
+ localizeElementProperties(elem) {
78
+ elem.label = this.getLocalizedString(elem.label);
79
+ return elem;
90
80
  }
91
- // warning: this function mutates the item
92
- getLocalizedContentItem(item) {
93
- item.label = this.getLocalizedLabelDefinition(item.label);
94
- item.values = Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});
95
- item.displayValues = Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});
81
+ localizeContentItem(item) {
82
+ this.localizeLabelDefinition(item.label);
83
+ this.localizeRawValuesDictionary(item.values);
84
+ this.localizeDisplayValuesDictionary(item.displayValues);
96
85
  return item;
97
86
  }
98
- getLocalizedRawValue(value) {
87
+ localizeRawValuesDictionary(values) {
88
+ for (const key of Object.keys(values)) {
89
+ values[key] = this.localizeRawValue(values[key]);
90
+ }
91
+ }
92
+ localizeDisplayValuesDictionary(values) {
93
+ for (const key of Object.keys(values)) {
94
+ values[key] = this.localizeDisplayValue(values[key]);
95
+ }
96
+ }
97
+ localizeRawValue(value) {
99
98
  if (typeof value === "string") {
100
99
  return this.getLocalizedString(value);
101
100
  }
102
101
  if (Value_js_1.Value.isNavigationValue(value)) {
103
- return {
104
- ...value,
105
- label: this.getLocalizedLabelDefinition(value.label),
106
- };
102
+ this.localizeLabelDefinition(value.label);
103
+ return value;
107
104
  }
108
105
  if (Value_js_1.Value.isNestedContent(value)) {
109
- return value.map((item) => ({
110
- ...item,
111
- values: Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {}),
112
- displayValues: Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {}),
113
- }));
106
+ value.forEach((item) => {
107
+ this.localizeRawValuesDictionary(item.values);
108
+ this.localizeDisplayValuesDictionary(item.displayValues);
109
+ });
110
+ return value;
114
111
  }
115
112
  if (Value_js_1.Value.isArray(value)) {
116
- return value.map((v) => this.getLocalizedRawValue(v));
113
+ for (let i = 0; i < value.length; ++i) {
114
+ value[i] = this.localizeRawValue(value[i]);
115
+ }
116
+ return value;
117
117
  }
118
118
  if (Value_js_1.Value.isMap(value)) {
119
- return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});
119
+ this.localizeRawValuesDictionary(value);
120
120
  }
121
121
  return value;
122
122
  }
123
- // warning: this function mutates the field
124
- getLocalizedContentField(field) {
123
+ localizeContentField(field) {
125
124
  field.label = this.getLocalizedString(field.label);
126
125
  if (field.isPropertiesField()) {
127
126
  if (field.isStructPropertiesField()) {
128
- field.memberFields = field.memberFields.map((m) => this.getLocalizedContentField(m));
127
+ field.memberFields.forEach((m) => this.localizeContentField(m));
129
128
  }
130
129
  else if (field.isArrayPropertiesField()) {
131
- field.itemsField = this.getLocalizedContentField(field.itemsField);
130
+ this.localizeContentField(field.itemsField);
132
131
  }
133
132
  }
134
133
  else if (field.isNestedContentField()) {
135
- field.nestedFields = field.nestedFields.map((m) => this.getLocalizedContentField(m));
134
+ field.nestedFields.forEach((m) => this.localizeContentField(m));
136
135
  }
137
136
  return field;
138
137
  }
139
- // warning: this function mutates the category
140
- getLocalizedCategoryDescription(category) {
138
+ localizeCategoryDescription(category) {
141
139
  category.label = this.getLocalizedString(category.label);
142
140
  category.description = this.getLocalizedString(category.description);
143
141
  return category;
144
142
  }
145
- getLocalizedDisplayValue(value) {
143
+ localizeDisplayValue(value) {
146
144
  if (typeof value === "undefined") {
147
145
  return undefined;
148
146
  }
@@ -150,9 +148,13 @@ class LocalizationHelper {
150
148
  return this.getLocalizedString(value);
151
149
  }
152
150
  if (Value_js_1.DisplayValue.isArray(value)) {
153
- return value.map((v) => this.getLocalizedDisplayValue(v));
151
+ for (let i = 0; i < value.length; ++i) {
152
+ value[i] = this.localizeDisplayValue(value[i]);
153
+ }
154
+ return value;
154
155
  }
155
- return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});
156
+ this.localizeDisplayValuesDictionary(value);
157
+ return value;
156
158
  }
157
159
  }
158
160
  exports.LocalizationHelper = LocalizationHelper;
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationHelper.js","sourceRoot":"","sources":["../../../src/presentation-common/LocalizationHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAGH,qDAA+C;AAC/C,2DAAqD;AAGrD,iDAA4E;AAI5E,6DAAiH;AAEjH,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAMlD,gBAAgB;AAChB,MAAa,kBAAkB;IACrB,mBAAmB,CAA0B;IAErD,YAAY,KAA8B;QACxC,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IACtD,CAAC;IAEM,kBAAkB,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,qDAAqD;IAC9C,iBAAiB,CAAC,KAAa;QACpC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAEM,gBAAgB,CAAC,IAAU;QAChC,OAAO;YACL,GAAG,IAAI;YACP,KAAK,EAAE,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC;YACnD,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI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AAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5G,CAAC;CACF;AA5JD,gDA4JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { CategoryDescription } from \"./content/Category.js\";\r\nimport { Content } from \"./content/Content.js\";\r\nimport { Descriptor } from \"./content/Descriptor.js\";\r\nimport { Field } from \"./content/Fields.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { DisplayValue, DisplayValueGroup, Value } from \"./content/Value.js\";\r\nimport { ElementProperties } from \"./ElementProperties.js\";\r\nimport { Node } from \"./hierarchy/Node.js\";\r\nimport { NodePathElement } from \"./hierarchy/NodePathElement.js\";\r\nimport { COMPOSITE_LABEL_DEFINITION_TYPENAME, LabelCompositeValue, LabelDefinition } from \"./LabelDefinition.js\";\r\n\r\nconst KEY_PATTERN = /@[\\w\\d\\-_]+:[\\w\\d\\-\\._]+?@/g;\r\n\r\ninterface LocalizationHelperProps {\r\n getLocalizedString: (key: string) => string;\r\n}\r\n\r\n/** @internal */\r\nexport class LocalizationHelper {\r\n private _getLocalizedString: (key: string) => string;\r\n\r\n constructor(props: LocalizationHelperProps) {\r\n this._getLocalizedString = props.getLocalizedString;\r\n }\r\n\r\n public getLocalizedString(text: string) {\r\n return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, \"\")));\r\n }\r\n\r\n /* eslint-disable @typescript-eslint/no-deprecated */\r\n public getLocalizedNodes(nodes: Node[]): Node[] {\r\n return nodes.map((n) => this.getLocalizedNode(n));\r\n }\r\n\r\n public getLocalizedNode(node: Node): Node {\r\n return {\r\n ...node,\r\n label: this.getLocalizedLabelDefinition(node.label),\r\n ...(node.description ? { description: this.getLocalizedString(node.description) } : undefined),\r\n };\r\n }\r\n\r\n public getLocalizedNodePathElement(npe: NodePathElement): NodePathElement {\r\n return {\r\n ...npe,\r\n node: this.getLocalizedNode(npe.node),\r\n children: npe.children.map((c) => this.getLocalizedNodePathElement(c)),\r\n };\r\n }\r\n /* eslint-enable @typescript-eslint/no-deprecated */\r\n\r\n public getLocalizedDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup {\r\n return {\r\n ...group,\r\n displayValue: this.getLocalizedDisplayValue(group.displayValue),\r\n };\r\n }\r\n\r\n public getLocalizedLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition {\r\n const getLocalizedComposite = (compositeValue: LabelCompositeValue) => ({\r\n ...compositeValue,\r\n values: compositeValue.values.map((value) => this.getLocalizedLabelDefinition(value)),\r\n });\r\n\r\n if (labelDefinition.typeName === COMPOSITE_LABEL_DEFINITION_TYPENAME) {\r\n return {\r\n ...labelDefinition,\r\n rawValue: getLocalizedComposite(labelDefinition.rawValue as LabelCompositeValue),\r\n };\r\n }\r\n if (labelDefinition.typeName === \"string\") {\r\n return {\r\n ...labelDefinition,\r\n rawValue: this.getLocalizedString(labelDefinition.rawValue as string),\r\n displayValue: this.getLocalizedString(labelDefinition.displayValue),\r\n };\r\n }\r\n return labelDefinition;\r\n }\r\n\r\n public getLocalizedLabelDefinitions(labelDefinitions: LabelDefinition[]) {\r\n return labelDefinitions.map((labelDefinition) => this.getLocalizedLabelDefinition(labelDefinition));\r\n }\r\n\r\n public getLocalizedContentDescriptor(descriptor: Descriptor) {\r\n const clone = new Descriptor(descriptor);\r\n clone.fields.forEach((field) => this.getLocalizedContentField(field));\r\n clone.categories.forEach((category) => this.getLocalizedCategoryDescription(category));\r\n return clone;\r\n }\r\n\r\n public getLocalizedContentItems(items: Item[]): Item[] {\r\n return items.map((item) => this.getLocalizedContentItem(item));\r\n }\r\n\r\n public getLocalizedContent(content: Content): Content {\r\n return new Content(this.getLocalizedContentDescriptor(content.descriptor), this.getLocalizedContentItems(content.contentSet));\r\n }\r\n\r\n public getLocalizedElementProperties(elem: ElementProperties): ElementProperties {\r\n return {\r\n ...elem,\r\n label: this.getLocalizedString(elem.label),\r\n };\r\n }\r\n\r\n // warning: this function mutates the item\r\n private getLocalizedContentItem(item: Item): Item {\r\n item.label = this.getLocalizedLabelDefinition(item.label);\r\n item.values = Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});\r\n item.displayValues = Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\r\n return item;\r\n }\r\n\r\n private getLocalizedRawValue(value: Value): Value {\r\n if (typeof value === \"string\") {\r\n return this.getLocalizedString(value);\r\n }\r\n if (Value.isNavigationValue(value)) {\r\n return {\r\n ...value,\r\n label: this.getLocalizedLabelDefinition(value.label),\r\n };\r\n }\r\n if (Value.isNestedContent(value)) {\r\n return value.map((item) => ({\r\n ...item,\r\n values: Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {}),\r\n displayValues: Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {}),\r\n }));\r\n }\r\n if (Value.isArray(value)) {\r\n return value.map((v) => this.getLocalizedRawValue(v));\r\n }\r\n if (Value.isMap(value)) {\r\n return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});\r\n }\r\n return value;\r\n }\r\n\r\n // warning: this function mutates the field\r\n private getLocalizedContentField<TField extends Field>(field: TField) {\r\n field.label = this.getLocalizedString(field.label);\r\n if (field.isPropertiesField()) {\r\n if (field.isStructPropertiesField()) {\r\n field.memberFields = field.memberFields.map((m) => this.getLocalizedContentField(m));\r\n } else if (field.isArrayPropertiesField()) {\r\n field.itemsField = this.getLocalizedContentField(field.itemsField);\r\n }\r\n } else if (field.isNestedContentField()) {\r\n field.nestedFields = field.nestedFields.map((m) => this.getLocalizedContentField(m));\r\n }\r\n return field;\r\n }\r\n\r\n // warning: this function mutates the category\r\n private getLocalizedCategoryDescription(category: CategoryDescription) {\r\n category.label = this.getLocalizedString(category.label);\r\n category.description = this.getLocalizedString(category.description);\r\n return category;\r\n }\r\n\r\n private getLocalizedDisplayValue(value: DisplayValue): DisplayValue {\r\n if (typeof value === \"undefined\") {\r\n return undefined;\r\n }\r\n if (typeof value === \"string\") {\r\n return this.getLocalizedString(value);\r\n }\r\n if (DisplayValue.isArray(value)) {\r\n return value.map((v) => this.getLocalizedDisplayValue(v));\r\n }\r\n return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"LocalizationHelper.js","sourceRoot":"","sources":["../../../src/presentation-common/LocalizationHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAOH,iDAA4E;AAI5E,6DAAiH;AAEjH,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAMlD;;;;GAIG;AACH,MAAa,kBAAkB;IACrB,mBAAmB,CAA0B;IAErD,YAAY,KAA8B;QACxC,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,kBAAkB,CAAC;IACtD,CAAC;IAEM,kBAAkB,CAAC,IAAY;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACjG,CAAC;IAED,qDAAqD;IAC9C,aAAa,CAAC,KAAa;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAA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GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,oBAAoB,CAAC,KAAmB;QAC9C,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,uBAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBACtC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,+BAA+B,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA5JD,gDA4JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { CategoryDescription } from \"./content/Category.js\";\r\nimport { Content } from \"./content/Content.js\";\r\nimport { Descriptor } from \"./content/Descriptor.js\";\r\nimport { Field } from \"./content/Fields.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { DisplayValue, DisplayValueGroup, Value } from \"./content/Value.js\";\r\nimport { ElementProperties } from \"./ElementProperties.js\";\r\nimport { Node } from \"./hierarchy/Node.js\";\r\nimport { NodePathElement } from \"./hierarchy/NodePathElement.js\";\r\nimport { COMPOSITE_LABEL_DEFINITION_TYPENAME, LabelCompositeValue, LabelDefinition } from \"./LabelDefinition.js\";\r\n\r\nconst KEY_PATTERN = /@[\\w\\d\\-_]+:[\\w\\d\\-\\._]+?@/g;\r\n\r\ninterface LocalizationHelperProps {\r\n getLocalizedString: (key: string) => string;\r\n}\r\n\r\n/**\r\n * Localizes presentation data structures **in place**. Callers must pass a mutable graph owned by the current\r\n * operation and must not reuse it as untranslated data for another locale.\r\n * @internal\r\n */\r\nexport class LocalizationHelper {\r\n private _getLocalizedString: (key: string) => string;\r\n\r\n constructor(props: LocalizationHelperProps) {\r\n this._getLocalizedString = props.getLocalizedString;\r\n }\r\n\r\n public getLocalizedString(text: string) {\r\n return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, \"\")));\r\n }\r\n\r\n /* eslint-disable @typescript-eslint/no-deprecated */\r\n public localizeNodes(nodes: Node[]): Node[] {\r\n nodes.forEach((n) => this.localizeNode(n));\r\n return nodes;\r\n }\r\n\r\n public localizeNode(node: Node): Node {\r\n this.localizeLabelDefinition(node.label);\r\n if (node.description) {\r\n node.description = this.getLocalizedString(node.description);\r\n }\r\n return node;\r\n }\r\n\r\n public localizeNodePathElement(npe: NodePathElement): NodePathElement {\r\n this.localizeNode(npe.node);\r\n npe.children.forEach((c) => this.localizeNodePathElement(c));\r\n return npe;\r\n }\r\n /* eslint-enable @typescript-eslint/no-deprecated */\r\n\r\n public localizeDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup {\r\n group.displayValue = this.localizeDisplayValue(group.displayValue);\r\n return group;\r\n }\r\n\r\n public localizeLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition {\r\n if (labelDefinition.typeName === COMPOSITE_LABEL_DEFINITION_TYPENAME) {\r\n (labelDefinition.rawValue as LabelCompositeValue).values.forEach((value) => this.localizeLabelDefinition(value));\r\n } else if (labelDefinition.typeName === \"string\") {\r\n labelDefinition.rawValue = this.getLocalizedString(labelDefinition.rawValue as string);\r\n labelDefinition.displayValue = this.getLocalizedString(labelDefinition.displayValue);\r\n }\r\n return labelDefinition;\r\n }\r\n\r\n public localizeLabelDefinitions(labelDefinitions: LabelDefinition[]) {\r\n labelDefinitions.forEach((labelDefinition) => this.localizeLabelDefinition(labelDefinition));\r\n return labelDefinitions;\r\n }\r\n\r\n public localizeContentDescriptor(descriptor: Descriptor) {\r\n descriptor.fields.forEach((field) => this.localizeContentField(field));\r\n descriptor.categories.forEach((category) => this.localizeCategoryDescription(category));\r\n return descriptor;\r\n }\r\n\r\n public localizeContentItems(items: Item[]): Item[] {\r\n items.forEach((item) => this.localizeContentItem(item));\r\n return items;\r\n }\r\n\r\n public localizeContent(content: Content): Content {\r\n this.localizeContentDescriptor(content.descriptor);\r\n this.localizeContentItems(content.contentSet);\r\n return content;\r\n }\r\n\r\n public localizeElementProperties(elem: ElementProperties): ElementProperties {\r\n elem.label = this.getLocalizedString(elem.label);\r\n return elem;\r\n }\r\n\r\n private localizeContentItem(item: Item): Item {\r\n this.localizeLabelDefinition(item.label);\r\n this.localizeRawValuesDictionary(item.values);\r\n this.localizeDisplayValuesDictionary(item.displayValues);\r\n return item;\r\n }\r\n\r\n private localizeRawValuesDictionary(values: { [key: string]: Value }) {\r\n for (const key of Object.keys(values)) {\r\n values[key] = this.localizeRawValue(values[key]);\r\n }\r\n }\r\n\r\n private localizeDisplayValuesDictionary(values: { [key: string]: DisplayValue }) {\r\n for (const key of Object.keys(values)) {\r\n values[key] = this.localizeDisplayValue(values[key]);\r\n }\r\n }\r\n\r\n private localizeRawValue(value: Value): Value {\r\n if (typeof value === \"string\") {\r\n return this.getLocalizedString(value);\r\n }\r\n if (Value.isNavigationValue(value)) {\r\n this.localizeLabelDefinition(value.label);\r\n return value;\r\n }\r\n if (Value.isNestedContent(value)) {\r\n value.forEach((item) => {\r\n this.localizeRawValuesDictionary(item.values);\r\n this.localizeDisplayValuesDictionary(item.displayValues);\r\n });\r\n return value;\r\n }\r\n if (Value.isArray(value)) {\r\n for (let i = 0; i < value.length; ++i) {\r\n value[i] = this.localizeRawValue(value[i]);\r\n }\r\n return value;\r\n }\r\n if (Value.isMap(value)) {\r\n this.localizeRawValuesDictionary(value);\r\n }\r\n return value;\r\n }\r\n\r\n private localizeContentField(field: Field) {\r\n field.label = this.getLocalizedString(field.label);\r\n if (field.isPropertiesField()) {\r\n if (field.isStructPropertiesField()) {\r\n field.memberFields.forEach((m) => this.localizeContentField(m));\r\n } else if (field.isArrayPropertiesField()) {\r\n this.localizeContentField(field.itemsField);\r\n }\r\n } else if (field.isNestedContentField()) {\r\n field.nestedFields.forEach((m) => this.localizeContentField(m));\r\n }\r\n return field;\r\n }\r\n\r\n private localizeCategoryDescription(category: CategoryDescription) {\r\n category.label = this.getLocalizedString(category.label);\r\n category.description = this.getLocalizedString(category.description);\r\n return category;\r\n }\r\n\r\n private localizeDisplayValue(value: DisplayValue): DisplayValue {\r\n if (typeof value === \"undefined\") {\r\n return undefined;\r\n }\r\n if (typeof value === \"string\") {\r\n return this.getLocalizedString(value);\r\n }\r\n if (DisplayValue.isArray(value)) {\r\n for (let i = 0; i < value.length; ++i) {\r\n value[i] = this.localizeDisplayValue(value[i]);\r\n }\r\n return value;\r\n }\r\n this.localizeDisplayValuesDictionary(value);\r\n return value;\r\n }\r\n}\r\n"]}
@@ -42,7 +42,7 @@ export interface RequestOptionsWithRuleset<TIModel, TRulesetVariable = RulesetVa
42
42
  /**
43
43
  * Request type for hierarchy requests.
44
44
  * @public
45
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
45
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
46
46
  * package for creating hierarchies.
47
47
  */
48
48
  export interface HierarchyRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {
@@ -70,7 +70,7 @@ export interface HierarchyRequestOptions<TIModel, TNodeKey, TRulesetVariable = R
70
70
  /**
71
71
  * Params for hierarchy level descriptor requests.
72
72
  * @public
73
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
73
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
74
74
  * package for creating hierarchies.
75
75
  */
76
76
  export interface HierarchyLevelDescriptorRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {
@@ -80,7 +80,7 @@ export interface HierarchyLevelDescriptorRequestOptions<TIModel, TNodeKey, TRule
80
80
  /**
81
81
  * Request type of filtering hierarchies by given ECInstance paths.
82
82
  * @public
83
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
83
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
84
84
  * package for creating hierarchies.
85
85
  */
86
86
  export interface FilterByInstancePathsHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {
@@ -95,7 +95,7 @@ export interface FilterByInstancePathsHierarchyRequestOptions<TIModel, TRulesetV
95
95
  /**
96
96
  * Request type of filtering hierarchies by given text.
97
97
  * @public
98
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
98
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
99
99
  * package for creating hierarchies.
100
100
  */
101
101
  export interface FilterByTextHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {
@@ -274,7 +274,7 @@ export interface ComputeSelectionRequestOptions<TIModel> extends RequestOptions<
274
274
  /**
275
275
  * Data structure for comparing a hierarchy after ruleset or ruleset variable changes.
276
276
  * @public
277
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
277
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
278
278
  * package for creating hierarchies.
279
279
  */
280
280
  export interface HierarchyCompareOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationManagerOptions.js","sourceRoot":"","sources":["../../../src/presentation-common/PresentationManagerOptions.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;AA4WH,0FAIC;AARD;;;GAGG;AACH,SAAgB,uCAAuC,CACrD,OAAuH;IAEvH,OAAQ,OAA0D,CAAC,SAAS,KAAK,SAAS,CAAC;AAC7F,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { BeEvent, Id64String } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { Descriptor, DescriptorFieldsSelector, SelectionInfo } from \"./content/Descriptor.js\";\r\nimport { FieldDescriptor } from \"./content/Fields.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { InstanceKey } from \"./EC.js\";\r\nimport { ElementProperties } from \"./ElementProperties.js\";\r\nimport { InstanceFilterDefinition } from \"./InstanceFilterDefinition.js\";\r\nimport { Ruleset } from \"./rules/Ruleset.js\";\r\nimport { RulesetVariable } from \"./RulesetVariables.js\";\r\nimport { SelectionScopeProps } from \"./selection/SelectionScope.js\";\r\n\r\n/**\r\n * A generic request options type used for both hierarchy and content requests.\r\n * @public\r\n */\r\nexport interface RequestOptions<TIModel> {\r\n /** iModel to request data from */\r\n imodel: TIModel;\r\n\r\n /** Optional locale to use when formatting / localizing data */\r\n locale?: string;\r\n\r\n /**\r\n * Unit system to use when formatting property values with units. Default presentation\r\n * unit is used if unit system is not specified.\r\n */\r\n unitSystem?: UnitSystemKey;\r\n}\r\n\r\n/**\r\n * Options for requests that require presentation ruleset. Not\r\n * meant to be used directly, see one of the subclasses.\r\n *\r\n * @public\r\n */\r\nexport interface RequestOptionsWithRuleset<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptions<TIModel> {\r\n /** Ruleset or id of the ruleset to use when requesting data */\r\n rulesetOrId: Ruleset | string;\r\n\r\n /** Ruleset variables to use when requesting data */\r\n rulesetVariables?: TRulesetVariable[];\r\n}\r\n\r\n/**\r\n * Request type for hierarchy requests.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Key of the parent node to get children for */\r\n parentKey?: TNodeKey;\r\n\r\n /**\r\n * An instance filter that should be applied for this hierarchy level.\r\n *\r\n * **Note:** May only be used on hierarchy levels that support filtering - check [[NavNode.supportsFiltering]] before\r\n * requesting filtered children.\r\n */\r\n instanceFilter?: InstanceFilterDefinition;\r\n\r\n /**\r\n * A limit to how many instances at most should be loaded for a hierarchy level. If the limit is exceeded,\r\n * the request fails with [[PresentationError]] having [[PresentationStatus.ResultSetTooLarge]] error number.\r\n *\r\n * Specifying the limit is useful when creating unlimited size result sets is not meaningful - this allows the library\r\n * to return early as soon as the limit is reached, instead of creating a very large result that's possibly too large to\r\n * be useful to be displayed to end users.\r\n *\r\n * @see [Hierarchies' filtering and limiting]($docs/presentation/hierarchies/FilteringLimiting.md)\r\n */\r\n sizeLimit?: number;\r\n}\r\n\r\n/**\r\n * Params for hierarchy level descriptor requests.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyLevelDescriptorRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Key of the parent node to get hierarchy level descriptor for. */\r\n parentKey?: TNodeKey;\r\n}\r\n\r\n/**\r\n * Request type of filtering hierarchies by given ECInstance paths.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface FilterByInstancePathsHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** A list of paths from root ECInstance to target ECInstance. */\r\n instancePaths: InstanceKey[][];\r\n\r\n /**\r\n * An optional index (`0 <= markedIndex < instancePaths.length`) to mark one of the instance paths. The\r\n * path is marked using `NodePathElement.isMarked` flag in the result.\r\n */\r\n markedIndex?: number;\r\n}\r\n\r\n/**\r\n * Request type of filtering hierarchies by given text.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface FilterByTextHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Text to filter the hierarchy by. */\r\n filterText: string;\r\n}\r\n\r\n/**\r\n * Request type for content sources requests.\r\n * @public\r\n */\r\nexport interface ContentSourcesRequestOptions<TIModel> extends RequestOptions<TIModel> {\r\n /** Full names of classes to get content sources for. Format for a full class name: `SchemaName:ClassName`. */\r\n classes: string[];\r\n}\r\n\r\n/**\r\n * Request type for content descriptor requests.\r\n * @public\r\n */\r\nexport interface ContentDescriptorRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /**\r\n * Content display type.\r\n * @see [[DefaultContentDisplayTypes]]\r\n */\r\n displayType: string;\r\n /**\r\n * Content flags used for content customization.\r\n * @see [[ContentFlags]]\r\n */\r\n contentFlags?: number;\r\n /** Input keys for getting the content */\r\n keys: TKeySet;\r\n /** Information about the selection event that was the cause of this content request */\r\n selection?: SelectionInfo;\r\n}\r\n\r\n/**\r\n * Request type for content requests.\r\n * @public\r\n */\r\nexport interface ContentRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Content descriptor for customizing the returned content */\r\n descriptor: TDescriptor;\r\n /** Input keys for getting the content */\r\n keys: TKeySet;\r\n /**\r\n * Flag that specifies whether value formatting should be omitted or not.\r\n * Content is returned without `displayValues` when this is set to `true`.\r\n */\r\n omitFormattedValues?: boolean;\r\n}\r\n\r\n/**\r\n * Request type for distinct values' requests.\r\n * @public\r\n */\r\nexport interface DistinctValuesRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\r\n /** Content descriptor for customizing the returned content */\r\n descriptor: TDescriptor;\r\n /** Input keys for getting the content */\r\n keys: TKeySet;\r\n /** Descriptor for a field distinct values are requested for */\r\n fieldDescriptor: FieldDescriptor;\r\n}\r\n\r\n/**\r\n * Request type for element properties requests\r\n * @public\r\n * @deprecated in 4.4.0 - might be removed in next major version. Use [[SingleElementPropertiesRequestOptions]] or [[MultiElementPropertiesRequestOptions]] directly.\r\n */\r\nexport type ElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> =\r\n | SingleElementPropertiesRequestOptions<TIModel>\r\n | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>;\r\n\r\n/**\r\n * Request type for single element properties requests.\r\n * @public\r\n */\r\nexport interface SingleElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> extends RequestOptions<TIModel> {\r\n /** ID of the element to get properties for. */\r\n elementId: Id64String;\r\n\r\n /**\r\n * Content parser that creates a result item based on given content descriptor and content item. Defaults\r\n * to a parser that creates [[ElementProperties]] objects.\r\n */\r\n contentParser?: (descriptor: Descriptor, item: Item) => TParsedContent;\r\n}\r\n\r\n/**\r\n * Base request type for multiple elements properties requests.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesBaseRequestOptions<TIModel, TParsedContent = ElementProperties> extends RequestOptions<TIModel> {\r\n /**\r\n * Content parser that creates a result item based on given content descriptor and content item. Defaults\r\n * to a parser that creates [[ElementProperties]] objects.\r\n */\r\n contentParser?: (descriptor: Descriptor, item: Item) => TParsedContent;\r\n\r\n /**\r\n * A callback that allows specifying which fields should be included or excluded in the result based on the given content descriptor. This\r\n * is useful when requesting properties of multiple elements, where the result set can be very large and it may be desirable to only get a\r\n * subset of all available fields.\r\n */\r\n fieldsSelector?: (descriptor: Descriptor) => DescriptorFieldsSelector | undefined;\r\n\r\n /**\r\n * The properties of multiple elements are going to be retrieved and returned in batches. Depending on the batch\r\n * size load on CPU vs MEMORY load may vary, so changing this attribute allows fine tuning the performance.\r\n * Defaults to `1000`.\r\n */\r\n batchSize?: number;\r\n}\r\n/**\r\n * Request type for multiple elements properties requests, where elements are specified by class.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesByClassRequestOptions<TIModel, TParsedContent = ElementProperties>\r\n extends MultiElementPropertiesBaseRequestOptions<TIModel, TParsedContent> {\r\n /**\r\n * Classes of the elements to get properties for. If [[elementClasses]] is `undefined`, all classes\r\n * are used. Classes should be specified in one of these formats: \"<schema name or alias>.<class_name>\" or\r\n * \"<schema name or alias>:<class_name>\".\r\n */\r\n elementClasses?: string[];\r\n}\r\n/**\r\n * Request type for multiple elements properties requests, where elements are specified by element id.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesByIdsRequestOptions<TIModel, TParsedContent = ElementProperties>\r\n extends MultiElementPropertiesBaseRequestOptions<TIModel, TParsedContent> {\r\n /**\r\n * A list of `bis.Element` IDs to get properties for.\r\n */\r\n elementIds?: Id64String[];\r\n}\r\n/**\r\n * Request type for multiple elements properties requests.\r\n * @public\r\n */\r\nexport type MultiElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> =\r\n | MultiElementPropertiesByClassRequestOptions<TIModel, TParsedContent>\r\n | MultiElementPropertiesByIdsRequestOptions<TIModel, TParsedContent>;\r\n\r\n/**\r\n * Request type for content instance keys' requests.\r\n * @public\r\n */\r\nexport interface ContentInstanceKeysRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\r\n /**\r\n * Content display type.\r\n * @see [[DefaultContentDisplayTypes]]\r\n */\r\n displayType?: string;\r\n /** Input keys for getting the content. */\r\n keys: TKeySet;\r\n}\r\n\r\n/**\r\n * Request type for label requests\r\n * @public\r\n */\r\nexport interface DisplayLabelRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\r\n /** Key of ECInstance to get label for */\r\n key: TInstanceKey;\r\n}\r\n\r\n/**\r\n * Request type for labels requests\r\n * @public\r\n */\r\nexport interface DisplayLabelsRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\r\n /** Keys of ECInstances to get labels for */\r\n keys: TInstanceKey[];\r\n}\r\n\r\n/**\r\n * Request options used for selection scope related requests\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\nexport interface SelectionScopeRequestOptions<TIModel> extends RequestOptions<TIModel> {} // eslint-disable-line @typescript-eslint/no-empty-object-type\r\n\r\n/**\r\n * Request options used for calculating selection based on given instance keys and selection scope.\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\nexport interface ComputeSelectionRequestOptions<TIModel> extends RequestOptions<TIModel> {\r\n elementIds: Id64String[];\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n scope: SelectionScopeProps;\r\n}\r\n\r\n/**\r\n * Data structure for comparing a hierarchy after ruleset or ruleset variable changes.\r\n * @public\r\n * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyCompareOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n prev: {\r\n rulesetOrId?: Ruleset | string;\r\n rulesetVariables?: TRulesetVariable[];\r\n };\r\n expandedNodeKeys?: TNodeKey[];\r\n continuationToken?: {\r\n prevHierarchyNode: string;\r\n currHierarchyNode: string;\r\n };\r\n resultSetSize?: number;\r\n}\r\n\r\n/**\r\n * Paging options\r\n * @public\r\n */\r\nexport interface PageOptions {\r\n /** Inclusive start 0-based index of the page */\r\n start?: number;\r\n /** Maximum size of the page */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * A wrapper type that injects [[PageOptions]] into supplied type\r\n * @public\r\n */\r\nexport type Paged<TOptions extends object> = TOptions & {\r\n /** Optional paging parameters */\r\n paging?: PageOptions;\r\n};\r\n\r\n/**\r\n * A wrapper type that injects priority into supplied type.\r\n * @public\r\n */\r\nexport type Prioritized<TOptions extends object> = TOptions & {\r\n /** Optional priority */\r\n priority?: number;\r\n};\r\n\r\n/**\r\n * Checks if supplied request options are for single or multiple element properties.\r\n * @internal\r\n */\r\nexport function isSingleElementPropertiesRequestOptions<TIModel, TParsedContent = any>(\r\n options: SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>,\r\n): options is SingleElementPropertiesRequestOptions<TIModel> {\r\n return (options as SingleElementPropertiesRequestOptions<TIModel>).elementId !== undefined;\r\n}\r\n\r\n/**\r\n * A wrapper type that injects cancelEvent into supplied type.\r\n * @public\r\n */\r\nexport type WithCancelEvent<TOptions extends object> = TOptions & {\r\n /** Event which is triggered when the request is canceled */\r\n cancelEvent?: BeEvent<() => void>;\r\n};\r\n"]}
1
+ {"version":3,"file":"PresentationManagerOptions.js","sourceRoot":"","sources":["../../../src/presentation-common/PresentationManagerOptions.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;AA4WH,0FAIC;AARD;;;GAGG;AACH,SAAgB,uCAAuC,CACrD,OAAuH;IAEvH,OAAQ,OAA0D,CAAC,SAAS,KAAK,SAAS,CAAC;AAC7F,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { BeEvent, Id64String } from \"@itwin/core-bentley\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { Descriptor, DescriptorFieldsSelector, SelectionInfo } from \"./content/Descriptor.js\";\r\nimport { FieldDescriptor } from \"./content/Fields.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { InstanceKey } from \"./EC.js\";\r\nimport { ElementProperties } from \"./ElementProperties.js\";\r\nimport { InstanceFilterDefinition } from \"./InstanceFilterDefinition.js\";\r\nimport { Ruleset } from \"./rules/Ruleset.js\";\r\nimport { RulesetVariable } from \"./RulesetVariables.js\";\r\nimport { SelectionScopeProps } from \"./selection/SelectionScope.js\";\r\n\r\n/**\r\n * A generic request options type used for both hierarchy and content requests.\r\n * @public\r\n */\r\nexport interface RequestOptions<TIModel> {\r\n /** iModel to request data from */\r\n imodel: TIModel;\r\n\r\n /** Optional locale to use when formatting / localizing data */\r\n locale?: string;\r\n\r\n /**\r\n * Unit system to use when formatting property values with units. Default presentation\r\n * unit is used if unit system is not specified.\r\n */\r\n unitSystem?: UnitSystemKey;\r\n}\r\n\r\n/**\r\n * Options for requests that require presentation ruleset. Not\r\n * meant to be used directly, see one of the subclasses.\r\n *\r\n * @public\r\n */\r\nexport interface RequestOptionsWithRuleset<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptions<TIModel> {\r\n /** Ruleset or id of the ruleset to use when requesting data */\r\n rulesetOrId: Ruleset | string;\r\n\r\n /** Ruleset variables to use when requesting data */\r\n rulesetVariables?: TRulesetVariable[];\r\n}\r\n\r\n/**\r\n * Request type for hierarchy requests.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Key of the parent node to get children for */\r\n parentKey?: TNodeKey;\r\n\r\n /**\r\n * An instance filter that should be applied for this hierarchy level.\r\n *\r\n * **Note:** May only be used on hierarchy levels that support filtering - check [[NavNode.supportsFiltering]] before\r\n * requesting filtered children.\r\n */\r\n instanceFilter?: InstanceFilterDefinition;\r\n\r\n /**\r\n * A limit to how many instances at most should be loaded for a hierarchy level. If the limit is exceeded,\r\n * the request fails with [[PresentationError]] having [[PresentationStatus.ResultSetTooLarge]] error number.\r\n *\r\n * Specifying the limit is useful when creating unlimited size result sets is not meaningful - this allows the library\r\n * to return early as soon as the limit is reached, instead of creating a very large result that's possibly too large to\r\n * be useful to be displayed to end users.\r\n *\r\n * @see [Hierarchies' filtering and limiting]($docs/presentation/hierarchies/FilteringLimiting.md)\r\n */\r\n sizeLimit?: number;\r\n}\r\n\r\n/**\r\n * Params for hierarchy level descriptor requests.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyLevelDescriptorRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Key of the parent node to get hierarchy level descriptor for. */\r\n parentKey?: TNodeKey;\r\n}\r\n\r\n/**\r\n * Request type of filtering hierarchies by given ECInstance paths.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface FilterByInstancePathsHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** A list of paths from root ECInstance to target ECInstance. */\r\n instancePaths: InstanceKey[][];\r\n\r\n /**\r\n * An optional index (`0 <= markedIndex < instancePaths.length`) to mark one of the instance paths. The\r\n * path is marked using `NodePathElement.isMarked` flag in the result.\r\n */\r\n markedIndex?: number;\r\n}\r\n\r\n/**\r\n * Request type of filtering hierarchies by given text.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface FilterByTextHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Text to filter the hierarchy by. */\r\n filterText: string;\r\n}\r\n\r\n/**\r\n * Request type for content sources requests.\r\n * @public\r\n */\r\nexport interface ContentSourcesRequestOptions<TIModel> extends RequestOptions<TIModel> {\r\n /** Full names of classes to get content sources for. Format for a full class name: `SchemaName:ClassName`. */\r\n classes: string[];\r\n}\r\n\r\n/**\r\n * Request type for content descriptor requests.\r\n * @public\r\n */\r\nexport interface ContentDescriptorRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /**\r\n * Content display type.\r\n * @see [[DefaultContentDisplayTypes]]\r\n */\r\n displayType: string;\r\n /**\r\n * Content flags used for content customization.\r\n * @see [[ContentFlags]]\r\n */\r\n contentFlags?: number;\r\n /** Input keys for getting the content */\r\n keys: TKeySet;\r\n /** Information about the selection event that was the cause of this content request */\r\n selection?: SelectionInfo;\r\n}\r\n\r\n/**\r\n * Request type for content requests.\r\n * @public\r\n */\r\nexport interface ContentRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n /** Content descriptor for customizing the returned content */\r\n descriptor: TDescriptor;\r\n /** Input keys for getting the content */\r\n keys: TKeySet;\r\n /**\r\n * Flag that specifies whether value formatting should be omitted or not.\r\n * Content is returned without `displayValues` when this is set to `true`.\r\n */\r\n omitFormattedValues?: boolean;\r\n}\r\n\r\n/**\r\n * Request type for distinct values' requests.\r\n * @public\r\n */\r\nexport interface DistinctValuesRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\r\n /** Content descriptor for customizing the returned content */\r\n descriptor: TDescriptor;\r\n /** Input keys for getting the content */\r\n keys: TKeySet;\r\n /** Descriptor for a field distinct values are requested for */\r\n fieldDescriptor: FieldDescriptor;\r\n}\r\n\r\n/**\r\n * Request type for element properties requests\r\n * @public\r\n * @deprecated in 4.4.0 - might be removed in next major version. Use [[SingleElementPropertiesRequestOptions]] or [[MultiElementPropertiesRequestOptions]] directly.\r\n */\r\nexport type ElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> =\r\n | SingleElementPropertiesRequestOptions<TIModel>\r\n | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>;\r\n\r\n/**\r\n * Request type for single element properties requests.\r\n * @public\r\n */\r\nexport interface SingleElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> extends RequestOptions<TIModel> {\r\n /** ID of the element to get properties for. */\r\n elementId: Id64String;\r\n\r\n /**\r\n * Content parser that creates a result item based on given content descriptor and content item. Defaults\r\n * to a parser that creates [[ElementProperties]] objects.\r\n */\r\n contentParser?: (descriptor: Descriptor, item: Item) => TParsedContent;\r\n}\r\n\r\n/**\r\n * Base request type for multiple elements properties requests.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesBaseRequestOptions<TIModel, TParsedContent = ElementProperties> extends RequestOptions<TIModel> {\r\n /**\r\n * Content parser that creates a result item based on given content descriptor and content item. Defaults\r\n * to a parser that creates [[ElementProperties]] objects.\r\n */\r\n contentParser?: (descriptor: Descriptor, item: Item) => TParsedContent;\r\n\r\n /**\r\n * A callback that allows specifying which fields should be included or excluded in the result based on the given content descriptor. This\r\n * is useful when requesting properties of multiple elements, where the result set can be very large and it may be desirable to only get a\r\n * subset of all available fields.\r\n */\r\n fieldsSelector?: (descriptor: Descriptor) => DescriptorFieldsSelector | undefined;\r\n\r\n /**\r\n * The properties of multiple elements are going to be retrieved and returned in batches. Depending on the batch\r\n * size load on CPU vs MEMORY load may vary, so changing this attribute allows fine tuning the performance.\r\n * Defaults to `1000`.\r\n */\r\n batchSize?: number;\r\n}\r\n/**\r\n * Request type for multiple elements properties requests, where elements are specified by class.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesByClassRequestOptions<TIModel, TParsedContent = ElementProperties>\r\n extends MultiElementPropertiesBaseRequestOptions<TIModel, TParsedContent> {\r\n /**\r\n * Classes of the elements to get properties for. If [[elementClasses]] is `undefined`, all classes\r\n * are used. Classes should be specified in one of these formats: \"<schema name or alias>.<class_name>\" or\r\n * \"<schema name or alias>:<class_name>\".\r\n */\r\n elementClasses?: string[];\r\n}\r\n/**\r\n * Request type for multiple elements properties requests, where elements are specified by element id.\r\n * @public\r\n */\r\nexport interface MultiElementPropertiesByIdsRequestOptions<TIModel, TParsedContent = ElementProperties>\r\n extends MultiElementPropertiesBaseRequestOptions<TIModel, TParsedContent> {\r\n /**\r\n * A list of `bis.Element` IDs to get properties for.\r\n */\r\n elementIds?: Id64String[];\r\n}\r\n/**\r\n * Request type for multiple elements properties requests.\r\n * @public\r\n */\r\nexport type MultiElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> =\r\n | MultiElementPropertiesByClassRequestOptions<TIModel, TParsedContent>\r\n | MultiElementPropertiesByIdsRequestOptions<TIModel, TParsedContent>;\r\n\r\n/**\r\n * Request type for content instance keys' requests.\r\n * @public\r\n */\r\nexport interface ContentInstanceKeysRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable>\r\n extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\r\n /**\r\n * Content display type.\r\n * @see [[DefaultContentDisplayTypes]]\r\n */\r\n displayType?: string;\r\n /** Input keys for getting the content. */\r\n keys: TKeySet;\r\n}\r\n\r\n/**\r\n * Request type for label requests\r\n * @public\r\n */\r\nexport interface DisplayLabelRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\r\n /** Key of ECInstance to get label for */\r\n key: TInstanceKey;\r\n}\r\n\r\n/**\r\n * Request type for labels requests\r\n * @public\r\n */\r\nexport interface DisplayLabelsRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\r\n /** Keys of ECInstances to get labels for */\r\n keys: TInstanceKey[];\r\n}\r\n\r\n/**\r\n * Request options used for selection scope related requests\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\nexport interface SelectionScopeRequestOptions<TIModel> extends RequestOptions<TIModel> {} // eslint-disable-line @typescript-eslint/no-empty-object-type\r\n\r\n/**\r\n * Request options used for calculating selection based on given instance keys and selection scope.\r\n * @public\r\n * @deprecated in 5.0 - might be removed in next major version. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.\r\n */\r\nexport interface ComputeSelectionRequestOptions<TIModel> extends RequestOptions<TIModel> {\r\n elementIds: Id64String[];\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n scope: SelectionScopeProps;\r\n}\r\n\r\n/**\r\n * Data structure for comparing a hierarchy after ruleset or ruleset variable changes.\r\n * @public\r\n * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)\r\n * package for creating hierarchies.\r\n */\r\nexport interface HierarchyCompareOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\r\n prev: {\r\n rulesetOrId?: Ruleset | string;\r\n rulesetVariables?: TRulesetVariable[];\r\n };\r\n expandedNodeKeys?: TNodeKey[];\r\n continuationToken?: {\r\n prevHierarchyNode: string;\r\n currHierarchyNode: string;\r\n };\r\n resultSetSize?: number;\r\n}\r\n\r\n/**\r\n * Paging options\r\n * @public\r\n */\r\nexport interface PageOptions {\r\n /** Inclusive start 0-based index of the page */\r\n start?: number;\r\n /** Maximum size of the page */\r\n size?: number;\r\n}\r\n\r\n/**\r\n * A wrapper type that injects [[PageOptions]] into supplied type\r\n * @public\r\n */\r\nexport type Paged<TOptions extends object> = TOptions & {\r\n /** Optional paging parameters */\r\n paging?: PageOptions;\r\n};\r\n\r\n/**\r\n * A wrapper type that injects priority into supplied type.\r\n * @public\r\n */\r\nexport type Prioritized<TOptions extends object> = TOptions & {\r\n /** Optional priority */\r\n priority?: number;\r\n};\r\n\r\n/**\r\n * Checks if supplied request options are for single or multiple element properties.\r\n * @internal\r\n */\r\nexport function isSingleElementPropertiesRequestOptions<TIModel, TParsedContent = any>(\r\n options: SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>,\r\n): options is SingleElementPropertiesRequestOptions<TIModel> {\r\n return (options as SingleElementPropertiesRequestOptions<TIModel>).elementId !== undefined;\r\n}\r\n\r\n/**\r\n * A wrapper type that injects cancelEvent into supplied type.\r\n * @public\r\n */\r\nexport type WithCancelEvent<TOptions extends object> = TOptions & {\r\n /** Event which is triggered when the request is canceled */\r\n cancelEvent?: BeEvent<() => void>;\r\n};\r\n"]}
@@ -56,28 +56,28 @@ export type PresentationRpcResponse<TResult = undefined> = Promise<PresentationR
56
56
  /**
57
57
  * Data structure for hierarchy request options.
58
58
  * @public
59
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
59
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
60
60
  * package for creating hierarchies.
61
61
  */
62
62
  export type HierarchyRpcRequestOptions = PresentationRpcRequestOptions<HierarchyRequestOptions<never, NodeKey, RulesetVariableJSON>>;
63
63
  /**
64
64
  * Data structure for hierarchy level descriptor RPC request options.
65
65
  * @public
66
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
66
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
67
67
  * package for creating hierarchies.
68
68
  */
69
69
  export type HierarchyLevelDescriptorRpcRequestOptions = PresentationRpcRequestOptions<HierarchyLevelDescriptorRequestOptions<never, NodeKey, RulesetVariableJSON>>;
70
70
  /**
71
71
  * Data structure for filtering hierarchy by ECInstance paths request options.
72
72
  * @public
73
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
73
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
74
74
  * package for creating hierarchies.
75
75
  */
76
76
  export type FilterByInstancePathsHierarchyRpcRequestOptions = PresentationRpcRequestOptions<FilterByInstancePathsHierarchyRequestOptions<never, RulesetVariableJSON>>;
77
77
  /**
78
78
  * Data structure for filtering hierarchy by text request options.
79
79
  * @public
80
- * @deprecated in 5.2 - will not be removed until after 2026-10-01. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
80
+ * @deprecated in 5.2 - might be removed in next major version. Use the new [@itwin/presentation-hierarchies](https://github.com/iTwin/presentation/blob/master/packages/hierarchies/README.md)
81
81
  * package for creating hierarchies.
82
82
  */
83
83
  export type FilterByTextHierarchyRpcRequestOptions = PresentationRpcRequestOptions<FilterByTextHierarchyRequestOptions<never, RulesetVariableJSON>>;