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

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