@kestra-io/ui-libs 0.0.198 → 0.0.200
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/{FlowYamlUtils-BCoMPOUZ.cjs → FlowYamlUtils-DE2Q92JR.cjs} +2 -2
- package/dist/FlowYamlUtils-DE2Q92JR.cjs.map +1 -0
- package/dist/{FlowYamlUtils-BHh3dCqD.js → FlowYamlUtils-XiHwEJpD.js} +215 -206
- package/dist/FlowYamlUtils-XiHwEJpD.js.map +1 -0
- package/dist/kestra-flowyamlutils.cjs.js +1 -1
- package/dist/kestra-flowyamlutils.es.js +1 -1
- package/dist/kestra-index.cjs.js +1 -1
- package/dist/kestra-index.es.js +1 -1
- package/dist/utils/FlowYamlUtils.d.ts +1 -1
- package/dist/utils/FlowYamlUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/utils/FlowYamlUtils.test.ts +127 -1
- package/src/utils/FlowYamlUtils.ts +26 -8
- package/dist/FlowYamlUtils-BCoMPOUZ.cjs.map +0 -1
- package/dist/FlowYamlUtils-BHh3dCqD.js.map +0 -1
package/dist/kestra-index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import js, { Document as zs, YAMLMap as hr } from "yaml";
|
|
2
|
-
import { g as Vp, e as Up, d as Hp, r as Gp, a as Bp, f as pf, b as Wp, c as jp, h as zp, u as Kp, i as Yp, j as Xp, k as Zp, l as Jp, m as Qp, n as em, s as tm, p as nm, o as rm, q as im, t as mf, v as am, w as om, x as Ks, y as Ys, z as sm, A as lm, B as vn, C as gf, D as ls, E as um, F as Bn, G as cm, H as us, I as cs, J as He, K as Wn, L as jn, M as _n, N as Vt, O as ds, P as zn, Q as fs, R as dm, S as vf, T as hs, U as fm, V as Ut, W as _f, X as hm, Y as yf, Z as pm, _ as mm, $ as Ef, a0 as ps, a1 as gm, a2 as vm, a3 as _m, a4 as Kn, a5 as ym, a6 as Em, a7 as bm, a8 as Cm, a9 as wm, aa as Sm, ab as bf, ac as km, ad as Lm, ae as Tm } from "./FlowYamlUtils-
|
|
2
|
+
import { g as Vp, e as Up, d as Hp, r as Gp, a as Bp, f as pf, b as Wp, c as jp, h as zp, u as Kp, i as Yp, j as Xp, k as Zp, l as Jp, m as Qp, n as em, s as tm, p as nm, o as rm, q as im, t as mf, v as am, w as om, x as Ks, y as Ys, z as sm, A as lm, B as vn, C as gf, D as ls, E as um, F as Bn, G as cm, H as us, I as cs, J as He, K as Wn, L as jn, M as _n, N as Vt, O as ds, P as zn, Q as fs, R as dm, S as vf, T as hs, U as fm, V as Ut, W as _f, X as hm, Y as yf, Z as pm, _ as mm, $ as Ef, a0 as ps, a1 as gm, a2 as vm, a3 as _m, a4 as Kn, a5 as ym, a6 as Em, a7 as bm, a8 as Cm, a9 as wm, aa as Sm, ab as bf, ac as km, ad as Lm, ae as Tm } from "./FlowYamlUtils-XiHwEJpD.js";
|
|
3
3
|
import { createElementBlock as k, openBlock as E, mergeProps as ie, createElementVNode as O, createCommentVNode as M, toDisplayString as z, getCurrentInstance as tn, inject as Om, ref as _e, shallowRef as In, computed as pe, watch as ct, onMounted as Yn, onUnmounted as Cf, defineComponent as Re, h as nn, createVNode as K, Text as dn, Fragment as Me, nextTick as ms, onBeforeUnmount as wf, renderSlot as ye, createTextVNode as Et, normalizeClass as he, createBlock as ue, withCtx as te, normalizeStyle as fn, unref as W, toRef as Xs, resolveComponent as An, effectScope as Nm, reactive as Sf, resolveDynamicComponent as Ht, renderList as _t, createSlots as kf, normalizeProps as Im, guardReactiveProps as Am, withModifiers as Lf, withAsyncContext as Zs, toRaw as Rm, defineAsyncComponent as Dm, Comment as Pm, Suspense as Mm } from "vue";
|
|
4
4
|
import $m from "humanize-duration";
|
|
5
5
|
import cn from "moment";
|
|
@@ -89,7 +89,7 @@ export declare function getLastBlock({ source, section, parentKey, keyName, subB
|
|
|
89
89
|
export declare function updateMetadata(source: string, metadata: Record<string, any>): string;
|
|
90
90
|
export declare const FLOW_SECTION_KEYS: readonly ["tasks", "triggers", "errors", "finally", "afterExecution", "pluginDefaults"];
|
|
91
91
|
export type FlowSectionKeys = typeof FLOW_SECTION_KEYS[number];
|
|
92
|
-
export declare const ORDERED_FLOW_ROOT_KEYS: readonly ["id", "namespace", "description", "retry", "labels", "inputs", "variables", "tasks", "triggers", "errors", "finally", "afterExecution", "pluginDefaults", "taskDefaults", "concurrency", "sla", "outputs", "disabled"];
|
|
92
|
+
export declare const ORDERED_FLOW_ROOT_KEYS: readonly ["id", "type", "namespace", "description", "retry", "labels", "inputs", "variables", "tasks", "triggers", "errors", "finally", "afterExecution", "pluginDefaults", "taskDefaults", "concurrency", "sla", "outputs", "disabled"];
|
|
93
93
|
export type FlowRootKeys = typeof ORDERED_FLOW_ROOT_KEYS[number];
|
|
94
94
|
export declare function cleanMetadata(source: string): string;
|
|
95
95
|
export declare function getMetadata(source: string): Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowYamlUtils.d.ts","sourceRoot":"","sources":["../../src/utils/FlowYamlUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,OAAO,EAWP,KAAK,EACR,MAAM,MAAM,CAAC;AAGd,wBAAgB,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,YAAY,UAAO,GAAG,CAAC,GAAG,SAAS,CAShF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,UAWlC;AAiBD,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAU9C;AAED,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,6BAUvC;AAwFD,wBAAgB,uBAAuB,CAAC,EACpC,MAAM,EACN,OAAO,EACP,EAAE,GACL,EAAE;IACC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAA;CACb,GAAG,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|
|
|
1273
1273
|
});
|
|
1274
1274
|
expect(result).toBe("triggers[0].conditions[1]");
|
|
1275
1275
|
})
|
|
1276
|
-
|
|
1277
1276
|
})
|
|
1277
|
+
|
|
1278
|
+
describe("replaceIdAndNamespace", () => {
|
|
1279
|
+
test("replaces id and namespace in yaml", () => {
|
|
1280
|
+
const yaml = `
|
|
1281
|
+
id: old-id
|
|
1282
|
+
namespace: old.namespace
|
|
1283
|
+
tasks:
|
|
1284
|
+
- id: task1
|
|
1285
|
+
`;
|
|
1286
|
+
const result = YamlUtils.replaceIdAndNamespace(yaml, "new-id", "new.namespace");
|
|
1287
|
+
expect(result).toContain("id: new-id");
|
|
1288
|
+
expect(result).toContain("namespace: new.namespace");
|
|
1289
|
+
});
|
|
1290
|
+
|
|
1291
|
+
test("handles quoted values", () => {
|
|
1292
|
+
const yaml = `
|
|
1293
|
+
id: "old-id"
|
|
1294
|
+
namespace: 'old.namespace'
|
|
1295
|
+
`;
|
|
1296
|
+
const result = YamlUtils.replaceIdAndNamespace(yaml, "new-id", "new.namespace");
|
|
1297
|
+
expect(result).toContain("id: \"new-id\"");
|
|
1298
|
+
expect(result).toContain("namespace: 'new.namespace'");
|
|
1299
|
+
});
|
|
1300
|
+
|
|
1301
|
+
test("handles yaml with only tasks and sets it on top", () => {
|
|
1302
|
+
const yaml = `
|
|
1303
|
+
tasks:
|
|
1304
|
+
- id: t1
|
|
1305
|
+
type: plugin1
|
|
1306
|
+
`;
|
|
1307
|
+
const result = YamlUtils.replaceIdAndNamespace(yaml, "new-id", "new.namespace");
|
|
1308
|
+
const lines = result.split("\n").map((l: string) => l.trim()).filter(Boolean);
|
|
1309
|
+
expect(result).toContain("id: new-id");
|
|
1310
|
+
expect(lines[0]).toBe("id: new-id");
|
|
1311
|
+
expect(result).toContain("namespace: new.namespace");
|
|
1312
|
+
});
|
|
1313
|
+
|
|
1314
|
+
test("handles empty yaml", () => {
|
|
1315
|
+
const yaml = `
|
|
1316
|
+
|
|
1317
|
+
`;
|
|
1318
|
+
const result = YamlUtils.replaceIdAndNamespace(yaml, "new-id", "new.namespace");
|
|
1319
|
+
expect(result).toContain("id: new-id");
|
|
1320
|
+
expect(result).toContain("namespace: new.namespace");
|
|
1321
|
+
});
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
describe("getMetadata", () => {
|
|
1325
|
+
test("returns all metadata except tasks, triggers, and errors", () => {
|
|
1326
|
+
const yaml = `
|
|
1327
|
+
id: test
|
|
1328
|
+
namespace: test.ns
|
|
1329
|
+
description: Test flow
|
|
1330
|
+
|
|
1331
|
+
tasks:
|
|
1332
|
+
- id: task1
|
|
1333
|
+
triggers:
|
|
1334
|
+
- id: trigger1
|
|
1335
|
+
errors:
|
|
1336
|
+
- id: error1
|
|
1337
|
+
finally:
|
|
1338
|
+
- id: finally1
|
|
1339
|
+
`;
|
|
1340
|
+
const metadata = YamlUtils.getMetadata(yaml);
|
|
1341
|
+
expect(metadata).toEqual({
|
|
1342
|
+
id: "test",
|
|
1343
|
+
namespace: "test.ns",
|
|
1344
|
+
description: "Test flow"
|
|
1345
|
+
});
|
|
1346
|
+
});
|
|
1347
|
+
|
|
1348
|
+
test("handles complex metadata values", () => {
|
|
1349
|
+
const yaml = `
|
|
1350
|
+
id: test
|
|
1351
|
+
labels:
|
|
1352
|
+
env: prod
|
|
1353
|
+
team: dev
|
|
1354
|
+
variables:
|
|
1355
|
+
var1: value1
|
|
1356
|
+
`;
|
|
1357
|
+
const metadata = YamlUtils.getMetadata(yaml);
|
|
1358
|
+
expect(metadata).toEqual({
|
|
1359
|
+
id: "test",
|
|
1360
|
+
labels: {
|
|
1361
|
+
env: "prod",
|
|
1362
|
+
team: "dev"
|
|
1363
|
+
},
|
|
1364
|
+
variables: {
|
|
1365
|
+
var1: "value1"
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
});
|
|
1369
|
+
|
|
1370
|
+
test("does not fail on empty yaml", () => {
|
|
1371
|
+
const yaml = "";
|
|
1372
|
+
const metadata = YamlUtils.getMetadata(yaml);
|
|
1373
|
+
expect(metadata).toEqual({});
|
|
1374
|
+
})
|
|
1375
|
+
});
|
|
1376
|
+
|
|
1377
|
+
describe("cleanMetadata", () => {
|
|
1378
|
+
test("removes empty sections", () => {
|
|
1379
|
+
const yaml = `
|
|
1380
|
+
id: test
|
|
1381
|
+
tasks: []
|
|
1382
|
+
triggers: []
|
|
1383
|
+
errors: []
|
|
1384
|
+
`;
|
|
1385
|
+
const result = YamlUtils.cleanMetadata(yaml);
|
|
1386
|
+
expect(result).toBe("id: test\n");
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
test("maintains correct order of sections", () => {
|
|
1390
|
+
const yaml = `
|
|
1391
|
+
tasks:
|
|
1392
|
+
- id: task1
|
|
1393
|
+
namespace: test
|
|
1394
|
+
id: test
|
|
1395
|
+
triggers:
|
|
1396
|
+
- id: trigger1
|
|
1397
|
+
`;
|
|
1398
|
+
const result = YamlUtils.cleanMetadata(yaml);
|
|
1399
|
+
const lines = result.split("\n").map((l: string) => l.trim()).filter(Boolean);
|
|
1400
|
+
expect(lines[0]).toBe("id: test");
|
|
1401
|
+
expect(lines[1]).toBe("namespace: test");
|
|
1402
|
+
});
|
|
1403
|
+
});
|
|
@@ -109,7 +109,7 @@ function getSectionNodeAndDocumentFromSource({source, section}: {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
function parseDocumentTyped(source: string) {
|
|
112
|
-
return parseDocument(source) as Document<YAMLMap<
|
|
112
|
+
return parseDocument(source) as Document<YAMLMap<Scalar<string>, Node>>;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function getSectionFromDocument({yamlDoc, section}:
|
|
@@ -677,9 +677,24 @@ export function isParentChildrenRelation({source, sections, key1, key2, keyName}
|
|
|
677
677
|
}
|
|
678
678
|
|
|
679
679
|
export function replaceIdAndNamespace(source: string, id: string, namespace: string) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
680
|
+
const yamlDoc = parseDocumentTyped(source);
|
|
681
|
+
yamlDoc.contents = yamlDoc.contents || new YAMLMap();
|
|
682
|
+
|
|
683
|
+
const existingNamespace = yamlDoc.getIn(["namespace"], true) as Scalar | undefined;
|
|
684
|
+
if(existingNamespace){
|
|
685
|
+
existingNamespace.value = namespace;
|
|
686
|
+
}else{
|
|
687
|
+
yamlDoc.contents.items.unshift(new Pair(new Scalar("namespace"), new Scalar(namespace)));
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const existingId = yamlDoc.getIn(["id"], true) as Scalar | undefined;
|
|
691
|
+
if(existingId){
|
|
692
|
+
existingId.value = id;
|
|
693
|
+
}else{
|
|
694
|
+
yamlDoc.contents.items.unshift(new Pair(new Scalar("id"), new Scalar(id)));
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
return yamlDoc.toString(TOSTRING_OPTIONS);
|
|
683
698
|
}
|
|
684
699
|
|
|
685
700
|
export function checkBlockAlreadyExists({source, section, newContent, keyName}:
|
|
@@ -779,6 +794,7 @@ export type FlowSectionKeys = typeof FLOW_SECTION_KEYS[number];
|
|
|
779
794
|
|
|
780
795
|
export const ORDERED_FLOW_ROOT_KEYS = [
|
|
781
796
|
"id",
|
|
797
|
+
"type",
|
|
782
798
|
"namespace",
|
|
783
799
|
"description",
|
|
784
800
|
"retry",
|
|
@@ -803,14 +819,14 @@ function isItemTruthy(item: Node) {
|
|
|
803
819
|
}
|
|
804
820
|
}
|
|
805
821
|
|
|
806
|
-
function cleanMetadataDocument(yamlDoc: Document<YAMLMap<
|
|
822
|
+
function cleanMetadataDocument(yamlDoc: Document<YAMLMap<Scalar<string>, Node | YAMLSeq>>) {
|
|
807
823
|
if (!yamlDoc?.contents?.items) {
|
|
808
824
|
return yamlDoc;
|
|
809
825
|
}
|
|
810
|
-
const updatedItems = [];
|
|
826
|
+
const updatedItems: Pair<Scalar<string>, Node>[] = [];
|
|
811
827
|
for (const prop of ORDERED_FLOW_ROOT_KEYS) {
|
|
812
828
|
const item = yamlDoc.contents?.items.find(
|
|
813
|
-
(e: any) => e.key.value === prop
|
|
829
|
+
(e: any) => (e.key.value ?? e.key) === prop
|
|
814
830
|
);
|
|
815
831
|
if (item?.value && isItemTruthy(item.value)) {
|
|
816
832
|
updatedItems.push(item);
|
|
@@ -826,9 +842,11 @@ export function cleanMetadata(source: string) {
|
|
|
826
842
|
return cleanedYamlDoc.toString(TOSTRING_OPTIONS);
|
|
827
843
|
}
|
|
828
844
|
|
|
829
|
-
export function getMetadata(source: string) {
|
|
845
|
+
export function getMetadata(source: string): Record<string, any> {
|
|
830
846
|
const yamlDoc = parseDocument(source) as any;
|
|
847
|
+
if(!yamlDoc.contents?.items) return {};
|
|
831
848
|
const metadata: Record<string, any> = {};
|
|
849
|
+
|
|
832
850
|
for (const item of yamlDoc.contents.items) {
|
|
833
851
|
if (!FLOW_SECTION_KEYS.includes(item.key.value)) {
|
|
834
852
|
metadata[item.key.value] =
|