@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,591 +1,489 @@
1
- import { selectorsToPredicate, withEnrichments, AnchoredIdDeriver, isPlRef, mapValueInVOE, mapPObjectData, ensurePColumn, isPColumnSpec, isPColumn, PColumnName, readAnnotation, isDataInfo, extractAllColumns, mapPTableDef, collectSpecQueryColumns, mapPTableDefV2, parseJson, mapDataInfo } from '@milaboratories/pl-model-common';
2
- import canonicalize from 'canonicalize';
3
- import { getCfgRenderCtx } from '../internal.js';
4
- import { getPluginData } from '../block_storage.js';
5
- import { TreeNodeAccessor, ifDef } from './accessor.js';
6
- import { StagingAccessorName, MainAccessorName } from './internal.js';
7
- import { PColumnCollection } from './util/column_collection.js';
8
- import { deriveLabels } from './util/label.js';
9
- import { patchInSetFilters } from './util/pframe_upgraders.js';
10
- import { allPColumnsReady } from './util/pcolumn_data.js';
1
+ import { getPluginData } from "../block_storage.js";
2
+ import { getCfgRenderCtx } from "../internal.js";
3
+ import { TreeNodeAccessor, ifDef } from "./accessor.js";
4
+ import { MainAccessorName, StagingAccessorName } from "./internal.js";
5
+ import { deriveLabels } from "./util/label.js";
6
+ import { allPColumnsReady } from "./util/pcolumn_data.js";
7
+ import { PColumnCollection } from "./util/column_collection.js";
8
+ import { patchInSetFilters } from "./util/pframe_upgraders.js";
9
+ import { AnchoredIdDeriver, PColumnName, collectSpecQueryColumns, ensurePColumn, extractAllColumns, isDataInfo, isPColumn, isPColumnSpec, isPlRef, mapDataInfo, mapPObjectData, mapPTableDef, mapPTableDefV2, mapValueInVOE, parseJson, readAnnotation, selectorsToPredicate, withEnrichments } from "@milaboratories/pl-model-common";
10
+ import canonicalize from "canonicalize";
11
11
 
12
+ //#region src/render/api.ts
12
13
  /**
13
- * Helper function to match domain objects
14
- * @param query Optional domain to match against
15
- * @param target Optional domain to match
16
- * @returns true if domains match, false otherwise
17
- */
14
+ * Helper function to match domain objects
15
+ * @param query Optional domain to match against
16
+ * @param target Optional domain to match
17
+ * @returns true if domains match, false otherwise
18
+ */
18
19
  function matchDomain(query, target) {
19
- if (query === undefined)
20
- return target === undefined;
21
- if (target === undefined)
22
- return true;
23
- for (const k in target) {
24
- if (query[k] !== target[k])
25
- return false;
26
- }
27
- return true;
20
+ if (query === void 0) return target === void 0;
21
+ if (target === void 0) return true;
22
+ for (const k in target) if (query[k] !== target[k]) return false;
23
+ return true;
28
24
  }
