@itwin/presentation-common 5.7.0-dev.1 → 5.7.0-dev.11

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 (27) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/Ruleset.schema.json +41 -123
  3. package/lib/cjs/presentation-common/ElementProperties.d.ts.map +1 -1
  4. package/lib/cjs/presentation-common/ElementProperties.js +16 -10
  5. package/lib/cjs/presentation-common/ElementProperties.js.map +1 -1
  6. package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts +8 -2
  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/ContentTraverser.js +1 -1
  10. package/lib/cjs/presentation-common/content/ContentTraverser.js.map +1 -1
  11. package/lib/cjs/presentation-common/content/Descriptor.d.ts +22 -6
  12. package/lib/cjs/presentation-common/content/Descriptor.d.ts.map +1 -1
  13. package/lib/cjs/presentation-common/content/Descriptor.js +156 -0
  14. package/lib/cjs/presentation-common/content/Descriptor.js.map +1 -1
  15. package/lib/esm/presentation-common/ElementProperties.d.ts.map +1 -1
  16. package/lib/esm/presentation-common/ElementProperties.js +17 -11
  17. package/lib/esm/presentation-common/ElementProperties.js.map +1 -1
  18. package/lib/esm/presentation-common/PresentationManagerOptions.d.ts +8 -2
  19. package/lib/esm/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
  20. package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
  21. package/lib/esm/presentation-common/content/ContentTraverser.js +1 -1
  22. package/lib/esm/presentation-common/content/ContentTraverser.js.map +1 -1
  23. package/lib/esm/presentation-common/content/Descriptor.d.ts +22 -6
  24. package/lib/esm/presentation-common/content/Descriptor.d.ts.map +1 -1
  25. package/lib/esm/presentation-common/content/Descriptor.js +157 -1
  26. package/lib/esm/presentation-common/content/Descriptor.js.map +1 -1
  27. package/package.json +11 -12
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Change Log - @itwin/presentation-common
2
2
 
3
- This log was last generated on Thu, 22 Jan 2026 16:18:35 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 05 Feb 2026 16:14:10 GMT and should not be manually modified.
4
+
5
+ ## 5.6.0
6
+ Thu, 05 Feb 2026 16:12:37 GMT
7
+
8
+ ### Updates
9
+
10
+ - Ensure array & struct parent fields are accessible from their items & member fields. Also, ensure `IContentVisitor` receives parent array & struct names as the `parentFieldName` when traversing content.
11
+ - Added `getFieldByName` method to `ArrayPropertiesField` and `StructPropertiesField`.
4
12
 
5
13
  ## 5.5.2
6
14
  Thu, 22 Jan 2026 16:16:54 GMT
@@ -104,10 +104,8 @@
104
104
  "type": "array"
105
105
  },
106
106
  "ruleType": {
107
+ "const": "ChildNodes",
107
108
  "description": "Used for serializing to JSON.",
108
- "enum": [
109
- "ChildNodes"
110
- ],
111
109
  "type": "string"
112
110
  },
113
111
  "specifications": {
@@ -166,10 +164,8 @@
166
164
  "type": "boolean"
167
165
  },
168
166
  "specType": {
167
+ "const": "Class",
169
168
  "description": "Used for serializing to JSON.",
170
- "enum": [
171
- "Class"
172
- ],
173
169
  "type": "string"
174
170
  }
175
171
  },
@@ -262,10 +258,8 @@
262
258
  "type": "array"
263
259
  },
264
260
  "specType": {
261
+ "const": "ContentInstancesOfSpecificClasses",
265
262
  "description": "Used for serializing to JSON.",
266
- "enum": [
267
- "ContentInstancesOfSpecificClasses"
268
- ],
269
263
  "type": "string"
270
264
  }
271
265
  },
@@ -331,10 +325,8 @@
331
325
  "type": "array"
332
326
  },
333
327
  "ruleType": {
328
+ "const": "ContentModifier",
334
329
  "description": "Used for serializing to JSON.",
335
- "enum": [
336
- "ContentModifier"
337
- ],
338
330
  "type": "string"
339
331
  }
340
332
  },
@@ -402,10 +394,8 @@
402
394
  "type": "array"
403
395
  },
404
396
  "specType": {
397
+ "const": "ContentRelatedInstances",
405
398
  "description": "Used for serializing to JSON.",
406
- "enum": [
407
- "ContentRelatedInstances"
408
- ],
409
399
  "type": "string"
410
400
  }
411
401
  },
@@ -439,10 +429,8 @@
439
429
  "type": "array"
440
430
  },
441
431
  "ruleType": {
432
+ "const": "Content",
442
433
  "description": "Used for serializing to JSON.",
443
- "enum": [
444
- "Content"
445
- ],
446
434
  "type": "string"
447
435
  },
448
436
  "specifications": {
@@ -535,10 +523,8 @@
535
523
  "type": "array"
536
524
  },
537
525
  "specType": {
526
+ "const": "CustomNode",
538
527
  "description": "Used for serializing to JSON.",
539
- "enum": [
540
- "CustomNode"
541
- ],
542
528
  "type": "string"
543
529
  },
544
530
  "suppressSimilarAncestorsCheck": {
@@ -621,10 +607,8 @@
621
607
  "type": "array"
622
608
  },
623
609
  "specType": {
610
+ "const": "CustomQueryInstanceNodes",
624
611
  "description": "Used for serializing to JSON.",
625
- "enum": [
626
- "CustomQueryInstanceNodes"
627
- ],
628
612
  "type": "string"
629
613
  },
630
614
  "suppressSimilarAncestorsCheck": {
@@ -694,10 +678,8 @@
694
678
  "type": "array"
695
679
  },
696
680
  "ruleType": {
681
+ "const": "DefaultPropertyCategoryOverride",
697
682
  "description": "Used for serializing to JSON.",
698
- "enum": [
699
- "DefaultPropertyCategoryOverride"
700
- ],
701
683
  "type": "string"
702
684
  },
703
685
  "specification": {
@@ -743,10 +725,8 @@
743
725
  "type": "array"
744
726
  },
