@platforma-sdk/model 1.96.4 → 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 +2 -2
- 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
|
@@ -26,9 +26,10 @@ export declare const BlockStorageFacadeCallbacks: {
|
|
|
26
26
|
readonly InitializationParamsDerive: "__pl_initializationParams_derive";
|
|
27
27
|
readonly StorageInitialFromParams: "__pl_storage_initialFromParams";
|
|
28
28
|
readonly InitializationParamsValidate: "__pl_initializationParams_validate";
|
|
29
|
+
readonly StorageApplyParams: "__pl_storage_applyParams";
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
31
|
-
* Lambda handles
|
|
32
|
+
* Lambda handles of the facade callbacks every block registers.
|
|
32
33
|
* Used by the middle layer to invoke callbacks via executeSingleLambda().
|
|
33
34
|
*/
|
|
34
35
|
export declare const BlockStorageFacadeHandles: {
|
|
@@ -42,6 +43,13 @@ export declare const BlockStorageFacadeHandles: {
|
|
|
42
43
|
__pl_storage_initialFromParams: ConfigRenderLambda<unknown>;
|
|
43
44
|
__pl_storage_migrate: ConfigRenderLambda<unknown>;
|
|
44
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Lambda handles of the facade callbacks a block registers only when its model declares what
|
|
48
|
+
* they run (see {@link BlockStorageFacadeCallbacks.StorageApplyParams}).
|
|
49
|
+
*/
|
|
50
|
+
export declare const BlockStorageFacadeOptionalHandles: {
|
|
51
|
+
__pl_storage_applyParams: ConfigRenderLambda<unknown>;
|
|
52
|
+
};
|
|
45
53
|
/**
|
|
46
54
|
* The complete facade interface between bundled blocks (SDK) and middle layer.
|
|
47
55
|
*
|
|
@@ -250,7 +258,36 @@ export interface BlockStorageFacade {
|
|
|
250
258
|
} | {
|
|
251
259
|
error?: undefined;
|
|
252
260
|
};
|
|
261
|
+
/**
|
|
262
|
+
* Put params onto the block's live data with the block's own `applyParams`.
|
|
263
|
+
*
|
|
264
|
+
* Registered, and listed in the block's config, only when the block declares `applyParams`
|
|
265
|
+
* (`BlockModelV3.applyParams`); a block without it, or bundled with an older SDK, has no such
|
|
266
|
+
* callback, and the caller builds data from params with
|
|
267
|
+
* {@link BlockStorageFacadeCallbacks.StorageInitialFromParams} instead.
|
|
268
|
+
*
|
|
269
|
+
* The params get what the from-params path gives them: the readable reference spelling is
|
|
270
|
+
* expanded and the kind's parser checks them; its output is what `applyParams` gets. They are
|
|
271
|
+
* live params, so nothing is relocated: references name blocks of this project.
|
|
272
|
+
*
|
|
273
|
+
* The data must be at the data model's current version, the one `applyParams` is written
|
|
274
|
+
* against; data waiting for a migration is refused. Plugin data and everything else in the
|
|
275
|
+
* storage stay as they are. Nothing is written: the caller decides what to do with the result.
|
|
276
|
+
*
|
|
277
|
+
* @param storageJson - Current storage as JSON string
|
|
278
|
+
* @param paramsJson - The new params as JSON string, whole
|
|
279
|
+
* @returns Either an error, or the storage with the params applied as JSON string
|
|
280
|
+
*/
|
|
281
|
+
[BlockStorageFacadeCallbacks.StorageApplyParams]?: (storageJson: StringifiedJson, paramsJson: StringifiedJson) => {
|
|
282
|
+
error: string;
|
|
283
|
+
} | {
|
|
284
|
+
error?: undefined;
|
|
285
|
+
storageJson: StringifiedJson;
|
|
286
|
+
};
|
|
253
287
|
}
|
|
254
|
-
/**
|
|
288
|
+
/**
|
|
289
|
+
* Register all facade callbacks at once. The types ensure every required callback is provided;
|
|
290
|
+
* an optional one left undefined is not registered.
|
|
291
|
+
*/
|
|
255
292
|
export declare function registerFacadeCallbacks(callbacks: BlockStorageFacade): void;
|
|
256
293
|
//# sourceMappingURL=block_storage_facade.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_storage_facade.d.ts","names":[],"sources":["../src/block_storage_facade.ts"],"mappings":";;;;;;;;qBA8Da;;;;;;;;;;qBAeA;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;
|
|
1
|
+
{"version":3,"file":"block_storage_facade.d.ts","names":[],"sources":["../src/block_storage_facade.ts"],"mappings":";;;;;;;;qBA8Da;;;;;;;;;;qBAeA;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;qBA8BW;;;;;;;;;;;;;;;qBAMA;;;;;;;;;;;;;;;;;;;;;;;iBA0BI;;;;;;;;GAQd,4BAA4B,sBAC3B,oBAAoB,iBACpB,SAAS,yBACN;;;;;;;GAQJ,4BAA4B,oBAC3B,aAAa,gCACV;;;;;;;GAQJ,4BAA4B,kBAC3B,oBAAoB;IAEhB;;IAEA;IACA,gBAAgB;IAChB;;;;;;;;;;;;;;;;;;GAmBL,4BAA4B,cAC3B,aAAa;IAET;;IACA;IAAe;IAAe,QAAQ;;IACtC;IAAmB;IAAgB,QAAQ;;;;;;;;;;;;;;;;;;;;;;GAsBhD,4BAA4B,oBAC3B,aAAa;IAET;;IACA;IAAe,QAAQ;;IACvB;IAAmB;IAAgB,QAAQ;;;;;;;GAOhD,4BAA4B,uBAAuB;;;;;;;;;;;;;;;;;GAkBnD,4BAA4B,8BAC3B,aAAa;IACR;;IAAoB;IAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6C7C,4BAA4B,4BAC3B,YAAY,iBACZ,cAAc;IACT;;IAAoB;IAAmB,aAAa;;;;;;;;;;;;;;;;;;;;;;GAsB1D,4BAA4B,gCAC3B,YAAY;IACP;;IAAoB;;;;;;;;;;;;;;;;;;;;;;GAsB1B,4BAA4B,uBAC3B,aAAa,iBACb,YAAY;IACP;;IAAoB;IAAmB,aAAa;;;;;;;wBAO7C,wBAAwB,WAAW"}
|
|
@@ -23,24 +23,43 @@ const BlockStorageFacadeCallbacks = {
|
|
|
23
23
|
StorageInitial: "__pl_storage_initial",
|
|
24
24
|
InitializationParamsDerive: "__pl_initializationParams_derive",
|
|
25
25
|
StorageInitialFromParams: "__pl_storage_initialFromParams",
|
|
26
|
-
InitializationParamsValidate: "__pl_initializationParams_validate"
|
|
26
|
+
InitializationParamsValidate: "__pl_initializationParams_validate",
|
|
27
|
+
StorageApplyParams: "__pl_storage_applyParams"
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
30
|
+
* Callbacks a block registers only when its model declares what they run. A block's config lists
|
|
31
|
+
* their handles only then, so whoever reads the config knows whether it may call them; the
|
|
32
|
+
* defaults filled in for a config that lists no callbacks leave them out.
|
|
33
|
+
*/
|
|
34
|
+
const OptionalFacadeCallbacks = { StorageApplyParams: BlockStorageFacadeCallbacks.StorageApplyParams };
|
|
35
|
+
/**
|
|
29
36
|
* Creates a map of lambda handles from a callbacks constant object.
|
|
30
37
|
* Keys are the callback string values (e.g., '__pl_storage_applyUpdate').
|
|
31
38
|
*/
|
|
32
39
|
function createFacadeHandles(callbacks) {
|
|
33
40
|
return Object.fromEntries(Object.values(callbacks).map((handle) => [handle, createRenderLambda({ handle })]));
|
|
34
41
|
}
|
|
42
|
+
const { StorageApplyParams: _optional, ...requiredFacadeCallbacks } = BlockStorageFacadeCallbacks;
|
|
35
43
|
/**
|
|
36
|
-
* Lambda handles
|
|
44
|
+
* Lambda handles of the facade callbacks every block registers.
|
|
37
45
|
* Used by the middle layer to invoke callbacks via executeSingleLambda().
|
|
38
46
|
*/
|
|
39
|
-
const BlockStorageFacadeHandles = createFacadeHandles(
|
|
40
|
-
/**
|
|
47
|
+
const BlockStorageFacadeHandles = createFacadeHandles(requiredFacadeCallbacks);
|
|
48
|
+
/**
|
|
49
|
+
* Lambda handles of the facade callbacks a block registers only when its model declares what
|
|
50
|
+
* they run (see {@link BlockStorageFacadeCallbacks.StorageApplyParams}).
|
|
51
|
+
*/
|
|
52
|
+
const BlockStorageFacadeOptionalHandles = createFacadeHandles(OptionalFacadeCallbacks);
|
|
53
|
+
/**
|
|
54
|
+
* Register all facade callbacks at once. The types ensure every required callback is provided;
|
|
55
|
+
* an optional one left undefined is not registered.
|
|
56
|
+
*/
|
|
41
57
|
function registerFacadeCallbacks(callbacks) {
|
|
42
|
-
for (const key of Object.values(BlockStorageFacadeCallbacks))
|
|
58
|
+
for (const key of Object.values(BlockStorageFacadeCallbacks)) {
|
|
59
|
+
const callback = callbacks[key];
|
|
60
|
+
if (callback !== void 0) tryRegisterCallback(key, callback);
|
|
61
|
+
}
|
|
43
62
|
}
|
|
44
|
-
export { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, registerFacadeCallbacks };
|
|
63
|
+
export { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, BlockStorageFacadeOptionalHandles, registerFacadeCallbacks };
|
|
45
64
|
|
|
46
65
|
//# sourceMappingURL=block_storage_facade.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_storage_facade.js","names":[],"sources":["../src/block_storage_facade.ts"],"sourcesContent":["/**\n * Block Storage Facade - Contract between bundled blocks and middle layer.\n *\n * ============================================================================\n * VERSIONING\n * ============================================================================\n *\n * Blocks declare their model API version via the `requiresModelAPIVersion` feature flag\n * (see BlockCodeKnownFeatureFlags). This determines how the middle layer manages block state:\n *\n * - Version 1: Legacy BlockModel - state is {args, uiState}, managed directly by middle layer\n * - Version 2: BlockModelV3 - uses blockStorage with VM-based callbacks (this facade)\n *\n * This facade (BlockStorageFacade) is used by blocks with `requiresModelAPIVersion: 2`.\n * The version number matches the model API version for clarity.\n *\n * ============================================================================\n * BACKWARD COMPATIBILITY WARNING\n * ============================================================================\n *\n * This file documents the FACADE between the SDK (bundled into blocks) and the\n * middle layer. Once a block is published, its SDK version is frozen. The middle\n * layer must support ALL previously released callback signatures indefinitely.\n *\n * RULES:\n * 1. NEVER change the signature of existing callbacks\n * 2. NEVER remove existing callbacks\n * 3. New callbacks CAN be added (old blocks won't register them, middle layer\n * should handle missing callbacks gracefully)\n * 4. Callback return types can be EXTENDED (add optional fields) but not changed\n * 5. Callback parameter types should remain compatible (middle layer may need\n * to handle both old and new formats)\n *\n * The facade consists of callbacks registered via `tryRegisterCallback()` with\n * the `__pl_` prefix. These are registered by the SDK when a block loads and\n * called by the middle layer to perform operations.\n *\n * ============================================================================\n * WHAT CAN BE CHANGED FREELY\n * ============================================================================\n *\n * - Middle layer code (lib/node/pl-middle-layer)\n * - SDK internal implementation (as long as callback contracts are preserved)\n * - SDK exports used ONLY by middle layer (not by blocks themselves)\n * - New SDK features that don't affect existing callbacks\n *\n * @module block_storage_facade\n */\n\nimport type { MutateStoragePayload } from \"./block_storage\";\nimport type { ConfigRenderLambda } from \"./bconfig\";\nimport { createRenderLambda, tryRegisterCallback } from \"./internal\";\nimport type { ArgsIssue, StringifiedJson } from \"@milaboratories/pl-model-common\";\n\n// =============================================================================\n// Facade Version\n// =============================================================================\n\n/**\n * The current facade version. This value is used for `requiresModelAPIVersion`\n * feature flag in BlockModelV3.\n */\nexport const BLOCK_STORAGE_FACADE_VERSION = 2;\n\n// =============================================================================\n// Facade Callback Names\n// =============================================================================\n\n/**\n * All facade callback names as constants.\n * These are the source of truth - the interface is derived from these.\n *\n * IMPORTANT: When adding a new callback:\n * 1. Add the constant here\n * 2. Add the callback signature to FacadeCallbackTypes below\n * 3. The BlockStorageFacade type will automatically include it\n */\nexport const BlockStorageFacadeCallbacks = {\n StorageApplyUpdate: \"__pl_storage_applyUpdate\",\n StorageDebugView: \"__pl_storage_debugView\",\n StorageMigrate: \"__pl_storage_migrate\",\n ArgsDerive: \"__pl_args_derive\",\n PrerunArgsDerive: \"__pl_prerunArgs_derive\",\n StorageInitial: \"__pl_storage_initial\",\n InitializationParamsDerive: \"__pl_initializationParams_derive\",\n StorageInitialFromParams: \"__pl_storage_initialFromParams\",\n InitializationParamsValidate: \"__pl_initializationParams_validate\",\n} as const;\n\n/**\n * Creates a map of lambda handles from a callbacks constant object.\n * Keys are the callback string values (e.g., '__pl_storage_applyUpdate').\n */\nfunction createFacadeHandles<T extends Record<string, string>>(\n callbacks: T,\n): { [K in T[keyof T]]: ConfigRenderLambda } {\n return Object.fromEntries(\n Object.values(callbacks).map((handle) => [handle, createRenderLambda({ handle })]),\n ) as { [K in T[keyof T]]: ConfigRenderLambda };\n}\n\n/**\n * Lambda handles for facade callbacks.\n * Used by the middle layer to invoke callbacks via executeSingleLambda().\n */\nexport const BlockStorageFacadeHandles = createFacadeHandles(BlockStorageFacadeCallbacks);\n\n// =============================================================================\n// Facade Interface (source of truth for callback signatures)\n// =============================================================================\n\n/**\n * The complete facade interface between bundled blocks (SDK) and middle layer.\n *\n * This interface defines ALL callbacks that a block registers. The middle layer\n * calls these callbacks to perform storage operations.\n *\n * ALL types are inlined to simplify versioning - when a callback changes,\n * the entire signature is visible in one place.\n *\n * BACKWARD COMPATIBILITY:\n * - This interface can only be EXTENDED, never shrunk\n * - Existing callback signatures MUST NOT change\n * - Middle layer should use Partial<BlockStorageFacade> when dealing with\n * blocks of unknown version (older blocks may not have all callbacks)\n *\n * Each callback is documented with:\n * - Purpose and when it's called\n * - Parameter descriptions\n * - Return value description\n */\nexport interface BlockStorageFacade {\n /**\n * Apply state update to storage.\n * Called when UI updates block state (setState) or plugin data.\n * @param currentStorageJson - Current storage as JSON string\n * @param payload - Update payload with operation type and value\n * @returns Updated storage as JSON string\n */\n [BlockStorageFacadeCallbacks.StorageApplyUpdate]: (\n currentStorageJson: StringifiedJson,\n payload: MutateStoragePayload,\n ) => StringifiedJson;\n\n /**\n * Get debug view of storage.\n * Called by developer tools to inspect storage state.\n * @param storageJson - Storage as JSON string (or undefined for new blocks)\n * @returns JSON string containing StorageDebugView\n */\n [BlockStorageFacadeCallbacks.StorageDebugView]: (\n storageJson: StringifiedJson | undefined,\n ) => StringifiedJson;\n\n /**\n * Run storage migration.\n * Called when block loads to migrate data to latest version.\n * @param currentStorageJson - Current storage as JSON string (or undefined for new blocks)\n * @returns Migration result - either error or success with new storage\n */\n [BlockStorageFacadeCallbacks.StorageMigrate]: (\n currentStorageJson: StringifiedJson | undefined,\n ) =>\n | { error: string }\n | {\n error?: undefined;\n newStorageJson: StringifiedJson;\n info: string;\n };\n\n /**\n * Derive args from storage.\n * Called to get block configuration args from storage, and whether the block may run them.\n *\n * A middle layer that predates args issues reads only `error` and `value`, and each variant\n * means the same to it as before: `value` is runnable args, `error` is no args. A block built\n * with an SDK that predates args issues returns `{ error }` or `{ value }` with no `issues`.\n *\n * @param storageJson - Storage as JSON string\n * @returns One of:\n * - `{ error }`: `args()` threw, so there are no args;\n * - `{ error, args, issues }`: args were built, but the block's `argsIssues()` found errors in\n * them, so the block must not run; `error` joins the error messages, `issues` lists every\n * issue;\n * - `{ value, issues }`: args the block may run; `issues` holds the warnings.\n */\n [BlockStorageFacadeCallbacks.ArgsDerive]: (\n storageJson: StringifiedJson,\n ) =>\n | { error: string }\n | { error: string; args: unknown; issues: ArgsIssue[] }\n | { error?: undefined; value: unknown; issues: ArgsIssue[] };\n\n /**\n * Derive prerunArgs from storage.\n * Called to get prerun args; falls back to args callback if not registered.\n *\n * A block with its own prerunArgs is staged with them unless its `prerunArgsIssues()` finds errors\n * in them. A block without its own prerunArgs is staged with its args unless its `argsIssues()`\n * finds errors in them.\n *\n * A middle layer that predates args issues reads only `error` and `value`: `value` is args to\n * stage, `error` skips staging. A block built with an SDK that predates args issues returns\n * `{ error }` or `{ value }` with no `issues`.\n *\n * @param storageJson - Storage as JSON string\n * @returns One of:\n * - `{ error }`: the lambda building the prerun args threw;\n * - `{ error, issues }`: prerun args were built, but errors were found in them, so the block\n * is not staged; `error` joins the error messages, `issues` lists every issue;\n * - `{ value, issues }`: args to stage, `undefined` to skip staging; `issues` holds the\n * warnings.\n */\n [BlockStorageFacadeCallbacks.PrerunArgsDerive]: (\n storageJson: StringifiedJson,\n ) =>\n | { error: string }\n | { error: string; issues: ArgsIssue[] }\n | { error?: undefined; value: unknown; issues: ArgsIssue[] };\n\n /**\n * Get initial storage JSON for new blocks.\n * Called when creating a new block to get complete initial storage.\n * @returns Initial storage as JSON string\n */\n [BlockStorageFacadeCallbacks.StorageInitial]: () => StringifiedJson;\n\n /**\n * Derive this block's template entry params from storage.\n * Called when exporting the project as a template.\n *\n * Every V3 block declares `.templateParams()` — the model does not build without\n * it — so every export produces params. A block whose state carries nothing worth\n * restoring returns `{}`, which is written out and used as-is by init.\n *\n * The returned params are written out exactly as they come back, references included: the\n * template engine carrying them recognizes nothing in there, and the block that receives\n * them on the way back in is what repoints them. The caller supplies everything else in the\n * entry — `id`, `kind` — so the lambda cannot set them.\n *\n * @param storageJson - Storage as JSON string\n * @returns Either an error, or the params to write\n */\n [BlockStorageFacadeCallbacks.InitializationParamsDerive]: (\n storageJson: StringifiedJson,\n ) => { error: string } | { error?: undefined; value: unknown };\n\n /**\n * Get initial storage JSON for a block created from params.\n * Called when applying a template, once per entry that carries `params`.\n *\n * The mirror image of {@link BlockStorageFacadeCallbacks.InitializationParamsDerive}:\n * that one turns storage into params, this one turns params into storage. Every\n * applied entry comes through here, including one whose file omitted `params` —\n * an omitted key is read as `{}` and checked like any other value, so no entry\n * reaches a block without passing its kind's contract.\n * {@link BlockStorageFacadeCallbacks.StorageInitial} stays the UI-creation path,\n * where there are genuinely no params.\n *\n * Separate from `StorageInitial` rather than an optional argument to it,\n * deliberately: a block bundled with an older SDK does not register this\n * callback at all, so the caller sees it missing and can say so. Widening\n * `StorageInitial` would instead have that block silently ignore the params and\n * produce a default-initialized block that looks successfully applied.\n *\n * The params arrive as ordinary live params — references are `PlRef`s, already\n * pointing at the ids the target project just assigned. Resolution happens in\n * the engine, before this call, so a block's init factory never handles a\n * template-local reference.\n *\n * Errors are returned, not thrown: a factory rejecting params it cannot use is\n * an expected outcome for a hand-written template file, and every entry's\n * problem is reported together.\n *\n * **Also where the entry's references are pointed at this project.** Params reach here\n * exactly as the file held them: nothing between the block that exported them and this call\n * marks a reference, reads one, or rewrites one, because recognizing one means knowing the\n * reference system and this bundle is where that knowledge lives. `blockIdsJson` maps each\n * template-local entry id to the block id it was given, holding the entries created so far —\n * so an id it does not name is left alone, and a reference to an entry created later names\n * nothing rather than naming the wrong block.\n *\n * Relocating and initializing are one call rather than two because every call\n * re-instantiates the runtime and re-evaluates the whole model bundle: splitting them would\n * parse the block twice per entry to produce an intermediate only the second half reads.\n *\n * @param paramsJson - The entry's params as JSON string, as the file held them\n * @param blockIdsJson - template-local entry id → assigned block id, as a JSON object\n * @returns Either an error, or the initial storage as JSON string\n */\n [BlockStorageFacadeCallbacks.StorageInitialFromParams]: (\n paramsJson: StringifiedJson,\n blockIdsJson: StringifiedJson,\n ) => { error: string } | { error?: undefined; storageJson: StringifiedJson };\n\n /**\n * Check params against this block's kind, creating nothing.\n *\n * Called once per entry before a template is applied, so params a kind rejects are\n * reported against the entry that carries them while there is still no project — the\n * same reason references and ids are checked before construction starts. Applying\n * without this call is safe but worse: `StorageInitialFromParams` runs the same check\n * and refuses, by which point earlier entries have already been created.\n *\n * A pass carries nothing back but its own absence of error: every kind declares a\n * parser, so a pass means the params were checked against the contract, not merely\n * that they were valid JSON.\n *\n * Reference ids inside the params may be placeholders at this point: the check runs\n * before blocks exist, so what is verified is the shape of the params, not what they\n * point at.\n *\n * @param paramsJson The entry's params as JSON string\n * @returns Why the params were rejected, or nothing\n */\n [BlockStorageFacadeCallbacks.InitializationParamsValidate]: (\n paramsJson: StringifiedJson,\n ) => { error: string } | { error?: undefined };\n}\n\n/** Register all facade callbacks at once. Ensures all required callbacks are provided. */\nexport function registerFacadeCallbacks(callbacks: BlockStorageFacade): void {\n for (const key of Object.values(BlockStorageFacadeCallbacks)) {\n tryRegisterCallback(key, callbacks[key] as (...args: any[]) => any);\n }\n}\n"],"mappings":";;;;;;AA8DA,MAAa,+BAA+B;;;;;;;;;;AAe5C,MAAa,8BAA8B;CACzC,oBAAoB;CACpB,kBAAkB;CAClB,gBAAgB;CAChB,YAAY;CACZ,kBAAkB;CAClB,gBAAgB;CAChB,4BAA4B;CAC5B,0BAA0B;CAC1B,8BAA8B;AAChC;;;;;AAMA,SAAS,oBACP,WAC2C;CAC3C,OAAO,OAAO,YACZ,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,WAAW,CAAC,QAAQ,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC,CACnF;AACF;;;;;AAMA,MAAa,4BAA4B,oBAAoB,2BAA2B;;AAwNxF,SAAgB,wBAAwB,WAAqC;CAC3E,KAAK,MAAM,OAAO,OAAO,OAAO,2BAA2B,GACzD,oBAAoB,KAAK,UAAU,IAA+B;AAEtE"}
|
|
1
|
+
{"version":3,"file":"block_storage_facade.js","names":[],"sources":["../src/block_storage_facade.ts"],"sourcesContent":["/**\n * Block Storage Facade - Contract between bundled blocks and middle layer.\n *\n * ============================================================================\n * VERSIONING\n * ============================================================================\n *\n * Blocks declare their model API version via the `requiresModelAPIVersion` feature flag\n * (see BlockCodeKnownFeatureFlags). This determines how the middle layer manages block state:\n *\n * - Version 1: Legacy BlockModel - state is {args, uiState}, managed directly by middle layer\n * - Version 2: BlockModelV3 - uses blockStorage with VM-based callbacks (this facade)\n *\n * This facade (BlockStorageFacade) is used by blocks with `requiresModelAPIVersion: 2`.\n * The version number matches the model API version for clarity.\n *\n * ============================================================================\n * BACKWARD COMPATIBILITY WARNING\n * ============================================================================\n *\n * This file documents the FACADE between the SDK (bundled into blocks) and the\n * middle layer. Once a block is published, its SDK version is frozen. The middle\n * layer must support ALL previously released callback signatures indefinitely.\n *\n * RULES:\n * 1. NEVER change the signature of existing callbacks\n * 2. NEVER remove existing callbacks\n * 3. New callbacks CAN be added (old blocks won't register them, middle layer\n * should handle missing callbacks gracefully)\n * 4. Callback return types can be EXTENDED (add optional fields) but not changed\n * 5. Callback parameter types should remain compatible (middle layer may need\n * to handle both old and new formats)\n *\n * The facade consists of callbacks registered via `tryRegisterCallback()` with\n * the `__pl_` prefix. These are registered by the SDK when a block loads and\n * called by the middle layer to perform operations.\n *\n * ============================================================================\n * WHAT CAN BE CHANGED FREELY\n * ============================================================================\n *\n * - Middle layer code (lib/node/pl-middle-layer)\n * - SDK internal implementation (as long as callback contracts are preserved)\n * - SDK exports used ONLY by middle layer (not by blocks themselves)\n * - New SDK features that don't affect existing callbacks\n *\n * @module block_storage_facade\n */\n\nimport type { MutateStoragePayload } from \"./block_storage\";\nimport type { ConfigRenderLambda } from \"./bconfig\";\nimport { createRenderLambda, tryRegisterCallback } from \"./internal\";\nimport type { ArgsIssue, StringifiedJson } from \"@milaboratories/pl-model-common\";\n\n// =============================================================================\n// Facade Version\n// =============================================================================\n\n/**\n * The current facade version. This value is used for `requiresModelAPIVersion`\n * feature flag in BlockModelV3.\n */\nexport const BLOCK_STORAGE_FACADE_VERSION = 2;\n\n// =============================================================================\n// Facade Callback Names\n// =============================================================================\n\n/**\n * All facade callback names as constants.\n * These are the source of truth - the interface is derived from these.\n *\n * IMPORTANT: When adding a new callback:\n * 1. Add the constant here\n * 2. Add the callback signature to FacadeCallbackTypes below\n * 3. The BlockStorageFacade type will automatically include it\n */\nexport const BlockStorageFacadeCallbacks = {\n StorageApplyUpdate: \"__pl_storage_applyUpdate\",\n StorageDebugView: \"__pl_storage_debugView\",\n StorageMigrate: \"__pl_storage_migrate\",\n ArgsDerive: \"__pl_args_derive\",\n PrerunArgsDerive: \"__pl_prerunArgs_derive\",\n StorageInitial: \"__pl_storage_initial\",\n InitializationParamsDerive: \"__pl_initializationParams_derive\",\n StorageInitialFromParams: \"__pl_storage_initialFromParams\",\n InitializationParamsValidate: \"__pl_initializationParams_validate\",\n StorageApplyParams: \"__pl_storage_applyParams\",\n} as const;\n\n/**\n * Callbacks a block registers only when its model declares what they run. A block's config lists\n * their handles only then, so whoever reads the config knows whether it may call them; the\n * defaults filled in for a config that lists no callbacks leave them out.\n */\nconst OptionalFacadeCallbacks = {\n StorageApplyParams: BlockStorageFacadeCallbacks.StorageApplyParams,\n} as const;\n\n/**\n * Creates a map of lambda handles from a callbacks constant object.\n * Keys are the callback string values (e.g., '__pl_storage_applyUpdate').\n */\nfunction createFacadeHandles<T extends Record<string, string>>(\n callbacks: T,\n): { [K in T[keyof T]]: ConfigRenderLambda } {\n return Object.fromEntries(\n Object.values(callbacks).map((handle) => [handle, createRenderLambda({ handle })]),\n ) as { [K in T[keyof T]]: ConfigRenderLambda };\n}\n\nconst { StorageApplyParams: _optional, ...requiredFacadeCallbacks } = BlockStorageFacadeCallbacks;\n\n/**\n * Lambda handles of the facade callbacks every block registers.\n * Used by the middle layer to invoke callbacks via executeSingleLambda().\n */\nexport const BlockStorageFacadeHandles = createFacadeHandles(requiredFacadeCallbacks);\n\n/**\n * Lambda handles of the facade callbacks a block registers only when its model declares what\n * they run (see {@link BlockStorageFacadeCallbacks.StorageApplyParams}).\n */\nexport const BlockStorageFacadeOptionalHandles = createFacadeHandles(OptionalFacadeCallbacks);\n\n// =============================================================================\n// Facade Interface (source of truth for callback signatures)\n// =============================================================================\n\n/**\n * The complete facade interface between bundled blocks (SDK) and middle layer.\n *\n * This interface defines ALL callbacks that a block registers. The middle layer\n * calls these callbacks to perform storage operations.\n *\n * ALL types are inlined to simplify versioning - when a callback changes,\n * the entire signature is visible in one place.\n *\n * BACKWARD COMPATIBILITY:\n * - This interface can only be EXTENDED, never shrunk\n * - Existing callback signatures MUST NOT change\n * - Middle layer should use Partial<BlockStorageFacade> when dealing with\n * blocks of unknown version (older blocks may not have all callbacks)\n *\n * Each callback is documented with:\n * - Purpose and when it's called\n * - Parameter descriptions\n * - Return value description\n */\nexport interface BlockStorageFacade {\n /**\n * Apply state update to storage.\n * Called when UI updates block state (setState) or plugin data.\n * @param currentStorageJson - Current storage as JSON string\n * @param payload - Update payload with operation type and value\n * @returns Updated storage as JSON string\n */\n [BlockStorageFacadeCallbacks.StorageApplyUpdate]: (\n currentStorageJson: StringifiedJson,\n payload: MutateStoragePayload,\n ) => StringifiedJson;\n\n /**\n * Get debug view of storage.\n * Called by developer tools to inspect storage state.\n * @param storageJson - Storage as JSON string (or undefined for new blocks)\n * @returns JSON string containing StorageDebugView\n */\n [BlockStorageFacadeCallbacks.StorageDebugView]: (\n storageJson: StringifiedJson | undefined,\n ) => StringifiedJson;\n\n /**\n * Run storage migration.\n * Called when block loads to migrate data to latest version.\n * @param currentStorageJson - Current storage as JSON string (or undefined for new blocks)\n * @returns Migration result - either error or success with new storage\n */\n [BlockStorageFacadeCallbacks.StorageMigrate]: (\n currentStorageJson: StringifiedJson | undefined,\n ) =>\n | { error: string }\n | {\n error?: undefined;\n newStorageJson: StringifiedJson;\n info: string;\n };\n\n /**\n * Derive args from storage.\n * Called to get block configuration args from storage, and whether the block may run them.\n *\n * A middle layer that predates args issues reads only `error` and `value`, and each variant\n * means the same to it as before: `value` is runnable args, `error` is no args. A block built\n * with an SDK that predates args issues returns `{ error }` or `{ value }` with no `issues`.\n *\n * @param storageJson - Storage as JSON string\n * @returns One of:\n * - `{ error }`: `args()` threw, so there are no args;\n * - `{ error, args, issues }`: args were built, but the block's `argsIssues()` found errors in\n * them, so the block must not run; `error` joins the error messages, `issues` lists every\n * issue;\n * - `{ value, issues }`: args the block may run; `issues` holds the warnings.\n */\n [BlockStorageFacadeCallbacks.ArgsDerive]: (\n storageJson: StringifiedJson,\n ) =>\n | { error: string }\n | { error: string; args: unknown; issues: ArgsIssue[] }\n | { error?: undefined; value: unknown; issues: ArgsIssue[] };\n\n /**\n * Derive prerunArgs from storage.\n * Called to get prerun args; falls back to args callback if not registered.\n *\n * A block with its own prerunArgs is staged with them unless its `prerunArgsIssues()` finds errors\n * in them. A block without its own prerunArgs is staged with its args unless its `argsIssues()`\n * finds errors in them.\n *\n * A middle layer that predates args issues reads only `error` and `value`: `value` is args to\n * stage, `error` skips staging. A block built with an SDK that predates args issues returns\n * `{ error }` or `{ value }` with no `issues`.\n *\n * @param storageJson - Storage as JSON string\n * @returns One of:\n * - `{ error }`: the lambda building the prerun args threw;\n * - `{ error, issues }`: prerun args were built, but errors were found in them, so the block\n * is not staged; `error` joins the error messages, `issues` lists every issue;\n * - `{ value, issues }`: args to stage, `undefined` to skip staging; `issues` holds the\n * warnings.\n */\n [BlockStorageFacadeCallbacks.PrerunArgsDerive]: (\n storageJson: StringifiedJson,\n ) =>\n | { error: string }\n | { error: string; issues: ArgsIssue[] }\n | { error?: undefined; value: unknown; issues: ArgsIssue[] };\n\n /**\n * Get initial storage JSON for new blocks.\n * Called when creating a new block to get complete initial storage.\n * @returns Initial storage as JSON string\n */\n [BlockStorageFacadeCallbacks.StorageInitial]: () => StringifiedJson;\n\n /**\n * Derive this block's template entry params from storage.\n * Called when exporting the project as a template.\n *\n * Every V3 block declares `.templateParams()` — the model does not build without\n * it — so every export produces params. A block whose state carries nothing worth\n * restoring returns `{}`, which is written out and used as-is by init.\n *\n * The returned params are written out exactly as they come back, references included: the\n * template engine carrying them recognizes nothing in there, and the block that receives\n * them on the way back in is what repoints them. The caller supplies everything else in the\n * entry — `id`, `kind` — so the lambda cannot set them.\n *\n * @param storageJson - Storage as JSON string\n * @returns Either an error, or the params to write\n */\n [BlockStorageFacadeCallbacks.InitializationParamsDerive]: (\n storageJson: StringifiedJson,\n ) => { error: string } | { error?: undefined; value: unknown };\n\n /**\n * Get initial storage JSON for a block created from params.\n * Called when applying a template, once per entry that carries `params`.\n *\n * The mirror image of {@link BlockStorageFacadeCallbacks.InitializationParamsDerive}:\n * that one turns storage into params, this one turns params into storage. Every\n * applied entry comes through here, including one whose file omitted `params` —\n * an omitted key is read as `{}` and checked like any other value, so no entry\n * reaches a block without passing its kind's contract.\n * {@link BlockStorageFacadeCallbacks.StorageInitial} stays the UI-creation path,\n * where there are genuinely no params.\n *\n * Separate from `StorageInitial` rather than an optional argument to it,\n * deliberately: a block bundled with an older SDK does not register this\n * callback at all, so the caller sees it missing and can say so. Widening\n * `StorageInitial` would instead have that block silently ignore the params and\n * produce a default-initialized block that looks successfully applied.\n *\n * The params arrive as ordinary live params — references are `PlRef`s, already\n * pointing at the ids the target project just assigned. Resolution happens in\n * the engine, before this call, so a block's init factory never handles a\n * template-local reference.\n *\n * Errors are returned, not thrown: a factory rejecting params it cannot use is\n * an expected outcome for a hand-written template file, and every entry's\n * problem is reported together.\n *\n * **Also where the entry's references are pointed at this project.** Params reach here\n * exactly as the file held them: nothing between the block that exported them and this call\n * marks a reference, reads one, or rewrites one, because recognizing one means knowing the\n * reference system and this bundle is where that knowledge lives. `blockIdsJson` maps each\n * template-local entry id to the block id it was given, holding the entries created so far —\n * so an id it does not name is left alone, and a reference to an entry created later names\n * nothing rather than naming the wrong block.\n *\n * Relocating and initializing are one call rather than two because every call\n * re-instantiates the runtime and re-evaluates the whole model bundle: splitting them would\n * parse the block twice per entry to produce an intermediate only the second half reads.\n *\n * @param paramsJson - The entry's params as JSON string, as the file held them\n * @param blockIdsJson - template-local entry id → assigned block id, as a JSON object\n * @returns Either an error, or the initial storage as JSON string\n */\n [BlockStorageFacadeCallbacks.StorageInitialFromParams]: (\n paramsJson: StringifiedJson,\n blockIdsJson: StringifiedJson,\n ) => { error: string } | { error?: undefined; storageJson: StringifiedJson };\n\n /**\n * Check params against this block's kind, creating nothing.\n *\n * Called once per entry before a template is applied, so params a kind rejects are\n * reported against the entry that carries them while there is still no project — the\n * same reason references and ids are checked before construction starts. Applying\n * without this call is safe but worse: `StorageInitialFromParams` runs the same check\n * and refuses, by which point earlier entries have already been created.\n *\n * A pass carries nothing back but its own absence of error: every kind declares a\n * parser, so a pass means the params were checked against the contract, not merely\n * that they were valid JSON.\n *\n * Reference ids inside the params may be placeholders at this point: the check runs\n * before blocks exist, so what is verified is the shape of the params, not what they\n * point at.\n *\n * @param paramsJson The entry's params as JSON string\n * @returns Why the params were rejected, or nothing\n */\n [BlockStorageFacadeCallbacks.InitializationParamsValidate]: (\n paramsJson: StringifiedJson,\n ) => { error: string } | { error?: undefined };\n\n /**\n * Put params onto the block's live data with the block's own `applyParams`.\n *\n * Registered, and listed in the block's config, only when the block declares `applyParams`\n * (`BlockModelV3.applyParams`); a block without it, or bundled with an older SDK, has no such\n * callback, and the caller builds data from params with\n * {@link BlockStorageFacadeCallbacks.StorageInitialFromParams} instead.\n *\n * The params get what the from-params path gives them: the readable reference spelling is\n * expanded and the kind's parser checks them; its output is what `applyParams` gets. They are\n * live params, so nothing is relocated: references name blocks of this project.\n *\n * The data must be at the data model's current version, the one `applyParams` is written\n * against; data waiting for a migration is refused. Plugin data and everything else in the\n * storage stay as they are. Nothing is written: the caller decides what to do with the result.\n *\n * @param storageJson - Current storage as JSON string\n * @param paramsJson - The new params as JSON string, whole\n * @returns Either an error, or the storage with the params applied as JSON string\n */\n [BlockStorageFacadeCallbacks.StorageApplyParams]?: (\n storageJson: StringifiedJson,\n paramsJson: StringifiedJson,\n ) => { error: string } | { error?: undefined; storageJson: StringifiedJson };\n}\n\n/**\n * Register all facade callbacks at once. The types ensure every required callback is provided;\n * an optional one left undefined is not registered.\n */\nexport function registerFacadeCallbacks(callbacks: BlockStorageFacade): void {\n for (const key of Object.values(BlockStorageFacadeCallbacks)) {\n const callback = callbacks[key];\n if (callback !== undefined) tryRegisterCallback(key, callback as (...args: any[]) => any);\n }\n}\n"],"mappings":";;;;;;AA8DA,MAAa,+BAA+B;;;;;;;;;;AAe5C,MAAa,8BAA8B;CACzC,oBAAoB;CACpB,kBAAkB;CAClB,gBAAgB;CAChB,YAAY;CACZ,kBAAkB;CAClB,gBAAgB;CAChB,4BAA4B;CAC5B,0BAA0B;CAC1B,8BAA8B;CAC9B,oBAAoB;AACtB;;;;;;AAOA,MAAM,0BAA0B,EAC9B,oBAAoB,4BAA4B,mBAClD;;;;;AAMA,SAAS,oBACP,WAC2C;CAC3C,OAAO,OAAO,YACZ,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,WAAW,CAAC,QAAQ,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC,CACnF;AACF;AAEA,MAAM,EAAE,oBAAoB,WAAW,GAAG,4BAA4B;;;;;AAMtE,MAAa,4BAA4B,oBAAoB,uBAAuB;;;;;AAMpF,MAAa,oCAAoC,oBAAoB,uBAAuB;;;;;AAoP5F,SAAgB,wBAAwB,WAAqC;CAC3E,KAAK,MAAM,OAAO,OAAO,OAAO,2BAA2B,GAAG;EAC5D,MAAM,WAAW,UAAU;EAC3B,IAAI,aAAa,KAAA,GAAW,oBAAoB,KAAK,QAAmC;CAC1F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterToQuery.cjs","names":["traverseFilterSpec"],"sources":["../../../src/filters/converters/filterToQuery.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type {\n AxisId,\n ColumnUniversalId,\n FilterSpec,\n FilterSpecLeaf,\n SingleAxisSelector,\n SpecQueryExpression,\n} from \"@milaboratories/pl-model-common\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport type QueryColumnIdAxis = {\n type: \"axis\";\n id: AxisId;\n};\n\nexport type QueryColumnIdColumn = {\n type: \"column\";\n /** May be a rich {@link ColumnUniversalId} (Discovered / Overridden / Filtered) or bare PObjectId. */\n id: ColumnUniversalId;\n};\n\nexport type QueryColumnId = QueryColumnIdAxis | QueryColumnIdColumn;\n\n/** Converts a QueryColumnId object into a SpecQueryExpression reference. */\nfunction resolveColumnRef(col: QueryColumnId): SpecQueryExpression {\n return col.type === \"axis\"\n ? { type: \"axisRef\", value: col.id as SingleAxisSelector }\n : { type: \"columnRef\", value: col.id };\n}\n\n/** Converts a FilterSpec tree into a SpecQueryExpression. */\nexport function filterSpecToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: FilterSpec<Leaf>,\n): SpecQueryExpression {\n return traverseFilterSpec(filter, {\n leaf: leafToSpecQueryExpr,\n and: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return { type: \"and\", input: inputs };\n },\n or: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return { type: \"or\", input: inputs };\n },\n not: (input) => ({ type: \"not\", input }),\n });\n}\n\nfunction leafToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: Leaf,\n): SpecQueryExpression {\n switch (filter.type) {\n case \"patternEquals\":\n return {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotEquals\":\n return {\n type: \"not\",\n input: {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternContainSubsequence\":\n return {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotContainSubsequence\":\n return {\n type: \"not\",\n input: {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternMatchesRegularExpression\":\n return {\n type: \"stringRegex\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n };\n case \"patternFuzzyContainSubsequence\":\n return {\n type: \"stringContainsFuzzy\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n maxEdits: filter.maxEdits ?? 1,\n caseInsensitive: false,\n substitutionsOnly: filter.substitutionsOnly ?? false,\n wildcard: filter.wildcard ?? null,\n };\n\n case \"equal\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"notEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ne\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThan\":\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThan\":\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n\n case \"equalToColumn\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: resolveColumnRef(filter.rhs),\n };\n case \"lessThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"lt\", left, right };\n }\n case \"greaterThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"gt\", left, right };\n }\n case \"lessThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"le\", left, right };\n }\n case \"greaterThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"ge\", left, right };\n }\n\n case \"inSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: false,\n };\n case \"notInSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: true,\n };\n\n case \"isNA\":\n return {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n };\n case \"isNotNA\":\n return {\n type: \"not\",\n input: {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n },\n };\n\n case \"ifNa\":\n return {\n type: \"fillNull\",\n input: resolveColumnRef(filter.column),\n replacement: { type: \"constant\", value: filter.replacement },\n };\n\n case \"topN\":\n case \"bottomN\":\n throw new Error(`Filter type \"${filter.type}\" is not supported in query expressions`);\n\n case undefined:\n throw new Error(\"Filter type is undefined\");\n\n default:\n assertNever(filter);\n }\n}\n"],"mappings":";;;;AAyBA,SAAS,iBAAiB,KAAyC;CACjE,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iB,OAAO,MAAM;GACrC,KAAK,OAAO;GACZ,QAAQ;EACV;EAEF,KAAK,QACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;EACvC;EACF,KAAK,WACH,OAAO;GACL,MAAM;GACN,OAAO;IACL,MAAM;IACN,OAAO,iBAAiB,OAAO,MAAM;GACvC;EACF;EAEF,KAAK,QACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;GACrC,aAAa;IAAE,MAAM;IAAY,OAAO,OAAO;GAAY;EAC7D;EAEF,KAAK;EACL,KAAK,WACH,MAAM,IAAI,MAAM,gBAAgB,OAAO,KAAK,wCAAwC;EAEtF,KAAK,KAAA,GACH,MAAM,IAAI,MAAM,0BAA0B;EAE5C,SACE,CAAA,GAAA,gCAAA,YAAA,CAAY,MAAM;CACtB;AACF"}
|
|
1
|
+
{"version":3,"file":"filterToQuery.cjs","names":["traverseFilterSpec"],"sources":["../../../src/filters/converters/filterToQuery.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type {\n ColumnUniversalId,\n FilterSpec,\n FilterSpecLeaf,\n SingleAxisSelector,\n SpecQueryExpression,\n} from \"@milaboratories/pl-model-common\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport type QueryColumnIdAxis = {\n type: \"axis\";\n /**\n * The axis: a whole axis id (`AxisId`), or a selector the engine matches against the axes of the\n * query (it refuses a selector that matches no axis or several).\n */\n id: SingleAxisSelector;\n};\n\nexport type QueryColumnIdColumn = {\n type: \"column\";\n /** May be a rich {@link ColumnUniversalId} (Discovered / Overridden / Filtered) or bare PObjectId. */\n id: ColumnUniversalId;\n};\n\nexport type QueryColumnId = QueryColumnIdAxis | QueryColumnIdColumn;\n\n/** Converts a QueryColumnId object into a SpecQueryExpression reference. */\nfunction resolveColumnRef(col: QueryColumnId): SpecQueryExpression {\n return col.type === \"axis\"\n ? { type: \"axisRef\", value: col.id }\n : { type: \"columnRef\", value: col.id };\n}\n\n/** Converts a FilterSpec tree into a SpecQueryExpression. */\nexport function filterSpecToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: FilterSpec<Leaf>,\n): SpecQueryExpression {\n return traverseFilterSpec(filter, {\n leaf: leafToSpecQueryExpr,\n and: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return { type: \"and\", input: inputs };\n },\n or: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return { type: \"or\", input: inputs };\n },\n not: (input) => ({ type: \"not\", input }),\n });\n}\n\nfunction leafToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: Leaf,\n): SpecQueryExpression {\n switch (filter.type) {\n case \"patternEquals\":\n return {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotEquals\":\n return {\n type: \"not\",\n input: {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternContainSubsequence\":\n return {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotContainSubsequence\":\n return {\n type: \"not\",\n input: {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternMatchesRegularExpression\":\n return {\n type: \"stringRegex\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n };\n case \"patternFuzzyContainSubsequence\":\n return {\n type: \"stringContainsFuzzy\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n maxEdits: filter.maxEdits ?? 1,\n caseInsensitive: false,\n substitutionsOnly: filter.substitutionsOnly ?? false,\n wildcard: filter.wildcard ?? null,\n };\n\n case \"equal\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"notEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ne\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThan\":\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThan\":\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n\n case \"equalToColumn\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: resolveColumnRef(filter.rhs),\n };\n case \"lessThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"lt\", left, right };\n }\n case \"greaterThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"gt\", left, right };\n }\n case \"lessThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"le\", left, right };\n }\n case \"greaterThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"ge\", left, right };\n }\n\n case \"inSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: false,\n };\n case \"notInSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: true,\n };\n\n case \"isNA\":\n return {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n };\n case \"isNotNA\":\n return {\n type: \"not\",\n input: {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n },\n };\n\n case \"ifNa\":\n return {\n type: \"fillNull\",\n input: resolveColumnRef(filter.column),\n replacement: { type: \"constant\", value: filter.replacement },\n };\n\n case \"topN\":\n case \"bottomN\":\n throw new Error(`Filter type \"${filter.type}\" is not supported in query expressions`);\n\n case undefined:\n throw new Error(\"Filter type is undefined\");\n\n default:\n assertNever(filter);\n }\n}\n"],"mappings":";;;;AA4BA,SAAS,iBAAiB,KAAyC;CACjE,OAAO,IAAI,SAAS,SAChB;EAAE,MAAM;EAAW,OAAO,IAAI;CAAG,IACjC;EAAE,MAAM;EAAa,OAAO,IAAI;CAAG;AACzC;;AAGA,SAAgB,0BACd,QACqB;CACrB,OAAOA,iBAAAA,mBAAmB,QAAQ;EAChC,MAAM;EACN,MAAM,WAAW;GACf,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MAAM,0CAA0C;GAE5D,OAAO;IAAE,MAAM;IA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ACrC,aAAa;IAAE,MAAM;IAAY,OAAO,OAAO;GAAY;EAC7D;EAEF,KAAK;EACL,KAAK,WACH,MAAM,IAAI,MAAM,gBAAgB,OAAO,KAAK,wCAAwC;EAEtF,KAAK,KAAA,GACH,MAAM,IAAI,MAAM,0BAA0B;EAE5C,SACE,CAAA,GAAA,gCAAA,YAAA,CAAY,MAAM;CACtB;AACF"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColumnUniversalId, FilterSpec, FilterSpecLeaf, SingleAxisSelector, SpecQueryExpression } from "@milaboratories/pl-model-common";
|
|
2
2
|
export type QueryColumnIdAxis = {
|
|
3
3
|
type: "axis";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The axis: a whole axis id (`AxisId`), or a selector the engine matches against the axes of the
|
|
6
|
+
* query (it refuses a selector that matches no axis or several).
|
|
7
|
+
*/
|
|
8
|
+
id: SingleAxisSelector;
|
|
5
9
|
};
|
|
6
10
|
export type QueryColumnIdColumn = {
|
|
7
11
|
type: "column";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterToQuery.d.ts","names":[],"sources":["../../../src/filters/converters/filterToQuery.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"filterToQuery.d.ts","names":[],"sources":["../../../src/filters/converters/filterToQuery.ts"],"mappings":";YAUY;EACV;;;;;EAKA,IAAI;;YAGM;EACV;;EAEA,IAAI;;YAGM,gBAAgB,oBAAoB;;wBAUhC,0BAA0B,aAAa,eAAe,gBACpE,QAAQ,WAAW,QAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterToQuery.js","names":[],"sources":["../../../src/filters/converters/filterToQuery.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type {\n AxisId,\n ColumnUniversalId,\n FilterSpec,\n FilterSpecLeaf,\n SingleAxisSelector,\n SpecQueryExpression,\n} from \"@milaboratories/pl-model-common\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport type QueryColumnIdAxis = {\n type: \"axis\";\n id: AxisId;\n};\n\nexport type QueryColumnIdColumn = {\n type: \"column\";\n /** May be a rich {@link ColumnUniversalId} (Discovered / Overridden / Filtered) or bare PObjectId. */\n id: ColumnUniversalId;\n};\n\nexport type QueryColumnId = QueryColumnIdAxis | QueryColumnIdColumn;\n\n/** Converts a QueryColumnId object into a SpecQueryExpression reference. */\nfunction resolveColumnRef(col: QueryColumnId): SpecQueryExpression {\n return col.type === \"axis\"\n ? { type: \"axisRef\", value: col.id as SingleAxisSelector }\n : { type: \"columnRef\", value: col.id };\n}\n\n/** Converts a FilterSpec tree into a SpecQueryExpression. */\nexport function filterSpecToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: FilterSpec<Leaf>,\n): SpecQueryExpression {\n return traverseFilterSpec(filter, {\n leaf: leafToSpecQueryExpr,\n and: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return { type: \"and\", input: inputs };\n },\n or: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return { type: \"or\", input: inputs };\n },\n not: (input) => ({ type: \"not\", input }),\n });\n}\n\nfunction leafToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: Leaf,\n): SpecQueryExpression {\n switch (filter.type) {\n case \"patternEquals\":\n return {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotEquals\":\n return {\n type: \"not\",\n input: {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternContainSubsequence\":\n return {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotContainSubsequence\":\n return {\n type: \"not\",\n input: {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternMatchesRegularExpression\":\n return {\n type: \"stringRegex\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n };\n case \"patternFuzzyContainSubsequence\":\n return {\n type: \"stringContainsFuzzy\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n maxEdits: filter.maxEdits ?? 1,\n caseInsensitive: false,\n substitutionsOnly: filter.substitutionsOnly ?? false,\n wildcard: filter.wildcard ?? null,\n };\n\n case \"equal\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"notEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ne\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThan\":\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThan\":\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n\n case \"equalToColumn\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: resolveColumnRef(filter.rhs),\n };\n case \"lessThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"lt\", left, right };\n }\n case \"greaterThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"gt\", left, right };\n }\n case \"lessThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"le\", left, right };\n }\n case \"greaterThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"ge\", left, right };\n }\n\n case \"inSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: false,\n };\n case \"notInSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: true,\n };\n\n case \"isNA\":\n return {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n };\n case \"isNotNA\":\n return {\n type: \"not\",\n input: {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n },\n };\n\n case \"ifNa\":\n return {\n type: \"fillNull\",\n input: resolveColumnRef(filter.column),\n replacement: { type: \"constant\", value: filter.replacement },\n };\n\n case \"topN\":\n case \"bottomN\":\n throw new Error(`Filter type \"${filter.type}\" is not supported in query expressions`);\n\n case undefined:\n throw new Error(\"Filter type is undefined\");\n\n default:\n assertNever(filter);\n }\n}\n"],"mappings":";;;;AAyBA,SAAS,iBAAiB,KAAyC;CACjE,OAAO,IAAI,SAAS,SAChB;EAAE,MAAM;EAAW,OAAO,IAAI;CAAyB,IACvD;EAAE,MAAM;EAAa,OAAO,IAAI;CAAG;AACzC;;AAGA,SAAgB,0BACd,QACqB;CACrB,OAAO,mBAAmB,QAAQ;EAChC,MAAM;EACN,MAAM,WAAW;GACf,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MAAM,0CAA0C;GAE5D,OAAO;IAAE,MAAM;IAAO,OAAO;GAAO;EACtC;EACA,KAAK,WAAW;GACd,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MAAM,yCAAyC;GAE3D,OAAO;IAAE,MAAM;IAAM,OAAO;GAAO;EACrC;EACA,MAAM,WAAW;GAAE,MAAM;GAAO;EAAM;CACxC,CAAC;AACH;AAEA,SAAS,oBACP,QACqB;CACrB,QAAQ,OAAO,MAAf;EACE,KAAK,iBACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;GACrC,OAAO,OAAO;GACd,iBAAiB;EACnB;EACF,KAAK,oBACH,OAAO;GACL,MAAM;GACN,OAAO;IACL,MAAM;IACN,OAAO,iBAAiB,OAAO,MAAM;IACrC,OAAO,OAAO;IACd,iBAAiB;GACnB;EACF;EACF,KAAK,6BACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;GACrC,OAAO,OAAO;GACd,iBAAiB;EACnB;EACF,KAAK,gCACH,OAAO;GACL,MAAM;GACN,OAAO;IACL,MAAM;IACN,OAAO,iBAAiB,OAAO,MAAM;IACrC,OAAO,OAAO;IACd,iBAAiB;GACnB;EACF;EACF,KAAK,mCACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;GACrC,OAAO,OAAO;EAChB;EACF,KAAK,kCACH,OAAO;GACL,MAAM;GACN,OAA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BAAiB,OAAO,MAAM;GACrC,KAAK,OAAO;GACZ,QAAQ;EACV;EACF,KAAK,YACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;GACrC,KAAK,OAAO;GACZ,QAAQ;EACV;EAEF,KAAK,QACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;EACvC;EACF,KAAK,WACH,OAAO;GACL,MAAM;GACN,OAAO;IACL,MAAM;IACN,OAAO,iBAAiB,OAAO,MAAM;GACvC;EACF;EAEF,KAAK,QACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;GACrC,aAAa;IAAE,MAAM;IAAY,OAAO,OAAO;GAAY;EAC7D;EAEF,KAAK;EACL,KAAK,WACH,MAAM,IAAI,MAAM,gBAAgB,OAAO,KAAK,wCAAwC;EAEtF,KAAK,KAAA,GACH,MAAM,IAAI,MAAM,0BAA0B;EAE5C,SACE,YAAY,MAAM;CACtB;AACF"}
|
|
1
|
+
{"version":3,"file":"filterToQuery.js","names":[],"sources":["../../../src/filters/converters/filterToQuery.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type {\n ColumnUniversalId,\n FilterSpec,\n FilterSpecLeaf,\n SingleAxisSelector,\n SpecQueryExpression,\n} from \"@milaboratories/pl-model-common\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport type QueryColumnIdAxis = {\n type: \"axis\";\n /**\n * The axis: a whole axis id (`AxisId`), or a selector the engine matches against the axes of the\n * query (it refuses a selector that matches no axis or several).\n */\n id: SingleAxisSelector;\n};\n\nexport type QueryColumnIdColumn = {\n type: \"column\";\n /** May be a rich {@link ColumnUniversalId} (Discovered / Overridden / Filtered) or bare PObjectId. */\n id: ColumnUniversalId;\n};\n\nexport type QueryColumnId = QueryColumnIdAxis | QueryColumnIdColumn;\n\n/** Converts a QueryColumnId object into a SpecQueryExpression reference. */\nfunction resolveColumnRef(col: QueryColumnId): SpecQueryExpression {\n return col.type === \"axis\"\n ? { type: \"axisRef\", value: col.id }\n : { type: \"columnRef\", value: col.id };\n}\n\n/** Converts a FilterSpec tree into a SpecQueryExpression. */\nexport function filterSpecToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: FilterSpec<Leaf>,\n): SpecQueryExpression {\n return traverseFilterSpec(filter, {\n leaf: leafToSpecQueryExpr,\n and: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return { type: \"and\", input: inputs };\n },\n or: (inputs) => {\n if (inputs.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return { type: \"or\", input: inputs };\n },\n not: (input) => ({ type: \"not\", input }),\n });\n}\n\nfunction leafToSpecQueryExpr<Leaf extends FilterSpecLeaf<QueryColumnId>>(\n filter: Leaf,\n): SpecQueryExpression {\n switch (filter.type) {\n case \"patternEquals\":\n return {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotEquals\":\n return {\n type: \"not\",\n input: {\n type: \"stringEquals\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternContainSubsequence\":\n return {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n };\n case \"patternNotContainSubsequence\":\n return {\n type: \"not\",\n input: {\n type: \"stringContains\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n caseInsensitive: false,\n },\n };\n case \"patternMatchesRegularExpression\":\n return {\n type: \"stringRegex\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n };\n case \"patternFuzzyContainSubsequence\":\n return {\n type: \"stringContainsFuzzy\",\n input: resolveColumnRef(filter.column),\n value: filter.value,\n maxEdits: filter.maxEdits ?? 1,\n caseInsensitive: false,\n substitutionsOnly: filter.substitutionsOnly ?? false,\n wildcard: filter.wildcard ?? null,\n };\n\n case \"equal\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"notEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ne\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThan\":\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThan\":\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"lessThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n case \"greaterThanOrEqual\":\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: resolveColumnRef(filter.column),\n right: { type: \"constant\", value: filter.x },\n };\n\n case \"equalToColumn\":\n return {\n type: \"numericComparison\",\n operand: \"eq\",\n left: resolveColumnRef(filter.column),\n right: resolveColumnRef(filter.rhs),\n };\n case \"lessThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"lt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"lt\", left, right };\n }\n case \"greaterThanColumn\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"gt\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"gt\", left, right };\n }\n case \"lessThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"le\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"le\", left, right };\n }\n case \"greaterThanColumnOrEqual\": {\n const left = resolveColumnRef(filter.column);\n const right = resolveColumnRef(filter.rhs);\n if (filter.minDiff !== undefined && filter.minDiff !== 0) {\n return {\n type: \"numericComparison\",\n operand: \"ge\",\n left: {\n type: \"numericBinary\",\n operand: \"add\",\n left,\n right: { type: \"constant\", value: filter.minDiff },\n },\n right,\n };\n }\n return { type: \"numericComparison\", operand: \"ge\", left, right };\n }\n\n case \"inSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: false,\n };\n case \"notInSet\":\n return {\n type: \"isIn\",\n input: resolveColumnRef(filter.column),\n set: filter.value,\n negate: true,\n };\n\n case \"isNA\":\n return {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n };\n case \"isNotNA\":\n return {\n type: \"not\",\n input: {\n type: \"isNull\",\n input: resolveColumnRef(filter.column),\n },\n };\n\n case \"ifNa\":\n return {\n type: \"fillNull\",\n input: resolveColumnRef(filter.column),\n replacement: { type: \"constant\", value: filter.replacement },\n };\n\n case \"topN\":\n case \"bottomN\":\n throw new Error(`Filter type \"${filter.type}\" is not supported in query expressions`);\n\n case undefined:\n throw new Error(\"Filter type is undefined\");\n\n default:\n assertNever(filter);\n }\n}\n"],"mappings":";;;;AA4BA,SAAS,iBAAiB,KAAyC;CACjE,OAAO,IAAI,SAAS,SAChB;EAAE,MAAM;EAAW,OAAO,IAAI;CAAG,IACjC;EAAE,MAAM;EAAa,OAAO,IAAI;CAAG;AACzC;;AAGA,SAAgB,0BACd,QACqB;CACrB,OAAO,mBAAmB,QAAQ;EAChC,MAAM;EACN,MAAM,WAAW;GACf,IAAI,OAAO,WAAW,GACpB,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QACH,OAAO;GACL,MAAM;GACN,OAAO,iBAAiB,OAAO,MAAM;GACrC,aAAa;IAAE,MAAM;IAAY,OAAO,OAAO;GAAY;EAC7D;EAEF,KAAK;EACL,KAAK,WACH,MAAM,IAAI,MAAM,gBAAgB,OAAO,KAAK,wCAAwC;EAEtF,KAAK,KAAA,GACH,MAAM,IAAI,MAAM,0BAA0B;EAE5C,SACE,YAAY,MAAM;CACtB;AACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -80,6 +80,7 @@ exports.BlockModelV3 = require_block_model.BlockModelV3;
|
|
|
80
80
|
exports.BlockRenderCtx = require_api.BlockRenderCtx;
|
|
81
81
|
exports.BlockStorageFacadeCallbacks = require_block_storage_facade.BlockStorageFacadeCallbacks;
|
|
82
82
|
exports.BlockStorageFacadeHandles = require_block_storage_facade.BlockStorageFacadeHandles;
|
|
83
|
+
exports.BlockStorageFacadeOptionalHandles = require_block_storage_facade.BlockStorageFacadeOptionalHandles;
|
|
83
84
|
exports.Column = require_column.Column;
|
|
84
85
|
exports.ColumnDiscoveredRecipe = require_column_discovered_recipe.ColumnDiscoveredRecipe;
|
|
85
86
|
exports.ColumnFilteredRecipe = require_column_filtered_recipe.ColumnFilteredRecipe;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { BlockConfig, BlockConfigV3, BlockConfigV4 } from "./bconfig/v3.js";
|
|
|
12
12
|
import { downgradeCfgOrLambda, extractConfig } from "./bconfig/normalization.js";
|
|
13
13
|
import { DeriveHref } from "./bconfig/util.js";
|
|
14
14
|
import "./bconfig/index.js";
|
|
15
|
-
import { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, registerFacadeCallbacks } from "./block_storage_facade.js";
|
|
15
|
+
import { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, BlockStorageFacadeOptionalHandles, registerFacadeCallbacks } from "./block_storage_facade.js";
|
|
16
16
|
import { BlockApiV1, CancelSubscription } from "./block_api_v1.js";
|
|
17
17
|
import { BlockApiV2 } from "./block_api_v2.js";
|
|
18
18
|
import { CurrentSdkInfo, PlatformaSDKVersion, SdkInfo } from "./version.js";
|
|
@@ -90,4 +90,4 @@ import "./services/index.js";
|
|
|
90
90
|
import { getEnvironmentValue } from "./env_value.js";
|
|
91
91
|
export * from "@milaboratories/pl-model-common";
|
|
92
92
|
export * from "@milaboratories/pl-error-like";
|
|
93
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetEnrichment, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, DiscoveredRoot, Entry, ExperimentDesign, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveExperimentDesignOptions, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, experimentDesign, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, listExperimentDesigns, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
|
93
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, BlockStorageFacadeOptionalHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetEnrichment, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, DiscoveredRoot, Entry, ExperimentDesign, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveExperimentDesignOptions, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, experimentDesign, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, listExperimentDesigns, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { OutputError, readOutput, wrapOutputs } from "./block_state_util.js";
|
|
|
2
2
|
import { isPluginOutputKey, pluginOutputKey, pluginOutputPrefix } from "./plugin_handle.js";
|
|
3
3
|
import { DataModel, DataModelBuilder } from "./block_migrations.js";
|
|
4
4
|
import { createBlockStorage, deriveDataFromStorage, getPluginData, getStorageData, isBlockStorage, migrateBlockStorage, normalizeBlockStorage, updateStorageData } from "./block_storage.js";
|
|
5
|
-
import { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, registerFacadeCallbacks } from "./block_storage_facade.js";
|
|
5
|
+
import { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, BlockStorageFacadeOptionalHandles, registerFacadeCallbacks } from "./block_storage_facade.js";
|
|
6
6
|
import { BLOCK_SERVICE_FLAGS, blockServiceNames } from "./services/block_services.js";
|
|
7
7
|
import { FutureRef } from "./render/future.js";
|
|
8
8
|
import { TreeNodeAccessor, ifDef } from "./render/accessor.js";
|
|
@@ -72,4 +72,4 @@ import { getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, g
|
|
|
72
72
|
import { getEnvironmentValue } from "./env_value.js";
|
|
73
73
|
export * from "@milaboratories/pl-model-common";
|
|
74
74
|
export * from "@milaboratories/pl-error-like";
|
|
75
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockModelV3, BlockRenderCtx, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, CurrentSdkInfo, DataColumn, DataColumnImpl, DataModel, DataModelBuilder, FutureRef, internal_exports as JsRenderInternal, MainAccessorName, OutputError, PColumnCollection, PFrameImpl, PlatformaSDKVersion, PluginDataModel, PluginDataModelBuilder, PluginInstance, PluginModel, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtxBase, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, StagingAccessorName, TreeNodeAccessor, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveExperimentDesignOptions, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, experimentDesign, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, listExperimentDesigns, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
|
75
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockModelV3, BlockRenderCtx, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, BlockStorageFacadeOptionalHandles, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, CurrentSdkInfo, DataColumn, DataColumnImpl, DataModel, DataModelBuilder, FutureRef, internal_exports as JsRenderInternal, MainAccessorName, OutputError, PColumnCollection, PFrameImpl, PlatformaSDKVersion, PluginDataModel, PluginDataModelBuilder, PluginInstance, PluginModel, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtxBase, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, StagingAccessorName, TreeNodeAccessor, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveExperimentDesignOptions, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, experimentDesign, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, listExperimentDesigns, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.97.0",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@milaboratories/columns-collection-driver": "0.3.4",
|
|
43
43
|
"@milaboratories/pf-driver": "1.9.25",
|
|
44
44
|
"@milaboratories/pf-spec-driver": "1.6.7",
|
|
45
|
-
"@milaboratories/ts-builder": "1.
|
|
45
|
+
"@milaboratories/ts-builder": "1.9.0",
|
|
46
46
|
"@milaboratories/ts-configs": "1.4.1",
|
|
47
47
|
"@platforma-sdk/block-kind": "1.1.1",
|
|
48
48
|
"@vitest/coverage-istanbul": "^4.1.12",
|