@platforma-sdk/model 1.87.0 → 1.88.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/block_api_v3.d.ts +9 -0
  2. package/dist/block_api_v3.d.ts.map +1 -1
  3. package/dist/block_model.cjs +89 -9
  4. package/dist/block_model.cjs.map +1 -1
  5. package/dist/block_model.d.ts +81 -19
  6. package/dist/block_model.d.ts.map +1 -1
  7. package/dist/block_model.js +89 -9
  8. package/dist/block_model.js.map +1 -1
  9. package/dist/block_storage_callbacks.cjs +128 -25
  10. package/dist/block_storage_callbacks.cjs.map +1 -1
  11. package/dist/block_storage_callbacks.js +129 -26
  12. package/dist/block_storage_callbacks.js.map +1 -1
  13. package/dist/block_storage_facade.cjs.map +1 -1
  14. package/dist/block_storage_facade.d.ts +37 -4
  15. package/dist/block_storage_facade.d.ts.map +1 -1
  16. package/dist/block_storage_facade.js.map +1 -1
  17. package/dist/columns/column_values.cjs +126 -0
  18. package/dist/columns/column_values.cjs.map +1 -0
  19. package/dist/columns/column_values.d.ts +65 -0
  20. package/dist/columns/column_values.d.ts.map +1 -0
  21. package/dist/columns/column_values.js +124 -0
  22. package/dist/columns/column_values.js.map +1 -0
  23. package/dist/columns/index.cjs +4 -0
  24. package/dist/columns/index.d.ts +2 -1
  25. package/dist/columns/index.js +2 -1
  26. package/dist/index.cjs +6 -0
  27. package/dist/index.d.ts +3 -1
  28. package/dist/index.js +3 -1
  29. package/dist/package.cjs +1 -1
  30. package/dist/package.js +1 -1
  31. package/dist/pframe_utils/column_value_options.cjs +85 -0
  32. package/dist/pframe_utils/column_value_options.cjs.map +1 -0
  33. package/dist/pframe_utils/column_value_options.d.ts +14 -0
  34. package/dist/pframe_utils/column_value_options.d.ts.map +1 -0
  35. package/dist/pframe_utils/column_value_options.js +85 -0
  36. package/dist/pframe_utils/column_value_options.js.map +1 -0
  37. package/dist/pframe_utils/index.cjs +2 -0
  38. package/dist/pframe_utils/index.cjs.map +1 -1
  39. package/dist/pframe_utils/index.d.ts +2 -1
  40. package/dist/pframe_utils/index.d.ts.map +1 -1
  41. package/dist/pframe_utils/index.js +2 -1
  42. package/dist/pframe_utils/index.js.map +1 -1
  43. package/package.json +15 -14
  44. package/src/args_issues.test.ts +532 -0
  45. package/src/block_api_v3.ts +10 -0
  46. package/src/block_model.ts +146 -32
  47. package/src/block_storage_callbacks.ts +174 -43
  48. package/src/block_storage_facade.ts +36 -6
  49. package/src/columns/column_values.test.ts +183 -0
  50. package/src/columns/column_values.ts +194 -0
  51. package/src/columns/index.ts +1 -0
  52. package/src/pframe_utils/column_value_options.test.ts +126 -0
  53. package/src/pframe_utils/column_value_options.ts +111 -0
  54. package/src/pframe_utils/index.ts +1 -0
@@ -1,7 +1,7 @@
1
1
  import { MutateStoragePayload } from "./block_storage.js";
2
2
  import { ConfigRenderLambda } from "./bconfig/lambdas.js";
3
3
  import "./bconfig/index.js";
4
- import { StringifiedJson } from "@milaboratories/pl-model-common";
4
+ import { ArgsIssue, StringifiedJson } from "@milaboratories/pl-model-common";
5
5
  /**
6
6
  * The current facade version. This value is used for `requiresModelAPIVersion`
7
7
  * feature flag in BlockModelV3.
@@ -93,27 +93,60 @@ export interface BlockStorageFacade {
93
93
  };
94
94
  /**
95
95
  * Derive args from storage.
96
- * Called to get block configuration args from storage.
96
+ * Called to get block configuration args from storage, and whether the block may run them.
97
+ *
98
+ * A middle layer that predates args issues reads only `error` and `value`, and each variant
99
+ * means the same to it as before: `value` is runnable args, `error` is no args. A block built
100
+ * with an SDK that predates args issues returns `{ error }` or `{ value }` with no `issues`.
101
+ *
97
102
  * @param storageJson - Storage as JSON string
98
- * @returns Args derivation result - either error or derived value
103
+ * @returns One of:
104
+ * - `{ error }`: `args()` threw, so there are no args;
105
+ * - `{ error, args, issues }`: args were built, but the block's `argsIssues()` found errors in
106
+ * them, so the block must not run; `error` joins the error messages, `issues` lists every
107
+ * issue;
108
+ * - `{ value, issues }`: args the block may run; `issues` holds the warnings.
99
109
  */
100
110
  [BlockStorageFacadeCallbacks.ArgsDerive]: (storageJson: StringifiedJson) => {
101
111
  error: string;
112
+ } | {
113
+ error: string;
114
+ args: unknown;
115
+ issues: ArgsIssue[];
102
116
  } | {
103
117
  error?: undefined;
104
118
  value: unknown;
119
+ issues: ArgsIssue[];
105
120
  };
106
121
  /**
107
122
  * Derive prerunArgs from storage.
108
123
  * Called to get prerun args; falls back to args callback if not registered.
124
+ *
125
+ * A block with its own prerunArgs is staged with them unless its `prerunArgsIssues()` finds errors
126
+ * in them. A block without its own prerunArgs is staged with its args unless its `argsIssues()`
127
+ * finds errors in them.
128
+ *
129
+ * A middle layer that predates args issues reads only `error` and `value`: `value` is args to
130
+ * stage, `error` skips staging. A block built with an SDK that predates args issues returns
131
+ * `{ error }` or `{ value }` with no `issues`.
132
+ *
109
133
  * @param storageJson - Storage as JSON string
110
- * @returns Args derivation result - either error or derived value
134
+ * @returns One of:
135
+ * - `{ error }`: the lambda building the prerun args threw;
136
+ * - `{ error, issues }`: prerun args were built, but errors were found in them, so the block
137
+ * is not staged; `error` joins the error messages, `issues` lists every issue;
138
+ * - `{ value, issues }`: args to stage, `undefined` to skip staging; `issues` holds the
139
+ * warnings.
111
140
  */