745
727
  "ruleType": {
728
+ "const": "DisabledSorting",
746
729
  "description": "Used for serializing to JSON.",
747
- "enum": [
748
- "DisabledSorting"
749
- ],
750
730
  "type": "string"
751
731
  }
752
732
  },
@@ -769,10 +749,8 @@
769
749
  "type": "string"
770
750
  },
771
751
  "specType": {
752
+ "const": "ECPropertyValue",
772
753
  "description": "Used for serializing to JSON.",
773
- "enum": [
774
- "ECPropertyValue"
775
- ],
776
754
  "type": "string"
777
755
  }
778
756
  },
@@ -814,10 +792,8 @@
814
792
  "type": "array"
815
793
  },
816
794
  "ruleType": {
795
+ "const": "ExtendedData",
817
796
  "description": "Used for serializing to JSON.",
818
- "enum": [
819
- "ExtendedData"
820
- ],
821
797
  "type": "string"
822
798
  }
823
799
  },
@@ -863,10 +839,8 @@
863
839
  "type": "array"
864
840
  },
865
841
  "ruleType": {
842
+ "const": "Grouping",
866
843
  "description": "Used for serializing to JSON.",
867
- "enum": [
868
- "Grouping"
869
- ],
870
844
  "type": "string"
871
845
  }
872
846
  },
@@ -905,10 +879,8 @@
905
879
  "type": "boolean"
906
880
  },
907
881
  "type": {
882
+ "const": "Id",
908
883
  "description": "Type of the identifier",
909
- "enum": [
910
- "Id"
911
- ],
912
884
  "type": "string"
913
885
  }
914
886
  },
@@ -942,10 +914,8 @@
942
914
  "type": "array"
943
915
  },
944
916
  "ruleType": {
917
+ "const": "InstanceLabelOverride",
945
918
  "description": "Used for serializing to JSON.",
946
- "enum": [
947
- "InstanceLabelOverride"
948
- ],
949
919
  "type": "string"
950
920
  },
951
921
  "values": {
@@ -968,10 +938,8 @@
968
938
  "description": "Specification returns ECInstance's briefcase ID in base36 format.",
969
939
  "properties": {
970
940
  "specType": {
941
+ "const": "BriefcaseId",
971
942
  "description": "Type of the specification",
972
- "enum": [
973
- "BriefcaseId"
974
- ],
975
943
  "type": "string"
976
944
  }
977
945
  },
@@ -985,10 +953,8 @@
985
953
  "description": "Specification uses ECClass display label as the label content.",
986
954
  "properties": {
987
955
  "specType": {
956
+ "const": "ClassLabel",
988
957
  "description": "Type of the specification",
989
- "enum": [
990
- "ClassLabel"
991
- ],
992
958
  "type": "string"
993
959
  }
994
960
  },
@@ -1006,10 +972,8 @@
1006
972
  "type": "boolean"
1007
973
  },
1008
974
  "specType": {
975
+ "const": "ClassName",
1009
976
  "description": "Type of the specification",
1010
- "enum": [
1011
- "ClassName"
1012
- ],
1013
977
  "type": "string"
1014
978
  }
1015
979
  },
@@ -1046,10 +1010,8 @@
1046
1010
  "type": "string"
1047
1011
  },
1048
1012
  "specType": {
1013
+ "const": "Composite",
1049
1014
  "description": "Type of the specification",
1050
- "enum": [
1051
- "Composite"
1052
- ],
1053
1015
  "type": "string"
1054
1016
  }
1055
1017
  },
@@ -1064,10 +1026,8 @@
1064
1026
  "description": "Specification returns ECInstance's local ID in base36 format.",
1065
1027
  "properties": {
1066
1028
  "specType": {
1029
+ "const": "LocalId",
1067
1030
  "description": "Type of the specification",
1068
- "enum": [
1069
- "LocalId"
1070
- ],
1071
1031
  "type": "string"
1072
1032
  }
1073
1033
  },
@@ -1099,10 +1059,8 @@
1099
1059
  "description": "Specification of the relationship path from `InstanceLabelOverride.class`\nto class of the property. If omitted, `InstanceLabelOverride.class` is used as property class."
1100
1060
  },
1101
1061
  "specType": {
1062
+ "const": "Property",
1102
1063
  "description": "Type of the specification",
1103
- "enum": [
1104
- "Property"
1105
- ],
1106
1064
  "type": "string"
1107
1065
  }
1108
1066
  },
@@ -1121,10 +1079,8 @@
1121
1079
  "description": "Specification of the relationship path from `InstanceLabelOverride.class`\nto class of the related instance."
1122
1080
  },
1123
1081
  "specType": {
1082
+ "const": "RelatedInstanceLabel",
1124
1083
  "description": "Type of the specification",
1125
- "enum": [
1126
- "RelatedInstanceLabel"
1127
- ],
1128
1084
  "type": "string"
1129
1085
  }
1130
1086
  },
@@ -1139,10 +1095,8 @@
1139
1095
  "description": "Specification uses the specified value as the label content.",
1140
1096
  "properties": {
1141
1097
  "specType": {
1098
+ "const": "String",
1142
1099
  "description": "Type of the specification",
1143
- "enum": [
1144
- "String"
1145
- ],
1146
1100
  "type": "string"
1147
1101
  },
1148
1102
  "value": {
@@ -1274,10 +1228,8 @@
1274
1228
  "type": "array"
1275
1229
  },
1276
1230
  "specType": {
1231
+ "const": "InstanceNodesOfSpecificClasses",
1277
1232
  "description": "Used for serializing to JSON.",
1278
- "enum": [
1279
- "InstanceNodesOfSpecificClasses"
1280
- ],
1281
1233
  "type": "string"
1282
1234
  },
1283
1235
  "suppressSimilarAncestorsCheck": {
@@ -1323,10 +1275,8 @@
1323
1275
  "description": "Identifier for no category. Used to make category displayed at root level by using\nthis identifier for `PropertyCategorySpecification.parentId`.",
1324
1276
  "properties": {
1325
1277
  "type": {
1278
+ "const": "None",
1326
1279
  "description": "Type of the identifier",
1327
- "enum": [
1328
- "None"
1329
- ],
1330
1280
  "type": "string"
1331
1281
  }
1332
1282
  },
@@ -1367,10 +1317,8 @@
1367
1317
  "type": "array"
1368
1318
  },
1369
1319
  "ruleType": {
1320
+ "const": "NodeArtifacts",
1370
1321
  "description": "Used for serializing to JSON.",
1371
- "enum": [
1372
- "NodeArtifacts"
1373
- ],
1374
1322
  "type": "string"
1375
1323
  }
1376
1324
  },
