@milaboratories/pl-middle-layer 1.10.22 → 1.10.23
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/block_registry/index.d.ts +0 -1
- package/dist/block_registry/index.d.ts.map +1 -1
- package/dist/block_registry/registry-v2-provider.d.ts +9 -0
- package/dist/block_registry/registry-v2-provider.d.ts.map +1 -0
- package/dist/block_registry/registry.d.ts +6 -28
- package/dist/block_registry/registry.d.ts.map +1 -1
- package/dist/block_registry/watcher.d.ts.map +1 -1
- package/dist/block_registry/well_known_registries.d.ts +4 -3
- package/dist/block_registry/well_known_registries.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +357 -341
- package/dist/index.mjs.map +1 -1
- package/dist/mutator/block-pack/block_pack.d.ts.map +1 -1
- package/dist/test/block_packs.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/block_registry/index.ts +0 -1
- package/src/block_registry/registry-v2-provider.ts +16 -0
- package/src/block_registry/registry.test.ts +9 -30
- package/src/block_registry/registry.ts +81 -71
- package/src/block_registry/watcher.ts +6 -3
- package/src/block_registry/well_known_registries.ts +10 -7
- package/src/index.ts +0 -3
- package/src/middle_layer/middle_layer.test.ts +50 -38
- package/src/middle_layer/render.test.ts +5 -10
- package/src/mutator/block-pack/block_pack.test.ts +7 -10
- package/src/mutator/block-pack/block_pack.ts +10 -4
- package/src/test/block_packs.ts +10 -6
- package/dist/block_registry/registry_spec.d.ts +0 -12
- package/dist/block_registry/registry_spec.d.ts.map +0 -1
- package/src/block_registry/registry_spec.ts +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_pack.d.ts","sourceRoot":"","sources":["../../../src/mutator/block-pack/block_pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAS,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE/F,OAAO,EAAqB,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAe,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAW,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD,eAAO,MAAM,mBAAmB,EAAE,YAAwD,CAAC;AAC3F,eAAO,MAAM,sBAAsB,aAAa,CAAC;AACjD,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAQjD,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBADL,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,UAAU,YAAA;IAGvB,cAAc,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"block_pack.d.ts","sourceRoot":"","sources":["../../../src/mutator/block-pack/block_pack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAS,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE/F,OAAO,EAAqB,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAe,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAW,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD,eAAO,MAAM,mBAAmB,EAAE,YAAwD,CAAC;AAC3F,eAAO,MAAM,sBAAsB,aAAa,CAAC;AACjD,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAQjD,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBADL,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,UAAU,YAAA;IAGvB,cAAc,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;IAsC5D,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA4G7E;AAYD,wBAAgB,eAAe,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,qBAAqB,GAAG,cAAc,CAO9F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_packs.d.ts","sourceRoot":"","sources":["../../src/test/block_packs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,eAAO,MAAM,cAAc,mBAE1B,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"block_packs.d.ts","sourceRoot":"","sources":["../../src/test/block_packs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,eAAO,MAAM,cAAc,mBAE1B,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,aAQxC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,aAQtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.23",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"utility-types": "^3.11.0",
|
|
28
28
|
"yaml": "^2.5.1",
|
|
29
29
|
"zod": "^3.23.8",
|
|
30
|
+
"@milaboratories/computable": "^2.1.7",
|
|
30
31
|
"@milaboratories/resolve-helper": "^1.0.1",
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@milaboratories/pl-
|
|
32
|
+
"@platforma-sdk/block-tools": "^2.3.0",
|
|
33
|
+
"@milaboratories/pl-client": "^2.4.15",
|
|
34
|
+
"@milaboratories/pl-drivers": "^1.2.22",
|
|
34
35
|
"@milaboratories/pl-model-common": "^1.3.13",
|
|
35
|
-
"@milaboratories/pl-model-middle-layer": "^1.
|
|
36
|
-
"@milaboratories/pl-tree": "^1.3.
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@milaboratories/ts-helpers": "^1.0.26",
|
|
36
|
+
"@milaboratories/pl-model-middle-layer": "^1.4.0",
|
|
37
|
+
"@milaboratories/pl-tree": "^1.3.12",
|
|
38
|
+
"@platforma-sdk/model": "^1.2.27",
|
|
39
|
+
"@milaboratories/ts-helpers": "^1.0.27",
|
|
40
40
|
"@platforma-sdk/workflow-tengo": "1.2.8"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@types/jest": "^29.5.13",
|
|
46
46
|
"@types/node": "~20.16.5",
|
|
47
47
|
"jest": "^29.7.0",
|
|
48
|
+
"@jest/globals": "^29.7.0",
|
|
48
49
|
"ts-jest": "^29.2.5",
|
|
49
50
|
"@milaboratories/platforma-build-configs": "1.0.1"
|
|
50
51
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { folderReaderByUrl, RegistryV2Reader } from '@platforma-sdk/block-tools';
|
|
2
|
+
import { Dispatcher } from 'undici';
|
|
3
|
+
|
|
4
|
+
export class V2RegistryProvider {
|
|
5
|
+
private readonly registries = new Map<string, RegistryV2Reader>();
|
|
6
|
+
|
|
7
|
+
constructor(private readonly http: Dispatcher) {}
|
|
8
|
+
|
|
9
|
+
public getRegistry(url: string): RegistryV2Reader {
|
|
10
|
+
const fromCache = this.registries.get(url);
|
|
11
|
+
if (fromCache) return fromCache;
|
|
12
|
+
const newRegistry = new RegistryV2Reader(url, folderReaderByUrl(url, this.http));
|
|
13
|
+
this.registries.set(url, newRegistry);
|
|
14
|
+
return newRegistry;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,35 +1,14 @@
|
|
|
1
|
+
import { test, expect } from '@jest/globals';
|
|
1
2
|
import { BlockPackRegistry } from './registry';
|
|
2
3
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
4
|
+
import { CentralBlockRegistry } from './well_known_registries';
|
|
5
|
+
import { V2RegistryProvider } from './registry-v2-provider';
|
|
6
|
+
import { Agent } from 'undici';
|
|
4
7
|
|
|
5
|
-
test('testing
|
|
6
|
-
const registry = new BlockPackRegistry([
|
|
7
|
-
{
|
|
8
|
-
type: 'folder_with_dev_packages',
|
|
9
|
-
label: 'Local dev',
|
|
10
|
-
path: path.resolve('integration')
|
|
11
|
-
}
|
|
8
|
+
test.skip('testing remote registry', async () => {
|
|
9
|
+
const registry = new BlockPackRegistry(new V2RegistryProvider(new Agent()), [
|
|
10
|
+
{ id: 'central', spec: CentralBlockRegistry }
|
|
12
11
|
]);
|
|
13
|
-
|
|
14
|
-
expect(
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test.skip('testing local dev registry with v2', async () => {
|
|
18
|
-
const registry = new BlockPackRegistry([
|
|
19
|
-
{
|
|
20
|
-
type: 'folder_with_dev_packages',
|
|
21
|
-
label: 'Local dev',
|
|
22
|
-
path: path.resolve('/Volumes/Data/Projects/MiLaboratory/blocks-beta')
|
|
23
|
-
}
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
console.dir(await registry.getPackagesOverview(), { depth: 5 });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('testing remote registry', async () => {
|
|
30
|
-
const registry = new BlockPackRegistry([CentralRegistry, CentralDevSnapshotRegistry]);
|
|
31
|
-
|
|
32
|
-
const packages = await registry.getPackagesOverview();
|
|
33
|
-
console.log(packages);
|
|
34
|
-
expect(packages.length).toBeGreaterThanOrEqual(2);
|
|
12
|
+
const listing = await registry.listBlockPacks();
|
|
13
|
+
expect(listing.blockPacks.length).toBeGreaterThanOrEqual(2);
|
|
35
14
|
});
|
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
import { Dispatcher, request } from 'undici';
|
|
2
|
-
import { RegistrySpec } from './registry_spec';
|
|
3
2
|
import { BlockPackSpecAny } from '../model';
|
|
4
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BlockPackDescriptionAbsolute,
|
|
5
|
+
BlockPackMetaEmbedAbsoluteBytes,
|
|
6
|
+
RegistryV1
|
|
7
|
+
} from '@platforma-sdk/block-tools';
|
|
5
8
|
import fs from 'node:fs';
|
|
6
9
|
import path from 'node:path';
|
|
7
10
|
import YAML from 'yaml';
|
|
8
11
|
import { assertNever } from '@milaboratories/ts-helpers';
|
|
9
12
|
import { LegacyDevBlockPackFiles } from '../dev_env';
|
|
10
13
|
import { tryLoadPackDescription } from '@platforma-sdk/block-tools';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Information about specific package with specific organization and package names.
|
|
23
|
-
* Mainly contain information about latest version of the package.
|
|
24
|
-
* */
|
|
25
|
-
export type BlockPackPackageOverview = {
|
|
26
|
-
organization: string;
|
|
27
|
-
/** @deprecated */
|
|
28
|
-
package: string;
|
|
29
|
-
name: string;
|
|
30
|
-
latestVersion: string;
|
|
31
|
-
latestMeta: BlockPackMeta;
|
|
32
|
-
registryLabel: string;
|
|
33
|
-
latestSpec: BlockPackSpecAny;
|
|
34
|
-
otherVersions: string[];
|
|
35
|
-
};
|
|
14
|
+
import { V2RegistryProvider } from './registry-v2-provider';
|
|
15
|
+
import {
|
|
16
|
+
BlockPackListing,
|
|
17
|
+
BlockPackOverview,
|
|
18
|
+
RegistryEntry,
|
|
19
|
+
RegistrySpec,
|
|
20
|
+
RegistryStatus
|
|
21
|
+
} from '@milaboratories/pl-model-middle-layer';
|
|
36
22
|
|
|
37
23
|
async function getFileContent(path: string) {
|
|
38
24
|
try {
|
|
@@ -80,14 +66,16 @@ export async function getDevV2PacketMtime(
|
|
|
80
66
|
|
|
81
67
|
export class BlockPackRegistry {
|
|
82
68
|
constructor(
|
|
83
|
-
private readonly
|
|
69
|
+
private readonly v2Provider: V2RegistryProvider,
|
|
70
|
+
private readonly registries: RegistryEntry[],
|
|
84
71
|
private readonly http?: Dispatcher
|
|
85
72
|
) {}
|
|
86
73
|
|
|
87
|
-
private async getPackagesForRoot(
|
|
88
|
-
const result:
|
|
74
|
+
private async getPackagesForRoot(regEntry: RegistryEntry): Promise<BlockPackOverview[]> {
|
|
75
|
+
const result: BlockPackOverview[] = [];
|
|
76
|
+
const regSpec = regEntry.spec;
|
|
89
77
|
switch (regSpec.type) {
|
|
90
|
-
case '
|
|
78
|
+
case 'remote-v1':
|
|
91
79
|
const httpOptions = this.http !== undefined ? { dispatcher: this.http } : {};
|
|
92
80
|
|
|
93
81
|
const overviewResponse = await request(
|
|
@@ -97,27 +85,39 @@ export class BlockPackRegistry {
|
|
|
97
85
|
const overview = (await overviewResponse.body.json()) as RegistryV1.GlobalOverview;
|
|
98
86
|
for (const overviewEntry of overview) {
|
|
99
87
|
const { organization, package: pkg, latestMeta, latestVersion } = overviewEntry;
|
|
100
|
-
|
|
88
|
+
const id = {
|
|
101
89
|
organization,
|
|
102
|
-
package: pkg,
|
|
103
90
|
name: pkg,
|
|
104
|
-
latestVersion
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
91
|
+
version: latestVersion
|
|
92
|
+
};
|
|
93
|
+
result.push({
|
|
94
|
+
registryId: regEntry.id,
|
|
95
|
+
id,
|
|
96
|
+
meta: {
|
|
97
|
+
title: latestMeta['title'] ?? 'No title',
|
|
98
|
+
description: latestMeta['description'] ?? 'No Description',
|
|
99
|
+
organization: {
|
|
100
|
+
name: organization,
|
|
101
|
+
url: 'https://unknown.com'
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
spec: {
|
|
108
105
|
type: 'from-registry-v1',
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
package: pkg,
|
|
112
|
-
version: latestVersion
|
|
113
|
-
// `${regSpec.url}/${packageContentPrefix({ organization, package: pkg, version: latestVersion })}`
|
|
106
|
+
id,
|
|
107
|
+
registryUrl: regSpec.url
|
|
114
108
|
},
|
|
115
109
|
otherVersions: overviewEntry.allVersions
|
|
116
110
|
});
|
|
117
111
|
}
|
|
118
112
|
return result;
|
|
119
113
|
|
|
120
|
-
case '
|
|
114
|
+
case 'remote-v2':
|
|
115
|
+
return (await this.v2Provider.getRegistry(regSpec.url).listBlockPacks()).map((e) => ({
|
|
116
|
+
...e,
|
|
117
|
+
registryId: regEntry.id
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
case 'local-dev':
|
|
121
121
|
for (const entry of await fs.promises.readdir(regSpec.path, { withFileTypes: true })) {
|
|
122
122
|
if (!entry.isDirectory()) continue;
|
|
123
123
|
const devPath = path.join(regSpec.path, entry.name);
|
|
@@ -130,39 +130,46 @@ export class BlockPackRegistry {
|
|
|
130
130
|
|
|
131
131
|
const mtime = await getDevV1PacketMtime(devPath);
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
const id = {
|
|
134
134
|
organization: config.organization,
|
|
135
|
-
package: config.package, // TODO delete
|
|
136
135
|
name: config.package,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
registryLabel: regSpec.label,
|
|
140
|
-
latestSpec: {
|
|
141
|
-
type: 'dev-v1',
|
|
142
|
-
folder: devPath,
|
|
143
|
-
mtime
|
|
144
|
-
},
|
|
145
|
-
otherVersions: []
|
|
146
|
-
});
|
|
147
|
-
}
|
|
136
|
+
version: 'DEV'
|
|
137
|
+
};
|
|
148
138
|
|
|
149
|
-
const v2Description = await tryLoadPackDescription(devPath);
|
|
150
|
-
if (v2Description !== undefined) {
|
|
151
|
-
const mtime = await getDevV2PacketMtime(v2Description);
|
|
152
139
|
result.push({
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
140
|
+
registryId: regEntry.id,
|
|
141
|
+
id,
|
|
142
|
+
meta: {
|
|
143
|
+
title: (config.meta['title'] as string) ?? 'No title',
|
|
144
|
+
description: (config.meta['description'] as string) ?? 'No Description',
|
|
145
|
+
organization: {
|
|
146
|
+
name: config.organization,
|
|
147
|
+
url: 'https://unknown.com'
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
spec: {
|
|
160
151
|
type: 'dev-v2',
|
|
161
152
|
folder: devPath,
|
|
162
153
|
mtime
|
|
163
154
|
},
|
|
164
155
|
otherVersions: []
|
|
165
156
|
});
|
|
157
|
+
} else {
|
|
158
|
+
const v2Description = await tryLoadPackDescription(devPath);
|
|
159
|
+
if (v2Description !== undefined) {
|
|
160
|
+
const mtime = await getDevV2PacketMtime(v2Description);
|
|
161
|
+
result.push({
|
|
162
|
+
registryId: regEntry.id,
|
|
163
|
+
id: v2Description.id,
|
|
164
|
+
meta: await BlockPackMetaEmbedAbsoluteBytes.parseAsync(v2Description.meta),
|
|
165
|
+
spec: {
|
|
166
|
+
type: 'dev-v2',
|
|
167
|
+
folder: devPath,
|
|
168
|
+
mtime
|
|
169
|
+
},
|
|
170
|
+
otherVersions: []
|
|
171
|
+
});
|
|
172
|
+
}
|
|
166
173
|
}
|
|
167
174
|
|
|
168
175
|
continue;
|
|
@@ -173,10 +180,13 @@ export class BlockPackRegistry {
|
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
|
|
176
|
-
public async
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
183
|
+
public async listBlockPacks(): Promise<BlockPackListing> {
|
|
184
|
+
const blockPacks: BlockPackOverview[] = [];
|
|
185
|
+
const registries: RegistryStatus[] = [];
|
|
186
|
+
for (const regSpecs of this.registries) {
|
|
187
|
+
registries.push({ ...regSpecs, status: 'online' });
|
|
188
|
+
blockPacks.push(...(await this.getPackagesForRoot(regSpecs)));
|
|
189
|
+
}
|
|
190
|
+
return { registries, blockPacks };
|
|
181
191
|
}
|
|
182
192
|
}
|
|
@@ -25,7 +25,6 @@ export class BlockUpdateWatcher extends PollComputablePool<
|
|
|
25
25
|
|
|
26
26
|
protected getKey(req: BlockPackSpec): string {
|
|
27
27
|
switch (req.type) {
|
|
28
|
-
case 'dev':
|
|
29
28
|
case 'dev-v1':
|
|
30
29
|
return `dev_1_${req.folder}_${req.mtime}`;
|
|
31
30
|
case 'dev-v2':
|
|
@@ -38,7 +37,6 @@ export class BlockUpdateWatcher extends PollComputablePool<
|
|
|
38
37
|
protected async readValue(req: BlockPackSpec): Promise<BlockPackSpec | undefined> {
|
|
39
38
|
try {
|
|
40
39
|
switch (req.type) {
|
|
41
|
-
case 'dev':
|
|
42
40
|
case 'dev-v1': {
|
|
43
41
|
const mtime = await getDevV1PacketMtime(req.folder);
|
|
44
42
|
if (mtime === req.mtime) return undefined;
|
|
@@ -65,7 +63,12 @@ export class BlockUpdateWatcher extends PollComputablePool<
|
|
|
65
63
|
): boolean {
|
|
66
64
|
if (res1 === undefined && res2 === undefined) return true;
|
|
67
65
|
if (res1 === undefined || res2 === undefined) return false;
|
|
68
|
-
if (
|
|
66
|
+
if (
|
|
67
|
+
res1.type === 'from-registry-v1' ||
|
|
68
|
+
res2.type === 'from-registry-v1' ||
|
|
69
|
+
res1.type === 'from-registry-v2' ||
|
|
70
|
+
res2.type === 'from-registry-v2'
|
|
71
|
+
)
|
|
69
72
|
throw new Error('Unexpected, not yet supported.');
|
|
70
73
|
return res1.folder === res2.folder && res1.mtime === res2.mtime;
|
|
71
74
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { RegistrySpec } from '
|
|
1
|
+
import { RegistrySpec } from '@milaboratories/pl-model-middle-layer';
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
type: '
|
|
5
|
-
|
|
3
|
+
export const CentralBlockRegistry: RegistrySpec = {
|
|
4
|
+
type: 'remote-v2',
|
|
5
|
+
url: 'https://blocks.pl-open.science/releases'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const V1CentralRegistry: RegistrySpec = {
|
|
9
|
+
type: 'remote-v1',
|
|
6
10
|
url: 'https://block.registry.platforma.bio/releases'
|
|
7
11
|
};
|
|
8
12
|
|
|
9
|
-
export const
|
|
10
|
-
type: '
|
|
11
|
-
label: 'Central Dev Snapshot registry',
|
|
13
|
+
export const V1CentralDevSnapshotRegistry: RegistrySpec = {
|
|
14
|
+
type: 'remote-v1',
|
|
12
15
|
url: 'https://block.registry.platforma.bio/dev'
|
|
13
16
|
};
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,3 @@ export type { FieldType, ResourceType } from '@milaboratories/pl-client';
|
|
|
16
16
|
export * from './mutator/template/template_loading';
|
|
17
17
|
export * from './mutator/template/render_template';
|
|
18
18
|
export * from './model/template_spec';
|
|
19
|
-
|
|
20
|
-
// TODO change to rich meta information from V2 registry
|
|
21
|
-
export { type BlockPackMeta } from './block_registry';
|
|
@@ -1,53 +1,67 @@
|
|
|
1
|
+
import { test, expect } from '@jest/globals';
|
|
1
2
|
import { TestHelpers } from '@milaboratories/pl-client';
|
|
2
3
|
import { MiddleLayer } from './middle_layer';
|
|
3
4
|
import { outputRef } from '../model/args';
|
|
4
5
|
import { randomUUID } from 'node:crypto';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import fs from 'node:fs';
|
|
7
|
-
import { BlockPackRegistry,
|
|
8
|
+
import { BlockPackRegistry, CentralBlockRegistry, getDevV1PacketMtime } from '../block_registry';
|
|
8
9
|
import { LocalBlobHandleAndSize, RemoteBlobHandleAndSize } from '@milaboratories/pl-model-common';
|
|
9
10
|
import { Project } from './project';
|
|
10
11
|
import { LegacyDevBlockPackConfig } from '../dev_env';
|
|
12
|
+
import { V2RegistryProvider } from '../block_registry/registry-v2-provider';
|
|
13
|
+
import { Agent } from 'undici';
|
|
14
|
+
import { BlockPackSpec } from '@milaboratories/pl-model-middle-layer';
|
|
11
15
|
|
|
12
|
-
const registry = new BlockPackRegistry([
|
|
13
|
-
|
|
16
|
+
const registry = new BlockPackRegistry(new V2RegistryProvider(new Agent()), [
|
|
17
|
+
{ id: 'central', spec: CentralBlockRegistry },
|
|
14
18
|
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
id: 'dev',
|
|
20
|
+
title: 'Local dev registry',
|
|
21
|
+
spec: {
|
|
22
|
+
type: 'local-dev',
|
|
23
|
+
path: path.resolve('./integration')
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
]);
|
|
20
27
|
|
|
21
28
|
async function getStandardBlockSpecs() {
|
|
22
|
-
const blocksFromRegistry = await registry.getPackagesOverview();
|
|
23
29
|
return {
|
|
24
|
-
enterNumbersSpecFromRemote:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
30
|
+
enterNumbersSpecFromRemote: {
|
|
31
|
+
type: 'from-registry-v1',
|
|
32
|
+
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
33
|
+
id: { organization: 'milaboratory', name: 'enter-numbers', version: '1.1.1' }
|
|
34
|
+
} satisfies BlockPackSpec,
|
|
35
|
+
enterNumbersSpecFromDev: {
|
|
36
|
+
type: 'dev-v1',
|
|
37
|
+
folder: path.resolve('./integration/block-beta-enter-numbers'),
|
|
38
|
+
mtime: '1727099575979300176'
|
|
39
|
+
} satisfies BlockPackSpec,
|
|
40
|
+
sumNumbersSpecFromRemote: {
|
|
41
|
+
type: 'from-registry-v1',
|
|
42
|
+
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
43
|
+
id: { organization: 'milaboratory', name: 'sum-numbers', version: '1.0.1' }
|
|
44
|
+
} satisfies BlockPackSpec,
|
|
45
|
+
sumNumbersSpecFromDev: {
|
|
46
|
+
type: 'dev-v1',
|
|
47
|
+
folder: path.resolve('./integration/block-beta-sum-numbers'),
|
|
48
|
+
mtime: '1727099575981045820'
|
|
49
|
+
} satisfies BlockPackSpec,
|
|
50
|
+
downloadFileSpecFromRemote: {
|
|
51
|
+
type: 'from-registry-v1',
|
|
52
|
+
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
53
|
+
id: { organization: 'milaboratory', name: 'download-file', version: '1.2.0' }
|
|
54
|
+
} satisfies BlockPackSpec,
|
|
55
|
+
uploadFileSpecFromRemote: {
|
|
56
|
+
type: 'from-registry-v1',
|
|
57
|
+
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
58
|
+
id: { organization: 'milaboratory', name: 'upload-file', version: '1.0.7' }
|
|
59
|
+
} satisfies BlockPackSpec,
|
|
60
|
+
readLogsSpecFromRemote: {
|
|
61
|
+
type: 'from-registry-v1',
|
|
62
|
+
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
63
|
+
id: { organization: 'milaboratory', name: 'read-logs', version: '1.0.7' }
|
|
64
|
+
} satisfies BlockPackSpec
|
|
51
65
|
};
|
|
52
66
|
}
|
|
53
67
|
|
|
@@ -444,7 +458,7 @@ test('block update test', async () => {
|
|
|
444
458
|
});
|
|
445
459
|
const mtime = await getDevV1PacketMtime(devBlockPath);
|
|
446
460
|
const block1Id = await prj.addBlock('Block 1', {
|
|
447
|
-
type: 'dev',
|
|
461
|
+
type: 'dev-v1',
|
|
448
462
|
folder: devBlockPath,
|
|
449
463
|
mtime
|
|
450
464
|
});
|
|
@@ -479,9 +493,7 @@ test('project open and close test', async () => {
|
|
|
479
493
|
const blockId = await prj.addBlock('Test Block', {
|
|
480
494
|
type: 'from-registry-v1',
|
|
481
495
|
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
482
|
-
organization: 'milaboratory',
|
|
483
|
-
package: 'enter-numbers',
|
|
484
|
-
version: '1.1.1'
|
|
496
|
+
id: { organization: 'milaboratory', name: 'enter-numbers', version: '1.1.1' }
|
|
485
497
|
});
|
|
486
498
|
await prj.setBlockArgs(blockId, { numbers: [1, 2, 3] });
|
|
487
499
|
const overview1 = await prj.overview.awaitStableValue();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { test, expect } from '@jest/globals';
|
|
1
2
|
import { awaitBlockDone, withMl } from './middle_layer.test';
|
|
2
3
|
import { getQuickJS, Scope, shouldInterruptAfterDeadline } from 'quickjs-emscripten';
|
|
3
4
|
import * as tp from 'node:timers/promises';
|
|
@@ -11,9 +12,7 @@ test('test JS render enter numbers', async () => {
|
|
|
11
12
|
const block1Id = await prj.addBlock('Block 1', {
|
|
12
13
|
type: 'from-registry-v1',
|
|
13
14
|
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
14
|
-
organization: 'milaboratory',
|
|
15
|
-
package: 'enter-numbers',
|
|
16
|
-
version: '1.1.1'
|
|
15
|
+
id: { organization: 'milaboratory', name: 'enter-numbers', version: '1.1.1' }
|
|
17
16
|
});
|
|
18
17
|
|
|
19
18
|
await prj.setBlockArgs(block1Id, { numbers: [1, 2, 3] });
|
|
@@ -35,14 +34,12 @@ test.skip('test JS render options', async () => {
|
|
|
35
34
|
const block1Id = await prj.addBlock('Block 1', {
|
|
36
35
|
type: 'from-registry-v1',
|
|
37
36
|
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
38
|
-
organization: 'milaboratory',
|
|
39
|
-
package: 'enter-numbers',
|
|
40
|
-
version: '1.1.1'
|
|
37
|
+
id: { organization: 'milaboratory', name: 'enter-numbers', version: '1.1.1' }
|
|
41
38
|
});
|
|
42
39
|
await prj.setBlockArgs(block1Id, { numbers: [1, 2, 3] });
|
|
43
40
|
|
|
44
41
|
const block2Id = await prj.addBlock('Block 2', {
|
|
45
|
-
type: 'dev',
|
|
42
|
+
type: 'dev-v1',
|
|
46
43
|
folder: '../../blocks-beta/block-beta-sum-numbers'
|
|
47
44
|
});
|
|
48
45
|
|
|
@@ -73,9 +70,7 @@ test.skip('test JS render download', async () => {
|
|
|
73
70
|
const block1Id = await prj.addBlock('Block 1', {
|
|
74
71
|
type: 'from-registry-v1',
|
|
75
72
|
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
76
|
-
organization: 'milaboratory',
|
|
77
|
-
package: 'download-file',
|
|
78
|
-
version: '1.2.0'
|
|
73
|
+
id: { organization: 'milaboratory', name: 'download-file', version: '1.2.0' }
|
|
79
74
|
});
|
|
80
75
|
|
|
81
76
|
await prj.setBlockArgs(block1Id, {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isNullResourceId,
|
|
3
|
-
poll,
|
|
4
|
-
TestHelpers,
|
|
5
|
-
toGlobalResourceId
|
|
6
|
-
} from '@milaboratories/pl-client';
|
|
1
|
+
import { isNullResourceId, poll, TestHelpers, toGlobalResourceId } from '@milaboratories/pl-client';
|
|
7
2
|
import { BlockPackPreparer, createBlockPack } from './block_pack';
|
|
8
3
|
import { BlockPackSpecAny } from '../../model';
|
|
9
4
|
import path from 'node:path';
|
|
@@ -16,14 +11,16 @@ test.each([
|
|
|
16
11
|
spec: {
|
|
17
12
|
type: 'from-registry-v1',
|
|
18
13
|
registryUrl: 'https://block.registry.platforma.bio/releases',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
id: {
|
|
15
|
+
organization: 'milaboratory',
|
|
16
|
+
name: 'enter-numbers',
|
|
17
|
+
version: '0.4.1'
|
|
18
|
+
}
|
|
22
19
|
} as BlockPackSpecAny
|
|
23
20
|
},
|
|
24
21
|
{
|
|
25
22
|
spec: {
|
|
26
|
-
type: 'dev',
|
|
23
|
+
type: 'dev-v1',
|
|
27
24
|
folder: path.resolve('integration', 'block-beta-sum-numbers')
|
|
28
25
|
} as BlockPackSpecAny
|
|
29
26
|
}
|
|
@@ -32,7 +32,6 @@ export class BlockPackPreparer {
|
|
|
32
32
|
case 'explicit':
|
|
33
33
|
return spec.config;
|
|
34
34
|
|
|
35
|
-
case 'dev':
|
|
36
35
|
case 'dev-v1': {
|
|
37
36
|
const devPaths = await resolveDevPacket(spec.folder, false);
|
|
38
37
|
const configContent = await fs.promises.readFile(devPaths.config, { encoding: 'utf-8' });
|
|
@@ -50,13 +49,17 @@ export class BlockPackPreparer {
|
|
|
50
49
|
case 'from-registry-v1': {
|
|
51
50
|
const httpOptions = this.http !== undefined ? { dispatcher: this.http } : {};
|
|
52
51
|
|
|
53
|
-
const urlPrefix = `${tSlash(spec.registryUrl)}${RegistryV1.packageContentPrefix(spec)}`;
|
|
52
|
+
const urlPrefix = `${tSlash(spec.registryUrl)}${RegistryV1.packageContentPrefix({ organization: spec.id.organization, package: spec.id.name, version: spec.id.version })}`;
|
|
54
53
|
|
|
55
54
|
const configResponse = await request(`${urlPrefix}/config.json`, httpOptions);
|
|
56
55
|
|
|
57
56
|
return (await configResponse.body.json()) as BlockConfig;
|
|
58
57
|
}
|
|
59
58
|
|
|
59
|
+
case 'from-registry-v2': {
|
|
60
|
+
throw new Error('NOT YET SUPPORTED!');
|
|
61
|
+
}
|
|
62
|
+
|
|
60
63
|
default:
|
|
61
64
|
return assertNever(spec);
|
|
62
65
|
}
|
|
@@ -67,7 +70,6 @@ export class BlockPackPreparer {
|
|
|
67
70
|
case 'explicit':
|
|
68
71
|
return spec;
|
|
69
72
|
|
|
70
|
-
case 'dev':
|
|
71
73
|
case 'dev-v1': {
|
|
72
74
|
const devPaths = await resolveDevPacket(spec.folder, false);
|
|
73
75
|
|
|
@@ -132,7 +134,7 @@ export class BlockPackPreparer {
|
|
|
132
134
|
case 'from-registry-v1': {
|
|
133
135
|
const httpOptions = this.http !== undefined ? { dispatcher: this.http } : {};
|
|
134
136
|
|
|
135
|
-
const urlPrefix = `${tSlash(spec.registryUrl)}${RegistryV1.packageContentPrefix(spec)}`;
|
|
137
|
+
const urlPrefix = `${tSlash(spec.registryUrl)}${RegistryV1.packageContentPrefix({ organization: spec.id.organization, package: spec.id.name, version: spec.id.version })}`;
|
|
136
138
|
|
|
137
139
|
const templateUrl = `${urlPrefix}/template.plj.gz`;
|
|
138
140
|
// template
|
|
@@ -163,6 +165,10 @@ export class BlockPackPreparer {
|
|
|
163
165
|
};
|
|
164
166
|
}
|
|
165
167
|
|
|
168
|
+
case 'from-registry-v2': {
|
|
169
|
+
throw new Error('NOT YET SUPPORTED!');
|
|
170
|
+
}
|
|
171
|
+
|
|
166
172
|
default:
|
|
167
173
|
return assertNever(spec);
|
|
168
174
|
}
|