@langchain/langgraph 0.2.62 → 0.2.63
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/README.md +14 -0
- package/dist/prebuilt/react_agent_executor.cjs +34 -13
- package/dist/prebuilt/react_agent_executor.d.ts +3 -0
- package/dist/prebuilt/react_agent_executor.js +34 -15
- package/dist/prebuilt/react_agent_executor.js.map +1 -1
- package/dist/prebuilt/tool_node.cjs +26 -4
- package/dist/prebuilt/tool_node.js +27 -5
- package/dist/prebuilt/tool_node.js.map +1 -1
- package/dist/pregel/debug.cjs +9 -7
- package/dist/pregel/debug.d.ts +10 -0
- package/dist/pregel/debug.js +2 -2
- package/dist/pregel/debug.js.map +1 -1
- package/dist/pregel/debug.test.cjs +189 -0
- package/dist/pregel/debug.test.d.ts +1 -0
- package/dist/pregel/debug.test.js +187 -0
- package/dist/pregel/debug.test.js.map +1 -0
- package/dist/pregel/io.mapCommand.test.cjs +151 -0
- package/dist/pregel/io.mapCommand.test.d.ts +1 -0
- package/dist/pregel/io.mapCommand.test.js +149 -0
- package/dist/pregel/io.mapCommand.test.js.map +1 -0
- package/dist/pregel/messages.test.cjs +351 -0
- package/dist/pregel/messages.test.d.ts +1 -0
- package/dist/pregel/messages.test.js +349 -0
- package/dist/pregel/messages.test.js.map +1 -0
- package/dist/pregel/read.cjs +1 -1
- package/dist/pregel/read.js +1 -1
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/read.test.cjs +194 -0
- package/dist/pregel/read.test.d.ts +1 -0
- package/dist/pregel/read.test.js +192 -0
- package/dist/pregel/read.test.js.map +1 -0
- package/dist/pregel/runner.test.cjs +66 -0
- package/dist/pregel/runner.test.d.ts +1 -0
- package/dist/pregel/runner.test.js +64 -0
- package/dist/pregel/runner.test.js.map +1 -0
- package/dist/pregel/utils/config.test.cjs +214 -0
- package/dist/pregel/utils/config.test.d.ts +1 -0
- package/dist/pregel/utils/config.test.js +212 -0
- package/dist/pregel/utils/config.test.js.map +1 -0
- package/dist/pregel/utils/subgraph.test.cjs +83 -0
- package/dist/pregel/utils/subgraph.test.d.ts +1 -0
- package/dist/pregel/utils/subgraph.test.js +81 -0
- package/dist/pregel/utils/subgraph.test.js.map +1 -0
- package/dist/pregel/validate.test.cjs +220 -0
- package/dist/pregel/validate.test.d.ts +1 -0
- package/dist/pregel/validate.test.js +218 -0
- package/dist/pregel/validate.test.js.map +1 -0
- package/dist/pregel/write.test.cjs +181 -0
- package/dist/pregel/write.test.d.ts +1 -0
- package/dist/pregel/write.test.js +179 -0
- package/dist/pregel/write.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const globals_1 = require("@jest/globals");
|
|
4
|
+
const debug_js_1 = require("./debug.cjs");
|
|
5
|
+
const last_value_js_1 = require("../channels/last_value.cjs");
|
|
6
|
+
const errors_js_1 = require("../errors.cjs");
|
|
7
|
+
(0, globals_1.describe)("wrap", () => {
|
|
8
|
+
(0, globals_1.it)("should wrap text with color codes", () => {
|
|
9
|
+
const color = {
|
|
10
|
+
start: "\x1b[34m",
|
|
11
|
+
end: "\x1b[0m",
|
|
12
|
+
};
|
|
13
|
+
const text = "test text";
|
|
14
|
+
const result = (0, debug_js_1.wrap)(color, text);
|
|
15
|
+
(0, globals_1.expect)(result).toBe(`${color.start}${text}${color.end}`);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
(0, globals_1.describe)("_readChannels", () => {
|
|
19
|
+
(0, globals_1.it)("should read values from channels", () => {
|
|
20
|
+
const channels = {
|
|
21
|
+
channel1: new last_value_js_1.LastValue(),
|
|
22
|
+
channel2: new last_value_js_1.LastValue(),
|
|
23
|
+
};
|
|
24
|
+
// Update channels with values
|
|
25
|
+
channels.channel1.update(["value1"]);
|
|
26
|
+
channels.channel2.update(["42"]);
|
|
27
|
+
const results = Array.from((0, debug_js_1._readChannels)(channels));
|
|
28
|
+
(0, globals_1.expect)(results).toEqual([
|
|
29
|
+
["channel1", "value1"],
|
|
30
|
+
["channel2", "42"],
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
(0, globals_1.it)("should skip empty channels", () => {
|
|
34
|
+
const mockEmptyChannel = {
|
|
35
|
+
lc_graph_name: "MockChannel",
|
|
36
|
+
lg_is_channel: true,
|
|
37
|
+
ValueType: "",
|
|
38
|
+
UpdateType: [],
|
|
39
|
+
get: globals_1.jest.fn().mockImplementation(() => {
|
|
40
|
+
throw new errors_js_1.EmptyChannelError("Empty channel");
|
|
41
|
+
}),
|
|
42
|
+
update: globals_1.jest.fn().mockReturnValue(true),
|
|
43
|
+
checkpoint: globals_1.jest.fn(),
|
|
44
|
+
fromCheckpoint: globals_1.jest
|
|
45
|
+
.fn()
|
|
46
|
+
.mockReturnThis(),
|
|
47
|
+
consume: globals_1.jest.fn().mockReturnValue(false),
|
|
48
|
+
};
|
|
49
|
+
const channels = {
|
|
50
|
+
channel1: new last_value_js_1.LastValue(),
|
|
51
|
+
emptyChannel: mockEmptyChannel,
|
|
52
|
+
};
|
|
53
|
+
// Update channel with value
|
|
54
|
+
channels.channel1.update(["value1"]);
|
|
55
|
+
const results = Array.from((0, debug_js_1._readChannels)(channels));
|
|
56
|
+
(0, globals_1.expect)(results).toEqual([["channel1", "value1"]]);
|
|
57
|
+
});
|
|
58
|
+
(0, globals_1.it)("should propagate non-empty channel errors", () => {
|
|
59
|
+
const mockErrorChannel = {
|
|
60
|
+
lc_graph_name: "MockChannel",
|
|
61
|
+
lg_is_channel: true,
|
|
62
|
+
ValueType: "",
|
|
63
|
+
UpdateType: [],
|
|
64
|
+
get: globals_1.jest.fn().mockImplementation(() => {
|
|
65
|
+
throw new Error("Other error");
|
|
66
|
+
}),
|
|
67
|
+
update: globals_1.jest.fn().mockReturnValue(true),
|
|
68
|
+
checkpoint: globals_1.jest.fn(),
|
|
69
|
+
fromCheckpoint: globals_1.jest
|
|
70
|
+
.fn()
|
|
71
|
+
.mockReturnThis(),
|
|
72
|
+
consume: globals_1.jest.fn().mockReturnValue(false),
|
|
73
|
+
};
|
|
74
|
+
const channels = {
|
|
75
|
+
channel1: new last_value_js_1.LastValue(),
|
|
76
|
+
errorChannel: mockErrorChannel,
|
|
77
|
+
};
|
|
78
|
+
channels.channel1.update(["value1"]);
|
|
79
|
+
(0, globals_1.expect)(() => Array.from((0, debug_js_1._readChannels)(channels))).toThrow("Other error");
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
(0, globals_1.describe)("tasksWithWrites", () => {
|
|
83
|
+
(0, globals_1.it)("should return task descriptions with no writes", () => {
|
|
84
|
+
const tasks = [
|
|
85
|
+
{
|
|
86
|
+
id: "task1",
|
|
87
|
+
name: "Task 1",
|
|
88
|
+
path: ["PULL", "Task 1"],
|
|
89
|
+
interrupts: [],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "task2",
|
|
93
|
+
name: "Task 2",
|
|
94
|
+
path: ["PULL", "Task 2"],
|
|
95
|
+
interrupts: [],
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
const pendingWrites = [];
|
|
99
|
+
const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites);
|
|
100
|
+
(0, globals_1.expect)(result).toEqual([
|
|
101
|
+
{ id: "task1", name: "Task 1", path: ["PULL", "Task 1"], interrupts: [] },
|
|
102
|
+
{ id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
(0, globals_1.it)("should include error information", () => {
|
|
106
|
+
const tasks = [
|
|
107
|
+
{
|
|
108
|
+
id: "task1",
|
|
109
|
+
name: "Task 1",
|
|
110
|
+
path: ["PULL", "Task 1"],
|
|
111
|
+
interrupts: [],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "task2",
|
|
115
|
+
name: "Task 2",
|
|
116
|
+
path: ["PULL", "Task 2"],
|
|
117
|
+
interrupts: [],
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
const pendingWrites = [
|
|
121
|
+
["task1", "__error__", { message: "Test error" }],
|
|
122
|
+
];
|
|
123
|
+
const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites);
|
|
124
|
+
(0, globals_1.expect)(result).toEqual([
|
|
125
|
+
{
|
|
126
|
+
id: "task1",
|
|
127
|
+
name: "Task 1",
|
|
128
|
+
path: ["PULL", "Task 1"],
|
|
129
|
+
error: { message: "Test error" },
|
|
130
|
+
interrupts: [],
|
|
131
|
+
},
|
|
132
|
+
{ id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
|
|
133
|
+
]);
|
|
134
|
+
});
|
|
135
|
+
(0, globals_1.it)("should include state information", () => {
|
|
136
|
+
const tasks = [
|
|
137
|
+
{
|
|
138
|
+
id: "task1",
|
|
139
|
+
name: "Task 1",
|
|
140
|
+
path: ["PULL", "Task 1"],
|
|
141
|
+
interrupts: [],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "task2",
|
|
145
|
+
name: "Task 2",
|
|
146
|
+
path: ["PULL", "Task 2"],
|
|
147
|
+
interrupts: [],
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
const pendingWrites = [];
|
|
151
|
+
const states = {
|
|
152
|
+
task1: { configurable: { key: "value" } },
|
|
153
|
+
};
|
|
154
|
+
const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites, states);
|
|
155
|
+
(0, globals_1.expect)(result).toEqual([
|
|
156
|
+
{
|
|
157
|
+
id: "task1",
|
|
158
|
+
name: "Task 1",
|
|
159
|
+
path: ["PULL", "Task 1"],
|
|
160
|
+
interrupts: [],
|
|
161
|
+
state: { configurable: { key: "value" } },
|
|
162
|
+
},
|
|
163
|
+
{ id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
|
|
164
|
+
]);
|
|
165
|
+
});
|
|
166
|
+
(0, globals_1.it)("should include interrupts", () => {
|
|
167
|
+
const tasks = [
|
|
168
|
+
{
|
|
169
|
+
id: "task1",
|
|
170
|
+
name: "Task 1",
|
|
171
|
+
path: ["PULL", "Task 1"],
|
|
172
|
+
interrupts: [],
|
|
173
|
+
},
|
|
174
|
+
];
|
|
175
|
+
const pendingWrites = [
|
|
176
|
+
["task1", "__interrupt__", { value: "Interrupted", when: "during" }],
|
|
177
|
+
];
|
|
178
|
+
const result = (0, debug_js_1.tasksWithWrites)(tasks, pendingWrites);
|
|
179
|
+
(0, globals_1.expect)(result).toEqual([
|
|
180
|
+
{
|
|
181
|
+
id: "task1",
|
|
182
|
+
name: "Task 1",
|
|
183
|
+
path: ["PULL", "Task 1"],
|
|
184
|
+
interrupts: [{ value: "Interrupted", when: "during" }],
|
|
185
|
+
},
|
|
186
|
+
]);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
//# sourceMappingURL=debug.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { describe, expect, it, jest } from "@jest/globals";
|
|
2
|
+
import { wrap, tasksWithWrites, _readChannels } from "./debug.js";
|
|
3
|
+
import { LastValue } from "../channels/last_value.js";
|
|
4
|
+
import { EmptyChannelError } from "../errors.js";
|
|
5
|
+
describe("wrap", () => {
|
|
6
|
+
it("should wrap text with color codes", () => {
|
|
7
|
+
const color = {
|
|
8
|
+
start: "\x1b[34m",
|
|
9
|
+
end: "\x1b[0m",
|
|
10
|
+
};
|
|
11
|
+
const text = "test text";
|
|
12
|
+
const result = wrap(color, text);
|
|
13
|
+
expect(result).toBe(`${color.start}${text}${color.end}`);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe("_readChannels", () => {
|
|
17
|
+
it("should read values from channels", () => {
|
|
18
|
+
const channels = {
|
|
19
|
+
channel1: new LastValue(),
|
|
20
|
+
channel2: new LastValue(),
|
|
21
|
+
};
|
|
22
|
+
// Update channels with values
|
|
23
|
+
channels.channel1.update(["value1"]);
|
|
24
|
+
channels.channel2.update(["42"]);
|
|
25
|
+
const results = Array.from(_readChannels(channels));
|
|
26
|
+
expect(results).toEqual([
|
|
27
|
+
["channel1", "value1"],
|
|
28
|
+
["channel2", "42"],
|
|
29
|
+
]);
|
|
30
|
+
});
|
|
31
|
+
it("should skip empty channels", () => {
|
|
32
|
+
const mockEmptyChannel = {
|
|
33
|
+
lc_graph_name: "MockChannel",
|
|
34
|
+
lg_is_channel: true,
|
|
35
|
+
ValueType: "",
|
|
36
|
+
UpdateType: [],
|
|
37
|
+
get: jest.fn().mockImplementation(() => {
|
|
38
|
+
throw new EmptyChannelError("Empty channel");
|
|
39
|
+
}),
|
|
40
|
+
update: jest.fn().mockReturnValue(true),
|
|
41
|
+
checkpoint: jest.fn(),
|
|
42
|
+
fromCheckpoint: jest
|
|
43
|
+
.fn()
|
|
44
|
+
.mockReturnThis(),
|
|
45
|
+
consume: jest.fn().mockReturnValue(false),
|
|
46
|
+
};
|
|
47
|
+
const channels = {
|
|
48
|
+
channel1: new LastValue(),
|
|
49
|
+
emptyChannel: mockEmptyChannel,
|
|
50
|
+
};
|
|
51
|
+
// Update channel with value
|
|
52
|
+
channels.channel1.update(["value1"]);
|
|
53
|
+
const results = Array.from(_readChannels(channels));
|
|
54
|
+
expect(results).toEqual([["channel1", "value1"]]);
|
|
55
|
+
});
|
|
56
|
+
it("should propagate non-empty channel errors", () => {
|
|
57
|
+
const mockErrorChannel = {
|
|
58
|
+
lc_graph_name: "MockChannel",
|
|
59
|
+
lg_is_channel: true,
|
|
60
|
+
ValueType: "",
|
|
61
|
+
UpdateType: [],
|
|
62
|
+
get: jest.fn().mockImplementation(() => {
|
|
63
|
+
throw new Error("Other error");
|
|
64
|
+
}),
|
|
65
|
+
update: jest.fn().mockReturnValue(true),
|
|
66
|
+
checkpoint: jest.fn(),
|
|
67
|
+
fromCheckpoint: jest
|
|
68
|
+
.fn()
|
|
69
|
+
.mockReturnThis(),
|
|
70
|
+
consume: jest.fn().mockReturnValue(false),
|
|
71
|
+
};
|
|
72
|
+
const channels = {
|
|
73
|
+
channel1: new LastValue(),
|
|
74
|
+
errorChannel: mockErrorChannel,
|
|
75
|
+
};
|
|
76
|
+
channels.channel1.update(["value1"]);
|
|
77
|
+
expect(() => Array.from(_readChannels(channels))).toThrow("Other error");
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe("tasksWithWrites", () => {
|
|
81
|
+
it("should return task descriptions with no writes", () => {
|
|
82
|
+
const tasks = [
|
|
83
|
+
{
|
|
84
|
+
id: "task1",
|
|
85
|
+
name: "Task 1",
|
|
86
|
+
path: ["PULL", "Task 1"],
|
|
87
|
+
interrupts: [],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: "task2",
|
|
91
|
+
name: "Task 2",
|
|
92
|
+
path: ["PULL", "Task 2"],
|
|
93
|
+
interrupts: [],
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
const pendingWrites = [];
|
|
97
|
+
const result = tasksWithWrites(tasks, pendingWrites);
|
|
98
|
+
expect(result).toEqual([
|
|
99
|
+
{ id: "task1", name: "Task 1", path: ["PULL", "Task 1"], interrupts: [] },
|
|
100
|
+
{ id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
it("should include error information", () => {
|
|
104
|
+
const tasks = [
|
|
105
|
+
{
|
|
106
|
+
id: "task1",
|
|
107
|
+
name: "Task 1",
|
|
108
|
+
path: ["PULL", "Task 1"],
|
|
109
|
+
interrupts: [],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "task2",
|
|
113
|
+
name: "Task 2",
|
|
114
|
+
path: ["PULL", "Task 2"],
|
|
115
|
+
interrupts: [],
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
const pendingWrites = [
|
|
119
|
+
["task1", "__error__", { message: "Test error" }],
|
|
120
|
+
];
|
|
121
|
+
const result = tasksWithWrites(tasks, pendingWrites);
|
|
122
|
+
expect(result).toEqual([
|
|
123
|
+
{
|
|
124
|
+
id: "task1",
|
|
125
|
+
name: "Task 1",
|
|
126
|
+
path: ["PULL", "Task 1"],
|
|
127
|
+
error: { message: "Test error" },
|
|
128
|
+
interrupts: [],
|
|
129
|
+
},
|
|
130
|
+
{ id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
|
|
131
|
+
]);
|
|
132
|
+
});
|
|
133
|
+
it("should include state information", () => {
|
|
134
|
+
const tasks = [
|
|
135
|
+
{
|
|
136
|
+
id: "task1",
|
|
137
|
+
name: "Task 1",
|
|
138
|
+
path: ["PULL", "Task 1"],
|
|
139
|
+
interrupts: [],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: "task2",
|
|
143
|
+
name: "Task 2",
|
|
144
|
+
path: ["PULL", "Task 2"],
|
|
145
|
+
interrupts: [],
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
const pendingWrites = [];
|
|
149
|
+
const states = {
|
|
150
|
+
task1: { configurable: { key: "value" } },
|
|
151
|
+
};
|
|
152
|
+
const result = tasksWithWrites(tasks, pendingWrites, states);
|
|
153
|
+
expect(result).toEqual([
|
|
154
|
+
{
|
|
155
|
+
id: "task1",
|
|
156
|
+
name: "Task 1",
|
|
157
|
+
path: ["PULL", "Task 1"],
|
|
158
|
+
interrupts: [],
|
|
159
|
+
state: { configurable: { key: "value" } },
|
|
160
|
+
},
|
|
161
|
+
{ id: "task2", name: "Task 2", path: ["PULL", "Task 2"], interrupts: [] },
|
|
162
|
+
]);
|
|
163
|
+
});
|
|
164
|
+
it("should include interrupts", () => {
|
|
165
|
+
const tasks = [
|
|
166
|
+
{
|
|
167
|
+
id: "task1",
|
|
168
|
+
name: "Task 1",
|
|
169
|
+
path: ["PULL", "Task 1"],
|
|
170
|
+
interrupts: [],
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
const pendingWrites = [
|
|
174
|
+
["task1", "__interrupt__", { value: "Interrupted", when: "during" }],
|
|
175
|
+
];
|
|
176
|
+
const result = tasksWithWrites(tasks, pendingWrites);
|
|
177
|
+
expect(result).toEqual([
|
|
178
|
+
{
|
|
179
|
+
id: "task1",
|
|
180
|
+
name: "Task 1",
|
|
181
|
+
path: ["PULL", "Task 1"],
|
|
182
|
+
interrupts: [{ value: "Interrupted", when: "during" }],
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
//# sourceMappingURL=debug.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.test.js","sourceRoot":"","sources":["../../src/pregel/debug.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,KAAK,GAAG;YACZ,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,SAAS;SACf,CAAC;QAEF,MAAM,IAAI,GAAG,WAAW,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEjC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAA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|
+
const constants_js_1 = require("../constants.cjs");
|
|
5
|
+
const io_js_1 = require("./io.cjs");
|
|
6
|
+
const errors_js_1 = require("../errors.cjs");
|
|
7
|
+
(0, globals_1.describe)("mapCommand", () => {
|
|
8
|
+
(0, globals_1.it)("should handle Command with goto (string)", () => {
|
|
9
|
+
const cmd = new constants_js_1.Command({
|
|
10
|
+
goto: "nextNode",
|
|
11
|
+
});
|
|
12
|
+
const pendingWrites = [];
|
|
13
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
14
|
+
(0, globals_1.expect)(result).toEqual([
|
|
15
|
+
[
|
|
16
|
+
"00000000-0000-0000-0000-000000000000",
|
|
17
|
+
"branch:__start__:__self__:nextNode",
|
|
18
|
+
"__start__",
|
|
19
|
+
],
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
(0, globals_1.it)("should handle Command with goto (Send object)", () => {
|
|
23
|
+
const send = new constants_js_1.Send("targetNode", { arg1: "value1" });
|
|
24
|
+
const cmd = new constants_js_1.Command({
|
|
25
|
+
goto: send,
|
|
26
|
+
});
|
|
27
|
+
const pendingWrites = [];
|
|
28
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
29
|
+
(0, globals_1.expect)(result).toEqual([
|
|
30
|
+
["00000000-0000-0000-0000-000000000000", "__pregel_tasks", send],
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
(0, globals_1.it)("should handle Command with goto (array of strings and Send objects)", () => {
|
|
34
|
+
const send = new constants_js_1.Send("targetNode", { arg1: "value1" });
|
|
35
|
+
const cmd = new constants_js_1.Command({
|
|
36
|
+
goto: ["nextNode1", send, "nextNode2"],
|
|
37
|
+
});
|
|
38
|
+
const pendingWrites = [];
|
|
39
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
40
|
+
(0, globals_1.expect)(result).toEqual([
|
|
41
|
+
[
|
|
42
|
+
"00000000-0000-0000-0000-000000000000",
|
|
43
|
+
"branch:__start__:__self__:nextNode1",
|
|
44
|
+
"__start__",
|
|
45
|
+
],
|
|
46
|
+
["00000000-0000-0000-0000-000000000000", "__pregel_tasks", send],
|
|
47
|
+
[
|
|
48
|
+
"00000000-0000-0000-0000-000000000000",
|
|
49
|
+
"branch:__start__:__self__:nextNode2",
|
|
50
|
+
"__start__",
|
|
51
|
+
],
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
(0, globals_1.it)("should throw error for invalid goto value", () => {
|
|
55
|
+
const cmd = new constants_js_1.Command({
|
|
56
|
+
// @ts-expect-error Testing invalid input
|
|
57
|
+
goto: { invalidType: true },
|
|
58
|
+
});
|
|
59
|
+
const pendingWrites = [];
|
|
60
|
+
(0, globals_1.expect)(() => Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites))).toThrow("In Command.send, expected Send or string, got object");
|
|
61
|
+
});
|
|
62
|
+
(0, globals_1.it)("should handle Command with resume (single value)", () => {
|
|
63
|
+
const cmd = new constants_js_1.Command({
|
|
64
|
+
resume: "resumeValue",
|
|
65
|
+
});
|
|
66
|
+
const pendingWrites = [];
|
|
67
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
68
|
+
(0, globals_1.expect)(result).toEqual([
|
|
69
|
+
["00000000-0000-0000-0000-000000000000", "__resume__", "resumeValue"],
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
(0, globals_1.it)("should handle Command with resume (object of task IDs)", () => {
|
|
73
|
+
// Using a valid UUID-like structure
|
|
74
|
+
const cmd = new constants_js_1.Command({
|
|
75
|
+
resume: {
|
|
76
|
+
"123e4567-e89b-12d3-a456-426614174000": "resumeValue1",
|
|
77
|
+
"123e4567-e89b-12d3-a456-426614174001": "resumeValue2",
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
const pendingWrites = [];
|
|
81
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
82
|
+
(0, globals_1.expect)(result).toEqual([
|
|
83
|
+
["123e4567-e89b-12d3-a456-426614174000", "__resume__", ["resumeValue1"]],
|
|
84
|
+
["123e4567-e89b-12d3-a456-426614174001", "__resume__", ["resumeValue2"]],
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
(0, globals_1.it)("should handle Command with update (object)", () => {
|
|
88
|
+
const cmd = new constants_js_1.Command({
|
|
89
|
+
update: {
|
|
90
|
+
channel1: "value1",
|
|
91
|
+
channel2: "value2",
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const pendingWrites = [];
|
|
95
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
96
|
+
(0, globals_1.expect)(result).toEqual([
|
|
97
|
+
["00000000-0000-0000-0000-000000000000", "channel1", "value1"],
|
|
98
|
+
["00000000-0000-0000-0000-000000000000", "channel2", "value2"],
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
101
|
+
(0, globals_1.it)("should handle Command with update (array of tuples)", () => {
|
|
102
|
+
const cmd = new constants_js_1.Command({
|
|
103
|
+
update: [
|
|
104
|
+
["channel1", "value1"],
|
|
105
|
+
["channel2", "value2"],
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
const pendingWrites = [];
|
|
109
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
110
|
+
(0, globals_1.expect)(result).toEqual([
|
|
111
|
+
["00000000-0000-0000-0000-000000000000", "channel1", "value1"],
|
|
112
|
+
["00000000-0000-0000-0000-000000000000", "channel2", "value2"],
|
|
113
|
+
]);
|
|
114
|
+
});
|
|
115
|
+
(0, globals_1.it)("should throw error for invalid update type", () => {
|
|
116
|
+
const cmd = new constants_js_1.Command({
|
|
117
|
+
// @ts-expect-error Testing invalid input
|
|
118
|
+
update: "invalidUpdateType",
|
|
119
|
+
});
|
|
120
|
+
const pendingWrites = [];
|
|
121
|
+
(0, globals_1.expect)(() => Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites))).toThrow("Expected cmd.update to be a dict mapping channel names to update values");
|
|
122
|
+
});
|
|
123
|
+
(0, globals_1.it)("should throw error for parent graph reference when none exists", () => {
|
|
124
|
+
const cmd = new constants_js_1.Command({
|
|
125
|
+
graph: constants_js_1.Command.PARENT,
|
|
126
|
+
goto: "nextNode",
|
|
127
|
+
});
|
|
128
|
+
const pendingWrites = [];
|
|
129
|
+
(0, globals_1.expect)(() => Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites))).toThrow(errors_js_1.InvalidUpdateError);
|
|
130
|
+
(0, globals_1.expect)(() => Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites))).toThrow("There is no parent graph.");
|
|
131
|
+
});
|
|
132
|
+
(0, globals_1.it)("should handle multiple command attributes together", () => {
|
|
133
|
+
const cmd = new constants_js_1.Command({
|
|
134
|
+
goto: "nextNode",
|
|
135
|
+
resume: "resumeValue",
|
|
136
|
+
update: { channel1: "value1" },
|
|
137
|
+
});
|
|
138
|
+
const pendingWrites = [];
|
|
139
|
+
const result = Array.from((0, io_js_1.mapCommand)(cmd, pendingWrites));
|
|
140
|
+
(0, globals_1.expect)(result).toEqual([
|
|
141
|
+
[
|
|
142
|
+
"00000000-0000-0000-0000-000000000000",
|
|
143
|
+
"branch:__start__:__self__:nextNode",
|
|
144
|
+
"__start__",
|
|
145
|
+
],
|
|
146
|
+
["00000000-0000-0000-0000-000000000000", "__resume__", "resumeValue"],
|
|
147
|
+
["00000000-0000-0000-0000-000000000000", "channel1", "value1"],
|
|
148
|
+
]);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=io.mapCommand.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|