@platforma-sdk/block-tools 2.4.12 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/config-B2n8i1gx.js +3 -0
- package/dist/config-B2n8i1gx.js.map +1 -0
- package/dist/config-Dvh9BG_1.mjs +1700 -0
- package/dist/config-Dvh9BG_1.mjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -89
- package/dist/index.mjs.map +1 -1
- package/dist/v2/registry/registry.d.ts.map +1 -1
- package/dist/v2/registry/schema_public.d.ts +1 -0
- package/dist/v2/registry/schema_public.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/v2/registry/registry.ts +47 -23
- package/src/v2/registry/registry_reader.ts +4 -4
- package/src/v2/registry/schema_public.ts +3 -0
- package/dist/config-ClvGIy46.js +0 -3
- package/dist/config-ClvGIy46.js.map +0 -1
- package/dist/config-dqDSqXfz.mjs +0 -1675
- package/dist/config-dqDSqXfz.mjs.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/v2/registry/registry_reader.ts","../src/io/folder_reader.ts"],"sourcesContent":["import {\n BlockPackId,\n BlockPackIdNoVersion,\n blockPackIdNoVersionEquals,\n BlockPackManifest,\n BlockPackMetaEmbeddedBytes,\n BlockPackMetaManifest,\n BlockPackOverview,\n SingleBlockPackOverview\n} from '@milaboratories/pl-model-middle-layer';\nimport { FolderReader } from '../../io';\nimport canonicalize from 'canonicalize';\nimport {\n GlobalOverviewFileName,\n GlobalOverviewReg,\n MainPrefix,\n ManifestFileName,\n ManifestSuffix,\n packageContentPrefixInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\nimport { calculateSha256 } from '../../util';\nimport { retry, Retry2TimesWithDelay } from '@milaboratories/ts-helpers';\n\nexport type BlockPackOverviewNoRegLabel = Omit<BlockPackOverview, 'registryId'>;\n\nexport type RegistryV2ReaderOps = {\n /** Number of milliseconds to cache retrieved block list for */\n cacheBlockListFor: number;\n /** Number of milliseconds to keep cached retrieved block list for, if new requests returns error */\n keepStaleBlockListFor: number;\n};\n\nconst DefaultRegistryV2ReaderOps: RegistryV2ReaderOps = {\n cacheBlockListFor: 45e3, // 45 seconds\n keepStaleBlockListFor: 300e3 // 5 minutes\n};\n\nexport class RegistryV2Reader {\n private readonly v2RootFolderReader: FolderReader;\n private readonly ops: RegistryV2ReaderOps;\n\n constructor(\n private readonly registryReader: FolderReader,\n ops?: Partial<RegistryV2ReaderOps>\n ) {\n this.v2RootFolderReader = registryReader.relativeReader(MainPrefix);\n this.ops = { ...DefaultRegistryV2ReaderOps, ...(ops ?? {}) };\n }\n\n /**\n * Embeds meta infromation relative to registry root.\n * Meta information that looks like:\n *\n * */\n private readonly embeddedGlobalMetaCache = new LRUCache<\n string,\n BlockPackMetaEmbeddedBytes,\n { meta: BlockPackMetaManifest; relativeTo?: BlockPackId }\n >({\n max: 500,\n fetchMethod: async (_key, _staleValue, options) =>\n await retry(async () => {\n const contentReader =\n options.context.relativeTo !== undefined\n ? this.v2RootFolderReader\n .relativeReader(packageContentPrefixInsideV2(options.context.relativeTo))\n .getContentReader()\n : this.v2RootFolderReader.getContentReader();\n return await BlockPackMetaEmbedBytes(contentReader).parseAsync(options.context.meta);\n }, Retry2TimesWithDelay)\n });\n\n private async embedMetaContent(\n id: BlockPackId,\n sha256: string,\n absolutePath: boolean,\n meta: BlockPackMetaManifest\n ): Promise<BlockPackMetaEmbeddedBytes> {\n return await this.embeddedGlobalMetaCache.forceFetch(\n canonicalize({ id, sha256, absolutePath })!,\n { context: { meta, relativeTo: absolutePath ? undefined : id } }\n );\n }\n\n private listCacheTimestamp: number = 0;\n private listCache: BlockPackOverviewNoRegLabel[] | undefined = undefined;\n\n public async listBlockPacks(): Promise<BlockPackOverviewNoRegLabel[]> {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor\n )\n return this.listCache;\n try {\n return await retry(async () => {\n // const rootContentReader = this.v2RootFolderReader.getContentReader();\n const globalOverview = GlobalOverviewReg.parse(\n JSON.parse(\n Buffer.from(await this.v2RootFolderReader.readFile(GlobalOverviewFileName)).toString()\n )\n );\n\n const result = await Promise.all(\n globalOverview.packages.map(async (p) => {\n const byChannelEntries = await Promise.all(\n Object.entries(p.latestByChannel).map(async ([channel, data]) => [\n channel,\n {\n id: data.description.id,\n meta: await this.embedMetaContent(\n p.latest.id,\n p.latestManifestSha256,\n true,\n p.latest.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id: p.latest.id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n }\n ])\n );\n return {\n id: p.id,\n latestByChannel: Object.fromEntries(byChannelEntries),\n allVersions: p.allVersionsWithChannels\n } satisfies BlockPackOverviewNoRegLabel;\n })\n );\n\n this.listCache = result;\n this.listCacheTimestamp = Date.now();\n\n return result;\n }, Retry2TimesWithDelay);\n } catch (e: unknown) {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor\n )\n return this.listCache;\n throw e;\n }\n }\n\n public async getLatestOverview(\n id: BlockPackIdNoVersion,\n channel: string\n ): Promise<SingleBlockPackOverview | undefined> {\n return await retry(async () => {\n const overview = (await this.listBlockPacks()).find((e) =>\n blockPackIdNoVersionEquals(id, e.id)\n );\n if (overview === undefined) return undefined;\n return overview.latestByChannel[channel];\n }, Retry2TimesWithDelay);\n }\n\n public async getSpecificOverview(\n id: BlockPackId,\n channel: string\n ): Promise<SingleBlockPackOverview> {\n return await retry(async () => {\n const manifestContent = await this.v2RootFolderReader.readFile(\n packageContentPrefixInsideV2(id) + ManifestSuffix\n );\n const overview = BlockPackManifest.parse(JSON.parse(Buffer.from(manifestContent).toString()));\n return {\n id: id,\n meta: await this.embedMetaContent(\n id,\n await calculateSha256(manifestContent),\n false,\n overview.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n };\n }, Retry2TimesWithDelay);\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) =>\n await retry(async () => {\n const packageFolderReader = this.v2RootFolderReader.relativeReader(\n packageContentPrefixInsideV2(id)\n );\n const manifest = BlockPackManifest.parse(\n JSON.parse(Buffer.from(await packageFolderReader.readFile(ManifestFileName)).toString())\n );\n return BlockComponentsAbsoluteUrl(packageFolderReader.rootUrl.toString()).parse(\n manifest.description.components\n );\n }, Retry2TimesWithDelay)\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Dispatcher, request } from 'undici';\nimport { RelativeContentReader } from '../v2';\nimport path from 'node:path';\nimport pathPosix from 'node:path/posix';\nimport fsp from 'node:fs/promises';\nimport { defaultHttpDispatcher } from '@milaboratories/pl-http';\n\nexport interface FolderReader {\n readonly rootUrl: URL;\n relativeReader(relativePath: string): FolderReader;\n readFile(file: string): Promise<Buffer>;\n getContentReader(relativePath?: string): RelativeContentReader;\n}\n\nclass HttpFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly httpDispatcher: Dispatcher\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetUrl = new URL(file, this.rootUrl);\n const response = await request(targetUrl, {\n dispatcher: this.httpDispatcher\n });\n return Buffer.from(await response.body.arrayBuffer());\n }\n\n public relativeReader(relativePath: string): HttpFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new HttpFolderReader(new URL(relativePath, this.rootUrl), this.httpDispatcher);\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: HttpFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nclass FSFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly root: string\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetPath = path.join(this.root, ...file.split(pathPosix.sep));\n return await fsp.readFile(targetPath);\n }\n\n public relativeReader(relativePath: string): FSFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new FSFolderReader(\n new URL(relativePath, this.rootUrl),\n path.join(this.root, ...relativePath.split(pathPosix.sep))\n );\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: FSFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nfunction posixToLocalPath(p: string): string {\n return p.split(pathPosix.sep).join(path.sep);\n}\n\nfunction localToPosix(p: string): string {\n return p.split(path.sep).join(pathPosix.sep);\n}\n\nexport function folderReaderByUrl(address: string, httpDispatcher?: Dispatcher): FolderReader {\n if (!address.endsWith('/')) address = address + '/';\n const url = new URL(address, `file:${localToPosix(path.resolve('.'))}/`);\n switch (url.protocol) {\n case 'file:':\n const rootPath = posixToLocalPath(url.pathname);\n return new FSFolderReader(url, rootPath);\n case 'https:':\n case 'http:':\n return new HttpFolderReader(url, httpDispatcher ?? defaultHttpDispatcher());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","retry","contentReader","packageContentPrefixInsideV2","BlockPackMetaEmbedBytes","Retry2TimesWithDelay","key","staleValue","id","packageFolderReader","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","sha256","absolutePath","meta","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","byChannelEntries","channel","data","e","overview","blockPackIdNoVersionEquals","manifestContent","ManifestSuffix","calculateSha256","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","defaultHttpDispatcher"],"mappings":"upBAkCMA,EAAkD,CACtD,kBAAmB,KACnB,sBAAuB,GACzB,EAEO,MAAMC,CAAiB,CAI5B,YACmBC,EACjBC,EACA,CANeC,EAAA,2BACAA,EAAA,YAeAA,EAAA,+BAA0B,IAAIC,EAAAA,SAI7C,CACA,IAAK,IACL,YAAa,MAAOC,EAAMC,EAAaC,IACrC,MAAMC,QAAM,SAAY,CACtB,MAAMC,EACJF,EAAQ,QAAQ,aAAe,OAC3B,KAAK,mBACF,eAAeG,EAAA,6BAA6BH,EAAQ,QAAQ,UAAU,CAAC,EACvE,mBACH,KAAK,mBAAmB,iBAAiB,EAC/C,OAAO,MAAMI,EAAwB,wBAAAF,CAAa,EAAE,WAAWF,EAAQ,QAAQ,IAAI,CAAA,EAClFK,EAAoB,oBAAA,CAAA,CAC1B,GAcOT,EAAA,0BAA6B,GAC7BA,EAAA,kBAsGSA,EAAA,uBAAkB,IAAIC,EAAAA,SAA0D,CAC/F,IAAK,IACL,YAAa,MAAOS,EAAKC,EAAY,CAAE,QAASC,CAAG,IACjD,MAAMP,EAAAA,MAAM,SAAY,CAChB,MAAAQ,EAAsB,KAAK,mBAAmB,eAClDN,EAAAA,6BAA6BK,CAAE,CACjC,EACME,EAAWC,EAAAA,kBAAkB,MACjC,KAAK,MAAM,OAAO,KAAK,MAAMF,EAAoB,SAASG,EAAAA,gBAAgB,CAAC,EAAE,SAAU,CAAA,CACzF,EACA,OAAOC,EAA2B,2BAAAJ,EAAoB,QAAQ,SAAA,CAAU,EAAE,MACxEC,EAAS,YAAY,UACvB,CAAA,EACCL,EAAoB,oBAAA,CAAA,CAC1B,GA/JkB,KAAA,eAAAX,EAGZ,KAAA,mBAAqBA,EAAe,eAAeoB,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,QAAQF,EAAaP,EAAK,QAAQ,GAAG,CAAC,CAAC,GAAG,EACvE,OAAQU,EAAI,SAAU,CACpB,IAAK,QACG,MAAAC,EAAWL,EAAiBI,EAAI,QAAQ,EACvC,OAAA,IAAIT,EAAeS,EAAKC,CAAQ,EACzC,IAAK,SACL,IAAK,QACH,OAAO,IAAIpB,EAAiBmB,EAAKjB,GAAkBmB,yBAAuB,EAC5E,QACE,MAAM,IAAI,MAAM,qBAAqBF,EAAI,QAAQ,EAAE,CAAA,CAEzD"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/v2/registry/registry_reader.ts","../src/io/folder_reader.ts"],"sourcesContent":["import {\n BlockPackId,\n BlockPackIdNoVersion,\n blockPackIdNoVersionEquals,\n BlockPackManifest,\n BlockPackMetaEmbeddedBytes,\n BlockPackMetaManifest,\n BlockPackOverview,\n SingleBlockPackOverview\n} from '@milaboratories/pl-model-middle-layer';\nimport { FolderReader } from '../../io';\nimport canonicalize from 'canonicalize';\nimport {\n GlobalOverviewFileName,\n GlobalOverviewReg,\n MainPrefix,\n ManifestFileName,\n ManifestSuffix,\n packageContentPrefixInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\nimport { calculateSha256 } from '../../util';\nimport { retry, Retry2TimesWithDelay } from '@milaboratories/ts-helpers';\n\nexport type BlockPackOverviewNoRegLabel = Omit<BlockPackOverview, 'registryId'>;\n\nexport type RegistryV2ReaderOps = {\n /** Number of milliseconds to cache retrieved block list for */\n cacheBlockListFor: number;\n /** Number of milliseconds to keep cached retrieved block list for, if new requests returns error */\n keepStaleBlockListFor: number;\n};\n\nconst DefaultRegistryV2ReaderOps: RegistryV2ReaderOps = {\n cacheBlockListFor: 45e3, // 45 seconds\n keepStaleBlockListFor: 300e3 // 5 minutes\n};\n\nexport class RegistryV2Reader {\n private readonly v2RootFolderReader: FolderReader;\n private readonly ops: RegistryV2ReaderOps;\n\n constructor(\n private readonly registryReader: FolderReader,\n ops?: Partial<RegistryV2ReaderOps>\n ) {\n this.v2RootFolderReader = registryReader.relativeReader(MainPrefix);\n this.ops = { ...DefaultRegistryV2ReaderOps, ...(ops ?? {}) };\n }\n\n /**\n * Embeds meta infromation relative to registry root.\n * Meta information that looks like:\n *\n * */\n private readonly embeddedGlobalMetaCache = new LRUCache<\n string,\n BlockPackMetaEmbeddedBytes,\n { meta: BlockPackMetaManifest; relativeTo?: BlockPackId }\n >({\n max: 500,\n fetchMethod: async (_key, _staleValue, options) =>\n await retry(async () => {\n const contentReader =\n options.context.relativeTo !== undefined\n ? this.v2RootFolderReader\n .relativeReader(packageContentPrefixInsideV2(options.context.relativeTo))\n .getContentReader()\n : this.v2RootFolderReader.getContentReader();\n return await BlockPackMetaEmbedBytes(contentReader).parseAsync(options.context.meta);\n }, Retry2TimesWithDelay)\n });\n\n private async embedMetaContent(\n id: BlockPackId,\n sha256: string,\n absolutePath: boolean,\n meta: BlockPackMetaManifest\n ): Promise<BlockPackMetaEmbeddedBytes> {\n return await this.embeddedGlobalMetaCache.forceFetch(\n canonicalize({ id, sha256, absolutePath })!,\n { context: { meta, relativeTo: absolutePath ? undefined : id } }\n );\n }\n\n private listCacheTimestamp: number = 0;\n private listCache: BlockPackOverviewNoRegLabel[] | undefined = undefined;\n\n public async listBlockPacks(): Promise<BlockPackOverviewNoRegLabel[]> {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor\n )\n return this.listCache;\n try {\n return await retry(async () => {\n // const rootContentReader = this.v2RootFolderReader.getContentReader();\n const globalOverview = GlobalOverviewReg.parse(\n JSON.parse(\n Buffer.from(await this.v2RootFolderReader.readFile(GlobalOverviewFileName)).toString()\n )\n );\n\n const result = await Promise.all(\n globalOverview.packages.map(async (p) => {\n const byChannelEntries = await Promise.all(\n Object.entries(p.latestByChannel).map(async ([channel, data]) => [\n channel,\n {\n id: data.description.id,\n meta: await this.embedMetaContent(\n data.description.id,\n data.manifestSha256,\n true,\n data.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id: data.description.id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n }\n ])\n );\n return {\n id: p.id,\n latestByChannel: Object.fromEntries(byChannelEntries),\n allVersions: p.allVersionsWithChannels\n } satisfies BlockPackOverviewNoRegLabel;\n })\n );\n\n this.listCache = result;\n this.listCacheTimestamp = Date.now();\n\n return result;\n }, Retry2TimesWithDelay);\n } catch (e: unknown) {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor\n )\n return this.listCache;\n throw e;\n }\n }\n\n public async getLatestOverview(\n id: BlockPackIdNoVersion,\n channel: string\n ): Promise<SingleBlockPackOverview | undefined> {\n return await retry(async () => {\n const overview = (await this.listBlockPacks()).find((e) =>\n blockPackIdNoVersionEquals(id, e.id)\n );\n if (overview === undefined) return undefined;\n return overview.latestByChannel[channel];\n }, Retry2TimesWithDelay);\n }\n\n public async getSpecificOverview(\n id: BlockPackId,\n channel: string\n ): Promise<SingleBlockPackOverview> {\n return await retry(async () => {\n const manifestContent = await this.v2RootFolderReader.readFile(\n packageContentPrefixInsideV2(id) + ManifestSuffix\n );\n const overview = BlockPackManifest.parse(JSON.parse(Buffer.from(manifestContent).toString()));\n return {\n id: id,\n meta: await this.embedMetaContent(\n id,\n await calculateSha256(manifestContent),\n false,\n overview.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n };\n }, Retry2TimesWithDelay);\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) =>\n await retry(async () => {\n const packageFolderReader = this.v2RootFolderReader.relativeReader(\n packageContentPrefixInsideV2(id)\n );\n const manifest = BlockPackManifest.parse(\n JSON.parse(Buffer.from(await packageFolderReader.readFile(ManifestFileName)).toString())\n );\n return BlockComponentsAbsoluteUrl(packageFolderReader.rootUrl.toString()).parse(\n manifest.description.components\n );\n }, Retry2TimesWithDelay)\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Dispatcher, request } from 'undici';\nimport { RelativeContentReader } from '../v2';\nimport path from 'node:path';\nimport pathPosix from 'node:path/posix';\nimport fsp from 'node:fs/promises';\nimport { defaultHttpDispatcher } from '@milaboratories/pl-http';\n\nexport interface FolderReader {\n readonly rootUrl: URL;\n relativeReader(relativePath: string): FolderReader;\n readFile(file: string): Promise<Buffer>;\n getContentReader(relativePath?: string): RelativeContentReader;\n}\n\nclass HttpFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly httpDispatcher: Dispatcher\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetUrl = new URL(file, this.rootUrl);\n const response = await request(targetUrl, {\n dispatcher: this.httpDispatcher\n });\n return Buffer.from(await response.body.arrayBuffer());\n }\n\n public relativeReader(relativePath: string): HttpFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new HttpFolderReader(new URL(relativePath, this.rootUrl), this.httpDispatcher);\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: HttpFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nclass FSFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly root: string\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetPath = path.join(this.root, ...file.split(pathPosix.sep));\n return await fsp.readFile(targetPath);\n }\n\n public relativeReader(relativePath: string): FSFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new FSFolderReader(\n new URL(relativePath, this.rootUrl),\n path.join(this.root, ...relativePath.split(pathPosix.sep))\n );\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: FSFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nfunction posixToLocalPath(p: string): string {\n return p.split(pathPosix.sep).join(path.sep);\n}\n\nfunction localToPosix(p: string): string {\n return p.split(path.sep).join(pathPosix.sep);\n}\n\nexport function folderReaderByUrl(address: string, httpDispatcher?: Dispatcher): FolderReader {\n if (!address.endsWith('/')) address = address + '/';\n const url = new URL(address, `file:${localToPosix(path.resolve('.'))}/`);\n switch (url.protocol) {\n case 'file:':\n const rootPath = posixToLocalPath(url.pathname);\n return new FSFolderReader(url, rootPath);\n case 'https:':\n case 'http:':\n return new HttpFolderReader(url, httpDispatcher ?? defaultHttpDispatcher());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","retry","contentReader","packageContentPrefixInsideV2","BlockPackMetaEmbedBytes","Retry2TimesWithDelay","key","staleValue","id","packageFolderReader","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","sha256","absolutePath","meta","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","byChannelEntries","channel","data","e","overview","blockPackIdNoVersionEquals","manifestContent","ManifestSuffix","calculateSha256","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","defaultHttpDispatcher"],"mappings":"upBAkCMA,EAAkD,CACtD,kBAAmB,KACnB,sBAAuB,GACzB,EAEO,MAAMC,CAAiB,CAI5B,YACmBC,EACjBC,EACA,CANeC,EAAA,2BACAA,EAAA,YAeAA,EAAA,+BAA0B,IAAIC,EAAAA,SAI7C,CACA,IAAK,IACL,YAAa,MAAOC,EAAMC,EAAaC,IACrC,MAAMC,QAAM,SAAY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
var y = (o, e, a) => e in o ? u(o, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[e] = a;
|
|
3
|
-
var
|
|
4
|
-
import { e as w, p as
|
|
5
|
-
import { U as me, T as fe, Y as
|
|
3
|
+
var s = (o, e, a) => y(o, typeof e != "symbol" ? e + "" : e, a);
|
|
4
|
+
import { e as w, p as h, f as R, G as C, h as P, i as B, j as F, M as b, k as x, m as O, n as T, o as S, q as D, r as M, t as U, u as E, v as L, P as V, w as G, x as N, y as j } from "./config-Dvh9BG_1.mjs";
|
|
5
|
+
import { U as me, T as fe, Y as ge, ae as ve, W as ke, X as ue, O as ye, a as we, B as Re, Q as Ce, b as Pe, a1 as Be, a0 as Fe, F as be, ad as xe, ab as Oe, ac as Te, aa as Se, ag as De, af as Me, a9 as Ue, a4 as Ee, $ as Le, a3 as Ve, V as Ge, R as Ne, z as je, S as Ae, D as Je, E as We, C as Ie, d as _e, H as ze, c as qe, l as $e, A as He, I as Ye, a8 as Ke, a7 as Qe, a2 as Xe, a6 as Ze, a5 as ea, Z as aa, K as ta, L as oa, N as ra, J as sa, s as ia, _ as na } from "./config-Dvh9BG_1.mjs";
|
|
6
6
|
import { request as A } from "undici";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import c from "node:path";
|
|
8
|
+
import d from "node:path/posix";
|
|
9
9
|
import J from "node:fs/promises";
|
|
10
10
|
import { defaultHttpDispatcher as W } from "@milaboratories/pl-http";
|
|
11
|
-
import { blockPackIdNoVersionEquals as I, BlockPackManifest as
|
|
11
|
+
import { blockPackIdNoVersionEquals as I, BlockPackManifest as g } from "@milaboratories/pl-model-middle-layer";
|
|
12
12
|
import v from "canonicalize";
|
|
13
13
|
import "zod";
|
|
14
14
|
import "mime-types";
|
|
15
15
|
import "tar";
|
|
16
16
|
import "@milaboratories/resolve-helper";
|
|
17
|
-
import { LRUCache as
|
|
18
|
-
import { retry as
|
|
17
|
+
import { LRUCache as k } from "lru-cache";
|
|
18
|
+
import { retry as n, Retry2TimesWithDelay as l } from "@milaboratories/ts-helpers";
|
|
19
19
|
const _ = {
|
|
20
20
|
cacheBlockListFor: 45e3,
|
|
21
21
|
// 45 seconds
|
|
@@ -24,83 +24,83 @@ const _ = {
|
|
|
24
24
|
};
|
|
25
25
|
class le {
|
|
26
26
|
constructor(e, a) {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
s(this, "v2RootFolderReader");
|
|
28
|
+
s(this, "ops");
|
|
29
29
|
/**
|
|
30
30
|
* Embeds meta infromation relative to registry root.
|
|
31
31
|
* Meta information that looks like:
|
|
32
32
|
*
|
|
33
33
|
* */
|
|
34
|
-
|
|
34
|
+
s(this, "embeddedGlobalMetaCache", new k({
|
|
35
35
|
max: 500,
|
|
36
|
-
fetchMethod: async (e, a, t) => await
|
|
37
|
-
const
|
|
38
|
-
return await R(
|
|
39
|
-
},
|
|
36
|
+
fetchMethod: async (e, a, t) => await n(async () => {
|
|
37
|
+
const r = t.context.relativeTo !== void 0 ? this.v2RootFolderReader.relativeReader(h(t.context.relativeTo)).getContentReader() : this.v2RootFolderReader.getContentReader();
|
|
38
|
+
return await R(r).parseAsync(t.context.meta);
|
|
39
|
+
}, l)
|
|
40
40
|
}));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
s(this, "listCacheTimestamp", 0);
|
|
42
|
+
s(this, "listCache");
|
|
43
|
+
s(this, "componentsCache", new k({
|
|
44
44
|
max: 500,
|
|
45
|
-
fetchMethod: async (e, a, { context: t }) => await
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
),
|
|
49
|
-
JSON.parse(Buffer.from(await
|
|
45
|
+
fetchMethod: async (e, a, { context: t }) => await n(async () => {
|
|
46
|
+
const r = this.v2RootFolderReader.relativeReader(
|
|
47
|
+
h(t)
|
|
48
|
+
), p = g.parse(
|
|
49
|
+
JSON.parse(Buffer.from(await r.readFile(b)).toString())
|
|
50
50
|
);
|
|
51
|
-
return x(
|
|
52
|
-
|
|
51
|
+
return x(r.rootUrl.toString()).parse(
|
|
52
|
+
p.description.components
|
|
53
53
|
);
|
|
54
|
-
},
|
|
54
|
+
}, l)
|
|
55
55
|
}));
|
|
56
56
|
this.registryReader = e, this.v2RootFolderReader = e.relativeReader(w), this.ops = { ..._, ...a ?? {} };
|
|
57
57
|
}
|
|
58
|
-
async embedMetaContent(e, a, t,
|
|
58
|
+
async embedMetaContent(e, a, t, r) {
|
|
59
59
|
return await this.embeddedGlobalMetaCache.forceFetch(
|
|
60
60
|
v({ id: e, sha256: a, absolutePath: t }),
|
|
61
|
-
{ context: { meta:
|
|
61
|
+
{ context: { meta: r, relativeTo: t ? void 0 : e } }
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
async listBlockPacks() {
|
|
65
65
|
if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor)
|
|
66
66
|
return this.listCache;
|
|
67
67
|
try {
|
|
68
|
-
return await
|
|
68
|
+
return await n(async () => {
|
|
69
69
|
const e = C.parse(
|
|
70
70
|
JSON.parse(
|
|
71
71
|
Buffer.from(await this.v2RootFolderReader.readFile(P)).toString()
|
|
72
72
|
)
|
|
73
73
|
), a = await Promise.all(
|
|
74
74
|
e.packages.map(async (t) => {
|
|
75
|
-
const
|
|
76
|
-
Object.entries(t.latestByChannel).map(async ([
|
|
77
|
-
|
|
75
|
+
const r = await Promise.all(
|
|
76
|
+
Object.entries(t.latestByChannel).map(async ([p, i]) => [
|
|
77
|
+
p,
|
|
78
78
|
{
|
|
79
|
-
id:
|
|
79
|
+
id: i.description.id,
|
|
80
80
|
meta: await this.embedMetaContent(
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
i.description.id,
|
|
82
|
+
i.manifestSha256,
|
|
83
83
|
!0,
|
|
84
|
-
|
|
84
|
+
i.description.meta
|
|
85
85
|
),
|
|
86
86
|
spec: {
|
|
87
87
|
type: "from-registry-v2",
|
|
88
|
-
id:
|
|
88
|
+
id: i.description.id,
|
|
89
89
|
registryUrl: this.registryReader.rootUrl.toString(),
|
|
90
|
-
channel:
|
|
90
|
+
channel: p
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
])
|
|
94
94
|
);
|
|
95
95
|
return {
|
|
96
96
|
id: t.id,
|
|
97
|
-
latestByChannel: Object.fromEntries(
|
|
97
|
+
latestByChannel: Object.fromEntries(r),
|
|
98
98
|
allVersions: t.allVersionsWithChannels
|
|
99
99
|
};
|
|
100
100
|
})
|
|
101
101
|
);
|
|
102
102
|
return this.listCache = a, this.listCacheTimestamp = Date.now(), a;
|
|
103
|
-
},
|
|
103
|
+
}, l);
|
|
104
104
|
} catch (e) {
|
|
105
105
|
if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor)
|
|
106
106
|
return this.listCache;
|
|
@@ -108,26 +108,26 @@ class le {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
async getLatestOverview(e, a) {
|
|
111
|
-
return await
|
|
111
|
+
return await n(async () => {
|
|
112
112
|
const t = (await this.listBlockPacks()).find(
|
|
113
|
-
(
|
|
113
|
+
(r) => I(e, r.id)
|
|
114
114
|
);
|
|
115
115
|
if (t !== void 0)
|
|
116
116
|
return t.latestByChannel[a];
|
|
117
|
-
},
|
|
117
|
+
}, l);
|
|
118
118
|
}
|
|
119
119
|
async getSpecificOverview(e, a) {
|
|
120
|
-
return await
|
|
120
|
+
return await n(async () => {
|
|
121
121
|
const t = await this.v2RootFolderReader.readFile(
|
|
122
|
-
|
|
123
|
-
),
|
|
122
|
+
h(e) + B
|
|
123
|
+
), r = g.parse(JSON.parse(Buffer.from(t).toString()));
|
|
124
124
|
return {
|
|
125
125
|
id: e,
|
|
126
126
|
meta: await this.embedMetaContent(
|
|
127
127
|
e,
|
|
128
128
|
await F(t),
|
|
129
129
|
!1,
|
|
130
|
-
|
|
130
|
+
r.description.meta
|
|
131
131
|
),
|
|
132
132
|
spec: {
|
|
133
133
|
type: "from-registry-v2",
|
|
@@ -136,13 +136,13 @@ class le {
|
|
|
136
136
|
channel: a
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
|
-
},
|
|
139
|
+
}, l);
|
|
140
140
|
}
|
|
141
141
|
async getComponents(e) {
|
|
142
142
|
return await this.componentsCache.forceFetch(v(e), { context: e });
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
class
|
|
145
|
+
class m {
|
|
146
146
|
constructor(e, a) {
|
|
147
147
|
this.rootUrl = e, this.httpDispatcher = a;
|
|
148
148
|
}
|
|
@@ -153,25 +153,25 @@ class h {
|
|
|
153
153
|
return Buffer.from(await t.body.arrayBuffer());
|
|
154
154
|
}
|
|
155
155
|
relativeReader(e) {
|
|
156
|
-
return e.endsWith("/") || (e = e + "/"), new
|
|
156
|
+
return e.endsWith("/") || (e = e + "/"), new m(new URL(e, this.rootUrl), this.httpDispatcher);
|
|
157
157
|
}
|
|
158
158
|
getContentReader(e) {
|
|
159
159
|
let a = this;
|
|
160
160
|
return e !== void 0 && (a = a.relativeReader(e)), (t) => a.readFile(t);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
class
|
|
163
|
+
class f {
|
|
164
164
|
constructor(e, a) {
|
|
165
165
|
this.rootUrl = e, this.root = a;
|
|
166
166
|
}
|
|
167
167
|
async readFile(e) {
|
|
168
|
-
const a =
|
|
168
|
+
const a = c.join(this.root, ...e.split(d.sep));
|
|
169
169
|
return await J.readFile(a);
|
|
170
170
|
}
|
|
171
171
|
relativeReader(e) {
|
|
172
|
-
return e.endsWith("/") || (e = e + "/"), new
|
|
172
|
+
return e.endsWith("/") || (e = e + "/"), new f(
|
|
173
173
|
new URL(e, this.rootUrl),
|
|
174
|
-
|
|
174
|
+
c.join(this.root, ...e.split(d.sep))
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
177
|
getContentReader(e) {
|
|
@@ -180,21 +180,21 @@ class m {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
function z(o) {
|
|
183
|
-
return o.split(
|
|
183
|
+
return o.split(d.sep).join(c.sep);
|
|
184
184
|
}
|
|
185
185
|
function q(o) {
|
|
186
|
-
return o.split(
|
|
186
|
+
return o.split(c.sep).join(d.sep);
|
|
187
187
|
}
|
|
188
188
|
function ce(o, e) {
|
|
189
189
|
o.endsWith("/") || (o = o + "/");
|
|
190
|
-
const a = new URL(o, `file:${q(
|
|
190
|
+
const a = new URL(o, `file:${q(c.resolve("."))}/`);
|
|
191
191
|
switch (a.protocol) {
|
|
192
192
|
case "file:":
|
|
193
193
|
const t = z(a.pathname);
|
|
194
|
-
return new
|
|
194
|
+
return new f(a, t);
|
|
195
195
|
case "https:":
|
|
196
196
|
case "http:":
|
|
197
|
-
return new
|
|
197
|
+
return new m(a, e ?? W());
|
|
198
198
|
default:
|
|
199
199
|
throw new Error(`Unknown protocol: ${a.protocol}`);
|
|
200
200
|
}
|
|
@@ -218,8 +218,8 @@ export {
|
|
|
218
218
|
x as BlockComponentsAbsoluteUrl,
|
|
219
219
|
me as BlockComponentsConsolidate,
|
|
220
220
|
fe as BlockComponentsDescription,
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
ge as BlockDescriptionPackageJsonField,
|
|
222
|
+
ve as BlockDescriptionToExplicitBinaryBytes,
|
|
223
223
|
ke as BlockPackDescriptionConsolidateToFolder,
|
|
224
224
|
ue as BlockPackDescriptionManifestAddRelativePathPrefix,
|
|
225
225
|
ye as BlockPackMetaConsolidate,
|
|
@@ -242,37 +242,38 @@ export {
|
|
|
242
242
|
w as MainPrefix,
|
|
243
243
|
b as ManifestFileName,
|
|
244
244
|
B as ManifestSuffix,
|
|
245
|
-
Ue as
|
|
246
|
-
Ee as
|
|
247
|
-
Le as
|
|
245
|
+
Ue as PackageManifestPattern,
|
|
246
|
+
Ee as PackageOverview,
|
|
247
|
+
Le as PackageOverviewFileName,
|
|
248
|
+
Ve as PackageOverviewVersionEntry,
|
|
248
249
|
pe as RegistryV1,
|
|
249
250
|
le as RegistryV2Reader,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
251
|
+
Ge as ResolvedBlockPackDescriptionFromPackageJson,
|
|
252
|
+
Ne as ResolvedModuleFile,
|
|
253
|
+
je as ResolvedModuleFolder,
|
|
254
|
+
Ae as S3Storage,
|
|
255
|
+
Je as absoluteToBase64,
|
|
256
|
+
We as absoluteToBytes,
|
|
257
|
+
Ie as absoluteToString,
|
|
258
|
+
_e as buildBlockPackDist,
|
|
259
|
+
ze as cpAbsoluteToRelative,
|
|
259
260
|
ce as folderReaderByUrl,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
261
|
+
qe as loadPackDescription,
|
|
262
|
+
$e as loadPackDescriptionRaw,
|
|
263
|
+
He as mapLocalToAbsolute,
|
|
264
|
+
Ye as packFolderToRelativeTgz,
|
|
265
|
+
Ke as packageChannelPrefix,
|
|
266
|
+
Qe as packageChannelPrefixInsideV2,
|
|
267
|
+
Xe as packageContentPrefix,
|
|
268
|
+
h as packageContentPrefixInsideV2,
|
|
269
|
+
Ze as packageOverviewPath,
|
|
270
|
+
ea as packageOverviewPathInsideV2,
|
|
271
|
+
aa as parsePackageName,
|
|
272
|
+
ta as relativeToContentString,
|
|
273
|
+
oa as relativeToExplicitBinary64,
|
|
274
|
+
ra as relativeToExplicitBytes,
|
|
274
275
|
sa as relativeToExplicitString,
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
ia as storageByUrl,
|
|
277
|
+
na as tryLoadPackDescription
|
|
277
278
|
};
|
|
278
279
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/v2/registry/registry_reader.ts","../src/io/folder_reader.ts"],"sourcesContent":["import {\n BlockPackId,\n BlockPackIdNoVersion,\n blockPackIdNoVersionEquals,\n BlockPackManifest,\n BlockPackMetaEmbeddedBytes,\n BlockPackMetaManifest,\n BlockPackOverview,\n SingleBlockPackOverview\n} from '@milaboratories/pl-model-middle-layer';\nimport { FolderReader } from '../../io';\nimport canonicalize from 'canonicalize';\nimport {\n GlobalOverviewFileName,\n GlobalOverviewReg,\n MainPrefix,\n ManifestFileName,\n ManifestSuffix,\n packageContentPrefixInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\nimport { calculateSha256 } from '../../util';\nimport { retry, Retry2TimesWithDelay } from '@milaboratories/ts-helpers';\n\nexport type BlockPackOverviewNoRegLabel = Omit<BlockPackOverview, 'registryId'>;\n\nexport type RegistryV2ReaderOps = {\n /** Number of milliseconds to cache retrieved block list for */\n cacheBlockListFor: number;\n /** Number of milliseconds to keep cached retrieved block list for, if new requests returns error */\n keepStaleBlockListFor: number;\n};\n\nconst DefaultRegistryV2ReaderOps: RegistryV2ReaderOps = {\n cacheBlockListFor: 45e3, // 45 seconds\n keepStaleBlockListFor: 300e3 // 5 minutes\n};\n\nexport class RegistryV2Reader {\n private readonly v2RootFolderReader: FolderReader;\n private readonly ops: RegistryV2ReaderOps;\n\n constructor(\n private readonly registryReader: FolderReader,\n ops?: Partial<RegistryV2ReaderOps>\n ) {\n this.v2RootFolderReader = registryReader.relativeReader(MainPrefix);\n this.ops = { ...DefaultRegistryV2ReaderOps, ...(ops ?? {}) };\n }\n\n /**\n * Embeds meta infromation relative to registry root.\n * Meta information that looks like:\n *\n * */\n private readonly embeddedGlobalMetaCache = new LRUCache<\n string,\n BlockPackMetaEmbeddedBytes,\n { meta: BlockPackMetaManifest; relativeTo?: BlockPackId }\n >({\n max: 500,\n fetchMethod: async (_key, _staleValue, options) =>\n await retry(async () => {\n const contentReader =\n options.context.relativeTo !== undefined\n ? this.v2RootFolderReader\n .relativeReader(packageContentPrefixInsideV2(options.context.relativeTo))\n .getContentReader()\n : this.v2RootFolderReader.getContentReader();\n return await BlockPackMetaEmbedBytes(contentReader).parseAsync(options.context.meta);\n }, Retry2TimesWithDelay)\n });\n\n private async embedMetaContent(\n id: BlockPackId,\n sha256: string,\n absolutePath: boolean,\n meta: BlockPackMetaManifest\n ): Promise<BlockPackMetaEmbeddedBytes> {\n return await this.embeddedGlobalMetaCache.forceFetch(\n canonicalize({ id, sha256, absolutePath })!,\n { context: { meta, relativeTo: absolutePath ? undefined : id } }\n );\n }\n\n private listCacheTimestamp: number = 0;\n private listCache: BlockPackOverviewNoRegLabel[] | undefined = undefined;\n\n public async listBlockPacks(): Promise<BlockPackOverviewNoRegLabel[]> {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor\n )\n return this.listCache;\n try {\n return await retry(async () => {\n // const rootContentReader = this.v2RootFolderReader.getContentReader();\n const globalOverview = GlobalOverviewReg.parse(\n JSON.parse(\n Buffer.from(await this.v2RootFolderReader.readFile(GlobalOverviewFileName)).toString()\n )\n );\n\n const result = await Promise.all(\n globalOverview.packages.map(async (p) => {\n const byChannelEntries = await Promise.all(\n Object.entries(p.latestByChannel).map(async ([channel, data]) => [\n channel,\n {\n id: data.description.id,\n meta: await this.embedMetaContent(\n p.latest.id,\n p.latestManifestSha256,\n true,\n p.latest.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id: p.latest.id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n }\n ])\n );\n return {\n id: p.id,\n latestByChannel: Object.fromEntries(byChannelEntries),\n allVersions: p.allVersionsWithChannels\n } satisfies BlockPackOverviewNoRegLabel;\n })\n );\n\n this.listCache = result;\n this.listCacheTimestamp = Date.now();\n\n return result;\n }, Retry2TimesWithDelay);\n } catch (e: unknown) {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor\n )\n return this.listCache;\n throw e;\n }\n }\n\n public async getLatestOverview(\n id: BlockPackIdNoVersion,\n channel: string\n ): Promise<SingleBlockPackOverview | undefined> {\n return await retry(async () => {\n const overview = (await this.listBlockPacks()).find((e) =>\n blockPackIdNoVersionEquals(id, e.id)\n );\n if (overview === undefined) return undefined;\n return overview.latestByChannel[channel];\n }, Retry2TimesWithDelay);\n }\n\n public async getSpecificOverview(\n id: BlockPackId,\n channel: string\n ): Promise<SingleBlockPackOverview> {\n return await retry(async () => {\n const manifestContent = await this.v2RootFolderReader.readFile(\n packageContentPrefixInsideV2(id) + ManifestSuffix\n );\n const overview = BlockPackManifest.parse(JSON.parse(Buffer.from(manifestContent).toString()));\n return {\n id: id,\n meta: await this.embedMetaContent(\n id,\n await calculateSha256(manifestContent),\n false,\n overview.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n };\n }, Retry2TimesWithDelay);\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) =>\n await retry(async () => {\n const packageFolderReader = this.v2RootFolderReader.relativeReader(\n packageContentPrefixInsideV2(id)\n );\n const manifest = BlockPackManifest.parse(\n JSON.parse(Buffer.from(await packageFolderReader.readFile(ManifestFileName)).toString())\n );\n return BlockComponentsAbsoluteUrl(packageFolderReader.rootUrl.toString()).parse(\n manifest.description.components\n );\n }, Retry2TimesWithDelay)\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Dispatcher, request } from 'undici';\nimport { RelativeContentReader } from '../v2';\nimport path from 'node:path';\nimport pathPosix from 'node:path/posix';\nimport fsp from 'node:fs/promises';\nimport { defaultHttpDispatcher } from '@milaboratories/pl-http';\n\nexport interface FolderReader {\n readonly rootUrl: URL;\n relativeReader(relativePath: string): FolderReader;\n readFile(file: string): Promise<Buffer>;\n getContentReader(relativePath?: string): RelativeContentReader;\n}\n\nclass HttpFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly httpDispatcher: Dispatcher\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetUrl = new URL(file, this.rootUrl);\n const response = await request(targetUrl, {\n dispatcher: this.httpDispatcher\n });\n return Buffer.from(await response.body.arrayBuffer());\n }\n\n public relativeReader(relativePath: string): HttpFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new HttpFolderReader(new URL(relativePath, this.rootUrl), this.httpDispatcher);\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: HttpFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nclass FSFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly root: string\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetPath = path.join(this.root, ...file.split(pathPosix.sep));\n return await fsp.readFile(targetPath);\n }\n\n public relativeReader(relativePath: string): FSFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new FSFolderReader(\n new URL(relativePath, this.rootUrl),\n path.join(this.root, ...relativePath.split(pathPosix.sep))\n );\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: FSFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nfunction posixToLocalPath(p: string): string {\n return p.split(pathPosix.sep).join(path.sep);\n}\n\nfunction localToPosix(p: string): string {\n return p.split(path.sep).join(pathPosix.sep);\n}\n\nexport function folderReaderByUrl(address: string, httpDispatcher?: Dispatcher): FolderReader {\n if (!address.endsWith('/')) address = address + '/';\n const url = new URL(address, `file:${localToPosix(path.resolve('.'))}/`);\n switch (url.protocol) {\n case 'file:':\n const rootPath = posixToLocalPath(url.pathname);\n return new FSFolderReader(url, rootPath);\n case 'https:':\n case 'http:':\n return new HttpFolderReader(url, httpDispatcher ?? defaultHttpDispatcher());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","retry","contentReader","packageContentPrefixInsideV2","BlockPackMetaEmbedBytes","Retry2TimesWithDelay","key","staleValue","id","packageFolderReader","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","sha256","absolutePath","meta","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","byChannelEntries","channel","data","overview","e","blockPackIdNoVersionEquals","manifestContent","ManifestSuffix","calculateSha256","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","defaultHttpDispatcher"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,MAAMA,IAAkD;AAAA,EACtD,mBAAmB;AAAA;AAAA,EACnB,uBAAuB;AAAA;AACzB;AAEO,MAAMC,GAAiB;AAAA,EAI5B,YACmBC,GACjBC,GACA;AANe,IAAAC,EAAA;AACA,IAAAA,EAAA;AAeA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,EAAA,iCAA0B,IAAIC,EAI7C;AAAA,MACA,KAAK;AAAA,MACL,aAAa,OAAOC,GAAMC,GAAaC,MACrC,MAAMC,EAAM,YAAY;AACtB,cAAMC,IACJF,EAAQ,QAAQ,eAAe,SAC3B,KAAK,mBACF,eAAeG,EAA6BH,EAAQ,QAAQ,UAAU,CAAC,EACvE,qBACH,KAAK,mBAAmB,iBAAiB;AAC/C,eAAO,MAAMI,EAAwBF,CAAa,EAAE,WAAWF,EAAQ,QAAQ,IAAI;AAAA,MAAA,GAClFK,CAAoB;AAAA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AAA,IAAIT,EAAeS,GAAKC,CAAQ;AAAA,IACzC,KAAK;AAAA,IACL,KAAK;AACH,aAAO,IAAIpB,EAAiBmB,GAAKjB,KAAkBmB,GAAuB;AAAA,IAC5E;AACE,YAAM,IAAI,MAAM,qBAAqBF,EAAI,QAAQ,EAAE;AAAA,EAAA;AAEzD;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/v2/registry/registry_reader.ts","../src/io/folder_reader.ts"],"sourcesContent":["import {\n BlockPackId,\n BlockPackIdNoVersion,\n blockPackIdNoVersionEquals,\n BlockPackManifest,\n BlockPackMetaEmbeddedBytes,\n BlockPackMetaManifest,\n BlockPackOverview,\n SingleBlockPackOverview\n} from '@milaboratories/pl-model-middle-layer';\nimport { FolderReader } from '../../io';\nimport canonicalize from 'canonicalize';\nimport {\n GlobalOverviewFileName,\n GlobalOverviewReg,\n MainPrefix,\n ManifestFileName,\n ManifestSuffix,\n packageContentPrefixInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\nimport { calculateSha256 } from '../../util';\nimport { retry, Retry2TimesWithDelay } from '@milaboratories/ts-helpers';\n\nexport type BlockPackOverviewNoRegLabel = Omit<BlockPackOverview, 'registryId'>;\n\nexport type RegistryV2ReaderOps = {\n /** Number of milliseconds to cache retrieved block list for */\n cacheBlockListFor: number;\n /** Number of milliseconds to keep cached retrieved block list for, if new requests returns error */\n keepStaleBlockListFor: number;\n};\n\nconst DefaultRegistryV2ReaderOps: RegistryV2ReaderOps = {\n cacheBlockListFor: 45e3, // 45 seconds\n keepStaleBlockListFor: 300e3 // 5 minutes\n};\n\nexport class RegistryV2Reader {\n private readonly v2RootFolderReader: FolderReader;\n private readonly ops: RegistryV2ReaderOps;\n\n constructor(\n private readonly registryReader: FolderReader,\n ops?: Partial<RegistryV2ReaderOps>\n ) {\n this.v2RootFolderReader = registryReader.relativeReader(MainPrefix);\n this.ops = { ...DefaultRegistryV2ReaderOps, ...(ops ?? {}) };\n }\n\n /**\n * Embeds meta infromation relative to registry root.\n * Meta information that looks like:\n *\n * */\n private readonly embeddedGlobalMetaCache = new LRUCache<\n string,\n BlockPackMetaEmbeddedBytes,\n { meta: BlockPackMetaManifest; relativeTo?: BlockPackId }\n >({\n max: 500,\n fetchMethod: async (_key, _staleValue, options) =>\n await retry(async () => {\n const contentReader =\n options.context.relativeTo !== undefined\n ? this.v2RootFolderReader\n .relativeReader(packageContentPrefixInsideV2(options.context.relativeTo))\n .getContentReader()\n : this.v2RootFolderReader.getContentReader();\n return await BlockPackMetaEmbedBytes(contentReader).parseAsync(options.context.meta);\n }, Retry2TimesWithDelay)\n });\n\n private async embedMetaContent(\n id: BlockPackId,\n sha256: string,\n absolutePath: boolean,\n meta: BlockPackMetaManifest\n ): Promise<BlockPackMetaEmbeddedBytes> {\n return await this.embeddedGlobalMetaCache.forceFetch(\n canonicalize({ id, sha256, absolutePath })!,\n { context: { meta, relativeTo: absolutePath ? undefined : id } }\n );\n }\n\n private listCacheTimestamp: number = 0;\n private listCache: BlockPackOverviewNoRegLabel[] | undefined = undefined;\n\n public async listBlockPacks(): Promise<BlockPackOverviewNoRegLabel[]> {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor\n )\n return this.listCache;\n try {\n return await retry(async () => {\n // const rootContentReader = this.v2RootFolderReader.getContentReader();\n const globalOverview = GlobalOverviewReg.parse(\n JSON.parse(\n Buffer.from(await this.v2RootFolderReader.readFile(GlobalOverviewFileName)).toString()\n )\n );\n\n const result = await Promise.all(\n globalOverview.packages.map(async (p) => {\n const byChannelEntries = await Promise.all(\n Object.entries(p.latestByChannel).map(async ([channel, data]) => [\n channel,\n {\n id: data.description.id,\n meta: await this.embedMetaContent(\n data.description.id,\n data.manifestSha256,\n true,\n data.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id: data.description.id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n }\n ])\n );\n return {\n id: p.id,\n latestByChannel: Object.fromEntries(byChannelEntries),\n allVersions: p.allVersionsWithChannels\n } satisfies BlockPackOverviewNoRegLabel;\n })\n );\n\n this.listCache = result;\n this.listCacheTimestamp = Date.now();\n\n return result;\n }, Retry2TimesWithDelay);\n } catch (e: unknown) {\n if (\n this.listCache !== undefined &&\n Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor\n )\n return this.listCache;\n throw e;\n }\n }\n\n public async getLatestOverview(\n id: BlockPackIdNoVersion,\n channel: string\n ): Promise<SingleBlockPackOverview | undefined> {\n return await retry(async () => {\n const overview = (await this.listBlockPacks()).find((e) =>\n blockPackIdNoVersionEquals(id, e.id)\n );\n if (overview === undefined) return undefined;\n return overview.latestByChannel[channel];\n }, Retry2TimesWithDelay);\n }\n\n public async getSpecificOverview(\n id: BlockPackId,\n channel: string\n ): Promise<SingleBlockPackOverview> {\n return await retry(async () => {\n const manifestContent = await this.v2RootFolderReader.readFile(\n packageContentPrefixInsideV2(id) + ManifestSuffix\n );\n const overview = BlockPackManifest.parse(JSON.parse(Buffer.from(manifestContent).toString()));\n return {\n id: id,\n meta: await this.embedMetaContent(\n id,\n await calculateSha256(manifestContent),\n false,\n overview.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id,\n registryUrl: this.registryReader.rootUrl.toString(),\n channel\n }\n };\n }, Retry2TimesWithDelay);\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) =>\n await retry(async () => {\n const packageFolderReader = this.v2RootFolderReader.relativeReader(\n packageContentPrefixInsideV2(id)\n );\n const manifest = BlockPackManifest.parse(\n JSON.parse(Buffer.from(await packageFolderReader.readFile(ManifestFileName)).toString())\n );\n return BlockComponentsAbsoluteUrl(packageFolderReader.rootUrl.toString()).parse(\n manifest.description.components\n );\n }, Retry2TimesWithDelay)\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Dispatcher, request } from 'undici';\nimport { RelativeContentReader } from '../v2';\nimport path from 'node:path';\nimport pathPosix from 'node:path/posix';\nimport fsp from 'node:fs/promises';\nimport { defaultHttpDispatcher } from '@milaboratories/pl-http';\n\nexport interface FolderReader {\n readonly rootUrl: URL;\n relativeReader(relativePath: string): FolderReader;\n readFile(file: string): Promise<Buffer>;\n getContentReader(relativePath?: string): RelativeContentReader;\n}\n\nclass HttpFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly httpDispatcher: Dispatcher\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetUrl = new URL(file, this.rootUrl);\n const response = await request(targetUrl, {\n dispatcher: this.httpDispatcher\n });\n return Buffer.from(await response.body.arrayBuffer());\n }\n\n public relativeReader(relativePath: string): HttpFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new HttpFolderReader(new URL(relativePath, this.rootUrl), this.httpDispatcher);\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: HttpFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nclass FSFolderReader implements FolderReader {\n constructor(\n public readonly rootUrl: URL,\n private readonly root: string\n ) {}\n\n public async readFile(file: string): Promise<Buffer> {\n const targetPath = path.join(this.root, ...file.split(pathPosix.sep));\n return await fsp.readFile(targetPath);\n }\n\n public relativeReader(relativePath: string): FSFolderReader {\n if (!relativePath.endsWith('/')) relativePath = relativePath + '/';\n return new FSFolderReader(\n new URL(relativePath, this.rootUrl),\n path.join(this.root, ...relativePath.split(pathPosix.sep))\n );\n }\n\n public getContentReader(relativePath?: string): RelativeContentReader {\n let reader: FSFolderReader = this;\n if (relativePath !== undefined) reader = reader.relativeReader(relativePath);\n return (path) => reader.readFile(path);\n }\n}\n\nfunction posixToLocalPath(p: string): string {\n return p.split(pathPosix.sep).join(path.sep);\n}\n\nfunction localToPosix(p: string): string {\n return p.split(path.sep).join(pathPosix.sep);\n}\n\nexport function folderReaderByUrl(address: string, httpDispatcher?: Dispatcher): FolderReader {\n if (!address.endsWith('/')) address = address + '/';\n const url = new URL(address, `file:${localToPosix(path.resolve('.'))}/`);\n switch (url.protocol) {\n case 'file:':\n const rootPath = posixToLocalPath(url.pathname);\n return new FSFolderReader(url, rootPath);\n case 'https:':\n case 'http:':\n return new HttpFolderReader(url, httpDispatcher ?? defaultHttpDispatcher());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","retry","contentReader","packageContentPrefixInsideV2","BlockPackMetaEmbedBytes","Retry2TimesWithDelay","key","staleValue","id","packageFolderReader","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","sha256","absolutePath","meta","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","byChannelEntries","channel","data","overview","e","blockPackIdNoVersionEquals","manifestContent","ManifestSuffix","calculateSha256","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","defaultHttpDispatcher"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,MAAMA,IAAkD;AAAA,EACtD,mBAAmB;AAAA;AAAA,EACnB,uBAAuB;AAAA;AACzB;AAEO,MAAMC,GAAiB;AAAA,EAI5B,YACmBC,GACjBC,GACA;AANe,IAAAC,EAAA;AACA,IAAAA,EAAA;AAeA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,EAAA,iCAA0B,IAAIC,EAI7C;AAAA,MACA,KAAK;AAAA,MACL,aAAa,OAAOC,GAAMC,GAAaC,MACrC,MAAM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AAkBC,GAAiBhB,GAA2C;AAC5F,EAAKgB,EAAQ,SAAS,GAAG,UAAaA,IAAU;AAC1C,QAAAC,IAAM,IAAI,IAAID,GAAS,QAAQF,EAAaP,EAAK,QAAQ,GAAG,CAAC,CAAC,GAAG;AACvE,UAAQU,EAAI,UAAU;AAAA,IACpB,KAAK;AACG,YAAAC,IAAWL,EAAiBI,EAAI,QAAQ;AACvC,aAAA,IAAIT,EAAeS,GAAKC,CAAQ;AAAA,IACzC,KAAK;AAAA,IACL,KAAK;AACH,aAAO,IAAIpB,EAAiBmB,GAAKjB,KAAkBmB,GAAuB;AAAA,IAC5E;AACE,YAAM,IAAI,MAAM,qBAAqBF,EAAI,QAAQ,EAAE;AAAA,EAAA;AAEzD;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/v2/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAEL,WAAW,EACX,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,uCAAuC,CAAC;AAQ/C,OAAO,EACL,iBAAiB,EAIjB,eAAe,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/v2/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAEL,WAAW,EACX,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,uCAAuC,CAAC;AAQ/C,OAAO,EACL,iBAAiB,EAIjB,eAAe,EAQhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAqD,qBAAqB,EAAE,MAAM,UAAU,CAAC;AASpG,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,eAAe,EACxB,MAAM,GAAE,QAAqC;YAGlD,cAAc;IAkLf,cAAc,CAAC,IAAI,GAAE,OAAO,GAAG,QAAQ,GAAG,SAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B9E,kBAAkB,CAC7B,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,SAAS,GAAG,eAAe,CAAC;IAM1B,iBAAiB,IAAI,OAAO,CAAC,SAAS,GAAG,iBAAiB,CAAC;YAM1D,YAAY;IAUb,mBAAmB,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM;IAapD,wBAAwB,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM;IAazD,cAAc,CACzB,QAAQ,EAAE,iBAAiB,EAC3B,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,IAAI,CAAC;CA2BjB"}
|
|
@@ -1412,6 +1412,7 @@ export declare function packageOverviewPathInsideV2(bp: BlockPackIdNoVersion): s
|
|
|
1412
1412
|
export declare function packageOverviewPath(bp: BlockPackIdNoVersion): string;
|
|
1413
1413
|
export declare function packageChannelPrefixInsideV2(bp: BlockPackId): string;
|
|
1414
1414
|
export declare function packageChannelPrefix(bp: BlockPackId): string;
|
|
1415
|
+
export declare const PackageManifestPattern: RegExp;
|
|
1415
1416
|
export declare const GlobalOverviewPath = "v2/overview.json";
|
|
1416
1417
|
export declare function GlobalOverviewEntry<const Description extends z.ZodTypeAny>(descriptionType: Description): z.ZodPipeline<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
1417
1418
|
id: z.ZodObject<Omit<{
|