@platforma-sdk/model 1.58.5 → 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 (365) 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 -60
  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 -58
  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 +10 -4
  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/index.ts +12 -11
  272. package/src/internal.ts +0 -1
  273. package/src/platforma.ts +4 -4
  274. package/src/plugin_handle.ts +1 -1
  275. package/src/plugin_model.test.ts +217 -21
  276. package/src/plugin_model.ts +450 -55
  277. package/src/raw_globals.ts +0 -1
  278. package/dist/annotations/converter.d.ts.map +0 -1
  279. package/dist/annotations/index.d.ts.map +0 -1
  280. package/dist/annotations/types.d.ts.map +0 -1
  281. package/dist/bconfig/index.d.ts.map +0 -1
  282. package/dist/bconfig/lambdas.d.ts.map +0 -1
  283. package/dist/bconfig/normalization.d.ts.map +0 -1
  284. package/dist/bconfig/types.d.ts.map +0 -1
  285. package/dist/bconfig/util.d.ts.map +0 -1
  286. package/dist/bconfig/v3.d.ts.map +0 -1
  287. package/dist/block_api_v1.d.ts.map +0 -1
  288. package/dist/block_api_v2.d.ts.map +0 -1
  289. package/dist/block_api_v3.d.ts.map +0 -1
  290. package/dist/block_migrations.d.ts.map +0 -1
  291. package/dist/block_model.d.ts.map +0 -1
  292. package/dist/block_model_legacy.d.ts.map +0 -1
  293. package/dist/block_state_patch.d.ts.map +0 -1
  294. package/dist/block_state_util.d.ts.map +0 -1
  295. package/dist/block_storage.d.ts.map +0 -1
  296. package/dist/block_storage_callbacks.d.ts +0 -115
  297. package/dist/block_storage_callbacks.d.ts.map +0 -1
  298. package/dist/block_storage_facade.d.ts.map +0 -1
  299. package/dist/components/PFrameForGraphs.d.ts.map +0 -1
  300. package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
  301. package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
  302. package/dist/components/PlAnnotations/index.d.ts.map +0 -1
  303. package/dist/components/PlAnnotations/types.d.ts +0 -3
  304. package/dist/components/PlAnnotations/types.d.ts.map +0 -1
  305. package/dist/components/PlDataTable/index.d.ts.map +0 -1
  306. package/dist/components/PlDataTable/labels.d.ts +0 -7
  307. package/dist/components/PlDataTable/labels.d.ts.map +0 -1
  308. package/dist/components/PlDataTable/state-migration.d.ts.map +0 -1
  309. package/dist/components/PlDataTable/table.d.ts.map +0 -1
  310. package/dist/components/PlDataTable/v4.d.ts.map +0 -1
  311. package/dist/components/PlDataTable/v5.d.ts.map +0 -1
  312. package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
  313. package/dist/components/PlSelectionModel.d.ts.map +0 -1
  314. package/dist/components/index.d.ts.map +0 -1
  315. package/dist/config/actions.d.ts.map +0 -1
  316. package/dist/config/actions_kinds.d.ts.map +0 -1
  317. package/dist/config/index.d.ts.map +0 -1
  318. package/dist/config/model.d.ts.map +0 -1
  319. package/dist/config/model_meta.d.ts.map +0 -1
  320. package/dist/config/type_engine.d.ts.map +0 -1
  321. package/dist/config/type_util.d.ts.map +0 -1
  322. package/dist/env_value.d.ts.map +0 -1
  323. package/dist/filters/converters/filterToQuery.d.ts.map +0 -1
  324. package/dist/filters/converters/filterUiToExpressionImpl.d.ts.map +0 -1
  325. package/dist/filters/converters/index.d.ts.map +0 -1
  326. package/dist/filters/distill.d.ts.map +0 -1
  327. package/dist/filters/index.d.ts.map +0 -1
  328. package/dist/filters/traverse.d.ts +0 -27
  329. package/dist/filters/traverse.d.ts.map +0 -1
  330. package/dist/filters/types.d.ts.map +0 -1
  331. package/dist/index.cjs.map +0 -1
  332. package/dist/index.d.ts.map +0 -1
  333. package/dist/index.js.map +0 -1
  334. package/dist/internal.d.ts +0 -36
  335. package/dist/internal.d.ts.map +0 -1
  336. package/dist/package.json.cjs +0 -6
  337. package/dist/package.json.cjs.map +0 -1
  338. package/dist/package.json.js +0 -4
  339. package/dist/package.json.js.map +0 -1
  340. package/dist/pframe.d.ts.map +0 -1
  341. package/dist/pframe_utils/axes.d.ts.map +0 -1
  342. package/dist/pframe_utils/columns.d.ts.map +0 -1
  343. package/dist/pframe_utils/index.d.ts.map +0 -1
  344. package/dist/pframe_utils/querySpec.d.ts +0 -2
  345. package/dist/pframe_utils/querySpec.d.ts.map +0 -1
  346. package/dist/platforma.d.ts.map +0 -1
  347. package/dist/plugin_handle.d.ts.map +0 -1
  348. package/dist/plugin_model.d.ts.map +0 -1
  349. package/dist/raw_globals.d.ts.map +0 -1
  350. package/dist/ref_util.d.ts.map +0 -1
  351. package/dist/render/accessor.d.ts.map +0 -1
  352. package/dist/render/api.d.ts.map +0 -1
  353. package/dist/render/future.d.ts.map +0 -1
  354. package/dist/render/index.d.ts.map +0 -1
  355. package/dist/render/internal.d.ts.map +0 -1
  356. package/dist/render/traversal_ops.d.ts.map +0 -1
  357. package/dist/render/util/axis_filtering.d.ts.map +0 -1
  358. package/dist/render/util/column_collection.d.ts.map +0 -1
  359. package/dist/render/util/index.d.ts.map +0 -1
  360. package/dist/render/util/label.d.ts.map +0 -1
  361. package/dist/render/util/pcolumn_data.d.ts.map +0 -1
  362. package/dist/render/util/pframe_upgraders.d.ts +0 -3
  363. package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
  364. package/dist/render/util/split_selectors.d.ts.map +0 -1
  365. package/dist/version.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * BlockStorage Callback Implementations - wired to facade callbacks in BlockModelV3._done().
