@milaboratories/pl-middle-layer 1.67.4 → 1.67.5
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/package.json +10 -10
- package/src/cfg_render/executor.test.ts +42 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-middle-layer",
|
|
3
|
-
"version": "1.67.
|
|
3
|
+
"version": "1.67.5",
|
|
4
4
|
"description": "Pl Middle Layer",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -32,23 +32,23 @@
|
|
|
32
32
|
"zod": "~3.25.76",
|
|
33
33
|
"@milaboratories/columns-collection-driver": "0.2.4",
|
|
34
34
|
"@milaboratories/computable": "2.9.8",
|
|
35
|
-
"@milaboratories/pf-driver": "1.9.1",
|
|
36
35
|
"@milaboratories/pl-deployments": "3.0.16",
|
|
36
|
+
"@milaboratories/pf-spec-driver": "1.5.1",
|
|
37
37
|
"@milaboratories/helpers": "1.14.5",
|
|
38
38
|
"@milaboratories/pl-client": "3.14.7",
|
|
39
|
-
"@milaboratories/pf-
|
|
40
|
-
"@milaboratories/pl-errors": "1.4.36",
|
|
39
|
+
"@milaboratories/pf-driver": "1.9.1",
|
|
41
40
|
"@milaboratories/pl-drivers": "1.16.16",
|
|
42
|
-
"@milaboratories/pl-
|
|
41
|
+
"@milaboratories/pl-errors": "1.4.36",
|
|
43
42
|
"@milaboratories/pl-model-backend": "1.4.21",
|
|
43
|
+
"@milaboratories/pl-model-common": "1.48.0",
|
|
44
44
|
"@milaboratories/pl-model-middle-layer": "1.32.0",
|
|
45
45
|
"@milaboratories/pl-http": "1.2.4",
|
|
46
|
-
"@milaboratories/pl-tree": "1.13.7",
|
|
47
46
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
48
|
-
"@
|
|
47
|
+
"@milaboratories/pl-tree": "1.13.7",
|
|
49
48
|
"@platforma-sdk/block-tools": "2.14.3",
|
|
50
|
-
"@
|
|
51
|
-
"@platforma-sdk/
|
|
49
|
+
"@platforma-sdk/workflow-tengo": "6.8.3",
|
|
50
|
+
"@platforma-sdk/model": "1.83.0",
|
|
51
|
+
"@milaboratories/ts-helpers": "1.8.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "~24.5.2",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"@vitest/coverage-istanbul": "^4.1.3",
|
|
57
57
|
"typescript": "~5.9.3",
|
|
58
58
|
"vitest": "^4.1.3",
|
|
59
|
-
"@milaboratories/ts-builder": "1.7.0",
|
|
60
59
|
"@milaboratories/build-configs": "2.0.0",
|
|
60
|
+
"@milaboratories/ts-builder": "1.7.0",
|
|
61
61
|
"@milaboratories/ts-configs": "1.4.0"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
@@ -1,64 +1,52 @@
|
|
|
1
1
|
import { Computable } from "@milaboratories/computable";
|
|
2
2
|
import { field, Pl, TestHelpers } from "@milaboratories/pl-client";
|
|
3
3
|
import { SynchronizedTreeState } from "@milaboratories/pl-tree";
|
|
4
|
-
import {
|
|
5
|
-
Args,
|
|
6
|
-
BlockConfigGeneric,
|
|
7
|
-
BlockModel,
|
|
8
|
-
getJsonField,
|
|
9
|
-
getResourceField,
|
|
10
|
-
getResourceValueAsJson,
|
|
11
|
-
InferOutputType,
|
|
12
|
-
isolate,
|
|
13
|
-
It,
|
|
14
|
-
MainOutputs,
|
|
15
|
-
makeObject,
|
|
16
|
-
mapArrayValues,
|
|
17
|
-
PlResourceEntry,
|
|
18
|
-
TypedConfig,
|
|
19
|
-
} from "@platforma-sdk/model";
|
|
4
|
+
import type { Cfg, PlResourceEntry } from "@platforma-sdk/model";
|
|
20
5
|
import { expect, test } from "vitest";
|
|
21
6
|
import { MiddleLayerDriverKit } from "../middle_layer/driver_kit";
|
|
22
7
|
import { computableFromCfgUnsafe } from "./executor";
|
|
23
8
|
|
|
9
|
+
// The SDK no longer ships a builder for these configs — it went away with the v1/v2
|
|
10
|
+
// block model — but the executor still has to render configs of blocks published
|
|
11
|
+
// before that. So the fixtures below are spelled out as plain `Cfg` trees.
|
|
12
|
+
|
|
13
|
+
const ctxVar = (variable: string): Cfg => ({ type: "GetFromCtx", variable });
|
|
14
|
+
const imm = (value: unknown): Cfg => ({ type: "Immediate", value });
|
|
15
|
+
const jsonField = (source: Cfg, field: Cfg): Cfg => ({ type: "GetJsonField", source, field });
|
|
16
|
+
const resourceField = (source: Cfg, field: Cfg): Cfg => ({
|
|
17
|
+
type: "GetResourceField",
|
|
18
|
+
source,
|
|
19
|
+
field,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const Args = ctxVar("$args");
|
|
23
|
+
const It = ctxVar("$it");
|
|
24
|
+
const MainOutputs = ctxVar("$prod");
|
|
25
|
+
|
|
24
26
|
test("local cfg test (no pl)", async () => {
|
|
25
27
|
const args = {
|
|
26
28
|
theC: "c",
|
|
27
29
|
a: { c: "hi" },
|
|
28
30
|
b: ["a", "b", "c"],
|
|
29
31
|
};
|
|
30
|
-
const theCValue =
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
).config as BlockConfigGeneric;
|
|
32
|
+
const theCValue = jsonField(Args, imm("theC"));
|
|
33
|
+
|
|
34
|
+
const outputs = {
|
|
35
|
+
out1: jsonField(jsonField(Args, imm("a")), theCValue),
|
|
36
|
+
out2: {
|
|
37
|
+
type: "MapArrayValues",
|
|
38
|
+
source: jsonField(Args, imm("b")),
|
|
39
|
+
itVar: "$it",
|
|
40
|
+
mapping: { type: "Isolate", cfg: { type: "MakeObject", template: { theField: It } } },
|
|
41
|
+
},
|
|
42
|
+
} satisfies Record<string, Cfg>;
|
|
42
43
|
|
|
43
44
|
const ctx = { $args: args };
|
|
44
45
|
|
|
45
|
-
const computable1 = computableFromCfgUnsafe(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
);
|
|
50
|
-
const out1 = (await computable1.getValue()) as InferOutputType<
|
|
51
|
-
(typeof cfg.outputs)["out1"],
|
|
52
|
-
typeof args,
|
|
53
|
-
unknown
|
|
54
|
-
>;
|
|
55
|
-
expect(out1).toEqual("hi");
|
|
56
|
-
|
|
57
|
-
const computable2 = computableFromCfgUnsafe(
|
|
58
|
-
{} as MiddleLayerDriverKit,
|
|
59
|
-
ctx,
|
|
60
|
-
cfg.outputs["out2"] as TypedConfig,
|
|
61
|
-
);
|
|
46
|
+
const computable1 = computableFromCfgUnsafe({} as MiddleLayerDriverKit, ctx, outputs.out1);
|
|
47
|
+
expect(await computable1.getValue()).toEqual("hi");
|
|
48
|
+
|
|
49
|
+
const computable2 = computableFromCfgUnsafe({} as MiddleLayerDriverKit, ctx, outputs.out2);
|
|
62
50
|
const out2 = await computable2.getValue();
|
|
63
51
|
expect(out2).toStrictEqual([{ theField: "a" }, { theField: "b" }, { theField: "c" }]);
|
|
64
52
|
});
|
|
@@ -71,20 +59,14 @@ test("cfg test with pl, simple", async () => {
|
|
|
71
59
|
const input = {
|
|
72
60
|
theC: "c",
|
|
73
61
|
};
|
|
74
|
-
const theCValue =
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
getResourceValueAsJson<TestResourceValue>()(getResourceField(MainOutputs, theCValue)),
|
|
83
|
-
"someField",
|
|
84
|
-
),
|
|
85
|
-
)
|
|
86
|
-
.done() as any
|
|
87
|
-
).config as BlockConfigGeneric;
|
|
62
|
+
const theCValue = jsonField(Args, imm("theC"));
|
|
63
|
+
|
|
64
|
+
const outputs = {
|
|
65
|
+
out1: jsonField(
|
|
66
|
+
{ type: "GetResourceValueAsJson", source: resourceField(MainOutputs, theCValue) },
|
|
67
|
+
imm("someField"),
|
|
68
|
+
),
|
|
69
|
+
} satisfies Record<string, Cfg>;
|
|
88
70
|
|
|
89
71
|
await TestHelpers.withTempRoot(async (pl) => {
|
|
90
72
|
const tree = await SynchronizedTreeState.init(pl, pl.clientRoot, {
|
|
@@ -100,7 +82,7 @@ test("cfg test with pl, simple", async () => {
|
|
|
100
82
|
const computable: Computable<unknown> = computableFromCfgUnsafe(
|
|
101
83
|
{} as MiddleLayerDriverKit,
|
|
102
84
|
ctx,
|
|
103
|
-
|
|
85
|
+
outputs.out1,
|
|
104
86
|
) as any;
|
|
105
87
|
|
|
106
88
|
expect(await computable.getValue()).toBeUndefined();
|