@@ -1385,10 +1333,8 @@
1385
1333
  "description": "Identifier of the default parent category.\n\nFor direct properties it's the default category. See `DefaultPropertyCategoryOverride` for overriding the default category.\n\nFor related properties it's the category made up from the related ECClass defined by the last\n`RelatedPropertiesSpecification` with `RelationshipMeaning.RelatedInstance`. If there's no such specification,\nthe default category is used.",
1386
1334
  "properties": {
1387
1335
  "type": {
1336
+ "const": "DefaultParent",
1388
1337
  "description": "Type of the identifier",
1389
- "enum": [
1390
- "DefaultParent"
1391
- ],
1392
1338
  "type": "string"
1393
1339
  }
1394
1340
  },
@@ -1463,10 +1409,8 @@
1463
1409
  "description": "Arbitrary JSON that can be handled by a property editor"
1464
1410
  },
1465
1411
  "paramsType": {
1412
+ "const": "Json",
1466
1413
  "description": "Used for serializing to JSON.",
1467
- "enum": [
1468
- "Json"
1469
- ],
1470
1414
  "type": "string"
1471
1415
  }
1472
1416
  },
@@ -1486,10 +1430,8 @@
1486
1430
  "type": "integer"
1487
1431
  },
1488
1432
  "paramsType": {
1433
+ "const": "Multiline",
1489
1434
  "description": "Used for serializing to JSON.",
1490
- "enum": [
1491
- "Multiline"
1492
- ],
1493
1435
  "type": "string"
1494
1436
  }
1495
1437
  },
@@ -1528,10 +1470,8 @@
1528
1470
  "type": "number"
1529
1471
  },
1530
1472
  "paramsType": {
1473
+ "const": "Range",
1531
1474
  "description": "Used for serializing to JSON.",
1532
- "enum": [
1533
- "Range"
1534
- ],
1535
1475
  "type": "string"
1536
1476
  }
1537
1477
  },
@@ -1562,10 +1502,8 @@
1562
1502
  "type": "number"
1563
1503
  },
1564
1504
  "paramsType": {
1505
+ "const": "Slider",
1565
1506
  "description": "Used for serializing to JSON.",
1566
- "enum": [
1567
- "Slider"
1568
- ],
1569
1507
  "type": "string"
1570
1508
  }
1571
1509
  },
@@ -1629,10 +1567,8 @@
1629
1567
  "type": "array"
1630
1568
  },
1631
1569
  "specType": {
1570
+ "const": "Property",
1632
1571
  "description": "Used for serializing to JSON.",
1633
- "enum": [
1634
- "Property"
1635
- ],
1636
1572
  "type": "string"
1637
1573
  }
1638
1574
  },
@@ -1712,10 +1648,8 @@
1712
1648
  "type": "array"
1713
1649
  },
1714
1650
  "ruleType": {
1651
+ "const": "PropertySorting",
1715
1652
  "description": "Used for serializing to JSON.",
1716
- "enum": [
1717
- "PropertySorting"
1718
- ],
1719
1653
  "type": "string"
1720
1654
  },
1721
1655
  "sortAscending": {
@@ -1944,10 +1878,8 @@
1944
1878
  "type": "array"
1945
1879
  },
1946
1880
  "specType": {
1881
+ "const": "RelatedInstanceNodes",
1947
1882
  "description": "Used for serializing to JSON.",
1948
- "enum": [
1949
- "RelatedInstanceNodes"
1950
- ],
1951
1883
  "type": "string"
1952
1884
  },
1953
1885
  "suppressSimilarAncestorsCheck": {
@@ -2133,9 +2065,7 @@
2133
2065
  "count": {
2134
2066
  "anyOf": [
2135
2067
  {
2136
- "enum": [
2137
- "*"
2138
- ],
2068
+ "const": "*",
2139
2069
  "type": "string"
2140
2070
  },
2141
2071
  {
@@ -2196,10 +2126,8 @@
2196
2126
  "description": "Identifier of the root category.\n\nFor direct properties it's the default category. See `DefaultPropertyCategoryOverride` for overriding the default category.\n\nFor related properties it's the category made up from the related ECClass defined by the first\n`RelatedPropertiesSpecification` with `RelationshipMeaning.RelatedInstance`. If there's no such specification,\nthe default category is used.",
2197
2127
  "properties": {
2198
2128
  "type": {
2129
+ "const": "Root",
2199
2130
  "description": "Type of the identifier",
2200
- "enum": [
2201
- "Root"
2202
- ],
2203
2131
  "type": "string"
2204
2132
  }
2205
2133
  },
@@ -2244,10 +2172,8 @@
2244
2172
  "type": "array"
2245
2173
  },
2246
2174
  "ruleType": {
2175
+ "const": "RootNodes",
2247
2176
  "description": "Used for serializing to JSON.",
2248
- "enum": [
2249
- "RootNodes"
2250
- ],
2251
2177
  "type": "string"
2252
2178
  },
2253
2179
  "specifications": {
@@ -2326,10 +2252,8 @@
2326
2252
  "type": "string"
2327
2253
  },
2328
2254
  "specType": {
2255
+ "const": "SameLabelInstance",
2329
2256
  "description": "Used for serializing to JSON.",
2330
- "enum": [
2331
- "SameLabelInstance"
2332
- ],
2333
2257
  "type": "string"
2334
2258
  }
2335
2259
  },
@@ -2347,10 +2271,8 @@
2347
2271
  "type": "string"
2348
2272
  },
2349
2273
  "type": {
2274
+ "const": "SchemaCategory",
2350
2275
  "description": "Type of the identifier",
2351
- "enum": [
2352
- "SchemaCategory"
2353
- ],
2354
2276
  "type": "string"
2355
2277
  }
2356
2278
  },
