@milaboratories/pl-middle-layer 1.65.9 → 1.66.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/js_render/column_registry.cjs +56 -0
- package/dist/js_render/column_registry.cjs.map +1 -0
- package/dist/js_render/column_registry.js +55 -0
- package/dist/js_render/column_registry.js.map +1 -0
- package/dist/js_render/computable_context.cjs +80 -12
- package/dist/js_render/computable_context.cjs.map +1 -1
- package/dist/js_render/computable_context.js +81 -13
- package/dist/js_render/computable_context.js.map +1 -1
- package/dist/js_render/service_injectors.cjs +43 -2
- package/dist/js_render/service_injectors.cjs.map +1 -1
- package/dist/js_render/service_injectors.js +43 -2
- package/dist/js_render/service_injectors.js.map +1 -1
- package/dist/js_render/spec_override_collapse.cjs +108 -0
- package/dist/js_render/spec_override_collapse.cjs.map +1 -0
- package/dist/js_render/spec_override_collapse.js +108 -0
- package/dist/js_render/spec_override_collapse.js.map +1 -0
- package/dist/middle_layer/block_ctx.cjs +2 -1
- package/dist/middle_layer/block_ctx.cjs.map +1 -1
- package/dist/middle_layer/block_ctx.js +2 -1
- package/dist/middle_layer/block_ctx.js.map +1 -1
- package/dist/mutator/template/template_cache.cjs.map +1 -1
- package/dist/mutator/template/template_cache.d.ts.map +1 -1
- package/dist/mutator/template/template_cache.js.map +1 -1
- package/dist/pool/data.cjs +2 -9
- package/dist/pool/data.cjs.map +1 -1
- package/dist/pool/data.d.ts.map +1 -1
- package/dist/pool/data.js +3 -10
- package/dist/pool/data.js.map +1 -1
- package/dist/pool/result_pool.cjs +0 -20
- package/dist/pool/result_pool.cjs.map +1 -1
- package/dist/pool/result_pool.js +1 -21
- package/dist/pool/result_pool.js.map +1 -1
- package/dist/pool/upstream_block_ctx.cjs +64 -0
- package/dist/pool/upstream_block_ctx.cjs.map +1 -0
- package/dist/pool/upstream_block_ctx.js +64 -0
- package/dist/pool/upstream_block_ctx.js.map +1 -0
- package/dist/service_factories.cjs +3 -1
- package/dist/service_factories.cjs.map +1 -1
- package/dist/service_factories.js +3 -1
- package/dist/service_factories.js.map +1 -1
- package/package.json +18 -17
- package/src/js_render/column_registry.ts +95 -0
- package/src/js_render/computable_context.ts +109 -26
- package/src/js_render/service_injectors.ts +106 -8
- package/src/js_render/spec_override_collapse.ts +211 -0
- package/src/middle_layer/block_ctx.ts +6 -1
- package/src/mutator/template/template_cache.test.ts +0 -14
- package/src/mutator/template/template_cache.ts +0 -14
- package/src/pool/data.ts +4 -3
- package/src/pool/result_pool.ts +1 -24
- package/src/pool/upstream_block_ctx.ts +85 -0
- package/src/service_factories.ts +2 -0
package/dist/pool/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","names":[],"sources":["../../src/pool/data.ts"],"sourcesContent":["import {\n PFrameDriverError,\n type BinaryChunk,\n type ParquetChunk,\n type ParquetChunkMapping,\n type ParquetChunkMetadata,\n type PColumnValue,\n type PlRef,\n type PObjectId,\n type PObjectSpec,\n} from \"@platforma-sdk/model\";\nimport { makeResourceSnapshot, type PlTreeNodeAccessor } from \"@milaboratories/pl-tree\";\nimport canonicalize from \"canonicalize\";\nimport {\n anyResourceIdToBigint,\n isNullSignedResourceId,\n resourceIdToString,\n resourceType,\n resourceTypeToString,\n resourceTypesEqual,\n type SignedResourceId,\n type ResourceType,\n} from \"@milaboratories/pl-client\";\nimport type { Writable } from \"utility-types\";\nimport { createHash } from \"node:crypto\";\nimport type { PFrameInternal } from \"@milaboratories/pl-model-middle-layer\";\nimport { OnDemandBlobResourceSnapshot } from \"@milaboratories/pl-drivers\";\n\n/**\n * Tree-independent reference to a blob resource used by the PFrame data flow.\n *\n * The earlier design carried a {@link PlTreeEntry} all the way into the blob pools;\n * resolution then went back through the originating tree, so when that tree dropped\n * the resource (e.g., a project recalculated with new settings), shared pool entries\n * — held alive by other projects — would start failing with \"resource not found in\n * the tree\" even though the underlying blob was still valid backend-side.\n *\n * BlobResourceRef captures the snapshot at parse time, where the tree is guaranteed\n * to resolve. The pools then key by rid (`resourceInfo.id`) and call into the\n * download driver with the snapshot directly — independent of any specific tree.\n */\nexport class BlobResourceRef {\n constructor(\n public readonly resourceInfo: { readonly id: SignedResourceId; readonly type: ResourceType },\n /** Present only for on-demand (remote) blobs; needed for size and signed handle. */\n public readonly onDemandSnapshot: OnDemandBlobResourceSnapshot | undefined,\n ) {}\n\n toJSON(): string {\n return resourceIdToString(this.resourceInfo.id);\n }\n}\n\nexport function makeLocalBlobRef(accessor: PlTreeNodeAccessor): BlobResourceRef {\n return new BlobResourceRef(accessor.resourceInfo, undefined);\n}\n\nfunction makeRemoteBlobRef(accessor: PlTreeNodeAccessor): BlobResourceRef {\n return new BlobResourceRef(\n accessor.resourceInfo,\n makeResourceSnapshot(accessor, OnDemandBlobResourceSnapshot),\n );\n}\n\nexport const PColumnDataJsonPartitioned = resourceType(\"PColumnData/JsonPartitioned\", \"1\");\nexport const PColumnDataJsonSuperPartitioned = resourceType(\n \"PColumnData/Partitioned/JsonPartitioned\",\n \"1\",\n);\nexport const PColumnDataBinaryPartitioned = resourceType(\"PColumnData/BinaryPartitioned\", \"1\");\nexport const PColumnDataBinarySuperPartitioned = resourceType(\n \"PColumnData/Partitioned/BinaryPartitioned\",\n \"1\",\n);\nexport const PColumnDataParquetPartitioned = resourceType(\"PColumnData/ParquetPartitioned\", \"1\");\nexport const PColumnDataParquetSuperPartitioned = resourceType(\n \"PColumnData/Partitioned/ParquetPartitioned\",\n \"1\",\n);\nexport const PColumnDataJson = resourceType(\"PColumnData/Json\", \"1\");\n\nexport const ParquetChunkResourceType = resourceType(\"ParquetChunk\", \"1\");\n\nexport type PColumnDataJsonResourceValue = {\n keyLength: number;\n data: Record<string, PColumnValue>;\n};\n\nexport type PColumnDataPartitionedResourceValue = {\n partitionKeyLength: number;\n};\n\nexport type PColumnDataSuperPartitionedResourceValue = {\n superPartitionKeyLength: number;\n partitionKeyLength: number;\n};\n\nconst BinaryPartitionedIndexFieldSuffix = \".index\";\nconst BinaryPartitionedValuesFieldSuffix = \".values\";\n\nexport function parseDataInfoResource(\n data: PlTreeNodeAccessor,\n): undefined | PFrameInternal.DataInfo<BlobResourceRef> {\n if (!data.getIsReadyOrError()) return undefined;\n\n const resourceData = data.getDataAsJson();\n if (resourceData === undefined)\n throw new PFrameDriverError(\"unexpected data info structure, no resource data\");\n\n if (resourceTypesEqual(data.resourceType, PColumnDataJson)) {\n const dataContent = resourceData as PColumnDataJsonResourceValue;\n\n return {\n type: \"Json\",\n keyLength: dataContent.keyLength,\n data: dataContent.data,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataJsonPartitioned)) {\n const meta = resourceData as PColumnDataPartitionedResourceValue;\n\n const parts = Object.fromEntries(\n data\n .listInputFields()\n .map((field) => [\n field,\n makeLocalBlobRef(data.traverse({ field, errorIfFieldNotSet: true })),\n ]),\n );\n\n return {\n type: \"JsonPartitioned\",\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataJsonSuperPartitioned)) {\n const meta = resourceData as PColumnDataSuperPartitionedResourceValue;\n\n const parts: Record<string, BlobResourceRef> = {};\n for (const superKey of data.listInputFields()) {\n const superPart = data.traverse({ field: superKey, errorIfFieldNotSet: true });\n const keys = superPart.listInputFields();\n if (keys === undefined)\n throw new PFrameDriverError(`no partition keys for super key ${superKey}`);\n\n for (const key of keys) {\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n parts[partKey] = makeLocalBlobRef(\n superPart.traverse({ field: key, errorIfFieldNotSet: true }),\n );\n }\n }\n\n return {\n type: \"JsonPartitioned\",\n partitionKeyLength: meta.superPartitionKeyLength + meta.partitionKeyLength,\n parts,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataBinaryPartitioned)) {\n const meta = resourceData as PColumnDataPartitionedResourceValue;\n\n const parts: Record<string, Partial<Writable<BinaryChunk<BlobResourceRef>>>> = {};\n\n // parsing the structure\n for (const field of data.listInputFields()) {\n if (field.endsWith(BinaryPartitionedIndexFieldSuffix)) {\n const partKey = field.slice(0, -BinaryPartitionedIndexFieldSuffix.length);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n part.index = makeLocalBlobRef(data.traverse({ field, errorIfFieldNotSet: true }));\n } else if (field.endsWith(BinaryPartitionedValuesFieldSuffix)) {\n const partKey = field.slice(0, -BinaryPartitionedValuesFieldSuffix.length);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n part.values = makeLocalBlobRef(data.traverse({ field, errorIfFieldNotSet: true }));\n } else throw new PFrameDriverError(`unrecognized part field name: ${field}`);\n }\n\n // structure validation\n for (const [key, part] of Object.entries(parts)) {\n if (part.index === undefined) throw new PFrameDriverError(`no index for part ${key}`);\n if (part.values === undefined) throw new PFrameDriverError(`no values for part ${key}`);\n }\n\n return {\n type: \"BinaryPartitioned\",\n partitionKeyLength: meta.partitionKeyLength,\n parts: parts as Record<string, BinaryChunk<BlobResourceRef>>,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataBinarySuperPartitioned)) {\n const meta = resourceData as PColumnDataSuperPartitionedResourceValue;\n\n const parts: Record<string, Partial<Writable<BinaryChunk<BlobResourceRef>>>> = {};\n for (const superKey of data.listInputFields()) {\n const superData = data.traverse({ field: superKey, errorIfFieldNotSet: true });\n const keys = superData.listInputFields();\n if (keys === undefined)\n throw new PFrameDriverError(`no partition keys for super key ${superKey}`);\n\n for (const field of keys) {\n if (field.endsWith(BinaryPartitionedIndexFieldSuffix)) {\n const key = field.slice(0, -BinaryPartitionedIndexFieldSuffix.length);\n\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n parts[partKey].index = makeLocalBlobRef(\n superData.traverse({ field, errorIfFieldNotSet: true }),\n );\n } else if (field.endsWith(BinaryPartitionedValuesFieldSuffix)) {\n const key = field.slice(0, -BinaryPartitionedValuesFieldSuffix.length);\n\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n parts[partKey].values = makeLocalBlobRef(\n superData.traverse({ field, errorIfFieldNotSet: true }),\n );\n } else throw new PFrameDriverError(`unrecognized part field name: ${field}`);\n }\n }\n\n return {\n type: \"BinaryPartitioned\",\n partitionKeyLength: meta.superPartitionKeyLength + meta.partitionKeyLength,\n parts: parts as Record<string, BinaryChunk<BlobResourceRef>>,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataParquetPartitioned)) {\n const meta = resourceData as PColumnDataPartitionedResourceValue;\n\n const parts: Record<string, ParquetChunk<BlobResourceRef>> = {};\n for (const key of data.listInputFields()) {\n const resource = data.traverse({\n field: key,\n assertFieldType: \"Input\",\n errorIfFieldNotSet: true,\n });\n\n parts[key] = traverseParquetChunkResource(resource);\n }\n\n return {\n type: \"ParquetPartitioned\",\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataParquetSuperPartitioned)) {\n const meta = resourceData as PColumnDataSuperPartitionedResourceValue;\n\n const parts: Record<string, ParquetChunk<BlobResourceRef>> = {};\n for (const superKey of data.listInputFields()) {\n const superPart = data.traverse({ field: superKey, errorIfFieldNotSet: true });\n const keys = superPart.listInputFields();\n if (keys === undefined)\n throw new PFrameDriverError(`no partition keys for super key ${superKey}`);\n\n for (const key of keys) {\n const resource = data.traverse({ field: key, errorIfFieldNotSet: true });\n\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n parts[partKey] = traverseParquetChunkResource(resource);\n }\n }\n\n return {\n type: \"ParquetPartitioned\",\n partitionKeyLength: meta.superPartitionKeyLength + meta.partitionKeyLength,\n parts,\n };\n }\n\n throw new PFrameDriverError(\n `unsupported resource type: ${resourceTypeToString(data.resourceType)}`,\n );\n}\n\nexport function traverseParquetChunkResource(\n resource: PlTreeNodeAccessor,\n): ParquetChunk<BlobResourceRef> {\n if (!resourceTypesEqual(resource.resourceType, ParquetChunkResourceType)) {\n throw new PFrameDriverError(\n `unknown resource type: ${resourceTypeToString(resource.resourceType)}, ` +\n `expected: ${resourceTypeToString(ParquetChunkResourceType)}`,\n );\n }\n\n const blob = makeRemoteBlobRef(\n resource.traverse({ field: \"blob\", assertFieldType: \"Service\", errorIfFieldNotSet: true }),\n );\n const partInfo = resource.getDataAsJson() as ParquetChunkMetadata;\n const mapping = resource\n .traverse({ field: \"mapping\", assertFieldType: \"Service\", errorIfFieldNotSet: true })\n .getDataAsJson() as ParquetChunkMapping;\n\n return {\n data: blob,\n ...partInfo,\n ...mapping,\n };\n}\n\nexport function deriveLegacyPObjectId(spec: PObjectSpec, data: PlTreeNodeAccessor): PObjectId {\n const hash = createHash(\"sha256\");\n hash.update(canonicalize(spec)!);\n const rid = !isNullSignedResourceId(data.originalId) ? data.originalId : data.id;\n hash.update(String(anyResourceIdToBigint(rid)));\n return hash.digest().toString(\"hex\") as PObjectId;\n}\n\nexport function deriveGlobalPObjectId(blockId: string, exportName: string): PObjectId {\n return canonicalize({ __isRef: true, blockId, name: exportName } satisfies PlRef)! as PObjectId;\n}\n\nexport function deriveLocalPObjectId(resolvePath: string[], outputName: string): PObjectId {\n return canonicalize({ resolvePath, name: outputName })! as PObjectId;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,kBAAb,MAA6B;CAET;CAEA;CAHlB,YACE,cAEA,kBACA;EAHgB,KAAA,eAAA;EAEA,KAAA,mBAAA;CACf;CAEH,SAAiB;EACf,OAAO,mBAAmB,KAAK,aAAa,EAAE;CAChD;AACF;AAEA,SAAgB,iBAAiB,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0BAA0B,qBAAqB,SAAS,YAAY,EAAE,cACvD,qBAAqB,wBAAwB,GAC9D;CAGF,MAAM,OAAO,kBACX,SAAS,SAAS;EAAE,OAAO;EAAQ,iBAAiB;EAAW,oBAAoB;CAAK,CAAC,CAC3F;CACA,MAAM,WAAW,SAAS,cAAc;CACxC,MAAM,UAAU,SACb,SAAS;EAAE,OAAO;EAAW,iBAAiB;EAAW,oBAAoB;CAAK,CAAC,CAAC,CACpF,cAAc;CAEjB,OAAO;EACL,MAAM;EACN,GAAG;EACH,GAAG;CACL;AACF;AAEA,SAAgB,sBAAsB,MAAmB,MAAqC;CAC5F,MAAM,OAAO,WAAW,QAAQ;CAChC,KAAK,OAAO,aAAa,IAAI,CAAE;CAC/B,MAAM,MAAM,CAAC,uBAAuB,KAAK,UAAU,IAAI,KAAK,aAAa,KAAK;CAC9E,KAAK,OAAO,OAAO,sBAAsB,GAAG,CAAC,CAAC;CAC9C,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,KAAK;AACrC;AAEA,SAAgB,sBAAsB,SAAiB,YAA+B;CACpF,OAAO,aAAa;EAAE,SAAS;EAAM;EAAS,MAAM;CAAW,CAAiB;AAClF;AAEA,SAAgB,qBAAqB,aAAuB,YAA+B;CACzF,OAAO,aAAa;EAAE;EAAa,MAAM;CAAW,CAAC;AACvD"}
|
|
1
|
+
{"version":3,"file":"data.js","names":[],"sources":["../../src/pool/data.ts"],"sourcesContent":["import {\n createGlobalPObjectId,\n createLocalPObjectId,\n PFrameDriverError,\n type BinaryChunk,\n type ParquetChunk,\n type ParquetChunkMapping,\n type ParquetChunkMetadata,\n type PColumnValue,\n type PObjectId,\n type PObjectSpec,\n} from \"@platforma-sdk/model\";\nimport { makeResourceSnapshot, type PlTreeNodeAccessor } from \"@milaboratories/pl-tree\";\nimport canonicalize from \"canonicalize\";\nimport {\n anyResourceIdToBigint,\n isNullSignedResourceId,\n resourceIdToString,\n resourceType,\n resourceTypeToString,\n resourceTypesEqual,\n type SignedResourceId,\n type ResourceType,\n} from \"@milaboratories/pl-client\";\nimport type { Writable } from \"utility-types\";\nimport { createHash } from \"node:crypto\";\nimport type { PFrameInternal } from \"@milaboratories/pl-model-middle-layer\";\nimport { OnDemandBlobResourceSnapshot } from \"@milaboratories/pl-drivers\";\n\n/**\n * Tree-independent reference to a blob resource used by the PFrame data flow.\n *\n * The earlier design carried a {@link PlTreeEntry} all the way into the blob pools;\n * resolution then went back through the originating tree, so when that tree dropped\n * the resource (e.g., a project recalculated with new settings), shared pool entries\n * — held alive by other projects — would start failing with \"resource not found in\n * the tree\" even though the underlying blob was still valid backend-side.\n *\n * BlobResourceRef captures the snapshot at parse time, where the tree is guaranteed\n * to resolve. The pools then key by rid (`resourceInfo.id`) and call into the\n * download driver with the snapshot directly — independent of any specific tree.\n */\nexport class BlobResourceRef {\n constructor(\n public readonly resourceInfo: { readonly id: SignedResourceId; readonly type: ResourceType },\n /** Present only for on-demand (remote) blobs; needed for size and signed handle. */\n public readonly onDemandSnapshot: OnDemandBlobResourceSnapshot | undefined,\n ) {}\n\n toJSON(): string {\n return resourceIdToString(this.resourceInfo.id);\n }\n}\n\nexport function makeLocalBlobRef(accessor: PlTreeNodeAccessor): BlobResourceRef {\n return new BlobResourceRef(accessor.resourceInfo, undefined);\n}\n\nfunction makeRemoteBlobRef(accessor: PlTreeNodeAccessor): BlobResourceRef {\n return new BlobResourceRef(\n accessor.resourceInfo,\n makeResourceSnapshot(accessor, OnDemandBlobResourceSnapshot),\n );\n}\n\nexport const PColumnDataJsonPartitioned = resourceType(\"PColumnData/JsonPartitioned\", \"1\");\nexport const PColumnDataJsonSuperPartitioned = resourceType(\n \"PColumnData/Partitioned/JsonPartitioned\",\n \"1\",\n);\nexport const PColumnDataBinaryPartitioned = resourceType(\"PColumnData/BinaryPartitioned\", \"1\");\nexport const PColumnDataBinarySuperPartitioned = resourceType(\n \"PColumnData/Partitioned/BinaryPartitioned\",\n \"1\",\n);\nexport const PColumnDataParquetPartitioned = resourceType(\"PColumnData/ParquetPartitioned\", \"1\");\nexport const PColumnDataParquetSuperPartitioned = resourceType(\n \"PColumnData/Partitioned/ParquetPartitioned\",\n \"1\",\n);\nexport const PColumnDataJson = resourceType(\"PColumnData/Json\", \"1\");\n\nexport const ParquetChunkResourceType = resourceType(\"ParquetChunk\", \"1\");\n\nexport type PColumnDataJsonResourceValue = {\n keyLength: number;\n data: Record<string, PColumnValue>;\n};\n\nexport type PColumnDataPartitionedResourceValue = {\n partitionKeyLength: number;\n};\n\nexport type PColumnDataSuperPartitionedResourceValue = {\n superPartitionKeyLength: number;\n partitionKeyLength: number;\n};\n\nconst BinaryPartitionedIndexFieldSuffix = \".index\";\nconst BinaryPartitionedValuesFieldSuffix = \".values\";\n\nexport function parseDataInfoResource(\n data: PlTreeNodeAccessor,\n): undefined | PFrameInternal.DataInfo<BlobResourceRef> {\n if (!data.getIsReadyOrError()) return undefined;\n\n const resourceData = data.getDataAsJson();\n if (resourceData === undefined)\n throw new PFrameDriverError(\"unexpected data info structure, no resource data\");\n\n if (resourceTypesEqual(data.resourceType, PColumnDataJson)) {\n const dataContent = resourceData as PColumnDataJsonResourceValue;\n\n return {\n type: \"Json\",\n keyLength: dataContent.keyLength,\n data: dataContent.data,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataJsonPartitioned)) {\n const meta = resourceData as PColumnDataPartitionedResourceValue;\n\n const parts = Object.fromEntries(\n data\n .listInputFields()\n .map((field) => [\n field,\n makeLocalBlobRef(data.traverse({ field, errorIfFieldNotSet: true })),\n ]),\n );\n\n return {\n type: \"JsonPartitioned\",\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataJsonSuperPartitioned)) {\n const meta = resourceData as PColumnDataSuperPartitionedResourceValue;\n\n const parts: Record<string, BlobResourceRef> = {};\n for (const superKey of data.listInputFields()) {\n const superPart = data.traverse({ field: superKey, errorIfFieldNotSet: true });\n const keys = superPart.listInputFields();\n if (keys === undefined)\n throw new PFrameDriverError(`no partition keys for super key ${superKey}`);\n\n for (const key of keys) {\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n parts[partKey] = makeLocalBlobRef(\n superPart.traverse({ field: key, errorIfFieldNotSet: true }),\n );\n }\n }\n\n return {\n type: \"JsonPartitioned\",\n partitionKeyLength: meta.superPartitionKeyLength + meta.partitionKeyLength,\n parts,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataBinaryPartitioned)) {\n const meta = resourceData as PColumnDataPartitionedResourceValue;\n\n const parts: Record<string, Partial<Writable<BinaryChunk<BlobResourceRef>>>> = {};\n\n // parsing the structure\n for (const field of data.listInputFields()) {\n if (field.endsWith(BinaryPartitionedIndexFieldSuffix)) {\n const partKey = field.slice(0, -BinaryPartitionedIndexFieldSuffix.length);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n part.index = makeLocalBlobRef(data.traverse({ field, errorIfFieldNotSet: true }));\n } else if (field.endsWith(BinaryPartitionedValuesFieldSuffix)) {\n const partKey = field.slice(0, -BinaryPartitionedValuesFieldSuffix.length);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n part.values = makeLocalBlobRef(data.traverse({ field, errorIfFieldNotSet: true }));\n } else throw new PFrameDriverError(`unrecognized part field name: ${field}`);\n }\n\n // structure validation\n for (const [key, part] of Object.entries(parts)) {\n if (part.index === undefined) throw new PFrameDriverError(`no index for part ${key}`);\n if (part.values === undefined) throw new PFrameDriverError(`no values for part ${key}`);\n }\n\n return {\n type: \"BinaryPartitioned\",\n partitionKeyLength: meta.partitionKeyLength,\n parts: parts as Record<string, BinaryChunk<BlobResourceRef>>,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataBinarySuperPartitioned)) {\n const meta = resourceData as PColumnDataSuperPartitionedResourceValue;\n\n const parts: Record<string, Partial<Writable<BinaryChunk<BlobResourceRef>>>> = {};\n for (const superKey of data.listInputFields()) {\n const superData = data.traverse({ field: superKey, errorIfFieldNotSet: true });\n const keys = superData.listInputFields();\n if (keys === undefined)\n throw new PFrameDriverError(`no partition keys for super key ${superKey}`);\n\n for (const field of keys) {\n if (field.endsWith(BinaryPartitionedIndexFieldSuffix)) {\n const key = field.slice(0, -BinaryPartitionedIndexFieldSuffix.length);\n\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n parts[partKey].index = makeLocalBlobRef(\n superData.traverse({ field, errorIfFieldNotSet: true }),\n );\n } else if (field.endsWith(BinaryPartitionedValuesFieldSuffix)) {\n const key = field.slice(0, -BinaryPartitionedValuesFieldSuffix.length);\n\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n let part = parts[partKey];\n if (part === undefined) {\n part = {};\n parts[partKey] = part;\n }\n parts[partKey].values = makeLocalBlobRef(\n superData.traverse({ field, errorIfFieldNotSet: true }),\n );\n } else throw new PFrameDriverError(`unrecognized part field name: ${field}`);\n }\n }\n\n return {\n type: \"BinaryPartitioned\",\n partitionKeyLength: meta.superPartitionKeyLength + meta.partitionKeyLength,\n parts: parts as Record<string, BinaryChunk<BlobResourceRef>>,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataParquetPartitioned)) {\n const meta = resourceData as PColumnDataPartitionedResourceValue;\n\n const parts: Record<string, ParquetChunk<BlobResourceRef>> = {};\n for (const key of data.listInputFields()) {\n const resource = data.traverse({\n field: key,\n assertFieldType: \"Input\",\n errorIfFieldNotSet: true,\n });\n\n parts[key] = traverseParquetChunkResource(resource);\n }\n\n return {\n type: \"ParquetPartitioned\",\n partitionKeyLength: meta.partitionKeyLength,\n parts,\n };\n } else if (resourceTypesEqual(data.resourceType, PColumnDataParquetSuperPartitioned)) {\n const meta = resourceData as PColumnDataSuperPartitionedResourceValue;\n\n const parts: Record<string, ParquetChunk<BlobResourceRef>> = {};\n for (const superKey of data.listInputFields()) {\n const superPart = data.traverse({ field: superKey, errorIfFieldNotSet: true });\n const keys = superPart.listInputFields();\n if (keys === undefined)\n throw new PFrameDriverError(`no partition keys for super key ${superKey}`);\n\n for (const key of keys) {\n const resource = data.traverse({ field: key, errorIfFieldNotSet: true });\n\n const partKey = JSON.stringify([\n ...(JSON.parse(superKey) as PColumnValue[]),\n ...(JSON.parse(key) as PColumnValue[]),\n ]);\n parts[partKey] = traverseParquetChunkResource(resource);\n }\n }\n\n return {\n type: \"ParquetPartitioned\",\n partitionKeyLength: meta.superPartitionKeyLength + meta.partitionKeyLength,\n parts,\n };\n }\n\n throw new PFrameDriverError(\n `unsupported resource type: ${resourceTypeToString(data.resourceType)}`,\n );\n}\n\nexport function traverseParquetChunkResource(\n resource: PlTreeNodeAccessor,\n): ParquetChunk<BlobResourceRef> {\n if (!resourceTypesEqual(resource.resourceType, ParquetChunkResourceType)) {\n throw new PFrameDriverError(\n `unknown resource type: ${resourceTypeToString(resource.resourceType)}, ` +\n `expected: ${resourceTypeToString(ParquetChunkResourceType)}`,\n );\n }\n\n const blob = makeRemoteBlobRef(\n resource.traverse({ field: \"blob\", assertFieldType: \"Service\", errorIfFieldNotSet: true }),\n );\n const partInfo = resource.getDataAsJson() as ParquetChunkMetadata;\n const mapping = resource\n .traverse({ field: \"mapping\", assertFieldType: \"Service\", errorIfFieldNotSet: true })\n .getDataAsJson() as ParquetChunkMapping;\n\n return {\n data: blob,\n ...partInfo,\n ...mapping,\n };\n}\n\nexport function deriveLegacyPObjectId(spec: PObjectSpec, data: PlTreeNodeAccessor): PObjectId {\n const hash = createHash(\"sha256\");\n hash.update(canonicalize(spec)!);\n const rid = !isNullSignedResourceId(data.originalId) ? data.originalId : data.id;\n hash.update(String(anyResourceIdToBigint(rid)));\n return hash.digest().toString(\"hex\") as PObjectId;\n}\n\nexport function deriveGlobalPObjectId(blockId: string, exportName: string): PObjectId {\n return createGlobalPObjectId(blockId, exportName);\n}\n\nexport function deriveLocalPObjectId(resolvePath: string[], outputName: string): PObjectId {\n return createLocalPObjectId(resolvePath, outputName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,kBAAb,MAA6B;CAET;CAEA;CAHlB,YACE,cAEA,kBACA;EAHgB,KAAA,eAAA;EAEA,KAAA,mBAAA;CACf;CAEH,SAAiB;EACf,OAAO,mBAAmB,KAAK,aAAa,EAAE;CAChD;AACF;AAEA,SAAgB,iBAAiB,UAA+C;CAC9E,OAAO,IAAI,gBAAgB,SAAS,cAAc,KAAA,CAAS;AAC7D;AAEA,SAAS,kBAAkB,UAA+C;CACxE,OAAO,IAAI,gBACT,SAAS,cACT,qBAAqB,UAAU,4BAA4B,CAC7D;AACF;AAEA,MAAa,6BAA6B,aAAa,+BAA+B,GAAG;AACzF,MAAa,kCAAkC,aAC7C,2CACA,GACF;AACA,MAAa,+BAA+B,aAAa,iCAAiC,GAAG;AAC7F,MAAa,oCAAoC,aAC/C,6CACA,GACF;AACA,MAAa,gCAAgC,aAAa,kCAAkC,GAAG;AAC/F,MAAa,qCAAqC,aAChD,8CACA,GACF;AACA,MAAa,kBAAkB,aAAa,oBAAoB,GAAG;AAEnE,MAAa,2BAA2B,aAAa,gBAAgB,GAAG;AAgBxE,MAAM,oCAAoC;AAC1C,MAAM,qCAAqC;AAE3C,SAAgB,sBACd,MACsD;CACtD,IAAI,CAAC,KAAK,kBAAkB,GAAG,OAAO,KAAA;CAEtC,MAAM,eAAe,KAAK,cAAc;CACxC,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,kBAAkB,kDAAkD;CAEhF,IAAI,mBAAmB,KAAK,cAAc,eAAe,GAAG;EAC1D,MAAM,cAAc;EAEpB,OAAO;GACL,MAAM;GACN,WAAW,YAAY;GACvB,MAAM,YAAY;EACpB;CACF,OAAO,IAAI,mBAAmB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154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
calculateOptions(predicate) {
|
|
157
|
-
const found = [];
|
|
158
|
-
for (const block of this.blocks.values()) {
|
|
159
|
-
const exportsChecked = /* @__PURE__ */ new Set();
|
|
160
|
-
const addToFound = (ctx) => {
|
|
161
|
-
for (const [exportName, result] of ctx.results) {
|
|
162
|
-
if (exportsChecked.has(exportName) || result.spec === void 0) continue;
|
|
163
|
-
exportsChecked.add(exportName);
|
|
164
|
-
if ((0, _platforma_sdk_model.executePSpecPredicate)(predicate, result.spec)) found.push({
|
|
165
|
-
label: block.info.label + " / " + exportName,
|
|
166
|
-
ref: require_args.outputRef(block.info.id, exportName),
|
|
167
|
-
spec: result.spec
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
if (block.staging !== void 0) addToFound(block.staging);
|
|
172
|
-
if (block.prod !== void 0) addToFound(block.prod);
|
|
173
|
-
}
|
|
174
|
-
return found;
|
|
175
|
-
}
|
|
176
156
|
static create(ctx, prjEntry, rootBlockId) {
|
|
177
157
|
const prj = ctx.accessor(prjEntry).node();
|
|
178
158
|
const structure = (0, _milaboratories_ts_helpers.notEmpty)(prj.getKeyValueAsJson(require_project_model.ProjectStructureKey));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result_pool.cjs","names":["deriveGlobalPObjectId","outputRef","ProjectStructureKey","stagingGraph","allBlocks","projectFieldName","parseRawPObjectCollection"],"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,\n} from \"@platforma-sdk/model\";\nimport { executePSpecPredicate, mapValueInVOE } from \"@platforma-sdk/model\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport { outputRef } from \"../model/args\";\nimport type { Block, ProjectStructure } from \"../model/project_model\";\nimport { ProjectStructureKey, projectFieldName } from \"../model/project_model\";\nimport { allBlocks, stagingGraph } from \"../model/project_model_util\";\nimport type { Optional } from \"utility-types\";\nimport { deriveGlobalPObjectId } from \"./data\";\nimport type { RawPObjectCollection, RawPObjectEntry } from \"./p_object_collection\";\nimport { parseRawPObjectCollection } 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;\n}\n"],"mappings":";;;;;;;;AA4CA,IAAa,aAAb,MAAa,WAAW;CAGH;CACA;CAHnB;CACA,YACE,KACA,QACA;EAFiB,KAAA,MAAA;EACA,KAAA,SAAA;EAEjB,IAAI,oBAAoB;EACxB,OAAO,KAAK,MAAM,SAAS,OAAO,OAAO,GACvC,KAAK,MAAM,OAAO,CAAC,MAAM,MAAM,MAAM,OAAO,GAC1C,IAAI,QAAQ,KAAA,GAAW;GACrB,IAAI,CAAC,IAAI,QAAQ;IACf,oBAAoB;IACpB,MAAM;GACR;GACA,KAAK,MAAM,UAAU,IAAI,QAAQ,OAAO,GACtC,IAAI,OAAO,SAAS,KAAA,GAAW;IAC7B,oBAAoB;IACpB,MAAM;GACR;EAEJ;EAEJ,KAAK,oBAAoB;CAC3B;CAEA,aAAoB,SAAiB,YAA6C;EAChF,MAAM,QAAQ,KAAK,OAAO,IAAI,OAAO;EACrC,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;EAChC,IAAI,SAAS,MAAM,MAAM,SAAS,IAAI,UAAU,CAAC,EAAE;EACnD,IAAI,WAAW,KAAA,GAAW,OAAO;EACjC,SAAS,MAAM,SA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AO,IAAI,UAAU,IAAI;IAAE,MAAM;IAAW;IAAM;GAAQ,CAAC;EAC7D;EAEA,OAAO,IAAI,WAAW,KAAK,MAAM;CACnC;AACF;;AAGA,SAAS,QACP,YACA,aACkC;CAClC,IAAI,gBAAgB,KAAA,GAClB,IAAI,YAIF,OAAO;EAAE,QAAQ;EAAO,yBAAS,IAAI,IAAI;CAAE;MACxC,OAAO,KAAA;CAGd,IAAI,YAAY,IAAI,OAAOC,4BAAAA,0BAA0B,YAAY,OAAO,OAAO,IAAI;MAC9E,OAAO,KAAA;AACd"}
|
|
1
|
+
{"version":3,"file":"result_pool.cjs","names":["deriveGlobalPObjectId","outputRef","ProjectStructureKey","stagingGraph","allBlocks","projectFieldName","parseRawPObjectCollection"],"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 PlRef,\n ResultCollection,\n ResultPoolEntry,\n ValueOrError,\n} from \"@platforma-sdk/model\";\nimport { mapValueInVOE } from \"@platforma-sdk/model\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport { outputRef } from \"../model/args\";\nimport type { Block, ProjectStructure } from \"../model/project_model\";\nimport { ProjectStructureKey, projectFieldName } from \"../model/project_model\";\nimport { allBlocks, stagingGraph } from \"../model/project_model_util\";\nimport type { Optional } from \"utility-types\";\nimport { deriveGlobalPObjectId } from \"./data\";\nimport type { RawPObjectCollection, RawPObjectEntry } from \"./p_object_collection\";\nimport { parseRawPObjectCollection } 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 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;\n}\n"],"mappings":";;;;;;;;AA2CA,IAAa,aAAb,MAAa,WAAW;CAGH;CACA;CAHnB;CACA,YACE,KACA,QACA;EAFiB,KAAA,MAAA;EACA,KAAA,SAAA;EAEjB,IAAI,oBAAoB;EACxB,OAAO,KAAK,MAAM,SAAS,OAAO,OAAO,GACvC,KAAK,MAAM,OAAO,CAAC,MAAM,MAAM,MAAM,OAAO,GAC1C,IAAI,QAAQ,KAAA,GAAW;GACrB,IAAI,CAAC,IAAI,QAAQ;IACf,oBAAoB;IACpB,MAA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;MACxC,OAAO,KAAA;CAGd,IAAI,YAAY,IAAI,OAAOC,4BAAAA,0BAA0B,YAAY,OAAO,OAAO,IAAI;MAC9E,OAAO,KAAA;AACd"}
|
package/dist/pool/result_pool.js
CHANGED
|
@@ -3,7 +3,7 @@ import { outputRef } from "../model/args.js";
|
|
|
3
3
|
import { allBlocks, stagingGraph } from "../model/project_model_util.js";
|
|
4
4
|
import { deriveGlobalPObjectId } from "./data.js";
|
|
5
5
|
import { parseRawPObjectCollection } from "./p_object_collection.js";
|
|
6
|
-
import {
|
|
6
|
+
import { mapValueInVOE } from "@platforma-sdk/model";
|
|
7
7
|
import { notEmpty } from "@milaboratories/ts-helpers";
|
|
8
8
|
//#region src/pool/result_pool.ts
|
|
9
9
|
var ResultPool = class ResultPool {
|
|
@@ -153,26 +153,6 @@ var ResultPool = class ResultPool {
|
|
|
153
153
|
instabilityMarker
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
calculateOptions(predicate) {
|
|
157
|
-
const found = [];
|
|
158
|
-
for (const block of this.blocks.values()) {
|
|
159
|
-
const exportsChecked = /* @__PURE__ */ new Set();
|
|
160
|
-
const addToFound = (ctx) => {
|
|
161
|
-
for (const [exportName, result] of ctx.results) {
|
|
162
|
-
if (exportsChecked.has(exportName) || result.spec === void 0) continue;
|
|
163
|
-
exportsChecked.add(exportName);
|
|
164
|
-
if (executePSpecPredicate(predicate, result.spec)) found.push({
|
|
165
|
-
label: block.info.label + " / " + exportName,
|
|
166
|
-
ref: outputRef(block.info.id, exportName),
|
|
167
|
-
spec: result.spec
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
if (block.staging !== void 0) addToFound(block.staging);
|
|
172
|
-
if (block.prod !== void 0) addToFound(block.prod);
|
|
173
|
-
}
|
|
174
|
-
return found;
|
|
175
|
-
}
|
|
176
156
|
static create(ctx, prjEntry, rootBlockId) {
|
|
177
157
|
const prj = ctx.accessor(prjEntry).node();
|
|
178
158
|
const structure = notEmpty(prj.getKeyValueAsJson(ProjectStructureKey));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result_pool.js","names":[],"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,\n} from \"@platforma-sdk/model\";\nimport { executePSpecPredicate, mapValueInVOE } from \"@platforma-sdk/model\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport { outputRef } from \"../model/args\";\nimport type { Block, ProjectStructure } from \"../model/project_model\";\nimport { ProjectStructureKey, projectFieldName } from \"../model/project_model\";\nimport { allBlocks, stagingGraph } from \"../model/project_model_util\";\nimport type { Optional } from \"utility-types\";\nimport { deriveGlobalPObjectId } from \"./data\";\nimport type { RawPObjectCollection, RawPObjectEntry } from \"./p_object_collection\";\nimport { parseRawPObjectCollection } 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;\n}\n"],"mappings":";;;;;;;;AA4CA,IAAa,aAAb,MAAa,WAAW;CAGH;CACA;CAHnB;CACA,YACE,KACA,QACA;EAFiB,KAAA,MAAA;EACA,KAAA,SAAA;EAEjB,IAAI,oBAAoB;EACxB,OAAO,KAAK,MAAM,SAAS,OAAO,OAAO,GACvC,KAAK,MAAM,OAAO,CAAC,MAAM,MAAM,MAAM,OAAO,GAC1C,IAAI,QAAQ,KAAA,GAAW;GACrB,IAAI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GACpB,CAAC,CACH;GACA,MAAM,UAAU,QACd,IAAI,SAAS;IACX,OAAO,iBAAiB,UAAU,IAAI,YAAY;IAClD,aAAa;IACb,2BAA2B;IAC3B,kBAAkB;GACpB,CAAC,MAAM,KAAA,GACP,IAAI,gBAAgB;IAClB,OAAO,iBAAiB,UAAU,IAAI,cAAc;IACpD,kBAAkB;GACpB,CAAC,CACH;GAEA,OAAO,IAAI,UAAU,IAAI;IAAE,MAAM;IAAW;IAAM;GAAQ,CAAC;EAC7D;EAEA,OAAO,IAAI,WAAW,KAAK,MAAM;CACnC;AACF;;AAGA,SAAS,QACP,YACA,aACkC;CAClC,IAAI,gBAAgB,KAAA,GAClB,IAAI,YAIF,OAAO;EAAE,QAAQ;EAAO,yBAAS,IAAI,IAAI;CAAE;MACxC,OAAO,KAAA;CAGd,IAAI,YAAY,IAAI,OAAO,0BAA0B,YAAY,OAAO,OAAO,IAAI;MAC9E,OAAO,KAAA;AACd"}
|
|
1
|
+
{"version":3,"file":"result_pool.js","names":[],"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 PlRef,\n ResultCollection,\n ResultPoolEntry,\n ValueOrError,\n} from \"@platforma-sdk/model\";\nimport { mapValueInVOE } from \"@platforma-sdk/model\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport { outputRef } from \"../model/args\";\nimport type { Block, ProjectStructure } from \"../model/project_model\";\nimport { ProjectStructureKey, projectFieldName } from \"../model/project_model\";\nimport { allBlocks, stagingGraph } from \"../model/project_model_util\";\nimport type { Optional } from \"utility-types\";\nimport { deriveGlobalPObjectId } from \"./data\";\nimport type { RawPObjectCollection, RawPObjectEntry } from \"./p_object_collection\";\nimport { parseRawPObjectCollection } 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 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;\n}\n"],"mappings":";;;;;;;;AA2CA,IAAa,aAAb,MAAa,WAAW;CAGH;CACA;CAHnB;CACA,YACE,KACA,QACA;EAFiB,KAAA,MAAA;EACA,KAAA,SAAA;EAEjB,IAAI,oBAAoB;EACxB,OAAO,KAAK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IAAI,IAAI;CAAE;MACxC,OAAO,KAAA;CAGd,IAAI,YAAY,IAAI,OAAO,0BAA0B,YAAY,OAAO,OAAO,IAAI;MAC9E,OAAO,KAAA;AACd"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_project_model = require("../model/project_model.cjs");
|
|
2
|
+
const require_project_model_util = require("../model/project_model_util.cjs");
|
|
3
|
+
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
4
|
+
//#region src/pool/upstream_block_ctx.ts
|
|
5
|
+
/**
|
|
6
|
+
* Collect upstream-block ctx accessors for the given root block.
|
|
7
|
+
*
|
|
8
|
+
* For each upstream block (per the staging graph) we try to resolve its
|
|
9
|
+
* `prodUiCtx` and `stagingUiCtx` resources. Only the `.ok` outcomes are
|
|
10
|
+
* surfaced; failures and missing fields collapse to `undefined`.
|
|
11
|
+
*
|
|
12
|
+
* SDK-side providers compose enumerate/status/data operations on top of these
|
|
13
|
+
* accessors using the helpers in `column_providers/accessor_traversal`.
|
|
14
|
+
*
|
|
15
|
+
* Note: this function is the only place that reads the project tree to build
|
|
16
|
+
* the upstream-pool view — the legacy `ResultPool` class is not used.
|
|
17
|
+
*/
|
|
18
|
+
function collectUpstreamBlockCtx(ctx, prjEntry, rootBlockId) {
|
|
19
|
+
const prj = ctx.accessor(prjEntry).node();
|
|
20
|
+
const structure = (0, _milaboratories_ts_helpers.notEmpty)(prj.getKeyValueAsJson(require_project_model.ProjectStructureKey));
|
|
21
|
+
const targetBlocks = require_project_model_util.stagingGraph(structure).traverseIds("upstream", rootBlockId);
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const blockInfo of require_project_model_util.allBlocks(structure)) {
|
|
24
|
+
if (!targetBlocks.has(blockInfo.id)) continue;
|
|
25
|
+
const prod = resolveCtxAccessor(prj, blockInfo.id, "prod");
|
|
26
|
+
const staging = resolveCtxAccessor(prj, blockInfo.id, "staging");
|
|
27
|
+
const prodIncomplete = prod.calculated && prod.accessor === void 0;
|
|
28
|
+
const stagingIncomplete = staging.calculated && staging.accessor === void 0;
|
|
29
|
+
out.push({
|
|
30
|
+
blockId: blockInfo.id,
|
|
31
|
+
prodCtx: prod.accessor,
|
|
32
|
+
stagingCtx: staging.accessor,
|
|
33
|
+
prodIncomplete: prodIncomplete || void 0,
|
|
34
|
+
stagingIncomplete: stagingIncomplete || void 0
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function resolveCtxAccessor(prj, blockId, kind) {
|
|
40
|
+
const ctxField = kind === "prod" ? "prodCtx" : "stagingCtx";
|
|
41
|
+
const uiCtxField = kind === "prod" ? "prodUiCtx" : "stagingUiCtx";
|
|
42
|
+
const calculated = prj.traverse({
|
|
43
|
+
field: require_project_model.projectFieldName(blockId, ctxField),
|
|
44
|
+
ignoreError: true,
|
|
45
|
+
pureFieldErrorToUndefined: true,
|
|
46
|
+
stableIfNotFound: true
|
|
47
|
+
}) !== void 0;
|
|
48
|
+
const uiCtx = prj.traverseOrError({
|
|
49
|
+
field: require_project_model.projectFieldName(blockId, uiCtxField),
|
|
50
|
+
stableIfNotFound: true
|
|
51
|
+
});
|
|
52
|
+
if (uiCtx === void 0 || !uiCtx.ok) return {
|
|
53
|
+
calculated,
|
|
54
|
+
accessor: void 0
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
calculated,
|
|
58
|
+
accessor: uiCtx.value
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.collectUpstreamBlockCtx = collectUpstreamBlockCtx;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=upstream_block_ctx.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream_block_ctx.cjs","names":["ProjectStructureKey","stagingGraph","allBlocks","projectFieldName"],"sources":["../../src/pool/upstream_block_ctx.ts"],"sourcesContent":["import type { ComputableCtx } from \"@milaboratories/computable\";\nimport type { PlTreeEntry, PlTreeNodeAccessor } from \"@milaboratories/pl-tree\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { UpstreamBlockCtx } from \"@milaboratories/pl-model-common\";\nimport type { ProjectStructure } from \"../model/project_model\";\nimport { ProjectStructureKey, projectFieldName } from \"../model/project_model\";\nimport { allBlocks, stagingGraph } from \"../model/project_model_util\";\n\nexport type { UpstreamBlockCtx } from \"@milaboratories/pl-model-common\";\n\n/**\n * Collect upstream-block ctx accessors for the given root block.\n *\n * For each upstream block (per the staging graph) we try to resolve its\n * `prodUiCtx` and `stagingUiCtx` resources. Only the `.ok` outcomes are\n * surfaced; failures and missing fields collapse to `undefined`.\n *\n * SDK-side providers compose enumerate/status/data operations on top of these\n * accessors using the helpers in `column_providers/accessor_traversal`.\n *\n * Note: this function is the only place that reads the project tree to build\n * the upstream-pool view — the legacy `ResultPool` class is not used.\n */\nexport function collectUpstreamBlockCtx(\n ctx: ComputableCtx,\n prjEntry: PlTreeEntry,\n rootBlockId: string,\n): UpstreamBlockCtx<PlTreeNodeAccessor>[] {\n const prj = ctx.accessor(prjEntry).node();\n const structure = notEmpty(prj.getKeyValueAsJson<ProjectStructure>(ProjectStructureKey));\n const graph = stagingGraph(structure);\n const targetBlocks = graph.traverseIds(\"upstream\", rootBlockId);\n\n const out: UpstreamBlockCtx<PlTreeNodeAccessor>[] = [];\n for (const blockInfo of allBlocks(structure)) {\n if (!targetBlocks.has(blockInfo.id)) continue;\n\n const prod = resolveCtxAccessor(prj, blockInfo.id, \"prod\");\n const staging = resolveCtxAccessor(prj, blockInfo.id, \"staging\");\n\n const prodIncomplete = prod.calculated && prod.accessor === undefined;\n const stagingIncomplete = staging.calculated && staging.accessor === undefined;\n\n out.push({\n blockId: blockInfo.id,\n prodCtx: prod.accessor,\n stagingCtx: staging.accessor,\n prodIncomplete: prodIncomplete || undefined,\n stagingIncomplete: stagingIncomplete || undefined,\n });\n }\n return out;\n}\n\ninterface CtxProbe {\n /** True if the ctx-holder field exists in the project tree (block has started rendering). */\n readonly calculated: boolean;\n /** Resolved ui-ctx accessor (only when `.ok`). */\n readonly accessor: PlTreeNodeAccessor | undefined;\n}\n\nfunction resolveCtxAccessor(\n prj: PlTreeNodeAccessor,\n blockId: string,\n kind: \"prod\" | \"staging\",\n): CtxProbe {\n const ctxField = kind === \"prod\" ? \"prodCtx\" : \"stagingCtx\";\n const uiCtxField = kind === \"prod\" ? \"prodUiCtx\" : \"stagingUiCtx\";\n\n const calculated =\n prj.traverse({\n field: projectFieldName(blockId, ctxField),\n ignoreError: true,\n pureFieldErrorToUndefined: true,\n stableIfNotFound: true,\n }) !== undefined;\n\n const uiCtx = prj.traverseOrError({\n field: projectFieldName(blockId, uiCtxField),\n stableIfNotFound: true,\n });\n\n if (uiCtx === undefined || !uiCtx.ok) return { calculated, accessor: undefined };\n return { calculated, accessor: uiCtx.value };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,SAAgB,wBACd,KACA,UACA,aACwC;CACxC,MAAM,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC,KAAK;CACxC,MAAM,aAAA,GAAA,2BAAA,SAAA,CAAqB,IAAI,kBAAoCA,sBAAAA,mBAAmB,CAAC;CAEvF,MAAM,eADQC,2BAAAA,aAAa,SACF,CAAC,CAAC,YAAY,YAAY,WAAW;CAE9D,MAAM,MAA8C,CAAC;CACrD,KAAK,MAAM,aAAaC,2BAAAA,UAAU,SAAS,GAAG;EAC5C,IAAI,CAAC,aAAa,IAAI,UAAU,EAAE,GAAG;EAErC,MAAM,OAAO,mBAAmB,KAAK,UAAU,IAAI,MAAM;EACzD,MAAM,UAAU,mBAAmB,KAAK,UAAU,IAAI,SAAS;EAE/D,MAAM,iBAAiB,KAAK,cAAc,KAAK,aAAa,KAAA;EAC5D,MAAM,oBAAoB,QAAQ,cAAc,QAAQ,aAAa,KAAA;EAErE,IAAI,KAAK;GACP,SAAS,UAAU;GACnB,SAAS,KAAK;GACd,YAAY,QAAQ;GACpB,gBAAgB,kBAAkB,KAAA;GAClC,mBAAmB,qBAAqB,KAAA;EAC1C,CAAC;CACH;CACA,OAAO;AACT;AASA,SAAS,mBACP,KACA,SACA,MACU;CACV,MAAM,WAAW,SAAS,SAAS,YAAY;CAC/C,MAAM,aAAa,SAAS,SAAS,cAAc;CAEnD,MAAM,aACJ,IAAI,SAAS;EACX,OAAOC,sBAAAA,iBAAiB,SAAS,QAAQ;EACzC,aAAa;EACb,2BAA2B;EAC3B,kBAAkB;CACpB,CAAC,MAAM,KAAA;CAET,MAAM,QAAQ,IAAI,gBAAgB;EAChC,OAAOA,sBAAAA,iBAAiB,SAAS,UAAU;EAC3C,kBAAkB;CACpB,CAAC;CAED,IAAI,UAAU,KAAA,KAAa,CAAC,MAAM,IAAI,OAAO;EAAE;EAAY,UAAU,KAAA;CAAU;CAC/E,OAAO;EAAE;EAAY,UAAU,MAAM;CAAM;AAC7C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ProjectStructureKey, projectFieldName } from "../model/project_model.js";
|
|
2
|
+
import { allBlocks, stagingGraph } from "../model/project_model_util.js";
|
|
3
|
+
import { notEmpty } from "@milaboratories/ts-helpers";
|
|
4
|
+
//#region src/pool/upstream_block_ctx.ts
|
|
5
|
+
/**
|
|
6
|
+
* Collect upstream-block ctx accessors for the given root block.
|
|
7
|
+
*
|
|
8
|
+
* For each upstream block (per the staging graph) we try to resolve its
|
|
9
|
+
* `prodUiCtx` and `stagingUiCtx` resources. Only the `.ok` outcomes are
|
|
10
|
+
* surfaced; failures and missing fields collapse to `undefined`.
|
|
11
|
+
*
|
|
12
|
+
* SDK-side providers compose enumerate/status/data operations on top of these
|
|
13
|
+
* accessors using the helpers in `column_providers/accessor_traversal`.
|
|
14
|
+
*
|
|
15
|
+
* Note: this function is the only place that reads the project tree to build
|
|
16
|
+
* the upstream-pool view — the legacy `ResultPool` class is not used.
|
|
17
|
+
*/
|
|
18
|
+
function collectUpstreamBlockCtx(ctx, prjEntry, rootBlockId) {
|
|
19
|
+
const prj = ctx.accessor(prjEntry).node();
|
|
20
|
+
const structure = notEmpty(prj.getKeyValueAsJson(ProjectStructureKey));
|
|
21
|
+
const targetBlocks = stagingGraph(structure).traverseIds("upstream", rootBlockId);
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const blockInfo of allBlocks(structure)) {
|
|
24
|
+
if (!targetBlocks.has(blockInfo.id)) continue;
|
|
25
|
+
const prod = resolveCtxAccessor(prj, blockInfo.id, "prod");
|
|
26
|
+
const staging = resolveCtxAccessor(prj, blockInfo.id, "staging");
|
|
27
|
+
const prodIncomplete = prod.calculated && prod.accessor === void 0;
|
|
28
|
+
const stagingIncomplete = staging.calculated && staging.accessor === void 0;
|
|
29
|
+
out.push({
|
|
30
|
+
blockId: blockInfo.id,
|
|
31
|
+
prodCtx: prod.accessor,
|
|
32
|
+
stagingCtx: staging.accessor,
|
|
33
|
+
prodIncomplete: prodIncomplete || void 0,
|
|
34
|
+
stagingIncomplete: stagingIncomplete || void 0
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function resolveCtxAccessor(prj, blockId, kind) {
|
|
40
|
+
const ctxField = kind === "prod" ? "prodCtx" : "stagingCtx";
|
|
41
|
+
const uiCtxField = kind === "prod" ? "prodUiCtx" : "stagingUiCtx";
|
|
42
|
+
const calculated = prj.traverse({
|
|
43
|
+
field: projectFieldName(blockId, ctxField),
|
|
44
|
+
ignoreError: true,
|
|
45
|
+
pureFieldErrorToUndefined: true,
|
|
46
|
+
stableIfNotFound: true
|
|
47
|
+
}) !== void 0;
|
|
48
|
+
const uiCtx = prj.traverseOrError({
|
|
49
|
+
field: projectFieldName(blockId, uiCtxField),
|
|
50
|
+
stableIfNotFound: true
|
|
51
|
+
});
|
|
52
|
+
if (uiCtx === void 0 || !uiCtx.ok) return {
|
|
53
|
+
calculated,
|
|
54
|
+
accessor: void 0
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
calculated,
|
|
58
|
+
accessor: uiCtx.value
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { collectUpstreamBlockCtx };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=upstream_block_ctx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream_block_ctx.js","names":[],"sources":["../../src/pool/upstream_block_ctx.ts"],"sourcesContent":["import type { ComputableCtx } from \"@milaboratories/computable\";\nimport type { PlTreeEntry, PlTreeNodeAccessor } from \"@milaboratories/pl-tree\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { UpstreamBlockCtx } from \"@milaboratories/pl-model-common\";\nimport type { ProjectStructure } from \"../model/project_model\";\nimport { ProjectStructureKey, projectFieldName } from \"../model/project_model\";\nimport { allBlocks, stagingGraph } from \"../model/project_model_util\";\n\nexport type { UpstreamBlockCtx } from \"@milaboratories/pl-model-common\";\n\n/**\n * Collect upstream-block ctx accessors for the given root block.\n *\n * For each upstream block (per the staging graph) we try to resolve its\n * `prodUiCtx` and `stagingUiCtx` resources. Only the `.ok` outcomes are\n * surfaced; failures and missing fields collapse to `undefined`.\n *\n * SDK-side providers compose enumerate/status/data operations on top of these\n * accessors using the helpers in `column_providers/accessor_traversal`.\n *\n * Note: this function is the only place that reads the project tree to build\n * the upstream-pool view — the legacy `ResultPool` class is not used.\n */\nexport function collectUpstreamBlockCtx(\n ctx: ComputableCtx,\n prjEntry: PlTreeEntry,\n rootBlockId: string,\n): UpstreamBlockCtx<PlTreeNodeAccessor>[] {\n const prj = ctx.accessor(prjEntry).node();\n const structure = notEmpty(prj.getKeyValueAsJson<ProjectStructure>(ProjectStructureKey));\n const graph = stagingGraph(structure);\n const targetBlocks = graph.traverseIds(\"upstream\", rootBlockId);\n\n const out: UpstreamBlockCtx<PlTreeNodeAccessor>[] = [];\n for (const blockInfo of allBlocks(structure)) {\n if (!targetBlocks.has(blockInfo.id)) continue;\n\n const prod = resolveCtxAccessor(prj, blockInfo.id, \"prod\");\n const staging = resolveCtxAccessor(prj, blockInfo.id, \"staging\");\n\n const prodIncomplete = prod.calculated && prod.accessor === undefined;\n const stagingIncomplete = staging.calculated && staging.accessor === undefined;\n\n out.push({\n blockId: blockInfo.id,\n prodCtx: prod.accessor,\n stagingCtx: staging.accessor,\n prodIncomplete: prodIncomplete || undefined,\n stagingIncomplete: stagingIncomplete || undefined,\n });\n }\n return out;\n}\n\ninterface CtxProbe {\n /** True if the ctx-holder field exists in the project tree (block has started rendering). */\n readonly calculated: boolean;\n /** Resolved ui-ctx accessor (only when `.ok`). */\n readonly accessor: PlTreeNodeAccessor | undefined;\n}\n\nfunction resolveCtxAccessor(\n prj: PlTreeNodeAccessor,\n blockId: string,\n kind: \"prod\" | \"staging\",\n): CtxProbe {\n const ctxField = kind === \"prod\" ? \"prodCtx\" : \"stagingCtx\";\n const uiCtxField = kind === \"prod\" ? \"prodUiCtx\" : \"stagingUiCtx\";\n\n const calculated =\n prj.traverse({\n field: projectFieldName(blockId, ctxField),\n ignoreError: true,\n pureFieldErrorToUndefined: true,\n stableIfNotFound: true,\n }) !== undefined;\n\n const uiCtx = prj.traverseOrError({\n field: projectFieldName(blockId, uiCtxField),\n stableIfNotFound: true,\n });\n\n if (uiCtx === undefined || !uiCtx.ok) return { calculated, accessor: undefined };\n return { calculated, accessor: uiCtx.value };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,SAAgB,wBACd,KACA,UACA,aACwC;CACxC,MAAM,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC,KAAK;CACxC,MAAM,YAAY,SAAS,IAAI,kBAAoC,mBAAmB,CAAC;CAEvF,MAAM,eADQ,aAAa,SACF,CAAC,CAAC,YAAY,YAAY,WAAW;CAE9D,MAAM,MAA8C,CAAC;CACrD,KAAK,MAAM,aAAa,UAAU,SAAS,GAAG;EAC5C,IAAI,CAAC,aAAa,IAAI,UAAU,EAAE,GAAG;EAErC,MAAM,OAAO,mBAAmB,KAAK,UAAU,IAAI,MAAM;EACzD,MAAM,UAAU,mBAAmB,KAAK,UAAU,IAAI,SAAS;EAE/D,MAAM,iBAAiB,KAAK,cAAc,KAAK,aAAa,KAAA;EAC5D,MAAM,oBAAoB,QAAQ,cAAc,QAAQ,aAAa,KAAA;EAErE,IAAI,KAAK;GACP,SAAS,UAAU;GACnB,SAAS,KAAK;GACd,YAAY,QAAQ;GACpB,gBAAgB,kBAAkB,KAAA;GAClC,mBAAmB,qBAAqB,KAAA;EAC1C,CAAC;CACH;CACA,OAAO;AACT;AASA,SAAS,mBACP,KACA,SACA,MACU;CACV,MAAM,WAAW,SAAS,SAAS,YAAY;CAC/C,MAAM,aAAa,SAAS,SAAS,cAAc;CAEnD,MAAM,aACJ,IAAI,SAAS;EACX,OAAO,iBAAiB,SAAS,QAAQ;EACzC,aAAa;EACb,2BAA2B;EAC3B,kBAAkB;CACpB,CAAC,MAAM,KAAA;CAET,MAAM,QAAQ,IAAI,gBAAgB;EAChC,OAAO,iBAAiB,SAAS,UAAU;EAC3C,kBAAkB;CACpB,CAAC;CAED,IAAI,UAAU,KAAA,KAAa,CAAC,MAAM,IAAI,OAAO;EAAE;EAAY,UAAU,KAAA;CAAU;CAC/E,OAAO;EAAE;EAAY,UAAU,MAAM;CAAM;AAC7C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
2
2
|
let _milaboratories_pf_spec_driver = require("@milaboratories/pf-spec-driver");
|
|
3
|
+
let _milaboratories_columns_collection_driver = require("@milaboratories/columns-collection-driver");
|
|
3
4
|
//#region src/service_factories.ts
|
|
4
5
|
/**
|
|
5
6
|
* Model service factories — add a factory for each new service here.
|
|
@@ -12,7 +13,8 @@ function createModelServiceRegistry(options) {
|
|
|
12
13
|
return new _milaboratories_pl_model_common.ModelServiceRegistry(_milaboratories_pl_model_common.Services, {
|
|
13
14
|
PFrameSpec: () => new _milaboratories_pf_spec_driver.SpecDriver({ logger: options.logger }),
|
|
14
15
|
PFrame: null,
|
|
15
|
-
Dialog: null
|
|
16
|
+
Dialog: null,
|
|
17
|
+
ColumnsCollection: () => new _milaboratories_columns_collection_driver.ColumnsCollectionDriverImpl()
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service_factories.cjs","names":["ModelServiceRegistry","Services","SpecDriver"],"sources":["../src/service_factories.ts"],"sourcesContent":["/**\n * Model service factories — add a factory for each new service here.\n *\n * Each entry maps a Services key to a factory function that creates the\n * model-side driver instance, or null if the service has no model-side driver\n * (e.g. node services whose driver is provided by the desktop app).\n */\n\nimport { ModelServiceRegistry, Services } from \"@milaboratories/pl-model-common\";\nimport { SpecDriver } from \"@milaboratories/pf-spec-driver\";\nimport { type MiLogger } from \"@milaboratories/ts-helpers\";\n\nexport type ModelServiceOptions = {\n logger: MiLogger;\n};\n\nexport function createModelServiceRegistry(options: ModelServiceOptions) {\n return new ModelServiceRegistry(Services, {\n PFrameSpec: () => new SpecDriver({ logger: options.logger }),\n PFrame: null,\n Dialog: null,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"service_factories.cjs","names":["ModelServiceRegistry","Services","SpecDriver","ColumnsCollectionDriverImpl"],"sources":["../src/service_factories.ts"],"sourcesContent":["/**\n * Model service factories — add a factory for each new service here.\n *\n * Each entry maps a Services key to a factory function that creates the\n * model-side driver instance, or null if the service has no model-side driver\n * (e.g. node services whose driver is provided by the desktop app).\n */\n\nimport { ModelServiceRegistry, Services } from \"@milaboratories/pl-model-common\";\nimport { SpecDriver } from \"@milaboratories/pf-spec-driver\";\nimport { ColumnsCollectionDriverImpl } from \"@milaboratories/columns-collection-driver\";\nimport { type MiLogger } from \"@milaboratories/ts-helpers\";\n\nexport type ModelServiceOptions = {\n logger: MiLogger;\n};\n\nexport function createModelServiceRegistry(options: ModelServiceOptions) {\n return new ModelServiceRegistry(Services, {\n PFrameSpec: () => new SpecDriver({ logger: options.logger }),\n PFrame: null,\n Dialog: null,\n ColumnsCollection: () => new ColumnsCollectionDriverImpl(),\n });\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,2BAA2B,SAA8B;CACvE,OAAO,IAAIA,gCAAAA,qBAAqBC,gCAAAA,UAAU;EACxC,kBAAkB,IAAIC,+BAAAA,WAAW,EAAE,QAAQ,QAAQ,OAAO,CAAC;EAC3D,QAAQ;EACR,QAAQ;EACR,yBAAyB,IAAIC,0CAAAA,4BAA4B;CAC3D,CAAC;AACH"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ModelServiceRegistry, Services } from "@milaboratories/pl-model-common";
|
|
2
2
|
import { SpecDriver } from "@milaboratories/pf-spec-driver";
|
|
3
|
+
import { ColumnsCollectionDriverImpl } from "@milaboratories/columns-collection-driver";
|
|
3
4
|
//#region src/service_factories.ts
|
|
4
5
|
/**
|
|
5
6
|
* Model service factories — add a factory for each new service here.
|
|
@@ -12,7 +13,8 @@ function createModelServiceRegistry(options) {
|
|
|
12
13
|
return new ModelServiceRegistry(Services, {
|
|
13
14
|
PFrameSpec: () => new SpecDriver({ logger: options.logger }),
|
|
14
15
|
PFrame: null,
|
|
15
|
-
Dialog: null
|
|
16
|
+
Dialog: null,
|
|
17
|
+
ColumnsCollection: () => new ColumnsCollectionDriverImpl()
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service_factories.js","names":[],"sources":["../src/service_factories.ts"],"sourcesContent":["/**\n * Model service factories — add a factory for each new service here.\n *\n * Each entry maps a Services key to a factory function that creates the\n * model-side driver instance, or null if the service has no model-side driver\n * (e.g. node services whose driver is provided by the desktop app).\n */\n\nimport { ModelServiceRegistry, Services } from \"@milaboratories/pl-model-common\";\nimport { SpecDriver } from \"@milaboratories/pf-spec-driver\";\nimport { type MiLogger } from \"@milaboratories/ts-helpers\";\n\nexport type ModelServiceOptions = {\n logger: MiLogger;\n};\n\nexport function createModelServiceRegistry(options: ModelServiceOptions) {\n return new ModelServiceRegistry(Services, {\n PFrameSpec: () => new SpecDriver({ logger: options.logger }),\n PFrame: null,\n Dialog: null,\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"service_factories.js","names":[],"sources":["../src/service_factories.ts"],"sourcesContent":["/**\n * Model service factories — add a factory for each new service here.\n *\n * Each entry maps a Services key to a factory function that creates the\n * model-side driver instance, or null if the service has no model-side driver\n * (e.g. node services whose driver is provided by the desktop app).\n */\n\nimport { ModelServiceRegistry, Services } from \"@milaboratories/pl-model-common\";\nimport { SpecDriver } from \"@milaboratories/pf-spec-driver\";\nimport { ColumnsCollectionDriverImpl } from \"@milaboratories/columns-collection-driver\";\nimport { type MiLogger } from \"@milaboratories/ts-helpers\";\n\nexport type ModelServiceOptions = {\n logger: MiLogger;\n};\n\nexport function createModelServiceRegistry(options: ModelServiceOptions) {\n return new ModelServiceRegistry(Services, {\n PFrameSpec: () => new SpecDriver({ logger: options.logger }),\n PFrame: null,\n Dialog: null,\n ColumnsCollection: () => new ColumnsCollectionDriverImpl(),\n });\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,2BAA2B,SAA8B;CACvE,OAAO,IAAI,qBAAqB,UAAU;EACxC,kBAAkB,IAAI,WAAW,EAAE,QAAQ,QAAQ,OAAO,CAAC;EAC3D,QAAQ;EACR,QAAQ;EACR,yBAAyB,IAAI,4BAA4B;CAC3D,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.66.0",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -31,24 +31,25 @@
|
|
|
31
31
|
"utility-types": "^3.11.0",
|
|
32
32
|
"yaml": "^2.8.0",
|
|
33
33
|
"zod": "~3.25.76",
|
|
34
|
-
"@milaboratories/
|
|
35
|
-
"@milaboratories/pf-driver": "1.7.16",
|
|
34
|
+
"@milaboratories/pf-spec-driver": "1.4.19",
|
|
36
35
|
"@milaboratories/computable": "2.9.6",
|
|
37
|
-
"@milaboratories/
|
|
38
|
-
"@milaboratories/
|
|
39
|
-
"@milaboratories/pl-client": "3.14.
|
|
40
|
-
"@milaboratories/
|
|
36
|
+
"@milaboratories/columns-collection-driver": "0.2.0",
|
|
37
|
+
"@milaboratories/helpers": "1.14.3",
|
|
38
|
+
"@milaboratories/pl-client": "3.14.1",
|
|
39
|
+
"@milaboratories/pf-driver": "1.8.0",
|
|
40
|
+
"@milaboratories/pl-drivers": "1.16.9",
|
|
41
|
+
"@milaboratories/pl-deployments": "3.0.11",
|
|
41
42
|
"@milaboratories/pl-http": "1.2.4",
|
|
42
|
-
"@milaboratories/pl-
|
|
43
|
-
"@milaboratories/pl-model-backend": "1.4.
|
|
44
|
-
"@milaboratories/pl-model-common": "1.
|
|
45
|
-
"@milaboratories/pl-
|
|
46
|
-
"@milaboratories/
|
|
43
|
+
"@milaboratories/pl-errors": "1.4.30",
|
|
44
|
+
"@milaboratories/pl-model-backend": "1.4.15",
|
|
45
|
+
"@milaboratories/pl-model-common": "1.47.0",
|
|
46
|
+
"@milaboratories/pl-model-middle-layer": "1.30.12",
|
|
47
|
+
"@milaboratories/ts-helpers": "1.8.4",
|
|
48
|
+
"@milaboratories/pl-tree": "1.13.0",
|
|
47
49
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
48
|
-
"@platforma-sdk/
|
|
49
|
-
"@platforma-sdk/block-tools": "2.12.
|
|
50
|
-
"@platforma-sdk/
|
|
51
|
-
"@milaboratories/ts-helpers": "1.8.4"
|
|
50
|
+
"@platforma-sdk/model": "1.80.0",
|
|
51
|
+
"@platforma-sdk/block-tools": "2.12.5",
|
|
52
|
+
"@platforma-sdk/workflow-tengo": "6.7.1"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@types/node": "~24.5.2",
|
|
@@ -56,8 +57,8 @@
|
|
|
56
57
|
"@vitest/coverage-istanbul": "^4.1.3",
|
|
57
58
|
"typescript": "~5.9.3",
|
|
58
59
|
"vitest": "^4.1.3",
|
|
59
|
-
"@milaboratories/build-configs": "2.0.0",
|
|
60
60
|
"@milaboratories/ts-builder": "1.6.0",
|
|
61
|
+
"@milaboratories/build-configs": "2.0.0",
|
|
61
62
|
"@milaboratories/ts-configs": "1.3.0"
|
|
62
63
|
},
|
|
63
64
|
"engines": {
|