@platforma-sdk/model 1.54.13 → 1.56.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.
Files changed (120) hide show
  1. package/dist/bconfig/normalization.cjs +8 -1
  2. package/dist/bconfig/normalization.cjs.map +1 -1
  3. package/dist/bconfig/normalization.d.ts.map +1 -1
  4. package/dist/bconfig/normalization.js +8 -1
  5. package/dist/bconfig/normalization.js.map +1 -1
  6. package/dist/block_api_v3.d.ts +2 -2
  7. package/dist/block_api_v3.d.ts.map +1 -1
  8. package/dist/block_migrations.cjs +246 -214
  9. package/dist/block_migrations.cjs.map +1 -1
  10. package/dist/block_migrations.d.ts +180 -158
  11. package/dist/block_migrations.d.ts.map +1 -1
  12. package/dist/block_migrations.js +247 -214
  13. package/dist/block_migrations.js.map +1 -1
  14. package/dist/block_model.cjs +85 -35
  15. package/dist/block_model.cjs.map +1 -1
  16. package/dist/block_model.d.ts +66 -38
  17. package/dist/block_model.d.ts.map +1 -1
  18. package/dist/block_model.js +86 -36
  19. package/dist/block_model.js.map +1 -1
  20. package/dist/{builder.cjs → block_model_legacy.cjs} +2 -2
  21. package/dist/block_model_legacy.cjs.map +1 -0
  22. package/dist/{builder.d.ts → block_model_legacy.d.ts} +1 -1
  23. package/dist/block_model_legacy.d.ts.map +1 -0
  24. package/dist/{builder.js → block_model_legacy.js} +2 -2
  25. package/dist/block_model_legacy.js.map +1 -0
  26. package/dist/block_state_patch.d.ts +11 -1
  27. package/dist/block_state_patch.d.ts.map +1 -1
  28. package/dist/block_storage.cjs +126 -109
  29. package/dist/block_storage.cjs.map +1 -1
  30. package/dist/block_storage.d.ts +109 -112
  31. package/dist/block_storage.d.ts.map +1 -1
  32. package/dist/block_storage.js +126 -101
  33. package/dist/block_storage.js.map +1 -1
  34. package/dist/block_storage_callbacks.cjs +227 -0
  35. package/dist/block_storage_callbacks.cjs.map +1 -0
  36. package/dist/block_storage_callbacks.d.ts +113 -0
  37. package/dist/block_storage_callbacks.d.ts.map +1 -0
  38. package/dist/block_storage_callbacks.js +218 -0
  39. package/dist/block_storage_callbacks.js.map +1 -0
  40. package/dist/block_storage_facade.cjs +104 -0
  41. package/dist/block_storage_facade.cjs.map +1 -0
  42. package/dist/block_storage_facade.d.ts +168 -0
  43. package/dist/block_storage_facade.d.ts.map +1 -0
  44. package/dist/block_storage_facade.js +99 -0
  45. package/dist/block_storage_facade.js.map +1 -0
  46. package/dist/index.cjs +13 -14
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.ts +8 -3
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +6 -4
  51. package/dist/index.js.map +1 -1
  52. package/dist/package.json.cjs +1 -1
  53. package/dist/package.json.js +1 -1
  54. package/dist/platforma.d.ts +11 -4
  55. package/dist/platforma.d.ts.map +1 -1
  56. package/dist/plugin_model.cjs +171 -0
  57. package/dist/plugin_model.cjs.map +1 -0
  58. package/dist/plugin_model.d.ts +162 -0
  59. package/dist/plugin_model.d.ts.map +1 -0
  60. package/dist/plugin_model.js +169 -0
  61. package/dist/plugin_model.js.map +1 -0
  62. package/dist/render/api.cjs +20 -21
  63. package/dist/render/api.cjs.map +1 -1
  64. package/dist/render/api.d.ts +8 -8
  65. package/dist/render/api.d.ts.map +1 -1
  66. package/dist/render/api.js +20 -21
  67. package/dist/render/api.js.map +1 -1
  68. package/dist/render/internal.cjs.map +1 -1
  69. package/dist/render/internal.d.ts +2 -1
  70. package/dist/render/internal.d.ts.map +1 -1
  71. package/dist/render/internal.js.map +1 -1
  72. package/dist/version.cjs +4 -0
  73. package/dist/version.cjs.map +1 -1
  74. package/dist/version.d.ts +4 -0
  75. package/dist/version.d.ts.map +1 -1
  76. package/dist/version.js +4 -1
  77. package/dist/version.js.map +1 -1
  78. package/package.json +5 -5
  79. package/src/bconfig/normalization.ts +8 -1
  80. package/src/block_api_v3.ts +2 -2
  81. package/src/block_migrations.test.ts +141 -171
  82. package/src/block_migrations.ts +300 -285
  83. package/src/block_model.ts +205 -95
  84. package/src/{builder.ts → block_model_legacy.ts} +1 -1
  85. package/src/block_state_patch.ts +13 -1
  86. package/src/block_storage.test.ts +283 -95
  87. package/src/block_storage.ts +199 -188
  88. package/src/block_storage_callbacks.ts +326 -0
  89. package/src/block_storage_facade.ts +199 -0
  90. package/src/index.ts +7 -3
  91. package/src/platforma.ts +26 -7
  92. package/src/plugin_model.test.ts +168 -0
  93. package/src/plugin_model.ts +242 -0
  94. package/src/render/api.ts +26 -24
  95. package/src/render/internal.ts +3 -1
  96. package/src/typing.test.ts +1 -1
  97. package/src/version.ts +8 -0
  98. package/dist/block_storage_vm.cjs +0 -262
  99. package/dist/block_storage_vm.cjs.map +0 -1
  100. package/dist/block_storage_vm.d.ts +0 -59
  101. package/dist/block_storage_vm.d.ts.map +0 -1
  102. package/dist/block_storage_vm.js +0 -258
  103. package/dist/block_storage_vm.js.map +0 -1
  104. package/dist/branding.d.ts +0 -7
  105. package/dist/branding.d.ts.map +0 -1
  106. package/dist/builder.cjs.map +0 -1
  107. package/dist/builder.d.ts.map +0 -1
  108. package/dist/builder.js.map +0 -1
  109. package/dist/sdk_info.cjs +0 -10
  110. package/dist/sdk_info.cjs.map +0 -1
  111. package/dist/sdk_info.d.ts +0 -5
  112. package/dist/sdk_info.d.ts.map +0 -1
  113. package/dist/sdk_info.js +0 -8
  114. package/dist/sdk_info.js.map +0 -1
  115. package/dist/unionize.d.ts +0 -12
  116. package/dist/unionize.d.ts.map +0 -1
  117. package/src/block_storage_vm.ts +0 -346
  118. package/src/branding.ts +0 -4
  119. package/src/sdk_info.ts +0 -9
  120. package/src/unionize.ts +0 -12
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block_storage_facade.js","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} 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]: (currentStorageJson: StringifiedJson | undefined) =>\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/** 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"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CG;AAOH;AACA;AACA;AAEA;;;AAGG;AACI,MAAM,4BAA4B,GAAG;AAE5C;AACA;AACA;AAEA;;;;;;;;AAQG;AACI,MAAM,2BAA2B,GAAG;AACzC,IAAA,kBAAkB,EAAE,0BAA0B;AAC9C,IAAA,gBAAgB,EAAE,wBAAwB;AAC1C,IAAA,cAAc,EAAE,sBAAsB;AACtC,IAAA,UAAU,EAAE,kBAAkB;AAC9B,IAAA,gBAAgB,EAAE,wBAAwB;AAC1C,IAAA,cAAc,EAAE,sBAAsB;;AAGxC;;;AAGG;AACH,SAAS,mBAAmB,CAC1B,SAAY,EAAA;AAEZ,IAAA,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CACtC;AAChD;AAEA;;;AAGG;MACU,yBAAyB,GAAG,mBAAmB,CAAC,2BAA2B;AA2FxF;AACM,SAAU,uBAAuB,CAAC,SAA6B,EAAA;IACnE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,EAAE;QAC5D,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAA4B,CAAC;IACrE;AACF;;;;"}
package/dist/index.cjs CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  var block_state_util = require('./block_state_util.cjs');
4
4
  var block_storage = require('./block_storage.cjs');
5
- var builder = require('./builder.cjs');
5
+ var block_storage_facade = require('./block_storage_facade.cjs');
6
+ var block_model_legacy = require('./block_model_legacy.cjs');
6
7
  var block_model = require('./block_model.cjs');
7
8
  var block_migrations = require('./block_migrations.cjs');
9
+ var plugin_model = require('./plugin_model.cjs');
8
10
  var normalization = require('./bconfig/normalization.cjs');
9
11
  var types = require('./bconfig/types.cjs');
10
12
  var PFrameForGraphs = require('./components/PFrameForGraphs.cjs');
@@ -23,7 +25,7 @@ var label = require('./render/util/label.cjs');
23
25
  var axis_filtering = require('./render/util/axis_filtering.cjs');
24
26
  var column_collection = require('./render/util/column_collection.cjs');
25
27
  var future = require('./render/future.cjs');
26
- var sdk_info = require('./sdk_info.cjs');
28
+ var version = require('./version.cjs');
27
29
  var raw_globals = require('./raw_globals.cjs');
28
30
  var filterToQuery = require('./filters/converters/filterToQuery.cjs');
29
31
  var filterUiToExpressionImpl = require('./filters/converters/filterUiToExpressionImpl.cjs');
@@ -45,30 +47,26 @@ exports.BLOCK_STORAGE_KEY = block_storage.BLOCK_STORAGE_KEY;
45
47
  exports.BLOCK_STORAGE_SCHEMA_VERSION = block_storage.BLOCK_STORAGE_SCHEMA_VERSION;
46
48
  exports.DATA_MODEL_DEFAULT_VERSION = block_storage.DATA_MODEL_DEFAULT_VERSION;
47
49
  exports.createBlockStorage = block_storage.createBlockStorage;
48
- exports.defaultBlockStorageHandlers = block_storage.defaultBlockStorageHandlers;
49
50
  exports.deriveDataFromStorage = block_storage.deriveDataFromStorage;
50
- exports.getFromStorage = block_storage.getFromStorage;
51
51
  exports.getPluginData = block_storage.getPluginData;
52
- exports.getPluginNames = block_storage.getPluginNames;
53
52
  exports.getStorageData = block_storage.getStorageData;
54
- exports.getStorageDataVersion = block_storage.getStorageDataVersion;
55
53
  exports.isBlockStorage = block_storage.isBlockStorage;
56
- exports.mergeBlockStorageHandlers = block_storage.mergeBlockStorageHandlers;
54
+ exports.migrateBlockStorage = block_storage.migrateBlockStorage;
57
55
  exports.normalizeBlockStorage = block_storage.normalizeBlockStorage;
58
- exports.removePluginData = block_storage.removePluginData;
59
- exports.setPluginData = block_storage.setPluginData;
60
- exports.updateStorage = block_storage.updateStorage;
61
56
  exports.updateStorageData = block_storage.updateStorageData;
62
- exports.updateStorageDataVersion = block_storage.updateStorageDataVersion;
63
- exports.BlockModel = builder.BlockModel;
57
+ exports.BLOCK_STORAGE_FACADE_VERSION = block_storage_facade.BLOCK_STORAGE_FACADE_VERSION;
58
+ exports.BlockStorageFacadeCallbacks = block_storage_facade.BlockStorageFacadeCallbacks;
59
+ exports.BlockStorageFacadeHandles = block_storage_facade.BlockStorageFacadeHandles;
60
+ exports.registerFacadeCallbacks = block_storage_facade.registerFacadeCallbacks;
61
+ exports.BlockModel = block_model_legacy.BlockModel;
64
62
  exports.BlockModelV3 = block_model.BlockModelV3;
65
63
  exports.DataModel = block_migrations.DataModel;
66
64
  exports.DataModelBuilder = block_migrations.DataModelBuilder;
67
65
  exports.DataUnrecoverableError = block_migrations.DataUnrecoverableError;
68
66
  exports.defaultRecover = block_migrations.defaultRecover;
69
- exports.defineDataVersions = block_migrations.defineDataVersions;
70
67
  exports.isDataUnrecoverableError = block_migrations.isDataUnrecoverableError;
71
68
  exports.makeDataVersioned = block_migrations.makeDataVersioned;
69
+ exports.PluginModel = plugin_model.PluginModel;
72
70
  exports.downgradeCfgOrLambda = normalization.downgradeCfgOrLambda;
73
71
  exports.extractConfig = normalization.extractConfig;
74
72
  exports.isConfigLambda = types.isConfigLambda;
@@ -151,7 +149,8 @@ exports.deriveLabels = label.deriveLabels;
151
149
  exports.filterDataInfoEntries = axis_filtering.filterDataInfoEntries;
152
150
  exports.PColumnCollection = column_collection.PColumnCollection;
153
151
  exports.FutureRef = future.FutureRef;
154
- exports.CurrentSdkInfo = sdk_info.CurrentSdkInfo;
152
+ exports.CurrentSdkInfo = version.CurrentSdkInfo;
153
+ exports.PlatformaSDKVersion = version.PlatformaSDKVersion;
155
154
  exports.getPlatformaApiVersion = raw_globals.getPlatformaApiVersion;
156
155
  exports.getRawPlatformaInstance = raw_globals.getRawPlatformaInstance;
157
156
  exports.filterSpecToSpecQueryExpr = filterToQuery.filterSpecToSpecQueryExpr;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  export * from "./block_state_patch";
2
2
  export * from "./block_state_util";
3
3
  export * from "./block_storage";
4
- export * from "./builder";
4
+ export * from "./block_storage_facade";
5
+ export * from "./block_model_legacy";
5
6
  export { BlockModelV3 } from "./block_model";
6
- export { DataModel, DataModelBuilder, DataUnrecoverableError, isDataUnrecoverableError, defineDataVersions, defaultRecover, makeDataVersioned, } from "./block_migrations";
7
+ export type { PluginInstance, ParamsInput } from "./block_model";
8
+ export { DataModel, DataModelBuilder, DataUnrecoverableError, isDataUnrecoverableError, defaultRecover, makeDataVersioned, } from "./block_migrations";
9
+ export type { LegacyV1State } from "./block_migrations";
10
+ export { PluginModel } from "./plugin_model";
11
+ export type { PluginRenderCtx } from "./plugin_model";
7
12
  export * from "./bconfig";
8
13
  export * from "./components";
9
14
  export * from "./config";
@@ -11,7 +16,7 @@ export * from "./pframe";
11
16
  export * from "./platforma";
12
17
  export * from "./ref_util";
13
18
  export * from "./render";
14
- export * from "./sdk_info";
19
+ export * from "./version";
15
20
  export * from "./raw_globals";
16
21
  export * from "./block_api_v1";
17
22
  export * from "./block_api_v2";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB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AAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAE9C,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export { OutputError, readOutput, wrapOutputs } from './block_state_util.js';
2
- export { BLOCK_STORAGE_KEY, BLOCK_STORAGE_SCHEMA_VERSION, DATA_MODEL_DEFAULT_VERSION, createBlockStorage, defaultBlockStorageHandlers, deriveDataFromStorage, getFromStorage, getPluginData, getPluginNames, getStorageData, getStorageDataVersion, isBlockStorage, mergeBlockStorageHandlers, normalizeBlockStorage, removePluginData, setPluginData, updateStorage, updateStorageData, updateStorageDataVersion } from './block_storage.js';
3
- export { BlockModel } from './builder.js';
2
+ export { BLOCK_STORAGE_KEY, BLOCK_STORAGE_SCHEMA_VERSION, DATA_MODEL_DEFAULT_VERSION, createBlockStorage, deriveDataFromStorage, getPluginData, getStorageData, isBlockStorage, migrateBlockStorage, normalizeBlockStorage, updateStorageData } from './block_storage.js';
3
+ export { BLOCK_STORAGE_FACADE_VERSION, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, registerFacadeCallbacks } from './block_storage_facade.js';
4
+ export { BlockModel } from './block_model_legacy.js';
4
5
  export { BlockModelV3 } from './block_model.js';
5
- export { DataModel, DataModelBuilder, DataUnrecoverableError, defaultRecover, defineDataVersions, isDataUnrecoverableError, makeDataVersioned } from './block_migrations.js';
6
+ export { DataModel, DataModelBuilder, DataUnrecoverableError, defaultRecover, isDataUnrecoverableError, makeDataVersioned } from './block_migrations.js';
7
+ export { PluginModel } from './plugin_model.js';
6
8
  export { downgradeCfgOrLambda, extractConfig } from './bconfig/normalization.js';
7
9
  export { isConfigLambda } from './bconfig/types.js';
8
10
  export { createPFrameForGraphs, enrichCompatible, getAvailableWithLinkersAxes, isHiddenFromGraphColumn, isHiddenFromUIColumn } from './components/PFrameForGraphs.js';
@@ -21,7 +23,7 @@ export { Trace, TraceEntry, deriveLabels } from './render/util/label.js';
21
23
  export { filterDataInfoEntries } from './render/util/axis_filtering.js';
22
24
  export { PColumnCollection } from './render/util/column_collection.js';
23
25
  export { FutureRef } from './render/future.js';
24
- export { CurrentSdkInfo } from './sdk_info.js';
26
+ export { CurrentSdkInfo, PlatformaSDKVersion } from './version.js';
25
27
  export { getPlatformaApiVersion, getRawPlatformaInstance } from './raw_globals.js';
26
28
  export { filterSpecToSpecQueryExpr } from './filters/converters/filterToQuery.js';
27
29
  export { convertFilterUiToExpressionImpl, convertFilterUiToExpressions } from './filters/converters/filterUiToExpressionImpl.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "1.54.13";
3
+ var version = "1.56.0";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- var version = "1.54.13";
1
+ var version = "1.56.0";
2
2
 
3
3
  export { version };
4
4
  //# sourceMappingURL=package.json.js.map
@@ -2,8 +2,9 @@ import type { BlockApiV1 } from "./block_api_v1";
2
2
  import type { BlockApiV2 } from "./block_api_v2";
3
3
  import type { BlockApiV3 } from "./block_api_v3";
4
4
  import type { BlockOutputsBase, BlockStateV3, DriverKit, OutputWithStatus } from "@milaboratories/pl-model-common";
5
- import type { SdkInfo } from "./sdk_info";
5
+ import type { SdkInfo } from "./version";
6
6
  import type { BlockStatePatch } from "./block_state_patch";
7
+ import type { PluginInstance } from "./block_model";
7
8
  /** Defines all methods to interact with the platform environment from within a block UI. @deprecated */
