@platforma-sdk/model 1.51.9 → 1.52.3
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/bconfig/lambdas.d.ts +26 -4
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/v3.d.ts +4 -2
- package/dist/bconfig/v3.d.ts.map +1 -1
- package/dist/block_api_v3.d.ts +32 -0
- package/dist/block_api_v3.d.ts.map +1 -0
- package/dist/block_migrations.cjs +138 -0
- package/dist/block_migrations.cjs.map +1 -0
- package/dist/block_migrations.d.ts +79 -0
- package/dist/block_migrations.d.ts.map +1 -0
- package/dist/block_migrations.js +136 -0
- package/dist/block_migrations.js.map +1 -0
- package/dist/block_model.cjs +222 -0
- package/dist/block_model.cjs.map +1 -0
- package/dist/block_model.d.ts +132 -0
- package/dist/block_model.d.ts.map +1 -0
- package/dist/block_model.js +220 -0
- package/dist/block_model.js.map +1 -0
- package/dist/block_storage.cjs +244 -0
- package/dist/block_storage.cjs.map +1 -0
- package/dist/block_storage.d.ts +208 -0
- package/dist/block_storage.d.ts.map +1 -0
- package/dist/block_storage.js +225 -0
- package/dist/block_storage.js.map +1 -0
- package/dist/block_storage_vm.cjs +264 -0
- package/dist/block_storage_vm.cjs.map +1 -0
- package/dist/block_storage_vm.d.ts +67 -0
- package/dist/block_storage_vm.d.ts.map +1 -0
- package/dist/block_storage_vm.js +260 -0
- package/dist/block_storage_vm.js.map +1 -0
- package/dist/builder.cjs +9 -6
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.ts +15 -30
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +10 -7
- package/dist/builder.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +2 -2
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlDataTable.cjs.map +1 -1
- package/dist/components/PlDataTable.d.ts +3 -3
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/components/PlDataTable.js.map +1 -1
- package/dist/index.cjs +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +38 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.ts +21 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +36 -1
- package/dist/internal.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- 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.map +1 -1
- package/dist/platforma.d.ts +18 -3
- package/dist/platforma.d.ts.map +1 -1
- package/dist/render/api.cjs +43 -16
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +19 -7
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +42 -17
- package/dist/render/api.js.map +1 -1
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +3 -1
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/internal.js.map +1 -1
- package/package.json +7 -7
- package/src/bconfig/lambdas.ts +35 -4
- package/src/bconfig/v3.ts +12 -2
- package/src/block_api_v3.ts +49 -0
- package/src/block_migrations.ts +173 -0
- package/src/block_model.ts +440 -0
- package/src/block_storage.test.ts +258 -0
- package/src/block_storage.ts +365 -0
- package/src/block_storage_vm.ts +349 -0
- package/src/builder.ts +24 -59
- package/src/components/PFrameForGraphs.ts +2 -2
- package/src/components/PlDataTable.ts +3 -3
- package/src/index.ts +3 -0
- package/src/internal.ts +51 -0
- package/src/pframe_utils/columns.ts +3 -3
- package/src/platforma.ts +31 -5
- package/src/render/api.ts +52 -21
- package/src/render/internal.ts +3 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { createBlockStorage, isBlockStorage, getStorageData, updateStorageData } from './block_storage.js';
|
|
2
|
+
export { BLOCK_STORAGE_KEY, BLOCK_STORAGE_SCHEMA_VERSION } from './block_storage.js';
|
|
3
|
+
import { tryRegisterCallback, tryGetCfgRenderCtx } from './internal.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* BlockStorage VM Integration - Internal module for VM-based storage operations.
|
|
7
|
+
*
|
|
8
|
+
* This module auto-registers internal callbacks that the middle layer can invoke
|
|
9
|
+
* to perform storage transformations. Block developers never interact with these
|
|
10
|
+
* directly - they only see `state`.
|
|
11
|
+
*
|
|
12
|
+
* Registered callbacks (all prefixed with `__pl_` for internal SDK use):
|
|
13
|
+
* - `__pl_storage_normalize`: (rawStorage) => { storage, data }
|
|
14
|
+
* - `__pl_storage_applyUpdate`: (currentStorageJson, payload) => updatedStorageJson
|
|
15
|
+
* - `__pl_storage_getInfo`: (rawStorage) => JSON string with storage info
|
|
16
|
+
* - `__pl_storage_migrate`: (currentStorageJson) => MigrationResult
|
|
17
|
+
* - `__pl_args_derive`: (storageJson) => ArgsDeriveResult
|
|
18
|
+
* - `__pl_prerunArgs_derive`: (storageJson) => ArgsDeriveResult
|
|
19
|
+
*
|
|
20
|
+
* Callbacks registered by DataModel.registerCallbacks():
|
|
21
|
+
* - `__pl_data_initial`: () => initial data
|
|
22
|
+
* - `__pl_data_upgrade`: (versioned) => UpgradeResult
|
|
23
|
+
* - `__pl_storage_initial`: () => initial BlockStorage as JSON string
|
|
24
|
+
*
|
|
25
|
+
* @module block_storage_vm
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes raw storage data and extracts state.
|
|
30
|
+
* Handles all formats:
|
|
31
|
+
* - New BlockStorage format (has discriminator)
|
|
32
|
+
* - Legacy V1/V2 format ({ args, uiState })
|
|
33
|
+
* - Raw V3 state (any other format)
|
|
34
|
+
*
|
|
35
|
+
* @param rawStorage - Raw data from blockStorage field (may be JSON string or object)
|
|
36
|
+
* @returns Object with normalized storage and extracted state
|
|
37
|
+
*/
|
|
38
|
+
function normalizeStorage(rawStorage) {
|
|
39
|
+
// Handle undefined/null
|
|
40
|
+
if (rawStorage === undefined || rawStorage === null) {
|
|
41
|
+
const storage = createBlockStorage({});
|
|
42
|
+
return { storage, data: {} };
|
|
43
|
+
}
|
|
44
|
+
// Parse JSON string if needed
|
|
45
|
+
let parsed = rawStorage;
|
|
46
|
+
if (typeof rawStorage === 'string') {
|
|
47
|
+
try {
|
|
48
|
+
parsed = JSON.parse(rawStorage);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// If parsing fails, treat string as the data
|
|
52
|
+
const storage = createBlockStorage(rawStorage);
|
|
53
|
+
return { storage, data: rawStorage };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Check for BlockStorage format (has discriminator)
|
|
57
|
+
if (isBlockStorage(parsed)) {
|
|
58
|
+
return { storage: parsed, data: getStorageData(parsed) };
|
|
59
|
+
}
|
|
60
|
+
// Check for legacy V1/V2 format: { args, uiState }
|
|
61
|
+
if (isLegacyModelV1ApiFormat(parsed)) {
|
|
62
|
+
// For legacy format, the whole object IS the data
|
|
63
|
+
const storage = createBlockStorage(parsed);
|
|
64
|
+
return { storage, data: parsed };
|
|
65
|
+
}
|
|
66
|
+
// Raw V3 data - wrap it
|
|
67
|
+
const storage = createBlockStorage(parsed);
|
|
68
|
+
return { storage, data: parsed };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Applies a state update to existing storage.
|
|
72
|
+
* Used when setData is called from the frontend.
|
|
73
|
+
*
|
|
74
|
+
* @param currentStorageJson - Current storage as JSON string (must be defined)
|
|
75
|
+
* @param newData - New data from application
|
|
76
|
+
* @returns Updated storage as JSON string
|
|
77
|
+
*/
|
|
78
|
+
function applyStorageUpdate(currentStorageJson, payload) {
|
|
79
|
+
const { storage: currentStorage } = normalizeStorage(currentStorageJson);
|
|
80
|
+
// Update data while preserving other storage fields (version, plugins)
|
|
81
|
+
const updatedStorage = updateStorageData(currentStorage, payload);
|
|
82
|
+
return JSON.stringify(updatedStorage);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Checks if data is in legacy Model API v1 format.
|
|
86
|
+
* Legacy format has { args, uiState? } at top level without the BlockStorage discriminator.
|
|
87
|
+
*/
|
|
88
|
+
function isLegacyModelV1ApiFormat(data) {
|
|
89
|
+
if (data === null || typeof data !== 'object')
|
|
90
|
+
return false;
|
|
91
|
+
if (isBlockStorage(data))
|
|
92
|
+
return false;
|
|
93
|
+
const obj = data;
|
|
94
|
+
return 'args' in obj;
|
|
95
|
+
}
|
|
96
|
+
// =============================================================================
|
|
97
|
+
// Auto-register internal callbacks when module is loaded in VM
|
|
98
|
+
// =============================================================================
|
|
99
|
+
// Register normalize callback
|
|
100
|
+
tryRegisterCallback('__pl_storage_normalize', (rawStorage) => {
|
|
101
|
+
return normalizeStorage(rawStorage);
|
|
102
|
+
});
|
|
103
|
+
// Register apply update callback (requires existing storage)
|
|
104
|
+
tryRegisterCallback('__pl_storage_applyUpdate', (currentStorageJson, payload) => {
|
|
105
|
+
return applyStorageUpdate(currentStorageJson, payload);
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Gets storage info from raw storage data.
|
|
109
|
+
* Returns structured info about the storage state.
|
|
110
|
+
*
|
|
111
|
+
* @param rawStorage - Raw data from blockStorage field (may be JSON string or object)
|
|
112
|
+
* @returns JSON string with storage info
|
|
113
|
+
*/
|
|
114
|
+
function getStorageInfo(rawStorage) {
|
|
115
|
+
const { storage } = normalizeStorage(rawStorage);
|
|
116
|
+
const info = {
|
|
117
|
+
dataVersion: storage.__dataVersion,
|
|
118
|
+
};
|
|
119
|
+
return JSON.stringify(info);
|
|
120
|
+
}
|
|
121
|
+
// Register get info callback
|
|
122
|
+
tryRegisterCallback('__pl_storage_getInfo', (rawStorage) => {
|
|
123
|
+
return getStorageInfo(rawStorage);
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* Runs storage migration using the DataModel's upgrade callback.
|
|
127
|
+
* This is the main entry point for the middle layer to trigger migrations.
|
|
128
|
+
*
|
|
129
|
+
* Uses the '__pl_data_upgrade' callback registered by DataModel.registerCallbacks() which:
|
|
130
|
+
* - Handles all migration logic internally
|
|
131
|
+
* - Returns { version, data, warning? } - warning present if reset to initial data
|
|
132
|
+
*
|
|
133
|
+
* @param currentStorageJson - Current storage as JSON string (or undefined)
|
|
134
|
+
* @returns MigrationResult
|
|
135
|
+
*/
|
|
136
|
+
function migrateStorage(currentStorageJson) {
|
|
137
|
+
// Get the callback registry context
|
|
138
|
+
const ctx = tryGetCfgRenderCtx();
|
|
139
|
+
if (ctx === undefined) {
|
|
140
|
+
return { error: 'Not in config rendering context' };
|
|
141
|
+
}
|
|
142
|
+
// Normalize storage to get current data and version
|
|
143
|
+
const { storage: currentStorage, data: currentData } = normalizeStorage(currentStorageJson);
|
|
144
|
+
const currentVersion = currentStorage.__dataVersion;
|
|
145
|
+
// Helper to create storage with given data and version
|
|
146
|
+
const createStorageJson = (data, version) => {
|
|
147
|
+
return JSON.stringify({
|
|
148
|
+
...currentStorage,
|
|
149
|
+
__dataVersion: version,
|
|
150
|
+
__data: data,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
// Get the upgrade callback (registered by DataModel.registerCallbacks())
|
|
154
|
+
const upgradeCallback = ctx.callbackRegistry['__pl_data_upgrade'];
|
|
155
|
+
if (typeof upgradeCallback !== 'function') {
|
|
156
|
+
return { error: '__pl_data_upgrade callback not found (DataModel not registered)' };
|
|
157
|
+
}
|
|
158
|
+
// Call the migrator's upgrade function
|
|
159
|
+
let result;
|
|
160
|
+
try {
|
|
161
|
+
result = upgradeCallback({ version: currentVersion, data: currentData });
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
const errorMsg = e instanceof Error ? e.message : String(e);
|
|
165
|
+
return { error: `upgrade() threw: ${errorMsg}` };
|
|
166
|
+
}
|
|
167
|
+
// Build info message
|
|
168
|
+
const info = result.version === currentVersion
|
|
169
|
+
? `No migration needed (v${currentVersion})`
|
|
170
|
+
: result.warning
|
|
171
|
+
? `Reset to initial data (v${result.version})`
|
|
172
|
+
: `Migrated v${currentVersion}→v${result.version}`;
|
|
173
|
+
return {
|
|
174
|
+
newStorageJson: createStorageJson(result.data, result.version),
|
|
175
|
+
info,
|
|
176
|
+
warn: result.warning,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
// Register migrate callback
|
|
180
|
+
tryRegisterCallback('__pl_storage_migrate', (currentStorageJson) => {
|
|
181
|
+
return migrateStorage(currentStorageJson);
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Derives args from storage using the registered 'args' callback.
|
|
185
|
+
* This extracts data from storage and passes it to the block's args() function.
|
|
186
|
+
*
|
|
187
|
+
* @param storageJson - Storage as JSON string
|
|
188
|
+
* @returns ArgsDeriveResult with derived args or error
|
|
189
|
+
*/
|
|
190
|
+
function deriveArgsFromStorage(storageJson) {
|
|
191
|
+
const ctx = tryGetCfgRenderCtx();
|
|
192
|
+
if (ctx === undefined) {
|
|
193
|
+
return { error: 'Not in config rendering context' };
|
|
194
|
+
}
|
|
195
|
+
// Extract data from storage
|
|
196
|
+
const { data } = normalizeStorage(storageJson);
|
|
197
|
+
// Get the args callback (registered by BlockModelV3.args())
|
|
198
|
+
const argsCallback = ctx.callbackRegistry['args'];
|
|
199
|
+
if (typeof argsCallback !== 'function') {
|
|
200
|
+
return { error: 'args callback not found' };
|
|
201
|
+
}
|
|
202
|
+
// Call the args callback with extracted data
|
|
203
|
+
try {
|
|
204
|
+
const result = argsCallback(data);
|
|
205
|
+
return { value: result };
|
|
206
|
+
}
|
|
207
|
+
catch (e) {
|
|
208
|
+
const errorMsg = e instanceof Error ? e.message : String(e);
|
|
209
|
+
return { error: `args() threw: ${errorMsg}` };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Register args derivation callback
|
|
213
|
+
tryRegisterCallback('__pl_args_derive', (storageJson) => {
|
|
214
|
+
return deriveArgsFromStorage(storageJson);
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* Derives prerunArgs from storage using the registered 'prerunArgs' callback.
|
|
218
|
+
* Falls back to 'args' callback if 'prerunArgs' is not defined.
|
|
219
|
+
*
|
|
220
|
+
* @param storageJson - Storage as JSON string
|
|
221
|
+
* @returns ArgsDeriveResult with derived prerunArgs or error
|
|
222
|
+
*/
|
|
223
|
+
function derivePrerunArgsFromStorage(storageJson) {
|
|
224
|
+
const ctx = tryGetCfgRenderCtx();
|
|
225
|
+
if (ctx === undefined) {
|
|
226
|
+
return { error: 'Not in config rendering context' };
|
|
227
|
+
}
|
|
228
|
+
// Extract data from storage
|
|
229
|
+
const { data } = normalizeStorage(storageJson);
|
|
230
|
+
// Try prerunArgs callback first
|
|
231
|
+
const prerunArgsCallback = ctx.callbackRegistry['prerunArgs'];
|
|
232
|
+
if (typeof prerunArgsCallback === 'function') {
|
|
233
|
+
try {
|
|
234
|
+
const result = prerunArgsCallback(data);
|
|
235
|
+
return { value: result };
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
const errorMsg = e instanceof Error ? e.message : String(e);
|
|
239
|
+
return { error: `prerunArgs() threw: ${errorMsg}` };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// Fall back to args callback
|
|
243
|
+
const argsCallback = ctx.callbackRegistry['args'];
|
|
244
|
+
if (typeof argsCallback !== 'function') {
|
|
245
|
+
return { error: 'args callback not found (fallback from missing prerunArgs)' };
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
const result = argsCallback(data);
|
|
249
|
+
return { value: result };
|
|
250
|
+
}
|
|
251
|
+
catch (e) {
|
|
252
|
+
const errorMsg = e instanceof Error ? e.message : String(e);
|
|
253
|
+
return { error: `args() threw (fallback): ${errorMsg}` };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Register prerunArgs derivation callback
|
|
257
|
+
tryRegisterCallback('__pl_prerunArgs_derive', (storageJson) => {
|
|
258
|
+
return derivePrerunArgsFromStorage(storageJson);
|
|
259
|
+
});
|
|
260
|
+
//# sourceMappingURL=block_storage_vm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block_storage_vm.js","sources":["../src/block_storage_vm.ts"],"sourcesContent":["/**\n * BlockStorage VM Integration - Internal module for VM-based storage operations.\n *\n * This module auto-registers internal callbacks that the middle layer can invoke\n * to perform storage transformations. Block developers never interact with these\n * directly - they only see `state`.\n *\n * Registered callbacks (all prefixed with `__pl_` for internal SDK use):\n * - `__pl_storage_normalize`: (rawStorage) => { storage, data }\n * - `__pl_storage_applyUpdate`: (currentStorageJson, payload) => updatedStorageJson\n * - `__pl_storage_getInfo`: (rawStorage) => JSON string with storage info\n * - `__pl_storage_migrate`: (currentStorageJson) => MigrationResult\n * - `__pl_args_derive`: (storageJson) => ArgsDeriveResult\n * - `__pl_prerunArgs_derive`: (storageJson) => ArgsDeriveResult\n *\n * Callbacks registered by DataModel.registerCallbacks():\n * - `__pl_data_initial`: () => initial data\n * - `__pl_data_upgrade`: (versioned) => UpgradeResult\n * - `__pl_storage_initial`: () => initial BlockStorage as JSON string\n *\n * @module block_storage_vm\n * @internal\n */\n\nimport {\n BLOCK_STORAGE_KEY,\n BLOCK_STORAGE_SCHEMA_VERSION,\n type BlockStorage,\n type MutateStoragePayload,\n createBlockStorage,\n getStorageData,\n isBlockStorage,\n updateStorageData,\n} from './block_storage';\nimport { tryGetCfgRenderCtx, tryRegisterCallback } from './internal';\n\n/**\n * Result of storage normalization\n */\nexport interface NormalizeStorageResult {\n /** The normalized BlockStorage object */\n storage: BlockStorage;\n /** The extracted data (what developers see) */\n data: unknown;\n}\n\n/**\n * Normalizes raw storage data and extracts state.\n * Handles all formats:\n * - New BlockStorage format (has discriminator)\n * - Legacy V1/V2 format ({ args, uiState })\n * - Raw V3 state (any other format)\n *\n * @param rawStorage - Raw data from blockStorage field (may be JSON string or object)\n * @returns Object with normalized storage and extracted state\n */\nfunction normalizeStorage(rawStorage: unknown): NormalizeStorageResult {\n // Handle undefined/null\n if (rawStorage === undefined || rawStorage === null) {\n const storage = createBlockStorage({});\n return { storage, data: {} };\n }\n\n // Parse JSON string if needed\n let parsed = rawStorage;\n if (typeof rawStorage === 'string') {\n try {\n parsed = JSON.parse(rawStorage);\n } catch {\n // If parsing fails, treat string as the data\n const storage = createBlockStorage(rawStorage);\n return { storage, data: rawStorage };\n }\n }\n\n // Check for BlockStorage format (has discriminator)\n if (isBlockStorage(parsed)) {\n return { storage: parsed, data: getStorageData(parsed) };\n }\n\n // Check for legacy V1/V2 format: { args, uiState }\n if (isLegacyModelV1ApiFormat(parsed)) {\n // For legacy format, the whole object IS the data\n const storage = createBlockStorage(parsed);\n return { storage, data: parsed };\n }\n\n // Raw V3 data - wrap it\n const storage = createBlockStorage(parsed);\n return { storage, data: parsed };\n}\n\n/**\n * Applies a state update to existing storage.\n * Used when setData is called from the frontend.\n *\n * @param currentStorageJson - Current storage as JSON string (must be defined)\n * @param newData - New data from application\n * @returns Updated storage as JSON string\n */\nfunction applyStorageUpdate(currentStorageJson: string, payload: MutateStoragePayload): string {\n const { storage: currentStorage } = normalizeStorage(currentStorageJson);\n\n // Update data while preserving other storage fields (version, plugins)\n const updatedStorage = updateStorageData(currentStorage, payload);\n\n return JSON.stringify(updatedStorage);\n}\n\n/**\n * Checks if data is in legacy Model API v1 format.\n * Legacy format has { args, uiState? } at top level without the BlockStorage discriminator.\n */\nfunction isLegacyModelV1ApiFormat(data: unknown): data is { args?: unknown } {\n if (data === null || typeof data !== 'object') return false;\n if (isBlockStorage(data)) return false;\n\n const obj = data as Record<string, unknown>;\n return 'args' in obj;\n}\n\n// =============================================================================\n// Auto-register internal callbacks when module is loaded in VM\n// =============================================================================\n\n// Register normalize callback\ntryRegisterCallback('__pl_storage_normalize', (rawStorage: unknown) => {\n return normalizeStorage(rawStorage);\n});\n\n// Register apply update callback (requires existing storage)\ntryRegisterCallback('__pl_storage_applyUpdate', (currentStorageJson: string, payload: MutateStoragePayload) => {\n return applyStorageUpdate(currentStorageJson, payload);\n});\n\n/**\n * Storage info result returned by __pl_storage_getInfo callback.\n */\nexport interface StorageInfo {\n /** Current data version (1-based, starts at 1) */\n dataVersion: number;\n}\n\n/**\n * Gets storage info from raw storage data.\n * Returns structured info about the storage state.\n *\n * @param rawStorage - Raw data from blockStorage field (may be JSON string or object)\n * @returns JSON string with storage info\n */\nfunction getStorageInfo(rawStorage: unknown): string {\n const { storage } = normalizeStorage(rawStorage);\n const info: StorageInfo = {\n dataVersion: storage.__dataVersion,\n };\n return JSON.stringify(info);\n}\n\n// Register get info callback\ntryRegisterCallback('__pl_storage_getInfo', (rawStorage: unknown) => {\n return getStorageInfo(rawStorage);\n});\n\n// =============================================================================\n// Migration Support\n// =============================================================================\n\n/**\n * Result of storage migration.\n * Returned by __pl_storage_migrate callback.\n *\n * - Error result: { error: string } - serious failure (no context, etc.)\n * - Success result: { newStorageJson: string, info: string, warn?: string } - migration succeeded or reset to initial\n */\nexport type MigrationResult =\n | { error: string }\n | { error?: undefined; newStorageJson: string; info: string; warn?: string };\n\n/** Result from Migrator.upgrade() */\ninterface UpgradeResult {\n version: number;\n data: unknown;\n warning?: string;\n}\n\n/**\n * Runs storage migration using the DataModel's upgrade callback.\n * This is the main entry point for the middle layer to trigger migrations.\n *\n * Uses the '__pl_data_upgrade' callback registered by DataModel.registerCallbacks() which:\n * - Handles all migration logic internally\n * - Returns { version, data, warning? } - warning present if reset to initial data\n *\n * @param currentStorageJson - Current storage as JSON string (or undefined)\n * @returns MigrationResult\n */\nfunction migrateStorage(currentStorageJson: string | undefined): MigrationResult {\n // Get the callback registry context\n const ctx = tryGetCfgRenderCtx();\n if (ctx === undefined) {\n return { error: 'Not in config rendering context' };\n }\n\n // Normalize storage to get current data and version\n const { storage: currentStorage, data: currentData } = normalizeStorage(currentStorageJson);\n const currentVersion = currentStorage.__dataVersion;\n\n // Helper to create storage with given data and version\n const createStorageJson = (data: unknown, version: number): string => {\n return JSON.stringify({\n ...currentStorage,\n __dataVersion: version,\n __data: data,\n });\n };\n\n // Get the upgrade callback (registered by DataModel.registerCallbacks())\n const upgradeCallback = ctx.callbackRegistry['__pl_data_upgrade'] as ((v: { version: number; data: unknown }) => UpgradeResult) | undefined;\n if (typeof upgradeCallback !== 'function') {\n return { error: '__pl_data_upgrade callback not found (DataModel not registered)' };\n }\n\n // Call the migrator's upgrade function\n let result: UpgradeResult;\n try {\n result = upgradeCallback({ version: currentVersion, data: currentData });\n } catch (e) {\n const errorMsg = e instanceof Error ? e.message : String(e);\n return { error: `upgrade() threw: ${errorMsg}` };\n }\n\n // Build info message\n const info = result.version === currentVersion\n ? `No migration needed (v${currentVersion})`\n : result.warning\n ? `Reset to initial data (v${result.version})`\n : `Migrated v${currentVersion}→v${result.version}`;\n\n return {\n newStorageJson: createStorageJson(result.data, result.version),\n info,\n warn: result.warning,\n };\n}\n\n// Register migrate callback\ntryRegisterCallback('__pl_storage_migrate', (currentStorageJson: string | undefined) => {\n return migrateStorage(currentStorageJson);\n});\n\n// =============================================================================\n// Args Derivation from Storage\n// =============================================================================\n\n/**\n * Result of args derivation from storage.\n * Returned by __pl_args_derive and __pl_prerunArgs_derive callbacks.\n */\nexport type ArgsDeriveResult =\n | { error: string }\n | { error?: undefined; value: unknown };\n\n/**\n * Derives args from storage using the registered 'args' callback.\n * This extracts data from storage and passes it to the block's args() function.\n *\n * @param storageJson - Storage as JSON string\n * @returns ArgsDeriveResult with derived args or error\n */\nfunction deriveArgsFromStorage(storageJson: string): ArgsDeriveResult {\n const ctx = tryGetCfgRenderCtx();\n if (ctx === undefined) {\n return { error: 'Not in config rendering context' };\n }\n\n // Extract data from storage\n const { data } = normalizeStorage(storageJson);\n\n // Get the args callback (registered by BlockModelV3.args())\n const argsCallback = ctx.callbackRegistry['args'] as ((data: unknown) => unknown) | undefined;\n if (typeof argsCallback !== 'function') {\n return { error: 'args callback not found' };\n }\n\n // Call the args callback with extracted data\n try {\n const result = argsCallback(data);\n return { value: result };\n } catch (e) {\n const errorMsg = e instanceof Error ? e.message : String(e);\n return { error: `args() threw: ${errorMsg}` };\n }\n}\n\n// Register args derivation callback\ntryRegisterCallback('__pl_args_derive', (storageJson: string) => {\n return deriveArgsFromStorage(storageJson);\n});\n\n/**\n * Derives prerunArgs from storage using the registered 'prerunArgs' callback.\n * Falls back to 'args' callback if 'prerunArgs' is not defined.\n *\n * @param storageJson - Storage as JSON string\n * @returns ArgsDeriveResult with derived prerunArgs or error\n */\nfunction derivePrerunArgsFromStorage(storageJson: string): ArgsDeriveResult {\n const ctx = tryGetCfgRenderCtx();\n if (ctx === undefined) {\n return { error: 'Not in config rendering context' };\n }\n\n // Extract data from storage\n const { data } = normalizeStorage(storageJson);\n\n // Try prerunArgs callback first\n const prerunArgsCallback = ctx.callbackRegistry['prerunArgs'] as ((data: unknown) => unknown) | undefined;\n if (typeof prerunArgsCallback === 'function') {\n try {\n const result = prerunArgsCallback(data);\n return { value: result };\n } catch (e) {\n const errorMsg = e instanceof Error ? e.message : String(e);\n return { error: `prerunArgs() threw: ${errorMsg}` };\n }\n }\n\n // Fall back to args callback\n const argsCallback = ctx.callbackRegistry['args'] as ((data: unknown) => unknown) | undefined;\n if (typeof argsCallback !== 'function') {\n return { error: 'args callback not found (fallback from missing prerunArgs)' };\n }\n\n try {\n const result = argsCallback(data);\n return { value: result };\n } catch (e) {\n const errorMsg = e instanceof Error ? e.message : String(e);\n return { error: `args() threw (fallback): ${errorMsg}` };\n }\n}\n\n// Register prerunArgs derivation callback\ntryRegisterCallback('__pl_prerunArgs_derive', (storageJson: string) => {\n return derivePrerunArgsFromStorage(storageJson);\n});\n\n// Export discriminator key and schema version for external checks\nexport { BLOCK_STORAGE_KEY, BLOCK_STORAGE_SCHEMA_VERSION };\n"],"names":[],"mappings":";;;;AAAA;;;;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,7 @@ class BlockModel {
|
|
|
38
38
|
output(key, cfgOrRf, flags = {}) {
|
|
39
39
|
if (typeof cfgOrRf === 'function') {
|
|
40
40
|
const handle = `output#${key}`;
|
|
41
|
-
internal.tryRegisterCallback(handle, () => cfgOrRf(new api.
|
|
41
|
+
internal.tryRegisterCallback(handle, () => cfgOrRf(new api.RenderCtxLegacy()));
|
|
42
42
|
return new BlockModel({
|
|
43
43
|
...this.config,
|
|
44
44
|
outputs: {
|
|
@@ -75,7 +75,7 @@ class BlockModel {
|
|
|
75
75
|
}
|
|
76
76
|
argsValid(cfgOrRf) {
|
|
77
77
|
if (typeof cfgOrRf === 'function') {
|
|
78
|
-
internal.tryRegisterCallback('inputsValid', () => cfgOrRf(new api.
|
|
78
|
+
internal.tryRegisterCallback('inputsValid', () => cfgOrRf(new api.RenderCtxLegacy()));
|
|
79
79
|
return new BlockModel({
|
|
80
80
|
...this.config,
|
|
81
81
|
inputsValid: {
|
|
@@ -96,7 +96,7 @@ class BlockModel {
|
|
|
96
96
|
return this.sections(actions.getImmediate(arrOrCfgOrRf));
|
|
97
97
|
}
|
|
98
98
|
else if (typeof arrOrCfgOrRf === 'function') {
|
|
99
|
-
internal.tryRegisterCallback('sections', () => arrOrCfgOrRf(new api.
|
|
99
|
+
internal.tryRegisterCallback('sections', () => arrOrCfgOrRf(new api.RenderCtxLegacy()));
|
|
100
100
|
return new BlockModel({
|
|
101
101
|
...this.config,
|
|
102
102
|
sections: {
|
|
@@ -114,7 +114,7 @@ class BlockModel {
|
|
|
114
114
|
}
|
|
115
115
|
/** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
|
|
116
116
|
title(rf) {
|
|
117
|
-
internal.tryRegisterCallback('title', () => rf(new api.
|
|
117
|
+
internal.tryRegisterCallback('title', () => rf(new api.RenderCtxLegacy()));
|
|
118
118
|
return new BlockModel({
|
|
119
119
|
...this.config,
|
|
120
120
|
title: {
|
|
@@ -124,7 +124,7 @@ class BlockModel {
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
subtitle(rf) {
|
|
127
|
-
internal.tryRegisterCallback('subtitle', () => rf(new api.
|
|
127
|
+
internal.tryRegisterCallback('subtitle', () => rf(new api.RenderCtxLegacy()));
|
|
128
128
|
return new BlockModel({
|
|
129
129
|
...this.config,
|
|
130
130
|
subtitle: {
|
|
@@ -134,7 +134,7 @@ class BlockModel {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
tags(rf) {
|
|
137
|
-
internal.tryRegisterCallback('tags', () => rf(new api.
|
|
137
|
+
internal.tryRegisterCallback('tags', () => rf(new api.RenderCtxLegacy()));
|
|
138
138
|
return new BlockModel({
|
|
139
139
|
...this.config,
|
|
140
140
|
tags: {
|
|
@@ -201,7 +201,10 @@ class BlockModel {
|
|
|
201
201
|
if (this.config.initialArgs === undefined)
|
|
202
202
|
throw new Error('Initial arguments not set.');
|
|
203
203
|
const config = {
|
|
204
|
+
v4: undefined,
|
|
204
205
|
v3: {
|
|
206
|
+
configVersion: 3,
|
|
207
|
+
modelAPIVersion: 1,
|
|
205
208
|
sdkVersion: version.PlatformaSDKVersion,
|
|
206
209
|
renderingMode: this.config.renderingMode,
|
|
207
210
|
initialArgs: this.config.initialArgs,
|
package/dist/builder.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.cjs","sources":["../src/builder.ts"],"sourcesContent":["import type { BlockRenderingMode, BlockSection, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer, OutputWithStatus } from '@milaboratories/pl-model-common';\nimport type { Checked, ConfigResult, TypedConfig } from './config';\nimport { getImmediate } from './config';\nimport { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';\nimport type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from './platforma';\nimport type { InferRenderFunctionReturn, RenderFunction } from './render';\nimport { RenderCtx } from './render';\nimport { PlatformaSDKVersion } from './version';\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ResolveCfgType,\n ExtractFunctionHandleReturn,\n ConfigRenderLambdaFlags,\n} from './bconfig';\nimport {\n downgradeCfgOrLambda,\n isConfigLambda,\n} from './bconfig';\n\ntype SectionsExpectedType = readonly BlockSection[];\n\ntype SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type SectionsRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends SectionsExpectedType ? true : false\n// >;\n\ntype InputsValidExpectedType = boolean;\n\ntype InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type InputsValidRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends InputsValidExpectedType ? true : false\n// >;\n\ntype NoOb = Record<string, never>;\n\n/** Main entry point that each block should use in it's \"config\" module. Don't forget\n * to call {@link done()} at the end of configuration. Value returned by this builder must be\n * exported as constant with name \"platforma\" from the \"config\" module. */\nexport class BlockModel<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n Href extends `/${string}` = '/',\n> {\n private constructor(\n private config: {\n readonly renderingMode: BlockRenderingMode;\n readonly initialArgs?: Args;\n readonly initialUiState: UiState;\n readonly outputs: OutputsCfg;\n readonly inputsValid: TypedConfigOrConfigLambda;\n readonly sections: TypedConfigOrConfigLambda;\n readonly title?: ConfigRenderLambda;\n readonly subtitle?: ConfigRenderLambda;\n readonly tags?: ConfigRenderLambda;\n readonly enrichmentTargets?: ConfigRenderLambda;\n readonly featureFlags: BlockCodeKnownFeatureFlags;\n },\n ) {}\n\n public static get INITIAL_BLOCK_FEATURE_FLAGS(): BlockCodeKnownFeatureFlags {\n return {\n supportsLazyState: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n };\n }\n\n /** Initiates configuration builder */\n public static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;\n /** Initiates configuration builder */\n public static create(): BlockModel<NoOb, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(): BlockModel<Args, {}, NoOb>;\n public static create(renderingMode: BlockRenderingMode = 'Heavy'): BlockModel<NoOb, {}, NoOb> {\n return new BlockModel<NoOb, {}, NoOb>({\n renderingMode,\n initialUiState: {},\n outputs: {},\n inputsValid: getImmediate(true),\n sections: getImmediate([]),\n featureFlags: BlockModel.INITIAL_BLOCK_FEATURE_FLAGS,\n });\n }\n\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param cfg configuration describing how to render cell value from the blocks\n * workflow outputs\n * @deprecated use lambda-based API\n * */\n public output<const Key extends string, const Cfg extends TypedConfig>(\n key: Key,\n cfg: Cfg\n ): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;\n /**\n * Add output cell wrapped with additional status information to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n flags: ConfigRenderLambdaFlags & { withStatus: true }\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true } },\n UiState,\n Href\n >;\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n flags?: ConfigRenderLambdaFlags\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n >;\n public output(\n key: string,\n cfgOrRf: TypedConfig | AnyFunction,\n flags: ConfigRenderLambdaFlags = {},\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n if (typeof cfgOrRf === 'function') {\n const handle = `output#${key}`;\n tryRegisterCallback(handle, () => cfgOrRf(new RenderCtx()));\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n },\n },\n });\n } else {\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: cfgOrRf,\n },\n });\n }\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n ) {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Shortcut for {@link output} with withStatus flag set to true. */\n public outputWithStatus<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n ) {\n return this.output(key, rf, { withStatus: true });\n }\n\n /** Shortcut for {@link output} with retentive and withStatus flags set to true. */\n public retentiveOutputWithStatus<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n ) {\n return this.output(key, rf, { retentive: true, withStatus: true });\n }\n\n /** Sets custom configuration predicate on the block args at which block can be executed\n * @deprecated use lambda-based API */\n public argsValid<Cfg extends TypedConfig>(\n cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n /** Sets custom configuration predicate on the block args at which block can be executed */\n public argsValid<RF extends RenderFunction<Args, UiState, boolean>>(\n rf: RF\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n public argsValid(\n cfgOrRf: TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (typeof cfgOrRf === 'function') {\n tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: {\n __renderLambda: true,\n handle: 'inputsValid',\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: cfgOrRf,\n });\n }\n }\n\n /** Sets the config to generate list of section in the left block overviews panel\n * @deprecated use lambda-based API */\n public sections<const S extends SectionsExpectedType>(\n rf: S\n ): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;\n /** Sets the config to generate list of section in the left block overviews panel */\n public sections<\n const Ret extends SectionsExpectedType,\n const RF extends RenderFunction<Args, UiState, Ret>,\n >(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;\n public sections<const Cfg extends TypedConfig>(\n cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>\n ): BlockModel<\n Args,\n OutputsCfg,\n UiState,\n DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>\n >;\n public sections(\n arrOrCfgOrRf: SectionsExpectedType | TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (Array.isArray(arrOrCfgOrRf)) {\n return this.sections(getImmediate(arrOrCfgOrRf));\n } else if (typeof arrOrCfgOrRf === 'function') {\n tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: {\n __renderLambda: true,\n handle: 'sections',\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: arrOrCfgOrRf as TypedConfig,\n });\n }\n }\n\n /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */\n public title(\n rf: RenderFunction<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('title', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n title: {\n __renderLambda: true,\n handle: 'title',\n },\n });\n }\n\n public subtitle(\n rf: RenderFunction<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('subtitle', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n subtitle: {\n __renderLambda: true,\n handle: 'subtitle',\n },\n });\n }\n\n public tags(\n rf: RenderFunction<Args, UiState, string[]>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('tags', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n tags: {\n __renderLambda: true,\n handle: 'tags',\n },\n });\n }\n\n /**\n * Sets initial args for the block, this value must be specified.\n * @deprecated use {@link withArgs}\n * */\n public initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return this.withArgs(value);\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialArgs: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialArgs,\n });\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(initialUiState: UiState): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialUiState,\n });\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n featureFlags: {\n ...this.config.featureFlags,\n ...flags,\n },\n });\n }\n\n /**\n * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.\n * Influences dependency graph construction.\n */\n public enriches(\n lambda: (args: Args) => PlRef[],\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('enrichmentTargets', lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n enrichmentTargets: {\n __renderLambda: true,\n handle: 'enrichmentTargets',\n },\n });\n }\n\n public done(apiVersion?: 1): PlatformaExtended<PlatformaV1<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >>;\n\n public done(apiVersion: 2): PlatformaExtended<PlatformaV2<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >>;\n\n /** Renders all provided block settings into a pre-configured platforma API\n * instance, that can be used in frontend to interact with block state, and\n * other features provided by the platforma to the block. */\n public done(apiVersion: PlatformaApiVersion = 1): PlatformaExtended<Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >> {\n return this.withFeatureFlags({\n ...this.config.featureFlags,\n requiresUIAPIVersion: apiVersion,\n }).#done();\n }\n\n #done(): PlatformaExtended<Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >> {\n if (this.config.initialArgs === undefined) throw new Error('Initial arguments not set.');\n\n const config: BlockConfigContainer = {\n v3: {\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n initialUiState: this.config.initialUiState,\n inputsValid: this.config.inputsValid,\n sections: this.config.sections,\n title: this.config.title,\n subtitle: this.config.subtitle,\n tags: this.config.tags,\n outputs: this.config.outputs,\n enrichmentTargets: this.config.enrichmentTargets,\n featureFlags: this.config.featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n inputsValid: downgradeCfgOrLambda(this.config.inputsValid),\n sections: downgradeCfgOrLambda(this.config.sections),\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]),\n ),\n };\n\n globalThis.platformaApiVersion = this.config.featureFlags.requiresUIAPIVersion as PlatformaApiVersion;\n\n if (!isInUI())\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n // normal operation inside the UI\n else return {\n ...getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }),\n blockModelInfo: {\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs)\n .map(([key, value]) => [key, {\n withStatus: Boolean(isConfigLambda(value) && value.withStatus),\n }]),\n ),\n },\n };\n }\n}\n\nexport type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig\n ? ResolveCfgType<CfgOrFH, Args, UiState>\n : CfgOrFH extends ConfigRenderLambda\n ? ExtractFunctionHandleReturn<CfgOrFH>\n : never;\n\ntype InferOutputsFromConfigs<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n> = {\n [Key in keyof OutputsCfg]:\n & OutputWithStatus<InferOutputType<OutputsCfg[Key], Args, UiState>>\n & { __unwrap: (OutputsCfg[Key] extends { withStatus: true } ? false : true) };\n};\n\nexport type PlatformaExtended<Pl extends Platforma = Platforma> = Pl & {\n blockModelInfo: BlockModelInfo;\n};\n\nexport type BlockModelInfo = {\n outputs: Record<string, {\n withStatus: boolean;\n }>;\n};\n"],"names":["getImmediate","tryRegisterCallback","RenderCtx","PlatformaSDKVersion","downgradeCfgOrLambda","isInUI","getPlatformaInstance","isConfigLambda"],"mappings":";;;;;;;;;;;;AAkDA;;AAE0E;MAC7D,UAAU,CAAA;AAOX,IAAA,MAAA;AADV,IAAA,WAAA,CACU,MAYP,EAAA;QAZO,IAAA,CAAA,MAAM,GAAN,MAAM;IAab;AAEI,IAAA,WAAW,2BAA2B,GAAA;QAC3C,OAAO;AACL,YAAA,iBAAiB,EAA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,CAAC,CAAC,CAAC,CAC9F;SACF;QAED,UAAU,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,oBAA2C;QAErG,IAAI,CAACC,eAAM,EAAE;;YAEX,OAAO,EAAE,MAAM,EAAS;;;YAErB,OAAO;gBACV,GAAGC,6BAAoB,CAAC,EAAE,UAAU,EAAEH,2BAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC;AAC7F,gBAAA,cAAc,EAAE;AACd,oBAAA,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;AAC/B,yBAAA,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE;4BAC3B,UAAU,EAAE,OAAO,CAACI,oBAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC;AAC/D,yBAAA,CAAC,CAAC,CACN;AACF,iBAAA;aACF;IACH;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"builder.cjs","sources":["../src/builder.ts"],"sourcesContent":["import type { BlockRenderingMode, BlockSection, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer } from '@milaboratories/pl-model-common';\nimport type { Checked, ConfigResult, TypedConfig } from './config';\nimport { getImmediate } from './config';\nimport { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';\nimport type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from './platforma';\nimport type { InferRenderFunctionReturn, RenderFunctionLegacy } from './render';\nimport { RenderCtxLegacy } from './render';\nimport { PlatformaSDKVersion } from './version';\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ConfigRenderLambdaFlags,\n InferOutputsFromConfigs,\n} from './bconfig';\nimport {\n downgradeCfgOrLambda,\n isConfigLambda,\n} from './bconfig';\nimport type { PlatformaExtended } from './platforma';\n\ntype SectionsExpectedType = readonly BlockSection[];\n\ntype SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false\n>;\n\ntype InputsValidExpectedType = boolean;\n\ntype InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false\n>;\n\ntype NoOb = Record<string, never>;\n\n/** Main entry point that each block should use in it's \"config\" module. Don't forget\n * to call {@link done()} at the end of configuration. Value returned by this builder must be\n * exported as constant with name \"platforma\" from the \"config\" module. */\nexport class BlockModel<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n Href extends `/${string}` = '/',\n> {\n private constructor(\n private config: {\n readonly renderingMode: BlockRenderingMode;\n readonly initialArgs?: Args;\n readonly initialUiState: UiState;\n readonly outputs: OutputsCfg;\n readonly inputsValid: TypedConfigOrConfigLambda;\n readonly sections: TypedConfigOrConfigLambda;\n readonly title?: ConfigRenderLambda;\n readonly subtitle?: ConfigRenderLambda;\n readonly tags?: ConfigRenderLambda;\n readonly enrichmentTargets?: ConfigRenderLambda;\n readonly featureFlags: BlockCodeKnownFeatureFlags;\n },\n ) {}\n\n public static get INITIAL_BLOCK_FEATURE_FLAGS(): BlockCodeKnownFeatureFlags {\n return {\n supportsLazyState: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n };\n }\n\n /** Initiates configuration builder */\n public static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;\n /** Initiates configuration builder */\n public static create(): BlockModel<NoOb, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(): BlockModel<Args, {}, NoOb>;\n public static create(renderingMode: BlockRenderingMode = 'Heavy'): BlockModel<NoOb, {}, NoOb> {\n return new BlockModel<NoOb, {}, NoOb>({\n renderingMode,\n initialUiState: {},\n outputs: {},\n inputsValid: getImmediate(true),\n sections: getImmediate([]),\n featureFlags: BlockModel.INITIAL_BLOCK_FEATURE_FLAGS,\n });\n }\n\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param cfg configuration describing how to render cell value from the blocks\n * workflow outputs\n * @deprecated use lambda-based API\n * */\n public output<const Key extends string, const Cfg extends TypedConfig>(\n key: Key,\n cfg: Cfg\n ): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;\n /**\n * Add output cell wrapped with additional status information to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n flags: ConfigRenderLambdaFlags & { withStatus: true }\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true } },\n UiState,\n Href\n >;\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n flags?: ConfigRenderLambdaFlags\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n >;\n public output(\n key: string,\n cfgOrRf: TypedConfig | AnyFunction,\n flags: ConfigRenderLambdaFlags = {},\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n if (typeof cfgOrRf === 'function') {\n const handle = `output#${key}`;\n tryRegisterCallback(handle, () => cfgOrRf(new RenderCtxLegacy()));\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n },\n },\n });\n } else {\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: cfgOrRf,\n },\n });\n }\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n ) {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Shortcut for {@link output} with withStatus flag set to true. */\n public outputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n ) {\n return this.output(key, rf, { withStatus: true });\n }\n\n /** Shortcut for {@link output} with retentive and withStatus flags set to true. */\n public retentiveOutputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n ) {\n return this.output(key, rf, { retentive: true, withStatus: true });\n }\n\n /** Sets custom configuration predicate on the block args at which block can be executed\n * @deprecated use lambda-based API */\n public argsValid<Cfg extends TypedConfig>(\n cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n /** Sets custom configuration predicate on the block args at which block can be executed */\n public argsValid<RF extends RenderFunctionLegacy<Args, UiState, boolean>>(\n rf: RF\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n public argsValid(\n cfgOrRf: TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (typeof cfgOrRf === 'function') {\n tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: {\n __renderLambda: true,\n handle: 'inputsValid',\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: cfgOrRf,\n });\n }\n }\n\n /** Sets the config to generate list of section in the left block overviews panel\n * @deprecated use lambda-based API */\n public sections<const S extends SectionsExpectedType>(\n rf: S\n ): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;\n /** Sets the config to generate list of section in the left block overviews panel */\n public sections<\n const Ret extends SectionsExpectedType,\n const RF extends RenderFunctionLegacy<Args, UiState, Ret>,\n >(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;\n public sections<const Cfg extends TypedConfig>(\n cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>\n ): BlockModel<\n Args,\n OutputsCfg,\n UiState,\n DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>\n >;\n public sections(\n arrOrCfgOrRf: SectionsExpectedType | TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (Array.isArray(arrOrCfgOrRf)) {\n return this.sections(getImmediate(arrOrCfgOrRf));\n } else if (typeof arrOrCfgOrRf === 'function') {\n tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: {\n __renderLambda: true,\n handle: 'sections',\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: arrOrCfgOrRf as TypedConfig,\n });\n }\n }\n\n /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */\n public title(\n rf: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('title', () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n title: {\n __renderLambda: true,\n handle: 'title',\n },\n });\n }\n\n public subtitle(\n rf: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('subtitle', () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n subtitle: {\n __renderLambda: true,\n handle: 'subtitle',\n },\n });\n }\n\n public tags(\n rf: RenderFunctionLegacy<Args, UiState, string[]>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('tags', () => rf(new RenderCtxLegacy()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n tags: {\n __renderLambda: true,\n handle: 'tags',\n },\n });\n }\n\n /**\n * Sets initial args for the block, this value must be specified.\n * @deprecated use {@link withArgs}\n * */\n public initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return this.withArgs(value);\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialArgs: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialArgs,\n });\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(initialUiState: UiState): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialUiState,\n });\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n featureFlags: {\n ...this.config.featureFlags,\n ...flags,\n },\n });\n }\n\n /**\n * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.\n * Influences dependency graph construction.\n */\n public enriches(\n lambda: (args: Args) => PlRef[],\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('enrichmentTargets', lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n enrichmentTargets: {\n __renderLambda: true,\n handle: 'enrichmentTargets',\n },\n });\n }\n\n public done(apiVersion?: 1): PlatformaExtended<PlatformaV1<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >>;\n\n public done(apiVersion: 2): PlatformaExtended<PlatformaV2<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >>;\n\n /** Renders all provided block settings into a pre-configured platforma API\n * instance, that can be used in frontend to interact with block state, and\n * other features provided by the platforma to the block. */\n public done(apiVersion: PlatformaApiVersion = 1): PlatformaExtended<Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >> {\n return this.withFeatureFlags({\n ...this.config.featureFlags,\n requiresUIAPIVersion: apiVersion,\n }).#done();\n }\n\n #done(): PlatformaExtended<Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >> {\n if (this.config.initialArgs === undefined) throw new Error('Initial arguments not set.');\n\n const config: BlockConfigContainer = {\n v4: undefined,\n v3: {\n configVersion: 3,\n modelAPIVersion: 1,\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n initialUiState: this.config.initialUiState,\n inputsValid: this.config.inputsValid,\n sections: this.config.sections,\n title: this.config.title,\n subtitle: this.config.subtitle,\n tags: this.config.tags,\n outputs: this.config.outputs,\n enrichmentTargets: this.config.enrichmentTargets,\n featureFlags: this.config.featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n inputsValid: downgradeCfgOrLambda(this.config.inputsValid),\n sections: downgradeCfgOrLambda(this.config.sections),\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]),\n ),\n };\n\n globalThis.platformaApiVersion = this.config.featureFlags.requiresUIAPIVersion as PlatformaApiVersion;\n\n if (!isInUI())\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n // normal operation inside the UI\n else return {\n ...getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }),\n blockModelInfo: {\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs)\n .map(([key, value]) => [key, {\n withStatus: Boolean(isConfigLambda(value) && value.withStatus),\n }]),\n ),\n },\n };\n }\n}\n"],"names":["getImmediate","tryRegisterCallback","RenderCtxLegacy","PlatformaSDKVersion","downgradeCfgOrLambda","isInUI","getPlatformaInstance","isConfigLambda"],"mappings":";;;;;;;;;;;;AAsCA;;AAE0E;MAC7D,UAAU,CAAA;AAOX,IAAA,MAAA;AADV,IAAA,WAAA,CACU,MAYP,EAAA;QAZO,IAAA,CAAA,MAAM,GAAN,MAAM;IAab;AAEI,IAAA,WAAW,2BAA2B,GAAA;QAC3C,OAAO;AACL,YAAA,iBAAiB,EAAE,IAAI;AACvB,YAAA,oBAAoB,EAAE,CAAC;AACvB,YAAA,uBAAuB,EAAE,CAAC;SAC3B;IACH;AAgBO,IAAA,OAAO,MAAM,CAAC,aAAA,GAAoC,OAAO,EAAA;QAC9D,OAAO,IAAI,UAAU,CAAiB;YACpC,aAAa;AACb,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,WAAW,EAAEA,oBAAY,CAAC,IAAI,CAAC;AAC/B,YAAA,QAAQ,EAAEA,oBAAY,CAAC,EAAE,CAAC;YAC1B,YAAY,EAAE,UAAU,CAAC,2BAA2B;AACrD,SAAA,CAAC;IACJ;AAkDO,IAAA,MAAM,CACX,GAAW,EACX,OAAkC,EAClC,QAAiC,EAAE,EAAA;AAEnC,QAAA,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;AACjC,YAAA,MAAM,MAAM,GAAG,CAAA,OAAA,EAAU,GAAG,EAAE;AAC9B,YAAAC,4BAAmB,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAIC,mBAAe,EAAE,CAAC,CAAC;YACjE,OAAO,IAAI,UAAU,CAAC;gBACpB,G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AAA;aACF;IACH;AACD;;;;"}
|
package/dist/builder.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { BlockRenderingMode, BlockSection, PlRef, BlockCodeKnownFeatureFlags
|
|
1
|
+
import type { BlockRenderingMode, BlockSection, PlRef, BlockCodeKnownFeatureFlags } from '@milaboratories/pl-model-common';
|
|
2
2
|
import type { Checked, ConfigResult, TypedConfig } from './config';
|
|
3
|
-
import type {
|
|
4
|
-
import type { InferRenderFunctionReturn,
|
|
5
|
-
import type { TypedConfigOrConfigLambda, ConfigRenderLambda, StdCtxArgsOnly, DeriveHref,
|
|
3
|
+
import type { PlatformaV1, PlatformaV2 } from './platforma';
|
|
4
|
+
import type { InferRenderFunctionReturn, RenderFunctionLegacy } from './render';
|
|
5
|
+
import type { TypedConfigOrConfigLambda, ConfigRenderLambda, StdCtxArgsOnly, DeriveHref, ConfigRenderLambdaFlags, InferOutputsFromConfigs } from './bconfig';
|
|
6
|
+
import type { PlatformaExtended } from './platforma';
|
|
6
7
|
type SectionsExpectedType = readonly BlockSection[];
|
|
7
8
|
type SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<Cfg, ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false>;
|
|
8
9
|
type InputsValidExpectedType = boolean;
|
|
@@ -49,7 +50,7 @@ export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedCon
|
|
|
49
50
|
* workflows outputs and interact with platforma drivers
|
|
50
51
|
* @param flags additional flags that may alter lambda rendering procedure
|
|
51
52
|
* */
|
|
52
|
-
output<const Key extends string, const RF extends
|
|
53
|
+
output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF, flags: ConfigRenderLambdaFlags & {
|
|
53
54
|
withStatus: true;
|
|
54
55
|
}): BlockModel<Args, OutputsCfg & {
|
|
55
56
|
[K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & {
|
|
@@ -64,34 +65,34 @@ export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedCon
|
|
|
64
65
|
* workflows outputs and interact with platforma drivers
|
|
65
66
|
* @param flags additional flags that may alter lambda rendering procedure
|
|
66
67
|
* */
|
|
67
|
-
output<const Key extends string, const RF extends
|
|
68
|
+
output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF, flags?: ConfigRenderLambdaFlags): BlockModel<Args, OutputsCfg & {
|
|
68
69
|
[K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>>;
|
|
69
70
|
}, UiState, Href>;
|
|
70
71
|
/** Shortcut for {@link output} with retentive flag set to true. */
|
|
71
|
-
retentiveOutput<const Key extends string, const RF extends
|
|
72
|
+
retentiveOutput<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>>; }, UiState, Href>;
|
|
72
73
|
/** Shortcut for {@link output} with withStatus flag set to true. */
|
|
73
|
-
outputWithStatus<const Key extends string, const RF extends
|
|
74
|
+
outputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & {
|
|
74
75
|
withStatus: true;
|
|
75
76
|
}; }, UiState, Href>;
|
|
76
77
|
/** Shortcut for {@link output} with retentive and withStatus flags set to true. */
|
|
77
|
-
retentiveOutputWithStatus<const Key extends string, const RF extends
|
|
78
|
+
retentiveOutputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & {
|
|
78
79
|
withStatus: true;
|
|
79
80
|
}; }, UiState, Href>;
|
|
80
81
|
/** Sets custom configuration predicate on the block args at which block can be executed
|
|
81
82
|
* @deprecated use lambda-based API */
|
|
82
83
|
argsValid<Cfg extends TypedConfig>(cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
83
84
|
/** Sets custom configuration predicate on the block args at which block can be executed */
|
|
84
|
-
argsValid<RF extends
|
|
85
|
+
argsValid<RF extends RenderFunctionLegacy<Args, UiState, boolean>>(rf: RF): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
85
86
|
/** Sets the config to generate list of section in the left block overviews panel
|
|
86
87
|
* @deprecated use lambda-based API */
|
|
87
88
|
sections<const S extends SectionsExpectedType>(rf: S): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;
|
|
88
89
|
/** Sets the config to generate list of section in the left block overviews panel */
|
|
89
|
-
sections<const Ret extends SectionsExpectedType, const RF extends
|
|
90
|
+
sections<const Ret extends SectionsExpectedType, const RF extends RenderFunctionLegacy<Args, UiState, Ret>>(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;
|
|
90
91
|
sections<const Cfg extends TypedConfig>(cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>>;
|
|
91
92
|
/** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
|
|
92
|
-
title(rf:
|
|
93
|
-
subtitle(rf:
|
|
94
|
-
tags(rf:
|
|
93
|
+
title(rf: RenderFunctionLegacy<Args, UiState, string>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
94
|
+
subtitle(rf: RenderFunctionLegacy<Args, UiState, string>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
95
|
+
tags(rf: RenderFunctionLegacy<Args, UiState, string[]>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
95
96
|
/**
|
|
96
97
|
* Sets initial args for the block, this value must be specified.
|
|
97
98
|
* @deprecated use {@link withArgs}
|
|
@@ -111,21 +112,5 @@ export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedCon
|
|
|
111
112
|
done(apiVersion?: 1): PlatformaExtended<PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>>;
|
|
112
113
|
done(apiVersion: 2): PlatformaExtended<PlatformaV2<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>>;
|
|
113
114
|
}
|
|
114
|
-
export type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig ? ResolveCfgType<CfgOrFH, Args, UiState> : CfgOrFH extends ConfigRenderLambda ? ExtractFunctionHandleReturn<CfgOrFH> : never;
|
|
115
|
-
type InferOutputsFromConfigs<Args, OutputsCfg extends Record<string, TypedConfigOrConfigLambda>, UiState> = {
|
|
116
|
-
[Key in keyof OutputsCfg]: OutputWithStatus<InferOutputType<OutputsCfg[Key], Args, UiState>> & {
|
|
117
|
-
__unwrap: (OutputsCfg[Key] extends {
|
|
118
|
-
withStatus: true;
|
|
119
|
-
} ? false : true);
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
export type PlatformaExtended<Pl extends Platforma = Platforma> = Pl & {
|
|
123
|
-
blockModelInfo: BlockModelInfo;
|
|
124
|
-
};
|
|
125
|
-
export type BlockModelInfo = {
|
|
126
|
-
outputs: Record<string, {
|
|
127
|
-
withStatus: boolean;
|
|
128
|
-
}>;
|
|
129
|
-
};
|
|
130
115
|
export {};
|
|
131
116
|
//# sourceMappingURL=builder.d.ts.map
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAe,KAAK,EAAE,0BAA0B,EAAwB,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB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