@platforma-sdk/model 1.58.3 → 1.58.9

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 (366) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +43 -0
  2. package/dist/_virtual/_rolldown/runtime.js +18 -0
  3. package/dist/annotations/converter.cjs +15 -20
  4. package/dist/annotations/converter.cjs.map +1 -1
  5. package/dist/annotations/converter.d.ts +6 -2
  6. package/dist/annotations/converter.js +14 -18
  7. package/dist/annotations/converter.js.map +1 -1
  8. package/dist/annotations/index.cjs +1 -0
  9. package/dist/annotations/index.d.ts +2 -3
  10. package/dist/annotations/index.js +1 -0
  11. package/dist/annotations/types.d.ts +21 -16
  12. package/dist/bconfig/index.cjs +2 -0
  13. package/dist/bconfig/index.d.ts +5 -6
  14. package/dist/bconfig/index.js +2 -0
  15. package/dist/bconfig/lambdas.d.ts +52 -52
  16. package/dist/bconfig/normalization.cjs +13 -18
  17. package/dist/bconfig/normalization.cjs.map +1 -1
  18. package/dist/bconfig/normalization.d.ts +10 -6
  19. package/dist/bconfig/normalization.js +12 -16
  20. package/dist/bconfig/normalization.js.map +1 -1
  21. package/dist/bconfig/types.cjs +4 -3
  22. package/dist/bconfig/types.cjs.map +1 -1
  23. package/dist/bconfig/types.d.ts +10 -5
  24. package/dist/bconfig/types.js +4 -2
  25. package/dist/bconfig/types.js.map +1 -1
  26. package/dist/bconfig/util.d.ts +7 -4
  27. package/dist/bconfig/v3.d.ts +10 -6
  28. package/dist/block_api_v1.d.ts +62 -58
  29. package/dist/block_api_v2.d.ts +51 -47
  30. package/dist/block_api_v3.d.ts +33 -29
  31. package/dist/block_migrations.cjs +481 -413
  32. package/dist/block_migrations.cjs.map +1 -1
  33. package/dist/block_migrations.d.ts +258 -204
  34. package/dist/block_migrations.js +482 -408
  35. package/dist/block_migrations.js.map +1 -1
  36. package/dist/block_model.cjs +312 -343
  37. package/dist/block_model.cjs.map +1 -1
  38. package/dist/block_model.d.ts +143 -147
  39. package/dist/block_model.js +312 -341
  40. package/dist/block_model.js.map +1 -1
  41. package/dist/block_model_legacy.cjs +231 -255
  42. package/dist/block_model_legacy.cjs.map +1 -1
  43. package/dist/block_model_legacy.d.ts +108 -106
  44. package/dist/block_model_legacy.js +231 -253
  45. package/dist/block_model_legacy.js.map +1 -1
  46. package/dist/block_state_patch.d.ts +10 -10
  47. package/dist/block_state_util.cjs +15 -19
  48. package/dist/block_state_util.cjs.map +1 -1
  49. package/dist/block_state_util.d.ts +14 -13
  50. package/dist/block_state_util.js +15 -18
  51. package/dist/block_state_util.js.map +1 -1
  52. package/dist/block_storage.cjs +233 -238
  53. package/dist/block_storage.cjs.map +1 -1
  54. package/dist/block_storage.d.ts +62 -78
  55. package/dist/block_storage.js +234 -237
  56. package/dist/block_storage.js.map +1 -1
  57. package/dist/block_storage_callbacks.cjs +156 -195
  58. package/dist/block_storage_callbacks.cjs.map +1 -1
  59. package/dist/block_storage_callbacks.js +156 -192
  60. package/dist/block_storage_callbacks.js.map +1 -1
  61. package/dist/block_storage_facade.cjs +29 -85
  62. package/dist/block_storage_facade.cjs.map +1 -1
  63. package/dist/block_storage_facade.d.ts +83 -126
  64. package/dist/block_storage_facade.js +29 -83
  65. package/dist/block_storage_facade.js.map +1 -1
  66. package/dist/components/PFrameForGraphs.cjs +26 -24
  67. package/dist/components/PFrameForGraphs.cjs.map +1 -1
  68. package/dist/components/PFrameForGraphs.d.ts +12 -7
  69. package/dist/components/PFrameForGraphs.js +25 -22
  70. package/dist/components/PFrameForGraphs.js.map +1 -1
  71. package/dist/components/PlAnnotations/filter.d.ts +62 -79
  72. package/dist/components/PlAnnotations/filters_ui.cjs +135 -171
  73. package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
  74. package/dist/components/PlAnnotations/filters_ui.d.ts +48 -46
  75. package/dist/components/PlAnnotations/filters_ui.js +135 -170
  76. package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
  77. package/dist/components/PlAnnotations/index.d.ts +2 -3
  78. package/dist/components/PlDataTable/index.cjs +2 -0
  79. package/dist/components/PlDataTable/index.d.ts +3 -5
  80. package/dist/components/PlDataTable/index.js +2 -0
  81. package/dist/components/PlDataTable/labels.cjs +59 -81
  82. package/dist/components/PlDataTable/labels.cjs.map +1 -1
  83. package/dist/components/PlDataTable/labels.js +58 -79
  84. package/dist/components/PlDataTable/labels.js.map +1 -1
  85. package/dist/components/PlDataTable/state-migration.cjs +186 -144
  86. package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
  87. package/dist/components/PlDataTable/state-migration.d.ts +85 -82
  88. package/dist/components/PlDataTable/state-migration.js +185 -142
  89. package/dist/components/PlDataTable/state-migration.js.map +1 -1
  90. package/dist/components/PlDataTable/table.cjs +172 -194
  91. package/dist/components/PlDataTable/table.cjs.map +1 -1
  92. package/dist/components/PlDataTable/table.d.ts +16 -12
  93. package/dist/components/PlDataTable/table.js +171 -192
  94. package/dist/components/PlDataTable/table.js.map +1 -1
  95. package/dist/components/PlDataTable/v4.d.ts +84 -119
  96. package/dist/components/PlDataTable/v5.d.ts +80 -103
  97. package/dist/components/PlMultiSequenceAlignment.cjs +27 -29
  98. package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
  99. package/dist/components/PlMultiSequenceAlignment.d.ts +36 -27
  100. package/dist/components/PlMultiSequenceAlignment.js +26 -27
  101. package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
  102. package/dist/components/PlSelectionModel.cjs +7 -6
  103. package/dist/components/PlSelectionModel.cjs.map +1 -1
  104. package/dist/components/PlSelectionModel.d.ts +10 -8
  105. package/dist/components/PlSelectionModel.js +7 -5
  106. package/dist/components/PlSelectionModel.js.map +1 -1
  107. package/dist/components/index.cjs +8 -0
  108. package/dist/components/index.d.ts +11 -6
  109. package/dist/components/index.js +8 -0
  110. package/dist/config/actions.cjs +138 -171
  111. package/dist/config/actions.cjs.map +1 -1
  112. package/dist/config/actions.d.ts +47 -47
  113. package/dist/config/actions.js +146 -178
  114. package/dist/config/actions.js.map +1 -1
  115. package/dist/config/actions_kinds.d.ts +114 -121
  116. package/dist/config/index.cjs +1 -0
  117. package/dist/config/index.d.ts +6 -7
  118. package/dist/config/index.js +1 -0
  119. package/dist/config/model.d.ts +131 -127
  120. package/dist/config/model_meta.d.ts +4 -1
  121. package/dist/config/type_engine.d.ts +22 -21
  122. package/dist/config/type_util.d.ts +12 -10
  123. package/dist/env_value.cjs +5 -6
  124. package/dist/env_value.cjs.map +1 -1
  125. package/dist/env_value.d.ts +4 -1
  126. package/dist/env_value.js +5 -5
  127. package/dist/env_value.js.map +1 -1
  128. package/dist/filters/converters/filterToQuery.cjs +273 -239
  129. package/dist/filters/converters/filterToQuery.cjs.map +1 -1
  130. package/dist/filters/converters/filterToQuery.d.ts +6 -2
  131. package/dist/filters/converters/filterToQuery.js +272 -237
  132. package/dist/filters/converters/filterToQuery.js.map +1 -1
  133. package/dist/filters/converters/filterUiToExpressionImpl.cjs +56 -85
  134. package/dist/filters/converters/filterUiToExpressionImpl.cjs.map +1 -1
  135. package/dist/filters/converters/filterUiToExpressionImpl.d.ts +8 -4
  136. package/dist/filters/converters/filterUiToExpressionImpl.js +55 -83
  137. package/dist/filters/converters/filterUiToExpressionImpl.js.map +1 -1
  138. package/dist/filters/converters/index.cjs +2 -0
  139. package/dist/filters/converters/index.d.ts +2 -3
  140. package/dist/filters/converters/index.js +2 -0
  141. package/dist/filters/distill.cjs +59 -50
  142. package/dist/filters/distill.cjs.map +1 -1
  143. package/dist/filters/distill.d.ts +6 -3
  144. package/dist/filters/distill.js +58 -48
  145. package/dist/filters/distill.js.map +1 -1
  146. package/dist/filters/index.cjs +4 -0
  147. package/dist/filters/index.d.ts +5 -4
  148. package/dist/filters/index.js +4 -0
  149. package/dist/filters/traverse.cjs +31 -40
  150. package/dist/filters/traverse.cjs.map +1 -1
  151. package/dist/filters/traverse.js +31 -39
  152. package/dist/filters/traverse.js.map +1 -1
  153. package/dist/filters/types.d.ts +10 -7
  154. package/dist/index.cjs +193 -187
  155. package/dist/index.d.ts +61 -28
  156. package/dist/index.js +49 -41
  157. package/dist/internal.cjs +48 -62
  158. package/dist/internal.cjs.map +1 -1
  159. package/dist/internal.js +49 -60
  160. package/dist/internal.js.map +1 -1
  161. package/dist/package.cjs +12 -0
  162. package/dist/package.cjs.map +1 -0
  163. package/dist/package.js +6 -0
  164. package/dist/package.js.map +1 -0
  165. package/dist/pframe.cjs +32 -37
  166. package/dist/pframe.cjs.map +1 -1
  167. package/dist/pframe.d.ts +14 -10
  168. package/dist/pframe.js +32 -35
  169. package/dist/pframe.js.map +1 -1
  170. package/dist/pframe_utils/axes.cjs +81 -114
  171. package/dist/pframe_utils/axes.cjs.map +1 -1
  172. package/dist/pframe_utils/axes.d.ts +10 -13
  173. package/dist/pframe_utils/axes.js +80 -112
  174. package/dist/pframe_utils/axes.js.map +1 -1
  175. package/dist/pframe_utils/columns.cjs +61 -81
  176. package/dist/pframe_utils/columns.cjs.map +1 -1
  177. package/dist/pframe_utils/columns.d.ts +15 -6
  178. package/dist/pframe_utils/columns.js +60 -79
  179. package/dist/pframe_utils/columns.js.map +1 -1
  180. package/dist/pframe_utils/index.cjs +232 -253
  181. package/dist/pframe_utils/index.cjs.map +1 -1
  182. package/dist/pframe_utils/index.d.ts +39 -35
  183. package/dist/pframe_utils/index.js +231 -251
  184. package/dist/pframe_utils/index.js.map +1 -1
  185. package/dist/platforma.d.ts +48 -46
  186. package/dist/plugin_handle.cjs +6 -14
  187. package/dist/plugin_handle.cjs.map +1 -1
  188. package/dist/plugin_handle.d.ts +20 -25
  189. package/dist/plugin_handle.js +6 -13
  190. package/dist/plugin_handle.js.map +1 -1
  191. package/dist/plugin_model.cjs +364 -163
  192. package/dist/plugin_model.cjs.map +1 -1
  193. package/dist/plugin_model.d.ts +280 -129
  194. package/dist/plugin_model.js +362 -163
  195. package/dist/plugin_model.js.map +1 -1
  196. package/dist/raw_globals.cjs +10 -22
  197. package/dist/raw_globals.cjs.map +1 -1
  198. package/dist/raw_globals.d.ts +8 -5
  199. package/dist/raw_globals.js +10 -20
  200. package/dist/raw_globals.js.map +1 -1
  201. package/dist/ref_util.cjs +14 -13
  202. package/dist/ref_util.cjs.map +1 -1
  203. package/dist/ref_util.d.ts +18 -12
  204. package/dist/ref_util.js +14 -11
  205. package/dist/ref_util.js.map +1 -1
  206. package/dist/render/accessor.cjs +213 -226
  207. package/dist/render/accessor.cjs.map +1 -1
  208. package/dist/render/accessor.d.ts +115 -120
  209. package/dist/render/accessor.js +212 -224
  210. package/dist/render/accessor.js.map +1 -1
  211. package/dist/render/api.cjs +478 -580
  212. package/dist/render/api.cjs.map +1 -1
  213. package/dist/render/api.d.ts +207 -209
  214. package/dist/render/api.js +476 -578
  215. package/dist/render/api.js.map +1 -1
  216. package/dist/render/future.cjs +28 -32
  217. package/dist/render/future.cjs.map +1 -1
  218. package/dist/render/future.d.ts +15 -11
  219. package/dist/render/future.js +28 -30
  220. package/dist/render/future.js.map +1 -1
  221. package/dist/render/index.cjs +8 -0
  222. package/dist/render/index.d.ts +10 -8
  223. package/dist/render/index.js +8 -0
  224. package/dist/render/internal.cjs +33 -29
  225. package/dist/render/internal.cjs.map +1 -1
  226. package/dist/render/internal.d.ts +78 -72
  227. package/dist/render/internal.js +29 -26
  228. package/dist/render/internal.js.map +1 -1
  229. package/dist/render/traversal_ops.d.ts +42 -43
  230. package/dist/render/util/axis_filtering.cjs +63 -86
  231. package/dist/render/util/axis_filtering.cjs.map +1 -1
  232. package/dist/render/util/axis_filtering.d.ts +10 -7
  233. package/dist/render/util/axis_filtering.js +63 -85
  234. package/dist/render/util/axis_filtering.js.map +1 -1
  235. package/dist/render/util/column_collection.cjs +266 -321
  236. package/dist/render/util/column_collection.cjs.map +1 -1
  237. package/dist/render/util/column_collection.d.ts +47 -47
  238. package/dist/render/util/column_collection.js +264 -319
  239. package/dist/render/util/column_collection.js.map +1 -1
  240. package/dist/render/util/index.cjs +4 -0
  241. package/dist/render/util/index.d.ts +4 -5
  242. package/dist/render/util/index.js +4 -0
  243. package/dist/render/util/label.cjs +129 -163
  244. package/dist/render/util/label.cjs.map +1 -1
  245. package/dist/render/util/label.d.ts +45 -46
  246. package/dist/render/util/label.js +128 -161
  247. package/dist/render/util/label.js.map +1 -1
  248. package/dist/render/util/pcolumn_data.cjs +315 -375
  249. package/dist/render/util/pcolumn_data.cjs.map +1 -1
  250. package/dist/render/util/pcolumn_data.d.ts +33 -32
  251. package/dist/render/util/pcolumn_data.js +314 -373
  252. package/dist/render/util/pcolumn_data.js.map +1 -1
  253. package/dist/render/util/pframe_upgraders.cjs +37 -42
  254. package/dist/render/util/pframe_upgraders.cjs.map +1 -1
  255. package/dist/render/util/pframe_upgraders.js +37 -41
  256. package/dist/render/util/pframe_upgraders.js.map +1 -1
  257. package/dist/render/util/split_selectors.d.ts +13 -9
  258. package/dist/version.cjs +6 -8
  259. package/dist/version.cjs.map +1 -1
  260. package/dist/version.d.ts +7 -4
  261. package/dist/version.js +5 -5
  262. package/dist/version.js.map +1 -1
  263. package/package.json +9 -3
  264. package/src/block_migrations.test.ts +184 -14
  265. package/src/block_migrations.ts +185 -30
  266. package/src/block_model.ts +111 -66
  267. package/src/block_storage.test.ts +147 -3
  268. package/src/block_storage.ts +43 -8
  269. package/src/block_storage_callbacks.ts +9 -4
  270. package/src/env_value.ts +0 -2
  271. package/src/filters/distill.ts +17 -6
  272. package/src/index.ts +12 -11
  273. package/src/internal.ts +0 -1
  274. package/src/platforma.ts +4 -4
  275. package/src/plugin_handle.ts +1 -1
  276. package/src/plugin_model.test.ts +217 -21
  277. package/src/plugin_model.ts +450 -55
  278. package/src/raw_globals.ts +0 -1
  279. package/dist/annotations/converter.d.ts.map +0 -1
  280. package/dist/annotations/index.d.ts.map +0 -1
  281. package/dist/annotations/types.d.ts.map +0 -1
  282. package/dist/bconfig/index.d.ts.map +0 -1
  283. package/dist/bconfig/lambdas.d.ts.map +0 -1
  284. package/dist/bconfig/normalization.d.ts.map +0 -1
  285. package/dist/bconfig/types.d.ts.map +0 -1
  286. package/dist/bconfig/util.d.ts.map +0 -1
  287. package/dist/bconfig/v3.d.ts.map +0 -1
  288. package/dist/block_api_v1.d.ts.map +0 -1
  289. package/dist/block_api_v2.d.ts.map +0 -1
  290. package/dist/block_api_v3.d.ts.map +0 -1
  291. package/dist/block_migrations.d.ts.map +0 -1
  292. package/dist/block_model.d.ts.map +0 -1
  293. package/dist/block_model_legacy.d.ts.map +0 -1
  294. package/dist/block_state_patch.d.ts.map +0 -1
  295. package/dist/block_state_util.d.ts.map +0 -1
  296. package/dist/block_storage.d.ts.map +0 -1
  297. package/dist/block_storage_callbacks.d.ts +0 -115
  298. package/dist/block_storage_callbacks.d.ts.map +0 -1
  299. package/dist/block_storage_facade.d.ts.map +0 -1
  300. package/dist/components/PFrameForGraphs.d.ts.map +0 -1
  301. package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
  302. package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
  303. package/dist/components/PlAnnotations/index.d.ts.map +0 -1
  304. package/dist/components/PlAnnotations/types.d.ts +0 -3
  305. package/dist/components/PlAnnotations/types.d.ts.map +0 -1
  306. package/dist/components/PlDataTable/index.d.ts.map +0 -1
  307. package/dist/components/PlDataTable/labels.d.ts +0 -7
  308. package/dist/components/PlDataTable/labels.d.ts.map +0 -1
  309. package/dist/components/PlDataTable/state-migration.d.ts.map +0 -1
  310. package/dist/components/PlDataTable/table.d.ts.map +0 -1
  311. package/dist/components/PlDataTable/v4.d.ts.map +0 -1
  312. package/dist/components/PlDataTable/v5.d.ts.map +0 -1
  313. package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
  314. package/dist/components/PlSelectionModel.d.ts.map +0 -1
  315. package/dist/components/index.d.ts.map +0 -1
  316. package/dist/config/actions.d.ts.map +0 -1
  317. package/dist/config/actions_kinds.d.ts.map +0 -1
  318. package/dist/config/index.d.ts.map +0 -1
  319. package/dist/config/model.d.ts.map +0 -1
  320. package/dist/config/model_meta.d.ts.map +0 -1
  321. package/dist/config/type_engine.d.ts.map +0 -1
  322. package/dist/config/type_util.d.ts.map +0 -1
  323. package/dist/env_value.d.ts.map +0 -1
  324. package/dist/filters/converters/filterToQuery.d.ts.map +0 -1
  325. package/dist/filters/converters/filterUiToExpressionImpl.d.ts.map +0 -1
  326. package/dist/filters/converters/index.d.ts.map +0 -1
  327. package/dist/filters/distill.d.ts.map +0 -1
  328. package/dist/filters/index.d.ts.map +0 -1
  329. package/dist/filters/traverse.d.ts +0 -27
  330. package/dist/filters/traverse.d.ts.map +0 -1
  331. package/dist/filters/types.d.ts.map +0 -1
  332. package/dist/index.cjs.map +0 -1
  333. package/dist/index.d.ts.map +0 -1
  334. package/dist/index.js.map +0 -1
  335. package/dist/internal.d.ts +0 -36
  336. package/dist/internal.d.ts.map +0 -1
  337. package/dist/package.json.cjs +0 -6
  338. package/dist/package.json.cjs.map +0 -1
  339. package/dist/package.json.js +0 -4
  340. package/dist/package.json.js.map +0 -1
  341. package/dist/pframe.d.ts.map +0 -1
  342. package/dist/pframe_utils/axes.d.ts.map +0 -1
  343. package/dist/pframe_utils/columns.d.ts.map +0 -1
  344. package/dist/pframe_utils/index.d.ts.map +0 -1
  345. package/dist/pframe_utils/querySpec.d.ts +0 -2
  346. package/dist/pframe_utils/querySpec.d.ts.map +0 -1
  347. package/dist/platforma.d.ts.map +0 -1
  348. package/dist/plugin_handle.d.ts.map +0 -1
  349. package/dist/plugin_model.d.ts.map +0 -1
  350. package/dist/raw_globals.d.ts.map +0 -1
  351. package/dist/ref_util.d.ts.map +0 -1
  352. package/dist/render/accessor.d.ts.map +0 -1
  353. package/dist/render/api.d.ts.map +0 -1
  354. package/dist/render/future.d.ts.map +0 -1
  355. package/dist/render/index.d.ts.map +0 -1
  356. package/dist/render/internal.d.ts.map +0 -1
  357. package/dist/render/traversal_ops.d.ts.map +0 -1
  358. package/dist/render/util/axis_filtering.d.ts.map +0 -1
  359. package/dist/render/util/column_collection.d.ts.map +0 -1
  360. package/dist/render/util/index.d.ts.map +0 -1
  361. package/dist/render/util/label.d.ts.map +0 -1
  362. package/dist/render/util/pcolumn_data.d.ts.map +0 -1
  363. package/dist/render/util/pframe_upgraders.d.ts +0 -3
  364. package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
  365. package/dist/render/util/split_selectors.d.ts.map +0 -1
  366. package/dist/version.d.ts.map +0 -1
