@itwin/presentation-common 4.4.0-dev.8 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/lib/cjs/presentation-common/LocalizationHelper.d.ts +16 -9
  3. package/lib/cjs/presentation-common/LocalizationHelper.d.ts.map +1 -1
  4. package/lib/cjs/presentation-common/LocalizationHelper.js +93 -68
  5. package/lib/cjs/presentation-common/LocalizationHelper.js.map +1 -1
  6. package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts +24 -4
  7. package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
  8. package/lib/cjs/presentation-common/PresentationManagerOptions.js.map +1 -1
  9. package/lib/cjs/presentation-common/content/Item.d.ts +13 -0
  10. package/lib/cjs/presentation-common/content/Item.d.ts.map +1 -1
  11. package/lib/cjs/presentation-common/content/Item.js +22 -0
  12. package/lib/cjs/presentation-common/content/Item.js.map +1 -1
  13. package/lib/cjs/presentation-common/content/PropertyValueFormatter.d.ts +3 -0
  14. package/lib/cjs/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -1
  15. package/lib/cjs/presentation-common/content/PropertyValueFormatter.js +8 -4
  16. package/lib/cjs/presentation-common/content/PropertyValueFormatter.js.map +1 -1
  17. package/lib/esm/presentation-common/LocalizationHelper.d.ts +16 -9
  18. package/lib/esm/presentation-common/LocalizationHelper.d.ts.map +1 -1
  19. package/lib/esm/presentation-common/LocalizationHelper.js +93 -68
  20. package/lib/esm/presentation-common/LocalizationHelper.js.map +1 -1
  21. package/lib/esm/presentation-common/PresentationManagerOptions.d.ts +24 -4
  22. package/lib/esm/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
  23. package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
  24. package/lib/esm/presentation-common/content/Item.d.ts +13 -0
  25. package/lib/esm/presentation-common/content/Item.d.ts.map +1 -1
  26. package/lib/esm/presentation-common/content/Item.js +22 -0
  27. package/lib/esm/presentation-common/content/Item.js.map +1 -1
  28. package/lib/esm/presentation-common/content/PropertyValueFormatter.d.ts +3 -0
  29. package/lib/esm/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -1
  30. package/lib/esm/presentation-common/content/PropertyValueFormatter.js +8 -4
  31. package/lib/esm/presentation-common/content/PropertyValueFormatter.js.map +1 -1
  32. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Change Log - @itwin/presentation-common
2
2
 
3
- This log was last generated on Thu, 14 Dec 2023 20:24:02 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 12 Feb 2024 18:15:58 GMT and should not be manually modified.
4
+
5
+ ## 4.4.0
6
+ Mon, 12 Feb 2024 18:15:58 GMT
7
+
8
+ ### Updates
9
+
10
+ - Handle SI and METRIC unit systems as a single unit system. This fixes a problem where temperatures are formatted in Kelvin even though metric was requested.
11
+ - Provide an option to control batch size for `PresentationManager.getElementProperties` multi-elements case.
12
+ - Add formatting for kind of quantity point properties.
13
+ - Add support for default formats in `KoqPropertyValueFormatter`.
14
+
15
+ ## 4.3.3
16
+ Wed, 03 Jan 2024 19:28:38 GMT
17
+
18
+ _Version update only_
4
19
 
5
20
  ## 4.3.2
6
21
  Thu, 14 Dec 2023 20:23:02 GMT
@@ -1,10 +1,14 @@
1
1
  /** @packageDocumentation
2
2
  * @module Core
3
3
  */
4
- import { Node } from "./hierarchy/Node";
5
4
  import { Content } from "./content/Content";
6
- import { LabelDefinition } from "./LabelDefinition";
5
+ import { Descriptor } from "./content/Descriptor";
6
+ import { Item } from "./content/Item";
7
+ import { DisplayValueGroup } from "./content/Value";
7
8
  import { ElementProperties } from "./ElementProperties";
9
+ import { Node } from "./hierarchy/Node";
10
+ import { NodePathElement } from "./hierarchy/NodePathElement";
11
+ import { LabelDefinition } from "./LabelDefinition";
8
12
  /** @internal */
9
13
  export interface LocalizationHelperProps {
10
14
  getLocalizedString: (key: string) => string;
@@ -15,16 +19,19 @@ export declare class LocalizationHelper {
15
19
  constructor(props: LocalizationHelperProps);
16
20
  getLocalizedString(text: string): string;
17
21
  getLocalizedNodes(nodes: Node[]): Node[];
22
+ getLocalizedNodePathElement(npe: NodePathElement): NodePathElement;
23
+ getLocalizedDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup;
18
24
  getLocalizedLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition;
19
25
  getLocalizedLabelDefinitions(labelDefinitions: LabelDefinition[]): LabelDefinition[];
26
+ getLocalizedContentDescriptor(descriptor: Descriptor): Descriptor;
27
+ getLocalizedContentItems(items: Item[]): Item[];
20
28
  getLocalizedContent(content: Content): Content;
21
29
  getLocalizedElementProperties(elem: ElementProperties): ElementProperties;
22
- private translateContentItem;
23
- private translateContentItemDisplayValue;
24
- private translateContentItemValue;
25
- private translateContentDescriptorField;
26
- private translateContentDescriptorCategory;
27
- private translateNode;
28
- private translateLabelDefinition;
30
+ private getLocalizedContentItem;
31
+ private getLocalizedRawValue;
32
+ private getLocalizedContentField;
33
+ private getLocalizedCategoryDescription;
34
+ private getLocalizedNode;
35
+ private getLocalizedDisplayValue;
29
36
  }
30
37
  //# 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;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAuB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,gBAAgB;AAChB,MAAM,WAAW,uBAAuB;IACtC,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7C;AAED,gBAAgB;AAChB,qBAAa,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AAO,CAAC,mBAAmB,CAA0B;gBAEzC,KAAK,EAAE,uBAAuB;IAInC,kBAAkB,CAAC,IAAI,EAAE,MAAM;IAI/B,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE;IAIxC,2BAA2B,CAAC,GAAG,EAAE,eAAe,GAAG,eAAe;IAQlE,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,GAAG,iBAAiB;IAO1E,2BAA2B,CAAC,eAAe,EAAE,eAAe,GAAG,eAAe;IAsB9E,4BAA4B,CAAC,gBAAgB,EAAE,eAAe,EAAE;IAIhE,6BAA6B,CAAC,UAAU,EAAE,UAAU;IAOpD,wBAAwB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE;IAI/C,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAI9C,6BAA6B,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB;IAQhF,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,oBAAoB;IAqB5B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,+BAA+B;IAMvC,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,wBAAwB;CAYjC"}
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  /** @packageDocumentation
7
7
  * @module Core
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.LocalizationHelper = void 0;
11
- const LabelDefinition_1 = require("./LabelDefinition");
11
+ const Content_1 = require("./content/Content");
12
+ const Descriptor_1 = require("./content/Descriptor");
12
13
  const Value_1 = require("./content/Value");
14
+ const LabelDefinition_1 = require("./LabelDefinition");
13
15
  const KEY_PATTERN = /@[\w\d\-_]+:[\w\d\-\._]+?@/g;
14
16
  /** @internal */
15
17
  class LocalizationHelper {
@@ -20,94 +22,117 @@ class LocalizationHelper {
20
22
  return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, "")));
21
23
  }
22
24
  getLocalizedNodes(nodes) {
23
- for (const node of nodes)
24
- this.translateNode(node);
25
- return nodes;
25
+ return nodes.map((n) => this.getLocalizedNode(n));
26
+ }
27
+ getLocalizedNodePathElement(npe) {
28
+ return {
29
+ ...npe,
30
+ node: this.getLocalizedNode(npe.node),
31
+ children: npe.children.map((c) => this.getLocalizedNodePathElement(c)),
32
+ };
33
+ }
34
+ getLocalizedDisplayValueGroup(group) {
35
+ return {
36
+ ...group,
37
+ displayValue: this.getLocalizedDisplayValue(group.displayValue),
38
+ };
26
39
  }
27
40
  getLocalizedLabelDefinition(labelDefinition) {
28
- this.translateLabelDefinition(labelDefinition);
41
+ const getLocalizedComposite = (compositeValue) => ({
42
+ ...compositeValue,
43
+ values: compositeValue.values.map((value) => this.getLocalizedLabelDefinition(value)),
44
+ });
45
+ if (labelDefinition.typeName === LabelDefinition_1.LabelDefinition.COMPOSITE_DEFINITION_TYPENAME) {
46
+ return {
47
+ ...labelDefinition,
48
+ rawValue: getLocalizedComposite(labelDefinition.rawValue),
49
+ };
50
+ }
51
+ if (labelDefinition.typeName === "string") {
52
+ return {
53
+ ...labelDefinition,
54
+ rawValue: this.getLocalizedString(labelDefinition.rawValue),
55
+ displayValue: this.getLocalizedString(labelDefinition.displayValue),
56
+ };
57
+ }
29
58
  return labelDefinition;
30
59
  }
