@blueking/bkflow-canvas-editor 1.1.0-beta.0 → 1.1.0-beta.10

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.
@@ -0,0 +1,504 @@
1
+ import { defineComponent as G, ref as S, computed as p, watch as U, nextTick as Y, resolveComponent as $, openBlock as c, createElementBlock as v, createVNode as m, Fragment as K, renderList as q, withKeys as J, withModifiers as W, normalizeClass as M, createElementVNode as a, createCommentVNode as T, toDisplayString as R, withCtx as k, createTextVNode as L, createBlock as F, onBeforeUnmount as Q, resolveDirective as X, normalizeStyle as Z, withDirectives as ee } from "vue";
2
+ import { L as te, S as se, E as oe, _ as z, n as ne, D, C as ae, b as le } from "./index-C16qU3Yx.js";
3
+ import { a as P } from "./composable-Cf47ka9M.js";
4
+ const ie = { class: "debug-result-node-list" }, ue = ["data-node-id", "aria-selected", "onClick", "onKeydown"], re = ["title"], de = {
5
+ key: 0,
6
+ class: "debug-result-node-list__mock",
7
+ "data-test": "node-mock-flag"
8
+ }, ce = {
9
+ key: 1,
10
+ class: "debug-result-node-list__empty"
11
+ }, me = /* @__PURE__ */ G({
12
+ __name: "node-list",
13
+ props: {
14
+ nodes: {},
15
+ modelValue: { default: "" }
16
+ },
17
+ emits: ["update:modelValue"],
18
+ setup(n, { emit: r }) {
19
+ const e = n, l = r, u = S(""), o = S("all"), b = S(null), g = [
20
+ { value: "all", label: "全部" },
21
+ { value: "finished", icon: "bkflow-canvas-dark-circle-checkbox", iconColor: "#5fb8ac" },
22
+ { value: "failed", icon: "bkflow-canvas-dark-circle-close", iconColor: "#fa4e41" },
23
+ { value: "running", iconComponent: te, iconColor: "#3a84ff" },
24
+ { value: "not_run", icon: "bkflow-canvas-weizhixing2", iconColor: "#b8bbc4" },
25
+ { value: "suspended", icon: "bkflow-canvas-zanting", iconColor: "#f59500" },
26
+ { value: "skipped", icon: "bkflow-canvas-tiaoguo2", iconColor: "#6e89af" }
27
+ ], y = p(
28
+ () => g.map((i) => ({
29
+ ...i,
30
+ count: i.value === "all" ? e.nodes.length : e.nodes.filter((t) => t.status === i.value).length
31
+ }))
32
+ ), w = p(() => {
33
+ const i = u.value.trim().toLowerCase();
34
+ return e.nodes.filter((t) => o.value !== "all" && t.status !== o.value ? !1 : i ? t.name.toLowerCase().includes(i) || t.type.toLowerCase().includes(i) || (t.typeName ?? "").toLowerCase().includes(i) : !0);
35
+ }), E = {
36
+ not_run: "未执行",
37
+ finished: "成功",
38
+ failed: "失败",
39
+ running: "正在调试",
40
+ suspended: "挂起",
41
+ skipped: "跳过"
42
+ }, N = p(() => u.value.trim() ? "搜索结果为空" : o.value !== "all" ? `暂无${E[o.value]}状态节点` : "暂无节点"), h = () => {
43
+ u.value = "", o.value = "all";
44
+ }, x = (i) => {
45
+ const t = b.value, d = t?.querySelector(`[data-node-id="${CSS.escape(i)}"]`);
46
+ if (!t || !d) return;
47
+ const s = t.getBoundingClientRect(), f = d.getBoundingClientRect();
48
+ f.top < s.top ? t.scrollTop -= s.top - f.top : f.bottom > s.bottom && (t.scrollTop += f.bottom - s.bottom);
49
+ };
50
+ return U(
51
+ () => e.modelValue,
52
+ async (i) => {
53
+ if (!i) return;
54
+ !w.value.some((d) => d.id === i) && e.nodes.some((d) => d.id === i) && (u.value = "", o.value = "all"), await Y(), x(i);
55
+ },
56
+ { flush: "post" }
57
+ ), (i, t) => {
58
+ const d = $("bk-input");
59
+ return c(), v("aside", ie, [
60
+ m(d, {
61
+ modelValue: u.value,
62
+ "onUpdate:modelValue": t[0] || (t[0] = (s) => u.value = s),
63
+ class: "debug-result-node-list__search",
64
+ placeholder: "搜索节点名称 / 类型",
65
+ type: "search",
66
+ clearable: "",
67
+ "data-test": "node-search"
68
+ }, null, 8, ["modelValue"]),
69
+ m(se, {
70
+ modelValue: o.value,
71
+ "onUpdate:modelValue": t[1] || (t[1] = (s) => o.value = s),
72
+ class: "debug-result-node-list__filters",
73
+ "data-test": "status-filters",
74
+ items: y.value
75
+ }, null, 8, ["modelValue", "items"]),
76
+ w.value.length > 0 ? (c(), v("div", {
77
+ key: 0,
78
+ ref_key: "itemsRef",
79
+ ref: b,
80
+ class: "debug-result-node-list__items",
81
+ role: "listbox"
82
+ }, [
83
+ (c(!0), v(K, null, q(w.value, (s) => (c(), v("div", {
84
+ key: s.id,
85
+ class: M([
86
+ "debug-result-node-list__item",
87
+ `is-${s.status}`,
88
+ {
89
+ "is-active": s.id === e.modelValue,
90
+ "is-unconfigured": !s.isConfigured
91
+ }
92
+ ]),
93
+ role: "option",
94
+ "data-test": "node-item",
95
+ "data-node-id": s.id,
96
+ "aria-selected": s.id === e.modelValue,
97
+ tabindex: "0",
98
+ onClick: (f) => l("update:modelValue", s.id),
99
+ onKeydown: J(W((f) => l("update:modelValue", s.id), ["prevent"]), ["enter", "space"])
100
+ }, [
101
+ a("span", {
102
+ class: M([
103
+ "debug-result-node-list__status",
104
+ `is-${s.status}`,
105
+ { "is-placeholder": !s.isConfigured }
106
+ ])
107
+ }, [
108
+ s.icon ? (c(), v("i", {
109
+ key: 0,
110
+ class: M(s.icon),
111
+ "data-test": "node-icon"
112
+ }, null, 2)) : T("", !0)
113
+ ], 2),
114
+ a("span", {
115
+ class: "debug-result-node-list__name",
116
+ title: s.isConfigured ? `${s.name} ${s.typeName || s.type}` : s.name
117
+ }, R(s.name), 9, re),
118
+ s.isMock ? (c(), v("span", de, "MOCK")) : T("", !0)
119
+ ], 42, ue))), 128))
120
+ ], 512)) : (c(), v("div", ce, [
121
+ m(oe, {
122
+ "is-search": !1,
123
+ title: N.value,
124
+ onClear: h
125
+ }, null, 8, ["title"])
126
+ ]))
127
+ ]);
128
+ };
129
+ }
130
+ }), pe = /* @__PURE__ */ z(me, [["__scopeId", "data-v-5f1b1514"]]);
131
+ function ve(n) {
132
+ if (n == null) return "";
133
+ if (typeof n == "string") return n;
134
+ if (typeof n == "object") {
135
+ const r = n, e = r.message;
136
+ if (typeof e == "string" && e) {
137
+ const l = r.type;
138
+ return typeof l == "string" && l ? `${l}: ${e}` : e;
139
+ }
140
+ try {
141
+ return JSON.stringify(n);
142
+ } catch {
143
+ return String(n);
144
+ }
145
+ }
146
+ return String(n);
147
+ }
148
+ const be = { class: "debug-result-tabs" }, _e = {
149
+ class: "debug-result-tabs__execution",
150
+ "data-test": "tab-execution"
151
+ }, ge = { class: "debug-result-tabs__row" }, fe = { class: "value" }, ye = { class: "debug-result-tabs__row" }, ke = { class: "value" }, we = {
152
+ key: 0,
153
+ class: "debug-result-tabs__row is-error"
154
+ }, xe = { class: "value" }, Ce = {
155
+ key: 0,
156
+ class: "debug-result-tabs__mock-banner",
157
+ "data-test": "mock-banner"
158
+ }, Ee = {
159
+ key: 1,
160
+ class: "debug-result-tabs__error-banner",
161
+ "data-test": "output-error"
162
+ }, he = {
163
+ key: 0,
164
+ class: "debug-result-tabs__error-text"
165
+ }, Ve = { class: "debug-result-tabs__error-guide" }, Re = {
166
+ class: "debug-result-tabs__logs",
167
+ "data-test": "tab-logs"
168
+ }, Se = /* @__PURE__ */ G({
169
+ __name: "result-tabs",
170
+ props: {
171
+ result: {},
172
+ isMock: { type: Boolean, default: !1 }
173
+ },
174
+ emits: ["reEditMock", "runReal", "runMock", "logsTabActive"],
175
+ setup(n, { emit: r }) {
176
+ const e = n, l = r, u = S("execution");
177
+ U(
178
+ u,
179
+ (i) => l("logsTabActive", i === "logs"),
180
+ { immediate: !0 }
181
+ );
182
+ const o = {
183
+ not_run: "未调试",
184
+ running: "正在调试",
185
+ finished: "成功",
186
+ failed: "失败",
187
+ suspended: "挂起",
188
+ skipped: "跳过"
189
+ }, b = p(() => o[e.result.execution.status] ?? e.result.execution.status), g = p(() => {
190
+ const i = e.result.execution.durationMs;
191
+ return i == null ? "--" : `${(i / 1e3).toFixed(1)}s`;
192
+ }), y = p(() => ve(e.result.error || e.result.execution.errorDetail)), w = p(() => e.result.execution.status === "failed"), E = (i) => Object.entries(i ?? {}).map(([t, d]) => ({ key: t, name: t, value: d })), N = p(() => E(e.result.inputs)), h = p(() => E(e.result.outputs)), x = p(() => e.result.logs == null ? "" : ne(e.result.logs));
193
+ return (i, t) => {
194
+ const d = $("bk-tab-panel"), s = $("bk-button"), f = $("bk-tab");
195
+ return c(), v("div", be, [
196
+ m(f, {
197
+ active: u.value,
198
+ "onUpdate:active": t[3] || (t[3] = (V) => u.value = V),
199
+ type: "card-grid"
200
+ }, {
201
+ default: k(() => [
202
+ m(d, {
203
+ name: "execution",
204
+ label: "执行信息"
205
+ }, {
206
+ default: k(() => [
207
+ a("div", _e, [
208
+ a("div", ge, [
209
+ t[4] || (t[4] = a("span", { class: "label" }, "执行状态", -1)),
210
+ a("span", fe, R(b.value), 1)
211
+ ]),
212
+ a("div", ye, [
213
+ t[5] || (t[5] = a("span", { class: "label" }, "调试用时", -1)),
214
+ a("span", ke, R(g.value), 1)
215
+ ]),
216
+ y.value ? (c(), v("div", we, [
217
+ t[6] || (t[6] = a("span", { class: "label" }, "错误信息", -1)),
218
+ a("span", xe, R(y.value), 1)
219
+ ])) : T("", !0)
220
+ ])
221
+ ]),
222
+ _: 1
223
+ }),
224
+ m(d, {
225
+ name: "inputs",
226
+ label: "输入参数"
227
+ }, {
228
+ default: k(() => [
229
+ m(D, {
230
+ rows: N.value,
231
+ loading: e.result.loading,
232
+ error: e.result.detailError,
233
+ "empty-text": "暂无输入参数"
234
+ }, null, 8, ["rows", "loading", "error"])
235
+ ]),
236
+ _: 1
237
+ }),
238
+ m(d, {
239
+ name: "outputs",
240
+ label: "输出结果"
241
+ }, {
242
+ default: k(() => [
243
+ e.isMock ? (c(), v("div", Ce, [
244
+ t[8] || (t[8] = a("span", null, "当前为 Mock 数据", -1)),
245
+ m(s, {
246
+ text: "",
247
+ theme: "primary",
248
+ size: "small",
249
+ "data-test": "re-edit-mock",
250
+ onClick: t[0] || (t[0] = (V) => l("reEditMock"))
251
+ }, {
252
+ default: k(() => [...t[7] || (t[7] = [
253
+ L(" 重新编辑 ", -1)
254
+ ])]),
255
+ _: 1
256
+ })
257
+ ])) : T("", !0),
258
+ w.value ? (c(), v("div", Ee, [
259
+ y.value ? (c(), v("p", he, R(y.value), 1)) : T("", !0),
260
+ a("p", Ve, [
261
+ t[11] || (t[11] = a("span", null, "该节点调试失败,可", -1)),
262
+ m(s, {
263
+ text: "",
264
+ theme: "primary",
265
+ "data-test": "rerun-real",
266
+ onClick: t[1] || (t[1] = (V) => l("runReal"))
267
+ }, {
268
+ default: k(() => [...t[9] || (t[9] = [
269
+ L("重新调试", -1)
270
+ ])]),
271
+ _: 1
272
+ }),
273
+ t[12] || (t[12] = a("span", null, "或直接", -1)),
274
+ m(s, {
275
+ text: "",
276
+ theme: "primary",
277
+ "data-test": "run-mock",
278
+ onClick: t[2] || (t[2] = (V) => l("runMock"))
279
+ }, {
280
+ default: k(() => [...t[10] || (t[10] = [
281
+ L("Mock输出", -1)
282
+ ])]),
283
+ _: 1
284
+ })
285
+ ])
286
+ ])) : (c(), F(D, {
287
+ key: 2,
288
+ rows: h.value,
289
+ loading: e.result.loading,
290
+ error: e.result.detailError,
291
+ "empty-text": "暂无输出结果"
292
+ }, null, 8, ["rows", "loading", "error"]))
293
+ ]),
294
+ _: 1
295
+ }),
296
+ m(d, {
297
+ name: "logs",
298
+ label: "调用日志"
299
+ }, {
300
+ default: k(() => [
301
+ a("div", Re, [
302
+ m(ae, {
303
+ "log-text": x.value,
304
+ loading: e.result.logLoading,
305
+ error: e.result.logError
306
+ }, null, 8, ["log-text", "loading", "error"])
307
+ ])
308
+ ]),
309
+ _: 1
310
+ })
311
+ ]),
312
+ _: 1
313
+ }, 8, ["active"])
314
+ ]);
315
+ };
316
+ }
317
+ }), Me = /* @__PURE__ */ z(Se, [["__scopeId", "data-v-5eca6f4b"]]), Te = {
318
+ ExclusiveGateway: "bkflow-canvas-fenzhiwangguan",
319
+ ParallelGateway: "bkflow-canvas-bingxingwangguan",
320
+ ConditionalParallelGateway: "bkflow-canvas-tiaojianbingxingwangguan",
321
+ ConvergeGateway: "bkflow-canvas-huijuwangguan"
322
+ }, B = {
323
+ ServiceActivity: "任务节点",
324
+ EmptyStartEvent: "开始节点",
325
+ EmptyEndEvent: "结束节点",
326
+ ExclusiveGateway: "分支网关",
327
+ ParallelGateway: "并行网关",
328
+ ConditionalParallelGateway: "条件并行网关",
329
+ ConvergeGateway: "汇聚网关"
330
+ };
331
+ function Ne(n) {
332
+ if (!n.component?.code) return "";
333
+ if (n.component.code === "uniform_api") {
334
+ const r = n.component.api_meta?.category?.name ?? "";
335
+ return P[r] ?? P.bkflow;
336
+ }
337
+ return P.bkflow;
338
+ }
339
+ function $e(n, r) {
340
+ const e = n?.location?.find((b) => b.id === r), l = e?.icon ?? "", u = n?.activities?.[r];
341
+ if (u)
342
+ return {
343
+ name: !!u.component?.code ? u.name || e?.name || r : "节点未配置",
344
+ type: u.type || "ServiceActivity",
345
+ typeName: B[u.type] ?? "任务节点",
346
+ icon: Ne(u)
347
+ };
348
+ const o = n?.gateways?.[r];
349
+ return o ? {
350
+ name: o.name || e?.name || B[o.type] || r,
351
+ type: o.type,
352
+ typeName: B[o.type] ?? "网关",
353
+ icon: l || Te[o.type] || ""
354
+ } : n?.start_event?.id === r ? {
355
+ name: n.start_event.name || "开始",
356
+ type: "EmptyStartEvent",
357
+ typeName: "开始节点",
358
+ icon: l || "bkflow-canvas-kaishi"
359
+ } : n?.end_event?.id === r ? {
360
+ name: n.end_event.name || "结束",
361
+ type: "EmptyEndEvent",
362
+ typeName: "结束节点",
363
+ icon: l || "bkflow-canvas-stop"
364
+ } : e ? {
365
+ name: e.name || r,
366
+ type: e.type || "",
367
+ typeName: "",
368
+ icon: l
369
+ } : { name: r, type: "", typeName: "", icon: "" };
370
+ }
371
+ function Le(n, r, e = /* @__PURE__ */ new Set()) {
372
+ const l = n?.activities;
373
+ if (!l) return [];
374
+ const u = new Map(
375
+ (r ?? []).map((o) => [o.node_id, le(o.status)])
376
+ );
377
+ return Object.values(l).map((o) => {
378
+ const b = !!o.component?.code, g = $e(n, o.id);
379
+ return {
380
+ id: o.id,
381
+ name: g.name,
382
+ type: g.type || o.type,
383
+ typeName: g.typeName,
384
+ icon: g.icon,
385
+ status: u.get(o.id) ?? "not_run",
386
+ isMock: e.has(o.id),
387
+ isConfigured: b
388
+ };
389
+ });
390
+ }
391
+ const Ae = { class: "debug-result-drawer__header" }, Pe = { class: "debug-result-drawer__header-left" }, Be = { class: "debug-result-drawer__body" }, Ge = { class: "debug-result-drawer__content" }, ze = { class: "debug-result-drawer__result" }, De = 44, Ue = /* @__PURE__ */ G({
392
+ __name: "index",
393
+ props: {
394
+ open: { type: Boolean },
395
+ context: {},
396
+ pipelineTree: {},
397
+ mockNodeIds: {},
398
+ modelValue: { default: "" },
399
+ result: {},
400
+ hasGlobalRun: { type: Boolean, default: !1 },
401
+ viewParamsPending: { type: Boolean, default: !1 }
402
+ },
403
+ emits: ["update:open", "update:modelValue", "reEditMock", "runReal", "runMock", "viewParams", "logsTabActive"],
404
+ setup(n, { emit: r }) {
405
+ const e = n, l = r, u = S(420), o = S(!1);
406
+ let b = 0, g = 0, y = "", w = "";
407
+ const E = p(() => ({
408
+ height: `${e.open ? u.value : De}px`
409
+ })), N = () => {
410
+ l("update:open", !e.open);
411
+ }, h = (C) => {
412
+ const _ = g - (C.clientY - b);
413
+ u.value = Math.max(200, Math.min(window.innerHeight * 0.8, _));
414
+ }, x = () => {
415
+ document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", x), document.body.style.cursor = y, document.body.style.userSelect = w, o.value = !1;
416
+ }, i = (C) => {
417
+ C.preventDefault(), o.value = !0, b = C.clientY, g = u.value, y = document.body.style.cursor, w = document.body.style.userSelect, document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", h), document.addEventListener("mouseup", x);
418
+ };
419
+ Q(x);
420
+ const t = p({
421
+ get: () => e.modelValue,
422
+ set: (C) => l("update:modelValue", C)
423
+ }), d = p(
424
+ () => Le(e.pipelineTree, e.context?.nodes, e.mockNodeIds)
425
+ ), s = p(() => e.mockNodeIds.has(e.modelValue)), f = () => {
426
+ !e.hasGlobalRun || e.viewParamsPending || l("viewParams");
427
+ }, V = () => {
428
+ e.modelValue && l("reEditMock", e.modelValue);
429
+ }, I = () => {
430
+ e.modelValue && l("runReal", e.modelValue);
431
+ }, O = () => {
432
+ e.modelValue && l("runMock", e.modelValue);
433
+ };
434
+ return (C, _) => {
435
+ const j = $("bk-button"), H = X("bk-tooltips");
436
+ return c(), v("div", {
437
+ class: M(["debug-result-drawer-wrapper", { "is-resizing": o.value }]),
438
+ style: Z(E.value)
439
+ }, [
440
+ e.open ? (c(), v("div", {
441
+ key: 0,
442
+ class: "debug-result-drawer__resize",
443
+ onMousedown: i
444
+ }, null, 32)) : T("", !0),
445
+ a("section", {
446
+ class: M(["debug-result-drawer", { "is-collapsed": !e.open }])
447
+ }, [
448
+ a("header", Ae, [
449
+ a("div", Pe, [
450
+ _[3] || (_[3] = a("span", { class: "debug-result-drawer__title" }, "调试结果", -1)),
451
+ _[4] || (_[4] = a("span", { class: "debug-result-drawer__divider" }, null, -1)),
452
+ ee((c(), F(j, {
453
+ text: "",
454
+ theme: "primary",
455
+ disabled: !e.hasGlobalRun,
456
+ loading: e.viewParamsPending,
457
+ onClick: f
458
+ }, {
459
+ default: k(() => [..._[2] || (_[2] = [
460
+ a("i", { class: "bkflow-canvas-icon bkflow-canvas-audit view-params-icon" }, null, -1),
461
+ L(" 查看参数 ", -1)
462
+ ])]),
463
+ _: 1
464
+ }, 8, ["disabled", "loading"])), [
465
+ [H, { content: "请先进行调试", disabled: e.hasGlobalRun }]
466
+ ])
467
+ ]),
468
+ a("span", {
469
+ class: "debug-result-drawer__collapse",
470
+ onClick: N
471
+ }, [
472
+ a("span", null, R(e.open ? "收起" : "展开"), 1),
473
+ a("i", {
474
+ class: M(["bkflow-canvas-icon bkflow-canvas-arrows-down debug-result-drawer__collapse-icon", { "is-expanded": e.open }])
475
+ }, null, 2)
476
+ ])
477
+ ]),
478
+ a("div", Be, [
479
+ a("div", Ge, [
480
+ m(pe, {
481
+ modelValue: t.value,
482
+ "onUpdate:modelValue": _[0] || (_[0] = (A) => t.value = A),
483
+ nodes: d.value
484
+ }, null, 8, ["modelValue", "nodes"]),
485
+ a("div", ze, [
486
+ m(Me, {
487
+ result: e.result,
488
+ "is-mock": s.value,
489
+ onReEditMock: V,
490
+ onRunReal: I,
491
+ onRunMock: O,
492
+ onLogsTabActive: _[1] || (_[1] = (A) => l("logsTabActive", A))
493
+ }, null, 8, ["result", "is-mock"])
494
+ ])
495
+ ])
496
+ ])
497
+ ], 2)
498
+ ], 6);
499
+ };
500
+ }
501
+ }), je = /* @__PURE__ */ z(Ue, [["__scopeId", "data-v-d1a8cf95"]]);
502
+ export {
503
+ je as default
504
+ };
@@ -0,0 +1,184 @@
1
+ import { defineComponent as $, ref as _, shallowRef as h, computed as V, watch as A, resolveComponent as C, resolveDirective as O, openBlock as c, createBlock as d, createSlots as P, withCtx as m, withDirectives as U, createElementBlock as K, createElementVNode as F, unref as G, createCommentVNode as g, createVNode as x, createTextVNode as B } from "vue";
2
+ import { cloneDeep as p } from "lodash";
3
+ import { u as H, i as S, g as Y, B as z, R as J, E as M, _ as Q } from "./index-C16qU3Yx.js";
4
+ import "bkui-vue/lib/message";
5
+ import "bkui-vue/lib/icon";
6
+ import "monaco-editor";
7
+ const W = {
8
+ string: "input",
9
+ text: "input",
10
+ textarea: "textarea",
11
+ int: "input",
12
+ integer: "input",
13
+ number: "input",
14
+ float: "input",
15
+ json: "json",
16
+ object: "json",
17
+ array: "array",
18
+ list: "array",
19
+ select: "select",
20
+ time: "timepicker",
21
+ datetime: "timepicker"
22
+ }, j = (e) => e.replace(/^\$\{(.+)\}$/, "$1"), E = (e) => `\${${j(e)}}`;
23
+ function X(e, r) {
24
+ const o = E(e.key), t = r ? p(r) : {}, i = e.custom_type ?? t.custom_type ?? W[e.type] ?? "input";
25
+ return {
26
+ ...t,
27
+ key: o,
28
+ name: e.name ?? t.name ?? j(e.key),
29
+ custom_type: i,
30
+ desc: t.desc ?? "",
31
+ index: t.index ?? 0,
32
+ show_type: "show",
33
+ source_info: t.source_info ?? {},
34
+ source_tag: t.source_tag ?? "",
35
+ source_type: t.source_type ?? "custom",
36
+ validation: t.validation ?? "",
37
+ value: e.default ?? t.value,
38
+ meta: {
39
+ ...t.meta ?? {},
40
+ required: e.required ?? t.meta?.required ?? !1
41
+ }
42
+ };
43
+ }
44
+ function Z(e, r = {}) {
45
+ if (!e) return {};
46
+ const o = e.constants;
47
+ return o && Object.keys(o).length > 0 ? { ...o } : Array.isArray(e.fields) && e.fields.length > 0 ? e.fields.reduce((t, i) => {
48
+ const n = E(i.key);
49
+ return t[n] = X(i, r[n]), t;
50
+ }, {}) : {};
51
+ }
52
+ const ee = { class: "global-debug-input" }, te = { class: "form-params-wrapper" }, oe = { class: "sideslider-footer-buttons" }, ae = /* @__PURE__ */ $({
53
+ __name: "index",
54
+ props: {
55
+ show: { type: Boolean },
56
+ schema: {},
57
+ pipelineConstants: { default: () => ({}) },
58
+ initialValues: { default: () => ({}) },
59
+ pending: { type: Boolean, default: !1 },
60
+ readonly: { type: Boolean, default: !1 }
61
+ },
62
+ emits: ["confirm", "close", "update:show"],
63
+ setup(e, { emit: r }) {
64
+ const o = e, t = r, i = H(), n = _({}), k = h([]), u = h([]), f = h(!1), v = _(), y = _(), b = V(() => k.value.filter((a) => S(a))), R = V(() => b.value.length > 0 || u.value.length > 0);
65
+ A(
66
+ () => o.show,
67
+ (a) => {
68
+ a && (n.value = p(o.initialValues ?? {}), D());
69
+ }
70
+ );
71
+ const D = async () => {
72
+ const a = Z(o.schema, o.pipelineConstants), s = Object.values(a).filter(
73
+ (l) => typeof l == "object" && l !== null && l.show_type === "show"
74
+ );
75
+ if (k.value = s, Object.keys(a).length < 1) {
76
+ u.value = [];
77
+ return;
78
+ }
79
+ f.value = !0;
80
+ try {
81
+ u.value = await Y(i, a);
82
+ } catch (l) {
83
+ console.error("Failed to build debug input forms from schema:", l), u.value = [];
84
+ } finally {
85
+ f.value = !1;
86
+ }
87
+ }, I = (a) => {
88
+ n.value = { ...n.value, ...p(a) };
89
+ }, L = async () => {
90
+ const [a, s] = await Promise.all([
91
+ Promise.resolve(
92
+ typeof y.value?.validate == "function" ? y.value.validate() : !0
93
+ ),
94
+ Promise.resolve(typeof v.value?.validate == "function" ? v.value.validate() : !0)
95
+ ]);
96
+ !a || !s || t("confirm", p(n.value));
97
+ }, w = () => {
98
+ t("close"), t("update:show", !1);
99
+ };
100
+ return (a, s) => {
101
+ const l = C("bk-button"), q = C("bk-sideslider"), N = O("bkloading");
102
+ return c(), d(q, {
103
+ title: "调试参数",
104
+ "is-show": o.show,
105
+ width: 700,
106
+ "quick-close": !0,
107
+ "esc-close": !1,
108
+ onClosed: w
109
+ }, P({
110
+ default: m(() => [
111
+ U((c(), K("div", ee, [
112
+ F("div", te, [
113
+ b.value.length > 0 ? (c(), d(G(z), {
114
+ key: 0,
115
+ ref_key: "builtinVariableFormRef",
116
+ ref: y,
117
+ modelValue: n.value,
118
+ "onUpdate:modelValue": s[0] || (s[0] = (T) => n.value = T),
119
+ variables: b.value,
120
+ editable: !o.readonly
121
+ }, null, 8, ["modelValue", "variables", "editable"])) : g("", !0),
122
+ u.value.length > 0 ? (c(), d(J, {
123
+ key: 1,
124
+ ref_key: "renderFormRef",
125
+ ref: v,
126
+ scheme: u.value,
127
+ editable: !o.readonly,
128
+ "form-option": {
129
+ showRequired: !0,
130
+ showGroup: !0,
131
+ showLabel: !1,
132
+ showHook: !1,
133
+ showDesc: !0,
134
+ formEdit: !o.readonly
135
+ },
136
+ "form-data": n.value,
137
+ onChange: I
138
+ }, null, 8, ["scheme", "editable", "form-option", "form-data"])) : g("", !0),
139
+ R.value ? g("", !0) : (c(), d(M, {
140
+ key: 2,
141
+ title: "暂无参数"
142
+ }))
143
+ ])
144
+ ])), [
145
+ [N, { loading: f.value }]
146
+ ])
147
+ ]),
148
+ _: 2
149
+ }, [
150
+ o.readonly ? void 0 : {
151
+ name: "footer",
152
+ fn: m(() => [
153
+ F("div", oe, [
154
+ x(l, {
155
+ theme: "primary",
156
+ "data-test": "save-and-run",
157
+ loading: o.pending,
158
+ onClick: L
159
+ }, {
160
+ default: m(() => [...s[1] || (s[1] = [
161
+ B(" 保存并执行 ", -1)
162
+ ])]),
163
+ _: 1
164
+ }, 8, ["loading"]),
165
+ x(l, {
166
+ disabled: o.pending,
167
+ onClick: w
168
+ }, {
169
+ default: m(() => [...s[2] || (s[2] = [
170
+ B("取消", -1)
171
+ ])]),
172
+ _: 1
173
+ }, 8, ["disabled"])
174
+ ])
175
+ ]),
176
+ key: "0"
177
+ }
178
+ ]), 1032, ["is-show"]);
179
+ };
180
+ }
181
+ }), ce = /* @__PURE__ */ Q(ae, [["__scopeId", "data-v-767dae0e"]]);
182
+ export {
183
+ ce as default
184
+ };