@milaboratories/pl-middle-layer 1.61.5 → 1.61.7
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.
|
@@ -148,7 +148,7 @@ var BlockPackRegistry = class {
|
|
|
148
148
|
}
|
|
149
149
|
if (v2Description !== void 0) {
|
|
150
150
|
const mtime = await getDevV2PacketMtime(v2Description);
|
|
151
|
-
const meta = await _platforma_sdk_block_tools.
|
|
151
|
+
const meta = await (0, _platforma_sdk_block_tools.embedBlockPackMetaAbsoluteBytes)(v2Description.meta);
|
|
152
152
|
if (meta.requiredCapabilities === void 0) {
|
|
153
153
|
const derived = require_required_capabilities.deriveRequiredCapabilities(await node_fs.default.promises.readFile(v2Description.components.workflow.main.file));
|
|
154
154
|
if (derived !== void 0) meta.requiredCapabilities = derived;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.cjs","names":["fs","LegacyDevBlockPackFiles","path","RegistryV1","AnyChannel","StableChannel","YAML","BlockPackMetaEmbedAbsoluteBytes","deriveRequiredCapabilities"],"sources":["../../src/block_registry/registry.ts"],"sourcesContent":["import type { Dispatcher } from \"undici\";\nimport { request } from \"undici\";\nimport type { BlockPackDescriptionAbsolute } from \"@platforma-sdk/block-tools\";\nimport { BlockPackMetaEmbedAbsoluteBytes, RegistryV1 } from \"@platforma-sdk/block-tools\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport YAML from \"yaml\";\nimport { assertNever } from \"@milaboratories/ts-helpers\";\nimport { LegacyDevBlockPackFiles } from \"../dev_env\";\nimport { tryLoadPackDescription } from \"@platforma-sdk/block-tools\";\nimport { deriveRequiredCapabilities } from \"../mutator/block-pack/required_capabilities\";\nimport type { V2RegistryProvider } from \"./registry-v2-provider\";\nimport type {\n BlockPackId,\n BlockPackListing,\n BlockPackOverview,\n RegistryEntry,\n RegistryStatus,\n SingleBlockPackOverview,\n} from \"@milaboratories/pl-model-middle-layer\";\nimport { AnyChannel, StableChannel } from \"@milaboratories/pl-model-middle-layer\";\n\nasync function getFileContent(path: string) {\n try {\n return await fs.promises.readFile(path, \"utf8\");\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nasync function getFileStat(path: string) {\n try {\n return await fs.promises.stat(path, { bigint: true });\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nexport async function getDevV1PacketMtime(devPath: string): Promise<string> {\n let mtime = 0n;\n for (const f of LegacyDevBlockPackFiles) {\n const fullPath = path.join(devPath, ...f);\n const stat = await getFileStat(fullPath);\n if (stat === undefined) continue;\n if (mtime < stat.mtimeNs) mtime = stat.mtimeNs;\n }\n return mtime.toString();\n}\n\nexport async function getDevV2PacketMtime(\n description: BlockPackDescriptionAbsolute,\n): Promise<string> {\n const wfStats = await fs.promises.stat(description.components.workflow.main.file, {\n bigint: true,\n });\n const modelStats = await fs.promises.stat(description.components.model.file, { bigint: true });\n return (wfStats.mtimeNs > modelStats.mtimeNs ? wfStats.mtimeNs : modelStats.mtimeNs).toString();\n}\n\nexport class BlockPackRegistry {\n constructor(\n private readonly v2Provider: V2RegistryProvider,\n private readonly registries: RegistryEntry[],\n private readonly http?: Dispatcher,\n ) {}\n\n private async getPackagesForRoot(\n regEntry: RegistryEntry,\n options?: { signal?: AbortSignal },\n ): Promise<BlockPackOverview[]> {\n const result: BlockPackOverview[] = [];\n const regSpec = regEntry.spec;\n switch (regSpec.type) {\n case \"remote-v1\": {\n const httpOptions = this.http !== undefined ? { dispatcher: this.http } : {};\n\n const overviewResponse = await request(`${regSpec.url}/${RegistryV1.GlobalOverviewPath}`, {\n ...httpOptions,\n signal: options?.signal,\n });\n const overview = (await overviewResponse.body.json()) as RegistryV1.GlobalOverview;\n for (const overviewEntry of overview) {\n const { organization, package: pkg, latestMeta, latestVersion } = overviewEntry;\n const id = {\n organization,\n name: pkg,\n version: latestVersion,\n };\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (latestMeta[\"title\"] as string | undefined) ?? \"No title\",\n description: (latestMeta[\"description\"] as string | undefined) ?? \"No Description\",\n organization: {\n name: organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"from-registry-v1\",\n id,\n registryUrl: regSpec.url,\n },\n };\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: overviewEntry.allVersions.map((v) => ({ version: v, channels: [] })),\n });\n }\n return result;\n }\n\n case \"remote-v2\":\n return (\n await this.v2Provider.getRegistry(regSpec.url).listBlockPacks({ signal: options?.signal })\n ).map((e) => ({\n ...e,\n registryId: regEntry.id,\n }));\n // e.latestByChannel[StableChannel]\n // ? {\n // ...e,\n // registryId: regEntry.id,\n // }\n // : {\n // ...e,\n // latestByChannel: {\n // ...e.latestByChannel,\n // [StableChannel]: ((s: SingleBlockPackOverview) => {\n // if (s.spec.type === 'from-registry-v2') {\n // return { ...s, spec: { ...s.spec, channel: StableChannel } };\n // }\n\n // return s;\n // })(e.latestByChannel[AnyChannel]),\n // },\n // registryId: regEntry.id,\n // },\n\n case \"local-dev\":\n for (const entry of await fs.promises.readdir(regSpec.path, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const devPath = path.join(regSpec.path, entry.name);\n\n const legacyYamlContent = await getFileContent(\n path.join(devPath, RegistryV1.PlPackageYamlConfigFile),\n );\n if (legacyYamlContent !== undefined) {\n const config = RegistryV1.PlPackageConfigData.parse(YAML.parse(legacyYamlContent));\n\n const mtime = await getDevV1PacketMtime(devPath);\n\n const id = {\n organization: config.organization,\n name: config.package,\n version: \"DEV\",\n };\n\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (config.meta[\"title\"] as string) ?? \"No title\",\n description: (config.meta[\"description\"] as string) ?? \"No Description\",\n organization: {\n name: config.organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"dev-v2\",\n folder: devPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n } else {\n let actualDevPath = devPath;\n let v2Description = await tryLoadPackDescription(actualDevPath);\n\n if (v2Description === undefined)\n // iterating over expected subfolder names where block developer may put root block-pack package\n for (const bpSubfolder of [\"block\", \"meta\"]) {\n actualDevPath = path.join(devPath, bpSubfolder);\n v2Description = await tryLoadPackDescription(actualDevPath);\n if (v2Description !== undefined) break;\n }\n\n if (v2Description !== undefined) {\n const mtime = await getDevV2PacketMtime(v2Description);\n\n const meta = await BlockPackMetaEmbedAbsoluteBytes.parseAsync(v2Description.meta);\n\n // `tryLoadPackDescription` reads `package.json#block.meta` —\n // the dev SOURCE meta the developer wrote.\n // `requiredCapabilities` is a PACK-TIME artifact written by\n // `block-tools pack` into `block-pack/manifest.json`.\n // So for any dev block, the source meta never carries the field.\n //\n // To surface the gate at listing time without requiring the\n // developer to re-pack on every workflow change, derive from\n // the compiled workflow bytes directly.\n if (meta.requiredCapabilities === undefined) {\n const workflowBytes = await fs.promises.readFile(\n v2Description.components.workflow.main.file,\n );\n const derived = deriveRequiredCapabilities(workflowBytes);\n if (derived !== undefined) meta.requiredCapabilities = derived;\n }\n\n const latestOverview: SingleBlockPackOverview = {\n id: v2Description.id,\n meta,\n featureFlags: v2Description.featureFlags,\n spec: {\n type: \"dev-v2\",\n folder: actualDevPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id: v2Description.id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n }\n }\n\n continue;\n }\n return result;\n default:\n return assertNever(regSpec);\n }\n }\n\n public async listBlockPacks(options?: { signal?: AbortSignal }): Promise<BlockPackListing> {\n const blockPacks: BlockPackOverview[] = [];\n const registries: RegistryStatus[] = [];\n for (const regSpecs of this.registries) {\n registries.push({ ...regSpecs, status: \"online\" });\n blockPacks.push(...(await this.getPackagesForRoot(regSpecs, options)));\n }\n return { registries, blockPacks };\n }\n\n public async getOverview(\n registryId: string,\n blockId: BlockPackId,\n channel: string,\n ): Promise<SingleBlockPackOverview> {\n const regSpec = this.registries.find((reg) => reg.id === registryId)?.spec;\n if (!regSpec) throw new Error(`Registry with id \"${registryId}\" not found`);\n if (regSpec.type !== \"remote-v2\")\n throw new Error(\n `Only \"remote-v2\" registries support specific package version overview retrieval.`,\n );\n const reg = this.v2Provider.getRegistry(regSpec.url);\n return await reg.getSpecificOverview(blockId, channel);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,eAAe,eAAe,MAAc;AAC1C,KAAI;AACF,SAAO,MAAMA,QAAAA,QAAG,SAAS,SAAS,MAAM,OAAO;UACxC,OAAgB;AACvB,MAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,SAC9D;AAEF,QAAM;;;AAIV,eAAe,YAAY,MAAc;AACvC,KAAI;AACF,SAAO,MAAMA,QAAAA,QAAG,SAAS,KAAK,MAAM,EAAE,QAAQ,MAAM,CAAC;UAC9C,OAAgB;AACvB,MAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,SAC9D;AAEF,QAAM;;;AAIV,eAAsB,oBAAoB,SAAkC;CAC1E,IAAI,QAAQ;AACZ,MAAK,MAAM,KAAKC,cAAAA,yBAAyB;EAEvC,MAAM,OAAO,MAAM,YADFC,UAAAA,QAAK,KAAK,SAAS,GAAG,EAAE,CACD;AACxC,MAAI,SAAS,KAAA,EAAW;AACxB,MAAI,QAAQ,KAAK,QAAS,SAAQ,KAAK;;AAEzC,QAAO,MAAM,UAAU;;AAGzB,eAAsB,oBACpB,aACiB;CACjB,MAAM,UAAU,MAAMF,QAAAA,QAAG,SAAS,KAAK,YAAY,WAAW,SAAS,KAAK,MAAM,EAChF,QAAQ,MACT,CAAC;CACF,MAAM,aAAa,MAAMA,QAA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.cjs","names":["fs","LegacyDevBlockPackFiles","path","RegistryV1","AnyChannel","StableChannel","YAML","deriveRequiredCapabilities"],"sources":["../../src/block_registry/registry.ts"],"sourcesContent":["import type { Dispatcher } from \"undici\";\nimport { request } from \"undici\";\nimport type { BlockPackDescriptionAbsolute } from \"@platforma-sdk/block-tools\";\nimport { embedBlockPackMetaAbsoluteBytes, RegistryV1 } from \"@platforma-sdk/block-tools\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport YAML from \"yaml\";\nimport { assertNever } from \"@milaboratories/ts-helpers\";\nimport { LegacyDevBlockPackFiles } from \"../dev_env\";\nimport { tryLoadPackDescription } from \"@platforma-sdk/block-tools\";\nimport { deriveRequiredCapabilities } from \"../mutator/block-pack/required_capabilities\";\nimport type { V2RegistryProvider } from \"./registry-v2-provider\";\nimport type {\n BlockPackId,\n BlockPackListing,\n BlockPackOverview,\n RegistryEntry,\n RegistryStatus,\n SingleBlockPackOverview,\n} from \"@milaboratories/pl-model-middle-layer\";\nimport { AnyChannel, StableChannel } from \"@milaboratories/pl-model-middle-layer\";\n\nasync function getFileContent(path: string) {\n try {\n return await fs.promises.readFile(path, \"utf8\");\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nasync function getFileStat(path: string) {\n try {\n return await fs.promises.stat(path, { bigint: true });\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nexport async function getDevV1PacketMtime(devPath: string): Promise<string> {\n let mtime = 0n;\n for (const f of LegacyDevBlockPackFiles) {\n const fullPath = path.join(devPath, ...f);\n const stat = await getFileStat(fullPath);\n if (stat === undefined) continue;\n if (mtime < stat.mtimeNs) mtime = stat.mtimeNs;\n }\n return mtime.toString();\n}\n\nexport async function getDevV2PacketMtime(\n description: BlockPackDescriptionAbsolute,\n): Promise<string> {\n const wfStats = await fs.promises.stat(description.components.workflow.main.file, {\n bigint: true,\n });\n const modelStats = await fs.promises.stat(description.components.model.file, { bigint: true });\n return (wfStats.mtimeNs > modelStats.mtimeNs ? wfStats.mtimeNs : modelStats.mtimeNs).toString();\n}\n\nexport class BlockPackRegistry {\n constructor(\n private readonly v2Provider: V2RegistryProvider,\n private readonly registries: RegistryEntry[],\n private readonly http?: Dispatcher,\n ) {}\n\n private async getPackagesForRoot(\n regEntry: RegistryEntry,\n options?: { signal?: AbortSignal },\n ): Promise<BlockPackOverview[]> {\n const result: BlockPackOverview[] = [];\n const regSpec = regEntry.spec;\n switch (regSpec.type) {\n case \"remote-v1\": {\n const httpOptions = this.http !== undefined ? { dispatcher: this.http } : {};\n\n const overviewResponse = await request(`${regSpec.url}/${RegistryV1.GlobalOverviewPath}`, {\n ...httpOptions,\n signal: options?.signal,\n });\n const overview = (await overviewResponse.body.json()) as RegistryV1.GlobalOverview;\n for (const overviewEntry of overview) {\n const { organization, package: pkg, latestMeta, latestVersion } = overviewEntry;\n const id = {\n organization,\n name: pkg,\n version: latestVersion,\n };\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (latestMeta[\"title\"] as string | undefined) ?? \"No title\",\n description: (latestMeta[\"description\"] as string | undefined) ?? \"No Description\",\n organization: {\n name: organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"from-registry-v1\",\n id,\n registryUrl: regSpec.url,\n },\n };\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: overviewEntry.allVersions.map((v) => ({ version: v, channels: [] })),\n });\n }\n return result;\n }\n\n case \"remote-v2\":\n return (\n await this.v2Provider.getRegistry(regSpec.url).listBlockPacks({ signal: options?.signal })\n ).map((e) => ({\n ...e,\n registryId: regEntry.id,\n }));\n // e.latestByChannel[StableChannel]\n // ? {\n // ...e,\n // registryId: regEntry.id,\n // }\n // : {\n // ...e,\n // latestByChannel: {\n // ...e.latestByChannel,\n // [StableChannel]: ((s: SingleBlockPackOverview) => {\n // if (s.spec.type === 'from-registry-v2') {\n // return { ...s, spec: { ...s.spec, channel: StableChannel } };\n // }\n\n // return s;\n // })(e.latestByChannel[AnyChannel]),\n // },\n // registryId: regEntry.id,\n // },\n\n case \"local-dev\":\n for (const entry of await fs.promises.readdir(regSpec.path, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const devPath = path.join(regSpec.path, entry.name);\n\n const legacyYamlContent = await getFileContent(\n path.join(devPath, RegistryV1.PlPackageYamlConfigFile),\n );\n if (legacyYamlContent !== undefined) {\n const config = RegistryV1.PlPackageConfigData.parse(YAML.parse(legacyYamlContent));\n\n const mtime = await getDevV1PacketMtime(devPath);\n\n const id = {\n organization: config.organization,\n name: config.package,\n version: \"DEV\",\n };\n\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (config.meta[\"title\"] as string) ?? \"No title\",\n description: (config.meta[\"description\"] as string) ?? \"No Description\",\n organization: {\n name: config.organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"dev-v2\",\n folder: devPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n } else {\n let actualDevPath = devPath;\n let v2Description = await tryLoadPackDescription(actualDevPath);\n\n if (v2Description === undefined)\n // iterating over expected subfolder names where block developer may put root block-pack package\n for (const bpSubfolder of [\"block\", \"meta\"]) {\n actualDevPath = path.join(devPath, bpSubfolder);\n v2Description = await tryLoadPackDescription(actualDevPath);\n if (v2Description !== undefined) break;\n }\n\n if (v2Description !== undefined) {\n const mtime = await getDevV2PacketMtime(v2Description);\n\n const meta = await embedBlockPackMetaAbsoluteBytes(v2Description.meta);\n\n // `tryLoadPackDescription` reads `package.json#block.meta` —\n // the dev SOURCE meta the developer wrote.\n // `requiredCapabilities` is a PACK-TIME artifact written by\n // `block-tools pack` into `block-pack/manifest.json`.\n // So for any dev block, the source meta never carries the field.\n //\n // To surface the gate at listing time without requiring the\n // developer to re-pack on every workflow change, derive from\n // the compiled workflow bytes directly.\n if (meta.requiredCapabilities === undefined) {\n const workflowBytes = await fs.promises.readFile(\n v2Description.components.workflow.main.file,\n );\n const derived = deriveRequiredCapabilities(workflowBytes);\n if (derived !== undefined) meta.requiredCapabilities = derived;\n }\n\n const latestOverview: SingleBlockPackOverview = {\n id: v2Description.id,\n meta,\n featureFlags: v2Description.featureFlags,\n spec: {\n type: \"dev-v2\",\n folder: actualDevPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id: v2Description.id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n }\n }\n\n continue;\n }\n return result;\n default:\n return assertNever(regSpec);\n }\n }\n\n public async listBlockPacks(options?: { signal?: AbortSignal }): Promise<BlockPackListing> {\n const blockPacks: BlockPackOverview[] = [];\n const registries: RegistryStatus[] = [];\n for (const regSpecs of this.registries) {\n registries.push({ ...regSpecs, status: \"online\" });\n blockPacks.push(...(await this.getPackagesForRoot(regSpecs, options)));\n }\n return { registries, blockPacks };\n }\n\n public async getOverview(\n registryId: string,\n blockId: BlockPackId,\n channel: string,\n ): Promise<SingleBlockPackOverview> {\n const regSpec = this.registries.find((reg) => reg.id === registryId)?.spec;\n if (!regSpec) throw new Error(`Registry with id \"${registryId}\" not found`);\n if (regSpec.type !== \"remote-v2\")\n throw new Error(\n `Only \"remote-v2\" registries support specific package version overview retrieval.`,\n );\n const reg = this.v2Provider.getRegistry(regSpec.url);\n return await reg.getSpecificOverview(blockId, channel);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,eAAe,eAAe,MAAc;AAC1C,KAAI;AACF,SAAO,MAAMA,QAAAA,QAAG,SAAS,SAAS,MAAM,OAAO;UACxC,OAAgB;AACvB,MAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,SAC9D;AAEF,Q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E,SAAA,GAAA,2BAAA,aAAmB,QAAQ;;;CAIjC,MAAa,eAAe,SAA+D;EACzF,MAAM,aAAkC,EAAE;EAC1C,MAAM,aAA+B,EAAE;AACvC,OAAK,MAAM,YAAY,KAAK,YAAY;AACtC,cAAW,KAAK;IAAE,GAAG;IAAU,QAAQ;IAAU,CAAC;AAClD,cAAW,KAAK,GAAI,MAAM,KAAK,mBAAmB,UAAU,QAAQ,CAAE;;AAExE,SAAO;GAAE;GAAY;GAAY;;CAGnC,MAAa,YACX,YACA,SACA,SACkC;EAClC,MAAM,UAAU,KAAK,WAAW,MAAM,QAAQ,IAAI,OAAO,WAAW,EAAE;AACtE,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,qBAAqB,WAAW,aAAa;AAC3E,MAAI,QAAQ,SAAS,YACnB,OAAM,IAAI,MACR,mFACD;AAEH,SAAO,MADK,KAAK,WAAW,YAAY,QAAQ,IAAI,CACnC,oBAAoB,SAAS,QAAQ"}
|
|
@@ -2,7 +2,7 @@ import { LegacyDevBlockPackFiles } from "../dev_env/index.js";
|
|
|
2
2
|
import { deriveRequiredCapabilities } from "../mutator/block-pack/required_capabilities.js";
|
|
3
3
|
import { AnyChannel, StableChannel } from "@milaboratories/pl-model-middle-layer";
|
|
4
4
|
import { request } from "undici";
|
|
5
|
-
import {
|
|
5
|
+
import { RegistryV1, embedBlockPackMetaAbsoluteBytes, tryLoadPackDescription } from "@platforma-sdk/block-tools";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import YAML from "yaml";
|
|
@@ -144,7 +144,7 @@ var BlockPackRegistry = class {
|
|
|
144
144
|
}
|
|
145
145
|
if (v2Description !== void 0) {
|
|
146
146
|
const mtime = await getDevV2PacketMtime(v2Description);
|
|
147
|
-
const meta = await
|
|
147
|
+
const meta = await embedBlockPackMetaAbsoluteBytes(v2Description.meta);
|
|
148
148
|
if (meta.requiredCapabilities === void 0) {
|
|
149
149
|
const derived = deriveRequiredCapabilities(await fs.promises.readFile(v2Description.components.workflow.main.file));
|
|
150
150
|
if (derived !== void 0) meta.requiredCapabilities = derived;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../../src/block_registry/registry.ts"],"sourcesContent":["import type { Dispatcher } from \"undici\";\nimport { request } from \"undici\";\nimport type { BlockPackDescriptionAbsolute } from \"@platforma-sdk/block-tools\";\nimport { BlockPackMetaEmbedAbsoluteBytes, RegistryV1 } from \"@platforma-sdk/block-tools\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport YAML from \"yaml\";\nimport { assertNever } from \"@milaboratories/ts-helpers\";\nimport { LegacyDevBlockPackFiles } from \"../dev_env\";\nimport { tryLoadPackDescription } from \"@platforma-sdk/block-tools\";\nimport { deriveRequiredCapabilities } from \"../mutator/block-pack/required_capabilities\";\nimport type { V2RegistryProvider } from \"./registry-v2-provider\";\nimport type {\n BlockPackId,\n BlockPackListing,\n BlockPackOverview,\n RegistryEntry,\n RegistryStatus,\n SingleBlockPackOverview,\n} from \"@milaboratories/pl-model-middle-layer\";\nimport { AnyChannel, StableChannel } from \"@milaboratories/pl-model-middle-layer\";\n\nasync function getFileContent(path: string) {\n try {\n return await fs.promises.readFile(path, \"utf8\");\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nasync function getFileStat(path: string) {\n try {\n return await fs.promises.stat(path, { bigint: true });\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nexport async function getDevV1PacketMtime(devPath: string): Promise<string> {\n let mtime = 0n;\n for (const f of LegacyDevBlockPackFiles) {\n const fullPath = path.join(devPath, ...f);\n const stat = await getFileStat(fullPath);\n if (stat === undefined) continue;\n if (mtime < stat.mtimeNs) mtime = stat.mtimeNs;\n }\n return mtime.toString();\n}\n\nexport async function getDevV2PacketMtime(\n description: BlockPackDescriptionAbsolute,\n): Promise<string> {\n const wfStats = await fs.promises.stat(description.components.workflow.main.file, {\n bigint: true,\n });\n const modelStats = await fs.promises.stat(description.components.model.file, { bigint: true });\n return (wfStats.mtimeNs > modelStats.mtimeNs ? wfStats.mtimeNs : modelStats.mtimeNs).toString();\n}\n\nexport class BlockPackRegistry {\n constructor(\n private readonly v2Provider: V2RegistryProvider,\n private readonly registries: RegistryEntry[],\n private readonly http?: Dispatcher,\n ) {}\n\n private async getPackagesForRoot(\n regEntry: RegistryEntry,\n options?: { signal?: AbortSignal },\n ): Promise<BlockPackOverview[]> {\n const result: BlockPackOverview[] = [];\n const regSpec = regEntry.spec;\n switch (regSpec.type) {\n case \"remote-v1\": {\n const httpOptions = this.http !== undefined ? { dispatcher: this.http } : {};\n\n const overviewResponse = await request(`${regSpec.url}/${RegistryV1.GlobalOverviewPath}`, {\n ...httpOptions,\n signal: options?.signal,\n });\n const overview = (await overviewResponse.body.json()) as RegistryV1.GlobalOverview;\n for (const overviewEntry of overview) {\n const { organization, package: pkg, latestMeta, latestVersion } = overviewEntry;\n const id = {\n organization,\n name: pkg,\n version: latestVersion,\n };\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (latestMeta[\"title\"] as string | undefined) ?? \"No title\",\n description: (latestMeta[\"description\"] as string | undefined) ?? \"No Description\",\n organization: {\n name: organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"from-registry-v1\",\n id,\n registryUrl: regSpec.url,\n },\n };\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: overviewEntry.allVersions.map((v) => ({ version: v, channels: [] })),\n });\n }\n return result;\n }\n\n case \"remote-v2\":\n return (\n await this.v2Provider.getRegistry(regSpec.url).listBlockPacks({ signal: options?.signal })\n ).map((e) => ({\n ...e,\n registryId: regEntry.id,\n }));\n // e.latestByChannel[StableChannel]\n // ? {\n // ...e,\n // registryId: regEntry.id,\n // }\n // : {\n // ...e,\n // latestByChannel: {\n // ...e.latestByChannel,\n // [StableChannel]: ((s: SingleBlockPackOverview) => {\n // if (s.spec.type === 'from-registry-v2') {\n // return { ...s, spec: { ...s.spec, channel: StableChannel } };\n // }\n\n // return s;\n // })(e.latestByChannel[AnyChannel]),\n // },\n // registryId: regEntry.id,\n // },\n\n case \"local-dev\":\n for (const entry of await fs.promises.readdir(regSpec.path, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const devPath = path.join(regSpec.path, entry.name);\n\n const legacyYamlContent = await getFileContent(\n path.join(devPath, RegistryV1.PlPackageYamlConfigFile),\n );\n if (legacyYamlContent !== undefined) {\n const config = RegistryV1.PlPackageConfigData.parse(YAML.parse(legacyYamlContent));\n\n const mtime = await getDevV1PacketMtime(devPath);\n\n const id = {\n organization: config.organization,\n name: config.package,\n version: \"DEV\",\n };\n\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (config.meta[\"title\"] as string) ?? \"No title\",\n description: (config.meta[\"description\"] as string) ?? \"No Description\",\n organization: {\n name: config.organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"dev-v2\",\n folder: devPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n } else {\n let actualDevPath = devPath;\n let v2Description = await tryLoadPackDescription(actualDevPath);\n\n if (v2Description === undefined)\n // iterating over expected subfolder names where block developer may put root block-pack package\n for (const bpSubfolder of [\"block\", \"meta\"]) {\n actualDevPath = path.join(devPath, bpSubfolder);\n v2Description = await tryLoadPackDescription(actualDevPath);\n if (v2Description !== undefined) break;\n }\n\n if (v2Description !== undefined) {\n const mtime = await getDevV2PacketMtime(v2Description);\n\n const meta = await BlockPackMetaEmbedAbsoluteBytes.parseAsync(v2Description.meta);\n\n // `tryLoadPackDescription` reads `package.json#block.meta` —\n // the dev SOURCE meta the developer wrote.\n // `requiredCapabilities` is a PACK-TIME artifact written by\n // `block-tools pack` into `block-pack/manifest.json`.\n // So for any dev block, the source meta never carries the field.\n //\n // To surface the gate at listing time without requiring the\n // developer to re-pack on every workflow change, derive from\n // the compiled workflow bytes directly.\n if (meta.requiredCapabilities === undefined) {\n const workflowBytes = await fs.promises.readFile(\n v2Description.components.workflow.main.file,\n );\n const derived = deriveRequiredCapabilities(workflowBytes);\n if (derived !== undefined) meta.requiredCapabilities = derived;\n }\n\n const latestOverview: SingleBlockPackOverview = {\n id: v2Description.id,\n meta,\n featureFlags: v2Description.featureFlags,\n spec: {\n type: \"dev-v2\",\n folder: actualDevPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id: v2Description.id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n }\n }\n\n continue;\n }\n return result;\n default:\n return assertNever(regSpec);\n }\n }\n\n public async listBlockPacks(options?: { signal?: AbortSignal }): Promise<BlockPackListing> {\n const blockPacks: BlockPackOverview[] = [];\n const registries: RegistryStatus[] = [];\n for (const regSpecs of this.registries) {\n registries.push({ ...regSpecs, status: \"online\" });\n blockPacks.push(...(await this.getPackagesForRoot(regSpecs, options)));\n }\n return { registries, blockPacks };\n }\n\n public async getOverview(\n registryId: string,\n blockId: BlockPackId,\n channel: string,\n ): Promise<SingleBlockPackOverview> {\n const regSpec = this.registries.find((reg) => reg.id === registryId)?.spec;\n if (!regSpec) throw new Error(`Registry with id \"${registryId}\" not found`);\n if (regSpec.type !== \"remote-v2\")\n throw new Error(\n `Only \"remote-v2\" registries support specific package version overview retrieval.`,\n );\n const reg = this.v2Provider.getRegistry(regSpec.url);\n return await reg.getSpecificOverview(blockId, channel);\n }\n}\n"],"mappings":";;;;;;;;;;AAsBA,eAAe,eAAe,MAAc;AAC1C,KAAI;AACF,SAAO,MAAM,GAAG,SAAS,SAAS,MAAM,OAAO;UACxC,OAAgB;AACvB,M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U,QAAQ;IAAU,CAAC;AAClD,cAAW,KAAK,GAAI,MAAM,KAAK,mBAAmB,UAAU,QAAQ,CAAE;;AAExE,SAAO;GAAE;GAAY;GAAY;;CAGnC,MAAa,YACX,YACA,SACA,SACkC;EAClC,MAAM,UAAU,KAAK,WAAW,MAAM,QAAQ,IAAI,OAAO,WAAW,EAAE;AACtE,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,qBAAqB,WAAW,aAAa;AAC3E,MAAI,QAAQ,SAAS,YACnB,OAAM,IAAI,MACR,mFACD;AAEH,SAAO,MADK,KAAK,WAAW,YAAY,QAAQ,IAAI,CACnC,oBAAoB,SAAS,QAAQ"}
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../src/block_registry/registry.ts"],"sourcesContent":["import type { Dispatcher } from \"undici\";\nimport { request } from \"undici\";\nimport type { BlockPackDescriptionAbsolute } from \"@platforma-sdk/block-tools\";\nimport { embedBlockPackMetaAbsoluteBytes, RegistryV1 } from \"@platforma-sdk/block-tools\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport YAML from \"yaml\";\nimport { assertNever } from \"@milaboratories/ts-helpers\";\nimport { LegacyDevBlockPackFiles } from \"../dev_env\";\nimport { tryLoadPackDescription } from \"@platforma-sdk/block-tools\";\nimport { deriveRequiredCapabilities } from \"../mutator/block-pack/required_capabilities\";\nimport type { V2RegistryProvider } from \"./registry-v2-provider\";\nimport type {\n BlockPackId,\n BlockPackListing,\n BlockPackOverview,\n RegistryEntry,\n RegistryStatus,\n SingleBlockPackOverview,\n} from \"@milaboratories/pl-model-middle-layer\";\nimport { AnyChannel, StableChannel } from \"@milaboratories/pl-model-middle-layer\";\n\nasync function getFileContent(path: string) {\n try {\n return await fs.promises.readFile(path, \"utf8\");\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nasync function getFileStat(path: string) {\n try {\n return await fs.promises.stat(path, { bigint: true });\n } catch (error: unknown) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return undefined;\n }\n throw error;\n }\n}\n\nexport async function getDevV1PacketMtime(devPath: string): Promise<string> {\n let mtime = 0n;\n for (const f of LegacyDevBlockPackFiles) {\n const fullPath = path.join(devPath, ...f);\n const stat = await getFileStat(fullPath);\n if (stat === undefined) continue;\n if (mtime < stat.mtimeNs) mtime = stat.mtimeNs;\n }\n return mtime.toString();\n}\n\nexport async function getDevV2PacketMtime(\n description: BlockPackDescriptionAbsolute,\n): Promise<string> {\n const wfStats = await fs.promises.stat(description.components.workflow.main.file, {\n bigint: true,\n });\n const modelStats = await fs.promises.stat(description.components.model.file, { bigint: true });\n return (wfStats.mtimeNs > modelStats.mtimeNs ? wfStats.mtimeNs : modelStats.mtimeNs).toString();\n}\n\nexport class BlockPackRegistry {\n constructor(\n private readonly v2Provider: V2RegistryProvider,\n private readonly registries: RegistryEntry[],\n private readonly http?: Dispatcher,\n ) {}\n\n private async getPackagesForRoot(\n regEntry: RegistryEntry,\n options?: { signal?: AbortSignal },\n ): Promise<BlockPackOverview[]> {\n const result: BlockPackOverview[] = [];\n const regSpec = regEntry.spec;\n switch (regSpec.type) {\n case \"remote-v1\": {\n const httpOptions = this.http !== undefined ? { dispatcher: this.http } : {};\n\n const overviewResponse = await request(`${regSpec.url}/${RegistryV1.GlobalOverviewPath}`, {\n ...httpOptions,\n signal: options?.signal,\n });\n const overview = (await overviewResponse.body.json()) as RegistryV1.GlobalOverview;\n for (const overviewEntry of overview) {\n const { organization, package: pkg, latestMeta, latestVersion } = overviewEntry;\n const id = {\n organization,\n name: pkg,\n version: latestVersion,\n };\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (latestMeta[\"title\"] as string | undefined) ?? \"No title\",\n description: (latestMeta[\"description\"] as string | undefined) ?? \"No Description\",\n organization: {\n name: organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"from-registry-v1\",\n id,\n registryUrl: regSpec.url,\n },\n };\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: overviewEntry.allVersions.map((v) => ({ version: v, channels: [] })),\n });\n }\n return result;\n }\n\n case \"remote-v2\":\n return (\n await this.v2Provider.getRegistry(regSpec.url).listBlockPacks({ signal: options?.signal })\n ).map((e) => ({\n ...e,\n registryId: regEntry.id,\n }));\n // e.latestByChannel[StableChannel]\n // ? {\n // ...e,\n // registryId: regEntry.id,\n // }\n // : {\n // ...e,\n // latestByChannel: {\n // ...e.latestByChannel,\n // [StableChannel]: ((s: SingleBlockPackOverview) => {\n // if (s.spec.type === 'from-registry-v2') {\n // return { ...s, spec: { ...s.spec, channel: StableChannel } };\n // }\n\n // return s;\n // })(e.latestByChannel[AnyChannel]),\n // },\n // registryId: regEntry.id,\n // },\n\n case \"local-dev\":\n for (const entry of await fs.promises.readdir(regSpec.path, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n const devPath = path.join(regSpec.path, entry.name);\n\n const legacyYamlContent = await getFileContent(\n path.join(devPath, RegistryV1.PlPackageYamlConfigFile),\n );\n if (legacyYamlContent !== undefined) {\n const config = RegistryV1.PlPackageConfigData.parse(YAML.parse(legacyYamlContent));\n\n const mtime = await getDevV1PacketMtime(devPath);\n\n const id = {\n organization: config.organization,\n name: config.package,\n version: \"DEV\",\n };\n\n const latestOverview: SingleBlockPackOverview = {\n id,\n meta: {\n title: (config.meta[\"title\"] as string) ?? \"No title\",\n description: (config.meta[\"description\"] as string) ?? \"No Description\",\n organization: {\n name: config.organization,\n url: \"https://unknown.com\",\n },\n },\n spec: {\n type: \"dev-v2\",\n folder: devPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n } else {\n let actualDevPath = devPath;\n let v2Description = await tryLoadPackDescription(actualDevPath);\n\n if (v2Description === undefined)\n // iterating over expected subfolder names where block developer may put root block-pack package\n for (const bpSubfolder of [\"block\", \"meta\"]) {\n actualDevPath = path.join(devPath, bpSubfolder);\n v2Description = await tryLoadPackDescription(actualDevPath);\n if (v2Description !== undefined) break;\n }\n\n if (v2Description !== undefined) {\n const mtime = await getDevV2PacketMtime(v2Description);\n\n const meta = await embedBlockPackMetaAbsoluteBytes(v2Description.meta);\n\n // `tryLoadPackDescription` reads `package.json#block.meta` —\n // the dev SOURCE meta the developer wrote.\n // `requiredCapabilities` is a PACK-TIME artifact written by\n // `block-tools pack` into `block-pack/manifest.json`.\n // So for any dev block, the source meta never carries the field.\n //\n // To surface the gate at listing time without requiring the\n // developer to re-pack on every workflow change, derive from\n // the compiled workflow bytes directly.\n if (meta.requiredCapabilities === undefined) {\n const workflowBytes = await fs.promises.readFile(\n v2Description.components.workflow.main.file,\n );\n const derived = deriveRequiredCapabilities(workflowBytes);\n if (derived !== undefined) meta.requiredCapabilities = derived;\n }\n\n const latestOverview: SingleBlockPackOverview = {\n id: v2Description.id,\n meta,\n featureFlags: v2Description.featureFlags,\n spec: {\n type: \"dev-v2\",\n folder: actualDevPath,\n mtime,\n },\n };\n\n result.push({\n registryId: regEntry.id,\n id: v2Description.id,\n latestByChannel: {\n [AnyChannel]: latestOverview,\n [StableChannel]: latestOverview,\n },\n allVersions: [],\n });\n }\n }\n\n continue;\n }\n return result;\n default:\n return assertNever(regSpec);\n }\n }\n\n public async listBlockPacks(options?: { signal?: AbortSignal }): Promise<BlockPackListing> {\n const blockPacks: BlockPackOverview[] = [];\n const registries: RegistryStatus[] = [];\n for (const regSpecs of this.registries) {\n registries.push({ ...regSpecs, status: \"online\" });\n blockPacks.push(...(await this.getPackagesForRoot(regSpecs, options)));\n }\n return { registries, blockPacks };\n }\n\n public async getOverview(\n registryId: string,\n blockId: BlockPackId,\n channel: string,\n ): Promise<SingleBlockPackOverview> {\n const regSpec = this.registries.find((reg) => reg.id === registryId)?.spec;\n if (!regSpec) throw new Error(`Registry with id \"${registryId}\" not found`);\n if (regSpec.type !== \"remote-v2\")\n throw new Error(\n `Only \"remote-v2\" registries support specific package version overview retrieval.`,\n );\n const reg = this.v2Provider.getRegistry(regSpec.url);\n return await reg.getSpecificOverview(blockId, channel);\n }\n}\n"],"mappings":";;;;;;;;;;AAsBA,eAAe,eAAe,MAAc;AAC1C,KAAI;AACF,SAAO,MAAM,GAAG,SAAS,SAAS,MAAM,OAAO;UACxC,OAAgB;AACvB,MAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,SAC9D;AAEF,QAAM;;;AAIV,eAAe,YAAY,MAAc;AACvC,KAAI;AACF,SAAO,MAAM,GAAG,SAAS,KAAK,MAAM,EAAE,QAAQ,MAAM,CAAC;UAC9C,OAAgB;AACvB,MAAI,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,SAC9D;AAEF,QAAM;;;AAIV,eAAsB,oBAAoB,SAAkC;CAC1E,IAAI,QAAQ;AACZ,MAAK,MAAM,KAAK,yBAAyB;EAEvC,MAAM,OAAO,MAAM,YADF,KAAK,KAAK,SAAS,GAAG,EAAE,CACD;AACxC,MAAI,SAAS,KAAA,EAAW;AACxB,MAAI,QAAQ,KAAK,QAAS,SAAQ,KAAK;;AAEzC,QAAO,MAAM,UAAU;;AAGzB,eAAsB,oBACpB,aACiB;CACjB,MAAM,UAAU,MAAM,GAAG,SAAS,KAAK,YAAY,WAAW,SAAS,KAAK,MAAM,EAChF,QAAQ,MACT,CAAC;CACF,MAAM,aAAa,MAAM,GAAG,SAAS,KAAK,YAAY,WAAW,MAAM,MAAM,EAAE,QAAQ,MAAM,CAAC;AAC9F,SAAQ,QAAQ,UAAU,WAAW,UAAU,QAAQ,UAAU,WAAW,SAAS,UAAU;;AAGjG,IAAa,oBAAb,MAA+B;CAC7B,YACE,YACA,YACA,MACA;AAHiB,OAAA,aAAA;AACA,OAAA,aAAA;AACA,OAAA,OAAA;;CAGnB,MAAc,mBACZ,UACA,SAC8B;EA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,SAAS;QACrB,IAAI,cAAc;QAClB,iBAAiB;UACd,aAAa;UACb,gBAAgB;SAClB;QACD,aAAa,EAAE;QAChB,CAAC;;;;AAMR,WAAO;GACT,QACE,QAAO,YAAY,QAAQ;;;CAIjC,MAAa,eAAe,SAA+D;EACzF,MAAM,aAAkC,EAAE;EAC1C,MAAM,aAA+B,EAAE;AACvC,OAAK,MAAM,YAAY,KAAK,YAAY;AACtC,cAAW,KAAK;IAAE,GAAG;IAAU,QAAQ;IAAU,CAAC;AAClD,cAAW,KAAK,GAAI,MAAM,KAAK,mBAAmB,UAAU,QAAQ,CAAE;;AAExE,SAAO;GAAE;GAAY;GAAY;;CAGnC,MAAa,YACX,YACA,SACA,SACkC;EAClC,MAAM,UAAU,KAAK,WAAW,MAAM,QAAQ,IAAI,OAAO,WAAW,EAAE;AACtE,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,qBAAqB,WAAW,aAAa;AAC3E,MAAI,QAAQ,SAAS,YACnB,OAAM,IAAI,MACR,mFACD;AAEH,SAAO,MADK,KAAK,WAAW,YAAY,QAAQ,IAAI,CACnC,oBAAoB,SAAS,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.61.
|
|
3
|
+
"version": "1.61.7",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -30,24 +30,24 @@
|
|
|
30
30
|
"utility-types": "^3.11.0",
|
|
31
31
|
"yaml": "^2.8.0",
|
|
32
32
|
"zod": "~3.25.76",
|
|
33
|
-
"@milaboratories/
|
|
33
|
+
"@milaboratories/computable": "2.9.4",
|
|
34
34
|
"@milaboratories/helpers": "1.14.2",
|
|
35
35
|
"@milaboratories/pl-client": "3.9.0",
|
|
36
|
-
"@milaboratories/computable": "2.9.4",
|
|
37
36
|
"@milaboratories/pl-deployments": "3.0.1",
|
|
38
|
-
"@milaboratories/pf-
|
|
39
|
-
"@milaboratories/
|
|
37
|
+
"@milaboratories/pf-driver": "1.4.14",
|
|
38
|
+
"@milaboratories/pf-spec-driver": "1.3.19",
|
|
40
39
|
"@milaboratories/pl-drivers": "1.14.12",
|
|
41
40
|
"@milaboratories/pl-errors": "1.4.12",
|
|
42
41
|
"@milaboratories/pl-model-backend": "1.3.3",
|
|
42
|
+
"@milaboratories/pl-http": "1.2.4",
|
|
43
43
|
"@milaboratories/pl-model-common": "1.42.0",
|
|
44
|
-
"@milaboratories/pl-
|
|
44
|
+
"@milaboratories/pl-tree": "1.12.2",
|
|
45
|
+
"@milaboratories/pl-model-middle-layer": "1.22.0",
|
|
45
46
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
46
47
|
"@milaboratories/ts-helpers": "1.8.2",
|
|
47
|
-
"@
|
|
48
|
-
"@platforma-sdk/model": "1.77.
|
|
49
|
-
"@platforma-sdk/workflow-tengo": "5.26.0"
|
|
50
|
-
"@platforma-sdk/block-tools": "2.8.3"
|
|
48
|
+
"@platforma-sdk/block-tools": "2.9.0",
|
|
49
|
+
"@platforma-sdk/model": "1.77.11",
|
|
50
|
+
"@platforma-sdk/workflow-tengo": "5.26.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "~24.5.2",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"semver": "^7.7.2",
|
|
57
57
|
"typescript": "~5.9.3",
|
|
58
58
|
"vitest": "^4.1.3",
|
|
59
|
+
"@milaboratories/build-configs": "2.0.0",
|
|
59
60
|
"@milaboratories/ts-configs": "1.2.3",
|
|
60
|
-
"@milaboratories/ts-builder": "1.5.0"
|
|
61
|
-
"@milaboratories/build-configs": "2.0.0"
|
|
61
|
+
"@milaboratories/ts-builder": "1.5.0"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22.19.0"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Dispatcher } from "undici";
|
|
2
2
|
import { request } from "undici";
|
|
3
3
|
import type { BlockPackDescriptionAbsolute } from "@platforma-sdk/block-tools";
|
|
4
|
-
import {
|
|
4
|
+
import { embedBlockPackMetaAbsoluteBytes, RegistryV1 } from "@platforma-sdk/block-tools";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import YAML from "yaml";
|
|
@@ -208,7 +208,7 @@ export class BlockPackRegistry {
|
|
|
208
208
|
if (v2Description !== undefined) {
|
|
209
209
|
const mtime = await getDevV2PacketMtime(v2Description);
|
|
210
210
|
|
|
211
|
-
const meta = await
|
|
211
|
+
const meta = await embedBlockPackMetaAbsoluteBytes(v2Description.meta);
|
|
212
212
|
|
|
213
213
|
// `tryLoadPackDescription` reads `package.json#block.meta` —
|
|
214
214
|
// the dev SOURCE meta the developer wrote.
|