@@ -1,58 +1,57 @@
1
- import { type PObjectSpec } from "@milaboratories/pl-model-common";
1
+ import { PObjectSpec } from "@milaboratories/pl-model-common";
2
2
  import { z } from "zod";
3
- export type RecordsWithLabel<T> = {
4
- value: T;
5
- label: string;
3
+
4
+ //#region src/render/util/label.d.ts
5
+ type RecordsWithLabel<T> = {
6
+ value: T;
7
+ label: string;
6
8
  };
7
- export type LabelDerivationOps = {
8
- /** Force inclusion of native column label */
9
- includeNativeLabel?: boolean;
10
- /** Separator to use between label parts (" / " by default) */
11
- separator?: string;
12
- /** If true, label will be added as suffix (at the end of the generated label). By default label added as a prefix. */
13
- addLabelAsSuffix?: boolean;
14
- /** Trace elements list that will be forced to be included in the label. */
15
- forceTraceElements?: string[];
9
+ type LabelDerivationOps = {
10
+ /** Force inclusion of native column label */includeNativeLabel?: boolean; /** Separator to use between label parts (" / " by default) */
11
+ separator?: string; /** If true, label will be added as suffix (at the end of the generated label). By default label added as a prefix. */
12
+ addLabelAsSuffix?: boolean; /** Trace elements list that will be forced to be included in the label. */
13
+ forceTraceElements?: string[];
16
14
  };
17
- export declare const TraceEntry: z.ZodObject<{
18
- type: z.ZodString;
19
- importance: z.ZodOptional<z.ZodNumber>;
20
- id: z.ZodOptional<z.ZodString>;
21
- label: z.ZodString;
15
+ declare const TraceEntry: z.ZodObject<{
16
+ type: z.ZodString;
17
+ importance: z.ZodOptional<z.ZodNumber>;
18
+ id: z.ZodOptional<z.ZodString>;
19
+ label: z.ZodString;
22
20
  }, "strip", z.ZodTypeAny, {
23
- type: string;
24
- label: string;
25
- id?: string | undefined;
26
- importance?: number | undefined;
21
+ label: string;
22
+ type: string;
23
+ importance?: number | undefined;
24
+ id?: string | undefined;
27
25
  }, {
28
- type: string;
29
- label: string;
30
- id?: string | undefined;
31
- importance?: number | undefined;
26
+ label: string;
27
+ type: string;
28
+ importance?: number | undefined;
29
+ id?: string | undefined;
32
30
  }>;
33
- export type TraceEntry = z.infer<typeof TraceEntry>;
34
- export declare const Trace: z.ZodArray<z.ZodObject<{
35
- type: z.ZodString;
36
- importance: z.ZodOptional<z.ZodNumber>;
37
- id: z.ZodOptional<z.ZodString>;
38
- label: z.ZodString;
31
+ type TraceEntry = z.infer<typeof TraceEntry>;
32
+ declare const Trace: z.ZodArray<z.ZodObject<{
33
+ type: z.ZodString;
34
+ importance: z.ZodOptional<z.ZodNumber>;
35
+ id: z.ZodOptional<z.ZodString>;
36
+ label: z.ZodString;
39
37
  }, "strip", z.ZodTypeAny, {
40
- type: string;
41
- label: string;
42
- id?: string | undefined;
43
- importance?: number | undefined;
38
+ label: string;
39
+ type: string;
40
+ importance?: number | undefined;
41
+ id?: string | undefined;
44
42
  }, {
45
- type: string;
46
- label: string;
47
- id?: string | undefined;
48
- importance?: number | undefined;
43
+ label: string;
44
+ type: string;
45
+ importance?: number | undefined;
46
+ id?: string | undefined;
49
47
  }>, "many">;
50
- export type Trace = z.infer<typeof Trace>;
48
+ type Trace = z.infer<typeof Trace>;
51
49
  type SpecExtractorResult = PObjectSpec | {
52
- spec: PObjectSpec;
53
- prefixTrace?: TraceEntry[];
54
- suffixTrace?: TraceEntry[];
50
+ spec: PObjectSpec;
51
+ prefixTrace?: TraceEntry[];
52
+ suffixTrace?: TraceEntry[];
55
53
  };
56
- export declare function deriveLabels<T>(values: T[], specExtractor: (obj: T) => SpecExtractorResult, ops?: LabelDerivationOps): RecordsWithLabel<T>[];
57
- export {};
54
+ declare function deriveLabels<T>(values: T[], specExtractor: (obj: T) => SpecExtractorResult, ops?: LabelDerivationOps): RecordsWithLabel<T>[];
55
+ //#endregion
56
+ export { LabelDerivationOps, RecordsWithLabel, Trace, TraceEntry, deriveLabels };
58
57
  //# sourceMappingURL=label.d.ts.map
@@ -1,171 +1,138 @@
1
- import { readAnnotation, Annotation, parseJson } from '@milaboratories/pl-model-common';
2
- import { z } from 'zod';
1
+ import { Annotation, parseJson, readAnnotation } from "@milaboratories/pl-model-common";
2
+ import { z } from "zod";
3
3
 
4
+ //#region src/render/util/label.ts
4
5
  const TraceEntry = z.object({
5
- type: z.string(),
6
- importance: z.number().optional(),
7
- id: z.string().optional(),
8
- label: z.string(),
6
+ type: z.string(),
7
+ importance: z.number().optional(),
8
+ id: z.string().optional(),
9
+ label: z.string()
9
10
  });
10
11
  const Trace = z.array(TraceEntry);
11
- const DistancePenalty = 0.001;
12
+ const DistancePenalty = .001;
12
13
  const LabelType = "__LABEL__";
13
14
  const LabelTypeFull = "__LABEL__@1";
14
15
  function deriveLabels(values, specExtractor, ops = {}) {
15
- const importances = new Map();
16
- const forceTraceElements = ops.forceTraceElements !== undefined && ops.forceTraceElements.length > 0
17
- ? new Set(ops.forceTraceElements)
18
- : undefined;
19
- // number of times certain type occurred among all of the
20
- const numberOfRecordsWithType = new Map();
21
- const enrichedRecords = values.map((value) => {
22
- const extractorResult = specExtractor(value);
23
- let spec;
24
- let prefixTrace;
25
- let suffixTrace;
26
- // Check if the result is the new structure or just PObjectSpec
27
- if ("spec" in extractorResult && typeof extractorResult.spec === "object") {
28
- // It's the new structure { spec, prefixTrace?, suffixTrace? }
29
- spec = extractorResult.spec;
30
- prefixTrace = extractorResult.prefixTrace;
31
- suffixTrace = extractorResult.suffixTrace;
32
- }
33
- else {
34
- // It's just PObjectSpec
35
- spec = extractorResult;
36
- }
37
- const label = readAnnotation(spec, Annotation.Label);
38
- const traceStr = readAnnotation(spec, Annotation.Trace);
39
- const baseTrace = (traceStr ? Trace.safeParse(parseJson(traceStr)).data : undefined) ?? [];
40
- const trace = [...(prefixTrace ?? []), ...baseTrace, ...(suffixTrace ?? [])];
41
- if (label !== undefined) {
42
- const labelEntry = { label, type: LabelType, importance: -2 };
43
- if (ops.addLabelAsSuffix)
44
- trace.push(labelEntry);
45
- else
46
- trace.splice(0, 0, labelEntry);
47
- }
48
- const fullTrace = [];
49
- const occurrences = new Map();
50
- for (let i = trace.length - 1; i >= 0; --i) {
51
- const { type: typeName } = trace[i];
52
- const importance = trace[i].importance ?? 0;
53
- const occurrenceIndex = (occurrences.get(typeName) ?? 0) + 1;
54
- occurrences.set(typeName, occurrenceIndex);
55
- const fullType = `${typeName}@${occurrenceIndex}`;
56
- numberOfRecordsWithType.set(fullType, (numberOfRecordsWithType.get(fullType) ?? 0) + 1);
57
- importances.set(fullType, Math.max(importances.get(fullType) ?? Number.NEGATIVE_INFINITY, importance - (trace.length - i) * DistancePenalty));
58
- fullTrace.push({ ...trace[i], fullType, occurrenceIndex: occurrenceIndex });
59
- }
60
- fullTrace.reverse();
61
- return {
62
- value,
63
- spec,
64
- label,
65
- fullTrace,
66
- };
67
- });
68
- // excluding repeated types (i.e. ..@2, ..@3, etc.) not found in some records
69
- const mainTypes = [];
70
- // repeated types (i.e. ..@2, ..@3, etc.) not found in some records
71
- const secondaryTypes = [];
72
- const allTypeRecords = [...importances];
73
- // sorting: most important types go first
74
- allTypeRecords.sort(([, i1], [, i2]) => i2 - i1);
75
- for (const [typeName] of allTypeRecords) {
76
- if (typeName.endsWith("@1") || numberOfRecordsWithType.get(typeName) === values.length)
77
- mainTypes.push(typeName);
78
- else
79
- secondaryTypes.push(typeName);
80
- }
81
- const calculate = (includedTypes, force = false) => {
82
- const result = [];
83
- for (let i = 0; i < enrichedRecords.length; i++) {
84
- const r = enrichedRecords[i];
85
- const includedTrace = r.fullTrace.filter((fm) => includedTypes.has(fm.fullType) || (forceTraceElements && forceTraceElements.has(fm.type)));
86
- if (includedTrace.length === 0) {
87
- if (force)
88
- result.push({
89
- label: "Unlabeled",
90
- value: r.value,
91
- });
92
- else
93
- return undefined;
94
- }
95
- const labelSet = includedTrace.map((fm) => fm.label);
96
- const sep = ops.separator ?? " / ";
97
- result.push({
98
- label: labelSet.join(sep),
99
- value: r.value,
100
- });
101
- }
102
- return result;
103
- };
104
- const countUniqueLabels = (result) => result === undefined ? 0 : new Set(result.map((c) => c.label)).size;
105
- // Post-processing: try removing types one by one (lowest importance first) to minimize the label set
106
- // Accepts removal if it doesn't decrease the number of unique labels (cardinality)
107
- const minimizeTypeSet = (typeSet) => {
108
- const initialResult = calculate(typeSet);
109
- if (initialResult === undefined) {
110
- return typeSet;
111
- }
112
- const currentCardinality = countUniqueLabels(initialResult);
113
- // Get types sorted by importance ascending (lowest first), excluding forced elements
114
- const removableSorted = [...typeSet]
115
- .filter((t) => !forceTraceElements?.has(t.split("@")[0]) &&
116
- !(ops.includeNativeLabel && t === LabelTypeFull))
117
- .sort((a, b) => (importances.get(a) ?? 0) - (importances.get(b) ?? 0));
118
- for (const typeToRemove of removableSorted) {
119
- const reducedSet = new Set(typeSet);
120
- reducedSet.delete(typeToRemove);
121
- const candidateResult = calculate(reducedSet);
122
- if (candidateResult !== undefined &&
123
- countUniqueLabels(candidateResult) >= currentCardinality) {
124
- typeSet.delete(typeToRemove);
125
- }
126
- }
127
- return typeSet;
128
- };
129
- if (mainTypes.length === 0) {
130
- if (secondaryTypes.length !== 0)
131
- throw new Error("Non-empty secondary types list while main types list is empty.");
132
- return calculate(new Set(LabelTypeFull), true);
133
- }
134
- //
135
- // includedTypes = 2
136
- // * *
137
- // T0 T1 T2 T3 T4 T5
138
- // *
139
- // additionalType = 3
140
- //
141
- // Resulting set: T0, T1, T3
142
- //
143
- let includedTypes = 0;
144
- let additionalType = -1;
145
- while (includedTypes < mainTypes.length) {
146
- const currentSet = new Set();
147
- if (ops.includeNativeLabel)
148
- currentSet.add(LabelTypeFull);
149
- for (let i = 0; i < includedTypes; ++i)
150
- currentSet.add(mainTypes[i]);
151
- if (additionalType >= 0)
152
- currentSet.add(mainTypes[additionalType]);
153
- const candidateResult = calculate(currentSet);
154
- if (candidateResult !== undefined && countUniqueLabels(candidateResult) === values.length) {
155
- minimizeTypeSet(currentSet);
156
- return calculate(currentSet);
157
- }
158
- additionalType++;
159
- if (additionalType >= mainTypes.length) {
160
- includedTypes++;
161
- additionalType = includedTypes;
162
- }
163
- }
164
- // Fallback: include all types, then try to minimize
165
- const fallbackSet = new Set([...mainTypes, ...secondaryTypes]);
166
- minimizeTypeSet(fallbackSet);
167
- return calculate(fallbackSet, true);
16
+ const importances = /* @__PURE__ */ new Map();
17
+ const forceTraceElements = ops.forceTraceElements !== void 0 && ops.forceTraceElements.length > 0 ? new Set(ops.forceTraceElements) : void 0;
18
+ const numberOfRecordsWithType = /* @__PURE__ */ new Map();
19
+ const enrichedRecords = values.map((value) => {
20
+ const extractorResult = specExtractor(value);
21
+ let spec;
22
+ let prefixTrace;
23
+ let suffixTrace;
24
+ if ("spec" in extractorResult && typeof extractorResult.spec === "object") {
25
+ spec = extractorResult.spec;
26
+ prefixTrace = extractorResult.prefixTrace;
27
+ suffixTrace = extractorResult.suffixTrace;
28
+ } else spec = extractorResult;
29
+ const label = readAnnotation(spec, Annotation.Label);
30
+ const traceStr = readAnnotation(spec, Annotation.Trace);
31
+ const baseTrace = (traceStr ? Trace.safeParse(parseJson(traceStr)).data : void 0) ?? [];
32
+ const trace = [
33
+ ...prefixTrace ?? [],
34
+ ...baseTrace,
35
+ ...suffixTrace ?? []
36
+ ];
37
+ if (label !== void 0) {
38
+ const labelEntry = {
39
+ label,
40
+ type: LabelType,
41
+ importance: -2
42
+ };
43
+ if (ops.addLabelAsSuffix) trace.push(labelEntry);
44
+ else trace.splice(0, 0, labelEntry);
45
+ }
46
+ const fullTrace = [];
47
+ const occurrences = /* @__PURE__ */ new Map();
48
+ for (let i = trace.length - 1; i >= 0; --i) {
49
+ const { type: typeName } = trace[i];
50
+ const importance = trace[i].importance ?? 0;
51
+ const occurrenceIndex = (occurrences.get(typeName) ?? 0) + 1;
52
+ occurrences.set(typeName, occurrenceIndex);
53
+ const fullType = `${typeName}@${occurrenceIndex}`;
54
+ numberOfRecordsWithType.set(fullType, (numberOfRecordsWithType.get(fullType) ?? 0) + 1);
55
+ importances.set(fullType, Math.max(importances.get(fullType) ?? Number.NEGATIVE_INFINITY, importance - (trace.length - i) * DistancePenalty));
56
+ fullTrace.push({
57
+ ...trace[i],
58
+ fullType,
59
+ occurrenceIndex
60
+ });
61
+ }
62
+ fullTrace.reverse();
63
+ return {
64
+ value,
65
+ spec,
66
+ label,
67
+ fullTrace
68
+ };
69
+ });
70
+ const mainTypes = [];
71
+ const secondaryTypes = [];
72
+ const allTypeRecords = [...importances];
73
+ allTypeRecords.sort(([, i1], [, i2]) => i2 - i1);
74
+ for (const [typeName] of allTypeRecords) if (typeName.endsWith("@1") || numberOfRecordsWithType.get(typeName) === values.length) mainTypes.push(typeName);
75
+ else secondaryTypes.push(typeName);
76
+ const calculate = (includedTypes, force = false) => {
77
+ const result = [];
78
+ for (let i = 0; i < enrichedRecords.length; i++) {
79
+ const r = enrichedRecords[i];
80
+ const includedTrace = r.fullTrace.filter((fm) => includedTypes.has(fm.fullType) || forceTraceElements && forceTraceElements.has(fm.type));
81
+ if (includedTrace.length === 0) if (force) result.push({
82
+ label: "Unlabeled",
83
+ value: r.value
84
+ });
85
+ else return void 0;
86
+ const labelSet = includedTrace.map((fm) => fm.label);
87
+ const sep = ops.separator ?? " / ";
88
+ result.push({
89
+ label: labelSet.join(sep),
90
+ value: r.value
91
+ });
92
+ }
93
+ return result;
94
+ };
95
+ const countUniqueLabels = (result) => result === void 0 ? 0 : new Set(result.map((c) => c.label)).size;
96
+ const minimizeTypeSet = (typeSet) => {
97
+ const initialResult = calculate(typeSet);
98
+ if (initialResult === void 0) return typeSet;
99
+ const currentCardinality = countUniqueLabels(initialResult);
100
+ const removableSorted = [...typeSet].filter((t) => !forceTraceElements?.has(t.split("@")[0]) && !(ops.includeNativeLabel && t === LabelTypeFull)).sort((a, b) => (importances.get(a) ?? 0) - (importances.get(b) ?? 0));
101
+ for (const typeToRemove of removableSorted) {
102
+ const reducedSet = new Set(typeSet);
103
+ reducedSet.delete(typeToRemove);
104
+ const candidateResult = calculate(reducedSet);
105
+ if (candidateResult !== void 0 && countUniqueLabels(candidateResult) >= currentCardinality) typeSet.delete(typeToRemove);
106
+ }
107
+ return typeSet;
108
+ };
109
+ if (mainTypes.length === 0) {
110
+ if (secondaryTypes.length !== 0) throw new Error("Non-empty secondary types list while main types list is empty.");
111
+ return calculate(new Set(LabelTypeFull), true);
112
+ }
113
+ let includedTypes = 0;
114
+ let additionalType = -1;
115
+ while (includedTypes < mainTypes.length) {
116
+ const currentSet = /* @__PURE__ */ new Set();
117
+ if (ops.includeNativeLabel) currentSet.add(LabelTypeFull);
118
+ for (let i = 0; i < includedTypes; ++i) currentSet.add(mainTypes[i]);
119
+ if (additionalType >= 0) currentSet.add(mainTypes[additionalType]);
120
+ const candidateResult = calculate(currentSet);
121
+ if (candidateResult !== void 0 && countUniqueLabels(candidateResult) === values.length) {
122
+ minimizeTypeSet(currentSet);
123
+ return calculate(currentSet);
124
+ }
125
+ additionalType++;
126
+ if (additionalType >= mainTypes.length) {
127
+ includedTypes++;
128
+ additionalType = includedTypes;
129
+ }
130
+ }
131
+ const fallbackSet = new Set([...mainTypes, ...secondaryTypes]);
132
+ minimizeTypeSet(fallbackSet);
133
+ return calculate(fallbackSet, true);
168
134
  }
169
135
 
136
+ //#endregion
170
137
  export { Trace, TraceEntry, deriveLabels };
171
- //# sourceMappingURL=label.js.map
138
+ //# sourceMappingURL=label.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"label.js","sources":["../../../src/render/util/label.ts"],"sourcesContent":["import {\n Annotation,\n parseJson,\n readAnnotation,\n type PObjectSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { z } from \"zod\";\n\nexport type RecordsWithLabel<T> = {\n value: T;\n label: string;\n};\n\nexport type LabelDerivationOps = {\n /** Force inclusion of native column label */\n includeNativeLabel?: boolean;\n /** Separator to use between label parts (\" / \" by default) */\n separator?: string;\n /** If true, label will be added as suffix (at the end of the generated label). By default label added as a prefix. */\n addLabelAsSuffix?: boolean;\n /** Trace elements list that will be forced to be included in the label. */\n forceTraceElements?: string[];\n};\n\nexport const TraceEntry = z.object({\n type: z.string(),\n importance: z.number().optional(),\n id: z.string().optional(),\n label: z.string(),\n});\nexport type TraceEntry = z.infer<typeof TraceEntry>;\ntype FullTraceEntry = TraceEntry & { fullType: string; occurrenceIndex: number };\n\nexport const Trace = z.array(TraceEntry);\nexport type Trace = z.infer<typeof Trace>;\ntype FullTrace = FullTraceEntry[];\n\n// Define the possible return types for the specExtractor function\ntype SpecExtractorResult =\n | PObjectSpec\n | {\n spec: PObjectSpec;\n prefixTrace?: TraceEntry[];\n suffixTrace?: TraceEntry[];\n };\n\nconst DistancePenalty = 0.001;\n\nconst LabelType = \"__LABEL__\";\nconst LabelTypeFull = \"__LABEL__@1\";\n\nexport function deriveLabels<T>(\n values: T[],\n specExtractor: (obj: T) => SpecExtractorResult,\n ops: LabelDerivationOps = {},\n): RecordsWithLabel<T>[] {\n const importances = new Map<string, number>();\n\n const forceTraceElements =\n ops.forceTraceElements !== undefined && ops.forceTraceElements.length > 0\n ? new Set(ops.forceTraceElements)\n : undefined;\n\n // number of times certain type occurred among all of the\n const numberOfRecordsWithType = new Map<string, number>();\n\n const enrichedRecords = values.map((value) => {\n const extractorResult = specExtractor(value);\n let spec: PObjectSpec;\n let prefixTrace: TraceEntry[] | undefined;\n let suffixTrace: TraceEntry[] | undefined;\n\n // Check if the result is the new structure or just PObjectSpec\n if (\"spec\" in extractorResult && typeof extractorResult.spec === \"object\") {\n // It's the new structure { spec, prefixTrace?, suffixTrace? }\n spec = extractorResult.spec;\n prefixTrace = extractorResult.prefixTrace;\n suffixTrace = extractorResult.suffixTrace;\n } else {\n // It's just PObjectSpec\n spec = extractorResult as PObjectSpec;\n }\n\n const label = readAnnotation(spec, Annotation.Label);\n const traceStr = readAnnotation(spec, Annotation.Trace);\n const baseTrace = (traceStr ? Trace.safeParse(parseJson(traceStr)).data : undefined) ?? [];\n\n const trace = [...(prefixTrace ?? []), ...baseTrace, ...(suffixTrace ?? [])];\n\n if (label !== undefined) {\n const labelEntry = { label, type: LabelType, importance: -2 };\n if (ops.addLabelAsSuffix) trace.push(labelEntry);\n else trace.splice(0, 0, labelEntry);\n }\n\n const fullTrace: FullTrace = [];\n\n const occurrences = new Map<string, number>();\n for (let i = trace.length - 1; i >= 0; --i) {\n const { type: typeName } = trace[i];\n const importance = trace[i].importance ?? 0;\n const occurrenceIndex = (occurrences.get(typeName) ?? 0) + 1;\n occurrences.set(typeName, occurrenceIndex);\n const fullType = `${typeName}@${occurrenceIndex}`;\n numberOfRecordsWithType.set(fullType, (numberOfRecordsWithType.get(fullType) ?? 0) + 1);\n importances.set(\n fullType,\n Math.max(\n importances.get(fullType) ?? Number.NEGATIVE_INFINITY,\n importance - (trace.length - i) * DistancePenalty,\n ),\n );\n fullTrace.push({ ...trace[i], fullType, occurrenceIndex: occurrenceIndex });\n }\n fullTrace.reverse();\n return {\n value,\n spec,\n label,\n fullTrace,\n };\n });\n\n // excluding repeated types (i.e. ..@2, ..@3, etc.) not found in some records\n const mainTypes: string[] = [];\n // repeated types (i.e. ..@2, ..@3, etc.) not found in some records\n const secondaryTypes: string[] = [];\n\n const allTypeRecords = [...importances];\n // sorting: most important types go first\n allTypeRecords.sort(([, i1], [, i2]) => i2 - i1);\n\n for (const [typeName] of allTypeRecords) {\n if (typeName.endsWith(\"@1\") || numberOfRecordsWithType.get(typeName) === values.length)\n mainTypes.push(typeName);\n else secondaryTypes.push(typeName);\n }\n\n const calculate = (includedTypes: Set<string>, force: boolean = false) => {\n const result: RecordsWithLabel<T>[] = [];\n for (let i = 0; i < enrichedRecords.length; i++) {\n const r = enrichedRecords[i];\n const includedTrace = r.fullTrace.filter(\n (fm) =>\n includedTypes.has(fm.fullType) || (forceTraceElements && forceTraceElements.has(fm.type)),\n );\n if (includedTrace.length === 0) {\n if (force)\n result.push({\n label: \"Unlabeled\",\n value: r.value,\n } satisfies RecordsWithLabel<T>);\n else return undefined;\n }\n const labelSet = includedTrace.map((fm) => fm.label);\n const sep = ops.separator ?? \" / \";\n result.push({\n label: labelSet.join(sep),\n value: r.value,\n } satisfies RecordsWithLabel<T>);\n }\n return result;\n };\n\n const countUniqueLabels = (result: RecordsWithLabel<T>[] | undefined): number =>\n result === undefined ? 0 : new Set(result.map((c) => c.label)).size;\n\n // Post-processing: try removing types one by one (lowest importance first) to minimize the label set\n // Accepts removal if it doesn't decrease the number of unique labels (cardinality)\n const minimizeTypeSet = (typeSet: Set<string>): Set<string> => {\n const initialResult = calculate(typeSet);\n if (initialResult === undefined) {\n return typeSet;\n }\n const currentCardinality = countUniqueLabels(initialResult);\n\n // Get types sorted by importance ascending (lowest first), excluding forced elements\n const removableSorted = [...typeSet]\n .filter(\n (t) =>\n !forceTraceElements?.has(t.split(\"@\")[0]) &&\n !(ops.includeNativeLabel && t === LabelTypeFull),\n )\n .sort((a, b) => (importances.get(a) ?? 0) - (importances.get(b) ?? 0));\n\n for (const typeToRemove of removableSorted) {\n const reducedSet = new Set(typeSet);\n reducedSet.delete(typeToRemove);\n const candidateResult = calculate(reducedSet);\n if (\n candidateResult !== undefined &&\n countUniqueLabels(candidateResult) >= currentCardinality\n ) {\n typeSet.delete(typeToRemove);\n }\n }\n return typeSet;\n };\n\n if (mainTypes.length === 0) {\n if (secondaryTypes.length !== 0)\n throw new Error(\"Non-empty secondary types list while main types list is empty.\");\n return calculate(new Set(LabelTypeFull), true)!;\n }\n\n //\n // includedTypes = 2\n // * *\n // T0 T1 T2 T3 T4 T5\n // *\n // additionalType = 3\n //\n // Resulting set: T0, T1, T3\n //\n let includedTypes = 0;\n let additionalType = -1;\n while (includedTypes < mainTypes.length) {\n const currentSet = new Set<string>();\n if (ops.includeNativeLabel) currentSet.add(LabelTypeFull);\n for (let i = 0; i < includedTypes; ++i) currentSet.add(mainTypes[i]);\n if (additionalType >= 0) currentSet.add(mainTypes[additionalType]);\n\n const candidateResult = calculate(currentSet);\n\n if (candidateResult !== undefined && countUniqueLabels(candidateResult) === values.length) {\n minimizeTypeSet(currentSet);\n return calculate(currentSet)!;\n }\n\n additionalType++;\n if (additionalType >= mainTypes.length) {\n includedTypes++;\n additionalType = includedTypes;\n }\n }\n\n // Fallback: include all types, then try to minimize\n const fallbackSet = new Set([...mainTypes, ...secondaryTypes]);\n minimizeTypeSet(fallbackSet);\n return calculate(fallbackSet, true)!;\n}\n"],"names":[],"mappings":";;;AAwBO,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;AACjC,IAAA,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;AAChB,IAAA,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACjC,IAAA,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;AACzB,IAAA,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;AAClB,CAAA;AAIM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU;AAavC,MAAM,eAAe,GAAG,KAAK;AAE7B,MAAM,SAAS,GAAG,WAAW;AAC7B,MAAM,aAAa,GAAG,aAAa;AAE7B,SAAU,YAAY,CAC1B,MAAW,EACX,aAA8C,EAC9C,MAA0B,EAAE,EAAA;AAE5B,IAAA,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB;AAE7C,IAAA,MAAM,kBAAkB,GACtB,GAAG,CAAC,kBAAkB,KAAK,SAAS,IAAI,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG;AACtE,UAAE,IAAI,GAAG,CAAC,GAAG,CAAC,kBAAkB;UAC9B,SAAS;;AAGf,IAAA,MAAM,uBAAuB,GAAG,IAAI,GAAG,EAAkB;IAEzD,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;AAC3C,QAAA,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC;AAC5C,QAAA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GAAG,SAAS,EAAE,GAAG,cAAc,CAAC,CAAC;IAC9D,eAAe,CAAC,WAAW,CAAC;AAC5B,IAAA,OAAO,SAAS,CAAC,WAAW,EAAE,IAAI,CAAE;AACtC;;;;"}
1
+ {"version":3,"file":"label.js","names":[],"sources":["../../../src/render/util/label.ts"],"sourcesContent":["import {\n Annotation,\n parseJson,\n readAnnotation,\n type PObjectSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { z } from \"zod\";\n\nexport type RecordsWithLabel<T> = {\n value: T;\n label: string;\n};\n\nexport type LabelDerivationOps = {\n /** Force inclusion of native column label */\n includeNativeLabel?: boolean;\n /** Separator to use between label parts (\" / \" by default) */\n separator?: string;\n /** If true, label will be added as suffix (at the end of the generated label). By default label added as a prefix. */\n addLabelAsSuffix?: boolean;\n /** Trace elements list that will be forced to be included in the label. */\n forceTraceElements?: string[];\n};\n\nexport const TraceEntry = z.object({\n type: z.string(),\n importance: z.number().optional(),\n id: z.string().optional(),\n label: z.string(),\n});\nexport type TraceEntry = z.infer<typeof TraceEntry>;\ntype FullTraceEntry = TraceEntry & { fullType: string; occurrenceIndex: number };\n\nexport const Trace = z.array(TraceEntry);\nexport type Trace = z.infer<typeof Trace>;\ntype FullTrace = FullTraceEntry[];\n\n// Define the possible return types for the specExtractor function\ntype SpecExtractorResult =\n | PObjectSpec\n | {\n spec: PObjectSpec;\n prefixTrace?: TraceEntry[];\n suffixTrace?: TraceEntry[];\n };\n\nconst DistancePenalty = 0.001;\n\nconst LabelType = \"__LABEL__\";\nconst LabelTypeFull = \"__LABEL__@1\";\n\nexport function deriveLabels<T>(\n values: T[],\n specExtractor: (obj: T) => SpecExtractorResult,\n ops: LabelDerivationOps = {},\n): RecordsWithLabel<T>[] {\n const importances = new Map<string, number>();\n\n const forceTraceElements =\n ops.forceTraceElements !== undefined && ops.forceTraceElements.length > 0\n ? new Set(ops.forceTraceElements)\n : undefined;\n\n // number of times certain type occurred among all of the\n const numberOfRecordsWithType = new Map<string, number>();\n\n const enrichedRecords = values.map((value) => {\n const extractorResult = specExtractor(value);\n let spec: PObjectSpec;\n let prefixTrace: TraceEntry[] | undefined;\n let suffixTrace: TraceEntry[] | undefined;\n\n // Check if the result is the new structure or just PObjectSpec\n if (\"spec\" in extractorResult && typeof extractorResult.spec === \"object\") {\n // It's the new structure { spec, prefixTrace?, suffixTrace? }\n spec = extractorResult.spec;\n prefixTrace = extractorResult.prefixTrace;\n suffixTrace = extractorResult.suffixTrace;\n } else {\n // It's just PObjectSpec\n spec = extractorResult as PObjectSpec;\n }\n\n const label = readAnnotation(spec, Annotation.Label);\n const traceStr = readAnnotation(spec, Annotation.Trace);\n const baseTrace = (traceStr ? Trace.safeParse(parseJson(traceStr)).data : undefined) ?? [];\n\n const trace = [...(prefixTrace ?? []), ...baseTrace, ...(suffixTrace ?? [])];\n\n if (label !== undefined) {\n const labelEntry = { label, type: LabelType, importance: -2 };\n if (ops.addLabelAsSuffix) trace.push(labelEntry);\n else trace.splice(0, 0, labelEntry);\n }\n\n const fullTrace: FullTrace = [];\n\n const occurrences = new Map<string, number>();\n for (let i = trace.length - 1; i >= 0; --i) {\n const { type: typeName } = trace[i];\n const importance = trace[i].importance ?? 0;\n const occurrenceIndex = (occurrences.get(typeName) ?? 0) + 1;\n occurrences.set(typeName, occurrenceIndex);\n const fullType = `${typeName}@${occurrenceIndex}`;\n numberOfRecordsWithType.set(fullType, (numberOfRecordsWithType.get(fullType) ?? 0) + 1);\n importances.set(\n fullType,\n Math.max(\n importances.get(fullType) ?? Number.NEGATIVE_INFINITY,\n importance - (trace.length - i) * DistancePenalty,\n ),\n );\n fullTrace.push({ ...trace[i], fullType, occurrenceIndex: occurrenceIndex });\n }\n fullTrace.reverse();\n return {\n value,\n spec,\n label,\n fullTrace,\n };\n });\n\n // excluding repeated types (i.e. ..@2, ..@3, etc.) not found in some records\n const mainTypes: string[] = [];\n // repeated types (i.e. ..@2, ..@3, etc.) not found in some records\n const secondaryTypes: string[] = [];\n\n const allTypeRecords = [...importances];\n // sorting: most important types go first\n allTypeRecords.sort(([, i1], [, i2]) => i2 - i1);\n\n for (const [typeName] of allTypeRecords) {\n if (typeName.endsWith(\"@1\") || numberOfRecordsWithType.get(typeName) === values.length)\n mainTypes.push(typeName);\n else secondaryTypes.push(typeName);\n }\n\n const calculate = (includedTypes: Set<string>, force: boolean = false) => {\n const result: RecordsWithLabel<T>[] = [];\n for (let i = 0; i < enrichedRecords.length; i++) {\n const r = enrichedRecords[i];\n const includedTrace = r.fullTrace.filter(\n (fm) =>\n includedTypes.has(fm.fullType) || (forceTraceElements && forceTraceElements.has(fm.type)),\n );\n if (includedTrace.length === 0) {\n if (force)\n result.push({\n label: \"Unlabeled\",\n value: r.value,\n } satisfies RecordsWithLabel<T>);\n else return undefined;\n }\n const labelSet = includedTrace.map((fm) => fm.label);\n const sep = ops.separator ?? \" / \";\n result.push({\n label: labelSet.join(sep),\n value: r.value,\n } satisfies RecordsWithLabel<T>);\n }\n return result;\n };\n\n const countUniqueLabels = (result: RecordsWithLabel<T>[] | undefined): number =>\n result === undefined ? 0 : new Set(result.map((c) => c.label)).size;\n\n // Post-processing: try removing types one by one (lowest importance first) to minimize the label set\n // Accepts removal if it doesn't decrease the number of unique labels (cardinality)\n const minimizeTypeSet = (typeSet: Set<string>): Set<string> => {\n const initialResult = calculate(typeSet);\n if (initialResult === undefined) {\n return typeSet;\n }\n const currentCardinality = countUniqueLabels(initialResult);\n\n // Get types sorted by importance ascending (lowest first), excluding forced elements\n const removableSorted = [...typeSet]\n .filter(\n (t) =>\n !forceTraceElements?.has(t.split(\"@\")[0]) &&\n !(ops.includeNativeLabel && t === LabelTypeFull),\n )\n .sort((a, b) => (importances.get(a) ?? 0) - (importances.get(b) ?? 0));\n\n for (const typeToRemove of removableSorted) {\n const reducedSet = new Set(typeSet);\n reducedSet.delete(typeToRemove);\n const candidateResult = calculate(reducedSet);\n if (\n candidateResult !== undefined &&\n countUniqueLabels(candidateResult) >= currentCardinality\n ) {\n typeSet.delete(typeToRemove);\n }\n }\n return typeSet;\n };\n\n if (mainTypes.length === 0) {\n if (secondaryTypes.length !== 0)\n throw new Error(\"Non-empty secondary types list while main types list is empty.\");\n return calculate(new Set(LabelTypeFull), true)!;\n }\n\n //\n // includedTypes = 2\n // * *\n // T0 T1 T2 T3 T4 T5\n // *\n // additionalType = 3\n //\n // Resulting set: T0, T1, T3\n //\n let includedTypes = 0;\n let additionalType = -1;\n while (includedTypes < mainTypes.length) {\n const currentSet = new Set<string>();\n if (ops.includeNativeLabel) currentSet.add(LabelTypeFull);\n for (let i = 0; i < includedTypes; ++i) currentSet.add(mainTypes[i]);\n if (additionalType >= 0) currentSet.add(mainTypes[additionalType]);\n\n const candidateResult = calculate(currentSet);\n\n if (candidateResult !== undefined && countUniqueLabels(candidateResult) === values.length) {\n minimizeTypeSet(currentSet);\n return calculate(currentSet)!;\n }\n\n additionalType++;\n if (additionalType >= mainTypes.length) {\n includedTypes++;\n additionalType = includedTypes;\n }\n }\n\n // Fallback: include all types, then try to minimize\n const fallbackSet = new Set([...mainTypes, ...secondaryTypes]);\n minimizeTypeSet(fallbackSet);\n return calculate(fallbackSet, true)!;\n}\n"],"mappings":";;;;AAwBA,MAAa,aAAa,EAAE,OAAO;CACjC,MAAM,EAAE,QAAQ;CAChB,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,IAAI,EAAE,QAAQ,CAAC,UAAU;CACzB,OAAO,EAAE,QAAQ;CAClB,CAAC;AAIF,MAAa,QAAQ,EAAE,MAAM,WAAW;AAaxC,MAAM,kBAAkB;AAExB,MAAM,YAAY;AAClB,MAAM,gBAAgB;AAEtB,SAAgB,aACd,QACA,eACA,MAA0B,EAAE,EACL;CACvB,MAAM,8BAAc,IAAI,KAAqB;CAE7C,MAAM,qBACJ,IAAI,uBAAuB,UAAa,IAAI,mBAAmB,SAAS,IACpE,IAAI,IAAI,IAAI,mBAAmB,GAC/B;CAGN,MAAM,0CAA0B,IAAI,KAAqB;CAEzD,MAAM,kBAA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