@blueking/bkflow-canvas-editor 1.1.0-beta.3 → 1.1.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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),d=require("./index-D301MshF.cjs"),L={class:"debug-result-node-list"},D=["data-node-id","aria-selected","onClick","onKeydown"],z=["title"],A={key:0,class:"debug-result-node-list__mock","data-test":"node-mock-flag"},P={key:1,class:"debug-result-node-list__empty"},I=e.defineComponent({__name:"node-list",props:{nodes:{},modelValue:{default:""}},emits:["update:modelValue"],setup(c,{emit:g}){const t=c,s=g,r=e.ref(""),m=e.ref("all"),_=e.ref(null),p={not_run:"未执行",finished:"成功",failed:"失败",running:"正在调试",suspended:"挂起",skipped:"跳过",revoked:"终止"},k=[{value:"all",label:"全部"},{value:"finished",icon:"bkflow-canvas-dark-circle-checkbox",iconColor:"#5fb8ac",tooltip:p.finished},{value:"failed",icon:"bkflow-canvas-dark-circle-close",iconColor:"#fa4e41",tooltip:p.failed},{value:"revoked",icon:"bkflow-canvas-stop-fill",iconColor:"#fa4e41",tooltip:p.revoked},{value:"running",iconComponent:d.LoadingStatusIcon,iconColor:"#3a84ff",tooltip:p.running},{value:"not_run",icon:"bkflow-canvas-weizhixing2",iconColor:"#b8bbc4",tooltip:p.not_run},{value:"suspended",icon:"bkflow-canvas-zanting",iconColor:"#f59500",tooltip:p.suspended},{value:"skipped",icon:"bkflow-canvas-tiaoguo2",iconColor:"#6e89af",tooltip:p.skipped}],w=e.computed(()=>k.map(a=>({...a,count:a.value==="all"?t.nodes.length:t.nodes.filter(n=>n.status===a.value).length}))),V=e.computed(()=>{const a=r.value.trim().toLowerCase();return t.nodes.filter(n=>m.value!=="all"&&n.status!==m.value?!1:a?n.name.toLowerCase().includes(a)||n.type.toLowerCase().includes(a)||(n.typeName??"").toLowerCase().includes(a):!0)}),C=e.computed(()=>r.value.trim()?"搜索结果为空":m.value!=="all"?`暂无${p[m.value]}状态节点`:"暂无节点"),x=()=>{r.value="",m.value="all"},y=a=>{const n=_.value,v=n?.querySelector(`[data-node-id="${CSS.escape(a)}"]`);if(!n||!v)return;const o=n.getBoundingClientRect(),b=v.getBoundingClientRect();b.top<o.top?n.scrollTop-=o.top-b.top:b.bottom>o.bottom&&(n.scrollTop+=b.bottom-o.bottom)};return e.watch(()=>t.modelValue,async a=>{if(!a)return;!V.value.some(v=>v.id===a)&&t.nodes.some(v=>v.id===a)&&(r.value="",m.value="all"),await e.nextTick(),y(a)},{flush:"post"}),(a,n)=>{const v=e.resolveComponent("bk-input");return e.openBlock(),e.createElementBlock("aside",L,[e.createVNode(v,{modelValue:r.value,"onUpdate:modelValue":n[0]||(n[0]=o=>r.value=o),class:"debug-result-node-list__search",placeholder:"搜索节点名称 / 类型",type:"search",clearable:"","data-test":"node-search"},null,8,["modelValue"]),e.createVNode(d.SegmentTabs,{modelValue:m.value,"onUpdate:modelValue":n[1]||(n[1]=o=>m.value=o),class:"debug-result-node-list__filters","data-test":"status-filters",items:w.value},null,8,["modelValue","items"]),V.value.length>0?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"itemsRef",ref:_,class:"debug-result-node-list__items",role:"listbox"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.id,class:e.normalizeClass(["debug-result-node-list__item",`is-${o.status}`,{"is-active":o.id===t.modelValue,"is-unconfigured":!o.isConfigured}]),role:"option","data-test":"node-item","data-node-id":o.id,"aria-selected":o.id===t.modelValue,tabindex:"0",onClick:b=>s("update:modelValue",o.id),onKeydown:e.withKeys(e.withModifiers(b=>s("update:modelValue",o.id),["prevent"]),["enter","space"])},[e.createElementVNode("span",{class:e.normalizeClass(["debug-result-node-list__status",`is-${o.status}`,{"is-placeholder":!o.isConfigured}])},[o.icon?(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(o.icon),"data-test":"node-icon"},null,2)):e.createCommentVNode("",!0)],2),e.createElementVNode("span",{class:"debug-result-node-list__name",title:o.isConfigured?`${o.name} ${o.typeName||o.type}`:o.name},e.toDisplayString(o.name),9,z),o.isMock?(e.openBlock(),e.createElementBlock("span",A,"MOCK")):e.createCommentVNode("",!0)],42,D))),128))],512)):(e.openBlock(),e.createElementBlock("div",P,[e.createVNode(d.EmptyException,{"is-search":!1,title:C.value,onClear:x},null,8,["title"])]))])}}}),H=d._export_sfc(I,[["__scopeId","data-v-db0cb31c"]]);function U(c){if(c==null)return"";if(typeof c=="string")return c;if(typeof c=="object"){const g=c,t=g.message;if(typeof t=="string"&&t){const s=g.type;return typeof s=="string"&&s?`${s}: ${t}`:t}try{return JSON.stringify(c)}catch{return String(c)}}return String(c)}const O={class:"debug-result-tabs"},F={class:"debug-result-tabs__failed-actions","data-test":"output-error-actions"},G={class:"debug-result-tabs__execution","data-test":"tab-execution"},K={class:"debug-result-tabs__row"},j={class:"value"},q={class:"debug-result-tabs__row"},Y={class:"value"},J={key:0,class:"debug-result-tabs__row is-error"},Q={class:"value"},W={class:"debug-result-tabs__mock-hint","data-test":"mock-banner"},X={class:"debug-result-tabs__logs","data-test":"tab-logs"},Z=e.defineComponent({__name:"result-tabs",props:{result:{},component:{},isMock:{type:Boolean,default:!1},canRunNodeDebug:{type:Boolean,default:!1}},emits:["reEditMock","runReal","runMock","logsTabActive"],setup(c,{emit:g}){const t=c,s=g,r=e.ref("execution");e.watch(r,f=>s("logsTabActive",f==="logs"),{immediate:!0});const m={not_run:"未调试",running:"正在调试",finished:"成功",failed:"失败",suspended:"挂起",skipped:"跳过",revoked:"已终止"},_=e.computed(()=>m[t.result.execution.status]??t.result.execution.status),p=e.computed(()=>d.formatSummaryDuration(t.result.execution.durationMs)),k=e.computed(()=>U(t.result.error||t.result.execution.errorDetail)),w=e.computed(()=>t.result.execution.status==="revoked"),V=e.computed(()=>d.isDebugAbnormalStatus(t.result.execution.status)),C=e.computed(()=>w.value?"该节点调试已终止,可":"该节点执行失败,可"),{loading:x,error:y,visibleInputs:a,visibleOutputs:n,outputNameMap:v}=d.usePluginParamMeta({component:()=>t.component}),o=e.computed(()=>t.result.loading||x.value),b=e.computed(()=>t.result.detailError||y.value),h=e.computed(()=>a.value.filter(({key:f})=>Object.prototype.hasOwnProperty.call(t.result.inputs,f)).map(({key:f,name:l})=>({key:f,name:l,value:t.result.inputs[f]}))),B=e.computed(()=>d.orderDebugRowsByDeclaredKeys(d.toDebugOutputValueRows(t.result.outputs,v.value),n.value.map(f=>f.key))),R=e.computed(()=>d.shouldShowMockReEditHint(t.isMock,n.value)),T=e.computed(()=>t.result.logs==null?"":d.normalizeLogText(t.result.logs));return(f,l)=>{const i=e.resolveComponent("bk-button"),u=e.resolveComponent("bk-tab-panel"),S=e.resolveComponent("bk-tab");return e.openBlock(),e.createElementBlock("div",O,[e.createVNode(S,{active:r.value,"onUpdate:active":l[3]||(l[3]=E=>r.value=E),type:"card-grid"},e.createSlots({default:e.withCtx(()=>[e.createVNode(u,{name:"execution",label:"执行信息"},{default:e.withCtx(()=>[e.createElementVNode("div",G,[e.createElementVNode("div",K,[l[8]||(l[8]=e.createElementVNode("span",{class:"label"},"执行状态",-1)),e.createElementVNode("span",j,e.toDisplayString(_.value),1)]),e.createElementVNode("div",q,[l[9]||(l[9]=e.createElementVNode("span",{class:"label"},"调试用时",-1)),e.createElementVNode("span",Y,e.toDisplayString(p.value),1)]),k.value?(e.openBlock(),e.createElementBlock("div",J,[l[10]||(l[10]=e.createElementVNode("span",{class:"label"},"错误信息",-1)),e.createElementVNode("span",Q,e.toDisplayString(k.value),1)])):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(u,{name:"inputs",label:"输入参数"},{default:e.withCtx(()=>[e.createVNode(d.DebugValueTable,{rows:h.value,loading:o.value,error:b.value,"empty-text":"暂无输入参数"},null,8,["rows","loading","error"])]),_:1}),e.createVNode(u,{name:"outputs",label:"输出结果"},{default:e.withCtx(()=>[e.createVNode(d.DebugValueTable,{rows:B.value,loading:o.value,error:b.value,"empty-text":"暂无输出结果"},e.createSlots({_:2},[R.value?{name:"toolbar",fn:e.withCtx(()=>[e.createElementVNode("div",W,[l[12]||(l[12]=e.createElementVNode("i",{class:"bkflow-canvas-icon bkflow-canvas-info debug-result-tabs__mock-info","aria-hidden":"true"},null,-1)),l[13]||(l[13]=e.createElementVNode("span",null,"当前为 Mock 数据",-1)),e.createVNode(i,{text:"",theme:"primary",size:"small","data-test":"re-edit-mock",onClick:l[2]||(l[2]=E=>s("reEditMock"))},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode(" 重新编辑 ",-1)])]),_:1})])]),key:"0"}:void 0]),1032,["rows","loading","error"])]),_:1}),e.createVNode(u,{name:"logs",label:"调用日志"},{default:e.withCtx(()=>[e.createElementVNode("div",X,[e.createVNode(d.CallLogsViewer,{"log-text":T.value,loading:t.result.logLoading,error:t.result.logError},null,8,["log-text","loading","error"])])]),_:1})]),_:2},[V.value&&t.canRunNodeDebug?{name:"setting",fn:e.withCtx(()=>[e.createElementVNode("div",F,[l[6]||(l[6]=e.createElementVNode("i",{class:"bkflow-canvas-icon bkflow-canvas-alert"},null,-1)),e.createElementVNode("span",null,e.toDisplayString(C.value),1),e.createVNode(i,{text:"",theme:"primary","data-test":"rerun-real",onClick:l[0]||(l[0]=E=>s("runReal"))},{default:e.withCtx(()=>[...l[4]||(l[4]=[e.createTextVNode("重新调试",-1)])]),_:1}),l[7]||(l[7]=e.createElementVNode("span",null,"或直接",-1)),e.createVNode(i,{text:"",theme:"primary","data-test":"run-mock",onClick:l[1]||(l[1]=E=>s("runMock"))},{default:e.withCtx(()=>[...l[5]||(l[5]=[e.createTextVNode("Mock 输出",-1)])]),_:1})])]),key:"0"}:void 0]),1032,["active"])])}}}),ee=d._export_sfc(Z,[["__scopeId","data-v-2a925689"]]),te={class:"debug-result-drawer__header"},oe={class:"debug-result-drawer__header-left"},le={class:"debug-result-drawer__body"},se={class:"debug-result-drawer__content"},ne={class:"debug-result-drawer__result"},ae={key:1,class:"debug-result-drawer__unselected","data-test":"node-unselected"},N=44,$=420,ue=e.defineComponent({__name:"index",props:{open:{type:Boolean},context:{},pipelineTree:{},mockNodeIds:{},modelValue:{default:""},result:{},hasGlobalRun:{type:Boolean,default:!1},viewParamsPending:{type:Boolean,default:!1},offsetLeft:{default:0}},emits:["update:open","update:modelValue","reEditMock","runReal","runMock","viewParams","logsTabActive"],setup(c,{emit:g}){const t=c,s=g,r=e.ref($),m=e.ref(!1);let _=0,p=0,k="",w="";const V=e.computed(()=>({left:`${t.offsetLeft}px`,height:`${t.open?r.value:N}px`})),C=()=>{t.open||(r.value=$),s("update:open",!t.open)},x=i=>{const u=i>N;u!==t.open&&s("update:open",u)},y=i=>{const u=p-(i.clientY-_);r.value=Math.max(N,Math.min(window.innerHeight*.8,u)),x(r.value)},a=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",a),document.body.style.cursor=k,document.body.style.userSelect=w,m.value=!1,r.value<=N&&(r.value=$,s("update:open",!1))},n=i=>{i.preventDefault(),m.value=!0,_=i.clientY,t.open?p=r.value:(s("update:open",!0),r.value=N,p=N),k=document.body.style.cursor,w=document.body.style.userSelect,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",a)};e.onBeforeUnmount(a);const v=e.computed({get:()=>t.modelValue,set:i=>s("update:modelValue",i)});e.watch(()=>t.modelValue,i=>{i||s("logsTabActive",!1)},{immediate:!0});const o=e.computed(()=>d.buildDebugResultNodeItems(t.pipelineTree,t.context?.nodes,t.mockNodeIds)),b=e.computed(()=>t.mockNodeIds.has(t.modelValue)),h=e.computed(()=>t.pipelineTree?.activities?.[t.modelValue]?.component),B=e.computed(()=>{const i=o.value.find(u=>u.id===t.modelValue);return i?.type==="ServiceActivity"&&i.isConfigured}),R=()=>{!t.hasGlobalRun||t.viewParamsPending||s("viewParams")},T=()=>{t.modelValue&&s("reEditMock",t.modelValue)},f=()=>{t.modelValue&&s("runReal",t.modelValue)},l=()=>{t.modelValue&&s("runMock",t.modelValue)};return(i,u)=>{const S=e.resolveComponent("bk-button"),E=e.resolveDirective("bk-tooltips");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["debug-result-drawer-wrapper",{"is-resizing":m.value}]),style:e.normalizeStyle(V.value)},[e.createElementVNode("div",{class:"debug-result-drawer__resize",onMousedown:n},null,32),e.createElementVNode("section",{class:e.normalizeClass(["debug-result-drawer",{"is-collapsed":!t.open}])},[e.createElementVNode("header",te,[e.createElementVNode("div",oe,[u[3]||(u[3]=e.createElementVNode("span",{class:"debug-result-drawer__title"},"调试结果",-1)),u[4]||(u[4]=e.createElementVNode("span",{class:"debug-result-drawer__divider"},null,-1)),e.withDirectives((e.openBlock(),e.createBlock(S,{text:"",theme:"primary",disabled:!t.hasGlobalRun,loading:t.viewParamsPending,onClick:R},{default:e.withCtx(()=>[...u[2]||(u[2]=[e.createElementVNode("i",{class:"bkflow-canvas-icon bkflow-canvas-audit view-params-icon"},null,-1),e.createTextVNode(" 查看参数 ",-1)])]),_:1},8,["disabled","loading"])),[[E,{content:"请先进行调试",disabled:t.hasGlobalRun}]])]),e.createElementVNode("span",{class:"debug-result-drawer__collapse",onClick:C},[e.createElementVNode("span",null,e.toDisplayString(t.open?"收起":"展开"),1),e.createElementVNode("i",{class:e.normalizeClass(["bkflow-canvas-icon bkflow-canvas-arrows-down debug-result-drawer__collapse-icon",{"is-expanded":t.open}])},null,2)])]),e.createElementVNode("div",le,[e.createElementVNode("div",se,[e.createVNode(H,{modelValue:v.value,"onUpdate:modelValue":u[0]||(u[0]=M=>v.value=M),nodes:o.value},null,8,["modelValue","nodes"]),e.createElementVNode("div",ne,[t.modelValue?(e.openBlock(),e.createBlock(ee,{key:0,result:t.result,component:h.value,"is-mock":b.value,"can-run-node-debug":B.value,onReEditMock:T,onRunReal:f,onRunMock:l,onLogsTabActive:u[1]||(u[1]=M=>s("logsTabActive",M))},null,8,["result","component","is-mock","can-run-node-debug"])):(e.openBlock(),e.createElementBlock("div",ae," 请先选择节点查看调试详情 "))])])])],2)],6)}}}),re=d._export_sfc(ue,[["__scopeId","data-v-84a5277a"]]);exports.default=re;
@@ -0,0 +1,234 @@
1
+ import { defineComponent as A, ref as V, shallowRef as x, computed as C, watch as U, resolveComponent as j, resolveDirective as K, openBlock as l, createBlock as f, createSlots as S, withCtx as y, withDirectives as G, createElementBlock as d, createElementVNode as i, createCommentVNode as v, Fragment as H, renderList as J, toDisplayString as B, unref as Y, createVNode as R, createTextVNode as E } from "vue";
2
+ import { c as _, u as z, i as M, b as Q, d as W, g as X, D as Z, B as ee, R as te, E as ae, _ as oe } from "./index-CQUL1ICn.js";
3
+ import "bkui-vue/lib/message";
4
+ import "bkui-vue/lib/icon";
5
+ import "monaco-editor";
6
+ const se = {
7
+ string: "input",
8
+ text: "input",
9
+ textarea: "textarea",
10
+ int: "input",
11
+ integer: "input",
12
+ number: "input",
13
+ float: "input",
14
+ json: "json",
15
+ object: "json",
16
+ array: "array",
17
+ list: "array",
18
+ select: "select",
19
+ time: "timepicker",
20
+ datetime: "timepicker"
21
+ }, L = (a) => a.replace(/^\$\{(.+)\}$/, "$1"), I = (a) => `\${${L(a)}}`;
22
+ function ne(a, c) {
23
+ const s = I(a.key), o = c ? _(c) : {}, p = a.custom_type ?? o.custom_type ?? se[a.type] ?? "input";
24
+ return {
25
+ ...o,
26
+ key: s,
27
+ name: a.name ?? o.name ?? L(a.key),
28
+ custom_type: p,
29
+ desc: o.desc ?? "",
30
+ index: o.index ?? 0,
31
+ show_type: "show",
32
+ source_info: o.source_info ?? {},
33
+ source_tag: o.source_tag ?? "",
34
+ source_type: o.source_type ?? "custom",
35
+ validation: o.validation ?? "",
36
+ value: a.default ?? o.value,
37
+ meta: {
38
+ ...o.meta ?? {},
39
+ required: a.required ?? o.meta?.required ?? !1
40
+ }
41
+ };
42
+ }
43
+ function le(a, c = {}) {
44
+ if (!a) return {};
45
+ const s = a.constants;
46
+ return s && Object.keys(s).length > 0 ? { ...s } : Array.isArray(a.fields) && a.fields.length > 0 ? a.fields.reduce((o, p) => {
47
+ const n = I(p.key);
48
+ return o[n] = ne(p, c[n]), o;
49
+ }, {}) : {};
50
+ }
51
+ const ie = { class: "global-debug-input" }, re = {
52
+ key: 0,
53
+ class: "global-debug-input__params",
54
+ "data-test": "input-params"
55
+ }, ue = { key: 0 }, de = ["title"], ce = { class: "col-value" }, pe = {
56
+ key: 1,
57
+ class: "global-debug-input__value"
58
+ }, me = {
59
+ key: 1,
60
+ class: "form-params-wrapper"
61
+ }, fe = { class: "sideslider-footer-buttons" }, ye = /* @__PURE__ */ A({
62
+ __name: "index",
63
+ props: {
64
+ show: { type: Boolean },
65
+ schema: {},
66
+ pipelineConstants: { default: () => ({}) },
67
+ initialValues: { default: () => ({}) },
68
+ pending: { type: Boolean, default: !1 },
69
+ readonly: { type: Boolean, default: !1 }
70
+ },
71
+ emits: ["confirm", "close", "update:show"],
72
+ setup(a, { emit: c }) {
73
+ const s = a, o = c, p = z(), n = V({}), b = x([]), m = x([]), g = x(!1), h = V(), k = V(), w = C(() => b.value.filter((e) => M(e))), O = C(() => w.value.length > 0 || m.value.length > 0), F = C(
74
+ () => [...b.value].sort((e, t) => (e.index ?? 0) - (t.index ?? 0)).map((e) => {
75
+ const t = Object.prototype.hasOwnProperty.call(n.value, e.key) ? n.value[e.key] : e.value;
76
+ return {
77
+ key: e.key,
78
+ name: e.name || e.key,
79
+ value: t,
80
+ display: W(t),
81
+ isComplex: Q(t)
82
+ };
83
+ })
84
+ );
85
+ U(
86
+ () => s.show,
87
+ (e) => {
88
+ e && (n.value = _(s.initialValues ?? {}), q());
89
+ }
90
+ );
91
+ const q = async () => {
92
+ const e = le(s.schema, s.pipelineConstants), t = Object.values(e).filter(
93
+ (r) => typeof r == "object" && r !== null && r.show_type === "show"
94
+ );
95
+ if (b.value = t, s.readonly || Object.keys(e).length < 1) {
96
+ m.value = [];
97
+ return;
98
+ }
99
+ g.value = !0;
100
+ try {
101
+ m.value = await X(p, e);
102
+ } catch (r) {
103
+ console.error("Failed to build debug input forms from schema:", r), m.value = [];
104
+ } finally {
105
+ g.value = !1;
106
+ }
107
+ }, N = (e) => {
108
+ n.value = { ...n.value, ..._(e) };
109
+ }, P = async () => {
110
+ const [e, t] = await Promise.all([
111
+ Promise.resolve(
112
+ typeof k.value?.validate == "function" ? k.value.validate() : !0
113
+ ),
114
+ Promise.resolve(typeof h.value?.validate == "function" ? h.value.validate() : !0)
115
+ ]);
116
+ !e || !t || o("confirm", _(n.value));
117
+ }, D = () => {
118
+ o("close"), o("update:show", !1);
119
+ };
120
+ return (e, t) => {
121
+ const r = j("bk-button"), T = j("bk-sideslider"), $ = K("bkloading");
122
+ return l(), f(T, {
123
+ title: "调试参数",
124
+ "is-show": s.show,
125
+ width: 960,
126
+ "quick-close": !0,
127
+ "esc-close": !1,
128
+ onClosed: D
129
+ }, S({
130
+ default: y(() => [
131
+ G((l(), d("div", ie, [
132
+ s.readonly ? (l(), d("table", re, [
133
+ t[2] || (t[2] = i("thead", null, [
134
+ i("tr", null, [
135
+ i("th", { class: "col-name" }, "参数名"),
136
+ i("th", { class: "col-value" }, "参数值")
137
+ ])
138
+ ], -1)),
139
+ i("tbody", null, [
140
+ F.value.length === 0 ? (l(), d("tr", ue, [...t[1] || (t[1] = [
141
+ i("td", {
142
+ class: "global-debug-input__empty",
143
+ colspan: "2"
144
+ }, "暂无参数", -1)
145
+ ])])) : v("", !0),
146
+ (l(!0), d(H, null, J(F.value, (u) => (l(), d("tr", {
147
+ key: u.key,
148
+ "data-test": "input-row"
149
+ }, [
150
+ i("td", {
151
+ class: "col-name",
152
+ title: u.key
153
+ }, B(u.name), 9, de),
154
+ i("td", ce, [
155
+ u.isComplex ? (l(), f(Z, {
156
+ key: 0,
157
+ value: u.value,
158
+ "data-test": "json-viewer"
159
+ }, null, 8, ["value"])) : (l(), d("pre", pe, B(u.display), 1))
160
+ ])
161
+ ]))), 128))
162
+ ])
163
+ ])) : (l(), d("div", me, [
164
+ w.value.length > 0 ? (l(), f(Y(ee), {
165
+ key: 0,
166
+ ref_key: "builtinVariableFormRef",
167
+ ref: k,
168
+ modelValue: n.value,
169
+ "onUpdate:modelValue": t[0] || (t[0] = (u) => n.value = u),
170
+ variables: w.value
171
+ }, null, 8, ["modelValue", "variables"])) : v("", !0),
172
+ m.value.length > 0 ? (l(), f(te, {
173
+ key: 1,
174
+ ref_key: "renderFormRef",
175
+ ref: h,
176
+ scheme: m.value,
177
+ editable: "",
178
+ "form-option": {
179
+ showRequired: !0,
180
+ showGroup: !0,
181
+ showLabel: !1,
182
+ showHook: !1,
183
+ showDesc: !0,
184
+ formEdit: !0
185
+ },
186
+ "form-data": n.value,
187
+ onChange: N
188
+ }, null, 8, ["scheme", "form-data"])) : v("", !0),
189
+ O.value ? v("", !0) : (l(), f(ae, {
190
+ key: 2,
191
+ title: "暂无参数"
192
+ }))
193
+ ]))
194
+ ])), [
195
+ [$, { loading: g.value }]
196
+ ])
197
+ ]),
198
+ _: 2
199
+ }, [
200
+ s.readonly ? void 0 : {
201
+ name: "footer",
202
+ fn: y(() => [
203
+ i("div", fe, [
204
+ R(r, {
205
+ theme: "primary",
206
+ "data-test": "save-and-run",
207
+ loading: s.pending,
208
+ onClick: P
209
+ }, {
210
+ default: y(() => [...t[3] || (t[3] = [
211
+ E(" 保存并执行 ", -1)
212
+ ])]),
213
+ _: 1
214
+ }, 8, ["loading"]),
215
+ R(r, {
216
+ disabled: s.pending,
217
+ onClick: D
218
+ }, {
219
+ default: y(() => [...t[4] || (t[4] = [
220
+ E("取消", -1)
221
+ ])]),
222
+ _: 1
223
+ }, 8, ["disabled"])
224
+ ])
225
+ ]),
226
+ key: "0"
227
+ }
228
+ ]), 1032, ["is-show"]);
229
+ };
230
+ }
231
+ }), ke = /* @__PURE__ */ oe(ye, [["__scopeId", "data-v-01a33593"]]);
232
+ export {
233
+ ke as default
234
+ };
@@ -0,0 +1,162 @@
1
+ import { defineComponent as q, ref as f, shallowRef as J, computed as x, watch as P, resolveComponent as p, resolveDirective as U, openBlock as l, createBlock as v, withCtx as i, withDirectives as z, createElementBlock as y, Fragment as A, renderList as W, createVNode as b, createCommentVNode as g, createElementVNode as V, createTextVNode as C, toDisplayString as M } from "vue";
2
+ import { InfoBox as X } from "bkui-vue/lib";
3
+ import G from "bkui-vue/lib/message";
4
+ import { u as H, c as K, M as Q, p as Z, m as $, h as ee, r as T, f as te, a as oe, _ as se } from "./index-CQUL1ICn.js";
5
+ const ae = {
6
+ key: 0,
7
+ class: "mock-data-sideslider__title-sep"
8
+ }, ne = ["title"], le = { class: "mock-data-sideslider" }, re = { class: "mock-data-sideslider__footer" }, ce = "当前节点的输出不支持mock,是否需要在调试时跳过当前节点?", ie = "跳过调试", ue = /* @__PURE__ */ q({
9
+ __name: "index",
10
+ props: {
11
+ show: { type: Boolean },
12
+ node: { default: null },
13
+ outputs: { default: () => ({}) },
14
+ pending: { type: Boolean, default: !1 }
15
+ },
16
+ emits: ["confirm", "close", "update:show"],
17
+ setup(O, { emit: E }) {
18
+ const t = O, _ = E, F = H(), k = f(!1), u = J([]), d = f({}), h = f({}), m = f(!1), B = x(() => m.value ? ce : "暂无输出结果"), N = x(() => m.value ? ie : "确定"), D = async () => {
19
+ if (t.node) {
20
+ k.value = !0, h.value = {}, m.value = !1;
21
+ try {
22
+ const e = await Z(F, t.node.component);
23
+ u.value = $(e.outputs ?? []), m.value = ee(e.outputs);
24
+ const o = t.outputs ?? {}, a = {};
25
+ u.value.forEach((s) => {
26
+ const r = Object.prototype.hasOwnProperty.call(o, s.key) ? o[s.key] : s.type === "object" ? {} : void 0, n = T(s);
27
+ a[s.key] = n === "json-editor" || n === "data-table" ? te(r) : r;
28
+ }), d.value = a;
29
+ } catch (e) {
30
+ console.error(e), u.value = [], d.value = {}, m.value = !1, G({ theme: "error", message: "加载输出结果失败" });
31
+ } finally {
32
+ k.value = !1;
33
+ }
34
+ }
35
+ }, S = () => {
36
+ const e = {}, o = {};
37
+ return u.value.forEach((a) => {
38
+ const s = d.value[a.key], r = T(a);
39
+ if (r === "json-editor" || r === "data-table") {
40
+ const n = oe(s);
41
+ if (!n.valid) {
42
+ e[a.key] = n.message;
43
+ return;
44
+ }
45
+ n.value !== void 0 && (o[a.key] = n.value);
46
+ return;
47
+ }
48
+ s !== void 0 && s !== "" && (o[a.key] = s);
49
+ }), { errors: e, outputs: o };
50
+ }, j = (e) => {
51
+ X({
52
+ title: "确认 Mock 输出?",
53
+ content: "Mock 输出将覆盖当前输出结果,执行时跳过该节点并以 Mock 值替代实际输出",
54
+ confirmText: "确定",
55
+ cancelText: "取消",
56
+ width: 400,
57
+ onConfirm: () => {
58
+ e();
59
+ }
60
+ });
61
+ }, Y = () => {
62
+ if (m.value) {
63
+ _("confirm", { outputs: {} });
64
+ return;
65
+ }
66
+ const { errors: e, outputs: o } = S();
67
+ h.value = e, !(Object.keys(e).length > 0) && j(() => _("confirm", { outputs: o }));
68
+ }, w = () => {
69
+ _("close"), _("update:show", !1);
70
+ };
71
+ return P(
72
+ () => [t.show, t.node?.id],
73
+ ([e]) => {
74
+ e && t.node && (d.value = K(t.outputs ?? {}), D());
75
+ },
76
+ { immediate: !0 }
77
+ ), (e, o) => {
78
+ const a = p("bk-form-item"), s = p("bk-form"), r = p("bk-exception"), n = p("bk-button"), I = p("bk-sideslider"), L = U("bkloading");
79
+ return l(), v(I, {
80
+ "is-show": t.show,
81
+ width: 960,
82
+ "quick-close": "",
83
+ "esc-close": !1,
84
+ onClosed: w
85
+ }, {
86
+ header: i(() => [
87
+ o[0] || (o[0] = V("span", { class: "mock-data-sideslider__title" }, "Mock输出", -1)),
88
+ t.node?.name ? (l(), y("span", ae, "-")) : g("", !0),
89
+ t.node?.name ? (l(), y("span", {
90
+ key: 1,
91
+ class: "mock-data-sideslider__title-node",
92
+ title: t.node.name
93
+ }, M(t.node.name), 9, ne)) : g("", !0)
94
+ ]),
95
+ footer: i(() => [
96
+ V("div", re, [
97
+ b(n, {
98
+ theme: "primary",
99
+ "data-test": "mock-confirm",
100
+ loading: t.pending,
101
+ onClick: Y
102
+ }, {
103
+ default: i(() => [
104
+ C(M(N.value), 1)
105
+ ]),
106
+ _: 1
107
+ }, 8, ["loading"]),
108
+ b(n, {
109
+ disabled: t.pending,
110
+ onClick: w
111
+ }, {
112
+ default: i(() => [...o[1] || (o[1] = [
113
+ C("取消", -1)
114
+ ])]),
115
+ _: 1
116
+ }, 8, ["disabled"])
117
+ ])
118
+ ]),
119
+ default: i(() => [
120
+ z((l(), y("div", le, [
121
+ u.value.length > 0 ? (l(), v(s, {
122
+ key: 0,
123
+ "form-type": "vertical",
124
+ "label-width": 120,
125
+ "data-test": "mock-outputs-form"
126
+ }, {
127
+ default: i(() => [
128
+ (l(!0), y(A, null, W(u.value, (c) => (l(), v(a, {
129
+ key: c.key,
130
+ label: c.name || c.key
131
+ }, {
132
+ default: i(() => [
133
+ b(Q, {
134
+ modelValue: d.value[c.key],
135
+ "onUpdate:modelValue": (R) => d.value[c.key] = R,
136
+ field: c,
137
+ error: h.value[c.key]
138
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "field", "error"])
139
+ ]),
140
+ _: 2
141
+ }, 1032, ["label"]))), 128))
142
+ ]),
143
+ _: 1
144
+ })) : k.value ? g("", !0) : (l(), v(r, {
145
+ key: 1,
146
+ class: "mock-data-sideslider__exception",
147
+ scene: "part",
148
+ type: "empty",
149
+ title: B.value
150
+ }, null, 8, ["title"]))
151
+ ])), [
152
+ [L, { loading: k.value }]
153
+ ])
154
+ ]),
155
+ _: 1
156
+ }, 8, ["is-show"]);
157
+ };
158
+ }
159
+ }), ke = /* @__PURE__ */ se(ue, [["__scopeId", "data-v-c4e2476a"]]);
160
+ export {
161
+ ke as default
162
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),M=require("bkui-vue/lib"),N=require("bkui-vue/lib/message"),s=require("./index-D301MshF.cjs"),O={key:0,class:"mock-data-sideslider__title-sep"},F=["title"],S={class:"mock-data-sideslider"},D={class:"mock-data-sideslider__footer"},j="当前节点的输出不支持mock,是否需要在调试时跳过当前节点?",q="跳过调试",Y=e.defineComponent({__name:"index",props:{show:{type:Boolean},node:{default:null},outputs:{default:()=>({})},pending:{type:Boolean,default:!1}},emits:["confirm","close","update:show"],setup(f,{emit:y}){const o=f,p=y,h=s.useFlowApiConfig(),k=e.ref(!1),u=e.shallowRef([]),d=e.ref({}),_=e.ref({}),m=e.ref(!1),b=e.computed(()=>m.value?j:"暂无输出结果"),C=e.computed(()=>m.value?q:"确定"),w=async()=>{if(o.node){k.value=!0,_.value={},m.value=!1;try{const t=await s.pluginDetailRequest(h,o.node.component);u.value=s.mergeOutputs(t.outputs??[]),m.value=s.hasOnlySystemOutputs(t.outputs);const n=o.outputs??{},a={};u.value.forEach(l=>{const c=Object.prototype.hasOwnProperty.call(n,l.key)?n[l.key]:l.type==="object"?{}:void 0,r=s.resolveMockFormControl(l);a[l.key]=r==="json-editor"||r==="data-table"?s.formatJsonFieldValue(c):c}),d.value=a}catch(t){console.error(t),u.value=[],d.value={},m.value=!1,N({theme:"error",message:"加载输出结果失败"})}finally{k.value=!1}}},g=()=>{const t={},n={};return u.value.forEach(a=>{const l=d.value[a.key],c=s.resolveMockFormControl(a);if(c==="json-editor"||c==="data-table"){const r=s.parseJsonFieldValue(l);if(!r.valid){t[a.key]=r.message;return}r.value!==void 0&&(n[a.key]=r.value);return}l!==void 0&&l!==""&&(n[a.key]=l)}),{errors:t,outputs:n}},x=t=>{M.InfoBox({title:"确认 Mock 输出?",content:"Mock 输出将覆盖当前输出结果,执行时跳过该节点并以 Mock 值替代实际输出",confirmText:"确定",cancelText:"取消",width:400,onConfirm:()=>{t()}})},V=()=>{if(m.value){p("confirm",{outputs:{}});return}const{errors:t,outputs:n}=g();_.value=t,!(Object.keys(t).length>0)&&x(()=>p("confirm",{outputs:n}))},v=()=>{p("close"),p("update:show",!1)};return e.watch(()=>[o.show,o.node?.id],([t])=>{t&&o.node&&(d.value=s.cloneDeep(o.outputs??{}),w())},{immediate:!0}),(t,n)=>{const a=e.resolveComponent("bk-form-item"),l=e.resolveComponent("bk-form"),c=e.resolveComponent("bk-exception"),r=e.resolveComponent("bk-button"),B=e.resolveComponent("bk-sideslider"),E=e.resolveDirective("bkloading");return e.openBlock(),e.createBlock(B,{"is-show":o.show,width:960,"quick-close":"","esc-close":!1,onClosed:v},{header:e.withCtx(()=>[n[0]||(n[0]=e.createElementVNode("span",{class:"mock-data-sideslider__title"},"Mock输出",-1)),o.node?.name?(e.openBlock(),e.createElementBlock("span",O,"-")):e.createCommentVNode("",!0),o.node?.name?(e.openBlock(),e.createElementBlock("span",{key:1,class:"mock-data-sideslider__title-node",title:o.node.name},e.toDisplayString(o.node.name),9,F)):e.createCommentVNode("",!0)]),footer:e.withCtx(()=>[e.createElementVNode("div",D,[e.createVNode(r,{theme:"primary","data-test":"mock-confirm",loading:o.pending,onClick:V},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.value),1)]),_:1},8,["loading"]),e.createVNode(r,{disabled:o.pending,onClick:v},{default:e.withCtx(()=>[...n[1]||(n[1]=[e.createTextVNode("取消",-1)])]),_:1},8,["disabled"])])]),default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",S,[u.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(u.value,i=>(e.openBlock(),e.createBlock(a,{key:i.key,label:i.name||i.key},{default:e.withCtx(()=>[e.createVNode(s.MockFieldRenderer,{modelValue:d.value[i.key],"onUpdate:modelValue":T=>d.value[i.key]=T,field:i,error:_.value[i.key]},null,8,["modelValue","onUpdate:modelValue","field","error"])]),_:2},1032,["label"]))),128))]),_:1})):k.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(c,{key:1,class:"mock-data-sideslider__exception",scene:"part",type:"empty",title:b.value},null,8,["title"]))])),[[E,{loading:k.value}]])]),_:1},8,["is-show"])}}}),I=s._export_sfc(Y,[["__scopeId","data-v-c4e2476a"]]);exports.default=I;