@blueking/bkflow-canvas-editor 1.1.0-beta.5 → 1.1.0-beta.6

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,178 @@
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-C5lTl48-.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
+ };
@@ -0,0 +1 @@
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-BoQLjwKV.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,m=f,y=r.useFlowApiConfig(),p=e.ref(!1),d=e.shallowRef([]),u=e.ref({}),k=e.ref({}),h=async()=>{if(t.node){p.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{p.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(),m("update:show",!1)}})},C=()=>{const{errors:n,outputs:o}=b();k.value=n,!(Object.keys(n).length>0)&&w(()=>m("confirm",{outputs:o}))},_=()=>{m("close"),m("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})):p.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(c,{key:1,class:"mock-data-sideslider__exception",scene:"part",type:"empty",title:"暂无输出参数"}))])),[[x,{loading:p.value}]])]),_:1},8,["is-show"])}}}),O=r._export_sfc(D,[["__scopeId","data-v-8b63ba90"]]);exports.default=O;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),p=require("lodash"),i=require("./index-BoQLjwKV.cjs");require("bkui-vue/lib/message");require("bkui-vue/lib/icon");require("monaco-editor");const q={string:"input",text:"input",textarea:"textarea",int:"input",integer:"input",number:"input",float:"input",json:"json",object:"json",array:"array",list:"array",select:"select",time:"timepicker",datetime:"timepicker"},_=t=>t.replace(/^\$\{(.+)\}$/,"$1"),k=t=>`\${${_(t)}}`;function D(t,u){const n=k(t.key),o=u?p.cloneDeep(u):{},c=t.custom_type??o.custom_type??q[t.type]??"input";return{...o,key:n,name:t.name??o.name??_(t.key),custom_type:c,desc:o.desc??"",index:o.index??0,show_type:"show",source_info:o.source_info??{},source_tag:o.source_tag??"",source_type:o.source_type??"custom",validation:o.validation??"",value:t.default??o.value,meta:{...o.meta??{},required:t.required??o.meta?.required??!1}}}function N(t,u={}){if(!t)return{};const n=t.constants;return n&&Object.keys(n).length>0?{...n}:Array.isArray(t.fields)&&t.fields.length>0?t.fields.reduce((o,c)=>{const s=k(c.key);return o[s]=D(c,u[s]),o},{}):{}}const j={class:"global-debug-input"},R={class:"form-params-wrapper"},E={class:"sideslider-footer-buttons"},T=e.defineComponent({__name:"index",props:{show:{type:Boolean},schema:{},pipelineConstants:{default:()=>({})},initialValues:{default:()=>({})},pending:{type:Boolean,default:!1}},emits:["confirm","close","update:show"],setup(t,{emit:u}){const n=t,o=u,c=i.useFlowApiConfig(),s=e.ref({}),h=e.shallowRef([]),d=e.shallowRef([]),m=e.shallowRef(!1),f=e.ref(),v=e.ref(),b=e.computed(()=>h.value.filter(a=>i.isBuiltinUsageVariable(a))),g=e.computed(()=>b.value.length>0||d.value.length>0);e.watch(()=>n.show,a=>{a&&(s.value=p.cloneDeep(n.initialValues??{}),w())});const w=async()=>{const a=N(n.schema,n.pipelineConstants),r=Object.values(a).filter(l=>typeof l=="object"&&l!==null&&l.show_type==="show");if(h.value=r,Object.keys(a).length<1){d.value=[];return}m.value=!0;try{d.value=await i.getInputFormsFromConstants(c,a)}catch(l){console.error("Failed to build debug input forms from schema:",l),d.value=[]}finally{m.value=!1}},V=a=>{s.value={...s.value,...p.cloneDeep(a)}},C=async()=>{const[a,r]=await Promise.all([Promise.resolve(typeof v.value?.validate=="function"?v.value.validate():!0),Promise.resolve(typeof f.value?.validate=="function"?f.value.validate():!0)]);!a||!r||o("confirm",p.cloneDeep(s.value))},y=()=>{o("close"),o("update:show",!1)};return(a,r)=>{const l=e.resolveComponent("bk-button"),x=e.resolveComponent("bk-sideslider"),B=e.resolveDirective("bkloading");return e.openBlock(),e.createBlock(x,{title:"调试参数","is-show":n.show,width:700,"quick-close":!0,"esc-close":!1,onClosed:y},{footer:e.withCtx(()=>[e.createElementVNode("div",E,[e.createVNode(l,{theme:"primary","data-test":"save-and-run",loading:n.pending,onClick:C},{default:e.withCtx(()=>[...r[1]||(r[1]=[e.createTextVNode(" 保存并执行 ",-1)])]),_:1},8,["loading"]),e.createVNode(l,{disabled:n.pending,onClick:y},{default:e.withCtx(()=>[...r[2]||(r[2]=[e.createTextVNode("取消",-1)])]),_:1},8,["disabled"])])]),default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",R,[b.value.length>0?(e.openBlock(),e.createBlock(e.unref(i.BuiltinVariableUsageForm),{key:0,ref_key:"builtinVariableFormRef",ref:v,modelValue:s.value,"onUpdate:modelValue":r[0]||(r[0]=F=>s.value=F),variables:b.value,editable:!0},null,8,["modelValue","variables"])):e.createCommentVNode("",!0),d.value.length>0?(e.openBlock(),e.createBlock(i.RenderForm,{key:1,ref_key:"renderFormRef",ref:f,scheme:d.value,editable:!0,"form-option":{showRequired:!0,showGroup:!0,showLabel:!1,showHook:!1,showDesc:!0,formEdit:!0},"form-data":s.value,onChange:V},null,8,["scheme","form-data"])):e.createCommentVNode("",!0),g.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(i.EmptyException,{key:2,title:"暂无参数"}))])])),[[B,{loading:m.value}]])]),_:1},8,["is-show"])}}}),I=i._export_sfc(T,[["__scopeId","data-v-e0e948eb"]]);exports.default=I;