@platforma-sdk/model 1.96.1 → 1.97.0
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/block_model.cjs +93 -6
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +64 -2
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +95 -8
- package/dist/block_model.js.map +1 -1
- package/dist/block_storage_callbacks.cjs +46 -0
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js +46 -1
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/block_storage_facade.cjs +25 -5
- package/dist/block_storage_facade.cjs.map +1 -1
- package/dist/block_storage_facade.d.ts +39 -2
- package/dist/block_storage_facade.d.ts.map +1 -1
- package/dist/block_storage_facade.js +25 -6
- package/dist/block_storage_facade.js.map +1 -1
- package/dist/filters/converters/filterToQuery.cjs.map +1 -1
- package/dist/filters/converters/filterToQuery.d.ts +6 -2
- package/dist/filters/converters/filterToQuery.d.ts.map +1 -1
- package/dist/filters/converters/filterToQuery.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +5 -5
- package/src/apply_params.test.ts +330 -0
- package/src/block_model.ts +120 -4
- package/src/block_storage_callbacks.ts +74 -0
- package/src/block_storage_facade.ts +51 -4
- package/src/filters/converters/filterToQuery.ts +6 -3
|
@@ -85,6 +85,16 @@ export const BlockStorageFacadeCallbacks = {
|
|
|
85
85
|
InitializationParamsDerive: "__pl_initializationParams_derive",
|
|
86
86
|
StorageInitialFromParams: "__pl_storage_initialFromParams",
|
|
87
87
|
InitializationParamsValidate: "__pl_initializationParams_validate",
|
|
88
|
+
StorageApplyParams: "__pl_storage_applyParams",
|
|
89
|
+
} as const;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Callbacks a block registers only when its model declares what they run. A block's config lists
|
|
93
|
+
* their handles only then, so whoever reads the config knows whether it may call them; the
|
|
94
|
+
* defaults filled in for a config that lists no callbacks leave them out.
|
|
95
|
+
*/
|
|
96
|
+
const OptionalFacadeCallbacks = {
|
|
97
|
+
StorageApplyParams: BlockStorageFacadeCallbacks.StorageApplyParams,
|
|
88
98
|
} as const;
|
|
89
99
|
|
|
90
100
|
/**
|
|
@@ -99,11 +109,19 @@ function createFacadeHandles<T extends Record<string, string>>(
|
|
|
99
109
|
) as { [K in T[keyof T]]: ConfigRenderLambda };
|
|
100
110
|
}
|
|
101
111
|
|
|
112
|
+
const { StorageApplyParams: _optional, ...requiredFacadeCallbacks } = BlockStorageFacadeCallbacks;
|
|
113
|
+
|
|
102
114
|
/**
|
|
103
|
-
* Lambda handles
|
|
115
|
+
* Lambda handles of the facade callbacks every block registers.
|
|
104
116
|
* Used by the middle layer to invoke callbacks via executeSingleLambda().
|
|
105
117
|
*/
|
|
106
|
-
export const BlockStorageFacadeHandles = createFacadeHandles(
|
|
118
|
+
export const BlockStorageFacadeHandles = createFacadeHandles(requiredFacadeCallbacks);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Lambda handles of the facade callbacks a block registers only when its model declares what
|
|
122
|
+
* they run (see {@link BlockStorageFacadeCallbacks.StorageApplyParams}).
|
|
123
|
+
*/
|
|
124
|
+
export const BlockStorageFacadeOptionalHandles = createFacadeHandles(OptionalFacadeCallbacks);
|
|
107
125
|
|
|
108
126
|
// =============================================================================
|
|
109
127
|
// Facade Interface (source of truth for callback signatures)
|
|
@@ -316,11 +334,40 @@ export interface BlockStorageFacade {
|
|
|
316
334
|
[BlockStorageFacadeCallbacks.InitializationParamsValidate]: (
|
|
317
335
|
paramsJson: StringifiedJson,
|
|
318
336
|
) => { error: string } | { error?: undefined };
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Put params onto the block's live data with the block's own `applyParams`.
|
|
340
|
+
*
|
|
341
|
+
* Registered, and listed in the block's config, only when the block declares `applyParams`
|
|
342
|
+
* (`BlockModelV3.applyParams`); a block without it, or bundled with an older SDK, has no such
|
|
343
|
+
* callback, and the caller builds data from params with
|
|
344
|
+
* {@link BlockStorageFacadeCallbacks.StorageInitialFromParams} instead.
|
|
345
|
+
*
|
|
346
|
+
* The params get what the from-params path gives them: the readable reference spelling is
|
|
347
|
+
* expanded and the kind's parser checks them; its output is what `applyParams` gets. They are
|
|
348
|
+
* live params, so nothing is relocated: references name blocks of this project.
|
|
349
|
+
*
|
|
350
|
+
* The data must be at the data model's current version, the one `applyParams` is written
|
|
351
|
+
* against; data waiting for a migration is refused. Plugin data and everything else in the
|
|
352
|
+
* storage stay as they are. Nothing is written: the caller decides what to do with the result.
|
|
353
|
+
*
|
|
354
|
+
* @param storageJson - Current storage as JSON string
|
|
355
|
+
* @param paramsJson - The new params as JSON string, whole
|
|
356
|
+
* @returns Either an error, or the storage with the params applied as JSON string
|
|
357
|
+
*/
|
|
358
|
+
[BlockStorageFacadeCallbacks.StorageApplyParams]?: (
|
|
359
|
+
storageJson: StringifiedJson,
|
|
360
|
+
paramsJson: StringifiedJson,
|
|
361
|
+
) => { error: string } | { error?: undefined; storageJson: StringifiedJson };
|
|
319
362
|
}
|
|
320
363
|
|
|
321
|
-
/**
|
|
364
|
+
/**
|
|
365
|
+
* Register all facade callbacks at once. The types ensure every required callback is provided;
|
|
366
|
+
* an optional one left undefined is not registered.
|
|
367
|
+
*/
|
|
322
368
|
export function registerFacadeCallbacks(callbacks: BlockStorageFacade): void {
|
|
323
369
|
for (const key of Object.values(BlockStorageFacadeCallbacks)) {
|
|
324
|
-
|
|
370
|
+
const callback = callbacks[key];
|
|
371
|
+
if (callback !== undefined) tryRegisterCallback(key, callback as (...args: any[]) => any);
|
|
325
372
|
}
|
|
326
373
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assertNever } from "@milaboratories/pl-model-common";
|
|
2
2
|
import type {
|
|
3
|
-
AxisId,
|
|
4
3
|
ColumnUniversalId,
|
|
5
4
|
FilterSpec,
|
|
6
5
|
FilterSpecLeaf,
|
|
@@ -11,7 +10,11 @@ import { traverseFilterSpec } from "../traverse";
|
|
|
11
10
|
|
|
12
11
|
export type QueryColumnIdAxis = {
|
|
13
12
|
type: "axis";
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The axis: a whole axis id (`AxisId`), or a selector the engine matches against the axes of the
|
|
15
|
+
* query (it refuses a selector that matches no axis or several).
|
|
16
|
+
*/
|
|
17
|
+
id: SingleAxisSelector;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
export type QueryColumnIdColumn = {
|
|
@@ -25,7 +28,7 @@ export type QueryColumnId = QueryColumnIdAxis | QueryColumnIdColumn;
|
|
|
25
28
|
/** Converts a QueryColumnId object into a SpecQueryExpression reference. */
|
|
26
29
|
function resolveColumnRef(col: QueryColumnId): SpecQueryExpression {
|
|
27
30
|
return col.type === "axis"
|
|
28
|
-
? { type: "axisRef", value: col.id
|
|
31
|
+
? { type: "axisRef", value: col.id }
|
|
29
32
|
: { type: "columnRef", value: col.id };
|
|
30
33
|
}
|
|
31
34
|
|