29
25
  /**
30
- * Transforms PColumn data into the internal representation expected by the platform
31
- * @param data Data from a PColumn to transform
32
- * @returns Transformed data compatible with platform API
33
- */
26
+ * Transforms PColumn data into the internal representation expected by the platform
27
+ * @param data Data from a PColumn to transform
28
+ * @returns Transformed data compatible with platform API
29
+ */
34
30
  function transformPColumnData(data) {
35
- return mapPObjectData(data, (d) => {
36
- if (d instanceof TreeNodeAccessor) {
37
- return d.handle;
38
- }
39
- else if (isDataInfo(d)) {
40
- return mapDataInfo(d, (accessor) => accessor.handle);
41
- }
42
- else {
43
- return d;
44
- }
45
- });
46
- }
47
- class ResultPool {
48
- ctx = getCfgRenderCtx();
49
- /**
50
- * @deprecated use getOptions()
51
- */
52
- calculateOptions(predicate) {
53
- return this.ctx.calculateOptions(predicate);
54
- }
55
- getOptions(predicateOrSelector, opts) {
56
- const predicate = typeof predicateOrSelector === "function"
57
- ? predicateOrSelector
58
- : selectorsToPredicate(predicateOrSelector);
59
- const filtered = this.getSpecs().entries.filter((s) => predicate(s.obj));
60
- let labelOps = {};
61
- let refsWithEnrichments = false;
62
- if (typeof opts !== "undefined") {
63
- if (typeof opts === "function") {
64
- labelOps = opts;
65
- }
66
- else if (typeof opts === "object") {
67
- if ("includeNativeLabel" in opts || "separator" in opts || "addLabelAsSuffix" in opts) {
68
- labelOps = opts;
69
- }
70
- else {
71
- opts = opts;
72
- labelOps = opts.label ?? {};
73
- refsWithEnrichments = opts.refsWithEnrichments ?? false;
74
- }
75
- }
76
- }
77
- if (typeof labelOps === "object")
78
- return deriveLabels(filtered, (o) => o.obj, labelOps ?? {}).map(({ value: { ref }, label }) => ({
79
- ref: withEnrichments(ref, refsWithEnrichments),
80
- label,
81
- }));
82
- else
83
- return filtered.map(({ ref, obj }) => ({
84
- ref: withEnrichments(ref, refsWithEnrichments),
85
- label: labelOps(obj, ref),
86
- }));
87
- }
88
- resolveAnchorCtx(anchorsOrCtx) {
89
- if (anchorsOrCtx instanceof AnchoredIdDeriver)
90
- return anchorsOrCtx;
91
- const resolvedAnchors = {};
92
- for (const [key, value] of Object.entries(anchorsOrCtx)) {
93
- if (isPlRef(value)) {
94
- const resolvedSpec = this.getPColumnSpecByRef(value);
95
- if (!resolvedSpec)
96
- return undefined;
97
- resolvedAnchors[key] = resolvedSpec;
98
- }
99
- else {
100
- resolvedAnchors[key] = value;
101
- }
102
- }
103
- return new AnchoredIdDeriver(resolvedAnchors);
104
- }
105
- /**
106
- * Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
107
- *
108
- * @param anchorsOrCtx - Anchor context for column selection (same as in getCanonicalOptions)
109
- * @param predicateOrSelectors - Predicate or selectors for filtering columns (same as in getCanonicalOptions)
110
- * @param opts - Optional configuration for label generation and data waiting
111
- * @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
112
- */
113
- getAnchoredPColumns(anchorsOrCtx, predicateOrSelectors, opts) {
114
- const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
115
- if (!anchorCtx)
116
- return undefined;
117
- return new PColumnCollection()
118
- .addColumnProvider(this)
119
- .addAxisLabelProvider(this)
120
- .getColumns(predicateOrSelectors, {
121
- ...opts,
122
- anchorCtx,
123
- });
124
- }
125
- /**
126
- * Calculates anchored identifier options for columns matching a given predicate and returns their
127
- * canonicalized representations.
128
- *
129
- * This function filters column specifications from the result pool that match the provided predicate,
130
- * creates a standardized AnchorCtx from the provided anchors, and generates a list of label-value
131
- * pairs for UI components (like dropdowns).
132
- *
133
- * @param anchorsOrCtx - Either:
134
- * - An existing AnchorCtx instance
135
- * - A record mapping anchor IDs to PColumnSpec objects
136
- * - A record mapping anchor IDs to PlRef objects (which will be resolved to PColumnSpec)
137
- * @param predicateOrSelectors - Either:
138
- * - A predicate function that takes a PColumnSpec and returns a boolean.
139
- * Only specs that return true will be included.
140
- * - An APColumnSelector object for declarative filtering, which will be
141
- * resolved against the provided anchors and matched using matchPColumn.
142
- * - An array of APColumnSelector objects - columns matching ANY selector
143
- * in the array will be included (OR operation).
144
- * @param opts - Optional configuration for label generation:
145
- * - labelOps: Optional configuration for label generation:
146
- * - includeNativeLabel: Whether to include native column labels
147
- * - separator: String to use between label parts (defaults to " / ")
148
- * - addLabelAsSuffix: Whether to add labels as suffix instead of prefix
149
- * - dontWaitAllData: Whether to skip columns that don't have all data (if not set, will return undefined,
150
- * if at least one column that requires splitting is missing data)
151
- * @returns An array of objects with `label` (display text) and `value` (anchored ID string) properties,
152
- * or undefined if any PlRef resolution fails.
153
- */
154
- getCanonicalOptions(anchorsOrCtx, predicateOrSelectors, opts) {
155
- const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
156
- if (!anchorCtx)
157
- return undefined;
158
- const entries = new PColumnCollection()
159
- .addColumnProvider(this)
160
- .addAxisLabelProvider(this)
161
- .getUniversalEntries(predicateOrSelectors, {
162
- ...opts,
163
- anchorCtx,
164
- });
165
- if (!entries)
166
- return undefined;
167
- return entries.map((item) => ({
168
- value: item.id,
169
- label: item.label,
170
- }));
171
- }
172
- /**
173
- * @deprecated use getData()
174
- */
175
- getDataFromResultPool() {
176
- return this.getData();
177
- }
178
- getData() {
179
- const result = this.ctx.getDataFromResultPool();
180
- return {
181
- isComplete: result.isComplete,
182
- entries: result.entries.map((e) => ({
183
- ref: e.ref,
184
- obj: {
185
- ...e.obj,
186
- data: new TreeNodeAccessor(e.obj.data, [e.ref.blockId, e.ref.name]),
187
- },
188
- })),
189
- };
190
- }
191
- /**
192
- * @deprecated use getDataWithErrors()
193
- */
194
- getDataWithErrorsFromResultPool() {
195
- return this.getDataWithErrors();
196
- }
197
- getDataWithErrors() {
198
- const result = this.ctx.getDataWithErrorsFromResultPool();
199
- return {
200
- isComplete: result.isComplete,
201
- entries: result.entries.map((e) => ({
202
- ref: e.ref,
203
- obj: {
204
- ...e.obj,
205
- data: mapValueInVOE(e.obj.data, (handle) => new TreeNodeAccessor(handle, [e.ref.blockId, e.ref.name])),
206
- },
207
- })),
208
- };
209
- }
210
- /**
211
- * @deprecated use getSpecs()
212
- */
213
- getSpecsFromResultPool() {
214
- return this.getSpecs();
215
- }
216
- getSpecs() {
217
- return this.ctx.getSpecsFromResultPool();
218
- }
219
- /**
220
- * @param ref a Ref
221
- * @returns data associated with the ref
222
- */
223
- getDataByRef(ref) {
224
- // @TODO remove after 1 Jan 2025; forward compatibility
225
- if (typeof this.ctx.getDataFromResultPoolByRef === "undefined")
226
- return this.getData().entries.find((f) => f.ref.blockId === ref.blockId && f.ref.name === ref.name)?.obj;
227
- const data = this.ctx.getDataFromResultPoolByRef(ref.blockId, ref.name); // Keep original call
228
- // Need to handle undefined case before mapping
229
- if (!data)
230
- return undefined;
231
- return mapPObjectData(data, (handle) => new TreeNodeAccessor(handle, [ref.blockId, ref.name]));
232
- }
233
- /**
234
- * Returns data associated with the ref ensuring that it is a p-column.
235
- * @param ref a Ref
236
- * @returns p-column associated with the ref
237
- */
238
- getPColumnByRef(ref) {
239
- const data = this.getDataByRef(ref);
240
- if (!data)
241
- return undefined;
242
- return ensurePColumn(data);
243
- }
244
- /**
245
- * Returns spec associated with the ref ensuring that it is a p-column spec.
246
- * @param ref a Ref
247
- * @returns p-column spec associated with the ref
248
- */
249
- getPColumnSpecByRef(ref) {
250
- const spec = this.getSpecByRef(ref);
251
- if (!spec)
252
- return undefined;
253
- if (!isPColumnSpec(spec))
254
- throw new Error(`not a PColumn spec (kind = ${spec.kind})`);
255
- return spec;
256
- }
257
- /**
258
- * @param ref a Ref
259
- * @returns object spec associated with the ref
260
- */
261
- getSpecByRef(ref) {
262
- return this.ctx.getSpecFromResultPoolByRef(ref.blockId, ref.name);
263
- }
264
- /**
265
- * @param spec object specification
266
- * @returns array of data objects with compatible specs
267
- * @deprecated delete this method after Jan 1, 2025
268
- */
269
- findDataWithCompatibleSpec(spec) {
270
- const result = [];
271
- out: for (const data of this.getData().entries) {
272
- if (!isPColumnSpec(data.obj.spec)) {
273
- continue;
274
- }
275
- const oth = data.obj.spec;
276
- if (spec.name !== oth.name) {
277
- continue;
278
- }
279
- if (spec.valueType !== oth.valueType) {
280
- continue;
281
- }
282
- if (spec.axesSpec.length !== oth.axesSpec.length) {
283
- continue;
284
- }
285
- if (!matchDomain(spec.domain, oth.domain)) {
286
- continue;
287
- }
288
- for (let i = 0; i < spec.axesSpec.length; ++i) {
289
- const qAx = spec.axesSpec[i];
290
- const tAx = oth.axesSpec[i];
291
- if (qAx.name !== tAx.name) {
292
- continue out;
293
- }
294
- if (qAx.type !== tAx.type) {
295
- continue out;
296
- }
297
- if (!matchDomain(qAx.domain, tAx.domain)) {
298
- continue out;
299
- }
300
- }
301
- result.push(data.obj);
302
- }
303
- return result;
304
- }
305
- /**
306
- * Find labels data for a given axis id. It will search for a label column and return its data as a map.
307
- * @returns a map of axis value => label
308
- */
309
- findLabels(axis) {
310
- const dataPool = this.getData();
311
- for (const column of dataPool.entries) {
312
- if (!isPColumn(column.obj))
313
- continue;
314
- const spec = column.obj.spec;
315
- if (spec.name === PColumnName.Label &&
316
- spec.axesSpec.length === 1 &&
317
- spec.axesSpec[0].name === axis.name &&
318
- spec.axesSpec[0].type === axis.type &&
319
- matchDomain(axis.domain, spec.axesSpec[0].domain)) {
320
- if (column.obj.data.resourceType.name !== "PColumnData/Json") {
321
- throw Error(`Expected JSON column for labels, got: ${column.obj.data.resourceType.name}`);
322
- }
323
- const labels = Object.fromEntries(Object.entries(column.obj.data.getDataAsJson().data).map((e) => [JSON.parse(e[0])[0], e[1]]));
324
- return labels;
325
- }
326
- }
327
- return undefined;
328
- }
329
- /**
330
- * Selects columns based on the provided selectors, returning PColumn objects
331
- * with lazily loaded data.
332
- *
333
- * @param selectors - A predicate function, a single selector, or an array of selectors.
334
- * @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
335
- */
336
- selectColumns(selectors) {
337
- const predicate = typeof selectors === "function" ? selectors : selectorsToPredicate(selectors);
338
- const matchedSpecs = this.getSpecs().entries.filter(({ obj: spec }) => {
339
- if (!isPColumnSpec(spec))
340
- return false;
341
- return predicate(spec);
342
- });
343
- // Map specs to PColumn objects with lazy data loading
344
- return matchedSpecs.map(({ ref, obj: spec }) => {
345
- // Type assertion needed because filter ensures it's PColumnSpec
346
- const pcolumnSpec = spec;
347
- let _cachedData = null; // Use null to distinguish initial state from undefined result
348
- // eslint-disable-next-line @typescript-eslint/no-this-alias
349
- const self = this; // Capture 'this' for use inside the getter
350
- return {
351
- id: canonicalize(ref),
352
- spec: pcolumnSpec,
353
- get data() {
354
- if (_cachedData !== null) {
355
- return _cachedData; // Return cached data (could be undefined if fetch failed)
356
- }
357
- _cachedData = self.getPColumnByRef(ref)?.data;
358
- return _cachedData;
359
- },
360
- }; // Cast needed because 'data' is a getter
361
- });
362
- }
363
- /**
364
- * Find labels data for a given axis id of a p-column.
365
- * @returns a map of axis value => label
366
- */
367
- findLabelsForColumnAxis(column, axisIdx) {
368
- const labels = this.findLabels(column.axesSpec[axisIdx]);
369
- if (!labels)
370
- return undefined;
371
- const axisKeys = readAnnotation(column, `pl7.app/axisKeys/${axisIdx}`);
372
- if (axisKeys !== undefined) {
373
- const keys = JSON.parse(axisKeys);
374
- return Object.fromEntries(keys.map((key) => {
375
- return [key, labels[key] ?? "Unlabelled"];
376
- }));
377
- }
378
- else {
379
- return labels;
380
- }
381
- }
31
+ return mapPObjectData(data, (d) => {
32
+ if (d instanceof TreeNodeAccessor) return d.handle;
33
+ else if (isDataInfo(d)) return mapDataInfo(d, (accessor) => accessor.handle);
34
+ else return d;
35
+ });
382
36
  }