31
60
  getLocalizedLabelDefinitions(labelDefinitions) {
32
- labelDefinitions.forEach((labelDefinition) => this.translateLabelDefinition(labelDefinition));
33
- return labelDefinitions;
61
+ return labelDefinitions.map((labelDefinition) => this.getLocalizedLabelDefinition(labelDefinition));
62
+ }
63
+ getLocalizedContentDescriptor(descriptor) {
64
+ const clone = new Descriptor_1.Descriptor(descriptor);
65
+ clone.fields.forEach((field) => this.getLocalizedContentField(field));
66
+ clone.categories.forEach((category) => this.getLocalizedCategoryDescription(category));
67
+ return clone;
68
+ }
69
+ getLocalizedContentItems(items) {
70
+ return items.map((item) => this.getLocalizedContentItem(item));
34
71
  }
35
72
  getLocalizedContent(content) {
36
- content.contentSet.forEach((item) => this.translateContentItem(item));
37
- content.descriptor.fields.forEach((field) => this.translateContentDescriptorField(field));
38
- content.descriptor.categories.forEach((category) => this.translateContentDescriptorCategory(category));
39
- return content;
73
+ return new Content_1.Content(this.getLocalizedContentDescriptor(content.descriptor), this.getLocalizedContentItems(content.contentSet));
40
74
  }
41
75
  getLocalizedElementProperties(elem) {
42
- elem.label = this.getLocalizedString(elem.label);
43
- return elem;
44
- }
45
- translateContentItem(item) {
46
- for (const key in item.displayValues) {
47
- // istanbul ignore else
48
- if (key)
49
- item.displayValues[key] = this.translateContentItemDisplayValue(item.displayValues[key]);
50
- }
51
- for (const key in item.values) {
52
- // istanbul ignore else
53
- if (key)
54
- item.values[key] = this.translateContentItemValue(item.values[key]);
55
- }
56
- this.translateLabelDefinition(item.label);
76
+ return {
77
+ ...elem,
78
+ label: this.getLocalizedString(elem.label),
79
+ };
57
80
  }
58
- translateContentItemDisplayValue(value) {
59
- // istanbul ignore else
60
- if (typeof value === "string") {
61
- value = this.getLocalizedString(value);
62
- }
63
- return value;
81
+ // warning: this function mutates the item
82
+ getLocalizedContentItem(item) {
83
+ item.label = this.getLocalizedLabelDefinition(item.label);
84
+ item.values = Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});
85
+ item.displayValues = Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});
86
+ return item;
64
87
  }