@@ -2424,10 +2346,8 @@
2424
2346
  "type": "array"
2425
2347
  },
2426
2348
  "specType": {
2349
+ "const": "SelectedNodeInstances",
2427
2350
  "description": "Used for serializing to JSON.",
2428
- "enum": [
2429
- "SelectedNodeInstances"
2430
- ],
2431
2351
  "type": "string"
2432
2352
  }
2433
2353
  },
@@ -2471,10 +2391,8 @@
2471
2391
  "type": "string"
2472
2392
  },
2473
2393
  "specType": {
2394
+ "const": "String",
2474
2395
  "description": "Used for serializing to JSON.",
2475
- "enum": [
2476
- "String"
2477
- ],
2478
2396
  "type": "string"
2479
2397
  }
2480
2398
  },
@@ -1 +1 @@
1
- {"version":3,"file":"ElementProperties.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/ElementProperties.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAe/D,O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EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,wCAAyC,SAAQ,sCAAsC;IACtG,8CAA8C;IAC9C,SAAS,EAAE,QAAQ,CAAC;IACpB,wBAAwB;IACxB,MAAM,EAAE,KAAK,CAAC;QAAE,CAAC,WAAW,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAE,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,2CAA2C,GAAG,wCAAwC,CAAC;AAExI;;;GAGG;AACH,MAAM,WAAW,mCAAoC,SAAQ,iCAAiC;IAC5F,mCAAmC;IACnC,IAAI,EAAE,QAAQ,CAAC;IACf,mCAAmC;IACnC,OAAO,EAAE;QAAE,CAAC,WAAW,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAE,CAAC;CACnE;AAED;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElF;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,sCAAsC,GAAG,kCAAkC,GAAG,mCAAmC,CAAC;AAE9J;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,6BAA6B,GAAG,6BAA6B,CAAC;AAElG,gBAAgB;AAChB,eAAO,MAAM,8BAA8B,QAAO,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,KAAK,iBAAiB,CAO3G,CAAC"}
1
+ {"version":3,"file":"ElementProperties.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/ElementProperties.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiC,UAAU,EAAe,MAAM,qBAAqB,CAAC;AAe7F,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;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,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAE,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,2CAA2C,GAAG,wCAAwC,CAAC;AAExI;;;GAGG;AACH,MAAM,WAAW,mCAAoC,SAAQ,iCAAiC;IAC5F,mCAAmC;IACnC,IAAI,EAAE,QAAQ,CAAC;IACf,mCAAmC;IACnC,OAAO,EAAE;QAAE,CAAC,WAAW,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAE,CAAC;CACnE;AAED;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElF;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,sCAAsC,GAAG,kCAAkC,GAAG,mCAAmC,CAAC;AAE9J;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,6BAA6B,GAAG,6BAA6B,CAAC;AAElG,gBAAgB;AAChB,eAAO,MAAM,8BAA8B,QAAO,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,KAAK,iBAAiB,CAO3G,CAAC"}
@@ -34,11 +34,14 @@ class ElementPropertiesAppender {
34
34
  this._propertyItems[label] = item;
35
35
  }
36
36
  finish() {
37
- // eslint-disable-next-line guard-for-in
38
- for (const categoryName in this._categoryItemAppenders) {
39
- const appender = this._categoryItemAppenders[categoryName];
40
- appender.finish();
41
- }
37
+ // create an ordered list of category depths / appenders starting with categories that have the most ancestors and finishing with categories
38
+ // that have no ancestors, so that when we call `finish` on appenders, child categories are finished before parent categories, otherwise
39
+ // we may skip parent categories, thinking they have no items
40
+ const categoriesNestedToRoot = new core_bentley_1.SortedArray((lhs, rhs) => rhs.categoryDepth - lhs.categoryDepth, core_bentley_1.DuplicatePolicy.Allow);
41
+ Object.entries(this._categoryItemAppenders).forEach(([_, { category, appender }]) => {
42
+ categoriesNestedToRoot.insert({ categoryDepth: countAncestors(category), appender });
43
+ });
44
+ categoriesNestedToRoot.forEach(({ appender }) => appender.finish());
42
45
  this._onItemFinished({
43
46
  class: this._item.classInfo?.label ?? "",
44
47
  id: this._item.primaryKeys[0]?.id ?? core_bentley_1.Id64.invalid,
@@ -47,12 +50,12 @@ class ElementPropertiesAppender {
47
50
  });
48
51
  }
49
52
  getCategoryAppender(parentAppender, category) {
50
- let appender = this._categoryItemAppenders[category.name];
51
- if (!appender) {
52
- appender = new CategoryItemAppender(parentAppender, category);
53
- this._categoryItemAppenders[category.name] = appender;
53
+ let entry = this._categoryItemAppenders[category.name];
54
+ if (!entry) {
55
+ entry = { category, appender: new CategoryItemAppender(parentAppender, category) };
56
+ this._categoryItemAppenders[category.name] = entry;
54
57
  }
55
- return appender;
58
+ return entry.appender;
56
59
  }
57
60
  }
58
61
  class CategoryItemAppender {
@@ -209,4 +212,7 @@ class ElementPropertiesBuilder {
209
212
  });
210
213
  }
211
214
  }