37
+ var ResultPool = class {
38
+ ctx = getCfgRenderCtx();
39
+ /**
40
+ * @deprecated use getOptions()
41
+ */
42
+ calculateOptions(predicate) {
43
+ return this.ctx.calculateOptions(predicate);
44
+ }
45
+ getOptions(predicateOrSelector, opts) {
46
+ const predicate = typeof predicateOrSelector === "function" ? predicateOrSelector : selectorsToPredicate(predicateOrSelector);
47
+ const filtered = this.getSpecs().entries.filter((s) => predicate(s.obj));
48
+ let labelOps = {};
49
+ let refsWithEnrichments = false;
50
+ if (typeof opts !== "undefined") {
51
+ if (typeof opts === "function") labelOps = opts;
52
+ else if (typeof opts === "object") if ("includeNativeLabel" in opts || "separator" in opts || "addLabelAsSuffix" in opts) labelOps = opts;
53
+ else {
54
+ opts = opts;
55
+ labelOps = opts.label ?? {};
56
+ refsWithEnrichments = opts.refsWithEnrichments ?? false;
57
+ }
58
+ }
59
+ if (typeof labelOps === "object") return deriveLabels(filtered, (o) => o.obj, labelOps ?? {}).map(({ value: { ref }, label }) => ({
60
+ ref: withEnrichments(ref, refsWithEnrichments),
61
+ label
62
+ }));
63
+ else return filtered.map(({ ref, obj }) => ({
64
+ ref: withEnrichments(ref, refsWithEnrichments),
65
+ label: labelOps(obj, ref)
66
+ }));
67
+ }
68
+ resolveAnchorCtx(anchorsOrCtx) {
69
+ if (anchorsOrCtx instanceof AnchoredIdDeriver) return anchorsOrCtx;
70
+ const resolvedAnchors = {};
71
+ for (const [key, value] of Object.entries(anchorsOrCtx)) if (isPlRef(value)) {
72
+ const resolvedSpec = this.getPColumnSpecByRef(value);
73
+ if (!resolvedSpec) return void 0;
74
+ resolvedAnchors[key] = resolvedSpec;
75
+ } else resolvedAnchors[key] = value;
76
+ return new AnchoredIdDeriver(resolvedAnchors);
77
+ }
78
+ /**
79
+ * Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
80
+ *
81
+ * @param anchorsOrCtx - Anchor context for column selection (same as in getCanonicalOptions)
82
+ * @param predicateOrSelectors - Predicate or selectors for filtering columns (same as in getCanonicalOptions)
83
+ * @param opts - Optional configuration for label generation and data waiting
84
+ * @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
85
+ */
86
+ getAnchoredPColumns(anchorsOrCtx, predicateOrSelectors, opts) {
87
+ const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
88
+ if (!anchorCtx) return void 0;
89
+ return new PColumnCollection().addColumnProvider(this).addAxisLabelProvider(this).getColumns(predicateOrSelectors, {
90
+ ...opts,
91
+ anchorCtx
92
+ });
93
+ }
94
+ /**
95
+ * Calculates anchored identifier options for columns matching a given predicate and returns their
96
+ * canonicalized representations.
97
+ *
98
+ * This function filters column specifications from the result pool that match the provided predicate,
99
+ * creates a standardized AnchorCtx from the provided anchors, and generates a list of label-value
100
+ * pairs for UI components (like dropdowns).
101
+ *
102
+ * @param anchorsOrCtx - Either:
103
+ * - An existing AnchorCtx instance
104
+ * - A record mapping anchor IDs to PColumnSpec objects
105
+ * - A record mapping anchor IDs to PlRef objects (which will be resolved to PColumnSpec)
106
+ * @param predicateOrSelectors - Either:
107
+ * - A predicate function that takes a PColumnSpec and returns a boolean.
108
+ * Only specs that return true will be included.
109
+ * - An APColumnSelector object for declarative filtering, which will be
110
+ * resolved against the provided anchors and matched using matchPColumn.
111
+ * - An array of APColumnSelector objects - columns matching ANY selector
112
+ * in the array will be included (OR operation).
113
+ * @param opts - Optional configuration for label generation:
114
+ * - labelOps: Optional configuration for label generation:
115
+ * - includeNativeLabel: Whether to include native column labels
116
+ * - separator: String to use between label parts (defaults to " / ")
117
+ * - addLabelAsSuffix: Whether to add labels as suffix instead of prefix
118
+ * - dontWaitAllData: Whether to skip columns that don't have all data (if not set, will return undefined,
119
+ * if at least one column that requires splitting is missing data)
120
+ * @returns An array of objects with `label` (display text) and `value` (anchored ID string) properties,
121
+ * or undefined if any PlRef resolution fails.
122
+ */
123
+ getCanonicalOptions(anchorsOrCtx, predicateOrSelectors, opts) {
124
+ const anchorCtx = this.resolveAnchorCtx(anchorsOrCtx);
125
+ if (!anchorCtx) return void 0;
126
+ const entries = new PColumnCollection().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(predicateOrSelectors, {
127
+ ...opts,
128
+ anchorCtx
129
+ });
130
+ if (!entries) return void 0;
131
+ return entries.map((item) => ({
132
+ value: item.id,
133
+ label: item.label
134
+ }));
135
+ }
136
+ /**
137
+ * @deprecated use getData()
138
+ */
139
+ getDataFromResultPool() {
140
+ return this.getData();
141
+ }
142
+ getData() {
143
+ const result = this.ctx.getDataFromResultPool();
144
+ return {
145
+ isComplete: result.isComplete,
146
+ entries: result.entries.map((e) => ({
147
+ ref: e.ref,
148
+ obj: {
149
+ ...e.obj,
150
+ data: new TreeNodeAccessor(e.obj.data, [e.ref.blockId, e.ref.name])
151
+ }
152
+ }))
153
+ };
154
+ }
155
+ /**
156
+ * @deprecated use getDataWithErrors()
157
+ */
158
+ getDataWithErrorsFromResultPool() {
159
+ return this.getDataWithErrors();
160
+ }
161
+ getDataWithErrors() {
162
+ const result = this.ctx.getDataWithErrorsFromResultPool();
163
+ return {
164
+ isComplete: result.isComplete,
165
+ entries: result.entries.map((e) => ({
166
+ ref: e.ref,
167
+ obj: {
168
+ ...e.obj,
169
+ data: mapValueInVOE(e.obj.data, (handle) => new TreeNodeAccessor(handle, [e.ref.blockId, e.ref.name]))
170
+ }
171
+ }))
172
+ };
173
+ }
174
+ /**
175
+ * @deprecated use getSpecs()
176
+ */
177
+ getSpecsFromResultPool() {
178
+ return this.getSpecs();
179
+ }
180
+ getSpecs() {
181
+ return this.ctx.getSpecsFromResultPool();
182
+ }
183
+ /**
184
+ * @param ref a Ref
185
+ * @returns data associated with the ref
186
+ */
187
+ getDataByRef(ref) {
188
+ if (typeof this.ctx.getDataFromResultPoolByRef === "undefined") return this.getData().entries.find((f) => f.ref.blockId === ref.blockId && f.ref.name === ref.name)?.obj;
189
+ const data = this.ctx.getDataFromResultPoolByRef(ref.blockId, ref.name);
190
+ if (!data) return void 0;
191
+ return mapPObjectData(data, (handle) => new TreeNodeAccessor(handle, [ref.blockId, ref.name]));
192
+ }
193
+ /**
194
+ * Returns data associated with the ref ensuring that it is a p-column.
195
+ * @param ref a Ref
196
+ * @returns p-column associated with the ref
197
+ */
198
+ getPColumnByRef(ref) {
199
+ const data = this.getDataByRef(ref);
200
+ if (!data) return void 0;
201
+ return ensurePColumn(data);
202
+ }
203
+ /**
204
+ * Returns spec associated with the ref ensuring that it is a p-column spec.
205
+ * @param ref a Ref
206
+ * @returns p-column spec associated with the ref
207
+ */
208
+ getPColumnSpecByRef(ref) {
209
+ const spec = this.getSpecByRef(ref);
210
+ if (!spec) return void 0;
211
+ if (!isPColumnSpec(spec)) throw new Error(`not a PColumn spec (kind = ${spec.kind})`);
212
+ return spec;
213
+ }
214
+ /**
215
+ * @param ref a Ref
216
+ * @returns object spec associated with the ref
217
+ */
218
+ getSpecByRef(ref) {
219
+ return this.ctx.getSpecFromResultPoolByRef(ref.blockId, ref.name);
220
+ }
221
+ /**
222
+ * @param spec object specification
223
+ * @returns array of data objects with compatible specs
224
+ * @deprecated delete this method after Jan 1, 2025
225
+ */
226
+ findDataWithCompatibleSpec(spec) {
227
+ const result = [];
228
+ out: for (const data of this.getData().entries) {
229
+ if (!isPColumnSpec(data.obj.spec)) continue;
230
+ const oth = data.obj.spec;
231
+ if (spec.name !== oth.name) continue;
232
+ if (spec.valueType !== oth.valueType) continue;
233
+ if (spec.axesSpec.length !== oth.axesSpec.length) continue;
234
+ if (!matchDomain(spec.domain, oth.domain)) continue;
235
+ for (let i = 0; i < spec.axesSpec.length; ++i) {
236
+ const qAx = spec.axesSpec[i];
237
+ const tAx = oth.axesSpec[i];
238
+ if (qAx.name !== tAx.name) continue out;
239
+ if (qAx.type !== tAx.type) continue out;
240
+ if (!matchDomain(qAx.domain, tAx.domain)) continue out;
241
+ }
242
+ result.push(data.obj);
243
+ }
244
+ return result;
245
+ }
246
+ /**
247
+ * Find labels data for a given axis id. It will search for a label column and return its data as a map.
248
+ * @returns a map of axis value => label
249
+ */
250
+ findLabels(axis) {
251
+ const dataPool = this.getData();
252
+ for (const column of dataPool.entries) {
253
+ if (!isPColumn(column.obj)) continue;
254
+ const spec = column.obj.spec;
255
+ if (spec.name === PColumnName.Label && spec.axesSpec.length === 1 && spec.axesSpec[0].name === axis.name && spec.axesSpec[0].type === axis.type && matchDomain(axis.domain, spec.axesSpec[0].domain)) {
256
+ if (column.obj.data.resourceType.name !== "PColumnData/Json") throw Error(`Expected JSON column for labels, got: ${column.obj.data.resourceType.name}`);
257
+ return Object.fromEntries(Object.entries(column.obj.data.getDataAsJson().data).map((e) => [JSON.parse(e[0])[0], e[1]]));
258
+ }
259
+ }
260
+ }
261
+ /**
262
+ * Selects columns based on the provided selectors, returning PColumn objects
263
+ * with lazily loaded data.
264
+ *
265
+ * @param selectors - A predicate function, a single selector, or an array of selectors.
266
+ * @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
267
+ */
268
+ selectColumns(selectors) {
269
+ const predicate = typeof selectors === "function" ? selectors : selectorsToPredicate(selectors);
270
+ return this.getSpecs().entries.filter(({ obj: spec }) => {
271
+ if (!isPColumnSpec(spec)) return false;
272
+ return predicate(spec);
273
+ }).map(({ ref, obj: spec }) => {
274
+ const pcolumnSpec = spec;
275
+ let _cachedData = null;
276
+ const self = this;
277
+ return {
278
+ id: canonicalize(ref),
279
+ spec: pcolumnSpec,
280
+ get data() {
281
+ if (_cachedData !== null) return _cachedData;
282
+ _cachedData = self.getPColumnByRef(ref)?.data;
283
+ return _cachedData;
284
+ }
285
+ };
286
+ });
287
+ }
288
+ /**
289
+ * Find labels data for a given axis id of a p-column.
290
+ * @returns a map of axis value => label
291
+ */
292
+ findLabelsForColumnAxis(column, axisIdx) {
293
+ const labels = this.findLabels(column.axesSpec[axisIdx]);
294
+ if (!labels) return void 0;
295
+ const axisKeys = readAnnotation(column, `pl7.app/axisKeys/${axisIdx}`);
296
+ if (axisKeys !== void 0) {
297
+ const keys = JSON.parse(axisKeys);
298
+ return Object.fromEntries(keys.map((key) => {
299
+ return [key, labels[key] ?? "Unlabelled"];
300
+ }));
301
+ } else return labels;
302
+ }
303
+ };
383
304
  /** Main entry point to the API available within model lambdas (like outputs, sections, etc..) */
