@milaboratories/pl-middle-layer 1.10.20 → 1.10.22
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/registry.d.ts.map +1 -1
- package/dist/dev_env/index.d.ts.map +1 -0
- package/dist/dev_env/util.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -51
- package/dist/index.mjs.map +1 -1
- package/dist/mutator/block-pack/block_pack.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/block_registry/registry.ts +4 -2
- package/src/{dev → dev_env}/index.ts +1 -11
- package/src/middle_layer/middle_layer.test.ts +1 -1
- package/src/mutator/block-pack/block_pack.ts +4 -2
- package/dist/dev/index.d.ts.map +0 -1
- package/dist/dev/util.d.ts.map +0 -1
- /package/dist/{dev → dev_env}/index.d.ts +0 -0
- /package/dist/{dev → dev_env}/util.d.ts +0 -0
- /package/src/{dev → dev_env}/util.ts +0 -0
package/dist/index.mjs
CHANGED
|
@@ -11,20 +11,21 @@ import I from "node:path";
|
|
|
11
11
|
import Ht from "yaml";
|
|
12
12
|
import { assertNever as D, notEmpty as w, HmacSha256Signer as dt, ConsoleLoggerAdapter as _t } from "@milaboratories/ts-helpers";
|
|
13
13
|
import * as Wt from "node:fs/promises";
|
|
14
|
-
import {
|
|
14
|
+
import { tryResolve as zt } from "@milaboratories/resolve-helper";
|
|
15
|
+
import { resourceTypesEqual as K, field as S, Pl as y, PlClient as qt, isNullResourceId as ce, ensureResourceIdNotNull as we, isResource as Yt, isResourceRef as Qt, isNotNullResourceId as _e, resourceType as X, resourceTypeToString as Zt, resourceIdToString as pt, isNotFoundError as Xt, isTimeoutOrCancelError as er, toGlobalResourceId as tr } from "@milaboratories/pl-client";
|
|
15
16
|
export * from "@milaboratories/pl-client";
|
|
16
|
-
import { SynchronizedTreeState as ht, PlError as
|
|
17
|
-
import { Computable as P, ChangeSource as We, PollComputablePool as
|
|
17
|
+
import { SynchronizedTreeState as ht, PlError as rr } from "@milaboratories/pl-tree";
|
|
18
|
+
import { Computable as P, ChangeSource as We, PollComputablePool as or, WatchableValue as sr } from "@milaboratories/computable";
|
|
18
19
|
import { randomUUID as Y, createHash as he } from "node:crypto";
|
|
19
20
|
import ft from "denque";
|
|
20
|
-
import { Templates as
|
|
21
|
+
import { Templates as nr } from "@platforma-sdk/workflow-tengo";
|
|
21
22
|
import Ee from "canonicalize";
|
|
22
|
-
import
|
|
23
|
-
import { Scope as Se, getQuickJS as
|
|
24
|
-
import { setTimeout as
|
|
23
|
+
import ir from "node:assert";
|
|
24
|
+
import { Scope as Se, getQuickJS as ar } from "quickjs-emscripten";
|
|
25
|
+
import { setTimeout as cr } from "node:timers/promises";
|
|
25
26
|
import * as gt from "node:os";
|
|
26
|
-
import { createDownloadClient as
|
|
27
|
-
import { PFrame as
|
|
27
|
+
import { createDownloadClient as ur, createLogsClient as lr, createUploadBlobClient as dr, createUploadProgressClient as pr, createLsFilesClient as hr, DownloadDriver as fr, UploadDriver as gr, LogsStreamDriver as mr, LogsDriver as vr, LsDriver as yr, DownloadUrlDriver as br } from "@milaboratories/pl-drivers";
|
|
28
|
+
import { PFrame as wr } from "@milaboratories/pframes-node";
|
|
28
29
|
async function ze(o) {
|
|
29
30
|
try {
|
|
30
31
|
return await Wt.stat(o, { bigint: !0 });
|
|
@@ -34,39 +35,30 @@ async function ze(o) {
|
|
|
34
35
|
throw e;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
const
|
|
38
|
+
const Sr = [U.PlPackageYamlConfigFile], kr = [U.PlPackageJsonConfigFile], je = ["backend", "dist", "tengo", "tpl", "main.plj.gz"], Te = ["config", "dist", "config.json"], mt = ["frontend", "dist"], qe = "block-model/dist/config.json", Cr = "block-ui/package.json", Pr = [
|
|
38
39
|
je,
|
|
39
40
|
Te,
|
|
40
|
-
wr,
|
|
41
41
|
Sr,
|
|
42
|
+
kr,
|
|
42
43
|
mt
|
|
43
44
|
];
|
|
44
|
-
async function
|
|
45
|
+
async function Fr(o) {
|
|
45
46
|
return await ze(I.join(o, ...Te)) !== void 0 || await ze(I.join(o, ...je)) !== void 0;
|
|
46
47
|
}
|
|
47
|
-
function Fr(o, e) {
|
|
48
|
-
try {
|
|
49
|
-
return require.resolve(e, {
|
|
50
|
-
paths: [o]
|
|
51
|
-
});
|
|
52
|
-
} catch (t) {
|
|
53
|
-
if (t.code !== "MODULE_NOT_FOUND") throw t;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
48
|
function me(o, e) {
|
|
57
|
-
const t =
|
|
49
|
+
const t = zt(o, e);
|
|
58
50
|
if (t === void 0) throw new Error(`Can't resolve ${e} against ${o}`);
|
|
59
51
|
return t;
|
|
60
52
|
}
|
|
61
53
|
async function Ye(o, e) {
|
|
62
|
-
if (I.isAbsolute(o) || (o = I.resolve(o)), await
|
|
54
|
+
if (I.isAbsolute(o) || (o = I.resolve(o)), await Fr(o))
|
|
63
55
|
return {
|
|
64
56
|
workflow: I.join(o, ...je),
|
|
65
57
|
config: I.join(o, ...Te),
|
|
66
58
|
ui: I.join(o, ...mt)
|
|
67
59
|
};
|
|
68
60
|
{
|
|
69
|
-
const t = me(o, qe), r = me(o, qe), s = me(o,
|
|
61
|
+
const t = me(o, qe), r = me(o, qe), s = me(o, Cr);
|
|
70
62
|
return { workflow: t, config: r, ui: I.resolve(s, "..", "dist") };
|
|
71
63
|
}
|
|
72
64
|
}
|
|
@@ -90,17 +82,19 @@ async function Rr(o) {
|
|
|
90
82
|
}
|
|
91
83
|
async function vt(o) {
|
|
92
84
|
let e = 0n;
|
|
93
|
-
for (const t of
|
|
85
|
+
for (const t of Pr) {
|
|
94
86
|
const r = I.join(o, ...t), s = await Rr(r);
|
|
95
87
|
s !== void 0 && e < s.mtimeNs && (e = s.mtimeNs);
|
|
96
88
|
}
|
|
97
89
|
return e.toString();
|
|
98
90
|
}
|
|
99
91
|
async function Ae(o) {
|
|
100
|
-
const e = await T.promises.stat(o.components.workflow.
|
|
92
|
+
const e = await T.promises.stat(o.components.workflow.main.file, {
|
|
93
|
+
bigint: !0
|
|
94
|
+
}), t = await T.promises.stat(o.components.model.file, { bigint: !0 });
|
|
101
95
|
return (e.mtimeNs > t.mtimeNs ? e.mtimeNs : t.mtimeNs).toString();
|
|
102
96
|
}
|
|
103
|
-
class
|
|
97
|
+
class Ws {
|
|
104
98
|
constructor(e, t) {
|
|
105
99
|
this.registrySpecs = e, this.http = t;
|
|
106
100
|
}
|
|
@@ -189,11 +183,11 @@ class _s {
|
|
|
189
183
|
return e;
|
|
190
184
|
}
|
|
191
185
|
}
|
|
192
|
-
const
|
|
186
|
+
const zs = {
|
|
193
187
|
type: "remote_v1",
|
|
194
188
|
label: "Central Release Registry",
|
|
195
189
|
url: "https://block.registry.platforma.bio/releases"
|
|
196
|
-
},
|
|
190
|
+
}, qs = {
|
|
197
191
|
type: "remote_v1",
|
|
198
192
|
label: "Central Dev Snapshot registry",
|
|
199
193
|
url: "https://block.registry.platforma.bio/dev"
|
|
@@ -406,7 +400,9 @@ class lo {
|
|
|
406
400
|
await T.promises.readFile(t.components.model.file, {
|
|
407
401
|
encoding: "utf-8"
|
|
408
402
|
})
|
|
409
|
-
), s = await T.promises.readFile(
|
|
403
|
+
), s = await T.promises.readFile(
|
|
404
|
+
t.components.workflow.main.file
|
|
405
|
+
), n = t.components.ui.folder, i = { ...e };
|
|
410
406
|
return e.mtime === void 0 && (i.mtime = await Ae(t)), {
|
|
411
407
|
type: "explicit",
|
|
412
408
|
template: {
|
|
@@ -582,7 +578,7 @@ function et(o, e) {
|
|
|
582
578
|
let ve;
|
|
583
579
|
async function Rt() {
|
|
584
580
|
if (ve === void 0) {
|
|
585
|
-
const o = await no(
|
|
581
|
+
const o = await no(nr["pframes.export-pframe"]);
|
|
586
582
|
if (o.type !== "explicit") throw new Error("Unexpected prepared template type.");
|
|
587
583
|
const e = he("sha256").update(o.content).digest("hex");
|
|
588
584
|
ve = { spec: o, hash: e };
|
|
@@ -1101,7 +1097,7 @@ class le {
|
|
|
1101
1097
|
$.forEach(({ id: v, fields: O }) => {
|
|
1102
1098
|
for (const [, F] of Object.entries(O))
|
|
1103
1099
|
if (F.ref !== void 0) {
|
|
1104
|
-
if (!
|
|
1100
|
+
if (!Yt(F.ref) || Qt(F.ref))
|
|
1105
1101
|
throw new Error("unexpected behaviour");
|
|
1106
1102
|
R.push([F, e.getResourceData(F.ref, !1)]);
|
|
1107
1103
|
}
|
|
@@ -1156,7 +1152,7 @@ async function be(o, e, t) {
|
|
|
1156
1152
|
return A(o, e, void 0, t);
|
|
1157
1153
|
}
|
|
1158
1154
|
async function A(o, e, t, r) {
|
|
1159
|
-
if (o instanceof
|
|
1155
|
+
if (o instanceof qt)
|
|
1160
1156
|
return await o.withWriteTx("ProjectAction", async (s) => {
|
|
1161
1157
|
const n = await le.load(s, e, t), i = await r(n);
|
|
1162
1158
|
return n.wasModified && (n.save(), await s.commit()), i;
|
|
@@ -1296,7 +1292,7 @@ function Bo(o) {
|
|
|
1296
1292
|
parts: r
|
|
1297
1293
|
};
|
|
1298
1294
|
}
|
|
1299
|
-
throw new Error(`unsupported resource type: ${
|
|
1295
|
+
throw new Error(`unsupported resource type: ${Zt(o.resourceType)}`);
|
|
1300
1296
|
}
|
|
1301
1297
|
function Ot(o, e) {
|
|
1302
1298
|
const t = he("sha256");
|
|
@@ -1344,7 +1340,7 @@ function Dt(o, e = !0, t = !1, r = "") {
|
|
|
1344
1340
|
function Ro(o, e = !0, t = "") {
|
|
1345
1341
|
if (!o.getIsReadyOrError()) throw new Error("resource is not ready");
|
|
1346
1342
|
const r = Dt(o, e, !1, t);
|
|
1347
|
-
|
|
1343
|
+
ir(r.locked);
|
|
1348
1344
|
const s = {};
|
|
1349
1345
|
for (const [n, i] of r.results) {
|
|
1350
1346
|
if (i.spec === void 0) throw new Error(`no spec for key ${n}`);
|
|
@@ -1352,7 +1348,7 @@ function Ro(o, e = !0, t = "") {
|
|
|
1352
1348
|
throw new Error(`no data for key ${n}`);
|
|
1353
1349
|
const a = i.data();
|
|
1354
1350
|
if (a === void 0) throw new Error(`no data for key ${n}`);
|
|
1355
|
-
if (!a.ok) throw new
|
|
1351
|
+
if (!a.ok) throw new rr(a.error);
|
|
1356
1352
|
s[n] = {
|
|
1357
1353
|
id: Ot(i.spec, a.value),
|
|
1358
1354
|
spec: i.spec,
|
|
@@ -2860,14 +2856,14 @@ class Je {
|
|
|
2860
2856
|
try {
|
|
2861
2857
|
await be(this.env.pl, this.rid, (e) => {
|
|
2862
2858
|
e.doRefresh(this.env.ops.stagingRenderingRate);
|
|
2863
|
-
}), await this.activeConfigs.getValue(), await
|
|
2859
|
+
}), await this.activeConfigs.getValue(), await cr(this.env.ops.projectRefreshInterval, this.abortController.signal);
|
|
2864
2860
|
} catch (e) {
|
|
2865
|
-
if (
|
|
2861
|
+
if (Xt(e)) {
|
|
2866
2862
|
console.warn(
|
|
2867
2863
|
"project refresh routine terminated, because project was externally deleted"
|
|
2868
2864
|
);
|
|
2869
2865
|
break;
|
|
2870
|
-
} else if (!
|
|
2866
|
+
} else if (!er(e))
|
|
2871
2867
|
throw new Error("Unexpected exception", { cause: e });
|
|
2872
2868
|
}
|
|
2873
2869
|
}
|
|
@@ -3128,7 +3124,7 @@ const Lt = {
|
|
|
3128
3124
|
}, ms = {
|
|
3129
3125
|
minDelay: 1500
|
|
3130
3126
|
}, vs = "__no_updates__";
|
|
3131
|
-
class ys extends
|
|
3127
|
+
class ys extends or {
|
|
3132
3128
|
constructor(t = {}) {
|
|
3133
3129
|
super({ ...t, ...ms });
|
|
3134
3130
|
d(this, "http");
|
|
@@ -3214,7 +3210,7 @@ function at(o) {
|
|
|
3214
3210
|
}
|
|
3215
3211
|
class bs {
|
|
3216
3212
|
constructor(e, t) {
|
|
3217
|
-
d(this, "pFrame", new
|
|
3213
|
+
d(this, "pFrame", new wr());
|
|
3218
3214
|
d(this, "blobIdToResource", /* @__PURE__ */ new Map());
|
|
3219
3215
|
d(this, "blobHandleComputables", /* @__PURE__ */ new Map());
|
|
3220
3216
|
d(this, "preloadBlob", async (e) => {
|
|
@@ -3401,20 +3397,20 @@ function ae(o, e) {
|
|
|
3401
3397
|
async function Ps(o, e, t) {
|
|
3402
3398
|
const r = { ...Lt, ...t };
|
|
3403
3399
|
Fs(e, r);
|
|
3404
|
-
const s = new dt(r.localSecret), n =
|
|
3400
|
+
const s = new dt(r.localSecret), n = ur(e, o, r.platformLocalStorageNameToPath), i = lr(o, e), a = dr(o, e), u = pr(o, e), c = hr(o, e), l = new fr(
|
|
3405
3401
|
e,
|
|
3406
3402
|
n,
|
|
3407
3403
|
i,
|
|
3408
3404
|
r.blobDownloadPath,
|
|
3409
3405
|
s,
|
|
3410
3406
|
r.blobDriverOps
|
|
3411
|
-
), p = new
|
|
3407
|
+
), p = new gr(
|
|
3412
3408
|
e,
|
|
3413
3409
|
s,
|
|
3414
3410
|
a,
|
|
3415
3411
|
u,
|
|
3416
3412
|
r.uploadDriverOps
|
|
3417
|
-
), h = new
|
|
3413
|
+
), h = new mr(i, r.logStreamDriverOps), g = new vr(h, l), b = new yr(e, c, o, s, r.localStorageNameToPath), B = new ws(l);
|
|
3418
3414
|
return {
|
|
3419
3415
|
blobDriver: l,
|
|
3420
3416
|
logDriver: g,
|
|
@@ -3456,7 +3452,7 @@ class Jt {
|
|
|
3456
3452
|
async createProject(e, t = Y()) {
|
|
3457
3453
|
const r = await this.pl.withWriteTx("MLCreateProject", async (s) => {
|
|
3458
3454
|
const n = await yo(s, e);
|
|
3459
|
-
return s.createField(S(this.projectListResourceId, t), "Dynamic", n), await s.commit(), await
|
|
3455
|
+
return s.createField(S(this.projectListResourceId, t), "Dynamic", n), await s.commit(), await tr(n);
|
|
3460
3456
|
});
|
|
3461
3457
|
return await this.projectListTree.refreshState(), r;
|
|
3462
3458
|
}
|
|
@@ -3528,7 +3524,7 @@ class Jt {
|
|
|
3528
3524
|
return h.lock(B), h.setField(g, B), await h.commit(), await B.globalId;
|
|
3529
3525
|
} else
|
|
3530
3526
|
return b.value;
|
|
3531
|
-
}), n = new _t(console), i = await Ps(e, n, r), a = new lo(i.signer), u = new
|
|
3527
|
+
}), n = new _t(console), i = await Ps(e, n, r), a = new lo(i.signer), u = new br(
|
|
3532
3528
|
n,
|
|
3533
3529
|
e.httpDispatcher,
|
|
3534
3530
|
r.frontendDownloadPath
|
|
@@ -3543,8 +3539,8 @@ class Jt {
|
|
|
3543
3539
|
minDelay: r.devBlockUpdateRecheckInterval,
|
|
3544
3540
|
http: e.httpDispatcher
|
|
3545
3541
|
}),
|
|
3546
|
-
quickJs: await
|
|
3547
|
-
}, l = new
|
|
3542
|
+
quickJs: await ar()
|
|
3543
|
+
}, l = new sr([]), p = await Mr(e, s, l, c);
|
|
3548
3544
|
return new Jt(
|
|
3549
3545
|
c,
|
|
3550
3546
|
i,
|
|
@@ -3557,9 +3553,9 @@ class Jt {
|
|
|
3557
3553
|
}
|
|
3558
3554
|
}
|
|
3559
3555
|
export {
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3556
|
+
Ws as BlockPackRegistry,
|
|
3557
|
+
qs as CentralDevSnapshotRegistry,
|
|
3558
|
+
zs as CentralRegistry,
|
|
3563
3559
|
Lt as DefaultDriverKitOps,
|
|
3564
3560
|
gs as DefaultMiddleLayerOps,
|
|
3565
3561
|
Ct as FrontendFromFolderResourceType,
|