@platforma-sdk/block-tools 2.2.0 → 2.3.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.
Files changed (73) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +94 -238
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/config-BbxbO3Iw.mjs +1601 -0
  6. package/dist/config-BbxbO3Iw.mjs.map +1 -0
  7. package/dist/config-BczgUC2N.js +3 -0
  8. package/dist/config-BczgUC2N.js.map +1 -0
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +184 -40
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/io/folder_reader.d.ts +10 -0
  14. package/dist/io/folder_reader.d.ts.map +1 -0
  15. package/dist/io/index.d.ts +3 -0
  16. package/dist/io/index.d.ts.map +1 -0
  17. package/dist/io/storage.d.ts.map +1 -0
  18. package/dist/lib.d.ts +1 -0
  19. package/dist/lib.d.ts.map +1 -1
  20. package/dist/registry_v1/registry.d.ts +1 -1
  21. package/dist/registry_v1/registry.d.ts.map +1 -1
  22. package/dist/registry_v1/v1_repo_schema.d.ts +1 -1
  23. package/dist/registry_v1/v1_repo_schema.d.ts.map +1 -1
  24. package/dist/util.d.ts +1 -0
  25. package/dist/util.d.ts.map +1 -1
  26. package/dist/v2/build_dist.d.ts.map +1 -1
  27. package/dist/v2/index.d.ts +1 -0
  28. package/dist/v2/index.d.ts.map +1 -1
  29. package/dist/v2/model/block_components.d.ts +298 -20
  30. package/dist/v2/model/block_components.d.ts.map +1 -1
  31. package/dist/v2/model/block_description.d.ts +329 -110
  32. package/dist/v2/model/block_description.d.ts.map +1 -1
  33. package/dist/v2/model/block_meta.d.ts +554 -2
  34. package/dist/v2/model/block_meta.d.ts.map +1 -1
  35. package/dist/v2/model/content_conversion.d.ts +3 -1
  36. package/dist/v2/model/content_conversion.d.ts.map +1 -1
  37. package/dist/v2/registry/index.d.ts +4 -0
  38. package/dist/v2/registry/index.d.ts.map +1 -0
  39. package/dist/v2/registry/registry.d.ts +1 -1
  40. package/dist/v2/registry/registry.d.ts.map +1 -1
  41. package/dist/v2/registry/registry_reader.d.ts +14 -0
  42. package/dist/v2/registry/registry_reader.d.ts.map +1 -0
  43. package/dist/v2/registry/schema_public.d.ts +2048 -259
  44. package/dist/v2/registry/schema_public.d.ts.map +1 -1
  45. package/package.json +7 -4
  46. package/src/cmd/build-meta.ts +2 -2
  47. package/src/cmd/publish.ts +1 -1
  48. package/src/io/folder_reader.test.ts +21 -0
  49. package/src/io/folder_reader.ts +85 -0
  50. package/src/io/index.ts +2 -0
  51. package/src/lib.ts +1 -0
  52. package/src/registry_v1/config.ts +1 -1
  53. package/src/registry_v1/registry.test.ts +1 -1
  54. package/src/registry_v1/registry.ts +1 -1
  55. package/src/registry_v1/v1_repo_schema.ts +1 -1
  56. package/src/util.ts +6 -0
  57. package/src/v2/build_dist.ts +2 -1
  58. package/src/v2/index.ts +1 -0
  59. package/src/v2/model/block_components.ts +10 -8
  60. package/src/v2/model/block_meta.ts +23 -5
  61. package/src/v2/model/content_conversion.ts +30 -1
  62. package/src/v2/registry/index.ts +3 -0
  63. package/src/v2/registry/registry.ts +19 -15
  64. package/src/v2/registry/registry_reader.ts +81 -0
  65. package/src/v2/registry/schema_public.ts +36 -10
  66. package/dist/config-DJqN5LSx.js +0 -3
  67. package/dist/config-DJqN5LSx.js.map +0 -1
  68. package/dist/config-rGaQLD-7.mjs +0 -1350
  69. package/dist/config-rGaQLD-7.mjs.map +0 -1
  70. package/dist/lib/storage.d.ts.map +0 -1
  71. /package/dist/{lib → io}/storage.d.ts +0 -0
  72. /package/src/{lib → io}/storage.test.ts +0 -0
  73. /package/src/{lib → io}/storage.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"schema_public.d.ts","sourceRoot":"","sources":["../../../src/v2/registry/schema_public.ts"],"names":[],"mappings":"AAAA,OAAO,EAG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block Registry",
