@pipelab/shared 1.0.0-beta.3 → 1.0.0-beta.30
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/.oxfmtrc.json +1 -1
- package/CHANGELOG.md +234 -0
- package/dist/index.cjs +44534 -0
- package/dist/index.d.cts +4664 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1514 -499
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1098 -436
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -4
- package/src/apis.ts +126 -31
- package/src/build-history.ts +3 -23
- package/src/config/connections-definition.ts +3 -0
- package/src/config/migrators.ts +176 -25
- package/src/config/projects-definition.ts +8 -1
- package/src/config/projects-types.ts +1 -25
- package/src/config.schema.ts +29 -5
- package/src/evaluator.ts +0 -1
- package/src/graph.ts +2 -70
- package/src/i18n/de_DE.json +138 -51
- package/src/i18n/en_US.json +67 -52
- package/src/i18n/es_ES.json +139 -52
- package/src/i18n/fr_FR.json +128 -44
- package/src/i18n/pt_BR.json +136 -49
- package/src/i18n/zh_CN.json +142 -55
- package/src/index.ts +21 -1
- package/src/ipc.types.ts +2 -0
- package/src/model.test.ts +306 -1
- package/src/model.ts +54 -43
- package/src/plugins/definitions.ts +26 -55
- package/src/plugins-list.ts +17 -0
- package/src/plugins.ts +10 -1
- package/src/utils.ts +26 -0
- package/tsconfig.json +2 -4
- package/tsconfig.test.json +8 -0
- package/tsdown.config.ts +12 -0
package/src/model.test.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import { SavedFileV1, SavedFileV2, SavedFileV3, SavedFileV4, SavedFileV5 } from "./model";
|
|
3
|
+
import {
|
|
4
|
+
savedFileMigrator,
|
|
5
|
+
normalizePipelineConfig,
|
|
6
|
+
appSettingsMigrator,
|
|
7
|
+
fileRepoMigrations,
|
|
8
|
+
connectionsMigrator,
|
|
9
|
+
} from "./config/migrators";
|
|
10
|
+
import { AppConfigV6, AppConfigV7 } from "./config.schema";
|
|
3
11
|
|
|
4
12
|
describe("model", () => {
|
|
5
13
|
it("should migrate 1.0.0 to 2.0.0", async () => {
|
|
@@ -211,4 +219,301 @@ describe("model", () => {
|
|
|
211
219
|
version: "3.0.0",
|
|
212
220
|
} satisfies SavedFileV3);
|
|
213
221
|
});
|
|
222
|
+
|
|
223
|
+
it("should migrate 3.0.0 to 4.0.0", async () => {
|
|
224
|
+
const v3: SavedFileV3 = {
|
|
225
|
+
version: "3.0.0",
|
|
226
|
+
canvas: {
|
|
227
|
+
blocks: [],
|
|
228
|
+
triggers: [],
|
|
229
|
+
},
|
|
230
|
+
description: "desc",
|
|
231
|
+
name: "name",
|
|
232
|
+
variables: [],
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const v4 = await savedFileMigrator.migrate(v3, {
|
|
236
|
+
debug: true,
|
|
237
|
+
target: "4.0.0",
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
expect(v4).toStrictEqual({
|
|
241
|
+
version: "4.0.0",
|
|
242
|
+
type: "default",
|
|
243
|
+
canvas: {
|
|
244
|
+
blocks: [],
|
|
245
|
+
triggers: [],
|
|
246
|
+
},
|
|
247
|
+
description: "desc",
|
|
248
|
+
name: "name",
|
|
249
|
+
variables: [],
|
|
250
|
+
} satisfies SavedFileV4);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("should migrate 4.0.0 to 5.0.0", async () => {
|
|
254
|
+
const v4: SavedFileV4 = {
|
|
255
|
+
version: "4.0.0",
|
|
256
|
+
type: "default",
|
|
257
|
+
canvas: {
|
|
258
|
+
blocks: [
|
|
259
|
+
{
|
|
260
|
+
uid: "b1",
|
|
261
|
+
type: "action",
|
|
262
|
+
origin: {
|
|
263
|
+
pluginId: "electron",
|
|
264
|
+
nodeId: "open",
|
|
265
|
+
},
|
|
266
|
+
params: {},
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
uid: "b2",
|
|
270
|
+
type: "action",
|
|
271
|
+
origin: {
|
|
272
|
+
pluginId: "dicord",
|
|
273
|
+
nodeId: "send",
|
|
274
|
+
},
|
|
275
|
+
params: {},
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
triggers: [],
|
|
279
|
+
},
|
|
280
|
+
description: "desc",
|
|
281
|
+
name: "name",
|
|
282
|
+
variables: [],
|
|
283
|
+
plugins: {
|
|
284
|
+
discord: "1.0.0",
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const v5 = await savedFileMigrator.migrate(v4, {
|
|
289
|
+
debug: true,
|
|
290
|
+
target: "5.0.0",
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
expect(v5).toStrictEqual({
|
|
294
|
+
version: "5.0.0",
|
|
295
|
+
canvas: {
|
|
296
|
+
blocks: [
|
|
297
|
+
{
|
|
298
|
+
uid: "b1",
|
|
299
|
+
type: "action",
|
|
300
|
+
origin: {
|
|
301
|
+
pluginId: "@pipelab/plugin-electron",
|
|
302
|
+
nodeId: "open",
|
|
303
|
+
// "electron" wasn't in the old plugins map, so version falls back to "latest"
|
|
304
|
+
version: "latest",
|
|
305
|
+
},
|
|
306
|
+
params: {},
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
uid: "b2",
|
|
310
|
+
type: "action",
|
|
311
|
+
origin: {
|
|
312
|
+
pluginId: "@pipelab/plugin-discord",
|
|
313
|
+
nodeId: "send",
|
|
314
|
+
// "dicord" mapped to "@pipelab/plugin-discord" which had version "1.0.0" in the old map
|
|
315
|
+
version: "1.0.0",
|
|
316
|
+
},
|
|
317
|
+
params: {},
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
triggers: [],
|
|
321
|
+
},
|
|
322
|
+
description: "desc",
|
|
323
|
+
name: "name",
|
|
324
|
+
variables: [],
|
|
325
|
+
// plugins top-level map is dropped in V5 for default pipelines
|
|
326
|
+
} satisfies SavedFileV5);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("should migrate AppConfigV6 to AppConfigV7", async () => {
|
|
330
|
+
const v6: AppConfigV6 = {
|
|
331
|
+
version: "6.0.0",
|
|
332
|
+
theme: "dark",
|
|
333
|
+
cacheFolder: "/some/path",
|
|
334
|
+
clearTemporaryFoldersOnPipelineEnd: true,
|
|
335
|
+
locale: "fr-FR",
|
|
336
|
+
tours: {
|
|
337
|
+
dashboard: { step: 1, completed: true },
|
|
338
|
+
editor: { step: 2, completed: false },
|
|
339
|
+
},
|
|
340
|
+
autosave: false,
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const v7 = await appSettingsMigrator.migrate(v6, { target: "7.0.0" });
|
|
344
|
+
|
|
345
|
+
expect(v7).toStrictEqual({
|
|
346
|
+
version: "7.0.0",
|
|
347
|
+
theme: "dark",
|
|
348
|
+
locale: "fr-FR",
|
|
349
|
+
tours: {
|
|
350
|
+
dashboard: { step: 1, completed: true },
|
|
351
|
+
editor: { step: 2, completed: false },
|
|
352
|
+
},
|
|
353
|
+
autosave: false,
|
|
354
|
+
agents: [],
|
|
355
|
+
plugins: expect.any(Array),
|
|
356
|
+
cacheFolder: "/some/path",
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe("normalizePipelineConfig", () => {
|
|
361
|
+
it("should normalize typo and legacy plugin IDs in block origins", () => {
|
|
362
|
+
const config = {
|
|
363
|
+
version: "5.0.0",
|
|
364
|
+
type: "default",
|
|
365
|
+
canvas: {
|
|
366
|
+
blocks: [
|
|
367
|
+
{
|
|
368
|
+
uid: "b1",
|
|
369
|
+
type: "action",
|
|
370
|
+
origin: {
|
|
371
|
+
pluginId: "dicord",
|
|
372
|
+
nodeId: "send",
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const changed = normalizePipelineConfig(config);
|
|
380
|
+
expect(changed).toBe(true);
|
|
381
|
+
expect(config.canvas.blocks[0].origin.pluginId).toBe("@pipelab/plugin-discord");
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
describe("fileRepoMigrations", () => {
|
|
386
|
+
it("should migrate FileRepoV1 (data record) to FileRepoV3 (pipelines array)", async () => {
|
|
387
|
+
const v1 = {
|
|
388
|
+
version: "1.0.0" as const,
|
|
389
|
+
data: {
|
|
390
|
+
"pipeline-1": {
|
|
391
|
+
project: "main",
|
|
392
|
+
type: "internal" as const,
|
|
393
|
+
configName: "pipeline-1",
|
|
394
|
+
lastModified: "2026-06-04",
|
|
395
|
+
},
|
|
396
|
+
"pipeline-2": {
|
|
397
|
+
project: "main",
|
|
398
|
+
type: "external" as const,
|
|
399
|
+
path: "/path/to/pipeline-2.json",
|
|
400
|
+
lastModified: "2026-06-04",
|
|
401
|
+
summary: {
|
|
402
|
+
plugins: ["steam"],
|
|
403
|
+
name: "Test Pipeline 2",
|
|
404
|
+
description: "Legacy external pipeline",
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
const v3 = await fileRepoMigrations.migrate(v1, { target: "3.0.0" });
|
|
411
|
+
|
|
412
|
+
expect(v3).toStrictEqual({
|
|
413
|
+
version: "3.0.0",
|
|
414
|
+
data: v1.data,
|
|
415
|
+
projects: [
|
|
416
|
+
{
|
|
417
|
+
id: "main",
|
|
418
|
+
name: "Default project",
|
|
419
|
+
description: "The initial default project",
|
|
420
|
+
},
|
|
421
|
+
],
|
|
422
|
+
pipelines: [
|
|
423
|
+
{
|
|
424
|
+
id: "pipeline-1",
|
|
425
|
+
project: "main",
|
|
426
|
+
type: "internal",
|
|
427
|
+
configName: "pipeline-1",
|
|
428
|
+
lastModified: "2026-06-04",
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
id: "pipeline-2",
|
|
432
|
+
project: "main",
|
|
433
|
+
type: "external",
|
|
434
|
+
path: "/path/to/pipeline-2.json",
|
|
435
|
+
lastModified: "2026-06-04",
|
|
436
|
+
summary: {
|
|
437
|
+
plugins: ["steam"],
|
|
438
|
+
name: "Test Pipeline 2",
|
|
439
|
+
description: "Legacy external pipeline",
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
],
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
it("should fallback to default value for corrupted config", async () => {
|
|
447
|
+
const corrupted: any = {
|
|
448
|
+
version: "1.0.0",
|
|
449
|
+
data: null,
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const result = await fileRepoMigrations.migrate(corrupted, { target: "3.0.0" });
|
|
453
|
+
expect(result.version).toBe("3.0.0");
|
|
454
|
+
expect(result.projects).toHaveLength(1);
|
|
455
|
+
expect(result.pipelines).toEqual([]);
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
describe("connectionsMigrator", () => {
|
|
460
|
+
it("should initialize default connections", async () => {
|
|
461
|
+
const result = await connectionsMigrator.migrate(undefined, { target: "1.0.0" });
|
|
462
|
+
expect(result).toStrictEqual({
|
|
463
|
+
version: "1.0.0",
|
|
464
|
+
connections: [],
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
describe("savedFileMigrator - edge cases", () => {
|
|
470
|
+
it("should normalize unmapped legacy plugin names and typos during migration to 5.0.0", async () => {
|
|
471
|
+
const v4: SavedFileV4 = {
|
|
472
|
+
version: "4.0.0",
|
|
473
|
+
type: "default",
|
|
474
|
+
canvas: {
|
|
475
|
+
blocks: [
|
|
476
|
+
{
|
|
477
|
+
uid: "b1",
|
|
478
|
+
type: "action",
|
|
479
|
+
origin: {
|
|
480
|
+
pluginId: "filesystem",
|
|
481
|
+
nodeId: "copy",
|
|
482
|
+
},
|
|
483
|
+
params: {},
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
uid: "b2",
|
|
487
|
+
type: "action",
|
|
488
|
+
origin: {
|
|
489
|
+
pluginId: "dicord",
|
|
490
|
+
nodeId: "send",
|
|
491
|
+
},
|
|
492
|
+
params: {},
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
uid: "b3",
|
|
496
|
+
type: "action",
|
|
497
|
+
origin: {
|
|
498
|
+
pluginId: "custom-cool",
|
|
499
|
+
nodeId: "run",
|
|
500
|
+
},
|
|
501
|
+
params: {},
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
triggers: [],
|
|
505
|
+
},
|
|
506
|
+
description: "Edge case plugin names test",
|
|
507
|
+
name: "Edge Case",
|
|
508
|
+
variables: [],
|
|
509
|
+
plugins: {},
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
const v5 = await savedFileMigrator.migrate(v4, { target: "5.0.0" });
|
|
513
|
+
|
|
514
|
+
expect(v5.canvas.blocks[0].origin.pluginId).toBe("@pipelab/plugin-filesystem");
|
|
515
|
+
expect(v5.canvas.blocks[1].origin.pluginId).toBe("@pipelab/plugin-discord");
|
|
516
|
+
expect(v5.canvas.blocks[2].origin.pluginId).toBe("custom-cool");
|
|
517
|
+
});
|
|
518
|
+
});
|
|
214
519
|
});
|
package/src/model.ts
CHANGED
|
@@ -32,6 +32,14 @@ export type Position = {
|
|
|
32
32
|
export const OriginValidator = object({
|
|
33
33
|
pluginId: string(),
|
|
34
34
|
nodeId: string(),
|
|
35
|
+
version: optional(
|
|
36
|
+
pipe(
|
|
37
|
+
string(),
|
|
38
|
+
description(
|
|
39
|
+
'Pinned version of the plugin for this block. Falls back to "latest" when absent.',
|
|
40
|
+
),
|
|
41
|
+
),
|
|
42
|
+
),
|
|
35
43
|
});
|
|
36
44
|
|
|
37
45
|
export type Origin = InferOutput<typeof OriginValidator>;
|
|
@@ -49,7 +57,7 @@ export type EditorParam = InferOutput<typeof EditorParamValidatorV3>;
|
|
|
49
57
|
const BlockActionValidatorV3 = object({
|
|
50
58
|
type: literal("action"),
|
|
51
59
|
uid: string(),
|
|
52
|
-
name: pipe(
|
|
60
|
+
name: optional(pipe(string(), description("A custom name provided by the user"))),
|
|
53
61
|
disabled: optional(boolean()),
|
|
54
62
|
params: record(
|
|
55
63
|
string(),
|
|
@@ -61,39 +69,6 @@ const BlockActionValidatorV3 = object({
|
|
|
61
69
|
origin: OriginValidator,
|
|
62
70
|
});
|
|
63
71
|
|
|
64
|
-
export type BlockCondition = {
|
|
65
|
-
type: "condition";
|
|
66
|
-
uid: string;
|
|
67
|
-
origin: Origin;
|
|
68
|
-
params: Record<string, any>;
|
|
69
|
-
branchTrue: Array<Block>;
|
|
70
|
-
branchFalse: Array<Block>;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const BlockConditionValidator: GenericSchema<BlockCondition> = object({
|
|
74
|
-
type: literal("condition"),
|
|
75
|
-
uid: string(),
|
|
76
|
-
origin: OriginValidator,
|
|
77
|
-
params: record(string(), any()),
|
|
78
|
-
branchTrue: lazy(() => array(BlockValidator)),
|
|
79
|
-
branchFalse: lazy(() => array(BlockValidator)),
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export type BlockLoop = {
|
|
83
|
-
type: "loop";
|
|
84
|
-
uid: string;
|
|
85
|
-
origin: Origin;
|
|
86
|
-
params: Record<string, any>;
|
|
87
|
-
children: Array<Block>;
|
|
88
|
-
};
|
|
89
|
-
const BlockLoopValidator: GenericSchema<BlockLoop> = object({
|
|
90
|
-
type: literal("loop"),
|
|
91
|
-
uid: string(),
|
|
92
|
-
origin: OriginValidator,
|
|
93
|
-
params: record(string(), any()),
|
|
94
|
-
children: lazy(() => array(BlockValidator)),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
72
|
const BlockEventValidator = object({
|
|
98
73
|
type: literal("event"),
|
|
99
74
|
uid: string(),
|
|
@@ -180,20 +155,22 @@ export const SavedFileValidatorV3 = object({
|
|
|
180
155
|
variables: array(VariableValidatorV1),
|
|
181
156
|
});
|
|
182
157
|
|
|
183
|
-
export const
|
|
158
|
+
export const SavedFileDefaultValidatorV4 = object({
|
|
184
159
|
version: literal("4.0.0"),
|
|
185
160
|
type: literal("default"),
|
|
186
161
|
name: string(),
|
|
187
162
|
description: string(),
|
|
163
|
+
plugins: optional(record(string(), string())),
|
|
188
164
|
canvas: CanvasValidatorV3,
|
|
189
165
|
variables: array(VariableValidatorV1),
|
|
190
166
|
});
|
|
191
167
|
|
|
192
|
-
export const
|
|
168
|
+
export const SavedFileSimpleValidatorV4 = object({
|
|
193
169
|
version: literal("4.0.0"),
|
|
194
170
|
type: literal("simple"),
|
|
195
171
|
name: string(),
|
|
196
172
|
description: string(),
|
|
173
|
+
plugins: optional(record(string(), string())),
|
|
197
174
|
source: object({
|
|
198
175
|
type: union([literal("c3-html"), literal("c3-nwjs"), literal("godot"), literal("html")]),
|
|
199
176
|
path: string(),
|
|
@@ -208,19 +185,53 @@ export const SavedFileSimpleValidator = object({
|
|
|
208
185
|
}),
|
|
209
186
|
});
|
|
210
187
|
|
|
211
|
-
export
|
|
212
|
-
|
|
213
|
-
|
|
188
|
+
export const SavedFileDefaultValidatorV5 = object({
|
|
189
|
+
version: literal("5.0.0"),
|
|
190
|
+
name: string(),
|
|
191
|
+
description: string(),
|
|
192
|
+
canvas: CanvasValidatorV3,
|
|
193
|
+
variables: array(VariableValidatorV1),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export const SavedFileSimpleValidatorV5 = object({
|
|
197
|
+
version: literal("5.0.0"),
|
|
198
|
+
type: literal("simple"),
|
|
199
|
+
name: string(),
|
|
200
|
+
description: string(),
|
|
201
|
+
plugins: record(string(), string()),
|
|
202
|
+
source: object({
|
|
203
|
+
type: union([literal("c3-html"), literal("c3-nwjs"), literal("godot"), literal("html")]),
|
|
204
|
+
path: string(),
|
|
205
|
+
}),
|
|
206
|
+
packaging: object({
|
|
207
|
+
enabled: boolean(),
|
|
208
|
+
}),
|
|
209
|
+
publishing: object({
|
|
210
|
+
steam: object({ enabled: boolean(), appId: optional(string()) }),
|
|
211
|
+
itch: object({ enabled: boolean(), project: optional(string()) }),
|
|
212
|
+
poki: object({ enabled: boolean(), gameId: optional(string()) }),
|
|
213
|
+
}),
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export type SavedFileDefault = InferOutput<typeof SavedFileDefaultValidatorV5>;
|
|
217
|
+
export type SavedFileSimple = InferOutput<typeof SavedFileSimpleValidatorV5>;
|
|
218
|
+
|
|
219
|
+
export const SavedFileValidatorV4 = union([
|
|
220
|
+
SavedFileDefaultValidatorV4,
|
|
221
|
+
SavedFileSimpleValidatorV4,
|
|
222
|
+
]);
|
|
223
|
+
export const SavedFileValidatorV5 = SavedFileDefaultValidatorV5;
|
|
214
224
|
|
|
215
225
|
export type SavedFileV1 = InferOutput<typeof SavedFileValidatorV1>;
|
|
216
226
|
export type SavedFileV2 = InferOutput<typeof SavedFileValidatorV2>;
|
|
217
227
|
export type SavedFileV3 = InferOutput<typeof SavedFileValidatorV3>;
|
|
218
228
|
export type SavedFileV4 = InferOutput<typeof SavedFileValidatorV4>;
|
|
219
|
-
export type
|
|
220
|
-
export
|
|
229
|
+
export type SavedFileV5 = InferOutput<typeof SavedFileValidatorV5>;
|
|
230
|
+
export type SavedFile = SavedFileV5;
|
|
231
|
+
export const SavedFileValidator = SavedFileValidatorV5;
|
|
221
232
|
|
|
222
233
|
export type Preset = SavedFile;
|
|
223
|
-
export type PresetResult = { data:
|
|
234
|
+
export type PresetResult = { data: Preset; hightlight?: boolean; disabled?: boolean };
|
|
224
235
|
export type PresetFn = () => Promise<PresetResult>;
|
|
225
236
|
|
|
226
237
|
export type Steps = Record<
|
|
@@ -230,4 +241,4 @@ export type Steps = Record<
|
|
|
230
241
|
}
|
|
231
242
|
>;
|
|
232
243
|
|
|
233
|
-
export type EnhancedFile<T
|
|
244
|
+
export type EnhancedFile<T = SavedFile> = WithId<SaveLocation> & { content: T };
|
|
@@ -79,6 +79,7 @@ export interface ControlTypePath extends ControlTypeBase {
|
|
|
79
79
|
type: "path";
|
|
80
80
|
options: OpenDialogOptions;
|
|
81
81
|
label?: string;
|
|
82
|
+
warnIfBlacklisted?: boolean;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
export interface ControlTypeJSON extends ControlTypeBase {
|
|
@@ -154,18 +155,36 @@ export type IconType =
|
|
|
154
155
|
icon: string;
|
|
155
156
|
};
|
|
156
157
|
export interface PluginDefinition {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
icon: IconType;
|
|
160
|
-
description: string;
|
|
158
|
+
packageName?: string;
|
|
159
|
+
version?: string;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
162
|
export type RendererNodeDefinition = {
|
|
164
163
|
node: PipelabNode;
|
|
165
164
|
};
|
|
166
165
|
|
|
166
|
+
export interface IntegrationField {
|
|
167
|
+
key: string;
|
|
168
|
+
label: string;
|
|
169
|
+
type: "text" | "password" | "file" | "directory";
|
|
170
|
+
placeholder?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface IntegrationDefinition {
|
|
174
|
+
name: string;
|
|
175
|
+
fields: IntegrationField[];
|
|
176
|
+
}
|
|
177
|
+
|
|
167
178
|
export interface RendererPluginDefinition extends PluginDefinition {
|
|
179
|
+
id: string;
|
|
180
|
+
name: string;
|
|
181
|
+
icon: IconType;
|
|
182
|
+
description: string;
|
|
183
|
+
isOfficial: boolean;
|
|
184
|
+
packageName: string;
|
|
185
|
+
version: string;
|
|
168
186
|
nodes: Array<RendererNodeDefinition>;
|
|
187
|
+
integrations?: Array<IntegrationDefinition>;
|
|
169
188
|
}
|
|
170
189
|
|
|
171
190
|
export interface MainPluginDefinition extends PluginDefinition {
|
|
@@ -177,6 +196,7 @@ export interface MainPluginDefinition extends PluginDefinition {
|
|
|
177
196
|
description: string;
|
|
178
197
|
validator: (options: any) => any;
|
|
179
198
|
}>;
|
|
199
|
+
integrations?: Array<IntegrationDefinition>;
|
|
180
200
|
}
|
|
181
201
|
|
|
182
202
|
export const createNodeDefinition = (def: MainPluginDefinition) => {
|
|
@@ -203,10 +223,7 @@ export type SetOutputActionFn<T extends Action> = (
|
|
|
203
223
|
key: keyof T["outputs"],
|
|
204
224
|
value: T["outputs"][typeof key]["value"],
|
|
205
225
|
) => void;
|
|
206
|
-
|
|
207
|
-
key: keyof T["outputs"],
|
|
208
|
-
value: T["outputs"][typeof key]["value"],
|
|
209
|
-
) => void;
|
|
226
|
+
|
|
210
227
|
export type SetOutputExpressionFn<T extends Expression> = (
|
|
211
228
|
key: keyof T["outputs"],
|
|
212
229
|
value: T["outputs"][typeof key]["value"],
|
|
@@ -244,12 +261,6 @@ export type ExtractInputsFromAction<ACTION extends Action> = {
|
|
|
244
261
|
[index in keyof ACTION["params"]]: ACTION["params"][index]["value"];
|
|
245
262
|
};
|
|
246
263
|
|
|
247
|
-
export type ExtractInputsFromCondition<CONDITION extends Condition> = {
|
|
248
|
-
[index in keyof CONDITION["params"]]: CONDITION["params"][index]["value"];
|
|
249
|
-
};
|
|
250
|
-
export type ExtractInputsFromLoop<LOOP extends Loop> = {
|
|
251
|
-
[index in keyof LOOP["params"]]: LOOP["params"][index]["value"];
|
|
252
|
-
};
|
|
253
264
|
export type ExtractInputsFromEvent<EVENT extends Event> = {
|
|
254
265
|
[index in keyof EVENT["params"]]: EVENT["params"][index]["value"];
|
|
255
266
|
};
|
|
@@ -257,32 +268,6 @@ export type ExtractInputsFromExpression<EXPRESSION extends Expression> = {
|
|
|
257
268
|
[index in keyof EXPRESSION["params"]]: EXPRESSION["params"][index]["value"];
|
|
258
269
|
};
|
|
259
270
|
|
|
260
|
-
export interface Condition extends BaseNode {
|
|
261
|
-
id: string;
|
|
262
|
-
type: "condition";
|
|
263
|
-
version?: number;
|
|
264
|
-
displayString: string;
|
|
265
|
-
icon: string;
|
|
266
|
-
name: string;
|
|
267
|
-
description: string;
|
|
268
|
-
params: InputsDefinition;
|
|
269
|
-
meta?: Meta;
|
|
270
|
-
platforms?: NodeJS.Platform[];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export interface Loop extends BaseNode {
|
|
274
|
-
id: string;
|
|
275
|
-
type: "loop";
|
|
276
|
-
version?: number;
|
|
277
|
-
displayString: string;
|
|
278
|
-
icon: string;
|
|
279
|
-
name: string;
|
|
280
|
-
description: string;
|
|
281
|
-
params: InputsDefinition;
|
|
282
|
-
meta?: Meta;
|
|
283
|
-
outputs: OutputsDefinition;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
271
|
export interface Expression extends BaseNode {
|
|
287
272
|
id: string;
|
|
288
273
|
type: "expression";
|
|
@@ -309,7 +294,7 @@ export interface Event extends BaseNode {
|
|
|
309
294
|
platforms?: NodeJS.Platform[];
|
|
310
295
|
}
|
|
311
296
|
|
|
312
|
-
export type PipelabNode = Event |
|
|
297
|
+
export type PipelabNode = Event | Expression | Action;
|
|
313
298
|
|
|
314
299
|
export const createDefinition = <T extends MainPluginDefinition>(definition: T) => {
|
|
315
300
|
return definition satisfies T;
|
|
@@ -450,20 +435,6 @@ export const createExpression = <T extends Omit<Expression, "type">>(expression:
|
|
|
450
435
|
} satisfies Expression;
|
|
451
436
|
};
|
|
452
437
|
|
|
453
|
-
export const createCondition = <T extends Omit<Condition, "type">>(condition: T) => {
|
|
454
|
-
return {
|
|
455
|
-
...condition,
|
|
456
|
-
type: "condition",
|
|
457
|
-
} satisfies Condition;
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
export const createLoop = <T extends Omit<Loop, "type">>(loop: T) => {
|
|
461
|
-
return {
|
|
462
|
-
...loop,
|
|
463
|
-
type: "loop",
|
|
464
|
-
} satisfies Loop;
|
|
465
|
-
};
|
|
466
|
-
|
|
467
438
|
export const createEvent = <T extends Omit<Event, "type">>(event: T) => {
|
|
468
439
|
return {
|
|
469
440
|
...event,
|
package/src/plugins.ts
CHANGED
|
@@ -9,7 +9,16 @@ export const usePlugins = () => {
|
|
|
9
9
|
const load = () => {};
|
|
10
10
|
|
|
11
11
|
const registerPlugins = (newPlugins: Plugin[]) => {
|
|
12
|
-
plugins.value
|
|
12
|
+
const current = [...plugins.value];
|
|
13
|
+
for (const np of newPlugins) {
|
|
14
|
+
const idx = current.findIndex((p) => p.id === np.id);
|
|
15
|
+
if (idx !== -1) {
|
|
16
|
+
current[idx] = np;
|
|
17
|
+
} else {
|
|
18
|
+
current.push(np);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
plugins.value = current;
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
return {
|
package/src/utils.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
export const foo = "bar";
|
|
2
2
|
|
|
3
3
|
export type WithId<T> = T extends string | number ? never : T & { id: string };
|
|
4
|
+
|
|
5
|
+
export const transformUrl = (url: string | undefined | null): string => {
|
|
6
|
+
if (url && typeof url === "string") {
|
|
7
|
+
const getHost = (): string => {
|
|
8
|
+
if (typeof window !== "undefined") {
|
|
9
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
10
|
+
if (isDev) {
|
|
11
|
+
return `http://${window.location.hostname}:33753`;
|
|
12
|
+
} else {
|
|
13
|
+
return `${window.location.protocol}//${window.location.host}`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return "http://localhost:33753";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (url.startsWith("file://")) {
|
|
20
|
+
const filePath = decodeURIComponent(url.substring("file://".length));
|
|
21
|
+
return `${getHost()}/media-file/${encodeURIComponent(filePath)}`;
|
|
22
|
+
}
|
|
23
|
+
if (url.startsWith("media://")) {
|
|
24
|
+
const filePath = decodeURIComponent(url.replace(/^media:\/\/+/, "/"));
|
|
25
|
+
return `${getHost()}/media-file/${encodeURIComponent(filePath)}`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return url || "";
|
|
29
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"emitDeclarationOnly": true,
|
|
5
5
|
"outDir": "dist",
|
|
6
|
-
"baseUrl": "."
|
|
7
|
-
"typeRoots": ["./src"],
|
|
8
|
-
"types": ["global.d.ts", "wasm.d.ts"]
|
|
6
|
+
"baseUrl": "."
|
|
9
7
|
},
|
|
10
|
-
"include": ["src/**/*", "
|
|
8
|
+
"include": ["src/**/*", "src/**/*.json"],
|
|
11
9
|
"exclude": ["node_modules", "dist"],
|
|
12
10
|
"references": [{ "path": "../migration" }]
|
|
13
11
|
}
|