8
9
  export interface PlatformaV1<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, UiState = unknown, Href extends `/${string}` = `/${string}`> extends BlockApiV1<Args, Outputs, UiState, Href>, DriverKit {
9
10
  /** Information about SDK version current platforma environment was compiled with. */
@@ -16,12 +17,14 @@ export interface PlatformaV2<Args = unknown, Outputs extends Record<string, Outp
16
17
  readonly sdkInfo: SdkInfo;
17
18
  readonly apiVersion: 2;
18
19
  }
19
- export interface PlatformaV3<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, Data = unknown, Href extends `/${string}` = `/${string}`> extends BlockApiV3<Args, Outputs, Data, Href>, DriverKit {
20
+ export interface PlatformaV3<Data = unknown, Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, Href extends `/${string}` = `/${string}`, Plugins extends Record<string, unknown> = Record<string, unknown>> extends BlockApiV3<Data, Args, Outputs, Href>, DriverKit {
20
21
  /** Information about SDK version current platforma environment was compiled with. */
21
22
  readonly sdkInfo: SdkInfo;
22
23
  readonly apiVersion: 3;
24
+ /** @internal Type brand for plugin type inference. Not used at runtime. */
25
+ readonly __pluginsBrand?: Plugins;
23
26
  }
24
- export type Platforma<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, UiState = unknown, Href extends `/${string}` = `/${string}`> = PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href> | PlatformaV3<Args, Outputs, UiState, Href>;
27
+ export type Platforma<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, UiStateOrData = unknown, Href extends `/${string}` = `/${string}`> = PlatformaV1<Args, Outputs, UiStateOrData, Href> | PlatformaV2<Args, Outputs, UiStateOrData, Href> | PlatformaV3<UiStateOrData, Args, Outputs, Href>;
25
28
  export type PlatformaExtended<Pl extends Platforma = Platforma> = Pl & {
26
29
  blockModelInfo: BlockModelInfo;
27
30
  };
@@ -39,6 +42,10 @@ export type InferHrefType<Pl extends Platforma> = Pl extends Platforma<unknown,
39
42
  export type PlatformaFactory = (config: {
40
43
  sdkVersion: string;
41
44
  }) => Platforma;
42
- export type InferBlockState<Pl extends Platforma> = BlockStateV3<InferOutputsType<Pl>, InferHrefType<Pl>>;
45
+ export type InferBlockState<Pl extends Platforma> = BlockStateV3<InferDataType<Pl>, InferOutputsType<Pl>, InferHrefType<Pl>>;
43
46
  export type InferBlockStatePatch<Pl extends Platforma> = BlockStatePatch<InferArgsType<Pl>, InferOutputsType<Pl>, InferUiState<Pl>, InferHrefType<Pl>>;
47
+ /** Extract plugin IDs as a string literal union from a Platforma type. */
48
+ export type InferPluginNames<Pl> = Pl extends PlatformaV3<any, any, any, any, infer P> ? string & keyof P : never;
49
+ /** Extract the Data type for a specific plugin by its ID. */
50
+ export type InferPluginData<Pl, PluginId extends string> = Pl extends PlatformaV3<any, any, any, any, infer P> ? PluginId extends keyof P ? P[PluginId] extends PluginInstance<infer D, any, any> ? D : never : never : never;
44
51
  //# sourceMappingURL=platforma.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platforma.d.ts","sourceRoot":"","sources":["../src/platforma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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
3
+ /**
4
+ * PluginModel - Builder for creating plugin types with data model and outputs.
5
+ *
6
+ * Plugins are UI components with their own model logic and persistent state.
7
+ * Block developers register plugin instances via BlockModelV3.plugin() method.
8
+ *
9
+ * @module plugin_model
10
+ */
11
+ /** Symbol for internal builder creation method */
12
+ const FROM_BUILDER = Symbol("fromBuilder");
13
+ // =============================================================================
14
+ // Plugin Type
15
+ // =============================================================================
16
+ /**
17
+ * Configured plugin instance returned by PluginModelFactory.create().
18
+ * Contains the plugin's name, data model, and output definitions.
19
+ */
20
+ class PluginModel {
21
+ /** Globally unique plugin name */
22
+ name;
23
+ /** Data model instance for this plugin */
24
+ dataModel;
25
+ /** Output definitions - functions that compute outputs from plugin context */
26
+ outputs;
27
+ constructor(input) {
28
+ this.name = input.name;
29
+ this.dataModel = input.dataModel;
30
+ this.outputs = input.outputs;
31
+ }
32
+ /**
33
+ * Internal method for creating PluginModel from factory.
34
+ * Uses Symbol key to prevent external access.
35
+ * @internal
36
+ */
37
+ static [FROM_BUILDER](input) {
38
+ return new this(input);
39
+ }
40
+ /**
41
+ * Creates a new PluginModelBuilder for building plugin definitions.
42
+ *
43
+ * @param options.name - Globally unique plugin name
44
+ * @param options.data - Factory function that creates the data model from config
45
+ * @returns PluginModelBuilder for chaining output definitions
46
+ *
47
+ * @example
48
+ * const dataModelChain = new DataModelBuilder().from<MyData>(DATA_MODEL_DEFAULT_VERSION);
49
+ *
50
+ * const myPlugin = PluginModel.define<MyData, MyParams, MyConfig>({
51
+ * name: 'myPlugin' as PluginName,
52
+ * data: (cfg) => dataModelChain.init(() => ({ value: cfg.defaultValue })),
53
+ * })
54
+ * .output('computed', (ctx) => ctx.data.value * ctx.params.multiplier)
55
+ * .build();
56
+ */
57
+ static define(options) {
58
+ return PluginModelBuilder[FROM_BUILDER](options);
59
+ }
60
+ }
61
+ /**
62
+ * Plugin factory returned by PluginModelBuilder.build().
63
+ * Call create() with config to get a configured PluginModel instance.
64
+ */
65
+ class PluginModelFactory {
66
+ name;
67
+ data;
68
+ outputs;
69
+ constructor(input) {
70
+ this.name = input.name;
71
+ this.data = input.data;
72
+ this.outputs = input.outputs;
73
+ }
74
+ /** Create a configured PluginModel instance */
75
+ create(config) {
76
+ return PluginModel[FROM_BUILDER]({
77
+ name: this.name,
78
+ dataModel: this.data(config),
79
+ outputs: this.outputs,
80
+ });
81
+ }
82
+ }
83
+ // =============================================================================
84
+ // Plugin Model Builder
85
+ // =============================================================================
86
+ /**
87
+ * Builder for creating PluginType with type-safe output definitions.
88
+ *
89
+ * Use `PluginModel.define()` to create a builder instance.
90
+ *
91
+ * @typeParam Data - Plugin's persistent data type
92
+ * @typeParam Params - Params derived from block's RenderCtx (optional)
93
+ * @typeParam Config - Static configuration passed to plugin factory (optional)
94
+ * @typeParam Outputs - Accumulated output types
95
+ *
96
+ * @example
97
+ * const dataModelChain = new DataModelBuilder().from<TableData>(DATA_MODEL_DEFAULT_VERSION);
98
+ *
99
+ * const dataTable = PluginModel.define<TableData, TableParams, TableConfig>({
100
+ * name: 'dataTable' as PluginName,
101
+ * data: (cfg) => {
102
+ * return dataModelChain.init(() => ({ state: createInitialState(cfg.ops) }));
103
+ * },
104
+ * })
105
+ * .output('model', (ctx) => createTableModel(ctx))
106
+ * .build();
107
+ */
108
+ class PluginModelBuilder {
109
+ name;
110
+ data;
111
+ outputs;
112
+ constructor(input) {
113
+ this.name = input.name;
114
+ this.data = input.data;
115
+ this.outputs =
116
+ input.outputs ??
117
+ {};
118
+ }
119
+ /**
120
+ * Internal method for creating PluginModelBuilder.
121
+ * Uses Symbol key to prevent external access.
122
+ * @internal
123
+ */
124
+ static [FROM_BUILDER](input) {
125
+ return new this(input);
126
+ }
127
+ /**
128
+ * Adds an output to the plugin.
129
+ *
130
+ * @param key - Output name
131
+ * @param fn - Function that computes the output value from plugin context
132
+ * @returns PluginModel with the new output added
133
+ *
134
+ * @example
135
+ * .output('model', (ctx) => createModel(ctx.params.columns, ctx.data.state))
136
+ * .output('isReady', (ctx) => ctx.params.columns !== undefined)
137
+ */
138
+ output(key, fn) {
139
+ return new PluginModelBuilder({
140
+ name: this.name,
141
+ data: this.data,
142
+ outputs: {
143
+ ...this.outputs,
144
+ [key]: fn,
145
+ },
146
+ });
147
+ }
148
+ /**
149
+ * Finalizes the plugin definition and returns a ConfigurablePluginModel.
150
+ *
151
+ * @returns Callable plugin factory that accepts config and returns PluginModel
152
+ *
153
+ * @example
154
+ * const myPlugin = new PluginModelBuilder('myPlugin', () => dataModel)
155
+ * .output('value', (ctx) => ctx.data.value)
156
+ * .build();
157
+ *
158
+ * // Later, call create() with config to get a configured instance:
159
+ * const configured = myPlugin.create({ defaultValue: 'test' });
160
+ */
161
+ build() {
162
+ return new PluginModelFactory({
163
+ name: this.name,
164
+ data: this.data,
165
+ outputs: this.outputs,
166
+ });
167
+ }
168
+ }
169
+
170
+ exports.PluginModel = PluginModel;
171
+ //# sourceMappingURL=plugin_model.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin_model.cjs","sources":["../src/plugin_model.ts"],"sourcesContent":["/**\n * PluginModel - Builder for creating plugin types with data model and outputs.\n *\n * Plugins are UI components with their own model logic and persistent state.\n * Block developers register plugin instances via BlockModelV3.plugin() method.\n *\n * @module plugin_model\n */\n\nimport type { DataModel } from \"./block_migrations\";\nimport type { PluginName } from \"./block_storage\";\nimport type { ResultPool } from \"./render\";\n\n/** Symbol for internal builder creation method */\nconst FROM_BUILDER = Symbol(\"fromBuilder\");\n\n// =============================================================================\n// Plugin Render Context\n// =============================================================================\n\n/**\n * Context passed to plugin output functions.\n * Provides access to plugin's persistent data, params derived from block context,\n * and the result pool for accessing workflow outputs.\n */\nexport interface PluginRenderCtx<Data, Params = undefined> {\n /** Plugin's persistent data */\n readonly data: Data;\n /** Params derived from block's RenderCtx */\n readonly params: Params;\n /** Result pool for accessing workflow outputs */\n readonly resultPool: ResultPool;\n}\n\n// =============================================================================\n// Plugin Type\n// =============================================================================\n\n/**\n * Configured plugin instance returned by PluginModelFactory.create().\n * Contains the plugin's name, data model, and output definitions.\n */\nexport class PluginModel<Data = unknown, Params = undefined, Outputs = {}> {\n /** Globally unique plugin name */\n readonly name: PluginName;\n /** Data model instance for this plugin */\n readonly dataModel: DataModel<Data>;\n /** Output definitions - functions that compute outputs from plugin context */\n readonly outputs: { [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K] };\n\n private constructor(input: {\n name: PluginName;\n dataModel: DataModel<Data>;\n outputs: { [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K] };\n }) {\n this.name = input.name;\n this.dataModel = input.dataModel;\n this.outputs = input.outputs;\n }\n\n /**\n * Internal method for creating PluginModel from factory.\n * Uses Symbol key to prevent external access.\n * @internal\n */\n static [FROM_BUILDER]<D, P, O>(input: {\n name: PluginName;\n dataModel: DataModel<D>;\n outputs: { [K in keyof O]: (ctx: PluginRenderCtx<D, P>) => O[K] };\n }): PluginModel<D, P, O> {\n return new this<D, P, O>(input);\n }\n\n /**\n * Creates a new PluginModelBuilder for building plugin definitions.\n *\n * @param options.name - Globally unique plugin name\n * @param options.data - Factory function that creates the data model from config\n * @returns PluginModelBuilder for chaining output definitions\n *\n * @example\n * const dataModelChain = new DataModelBuilder().from<MyData>(DATA_MODEL_DEFAULT_VERSION);\n *\n * const myPlugin = PluginModel.define<MyData, MyParams, MyConfig>({\n * name: 'myPlugin' as PluginName,\n * data: (cfg) => dataModelChain.init(() => ({ value: cfg.defaultValue })),\n * })\n * .output('computed', (ctx) => ctx.data.value * ctx.params.multiplier)\n * .build();\n */\n static define<Data, Params = undefined, Config = undefined>(options: {\n name: PluginName;\n data: (config?: Config) => DataModel<Data>;\n }): PluginModelBuilder<Data, Params, Config> {\n return PluginModelBuilder[FROM_BUILDER]<Data, Params, Config>(options);\n }\n}\n\n/**\n * Plugin factory returned by PluginModelBuilder.build().\n * Call create() with config to get a configured PluginModel instance.\n */\nclass PluginModelFactory<Data, Params, Config, Outputs> {\n private readonly name: PluginName;\n private readonly data: (config?: Config) => DataModel<Data>;\n private readonly outputs: {\n [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K];\n };\n\n constructor(input: {\n name: PluginName;\n data: (config?: Config) => DataModel<Data>;\n outputs: { [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K] };\n }) {\n this.name = input.name;\n this.data = input.data;\n this.outputs = input.outputs;\n }\n\n /** Create a configured PluginModel instance */\n create(config?: Config): PluginModel<Data, Params, Outputs> {\n return PluginModel[FROM_BUILDER]<Data, Params, Outputs>({\n name: this.name,\n dataModel: this.data(config),\n outputs: this.outputs,\n });\n }\n}\n\n// =============================================================================\n// Plugin Model Builder\n// =============================================================================\n\n/**\n * Builder for creating PluginType with type-safe output definitions.\n *\n * Use `PluginModel.define()` to create a builder instance.\n *\n * @typeParam Data - Plugin's persistent data type\n * @typeParam Params - Params derived from block's RenderCtx (optional)\n * @typeParam Config - Static configuration passed to plugin factory (optional)\n * @typeParam Outputs - Accumulated output types\n *\n * @example\n * const dataModelChain = new DataModelBuilder().from<TableData>(DATA_MODEL_DEFAULT_VERSION);\n *\n * const dataTable = PluginModel.define<TableData, TableParams, TableConfig>({\n * name: 'dataTable' as PluginName,\n * data: (cfg) => {\n * return dataModelChain.init(() => ({ state: createInitialState(cfg.ops) }));\n * },\n * })\n * .output('model', (ctx) => createTableModel(ctx))\n * .build();\n */\nclass PluginModelBuilder<\n Data,\n Params = undefined,\n Config = undefined,\n Outputs extends Record<string, unknown> = {},\n> {\n private readonly name: PluginName;\n private readonly data: (config?: Config) => DataModel<Data>;\n private readonly outputs: {\n [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K];\n };\n\n private constructor(input: {\n name: PluginName;\n data: (config?: Config) => DataModel<Data>;\n outputs?: { [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K] };\n }) {\n this.name = input.name;\n this.data = input.data;\n this.outputs =\n input.outputs ??\n ({} as { [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K] });\n }\n\n /**\n * Internal method for creating PluginModelBuilder.\n * Uses Symbol key to prevent external access.\n * @internal\n */\n static [FROM_BUILDER]<D, P, C, O extends Record<string, unknown> = {}>(input: {\n name: PluginName;\n data: (config?: C) => DataModel<D>;\n outputs?: { [K in keyof O]: (ctx: PluginRenderCtx<D, P>) => O[K] };\n }): PluginModelBuilder<D, P, C, O> {\n return new this<D, P, C, O>(input);\n }\n\n /**\n * Adds an output to the plugin.\n *\n * @param key - Output name\n * @param fn - Function that computes the output value from plugin context\n * @returns PluginModel with the new output added\n *\n * @example\n * .output('model', (ctx) => createModel(ctx.params.columns, ctx.data.state))\n * .output('isReady', (ctx) => ctx.params.columns !== undefined)\n */\n output<const Key extends string, T>(\n key: Key,\n fn: (ctx: PluginRenderCtx<Data, Params>) => T,\n ): PluginModelBuilder<Data, Params, Config, Outputs & { [K in Key]: T }> {\n return new PluginModelBuilder<Data, Params, Config, Outputs & { [K in Key]: T }>({\n name: this.name,\n data: this.data,\n outputs: {\n ...this.outputs,\n [key]: fn,\n } as {\n [K in keyof (Outputs & { [P in Key]: T })]: (\n ctx: PluginRenderCtx<Data, Params>,\n ) => (Outputs & { [P in Key]: T })[K];\n },\n });\n }\n\n /**\n * Finalizes the plugin definition and returns a ConfigurablePluginModel.\n *\n * @returns Callable plugin factory that accepts config and returns PluginModel\n *\n * @example\n * const myPlugin = new PluginModelBuilder('myPlugin', () => dataModel)\n * .output('value', (ctx) => ctx.data.value)\n * .build();\n *\n * // Later, call create() with config to get a configured instance:\n * const configured = myPlugin.create({ defaultValue: 'test' });\n */\n build(): PluginModelFactory<Data, Params, Config, Outputs> {\n return new PluginModelFactory<Data, Params, Config, Outputs>({\n name: this.name,\n data: this.data,\n outputs: this.outputs,\n });\n }\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAMH;AACA,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC;AA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,IAAA,OAAO;AAIxB,IAAA,WAAA,CAAoB,KAInB,EAAA;AACC,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;AACtB,QAAA,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;AACtB,QAAA,IAAI,CAAC,OAAO;AACV,YAAA,KAAK,CAAC,OAAO;AACZ,gBAAA,EAAmF;IACxF;AAEA;;;;AAIG;AACH,IAAA,QAAQ,YAAY,CAAC,CAAkD,KAItE,EAAA;AACC,QAAA,OAAO,IAAI,IAAI,CAAa,KAAK,CAAC;IACpC;AAEA;;;;;;;;;;AAUG;IACH,MAAM,CACJ,GAAQ,EACR,EAA6C,EAAA;QAE7C,OAAO,IAAI,kBAAkB,CAAoD;YAC/E,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;AACf,YAAA,OAAO,EAAE;gBACP,GAAG,IAAI,CAAC,OAAO;gBACf,CAAC,GAAG,GAAG,EAAE;AAKV,aAAA;AACF,SAAA,CAAC;IACJ;AAEA;;;;;;;;;;;;AAYG;IACH,KAAK,GAAA;QACH,OAAO,IAAI,kBAAkB,CAAgC;YAC3D,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;AACtB,SAAA,CAAC;IACJ;AACD;;;;"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * PluginModel - Builder for creating plugin types with data model and outputs.
3
+ *
4
+ * Plugins are UI components with their own model logic and persistent state.
5
+ * Block developers register plugin instances via BlockModelV3.plugin() method.
6
+ *
7
+ * @module plugin_model
8
+ */
9
+ import type { DataModel } from "./block_migrations";
10
+ import type { PluginName } from "./block_storage";
11
+ import type { ResultPool } from "./render";
12
+ /** Symbol for internal builder creation method */
13
+ declare const FROM_BUILDER: unique symbol;
14
+ /**
15
+ * Context passed to plugin output functions.
16
+ * Provides access to plugin's persistent data, params derived from block context,
17
+ * and the result pool for accessing workflow outputs.
18
+ */
19
+ export interface PluginRenderCtx<Data, Params = undefined> {
20
+ /** Plugin's persistent data */
21
+ readonly data: Data;
22
+ /** Params derived from block's RenderCtx */
23
+ readonly params: Params;
24
+ /** Result pool for accessing workflow outputs */
25
+ readonly resultPool: ResultPool;
26
+ }
27
+ /**
28
+ * Configured plugin instance returned by PluginModelFactory.create().
29
+ * Contains the plugin's name, data model, and output definitions.
30
+ */
31
+ export declare class PluginModel<Data = unknown, Params = undefined, Outputs = {}> {
32
+ /** Globally unique plugin name */
33
+ readonly name: PluginName;
34
+ /** Data model instance for this plugin */
35
+ readonly dataModel: DataModel<Data>;
36
+ /** Output definitions - functions that compute outputs from plugin context */
37
+ readonly outputs: {
38
+ [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K];
39
+ };
40
+ private constructor();
41
+ /**
42
+ * Internal method for creating PluginModel from factory.
43
+ * Uses Symbol key to prevent external access.
44
+ * @internal
45
+ */
46
+ static [FROM_BUILDER]<D, P, O>(input: {
47
+ name: PluginName;
48
+ dataModel: DataModel<D>;
49
+ outputs: {
50
+ [K in keyof O]: (ctx: PluginRenderCtx<D, P>) => O[K];
51
+ };
52
+ }): PluginModel<D, P, O>;
53
+ /**
54
+ * Creates a new PluginModelBuilder for building plugin definitions.
55
+ *
56
+ * @param options.name - Globally unique plugin name
57
+ * @param options.data - Factory function that creates the data model from config
58
+ * @returns PluginModelBuilder for chaining output definitions
59
+ *
60
+ * @example
61
+ * const dataModelChain = new DataModelBuilder().from<MyData>(DATA_MODEL_DEFAULT_VERSION);
62
+ *
63
+ * const myPlugin = PluginModel.define<MyData, MyParams, MyConfig>({
64
+ * name: 'myPlugin' as PluginName,
65
+ * data: (cfg) => dataModelChain.init(() => ({ value: cfg.defaultValue })),
66
+ * })
67
+ * .output('computed', (ctx) => ctx.data.value * ctx.params.multiplier)
68
+ * .build();
69
+ */
70
+ static define<Data, Params = undefined, Config = undefined>(options: {
71
+ name: PluginName;
72
+ data: (config?: Config) => DataModel<Data>;
73
+ }): PluginModelBuilder<Data, Params, Config>;
74
+ }
75
+ /**
76
+ * Plugin factory returned by PluginModelBuilder.build().
77
+ * Call create() with config to get a configured PluginModel instance.
78
+ */
79
+ declare class PluginModelFactory<Data, Params, Config, Outputs> {
80
+ private readonly name;
81
+ private readonly data;
82
+ private readonly outputs;
83
+ constructor(input: {
84
+ name: PluginName;
85
+ data: (config?: Config) => DataModel<Data>;
86
+ outputs: {
87
+ [K in keyof Outputs]: (ctx: PluginRenderCtx<Data, Params>) => Outputs[K];
88
+ };
89
+ });
90
+ /** Create a configured PluginModel instance */
91
+ create(config?: Config): PluginModel<Data, Params, Outputs>;
92
+ }
93
+ /**
94
+ * Builder for creating PluginType with type-safe output definitions.
95
+ *
96
+ * Use `PluginModel.define()` to create a builder instance.
97
+ *
98
+ * @typeParam Data - Plugin's persistent data type
99
+ * @typeParam Params - Params derived from block's RenderCtx (optional)
100
+ * @typeParam Config - Static configuration passed to plugin factory (optional)
101
+ * @typeParam Outputs - Accumulated output types
102
+ *
103
+ * @example
104
+ * const dataModelChain = new DataModelBuilder().from<TableData>(DATA_MODEL_DEFAULT_VERSION);
105
+ *
106
+ * const dataTable = PluginModel.define<TableData, TableParams, TableConfig>({
107
+ * name: 'dataTable' as PluginName,
108
+ * data: (cfg) => {
109
+ * return dataModelChain.init(() => ({ state: createInitialState(cfg.ops) }));
110
+ * },
111
+ * })
112
+ * .output('model', (ctx) => createTableModel(ctx))
113
+ * .build();
114
+ */
115
+ declare class PluginModelBuilder<Data, Params = undefined, Config = undefined, Outputs extends Record<string, unknown> = {}> {
116
+ private readonly name;
117
+ private readonly data;
118
+ private readonly outputs;
119
+ private constructor();
120
+ /**
121
+ * Internal method for creating PluginModelBuilder.
122
+ * Uses Symbol key to prevent external access.
123
+ * @internal
124
+ */
125
+ static [FROM_BUILDER]<D, P, C, O extends Record<string, unknown> = {}>(input: {
126
+ name: PluginName;
127
+ data: (config?: C) => DataModel<D>;
128
+ outputs?: {
129
+ [K in keyof O]: (ctx: PluginRenderCtx<D, P>) => O[K];
130
+ };
131
+ }): PluginModelBuilder<D, P, C, O>;
132
+ /**
133
+ * Adds an output to the plugin.
134
+ *
135
+ * @param key - Output name
136
+ * @param fn - Function that computes the output value from plugin context
137
+ * @returns PluginModel with the new output added
138
+ *
139
+ * @example
140
+ * .output('model', (ctx) => createModel(ctx.params.columns, ctx.data.state))
141
+ * .output('isReady', (ctx) => ctx.params.columns !== undefined)
142
+ */
143
+ output<const Key extends string, T>(key: Key, fn: (ctx: PluginRenderCtx<Data, Params>) => T): PluginModelBuilder<Data, Params, Config, Outputs & {
144
+ [K in Key]: T;
145
+ }>;
146
+ /**
147
+ * Finalizes the plugin definition and returns a ConfigurablePluginModel.
148
+ *
149
+ * @returns Callable plugin factory that accepts config and returns PluginModel
150
+ *
151
+ * @example
152
+ * const myPlugin = new PluginModelBuilder('myPlugin', () => dataModel)
153
+ * .output('value', (ctx) => ctx.data.value)
154
+ * .build();
155
+ *
156
+ * // Later, call create() with config to get a configured instance:
157
+ * const configured = myPlugin.create({ defaultValue: 'test' });
158
+ */
159
+ build(): PluginModelFactory<Data, Params, Config, Outputs>;
160
+ }
161
+ export {};
162
+ //# sourceMappingURL=plugin_model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin_model.d.ts","sourceRoot":"","sources":["../src/plugin_model.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,kDAAkD;AAClD,QAAA,MAAM,YAAY,eAAwB,CAAC;AAM3C;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IACvD,+BAA+B;IAC/B,QAAQ,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