@platforma-sdk/model 1.55.0 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/block_model.cjs +27 -8
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +28 -9
- package/dist/block_model.js.map +1 -1
- package/dist/block_storage.cjs +8 -5
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +6 -4
- package/dist/block_storage.d.ts.map +1 -1
- package/dist/block_storage.js +8 -5
- package/dist/block_storage.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/plugin_model.cjs.map +1 -1
- package/dist/plugin_model.d.ts +1 -14
- package/dist/plugin_model.d.ts.map +1 -1
- package/dist/plugin_model.js.map +1 -1
- package/dist/render/api.cjs +42 -2
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +22 -2
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +42 -3
- package/dist/render/api.js.map +1 -1
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +2 -1
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/internal.js.map +1 -1
- package/package.json +5 -5
- package/src/block_model.ts +30 -9
- package/src/block_storage.test.ts +4 -2
- package/src/block_storage.ts +8 -8
- package/src/index.ts +0 -1
- package/src/plugin_model.ts +1 -19
- package/src/render/api.ts +52 -2
- package/src/render/internal.ts +3 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Optional } from "utility-types";
|
|
2
|
-
import type { Branded } from "@milaboratories/pl-model-common";
|
|
2
|
+
import type { Branded, StringifiedJson } from "@milaboratories/pl-model-common";
|
|
3
3
|
import type { CommonFieldTraverseOps, FieldTraversalStep, ResourceType } from "./traversal_ops";
|
|
4
4
|
import type { ArchiveFormat, AnyFunction, Option, PColumn, PColumnValues, PFrameDef, PFrameHandle, PObject, PObjectSpec, PSpecPredicate, PTableDef, PTableDefV2, PTableHandle, ResultCollection, ValueOrError, DataInfo, RangeBytes } from "@milaboratories/pl-model-common";
|
|
5
5
|
import type { TreeNodeAccessor } from "./accessor";
|
|
@@ -65,6 +65,7 @@ export interface GlobalCfgRenderCtx extends GlobalCfgRenderCtxMethods {
|
|
|
65
65
|
readonly uiState?: string | (() => string);
|
|
66
66
|
readonly data: string | (() => string);
|
|
67
67
|
readonly activeArgs: undefined | string | (() => string | undefined);
|
|
68
|
+
readonly blockStorage: () => StringifiedJson;
|
|
68
69
|
readonly callbackRegistry: Record<string, AnyFunction>;
|
|
69
70
|
readonly featureFlags?: typeof GlobalCfgRenderCtxFeatureFlags;
|
|
70
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/render/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/render/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,MAAM,EACN,OAAO,EACP,aAAa,EACb,SAAS,EACT,YAAY,EACZ,OAAO,EACP,WAAW,EACX,cAAc,EACd,SAAS,EACT,WAAW,EACX,YAAY,EACZ,gBAAgB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,MAAM,GAAG,IAAI,CAAC;IAE/B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,8BAA8B;;;;;;CAM1C,CAAC;AAEF,MAAM,WAAW,kBAAmB,SAAQ,yBAAyB;IAUnE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACvC,kHAAkH;IAClH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;IAErE,QAAQ,CAAC,YAAY,EAAE,MAAM,eAAe,CAAC;IAK7C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvD,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,8BAA8B,CAAC;CAC/D;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,mBAAmB,EAAE,YAAY,EAAE,CAAC;CACrC,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAE9D;AAiBD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAI5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sources":["../../src/render/internal.ts"],"sourcesContent":["import type { Optional } from \"utility-types\";\nimport type { Branded } from \"@milaboratories/pl-model-common\";\nimport type { CommonFieldTraverseOps, FieldTraversalStep, ResourceType } from \"./traversal_ops\";\nimport type {\n ArchiveFormat,\n AnyFunction,\n Option,\n PColumn,\n PColumnValues,\n PFrameDef,\n PFrameHandle,\n PObject,\n PObjectSpec,\n PSpecPredicate,\n PTableDef,\n PTableDefV2,\n PTableHandle,\n ResultCollection,\n ValueOrError,\n DataInfo,\n RangeBytes,\n} from \"@milaboratories/pl-model-common\";\nimport type { TreeNodeAccessor } from \"./accessor\";\n\nexport const StagingAccessorName = \"staging\";\nexport const MainAccessorName = \"main\";\n\nexport type AccessorHandle = Branded<string, \"AccessorHandle\">;\nexport type FutureHandle = Branded<string, \"FutureHandle\">;\n\nexport type PColumnDataUniversal<TreeEntry = TreeNodeAccessor> =\n | TreeEntry\n | DataInfo<TreeEntry>\n | PColumnValues;\n\nexport interface GlobalCfgRenderCtxMethods<AHandle = AccessorHandle, FHandle = FutureHandle> {\n //\n // Root accessor creation\n //\n\n getAccessorHandleByName(name: string): AHandle | undefined;\n\n //\n // Basic resource accessor actions\n //\n\n resolveWithCommon(\n handle: AHandle,\n commonOptions: CommonFieldTraverseOps,\n ...steps: (FieldTraversalStep | string)[]\n ): AHandle | undefined;\n\n getResourceType(handle: AHandle): ResourceType;\n\n getInputsLocked(handle: AHandle): boolean;\n\n getOutputsLocked(handle: AHandle): boolean;\n\n getIsReadyOrError(handle: AHandle): boolean;\n\n getIsFinal(handle: AHandle): boolean;\n\n getError(handle: AHandle): AHandle | undefined;\n\n listInputFields(handle: AHandle): string[];\n\n listOutputFields(handle: AHandle): string[];\n\n listDynamicFields(handle: AHandle): string[];\n\n getKeyValueBase64(handle: AHandle, key: string): string | undefined;\n\n getKeyValueAsString(handle: AHandle, key: string): string | undefined;\n\n getDataBase64(handle: AHandle): string | undefined;\n\n getDataAsString(handle: AHandle): string | undefined;\n\n /** If not final returns undefined */\n parsePObjectCollection(\n handle: AHandle,\n errorOnUnknownField: boolean,\n prefix: string,\n ...resolvePath: string[]\n ): Record<string, PObject<AHandle>> | undefined;\n\n //\n // Blob\n //\n\n getBlobContentAsBase64(handle: AHandle, range?: RangeBytes): FHandle; // string | undefined\n\n getBlobContentAsString(handle: AHandle, range?: RangeBytes): FHandle; // string | undefined\n\n getDownloadedBlobContentHandle(handle: AHandle): FHandle; // LocalBlobHandleAndSize | undefined;\n\n getOnDemandBlobContentHandle(handle: AHandle): FHandle; // RemoteBlobHandleAndSize | undefined;\n\n //\n // Blobs to URLs\n //\n\n extractArchiveAndGetURL(handle: AHandle, format: ArchiveFormat): FHandle;\n\n //\n // Import progress\n //\n\n getImportProgress(handle: AHandle): FHandle; // ImportProgress;\n\n //\n // Logs\n //\n\n getLastLogs(handle: AHandle, nLines: number): FHandle; // string | undefined;\n\n getProgressLog(handle: AHandle, patternToSearch: string): FHandle; // string | undefined;\n\n getProgressLogWithInfo(handle: AHandle, patternToSearch: string): FHandle; // ProgressLogWithInfo | undefined;\n\n getLogHandle(handle: AHandle): FHandle; // AnyLogHandle | undefined;\n\n //\n // Blocks\n //\n\n /** @deprecated at some point will stop working and will return dummy values */\n getBlockLabel(blockId: string): string;\n\n //\n // Result Pool\n //\n\n getDataFromResultPool(): ResultCollection<PObject<AHandle>>;\n\n getDataWithErrorsFromResultPool(): ResultCollection<\n Optional<PObject<ValueOrError<AHandle, Error>>, \"id\">\n >;\n\n getSpecsFromResultPool(): ResultCollection<PObjectSpec>;\n\n getSpecFromResultPoolByRef(blockId: string, exportName: string): PObjectSpec | undefined;\n\n getDataFromResultPoolByRef(blockId: string, exportName: string): PObject<AHandle> | undefined;\n\n calculateOptions(predicate: PSpecPredicate): Option[];\n\n //\n // PFrame / PTable\n //\n\n createPFrame(def: PFrameDef<PColumn<AHandle | PColumnValues | DataInfo<AHandle>>>): PFrameHandle;\n\n createPTable(def: PTableDef<PColumn<AHandle | PColumnValues | DataInfo<AHandle>>>): PTableHandle;\n\n createPTableV2(\n def: PTableDefV2<PColumn<AHandle | PColumnValues | DataInfo<AHandle>>>,\n ): PTableHandle;\n\n //\n // Computable\n //\n\n getCurrentUnstableMarker(): string | undefined;\n\n //\n // Logging\n //\n\n logInfo(message: string): void;\n\n logWarn(message: string): void;\n\n logError(message: string): void;\n}\n\nexport const GlobalCfgRenderCtxFeatureFlags = {\n explicitColumnsSupport: true as const,\n inlineColumnsSupport: true as const,\n activeArgs: true as const,\n pTablePartitionFiltersSupport: true as const,\n pFrameInSetFilterSupport: true as const,\n};\n\nexport interface GlobalCfgRenderCtx extends GlobalCfgRenderCtxMethods {\n //\n // State: Args, UI State, Active Args\n //\n // Old runtime injects these values as strings, new runtime injects them as functions\n // that return strings, if block declares supportsLazyState flag.\n // If function not called in lazy state API, then resulting output will not depend on these values,\n // and thus will not be recalculated on corresponding state change.\n //\n\n readonly args: string | (() => string);\n /** @deprecated Use `data` instead. Optional for backward compatibility - falls back to `data` if not injected. */\n readonly uiState?: string | (() => string);\n readonly data: string | (() => string);\n readonly activeArgs: undefined | string | (() => string | undefined);\n\n // Note: strings below are used because, anyway, using strings is the only way\n // to get data inside the QuickJS context, as it is implemented now. With this\n // approach deserialization can be lazily postponed until it is actually needed.\n readonly callbackRegistry: Record<string, AnyFunction>;\n readonly featureFlags?: typeof GlobalCfgRenderCtxFeatureFlags;\n}\n\nexport type FutureAwait = {\n __awaited_futures__: FutureHandle[];\n};\n\nexport function isFutureAwait(obj: unknown): obj is FutureAwait {\n return typeof obj === \"object\" && obj !== null && \"__awaited_futures__\" in obj;\n}\n\nfunction addAllFutureAwaits(set: Set<string>, visited: Set<unknown>, node: unknown) {\n if (visited.has(node)) return;\n visited.add(node);\n\n const type = typeof node;\n if (type === \"object\") {\n if (isFutureAwait(node)) node.__awaited_futures__.forEach((a) => set.add(a));\n else if (Array.isArray(node))\n for (const nested of node) addAllFutureAwaits(set, visited, nested);\n else\n for (const [, nested] of Object.entries(node as object))\n if (nested !== node) addAllFutureAwaits(set, visited, nested);\n }\n}\n\nexport function getAllFutureAwaits(obj: unknown): Set<string> {\n const set = new Set<string>();\n addAllFutureAwaits(set, new Set(), obj);\n return set;\n}\n"],"names":[],"mappings":"AAwBO,MAAM,mBAAmB,GAAG;AAC5B,MAAM,gBAAgB,GAAG;AAuJzB,MAAM,8BAA8B,GAAG;AAC5C,IAAA,sBAAsB,EAAE,IAAa;AACrC,IAAA,oBAAoB,EAAE,IAAa;AACnC,IAAA,UAAU,EAAE,IAAa;AACzB,IAAA,6BAA6B,EAAE,IAAa;AAC5C,IAAA,wBAAwB,EAAE,IAAa;;
|
|
1
|
+
{"version":3,"file":"internal.js","sources":["../../src/render/internal.ts"],"sourcesContent":["import type { Optional } from \"utility-types\";\nimport type { Branded, StringifiedJson } from \"@milaboratories/pl-model-common\";\nimport type { CommonFieldTraverseOps, FieldTraversalStep, ResourceType } from \"./traversal_ops\";\nimport type {\n ArchiveFormat,\n AnyFunction,\n Option,\n PColumn,\n PColumnValues,\n PFrameDef,\n PFrameHandle,\n PObject,\n PObjectSpec,\n PSpecPredicate,\n PTableDef,\n PTableDefV2,\n PTableHandle,\n ResultCollection,\n ValueOrError,\n DataInfo,\n RangeBytes,\n} from \"@milaboratories/pl-model-common\";\nimport type { TreeNodeAccessor } from \"./accessor\";\n\nexport const StagingAccessorName = \"staging\";\nexport const MainAccessorName = \"main\";\n\nexport type AccessorHandle = Branded<string, \"AccessorHandle\">;\nexport type FutureHandle = Branded<string, \"FutureHandle\">;\n\nexport type PColumnDataUniversal<TreeEntry = TreeNodeAccessor> =\n | TreeEntry\n | DataInfo<TreeEntry>\n | PColumnValues;\n\nexport interface GlobalCfgRenderCtxMethods<AHandle = AccessorHandle, FHandle = FutureHandle> {\n //\n // Root accessor creation\n //\n\n getAccessorHandleByName(name: string): AHandle | undefined;\n\n //\n // Basic resource accessor actions\n //\n\n resolveWithCommon(\n handle: AHandle,\n commonOptions: CommonFieldTraverseOps,\n ...steps: (FieldTraversalStep | string)[]\n ): AHandle | undefined;\n\n getResourceType(handle: AHandle): ResourceType;\n\n getInputsLocked(handle: AHandle): boolean;\n\n getOutputsLocked(handle: AHandle): boolean;\n\n getIsReadyOrError(handle: AHandle): boolean;\n\n getIsFinal(handle: AHandle): boolean;\n\n getError(handle: AHandle): AHandle | undefined;\n\n listInputFields(handle: AHandle): string[];\n\n listOutputFields(handle: AHandle): string[];\n\n listDynamicFields(handle: AHandle): string[];\n\n getKeyValueBase64(handle: AHandle, key: string): string | undefined;\n\n getKeyValueAsString(handle: AHandle, key: string): string | undefined;\n\n getDataBase64(handle: AHandle): string | undefined;\n\n getDataAsString(handle: AHandle): string | undefined;\n\n /** If not final returns undefined */\n parsePObjectCollection(\n handle: AHandle,\n errorOnUnknownField: boolean,\n prefix: string,\n ...resolvePath: string[]\n ): Record<string, PObject<AHandle>> | undefined;\n\n //\n // Blob\n //\n\n getBlobContentAsBase64(handle: AHandle, range?: RangeBytes): FHandle; // string | undefined\n\n getBlobContentAsString(handle: AHandle, range?: RangeBytes): FHandle; // string | undefined\n\n getDownloadedBlobContentHandle(handle: AHandle): FHandle; // LocalBlobHandleAndSize | undefined;\n\n getOnDemandBlobContentHandle(handle: AHandle): FHandle; // RemoteBlobHandleAndSize | undefined;\n\n //\n // Blobs to URLs\n //\n\n extractArchiveAndGetURL(handle: AHandle, format: ArchiveFormat): FHandle;\n\n //\n // Import progress\n //\n\n getImportProgress(handle: AHandle): FHandle; // ImportProgress;\n\n //\n // Logs\n //\n\n getLastLogs(handle: AHandle, nLines: number): FHandle; // string | undefined;\n\n getProgressLog(handle: AHandle, patternToSearch: string): FHandle; // string | undefined;\n\n getProgressLogWithInfo(handle: AHandle, patternToSearch: string): FHandle; // ProgressLogWithInfo | undefined;\n\n getLogHandle(handle: AHandle): FHandle; // AnyLogHandle | undefined;\n\n //\n // Blocks\n //\n\n /** @deprecated at some point will stop working and will return dummy values */\n getBlockLabel(blockId: string): string;\n\n //\n // Result Pool\n //\n\n getDataFromResultPool(): ResultCollection<PObject<AHandle>>;\n\n getDataWithErrorsFromResultPool(): ResultCollection<\n Optional<PObject<ValueOrError<AHandle, Error>>, \"id\">\n >;\n\n getSpecsFromResultPool(): ResultCollection<PObjectSpec>;\n\n getSpecFromResultPoolByRef(blockId: string, exportName: string): PObjectSpec | undefined;\n\n getDataFromResultPoolByRef(blockId: string, exportName: string): PObject<AHandle> | undefined;\n\n calculateOptions(predicate: PSpecPredicate): Option[];\n\n //\n // PFrame / PTable\n //\n\n createPFrame(def: PFrameDef<PColumn<AHandle | PColumnValues | DataInfo<AHandle>>>): PFrameHandle;\n\n createPTable(def: PTableDef<PColumn<AHandle | PColumnValues | DataInfo<AHandle>>>): PTableHandle;\n\n createPTableV2(\n def: PTableDefV2<PColumn<AHandle | PColumnValues | DataInfo<AHandle>>>,\n ): PTableHandle;\n\n //\n // Computable\n //\n\n getCurrentUnstableMarker(): string | undefined;\n\n //\n // Logging\n //\n\n logInfo(message: string): void;\n\n logWarn(message: string): void;\n\n logError(message: string): void;\n}\n\nexport const GlobalCfgRenderCtxFeatureFlags = {\n explicitColumnsSupport: true as const,\n inlineColumnsSupport: true as const,\n activeArgs: true as const,\n pTablePartitionFiltersSupport: true as const,\n pFrameInSetFilterSupport: true as const,\n};\n\nexport interface GlobalCfgRenderCtx extends GlobalCfgRenderCtxMethods {\n //\n // State: Args, UI State, Active Args\n //\n // Old runtime injects these values as strings, new runtime injects them as functions\n // that return strings, if block declares supportsLazyState flag.\n // If function not called in lazy state API, then resulting output will not depend on these values,\n // and thus will not be recalculated on corresponding state change.\n //\n\n readonly args: string | (() => string);\n /** @deprecated Use `data` instead. Optional for backward compatibility - falls back to `data` if not injected. */\n readonly uiState?: string | (() => string);\n readonly data: string | (() => string);\n readonly activeArgs: undefined | string | (() => string | undefined);\n\n readonly blockStorage: () => StringifiedJson;\n\n // Note: strings below are used because, anyway, using strings is the only way\n // to get data inside the QuickJS context, as it is implemented now. With this\n // approach deserialization can be lazily postponed until it is actually needed.\n readonly callbackRegistry: Record<string, AnyFunction>;\n readonly featureFlags?: typeof GlobalCfgRenderCtxFeatureFlags;\n}\n\nexport type FutureAwait = {\n __awaited_futures__: FutureHandle[];\n};\n\nexport function isFutureAwait(obj: unknown): obj is FutureAwait {\n return typeof obj === \"object\" && obj !== null && \"__awaited_futures__\" in obj;\n}\n\nfunction addAllFutureAwaits(set: Set<string>, visited: Set<unknown>, node: unknown) {\n if (visited.has(node)) return;\n visited.add(node);\n\n const type = typeof node;\n if (type === \"object\") {\n if (isFutureAwait(node)) node.__awaited_futures__.forEach((a) => set.add(a));\n else if (Array.isArray(node))\n for (const nested of node) addAllFutureAwaits(set, visited, nested);\n else\n for (const [, nested] of Object.entries(node as object))\n if (nested !== node) addAllFutureAwaits(set, visited, nested);\n }\n}\n\nexport function getAllFutureAwaits(obj: unknown): Set<string> {\n const set = new Set<string>();\n addAllFutureAwaits(set, new Set(), obj);\n return set;\n}\n"],"names":[],"mappings":"AAwBO,MAAM,mBAAmB,GAAG;AAC5B,MAAM,gBAAgB,GAAG;AAuJzB,MAAM,8BAA8B,GAAG;AAC5C,IAAA,sBAAsB,EAAE,IAAa;AACrC,IAAA,oBAAoB,EAAE,IAAa;AACnC,IAAA,UAAU,EAAE,IAAa;AACzB,IAAA,6BAA6B,EAAE,IAAa;AAC5C,IAAA,wBAAwB,EAAE,IAAa;;AAgCnC,SAAU,aAAa,CAAC,GAAY,EAAA;AACxC,IAAA,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,qBAAqB,IAAI,GAAG;AAChF;AAEA,SAAS,kBAAkB,CAAC,GAAgB,EAAE,OAAqB,EAAE,IAAa,EAAA;AAChF,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE;AACvB,IAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;AAEjB,IAAA,MAAM,IAAI,GAAG,OAAO,IAAI;AACxB,IAAA,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,IAAI,aAAa,CAAC,IAAI,CAAC;AAAE,YAAA,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACvE,aAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAC1B,KAAK,MAAM,MAAM,IAAI,IAAI;AAAE,gBAAA,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC;;YAEnE,KAAK,MAAM,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAc,CAAC;gBACrD,IAAI,MAAM,KAAK,IAAI;AAAE,oBAAA,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC;IACnE;AACF;AAEM,SAAU,kBAAkB,CAAC,GAAY,EAAA;AAC7C,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU;IAC7B,kBAAkB,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,CAAC;AACvC,IAAA,OAAO,GAAG;AACZ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"zod": "~3.23.8",
|
|
27
27
|
"@milaboratories/helpers": "1.13.5",
|
|
28
28
|
"@milaboratories/pl-error-like": "1.12.8",
|
|
29
|
-
"@milaboratories/
|
|
30
|
-
"@milaboratories/
|
|
29
|
+
"@milaboratories/ptabler-expression-js": "1.1.22",
|
|
30
|
+
"@milaboratories/pl-model-common": "1.25.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@vitest/coverage-istanbul": "^4.0.16",
|
|
34
34
|
"fast-json-patch": "^3.1.1",
|
|
35
35
|
"typescript": "~5.6.3",
|
|
36
36
|
"vitest": "^4.0.16",
|
|
37
|
+
"@milaboratories/build-configs": "1.4.4",
|
|
37
38
|
"@milaboratories/ts-builder": "1.2.10",
|
|
38
|
-
"@milaboratories/ts-configs": "1.2.1"
|
|
39
|
-
"@milaboratories/build-configs": "1.4.4"
|
|
39
|
+
"@milaboratories/ts-configs": "1.2.1"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "ts-builder build --target node",
|
package/src/block_model.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { getPlatformaInstance, isInUI, createAndRegisterRenderLambda } from "./i
|
|
|
10
10
|
import type { DataModel } from "./block_migrations";
|
|
11
11
|
import type { PlatformaV3 } from "./platforma";
|
|
12
12
|
import type { InferRenderFunctionReturn, RenderFunction } from "./render";
|
|
13
|
-
import {
|
|
13
|
+
import { BlockRenderCtx, PluginRenderCtx } from "./render";
|
|
14
14
|
import type { PluginModel } from "./plugin_model";
|
|
15
15
|
import type { RenderCtxBase } from "./render";
|
|
16
16
|
import { PlatformaSDKVersion } from "./version";
|
|
@@ -192,8 +192,8 @@ export class BlockModelV3<
|
|
|
192
192
|
outputs: {
|
|
193
193
|
...this.config.outputs,
|
|
194
194
|
[key]: createAndRegisterRenderLambda({
|
|
195
|
-
handle: `output#${key}`,
|
|
196
|
-
lambda: () => cfgOrRf(new
|
|
195
|
+
handle: `block-output#${key}`,
|
|
196
|
+
lambda: () => cfgOrRf(new BlockRenderCtx<Args, Data>()),
|
|
197
197
|
...flags,
|
|
198
198
|
}),
|
|
199
199
|
},
|
|
@@ -287,7 +287,7 @@ export class BlockModelV3<
|
|
|
287
287
|
...this.config,
|
|
288
288
|
// Replace the default sections callback with the user-provided one
|
|
289
289
|
sections: createAndRegisterRenderLambda(
|
|
290
|
-
{ handle: "sections", lambda: () => rf(new
|
|
290
|
+
{ handle: "sections", lambda: () => rf(new BlockRenderCtx<Args, Data>()) },
|
|
291
291
|
true,
|
|
292
292
|
),
|
|
293
293
|
});
|
|
@@ -301,7 +301,7 @@ export class BlockModelV3<
|
|
|
301
301
|
...this.config,
|
|
302
302
|
title: createAndRegisterRenderLambda({
|
|
303
303
|
handle: "title",
|
|
304
|
-
lambda: () => rf(new
|
|
304
|
+
lambda: () => rf(new BlockRenderCtx<Args, Data>()),
|
|
305
305
|
}),
|
|
306
306
|
});
|
|
307
307
|
}
|
|
@@ -313,7 +313,7 @@ export class BlockModelV3<
|
|
|
313
313
|
...this.config,
|
|
314
314
|
subtitle: createAndRegisterRenderLambda({
|
|
315
315
|
handle: "subtitle",
|
|
316
|
-
lambda: () => rf(new
|
|
316
|
+
lambda: () => rf(new BlockRenderCtx<Args, Data>()),
|
|
317
317
|
}),
|
|
318
318
|
});
|
|
319
319
|
}
|
|
@@ -325,7 +325,7 @@ export class BlockModelV3<
|
|
|
325
325
|
...this.config,
|
|
326
326
|
tags: createAndRegisterRenderLambda({
|
|
327
327
|
handle: "tags",
|
|
328
|
-
lambda: () => rf(new
|
|
328
|
+
lambda: () => rf(new BlockRenderCtx<Args, Data>()),
|
|
329
329
|
}),
|
|
330
330
|
});
|
|
331
331
|
}
|
|
@@ -458,6 +458,27 @@ export class BlockModelV3<
|
|
|
458
458
|
derivePrerunArgsFromStorage(storageJson, argsFunction, prerunArgsFunction),
|
|
459
459
|
});
|
|
460
460
|
|
|
461
|
+
// Register plugin input and output lambdas
|
|
462
|
+
const pluginOutputs: Record<string, ConfigRenderLambda> = {};
|
|
463
|
+
for (const [pluginId, { model, inputs }] of Object.entries(plugins)) {
|
|
464
|
+
// Wrap plugin param lambdas: close over BlockRenderCtx creation
|
|
465
|
+
const wrappedInputs: Record<string, () => unknown> = {};
|
|
466
|
+
for (const [paramKey, paramFn] of Object.entries(inputs)) {
|
|
467
|
+
wrappedInputs[paramKey] = () => paramFn(new BlockRenderCtx());
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// Register plugin outputs (in config pack, evaluated by middle layer)
|
|
471
|
+
const outputs = model.outputs as Record<string, (ctx: PluginRenderCtx) => unknown>;
|
|
472
|
+
for (const [outputKey, outputFn] of Object.entries(outputs)) {
|
|
473
|
+
const key = `plugin-output#${pluginId}#${outputKey}`;
|
|
474
|
+
pluginOutputs[key] = createAndRegisterRenderLambda({
|
|
475
|
+
handle: key,
|
|
476
|
+
lambda: () => outputFn(new PluginRenderCtx(pluginId, wrappedInputs)),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
const allOutputs = { ...this.config.outputs, ...pluginOutputs };
|
|
481
|
+
|
|
461
482
|
const blockConfig: BlockConfigContainer = {
|
|
462
483
|
v4: {
|
|
463
484
|
configVersion: 4,
|
|
@@ -468,7 +489,7 @@ export class BlockModelV3<
|
|
|
468
489
|
title: this.config.title,
|
|
469
490
|
subtitle: this.config.subtitle,
|
|
470
491
|
tags: this.config.tags,
|
|
471
|
-
outputs:
|
|
492
|
+
outputs: allOutputs,
|
|
472
493
|
enrichmentTargets: this.config.enrichmentTargets,
|
|
473
494
|
featureFlags: this.config.featureFlags,
|
|
474
495
|
blockLifecycleCallbacks: { ...BlockStorageFacadeHandles },
|
|
@@ -500,7 +521,7 @@ export class BlockModelV3<
|
|
|
500
521
|
}),
|
|
501
522
|
blockModelInfo: {
|
|
502
523
|
outputs: Object.fromEntries(
|
|
503
|
-
Object.entries(
|
|
524
|
+
Object.entries(allOutputs).map(([key, value]) => [
|
|
504
525
|
key,
|
|
505
526
|
{
|
|
506
527
|
withStatus: Boolean(isConfigLambda(value) && value.withStatus),
|
|
@@ -218,8 +218,10 @@ describe("BlockStorage", () => {
|
|
|
218
218
|
expect(getPluginData(storage, "chart1")).toEqual({ type: "bar" });
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
it("getPluginData should
|
|
222
|
-
expect(getPluginData(baseStorage, "nonexistent")).
|
|
221
|
+
it("getPluginData should throw for missing plugin", () => {
|
|
222
|
+
expect(() => getPluginData(baseStorage, "nonexistent")).toThrow(
|
|
223
|
+
"Plugin 'nonexistent' not found in block storage",
|
|
224
|
+
);
|
|
223
225
|
});
|
|
224
226
|
|
|
225
227
|
it("should not modify original storage (immutability)", () => {
|
package/src/block_storage.ts
CHANGED
|
@@ -381,17 +381,17 @@ export function migrateBlockStorage(
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
/**
|
|
384
|
-
* Gets plugin-specific data from
|
|
384
|
+
* Gets plugin-specific data from block storage.
|
|
385
|
+
* Accepts raw storage (any format) and normalizes internally.
|
|
385
386
|
*
|
|
386
|
-
* @param
|
|
387
|
+
* @param rawStorage - Raw block storage (may be legacy format or BlockStorage)
|
|
387
388
|
* @param pluginId - The plugin instance id
|
|
388
|
-
* @returns The plugin data
|
|
389
|
+
* @returns The plugin data
|
|
390
|
+
* @throws If pluginId is not found in storage
|
|
389
391
|
*/
|
|
390
|
-
export function getPluginData<TData = unknown>(
|
|
391
|
-
storage
|
|
392
|
-
pluginId: string,
|
|
393
|
-
): TData | undefined {
|
|
392
|
+
export function getPluginData<TData = unknown>(rawStorage: unknown, pluginId: string): TData {
|
|
393
|
+
const storage = normalizeBlockStorage(rawStorage);
|
|
394
394
|
const pluginEntry = storage.__plugins?.[pluginId];
|
|
395
|
-
if (!pluginEntry)
|
|
395
|
+
if (!pluginEntry) throw new Error(`Plugin '${pluginId}' not found in block storage`);
|
|
396
396
|
return pluginEntry.__data as TData;
|
|
397
397
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,6 @@ export {
|
|
|
15
15
|
} from "./block_migrations";
|
|
16
16
|
export type { LegacyV1State } from "./block_migrations";
|
|
17
17
|
export { PluginModel } from "./plugin_model";
|
|
18
|
-
export type { PluginRenderCtx } from "./plugin_model";
|
|
19
18
|
export * from "./bconfig";
|
|
20
19
|
export * from "./components";
|
|
21
20
|
export * from "./config";
|
package/src/plugin_model.ts
CHANGED
|
@@ -9,29 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
import type { DataModel } from "./block_migrations";
|
|
11
11
|
import type { PluginName } from "./block_storage";
|
|
12
|
-
import type {
|
|
12
|
+
import type { PluginRenderCtx } from "./render";
|
|
13
13
|
|
|
14
14
|
/** Symbol for internal builder creation method */
|
|
15
15
|
const FROM_BUILDER = Symbol("fromBuilder");
|
|
16
16
|
|
|
17
|
-
// =============================================================================
|
|
18
|
-
// Plugin Render Context
|
|
19
|
-
// =============================================================================
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Context passed to plugin output functions.
|
|
23
|
-
* Provides access to plugin's persistent data, params derived from block context,
|
|
24
|
-
* and the result pool for accessing workflow outputs.
|
|
25
|
-
*/
|
|
26
|
-
export interface PluginRenderCtx<Data, Params = undefined> {
|
|
27
|
-
/** Plugin's persistent data */
|
|
28
|
-
readonly data: Data;
|
|
29
|
-
/** Params derived from block's RenderCtx */
|
|
30
|
-
readonly params: Params;
|
|
31
|
-
/** Result pool for accessing workflow outputs */
|
|
32
|
-
readonly resultPool: ResultPool;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
17
|
// =============================================================================
|
|
36
18
|
// Plugin Type
|
|
37
19
|
// =============================================================================
|
package/src/render/api.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
AnchoredIdDeriver,
|
|
31
31
|
collectSpecQueryColumns,
|
|
32
32
|
ensurePColumn,
|
|
33
|
+
parseJson,
|
|
33
34
|
extractAllColumns,
|
|
34
35
|
isDataInfo,
|
|
35
36
|
isPColumn,
|
|
@@ -48,6 +49,7 @@ import {
|
|
|
48
49
|
import canonicalize from "canonicalize";
|
|
49
50
|
import type { Optional } from "utility-types";
|
|
50
51
|
import { getCfgRenderCtx } from "../internal";
|
|
52
|
+
import { getPluginData } from "../block_storage";
|
|
51
53
|
import { TreeNodeAccessor, ifDef } from "./accessor";
|
|
52
54
|
import type { FutureRef } from "./future";
|
|
53
55
|
import type { AccessorHandle, GlobalCfgRenderCtx } from "./internal";
|
|
@@ -711,7 +713,7 @@ export abstract class RenderCtxBase<Args = unknown, Data = unknown> {
|
|
|
711
713
|
}
|
|
712
714
|
|
|
713
715
|
/** Main entry point to the API available within model lambdas (like outputs, sections, etc..) for v3+ blocks */
|
|
714
|
-
export class
|
|
716
|
+
export class BlockRenderCtx<Args = unknown, Data = unknown> extends RenderCtxBase<Args, Data> {
|
|
715
717
|
private argsCache?: { v: Args | undefined };
|
|
716
718
|
public get args(): Args | undefined {
|
|
717
719
|
if (this.argsCache === undefined) {
|
|
@@ -751,8 +753,56 @@ export class RenderCtxLegacy<Args = unknown, UiState = unknown> extends RenderCt
|
|
|
751
753
|
}
|
|
752
754
|
}
|
|
753
755
|
|
|
756
|
+
/**
|
|
757
|
+
* Render context for plugin output functions.
|
|
758
|
+
* Reads plugin data from blockStorage and derives params from pre-wrapped input callbacks.
|
|
759
|
+
*/
|
|
760
|
+
export class PluginRenderCtx<Data = unknown, Params = unknown> {
|
|
761
|
+
private readonly ctx: GlobalCfgRenderCtx;
|
|
762
|
+
private readonly pluginId: string;
|
|
763
|
+
private readonly wrappedInputs: Record<string, () => unknown>;
|
|
764
|
+
|
|
765
|
+
constructor(pluginId: string, wrappedInputs: Record<string, () => unknown>) {
|
|
766
|
+
this.ctx = getCfgRenderCtx();
|
|
767
|
+
this.pluginId = pluginId;
|
|
768
|
+
this.wrappedInputs = wrappedInputs;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
private dataCache?: { v: Data };
|
|
772
|
+
|
|
773
|
+
/** Plugin's persistent data from blockStorage.__plugins.{pluginId}.__data */
|
|
774
|
+
public get data(): Data {
|
|
775
|
+
if (this.dataCache === undefined) {
|
|
776
|
+
const raw = this.ctx.blockStorage();
|
|
777
|
+
const pluginData = getPluginData<Data>(parseJson(raw), this.pluginId);
|
|
778
|
+
this.dataCache = { v: pluginData };
|
|
779
|
+
}
|
|
780
|
+
return this.dataCache.v;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
private paramsCache?: { v: Params };
|
|
784
|
+
|
|
785
|
+
/** Params derived from block context via pre-wrapped input callbacks */
|
|
786
|
+
public get params(): Params {
|
|
787
|
+
if (this.paramsCache === undefined) {
|
|
788
|
+
const result: Record<string, unknown> = {};
|
|
789
|
+
for (const [key, fn] of Object.entries(this.wrappedInputs)) {
|
|
790
|
+
result[key] = fn();
|
|
791
|
+
}
|
|
792
|
+
this.paramsCache = { v: result as Params };
|
|
793
|
+
}
|
|
794
|
+
return this.paramsCache.v;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/** Result pool — same as block, from cfgRenderCtx methods */
|
|
798
|
+
public readonly resultPool = new ResultPool();
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/** @deprecated Use BlockRenderCtx instead */
|
|
802
|
+
export type RenderCtx<Args = unknown, Data = unknown> = BlockRenderCtx<Args, Data>;
|
|
803
|
+
|
|
754
804
|
export type RenderFunction<Args = unknown, State = unknown, Ret = unknown> = (
|
|
755
|
-
rCtx:
|
|
805
|
+
rCtx: BlockRenderCtx<Args, State>,
|
|
756
806
|
) => Ret;
|
|
757
807
|
|
|
758
808
|
export type RenderFunctionLegacy<Args = unknown, State = unknown, Ret = unknown> = (
|
package/src/render/internal.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Optional } from "utility-types";
|
|
2
|
-
import type { Branded } from "@milaboratories/pl-model-common";
|
|
2
|
+
import type { Branded, StringifiedJson } from "@milaboratories/pl-model-common";
|
|
3
3
|
import type { CommonFieldTraverseOps, FieldTraversalStep, ResourceType } from "./traversal_ops";
|
|
4
4
|
import type {
|
|
5
5
|
ArchiveFormat,
|
|
@@ -198,6 +198,8 @@ export interface GlobalCfgRenderCtx extends GlobalCfgRenderCtxMethods {
|
|
|
198
198
|
readonly data: string | (() => string);
|
|
199
199
|
readonly activeArgs: undefined | string | (() => string | undefined);
|
|
200
200
|
|
|
201
|
+
readonly blockStorage: () => StringifiedJson;
|
|
202
|
+
|
|
201
203
|
// Note: strings below are used because, anyway, using strings is the only way
|
|
202
204
|
// to get data inside the QuickJS context, as it is implemented now. With this
|
|
203
205
|
// approach deserialization can be lazily postponed until it is actually needed.
|