@milaboratories/pl-middle-layer 1.45.5 → 1.46.1
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/index.cjs +58 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/js_render/computable_context.cjs +37 -7
- package/dist/js_render/computable_context.cjs.map +1 -1
- package/dist/js_render/computable_context.d.ts.map +1 -1
- package/dist/js_render/computable_context.js +37 -7
- package/dist/js_render/computable_context.js.map +1 -1
- package/dist/js_render/context.cjs +12 -4
- package/dist/js_render/context.cjs.map +1 -1
- package/dist/js_render/context.d.ts +9 -0
- package/dist/js_render/context.d.ts.map +1 -1
- package/dist/js_render/context.js +12 -4
- package/dist/js_render/context.js.map +1 -1
- package/dist/js_render/index.cjs +1 -1
- package/dist/js_render/index.cjs.map +1 -1
- package/dist/js_render/index.js +1 -1
- package/dist/js_render/index.js.map +1 -1
- package/dist/middle_layer/block.cjs +7 -8
- package/dist/middle_layer/block.cjs.map +1 -1
- package/dist/middle_layer/block.d.ts +4 -4
- package/dist/middle_layer/block.d.ts.map +1 -1
- package/dist/middle_layer/block.js +7 -8
- package/dist/middle_layer/block.js.map +1 -1
- package/dist/middle_layer/block_ctx.cjs +67 -13
- package/dist/middle_layer/block_ctx.cjs.map +1 -1
- package/dist/middle_layer/block_ctx.d.ts +4 -7
- package/dist/middle_layer/block_ctx.d.ts.map +1 -1
- package/dist/middle_layer/block_ctx.js +68 -14
- package/dist/middle_layer/block_ctx.js.map +1 -1
- package/dist/middle_layer/block_ctx_unsafe.cjs +10 -3
- package/dist/middle_layer/block_ctx_unsafe.cjs.map +1 -1
- package/dist/middle_layer/block_ctx_unsafe.d.ts +1 -1
- package/dist/middle_layer/block_ctx_unsafe.d.ts.map +1 -1
- package/dist/middle_layer/block_ctx_unsafe.js +10 -3
- package/dist/middle_layer/block_ctx_unsafe.js.map +1 -1
- package/dist/middle_layer/frontend_path.cjs +1 -0
- package/dist/middle_layer/frontend_path.cjs.map +1 -1
- package/dist/middle_layer/frontend_path.js +1 -0
- package/dist/middle_layer/frontend_path.js.map +1 -1
- package/dist/middle_layer/middle_layer.cjs +1 -0
- package/dist/middle_layer/middle_layer.cjs.map +1 -1
- package/dist/middle_layer/middle_layer.d.ts +1 -1
- package/dist/middle_layer/middle_layer.d.ts.map +1 -1
- package/dist/middle_layer/middle_layer.js +1 -0
- package/dist/middle_layer/middle_layer.js.map +1 -1
- package/dist/middle_layer/project.cjs +75 -28
- package/dist/middle_layer/project.cjs.map +1 -1
- package/dist/middle_layer/project.d.ts +34 -7
- package/dist/middle_layer/project.d.ts.map +1 -1
- package/dist/middle_layer/project.js +76 -29
- package/dist/middle_layer/project.js.map +1 -1
- package/dist/middle_layer/project_overview.cjs +32 -11
- package/dist/middle_layer/project_overview.cjs.map +1 -1
- package/dist/middle_layer/project_overview.d.ts.map +1 -1
- package/dist/middle_layer/project_overview.js +32 -11
- package/dist/middle_layer/project_overview.js.map +1 -1
- package/dist/middle_layer/render.cjs +1 -1
- package/dist/middle_layer/render.cjs.map +1 -1
- package/dist/middle_layer/render.js +1 -1
- package/dist/middle_layer/render.js.map +1 -1
- package/dist/middle_layer/render.test.d.ts.map +1 -1
- package/dist/model/block_storage_helper.cjs +210 -0
- package/dist/model/block_storage_helper.cjs.map +1 -0
- package/dist/model/block_storage_helper.d.ts +98 -0
- package/dist/model/block_storage_helper.d.ts.map +1 -0
- package/dist/model/block_storage_helper.js +153 -0
- package/dist/model/block_storage_helper.js.map +1 -0
- package/dist/model/index.d.ts +2 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/project_helper.cjs +177 -0
- package/dist/model/project_helper.cjs.map +1 -1
- package/dist/model/project_helper.d.ts +110 -1
- package/dist/model/project_helper.d.ts.map +1 -1
- package/dist/model/project_helper.js +178 -1
- package/dist/model/project_helper.js.map +1 -1
- package/dist/model/project_model.cjs +6 -3
- package/dist/model/project_model.cjs.map +1 -1
- package/dist/model/project_model.d.ts +3 -2
- package/dist/model/project_model.d.ts.map +1 -1
- package/dist/model/project_model.js +6 -4
- package/dist/model/project_model.js.map +1 -1
- package/dist/mutator/block-pack/block_pack.cjs +1 -2
- package/dist/mutator/block-pack/block_pack.cjs.map +1 -1
- package/dist/mutator/block-pack/block_pack.d.ts.map +1 -1
- package/dist/mutator/block-pack/block_pack.js +1 -2
- package/dist/mutator/block-pack/block_pack.js.map +1 -1
- package/dist/mutator/block-pack/frontend.cjs +1 -0
- package/dist/mutator/block-pack/frontend.cjs.map +1 -1
- package/dist/mutator/block-pack/frontend.js +1 -0
- package/dist/mutator/block-pack/frontend.js.map +1 -1
- package/dist/mutator/migration.cjs +64 -3
- package/dist/mutator/migration.cjs.map +1 -1
- package/dist/mutator/migration.d.ts.map +1 -1
- package/dist/mutator/migration.js +66 -5
- package/dist/mutator/migration.js.map +1 -1
- package/dist/mutator/project-v3.test.d.ts +2 -0
- package/dist/mutator/project-v3.test.d.ts.map +1 -0
- package/dist/mutator/project.cjs +282 -41
- package/dist/mutator/project.cjs.map +1 -1
- package/dist/mutator/project.d.ts +77 -12
- package/dist/mutator/project.d.ts.map +1 -1
- package/dist/mutator/project.js +283 -42
- package/dist/mutator/project.js.map +1 -1
- package/dist/pool/result_pool.cjs +9 -6
- package/dist/pool/result_pool.cjs.map +1 -1
- package/dist/pool/result_pool.d.ts.map +1 -1
- package/dist/pool/result_pool.js +9 -6
- package/dist/pool/result_pool.js.map +1 -1
- package/package.json +15 -15
- package/src/js_render/computable_context.ts +37 -7
- package/src/js_render/context.ts +12 -5
- package/src/js_render/index.ts +1 -1
- package/src/middle_layer/block.ts +13 -14
- package/src/middle_layer/block_ctx.ts +70 -23
- package/src/middle_layer/block_ctx_unsafe.ts +11 -4
- package/src/middle_layer/middle_layer.ts +2 -1
- package/src/middle_layer/project.ts +86 -40
- package/src/middle_layer/project_overview.ts +44 -20
- package/src/middle_layer/render.test.ts +1 -1
- package/src/middle_layer/render.ts +1 -1
- package/src/model/block_storage_helper.ts +213 -0
- package/src/model/index.ts +2 -1
- package/src/model/project_helper.ts +249 -1
- package/src/model/project_model.ts +9 -5
- package/src/mutator/block-pack/block_pack.ts +1 -2
- package/src/mutator/migration.ts +79 -6
- package/src/mutator/project-v3.test.ts +280 -0
- package/src/mutator/project.test.ts +27 -27
- package/src/mutator/project.ts +351 -68
- package/src/pool/result_pool.ts +11 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result_pool.d.ts","sourceRoot":"","sources":["../../src/pool/result_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EACV,MAAM,EACN,OAAO,EACP,WAAW,EACX,cAAc,EACd,KAAK,EACL,gBAAgB,EAEhB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAe7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS9C,0CAA0C;AAC1C,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,CAAC;AAYxD,MAAM,WAAW,wBAAwB,CAAC,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,cAAe,SAAQ,MAAM;IAC5C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;AAED,qBAAa,UAAU;IAGnB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHzB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAU;IAC5C,OAAO;IAuBA,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,WAA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,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAoBhE,iBAAiB,IAAI,wBAAwB,CAClD,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CACjE;IAuDM,QAAQ,IAAI,wBAAwB,CAAC,WAAW,CAAC;IAgDjD,gBAAgB,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,EAAE;WAsBtD,MAAM,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU;CA0CjG"}
|
package/dist/pool/result_pool.js
CHANGED
|
@@ -41,13 +41,13 @@ class ResultPool {
|
|
|
41
41
|
result = block.staging?.results?.get(exportName)?.spec;
|
|
42
42
|
if (result !== undefined)
|
|
43
43
|
return result;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
// Note: Don't mark unstable when staging is absent - it may be intentionally skipped
|
|
45
|
+
// for v3 blocks with undefined prerunArgs.
|
|
46
|
+
if (block.staging !== undefined && !block.staging.locked)
|
|
47
47
|
this.ctx.markUnstable(`staging_not_locked:${blockId}`);
|
|
48
48
|
else if (block.prod !== undefined && !block.prod.locked)
|
|
49
49
|
this.ctx.markUnstable(`prod_not_locked:${blockId}`);
|
|
50
|
-
// if prod is
|
|
50
|
+
// if neither prod nor staging is present, returned undefined value is considered stable
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
53
|
getDataOrErrorByRef(blockId, exportName) {
|
|
@@ -168,8 +168,9 @@ class ResultPool {
|
|
|
168
168
|
exportsProcessed.add(exportName);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
// Note: Don't mark unstable when staging is absent - it may be intentionally skipped
|
|
172
|
+
// for v3 blocks with undefined prerunArgs. If prod exists, use it; if neither exists,
|
|
173
|
+
// the block simply has no specs to contribute.
|
|
173
174
|
if (block.prod !== undefined) {
|
|
174
175
|
if (!block.prod.locked)
|
|
175
176
|
markUnstable(`prod_not_locked:${blockId}`);
|
|
@@ -234,8 +235,10 @@ class ResultPool {
|
|
|
234
235
|
field: projectFieldName(blockInfo.id, 'stagingCtx'),
|
|
235
236
|
ignoreError: true,
|
|
236
237
|
pureFieldErrorToUndefined: true,
|
|
238
|
+
stableIfNotFound: true,
|
|
237
239
|
}) !== undefined, prj.traverseOrError({
|
|
238
240
|
field: projectFieldName(blockInfo.id, 'stagingUiCtx'),
|
|
241
|
+
stableIfNotFound: true,
|
|
239
242
|
}));
|
|
240
243
|
blocks.set(blockInfo.id, { info: blockInfo, prod, staging });
|
|
241
244
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result_pool.js","sources":["../../src/pool/result_pool.ts"],"sourcesContent":["import type { ComputableCtx } from '@milaboratories/computable';\nimport type { PlTreeEntry, PlTreeNodeAccessor } from '@milaboratories/pl-tree';\nimport type {\n Option,\n PObject,\n PObjectSpec,\n PSpecPredicate,\n PlRef,\n ResultCollection,\n ResultPoolEntry,\n ValueOrError } from '@platforma-sdk/model';\nimport {\n executePSpecPredicate,\n mapValueInVOE,\n} from '@platforma-sdk/model';\nimport { notEmpty } from '@milaboratories/ts-helpers';\nimport { outputRef } from '../model/args';\nimport type {\n Block,\n ProjectStructure } from '../model/project_model';\nimport {\n ProjectStructureKey,\n projectFieldName,\n} from '../model/project_model';\nimport { allBlocks, stagingGraph } from '../model/project_model_util';\nimport type { Optional } from 'utility-types';\nimport { deriveGlobalPObjectId } from './data';\nimport type {\n RawPObjectCollection,\n RawPObjectEntry } from './p_object_collection';\nimport {\n parseRawPObjectCollection,\n} from './p_object_collection';\n\n/** All exported results are addressed */\nexport type ResultKey = Pick<PlRef, 'blockId' | 'name'>;\n\n/** Represents current information about particular block */\ninterface PoolBlock {\n /** Meta information from the project structure */\n readonly info: Block;\n /** Production ctx, if exists. If block's prod was executed, this field is guaranteed to be defined. */\n readonly prod?: RawPObjectCollection;\n /** Staging ctx, if exists. If staging was rendered, this field is guaranteed to be defined. */\n readonly staging?: RawPObjectCollection;\n}\n\nexport interface ExtendedResultCollection<T> extends ResultCollection<T> {\n readonly instabilityMarker: string | undefined;\n}\n\nexport interface ExtendedOption extends Option {\n readonly spec: PObjectSpec;\n}\n\nexport class ResultPool {\n private readonly allSpecsAvailable: boolean;\n private constructor(\n private readonly ctx: ComputableCtx,\n private readonly blocks: Map<string, PoolBlock>,\n ) {\n let allSpecsAvailable = true;\n outer: for (const block of blocks.values()) {\n for (const ctx of [block.prod, block.staging])\n if (ctx !== undefined) {\n if (!ctx.locked) {\n allSpecsAvailable = false;\n break outer;\n }\n for (const result of ctx.results.values()) {\n if (result.spec === undefined) {\n allSpecsAvailable = false;\n break outer;\n }\n }\n }\n }\n this.allSpecsAvailable = allSpecsAvailable;\n }\n\n public getSpecByRef(blockId: string, exportName: string): PObjectSpec | undefined {\n const block = this.blocks.get(blockId);\n if (block === undefined) return undefined;\n let result = block.prod?.results?.get(exportName)?.spec;\n if (result !== undefined) return result;\n result = block.staging?.results?.get(exportName)?.spec;\n if (result !== undefined) return result;\n if (block.staging === undefined) this.ctx.markUnstable(`staging_not_rendered:${blockId}`);\n else if (!block.staging.locked) this.ctx.markUnstable(`staging_not_locked:${blockId}`);\n else if (block.prod !== undefined && !block.prod.locked)\n this.ctx.markUnstable(`prod_not_locked:${blockId}`);\n // if prod is absent, returned undefined value is considered stable\n return undefined;\n }\n\n public getDataOrErrorByRef(\n blockId: string,\n exportName: string,\n ): ValueOrError<PObject<PlTreeNodeAccessor>, Error> | undefined {\n const block = this.blocks.get(blockId);\n if (block === undefined) return undefined;\n const result = block.prod?.results?.get(exportName);\n const data = result?.data?.();\n if (result !== undefined && result.spec !== undefined && data !== undefined)\n return mapValueInVOE(data, (value) => ({\n id: deriveGlobalPObjectId(blockId, exportName),\n spec: result.spec!,\n data: value,\n }));\n if (result !== undefined) this.ctx.markUnstable(`no_data:${blockId}:${exportName}`);\n if (block.prod !== undefined && !block.prod.locked)\n this.ctx.markUnstable(`prod_not_locked:${blockId}`);\n // if prod is absent, returned undefined value is considered stable\n return undefined;\n }\n\n public getDataByRef(\n blockId: string,\n exportName: string,\n ): PObject<PlTreeNodeAccessor> | undefined {\n const res = this.getDataOrErrorByRef(blockId, exportName);\n if (res === undefined || !res.ok) return undefined;\n return res.value;\n }\n\n public getData(): ExtendedResultCollection<PObject<PlTreeNodeAccessor>> {\n const resultWithErrors = this.getDataWithErrors();\n const entries: ResultPoolEntry<PObject<PlTreeNodeAccessor>>[] = [];\n for (const res of resultWithErrors.entries)\n if (res.obj.id !== undefined && res.obj.data.ok)\n entries.push({\n ref: res.ref,\n obj: {\n id: res.obj.id,\n spec: res.obj.spec,\n data: res.obj.data.value,\n },\n });\n return {\n entries,\n isComplete: resultWithErrors.isComplete,\n instabilityMarker: resultWithErrors.instabilityMarker,\n };\n }\n\n public getDataWithErrors(): ExtendedResultCollection<\n Optional<PObject<ValueOrError<PlTreeNodeAccessor, Error>>, 'id'>\n > {\n const entries: ResultPoolEntry<\n Optional<PObject<ValueOrError<PlTreeNodeAccessor, Error>>, 'id'>\n >[] = [];\n let isComplete = true;\n\n let instabilityMarker: string | undefined = undefined;\n const markUnstable = (marker: string) => {\n if (instabilityMarker === undefined) instabilityMarker = marker;\n isComplete = false;\n };\n\n const tryAddEntry = (blockId: string, exportName: string, result: RawPObjectEntry) => {\n if (result.spec !== undefined && result.hasData === true && result.data !== undefined) {\n const data = result.data();\n if (data !== undefined) {\n entries.push({\n ref: outputRef(blockId, exportName),\n obj: {\n id: data.ok ? deriveGlobalPObjectId(blockId, exportName) : undefined,\n spec: result.spec,\n data,\n },\n });\n } else markUnstable(`no_data:${blockId}:${exportName}`); // because data will eventually be resolved\n }\n };\n\n for (const [blockId, block] of this.blocks) {\n const exportsProcessed = new Set<string>();\n\n if (block.prod !== undefined) {\n if (!block.prod.locked) markUnstable(`prod_not_locked:${blockId}`);\n for (const [exportName, result] of block.prod.results) {\n // any signal that this export will be (or already is) present in the prod\n // will prevent adding it from staging\n exportsProcessed.add(exportName);\n tryAddEntry(blockId, exportName, result);\n }\n }\n\n if (block.staging !== undefined) {\n if (!block.staging.locked) markUnstable(`staging_not_locked:${blockId}`);\n\n for (const [exportName, result] of block.staging.results) {\n // trying to add something only if result is absent in prod\n if (exportsProcessed.has(exportName)) continue;\n tryAddEntry(blockId, exportName, result);\n }\n }\n }\n\n return { entries, isComplete, instabilityMarker };\n }\n\n public getSpecs(): ExtendedResultCollection<PObjectSpec> {\n const entries: ResultPoolEntry<PObjectSpec>[] = [];\n\n let isComplete = true;\n\n let instabilityMarker: string | undefined = undefined;\n const markUnstable = (marker: string) => {\n if (instabilityMarker === undefined) instabilityMarker = marker;\n isComplete = false;\n };\n\n for (const [blockId, block] of this.blocks) {\n const exportsProcessed = new Set<string>();\n if (block.staging !== undefined) {\n if (!block.staging.locked) markUnstable(`staging_not_locked:${blockId}`);\n\n for (const [exportName, result] of block.staging.results)\n if (result.spec !== undefined) {\n entries.push({\n ref: outputRef(blockId, exportName),\n obj: result.spec,\n });\n exportsProcessed.add(exportName);\n }\n } else markUnstable(`staging_not_rendered:${blockId}`); // because staging will be inevitably rendered soon\n\n if (block.prod !== undefined) {\n if (!block.prod.locked) markUnstable(`prod_not_locked:${blockId}`);\n for (const [exportName, result] of block.prod.results) {\n // staging have higher priority when we are interested in specs\n if (exportsProcessed.has(exportName)) continue;\n\n if (result.spec !== undefined) {\n entries.push({\n ref: outputRef(blockId, exportName),\n obj: result.spec,\n });\n }\n }\n }\n }\n\n return { entries, isComplete, instabilityMarker };\n }\n\n public calculateOptions(predicate: PSpecPredicate): ExtendedOption[] {\n const found: ExtendedOption[] = [];\n for (const block of this.blocks.values()) {\n const exportsChecked = new Set<string>();\n const addToFound = (ctx: RawPObjectCollection) => {\n for (const [exportName, result] of ctx.results) {\n if (exportsChecked.has(exportName) || result.spec === undefined) continue;\n exportsChecked.add(exportName);\n if (executePSpecPredicate(predicate, result.spec))\n found.push({\n label: block.info.label + ' / ' + exportName,\n ref: outputRef(block.info.id, exportName),\n spec: result.spec,\n });\n }\n };\n if (block.staging !== undefined) addToFound(block.staging);\n if (block.prod !== undefined) addToFound(block.prod);\n }\n return found;\n }\n\n public static create(ctx: ComputableCtx, prjEntry: PlTreeEntry, rootBlockId: string): ResultPool {\n const prj = ctx.accessor(prjEntry).node();\n\n const structure = notEmpty(prj.getKeyValueAsJson<ProjectStructure>(ProjectStructureKey));\n const graph = stagingGraph(structure);\n const targetBlocks = graph.traverseIds('upstream', rootBlockId);\n\n const blocks = new Map<string, PoolBlock>();\n\n for (const blockInfo of allBlocks(structure)) {\n if (!targetBlocks.has(blockInfo.id)) continue;\n\n const prod = loadCtx(\n prj.traverse({\n field: projectFieldName(blockInfo.id, 'prodCtx'),\n ignoreError: true,\n pureFieldErrorToUndefined: true,\n stableIfNotFound: true,\n }) !== undefined,\n prj.traverseOrError({\n field: projectFieldName(blockInfo.id, 'prodUiCtx'),\n stableIfNotFound: true,\n }),\n );\n const staging = loadCtx(\n prj.traverse({\n field: projectFieldName(blockInfo.id, 'stagingCtx'),\n ignoreError: true,\n pureFieldErrorToUndefined: true,\n }) !== undefined,\n prj.traverseOrError({\n field: projectFieldName(blockInfo.id, 'stagingUiCtx'),\n }),\n );\n\n blocks.set(blockInfo.id, { info: blockInfo, prod, staging });\n }\n\n return new ResultPool(ctx, blocks);\n }\n}\n\n/** Loads single BContext data */\nfunction loadCtx(\n calculated: boolean,\n ctxAccessor: ValueOrError<PlTreeNodeAccessor, Error> | undefined,\n): RawPObjectCollection | undefined {\n if (ctxAccessor === undefined) {\n if (calculated)\n // this case defines the situation when ctx holder is present, but the ctx itself is\n // not yet available, to simplify the logic we make this situation indistinguishable\n // from empty unlocked cotext\n return { locked: false, results: new Map() };\n else return undefined;\n }\n\n if (ctxAccessor.ok) return parseRawPObjectCollection(ctxAccessor.value, false, true);\n else return undefined;\n}\n"],"names":[],"mappings":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S,OAAO,CACd,UAAmB,EACnB,WAAgE,EAAA;AAEhE,IAAA,IAAI,WAAW,KAAK,SAAS,EAAE;AAC7B,QAAA,IAAI,UAAU;;;;YAIZ,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE;;AACzC,YAAA,OAAO,SAAS;IACvB;IAEA,IAAI,WAAW,CAAC,EAAE;QAAE,OAAO,yBAAyB,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;;AAC/E,QAAA,OAAO,SAAS;AACvB;;;;"}
|
|
1
|
+
{"version":3,"file":"result_pool.js","sources":["../../src/pool/result_pool.ts"],"sourcesContent":["import type { ComputableCtx } from '@milaboratories/computable';\nimport type { PlTreeEntry, PlTreeNodeAccessor } from '@milaboratories/pl-tree';\nimport type {\n Option,\n PObject,\n PObjectSpec,\n PSpecPredicate,\n PlRef,\n ResultCollection,\n ResultPoolEntry,\n ValueOrError } from '@platforma-sdk/model';\nimport {\n executePSpecPredicate,\n mapValueInVOE,\n} from '@platforma-sdk/model';\nimport { notEmpty } from '@milaboratories/ts-helpers';\nimport { outputRef } from '../model/args';\nimport type {\n Block,\n ProjectStructure } from '../model/project_model';\nimport {\n ProjectStructureKey,\n projectFieldName,\n} from '../model/project_model';\nimport { allBlocks, stagingGraph } from '../model/project_model_util';\nimport type { Optional } from 'utility-types';\nimport { deriveGlobalPObjectId } from './data';\nimport type {\n RawPObjectCollection,\n RawPObjectEntry } from './p_object_collection';\nimport {\n parseRawPObjectCollection,\n} from './p_object_collection';\n\n/** All exported results are addressed */\nexport type ResultKey = Pick<PlRef, 'blockId' | 'name'>;\n\n/** Represents current information about particular block */\ninterface PoolBlock {\n /** Meta information from the project structure */\n readonly info: Block;\n /** Production ctx, if exists. If block's prod was executed, this field is guaranteed to be defined. */\n readonly prod?: RawPObjectCollection;\n /** Staging ctx, if exists. If staging was rendered, this field is guaranteed to be defined. */\n readonly staging?: RawPObjectCollection;\n}\n\nexport interface ExtendedResultCollection<T> extends ResultCollection<T> {\n readonly instabilityMarker: string | undefined;\n}\n\nexport interface ExtendedOption extends Option {\n readonly spec: PObjectSpec;\n}\n\nexport class ResultPool {\n private readonly allSpecsAvailable: boolean;\n private constructor(\n private readonly ctx: ComputableCtx,\n private readonly blocks: Map<string, PoolBlock>,\n ) {\n let allSpecsAvailable = true;\n outer: for (const block of blocks.values()) {\n for (const ctx of [block.prod, block.staging])\n if (ctx !== undefined) {\n if (!ctx.locked) {\n allSpecsAvailable = false;\n break outer;\n }\n for (const result of ctx.results.values()) {\n if (result.spec === undefined) {\n allSpecsAvailable = false;\n break outer;\n }\n }\n }\n }\n this.allSpecsAvailable = allSpecsAvailable;\n }\n\n public getSpecByRef(blockId: string, exportName: string): PObjectSpec | undefined {\n const block = this.blocks.get(blockId);\n if (block === undefined) return undefined;\n let result = block.prod?.results?.get(exportName)?.spec;\n if (result !== undefined) return result;\n result = block.staging?.results?.get(exportName)?.spec;\n if (result !== undefined) return result;\n // Note: Don't mark unstable when staging is absent - it may be intentionally skipped\n // for v3 blocks with undefined prerunArgs.\n if (block.staging !== undefined && !block.staging.locked)\n this.ctx.markUnstable(`staging_not_locked:${blockId}`);\n else if (block.prod !== undefined && !block.prod.locked)\n this.ctx.markUnstable(`prod_not_locked:${blockId}`);\n // if neither prod nor staging is present, returned undefined value is considered stable\n return undefined;\n }\n\n public getDataOrErrorByRef(\n blockId: string,\n exportName: string,\n ): ValueOrError<PObject<PlTreeNodeAccessor>, Error> | undefined {\n const block = this.blocks.get(blockId);\n if (block === undefined) return undefined;\n const result = block.prod?.results?.get(exportName);\n const data = result?.data?.();\n if (result !== undefined && result.spec !== undefined && data !== undefined)\n return mapValueInVOE(data, (value) => ({\n id: deriveGlobalPObjectId(blockId, exportName),\n spec: result.spec!,\n data: value,\n }));\n if (result !== undefined) this.ctx.markUnstable(`no_data:${blockId}:${exportName}`);\n if (block.prod !== undefined && !block.prod.locked)\n this.ctx.markUnstable(`prod_not_locked:${blockId}`);\n // if prod is absent, returned undefined value is considered stable\n return undefined;\n }\n\n public getDataByRef(\n blockId: string,\n exportName: string,\n ): PObject<PlTreeNodeAccessor> | undefined {\n const res = this.getDataOrErrorByRef(blockId, exportName);\n if (res === undefined || !res.ok) return undefined;\n return res.value;\n }\n\n public getData(): ExtendedResultCollection<PObject<PlTreeNodeAccessor>> {\n const resultWithErrors = this.getDataWithErrors();\n const entries: ResultPoolEntry<PObject<PlTreeNodeAccessor>>[] = [];\n for (const res of resultWithErrors.entries)\n if (res.obj.id !== undefined && res.obj.data.ok)\n entries.push({\n ref: res.ref,\n obj: {\n id: res.obj.id,\n spec: res.obj.spec,\n data: res.obj.data.value,\n },\n });\n return {\n entries,\n isComplete: resultWithErrors.isComplete,\n instabilityMarker: resultWithErrors.instabilityMarker,\n };\n }\n\n public getDataWithErrors(): ExtendedResultCollection<\n Optional<PObject<ValueOrError<PlTreeNodeAccessor, Error>>, 'id'>\n > {\n const entries: ResultPoolEntry<\n Optional<PObject<ValueOrError<PlTreeNodeAccessor, Error>>, 'id'>\n >[] = [];\n let isComplete = true;\n\n let instabilityMarker: string | undefined = undefined;\n const markUnstable = (marker: string) => {\n if (instabilityMarker === undefined) instabilityMarker = marker;\n isComplete = false;\n };\n\n const tryAddEntry = (blockId: string, exportName: string, result: RawPObjectEntry) => {\n if (result.spec !== undefined && result.hasData === true && result.data !== undefined) {\n const data = result.data();\n if (data !== undefined) {\n entries.push({\n ref: outputRef(blockId, exportName),\n obj: {\n id: data.ok ? deriveGlobalPObjectId(blockId, exportName) : undefined,\n spec: result.spec,\n data,\n },\n });\n } else markUnstable(`no_data:${blockId}:${exportName}`); // because data will eventually be resolved\n }\n };\n\n for (const [blockId, block] of this.blocks) {\n const exportsProcessed = new Set<string>();\n\n if (block.prod !== undefined) {\n if (!block.prod.locked) markUnstable(`prod_not_locked:${blockId}`);\n for (const [exportName, result] of block.prod.results) {\n // any signal that this export will be (or already is) present in the prod\n // will prevent adding it from staging\n exportsProcessed.add(exportName);\n tryAddEntry(blockId, exportName, result);\n }\n }\n\n if (block.staging !== undefined) {\n if (!block.staging.locked) markUnstable(`staging_not_locked:${blockId}`);\n\n for (const [exportName, result] of block.staging.results) {\n // trying to add something only if result is absent in prod\n if (exportsProcessed.has(exportName)) continue;\n tryAddEntry(blockId, exportName, result);\n }\n }\n }\n\n return { entries, isComplete, instabilityMarker };\n }\n\n public getSpecs(): ExtendedResultCollection<PObjectSpec> {\n const entries: ResultPoolEntry<PObjectSpec>[] = [];\n\n let isComplete = true;\n\n let instabilityMarker: string | undefined = undefined;\n const markUnstable = (marker: string) => {\n if (instabilityMarker === undefined) instabilityMarker = marker;\n isComplete = false;\n };\n\n for (const [blockId, block] of this.blocks) {\n const exportsProcessed = new Set<string>();\n if (block.staging !== undefined) {\n if (!block.staging.locked) markUnstable(`staging_not_locked:${blockId}`);\n\n for (const [exportName, result] of block.staging.results)\n if (result.spec !== undefined) {\n entries.push({\n ref: outputRef(blockId, exportName),\n obj: result.spec,\n });\n exportsProcessed.add(exportName);\n }\n }\n // Note: Don't mark unstable when staging is absent - it may be intentionally skipped\n // for v3 blocks with undefined prerunArgs. If prod exists, use it; if neither exists,\n // the block simply has no specs to contribute.\n\n if (block.prod !== undefined) {\n if (!block.prod.locked) markUnstable(`prod_not_locked:${blockId}`);\n for (const [exportName, result] of block.prod.results) {\n // staging have higher priority when we are interested in specs\n if (exportsProcessed.has(exportName)) continue;\n\n if (result.spec !== undefined) {\n entries.push({\n ref: outputRef(blockId, exportName),\n obj: result.spec,\n });\n }\n }\n }\n }\n\n return { entries, isComplete, instabilityMarker };\n }\n\n public calculateOptions(predicate: PSpecPredicate): ExtendedOption[] {\n const found: ExtendedOption[] = [];\n for (const block of this.blocks.values()) {\n const exportsChecked = new Set<string>();\n const addToFound = (ctx: RawPObjectCollection) => {\n for (const [exportName, result] of ctx.results) {\n if (exportsChecked.has(exportName) || result.spec === undefined) continue;\n exportsChecked.add(exportName);\n if (executePSpecPredicate(predicate, result.spec))\n found.push({\n label: block.info.label + ' / ' + exportName,\n ref: outputRef(block.info.id, exportName),\n spec: result.spec,\n });\n }\n };\n if (block.staging !== undefined) addToFound(block.staging);\n if (block.prod !== undefined) addToFound(block.prod);\n }\n return found;\n }\n\n public static create(ctx: ComputableCtx, prjEntry: PlTreeEntry, rootBlockId: string): ResultPool {\n const prj = ctx.accessor(prjEntry).node();\n\n const structure = notEmpty(prj.getKeyValueAsJson<ProjectStructure>(ProjectStructureKey));\n const graph = stagingGraph(structure);\n const targetBlocks = graph.traverseIds('upstream', rootBlockId);\n\n const blocks = new Map<string, PoolBlock>();\n\n for (const blockInfo of allBlocks(structure)) {\n if (!targetBlocks.has(blockInfo.id)) continue;\n\n const prod = loadCtx(\n prj.traverse({\n field: projectFieldName(blockInfo.id, 'prodCtx'),\n ignoreError: true,\n pureFieldErrorToUndefined: true,\n stableIfNotFound: true,\n }) !== undefined,\n prj.traverseOrError({\n field: projectFieldName(blockInfo.id, 'prodUiCtx'),\n stableIfNotFound: true,\n }),\n );\n const staging = loadCtx(\n prj.traverse({\n field: projectFieldName(blockInfo.id, 'stagingCtx'),\n ignoreError: true,\n pureFieldErrorToUndefined: true,\n stableIfNotFound: true,\n }) !== undefined,\n prj.traverseOrError({\n field: projectFieldName(blockInfo.id, 'stagingUiCtx'),\n stableIfNotFound: true,\n }),\n );\n\n blocks.set(blockInfo.id, { info: blockInfo, prod, staging });\n }\n\n return new ResultPool(ctx, blocks);\n }\n}\n\n/** Loads single BContext data */\nfunction loadCtx(\n calculated: boolean,\n ctxAccessor: ValueOrError<PlTreeNodeAccessor, Error> | undefined,\n): RawPObjectCollection | undefined {\n if (ctxAccessor === undefined) {\n if (calculated)\n // this case defines the situation when ctx holder is present, but the ctx itself is\n // not yet available, to simplify the logic we make this situation indistinguishable\n // from empty unlocked cotext\n return { locked: false, results: new Map() };\n else return undefined;\n }\n\n if (ctxAccessor.ok) return parseRawPObjectCollection(ctxAccessor.value, false, true);\n else return undefined;\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;AAC7B,QAAA,IAAI,UAAU;;;;YAIZ,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE;;AACzC,YAAA,OAAO,SAAS;IACvB;IAEA,IAAI,WAAW,CAAC,EAAE;QAAE,OAAO,yBAAyB,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;;AAC/E,QAAA,OAAO,SAAS;AACvB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.1",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.19.0"
|
|
@@ -33,22 +33,22 @@
|
|
|
33
33
|
"zod": "~3.23.8",
|
|
34
34
|
"remeda": "^2.28.0",
|
|
35
35
|
"@milaboratories/pl-http": "1.2.0",
|
|
36
|
-
"@milaboratories/
|
|
36
|
+
"@milaboratories/computable": "2.8.1",
|
|
37
|
+
"@platforma-sdk/block-tools": "2.6.30",
|
|
37
38
|
"@milaboratories/resolve-helper": "1.1.1",
|
|
38
|
-
"@milaboratories/
|
|
39
|
-
"@
|
|
40
|
-
"@milaboratories/pl-model-common": "1.
|
|
41
|
-
"@milaboratories/pl-
|
|
42
|
-
"@milaboratories/pl-
|
|
43
|
-
"@milaboratories/pl-
|
|
44
|
-
"@
|
|
45
|
-
"@milaboratories/
|
|
46
|
-
"@platforma-sdk/model": "1.51.9",
|
|
47
|
-
"@milaboratories/pl-config": "1.7.9",
|
|
48
|
-
"@milaboratories/pl-errors": "1.1.52",
|
|
49
|
-
"@milaboratories/pf-driver": "1.0.23",
|
|
39
|
+
"@milaboratories/pl-drivers": "1.11.38",
|
|
40
|
+
"@milaboratories/pl-client": "2.16.21",
|
|
41
|
+
"@milaboratories/pl-model-common": "1.24.0",
|
|
42
|
+
"@milaboratories/pl-model-middle-layer": "1.10.0",
|
|
43
|
+
"@milaboratories/pl-model-backend": "1.1.38",
|
|
44
|
+
"@milaboratories/pl-tree": "1.8.29",
|
|
45
|
+
"@platforma-sdk/model": "1.52.0",
|
|
46
|
+
"@milaboratories/pl-config": "1.7.10",
|
|
50
47
|
"@platforma-sdk/workflow-tengo": "5.8.0",
|
|
51
|
-
"@milaboratories/
|
|
48
|
+
"@milaboratories/ts-helpers": "1.6.0",
|
|
49
|
+
"@milaboratories/pl-deployments": "2.15.3",
|
|
50
|
+
"@milaboratories/pl-errors": "1.1.53",
|
|
51
|
+
"@milaboratories/pf-driver": "1.0.24"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"semver": "^7.7.2",
|
|
@@ -499,17 +499,33 @@ implements JsRenderInternal.GlobalCfgRenderCtxMethods<string, string> {
|
|
|
499
499
|
vm.newFunction(name, fn).consume((fnh) => vm.setProp(configCtx, name + '__internal__', fnh));
|
|
500
500
|
};
|
|
501
501
|
|
|
502
|
+
// Check if this is a v1/v2 block (requiresModelAPIVersion !== 2)
|
|
503
|
+
// For v1/v2 blocks, state is {args, uiState} and we need to inject uiState separately
|
|
504
|
+
const isLegacyBlock = !checkBlockFlag(this.featureFlags, 'requiresModelAPIVersion', 2);
|
|
505
|
+
|
|
506
|
+
// Helper to extract uiState from legacy state format {args, uiState}
|
|
507
|
+
const extractUiState = (stateJson: string | undefined): string => {
|
|
508
|
+
if (!stateJson) return '{}';
|
|
509
|
+
try {
|
|
510
|
+
const parsed = JSON.parse(stateJson);
|
|
511
|
+
return JSON.stringify(parsed?.uiState ?? {});
|
|
512
|
+
} catch {
|
|
513
|
+
return '{}';
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
|
|
502
517
|
if (checkBlockFlag(this.featureFlags, 'supportsLazyState')) {
|
|
503
518
|
// injecting lazy state functions
|
|
504
519
|
exportCtxFunction('args', () => {
|
|
505
520
|
if (this.computableCtx === undefined)
|
|
506
521
|
throw new Error(`Add dummy call to ctx.args outside the future lambda. Can't be directly used in this context.`);
|
|
507
|
-
|
|
522
|
+
const args = this.blockCtx.args(this.computableCtx);
|
|
523
|
+
return args === undefined ? vm.undefined : vm.newString(args);
|
|
508
524
|
});
|
|
509
|
-
exportCtxFunction('
|
|
525
|
+
exportCtxFunction('data', () => {
|
|
510
526
|
if (this.computableCtx === undefined)
|
|
511
|
-
throw new Error(`Add dummy call to ctx.
|
|
512
|
-
return vm.newString(this.blockCtx.
|
|
527
|
+
throw new Error(`Add dummy call to ctx.state outside the future lambda. Can't be directly used in this context.`);
|
|
528
|
+
return vm.newString(this.blockCtx.data(this.computableCtx) ?? '{}');
|
|
513
529
|
});
|
|
514
530
|
exportCtxFunction('activeArgs', () => {
|
|
515
531
|
if (this.computableCtx === undefined)
|
|
@@ -517,14 +533,28 @@ implements JsRenderInternal.GlobalCfgRenderCtxMethods<string, string> {
|
|
|
517
533
|
const res = this.blockCtx.activeArgs(this.computableCtx);
|
|
518
534
|
return res === undefined ? vm.undefined : vm.newString(res);
|
|
519
535
|
});
|
|
536
|
+
// For v1/v2 blocks, also inject uiState (extracted from state.uiState)
|
|
537
|
+
if (isLegacyBlock) {
|
|
538
|
+
exportCtxFunction('uiState', () => {
|
|
539
|
+
if (this.computableCtx === undefined)
|
|
540
|
+
throw new Error(`Add dummy call to ctx.uiState outside the future lambda. Can't be directly used in this context.`);
|
|
541
|
+
return vm.newString(extractUiState(this.blockCtx.data(this.computableCtx)));
|
|
542
|
+
});
|
|
543
|
+
}
|
|
520
544
|
} else {
|
|
521
545
|
const args = this.blockCtx.args(this.computableCtx!);
|
|
522
546
|
const activeArgs = this.blockCtx.activeArgs(this.computableCtx!);
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
547
|
+
const data = this.blockCtx.data(this.computableCtx!);
|
|
548
|
+
if (args !== undefined) {
|
|
549
|
+
vm.setProp(configCtx, 'args', localScope.manage(vm.newString(args)));
|
|
550
|
+
}
|
|
551
|
+
vm.setProp(configCtx, 'data', localScope.manage(vm.newString(data ?? '{}')));
|
|
526
552
|
if (activeArgs !== undefined)
|
|
527
553
|
vm.setProp(configCtx, 'activeArgs', localScope.manage(vm.newString(activeArgs)));
|
|
554
|
+
// For v1/v2 blocks, also inject uiState (extracted from state.uiState)
|
|
555
|
+
if (isLegacyBlock) {
|
|
556
|
+
vm.setProp(configCtx, 'uiState', localScope.manage(vm.newString(extractUiState(data))));
|
|
557
|
+
}
|
|
528
558
|
}
|
|
529
559
|
|
|
530
560
|
//
|
package/src/js_render/context.ts
CHANGED
|
@@ -51,6 +51,15 @@ export class JsExecutionContext {
|
|
|
51
51
|
|
|
52
52
|
public readonly computableHelper: ComputableContextHelper | undefined;
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new JS execution context.
|
|
56
|
+
*
|
|
57
|
+
* @param scope - QuickJS scope for memory management
|
|
58
|
+
* @param vm - QuickJS VM context
|
|
59
|
+
* @param deadlineSetter - Function to set execution deadline
|
|
60
|
+
* @param featureFlags - Block feature flags
|
|
61
|
+
* @param computableEnv - Optional reactive computable environment (for outputs, inputsValid, etc.)
|
|
62
|
+
*/
|
|
54
63
|
constructor(
|
|
55
64
|
public readonly scope: Scope,
|
|
56
65
|
public readonly vm: QuickJSContext,
|
|
@@ -237,12 +246,10 @@ export class JsExecutionContext {
|
|
|
237
246
|
this.exportObjectUniversal(JsRenderInternal.GlobalCfgRenderCtxFeatureFlags, localScope),
|
|
238
247
|
);
|
|
239
248
|
|
|
240
|
-
//
|
|
241
|
-
|
|
242
|
-
//
|
|
243
|
-
|
|
244
|
-
if (this.computableHelper !== undefined)
|
|
249
|
+
// Inject context values from computableHelper (reactive context for outputs, inputsValid, etc.)
|
|
250
|
+
if (this.computableHelper !== undefined) {
|
|
245
251
|
this.computableHelper.injectCtx(configCtx);
|
|
252
|
+
}
|
|
246
253
|
|
|
247
254
|
//
|
|
248
255
|
// Creating global variable inside the vm
|
package/src/js_render/index.ts
CHANGED
|
@@ -180,7 +180,7 @@ export function executeSingleLambda(
|
|
|
180
180
|
// Initializing the model
|
|
181
181
|
rCtx.evaluateBundle(code.content);
|
|
182
182
|
|
|
183
|
-
// Running the lambda
|
|
183
|
+
// Running the lambda with arguments (e.g., state for args(), args for enrichmentTargets())
|
|
184
184
|
return rCtx.importObjectUniversal(rCtx.runCallback(fh.handle, ...args));
|
|
185
185
|
} finally {
|
|
186
186
|
scope.dispose();
|
|
@@ -12,43 +12,42 @@ import { blockArgsAuthorKey } from '../model/project_model';
|
|
|
12
12
|
import { ifNotUndef } from '../cfg_render/util';
|
|
13
13
|
import type { MiddleLayerEnvironment } from './middle_layer';
|
|
14
14
|
import { getBlockPackInfo } from './util';
|
|
15
|
-
import type { AuthorMarker,
|
|
15
|
+
import type { AuthorMarker, BlockStateInternalV3 } from '@milaboratories/pl-model-middle-layer';
|
|
16
16
|
import { computableFromCfgOrRF } from './render';
|
|
17
17
|
import { resourceIdToString } from '@milaboratories/pl-client';
|
|
18
18
|
import { deepFreeze } from '@milaboratories/ts-helpers';
|
|
19
19
|
import { extractCodeWithInfo } from '@platforma-sdk/model';
|
|
20
20
|
import { getDebugFlags } from '../debug';
|
|
21
21
|
|
|
22
|
-
export type
|
|
22
|
+
export type BlockParameters = Omit<BlockStateInternalV3, 'outputs' | 'navigationState'>;
|
|
23
23
|
|
|
24
|
-
export function
|
|
24
|
+
export function getBlockParameters(
|
|
25
25
|
projectEntry: PlTreeEntry,
|
|
26
26
|
blockId: string
|
|
27
|
-
): Computable<
|
|
28
|
-
export function
|
|
27
|
+
): Computable<BlockParameters>;
|
|
28
|
+
export function getBlockParameters(
|
|
29
29
|
projectEntry: PlTreeEntry,
|
|
30
30
|
blockId: string,
|
|
31
31
|
cCtx: ComputableCtx
|
|
32
|
-
):
|
|
33
|
-
export function
|
|
32
|
+
): BlockParameters;
|
|
33
|
+
export function getBlockParameters(
|
|
34
34
|
projectEntry: PlTreeEntry,
|
|
35
35
|
blockId: string,
|
|
36
36
|
cCtx?: ComputableCtx,
|
|
37
|
-
):
|
|
37
|
+
): BlockParameters | Computable<BlockParameters> {
|
|
38
38
|
if (cCtx === undefined)
|
|
39
|
-
return Computable.make((c) =>
|
|
39
|
+
return Computable.make((c) => getBlockParameters(projectEntry, blockId, c), {
|
|
40
40
|
key: `inputs#${resourceIdToString(projectEntry.rid)}#${blockId}`,
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
const prj = cCtx.accessor(projectEntry).node();
|
|
44
44
|
const ctx = constructBlockContextArgsOnly(projectEntry, blockId);
|
|
45
|
-
const
|
|
45
|
+
const blockStorageJson = ctx.blockStorage(cCtx);
|
|
46
|
+
// Parse raw storage JSON - UI will derive data using sdk/model
|
|
47
|
+
const blockStorage = blockStorageJson !== undefined ? deepFreeze(JSON.parse(blockStorageJson)) : undefined;
|
|
46
48
|
return {
|
|
47
49
|
author: prj.getKeyValueAsJson<AuthorMarker>(blockArgsAuthorKey(blockId)),
|
|
48
|
-
|
|
49
|
-
args: deepFreeze(JSON.parse(ctx.args(cCtx))),
|
|
50
|
-
// @TODO add deserialization caching
|
|
51
|
-
ui: uiState !== undefined ? deepFreeze(JSON.parse(uiState)) : undefined,
|
|
50
|
+
blockStorage,
|
|
52
51
|
};
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -11,19 +11,16 @@ import {
|
|
|
11
11
|
} from '../model/project_model';
|
|
12
12
|
import { allBlocks } from '../model/project_model_util';
|
|
13
13
|
import { ResultPool } from '../pool/result_pool';
|
|
14
|
-
|
|
15
|
-
export type BlockContextMaterialized = {
|
|
16
|
-
readonly blockId: string;
|
|
17
|
-
readonly args: string;
|
|
18
|
-
readonly uiState?: string;
|
|
19
|
-
};
|
|
14
|
+
import { deriveDataFromStorage } from '@platforma-sdk/model';
|
|
20
15
|
|
|
21
16
|
export type BlockContextArgsOnly = {
|
|
22
17
|
readonly blockId: string;
|
|
23
|
-
readonly args: (cCtx: ComputableCtx) => string;
|
|
18
|
+
readonly args: (cCtx: ComputableCtx) => string | undefined;
|
|
24
19
|
readonly activeArgs: (cCtx: ComputableCtx) => string | undefined;
|
|
25
|
-
readonly uiState: (cCtx: ComputableCtx) => string | undefined;
|
|
26
20
|
readonly blockMeta: (cCtx: ComputableCtx) => Map<string, Block>;
|
|
21
|
+
readonly data: (cCtx: ComputableCtx) => string | undefined;
|
|
22
|
+
readonly blockStorage: (cCtx: ComputableCtx) => string | undefined;
|
|
23
|
+
readonly prerunArgs: (cCtx: ComputableCtx) => string | undefined;
|
|
27
24
|
};
|
|
28
25
|
|
|
29
26
|
export type BlockContextFull = BlockContextArgsOnly & {
|
|
@@ -38,17 +35,17 @@ export function constructBlockContextArgsOnly(
|
|
|
38
35
|
projectEntry: PlTreeEntry,
|
|
39
36
|
blockId: string,
|
|
40
37
|
): BlockContextArgsOnly {
|
|
41
|
-
const args = (cCtx: ComputableCtx) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
const args = (cCtx: ComputableCtx) => {
|
|
39
|
+
const data = cCtx
|
|
40
|
+
.accessor(projectEntry)
|
|
41
|
+
.node()
|
|
42
|
+
.traverse({
|
|
43
|
+
field: projectFieldName(blockId, 'currentArgs'),
|
|
44
|
+
stableIfNotFound: true,
|
|
45
|
+
})
|
|
46
|
+
?.getData();
|
|
47
|
+
return data ? cachedDecode(data) : undefined;
|
|
48
|
+
};
|
|
52
49
|
const activeArgs = (cCtx: ComputableCtx) => {
|
|
53
50
|
const data = cCtx
|
|
54
51
|
.accessor(projectEntry)
|
|
@@ -60,12 +57,48 @@ export function constructBlockContextArgsOnly(
|
|
|
60
57
|
?.getData();
|
|
61
58
|
return data ? cachedDecode(data) : undefined;
|
|
62
59
|
};
|
|
63
|
-
const
|
|
60
|
+
const data = (cCtx: ComputableCtx) => {
|
|
61
|
+
const data = cCtx
|
|
62
|
+
.accessor(projectEntry)
|
|
63
|
+
.node()
|
|
64
|
+
.traverse({
|
|
65
|
+
field: projectFieldName(blockId, 'blockStorage'),
|
|
66
|
+
stableIfNotFound: true,
|
|
67
|
+
})
|
|
68
|
+
?.getData();
|
|
69
|
+
if (!data) return undefined;
|
|
70
|
+
|
|
71
|
+
const rawJson = cachedDecode(data);
|
|
72
|
+
if (!rawJson) return undefined;
|
|
73
|
+
|
|
74
|
+
// Parse to check if it's BlockStorage format
|
|
75
|
+
try {
|
|
76
|
+
const parsed = JSON.parse(rawJson);
|
|
77
|
+
return JSON.stringify(deriveDataFromStorage(parsed));
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error('Error deriving data from storage', err);
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
// Returns raw blockStorage JSON - UI derives data using sdk/model
|
|
84
|
+
const blockStorage = (cCtx: ComputableCtx) => {
|
|
85
|
+
const storageData = cCtx
|
|
86
|
+
.accessor(projectEntry)
|
|
87
|
+
.node()
|
|
88
|
+
.traverse({
|
|
89
|
+
field: projectFieldName(blockId, 'blockStorage'),
|
|
90
|
+
stableIfNotFound: true,
|
|
91
|
+
})
|
|
92
|
+
?.getData();
|
|
93
|
+
if (!storageData) return undefined;
|
|
94
|
+
return cachedDecode(storageData);
|
|
95
|
+
};
|
|
96
|
+
const prerunArgs = (cCtx: ComputableCtx) => {
|
|
64
97
|
const data = cCtx
|
|
65
98
|
.accessor(projectEntry)
|
|
66
99
|
.node()
|
|
67
100
|
.traverse({
|
|
68
|
-
field: projectFieldName(blockId, '
|
|
101
|
+
field: projectFieldName(blockId, 'currentPrerunArgs'),
|
|
69
102
|
stableIfNotFound: true,
|
|
70
103
|
})
|
|
71
104
|
?.getData();
|
|
@@ -75,7 +108,9 @@ export function constructBlockContextArgsOnly(
|
|
|
75
108
|
blockId,
|
|
76
109
|
args,
|
|
77
110
|
activeArgs,
|
|
78
|
-
|
|
111
|
+
data,
|
|
112
|
+
blockStorage,
|
|
113
|
+
prerunArgs,
|
|
79
114
|
blockMeta: (cCtx: ComputableCtx) => {
|
|
80
115
|
const prj = cCtx.accessor(projectEntry).node();
|
|
81
116
|
const structure = notEmpty(prj.getKeyValueAsJson<ProjectStructure>(ProjectStructureKey));
|
|
@@ -104,15 +139,27 @@ export function constructBlockContext(
|
|
|
104
139
|
?.persist();
|
|
105
140
|
},
|
|
106
141
|
staging: (cCtx: ComputableCtx) => {
|
|
142
|
+
// Check if staging is expected (currentPrerunArgs is set)
|
|
143
|
+
// For blocks with failed args derivation, staging will never be rendered
|
|
144
|
+
const hasPrerunArgs = cCtx
|
|
145
|
+
.accessor(projectEntry)
|
|
146
|
+
.node({ ignoreError: true })
|
|
147
|
+
.traverse({
|
|
148
|
+
field: projectFieldName(blockId, 'currentPrerunArgs'),
|
|
149
|
+
stableIfNotFound: true,
|
|
150
|
+
ignoreError: true,
|
|
151
|
+
}) !== undefined;
|
|
152
|
+
|
|
107
153
|
const result = cCtx
|
|
108
154
|
.accessor(projectEntry)
|
|
109
155
|
.node({ ignoreError: true })
|
|
110
156
|
.traverse({
|
|
111
157
|
field: projectFieldName(blockId, 'stagingOutput'),
|
|
158
|
+
// Only mark stable if staging is NOT expected (no prerunArgs)
|
|
159
|
+
stableIfNotFound: !hasPrerunArgs,
|
|
112
160
|
ignoreError: true,
|
|
113
161
|
})
|
|
114
162
|
?.persist();
|
|
115
|
-
if (result === undefined) cCtx.markUnstable('staging_not_rendered');
|
|
116
163
|
return result;
|
|
117
164
|
},
|
|
118
165
|
getResultsPool: (cCtx: ComputableCtx) => ResultPool.create(cCtx, projectEntry, blockId),
|
|
@@ -4,7 +4,7 @@ import type { PlResourceEntry, StdCtx } from '@platforma-sdk/model';
|
|
|
4
4
|
import type { BlockContextAny } from './block_ctx';
|
|
5
5
|
|
|
6
6
|
type SC = StdCtx<unknown, unknown>;
|
|
7
|
-
type SCAO = Pick<SC, '$blockId' | '$ui' | '$args'>;
|
|
7
|
+
type SCAO = Pick<SC, '$blockId' | '$ui' | '$args' | '$data'>;
|
|
8
8
|
export type MatStdCtxArgsOnly = {
|
|
9
9
|
[Var in keyof SCAO]: SCAO[Var] extends PlResourceEntry
|
|
10
10
|
? PlTreeEntry | ((cCtx: ComputableCtx) => PlTreeEntry | undefined) | undefined
|
|
@@ -21,10 +21,17 @@ export const NonKeyCtxFields = ['$prod', '$staging'];
|
|
|
21
21
|
export function toCfgContext(ctx: BlockContextAny): MatStdCtx {
|
|
22
22
|
return {
|
|
23
23
|
$blockId: ctx.blockId,
|
|
24
|
-
$args: (cCtx: ComputableCtx) =>
|
|
24
|
+
$args: (cCtx: ComputableCtx) => {
|
|
25
|
+
const args = ctx.args(cCtx);
|
|
26
|
+
return args !== undefined ? JSON.parse(args) as unknown : undefined;
|
|
27
|
+
},
|
|
25
28
|
$ui: (cCtx: ComputableCtx) => {
|
|
26
|
-
const
|
|
27
|
-
return
|
|
29
|
+
const data = ctx.data(cCtx);
|
|
30
|
+
return data !== undefined ? JSON.parse(data) as unknown : undefined;
|
|
31
|
+
},
|
|
32
|
+
$data: (cCtx: ComputableCtx) => {
|
|
33
|
+
const data = ctx.data(cCtx);
|
|
34
|
+
return data !== undefined ? JSON.parse(data) as unknown : undefined;
|
|
28
35
|
},
|
|
29
36
|
$prod: ctx.prod,
|
|
30
37
|
$staging: ctx.staging,
|
|
@@ -72,7 +72,7 @@ export interface MiddleLayerEnvironment {
|
|
|
72
72
|
* are required.
|
|
73
73
|
* */
|
|
74
74
|
export class MiddleLayer {
|
|
75
|
-
|
|
75
|
+
public readonly pl: PlClient;
|
|
76
76
|
|
|
77
77
|
/** Contains a reactive list of projects along with their meta information. */
|
|
78
78
|
public readonly projectList: ComputableStableDefined<ProjectListEntry[]>;
|
|
@@ -279,6 +279,7 @@ export class MiddleLayer {
|
|
|
279
279
|
const runtimeCapabilities = new RuntimeCapabilities();
|
|
280
280
|
// add runtime capabilities of model here
|
|
281
281
|
runtimeCapabilities.addSupportedRequirement('requiresModelAPIVersion', 1);
|
|
282
|
+
runtimeCapabilities.addSupportedRequirement('requiresModelAPIVersion', 2);
|
|
282
283
|
// runtime capabilities of the desktop are to be added by the desktop app / test framework
|
|
283
284
|
|
|
284
285
|
const env: MiddleLayerEnvironment = {
|