@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.
- package/dist/annotations/converter.cjs +11 -11
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.d.ts +1 -1
- package/dist/annotations/converter.d.ts.map +1 -1
- package/dist/annotations/converter.js +11 -11
- package/dist/annotations/converter.js.map +1 -1
- package/dist/annotations/index.d.ts +2 -2
- package/dist/annotations/types.d.ts +4 -4
- package/dist/bconfig/index.d.ts +5 -5
- package/dist/bconfig/lambdas.d.ts +7 -7
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/normalization.cjs.map +1 -1
- package/dist/bconfig/normalization.d.ts +3 -3
- package/dist/bconfig/normalization.js.map +1 -1
- package/dist/bconfig/types.cjs.map +1 -1
- package/dist/bconfig/types.d.ts +2 -2
- package/dist/bconfig/types.d.ts.map +1 -1
- package/dist/bconfig/types.js.map +1 -1
- package/dist/bconfig/util.d.ts +4 -4
- package/dist/bconfig/v3.d.ts +3 -3
- package/dist/block_api_v1.d.ts +2 -2
- package/dist/block_api_v1.d.ts.map +1 -1
- package/dist/block_api_v2.d.ts +2 -2
- package/dist/block_api_v2.d.ts.map +1 -1
- package/dist/block_api_v3.d.ts +3 -3
- package/dist/block_migrations.cjs +10 -10
- package/dist/block_migrations.cjs.map +1 -1
- package/dist/block_migrations.d.ts.map +1 -1
- package/dist/block_migrations.js +10 -10
- package/dist/block_migrations.js.map +1 -1
- package/dist/block_model.cjs +11 -11
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +8 -8
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +11 -11
- package/dist/block_model.js.map +1 -1
- package/dist/block_state_patch.d.ts +2 -2
- package/dist/block_state_util.cjs +1 -1
- package/dist/block_state_util.cjs.map +1 -1
- package/dist/block_state_util.d.ts +3 -3
- package/dist/block_state_util.js +1 -1
- package/dist/block_state_util.js.map +1 -1
- package/dist/block_storage.cjs +10 -10
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +2 -2
- package/dist/block_storage.d.ts.map +1 -1
- package/dist/block_storage.js +10 -10
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_vm.cjs +22 -22
- package/dist/block_storage_vm.cjs.map +1 -1
- package/dist/block_storage_vm.d.ts +1 -1
- package/dist/block_storage_vm.d.ts.map +1 -1
- package/dist/block_storage_vm.js +22 -22
- package/dist/block_storage_vm.js.map +1 -1
- package/dist/builder.cjs +32 -23
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.ts +7 -7
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +32 -23
- package/dist/builder.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs +7 -6
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +4 -4
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PFrameForGraphs.js +7 -6
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlAnnotations/filter.d.ts +14 -14
- package/dist/components/PlAnnotations/filter.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.cjs +46 -46
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts +10 -34
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.js +46 -46
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
- package/dist/components/PlAnnotations/index.d.ts +2 -2
- package/dist/components/PlAnnotations/types.d.ts +2 -2
- package/dist/components/PlDataTable.cjs +19 -20
- package/dist/components/PlDataTable.cjs.map +1 -1
- package/dist/components/PlDataTable.d.ts +27 -27
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/components/PlDataTable.js +19 -20
- package/dist/components/PlDataTable.js.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.cjs +2 -2
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +6 -6
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.js +2 -2
- package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
- package/dist/components/PlSelectionModel.cjs.map +1 -1
- package/dist/components/PlSelectionModel.d.ts +1 -1
- package/dist/components/PlSelectionModel.js.map +1 -1
- package/dist/components/index.d.ts +5 -5
- package/dist/config/actions.cjs +39 -39
- package/dist/config/actions.cjs.map +1 -1
- package/dist/config/actions.d.ts +9 -9
- package/dist/config/actions.d.ts.map +1 -1
- package/dist/config/actions.js +39 -39
- package/dist/config/actions.js.map +1 -1
- package/dist/config/actions_kinds.d.ts +30 -30
- package/dist/config/actions_kinds.d.ts.map +1 -1
- package/dist/config/index.d.ts +6 -6
- package/dist/config/model.d.ts +28 -28
- package/dist/config/model_meta.d.ts +1 -1
- package/dist/config/type_engine.d.ts +3 -3
- package/dist/config/type_util.d.ts +2 -2
- package/dist/env_value.cjs +1 -1
- package/dist/env_value.cjs.map +1 -1
- package/dist/env_value.js +1 -1
- package/dist/env_value.js.map +1 -1
- package/dist/filters/converter.cjs +36 -32
- package/dist/filters/converter.cjs.map +1 -1
- package/dist/filters/converter.d.ts +2 -2
- package/dist/filters/converter.d.ts.map +1 -1
- package/dist/filters/converter.js +36 -32
- package/dist/filters/converter.js.map +1 -1
- package/dist/filters/index.d.ts +2 -2
- package/dist/filters/types.d.ts +33 -33
- package/dist/filters/types.d.ts.map +1 -1
- package/dist/index.d.ts +24 -24
- package/dist/internal.cjs +7 -7
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.ts +4 -4
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +7 -7
- package/dist/internal.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/pframe.cjs +1 -1
- package/dist/pframe.cjs.map +1 -1
- package/dist/pframe.d.ts +1 -1
- package/dist/pframe.js +1 -1
- package/dist/pframe.js.map +1 -1
- package/dist/pframe_utils/columns.cjs +23 -15
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +3 -3
- package/dist/pframe_utils/columns.d.ts.map +1 -1
- package/dist/pframe_utils/columns.js +23 -15
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/pframe_utils/index.cjs +25 -25
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +3 -3
- package/dist/pframe_utils/index.d.ts.map +1 -1
- package/dist/pframe_utils/index.js +25 -25
- package/dist/pframe_utils/index.js.map +1 -1
- package/dist/platforma.d.ts +7 -7
- package/dist/platforma.d.ts.map +1 -1
- package/dist/raw_globals.cjs +4 -1
- package/dist/raw_globals.cjs.map +1 -1
- package/dist/raw_globals.d.ts +2 -2
- package/dist/raw_globals.d.ts.map +1 -1
- package/dist/raw_globals.js +4 -1
- package/dist/raw_globals.js.map +1 -1
- package/dist/ref_util.cjs +4 -4
- package/dist/ref_util.cjs.map +1 -1
- package/dist/ref_util.d.ts +1 -1
- package/dist/ref_util.js +4 -4
- package/dist/ref_util.js.map +1 -1
- package/dist/render/accessor.cjs +24 -24
- package/dist/render/accessor.cjs.map +1 -1
- package/dist/render/accessor.d.ts +10 -10
- package/dist/render/accessor.d.ts.map +1 -1
- package/dist/render/accessor.js +24 -24
- package/dist/render/accessor.js.map +1 -1
- package/dist/render/api.cjs +23 -23
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +11 -11
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +23 -23
- package/dist/render/api.js.map +1 -1
- package/dist/render/future.cjs.map +1 -1
- package/dist/render/future.d.ts +1 -1
- package/dist/render/future.js.map +1 -1
- package/dist/render/index.d.ts +6 -6
- package/dist/render/internal.cjs +4 -4
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +7 -7
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/internal.js +4 -4
- package/dist/render/internal.js.map +1 -1
- package/dist/render/traversal_ops.d.ts +1 -1
- package/dist/render/util/axis_filtering.cjs +48 -44
- package/dist/render/util/axis_filtering.cjs.map +1 -1
- package/dist/render/util/axis_filtering.d.ts +2 -2
- package/dist/render/util/axis_filtering.js +48 -44
- package/dist/render/util/axis_filtering.js.map +1 -1
- package/dist/render/util/column_collection.cjs +42 -35
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +4 -4
- package/dist/render/util/column_collection.d.ts.map +1 -1
- package/dist/render/util/column_collection.js +42 -35
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.d.ts +4 -4
- package/dist/render/util/label.cjs +15 -21
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +2 -2
- package/dist/render/util/label.d.ts.map +1 -1
- package/dist/render/util/label.js +15 -21
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +56 -54
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +5 -5
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js +56 -54
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/dist/render/util/pframe_upgraders.cjs +6 -6
- package/dist/render/util/pframe_upgraders.cjs.map +1 -1
- package/dist/render/util/pframe_upgraders.d.ts +1 -1
- package/dist/render/util/pframe_upgraders.d.ts.map +1 -1
- package/dist/render/util/pframe_upgraders.js +6 -6
- package/dist/render/util/pframe_upgraders.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +1 -1
- package/dist/render/util/split_selectors.d.ts.map +1 -1
- package/dist/sdk_info.cjs.map +1 -1
- package/dist/sdk_info.js.map +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +24 -22
- package/src/annotations/converter.test.ts +98 -101
- package/src/annotations/converter.ts +21 -17
- package/src/annotations/index.ts +2 -2
- package/src/annotations/types.ts +4 -4
- package/src/bconfig/index.ts +5 -5
- package/src/bconfig/lambdas.ts +10 -12
- package/src/bconfig/normalization.ts +5 -5
- package/src/bconfig/types.ts +3 -5
- package/src/bconfig/util.ts +3 -3
- package/src/bconfig/v3.ts +3 -3
- package/src/block_api_v1.ts +7 -3
- package/src/block_api_v2.ts +7 -3
- package/src/block_api_v3.ts +3 -3
- package/src/block_migrations.test.ts +66 -67
- package/src/block_migrations.ts +16 -16
- package/src/block_model.ts +76 -140
- package/src/block_state_patch.ts +2 -2
- package/src/block_state_util.ts +4 -4
- package/src/block_storage.test.ts +106 -99
- package/src/block_storage.ts +22 -25
- package/src/block_storage_vm.ts +41 -35
- package/src/builder.ts +107 -95
- package/src/components/PFrameForGraphs.test.ts +261 -255
- package/src/components/PFrameForGraphs.ts +35 -22
- package/src/components/PlAnnotations/filter.ts +21 -15
- package/src/components/PlAnnotations/filters_ui.test.ts +230 -73
- package/src/components/PlAnnotations/filters_ui.ts +138 -105
- package/src/components/PlAnnotations/index.ts +2 -2
- package/src/components/PlAnnotations/types.ts +2 -2
- package/src/components/PlDataTable.ts +177 -164
- package/src/components/PlMultiSequenceAlignment.ts +11 -18
- package/src/components/PlSelectionModel.ts +1 -1
- package/src/components/index.ts +5 -5
- package/src/config/actions.ts +64 -59
- package/src/config/actions_kinds.ts +38 -34
- package/src/config/index.ts +6 -6
- package/src/config/model.ts +28 -28
- package/src/config/model_meta.ts +1 -1
- package/src/config/type_engine.ts +3 -3
- package/src/config/type_util.ts +2 -2
- package/src/env_value.ts +2 -2
- package/src/filters/converter.test.ts +185 -144
- package/src/filters/converter.ts +47 -35
- package/src/filters/index.ts +2 -2
- package/src/filters/types.ts +44 -39
- package/src/global.d.ts +1 -1
- package/src/index.ts +24 -24
- package/src/internal.ts +27 -17
- package/src/pframe.ts +3 -3
- package/src/pframe_utils/columns.ts +81 -31
- package/src/pframe_utils/index.ts +65 -43
- package/src/platforma.ts +44 -21
- package/src/raw_globals.ts +13 -7
- package/src/ref_util.ts +6 -6
- package/src/render/accessor.ts +43 -44
- package/src/render/api.ts +102 -78
- package/src/render/future.ts +2 -2
- package/src/render/index.ts +6 -6
- package/src/render/internal.ts +11 -12
- package/src/render/traversal_ops.ts +1 -1
- package/src/render/util/axis_filtering.ts +67 -52
- package/src/render/util/column_collection.ts +171 -91
- package/src/render/util/index.ts +4 -4
- package/src/render/util/label.test.ts +139 -139
- package/src/render/util/label.ts +42 -33
- package/src/render/util/pcolumn_data.ts +111 -75
- package/src/render/util/pframe_upgraders.ts +24 -13
- package/src/render/util/split_selectors.ts +6 -1
- package/src/sdk_info.ts +1 -1
- package/src/typing.test.ts +56 -56
- package/src/version.ts +1 -1
package/src/block_storage_vm.ts
CHANGED
|
@@ -32,9 +32,9 @@ import {
|
|
|
32
32
|
isBlockStorage,
|
|
33
33
|
normalizeBlockStorage,
|
|
34
34
|
updateStorageData,
|
|
35
|
-
} from
|
|
36
|
-
import { stringifyJson, type StringifiedJson } from
|
|
37
|
-
import { tryGetCfgRenderCtx, tryRegisterCallback } from
|
|
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 ===
|
|
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 !==
|
|
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
|
|
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(
|
|
131
|
-
|
|
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(
|
|
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:
|
|
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[
|
|
210
|
-
|
|
211
|
-
|
|
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 =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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(
|
|
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:
|
|
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[
|
|
272
|
-
if (typeof argsCallback !==
|
|
273
|
-
return { error:
|
|
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(
|
|
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:
|
|
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[
|
|
309
|
-
|
|
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[
|
|
321
|
-
if (typeof argsCallback !==
|
|
322
|
-
return { error:
|
|
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(
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
17
|
-
import {
|
|
18
|
-
|
|
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 =
|
|
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 & {
|
|
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 ===
|
|
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<
|
|
177
|
-
|
|
178
|
-
|
|
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<
|
|
185
|
-
|
|
186
|
-
|
|
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<
|
|
193
|
-
|
|
194
|
-
|
|
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 ===
|
|
212
|
-
tryRegisterCallback(
|
|
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:
|
|
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 ===
|
|
252
|
-
tryRegisterCallback(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
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:
|
|
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>(
|
|
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(
|
|
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
|
-
|
|
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:
|
|
363
|
+
handle: "enrichmentTargets",
|
|
356
364
|
},
|
|
357
365
|
});
|
|
358
366
|
}
|
|
359
367
|
|
|
360
|
-
public done(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
UiState,
|
|
364
|
-
|
|
365
|
-
>>;
|
|
368
|
+
public done(
|
|
369
|
+
apiVersion?: 1,
|
|
370
|
+
): PlatformaExtended<
|
|
371
|
+
PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>
|
|
372
|
+
>;
|
|
366
373
|
|
|
367
|
-
public done(
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
UiState,
|
|
371
|
-
|
|
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(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
UiState,
|
|
381
|
-
|
|
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<
|
|
390
|
-
Args,
|
|
391
|
-
|
|
392
|
-
|
|
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]) => [
|
|
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
|
|
432
|
+
globalThis.platformaApiVersion = this.config.featureFlags
|
|
433
|
+
.requiresUIAPIVersion as PlatformaApiVersion;
|
|
428
434
|
|
|
429
435
|
if (!isInUI())
|
|
430
|
-
|
|
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
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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
|
}
|