112
141
  [BlockStorageFacadeCallbacks.PrerunArgsDerive]: (storageJson: StringifiedJson) => {
113
142
  error: string;
143
+ } | {
144
+ error: string;
145
+ issues: ArgsIssue[];
114
146
  } | {
115
147
  error?: undefined;
116
148
  value: unknown;
149
+ issues: ArgsIssue[];
117
150
  };
118
151
  /**
119
152
  * Get initial storage JSON for new blocks.
@@ -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;;;;;;qBAmBW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BI;;;;;;;;GAQd,4BAA4B,sBAC3B,oBAAoB,iBACpB,SAAS,yBACN;;;;;;;GAQJ,4BAA4B,oBAC3B,aAAa,gCACV;;;;;;;GAQJ,4BAA4B,kBAC3B,oBAAoB;IAEhB;;IAEA;IACA,gBAAgB;IAChB;;;;;;;;GASL,4BAA4B,cAC3B,aAAa;IACR;;IAAoB;IAAmB;;;;;;;;GAQ7C,4BAA4B,oBAC3B,aAAa;IACR;;IAAoB;IAAmB;;;;;;;GAO7C,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;;;;wBAIb,wBAAwB,WAAW"}
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;;;;;;qBAmBW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;wBAIb,wBAAwB,WAAW"}
@@ -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 { 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.\n * @param storageJson - Storage as JSON string\n * @returns Args derivation result - either error or derived value\n */\n [BlockStorageFacadeCallbacks.ArgsDerive]: (\n storageJson: StringifiedJson,\n ) => { error: string } | { error?: undefined; value: unknown };\n\n /**\n * Derive prerunArgs from storage.\n * Called to get prerun args; falls back to args callback if not registered.\n * @param storageJson - Storage as JSON string\n * @returns Args derivation result - either error or derived value\n */\n [BlockStorageFacadeCallbacks.PrerunArgsDerive]: (\n storageJson: StringifiedJson,\n ) => { error: string } | { error?: undefined; value: unknown };\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;;AA0LxF,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} 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"}
@@ -0,0 +1,126 @@
1
+ const require_internal = require("../internal.cjs");
2
+ const require_api = require("../render/api.cjs");
3
+ const require_index = require("./column_recipes/index.cjs");
4
+ let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
5
+ // src/columns/column_values.ts
6
+ /**
7
+ * The model of a value picker over the values of `valueColumn`, for a model output; the UI reads
8
+ * the options through it (`usePlColumnValueOptions`, `PlColumnValueDropdown`). Each option is a
9
+ * value of `valueColumn`, labelled by the value of `labelColumn` in the same row, or by the value
10
+ * itself when no label column is given.
11
+ *
12
+ * `absent` once the value column is gone: a stored id may name a column its upstream block no
13
+ * longer produces. A label column that is gone leaves the values to label themselves; one that is
14
+ * still resolving keeps the model resolving.
15
+ */
16
+ function createColumnValueOptions(columns, deps) {
17
+ const ctx = deps?.ctx ?? require_internal.getCfgRenderCtx();
18
+ const value = frameEntryOf(columns.valueColumn, ctx);
19
+ const valueColumn = value.id;
20
+ if (value.status !== "present") return {
21
+ type: value.status,
22
+ valueColumn
23
+ };
24
+ const label = columns.labelColumn === void 0 ? void 0 : frameEntryOf(columns.labelColumn, ctx);
25
+ if (label?.status === "resolving") return {
26
+ type: "resolving",
27
+ valueColumn
28
+ };
29
+ const labelled = label?.status === "present" && label.frameId !== value.frameId ? label : void 0;
30
+ return {
31
+ type: "present",
32
+ valueColumn,
33
+ frame: ctx.createPFrame(labelled === void 0 ? [value.def] : [value.def, labelled.def]),
34
+ frameColumns: {
35
+ value: value.frameId,
36
+ label: labelled?.frameId ?? null
37
+ }
38
+ };
39
+ }
40
+ /**
41
+ * Distinct `values` of `column` as options, each a column value id naming the column, labelled
42
+ * by the value itself and ordered naturally by label ("R2" before "R10"). Empty values are not
43
+ * offered.
44
+ */
45
+ function deriveColumnValueOptions(column, values) {
46
+ return deriveLabelledColumnValueOptions(column, values.map((value) => ({
47
+ value,
48
+ label: value
49
+ })));
50
+ }
51
+ /**
52
+ * Distinct values of `column` among `rows` as options, each a column value id naming the column,
53
+ * labelled by the label of the first row holding the value, and ordered naturally by label ("R2"
54
+ * before "R10"). Empty values are not offered; a value whose label is empty labels itself.
55
+ */
56
+ function deriveLabelledColumnValueOptions(column, rows) {
57
+ const options = /* @__PURE__ */ new Map();
58
+ for (const { value, label } of rows) {
59
+ if (value === "" || options.has(value)) continue;
60
+ options.set(value, {
61
+ value: (0, _milaboratories_pl_model_common.createColumnValueId)({
62
+ column,
63
+ value
64
+ }),
65
+ label: label === "" ? value : label
66
+ });
67
+ }
68
+ return [...options.values()].sort((a, b) => compareNatural(a.label, b.label));
69
+ }
70
+ /**
71
+ * A column given by id or by a recipe goes into the frame by its id, which the frame holds as the
72
+ * bare id of its leaf; a materialised column goes in as it is.
73
+ */
74
+ function frameEntryOf(column, ctx) {
75
+ if (typeof column === "string") return {
76
+ id: column,
77
+ status: require_index.ColumnRecipe.getStatus(column, { ctx }),
78
+ frameId: (0, _milaboratories_pl_model_common.extractPObjectId)(column),
79
+ def: column
80
+ };
81
+ if ((0, _milaboratories_pl_model_common.isPColumn)(column)) return {
82
+ id: column.id,
83
+ status: "present",
84
+ frameId: column.id,
85
+ def: require_api.finalizePColumnData(column)
86
+ };
87
+ return {
88
+ id: column.id,
89
+ status: column.getDataStatus(),
90
+ frameId: (0, _milaboratories_pl_model_common.extractPObjectId)(column.id),
91
+ def: column.id
92
+ };
93
+ }
94
+ const CHUNKS = /\d+|\D+/g;
95
+ /**
96
+ * Natural order: runs of digits compare as numbers, other text case-insensitively, so "R2"
97
+ * comes before "R10". The model runtime has no `Intl`.
98
+ */
99
+ function compareNatural(a, b) {
100
+ const chunksA = a.match(CHUNKS) ?? [];
101
+ const chunksB = b.match(CHUNKS) ?? [];
102
+ for (let i = 0; i < Math.min(chunksA.length, chunksB.length); i++) {
103
+ const order = compareChunks(chunksA[i], chunksB[i]);
104
+ if (order !== 0) return order;
105
+ }
106
+ return chunksA.length - chunksB.length || compareStrings(a, b);
107
+ }
108
+ function compareChunks(a, b) {
109
+ if (isDigits(a) && isDigits(b)) {
110
+ const numberA = a.replace(/^0+(?=\d)/, "");
111
+ const numberB = b.replace(/^0+(?=\d)/, "");
112
+ return numberA.length - numberB.length || compareStrings(numberA, numberB);
113
+ }
114
+ return compareStrings(a.toLowerCase(), b.toLowerCase());
115
+ }
116
+ function isDigits(chunk) {
117
+ return chunk.charCodeAt(0) >= 48 && chunk.charCodeAt(0) <= 57;
118
+ }
119
+ function compareStrings(a, b) {
120
+ return a < b ? -1 : a > b ? 1 : 0;
121
+ }
122
+ exports.createColumnValueOptions = createColumnValueOptions;
123
+ exports.deriveColumnValueOptions = deriveColumnValueOptions;
124
+ exports.deriveLabelledColumnValueOptions = deriveLabelledColumnValueOptions;
125
+
126
+ //# sourceMappingURL=column_values.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column_values.cjs","names":["getCfgRenderCtx","createColumnValueId","ColumnRecipe","extractPObjectId","isPColumn","finalizePColumnData"],"sources":["../../src/columns/column_values.ts"],"sourcesContent":["import {\n createColumnValueId,\n extractPObjectId,\n isPColumn,\n type ColumnUniversalId,\n type ColumnValueId,\n type PColumn,\n type PFrameHandle,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { finalizePColumnData } from \"../render/api\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { ColumnRecipe } from \"./column_recipes\";\nimport type { ColumnResolutionStatus } from \"./column_recipes/types\";\nimport type { DataColumnRecipe } from \"./data_column\";\n\n/** Drop-down option for a value of a column — column-value-id valued. */\nexport type ColumnValueOption = {\n readonly value: ColumnValueId;\n readonly label: string;\n};\n\n/** A column a value picker offers the values of, or labels them by. */\nexport type ColumnValueOptionsColumn =\n | ColumnUniversalId\n | PColumn<undefined | PColumnDataUniversal>\n | DataColumnRecipe\n | ColumnRecipe;\n\n/**\n * What a UI reads the options of a value picker from: a frame holding the value column, and the\n * label column while there is one, as long as the value column is there. `valueColumn` is the\n * column the options are values of, so the UI can tell a model that still describes an earlier\n * pick. `frameColumns` names both columns as the frame holds them.\n */\nexport type ColumnValueOptionsModel =\n | { readonly type: \"resolving\"; readonly valueColumn: ColumnUniversalId }\n | { readonly type: \"absent\"; readonly valueColumn: ColumnUniversalId }\n | {\n readonly type: \"present\";\n readonly valueColumn: ColumnUniversalId;\n readonly frame: PFrameHandle;\n readonly frameColumns: {\n readonly value: PObjectId;\n /** `null` when the values label themselves. */\n readonly label: PObjectId | null;\n };\n };\n\n/**\n * The model of a value picker over the values of `valueColumn`, for a model output; the UI reads\n * the options through it (`usePlColumnValueOptions`, `PlColumnValueDropdown`). Each option is a\n * value of `valueColumn`, labelled by the value of `labelColumn` in the same row, or by the value\n * itself when no label column is given.\n *\n * `absent` once the value column is gone: a stored id may name a column its upstream block no\n * longer produces. A label column that is gone leaves the values to label themselves; one that is\n * still resolving keeps the model resolving.\n */\nexport function createColumnValueOptions(\n columns: {\n readonly valueColumn: ColumnValueOptionsColumn;\n readonly labelColumn?: ColumnValueOptionsColumn;\n },\n deps?: { readonly ctx?: GlobalCfgRenderCtx },\n): ColumnValueOptionsModel {\n const ctx = deps?.ctx ?? getCfgRenderCtx();\n const value = frameEntryOf(columns.valueColumn, ctx);\n const valueColumn = value.id;\n if (value.status !== \"present\") return { type: value.status, valueColumn };\n\n const label =\n columns.labelColumn === undefined ? undefined : frameEntryOf(columns.labelColumn, ctx);\n if (label?.status === \"resolving\") return { type: \"resolving\", valueColumn };\n const labelled =\n label?.status === \"present\" && label.frameId !== value.frameId ? label : undefined;\n\n const frame = ctx.createPFrame(labelled === undefined ? [value.def] : [value.def, labelled.def]);\n return {\n type: \"present\",\n valueColumn,\n frame,\n frameColumns: { value: value.frameId, label: labelled?.frameId ?? null },\n };\n}\n\n/**\n * Distinct `values` of `column` as options, each a column value id naming the column, labelled\n * by the value itself and ordered naturally by label (\"R2\" before \"R10\"). Empty values are not\n * offered.\n */\nexport function deriveColumnValueOptions(\n column: ColumnUniversalId,\n values: readonly string[],\n): ColumnValueOption[] {\n return deriveLabelledColumnValueOptions(\n column,\n values.map((value) => ({ value, label: value })),\n );\n}\n\n/**\n * Distinct values of `column` among `rows` as options, each a column value id naming the column,\n * labelled by the label of the first row holding the value, and ordered naturally by label (\"R2\"\n * before \"R10\"). Empty values are not offered; a value whose label is empty labels itself.\n */\nexport function deriveLabelledColumnValueOptions(\n column: ColumnUniversalId,\n rows: readonly { readonly value: string; readonly label: string }[],\n): ColumnValueOption[] {\n const options = new Map<string, ColumnValueOption>();\n for (const { value, label } of rows) {\n if (value === \"\" || options.has(value)) continue;\n options.set(value, {\n value: createColumnValueId({ column, value }),\n label: label === \"\" ? value : label,\n });\n }\n return [...options.values()].sort((a, b) => compareNatural(a.label, b.label));\n}\n\n// Internals\n\n/** A column as a frame is made of it: its id, its status, and what the frame is created from. */\ntype FrameEntry = {\n readonly id: ColumnUniversalId;\n readonly status: ColumnResolutionStatus;\n readonly frameId: PObjectId;\n readonly def: Parameters<GlobalCfgRenderCtx[\"createPFrame\"]>[0][number];\n};\n\n/**\n * A column given by id or by a recipe goes into the frame by its id, which the frame holds as the\n * bare id of its leaf; a materialised column goes in as it is.\n */\nfunction frameEntryOf(column: ColumnValueOptionsColumn, ctx: GlobalCfgRenderCtx): FrameEntry {\n if (typeof column === \"string\") {\n return {\n id: column,\n status: ColumnRecipe.getStatus(column, { ctx }),\n frameId: extractPObjectId(column),\n def: column,\n };\n }\n if (isPColumn<undefined | PColumnDataUniversal>(column)) {\n return {\n id: column.id,\n status: \"present\",\n frameId: column.id,\n def: finalizePColumnData(column),\n };\n }\n return {\n id: column.id,\n status: column.getDataStatus(),\n frameId: extractPObjectId(column.id),\n def: column.id,\n };\n}\n\nconst CHUNKS = /\\d+|\\D+/g;\n\n/**\n * Natural order: runs of digits compare as numbers, other text case-insensitively, so \"R2\"\n * comes before \"R10\". The model runtime has no `Intl`.\n */\nfunction compareNatural(a: string, b: string): number {\n const chunksA = a.match(CHUNKS) ?? [];\n const chunksB = b.match(CHUNKS) ?? [];\n for (let i = 0; i < Math.min(chunksA.length, chunksB.length); i++) {\n const order = compareChunks(chunksA[i], chunksB[i]);\n if (order !== 0) return order;\n }\n return chunksA.length - chunksB.length || compareStrings(a, b);\n}\n\nfunction compareChunks(a: string, b: string): number {\n if (isDigits(a) && isDigits(b)) {\n // Compared as digit strings, so numbers of any length keep their order.\n const numberA = a.replace(/^0+(?=\\d)/, \"\");\n const numberB = b.replace(/^0+(?=\\d)/, \"\");\n return numberA.length - numberB.length || compareStrings(numberA, numberB);\n }\n return compareStrings(a.toLowerCase(), b.toLowerCase());\n}\n\nfunction isDigits(chunk: string): boolean {\n return chunk.charCodeAt(0) >= 48 && chunk.charCodeAt(0) <= 57;\n}\n\nfunction compareStrings(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n"],"mappings":"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"}
@@ -0,0 +1,65 @@
1
+ import { GlobalCfgRenderCtx, PColumnDataUniversal } from "../render/internal.js";
2
+ import { DataColumnRecipe } from "./data_column.js";
3
+ import { ColumnRecipe } from "./column_recipes/index.js";
4
+ import { ColumnUniversalId, ColumnValueId, PColumn, PFrameHandle, PObjectId } from "@milaboratories/pl-model-common";
5
+ /** Drop-down option for a value of a column — column-value-id valued. */
6
+ export type ColumnValueOption = {
7
+ readonly value: ColumnValueId;
8
+ readonly label: string;
9
+ };
10
+ /** A column a value picker offers the values of, or labels them by. */
11
+ export type ColumnValueOptionsColumn = ColumnUniversalId | PColumn<undefined | PColumnDataUniversal> | DataColumnRecipe | ColumnRecipe;
12
+ /**
13
+ * What a UI reads the options of a value picker from: a frame holding the value column, and the
14
+ * label column while there is one, as long as the value column is there. `valueColumn` is the
15
+ * column the options are values of, so the UI can tell a model that still describes an earlier
16
+ * pick. `frameColumns` names both columns as the frame holds them.
17
+ */
18
+ export type ColumnValueOptionsModel = {
19
+ readonly type: "resolving";
20
+ readonly valueColumn: ColumnUniversalId;
21
+ } | {
22
+ readonly type: "absent";
23
+ readonly valueColumn: ColumnUniversalId;
24
+ } | {
25
+ readonly type: "present";
26
+ readonly valueColumn: ColumnUniversalId;
27
+ readonly frame: PFrameHandle;
28
+ readonly frameColumns: {
29
+ readonly value: PObjectId;
30
+ /** `null` when the values label themselves. */
31
+ readonly label: PObjectId | null;
32
+ };
33
+ };
34
+ /**
35
+ * The model of a value picker over the values of `valueColumn`, for a model output; the UI reads
36
+ * the options through it (`usePlColumnValueOptions`, `PlColumnValueDropdown`). Each option is a
37
+ * value of `valueColumn`, labelled by the value of `labelColumn` in the same row, or by the value
38
+ * itself when no label column is given.
39
+ *
40
+ * `absent` once the value column is gone: a stored id may name a column its upstream block no
41
+ * longer produces. A label column that is gone leaves the values to label themselves; one that is
42
+ * still resolving keeps the model resolving.
43
+ */
44
+ export declare function createColumnValueOptions(columns: {
45
+ readonly valueColumn: ColumnValueOptionsColumn;
46
+ readonly labelColumn?: ColumnValueOptionsColumn;
47
+ }, deps?: {
48
+ readonly ctx?: GlobalCfgRenderCtx;
49
+ }): ColumnValueOptionsModel;
50
+ /**
51
+ * Distinct `values` of `column` as options, each a column value id naming the column, labelled
52
+ * by the value itself and ordered naturally by label ("R2" before "R10"). Empty values are not
53
+ * offered.
54
+ */
55
+ export declare function deriveColumnValueOptions(column: ColumnUniversalId, values: readonly string[]): ColumnValueOption[];
56
+ /**
57
+ * Distinct values of `column` among `rows` as options, each a column value id naming the column,
58
+ * labelled by the label of the first row holding the value, and ordered naturally by label ("R2"
59
+ * before "R10"). Empty values are not offered; a value whose label is empty labels itself.
60
+ */
61
+ export declare function deriveLabelledColumnValueOptions(column: ColumnUniversalId, rows: readonly {
62
+ readonly value: string;
63
+ readonly label: string;
64
+ }[]): ColumnValueOption[];
65
+ //# sourceMappingURL=column_values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column_values.d.ts","names":[],"sources":["../../src/columns/column_values.ts"],"mappings":";;;;;YAkBY;WACD,OAAO;WACP;;;YAIC,2BACR,oBACA,oBAAoB,wBACpB,mBACA;;;;;;;YAQQ;WACG;WAA4B,aAAa;;WACzC;WAAyB,aAAa;;WAEtC;WACA,aAAa;WACb,OAAO;WACP;aACE,OAAO;;aAEP,OAAO;;;;;;;;;;;;;wBAcR,yBACd;WACW,aAAa;WACb,cAAc;GAEzB;WAAkB,MAAM;IACvB;;;;;;wBA0Ba,yBACd,QAAQ,mBACR,4BACC;;;;;;wBAYa,iCACd,QAAQ,mBACR;WAA0B;WAAwB;MACjD"}
@@ -0,0 +1,124 @@
1
+ import { getCfgRenderCtx } from "../internal.js";
2
+ import { finalizePColumnData } from "../render/api.js";
3
+ import { ColumnRecipe } from "./column_recipes/index.js";
4
+ import { createColumnValueId, extractPObjectId, isPColumn } from "@milaboratories/pl-model-common";
5
+ // src/columns/column_values.ts
6
+ /**
7
+ * The model of a value picker over the values of `valueColumn`, for a model output; the UI reads
8
+ * the options through it (`usePlColumnValueOptions`, `PlColumnValueDropdown`). Each option is a
9
+ * value of `valueColumn`, labelled by the value of `labelColumn` in the same row, or by the value
10
+ * itself when no label column is given.
11
+ *
12
+ * `absent` once the value column is gone: a stored id may name a column its upstream block no
13
+ * longer produces. A label column that is gone leaves the values to label themselves; one that is
14
+ * still resolving keeps the model resolving.
15
+ */
16
+ function createColumnValueOptions(columns, deps) {
17
+ const ctx = deps?.ctx ?? getCfgRenderCtx();
18
+ const value = frameEntryOf(columns.valueColumn, ctx);
19
+ const valueColumn = value.id;
20
+ if (value.status !== "present") return {
21
+ type: value.status,
22
+ valueColumn
23
+ };
24
+ const label = columns.labelColumn === void 0 ? void 0 : frameEntryOf(columns.labelColumn, ctx);
25
+ if (label?.status === "resolving") return {
26
+ type: "resolving",
27
+ valueColumn
28
+ };
29
+ const labelled = label?.status === "present" && label.frameId !== value.frameId ? label : void 0;
30
+ return {
31
+ type: "present",
32
+ valueColumn,
33
+ frame: ctx.createPFrame(labelled === void 0 ? [value.def] : [value.def, labelled.def]),
34
+ frameColumns: {
35
+ value: value.frameId,
36
+ label: labelled?.frameId ?? null
37
+ }
38
+ };
39
+ }
40
+ /**
41
+ * Distinct `values` of `column` as options, each a column value id naming the column, labelled
42
+ * by the value itself and ordered naturally by label ("R2" before "R10"). Empty values are not
43
+ * offered.
44
+ */
45
+ function deriveColumnValueOptions(column, values) {
46
+ return deriveLabelledColumnValueOptions(column, values.map((value) => ({
47
+ value,
48
+ label: value
49
+ })));
50
+ }
51
+ /**
52
+ * Distinct values of `column` among `rows` as options, each a column value id naming the column,
53
+ * labelled by the label of the first row holding the value, and ordered naturally by label ("R2"
54
+ * before "R10"). Empty values are not offered; a value whose label is empty labels itself.
55
+ */
56
+ function deriveLabelledColumnValueOptions(column, rows) {
57
+ const options = /* @__PURE__ */ new Map();
58
+ for (const { value, label } of rows) {
59
+ if (value === "" || options.has(value)) continue;
60
+ options.set(value, {
61
+ value: createColumnValueId({
62
+ column,
63
+ value
64
+ }),
65
+ label: label === "" ? value : label
66
+ });
67
+ }
68
+ return [...options.values()].sort((a, b) => compareNatural(a.label, b.label));
69
+ }
70
+ /**
71
+ * A column given by id or by a recipe goes into the frame by its id, which the frame holds as the
72
+ * bare id of its leaf; a materialised column goes in as it is.
73
+ */
74
+ function frameEntryOf(column, ctx) {
75
+ if (typeof column === "string") return {
76
+ id: column,
77
+ status: ColumnRecipe.getStatus(column, { ctx }),
78
+ frameId: extractPObjectId(column),
79
+ def: column
80
+ };
81
+ if (isPColumn(column)) return {
82
+ id: column.id,
83
+ status: "present",
84
+ frameId: column.id,
85
+ def: finalizePColumnData(column)
86
+ };
87
+ return {
88
+ id: column.id,
89
+ status: column.getDataStatus(),
90
+ frameId: extractPObjectId(column.id),
91
+ def: column.id
92
+ };
93
+ }
94
+ const CHUNKS = /\d+|\D+/g;
95
+ /**
96
+ * Natural order: runs of digits compare as numbers, other text case-insensitively, so "R2"
97
+ * comes before "R10". The model runtime has no `Intl`.
98
+ */
99
+ function compareNatural(a, b) {
100
+ const chunksA = a.match(CHUNKS) ?? [];
101
+ const chunksB = b.match(CHUNKS) ?? [];
102
+ for (let i = 0; i < Math.min(chunksA.length, chunksB.length); i++) {
103
+ const order = compareChunks(chunksA[i], chunksB[i]);
104
+ if (order !== 0) return order;
105
+ }
106
+ return chunksA.length - chunksB.length || compareStrings(a, b);
107
+ }
108
+ function compareChunks(a, b) {
109
+ if (isDigits(a) && isDigits(b)) {
110
+ const numberA = a.replace(/^0+(?=\d)/, "");
111
+ const numberB = b.replace(/^0+(?=\d)/, "");
112
+ return numberA.length - numberB.length || compareStrings(numberA, numberB);
113
+ }
114
+ return compareStrings(a.toLowerCase(), b.toLowerCase());
115
+ }
116
+ function isDigits(chunk) {
117
+ return chunk.charCodeAt(0) >= 48 && chunk.charCodeAt(0) <= 57;
118
+ }
119
+ function compareStrings(a, b) {
120
+ return a < b ? -1 : a > b ? 1 : 0;
121
+ }
122
+ export { createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions };
123
+
124
+ //# sourceMappingURL=column_values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column_values.js","names":[],"sources":["../../src/columns/column_values.ts"],"sourcesContent":["import {\n createColumnValueId,\n extractPObjectId,\n isPColumn,\n type ColumnUniversalId,\n type ColumnValueId,\n type PColumn,\n type PFrameHandle,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { finalizePColumnData } from \"../render/api\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { ColumnRecipe } from \"./column_recipes\";\nimport type { ColumnResolutionStatus } from \"./column_recipes/types\";\nimport type { DataColumnRecipe } from \"./data_column\";\n\n/** Drop-down option for a value of a column — column-value-id valued. */\nexport type ColumnValueOption = {\n readonly value: ColumnValueId;\n readonly label: string;\n};\n\n/** A column a value picker offers the values of, or labels them by. */\nexport type ColumnValueOptionsColumn =\n | ColumnUniversalId\n | PColumn<undefined | PColumnDataUniversal>\n | DataColumnRecipe\n | ColumnRecipe;\n\n/**\n * What a UI reads the options of a value picker from: a frame holding the value column, and the\n * label column while there is one, as long as the value column is there. `valueColumn` is the\n * column the options are values of, so the UI can tell a model that still describes an earlier\n * pick. `frameColumns` names both columns as the frame holds them.\n */\nexport type ColumnValueOptionsModel =\n | { readonly type: \"resolving\"; readonly valueColumn: ColumnUniversalId }\n | { readonly type: \"absent\"; readonly valueColumn: ColumnUniversalId }\n | {\n readonly type: \"present\";\n readonly valueColumn: ColumnUniversalId;\n readonly frame: PFrameHandle;\n readonly frameColumns: {\n readonly value: PObjectId;\n /** `null` when the values label themselves. */\n readonly label: PObjectId | null;\n };\n };\n\n/**\n * The model of a value picker over the values of `valueColumn`, for a model output; the UI reads\n * the options through it (`usePlColumnValueOptions`, `PlColumnValueDropdown`). Each option is a\n * value of `valueColumn`, labelled by the value of `labelColumn` in the same row, or by the value\n * itself when no label column is given.\n *\n * `absent` once the value column is gone: a stored id may name a column its upstream block no\n * longer produces. A label column that is gone leaves the values to label themselves; one that is\n * still resolving keeps the model resolving.\n */\nexport function createColumnValueOptions(\n columns: {\n readonly valueColumn: ColumnValueOptionsColumn;\n readonly labelColumn?: ColumnValueOptionsColumn;\n },\n deps?: { readonly ctx?: GlobalCfgRenderCtx },\n): ColumnValueOptionsModel {\n const ctx = deps?.ctx ?? getCfgRenderCtx();\n const value = frameEntryOf(columns.valueColumn, ctx);\n const valueColumn = value.id;\n if (value.status !== \"present\") return { type: value.status, valueColumn };\n\n const label =\n columns.labelColumn === undefined ? undefined : frameEntryOf(columns.labelColumn, ctx);\n if (label?.status === \"resolving\") return { type: \"resolving\", valueColumn };\n const labelled =\n label?.status === \"present\" && label.frameId !== value.frameId ? label : undefined;\n\n const frame = ctx.createPFrame(labelled === undefined ? [value.def] : [value.def, labelled.def]);\n return {\n type: \"present\",\n valueColumn,\n frame,\n frameColumns: { value: value.frameId, label: labelled?.frameId ?? null },\n };\n}\n\n/**\n * Distinct `values` of `column` as options, each a column value id naming the column, labelled\n * by the value itself and ordered naturally by label (\"R2\" before \"R10\"). Empty values are not\n * offered.\n */\nexport function deriveColumnValueOptions(\n column: ColumnUniversalId,\n values: readonly string[],\n): ColumnValueOption[] {\n return deriveLabelledColumnValueOptions(\n column,\n values.map((value) => ({ value, label: value })),\n );\n}\n\n/**\n * Distinct values of `column` among `rows` as options, each a column value id naming the column,\n * labelled by the label of the first row holding the value, and ordered naturally by label (\"R2\"\n * before \"R10\"). Empty values are not offered; a value whose label is empty labels itself.\n */\nexport function deriveLabelledColumnValueOptions(\n column: ColumnUniversalId,\n rows: readonly { readonly value: string; readonly label: string }[],\n): ColumnValueOption[] {\n const options = new Map<string, ColumnValueOption>();\n for (const { value, label } of rows) {\n if (value === \"\" || options.has(value)) continue;\n options.set(value, {\n value: createColumnValueId({ column, value }),\n label: label === \"\" ? value : label,\n });\n }\n return [...options.values()].sort((a, b) => compareNatural(a.label, b.label));\n}\n\n// Internals\n\n/** A column as a frame is made of it: its id, its status, and what the frame is created from. */\ntype FrameEntry = {\n readonly id: ColumnUniversalId;\n readonly status: ColumnResolutionStatus;\n readonly frameId: PObjectId;\n readonly def: Parameters<GlobalCfgRenderCtx[\"createPFrame\"]>[0][number];\n};\n\n/**\n * A column given by id or by a recipe goes into the frame by its id, which the frame holds as the\n * bare id of its leaf; a materialised column goes in as it is.\n */\nfunction frameEntryOf(column: ColumnValueOptionsColumn, ctx: GlobalCfgRenderCtx): FrameEntry {\n if (typeof column === \"string\") {\n return {\n id: column,\n status: ColumnRecipe.getStatus(column, { ctx }),\n frameId: extractPObjectId(column),\n def: column,\n };\n }\n if (isPColumn<undefined | PColumnDataUniversal>(column)) {\n return {\n id: column.id,\n status: \"present\",\n frameId: column.id,\n def: finalizePColumnData(column),\n };\n }\n return {\n id: column.id,\n status: column.getDataStatus(),\n frameId: extractPObjectId(column.id),\n def: column.id,\n };\n}\n\nconst CHUNKS = /\\d+|\\D+/g;\n\n/**\n * Natural order: runs of digits compare as numbers, other text case-insensitively, so \"R2\"\n * comes before \"R10\". The model runtime has no `Intl`.\n */\nfunction compareNatural(a: string, b: string): number {\n const chunksA = a.match(CHUNKS) ?? [];\n const chunksB = b.match(CHUNKS) ?? [];\n for (let i = 0; i < Math.min(chunksA.length, chunksB.length); i++) {\n const order = compareChunks(chunksA[i], chunksB[i]);\n if (order !== 0) return order;\n }\n return chunksA.length - chunksB.length || compareStrings(a, b);\n}\n\nfunction compareChunks(a: string, b: string): number {\n if (isDigits(a) && isDigits(b)) {\n // Compared as digit strings, so numbers of any length keep their order.\n const numberA = a.replace(/^0+(?=\\d)/, \"\");\n const numberB = b.replace(/^0+(?=\\d)/, \"\");\n return numberA.length - numberB.length || compareStrings(numberA, numberB);\n }\n return compareStrings(a.toLowerCase(), b.toLowerCase());\n}\n\nfunction isDigits(chunk: string): boolean {\n return chunk.charCodeAt(0) >= 48 && chunk.charCodeAt(0) <= 57;\n}\n\nfunction compareStrings(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4DA,SAAgB,yBACd,SAIA,MACyB;CACzB,MAAM,MAAM,MAAM,OAAO,gBAAgB;CACzC,MAAM,QAAQ,aAAa,QAAQ,aAAa,GAAG;CACnD,MAAM,cAAc,MAAM;CAC1B,IAAI,MAAM,WAAW,WAAW,OAAO;EAAE,MAAM,MAAM;EAAQ;CAAY;CAEzE,MAAM,QACJ,QAAQ,gBAAgB,KAAA,IAAY,KAAA,IAAY,aAAa,QAAQ,aAAa,GAAG;CACvF,IAAI,OAAO,WAAW,aAAa,OAAO;EAAE,MAAM;EAAa;CAAY;CAC3E,MAAM,WACJ,OAAO,WAAW,aAAa,MAAM,YAAY,MAAM,UAAU,QAAQ,KAAA;CAG3E,OAAO;EACL,MAAM;EACN;EACA,OAJY,IAAI,aAAa,aAAa,KAAA,IAAY,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,KAAK,SAAS,GAAG,CAIxF;EACJ,cAAc;GAAE,OAAO,MAAM;GAAS,OAAO,UAAU,WAAW;EAAK;CACzE;AACF;;;;;;AAOA,SAAgB,yBACd,QACA,QACqB;CACrB,OAAO,iCACL,QACA,OAAO,KAAK,WAAW;EAAE;EAAO,OAAO;CAAM,EAAE,CACjD;AACF;;;;;;AAOA,SAAgB,iCACd,QACA,MACqB;CACrB,MAAM,0BAAU,IAAI,IAA+B;CACnD,KAAK,MAAM,EAAE,OAAO,WAAW,MAAM;EACnC,IAAI,UAAU,MAAM,QAAQ,IAAI,KAAK,GAAG;EACxC,QAAQ,IAAI,OAAO;GACjB,OAAO,oBAAoB;IAAE;IAAQ;GAAM,CAAC;GAC5C,OAAO,UAAU,KAAK,QAAQ;EAChC,CAAC;CACH;CACA,OAAO,CAAC,GAAG,QAAQ,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC;AAC9E;;;;;AAgBA,SAAS,aAAa,QAAkC,KAAqC;CAC3F,IAAI,OAAO,WAAW,UACpB,OAAO;EACL,IAAI;EACJ,QAAQ,aAAa,UAAU,QAAQ,EAAE,IAAI,CAAC;EAC9C,SAAS,iBAAiB,MAAM;EAChC,KAAK;CACP;CAEF,IAAI,UAA4C,MAAM,GACpD,OAAO;EACL,IAAI,OAAO;EACX,QAAQ;EACR,SAAS,OAAO;EAChB,KAAK,oBAAoB,MAAM;CACjC;CAEF,OAAO;EACL,IAAI,OAAO;EACX,QAAQ,OAAO,cAAc;EAC7B,SAAS,iBAAiB,OAAO,EAAE;EACnC,KAAK,OAAO;CACd;AACF;AAEA,MAAM,SAAS;;;;;AAMf,SAAS,eAAe,GAAW,GAAmB;CACpD,MAAM,UAAU,EAAE,MAAM,MAAM,KAAK,CAAC;CACpC,MAAM,UAAU,EAAE,MAAM,MAAM,KAAK,CAAC;CACpC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IAAI,QAAQ,QAAQ,QAAQ,MAAM,GAAG,KAAK;EACjE,MAAM,QAAQ,cAAc,QAAQ,IAAI,QAAQ,EAAE;EAClD,IAAI,UAAU,GAAG,OAAO;CAC1B;CACA,OAAO,QAAQ,SAAS,QAAQ,UAAU,eAAe,GAAG,CAAC;AAC/D;AAEA,SAAS,cAAc,GAAW,GAAmB;CACnD,IAAI,SAAS,CAAC,KAAK,SAAS,CAAC,GAAG;EAE9B,MAAM,UAAU,EAAE,QAAQ,aAAa,EAAE;EACzC,MAAM,UAAU,EAAE,QAAQ,aAAa,EAAE;EACzC,OAAO,QAAQ,SAAS,QAAQ,UAAU,eAAe,SAAS,OAAO;CAC3E;CACA,OAAO,eAAe,EAAE,YAAY,GAAG,EAAE,YAAY,CAAC;AACxD;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,MAAM,WAAW,CAAC,KAAK,MAAM,MAAM,WAAW,CAAC,KAAK;AAC7D;AAEA,SAAS,eAAe,GAAW,GAAmB;CACpD,OAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;AAClC"}
@@ -11,6 +11,7 @@ const require_peer_links = require("./peer_links.cjs");
11
11
  const require_utils = require("./utils.cjs");