384
- class RenderCtxBase {
385
- ctx;
386
- constructor() {
387
- this.ctx = getCfgRenderCtx();
388
- }
389
- dataCache;
390
- get data() {
391
- if (this.dataCache === undefined) {
392
- const raw = this.ctx.data;
393
- const value = typeof raw === "function" ? raw() : raw;
394
- this.dataCache = { v: value ? JSON.parse(value) : {} };
395
- }
396
- return this.dataCache.v;
397
- }
398
- // lazy rendering because this feature is rarely used
399
- activeArgsCache;
400
- /**
401
- * Returns args snapshot the block was executed for (i.e. when "Run" button was pressed).
402
- * Returns undefined, if block was never executed or stopped mid-way execution, so that the result was cleared.
403
- * */
404
- get activeArgs() {
405
- if (this.activeArgsCache === undefined) {
406
- const raw = this.ctx.activeArgs;
407
- const value = typeof raw === "function" ? raw() : raw;
408
- this.activeArgsCache = {
409
- v: value ? JSON.parse(value) : undefined,
410
- };
411
- }
412
- return this.activeArgsCache.v;
413
- }
414
- // /** Can be used to determine features provided by the desktop instance. */
415
- // public get featureFlags() {
416
- // return this.ctx.featureFlags;
417
- // }
418
- getNamedAccessor(name) {
419
- return ifDef(this.ctx.getAccessorHandleByName(name), (accessor) => new TreeNodeAccessor(accessor, [name]));
420
- }
421
- get prerun() {
422
- return this.getNamedAccessor(StagingAccessorName);
423
- }
424
- get outputs() {
425
- return this.getNamedAccessor(MainAccessorName);
426
- }
427
- resultPool = new ResultPool();
428
- /**
429
- * Find labels data for a given axis id. It will search for a label column and return its data as a map.
430
- * @returns a map of axis value => label
431
- * @deprecated Use resultPool.findLabels instead
432
- */
433
- findLabels(axis) {
434
- return this.resultPool.findLabels(axis);
435
- }
436
- verifyInlineAndExplicitColumnsSupport(columns) {
437
- const hasInlineColumns = columns.some((c) => !(c.data instanceof TreeNodeAccessor) || isDataInfo(c.data)); // Updated check for DataInfo
438
- const inlineColumnsSupport = this.ctx.featureFlags?.inlineColumnsSupport === true;
439
- if (hasInlineColumns && !inlineColumnsSupport)
440
- throw Error(`Inline or explicit columns not supported`); // Combined check
441
- // Removed redundant explicitColumns check
442
- }
443
- patchPTableDef(def) {
444
- if (!this.ctx.featureFlags?.pTablePartitionFiltersSupport) {
445
- // For old desktop move all partition filters to filters field as it doesn't read partitionFilters field
446
- def = {
447
- ...def,
448
- partitionFilters: [],
449
- filters: [...def.partitionFilters, ...def.filters],
450
- };
451
- }
452
- if (!this.ctx.featureFlags?.pFrameInSetFilterSupport) {
453
- def = {
454
- ...def,
455
- partitionFilters: patchInSetFilters(def.partitionFilters),
456
- filters: patchInSetFilters(def.filters),
457
- };
458
- }
459
- return def;
460
- }
461
- // TODO remove all non-PColumn fields
462
- createPFrame(def) {
463
- this.verifyInlineAndExplicitColumnsSupport(def);
464
- if (!allPColumnsReady(def))
465
- return undefined;
466
- return this.ctx.createPFrame(def.map((c) => transformPColumnData(c)));
467
- }
468
- createPTable(def) {
469
- let rawDef;
470
- if ("columns" in def) {
471
- rawDef = this.patchPTableDef({
472
- src: {
473
- type: "full",
474
- entries: def.columns.map((c) => ({ type: "column", column: c })),
475
- },
476
- partitionFilters: def.filters ?? [],
477
- filters: [],
478
- sorting: def.sorting ?? [],
479
- });
480
- }
481
- else {
482
- rawDef = this.patchPTableDef(def);
483
- }
484
- const columns = extractAllColumns(rawDef.src);
485
- this.verifyInlineAndExplicitColumnsSupport(columns);
486
- if (!allPColumnsReady(columns))
487
- return undefined;
488
- return this.ctx.createPTable(mapPTableDef(rawDef, (po) => transformPColumnData(po)));
489
- }
490
- createPTableV2(def) {
491
- const columns = collectSpecQueryColumns(def.query);
492
- this.verifyInlineAndExplicitColumnsSupport(columns);
493
- if (!allPColumnsReady(columns))
494
- return undefined;
495
- return this.ctx.createPTableV2(mapPTableDefV2(def, (po) => transformPColumnData(po)));
496
- }
497
- /** @deprecated scheduled for removal from SDK */
498
- getBlockLabel(blockId) {
499
- return this.ctx.getBlockLabel(blockId);
500
- }
501
- getCurrentUnstableMarker() {
502
- return this.ctx.getCurrentUnstableMarker();
503
- }
504
- logInfo(msg) {
505
- this.ctx.logInfo(msg);
506
- }
507
- logWarn(msg) {
508
- this.ctx.logWarn(msg);
509
- }
510
- logError(msg) {
511
- this.ctx.logError(msg);
512
- }
513
- }
305
+ var RenderCtxBase = class {
306
+ ctx;
307
+ constructor() {
308
+ this.ctx = getCfgRenderCtx();
309
+ }
310
+ dataCache;
311
+ get data() {
312
+ if (this.dataCache === void 0) {
313
+ const raw = this.ctx.data;
314
+ const value = typeof raw === "function" ? raw() : raw;
315
+ this.dataCache = { v: value ? JSON.parse(value) : {} };
316
+ }
317
+ return this.dataCache.v;
318
+ }
319
+ activeArgsCache;
320
+ /**
321
+ * Returns args snapshot the block was executed for (i.e. when "Run" button was pressed).
322
+ * Returns undefined, if block was never executed or stopped mid-way execution, so that the result was cleared.
323
+ * */
324
+ get activeArgs() {
325
+ if (this.activeArgsCache === void 0) {
326
+ const raw = this.ctx.activeArgs;
327
+ const value = typeof raw === "function" ? raw() : raw;
328
+ this.activeArgsCache = { v: value ? JSON.parse(value) : void 0 };
329
+ }
330
+ return this.activeArgsCache.v;
331
+ }
332
+ getNamedAccessor(name) {
333
+ return ifDef(this.ctx.getAccessorHandleByName(name), (accessor) => new TreeNodeAccessor(accessor, [name]));
334
+ }
335
+ get prerun() {
336
+ return this.getNamedAccessor(StagingAccessorName);
337
+ }
338
+ get outputs() {
339
+ return this.getNamedAccessor(MainAccessorName);
340
+ }
341
+ resultPool = new ResultPool();
342
+ /**
343
+ * Find labels data for a given axis id. It will search for a label column and return its data as a map.
344
+ * @returns a map of axis value => label
345
+ * @deprecated Use resultPool.findLabels instead
346
+ */
347
+ findLabels(axis) {
348
+ return this.resultPool.findLabels(axis);
349
+ }
350
+ verifyInlineAndExplicitColumnsSupport(columns) {
351
+ const hasInlineColumns = columns.some((c) => !(c.data instanceof TreeNodeAccessor) || isDataInfo(c.data));
352
+ const inlineColumnsSupport = this.ctx.featureFlags?.inlineColumnsSupport === true;
353
+ if (hasInlineColumns && !inlineColumnsSupport) throw Error(`Inline or explicit columns not supported`);
354
+ }
355
+ patchPTableDef(def) {
356
+ if (!this.ctx.featureFlags?.pTablePartitionFiltersSupport) def = {
357
+ ...def,
358
+ partitionFilters: [],
359
+ filters: [...def.partitionFilters, ...def.filters]
360
+ };
361
+ if (!this.ctx.featureFlags?.pFrameInSetFilterSupport) def = {
362
+ ...def,
363
+ partitionFilters: patchInSetFilters(def.partitionFilters),
364
+ filters: patchInSetFilters(def.filters)
365
+ };
366
+ return def;
367
+ }
368
+ createPFrame(def) {
369
+ this.verifyInlineAndExplicitColumnsSupport(def);
370
+ if (!allPColumnsReady(def)) return void 0;
371
+ return this.ctx.createPFrame(def.map((c) => transformPColumnData(c)));
372
+ }
373
+ createPTable(def) {
374
+ let rawDef;
375
+ if ("columns" in def) rawDef = this.patchPTableDef({
376
+ src: {
377
+ type: "full",
378
+ entries: def.columns.map((c) => ({
379
+ type: "column",
380
+ column: c
381
+ }))
382
+ },
383
+ partitionFilters: def.filters ?? [],
384
+ filters: [],
385
+ sorting: def.sorting ?? []
386
+ });
387
+ else rawDef = this.patchPTableDef(def);
388
+ const columns = extractAllColumns(rawDef.src);
389
+ this.verifyInlineAndExplicitColumnsSupport(columns);
390
+ if (!allPColumnsReady(columns)) return void 0;
391
+ return this.ctx.createPTable(mapPTableDef(rawDef, (po) => transformPColumnData(po)));
392
+ }
393
+ createPTableV2(def) {
394
+ const columns = collectSpecQueryColumns(def.query);
395
+ this.verifyInlineAndExplicitColumnsSupport(columns);
396
+ if (!allPColumnsReady(columns)) return void 0;
397
+ return this.ctx.createPTableV2(mapPTableDefV2(def, (po) => transformPColumnData(po)));
398
+ }
399
+ /** @deprecated scheduled for removal from SDK */
400
+ getBlockLabel(blockId) {
401
+ return this.ctx.getBlockLabel(blockId);
402
+ }
403
+ getCurrentUnstableMarker() {
404
+ return this.ctx.getCurrentUnstableMarker();
405
+ }
406
+ logInfo(msg) {
407
+ this.ctx.logInfo(msg);
408
+ }
409
+ logWarn(msg) {
410
+ this.ctx.logWarn(msg);
411
+ }
412
+ logError(msg) {
413
+ this.ctx.logError(msg);
414
+ }
415
+ };
514
416
  /** Main entry point to the API available within model lambdas (like outputs, sections, etc..) for v3+ blocks */
