@platforma-sdk/model 1.53.11 → 1.53.13

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 (288) hide show
  1. package/dist/annotations/converter.cjs +11 -11
  2. package/dist/annotations/converter.cjs.map +1 -1
  3. package/dist/annotations/converter.d.ts +1 -1
  4. package/dist/annotations/converter.d.ts.map +1 -1
  5. package/dist/annotations/converter.js +11 -11
  6. package/dist/annotations/converter.js.map +1 -1
  7. package/dist/annotations/index.d.ts +2 -2
  8. package/dist/annotations/types.d.ts +4 -4
  9. package/dist/bconfig/index.d.ts +5 -5
  10. package/dist/bconfig/lambdas.d.ts +7 -7
  11. package/dist/bconfig/lambdas.d.ts.map +1 -1
  12. package/dist/bconfig/normalization.cjs.map +1 -1
  13. package/dist/bconfig/normalization.d.ts +3 -3
  14. package/dist/bconfig/normalization.js.map +1 -1
  15. package/dist/bconfig/types.cjs.map +1 -1
  16. package/dist/bconfig/types.d.ts +2 -2
  17. package/dist/bconfig/types.d.ts.map +1 -1
  18. package/dist/bconfig/types.js.map +1 -1
  19. package/dist/bconfig/util.d.ts +4 -4
  20. package/dist/bconfig/v3.d.ts +3 -3
  21. package/dist/block_api_v1.d.ts +2 -2
  22. package/dist/block_api_v1.d.ts.map +1 -1
  23. package/dist/block_api_v2.d.ts +2 -2
  24. package/dist/block_api_v2.d.ts.map +1 -1
  25. package/dist/block_api_v3.d.ts +3 -3
  26. package/dist/block_migrations.cjs +10 -10
  27. package/dist/block_migrations.cjs.map +1 -1
  28. package/dist/block_migrations.d.ts.map +1 -1
  29. package/dist/block_migrations.js +10 -10
  30. package/dist/block_migrations.js.map +1 -1
  31. package/dist/block_model.cjs +11 -11
  32. package/dist/block_model.cjs.map +1 -1
  33. package/dist/block_model.d.ts +8 -8
  34. package/dist/block_model.d.ts.map +1 -1
  35. package/dist/block_model.js +11 -11
  36. package/dist/block_model.js.map +1 -1
  37. package/dist/block_state_patch.d.ts +2 -2
  38. package/dist/block_state_util.cjs +1 -1
  39. package/dist/block_state_util.cjs.map +1 -1
  40. package/dist/block_state_util.d.ts +3 -3
  41. package/dist/block_state_util.js +1 -1
  42. package/dist/block_state_util.js.map +1 -1
  43. package/dist/block_storage.cjs +10 -10
  44. package/dist/block_storage.cjs.map +1 -1
  45. package/dist/block_storage.d.ts +2 -2
  46. package/dist/block_storage.d.ts.map +1 -1
  47. package/dist/block_storage.js +10 -10
  48. package/dist/block_storage.js.map +1 -1
  49. package/dist/block_storage_vm.cjs +22 -22
  50. package/dist/block_storage_vm.cjs.map +1 -1
  51. package/dist/block_storage_vm.d.ts +1 -1
  52. package/dist/block_storage_vm.d.ts.map +1 -1
  53. package/dist/block_storage_vm.js +22 -22
  54. package/dist/block_storage_vm.js.map +1 -1
  55. package/dist/builder.cjs +32 -23
  56. package/dist/builder.cjs.map +1 -1
  57. package/dist/builder.d.ts +7 -7
  58. package/dist/builder.d.ts.map +1 -1
  59. package/dist/builder.js +32 -23
  60. package/dist/builder.js.map +1 -1
  61. package/dist/components/PFrameForGraphs.cjs +7 -6
  62. package/dist/components/PFrameForGraphs.cjs.map +1 -1
  63. package/dist/components/PFrameForGraphs.d.ts +4 -4
  64. package/dist/components/PFrameForGraphs.d.ts.map +1 -1
  65. package/dist/components/PFrameForGraphs.js +7 -6
  66. package/dist/components/PFrameForGraphs.js.map +1 -1
  67. package/dist/components/PlAnnotations/filter.d.ts +14 -14
  68. package/dist/components/PlAnnotations/filter.d.ts.map +1 -1
  69. package/dist/components/PlAnnotations/filters_ui.cjs +46 -46
  70. package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
  71. package/dist/components/PlAnnotations/filters_ui.d.ts +10 -34
  72. package/dist/components/PlAnnotations/filters_ui.d.ts.map +1 -1
  73. package/dist/components/PlAnnotations/filters_ui.js +46 -46
  74. package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
  75. package/dist/components/PlAnnotations/index.d.ts +2 -2
  76. package/dist/components/PlAnnotations/types.d.ts +2 -2
  77. package/dist/components/PlDataTable.cjs +19 -20
  78. package/dist/components/PlDataTable.cjs.map +1 -1
  79. package/dist/components/PlDataTable.d.ts +27 -27
  80. package/dist/components/PlDataTable.d.ts.map +1 -1
  81. package/dist/components/PlDataTable.js +19 -20
  82. package/dist/components/PlDataTable.js.map +1 -1
  83. package/dist/components/PlMultiSequenceAlignment.cjs +2 -2
  84. package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
  85. package/dist/components/PlMultiSequenceAlignment.d.ts +6 -6
  86. package/dist/components/PlMultiSequenceAlignment.d.ts.map +1 -1
  87. package/dist/components/PlMultiSequenceAlignment.js +2 -2
  88. package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
  89. package/dist/components/PlSelectionModel.cjs.map +1 -1
  90. package/dist/components/PlSelectionModel.d.ts +1 -1
  91. package/dist/components/PlSelectionModel.js.map +1 -1
  92. package/dist/components/index.d.ts +5 -5
  93. package/dist/config/actions.cjs +39 -39
  94. package/dist/config/actions.cjs.map +1 -1
  95. package/dist/config/actions.d.ts +9 -9
  96. package/dist/config/actions.d.ts.map +1 -1
  97. package/dist/config/actions.js +39 -39
  98. package/dist/config/actions.js.map +1 -1
  99. package/dist/config/actions_kinds.d.ts +30 -30
  100. package/dist/config/actions_kinds.d.ts.map +1 -1
  101. package/dist/config/index.d.ts +6 -6
  102. package/dist/config/model.d.ts +28 -28
  103. package/dist/config/model_meta.d.ts +1 -1
  104. package/dist/config/type_engine.d.ts +3 -3
  105. package/dist/config/type_util.d.ts +2 -2
  106. package/dist/env_value.cjs +1 -1
  107. package/dist/env_value.cjs.map +1 -1
  108. package/dist/env_value.js +1 -1
  109. package/dist/env_value.js.map +1 -1
  110. package/dist/filters/converter.cjs +36 -32
  111. package/dist/filters/converter.cjs.map +1 -1
  112. package/dist/filters/converter.d.ts +2 -2
  113. package/dist/filters/converter.d.ts.map +1 -1
  114. package/dist/filters/converter.js +36 -32
  115. package/dist/filters/converter.js.map +1 -1
  116. package/dist/filters/index.d.ts +2 -2
  117. package/dist/filters/types.d.ts +33 -33
  118. package/dist/filters/types.d.ts.map +1 -1
  119. package/dist/index.d.ts +24 -24
  120. package/dist/internal.cjs +7 -7
  121. package/dist/internal.cjs.map +1 -1
  122. package/dist/internal.d.ts +4 -4
  123. package/dist/internal.d.ts.map +1 -1
  124. package/dist/internal.js +7 -7
  125. package/dist/internal.js.map +1 -1
  126. package/dist/package.json.cjs +1 -1
  127. package/dist/package.json.js +1 -1
  128. package/dist/pframe.cjs +1 -1
  129. package/dist/pframe.cjs.map +1 -1
  130. package/dist/pframe.d.ts +1 -1
  131. package/dist/pframe.js +1 -1
  132. package/dist/pframe.js.map +1 -1
  133. package/dist/pframe_utils/columns.cjs +23 -15
  134. package/dist/pframe_utils/columns.cjs.map +1 -1
  135. package/dist/pframe_utils/columns.d.ts +3 -3
  136. package/dist/pframe_utils/columns.d.ts.map +1 -1
  137. package/dist/pframe_utils/columns.js +23 -15
  138. package/dist/pframe_utils/columns.js.map +1 -1
  139. package/dist/pframe_utils/index.cjs +25 -25
  140. package/dist/pframe_utils/index.cjs.map +1 -1
  141. package/dist/pframe_utils/index.d.ts +3 -3
  142. package/dist/pframe_utils/index.d.ts.map +1 -1
  143. package/dist/pframe_utils/index.js +25 -25
  144. package/dist/pframe_utils/index.js.map +1 -1
  145. package/dist/platforma.d.ts +7 -7
  146. package/dist/platforma.d.ts.map +1 -1
  147. package/dist/raw_globals.cjs +4 -1
  148. package/dist/raw_globals.cjs.map +1 -1
  149. package/dist/raw_globals.d.ts +2 -2
  150. package/dist/raw_globals.d.ts.map +1 -1
  151. package/dist/raw_globals.js +4 -1
  152. package/dist/raw_globals.js.map +1 -1
  153. package/dist/ref_util.cjs +4 -4
  154. package/dist/ref_util.cjs.map +1 -1
  155. package/dist/ref_util.d.ts +1 -1
  156. package/dist/ref_util.js +4 -4
  157. package/dist/ref_util.js.map +1 -1
  158. package/dist/render/accessor.cjs +24 -24
  159. package/dist/render/accessor.cjs.map +1 -1
  160. package/dist/render/accessor.d.ts +10 -10
  161. package/dist/render/accessor.d.ts.map +1 -1
  162. package/dist/render/accessor.js +24 -24
  163. package/dist/render/accessor.js.map +1 -1
  164. package/dist/render/api.cjs +23 -23
  165. package/dist/render/api.cjs.map +1 -1
  166. package/dist/render/api.d.ts +11 -11
  167. package/dist/render/api.d.ts.map +1 -1
  168. package/dist/render/api.js +23 -23
  169. package/dist/render/api.js.map +1 -1
  170. package/dist/render/future.cjs.map +1 -1
  171. package/dist/render/future.d.ts +1 -1
  172. package/dist/render/future.js.map +1 -1
  173. package/dist/render/index.d.ts +6 -6
  174. package/dist/render/internal.cjs +4 -4
  175. package/dist/render/internal.cjs.map +1 -1
  176. package/dist/render/internal.d.ts +7 -7
  177. package/dist/render/internal.d.ts.map +1 -1
  178. package/dist/render/internal.js +4 -4
  179. package/dist/render/internal.js.map +1 -1
  180. package/dist/render/traversal_ops.d.ts +1 -1
  181. package/dist/render/util/axis_filtering.cjs +48 -44
  182. package/dist/render/util/axis_filtering.cjs.map +1 -1
  183. package/dist/render/util/axis_filtering.d.ts +2 -2
  184. package/dist/render/util/axis_filtering.js +48 -44
  185. package/dist/render/util/axis_filtering.js.map +1 -1
  186. package/dist/render/util/column_collection.cjs +42 -35
  187. package/dist/render/util/column_collection.cjs.map +1 -1
  188. package/dist/render/util/column_collection.d.ts +4 -4
  189. package/dist/render/util/column_collection.d.ts.map +1 -1
  190. package/dist/render/util/column_collection.js +42 -35
  191. package/dist/render/util/column_collection.js.map +1 -1
  192. package/dist/render/util/index.d.ts +4 -4
  193. package/dist/render/util/label.cjs +15 -21
  194. package/dist/render/util/label.cjs.map +1 -1
  195. package/dist/render/util/label.d.ts +2 -2
  196. package/dist/render/util/label.d.ts.map +1 -1
  197. package/dist/render/util/label.js +15 -21
  198. package/dist/render/util/label.js.map +1 -1
  199. package/dist/render/util/pcolumn_data.cjs +56 -54
  200. package/dist/render/util/pcolumn_data.cjs.map +1 -1
  201. package/dist/render/util/pcolumn_data.d.ts +5 -5
  202. package/dist/render/util/pcolumn_data.d.ts.map +1 -1
  203. package/dist/render/util/pcolumn_data.js +56 -54
  204. package/dist/render/util/pcolumn_data.js.map +1 -1
  205. package/dist/render/util/pframe_upgraders.cjs +6 -6
  206. package/dist/render/util/pframe_upgraders.cjs.map +1 -1
  207. package/dist/render/util/pframe_upgraders.d.ts +1 -1
  208. package/dist/render/util/pframe_upgraders.d.ts.map +1 -1
  209. package/dist/render/util/pframe_upgraders.js +6 -6
  210. package/dist/render/util/pframe_upgraders.js.map +1 -1
  211. package/dist/render/util/split_selectors.d.ts +1 -1
  212. package/dist/render/util/split_selectors.d.ts.map +1 -1
  213. package/dist/sdk_info.cjs.map +1 -1
  214. package/dist/sdk_info.js.map +1 -1
  215. package/dist/version.cjs.map +1 -1
  216. package/dist/version.js.map +1 -1
  217. package/package.json +24 -22
  218. package/src/annotations/converter.test.ts +98 -101
  219. package/src/annotations/converter.ts +21 -17
  220. package/src/annotations/index.ts +2 -2
  221. package/src/annotations/types.ts +4 -4
  222. package/src/bconfig/index.ts +5 -5
  223. package/src/bconfig/lambdas.ts +10 -12
  224. package/src/bconfig/normalization.ts +5 -5
  225. package/src/bconfig/types.ts +3 -5
  226. package/src/bconfig/util.ts +3 -3
  227. package/src/bconfig/v3.ts +3 -3
  228. package/src/block_api_v1.ts +7 -3
  229. package/src/block_api_v2.ts +7 -3
  230. package/src/block_api_v3.ts +3 -3
  231. package/src/block_migrations.test.ts +66 -67
  232. package/src/block_migrations.ts +16 -16
  233. package/src/block_model.ts +76 -140
  234. package/src/block_state_patch.ts +2 -2
  235. package/src/block_state_util.ts +4 -4
  236. package/src/block_storage.test.ts +106 -99
  237. package/src/block_storage.ts +22 -25
  238. package/src/block_storage_vm.ts +41 -35
  239. package/src/builder.ts +107 -95
  240. package/src/components/PFrameForGraphs.test.ts +261 -255
  241. package/src/components/PFrameForGraphs.ts +35 -22
  242. package/src/components/PlAnnotations/filter.ts +21 -15
  243. package/src/components/PlAnnotations/filters_ui.test.ts +230 -73
  244. package/src/components/PlAnnotations/filters_ui.ts +138 -105
  245. package/src/components/PlAnnotations/index.ts +2 -2
  246. package/src/components/PlAnnotations/types.ts +2 -2
  247. package/src/components/PlDataTable.ts +177 -164
  248. package/src/components/PlMultiSequenceAlignment.ts +11 -18
  249. package/src/components/PlSelectionModel.ts +1 -1
  250. package/src/components/index.ts +5 -5
  251. package/src/config/actions.ts +64 -59
  252. package/src/config/actions_kinds.ts +38 -34
  253. package/src/config/index.ts +6 -6
  254. package/src/config/model.ts +28 -28
  255. package/src/config/model_meta.ts +1 -1
  256. package/src/config/type_engine.ts +3 -3
  257. package/src/config/type_util.ts +2 -2
  258. package/src/env_value.ts +2 -2
  259. package/src/filters/converter.test.ts +185 -144
  260. package/src/filters/converter.ts +47 -35
  261. package/src/filters/index.ts +2 -2
  262. package/src/filters/types.ts +44 -39
  263. package/src/global.d.ts +1 -1
  264. package/src/index.ts +24 -24
  265. package/src/internal.ts +27 -17
  266. package/src/pframe.ts +3 -3
  267. package/src/pframe_utils/columns.ts +81 -31
  268. package/src/pframe_utils/index.ts +65 -43
  269. package/src/platforma.ts +44 -21
  270. package/src/raw_globals.ts +13 -7
  271. package/src/ref_util.ts +6 -6
  272. package/src/render/accessor.ts +43 -44
  273. package/src/render/api.ts +102 -78
  274. package/src/render/future.ts +2 -2
  275. package/src/render/index.ts +6 -6
  276. package/src/render/internal.ts +11 -12
  277. package/src/render/traversal_ops.ts +1 -1
  278. package/src/render/util/axis_filtering.ts +67 -52
  279. package/src/render/util/column_collection.ts +171 -91
  280. package/src/render/util/index.ts +4 -4
  281. package/src/render/util/label.test.ts +139 -139
  282. package/src/render/util/label.ts +42 -33
  283. package/src/render/util/pcolumn_data.ts +111 -75
  284. package/src/render/util/pframe_upgraders.ts +24 -13
  285. package/src/render/util/split_selectors.ts +6 -1
  286. package/src/sdk_info.ts +1 -1
  287. package/src/typing.test.ts +56 -56
  288. package/src/version.ts +1 -1