12
12
  const require_derive_axis_values_labels = require("./derive_axis_values_labels.cjs");
13
13
  const require_split_by_axes = require("./split_by_axes.cjs");
14
+ const require_column_values = require("./column_values.cjs");
14
15
  exports.AccessorColumnsProvider = require_providers.AccessorColumnsProvider;
15
16
  exports.AccessorColumnsProviderImpl = require_providers.AccessorColumnsProviderImpl;
16
17
  exports.ArrayColumnsProvider = require_providers.ArrayColumnsProvider;
@@ -30,9 +31,12 @@ exports._ctxProvidersCache = require_index$1._ctxProvidersCache;
30
31
  exports.collectDatasetAxes = require_peer_links.collectDatasetAxes;
31
32
  exports.collectLinkerColumns = require_utils.collectLinkerColumns;
32
33
  exports.collectLinkerIds = require_utils.collectLinkerIds;
34
+ exports.createColumnValueOptions = require_column_values.createColumnValueOptions;
33
35
  exports.createPeerLinkFinder = require_utils.createPeerLinkFinder;
34
36
  exports.deriveAxisValuesLabels = require_derive_axis_values_labels.deriveAxisValuesLabels;
35
37
  exports.deriveColumnOptions = require_utils.deriveColumnOptions;
38
+ exports.deriveColumnValueOptions = require_column_values.deriveColumnValueOptions;
39
+ exports.deriveLabelledColumnValueOptions = require_column_values.deriveLabelledColumnValueOptions;
36
40
  exports.deriveRecipeOptions = require_utils.deriveRecipeOptions;
