@pipelab/core-node 1.0.0-beta.18 → 1.0.0-beta.19
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/CHANGELOG.md +9 -0
- package/dist/config-Bi0ORcTK.mjs +2 -0
- package/dist/config-CFgGRD9U.mjs +265 -0
- package/dist/config-CFgGRD9U.mjs.map +1 -0
- package/dist/index.d.mts +29 -18
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +784 -303
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/config.test.ts +59 -11
- package/src/config.ts +71 -32
- package/src/context.ts +42 -4
- package/src/handlers/config.ts +252 -72
- package/src/handlers/engine.ts +2 -2
- package/src/handlers/index.ts +2 -0
- package/src/handlers/migration.ts +598 -0
- package/src/index.ts +9 -2
- package/src/plugins-registry.ts +2 -2
- package/src/runner.ts +0 -3
- package/src/server.ts +0 -3
- package/src/utils.ts +2 -2
- package/dist/config-CEkOf95p.mjs +0 -2
- package/src/migrations.ts +0 -60
package/src/handlers/config.ts
CHANGED
|
@@ -1,138 +1,318 @@
|
|
|
1
1
|
import { useAPI } from "../ipc-core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
useLogger,
|
|
4
|
+
appSettingsMigrator,
|
|
5
|
+
connectionsMigrator,
|
|
6
|
+
fileRepoMigrations,
|
|
7
|
+
} from "@pipelab/shared";
|
|
8
|
+
import {
|
|
9
|
+
setupSettingsConfigFile,
|
|
10
|
+
setupConnectionsConfigFile,
|
|
11
|
+
setupProjectsConfigFile,
|
|
12
|
+
setupPipelineConfigFileByName,
|
|
13
|
+
setupPipelineConfigFileByPath,
|
|
14
|
+
deletePipelineConfigFileByName,
|
|
15
|
+
deletePipelineConfigFileByPath,
|
|
16
|
+
} from "../config";
|
|
4
17
|
import { PipelabContext } from "../context";
|
|
5
|
-
import fs from "node:fs/promises";
|
|
6
|
-
import path from "node:path";
|
|
7
18
|
|
|
8
19
|
export const registerConfigHandlers = (context: PipelabContext) => {
|
|
9
20
|
const { handle } = useAPI();
|
|
10
21
|
const { logger } = useLogger();
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
logger().info("
|
|
15
|
-
|
|
23
|
+
// Settings
|
|
24
|
+
handle("settings:load", async (_, { send }) => {
|
|
25
|
+
logger().info("settings:load");
|
|
16
26
|
try {
|
|
17
|
-
const manager = await
|
|
27
|
+
const manager = await setupSettingsConfigFile(context);
|
|
18
28
|
const json = await manager.getConfig();
|
|
19
|
-
|
|
20
29
|
send({
|
|
21
30
|
type: "end",
|
|
22
|
-
data: {
|
|
23
|
-
type: "success",
|
|
24
|
-
result: {
|
|
25
|
-
result: json,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
31
|
+
data: { type: "success", result: json },
|
|
28
32
|
});
|
|
29
33
|
} catch (e) {
|
|
30
|
-
logger().error(
|
|
34
|
+
logger().error("settings:load error:", e);
|
|
31
35
|
send({
|
|
32
36
|
type: "end",
|
|
33
|
-
data: {
|
|
34
|
-
type: "error",
|
|
35
|
-
ipcError: e instanceof Error ? e.message : `Unable to load config ${name}`,
|
|
36
|
-
},
|
|
37
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to load settings" },
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
handle("
|
|
42
|
-
const { data
|
|
43
|
-
|
|
42
|
+
handle("settings:save", async (_, { send, value }) => {
|
|
43
|
+
const { data } = value;
|
|
44
44
|
try {
|
|
45
|
-
const manager = await
|
|
45
|
+
const manager = await setupSettingsConfigFile(context);
|
|
46
46
|
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
47
47
|
await manager.setConfig(json);
|
|
48
|
+
send({
|
|
49
|
+
type: "end",
|
|
50
|
+
data: { type: "success", result: "ok" },
|
|
51
|
+
});
|
|
52
|
+
} catch (e) {
|
|
53
|
+
logger().error("settings:save error:", e);
|
|
54
|
+
send({
|
|
55
|
+
type: "end",
|
|
56
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to save settings" },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
48
60
|
|
|
61
|
+
handle("settings:reset", async (_, { send, value }) => {
|
|
62
|
+
const { key } = value;
|
|
63
|
+
try {
|
|
64
|
+
const manager = await setupSettingsConfigFile(context);
|
|
65
|
+
const currentConfig = await manager.getConfig();
|
|
66
|
+
const defaultValue = (appSettingsMigrator.defaultValue as any)[key];
|
|
67
|
+
await manager.setConfig({
|
|
68
|
+
...(currentConfig ? (currentConfig as any) : {}),
|
|
69
|
+
[key]: defaultValue,
|
|
70
|
+
} as any);
|
|
49
71
|
send({
|
|
50
72
|
type: "end",
|
|
51
|
-
data: {
|
|
52
|
-
type: "success",
|
|
53
|
-
result: {
|
|
54
|
-
result: "ok",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
73
|
+
data: { type: "success", result: "ok" },
|
|
57
74
|
});
|
|
58
75
|
} catch (e) {
|
|
59
|
-
logger().error(
|
|
76
|
+
logger().error("settings:reset error:", e);
|
|
60
77
|
send({
|
|
61
78
|
type: "end",
|
|
62
|
-
data: {
|
|
63
|
-
type: "error",
|
|
64
|
-
ipcError: e instanceof Error ? e.message : `Unable to save config ${name}`,
|
|
65
|
-
},
|
|
79
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to reset settings" },
|
|
66
80
|
});
|
|
67
81
|
}
|
|
68
82
|
});
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
logger().info("
|
|
84
|
+
// Connections
|
|
85
|
+
handle("connections:load", async (_, { send }) => {
|
|
86
|
+
logger().info("connections:load");
|
|
87
|
+
try {
|
|
88
|
+
const manager = await setupConnectionsConfigFile(context);
|
|
89
|
+
const json = await manager.getConfig();
|
|
90
|
+
send({
|
|
91
|
+
type: "end",
|
|
92
|
+
data: { type: "success", result: json },
|
|
93
|
+
});
|
|
94
|
+
} catch (e) {
|
|
95
|
+
logger().error("connections:load error:", e);
|
|
96
|
+
send({
|
|
97
|
+
type: "end",
|
|
98
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to load connections" },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
73
102
|
|
|
103
|
+
handle("connections:save", async (_, { send, value }) => {
|
|
104
|
+
const { data } = value;
|
|
74
105
|
try {
|
|
75
|
-
const manager = await
|
|
76
|
-
const
|
|
106
|
+
const manager = await setupConnectionsConfigFile(context);
|
|
107
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
108
|
+
await manager.setConfig(json);
|
|
109
|
+
send({
|
|
110
|
+
type: "end",
|
|
111
|
+
data: { type: "success", result: "ok" },
|
|
112
|
+
});
|
|
113
|
+
} catch (e) {
|
|
114
|
+
logger().error("connections:save error:", e);
|
|
115
|
+
send({
|
|
116
|
+
type: "end",
|
|
117
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to save connections" },
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
77
121
|
|
|
78
|
-
|
|
122
|
+
handle("connections:reset", async (_, { send, value }) => {
|
|
123
|
+
const { key } = value;
|
|
124
|
+
try {
|
|
125
|
+
const manager = await setupConnectionsConfigFile(context);
|
|
126
|
+
const currentConfig = await manager.getConfig();
|
|
127
|
+
const defaultValue = (connectionsMigrator.defaultValue as any)[key];
|
|
128
|
+
await manager.setConfig({
|
|
129
|
+
...(currentConfig ? (currentConfig as any) : {}),
|
|
130
|
+
[key]: defaultValue,
|
|
131
|
+
} as any);
|
|
132
|
+
send({
|
|
133
|
+
type: "end",
|
|
134
|
+
data: { type: "success", result: "ok" },
|
|
135
|
+
});
|
|
136
|
+
} catch (e) {
|
|
137
|
+
logger().error("connections:reset error:", e);
|
|
138
|
+
send({
|
|
139
|
+
type: "end",
|
|
140
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to reset connections" },
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
79
144
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
145
|
+
// Projects
|
|
146
|
+
handle("projects:load", async (_, { send }) => {
|
|
147
|
+
logger().info("projects:load");
|
|
148
|
+
try {
|
|
149
|
+
const manager = await setupProjectsConfigFile(context);
|
|
150
|
+
const json = await manager.getConfig();
|
|
151
|
+
send({
|
|
152
|
+
type: "end",
|
|
153
|
+
data: { type: "success", result: json },
|
|
154
|
+
});
|
|
155
|
+
} catch (e) {
|
|
156
|
+
logger().error("projects:load error:", e);
|
|
157
|
+
send({
|
|
158
|
+
type: "end",
|
|
159
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to load projects" },
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
83
163
|
|
|
84
|
-
|
|
164
|
+
handle("projects:save", async (_, { send, value }) => {
|
|
165
|
+
const { data } = value;
|
|
166
|
+
try {
|
|
167
|
+
const manager = await setupProjectsConfigFile(context);
|
|
168
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
169
|
+
await manager.setConfig(json);
|
|
170
|
+
send({
|
|
171
|
+
type: "end",
|
|
172
|
+
data: { type: "success", result: "ok" },
|
|
173
|
+
});
|
|
174
|
+
} catch (e) {
|
|
175
|
+
logger().error("projects:save error:", e);
|
|
176
|
+
send({
|
|
177
|
+
type: "end",
|
|
178
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to save projects" },
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
85
182
|
|
|
183
|
+
handle("projects:reset", async (_, { send, value }) => {
|
|
184
|
+
const { key } = value;
|
|
185
|
+
try {
|
|
186
|
+
const manager = await setupProjectsConfigFile(context);
|
|
187
|
+
const currentConfig = await manager.getConfig();
|
|
188
|
+
const defaultValue = (fileRepoMigrations.defaultValue as any)[key];
|
|
86
189
|
await manager.setConfig({
|
|
87
190
|
...(currentConfig ? (currentConfig as any) : {}),
|
|
88
191
|
[key]: defaultValue,
|
|
89
192
|
} as any);
|
|
193
|
+
send({
|
|
194
|
+
type: "end",
|
|
195
|
+
data: { type: "success", result: "ok" },
|
|
196
|
+
});
|
|
197
|
+
} catch (e) {
|
|
198
|
+
logger().error("projects:reset error:", e);
|
|
199
|
+
send({
|
|
200
|
+
type: "end",
|
|
201
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : "Unable to reset projects" },
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
90
205
|
|
|
206
|
+
// Pipeline (ByName)
|
|
207
|
+
handle("pipeline:load-by-name", async (_, { send, value }) => {
|
|
208
|
+
const { name } = value;
|
|
209
|
+
logger().info("pipeline:load-by-name", name);
|
|
210
|
+
try {
|
|
211
|
+
const manager = await setupPipelineConfigFileByName(name, context);
|
|
212
|
+
const json = await manager.getConfig();
|
|
91
213
|
send({
|
|
92
214
|
type: "end",
|
|
93
|
-
data: {
|
|
94
|
-
type: "success",
|
|
95
|
-
result: {
|
|
96
|
-
result: "ok",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
215
|
+
data: { type: "success", result: json },
|
|
99
216
|
});
|
|
100
217
|
} catch (e) {
|
|
101
|
-
logger().error(`
|
|
218
|
+
logger().error(`pipeline:load-by-name error for ${name}:`, e);
|
|
102
219
|
send({
|
|
103
220
|
type: "end",
|
|
104
|
-
data: {
|
|
105
|
-
type: "error",
|
|
106
|
-
ipcError: e instanceof Error ? e.message : `Unable to reset config ${name}`,
|
|
107
|
-
},
|
|
221
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : `Unable to load pipeline ${name}` },
|
|
108
222
|
});
|
|
109
223
|
}
|
|
110
224
|
});
|
|
111
225
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
226
|
+
// Pipeline (ByPath)
|
|
227
|
+
handle("pipeline:load-by-path", async (_, { send, value }) => {
|
|
228
|
+
const { path: absolutePath } = value;
|
|
229
|
+
logger().info("pipeline:load-by-path", absolutePath);
|
|
230
|
+
try {
|
|
231
|
+
const manager = await setupPipelineConfigFileByPath(absolutePath, context);
|
|
232
|
+
const json = await manager.getConfig();
|
|
233
|
+
send({
|
|
234
|
+
type: "end",
|
|
235
|
+
data: { type: "success", result: json },
|
|
236
|
+
});
|
|
237
|
+
} catch (e) {
|
|
238
|
+
logger().error(`pipeline:load-by-path error for ${absolutePath}:`, e);
|
|
239
|
+
send({
|
|
240
|
+
type: "end",
|
|
241
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : `Unable to load pipeline ${absolutePath}` },
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
});
|
|
115
245
|
|
|
246
|
+
handle("pipeline:save-by-name", async (_, { send, value }) => {
|
|
247
|
+
const { data, name } = value;
|
|
116
248
|
try {
|
|
117
|
-
await
|
|
249
|
+
const manager = await setupPipelineConfigFileByName(name, context);
|
|
250
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
251
|
+
await manager.setConfig(json);
|
|
252
|
+
send({
|
|
253
|
+
type: "end",
|
|
254
|
+
data: { type: "success", result: "ok" },
|
|
255
|
+
});
|
|
256
|
+
} catch (e) {
|
|
257
|
+
logger().error(`pipeline:save-by-name error for ${name}:`, e);
|
|
258
|
+
send({
|
|
259
|
+
type: "end",
|
|
260
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : `Unable to save pipeline ${name}` },
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
handle("pipeline:save-by-path", async (_, { send, value }) => {
|
|
266
|
+
const { data, path: absolutePath } = value;
|
|
267
|
+
try {
|
|
268
|
+
const manager = await setupPipelineConfigFileByPath(absolutePath, context);
|
|
269
|
+
const json = typeof data === "string" ? JSON.parse(data) : data;
|
|
270
|
+
await manager.setConfig(json);
|
|
271
|
+
send({
|
|
272
|
+
type: "end",
|
|
273
|
+
data: { type: "success", result: "ok" },
|
|
274
|
+
});
|
|
275
|
+
} catch (e) {
|
|
276
|
+
logger().error(`pipeline:save-by-path error for ${absolutePath}:`, e);
|
|
277
|
+
send({
|
|
278
|
+
type: "end",
|
|
279
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : `Unable to save pipeline ${absolutePath}` },
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
});
|
|
118
283
|
|
|
284
|
+
handle("pipeline:delete-by-name", async (_, { send, value }) => {
|
|
285
|
+
const { name } = value;
|
|
286
|
+
logger().info("pipeline:delete-by-name", name);
|
|
287
|
+
try {
|
|
288
|
+
await deletePipelineConfigFileByName(name, context);
|
|
289
|
+
send({
|
|
290
|
+
type: "end",
|
|
291
|
+
data: { type: "success", result: "ok" },
|
|
292
|
+
});
|
|
293
|
+
} catch (e) {
|
|
294
|
+
logger().error(`pipeline:delete-by-name error for ${name}:`, e);
|
|
295
|
+
send({
|
|
296
|
+
type: "end",
|
|
297
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : `Unable to delete pipeline ${name}` },
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
handle("pipeline:delete-by-path", async (_, { send, value }) => {
|
|
303
|
+
const { path: absolutePath } = value;
|
|
304
|
+
logger().info("pipeline:delete-by-path", absolutePath);
|
|
305
|
+
try {
|
|
306
|
+
await deletePipelineConfigFileByPath(absolutePath, context);
|
|
119
307
|
send({
|
|
120
308
|
type: "end",
|
|
121
|
-
data: {
|
|
122
|
-
type: "success",
|
|
123
|
-
result: {
|
|
124
|
-
result: "ok",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
309
|
+
data: { type: "success", result: "ok" },
|
|
127
310
|
});
|
|
128
311
|
} catch (e) {
|
|
129
|
-
logger().error(`
|
|
312
|
+
logger().error(`pipeline:delete-by-path error for ${absolutePath}:`, e);
|
|
130
313
|
send({
|
|
131
314
|
type: "end",
|
|
132
|
-
data: {
|
|
133
|
-
type: "error",
|
|
134
|
-
ipcError: e instanceof Error ? e.message : `Unable to delete config ${name}`,
|
|
135
|
-
},
|
|
315
|
+
data: { type: "error", ipcError: e instanceof Error ? e.message : `Unable to delete pipeline ${absolutePath}` },
|
|
136
316
|
});
|
|
137
317
|
}
|
|
138
318
|
});
|
package/src/handlers/engine.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { presets } from "../presets/list";
|
|
|
6
6
|
import { handleActionExecute } from "../handler-func";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { rm } from "node:fs/promises";
|
|
9
|
-
import {
|
|
9
|
+
import { setupSettingsConfigFile } from "../config";
|
|
10
10
|
import { AppConfig } from "@pipelab/shared";
|
|
11
11
|
|
|
12
12
|
export const registerEngineHandlers = (context: PipelabContext) => {
|
|
@@ -142,7 +142,7 @@ export const registerEngineHandlers = (context: PipelabContext) => {
|
|
|
142
142
|
|
|
143
143
|
handle("graph:execute", async (event, { send, value }) => {
|
|
144
144
|
const { graph, variables, projectName, projectPath, pipelineId } = value;
|
|
145
|
-
const settings = await
|
|
145
|
+
const settings = await setupSettingsConfigFile(context);
|
|
146
146
|
const config = await settings.getConfig();
|
|
147
147
|
|
|
148
148
|
const effectiveProjectName = projectName || "Unnamed Project";
|
package/src/handlers/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { registerAgentsHandlers } from "./agents";
|
|
|
7
7
|
import { registerAuthHandlers } from "./auth";
|
|
8
8
|
import { registerSystemHandlers } from "./system";
|
|
9
9
|
import { registerPluginsHandlers } from "./plugins";
|
|
10
|
+
import { registerMigrationHandlers } from "./migration";
|
|
10
11
|
import { builtInPlugins } from "../plugins-registry";
|
|
11
12
|
import { usePlugins } from "@pipelab/shared";
|
|
12
13
|
import { PipelabContext } from "../context";
|
|
@@ -26,6 +27,7 @@ export const registerAllHandlers = async (options: {
|
|
|
26
27
|
registerAuthHandlers(context);
|
|
27
28
|
registerSystemHandlers(options);
|
|
28
29
|
registerPluginsHandlers(context);
|
|
30
|
+
registerMigrationHandlers(context);
|
|
29
31
|
|
|
30
32
|
const { registerPlugins } = usePlugins();
|
|
31
33
|
// Execute in the background! The plugins will be dynamically registered and broadcasted to the UI.
|