515
- class BlockRenderCtx extends RenderCtxBase {
516
- argsCache;
517
- get args() {
518
- if (this.argsCache === undefined) {
519
- const raw = this.ctx.args;
520
- const value = typeof raw === "function" ? raw() : raw;
521
- this.argsCache = { v: value === undefined ? undefined : JSON.parse(value) };
522
- }
523
- return this.argsCache.v;
524
- }
525
- }
417
+ var BlockRenderCtx = class extends RenderCtxBase {
418
+ argsCache;
419
+ get args() {
420
+ if (this.argsCache === void 0) {
421
+ const raw = this.ctx.args;
422
+ const value = typeof raw === "function" ? raw() : raw;
423
+ this.argsCache = { v: value === void 0 ? void 0 : JSON.parse(value) };
424
+ }
425
+ return this.argsCache.v;
426
+ }
427
+ };
526
428
  /** Render context for legacy v1/v2 blocks - provides backward compatibility */
527
- class RenderCtxLegacy extends RenderCtxBase {
528
- argsCache;
529
- get args() {
530
- if (this.argsCache === undefined) {
531
- const raw = this.ctx.args;
532
- const value = typeof raw === "function" ? raw() : raw;
533
- this.argsCache = { v: JSON.parse(value) };
534
- }
535
- return this.argsCache.v;
536
- }
537
- uiStateCache;
538
- get uiState() {
539
- if (this.uiStateCache === undefined) {
540
- const raw = this.ctx.uiState;
541
- const value = typeof raw === "function" ? raw() : raw;
542
- this.uiStateCache = { v: value ? JSON.parse(value) : {} };
543
- }
544
- return this.uiStateCache.v;
545
- }
546
- }
429
+ var RenderCtxLegacy = class extends RenderCtxBase {
430
+ argsCache;
431
+ get args() {
432
+ if (this.argsCache === void 0) {
433
+ const raw = this.ctx.args;
434
+ const value = typeof raw === "function" ? raw() : raw;
435
+ this.argsCache = { v: JSON.parse(value) };
436
+ }
437
+ return this.argsCache.v;
438
+ }
439
+ uiStateCache;
440
+ get uiState() {
441
+ if (this.uiStateCache === void 0) {
442
+ const raw = this.ctx.uiState;
443
+ const value = typeof raw === "function" ? raw() : raw;
444
+ this.uiStateCache = { v: value ? JSON.parse(value) : {} };
445
+ }
446
+ return this.uiStateCache.v;
447
+ }
448
+ };
547
449
  /**
548
- * Render context for plugin output functions.
549
- * Reads plugin data from blockStorage and derives params from pre-wrapped input callbacks.
550
- *
551
- * Parameterized on the factory-like phantom F so that getPluginData returns
552
- * InferFactoryData<F> directly — no casts needed for the data getter.
553
- *
554
- * @typeParam F - PluginFactoryLike phantom carrying data/params/outputs types
555
- */
556
- class PluginRenderCtx {
557
- ctx;
558
- handle;
559
- wrappedInputs;
560
- constructor(handle, wrappedInputs) {
561
- this.ctx = getCfgRenderCtx();
562
- this.handle = handle;
563
- this.wrappedInputs = wrappedInputs;
564
- }
565
- dataCache;
566
- /** Plugin's persistent data from blockStorage.__plugins.{pluginId}.__data */
567
- get data() {
568
- if (this.dataCache === undefined) {
569
- const raw = this.ctx.blockStorage();
570
- this.dataCache = { v: getPluginData(parseJson(raw), this.handle) };
571
- }
572
- return this.dataCache.v;
573
- }
574
- paramsCache;
575
- /** Params derived from block context via pre-wrapped input callbacks */
576
- get params() {
577
- if (this.paramsCache === undefined) {
578
- const result = {};
579
- for (const [key, fn] of Object.entries(this.wrappedInputs)) {
580
- result[key] = fn();
581
- }
582
- this.paramsCache = { v: result };
583
- }
584
- return this.paramsCache.v;
585
- }
586
- /** Result pool — same as block, from cfgRenderCtx methods */
587
- resultPool = new ResultPool();
588
- }
450
+ * Render context for plugin output functions.
451
+ * Reads plugin data from blockStorage and derives params from pre-wrapped input callbacks.
452
+ *
453
+ * Parameterized on the factory-like phantom F so that getPluginData returns
454
+ * InferFactoryData<F> directly — no casts needed for the data getter.
455
+ *
456
+ * @typeParam F - PluginFactoryLike phantom carrying data/params/outputs types
457
+ */
458
+ var PluginRenderCtx = class {
459
+ ctx;
460
+ handle;
461
+ wrappedInputs;
462
+ constructor(handle, wrappedInputs) {
463
+ this.ctx = getCfgRenderCtx();
464
+ this.handle = handle;
465
+ this.wrappedInputs = wrappedInputs;
466
+ }
467
+ dataCache;
468
+ /** Plugin's persistent data from blockStorage.__plugins.{pluginId}.__data */
469
+ get data() {
470
+ if (this.dataCache === void 0) this.dataCache = { v: getPluginData(parseJson(this.ctx.blockStorage()), this.handle) };
471
+ return this.dataCache.v;
472
+ }
473
+ paramsCache;
474
+ /** Params derived from block context via pre-wrapped input callbacks */
475
+ get params() {
476
+ if (this.paramsCache === void 0) {
477
+ const result = {};
478
+ for (const [key, fn] of Object.entries(this.wrappedInputs)) result[key] = fn();
479
+ this.paramsCache = { v: result };
480
+ }
481
+ return this.paramsCache.v;
482
+ }
483
+ /** Result pool — same as block, from cfgRenderCtx methods */
484
+ resultPool = new ResultPool();
485
+ };
589
486
 
487
+ //#endregion
590
488
  export { BlockRenderCtx, PluginRenderCtx, RenderCtxBase, RenderCtxLegacy, ResultPool };
591
- //# sourceMappingURL=api.js.map
489
+ //# sourceMappingURL=api.js.map