37
41
  exports.describePeerLinks = require_peer_links.describePeerLinks;
38
42
  exports.findPeerLinks = require_peer_links.findPeerLinks;
@@ -13,4 +13,5 @@ import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, Column
13
13
  import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
14
14
  import { ColumnOption, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
15
15
  import { DatasetAxes, collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./peer_links.js";
16
- export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, ColumnOverriddenRecipe, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsProvider, ColumnsSource, ColumnsSourceShorthand, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DatasetAxes, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, type SpecQuery, SplitAxis, SplitByAxesOpts, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
16
+ import { ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "./column_values.js";
17
+ export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, ColumnOverriddenRecipe, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsProvider, ColumnsSource, ColumnsSourceShorthand, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DatasetAxes, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, type SpecQuery, SplitAxis, SplitByAxesOpts, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createColumnValueOptions, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
@@ -11,4 +11,5 @@ import { collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolData
11
11
  import { collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
12
12
  import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
13
13
  import { splitByAxes } from "./split_by_axes.js";
14
- export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, DataColumn, DataColumnImpl, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
14
+ import { createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "./column_values.js";
15
+ export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, DataColumn, DataColumnImpl, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createColumnValueOptions, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ const require_peer_links = require("./columns/peer_links.cjs");
38
38
  const require_utils = require("./columns/utils.cjs");
39
39
  const require_derive_axis_values_labels = require("./columns/derive_axis_values_labels.cjs");
40
40
  const require_split_by_axes = require("./columns/split_by_axes.cjs");
41
+ const require_column_values = require("./columns/column_values.cjs");
41
42
  require("./columns/index.cjs");
42
43
  const require_columns = require("./pframe_utils/columns.cjs");
43
44
  const require_PFrameForGraphs = require("./components/PFrameForGraphs.cjs");
@@ -65,6 +66,7 @@ require("./labels/index.cjs");
65
66
  const require_raw_globals = require("./raw_globals.cjs");
66
67
  const require_converter = require("./annotations/converter.cjs");
67
68
  require("./annotations/index.cjs");
69
+ const require_column_value_options = require("./pframe_utils/column_value_options.cjs");
68
70
  const require_index$11 = require("./pframe_utils/index.cjs");
69
71
  const require_env_value = require("./env_value.cjs");
70
72
  exports.AccessorColumnsProvider = require_providers.AccessorColumnsProvider;
@@ -137,6 +139,7 @@ exports.convertFilterUiToExpressionImpl = require_filterUiToExpressionImpl.conve
137
139
  exports.convertFilterUiToExpressions = require_filterUiToExpressionImpl.convertFilterUiToExpressions;
138
140
  exports.convertOrParsePColumnData = require_pcolumn_data.convertOrParsePColumnData;
139
141
  exports.createBlockStorage = require_block_storage.createBlockStorage;
142
+ exports.createColumnValueOptions = require_column_values.createColumnValueOptions;
140
143
  exports.createDatasetSelection = require_dataset_selection.createDatasetSelection;
141
144
  exports.createDefaultPTableParams = require_state_migration.createDefaultPTableParams;
142
145
  exports.createPFrameForGraphs = require_PFrameForGraphs.createPFrameForGraphs;
@@ -151,9 +154,11 @@ exports.createRowSelectionColumn = require_PlMultiSequenceAlignment.createRowSel
151
154
  exports.createServiceProxy = require_service_bridge.createServiceProxy;
152
155
  exports.deriveAxisValuesLabels = require_derive_axis_values_labels.deriveAxisValuesLabels;
153
156
  exports.deriveColumnOptions = require_utils.deriveColumnOptions;
157
+ exports.deriveColumnValueOptions = require_column_values.deriveColumnValueOptions;
154
158
  exports.deriveDataFromStorage = require_block_storage.deriveDataFromStorage;
155
159
  exports.deriveDistinctLabels = require_derive_distinct_labels.deriveDistinctLabels;
156
160
  exports.deriveDistinctTooltips = require_derive_distinct_tooltips.deriveDistinctTooltips;
161
+ exports.deriveLabelledColumnValueOptions = require_column_values.deriveLabelledColumnValueOptions;
157
162
  exports.deriveLabels = require_label.deriveLabels;
158
163
  exports.deriveRecipeOptions = require_utils.deriveRecipeOptions;
159
164
  exports.describePeerLinks = require_peer_links.describePeerLinks;
@@ -220,6 +225,7 @@ exports.peerLinkedLast = require_peer_links.peerLinkedLast;
220
225
  exports.pluginOutputKey = require_plugin_handle.pluginOutputKey;
221
226
  exports.pluginOutputPrefix = require_plugin_handle.pluginOutputPrefix;
222
227
  exports.queriesQualifications = require_utils.queriesQualifications;
228
+ exports.readColumnValueOptions = require_column_value_options.readColumnValueOptions;
223
229
  exports.readOutput = require_block_state_util.readOutput;
224
230
  exports.registerFacadeCallbacks = require_block_storage_facade.registerFacadeCallbacks;
225
231
  exports.splitByAxes = require_split_by_axes.splitByAxes;