215
+ function countAncestors(child) {
216
+ return child.parent ? 1 + countAncestors(child.parent) : 0;
217
+ }
212
218
  //# sourceMappingURL=ElementProperties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ElementProperties.js","sourceRoot":"","sources":["../../../src/presentation-common/ElementProperties.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA+D;AAE/D,uEAYuC;AAGvC,qEAAmE;AA8HnE,gBAAgB;AACT,MAAM,8BAA8B,GAAG,GAAgE,EAAE;IAC9G,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC/C,MAAM,eAAe,GAAG,IAAA,4CAAsB,EAAC,OAAO,CAAC,CAAC;IACxD,OAAO,CAAC,UAAsB,EAAE,IAAU,EAAE,EAAE;QAC5C,eAAe,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,8BAA8B,kC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gB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;YACpD,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IACM,qBAAqB,CAAC,KAAiC;QAC5D,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YAC9C,IAAI,EAAE,WAAW;YACjB,gEAAgE;YAChE,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { CategoryDescription } from \"./content/Category.js\";\r\nimport {\r\n createContentTraverser,\r\n IContentVisitor,\r\n ProcessFieldHierarchiesProps,\r\n ProcessMergedValueProps,\r\n ProcessPrimitiveValueProps,\r\n StartArrayProps,\r\n StartCategoryProps,\r\n StartContentProps,\r\n StartFieldProps,\r\n StartItemProps,\r\n StartStructProps,\r\n} from \"./content/ContentTraverser.js\";\r\nimport { Descriptor } from \"./content/Descriptor.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { PropertyValueFormat } from \"./content/TypeDescription.js\";\r\n\r\n/**\r\n * Data structure for storing element properties information in a simplified format.\r\n * @see [[Content]] for a format that stores all available element property data.\r\n * @public\r\n */\r\nexport interface ElementProperties {\r\n /** Label of element's ECClass. */\r\n class: string;\r\n /** Element's ID. */\r\n id: Id64String;\r\n /** Element's label. */\r\n label: string;\r\n /** Container of property values */\r\n items: { [label: string]: ElementPropertiesItem };\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: \"category\" | ElementPropertiesPropertyValueType;\r\n}\r\n\r\n/**\r\n * Definition for a category. A category can nest other property items, including categories.\r\n * @public\r\n */\r\nexport interface ElementPropertiesCategoryItem extends ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: \"category\";\r\n /** Container of property values */\r\n items: { [label: string]: ElementPropertiesItem };\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesPropertyItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPropertyItemBase extends ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: ElementPropertiesPropertyValueType;\r\n}\r\n\r\n/**\r\n * Definition for a primitive property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPrimitivePropertyItem extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"primitive\";\r\n /** Display value of the property. */\r\n value: string;\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesArrayPropertyItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesArrayPropertyItemBase extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"array\";\r\n /** Type of values contained in this array. */\r\n valueType: \"primitive\" | \"struct\";\r\n}\r\n\r\n/**\r\n * Definition for a primitives' array property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPrimitiveArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\r\n /** Type of values contained in this array. */\r\n valueType: \"primitive\";\r\n /** Array of display values. */\r\n values: string[];\r\n}\r\n\r\n/**\r\n * Definition for a structs' array property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesStructArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\r\n /** Type of values contained in this array. */\r\n valueType: \"struct\";\r\n /** Array of structs. */\r\n values: Array<{ [memberLabel: string]: ElementPropertiesPropertyItem }>;\r\n}\r\n\r\n/**\r\n * Definition for an array property value.\r\n * @public\r\n */\r\nexport type ElementPropertiesArrayPropertyItem = ElementPropertiesPrimitiveArrayPropertyItem | ElementPropertiesStructArrayPropertyItem;\r\n\r\n/**\r\n * Definition for an struct property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesStructPropertyItem extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"struct\";\r\n /** Container of struct members. */\r\n members: { [memberLabel: string]: ElementPropertiesPropertyItem };\r\n}\r\n\r\n/**\r\n * Available element property types.\r\n * @public\r\n */\r\nexport type ElementPropertiesPropertyValueType = \"primitive\" | \"array\" | \"struct\";\r\n\r\n/**\r\n * Definition of a property value.\r\n * @public\r\n */\r\nexport type ElementPropertiesPropertyItem = ElementPropertiesPrimitivePropertyItem | ElementPropertiesArrayPropertyItem | ElementPropertiesStructPropertyItem;\r\n\r\n/**\r\n * Definition of a property item, including a property category.\r\n * @public\r\n */\r\nexport type ElementPropertiesItem = ElementPropertiesCategoryItem | ElementPropertiesPropertyItem;\r\n\r\n/** @internal */\r\nexport const createElementPropertiesBuilder = (): ((descriptor: Descriptor, item: Item) => ElementProperties) => {\r\n const builder = new ElementPropertiesBuilder();\r\n const traverseContent = createContentTraverser(builder);\r\n return (descriptor: Descriptor, item: Item) => {\r\n traverseContent(descriptor, [item]);\r\n return builder.items[0];\r\n };\r\n};\r\n\r\ninterface IPropertiesAppender {\r\n append(label: string, item: ElementPropertiesItem): void;\r\n finish(): void;\r\n}\r\n\r\nclass ElementPropertiesAppender implements IPropertiesAppender {\r\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\r\n private _categoryItemAppenders: { [categoryName: string]: IPropertiesAppender } = {};\r\n constructor(\r\n private _item: Item,\r\n private _onItemFinished: (item: ElementProperties) => void,\r\n ) {}\r\n\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._propertyItems[label] = item;\r\n }\r\n\r\n public finish(): void {\r\n // eslint-disable-next-line guard-for-in\r\n for (const categoryName in this._categoryItemAppenders) {\r\n const appender = this._categoryItemAppenders[categoryName];\r\n appender.finish();\r\n }\r\n\r\n this._onItemFinished({\r\n class: this._item.classInfo?.label ?? \"\",\r\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\r\n label: this._item.label.displayValue,\r\n items: this._propertyItems,\r\n });\r\n }\r\n\r\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\r\n let appender = this._categoryItemAppenders[category.name];\r\n if (!appender) {\r\n appender = new CategoryItemAppender(parentAppender, category);\r\n this._categoryItemAppenders[category.name] = appender;\r\n }\r\n return appender;\r\n }\r\n}\r\n\r\nclass CategoryItemAppender implements IPropertiesAppender {\r\n private _items: { [label: string]: ElementPropertiesItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _category: CategoryDescription,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._items[label] = item;\r\n }\r\n public finish(): void {\r\n if (Object.keys(this._items).length === 0) {\r\n return;\r\n }\r\n\r\n this._parentAppender.append(this._category.label, {\r\n type: \"category\",\r\n items: this._items,\r\n });\r\n }\r\n}\r\n\r\nclass ArrayItemAppender implements IPropertiesAppender {\r\n private _items: ElementPropertiesPropertyItem[] = [];\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartArrayProps,\r\n ) {}\r\n public append(_label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._items.push(item);\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\r\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive) {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\r\n } else {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\r\n }\r\n }\r\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"primitive\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"primitive\");\r\n return item.value;\r\n }),\r\n };\r\n }\r\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"struct\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"struct\");\r\n return item.members;\r\n }),\r\n };\r\n }\r\n}\r\n\r\nclass StructItemAppender implements IPropertiesAppender {\r\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartStructProps,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._members[label] = item;\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\r\n this._parentAppender.append(this._props.hierarchy.field.label, {\r\n type: \"struct\",\r\n members: this._members,\r\n });\r\n }\r\n}\r\n\r\nclass ElementPropertiesBuilder implements IContentVisitor {\r\n private _appendersStack: IPropertiesAppender[] = [];\r\n private _items: ElementProperties[] = [];\r\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\r\n\r\n public get items(): ElementProperties[] {\r\n return this._items;\r\n }\r\n\r\n private get _currentAppender(): IPropertiesAppender {\r\n const appender = this._appendersStack[this._appendersStack.length - 1];\r\n assert(appender !== undefined);\r\n return appender;\r\n }\r\n\r\n public startContent(_props: StartContentProps): boolean {\r\n this._appendersStack = [];\r\n this._items = [];\r\n this._elementPropertiesAppender = undefined;\r\n return true;\r\n }\r\n public finishContent(): void {}\r\n\r\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void {}\r\n\r\n public startItem(props: StartItemProps): boolean {\r\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\r\n this._appendersStack.push(this._elementPropertiesAppender);\r\n return true;\r\n }\r\n public finishItem(): void {\r\n this._appendersStack.pop();\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._elementPropertiesAppender.finish();\r\n this._elementPropertiesAppender = undefined;\r\n }\r\n\r\n public startCategory(props: StartCategoryProps): boolean {\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\r\n return true;\r\n }\r\n public finishCategory(): void {\r\n this._appendersStack.pop();\r\n }\r\n\r\n public startField(_props: StartFieldProps): boolean {\r\n return true;\r\n }\r\n public finishField(): void {}\r\n\r\n public startStruct(props: StartStructProps): boolean {\r\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishStruct(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public startArray(props: StartArrayProps): boolean {\r\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishArray(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public processMergedValue(props: ProcessMergedValueProps): void {\r\n this._currentAppender.append(props.mergedField.label, {\r\n type: \"primitive\",\r\n value: \"\",\r\n });\r\n }\r\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\r\n this._currentAppender.append(props.field.label, {\r\n type: \"primitive\",\r\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\r\n value: props.displayValue?.toString() ?? \"\",\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ElementProperties.js","sourceRoot":"","sources":["../../../src/presentation-common/ElementProperties.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA6F;AAE7F,uEAYuC;AAGvC,qEAAmE;AA8HnE,gBAAgB;AACT,MAAM,8BAA8B,GAAG,GAAgE,EAAE;IAC9G,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC/C,MAAM,eAAe,GAAG,IAAA,4CAAsB,EAAC,OAAO,CAAC,CAAC;IACxD,OAAO,CAAC,UAAsB,EAAE,IAAU,EAAE,EAAE;QAC5C,eAAe,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAA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WAAW,CAAC,KAAuB;QACxC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IACM,YAAY;QACjB,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;IAEM,UAAU,CAAC,KAAsB;QACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IACM,WAAW;QAChB,IAAI,CAAC,eAAe,CAAC,GAAG,EAAG,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;IAEM,kBAAkB,CAAC,KAA8B;QACtD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;YACpD,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IACM,qBAAqB,CAAC,KAAiC;QAC5D,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;YAC9C,IAAI,EAAE,WAAW;YACjB,gEAAgE;YAChE,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5C,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,cAAc,CAA2B,KAAQ;IACxD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,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 RPC\r\n */\r\n\r\nimport { assert, DuplicatePolicy, Id64, Id64String, SortedArray } from \"@itwin/core-bentley\";\r\nimport { CategoryDescription } from \"./content/Category.js\";\r\nimport {\r\n createContentTraverser,\r\n IContentVisitor,\r\n ProcessFieldHierarchiesProps,\r\n ProcessMergedValueProps,\r\n ProcessPrimitiveValueProps,\r\n StartArrayProps,\r\n StartCategoryProps,\r\n StartContentProps,\r\n StartFieldProps,\r\n StartItemProps,\r\n StartStructProps,\r\n} from \"./content/ContentTraverser.js\";\r\nimport { Descriptor } from \"./content/Descriptor.js\";\r\nimport { Item } from \"./content/Item.js\";\r\nimport { PropertyValueFormat } from \"./content/TypeDescription.js\";\r\n\r\n/**\r\n * Data structure for storing element properties information in a simplified format.\r\n * @see [[Content]] for a format that stores all available element property data.\r\n * @public\r\n */\r\nexport interface ElementProperties {\r\n /** Label of element's ECClass. */\r\n class: string;\r\n /** Element's ID. */\r\n id: Id64String;\r\n /** Element's label. */\r\n label: string;\r\n /** Container of property values */\r\n items: { [label: string]: ElementPropertiesItem };\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: \"category\" | ElementPropertiesPropertyValueType;\r\n}\r\n\r\n/**\r\n * Definition for a category. A category can nest other property items, including categories.\r\n * @public\r\n */\r\nexport interface ElementPropertiesCategoryItem extends ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: \"category\";\r\n /** Container of property values */\r\n items: { [label: string]: ElementPropertiesItem };\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesPropertyItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPropertyItemBase extends ElementPropertiesItemBase {\r\n /** Type of the properties item. */\r\n type: ElementPropertiesPropertyValueType;\r\n}\r\n\r\n/**\r\n * Definition for a primitive property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPrimitivePropertyItem extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"primitive\";\r\n /** Display value of the property. */\r\n value: string;\r\n}\r\n\r\n/**\r\n * Base type for all [[ElementPropertiesArrayPropertyItem]] types.\r\n * @public\r\n */\r\nexport interface ElementPropertiesArrayPropertyItemBase extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"array\";\r\n /** Type of values contained in this array. */\r\n valueType: \"primitive\" | \"struct\";\r\n}\r\n\r\n/**\r\n * Definition for a primitives' array property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesPrimitiveArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\r\n /** Type of values contained in this array. */\r\n valueType: \"primitive\";\r\n /** Array of display values. */\r\n values: string[];\r\n}\r\n\r\n/**\r\n * Definition for a structs' array property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesStructArrayPropertyItem extends ElementPropertiesArrayPropertyItemBase {\r\n /** Type of values contained in this array. */\r\n valueType: \"struct\";\r\n /** Array of structs. */\r\n values: Array<{ [memberLabel: string]: ElementPropertiesPropertyItem }>;\r\n}\r\n\r\n/**\r\n * Definition for an array property value.\r\n * @public\r\n */\r\nexport type ElementPropertiesArrayPropertyItem = ElementPropertiesPrimitiveArrayPropertyItem | ElementPropertiesStructArrayPropertyItem;\r\n\r\n/**\r\n * Definition for an struct property value.\r\n * @public\r\n */\r\nexport interface ElementPropertiesStructPropertyItem extends ElementPropertiesPropertyItemBase {\r\n /** Type of the properties item. */\r\n type: \"struct\";\r\n /** Container of struct members. */\r\n members: { [memberLabel: string]: ElementPropertiesPropertyItem };\r\n}\r\n\r\n/**\r\n * Available element property types.\r\n * @public\r\n */\r\nexport type ElementPropertiesPropertyValueType = \"primitive\" | \"array\" | \"struct\";\r\n\r\n/**\r\n * Definition of a property value.\r\n * @public\r\n */\r\nexport type ElementPropertiesPropertyItem = ElementPropertiesPrimitivePropertyItem | ElementPropertiesArrayPropertyItem | ElementPropertiesStructPropertyItem;\r\n\r\n/**\r\n * Definition of a property item, including a property category.\r\n * @public\r\n */\r\nexport type ElementPropertiesItem = ElementPropertiesCategoryItem | ElementPropertiesPropertyItem;\r\n\r\n/** @internal */\r\nexport const createElementPropertiesBuilder = (): ((descriptor: Descriptor, item: Item) => ElementProperties) => {\r\n const builder = new ElementPropertiesBuilder();\r\n const traverseContent = createContentTraverser(builder);\r\n return (descriptor: Descriptor, item: Item) => {\r\n traverseContent(descriptor, [item]);\r\n return builder.items[0];\r\n };\r\n};\r\n\r\ninterface IPropertiesAppender {\r\n append(label: string, item: ElementPropertiesItem): void;\r\n finish(): void;\r\n}\r\n\r\nclass ElementPropertiesAppender implements IPropertiesAppender {\r\n private _propertyItems: { [label: string]: ElementPropertiesItem } = {};\r\n private _categoryItemAppenders: { [categoryName: string]: { category: CategoryDescription; appender: IPropertiesAppender } } = {};\r\n constructor(\r\n private _item: Item,\r\n private _onItemFinished: (item: ElementProperties) => void,\r\n ) {}\r\n\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._propertyItems[label] = item;\r\n }\r\n\r\n public finish(): void {\r\n // create an ordered list of category depths / appenders starting with categories that have the most ancestors and finishing with categories\r\n // that have no ancestors, so that when we call `finish` on appenders, child categories are finished before parent categories, otherwise\r\n // we may skip parent categories, thinking they have no items\r\n const categoriesNestedToRoot = new SortedArray<{ categoryDepth: number; appender: IPropertiesAppender }>(\r\n (lhs, rhs) => rhs.categoryDepth - lhs.categoryDepth,\r\n DuplicatePolicy.Allow,\r\n );\r\n Object.entries(this._categoryItemAppenders).forEach(([_, { category, appender }]) => {\r\n categoriesNestedToRoot.insert({ categoryDepth: countAncestors(category), appender });\r\n });\r\n categoriesNestedToRoot.forEach(({ appender }) => appender.finish());\r\n\r\n this._onItemFinished({\r\n class: this._item.classInfo?.label ?? \"\",\r\n id: this._item.primaryKeys[0]?.id ?? Id64.invalid,\r\n label: this._item.label.displayValue,\r\n items: this._propertyItems,\r\n });\r\n }\r\n\r\n public getCategoryAppender(parentAppender: IPropertiesAppender, category: CategoryDescription): IPropertiesAppender {\r\n let entry = this._categoryItemAppenders[category.name];\r\n if (!entry) {\r\n entry = { category, appender: new CategoryItemAppender(parentAppender, category) };\r\n this._categoryItemAppenders[category.name] = entry;\r\n }\r\n return entry.appender;\r\n }\r\n}\r\n\r\nclass CategoryItemAppender implements IPropertiesAppender {\r\n private _items: { [label: string]: ElementPropertiesItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _category: CategoryDescription,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n this._items[label] = item;\r\n }\r\n public finish(): void {\r\n if (Object.keys(this._items).length === 0) {\r\n return;\r\n }\r\n\r\n this._parentAppender.append(this._category.label, {\r\n type: \"category\",\r\n items: this._items,\r\n });\r\n }\r\n}\r\n\r\nclass ArrayItemAppender implements IPropertiesAppender {\r\n private _items: ElementPropertiesPropertyItem[] = [];\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartArrayProps,\r\n ) {}\r\n public append(_label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._items.push(item);\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Array);\r\n if (this._props.valueType.memberType.valueFormat === PropertyValueFormat.Primitive) {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createPrimitivesArray());\r\n } else {\r\n this._parentAppender.append(this._props.hierarchy.field.label, this.createStructsArray());\r\n }\r\n }\r\n private createPrimitivesArray(): ElementPropertiesPrimitiveArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"primitive\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"primitive\");\r\n return item.value;\r\n }),\r\n };\r\n }\r\n private createStructsArray(): ElementPropertiesStructArrayPropertyItem {\r\n return {\r\n type: \"array\",\r\n valueType: \"struct\",\r\n values: this._items.map((item) => {\r\n assert(item.type === \"struct\");\r\n return item.members;\r\n }),\r\n };\r\n }\r\n}\r\n\r\nclass StructItemAppender implements IPropertiesAppender {\r\n private _members: { [label: string]: ElementPropertiesPropertyItem } = {};\r\n constructor(\r\n private _parentAppender: IPropertiesAppender,\r\n private _props: StartStructProps,\r\n ) {}\r\n public append(label: string, item: ElementPropertiesItem): void {\r\n assert(item.type !== \"category\");\r\n this._members[label] = item;\r\n }\r\n public finish(): void {\r\n assert(this._props.valueType.valueFormat === PropertyValueFormat.Struct);\r\n this._parentAppender.append(this._props.hierarchy.field.label, {\r\n type: \"struct\",\r\n members: this._members,\r\n });\r\n }\r\n}\r\n\r\nclass ElementPropertiesBuilder implements IContentVisitor {\r\n private _appendersStack: IPropertiesAppender[] = [];\r\n private _items: ElementProperties[] = [];\r\n private _elementPropertiesAppender: ElementPropertiesAppender | undefined;\r\n\r\n public get items(): ElementProperties[] {\r\n return this._items;\r\n }\r\n\r\n private get _currentAppender(): IPropertiesAppender {\r\n const appender = this._appendersStack[this._appendersStack.length - 1];\r\n assert(appender !== undefined);\r\n return appender;\r\n }\r\n\r\n public startContent(_props: StartContentProps): boolean {\r\n this._appendersStack = [];\r\n this._items = [];\r\n this._elementPropertiesAppender = undefined;\r\n return true;\r\n }\r\n public finishContent(): void {}\r\n\r\n public processFieldHierarchies(_props: ProcessFieldHierarchiesProps): void {}\r\n\r\n public startItem(props: StartItemProps): boolean {\r\n this._elementPropertiesAppender = new ElementPropertiesAppender(props.item, (item) => this._items.push(item));\r\n this._appendersStack.push(this._elementPropertiesAppender);\r\n return true;\r\n }\r\n public finishItem(): void {\r\n this._appendersStack.pop();\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._elementPropertiesAppender.finish();\r\n this._elementPropertiesAppender = undefined;\r\n }\r\n\r\n public startCategory(props: StartCategoryProps): boolean {\r\n assert(this._elementPropertiesAppender !== undefined);\r\n this._appendersStack.push(this._elementPropertiesAppender.getCategoryAppender(this._currentAppender, props.category));\r\n return true;\r\n }\r\n public finishCategory(): void {\r\n this._appendersStack.pop();\r\n }\r\n\r\n public startField(_props: StartFieldProps): boolean {\r\n return true;\r\n }\r\n public finishField(): void {}\r\n\r\n public startStruct(props: StartStructProps): boolean {\r\n this._appendersStack.push(new StructItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishStruct(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public startArray(props: StartArrayProps): boolean {\r\n this._appendersStack.push(new ArrayItemAppender(this._currentAppender, props));\r\n return true;\r\n }\r\n public finishArray(): void {\r\n this._appendersStack.pop()!.finish();\r\n }\r\n\r\n public processMergedValue(props: ProcessMergedValueProps): void {\r\n this._currentAppender.append(props.mergedField.label, {\r\n type: \"primitive\",\r\n value: \"\",\r\n });\r\n }\r\n public processPrimitiveValue(props: ProcessPrimitiveValueProps): void {\r\n this._currentAppender.append(props.field.label, {\r\n type: \"primitive\",\r\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\r\n value: props.displayValue?.toString() ?? \"\",\r\n });\r\n }\r\n}\r\n\r\nfunction countAncestors<T extends { parent?: T }>(child: T): number {\r\n return child.parent ? 1 + countAncestors(child.parent) : 0;\r\n}\r\n"]}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { BeEvent, Id64String } from "@itwin/core-bentley";
