@blueking/bkflow-canvas-editor 1.1.0-beta.4 → 1.1.0-beta.40

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"),s=require("./index-DvcBKeRr.cjs");require("bkui-vue/lib/message");require("bkui-vue/lib/icon");require("monaco-editor");const N={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"},h=l=>l.replace(/^\$\{(.+)\}$/,"$1"),g=l=>`\${${h(l)}}`;function F(l,c){const a=g(l.key),n=c?s.cloneDeep(c):{},d=l.custom_type??n.custom_type??N[l.type]??"input";return{...n,key:a,name:l.name??n.name??h(l.key),custom_type:d,desc:n.desc??"",index:n.index??0,show_type:"show",source_info:n.source_info??{},source_tag:n.source_tag??"",source_type:n.source_type??"custom",validation:n.validation??"",value:l.default??n.value,meta:{...n.meta??{},required:l.required??n.meta?.required??!1}}}function D(l,c={}){if(!l)return{};const a=l.constants;return a&&Object.keys(a).length>0?{...a}:Array.isArray(l.fields)&&l.fields.length>0?l.fields.reduce((n,d)=>{const r=g(d.key);return n[r]=F(d,c[r]),n},{}):{}}const j={class:"global-debug-input"},q={key:0,class:"global-debug-input__params","data-test":"input-params"},R={key:0},L=["title"],O={class:"col-value"},T={key:1,class:"global-debug-input__value"},I={key:1,class:"form-params-wrapper"},P={class:"sideslider-footer-buttons"},$=e.defineComponent({__name:"index",props:{show:{type:Boolean},schema:{},pipelineConstants:{default:()=>({})},initialValues:{default:()=>({})},pending:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1}},emits:["confirm","close","update:show"],setup(l,{emit:c}){const a=l,n=c,d=s.useFlowApiConfig(),r=e.ref({}),p=e.shallowRef([]),m=e.shallowRef([]),f=e.shallowRef(!1),y=e.ref(),v=e.ref(),k=e.computed(()=>p.value.filter(t=>s.isBuiltinUsageVariable(t))),V=e.computed(()=>k.value.length>0||m.value.length>0),b=e.computed(()=>[...p.value].sort((t,o)=>(t.index??0)-(o.index??0)).map(t=>{const o=Object.prototype.hasOwnProperty.call(r.value,t.key)?r.value[t.key]:t.value;return{key:t.key,name:t.name||t.key,value:o,display:s.formatDebugValue(o),isComplex:s.isComplexDebugValue(o)}}));e.watch(()=>a.show,t=>{t&&(r.value=s.cloneDeep(a.initialValues??{}),w())});const w=async()=>{const t=D(a.schema,a.pipelineConstants),o=Object.values(t).filter(i=>typeof i=="object"&&i!==null&&i.show_type==="show");if(p.value=o,a.readonly||Object.keys(t).length<1){m.value=[];return}f.value=!0;try{m.value=await s.getInputFormsFromConstants(d,t)}catch(i){console.error("Failed to build debug input forms from schema:",i),m.value=[]}finally{f.value=!1}},B=t=>{r.value={...r.value,...s.cloneDeep(t)}},C=async()=>{const[t,o]=await Promise.all([Promise.resolve(typeof v.value?.validate=="function"?v.value.validate():!0),Promise.resolve(typeof y.value?.validate=="function"?y.value.validate():!0)]);!t||!o||n("confirm",s.cloneDeep(r.value))},_=()=>{n("close"),n("update:show",!1)};return(t,o)=>{const i=e.resolveComponent("bk-button"),x=e.resolveComponent("bk-sideslider"),E=e.resolveDirective("bkloading");return e.openBlock(),e.createBlock(x,{title:"调试参数","is-show":a.show,width:960,"quick-close":!0,"esc-close":!1,onClosed:_},e.createSlots({default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",j,[a.readonly?(e.openBlock(),e.createElementBlock("table",q,[o[2]||(o[2]=e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[e.createElementVNode("th",{class:"col-name"},"参数名"),e.createElementVNode("th",{class:"col-value"},"参数值")])],-1)),e.createElementVNode("tbody",null,[b.value.length===0?(e.openBlock(),e.createElementBlock("tr",R,[...o[1]||(o[1]=[e.createElementVNode("td",{class:"global-debug-input__empty",colspan:"2"},"暂无参数",-1)])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,u=>(e.openBlock(),e.createElementBlock("tr",{key:u.key,"data-test":"input-row"},[e.createElementVNode("td",{class:"col-name",title:u.key},e.toDisplayString(u.name),9,L),e.createElementVNode("td",O,[u.isComplex?(e.openBlock(),e.createBlock(s.DebugJsonViewer,{key:0,value:u.value,"data-test":"json-viewer"},null,8,["value"])):(e.openBlock(),e.createElementBlock("pre",T,e.toDisplayString(u.display),1))])]))),128))])])):(e.openBlock(),e.createElementBlock("div",I,[k.value.length>0?(e.openBlock(),e.createBlock(e.unref(s.BuiltinVariableUsageForm),{key:0,ref_key:"builtinVariableFormRef",ref:v,modelValue:r.value,"onUpdate:modelValue":o[0]||(o[0]=u=>r.value=u),variables:k.value},null,8,["modelValue","variables"])):e.createCommentVNode("",!0),m.value.length>0?(e.openBlock(),e.createBlock(s.RenderForm,{key:1,ref_key:"renderFormRef",ref:y,scheme:m.value,editable:"","form-option":{showRequired:!0,showGroup:!0,showLabel:!1,showHook:!1,showDesc:!0,formEdit:!0},"form-data":r.value,onChange:B},null,8,["scheme","form-data"])):e.createCommentVNode("",!0),V.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(s.EmptyException,{key:2,title:"暂无参数"}))]))])),[[E,{loading:f.value}]])]),_:2},[a.readonly?void 0:{name:"footer",fn:e.withCtx(()=>[e.createElementVNode("div",P,[e.createVNode(i,{theme:"primary","data-test":"save-and-run",loading:a.pending,onClick:C},{default:e.withCtx(()=>[...o[3]||(o[3]=[e.createTextVNode(" 保存并执行 ",-1)])]),_:1},8,["loading"]),e.createVNode(i,{disabled:a.pending,onClick:_},{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("取消",-1)])]),_:1},8,["disabled"])])]),key:"0"}]),1032,["is-show"])}}}),S=s._export_sfc($,[["__scopeId","data-v-01a33593"]]);exports.default=S;
@@ -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-BnAo53k0.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
+ };