@@ -32,9 +32,9 @@ import {
32
32
  isBlockStorage,
33
33
  normalizeBlockStorage,
34
34
  updateStorageData,
35
- } from './block_storage';
36
- import { stringifyJson, type StringifiedJson } from '@milaboratories/pl-model-common';
37
- import { tryGetCfgRenderCtx, tryRegisterCallback } from './internal';
35
+ } from "./block_storage";
36
+ import { stringifyJson, type StringifiedJson } from "@milaboratories/pl-model-common";
37
+ import { tryGetCfgRenderCtx, tryRegisterCallback } from "./internal";
38
38
 
39
39
  /**
40
40
  * Result of storage normalization
@@ -65,7 +65,7 @@ function normalizeStorage(rawStorage: unknown): NormalizeStorageResult {
65
65
 
66
66
  // Parse JSON string if needed
67
67
  let parsed = rawStorage;
68
- if (typeof rawStorage === 'string') {
68
+ if (typeof rawStorage === "string") {
69
69
  try {
70
70
  parsed = JSON.parse(rawStorage);
71
71
  } catch {
@@ -115,11 +115,11 @@ function applyStorageUpdate(currentStorageJson: string, payload: MutateStoragePa
115
115
  * Legacy format has { args, uiState? } at top level without the BlockStorage discriminator.
116
116
  */
