@platforma-sdk/block-tools 2.3.30 → 2.4.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/README.md +60 -2
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +142 -87
- package/dist/cli.mjs.map +1 -1
- package/dist/cmd/index.d.ts +8 -6
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/mark-stable.d.ts +14 -0
- package/dist/cmd/mark-stable.d.ts.map +1 -0
- package/dist/cmd/publish.d.ts +1 -0
- package/dist/cmd/publish.d.ts.map +1 -1
- package/dist/config-DJEjRJs6.mjs +1671 -0
- package/dist/config-DJEjRJs6.mjs.map +1 -0
- package/dist/config-R2w8AhfY.js +3 -0
- package/dist/config-R2w8AhfY.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -132
- package/dist/index.mjs.map +1 -1
- package/dist/v2/build_dist.d.ts.map +1 -1
- package/dist/v2/model/block_description.d.ts.map +1 -1
- package/dist/v2/registry/registry.d.ts +6 -3
- package/dist/v2/registry/registry.d.ts.map +1 -1
- package/dist/v2/registry/registry_reader.d.ts +10 -3
- package/dist/v2/registry/registry_reader.d.ts.map +1 -1
- package/dist/v2/registry/schema_public.d.ts +15476 -1938
- package/dist/v2/registry/schema_public.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/cmd/index.ts +8 -6
- package/src/cmd/mark-stable.ts +71 -0
- package/src/cmd/publish.ts +11 -13
- package/src/io/storage.test.ts +2 -1
- package/src/v2/build_dist.test.ts +1 -0
- package/src/v2/build_dist.ts +2 -1
- package/src/v2/registry/registry.test.ts +60 -0
- package/src/v2/registry/registry.ts +87 -22
- package/src/v2/registry/registry_reader.test.ts +4 -0
- package/src/v2/registry/registry_reader.ts +83 -30
- package/src/v2/registry/schema_public.ts +61 -5
- package/src/v2/source_package.test.ts +1 -0
- package/dist/config-BVDkG_N7.js +0 -3
- package/dist/config-BVDkG_N7.js.map +0 -1
- package/dist/config-C9KOwWbG.mjs +0 -1602
- package/dist/config-C9KOwWbG.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 BlockPackOverview\n} from '@milaboratories/pl-model-middle-layer';\nimport { FolderReader } from '../../io';\nimport canonicalize from 'canonicalize';\nimport {\n GlobalOverviewEntryReg,\n GlobalOverviewFileName,\n GlobalOverviewReg,\n MainPrefix,\n ManifestFileName,\n packageContentPrefixInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\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 private readonly embeddedMetaCache = new LRUCache<\n string,\n BlockPackMetaEmbeddedBytes,\n GlobalOverviewEntryReg\n >({\n max: 500,\n fetchMethod: async (_key, _staleValue, options) => {\n const rootContentReader = this.v2RootFolderReader.getContentReader();\n return await BlockPackMetaEmbedBytes(rootContentReader).parseAsync(\n options.context.latest.meta\n );\n }\n });\n\n private async embedMetaContent(\n entry: GlobalOverviewEntryReg\n ): Promise<BlockPackMetaEmbeddedBytes> {\n return await this.embeddedMetaCache.forceFetch(\n canonicalize({ id: entry.id, sha256: entry.latestManifestSha256 })!,\n { context: entry }\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 // 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(\n async (p) =>\n ({\n id: p.latest.id,\n meta: await this.embedMetaContent(p),\n spec: {\n type: 'from-registry-v2',\n id: p.latest.id,\n registryUrl: this.registryReader.rootUrl.toString()\n },\n otherVersions: p.allVersions\n }) satisfies BlockPackOverviewNoRegLabel\n )\n );\n\n this.listCache = result;\n this.listCacheTimestamp = Date.now();\n\n return result;\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 getOverviewForSpec(\n id: BlockPackIdNoVersion\n ): Promise<BlockPackOverviewNoRegLabel | undefined> {\n return (await this.listBlockPacks()).find((e) => blockPackIdNoVersionEquals(id, e.id));\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) => {\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 }\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Agent, 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';\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 ?? new Agent());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","rootContentReader","BlockPackMetaEmbedBytes","key","staleValue","id","packageFolderReader","packageContentPrefixInsideV2","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","entry","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","e","blockPackIdNoVersionEquals","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","Agent"],"mappings":"0kBA8BMA,EAAkD,CACtD,kBAAmB,KACnB,sBAAuB,GACzB,EAEO,MAAMC,CAAiB,CAI5B,YACmBC,EACjBC,EACA,CANeC,EAAA,2BACAA,EAAA,YAUAA,EAAA,yBAAoB,IAAIC,EAAAA,SAIvC,CACA,IAAK,IACL,YAAa,MAAOC,EAAMC,EAAaC,IAAY,CAC3C,MAAAC,EAAoB,KAAK,mBAAmB,iBAAiB,EAC5D,OAAA,MAAMC,EAAAA,wBAAwBD,CAAiB,EAAE,WACt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,EAAK,KAAK,KAAK,KAAM,GAAGN,EAAK,MAAMU,EAAU,GAAG,CAAC,EAC7D,OAAA,MAAMC,EAAI,SAASF,CAAU,CAAA,CAG/B,eAAeL,EAAsC,CAC1D,OAAKA,EAAa,SAAS,GAAG,MAAkBA,EAAe,KACxD,IAAIG,EACT,IAAI,IAAIH,EAAc,KAAK,OAAO,EAClCE,EAAK,KAAK,KAAK,KAAM,GAAGF,EAAa,MAAMM,EAAU,GAAG,CAAC,CAC3D,CAAA,CAGK,iBAAiBN,EAA8C,CACpE,IAAIC,EAAyB,KAC7B,OAAID,IAAiB,SAAoBC,EAAAA,EAAO,eAAeD,CAAY,GACnEE,GAASD,EAAO,SAASC,CAAI,CAAA,CAEzC,CAEA,SAASM,EAAiBlB,EAAmB,CAC3C,OAAOA,EAAE,MAAMgB,EAAU,GAAG,EAAE,KAAKJ,EAAK,GAAG,CAC7C,CAEA,SAASO,EAAanB,EAAmB,CACvC,OAAOA,EAAE,MAAMY,EAAK,GAAG,EAAE,KAAKI,EAAU,GAAG,CAC7C,CAEgB,SAAAI,EAAkBC,EAAiBhB,EAA2C,CACvFgB,EAAQ,SAAS,GAAG,MAAaA,EAAU,KAC1C,MAAAC,EAAM,IAAI,IAAID,EAAS,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,GAAkB,IAAImB,OAAO,EAChE,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 packageContentPrefixInsideV2,\n packageOverviewPathInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\nimport { calculateSha256 } from '../../util';\n\nexport type BlockPackOverviewNoRegLabel = Omit<BlockPackOverview, 'registryId'>;\nexport type SingleBlockPackOverviewNoRegLabel = Omit<SingleBlockPackOverview, '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 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 }\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 // 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 } 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<SingleBlockPackOverviewNoRegLabel | undefined> {\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 }\n\n public async getSpecificOverview(id: BlockPackId): Promise<SingleBlockPackOverviewNoRegLabel> {\n const overviewContent = await this.v2RootFolderReader.readFile(packageOverviewPathInsideV2(id));\n const overview = BlockPackManifest.parse(JSON.parse(Buffer.from(overviewContent).toString()));\n return {\n id: id,\n meta: await this.embedMetaContent(\n id,\n await calculateSha256(overviewContent),\n false,\n overview.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id,\n registryUrl: this.registryReader.rootUrl.toString()\n }\n };\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) => {\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 }\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Agent, 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';\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 ?? new Agent());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","contentReader","packageContentPrefixInsideV2","BlockPackMetaEmbedBytes","key","staleValue","id","packageFolderReader","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","sha256","absolutePath","meta","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","byChannelEntries","channel","data","e","overview","blockPackIdNoVersionEquals","overviewContent","packageOverviewPathInsideV2","calculateSha256","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","Agent"],"mappings":"0kBAkCMA,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,IAAY,CACjD,MAAMC,EACJD,EAAQ,QAAQ,aAAe,OAC3B,KAAK,mBACF,eAAeE,EAAA,6BAA6BF,EAAQ,QAAQ,UAAU,CAAC,EACvE,mBACH,KAAK,mBAAmB,iBAAiB,EAC/C,OAAO,MAAMG,EAAwB,wBAAAF,CAAa,EAAE,WAAWD,EAAQ,QAAQ,IAAI,CAAA,CACrF,CACD,GAcOJ,EAAA,0BAA6B,GAC7BA,EAAA,kBA0FSA,EAAA,uBAAkB,IAAIC,EAAAA,SAA0D,CAC/F,IAAK,IACL,YAAa,MAAOO,EAAKC,EAAY,CAAE,QAASC,KAAS,CACjD,MAAAC,EAAsB,KAAK,mBAAmB,eAClDL,EAAAA,6BAA6BI,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,CACF,CACD,GAjJkB,KAA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,OAAA,IAAIT,EAAeS,EAAKC,CAAQ,EACzC,IAAK,SACL,IAAK,QACH,OAAO,IAAIpB,EAAiBmB,EAAKjB,GAAkB,IAAImB,OAAO,EAChE,QACE,MAAM,IAAI,MAAM,qBAAqBF,EAAI,QAAQ,EAAE,CAAA,CAEzD"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,82 +1,100 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { e as
|
|
5
|
-
import {
|
|
6
|
-
import { Agent as
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var k = (o, e, a) => e in o ? g(o, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[e] = a;
|
|
3
|
+
var r = (o, e, a) => k(o, typeof e != "symbol" ? e + "" : e, a);
|
|
4
|
+
import { e as u, p as d, f as w, G as R, h as y, i as C, j as P, M as B, k as F, m as b, n as x, o as O, q as S, r as T, t as D, u as M, v as U, P as E, w as L, x as V, y as G } from "./config-DJEjRJs6.mjs";
|
|
5
|
+
import { U as ce, T as pe, Y as de, ad as he, W as fe, X as me, O as ve, a as ge, B as ke, Q as ue, b as we, a1 as Re, a0 as ye, F as Ce, ac as Pe, aa as Be, ab as Fe, a9 as be, af as xe, ae as Oe, a3 as Se, a5 as Te, $ as De, a4 as Me, V as Ue, R as Ee, z as Le, S as Ve, D as Ge, E as Ne, C as je, d as Ae, H as Je, c as Ie, l as We, A as _e, I as ze, a8 as qe, a7 as $e, a2 as Ye, a6 as He, Z as Ke, K as Qe, L as Xe, N as Ze, J as ea, s as aa, _ as ta } from "./config-DJEjRJs6.mjs";
|
|
6
|
+
import { Agent as N, request as j } from "undici";
|
|
7
7
|
import i from "node:path";
|
|
8
8
|
import l from "node:path/posix";
|
|
9
|
-
import
|
|
10
|
-
import { blockPackIdNoVersionEquals as
|
|
11
|
-
import
|
|
9
|
+
import A from "node:fs/promises";
|
|
10
|
+
import { blockPackIdNoVersionEquals as J, BlockPackManifest as h } from "@milaboratories/pl-model-middle-layer";
|
|
11
|
+
import f from "canonicalize";
|
|
12
12
|
import "zod";
|
|
13
13
|
import "mime-types";
|
|
14
14
|
import "tar";
|
|
15
15
|
import "@milaboratories/resolve-helper";
|
|
16
|
-
import { LRUCache as
|
|
17
|
-
const
|
|
16
|
+
import { LRUCache as m } from "lru-cache";
|
|
17
|
+
const I = {
|
|
18
18
|
cacheBlockListFor: 45e3,
|
|
19
19
|
// 45 seconds
|
|
20
20
|
keepStaleBlockListFor: 3e5
|
|
21
21
|
// 5 minutes
|
|
22
22
|
};
|
|
23
|
-
class
|
|
23
|
+
class se {
|
|
24
24
|
constructor(e, a) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
r(this, "v2RootFolderReader");
|
|
26
|
+
r(this, "ops");
|
|
27
|
+
/**
|
|
28
|
+
* Embeds meta infromation relative to registry root.
|
|
29
|
+
* Meta information that looks like:
|
|
30
|
+
*
|
|
31
|
+
* */
|
|
32
|
+
r(this, "embeddedGlobalMetaCache", new m({
|
|
28
33
|
max: 500,
|
|
29
34
|
fetchMethod: async (e, a, t) => {
|
|
30
|
-
const
|
|
31
|
-
return await
|
|
32
|
-
t.context.latest.meta
|
|
33
|
-
);
|
|
35
|
+
const s = t.context.relativeTo !== void 0 ? this.v2RootFolderReader.relativeReader(d(t.context.relativeTo)).getContentReader() : this.v2RootFolderReader.getContentReader();
|
|
36
|
+
return await w(s).parseAsync(t.context.meta);
|
|
34
37
|
}
|
|
35
38
|
}));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
r(this, "listCacheTimestamp", 0);
|
|
40
|
+
r(this, "listCache");
|
|
41
|
+
r(this, "componentsCache", new m({
|
|
39
42
|
max: 500,
|
|
40
43
|
fetchMethod: async (e, a, { context: t }) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
),
|
|
44
|
-
JSON.parse(Buffer.from(await
|
|
44
|
+
const s = this.v2RootFolderReader.relativeReader(
|
|
45
|
+
d(t)
|
|
46
|
+
), n = h.parse(
|
|
47
|
+
JSON.parse(Buffer.from(await s.readFile(B)).toString())
|
|
45
48
|
);
|
|
46
|
-
return
|
|
47
|
-
|
|
49
|
+
return F(s.rootUrl.toString()).parse(
|
|
50
|
+
n.description.components
|
|
48
51
|
);
|
|
49
52
|
}
|
|
50
53
|
}));
|
|
51
|
-
this.registryReader = e, this.v2RootFolderReader = e.relativeReader(
|
|
54
|
+
this.registryReader = e, this.v2RootFolderReader = e.relativeReader(u), this.ops = { ...I, ...a ?? {} };
|
|
52
55
|
}
|
|
53
|
-
async embedMetaContent(e) {
|
|
54
|
-
return await this.
|
|
55
|
-
|
|
56
|
-
{ context: e }
|
|
56
|
+
async embedMetaContent(e, a, t, s) {
|
|
57
|
+
return await this.embeddedGlobalMetaCache.forceFetch(
|
|
58
|
+
f({ id: e, sha256: a, absolutePath: t }),
|
|
59
|
+
{ context: { meta: s, relativeTo: t ? void 0 : e } }
|
|
57
60
|
);
|
|
58
61
|
}
|
|
59
62
|
async listBlockPacks() {
|
|
60
63
|
if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor)
|
|
61
64
|
return this.listCache;
|
|
62
65
|
try {
|
|
63
|
-
const e =
|
|
66
|
+
const e = R.parse(
|
|
64
67
|
JSON.parse(
|
|
65
|
-
Buffer.from(await this.v2RootFolderReader.readFile(
|
|
68
|
+
Buffer.from(await this.v2RootFolderReader.readFile(y)).toString()
|
|
66
69
|
)
|
|
67
70
|
), a = await Promise.all(
|
|
68
|
-
e.packages.map(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
e.packages.map(async (t) => {
|
|
72
|
+
const s = await Promise.all(
|
|
73
|
+
Object.entries(t.latestByChannel).map(async ([n, v]) => [
|
|
74
|
+
n,
|
|
75
|
+
{
|
|
76
|
+
id: v.description.id,
|
|
77
|
+
meta: await this.embedMetaContent(
|
|
78
|
+
t.latest.id,
|
|
79
|
+
t.latestManifestSha256,
|
|
80
|
+
!0,
|
|
81
|
+
t.latest.meta
|
|
82
|
+
),
|
|
83
|
+
spec: {
|
|
84
|
+
type: "from-registry-v2",
|
|
85
|
+
id: t.latest.id,
|
|
86
|
+
registryUrl: this.registryReader.rootUrl.toString(),
|
|
87
|
+
channel: n
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
])
|
|
91
|
+
);
|
|
92
|
+
return {
|
|
93
|
+
id: t.id,
|
|
94
|
+
latestByChannel: Object.fromEntries(s),
|
|
95
|
+
allVersions: t.allVersionsWithChannels
|
|
96
|
+
};
|
|
97
|
+
})
|
|
80
98
|
);
|
|
81
99
|
return this.listCache = a, this.listCacheTimestamp = Date.now(), a;
|
|
82
100
|
} catch (e) {
|
|
@@ -85,56 +103,62 @@ class ae {
|
|
|
85
103
|
throw e;
|
|
86
104
|
}
|
|
87
105
|
}
|
|
88
|
-
async
|
|
89
|
-
|
|
106
|
+
async getLatestOverview(e, a) {
|
|
107
|
+
const t = (await this.listBlockPacks()).find(
|
|
108
|
+
(s) => J(e, s.id)
|
|
109
|
+
);
|
|
110
|
+
if (t !== void 0)
|
|
111
|
+
return t.latestByChannel[a];
|
|
112
|
+
}
|
|
113
|
+
async getSpecificOverview(e) {
|
|
114
|
+
const a = await this.v2RootFolderReader.readFile(C(e)), t = h.parse(JSON.parse(Buffer.from(a).toString()));
|
|
115
|
+
return {
|
|
116
|
+
id: e,
|
|
117
|
+
meta: await this.embedMetaContent(
|
|
118
|
+
e,
|
|
119
|
+
await P(a),
|
|
120
|
+
!1,
|
|
121
|
+
t.description.meta
|
|
122
|
+
),
|
|
123
|
+
spec: {
|
|
124
|
+
type: "from-registry-v2",
|
|
125
|
+
id: e,
|
|
126
|
+
registryUrl: this.registryReader.rootUrl.toString()
|
|
127
|
+
}
|
|
128
|
+
};
|
|
90
129
|
}
|
|
91
130
|
async getComponents(e) {
|
|
92
|
-
return await this.componentsCache.forceFetch(
|
|
131
|
+
return await this.componentsCache.forceFetch(f(e), { context: e });
|
|
93
132
|
}
|
|
94
133
|
}
|
|
95
|
-
|
|
96
|
-
__proto__: null,
|
|
97
|
-
GlobalOverviewPath: B,
|
|
98
|
-
MetaFile: y,
|
|
99
|
-
PlPackageConfigData: C,
|
|
100
|
-
PlPackageJsonConfigFile: F,
|
|
101
|
-
PlPackageYamlConfigFile: b,
|
|
102
|
-
PlRegCommonConfigData: x,
|
|
103
|
-
PlRegFullPackageConfigData: D,
|
|
104
|
-
PlRegPackageConfig: T,
|
|
105
|
-
PlRegPackageConfigDataShard: M,
|
|
106
|
-
packageContentPrefix: O,
|
|
107
|
-
packageOverviewPath: S,
|
|
108
|
-
payloadFilePath: U
|
|
109
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
110
|
-
class n {
|
|
134
|
+
class c {
|
|
111
135
|
constructor(e, a) {
|
|
112
136
|
this.rootUrl = e, this.httpDispatcher = a;
|
|
113
137
|
}
|
|
114
138
|
async readFile(e) {
|
|
115
|
-
const a = new URL(e, this.rootUrl), t = await
|
|
139
|
+
const a = new URL(e, this.rootUrl), t = await j(a, {
|
|
116
140
|
dispatcher: this.httpDispatcher
|
|
117
141
|
});
|
|
118
142
|
return Buffer.from(await t.body.arrayBuffer());
|
|
119
143
|
}
|
|
120
144
|
relativeReader(e) {
|
|
121
|
-
return e.endsWith("/") || (e = e + "/"), new
|
|
145
|
+
return e.endsWith("/") || (e = e + "/"), new c(new URL(e, this.rootUrl), this.httpDispatcher);
|
|
122
146
|
}
|
|
123
147
|
getContentReader(e) {
|
|
124
148
|
let a = this;
|
|
125
149
|
return e !== void 0 && (a = a.relativeReader(e)), (t) => a.readFile(t);
|
|
126
150
|
}
|
|
127
151
|
}
|
|
128
|
-
class
|
|
152
|
+
class p {
|
|
129
153
|
constructor(e, a) {
|
|
130
154
|
this.rootUrl = e, this.root = a;
|
|
131
155
|
}
|
|
132
156
|
async readFile(e) {
|
|
133
157
|
const a = i.join(this.root, ...e.split(l.sep));
|
|
134
|
-
return await
|
|
158
|
+
return await A.readFile(a);
|
|
135
159
|
}
|
|
136
160
|
relativeReader(e) {
|
|
137
|
-
return e.endsWith("/") || (e = e + "/"), new
|
|
161
|
+
return e.endsWith("/") || (e = e + "/"), new p(
|
|
138
162
|
new URL(e, this.rootUrl),
|
|
139
163
|
i.join(this.root, ...e.split(l.sep))
|
|
140
164
|
);
|
|
@@ -144,80 +168,100 @@ class c {
|
|
|
144
168
|
return e !== void 0 && (a = a.relativeReader(e)), (t) => a.readFile(t);
|
|
145
169
|
}
|
|
146
170
|
}
|
|
147
|
-
function
|
|
171
|
+
function W(o) {
|
|
148
172
|
return o.split(l.sep).join(i.sep);
|
|
149
173
|
}
|
|
150
|
-
function
|
|
174
|
+
function _(o) {
|
|
151
175
|
return o.split(i.sep).join(l.sep);
|
|
152
176
|
}
|
|
153
|
-
function
|
|
177
|
+
function re(o, e) {
|
|
154
178
|
o.endsWith("/") || (o = o + "/");
|
|
155
|
-
const a = new URL(o, `file:${
|
|
179
|
+
const a = new URL(o, `file:${_(i.resolve("."))}/`);
|
|
156
180
|
switch (a.protocol) {
|
|
157
181
|
case "file:":
|
|
158
|
-
const t =
|
|
159
|
-
return new
|
|
182
|
+
const t = W(a.pathname);
|
|
183
|
+
return new p(a, t);
|
|
160
184
|
case "https:":
|
|
161
185
|
case "http:":
|
|
162
|
-
return new
|
|
186
|
+
return new c(a, e ?? new N());
|
|
163
187
|
default:
|
|
164
188
|
throw new Error(`Unknown protocol: ${a.protocol}`);
|
|
165
189
|
}
|
|
166
190
|
}
|
|
191
|
+
const ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
192
|
+
__proto__: null,
|
|
193
|
+
GlobalOverviewPath: b,
|
|
194
|
+
MetaFile: x,
|
|
195
|
+
PlPackageConfigData: O,
|
|
196
|
+
PlPackageJsonConfigFile: S,
|
|
197
|
+
PlPackageYamlConfigFile: T,
|
|
198
|
+
PlRegCommonConfigData: D,
|
|
199
|
+
PlRegFullPackageConfigData: M,
|
|
200
|
+
PlRegPackageConfig: U,
|
|
201
|
+
PlRegPackageConfigDataShard: E,
|
|
202
|
+
packageContentPrefix: L,
|
|
203
|
+
packageOverviewPath: V,
|
|
204
|
+
payloadFilePath: G
|
|
205
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
167
206
|
export {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
207
|
+
F as BlockComponentsAbsoluteUrl,
|
|
208
|
+
ce as BlockComponentsConsolidate,
|
|
209
|
+
pe as BlockComponentsDescription,
|
|
210
|
+
de as BlockDescriptionPackageJsonField,
|
|
211
|
+
he as BlockDescriptionToExplicitBinaryBytes,
|
|
212
|
+
fe as BlockPackDescriptionConsolidateToFolder,
|
|
213
|
+
me as BlockPackDescriptionManifestAddRelativePathPrefix,
|
|
214
|
+
ve as BlockPackMetaConsolidate,
|
|
215
|
+
ge as BlockPackMetaDescription,
|
|
216
|
+
ke as BlockPackMetaEmbedAbsoluteBase64,
|
|
217
|
+
ue as BlockPackMetaEmbedAbsoluteBytes,
|
|
218
|
+
w as BlockPackMetaEmbedBytes,
|
|
219
|
+
we as BlockRegistryV2,
|
|
220
|
+
Re as ChannelNameRegexp,
|
|
221
|
+
ye as ChannelsFolder,
|
|
222
|
+
Ce as FSStorage,
|
|
223
|
+
Pe as GlobalOverview,
|
|
224
|
+
Be as GlobalOverviewEntry,
|
|
225
|
+
Fe as GlobalOverviewEntryReg,
|
|
226
|
+
y as GlobalOverviewFileName,
|
|
227
|
+
be as GlobalOverviewPath,
|
|
228
|
+
R as GlobalOverviewReg,
|
|
229
|
+
xe as GlobalOverviewToExplicitBinaryBase64,
|
|
230
|
+
Oe as GlobalOverviewToExplicitBinaryBytes,
|
|
231
|
+
u as MainPrefix,
|
|
232
|
+
B as ManifestFileName,
|
|
233
|
+
Se as ManifestSuffix,
|
|
234
|
+
Te as PackageOverview,
|
|
235
|
+
De as PackageOverviewFileName,
|
|
236
|
+
Me as PackageOverviewVersionEntry,
|
|
237
|
+
ie as RegistryV1,
|
|
238
|
+
se as RegistryV2Reader,
|
|
239
|
+
Ue as ResolvedBlockPackDescriptionFromPackageJson,
|
|
240
|
+
Ee as ResolvedModuleFile,
|
|
241
|
+
Le as ResolvedModuleFolder,
|
|
242
|
+
Ve as S3Storage,
|
|
243
|
+
Ge as absoluteToBase64,
|
|
244
|
+
Ne as absoluteToBytes,
|
|
245
|
+
je as absoluteToString,
|
|
246
|
+
Ae as buildBlockPackDist,
|
|
247
|
+
Je as cpAbsoluteToRelative,
|
|
248
|
+
re as folderReaderByUrl,
|
|
249
|
+
Ie as loadPackDescription,
|
|
250
|
+
We as loadPackDescriptionRaw,
|
|
251
|
+
_e as mapLocalToAbsolute,
|
|
252
|
+
ze as packFolderToRelativeTgz,
|
|
253
|
+
qe as packageChannelPrefix,
|
|
254
|
+
$e as packageChannelPrefixInsideV2,
|
|
255
|
+
Ye as packageContentPrefix,
|
|
256
|
+
d as packageContentPrefixInsideV2,
|
|
257
|
+
He as packageOverviewPath,
|
|
258
|
+
C as packageOverviewPathInsideV2,
|
|
259
|
+
Ke as parsePackageName,
|
|
260
|
+
Qe as relativeToContentString,
|
|
261
|
+
Xe as relativeToExplicitBinary64,
|
|
262
|
+
Ze as relativeToExplicitBytes,
|
|
263
|
+
ea as relativeToExplicitString,
|
|
264
|
+
aa as storageByUrl,
|
|
265
|
+
ta as tryLoadPackDescription
|
|
222
266
|
};
|
|
223
267
|
//# 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 BlockPackOverview\n} from '@milaboratories/pl-model-middle-layer';\nimport { FolderReader } from '../../io';\nimport canonicalize from 'canonicalize';\nimport {\n GlobalOverviewEntryReg,\n GlobalOverviewFileName,\n GlobalOverviewReg,\n MainPrefix,\n ManifestFileName,\n packageContentPrefixInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\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 private readonly embeddedMetaCache = new LRUCache<\n string,\n BlockPackMetaEmbeddedBytes,\n GlobalOverviewEntryReg\n >({\n max: 500,\n fetchMethod: async (_key, _staleValue, options) => {\n const rootContentReader = this.v2RootFolderReader.getContentReader();\n return await BlockPackMetaEmbedBytes(rootContentReader).parseAsync(\n options.context.latest.meta\n );\n }\n });\n\n private async embedMetaContent(\n entry: GlobalOverviewEntryReg\n ): Promise<BlockPackMetaEmbeddedBytes> {\n return await this.embeddedMetaCache.forceFetch(\n canonicalize({ id: entry.id, sha256: entry.latestManifestSha256 })!,\n { context: entry }\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 // 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(\n async (p) =>\n ({\n id: p.latest.id,\n meta: await this.embedMetaContent(p),\n spec: {\n type: 'from-registry-v2',\n id: p.latest.id,\n registryUrl: this.registryReader.rootUrl.toString()\n },\n otherVersions: p.allVersions\n }) satisfies BlockPackOverviewNoRegLabel\n )\n );\n\n this.listCache = result;\n this.listCacheTimestamp = Date.now();\n\n return result;\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 getOverviewForSpec(\n id: BlockPackIdNoVersion\n ): Promise<BlockPackOverviewNoRegLabel | undefined> {\n return (await this.listBlockPacks()).find((e) => blockPackIdNoVersionEquals(id, e.id));\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) => {\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 }\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Agent, 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';\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 ?? new Agent());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","rootContentReader","BlockPackMetaEmbedBytes","key","staleValue","id","packageFolderReader","packageContentPrefixInsideV2","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","entry","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","e","blockPackIdNoVersionEquals","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","Agent"],"mappings":";;;;;;;;;;;;;;;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AAE,MAAMgB,EAAU,GAAG,EAAE,KAAKJ,EAAK,GAAG;AAC7C;AAEA,SAASO,EAAanB,GAAmB;AACvC,SAAOA,EAAE,MAAMY,EAAK,GAAG,EAAE,KAAKI,EAAU,GAAG;AAC7C;AAEgB,SAAAI,GAAkBC,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,KAAkB,IAAImB,GAAO;AAAA,IAChE;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 packageContentPrefixInsideV2,\n packageOverviewPathInsideV2\n} from './schema_public';\nimport { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';\nimport { LRUCache } from 'lru-cache';\nimport { calculateSha256 } from '../../util';\n\nexport type BlockPackOverviewNoRegLabel = Omit<BlockPackOverview, 'registryId'>;\nexport type SingleBlockPackOverviewNoRegLabel = Omit<SingleBlockPackOverview, '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 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 }\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 // 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 } 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<SingleBlockPackOverviewNoRegLabel | undefined> {\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 }\n\n public async getSpecificOverview(id: BlockPackId): Promise<SingleBlockPackOverviewNoRegLabel> {\n const overviewContent = await this.v2RootFolderReader.readFile(packageOverviewPathInsideV2(id));\n const overview = BlockPackManifest.parse(JSON.parse(Buffer.from(overviewContent).toString()));\n return {\n id: id,\n meta: await this.embedMetaContent(\n id,\n await calculateSha256(overviewContent),\n false,\n overview.description.meta\n ),\n spec: {\n type: 'from-registry-v2',\n id,\n registryUrl: this.registryReader.rootUrl.toString()\n }\n };\n }\n\n private readonly componentsCache = new LRUCache<string, BlockComponentsAbsoluteUrl, BlockPackId>({\n max: 500,\n fetchMethod: async (key, staleValue, { context: id }) => {\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 }\n });\n\n public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {\n return await this.componentsCache.forceFetch(canonicalize(id)!, { context: id });\n }\n}\n","import { Agent, 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';\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 ?? new Agent());\n default:\n throw new Error(`Unknown protocol: ${url.protocol}`);\n }\n}\n"],"names":["DefaultRegistryV2ReaderOps","RegistryV2Reader","registryReader","ops","__publicField","LRUCache","_key","_staleValue","options","contentReader","packageContentPrefixInsideV2","BlockPackMetaEmbedBytes","key","staleValue","id","packageFolderReader","manifest","BlockPackManifest","ManifestFileName","BlockComponentsAbsoluteUrl","MainPrefix","sha256","absolutePath","meta","canonicalize","globalOverview","GlobalOverviewReg","GlobalOverviewFileName","result","p","byChannelEntries","channel","data","overview","e","blockPackIdNoVersionEquals","overviewContent","packageOverviewPathInsideV2","calculateSha256","HttpFolderReader","rootUrl","httpDispatcher","file","targetUrl","response","request","relativePath","reader","path","FSFolderReader","root","targetPath","pathPosix","fsp","posixToLocalPath","localToPosix","folderReaderByUrl","address","url","rootPath","Agent"],"mappings":";;;;;;;;;;;;;;;;AAkCA,MAAMA,IAAkD;AAAA,EACtD,mBAAmB;AAAA;AAAA,EACnB,uBAAuB;AAAA;AACzB;AAEO,MAAMC,GAAiB;AAAA,EAI5B,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ID,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,KAAkB,IAAImB,GAAO;AAAA,IAChE;AACE,YAAM,IAAI,MAAM,qBAAqBF,EAAI,QAAQ,EAAE;AAAA,EAAA;AAEzD;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_dist.d.ts","sourceRoot":"","sources":["../../src/v2/build_dist.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGlB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAA2C,MAAM,SAAS,CAAC;AAKhG,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,4BAA4B,EACzC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"build_dist.d.ts","sourceRoot":"","sources":["../../src/v2/build_dist.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGlB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAA2C,MAAM,SAAS,CAAC;AAKhG,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,4BAA4B,EACzC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,iBAAiB,CAAC,CAoB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_description.d.ts","sourceRoot":"","sources":["../../../src/v2/model/block_description.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAgB,2CAA2C,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAA7+L,CAAC;;;;;;;;;;;gBAA6S,CAAC;;;;;;;;;;;;;;gBAA4Z,CAAC;;;;;;;;;;;WAAuS,CAAC;uBAA6C,CAAC;;;;;;;iBAAoL,CAAC;;;;;;;YAA+K,CAAC;;;;;;;;YAA6M,CAAC;eAAqC,CAAC;YAAkC,CAAC;0BAAkD,CAAC;;;;;gBAA0H,CAAC;;;;;;;;;;;WAAuS,CAAC;uBAA6C,CAAC;;;;;;;iBAAoL,CAAC;;;;;;;YAA+K,CAAC;;;;;;;;YAA6M,CAAC;eAAqC,CAAC;YAAkC,CAAC;0BAAkD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;gBAAkgB,CAAC;;;;;;;;;;;WAAuS,CAAC;uBAA6C,CAAC;;;;;;;iBAAoL,CAAC;;;;;;;YAA+K,CAAC;;;;;;;;YAA6M,CAAC;eAAqC,CAAC;YAAkC,CAAC;0BAAkD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAA8oB,CAAC;;;;;;;;;;;WAAuS,CAAC;uBAA6C,CAAC;;;;;;;iBAAoL,CAAC;;;;;;;YAA+K,CAAC;;;;;;;;YAA6M,CAAC;eAAqC,CAAC;YAAkC,CAAC;0BAAkD,CAAC;;;;;;;IADjonB"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { MiLogger } from '@milaboratories/ts-helpers';
|
|
2
2
|
import { RegistryStorage } from '../../io/storage';
|
|
3
|
-
import { BlockPackIdNoVersion, BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
|
|
3
|
+
import { BlockPackId, BlockPackIdNoVersion, BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
|
|
4
4
|
import { GlobalOverviewReg, PackageOverview } from './schema_public';
|
|
5
5
|
import { RelativeContentReader } from '../model';
|
|
6
6
|
export declare class BlockRegistryV2 {
|
|
7
7
|
private readonly storage;
|
|
8
|
-
private readonly logger
|
|
9
|
-
constructor(storage: RegistryStorage, logger?: MiLogger
|
|
8
|
+
private readonly logger;
|
|
9
|
+
constructor(storage: RegistryStorage, logger?: MiLogger);
|
|
10
10
|
private updateRegistry;
|
|
11
11
|
updateIfNeeded(force?: boolean): Promise<void>;
|
|
12
12
|
getPackageOverview(name: BlockPackIdNoVersion): Promise<undefined | PackageOverview>;
|
|
13
13
|
getGlobalOverview(): Promise<undefined | GlobalOverviewReg>;
|
|
14
|
+
private marchChanged;
|
|
15
|
+
addPackageToChannel(id: BlockPackId, channel: string): Promise<void>;
|
|
16
|
+
removePackageFromChannel(id: BlockPackId, channel: string): Promise<void>;
|
|
14
17
|
publishPackage(manifest: BlockPackManifest, fileReader: RelativeContentReader): Promise<void>;
|
|
15
18
|
}
|
|
16
19
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/v2/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,EAEX,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,uCAAuC,CAAC;AAQ/C,OAAO,EACL,iBAAiB,EAIjB,eAAe,EAMhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAqD,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAWpG,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,eAAe,EACxB,MAAM,GAAE,QAAqC;YAGlD,cAAc;IAuJf,cAAc,CAAC,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBrD,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"}
|