5
5
  "types": "./dist/lib.d.ts",
6
6
  "main": "./dist/index.js",
@@ -25,14 +25,16 @@
25
25
  "dependencies": {
26
26
  "@aws-sdk/client-s3": "^3.658.1",
27
27
  "@oclif/core": "^4.0.23",
28
+ "canonicalize": "^2.0.0",
29
+ "undici": "^6.19.8",
28
30
  "mime-types": "^2.1.35",
29
31
  "tar": "^7.4.3",
30
32
  "yaml": "^2.5.1",
31
33
  "zod": "^3.23.8",
32
34
  "@milaboratories/resolve-helper": "^1.0.1",
33
- "@milaboratories/pl-model-middle-layer": "^1.3.0",
34
- "@milaboratories/ts-helpers": "^1.0.26",
35
- "@milaboratories/ts-helpers-oclif": "^1.1.4"
35
+ "@milaboratories/pl-model-middle-layer": "^1.4.1",
36
+ "@milaboratories/ts-helpers": "^1.0.27",
37
+ "@milaboratories/ts-helpers-oclif": "^1.1.5"
36
38
  },
37
39
  "devDependencies": {
38
40
  "typescript": "~5.5.4",
@@ -46,6 +48,7 @@
46
48
  "@types/node": "~20.16.5",
47
49
  "@types/semver": "^7.5.8",
48
50
  "jest": "^29.7.0",
51
+ "@jest/globals": "^29.7.0",
49
52
  "oclif": "^4.14.35",
50
53
  "ts-jest": "^29.2.5",
51
54
  "@milaboratories/platforma-build-configs": "1.0.1"
@@ -2,7 +2,7 @@ import { Command, Flags } from '@oclif/core';
2
2
  import path from 'path';
3
3
  import fs from 'fs';
4
4
  import { loadPackDescriptionRaw } from '../v2';
5
- import { BlockPackMetaDescription, BlockPackMetaEmbed } from '../v2/model/block_meta';
5
+ import { BlockPackMetaDescription, BlockPackMetaEmbedAbsoluteBase64 } from '../v2/model/block_meta';
6
6
 
7
7
  export default class BuildMeta extends Command {
8
8
  static override description =
@@ -29,7 +29,7 @@ export default class BuildMeta extends Command {
29
29
  const { flags } = await this.parse(BuildMeta);
30
30
  const modulePath = path.resolve(flags.modulePath);
31
31
  const descriptionRaw = await loadPackDescriptionRaw(modulePath);
32
- const metaEmbedded = await BlockPackMetaEmbed.parseAsync(
32
+ const metaEmbedded = await BlockPackMetaEmbedAbsoluteBase64.parseAsync(
33
33
  BlockPackMetaDescription(modulePath).parse(descriptionRaw.meta)
34
34
  );
35
35
 
@@ -3,7 +3,7 @@ import fs from 'node:fs';
3
3
  import { OclifLoggerAdapter } from '@milaboratories/ts-helpers-oclif';
4
4
  import { ManifestFileName } from '../v2/registry/schema_public';
5
5
  import { BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
6
- import { storageByUrl } from '../lib/storage';
6
+ import { storageByUrl } from '../io/storage';
7
7
  import { BlockRegistryV2 } from '../v2/registry/registry';
8
8
  import path from 'node:path';
9
9
 
@@ -0,0 +1,21 @@
1
+ import { expect, test } from '@jest/globals';
2
+ import { folderReaderByUrl } from './folder_reader';
3
+
4
+ test('test fs reader', async () => {
5
+ const reader = folderReaderByUrl('file:.');
6
+ const content = await reader.getContentReader()('package.json');
7
+ expect(content).toBeDefined();
8
+ expect(content.length).toBeGreaterThan(10);
9
+ });
10
+
11
+ test('test url reader with slash', async () => {
12
+ const reader = folderReaderByUrl('https://cdn.milaboratory.com/');
13
+ const content = await reader.getContentReader()('ping');
14
+ expect(content?.toString('utf8')).toStrictEqual('pong');
15
+ });
16
+
17
+ test('test url reader without slash', async () => {
18
+ const reader = folderReaderByUrl('https://cdn.milaboratory.com');
19
+ const content = await reader.getContentReader()('ping');
20
+ expect(content?.toString('utf8')).toStrictEqual('pong');
21
+ });
@@ -0,0 +1,85 @@
1
+ import { Agent, Dispatcher, request } from 'undici';
2
+ import { RelativeContentReader } from '../v2';
3
+ import path from 'node:path';
4
+ import pathPosix from 'node:path/posix';
5
+ import fsp from 'node:fs/promises';
6
+
7
+ export interface FolderReader {
8
+ readonly rootUrl: URL;
9
+ relativeReader(relativePath: string): FolderReader;
10
+ readFile(file: string): Promise<Buffer>;
11
+ getContentReader(relativePath?: string): RelativeContentReader;
12
+ }
13
+
14
+ class HttpFolderReader implements FolderReader {
15
+ constructor(
16
+ public readonly rootUrl: URL,
17
+ private readonly httpDispatcher: Dispatcher
18
+ ) {}
19
+
20
+ public async readFile(file: string): Promise<Buffer> {
21
+ const targetUrl = new URL(file, this.rootUrl);
22
+ const response = await request(targetUrl, {
23
+ dispatcher: this.httpDispatcher
24
+ });
25
+ return Buffer.from(await response.body.arrayBuffer());
26
+ }
27
+
28
+ public relativeReader(relativePath: string): HttpFolderReader {
29
+ return new HttpFolderReader(new URL(relativePath, this.rootUrl), this.httpDispatcher);
30
+ }
31
+
32
+ public getContentReader(relativePath?: string): RelativeContentReader {
33
+ let reader: HttpFolderReader = this;
34
+ if (relativePath !== undefined) reader = reader.relativeReader(relativePath);
35
+ return (path) => reader.readFile(path);
36
+ }
37
+ }
38
+
39
+ class FSFolderReader implements FolderReader {
40
+ constructor(
41
+ public readonly rootUrl: URL,
42
+ private readonly root: string
43
+ ) {}
44
+
45
+ public async readFile(file: string): Promise<Buffer> {
46
+ const targetPath = path.join(this.root, ...file.split(pathPosix.sep));
47
+ return await fsp.readFile(targetPath);
48
+ }
49
+
50
+ public relativeReader(relativePath: string): FSFolderReader {
51
+ return new FSFolderReader(
52
+ new URL(relativePath, this.rootUrl),
53
+ path.join(this.root, ...relativePath.split(pathPosix.sep))
54
+ );
55
+ }
56
+
57
+ public getContentReader(relativePath?: string): RelativeContentReader {
58
+ let reader: FSFolderReader = this;
59
+ if (relativePath !== undefined) reader = reader.relativeReader(relativePath);
60
+ return (path) => reader.readFile(path);
61
+ }
62
+ }
63
+
64
+ function posixToLocalPath(p: string): string {
65
+ return p.split(pathPosix.sep).join(path.sep);
66
+ }
67
+
68
+ function localToPosix(p: string): string {
69
+ return p.split(path.sep).join(pathPosix.sep);
70
+ }
71
+
72
+ export function folderReaderByUrl(address: string, httpDispatcher?: Dispatcher): FolderReader {
73
+ if (!address.endsWith('/')) address = address + '/';
74
+ const url = new URL(address, `file:${localToPosix(path.resolve('.'))}/`);
75
+ switch (url.protocol) {
76
+ case 'file:':
77
+ const rootPath = posixToLocalPath(url.pathname);
78
+ return new FSFolderReader(url, rootPath);
79
+ case 'https:':
80
+ case 'http:':
81
+ return new HttpFolderReader(url, httpDispatcher ?? new Agent());
82
+ default:
83
+ throw new Error(`Unknown protocol: ${url.protocol}`);
84
+ }
85
+ }
@@ -0,0 +1,2 @@
1
+ export * from './folder_reader';
2
+ export * from './storage';
package/src/lib.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * as RegistryV1 from './registry_v1';
2
+ export * from './io';
2
3
  export * from './v2';
@@ -8,7 +8,7 @@ import {
8
8
  } from './config_schema';
9
9
  import * as os from 'node:os';
10
10
  import { BlockRegistry } from './registry';
11
- import { storageByUrl } from '../lib/storage';
11
+ import { storageByUrl } from '../io/storage';
12
12
  import { FullBlockPackageName } from './v1_repo_schema';
13
13
  import { MiLogger } from '@milaboratories/ts-helpers';
14
14
 
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import path from 'node:path';
3
- import { RegistryStorage, S3Storage, storageByUrl } from '../lib/storage';
3
+ import { RegistryStorage, storageByUrl } from '../io';
4
4
  import fs from 'node:fs';
5
5
  import { BlockRegistry } from './registry';
6
6
  import { ConsoleLoggerAdapter } from '@milaboratories/ts-helpers';
@@ -1,4 +1,4 @@
1
- import { RegistryStorage } from '../lib/storage';
1
+ import { RegistryStorage } from '../io/storage';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import semver from 'semver';
4
4
  import {
@@ -36,7 +36,7 @@ export interface GlobalOverviewEntry {
36
36
  package: string;
37
37
  allVersions: string[];
38
38
  latestVersion: string;
39
- latestMeta: object;
39
+ latestMeta: any;
40
40
  }
41
41
 
42
42
  export type GlobalOverview = GlobalOverviewEntry[];
package/src/util.ts CHANGED
@@ -23,3 +23,9 @@ export async function tryStat(path: string): Promise<BigIntStats | undefined> {
23
23
  throw error;
24
24
  }
25
25
  }
26
+
27
+ export async function calculateSha256(bytes: ArrayBuffer) {
28
+ return Buffer.from(await crypto.subtle.digest('sha-256', bytes))
29
+ .toString('hex')
30
+ .toUpperCase();
31
+ }
@@ -7,6 +7,7 @@ import {
7
7
  import { BlockPackDescriptionAbsolute, BlockPackDescriptionConsolidateToFolder } from './model';
8
8
  import fsp from 'node:fs/promises';
9
9
  import path from 'node:path';
10
+ import { calculateSha256 } from '../util';
10
11
 
11
12
  export async function buildBlockPackDist(
12
13
  description: BlockPackDescriptionAbsolute,
@@ -19,7 +20,7 @@ export async function buildBlockPackDist(
19
20
  const filesForManifest = await Promise.all(
20
21
  files.map(async (f): Promise<ManifestFileInfo> => {
21
22
  const bytes = await fsp.readFile(path.resolve(dst, f));
22
- const sha256 = Buffer.from(await crypto.subtle.digest('sha-256', bytes)).toString('hex');
23
+ const sha256 = await calculateSha256(bytes);
23
24
  return { name: f, size: bytes.length, sha256 };
24
25
  })
25
26
  );
package/src/v2/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './model';
2
2
  export * from './build_dist';
3
3
  export * from './source_package';
4
+ export * from './registry';
@@ -9,7 +9,9 @@ import {
9
9
  BlockComponents,
10
10
  BlockComponentsManifest,
11
11
  ContentAbsoluteBinaryLocal,
12
- ContentAbsoluteFolder
12
+ ContentAbsoluteFolder,
13
+ ContentRelative,
14
+ mapRemoteToAbsolute
13
15
  } from '@milaboratories/pl-model-middle-layer';
14
16
 
15
17
  export function BlockComponentsDescription(moduleRoot: string) {
@@ -27,10 +29,10 @@ export function BlockComponentsConsolidate(dstFolder: string, fileAccumulator?:
27
29
  ).pipe(BlockComponentsManifest);
28
30
  }
29
31
 
30
- // export function BlockComponentsAbsoluteUrl(prefix: string) {
31
- // return BlockComponents(
32
- // ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix)),
33
- // ContentRelativeBinary.transform(mapRemoteToAbsolute(prefix))
34
- // );
35
- // }
36
- // export type BlockComponentsAbsolute = z.infer<ReturnType<typeof BlockComponentsAbsoluteUrl>>;
32
+ export function BlockComponentsAbsoluteUrl(prefix: string) {
33
+ return BlockComponents(
34
+ ContentRelative.transform(mapRemoteToAbsolute(prefix)),
35
+ ContentRelative.transform(mapRemoteToAbsolute(prefix))
36
+ );
37
+ }
38
+ export type BlockComponentsAbsoluteUrl = z.infer<ReturnType<typeof BlockComponentsAbsoluteUrl>>;
@@ -1,16 +1,23 @@
1
1
  import {
2
2
  BlockPackMeta,
3
- BlockPackMetaEmbeddedContent,
3
+ BlockPackMetaEmbeddedBase64,
4
+ BlockPackMetaEmbeddedBytes,
4
5
  ContentAbsoluteBinaryLocal,
5
6
  ContentAbsoluteTextLocal,
7
+ ContentRelativeBinary,
8
+ ContentRelativeText,
6
9
  DescriptionContentBinary,
7
10
  DescriptionContentText
8
11
  } from '@milaboratories/pl-model-middle-layer';
9
12
  import {
10
13
  absoluteToBase64,
14
+ absoluteToBytes,
11
15
  absoluteToString,
12
16
  cpAbsoluteToRelative,
13
- mapLocalToAbsolute
17
+ mapLocalToAbsolute,
18
+ RelativeContentReader,
19
+ relativeToContentString,
20
+ relativeToExplicitBytes
14
21
  } from './content_conversion';
15
22
  import { z } from 'zod';
16
23
 
@@ -29,8 +36,19 @@ export function BlockPackMetaConsolidate(dstFolder: string, fileAccumulator?: st
29
36
  );
30
37
  }
31
38
 
32
- export const BlockPackMetaEmbed = BlockPackMeta(
39
+ export const BlockPackMetaEmbedAbsoluteBase64 = BlockPackMeta(
33
40
  ContentAbsoluteTextLocal.transform(absoluteToString()),
34
41
  ContentAbsoluteBinaryLocal.transform(absoluteToBase64())
35
- ).pipe(BlockPackMetaEmbeddedContent);
36
- export type BlockPackMetaEmbed = z.infer<typeof BlockPackMetaEmbed>;
42
+ ).pipe(BlockPackMetaEmbeddedBase64);
43
+
44
+ export const BlockPackMetaEmbedAbsoluteBytes = BlockPackMeta(
45
+ ContentAbsoluteTextLocal.transform(absoluteToString()),
46
+ ContentAbsoluteBinaryLocal.transform(absoluteToBytes())
47
+ ).pipe(BlockPackMetaEmbeddedBytes);
48
+
49
+ export function BlockPackMetaEmbedBytes(reader: RelativeContentReader) {
50
+ return BlockPackMeta(
51
+ ContentRelativeText.transform(relativeToContentString(reader)),
52
+ ContentRelativeBinary.transform(relativeToExplicitBytes(reader))
53
+ ).pipe(BlockPackMetaEmbeddedBytes);
54
+ }
@@ -122,6 +122,28 @@ export function absoluteToBase64(): (
122
122
  };
123
123
  }
124
124
 
125
+ export function absoluteToBytes(): (
126
+ value: ContentAbsoluteBinaryLocal
127
+ ) => Promise<ContentExplicitBytes> {
128
+ return async (value) => {
129
+ if (value.type === 'absolute-file') {
130
+ const mimeType = mime.lookup(value.file);
131
+ if (!mimeType) throw new Error(`Can't recognize mime type of the file: ${value.file}.`);
132
+ return {
133
+ type: 'explicit-bytes',
134
+ mimeType,
135
+ content: Buffer.from(await fsp.readFile(value.file))
136
+ };
137
+ } else if (value.type === 'explicit-base64') {
138
+ return {
139
+ type: 'explicit-bytes',
140
+ mimeType: value.mimeType,
141
+ content: Buffer.from(value.content, 'base64')
142
+ };
143
+ } else return value;
144
+ };
145
+ }
146
+
125
147
  export function cpAbsoluteToRelative(
126
148
  dstFolder: string,
127
149
  fileAccumulator?: string[]
@@ -162,7 +184,7 @@ export function packFolderToRelativeTgz(
162
184
 
163
185
  export type RelativeContentReader = (relativePath: string) => Promise<Buffer>;
164
186
 
165
- export function relativeToExplicitText(
187
+ export function relativeToExplicitString(
166
188
  reader: RelativeContentReader
167
189
  ): (value: ContentRelativeText) => Promise<ContentExplicitString> {
168
190
  return async (value) =>
@@ -171,6 +193,13 @@ export function relativeToExplicitText(
171
193
  : { type: 'explicit-string', content: (await reader(value.path)).toString('utf8') };
172
194
  }
173
195
 
196
+ export function relativeToContentString(
197
+ reader: RelativeContentReader
198
+ ): (value: ContentRelativeText) => Promise<string> {
199
+ return async (value) =>
200
+ value.type === 'explicit-string' ? value.content : (await reader(value.path)).toString('utf8');
201
+ }
202
+
174
203
  export function relativeToExplicitBinary64(
175
204
  reader: RelativeContentReader
176
205
  ): (value: ContentRelativeBinary) => Promise<ContentExplicitBase64> {
@@ -0,0 +1,3 @@
1
+ export * from './registry'
2
+ export * from './registry_reader'
3
+ export * from './schema_public'
@@ -1,6 +1,6 @@
1
1
  import { MiLogger } from '@milaboratories/ts-helpers';
2
2
  import { compare as compareSemver, satisfies } from 'semver';
3
- import { RegistryStorage } from '../../lib/storage';
3
+ import { RegistryStorage } from '../../io/storage';
4
4
  import { BlockPackIdNoVersion, BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
5
5
  import {
6
6
  GlobalUpdateSeedInFile,
@@ -20,6 +20,7 @@ import {
20
20
  } from './schema_public';
21
21
  import { BlockPackDescriptionManifestAddRelativePathPrefix, RelativeContentReader } from '../model';
22
22
  import { randomUUID } from 'node:crypto';
23
+ import { calculateSha256 } from '../../util';
23
24
 
24
25
  type PackageUpdateInfo = {
25
26
  package: BlockPackIdNoVersion;
@@ -75,7 +76,7 @@ export class BlockRegistryV2 {
75
76
  // reading existing overview
76
77
  const overviewFile = packageOverviewPath(packageInfo.package);
77
78
  const pOverviewContent = await this.storage.getFile(overviewFile);
78
- let packageOverview: PackageOverview =
79
+ const packageOverview: PackageOverview =
79
80
  pOverviewContent === undefined
80
81
  ? { schema: 'v2', versions: [] }
81
82
  : PackageOverview.parse(JSON.parse(pOverviewContent.toString()));
@@ -85,7 +86,7 @@ export class BlockRegistryV2 {
85
86
 
86
87
  // removing versions that we will update
87
88
  const newVersions = packageOverview.versions.filter(
88
- (e) => !packageInfo.versions.has(e.id.version)
89
+ (e) => !packageInfo.versions.has(e.description.id.version)
89
90
  );
90
91
 
91
92
  // reading new entries
@@ -98,15 +99,19 @@ export class BlockRegistryV2 {
98
99
  }) + ManifestSuffix
99
100
  );
100
101
  if (!manifestContent) continue; // absent package
101
- newVersions.push(
102
- BlockPackDescriptionManifestAddRelativePathPrefix(version).parse(
102
+ const sha256 = await calculateSha256(manifestContent);
103
+ newVersions.push({
104
+ description: BlockPackDescriptionManifestAddRelativePathPrefix(version).parse(
103
105
  BlockPackManifest.parse(JSON.parse(manifestContent.toString('utf8'))).description
104
- )
105
- );
106
+ ),
107
+ manifestSha256: sha256
108
+ });
106
109
  }
107
110
 
108
111
  // sorting entries according to version
109
- newVersions.sort((e1, e2) => compareSemver(e2.id.version, e1.id.version));
112
+ newVersions.sort((e1, e2) =>
113
+ compareSemver(e2.description.id.version, e1.description.id.version)
114
+ );
110
115
 
111
116
  // write package overview back
112
117
  await this.storage.putFile(
@@ -128,10 +133,11 @@ export class BlockRegistryV2 {
128
133
  organization: packageInfo.package.organization,
129
134
  name: packageInfo.package.name
130
135
  },
131
- allVersions: newVersions.map((e) => e.id.version).reverse(),
132
- latest: BlockPackDescriptionManifestAddRelativePathPrefix(packageInfo.package.name).parse(
133
- newVersions[0]
134
- )
136
+ allVersions: newVersions.map((e) => e.description.id.version).reverse(),
137
+ latest: BlockPackDescriptionManifestAddRelativePathPrefix(
138
+ `${packageInfo.package.organization}/${packageInfo.package.name}`
139
+ ).parse(newVersions[0].description),
140
+ latestManifestSha256: newVersions[0].manifestSha256
135
141
  });
136
142
  }
137
143
 
@@ -204,9 +210,7 @@ export class BlockRegistryV2 {
204
210
  throw new Error(
205
211
  `Actual file size don't match file size from the manifest file for ${f.name} (actual = ${bytes.length}; manifest = ${f.size})`
206
212
  );
207
- const sha256 = Buffer.from(await crypto.subtle.digest('sha-256', bytes))
208
- .toString('hex')
209
- .toUpperCase();
213
+ const sha256 = await calculateSha256(bytes);
210
214
  if (sha256 !== f.sha256.toUpperCase())
211
215
  throw new Error(
212
216
  `Actual file SHA-256 don't match the checksum from the manifest file for ${f.name} (actual = ${sha256}; manifest = ${f.sha256.toUpperCase()})`
@@ -0,0 +1,81 @@
1
+ import {
2
+ BlockPackId,
3
+ BlockPackManifest,
4
+ BlockPackMetaEmbeddedBytes,
5
+ BlockPackOverview
6
+ } from '@milaboratories/pl-model-middle-layer';
7
+ import { FolderReader } from '../../io';
8
+ import canonicalize from 'canonicalize';
9
+ import {
10
+ GlobalOverviewEntryReg,
11
+ GlobalOverviewFileName,
12
+ GlobalOverviewReg,
13
+ MainPrefix,
14
+ ManifestFileName,
15
+ packageContentPrefix,
16
+ packageContentPrefixInsideV2
17
+ } from './schema_public';
18
+ import { BlockComponentsAbsoluteUrl, BlockPackMetaEmbedBytes } from '../model';
19
+
20
+ export type BlockPackOverviewNoRegLabel = Omit<BlockPackOverview, 'registryId'>;
21
+
22
+ export class RegistryV2Reader {
23
+ private readonly metaCache = new Map<
24
+ string,
25
+ { sha256: string; meta: BlockPackMetaEmbeddedBytes }
26
+ >();
27
+
28
+ private readonly v2RootFolderReader: FolderReader;
29
+
30
+ constructor(private readonly registryReader: FolderReader) {
31
+ this.v2RootFolderReader = registryReader.relativeReader(MainPrefix);
32
+ }
33
+
34
+ private async embedMetaContent(
35
+ entry: GlobalOverviewEntryReg
36
+ ): Promise<BlockPackMetaEmbeddedBytes> {
37
+ const id = canonicalize(entry.id)!;
38
+ const fromCache = this.metaCache.get(id);
39
+ if (fromCache && fromCache.sha256 === entry.latestManifestSha256) return fromCache.meta;
40
+ const rootContentReader = this.v2RootFolderReader.getContentReader();
41
+ const meta = await BlockPackMetaEmbedBytes(rootContentReader).parseAsync(entry.latest.meta);
42
+ this.metaCache.set(id, { sha256: entry.latestManifestSha256, meta });
43
+ return meta;
44
+ }
45
+
46
+ public async listBlockPacks(): Promise<BlockPackOverviewNoRegLabel[]> {
47
+ const rootContentReader = this.v2RootFolderReader.getContentReader();
48
+ const globalOverview = GlobalOverviewReg.parse(
49
+ JSON.parse(
50
+ Buffer.from(await this.v2RootFolderReader.readFile(GlobalOverviewFileName)).toString()
51
+ )
52
+ );
53
+ return await Promise.all(
54
+ globalOverview.packages.map(
55
+ async (p) =>
56
+ ({
57
+ id: p.latest.id,
58
+ meta: await this.embedMetaContent(p),
59
+ spec: {
60
+ type: 'from-registry-v2',
61
+ id: p.latest.id,
62
+ registryUrl: this.registryReader.rootUrl.toString()
63
+ },
64
+ otherVersions: p.allVersions
65
+ }) satisfies BlockPackOverviewNoRegLabel
66
+ )
67
+ );
68
+ }
69
+
70
+ public async getComponents(id: BlockPackId): Promise<BlockComponentsAbsoluteUrl> {
71
+ const packageFolderReader = this.v2RootFolderReader.relativeReader(
72
+ packageContentPrefixInsideV2(id)
73
+ );
74
+ const manifest = BlockPackManifest.parse(
75
+ JSON.parse(Buffer.from(await packageFolderReader.readFile(ManifestFileName)).toString())
76
+ );
77
+ return BlockComponentsAbsoluteUrl(packageFolderReader.rootUrl.toString()).parse(
78
+ manifest.description.components
79
+ );
80
+ }
81
+ }