117
117
  function isLegacyModelV1ApiFormat(data: unknown): data is { args?: unknown } {
118
- if (data === null || typeof data !== 'object') return false;
118
+ if (data === null || typeof data !== "object") return false;
119
119
  if (isBlockStorage(data)) return false;
120
120
 
121
121
  const obj = data as Record<string, unknown>;
122
- return 'args' in obj;
122
+ return "args" in obj;
123
123
  }
124
124
 
125
125
  // =============================================================================
@@ -127,9 +127,12 @@ function isLegacyModelV1ApiFormat(data: unknown): data is { args?: unknown } {
127
127
  // =============================================================================
128
128
 
129
129
  // Register apply update callback (requires existing storage)
130
- tryRegisterCallback('__pl_storage_applyUpdate', (currentStorageJson: string, payload: MutateStoragePayload) => {
131
- return applyStorageUpdate(currentStorageJson, payload);
132
- });
130
+ tryRegisterCallback(
131
+ "__pl_storage_applyUpdate",
132
+ (currentStorageJson: string, payload: MutateStoragePayload) => {
133
+ return applyStorageUpdate(currentStorageJson, payload);
134
+ },
135
+ );
133
136
 
134
137
  /**
135
138
  * Gets storage debug view from raw storage data.
@@ -148,7 +151,7 @@ function getStorageDebugView(rawStorage: unknown): StringifiedJson<StorageDebugV
148
151
  }
149
152
 
150
153
  // Register debug view callback
151
- tryRegisterCallback('__pl_storage_debugView', (rawStorage: unknown) => {
154
+ tryRegisterCallback("__pl_storage_debugView", (rawStorage: unknown) => {
152
155
  return getStorageDebugView(rawStorage);
153
156
  });
154
157
 
@@ -189,7 +192,7 @@ function migrateStorage(currentStorageJson: string | undefined): MigrationResult
189
192
  // Get the callback registry context
190
193
  const ctx = tryGetCfgRenderCtx();
191
194
  if (ctx === undefined) {
192
- return { error: 'Not in config rendering context' };
195
+ return { error: "Not in config rendering context" };
193
196
  }
194
197
 
195
198
  // Normalize storage to get current data and version
@@ -206,9 +209,11 @@ function migrateStorage(currentStorageJson: string | undefined): MigrationResult
206
209
  };
207
210
 
208
211
  // Get the migrate callback (registered by DataModel.registerCallbacks())
209
- const migrateCallback = ctx.callbackRegistry['__pl_data_upgrade'] as ((v: { version: string; data: unknown }) => DataMigrationResult) | undefined;
210
- if (typeof migrateCallback !== 'function') {
211
- return { error: '__pl_data_upgrade callback not found (DataModel not registered)' };
212
+ const migrateCallback = ctx.callbackRegistry["__pl_data_upgrade"] as
213
+ | ((v: { version: string; data: unknown }) => DataMigrationResult)
214
+ | undefined;
215
+ if (typeof migrateCallback !== "function") {
216
+ return { error: "__pl_data_upgrade callback not found (DataModel not registered)" };
212
217
  }
213
218
 
214
219
  // Call the migrator's migrate function
@@ -221,11 +226,12 @@ function migrateStorage(currentStorageJson: string | undefined): MigrationResult
221
226
  }
222
227
 
223
228
  // Build info message
224
- const info = result.version === currentVersion
225
- ? `No migration needed (${currentVersion})`
226
- : result.warning
227
- ? `Reset to initial data (${result.version})`
228
- : `Migrated ${currentVersion}→${result.version}`;
229
+ const info =
230
+ result.version === currentVersion
231
+ ? `No migration needed (${currentVersion})`
232
+ : result.warning
233
+ ? `Reset to initial data (${result.version})`
234
+ : `Migrated ${currentVersion}→${result.version}`;
229
235
 
230
236
  return {
231
237
  newStorageJson: createStorageJson(result.data, result.version),
@@ -235,7 +241,7 @@ function migrateStorage(currentStorageJson: string | undefined): MigrationResult
235
241
  }
236
242
 
237
243
  // Register migrate callback
238
- tryRegisterCallback('__pl_storage_migrate', (currentStorageJson: string | undefined) => {
244
+ tryRegisterCallback("__pl_storage_migrate", (currentStorageJson: string | undefined) => {
239
245
  return migrateStorage(currentStorageJson);
240
246
  });
241
247
 
@@ -247,9 +253,7 @@ tryRegisterCallback('__pl_storage_migrate', (currentStorageJson: string | undefi
247
253
  * Result of args derivation from storage.
248
254
  * Returned by __pl_args_derive and __pl_prerunArgs_derive callbacks.
249
255
  */
250
- export type ArgsDeriveResult =
251
- | { error: string }
252
- | { error?: undefined; value: unknown };
256
+ export type ArgsDeriveResult = { error: string } | { error?: undefined; value: unknown };
253
257
 
254
258
  /**
255
259
  * Derives args from storage using the registered 'args' callback.
@@ -261,16 +265,16 @@ export type ArgsDeriveResult =
261
265
  function deriveArgsFromStorage(storageJson: string): ArgsDeriveResult {
262
266
  const ctx = tryGetCfgRenderCtx();
263
267
  if (ctx === undefined) {
264
- return { error: 'Not in config rendering context' };
268
+ return { error: "Not in config rendering context" };
265
269
  }
266
270
 
267
271
  // Extract data from storage
268
272
  const { data } = normalizeStorage(storageJson);
269
273
 
270
274
  // Get the args callback (registered by BlockModelV3.args())
271
- const argsCallback = ctx.callbackRegistry['args'] as ((data: unknown) => unknown) | undefined;
272
- if (typeof argsCallback !== 'function') {
273
- return { error: 'args callback not found' };
275
+ const argsCallback = ctx.callbackRegistry["args"] as ((data: unknown) => unknown) | undefined;
276
+ if (typeof argsCallback !== "function") {
277
+ return { error: "args callback not found" };
274
278
  }
275
279
 
276
280
  // Call the args callback with extracted data
@@ -284,7 +288,7 @@ function deriveArgsFromStorage(storageJson: string): ArgsDeriveResult {
284
288
  }
285
289
 
286
290
  // Register args derivation callback
287
- tryRegisterCallback('__pl_args_derive', (storageJson: string) => {
291
+ tryRegisterCallback("__pl_args_derive", (storageJson: string) => {
288
292
  return deriveArgsFromStorage(storageJson);
289
293
  });
290
294
 
@@ -298,15 +302,17 @@ tryRegisterCallback('__pl_args_derive', (storageJson: string) => {
298
302
  function derivePrerunArgsFromStorage(storageJson: string): ArgsDeriveResult {
299
303
  const ctx = tryGetCfgRenderCtx();
300
304
  if (ctx === undefined) {
301
- return { error: 'Not in config rendering context' };
305
+ return { error: "Not in config rendering context" };
302
306
  }
303
307
 
304
308
  // Extract data from storage
305
309
  const { data } = normalizeStorage(storageJson);
306
310
 
307
311
  // Try prerunArgs callback first
308
- const prerunArgsCallback = ctx.callbackRegistry['prerunArgs'] as ((data: unknown) => unknown) | undefined;
309
- if (typeof prerunArgsCallback === 'function') {
312
+ const prerunArgsCallback = ctx.callbackRegistry["prerunArgs"] as
313
+ | ((data: unknown) => unknown)
314
+ | undefined;
315
+ if (typeof prerunArgsCallback === "function") {
310
316
  try {
311
317
  const result = prerunArgsCallback(data);
312
318
  return { value: result };
@@ -317,9 +323,9 @@ function derivePrerunArgsFromStorage(storageJson: string): ArgsDeriveResult {
317
323
  }
318
324
 
319
325
  // Fall back to args callback
320
- const argsCallback = ctx.callbackRegistry['args'] as ((data: unknown) => unknown) | undefined;
321
- if (typeof argsCallback !== 'function') {
322
- return { error: 'args callback not found (fallback from missing prerunArgs)' };
326
+ const argsCallback = ctx.callbackRegistry["args"] as ((data: unknown) => unknown) | undefined;
327
+ if (typeof argsCallback !== "function") {
328
+ return { error: "args callback not found (fallback from missing prerunArgs)" };
323
329
  }
324
330
 
325
331
  try {
@@ -332,7 +338,7 @@ function derivePrerunArgsFromStorage(storageJson: string): ArgsDeriveResult {
332
338
  }
333
339
 
334
340
  // Register prerunArgs derivation callback
335
- tryRegisterCallback('__pl_prerunArgs_derive', (storageJson: string) => {
341
+ tryRegisterCallback("__pl_prerunArgs_derive", (storageJson: string) => {
336
342
  return derivePrerunArgsFromStorage(storageJson);
337
343
  });
338
344
 
package/src/builder.ts CHANGED
@@ -1,11 +1,18 @@
1
- import type { BlockRenderingMode, BlockSection, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer } from '@milaboratories/pl-model-common';
2
- import type { Checked, ConfigResult, TypedConfig } from './config';
3
- import { getImmediate } from './config';
4
- import { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';
5
- import type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from './platforma';
6
- import type { InferRenderFunctionReturn, RenderFunctionLegacy } from './render';
7
- import { RenderCtxLegacy } from './render';
8
- import { PlatformaSDKVersion } from './version';
1
+ import type {
2
+ BlockRenderingMode,
3
+ BlockSection,
4
+ AnyFunction,
5
+ PlRef,
6
+ BlockCodeKnownFeatureFlags,
7
+ BlockConfigContainer,
8
+ } from "@milaboratories/pl-model-common";
9
+ import type { Checked, ConfigResult, TypedConfig } from "./config";
10
+ import { getImmediate } from "./config";
11
+ import { getPlatformaInstance, isInUI, tryRegisterCallback } from "./internal";
12
+ import type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from "./platforma";
13
+ import type { InferRenderFunctionReturn, RenderFunctionLegacy } from "./render";
14
+ import { RenderCtxLegacy } from "./render";
15
+ import { PlatformaSDKVersion } from "./version";
9
16
  import type {
10
17
  TypedConfigOrConfigLambda,
11
18
  ConfigRenderLambda,
@@ -13,12 +20,9 @@ import type {
13
20
  DeriveHref,
14
21
  ConfigRenderLambdaFlags,
15
22
  InferOutputsFromConfigs,
16
- } from './bconfig';
17
- import {
18
- downgradeCfgOrLambda,
19
- isConfigLambda,
20
- } from './bconfig';
21
- import type { PlatformaExtended } from './platforma';
23
+ } from "./bconfig";
24
+ import { downgradeCfgOrLambda, isConfigLambda } from "./bconfig";
25
+ import type { PlatformaExtended } from "./platforma";
22
26
 
23
27
  type SectionsExpectedType = readonly BlockSection[];
24
28
 
@@ -43,7 +47,7 @@ export class BlockModel<
43
47
  Args,
44
48
  OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,
45
49
  UiState,
46
- Href extends `/${string}` = '/',
50
+ Href extends `/${string}` = "/",
47
51
  > {
48
52
  private constructor(
49
53
  private config: {
@@ -83,7 +87,7 @@ export class BlockModel<
83
87
  * @deprecated use create method without generic parameter
84
88
  */
85
89
  public static create<Args>(): BlockModel<Args, {}, NoOb>;
86
- public static create(renderingMode: BlockRenderingMode = 'Heavy'): BlockModel<NoOb, {}, NoOb> {
90
+ public static create(renderingMode: BlockRenderingMode = "Heavy"): BlockModel<NoOb, {}, NoOb> {
87
91
  return new BlockModel<NoOb, {}, NoOb>({
88
92
  renderingMode,
89
93
  initialUiState: {},
@@ -104,7 +108,7 @@ export class BlockModel<
104
108
  * */
105
109
  public output<const Key extends string, const Cfg extends TypedConfig>(
106
110
  key: Key,
107
- cfg: Cfg
111
+ cfg: Cfg,
108
112
  ): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;
109
113
  /**
110
114
  * Add output cell wrapped with additional status information to the configuration
@@ -117,10 +121,12 @@ export class BlockModel<
117
121
  public output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(
118
122
  key: Key,
119
123
  rf: RF,
120
- flags: ConfigRenderLambdaFlags & { withStatus: true }
124
+ flags: ConfigRenderLambdaFlags & { withStatus: true },
121
125
  ): BlockModel<
122
126
  Args,
123
- OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true } },
127
+ OutputsCfg & {
128
+ [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true };
129
+ },
124
130
  UiState,
125
131
  Href
126
132
  >;
@@ -135,7 +141,7 @@ export class BlockModel<
135
141
  public output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(
136
142
  key: Key,
137
143
  rf: RF,
138
- flags?: ConfigRenderLambdaFlags
144
+ flags?: ConfigRenderLambdaFlags,
139
145
  ): BlockModel<
140
146
  Args,
141
147
  OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },
@@ -147,7 +153,7 @@ export class BlockModel<
147
153
  cfgOrRf: TypedConfig | AnyFunction,
148
154
  flags: ConfigRenderLambdaFlags = {},
149
155
  ): BlockModel<Args, OutputsCfg, UiState, Href> {
150
- if (typeof cfgOrRf === 'function') {
156
+ if (typeof cfgOrRf === "function") {
151
157
  const handle = `output#${key}`;
152
158
  tryRegisterCallback(handle, () => cfgOrRf(new RenderCtxLegacy()));
153
159
  return new BlockModel({
@@ -173,48 +179,48 @@ export class BlockModel<
173
179
  }
174
180
 
175
181
  /** Shortcut for {@link output} with retentive flag set to true. */
176
- public retentiveOutput<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(
177
- key: Key,
178
- rf: RF,
179
- ) {
182
+ public retentiveOutput<
183
+ const Key extends string,
184
+ const RF extends RenderFunctionLegacy<Args, UiState>,
185
+ >(key: Key, rf: RF) {
180
186
  return this.output(key, rf, { retentive: true });
181
187
  }
182
188
 
183
189
  /** Shortcut for {@link output} with withStatus flag set to true. */
184
- public outputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(
185
- key: Key,
186
- rf: RF,
187
- ) {
190
+ public outputWithStatus<
191
+ const Key extends string,
192
+ const RF extends RenderFunctionLegacy<Args, UiState>,
193
+ >(key: Key, rf: RF) {
188
194
  return this.output(key, rf, { withStatus: true });
189
195
  }
190
196
 
191
197
  /** Shortcut for {@link output} with retentive and withStatus flags set to true. */
192
- public retentiveOutputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(
193
- key: Key,
194
- rf: RF,
195
- ) {
198
+ public retentiveOutputWithStatus<
199
+ const Key extends string,
200
+ const RF extends RenderFunctionLegacy<Args, UiState>,
201
+ >(key: Key, rf: RF) {
196
202
  return this.output(key, rf, { retentive: true, withStatus: true });
197
203
  }
198
204
 
199
205
  /** Sets custom configuration predicate on the block args at which block can be executed
200
206
  * @deprecated use lambda-based API */
201
207
  public argsValid<Cfg extends TypedConfig>(
202
- cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>
208
+ cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>,
203
209
  ): BlockModel<Args, OutputsCfg, UiState, Href>;
204
210
  /** Sets custom configuration predicate on the block args at which block can be executed */
205
211
  public argsValid<RF extends RenderFunctionLegacy<Args, UiState, boolean>>(
206
- rf: RF
212
+ rf: RF,
207
213
  ): BlockModel<Args, OutputsCfg, UiState, Href>;
208
214
  public argsValid(
209
215
  cfgOrRf: TypedConfig | AnyFunction,
210
216
  ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {
211
- if (typeof cfgOrRf === 'function') {
212
- tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtxLegacy()));
217
+ if (typeof cfgOrRf === "function") {
218
+ tryRegisterCallback("inputsValid", () => cfgOrRf(new RenderCtxLegacy()));
213
219
  return new BlockModel<Args, OutputsCfg, UiState>({
214
220
  ...this.config,
215
221
  inputsValid: {
216
222
  __renderLambda: true,
217
- handle: 'inputsValid',
223
+ handle: "inputsValid",
218
224
  },
219
225
  });
220
226
  } else {
@@ -228,7 +234,7 @@ export class BlockModel<
228
234
  /** Sets the config to generate list of section in the left block overviews panel
229
235
  * @deprecated use lambda-based API */
230
236
  public sections<const S extends SectionsExpectedType>(
231
- rf: S
237
+ rf: S,
232
238
  ): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;
233
239
  /** Sets the config to generate list of section in the left block overviews panel */
234
240
  public sections<
@@ -236,7 +242,7 @@ export class BlockModel<
236
242
  const RF extends RenderFunctionLegacy<Args, UiState, Ret>,
237
243
  >(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;
238
244
  public sections<const Cfg extends TypedConfig>(
239
- cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>
245
+ cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>,
240
246
  ): BlockModel<
241
247
  Args,
242
248
  OutputsCfg,
@@ -248,13 +254,13 @@ export class BlockModel<
248
254
  ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {
249
255
  if (Array.isArray(arrOrCfgOrRf)) {
250
256
  return this.sections(getImmediate(arrOrCfgOrRf));
251
- } else if (typeof arrOrCfgOrRf === 'function') {
252
- tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtxLegacy()));
257
+ } else if (typeof arrOrCfgOrRf === "function") {
258
+ tryRegisterCallback("sections", () => arrOrCfgOrRf(new RenderCtxLegacy()));
253
259
  return new BlockModel<Args, OutputsCfg, UiState>({
254
260
  ...this.config,
255
261
  sections: {
256
262
  __renderLambda: true,
257
- handle: 'sections',
263
+ handle: "sections",
258
264
  },
259
265
  });
260
266
  } else {
@@ -269,12 +275,12 @@ export class BlockModel<
269
275
  public title(
270
276
  rf: RenderFunctionLegacy<Args, UiState, string>,
271
277
  ): BlockModel<Args, OutputsCfg, UiState, Href> {
272
- tryRegisterCallback('title', () => rf(new RenderCtxLegacy()));
278
+ tryRegisterCallback("title", () => rf(new RenderCtxLegacy()));
273
279
  return new BlockModel<Args, OutputsCfg, UiState, Href>({
274
280
  ...this.config,
275
281
  title: {
276
282
  __renderLambda: true,
277
- handle: 'title',
283
+ handle: "title",
278
284
  },
279
285
  });
280
286
  }
@@ -282,12 +288,12 @@ export class BlockModel<
282
288
  public subtitle(
283
289
  rf: RenderFunctionLegacy<Args, UiState, string>,
284
290
  ): BlockModel<Args, OutputsCfg, UiState, Href> {
285
- tryRegisterCallback('subtitle', () => rf(new RenderCtxLegacy()));
291
+ tryRegisterCallback("subtitle", () => rf(new RenderCtxLegacy()));
286
292
  return new BlockModel<Args, OutputsCfg, UiState, Href>({
287
293
  ...this.config,
288
294
  subtitle: {
289
295
  __renderLambda: true,
290
- handle: 'subtitle',
296
+ handle: "subtitle",
291
297
  },
292
298
  });
293
299
  }
@@ -295,12 +301,12 @@ export class BlockModel<
295
301
  public tags(
296
302
  rf: RenderFunctionLegacy<Args, UiState, string[]>,
297
303
  ): BlockModel<Args, OutputsCfg, UiState, Href> {
298
- tryRegisterCallback('tags', () => rf(new RenderCtxLegacy()));
304
+ tryRegisterCallback("tags", () => rf(new RenderCtxLegacy()));
299
305
  return new BlockModel<Args, OutputsCfg, UiState, Href>({
300
306
  ...this.config,
301
307
  tags: {
302
308
  __renderLambda: true,
303
- handle: 'tags',
309
+ handle: "tags",
304
310
  },
305
311
  });
306
312
  }
@@ -322,7 +328,9 @@ export class BlockModel<
322
328
  }
323
329
 
324
330
  /** Defines type and sets initial value for block UiState. */
325
- public withUiState<UiState>(initialUiState: UiState): BlockModel<Args, OutputsCfg, UiState, Href> {
331
+ public withUiState<UiState>(
332
+ initialUiState: UiState,
333
+ ): BlockModel<Args, OutputsCfg, UiState, Href> {
326
334
  return new BlockModel<Args, OutputsCfg, UiState, Href>({
327
335
  ...this.config,
328
336
  initialUiState,
@@ -330,7 +338,9 @@ export class BlockModel<
330
338
  }
331
339
 
332
340
  /** Sets or overrides feature flags for the block. */
333
- public withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href> {
341
+ public withFeatureFlags(
342
+ flags: Partial<BlockCodeKnownFeatureFlags>,
343
+ ): BlockModel<Args, OutputsCfg, UiState, Href> {
334
344
  return new BlockModel<Args, OutputsCfg, UiState, Href>({
335
345
  ...this.config,
336
346
  featureFlags: {
@@ -344,55 +354,47 @@ export class BlockModel<
344
354
  * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
345
355
  * Influences dependency graph construction.
346
356
  */
347
- public enriches(
348
- lambda: (args: Args) => PlRef[],
349
- ): BlockModel<Args, OutputsCfg, UiState, Href> {
350
- tryRegisterCallback('enrichmentTargets', lambda);
357
+ public enriches(lambda: (args: Args) => PlRef[]): BlockModel<Args, OutputsCfg, UiState, Href> {
358
+ tryRegisterCallback("enrichmentTargets", lambda);
351
359
  return new BlockModel<Args, OutputsCfg, UiState, Href>({
352
360
  ...this.config,
353
361
  enrichmentTargets: {
354
362
  __renderLambda: true,
355
- handle: 'enrichmentTargets',
363
+ handle: "enrichmentTargets",
356
364
  },
357
365
  });
358
366
  }
359
367
 
360
- public done(apiVersion?: 1): PlatformaExtended<PlatformaV1<
361
- Args,
362
- InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
363
- UiState,
364
- Href
365
- >>;
368
+ public done(
369
+ apiVersion?: 1,
370
+ ): PlatformaExtended<
371
+ PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>
372
+ >;
366
373
 
367
- public done(apiVersion: 2): PlatformaExtended<PlatformaV2<
368
- Args,
369
- InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
370
- UiState,
371
- Href
372
- >>;
374
+ public done(
375
+ apiVersion: 2,
376
+ ): PlatformaExtended<
377
+ PlatformaV2<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>
378
+ >;
373
379
 
374
380
  /** Renders all provided block settings into a pre-configured platforma API
375
381
  * instance, that can be used in frontend to interact with block state, and
376
382
  * other features provided by the platforma to the block. */
377
- public done(apiVersion: PlatformaApiVersion = 1): PlatformaExtended<Platforma<
378
- Args,
379
- InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
380
- UiState,
381
- Href
382
- >> {
383
+ public done(
384
+ apiVersion: PlatformaApiVersion = 1,
385
+ ): PlatformaExtended<
386
+ Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>
387
+ > {
383
388
  return this.withFeatureFlags({
384
389
  ...this.config.featureFlags,
385
390
  requiresUIAPIVersion: apiVersion,
386
391
  }).#done();
387
392
  }
388
393
 
389
- #done(): PlatformaExtended<Platforma<
390
- Args,
391
- InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
392
- UiState,
393
- Href
394
- >> {
395
- if (this.config.initialArgs === undefined) throw new Error('Initial arguments not set.');
394
+ #done(): PlatformaExtended<
395
+ Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>
396
+ > {
397
+ if (this.config.initialArgs === undefined) throw new Error("Initial arguments not set.");
396
398
 
397
399
  const config: BlockConfigContainer = {
398
400
  v4: undefined,
@@ -420,26 +422,36 @@ export class BlockModel<
420
422
  inputsValid: downgradeCfgOrLambda(this.config.inputsValid),
421
423
  sections: downgradeCfgOrLambda(this.config.sections),
422
424
  outputs: Object.fromEntries(
423
- Object.entries(this.config.outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]),
425
+ Object.entries(this.config.outputs).map(([key, value]) => [
426
+ key,
427
+ downgradeCfgOrLambda(value),
428
+ ]),
424
429
  ),
425
430
  };
426
431
 
427
- globalThis.platformaApiVersion = this.config.featureFlags.requiresUIAPIVersion as PlatformaApiVersion;
432
+ globalThis.platformaApiVersion = this.config.featureFlags
433
+ .requiresUIAPIVersion as PlatformaApiVersion;
428
434
 
429
435
  if (!isInUI())
430
- // we are in the configuration rendering routine, not in actual UI
436
+ // we are in the configuration rendering routine, not in actual UI
431
437
  return { config } as any;
432
438
  // normal operation inside the UI
433
- else return {
434
- ...getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }),
435
- blockModelInfo: {
436
- outputs: Object.fromEntries(
437
- Object.entries(this.config.outputs)
438
- .map(([key, value]) => [key, {
439
- withStatus: Boolean(isConfigLambda(value) && value.withStatus),
440
- }]),
441
- ),
442
- },
443
- };
439
+ else
440
+ return {
441
+ ...getPlatformaInstance({
442
+ sdkVersion: PlatformaSDKVersion,
443
+ apiVersion: platformaApiVersion,
444
+ }),
445
+ blockModelInfo: {
446
+ outputs: Object.fromEntries(
447
+ Object.entries(this.config.outputs).map(([key, value]) => [
448
+ key,
449
+ {
450
+ withStatus: Boolean(isConfigLambda(value) && value.withStatus),
451
+ },
452
+ ]),
453
+ ),
454
+ },
455
+ };
444
456
  }
445
457
  }