@platforma-sdk/block-tools 2.1.11 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +113 -71
- package/dist/cli.mjs.map +1 -1
- package/dist/cmd/index.d.ts +2 -0
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/publish.d.ts +11 -0
- package/dist/cmd/publish.d.ts.map +1 -0
- package/dist/config-B1U40s2a.js +3 -0
- package/dist/config-B1U40s2a.js.map +1 -0
- package/dist/config-YukCegnp.mjs +1587 -0
- package/dist/config-YukCegnp.mjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +170 -38
- package/dist/index.mjs.map +1 -1
- package/dist/io/folder_reader.d.ts +24 -0
- package/dist/io/folder_reader.d.ts.map +1 -0
- package/dist/io/index.d.ts +3 -0
- package/dist/io/index.d.ts.map +1 -0
- package/dist/io/storage.d.ts.map +1 -0
- package/dist/lib.d.ts +1 -0
- package/dist/lib.d.ts.map +1 -1
- package/dist/registry_v1/config_schema.d.ts +13 -13
- package/dist/registry_v1/registry.d.ts +1 -1
- package/dist/registry_v1/registry.d.ts.map +1 -1
- package/dist/registry_v1/v1_repo_schema.d.ts +1 -1
- package/dist/registry_v1/v1_repo_schema.d.ts.map +1 -1
- package/dist/v2/build_dist.d.ts +2 -1
- package/dist/v2/build_dist.d.ts.map +1 -1
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/model/block_components.d.ts +170 -178
- package/dist/v2/model/block_components.d.ts.map +1 -1
- package/dist/v2/model/block_description.d.ts +2873 -0
- package/dist/v2/model/block_description.d.ts.map +1 -0
- package/dist/v2/model/{meta.d.ts → block_meta.d.ts} +555 -3
- package/dist/v2/model/block_meta.d.ts.map +1 -0
- package/dist/v2/model/content_conversion.d.ts +7 -2
- package/dist/v2/model/content_conversion.d.ts.map +1 -1
- package/dist/v2/model/index.d.ts +3 -2079
- package/dist/v2/model/index.d.ts.map +1 -1
- package/dist/v2/registry/index.d.ts +4 -0
- package/dist/v2/registry/index.d.ts.map +1 -0
- package/dist/v2/registry/registry.d.ts +16 -0
- package/dist/v2/registry/registry.d.ts.map +1 -0
- package/dist/v2/registry/registry_reader.d.ts +12 -0
- package/dist/v2/registry/registry_reader.d.ts.map +1 -0
- package/dist/v2/registry/schema_internal.d.ts +7 -0
- package/dist/v2/registry/schema_internal.d.ts.map +1 -0
- package/dist/v2/registry/schema_public.d.ts +4499 -0
- package/dist/v2/registry/schema_public.d.ts.map +1 -0
- package/package.json +8 -5
- package/src/cmd/build-meta.ts +2 -2
- package/src/cmd/index.ts +2 -0
- package/src/cmd/publish.ts +69 -0
- package/src/io/folder_reader.test.ts +21 -0
- package/src/io/folder_reader.ts +77 -0
- package/src/io/index.ts +2 -0
- package/src/lib.ts +1 -0
- package/src/registry_v1/config.ts +1 -1
- package/src/registry_v1/registry.test.ts +1 -1
- package/src/registry_v1/registry.ts +1 -1
- package/src/registry_v1/v1_repo_schema.ts +1 -1
- package/src/v2/build_dist.ts +16 -12
- package/src/v2/index.ts +1 -0
- package/src/v2/model/block_components.ts +14 -10
- package/src/v2/model/block_description.ts +49 -0
- package/src/v2/model/{meta.ts → block_meta.ts} +23 -5
- package/src/v2/model/content_conversion.ts +78 -10
- package/src/v2/model/index.ts +3 -44
- package/src/v2/registry/index.ts +3 -0
- package/src/v2/registry/registry.ts +240 -0
- package/src/v2/registry/registry_reader.ts +71 -0
- package/src/v2/registry/schema_internal.ts +13 -0
- package/src/v2/registry/schema_public.ts +112 -0
- package/dist/config-Br5DwFuM.mjs +0 -1317
- package/dist/config-Br5DwFuM.mjs.map +0 -1
- package/dist/config-DMAm68Pm.js +0 -3
- package/dist/config-DMAm68Pm.js.map +0 -1
- package/dist/lib/storage.d.ts.map +0 -1
- package/dist/v2/model/common.d.ts +0 -3
- package/dist/v2/model/common.d.ts.map +0 -1
- package/dist/v2/model/content_types.d.ts +0 -478
- package/dist/v2/model/content_types.d.ts.map +0 -1
- package/dist/v2/model/meta.d.ts.map +0 -1
- package/dist/v2/registry/schema.d.ts +0 -15
- package/dist/v2/registry/schema.d.ts.map +0 -1
- package/src/v2/model/common.ts +0 -2
- package/src/v2/model/content_types.ts +0 -233
- package/src/v2/registry/schema.ts +0 -29
- /package/dist/{lib → io}/storage.d.ts +0 -0
- /package/src/{lib → io}/storage.test.ts +0 -0
- /package/src/{lib → io}/storage.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema_public.d.ts","sourceRoot":"","sources":["../../../src/v2/registry/schema_public.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,oBAAoB,EAOrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAqD,MAAM,UAAU,CAAC;AAEpG,eAAO,MAAM,UAAU,QAAQ,CAAC;AAEhC,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AACvD,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAEhD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAE5D;AAED,eAAO,MAAM,cAAc,QAAyB,CAAC;AAMrD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAiF+kR,CAAC;;;;;;;;;;;oBAA6S,CAAC;;;;;;;;;;;;;oBAAoW,CAAC;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUjF;AACD,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CACtD,UAAU,CAAC,OAAO,oCAAoC,CAAC,CACxD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/block-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Utility to manipulate Platforma Blocks and 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
|
-
"@milaboratories/resolve-helper": "1.0.1",
|
|
33
|
-
"@milaboratories/pl-model-middle-layer": "^1.
|
|
34
|
-
"@milaboratories/ts-helpers": "^1.0.
|
|
35
|
-
"@milaboratories/ts-helpers-oclif": "^1.1.
|
|
34
|
+
"@milaboratories/resolve-helper": "^1.0.1",
|
|
35
|
+
"@milaboratories/pl-model-middle-layer": "^1.4.0",
|
|
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"
|
package/src/cmd/build-meta.ts
CHANGED
|
@@ -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,
|
|
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
|
|
32
|
+
const metaEmbedded = await BlockPackMetaEmbedAbsoluteBase64.parseAsync(
|
|
33
33
|
BlockPackMetaDescription(modulePath).parse(descriptionRaw.meta)
|
|
34
34
|
);
|
|
35
35
|
|
package/src/cmd/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BuildMeta from './build-meta';
|
|
2
2
|
import BuildModel from './build-model';
|
|
3
3
|
import PackBlock from './pack-block';
|
|
4
|
+
import Publish from './publish';
|
|
4
5
|
import UploadPackageV1 from './upload-package-v1';
|
|
5
6
|
|
|
6
7
|
// prettier-ignore
|
|
@@ -9,4 +10,5 @@ export const COMMANDS = {
|
|
|
9
10
|
'pack': PackBlock,
|
|
10
11
|
'build-model': BuildModel,
|
|
11
12
|
'build-meta': BuildMeta,
|
|
13
|
+
'publish': Publish,
|
|
12
14
|
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { OclifLoggerAdapter } from '@milaboratories/ts-helpers-oclif';
|
|
4
|
+
import { ManifestFileName } from '../v2/registry/schema_public';
|
|
5
|
+
import { BlockPackManifest } from '@milaboratories/pl-model-middle-layer';
|
|
6
|
+
import { storageByUrl } from '../io/storage';
|
|
7
|
+
import { BlockRegistryV2 } from '../v2/registry/registry';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
export default class Publish extends Command {
|
|
11
|
+
static description =
|
|
12
|
+
'Publishes the block package and refreshes the registry (for v2 block-pack schema)';
|
|
13
|
+
|
|
14
|
+
static flags = {
|
|
15
|
+
registry: Flags.string({
|
|
16
|
+
char: 'r',
|
|
17
|
+
summary: 'full address of the registry',
|
|
18
|
+
helpValue: '<address>',
|
|
19
|
+
env: 'PL_REGISTRY',
|
|
20
|
+
required: true
|
|
21
|
+
}),
|
|
22
|
+
|
|
23
|
+
manifest: Flags.file({
|
|
24
|
+
char: 'm',
|
|
25
|
+
summary: 'manifest file path',
|
|
26
|
+
exists: true,
|
|
27
|
+
default: `./block-pack/${ManifestFileName}`
|
|
28
|
+
}),
|
|
29
|
+
|
|
30
|
+
refresh: Flags.boolean({
|
|
31
|
+
summary: 'refresh repository after adding the package',
|
|
32
|
+
default: true,
|
|
33
|
+
allowNo: true,
|
|
34
|
+
env: 'PL_REGISTRY_REFRESH'
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
public async run(): Promise<void> {
|
|
39
|
+
const { flags } = await this.parse(Publish);
|
|
40
|
+
|
|
41
|
+
// if (flags.meta) {
|
|
42
|
+
// if (flags.meta.endsWith('.json'))
|
|
43
|
+
// configFromFlags.meta = JSON.parse(
|
|
44
|
+
// await fs.promises.readFile(flags.meta, { encoding: 'utf-8' })
|
|
45
|
+
// );
|
|
46
|
+
// else if (flags.meta.endsWith('.yaml'))
|
|
47
|
+
// configFromFlags.meta = YAML.parse(
|
|
48
|
+
// await fs.promises.readFile(flags.meta, { encoding: 'utf-8' })
|
|
49
|
+
// );
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
const manifestPath = path.resolve(flags.manifest);
|
|
53
|
+
const manifest = BlockPackManifest.parse(
|
|
54
|
+
JSON.parse(await fs.promises.readFile(manifestPath, { encoding: 'utf-8' }))
|
|
55
|
+
);
|
|
56
|
+
const manifestRoot = path.dirname(manifestPath);
|
|
57
|
+
|
|
58
|
+
this.log(`Manifest root = ${manifestRoot}`);
|
|
59
|
+
|
|
60
|
+
const storage = storageByUrl(flags.registry);
|
|
61
|
+
const registry = new BlockRegistryV2(storage, new OclifLoggerAdapter(this));
|
|
62
|
+
|
|
63
|
+
await registry.publishPackage(manifest, async (file) =>
|
|
64
|
+
Buffer.from(await fs.promises.readFile(path.resolve(manifestRoot, file)))
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
if (flags.refresh) await registry.updateIfNeeded();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -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,77 @@
|
|
|
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
|
+
relativeReader(relativePath: string): FolderReader;
|
|
9
|
+
readFile(file: string): Promise<Buffer>;
|
|
10
|
+
getContentReader(relativePath?: string): RelativeContentReader;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class HttpFolderReader implements FolderReader {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly root: URL,
|
|
16
|
+
private readonly httpDispatcher: Dispatcher
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
public async readFile(file: string): Promise<Buffer> {
|
|
20
|
+
const targetUrl = new URL(file, this.root);
|
|
21
|
+
const response = await request(targetUrl, {
|
|
22
|
+
dispatcher: this.httpDispatcher
|
|
23
|
+
});
|
|
24
|
+
return Buffer.from(await response.body.arrayBuffer());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public relativeReader(relativePath: string): HttpFolderReader {
|
|
28
|
+
return new HttpFolderReader(new URL(relativePath, this.root), this.httpDispatcher);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public getContentReader(relativePath?: string): RelativeContentReader {
|
|
32
|
+
let reader: HttpFolderReader = this;
|
|
33
|
+
if (relativePath !== undefined) reader = reader.relativeReader(relativePath);
|
|
34
|
+
return (path) => reader.readFile(path);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class FSFolderReader implements FolderReader {
|
|
39
|
+
constructor(private readonly root: string) {}
|
|
40
|
+
|
|
41
|
+
public async readFile(file: string): Promise<Buffer> {
|
|
42
|
+
const targetPath = path.join(this.root, ...file.split(pathPosix.sep));
|
|
43
|
+
return await fsp.readFile(targetPath);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public relativeReader(relativePath: string): FSFolderReader {
|
|
47
|
+
return new FSFolderReader(path.join(this.root, ...relativePath.split(pathPosix.sep)));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public getContentReader(relativePath?: string): RelativeContentReader {
|
|
51
|
+
let reader: FSFolderReader = this;
|
|
52
|
+
if (relativePath !== undefined) reader = reader.relativeReader(relativePath);
|
|
53
|
+
return (path) => reader.readFile(path);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function posixToLocalPath(p: string): string {
|
|
58
|
+
return p.split(pathPosix.sep).join(path.sep);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function localToPosix(p: string): string {
|
|
62
|
+
return p.split(path.sep).join(pathPosix.sep);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function folderReaderByUrl(address: string, httpDispatcher?: Dispatcher): FolderReader {
|
|
66
|
+
const url = new URL(address, `file:${localToPosix(path.resolve('.'))}/`);
|
|
67
|
+
switch (url.protocol) {
|
|
68
|
+
case 'file:':
|
|
69
|
+
const root = posixToLocalPath(url.pathname);
|
|
70
|
+
return new FSFolderReader(root);
|
|
71
|
+
case 'https:':
|
|
72
|
+
case 'http:':
|
|
73
|
+
return new HttpFolderReader(url, httpDispatcher ?? new Agent());
|
|
74
|
+
default:
|
|
75
|
+
throw new Error(`Unknown protocol: ${url.protocol}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
package/src/io/index.ts
ADDED
package/src/lib.ts
CHANGED
|
@@ -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 '../
|
|
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,
|
|
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';
|
package/src/v2/build_dist.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BlockPackDescriptionAbsolute,
|
|
3
|
-
BlockPackDescriptionConsolidateToFolder,
|
|
4
2
|
BlockPackDescriptionManifest,
|
|
5
3
|
BlockPackManifest,
|
|
6
|
-
BlockPackManifestFile
|
|
7
|
-
|
|
4
|
+
BlockPackManifestFile,
|
|
5
|
+
ManifestFileInfo
|
|
6
|
+
} from '@milaboratories/pl-model-middle-layer';
|
|
7
|
+
import { BlockPackDescriptionAbsolute, BlockPackDescriptionConsolidateToFolder } from './model';
|
|
8
8
|
import fsp from 'node:fs/promises';
|
|
9
|
-
import { BlockPackMetaConsolidate, BlockPackMetaDescription } from './model/meta';
|
|
10
|
-
import { patch } from 'semver';
|
|
11
9
|
import path from 'node:path';
|
|
12
10
|
|
|
13
11
|
export async function buildBlockPackDist(
|
|
@@ -16,14 +14,20 @@ export async function buildBlockPackDist(
|
|
|
16
14
|
): Promise<BlockPackManifest> {
|
|
17
15
|
await fsp.mkdir(dst, { recursive: true });
|
|
18
16
|
const files: string[] = [];
|
|
19
|
-
const descriptionRelative =
|
|
20
|
-
description
|
|
17
|
+
const descriptionRelative: BlockPackDescriptionManifest =
|
|
18
|
+
await BlockPackDescriptionConsolidateToFolder(dst, files).parseAsync(description);
|
|
19
|
+
const filesForManifest = await Promise.all(
|
|
20
|
+
files.map(async (f): Promise<ManifestFileInfo> => {
|
|
21
|
+
const bytes = await fsp.readFile(path.resolve(dst, f));
|
|
22
|
+
const sha256 = Buffer.from(await crypto.subtle.digest('sha-256', bytes)).toString('hex');
|
|
23
|
+
return { name: f, size: bytes.length, sha256 };
|
|
24
|
+
})
|
|
21
25
|
);
|
|
22
26
|
const manifest: BlockPackManifest = BlockPackManifest.parse({
|
|
23
|
-
schema: '
|
|
24
|
-
|
|
25
|
-
files
|
|
26
|
-
});
|
|
27
|
+
schema: 'v2',
|
|
28
|
+
description: descriptionRelative,
|
|
29
|
+
files: filesForManifest
|
|
30
|
+
} satisfies BlockPackManifest);
|
|
27
31
|
await fsp.writeFile(path.resolve(dst, BlockPackManifestFile), JSON.stringify(manifest));
|
|
28
32
|
return manifest;
|
|
29
33
|
}
|
package/src/v2/index.ts
CHANGED
|
@@ -3,10 +3,14 @@ import {
|
|
|
3
3
|
ResolvedModuleFile,
|
|
4
4
|
ResolvedModuleFolder,
|
|
5
5
|
packFolderToRelativeTgz,
|
|
6
|
-
cpAbsoluteToRelative
|
|
7
|
-
mapRemoteToAbsolute,
|
|
6
|
+
cpAbsoluteToRelative
|
|
8
7
|
} from './content_conversion';
|
|
9
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
BlockComponents,
|
|
10
|
+
BlockComponentsManifest,
|
|
11
|
+
ContentAbsoluteBinaryLocal,
|
|
12
|
+
ContentAbsoluteFolder
|
|
13
|
+
} from '@milaboratories/pl-model-middle-layer';
|
|
10
14
|
|
|
11
15
|
export function BlockComponentsDescription(moduleRoot: string) {
|
|
12
16
|
return BlockComponents(
|
|
@@ -23,10 +27,10 @@ export function BlockComponentsConsolidate(dstFolder: string, fileAccumulator?:
|
|
|
23
27
|
).pipe(BlockComponentsManifest);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
export function BlockComponentsAbsoluteUrl(prefix: string) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
export type BlockComponentsAbsolute = z.infer<ReturnType<typeof BlockComponentsAbsoluteUrl>>;
|
|
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>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addPrefixToRelative,
|
|
3
|
+
BlockComponents,
|
|
4
|
+
BlockPackDescriptionManifest,
|
|
5
|
+
BlockPackMeta,
|
|
6
|
+
ContentRelative,
|
|
7
|
+
ContentRelativeBinary,
|
|
8
|
+
ContentRelativeText,
|
|
9
|
+
CreateBlockPackDescriptionSchema
|
|
10
|
+
} from '@milaboratories/pl-model-middle-layer';
|
|
11
|
+
import { BlockComponentsConsolidate, BlockComponentsDescription } from './block_components';
|
|
12
|
+
import { BlockPackMetaConsolidate, BlockPackMetaDescription } from './block_meta';
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
|
|
15
|
+
export function ResolvedBlockPackDescriptionFromPackageJson(root: string) {
|
|
16
|
+
return CreateBlockPackDescriptionSchema(
|
|
17
|
+
BlockComponentsDescription(root),
|
|
18
|
+
BlockPackMetaDescription(root)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
export type BlockPackDescriptionAbsolute = z.infer<
|
|
22
|
+
ReturnType<typeof ResolvedBlockPackDescriptionFromPackageJson>
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export function BlockPackDescriptionConsolidateToFolder(
|
|
26
|
+
dstFolder: string,
|
|
27
|
+
fileAccumulator?: string[]
|
|
28
|
+
) {
|
|
29
|
+
return CreateBlockPackDescriptionSchema(
|
|
30
|
+
BlockComponentsConsolidate(dstFolder, fileAccumulator),
|
|
31
|
+
BlockPackMetaConsolidate(dstFolder, fileAccumulator)
|
|
32
|
+
).pipe(BlockPackDescriptionManifest);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function BlockPackDescriptionManifestAddRelativePathPrefix(prefix: string) {
|
|
36
|
+
const transformer = addPrefixToRelative(prefix);
|
|
37
|
+
return BlockPackDescriptionManifest.pipe(
|
|
38
|
+
CreateBlockPackDescriptionSchema(
|
|
39
|
+
BlockComponents(
|
|
40
|
+
ContentRelative.transform(transformer),
|
|
41
|
+
ContentRelative.transform(transformer)
|
|
42
|
+
),
|
|
43
|
+
BlockPackMeta(
|
|
44
|
+
ContentRelativeText.transform(transformer),
|
|
45
|
+
ContentRelativeBinary.transform(transformer)
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
).pipe(BlockPackDescriptionManifest);
|
|
49
|
+
}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BlockPackMeta,
|
|
3
|
+
BlockPackMetaEmbeddedBase64,
|
|
4
|
+
BlockPackMetaEmbeddedBytes,
|
|
3
5
|
ContentAbsoluteBinaryLocal,
|
|
4
6
|
ContentAbsoluteTextLocal,
|
|
7
|
+
ContentRelativeBinary,
|
|
8
|
+
ContentRelativeText,
|
|
5
9
|
DescriptionContentBinary,
|
|
6
10
|
DescriptionContentText
|
|
7
11
|
} from '@milaboratories/pl-model-middle-layer';
|
|
8
12
|
import {
|
|
9
13
|
absoluteToBase64,
|
|
14
|
+
absoluteToBytes,
|
|
10
15
|
absoluteToString,
|
|
11
16
|
cpAbsoluteToRelative,
|
|
12
|
-
mapLocalToAbsolute
|
|
17
|
+
mapLocalToAbsolute,
|
|
18
|
+
RelativeContentReader,
|
|
19
|
+
relativeToContentString,
|
|
20
|
+
relativeToExplicitBytes
|
|
13
21
|
} from './content_conversion';
|
|
14
22
|
import { z } from 'zod';
|
|
15
|
-
import { BlockPackMetaEmbeddedContent } from '@milaboratories/pl-model-middle-layer';
|
|
16
23
|
|
|
17
24
|
export function BlockPackMetaDescription(root: string) {
|
|
18
25
|
return BlockPackMeta(
|
|
@@ -29,8 +36,19 @@ export function BlockPackMetaConsolidate(dstFolder: string, fileAccumulator?: st
|
|
|
29
36
|
);
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
export const
|
|
39
|
+
export const BlockPackMetaEmbedAbsoluteBase64 = BlockPackMeta(
|
|
33
40
|
ContentAbsoluteTextLocal.transform(absoluteToString()),
|
|
34
41
|
ContentAbsoluteBinaryLocal.transform(absoluteToBase64())
|
|
35
|
-
).pipe(
|
|
36
|
-
|
|
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
|
+
}
|
|
@@ -8,10 +8,13 @@ import {
|
|
|
8
8
|
ContentAbsoluteFile,
|
|
9
9
|
ContentAbsoluteFolder,
|
|
10
10
|
ContentAbsoluteTextLocal,
|
|
11
|
-
ContentAbsoluteUrl,
|
|
12
11
|
ContentAnyLocal,
|
|
13
12
|
ContentExplicitBase64,
|
|
14
|
-
|
|
13
|
+
ContentExplicitBytes,
|
|
14
|
+
ContentExplicitString,
|
|
15
|
+
ContentRelative,
|
|
16
|
+
ContentRelativeBinary,
|
|
17
|
+
ContentRelativeText
|
|
15
18
|
} from '@milaboratories/pl-model-middle-layer';
|
|
16
19
|
import { tryResolve } from '@milaboratories/resolve-helper';
|
|
17
20
|
|
|
@@ -119,6 +122,28 @@ export function absoluteToBase64(): (
|
|
|
119
122
|
};
|
|
120
123
|
}
|
|
121
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
|
+
|
|
122
147
|
export function cpAbsoluteToRelative(
|
|
123
148
|
dstFolder: string,
|
|
124
149
|
fileAccumulator?: string[]
|
|
@@ -157,12 +182,55 @@ export function packFolderToRelativeTgz(
|
|
|
157
182
|
};
|
|
158
183
|
}
|
|
159
184
|
|
|
160
|
-
export
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
185
|
+
export type RelativeContentReader = (relativePath: string) => Promise<Buffer>;
|
|
186
|
+
|
|
187
|
+
export function relativeToExplicitString(
|
|
188
|
+
reader: RelativeContentReader
|
|
189
|
+
): (value: ContentRelativeText) => Promise<ContentExplicitString> {
|
|
190
|
+
return async (value) =>
|
|
191
|
+
value.type === 'explicit-string'
|
|
192
|
+
? value
|
|
193
|
+
: { type: 'explicit-string', content: (await reader(value.path)).toString('utf8') };
|
|
194
|
+
}
|
|
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
|
+
|
|
203
|
+
export function relativeToExplicitBinary64(
|
|
204
|
+
reader: RelativeContentReader
|
|
205
|
+
): (value: ContentRelativeBinary) => Promise<ContentExplicitBase64> {
|
|
206
|
+
return async (value) => {
|
|
207
|
+
if (value.type === 'explicit-base64') return value;
|
|
208
|
+
const mimeType = mime.lookup(value.path);
|
|
209
|
+
if (!mimeType) throw new Error(`Can't recognize mime type of the file: ${value.path}.`);
|
|
210
|
+
return {
|
|
211
|
+
type: 'explicit-base64',
|
|
212
|
+
mimeType,
|
|
213
|
+
content: (await reader(value.path)).toString('base64')
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function relativeToExplicitBytes(
|
|
219
|
+
reader: RelativeContentReader
|
|
220
|
+
): (value: ContentRelativeBinary) => Promise<ContentExplicitBytes> {
|
|
221
|
+
return async (value) => {
|
|
222
|
+
if (value.type === 'explicit-base64')
|
|
223
|
+
return {
|
|
224
|
+
type: 'explicit-bytes',
|
|
225
|
+
mimeType: value.mimeType,
|
|
226
|
+
content: Buffer.from(value.content, 'base64')
|
|
227
|
+
};
|
|
228
|
+
const mimeType = mime.lookup(value.path);
|
|
229
|
+
if (!mimeType) throw new Error(`Can't recognize mime type of the file: ${value.path}.`);
|
|
230
|
+
return {
|
|
231
|
+
type: 'explicit-bytes',
|
|
232
|
+
mimeType,
|
|
233
|
+
content: await reader(value.path)
|
|
234
|
+
};
|
|
235
|
+
};
|
|
168
236
|
}
|
package/src/v2/model/index.ts
CHANGED
|
@@ -1,46 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { BlockComponentsConsolidate, BlockComponentsDescription } from './block_components';
|
|
3
|
-
import {
|
|
4
|
-
BlockComponentsManifest,
|
|
5
|
-
BlockPackMetaManifest,
|
|
6
|
-
CreateBlockPackDescriptionSchema
|
|
7
|
-
} from '@milaboratories/pl-model-middle-layer';
|
|
8
|
-
import { BlockPackMetaConsolidate, BlockPackMetaDescription } from './meta';
|
|
9
|
-
|
|
10
|
-
export * from './block_components';
|
|
11
1
|
export * from './content_conversion';
|
|
12
2
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
BlockPackMetaDescription(root)
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
export type BlockPackDescriptionAbsolute = z.infer<
|
|
20
|
-
ReturnType<typeof ResolvedBlockPackDescriptionFromPackageJson>
|
|
21
|
-
>;
|
|
22
|
-
|
|
23
|
-
export function BlockPackDescriptionConsolidateToFolder(
|
|
24
|
-
dstFolder: string,
|
|
25
|
-
fileAccumulator?: string[]
|
|
26
|
-
) {
|
|
27
|
-
return CreateBlockPackDescriptionSchema(
|
|
28
|
-
BlockComponentsConsolidate(dstFolder, fileAccumulator),
|
|
29
|
-
//BlockPackMetaToExplicit
|
|
30
|
-
BlockPackMetaConsolidate(dstFolder, fileAccumulator)
|
|
31
|
-
).pipe(BlockPackDescriptionManifest);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const BlockPackDescriptionManifest = CreateBlockPackDescriptionSchema(
|
|
35
|
-
BlockComponentsManifest,
|
|
36
|
-
BlockPackMetaManifest
|
|
37
|
-
);
|
|
38
|
-
export type BlockPackDescriptionManifest = z.infer<typeof BlockPackDescriptionManifest>;
|
|
39
|
-
|
|
40
|
-
export const BlockPackManifest = BlockPackDescriptionManifest.extend({
|
|
41
|
-
schema: z.literal('v1'),
|
|
42
|
-
files: z.array(z.string())
|
|
43
|
-
});
|
|
44
|
-
export type BlockPackManifest = z.infer<typeof BlockPackManifest>;
|
|
45
|
-
|
|
46
|
-
export const BlockPackManifestFile = 'manifest.json';
|
|
3
|
+
export * from './block_meta';
|
|
4
|
+
export * from './block_components';
|
|
5
|
+
export * from './block_description';
|