5
5
  import { UnitSystemKey } from "@itwin/core-quantity";
6
- import { Descriptor, SelectionInfo } from "./content/Descriptor.js";
6
+ import { Descriptor, DescriptorFieldsSelector, SelectionInfo } from "./content/Descriptor.js";
7
7
  import { FieldDescriptor } from "./content/Fields.js";
8
8
  import { Item } from "./content/Item.js";
9
9
  import { InstanceKey } from "./EC.js";
@@ -186,9 +186,15 @@ export interface MultiElementPropertiesBaseRequestOptions<TIModel, TParsedConten
186
186
  * to a parser that creates [[ElementProperties]] objects.
187
187
  */
188
188
  contentParser?: (descriptor: Descriptor, item: Item) => TParsedContent;
189
+ /**
190
+ * A callback that allows specifying which fields should be included or excluded in the result based on the given content descriptor. This
191
+ * 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
192
+ * subset of all available fields.
193
+ */
194
+ fieldsSelector?: (descriptor: Descriptor) => DescriptorFieldsSelector | undefined;
189
195
  /**
190
196
  * The properties of multiple elements are going to be retrieved and returned in batches. Depending on the batch
191
- * size load on CPU vs MEMORY load may vary, so changing this attribute allows to fine tune the performance.
197
+ * size load on CPU vs MEMORY load may vary, so changing this attribute allows fine tuning the performance.
192
198
  * Defaults to `1000`.
193
199
  */
194
200
  batchSize?: number;