65
- translateContentItemValue(value) {
88
+ getLocalizedRawValue(value) {
66
89
  if (typeof value === "string") {
67
- value = this.getLocalizedString(value);
90
+ return this.getLocalizedString(value);
68
91
  }
69
- else if (Value_1.Value.isNavigationValue(value)) {
70
- this.translateLabelDefinition(value.label);
92
+ if (Value_1.Value.isNavigationValue(value)) {
93
+ return {
94
+ ...value,
95
+ label: this.getLocalizedLabelDefinition(value.label),
96
+ };
71
97
  }
72
- else if (Value_1.Value.isNestedContent(value)) {
73
- for (const nestedValue of value) {
74
- for (const key in nestedValue.values) {
75
- // istanbul ignore else
76
- if (key)
77
- nestedValue.values[key] = this.translateContentItemValue(nestedValue.values[key]);
78
- }
79
- for (const key in nestedValue.displayValues) {
80
- // istanbul ignore else
81
- if (key)
82
- nestedValue.displayValues[key] = this.translateContentItemDisplayValue(nestedValue.displayValues[key]);
83
- }
84
- }
98
+ if (Value_1.Value.isNestedContent(value)) {
99
+ return value.map((item) => ({
100
+ ...item,
101
+ values: Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {}),
102
+ displayValues: Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {}),
103
+ }));
85
104
  }
86
105
  return value;
87
106
  }
88
- translateContentDescriptorField(field) {
107
+ // warning: this function mutates the field
108
+ getLocalizedContentField(field) {
89
109
  field.label = this.getLocalizedString(field.label);
110
+ return field;
90
111
  }
91
- translateContentDescriptorCategory(category) {
112
+ // warning: this function mutates the category
113
+ getLocalizedCategoryDescription(category) {
92
114
  category.label = this.getLocalizedString(category.label);
93
115
  category.description = this.getLocalizedString(category.description);
116
+ return category;
94
117
  }
95
- translateNode(node) {
96
- this.translateLabelDefinition(node.label);
97
- // istanbul ignore else
98
- if (node.description)
99
- node.description = this.getLocalizedString(node.description);
100
- }
101
- translateLabelDefinition(labelDefinition) {
102
- const translateComposite = (compositeValue) => {
103
- compositeValue.values.map((value) => this.translateLabelDefinition(value));
118
+ getLocalizedNode(node) {
119
+ return {
120
+ ...node,
121
+ label: this.getLocalizedLabelDefinition(node.label),
122
+ ...(node.description ? { description: this.getLocalizedString(node.description) } : undefined),
104
123
  };
105
- if (labelDefinition.typeName === LabelDefinition_1.LabelDefinition.COMPOSITE_DEFINITION_TYPENAME)
106
- translateComposite(labelDefinition.rawValue);
107
- else if (labelDefinition.typeName === "string") {
108
- labelDefinition.rawValue = this.getLocalizedString(labelDefinition.rawValue);
109
- labelDefinition.displayValue = this.getLocalizedString(labelDefinition.displayValue);
124
+ }
125
+ getLocalizedDisplayValue(value) {
126
+ if (typeof value === "undefined") {
127
+ return undefined;
128
+ }
129
+ if (typeof value === "string") {
130
+ return this.getLocalizedString(value);
131
+ }
132
+ if (Array.isArray(value)) {
133
+ return value.map((v) => this.getLocalizedDisplayValue(v));
110
134
  }
135
+ return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});
111
136
  }
112
137
  }
113
138
  exports.LocalizationHelper = LocalizationHelper;
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationHelper.js","sourceRoot":"","sources":["../../../src/presentation-common/LocalizationHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAKH,uDAAyE;AACzE,2CAAsD;AAKtD,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAOlD,gBAAgB;AAChB,MAAa,kBAAkB;IAG7B,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;IAEM,iBAAiB,CAAC,KAAa;QACpC,KAAK,MAAM,IAAI,IAAI,KAAK;YACtB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,O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------------------------------------------------------------------------------------------\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 { Node } from \"./hierarchy/Node\";\nimport { Content } from \"./content/Content\";\nimport { Item } from \"./content/Item\";\nimport { LabelCompositeValue, LabelDefinition } from \"./LabelDefinition\";\nimport { DisplayValue, Value } from \"./content/Value\";\nimport { Field } from \"./content/Fields\";\nimport { CategoryDescription } from \"./content/Category\";\nimport { ElementProperties } from \"./ElementProperties\";\n\nconst KEY_PATTERN = /@[\\w\\d\\-_]+:[\\w\\d\\-\\._]+?@/g;\n\n/** @internal */\nexport interface LocalizationHelperProps {\n getLocalizedString: (key: string) => string;\n}\n\n/** @internal */\nexport class LocalizationHelper {\n private _getLocalizedString: (key: string) => string;\n\n constructor(props: LocalizationHelperProps) {\n this._getLocalizedString = props.getLocalizedString;\n }\n\n public getLocalizedString(text: string) {\n return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, \"\")));\n }\n\n public getLocalizedNodes(nodes: Node[]): Node[] {\n for (const node of nodes)\n this.translateNode(node);\n return nodes;\n }\n\n public getLocalizedLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition {\n this.translateLabelDefinition(labelDefinition);\n return labelDefinition;\n }\n\n public getLocalizedLabelDefinitions(labelDefinitions: LabelDefinition[]) {\n labelDefinitions.forEach((labelDefinition) => this.translateLabelDefinition(labelDefinition));\n return labelDefinitions;\n }\n\n public getLocalizedContent(content: Content) {\n content.contentSet.forEach((item) => this.translateContentItem(item));\n content.descriptor.fields.forEach((field) => this.translateContentDescriptorField(field));\n content.descriptor.categories.forEach((category) => this.translateContentDescriptorCategory(category));\n return content;\n }\n\n public getLocalizedElementProperties(elem: ElementProperties) {\n elem.label = this.getLocalizedString(elem.label);\n return elem;\n }\n\n private translateContentItem(item: Item) {\n for (const key in item.displayValues) {\n // istanbul ignore else\n if (key)\n item.displayValues[key] = this.translateContentItemDisplayValue(item.displayValues[key]);\n }\n for (const key in item.values) {\n // istanbul ignore else\n if (key)\n item.values[key] = this.translateContentItemValue(item.values[key]);\n }\n this.translateLabelDefinition(item.label);\n }\n\n private translateContentItemDisplayValue(value: DisplayValue): DisplayValue {\n // istanbul ignore else\n if (typeof value === \"string\") {\n value = this.getLocalizedString(value);\n }\n return value;\n }\n\n private translateContentItemValue(value: Value): Value {\n if (typeof value === \"string\") {\n value = this.getLocalizedString(value);\n } else if (Value.isNavigationValue(value)) {\n this.translateLabelDefinition(value.label);\n } else if (Value.isNestedContent(value)) {\n for (const nestedValue of value) {\n for (const key in nestedValue.values) {\n // istanbul ignore else\n if (key)\n nestedValue.values[key] = this.translateContentItemValue(nestedValue.values[key]);\n }\n for (const key in nestedValue.displayValues) {\n // istanbul ignore else\n if (key)\n nestedValue.displayValues[key] = this.translateContentItemDisplayValue(nestedValue.displayValues[key]);\n }\n }\n }\n return value;\n }\n\n private translateContentDescriptorField(field: Field) {\n field.label = this.getLocalizedString(field.label);\n }\n\n private translateContentDescriptorCategory(category: CategoryDescription) {\n category.label = this.getLocalizedString(category.label);\n category.description = this.getLocalizedString(category.description);\n }\n\n private translateNode(node: Node) {\n this.translateLabelDefinition(node.label);\n // istanbul ignore else\n if (node.description)\n node.description = this.getLocalizedString(node.description);\n }\n\n private translateLabelDefinition(labelDefinition: LabelDefinition) {\n const translateComposite = (compositeValue: LabelCompositeValue) => {\n compositeValue.values.map((value) => this.translateLabelDefinition(value));\n };\n\n if (labelDefinition.typeName === LabelDefinition.COMPOSITE_DEFINITION_TYPENAME)\n translateComposite(labelDefinition.rawValue as LabelCompositeValue);\n else if (labelDefinition.typeName === \"string\") {\n labelDefinition.rawValue = this.getLocalizedString(labelDefinition.rawValue as string);\n labelDefinition.displayValue = this.getLocalizedString(labelDefinition.displayValue);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"LocalizationHelper.js","sourceRoot":"","sources":["../../../src/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QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,gBAAgB,CAAC,IAAU;QACjC,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,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC/F,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAAC,KAAmB;QAClD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,SAAS,CAAC;SAClB;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;SACvC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;QACD,OAAO,MAAM,CAAC,OAAO,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;AA3ID,gDA2IC","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 { CategoryDescription } from \"./content/Category\";\nimport { Content } from \"./content/Content\";\nimport { Descriptor } from \"./content/Descriptor\";\nimport { Field } from \"./content/Fields\";\nimport { Item } from \"./content/Item\";\nimport { DisplayValue, DisplayValueGroup, Value } from \"./content/Value\";\nimport { ElementProperties } from \"./ElementProperties\";\nimport { Node } from \"./hierarchy/Node\";\nimport { NodePathElement } from \"./hierarchy/NodePathElement\";\nimport { LabelCompositeValue, LabelDefinition } from \"./LabelDefinition\";\n\nconst KEY_PATTERN = /@[\\w\\d\\-_]+:[\\w\\d\\-\\._]+?@/g;\n\n/** @internal */\nexport interface LocalizationHelperProps {\n getLocalizedString: (key: string) => string;\n}\n\n/** @internal */\nexport class LocalizationHelper {\n private _getLocalizedString: (key: string) => string;\n\n constructor(props: LocalizationHelperProps) {\n this._getLocalizedString = props.getLocalizedString;\n }\n\n public getLocalizedString(text: string) {\n return text.replace(KEY_PATTERN, (key) => this._getLocalizedString(key.replace(/^@|@$/g, \"\")));\n }\n\n public getLocalizedNodes(nodes: Node[]): Node[] {\n return nodes.map((n) => this.getLocalizedNode(n));\n }\n\n public getLocalizedNodePathElement(npe: NodePathElement): NodePathElement {\n return {\n ...npe,\n node: this.getLocalizedNode(npe.node),\n children: npe.children.map((c) => this.getLocalizedNodePathElement(c)),\n };\n }\n\n public getLocalizedDisplayValueGroup(group: DisplayValueGroup): DisplayValueGroup {\n return {\n ...group,\n displayValue: this.getLocalizedDisplayValue(group.displayValue),\n };\n }\n\n public getLocalizedLabelDefinition(labelDefinition: LabelDefinition): LabelDefinition {\n const getLocalizedComposite = (compositeValue: LabelCompositeValue) => ({\n ...compositeValue,\n values: compositeValue.values.map((value) => this.getLocalizedLabelDefinition(value)),\n });\n\n if (labelDefinition.typeName === LabelDefinition.COMPOSITE_DEFINITION_TYPENAME) {\n return {\n ...labelDefinition,\n rawValue: getLocalizedComposite(labelDefinition.rawValue as LabelCompositeValue),\n };\n }\n if (labelDefinition.typeName === \"string\") {\n return {\n ...labelDefinition,\n rawValue: this.getLocalizedString(labelDefinition.rawValue as string),\n displayValue: this.getLocalizedString(labelDefinition.displayValue),\n };\n }\n return labelDefinition;\n }\n\n public getLocalizedLabelDefinitions(labelDefinitions: LabelDefinition[]) {\n return labelDefinitions.map((labelDefinition) => this.getLocalizedLabelDefinition(labelDefinition));\n }\n\n public getLocalizedContentDescriptor(descriptor: Descriptor) {\n const clone = new Descriptor(descriptor);\n clone.fields.forEach((field) => this.getLocalizedContentField(field));\n clone.categories.forEach((category) => this.getLocalizedCategoryDescription(category));\n return clone;\n }\n\n public getLocalizedContentItems(items: Item[]): Item[] {\n return items.map((item) => this.getLocalizedContentItem(item));\n }\n\n public getLocalizedContent(content: Content): Content {\n return new Content(this.getLocalizedContentDescriptor(content.descriptor), this.getLocalizedContentItems(content.contentSet));\n }\n\n public getLocalizedElementProperties(elem: ElementProperties): ElementProperties {\n return {\n ...elem,\n label: this.getLocalizedString(elem.label),\n };\n }\n\n // warning: this function mutates the item\n private getLocalizedContentItem(item: Item): Item {\n item.label = this.getLocalizedLabelDefinition(item.label);\n item.values = Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {});\n item.displayValues = Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\n return item;\n }\n\n private getLocalizedRawValue(value: Value): Value {\n if (typeof value === \"string\") {\n return this.getLocalizedString(value);\n }\n if (Value.isNavigationValue(value)) {\n return {\n ...value,\n label: this.getLocalizedLabelDefinition(value.label),\n };\n }\n if (Value.isNestedContent(value)) {\n return value.map((item) => ({\n ...item,\n values: Object.entries(item.values).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedRawValue(v) }), {}),\n displayValues: Object.entries(item.displayValues).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {}),\n }));\n }\n return value;\n }\n\n // warning: this function mutates the field\n private getLocalizedContentField(field: Field) {\n field.label = this.getLocalizedString(field.label);\n return field;\n }\n\n // warning: this function mutates the category\n private getLocalizedCategoryDescription(category: CategoryDescription) {\n category.label = this.getLocalizedString(category.label);\n category.description = this.getLocalizedString(category.description);\n return category;\n }\n\n private getLocalizedNode(node: Node) {\n return {\n ...node,\n label: this.getLocalizedLabelDefinition(node.label),\n ...(node.description ? { description: this.getLocalizedString(node.description) } : undefined),\n };\n }\n\n private getLocalizedDisplayValue(value: DisplayValue): DisplayValue {\n if (typeof value === \"undefined\") {\n return undefined;\n }\n if (typeof value === \"string\") {\n return this.getLocalizedString(value);\n }\n if (Array.isArray(value)) {\n return value.map((v) => this.getLocalizedDisplayValue(v));\n }\n return Object.entries(value).reduce((o, [k, v]) => ({ ...o, [k]: this.getLocalizedDisplayValue(v) }), {});\n }\n}\n"]}
@@ -3,13 +3,15 @@
3
3
  */
4
4
  import { BeEvent, Id64String } from "@itwin/core-bentley";
5
5
  import { UnitSystemKey } from "@itwin/core-quantity";
6
- import { SelectionInfo } from "./content/Descriptor";
6
+ import { Descriptor, SelectionInfo } from "./content/Descriptor";
7
7
  import { FieldDescriptor } from "./content/Fields";
8
8
  import { InstanceKey } from "./EC";
9
9
  import { InstanceFilterDefinition } from "./InstanceFilterDefinition";
10
10
  import { Ruleset } from "./rules/Ruleset";
11
11
  import { RulesetVariable } from "./RulesetVariables";
12
12
  import { SelectionScopeProps } from "./selection/SelectionScope";
13
+ import { Item } from "./content/Item";
14
+ import { ElementProperties } from "./ElementProperties";
13
15
  /**
14
16
  * A generic request options type used for both hierarchy and content requests.
15
17
  * @public
@@ -119,6 +121,11 @@ export interface ContentDescriptorRequestOptions<TIModel, TKeySet, TRulesetVaria
119
121
  * @see [[DefaultContentDisplayTypes]]
120
122
  */
121
123
  displayType: string;
124
+ /**
125
+ * Content flags used for content customization.
126
+ * @see [[ContentFlags]]
127
+ */
128
+ contentFlags?: number;
122
129
  /** Input keys for getting the content */
123
130
  keys: TKeySet;
124
131
  /** Information about the selection event that was the cause of this content request */
@@ -155,8 +162,9 @@ export interface DistinctValuesRequestOptions<TIModel, TDescriptor, TKeySet, TRu
155
162
  /**
156
163
  * Request type for element properties requests
157
164
  * @public
165
+ * @deprecated in 4.x. Use [[SingleElementPropertiesRequestOptions]] or [[MultiElementPropertiesRequestOptions]] directly.
158
166
  */
159
- export type ElementPropertiesRequestOptions<TIModel> = SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel>;
167
+ export type ElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> = SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>;
160
168
  /**
161
169
  * Request type for single element properties requests.
162
170
  * @public
@@ -169,13 +177,25 @@ export interface SingleElementPropertiesRequestOptions<TIModel> extends RequestO
169
177
  * Request type for multiple elements properties requests.
170
178
  * @public
171
179
  */
172
- export interface MultiElementPropertiesRequestOptions<TIModel> extends RequestOptions<TIModel> {
180
+ export interface MultiElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> extends RequestOptions<TIModel> {
173
181
  /**
174
182
  * Classes of the elements to get properties for. If [[elementClasses]] is `undefined`, all classes
175
183
  * are used. Classes should be specified in one of these formats: "<schema name or alias>.<class_name>" or
176
184
  * "<schema name or alias>:<class_name>".
177
185
  */
178
186
  elementClasses?: string[];
187
+ /**
188
+ * Content parser that creates a result item based on given content descriptor and content item. Defaults
189
+ * to a parser that creates [[ElementProperties]] objects.
190
+ * @beta
191
+ */
192
+ contentParser?: (descriptor: Descriptor, item: Item) => TParsedContent;
193
+ /**
194
+ * The properties of multiple elements are going to be retrieved and returned in batches. Depending on the batch
195
+ * size load on CPU vs MEMORY load may vary, so changing this attribute allows to fine tune the performance.
196
+ * Defaults to `1000`.
197
+ */
198
+ batchSize?: number;
179
199
  }
180
200
  /**
181
201
  * Request type for content instance keys' requests.
@@ -268,7 +288,7 @@ export type Prioritized<TOptions extends {}> = TOptions & {
268
288
  * Checks if supplied request options are for single or multiple element properties.
269
289
  * @internal
270
290
  */
271
- export declare function isSingleElementPropertiesRequestOptions<TIModel>(options: ElementPropertiesRequestOptions<TIModel>): options is SingleElementPropertiesRequestOptions<TIModel>;
291
+ export declare function isSingleElementPropertiesRequestOptions<TIModel, TParsedContent = any>(options: SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>): options is SingleElementPropertiesRequestOptions<TIModel>;
272
292
  /**
273
293
  * A wrapper type that injects cancelEvent into supplied type.
274
294
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationManagerOptions.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/PresentationManagerOptions.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO;IACrC,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAEhB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB,C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resentationManagerOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAqPH,gBAAgB;AAChB,SAAgB,gCAAgC,CAAU,OAAwF;IAChJ,OAAO,CAAC,CAAE,OAAmD,CAAC,UAAU,CAAC;AAC3E,CAAC;AAFD,4EAEC;AAgDD;;;GAGG;AACH,SAAgB,uCAAuC,CAAU,OAAiD;IAChH,OAAQ,OAA0D,CAAC,SAAS,KAAK,SAAS,CAAC;AAC7F,CAAC;AAFD,0FAEC","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 { BeEvent, Id64String } from \"@itwin/core-bentley\";\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\nimport { SelectionInfo } from \"./content/Descriptor\";\nimport { FieldDescriptor } from \"./content/Fields\";\nimport { InstanceKey } from \"./EC\";\nimport { InstanceFilterDefinition } from \"./InstanceFilterDefinition\";\nimport { Ruleset } from \"./rules/Ruleset\";\nimport { RulesetVariable } from \"./RulesetVariables\";\nimport { SelectionScopeProps } from \"./selection/SelectionScope\";\n\n/**\n * A generic request options type used for both hierarchy and content requests.\n * @public\n */\nexport interface RequestOptions<TIModel> {\n /** iModel to request data from */\n imodel: TIModel;\n\n /** Optional locale to use when formatting / localizing data */\n locale?: string;\n\n /**\n * Unit system to use when formatting property values with units. Default presentation\n * unit is used if unit system is not specified.\n */\n unitSystem?: UnitSystemKey;\n\n /**\n * Expected form of response. This property is set automatically on newer frontends.\n * `unparsed-json` — deliver response from native addon without parsing it.\n * @internal\n */\n transport?: \"unparsed-json\";\n}\n\n/**\n * Options for requests that require presentation ruleset. Not\n * meant to be used directly, see one of the subclasses.\n *\n * @public\n */\nexport interface RequestOptionsWithRuleset<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptions<TIModel> {\n /** Ruleset or id of the ruleset to use when requesting data */\n rulesetOrId: Ruleset | string;\n\n /** Ruleset variables to use when requesting data */\n rulesetVariables?: TRulesetVariable[];\n}\n\n/**\n * Request type for hierarchy requests.\n * @public\n */\nexport interface HierarchyRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Key of the parent node to get children for */\n parentKey?: TNodeKey;\n\n /**\n * An instance filter that should be applied for this hierarchy level.\n *\n * **Note:** May only be used on hierarchy levels that support filtering - check [[NavNode.supportsFiltering]] before\n * requesting filtered children.\n *\n * @beta\n */\n instanceFilter?: InstanceFilterDefinition;\n\n /**\n * A limit to how many instances at most should be loaded for a hierarchy level. If the limit is exceeded,\n * the request fails with [[PresentationError]] having [[PresentationStatus.ResultSetTooLarge]] error number.\n *\n * Specifying the limit is useful when creating unlimited size result sets is not meaningful - this allows the library\n * to return early as soon as the limit is reached, instead of creating a very large result that's possibly too large to\n * be useful to be displayed to end users.\n *\n * @see [Hierarchies' filtering and limiting]($docs/presentation/hierarchies/FilteringLimiting.md)\n * @beta\n */\n sizeLimit?: number;\n}\n\n/**\n * Params for hierarchy level descriptor requests.\n * @beta\n */\nexport interface HierarchyLevelDescriptorRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Key of the parent node to get hierarchy level descriptor for. */\n parentKey?: TNodeKey;\n}\n\n/**\n * Request type of filtering hierarchies by given ECInstance paths.\n * @public\n */\nexport interface FilterByInstancePathsHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** A list of paths from root ECInstance to target ECInstance. */\n instancePaths: InstanceKey[][];\n\n /**\n * An optional index (`0 <= markedIndex < instancePaths.length`) to mark one of the instance paths. The\n * path is marked using `NodePathElement.isMarked` flag in the result.\n */\n markedIndex?: number;\n}\n\n/**\n * Request type of filtering hierarchies by given text.\n * @public\n */\nexport interface FilterByTextHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Text to filter the hierarchy by. */\n filterText: string;\n}\n\n/**\n * Request type for content sources requests.\n * @public\n */\nexport interface ContentSourcesRequestOptions<TIModel> extends RequestOptions<TIModel> {\n /** Full names of classes to get content sources for. Format for a full class name: `SchemaName:ClassName`. */\n classes: string[];\n}\n\n/**\n * Request type for content descriptor requests.\n * @public\n */\nexport interface ContentDescriptorRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /**\n * Content display type.\n * @see [[DefaultContentDisplayTypes]]\n */\n displayType: string;\n /** Input keys for getting the content */\n keys: TKeySet;\n /** Information about the selection event that was the cause of this content request */\n selection?: SelectionInfo;\n}\n\n/**\n * Request type for content requests.\n * @public\n */\nexport interface ContentRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Content descriptor for customizing the returned content */\n descriptor: TDescriptor;\n /** Input keys for getting the content */\n keys: TKeySet;\n /**\n * Flag that specifies whether value formatting should be emitted or not.\n * Content is returned without `displayValues` when this is set to `true`.\n * @alpha\n */\n omitFormattedValues?: boolean;\n}\n\n/**\n * Request type for distinct values' requests.\n * @public\n */\nexport interface DistinctValuesRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable> extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\n /** Content descriptor for customizing the returned content */\n descriptor: TDescriptor;\n /** Input keys for getting the content */\n keys: TKeySet;\n /** Descriptor for a field distinct values are requested for */\n fieldDescriptor: FieldDescriptor;\n}\n\n/**\n * Request type for element properties requests\n * @public\n */\nexport type ElementPropertiesRequestOptions<TIModel> = SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel>;\n\n/**\n * Request type for single element properties requests.\n * @public\n */\nexport interface SingleElementPropertiesRequestOptions<TIModel> extends RequestOptions<TIModel> {\n /** ID of the element to get properties for. */\n elementId: Id64String;\n}\n\n/**\n * Request type for multiple elements properties requests.\n * @public\n */\nexport interface MultiElementPropertiesRequestOptions<TIModel> extends RequestOptions<TIModel> {\n /**\n * Classes of the elements to get properties for. If [[elementClasses]] is `undefined`, all classes\n * are used. Classes should be specified in one of these formats: \"<schema name or alias>.<class_name>\" or\n * \"<schema name or alias>:<class_name>\".\n */\n elementClasses?: string[];\n}\n\n/**\n * Request type for content instance keys' requests.\n * @public\n */\nexport interface ContentInstanceKeysRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable> extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\n /**\n * Content display type.\n * @see [[DefaultContentDisplayTypes]]\n */\n displayType?: string;\n /** Input keys for getting the content. */\n keys: TKeySet;\n}\n\n/**\n * Request type for label requests\n * @public\n */\nexport interface DisplayLabelRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\n /** Key of ECInstance to get label for */\n key: TInstanceKey;\n}\n\n/**\n * Request type for labels requests\n * @public\n */\nexport interface DisplayLabelsRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\n /** Keys of ECInstances to get labels for */\n keys: TInstanceKey[];\n}\n\n/**\n * Request options used for selection scope related requests\n * @public\n */\nexport interface SelectionScopeRequestOptions<TIModel> extends RequestOptions<TIModel> { } // eslint-disable-line @typescript-eslint/no-empty-interface\n\n/**\n * Request options used for calculating selection based on given instance keys and selection scope.\n * @public\n */\nexport interface ComputeSelectionRequestOptions<TIModel> extends RequestOptions<TIModel> {\n elementIds: Id64String[];\n scope: SelectionScopeProps;\n}\n/** @internal */\nexport function isComputeSelectionRequestOptions<TIModel>(options: ComputeSelectionRequestOptions<TIModel> | SelectionScopeRequestOptions<TIModel>): options is ComputeSelectionRequestOptions<TIModel> {\n return !!(options as ComputeSelectionRequestOptions<TIModel>).elementIds;\n}\n\n/**\n * Data structure for comparing a hierarchy after ruleset or ruleset variable changes.\n * @public\n */\nexport interface HierarchyCompareOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n prev: {\n rulesetOrId?: Ruleset | string;\n rulesetVariables?: TRulesetVariable[];\n };\n expandedNodeKeys?: TNodeKey[];\n continuationToken?: {\n prevHierarchyNode: string;\n currHierarchyNode: string;\n };\n resultSetSize?: number;\n}\n\n/**\n * Paging options\n * @public\n */\nexport interface PageOptions {\n /** Inclusive start 0-based index of the page */\n start?: number;\n /** Maximum size of the page */\n size?: number;\n}\n\n/**\n * A wrapper type that injects [[PageOptions]] into supplied type\n * @public\n */\nexport type Paged<TOptions extends {}> = TOptions & {\n /** Optional paging parameters */\n paging?: PageOptions;\n};\n\n/**\n * A wrapper type that injects priority into supplied type.\n * @public\n */\nexport type Prioritized<TOptions extends {}> = TOptions & {\n /** Optional priority */\n priority?: number;\n};\n\n/**\n * Checks if supplied request options are for single or multiple element properties.\n * @internal\n */\nexport function isSingleElementPropertiesRequestOptions<TIModel>(options: ElementPropertiesRequestOptions<TIModel>): options is SingleElementPropertiesRequestOptions<TIModel> {\n return (options as SingleElementPropertiesRequestOptions<TIModel>).elementId !== undefined;\n}\n\n/**\n * A wrapper type that injects cancelEvent into supplied type.\n * @public\n */\nexport type WithCancelEvent<TOptions extends {}> = TOptions & {\n /** Event which is triggered when the request is canceled */\n cancelEvent?: BeEvent<() => void>;\n};\n"]}
1
+ {"version":3,"file":"PresentationManagerOptions.js","sourceRoot":"","sources":["../../../src/presentation-common/PresentationManagerOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2QH,gBAAgB;AAChB,SAAgB,gCAAgC,CAAU,OAAwF;IAChJ,OAAO,CAAC,CAAE,OAAmD,CAAC,UAAU,CAAC;AAC3E,CAAC;AAFD,4EAEC;AAgDD;;;GAGG;AACH,SAAgB,uCAAuC,CAAgC,OAAuH;IAC5M,OAAQ,OAA0D,CAAC,SAAS,KAAK,SAAS,CAAC;AAC7F,CAAC;AAFD,0FAEC","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 { BeEvent, Id64String } from \"@itwin/core-bentley\";\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\nimport { Descriptor, SelectionInfo } from \"./content/Descriptor\";\nimport { FieldDescriptor } from \"./content/Fields\";\nimport { InstanceKey } from \"./EC\";\nimport { InstanceFilterDefinition } from \"./InstanceFilterDefinition\";\nimport { Ruleset } from \"./rules/Ruleset\";\nimport { RulesetVariable } from \"./RulesetVariables\";\nimport { SelectionScopeProps } from \"./selection/SelectionScope\";\nimport { Item } from \"./content/Item\";\nimport { ElementProperties } from \"./ElementProperties\";\n\n/**\n * A generic request options type used for both hierarchy and content requests.\n * @public\n */\nexport interface RequestOptions<TIModel> {\n /** iModel to request data from */\n imodel: TIModel;\n\n /** Optional locale to use when formatting / localizing data */\n locale?: string;\n\n /**\n * Unit system to use when formatting property values with units. Default presentation\n * unit is used if unit system is not specified.\n */\n unitSystem?: UnitSystemKey;\n\n /**\n * Expected form of response. This property is set automatically on newer frontends.\n * `unparsed-json` — deliver response from native addon without parsing it.\n * @internal\n */\n transport?: \"unparsed-json\";\n}\n\n/**\n * Options for requests that require presentation ruleset. Not\n * meant to be used directly, see one of the subclasses.\n *\n * @public\n */\nexport interface RequestOptionsWithRuleset<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptions<TIModel> {\n /** Ruleset or id of the ruleset to use when requesting data */\n rulesetOrId: Ruleset | string;\n\n /** Ruleset variables to use when requesting data */\n rulesetVariables?: TRulesetVariable[];\n}\n\n/**\n * Request type for hierarchy requests.\n * @public\n */\nexport interface HierarchyRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Key of the parent node to get children for */\n parentKey?: TNodeKey;\n\n /**\n * An instance filter that should be applied for this hierarchy level.\n *\n * **Note:** May only be used on hierarchy levels that support filtering - check [[NavNode.supportsFiltering]] before\n * requesting filtered children.\n *\n * @beta\n */\n instanceFilter?: InstanceFilterDefinition;\n\n /**\n * A limit to how many instances at most should be loaded for a hierarchy level. If the limit is exceeded,\n * the request fails with [[PresentationError]] having [[PresentationStatus.ResultSetTooLarge]] error number.\n *\n * Specifying the limit is useful when creating unlimited size result sets is not meaningful - this allows the library\n * to return early as soon as the limit is reached, instead of creating a very large result that's possibly too large to\n * be useful to be displayed to end users.\n *\n * @see [Hierarchies' filtering and limiting]($docs/presentation/hierarchies/FilteringLimiting.md)\n * @beta\n */\n sizeLimit?: number;\n}\n\n/**\n * Params for hierarchy level descriptor requests.\n * @beta\n */\nexport interface HierarchyLevelDescriptorRequestOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Key of the parent node to get hierarchy level descriptor for. */\n parentKey?: TNodeKey;\n}\n\n/**\n * Request type of filtering hierarchies by given ECInstance paths.\n * @public\n */\nexport interface FilterByInstancePathsHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** A list of paths from root ECInstance to target ECInstance. */\n instancePaths: InstanceKey[][];\n\n /**\n * An optional index (`0 <= markedIndex < instancePaths.length`) to mark one of the instance paths. The\n * path is marked using `NodePathElement.isMarked` flag in the result.\n */\n markedIndex?: number;\n}\n\n/**\n * Request type of filtering hierarchies by given text.\n * @public\n */\nexport interface FilterByTextHierarchyRequestOptions<TIModel, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Text to filter the hierarchy by. */\n filterText: string;\n}\n\n/**\n * Request type for content sources requests.\n * @public\n */\nexport interface ContentSourcesRequestOptions<TIModel> extends RequestOptions<TIModel> {\n /** Full names of classes to get content sources for. Format for a full class name: `SchemaName:ClassName`. */\n classes: string[];\n}\n\n/**\n * Request type for content descriptor requests.\n * @public\n */\nexport interface ContentDescriptorRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /**\n * Content display type.\n * @see [[DefaultContentDisplayTypes]]\n */\n displayType: string;\n /**\n * Content flags used for content customization.\n * @see [[ContentFlags]]\n */\n contentFlags?: number;\n /** Input keys for getting the content */\n keys: TKeySet;\n /** Information about the selection event that was the cause of this content request */\n selection?: SelectionInfo;\n}\n\n/**\n * Request type for content requests.\n * @public\n */\nexport interface ContentRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n /** Content descriptor for customizing the returned content */\n descriptor: TDescriptor;\n /** Input keys for getting the content */\n keys: TKeySet;\n /**\n * Flag that specifies whether value formatting should be emitted or not.\n * Content is returned without `displayValues` when this is set to `true`.\n * @alpha\n */\n omitFormattedValues?: boolean;\n}\n\n/**\n * Request type for distinct values' requests.\n * @public\n */\nexport interface DistinctValuesRequestOptions<TIModel, TDescriptor, TKeySet, TRulesetVariable = RulesetVariable> extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\n /** Content descriptor for customizing the returned content */\n descriptor: TDescriptor;\n /** Input keys for getting the content */\n keys: TKeySet;\n /** Descriptor for a field distinct values are requested for */\n fieldDescriptor: FieldDescriptor;\n}\n\n/**\n * Request type for element properties requests\n * @public\n * @deprecated in 4.x. Use [[SingleElementPropertiesRequestOptions]] or [[MultiElementPropertiesRequestOptions]] directly.\n */\nexport type ElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> = SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>;\n\n/**\n * Request type for single element properties requests.\n * @public\n */\nexport interface SingleElementPropertiesRequestOptions<TIModel> extends RequestOptions<TIModel> {\n /** ID of the element to get properties for. */\n elementId: Id64String;\n}\n\n/**\n * Request type for multiple elements properties requests.\n * @public\n */\nexport interface MultiElementPropertiesRequestOptions<TIModel, TParsedContent = ElementProperties> extends RequestOptions<TIModel> {\n /**\n * Classes of the elements to get properties for. If [[elementClasses]] is `undefined`, all classes\n * are used. Classes should be specified in one of these formats: \"<schema name or alias>.<class_name>\" or\n * \"<schema name or alias>:<class_name>\".\n */\n elementClasses?: string[];\n\n /**\n * Content parser that creates a result item based on given content descriptor and content item. Defaults\n * to a parser that creates [[ElementProperties]] objects.\n * @beta\n */\n contentParser?: (descriptor: Descriptor, item: Item) => TParsedContent;\n\n /**\n * The properties of multiple elements are going to be retrieved and returned in batches. Depending on the batch\n * size load on CPU vs MEMORY load may vary, so changing this attribute allows to fine tune the performance.\n * Defaults to `1000`.\n */\n batchSize?: number;\n}\n\n/**\n * Request type for content instance keys' requests.\n * @public\n */\nexport interface ContentInstanceKeysRequestOptions<TIModel, TKeySet, TRulesetVariable = RulesetVariable> extends Paged<RequestOptionsWithRuleset<TIModel, TRulesetVariable>> {\n /**\n * Content display type.\n * @see [[DefaultContentDisplayTypes]]\n */\n displayType?: string;\n /** Input keys for getting the content. */\n keys: TKeySet;\n}\n\n/**\n * Request type for label requests\n * @public\n */\nexport interface DisplayLabelRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\n /** Key of ECInstance to get label for */\n key: TInstanceKey;\n}\n\n/**\n * Request type for labels requests\n * @public\n */\nexport interface DisplayLabelsRequestOptions<TIModel, TInstanceKey> extends RequestOptions<TIModel> {\n /** Keys of ECInstances to get labels for */\n keys: TInstanceKey[];\n}\n\n/**\n * Request options used for selection scope related requests\n * @public\n */\nexport interface SelectionScopeRequestOptions<TIModel> extends RequestOptions<TIModel> { } // eslint-disable-line @typescript-eslint/no-empty-interface\n\n/**\n * Request options used for calculating selection based on given instance keys and selection scope.\n * @public\n */\nexport interface ComputeSelectionRequestOptions<TIModel> extends RequestOptions<TIModel> {\n elementIds: Id64String[];\n scope: SelectionScopeProps;\n}\n/** @internal */\nexport function isComputeSelectionRequestOptions<TIModel>(options: ComputeSelectionRequestOptions<TIModel> | SelectionScopeRequestOptions<TIModel>): options is ComputeSelectionRequestOptions<TIModel> {\n return !!(options as ComputeSelectionRequestOptions<TIModel>).elementIds;\n}\n\n/**\n * Data structure for comparing a hierarchy after ruleset or ruleset variable changes.\n * @public\n */\nexport interface HierarchyCompareOptions<TIModel, TNodeKey, TRulesetVariable = RulesetVariable> extends RequestOptionsWithRuleset<TIModel, TRulesetVariable> {\n prev: {\n rulesetOrId?: Ruleset | string;\n rulesetVariables?: TRulesetVariable[];\n };\n expandedNodeKeys?: TNodeKey[];\n continuationToken?: {\n prevHierarchyNode: string;\n currHierarchyNode: string;\n };\n resultSetSize?: number;\n}\n\n/**\n * Paging options\n * @public\n */\nexport interface PageOptions {\n /** Inclusive start 0-based index of the page */\n start?: number;\n /** Maximum size of the page */\n size?: number;\n}\n\n/**\n * A wrapper type that injects [[PageOptions]] into supplied type\n * @public\n */\nexport type Paged<TOptions extends {}> = TOptions & {\n /** Optional paging parameters */\n paging?: PageOptions;\n};\n\n/**\n * A wrapper type that injects priority into supplied type.\n * @public\n */\nexport type Prioritized<TOptions extends {}> = TOptions & {\n /** Optional priority */\n priority?: number;\n};\n\n/**\n * Checks if supplied request options are for single or multiple element properties.\n * @internal\n */\nexport function isSingleElementPropertiesRequestOptions<TIModel, TParsedContent = any>(options: SingleElementPropertiesRequestOptions<TIModel> | MultiElementPropertiesRequestOptions<TIModel, TParsedContent>): options is SingleElementPropertiesRequestOptions<TIModel> {\n return (options as SingleElementPropertiesRequestOptions<TIModel>).elementId !== undefined;\n}\n\n/**\n * A wrapper type that injects cancelEvent into supplied type.\n * @public\n */\nexport type WithCancelEvent<TOptions extends {}> = TOptions & {\n /** Event which is triggered when the request is canceled */\n cancelEvent?: BeEvent<() => void>;\n};\n"]}
@@ -82,5 +82,18 @@ export declare class Item {
82
82
  * @internal
83
83
  */
84
84
  static reviver(key: string, value: any): any;
85
+ /**
86
+ * Deserialize items list from JSON
87
+ * @param json JSON or JSON serialized to string to deserialize from
88
+ * @returns Deserialized items list
89
+ * @internal
90
+ */
91
+ static listFromJSON(json: ItemJSON[] | string): Item[];
92
+ /**
93
+ * Reviver function that can be used as a second argument for
94
+ * `JSON.parse` method when parsing [[Item]][] objects.
95
+ * @internal
96
+ */
97
+ static listReviver(key: string, value: any): any;
85
98
  }
86
99
  //# sourceMappingURL=Item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../src/presentation-common/content/Item.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAwB,KAAK,EAAE,SAAS,EAAiB,MAAM,SAAS,CAAC;AAEhH;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;IAC1B,WAAW,EAAE,WAAW,EAAE,CAAC;IAG3B,eAAe,EAAE,mBAAmB,CAAC;IACrC,gKAAgK;IAChK,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,MAAM,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAEpC,aAAa,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAClD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACvC;AAED;;;GAG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gBAAgB,EAAE,MAAM,EAAE,CAAC;IAClC,oDAAoD;IAC7C,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAE7C;;;;;;;;;;OAUG;gBACgB,WAAW,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAC/H,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,gBAAgB,CAAC,YAAY,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IAWnJ;;OAEG;IACI,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIhD,oCAAoC;IAC7B,MAAM,IAAI,QAAQ;IAazB,qCAAqC;WACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS;IAiB7E;;;;OAIG;WACW,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG;IAInD;;;;;OAKG;WACW,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,GAAG,IAAI,EAAE;IAS7D;;;;OAIG;WACW,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG;CAGxD"}
@@ -80,6 +80,28 @@ class Item {
80
80
  static reviver(key, value) {
81
81
  return key === "" ? Item.fromJSON(value) : value;
82
82
  }
83
+ /**
84
+ * Deserialize items list from JSON
85
+ * @param json JSON or JSON serialized to string to deserialize from
86
+ * @returns Deserialized items list
87
+ * @internal
88
+ */
89
+ static listFromJSON(json) {
90
+ if (typeof json === "string") {
91
+ // eslint-disable-next-line @typescript-eslint/unbound-method
92
+ return JSON.parse(json, Item.listReviver);
93
+ }
94
+ // eslint-disable-next-line @typescript-eslint/unbound-method
95
+ return json.map(Item.fromJSON).filter((item) => !!item);
96
+ }
97
+ /**
98
+ * Reviver function that can be used as a second argument for
99
+ * `JSON.parse` method when parsing [[Item]][] objects.
100
+ * @internal
101
+ */
102
+ static listReviver(key, value) {
103
+ return key === "" ? Item.listFromJSON(value) : value;
104
+ }
83
105
  }
84
106
  exports.Item = Item;
85
107
  //# sourceMappingURL=Item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/presentation-common/content/Item.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAA0E;AAE1E,mCAAgH;AAuBhH;;;GAGG;AACH,MAAa,IAAI;IA0Bf;;;;;;;;;;OAUG;IACH,YAAmB,WAA0B,EAAE,KAA+B,EAAE,OAAe,EAAE,SAAgC,EAC/H,MAA+B,EAAE,aAA6C,EAAE,gBAA0B,EAAE,YAAqC;QACjJ,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,8CAA8C;QACtE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,iCAAe,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5F,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,SAAiB;QACpC,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,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,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;CACF;AAhGD,oBAgGC","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 Content\n */\n\nimport { ClassInfo, InstanceKey } from \"../EC\";\nimport { LabelDefinition, LabelDefinitionJSON } from \"../LabelDefinition\";\nimport { ValuesDictionary } from \"../Utils\";\nimport { DisplayValue, DisplayValueJSON, DisplayValuesMapJSON, Value, ValueJSON, ValuesMapJSON } from \"./Value\";\n\n/**\n * Serialized [[Item]] JSON representation.\n * @public\n */\nexport interface ItemJSON {\n inputKeys?: InstanceKey[];\n primaryKeys: InstanceKey[];\n // TODO: rename to `label`\n // eslint-disable-next-line deprecation/deprecation\n labelDefinition: LabelDefinitionJSON;\n /** @deprecated in 3.x. Use [[extendedData]] instead. See [extended data usage page]($docs/presentation/customization/ExtendedDataUsage.md) for more details. */\n imageId: string;\n classInfo?: ClassInfo;\n // eslint-disable-next-line deprecation/deprecation\n values: ValuesDictionary<ValueJSON>;\n // eslint-disable-next-line deprecation/deprecation\n displayValues: ValuesDictionary<DisplayValueJSON>;\n mergedFieldNames: string[];\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single content record.\n * @public\n */\nexport class Item {\n /**\n * Keys of input instances that caused this item to be included in content. Only set if the content is\n * created with [[ContentFlags.IncludeInputKeys]] flag.\n */\n public inputKeys?: InstanceKey[];\n /** Keys of instances whose data is contained in this item */\n public primaryKeys: InstanceKey[];\n /** Display label of the item */\n public label: LabelDefinition;\n /**\n * ID of the image associated with this item\n * @deprecated in 3.x. Use [[extendedData]] instead. See [extended data usage page]($docs/presentation/customization/ExtendedDataUsage.md) for more details.\n */\n public imageId: string;\n /** For cases when item consists only of same class instances, information about the ECClass */\n public classInfo?: ClassInfo;\n /** Raw values dictionary */\n public values: ValuesDictionary<Value>;\n /** Display values dictionary */\n public displayValues: ValuesDictionary<DisplayValue>;\n /** List of field names whose values are merged (see [Merging values]($docs/presentation/content/Terminology#value-merging)) */\n public mergedFieldNames: string[];\n /** Extended data injected into this content item */\n public extendedData?: { [key: string]: any };\n\n /**\n * Creates an instance of Item.\n * @param primaryKeys Keys of instances whose data is contained in this item\n * @param label Display label of the item\n * @param imageId ID of the image associated with this item\n * @param classInfo For cases when item consists only of same class instances, information about the ECClass\n * @param values Raw values dictionary\n * @param displayValues Display values dictionary\n * @param mergedFieldNames List of field names whose values are merged (see [Merging values]($docs/presentation/content/Terminology#value-merging))\n * @param extendedData Extended data injected into this content item\n */\n public constructor(primaryKeys: InstanceKey[], label: string | LabelDefinition, imageId: string, classInfo: ClassInfo | undefined,\n values: ValuesDictionary<Value>, displayValues: ValuesDictionary<DisplayValue>, mergedFieldNames: string[], extendedData?: { [key: string]: any }) {\n this.primaryKeys = primaryKeys;\n this.imageId = imageId; // eslint-disable-line deprecation/deprecation\n this.classInfo = classInfo;\n this.values = values;\n this.displayValues = displayValues;\n this.mergedFieldNames = mergedFieldNames;\n this.extendedData = extendedData;\n this.label = (typeof label === \"string\") ? LabelDefinition.fromLabelString(label) : label;\n }\n\n /**\n * Is value of field with the specified name merged in this record.\n */\n public isFieldMerged(fieldName: string): boolean {\n return -1 !== this.mergedFieldNames.indexOf(fieldName);\n }\n\n /** Serialize this object to JSON */\n public toJSON(): ItemJSON {\n const { label, ...baseItem } = this;\n return {\n ...baseItem,\n // eslint-disable-next-line deprecation/deprecation\n values: Value.toJSON(this.values) as ValuesMapJSON,\n // eslint-disable-next-line deprecation/deprecation\n displayValues: DisplayValue.toJSON(this.displayValues) as DisplayValuesMapJSON,\n // eslint-disable-next-line deprecation/deprecation\n labelDefinition: LabelDefinition.toJSON(label),\n };\n }\n\n /** Deserialize [[Item]] from JSON */\n public static fromJSON(json: ItemJSON | string | undefined): Item | undefined {\n if (!json)\n return undefined;\n if (typeof json === \"string\")\n return JSON.parse(json, (key, value) => Item.reviver(key, value));\n const item = Object.create(Item.prototype);\n const { labelDefinition, ...baseJson } = json;\n return Object.assign(item, baseJson, {\n // eslint-disable-next-line deprecation/deprecation\n values: Value.fromJSON(json.values),\n // eslint-disable-next-line deprecation/deprecation\n displayValues: DisplayValue.fromJSON(json.displayValues),\n // eslint-disable-next-line deprecation/deprecation\n label: LabelDefinition.fromJSON(labelDefinition),\n } as Partial<Item>);\n }\n\n /**\n * Reviver function that can be used as a second argument for\n * `JSON.parse` method when parsing Item objects.\n * @internal\n */\n public static reviver(key: string, value: any): any {\n return key === \"\" ? Item.fromJSON(value) : value;\n }\n}\n"]}
1
+ {"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/presentation-common/content/Item.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAA0E;AAE1E,mCAAgH;AAuBhH;;;GAGG;AACH,MAAa,IAAI;IA0Bf;;;;;;;;;;OAUG;IACH,YAAmB,WAA0B,EAAE,KAA+B,EAAE,OAAe,EAAE,SAAgC,EAC/H,MAA+B,EAAE,aAA6C,EAAE,gBAA0B,EAAE,YAAqC;QACjJ,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,8CAA8C;QACtE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,iCAAe,CAAC,eAAe,CAAC,KAAK,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xD,mDAAmD;YACnD,KAAK,EAAE,iCAAe,CAAC,QAAQ,CAAC,eAAe,CAAC;SAChC,CAAC,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,GAAW,EAAE,KAAU;QAC3C,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,YAAY,CAAC,IAAyB;QAClD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,6DAA6D;YAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;SAC3C;QACD,6DAA6D;QAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAgB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,GAAW,EAAE,KAAU;QAC/C,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,CAAC;CACF;AAxHD,oBAwHC","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 Content\n */\n\nimport { ClassInfo, InstanceKey } from \"../EC\";\nimport { LabelDefinition, LabelDefinitionJSON } from \"../LabelDefinition\";\nimport { ValuesDictionary } from \"../Utils\";\nimport { DisplayValue, DisplayValueJSON, DisplayValuesMapJSON, Value, ValueJSON, ValuesMapJSON } from \"./Value\";\n\n/**\n * Serialized [[Item]] JSON representation.\n * @public\n */\nexport interface ItemJSON {\n inputKeys?: InstanceKey[];\n primaryKeys: InstanceKey[];\n // TODO: rename to `label`\n // eslint-disable-next-line deprecation/deprecation\n labelDefinition: LabelDefinitionJSON;\n /** @deprecated in 3.x. Use [[extendedData]] instead. See [extended data usage page]($docs/presentation/customization/ExtendedDataUsage.md) for more details. */\n imageId: string;\n classInfo?: ClassInfo;\n // eslint-disable-next-line deprecation/deprecation\n values: ValuesDictionary<ValueJSON>;\n // eslint-disable-next-line deprecation/deprecation\n displayValues: ValuesDictionary<DisplayValueJSON>;\n mergedFieldNames: string[];\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A data structure that represents a single content record.\n * @public\n */\nexport class Item {\n /**\n * Keys of input instances that caused this item to be included in content. Only set if the content is\n * created with [[ContentFlags.IncludeInputKeys]] flag.\n */\n public inputKeys?: InstanceKey[];\n /** Keys of instances whose data is contained in this item */\n public primaryKeys: InstanceKey[];\n /** Display label of the item */\n public label: LabelDefinition;\n /**\n * ID of the image associated with this item\n * @deprecated in 3.x. Use [[extendedData]] instead. See [extended data usage page]($docs/presentation/customization/ExtendedDataUsage.md) for more details.\n */\n public imageId: string;\n /** For cases when item consists only of same class instances, information about the ECClass */\n public classInfo?: ClassInfo;\n /** Raw values dictionary */\n public values: ValuesDictionary<Value>;\n /** Display values dictionary */\n public displayValues: ValuesDictionary<DisplayValue>;\n /** List of field names whose values are merged (see [Merging values]($docs/presentation/content/Terminology#value-merging)) */\n public mergedFieldNames: string[];\n /** Extended data injected into this content item */\n public extendedData?: { [key: string]: any };\n\n /**\n * Creates an instance of Item.\n * @param primaryKeys Keys of instances whose data is contained in this item\n * @param label Display label of the item\n * @param imageId ID of the image associated with this item\n * @param classInfo For cases when item consists only of same class instances, information about the ECClass\n * @param values Raw values dictionary\n * @param displayValues Display values dictionary\n * @param mergedFieldNames List of field names whose values are merged (see [Merging values]($docs/presentation/content/Terminology#value-merging))\n * @param extendedData Extended data injected into this content item\n */\n public constructor(primaryKeys: InstanceKey[], label: string | LabelDefinition, imageId: string, classInfo: ClassInfo | undefined,\n values: ValuesDictionary<Value>, displayValues: ValuesDictionary<DisplayValue>, mergedFieldNames: string[], extendedData?: { [key: string]: any }) {\n this.primaryKeys = primaryKeys;\n this.imageId = imageId; // eslint-disable-line deprecation/deprecation\n this.classInfo = classInfo;\n this.values = values;\n this.displayValues = displayValues;\n this.mergedFieldNames = mergedFieldNames;\n this.extendedData = extendedData;\n this.label = (typeof label === \"string\") ? LabelDefinition.fromLabelString(label) : label;\n }\n\n /**\n * Is value of field with the specified name merged in this record.\n */\n public isFieldMerged(fieldName: string): boolean {\n return -1 !== this.mergedFieldNames.indexOf(fieldName);\n }\n\n /** Serialize this object to JSON */\n public toJSON(): ItemJSON {\n const { label, ...baseItem } = this;\n return {\n ...baseItem,\n // eslint-disable-next-line deprecation/deprecation\n values: Value.toJSON(this.values) as ValuesMapJSON,\n // eslint-disable-next-line deprecation/deprecation\n displayValues: DisplayValue.toJSON(this.displayValues) as DisplayValuesMapJSON,\n // eslint-disable-next-line deprecation/deprecation\n labelDefinition: LabelDefinition.toJSON(label),\n };\n }\n\n /** Deserialize [[Item]] from JSON */\n public static fromJSON(json: ItemJSON | string | undefined): Item | undefined {\n if (!json)\n return undefined;\n if (typeof json === \"string\")\n return JSON.parse(json, (key, value) => Item.reviver(key, value));\n const item = Object.create(Item.prototype);\n const { labelDefinition, ...baseJson } = json;\n return Object.assign(item, baseJson, {\n // eslint-disable-next-line deprecation/deprecation\n values: Value.fromJSON(json.values),\n // eslint-disable-next-line deprecation/deprecation\n displayValues: DisplayValue.fromJSON(json.displayValues),\n // eslint-disable-next-line deprecation/deprecation\n label: LabelDefinition.fromJSON(labelDefinition),\n } as Partial<Item>);\n }\n\n /**\n * Reviver function that can be used as a second argument for\n * `JSON.parse` method when parsing Item objects.\n * @internal\n */\n public static reviver(key: string, value: any): any {\n return key === \"\" ? Item.fromJSON(value) : value;\n }\n\n /**\n * Deserialize items list from JSON\n * @param json JSON or JSON serialized to string to deserialize from\n * @returns Deserialized items list\n * @internal\n */\n public static listFromJSON(json: ItemJSON[] | string): Item[] {\n if (typeof json === \"string\") {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return JSON.parse(json, Item.listReviver);\n }\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return json.map(Item.fromJSON).filter((item): item is Item => !!item);\n }\n\n /**\n * Reviver function that can be used as a second argument for\n * `JSON.parse` method when parsing [[Item]][] objects.\n * @internal\n */\n public static listReviver(key: string, value: any): any {\n return key === \"\" ? Item.listFromJSON(value) : value;\n }\n}\n"]}
@@ -4,7 +4,9 @@
4
4
  import { UnitSystemKey } from "@itwin/core-quantity";
5
5
  import { KoqPropertyValueFormatter } from "../KoqPropertyValueFormatter";
6
6
  import { Content } from "./Content";
7
+ import { Descriptor } from "./Descriptor";
7
8
  import { Field } from "./Fields";
9
+ import { Item } from "./Item";
8
10
  import { DisplayValue, Value } from "./Value";
9
11
  /** @alpha */
10
12
  export declare class ContentFormatter {
@@ -12,6 +14,7 @@ export declare class ContentFormatter {
12
14
  private _unitSystem?;
13
15
  constructor(_propertyValueFormatter: ContentPropertyValueFormatter, _unitSystem?: UnitSystemKey | undefined);
14
16
  formatContent(content: Content): Promise<Content>;
17
+ formatContentItems(items: Item[], descriptor: Descriptor): Promise<Item[]>;
15
18
  private formatValues;
16
19
  private formatNestedContentDisplayValues;
17
20
  }