2
+ * BlockStorage Callback Implementations - wired to facade callbacks in BlockModelV3.done().
3
3
  *
4
4
  * Provides pure functions for storage operations (migration, initialization,
5
5
  * args derivation, updates, debug views). Each function takes its dependencies
@@ -27,7 +27,7 @@ import {
27
27
  import type { PluginHandle } from "./plugin_handle";
28
28
 
29
29
  import { stringifyJson, type StringifiedJson } from "@milaboratories/pl-model-common";
30
- import type { DataVersioned } from "./block_migrations";
30
+ import type { DataVersioned, TransferRecord } from "./block_migrations";
31
31
 
32
32
  // =============================================================================
33
33
  // Hook interfaces for dependency injection
@@ -35,13 +35,18 @@ import type { DataVersioned } from "./block_migrations";
35
35
 
36
36
  /** Dependencies for storage migration */
37
37
  export interface MigrationHooks {
38
- migrateBlockData: (versioned: DataVersioned<unknown>) => DataVersioned<unknown>;
38
+ migrateBlockData: (versioned: DataVersioned<unknown>) => DataVersioned<unknown> & {
39
+ transfers: TransferRecord;
40
+ };
39
41
  getPluginRegistry: () => PluginRegistry;
40
42
  migratePluginData: (
41
43
  handle: PluginHandle,
42
44
  versioned: DataVersioned<unknown>,
43
45
  ) => DataVersioned<unknown> | undefined;
44
- createPluginData: (handle: PluginHandle) => DataVersioned<unknown>;
46
+ createPluginData: (
47
+ handle: PluginHandle,
48
+ transfer?: DataVersioned<unknown>,
49
+ ) => DataVersioned<unknown>;
45
50
  }
46
51
 
47
52
  /** Dependencies for initial storage creation */
package/src/env_value.ts CHANGED
@@ -1,5 +1,3 @@
1
- import {} from "./global";
2
-
3
1
  export function getEnvironmentValue(name: string): string | undefined {
4
2
  if (typeof globalThis.getEnvironmentValue !== "function") return undefined;
5
3
  else return globalThis.getEnvironmentValue(name);
package/src/index.ts CHANGED
@@ -25,18 +25,19 @@ export {
25
25
  export * from "./block_storage_facade";
26
26
  export * from "./block_model_legacy";
27
27
  export { BlockModelV3 } from "./block_model";
28
- export type { PluginInstance, ParamsInput } from "./block_model";
28
+ export type { PluginRecord, ParamsInput } from "./block_model";
29
+ export { DataModel, DataModelBuilder } from "./block_migrations";
29
30
  export {
30
- DataModel,
31
- DataModelBuilder,
32
- DataMigrationError,
33
- DataUnrecoverableError,
34
- isDataUnrecoverableError,
35
- defaultRecover,
36
- makeDataVersioned,
37
- } from "./block_migrations";
38
- export type { LegacyV1State } from "./block_migrations";
39
- export * from "./plugin_model";
31
+ type PluginData,
32
+ type PluginParams,
33
+ type PluginOutputs,
34
+ type PluginConfig,
35
+ PluginDataModel,
36
+ PluginDataModelBuilder,
37
+ PluginInstance,
38
+ PluginModel,
39
+ type PluginFactory,
40
+ } from "./plugin_model";
40
41
  export * from "./bconfig";
41
42
  export * from "./components";
42
43
  export * from "./config";
package/src/internal.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { OutputWithStatus } from "@milaboratories/pl-model-common";
2
- import {} from "./global";
3
2
  import type { Platforma, PlatformaApiVersion } from "./platforma";
4
3
  import type { FutureHandle, GlobalCfgRenderCtx } from "./render/internal";
5
4
  import type { ConfigRenderLambda, ConfigRenderLambdaFlags } from "./bconfig";
package/src/platforma.ts CHANGED
@@ -9,7 +9,7 @@ import type {
9
9
  } from "@milaboratories/pl-model-common";
10
10
  import type { SdkInfo } from "./version";
11
11
  import type { BlockStatePatch } from "./block_state_patch";
12
- import type { PluginInstance } from "./block_model";
12
+ import type { PluginRecord } from "./block_model";
13
13
  import type { PluginHandle, PluginFactoryLike } from "./plugin_handle";
14
14
 
15
15
  /** Defines all methods to interact with the platform environment from within a block UI. @deprecated */
@@ -134,7 +134,7 @@ export type InferPluginNames<Pl> =
134
134
  export type InferPluginData<Pl, PluginId extends string> =
135
135
  Pl extends PlatformaV3<unknown, unknown, BlockOutputsBase, `/${string}`, infer P>
136
136
  ? PluginId extends keyof P
137
- ? P[PluginId] extends PluginInstance<infer D, any, any>
137
+ ? P[PluginId] extends PluginRecord<infer D, any, any>
138
138
  ? D
139
139
  : never
140
140
  : never
@@ -143,10 +143,10 @@ export type InferPluginData<Pl, PluginId extends string> =
143
143
  /**
144
144
  * Map each plugin instance to a type-safe opaque handle branded with normalized phantom.
145
145
  * Uses the same brand structure as InferPluginHandle — only data/params/outputs, no config —
146
- * because PluginInstance doesn't carry Config (it's lost after factory.create()).
146
+ * because PluginRecord doesn't carry Config (lost after factory.create()).
147
147
  */
148
148
  export type InferPluginHandles<T extends Record<string, unknown>> = {
149
- readonly [K in keyof T]: T[K] extends PluginInstance<infer Data, infer Params, infer Outputs>
149
+ readonly [K in keyof T]: T[K] extends PluginRecord<infer Data, infer Params, infer Outputs>
150
150
  ? PluginHandle<PluginFactoryLike<Data, Params, Outputs>>
151
151
  : never;
152
152
  };
@@ -13,7 +13,7 @@ import type { Branded } from "@milaboratories/helpers";
13
13
  /**
14
14
  * Phantom-only base type for constraining PluginHandle's type parameter.
15
15
  *
16
- * PluginFactory has create() → PluginModel with function properties, making it invariant
16
+ * PluginFactory has create() → PluginInstance with function properties, making it invariant
17
17
  * under strictFunctionTypes. PluginFactoryLike exposes only the covariant `__types` phantom,
18
18
  * avoiding the contravariance chain. Handles only need `__types` for type extraction.
19
19
  *
@@ -1,14 +1,15 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { PluginModel } from "./plugin_model";
2
+ import {
3
+ PluginModel,
4
+ PluginDataModelBuilder,
5
+ PluginInstance,
6
+ CREATE_PLUGIN_MODEL,
7
+ } from "./plugin_model";
3
8
  import type { PluginRenderCtx } from "./plugin_model";
4
9
  import { DataModelBuilder } from "./block_migrations";
5
- import { type PluginName } from "./block_storage";
10
+ import { type PluginName, DATA_MODEL_LEGACY_VERSION } from "./block_storage";
6
11
  import type { ResultPool } from "./render";
7
12
 
8
- // =============================================================================
9
- // Test Fixtures
10
- // =============================================================================
11
-
12
13
  type Data = { count: number; label: string };
13
14
 
14
15
  const dataModelChain = new DataModelBuilder().from<Data>("v1");
@@ -16,10 +17,6 @@ const dataModelChain = new DataModelBuilder().from<Data>("v1");
16
17
  // Mock ResultPool for testing
17
18
  const mockResultPool = {} as ResultPool;
18
19
 
19
- // =============================================================================
20
- // Tests
21
- // =============================================================================
22
-
23
20
  describe("PluginModel", () => {
24
21
  it("creates PluginModel with required fields", () => {
25
22
  const factory = PluginModel.define<Data>({
@@ -27,7 +24,8 @@ describe("PluginModel", () => {
27
24
  data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
28
25
  }).build();
29
26
 
30
- const plugin = factory.create();
27
+ const instance = factory.create({ pluginId: "test" });
28
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
31
29
  expect(plugin.name).toBe("testPlugin");
32
30
  expect(plugin.outputs).toEqual({});
33
31
  });
@@ -40,7 +38,8 @@ describe("PluginModel", () => {
40
38
  data: (cfg) => dataModelChain.init(() => ({ count: cfg.initialCount, label: "initialized" })),
41
39
  }).build();
42
40
 
43
- const plugin = factory.create({ initialCount: 100 });
41
+ const instance = factory.create({ pluginId: "inst1", config: { initialCount: 100 } });
42
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
44
43
  expect(plugin.name).toBe("factoryPlugin");
45
44
  expect(plugin.dataModel.initialData()).toEqual({ count: 100, label: "initialized" });
46
45
  });
@@ -53,7 +52,8 @@ describe("PluginModel", () => {
53
52
  .output("doubled", (ctx) => ctx.data.count * ctx.params.multiplier)
54
53
  .build();
55
54
 
56
- const plugin = factory.create();
55
+ const instance = factory.create({ pluginId: "inst1" });
56
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
57
57
  expect(Object.keys(plugin.outputs)).toEqual(["doubled"]);
58
58
  });
59
59
 
@@ -67,7 +67,8 @@ describe("PluginModel", () => {
67
67
  .output("isReady", (ctx) => ctx.data.count > 0)
68
68
  .build();
69
69
 
70
- const plugin = factory.create();
70
+ const instance = factory.create({ pluginId: "inst1" });
71
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
71
72
  expect(Object.keys(plugin.outputs).sort()).toEqual(["formattedCount", "isReady", "upperLabel"]);
72
73
  });
73
74
 
@@ -79,7 +80,8 @@ describe("PluginModel", () => {
79
80
  .output("computed", (ctx) => ctx.data.count * ctx.params.factor)
80
81
  .build();
81
82
 
82
- const plugin = factory.create();
83
+ const instance = factory.create({ pluginId: "inst1" });
84
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
83
85
 
84
86
  const ctx: PluginRenderCtx<Data, { factor: number }> = {
85
87
  data: { count: 5, label: "" },
@@ -99,7 +101,8 @@ describe("PluginModel", () => {
99
101
  .output("hasResultPool", (ctx) => ctx.resultPool !== undefined)
100
102
  .build();
101
103
 
102
- const plugin = factory.create();
104
+ const instance = factory.create({ pluginId: "inst1" });
105
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
103
106
 
104
107
  const ctx: PluginRenderCtx<Data> = {
105
108
  data: { count: 0, label: "" },
@@ -119,7 +122,8 @@ describe("PluginModel", () => {
119
122
  .output("hasSelection", (ctx) => ctx.data.count >= 0)
120
123
  .build();
121
124
 
122
- const plugin = factory.create({ option: true });
125
+ const instance = factory.create({ pluginId: "inst1", config: { option: true } });
126
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
123
127
  expect(plugin.name).toBe("completePlugin");
124
128
  expect(Object.keys(plugin.outputs).sort()).toEqual(["currentItem", "hasSelection"]);
125
129
  });
@@ -130,7 +134,8 @@ describe("PluginModel", () => {
130
134
  data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
131
135
  }).build();
132
136
 
133
- const plugin = factory.create();
137
+ const instance = factory.create({ pluginId: "inst1" });
138
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
134
139
  expect(plugin.outputs).toEqual({});
135
140
  });
136
141
 
@@ -143,7 +148,11 @@ describe("PluginModel", () => {
143
148
  dataModelChain.init(() => ({ count: cfg.defaultCount, label: cfg.defaultLabel })),
144
149
  }).build();
145
150
 
146
- const plugin = factory.create({ defaultCount: 10, defaultLabel: "default" });
151
+ const instance = factory.create({
152
+ pluginId: "inst1",
153
+ config: { defaultCount: 10, defaultLabel: "default" },
154
+ });
155
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
147
156
  expect(plugin.dataModel.initialData()).toEqual({ count: 10, label: "default" });
148
157
  });
149
158
 
@@ -159,10 +168,197 @@ describe("PluginModel", () => {
159
168
  const factory1 = pluginWithOutput1.build();
160
169
  const factory2 = pluginWithOutput2.build();
161
170
 
162
- const plugin1 = factory1.create(undefined);
163
- const plugin2 = factory2.create(undefined);
171
+ const plugin1 = factory1.create({ pluginId: "p1" })[CREATE_PLUGIN_MODEL]();
172
+ const plugin2 = factory2.create({ pluginId: "p2" })[CREATE_PLUGIN_MODEL]();
164
173
 
165
174
  expect(Object.keys(plugin1.outputs)).toEqual(["first"]);
166
175
  expect(Object.keys(plugin2.outputs)).toEqual(["second"]);
167
176
  });
168
177
  });
178
+
179
+ describe("PluginDataModel", () => {
180
+ it("creates default data via new PluginDataModelBuilder().from().init()", () => {
181
+ type PData = { items: string[] };
182
+ const pdm = new PluginDataModelBuilder().from<PData>("v1").init(() => ({ items: [] }));
183
+
184
+ const defaultData = pdm.getDefaultData();
185
+ expect(defaultData.version).toBe("v1");
186
+ expect(defaultData.data).toStrictEqual({ items: [] });
187
+ });
188
+
189
+ it("getDefaultData passes config to init function", () => {
190
+ type PData = { items: string[]; count: number };
191
+ type PConfig = { defaultCount: number };
192
+
193
+ const pdm = new PluginDataModelBuilder().from<PData>("v1").init<PConfig>((config?) => ({
194
+ items: [],
195
+ count: config?.defaultCount ?? 0,
196
+ }));
197
+
198
+ // Without config
199
+ const noConfig = pdm.getDefaultData();
200
+ expect(noConfig.data).toStrictEqual({ items: [], count: 0 });
201
+
202
+ // With config
203
+ const withConfig = pdm.getDefaultData({ defaultCount: 42 });
204
+ expect(withConfig.data).toStrictEqual({ items: [], count: 42 });
205
+ });
206
+
207
+ it("supports .recover() in the chain", () => {
208
+ type V1 = { value: number };
209
+ type V2 = { value: number; label: string };
210
+
211
+ const pdm = new PluginDataModelBuilder()
212
+ .from<V1>("v1")
213
+ .recover((version, data) => {
214
+ if (version === "legacy") return { value: (data as any).val || 0 };
215
+ throw new Error(`Unknown version: ${version}`);
216
+ })
217
+ .migrate<V2>("v2", (v1) => ({ ...v1, label: "recovered" }))
218
+ .init(() => ({ value: 0, label: "" }));
219
+
220
+ // Recovery path — test via inner dataModel
221
+ const result = pdm.dataModel.migrate({ version: "legacy", data: { val: 99 } });
222
+ expect(result.version).toBe("v2");
223
+ expect(result.data).toStrictEqual({ value: 99, label: "recovered" });
224
+ });
225
+
226
+ it("getDefaultData uses config from PluginDataModel path", () => {
227
+ type PData = { value: number };
228
+ type PConfig = { defaultValue: number };
229
+
230
+ const pdm = new PluginDataModelBuilder()
231
+ .from<PData>("v1")
232
+ .init<PConfig>((config?) => ({ value: config?.defaultValue ?? 0 }));
233
+
234
+ const factory = PluginModel.define({
235
+ name: "pdmTest" as PluginName,
236
+ data: pdm,
237
+ }).build();
238
+
239
+ const plugin = factory
240
+ .create({ pluginId: "inst1", config: { defaultValue: 42 } })
241
+ [CREATE_PLUGIN_MODEL]();
242
+ expect(plugin.getDefaultData().data).toStrictEqual({ value: 42 });
243
+ });
244
+
245
+ it("getDefaultData works for function-based data", () => {
246
+ const factory = PluginModel.define<Data>({
247
+ name: "fnTest" as PluginName,
248
+ data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
249
+ }).build();
250
+
251
+ const plugin = factory.create({ pluginId: "inst1" })[CREATE_PLUGIN_MODEL]();
252
+ expect(plugin.getDefaultData().data).toStrictEqual({ count: 0, label: "" });
253
+ });
254
+
255
+ it("upgradeLegacy allows migrating from DATA_MODEL_LEGACY_VERSION", () => {
256
+ type V1 = { value: number };
257
+ type V2 = { value: number; extra: string };
258
+
259
+ const pdm = new PluginDataModelBuilder()
260
+ .from<V1>("v1")
261
+ .upgradeLegacy((data) => ({ value: (data as any).oldValue ?? 0 }))
262
+ .migrate<V2>("v2", (v1) => ({ ...v1, extra: "added" }))
263
+ .init(() => ({ value: 0, extra: "" }));
264
+
265
+ // Legacy path: data arrives with DATA_MODEL_LEGACY_VERSION
266
+ const result = pdm.dataModel.migrate({
267
+ version: DATA_MODEL_LEGACY_VERSION,
268
+ data: { oldValue: 42 },
269
+ });
270
+ expect(result.version).toBe("v2");
271
+ expect(result.data).toStrictEqual({ value: 42, extra: "added" });
272
+ });
273
+
274
+ it("upgradeLegacy is not needed for normal version migration", () => {
275
+ type V1 = { value: number };
276
+ type V2 = { value: number; extra: string };
277
+
278
+ const pdm = new PluginDataModelBuilder()
279
+ .from<V1>("v1")
280
+ .upgradeLegacy((data) => ({ value: (data as any).oldValue ?? 0 }))
281
+ .migrate<V2>("v2", (v1) => ({ ...v1, extra: "added" }))
282
+ .init(() => ({ value: 0, extra: "" }));
283
+
284
+ // Normal migration: v1 → v2
285
+ const result = pdm.dataModel.migrate({
286
+ version: "v1",
287
+ data: { value: 10 },
288
+ });
289
+ expect(result.version).toBe("v2");
290
+ expect(result.data).toStrictEqual({ value: 10, extra: "added" });
291
+ });
292
+ });
293
+
294
+ describe("PluginInstance", () => {
295
+ it("factory.create() returns a PluginInstance with correct id", () => {
296
+ const factory = PluginModel.define<Data>({
297
+ name: "instanceTest" as PluginName,
298
+ data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
299
+ }).build();
300
+
301
+ const instance = factory.create({ pluginId: "myTable" });
302
+ expect(instance).toBeInstanceOf(PluginInstance);
303
+ expect(instance.id).toBe("myTable");
304
+ });
305
+
306
+ it("PluginInstance[CREATE_PLUGIN_MODEL]() delegates to factory", () => {
307
+ type Config = { initial: number };
308
+ const factory = PluginModel.define<Data, undefined, Config>({
309
+ name: "delegateTest" as PluginName,
310
+ data: (cfg) => dataModelChain.init(() => ({ count: cfg.initial, label: "" })),
311
+ }).build();
312
+
313
+ const instance = factory.create({ pluginId: "inst1", config: { initial: 42 } });
314
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
315
+ expect(plugin.name).toBe("delegateTest");
316
+ expect(plugin.dataModel.initialData()).toStrictEqual({ count: 42, label: "" });
317
+ });
318
+
319
+ it("PluginInstance without transferAt has empty transferVersion", () => {
320
+ const factory = PluginModel.define<Data>({
321
+ name: "noTransfer" as PluginName,
322
+ data: () => dataModelChain.init(() => ({ count: 0, label: "" })),
323
+ }).build();
324
+
325
+ const instance = factory.create({ pluginId: "inst1" });
326
+ expect(instance.transferVersion).toBe("");
327
+ });
328
+
329
+ it("PluginInstance with transferAt has correct transferVersion", () => {
330
+ type V1 = { value: number };
331
+ type V2 = { value: number; label: string };
332
+ const pdm = new PluginDataModelBuilder()
333
+ .from<V1>("v1")
334
+ .migrate<V2>("v2", (v1) => ({ ...v1, label: "" }))
335
+ .init(() => ({ value: 0, label: "" }));
336
+
337
+ const factory = PluginModel.define({
338
+ name: "withTransfer" as PluginName,
339
+ data: pdm,
340
+ }).build();
341
+
342
+ const instance = factory.create({ pluginId: "inst1", transferAt: "v1" });
343
+ expect(instance.transferVersion).toBe("v1");
344
+ });
345
+
346
+ it("config is captured in getDefaultData closure", () => {
347
+ type PData = { items: string[]; count: number };
348
+ type PConfig = { defaultCount: number };
349
+
350
+ const pdm = new PluginDataModelBuilder().from<PData>("v1").init<PConfig>((config?) => ({
351
+ items: [],
352
+ count: config?.defaultCount ?? 0,
353
+ }));
354
+
355
+ const factory = PluginModel.define({
356
+ name: "configStore" as PluginName,
357
+ data: pdm,
358
+ }).build();
359
+
360
+ const instance = factory.create({ pluginId: "inst1", config: { defaultCount: 99 } });
361
+ const plugin = instance[CREATE_PLUGIN_MODEL]();
362
+ expect(plugin.getDefaultData().data).toStrictEqual({ items: [], count: 99 });
363
+ });
364
+ });