@blueking/bkflow-canvas-editor 1.1.0-beta.2 → 1.1.0-beta.21

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,235 @@
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 { cloneDeep as _ } from "lodash";
3
+ import { u as z, i as M, b as Q, c as W, g as X, D as Z, B as ee, R as te, E as ae, _ as oe } from "./index-DUOfuLCl.js";
4
+ import "bkui-vue/lib/message";
5
+ import "bkui-vue/lib/icon";
6
+ import "monaco-editor";
7
+ const se = {
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
+ }, L = (a) => a.replace(/^\$\{(.+)\}$/, "$1"), I = (a) => `\${${L(a)}}`;
23
+ function ne(a, c) {
24
+ const s = I(a.key), o = c ? _(c) : {}, p = a.custom_type ?? o.custom_type ?? se[a.type] ?? "input";
25
+ return {
26
+ ...o,
27
+ key: s,
28
+ name: a.name ?? o.name ?? L(a.key),
29
+ custom_type: p,
30
+ desc: o.desc ?? "",
31
+ index: o.index ?? 0,
32
+ show_type: "show",
33
+ source_info: o.source_info ?? {},
34
+ source_tag: o.source_tag ?? "",
35
+ source_type: o.source_type ?? "custom",
36
+ validation: o.validation ?? "",
37
+ value: a.default ?? o.value,
38
+ meta: {
39
+ ...o.meta ?? {},
40
+ required: a.required ?? o.meta?.required ?? !1
41
+ }
42
+ };
43
+ }
44
+ function le(a, c = {}) {
45
+ if (!a) return {};
46
+ const s = a.constants;
47
+ return s && Object.keys(s).length > 0 ? { ...s } : Array.isArray(a.fields) && a.fields.length > 0 ? a.fields.reduce((o, p) => {
48
+ const n = I(p.key);
49
+ return o[n] = ne(p, c[n]), o;
50
+ }, {}) : {};
51
+ }
52
+ const ie = { class: "global-debug-input" }, re = {
53
+ key: 0,
54
+ class: "global-debug-input__params",
55
+ "data-test": "input-params"
56
+ }, ue = { key: 0 }, de = ["title"], ce = { class: "col-value" }, pe = {
57
+ key: 1,
58
+ class: "global-debug-input__value"
59
+ }, me = {
60
+ key: 1,
61
+ class: "form-params-wrapper"
62
+ }, fe = { class: "sideslider-footer-buttons" }, ye = /* @__PURE__ */ A({
63
+ __name: "index",
64
+ props: {
65
+ show: { type: Boolean },
66
+ schema: {},
67
+ pipelineConstants: { default: () => ({}) },
68
+ initialValues: { default: () => ({}) },
69
+ pending: { type: Boolean, default: !1 },
70
+ readonly: { type: Boolean, default: !1 }
71
+ },
72
+ emits: ["confirm", "close", "update:show"],
73
+ setup(a, { emit: c }) {
74
+ 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(
75
+ () => [...b.value].sort((e, t) => (e.index ?? 0) - (t.index ?? 0)).map((e) => {
76
+ const t = Object.prototype.hasOwnProperty.call(n.value, e.key) ? n.value[e.key] : e.value;
77
+ return {
78
+ key: e.key,
79
+ name: e.name || e.key,
80
+ value: t,
81
+ display: W(t),
82
+ isComplex: Q(t)
83
+ };
84
+ })
85
+ );
86
+ U(
87
+ () => s.show,
88
+ (e) => {
89
+ e && (n.value = _(s.initialValues ?? {}), q());
90
+ }
91
+ );
92
+ const q = async () => {
93
+ const e = le(s.schema, s.pipelineConstants), t = Object.values(e).filter(
94
+ (r) => typeof r == "object" && r !== null && r.show_type === "show"
95
+ );
96
+ if (b.value = t, s.readonly || Object.keys(e).length < 1) {
97
+ m.value = [];
98
+ return;
99
+ }
100
+ g.value = !0;
101
+ try {
102
+ m.value = await X(p, e);
103
+ } catch (r) {
104
+ console.error("Failed to build debug input forms from schema:", r), m.value = [];
105
+ } finally {
106
+ g.value = !1;
107
+ }
108
+ }, N = (e) => {
109
+ n.value = { ...n.value, ..._(e) };
110
+ }, P = async () => {
111
+ const [e, t] = await Promise.all([
112
+ Promise.resolve(
113
+ typeof k.value?.validate == "function" ? k.value.validate() : !0
114
+ ),
115
+ Promise.resolve(typeof h.value?.validate == "function" ? h.value.validate() : !0)
116
+ ]);
117
+ !e || !t || o("confirm", _(n.value));
118
+ }, D = () => {
119
+ o("close"), o("update:show", !1);
120
+ };
121
+ return (e, t) => {
122
+ const r = j("bk-button"), T = j("bk-sideslider"), $ = K("bkloading");
123
+ return l(), f(T, {
124
+ title: "调试参数",
125
+ "is-show": s.show,
126
+ width: 960,
127
+ "quick-close": !0,
128
+ "esc-close": !1,
129
+ onClosed: D
130
+ }, S({
131
+ default: y(() => [
132
+ G((l(), d("div", ie, [
133
+ s.readonly ? (l(), d("table", re, [
134
+ t[2] || (t[2] = i("thead", null, [
135
+ i("tr", null, [
136
+ i("th", { class: "col-name" }, "参数名"),
137
+ i("th", { class: "col-value" }, "参数值")
138
+ ])
139
+ ], -1)),
140
+ i("tbody", null, [
141
+ F.value.length === 0 ? (l(), d("tr", ue, [...t[1] || (t[1] = [
142
+ i("td", {
143
+ class: "global-debug-input__empty",
144
+ colspan: "2"
145
+ }, "暂无参数", -1)
146
+ ])])) : v("", !0),
147
+ (l(!0), d(H, null, J(F.value, (u) => (l(), d("tr", {
148
+ key: u.key,
149
+ "data-test": "input-row"
150
+ }, [
151
+ i("td", {
152
+ class: "col-name",
153
+ title: u.key
154
+ }, B(u.name), 9, de),
155
+ i("td", ce, [
156
+ u.isComplex ? (l(), f(Z, {
157
+ key: 0,
158
+ value: u.value,
159
+ "data-test": "json-viewer"
160
+ }, null, 8, ["value"])) : (l(), d("pre", pe, B(u.display), 1))
161
+ ])
162
+ ]))), 128))
163
+ ])
164
+ ])) : (l(), d("div", me, [
165
+ w.value.length > 0 ? (l(), f(Y(ee), {
166
+ key: 0,
167
+ ref_key: "builtinVariableFormRef",
168
+ ref: k,
169
+ modelValue: n.value,
170
+ "onUpdate:modelValue": t[0] || (t[0] = (u) => n.value = u),
171
+ variables: w.value
172
+ }, null, 8, ["modelValue", "variables"])) : v("", !0),
173
+ m.value.length > 0 ? (l(), f(te, {
174
+ key: 1,
175
+ ref_key: "renderFormRef",
176
+ ref: h,
177
+ scheme: m.value,
178
+ editable: "",
179
+ "form-option": {
180
+ showRequired: !0,
181
+ showGroup: !0,
182
+ showLabel: !1,
183
+ showHook: !1,
184
+ showDesc: !0,
185
+ formEdit: !0
186
+ },
187
+ "form-data": n.value,
188
+ onChange: N
189
+ }, null, 8, ["scheme", "form-data"])) : v("", !0),
190
+ O.value ? v("", !0) : (l(), f(ae, {
191
+ key: 2,
192
+ title: "暂无参数"
193
+ }))
194
+ ]))
195
+ ])), [
196
+ [$, { loading: g.value }]
197
+ ])
198
+ ]),
199
+ _: 2
200
+ }, [
201
+ s.readonly ? void 0 : {
202
+ name: "footer",
203
+ fn: y(() => [
204
+ i("div", fe, [
205
+ R(r, {
206
+ theme: "primary",
207
+ "data-test": "save-and-run",
208
+ loading: s.pending,
209
+ onClick: P
210
+ }, {
211
+ default: y(() => [...t[3] || (t[3] = [
212
+ E(" 保存并执行 ", -1)
213
+ ])]),
214
+ _: 1
215
+ }, 8, ["loading"]),
216
+ R(r, {
217
+ disabled: s.pending,
218
+ onClick: D
219
+ }, {
220
+ default: y(() => [...t[4] || (t[4] = [
221
+ E("取消", -1)
222
+ ])]),
223
+ _: 1
224
+ }, 8, ["disabled"])
225
+ ])
226
+ ]),
227
+ key: "0"
228
+ }
229
+ ]), 1032, ["is-show"]);
230
+ };
231
+ }
232
+ }), we = /* @__PURE__ */ oe(ye, [["__scopeId", "data-v-95858958"]]);
233
+ export {
234
+ we as default
235
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),p=require("lodash"),r=require("./index-j9vPPW5D.cjs");require("bkui-vue/lib/message");require("bkui-vue/lib/icon");require("monaco-editor");const F={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"},g=l=>l.replace(/^\$\{(.+)\}$/,"$1"),V=l=>`\${${g(l)}}`;function D(l,c){const a=V(l.key),n=c?p.cloneDeep(c):{},d=l.custom_type??n.custom_type??F[l.type]??"input";return{...n,key:a,name:l.name??n.name??g(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 j(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 s=V(d.key);return n[s]=D(d,c[s]),n},{}):{}}const q={class:"global-debug-input"},R={key:0,class:"global-debug-input__params","data-test":"input-params"},L={key:0},O=["title"],T={class:"col-value"},I={key:1,class:"global-debug-input__value"},P={key:1,class:"form-params-wrapper"},$={class:"sideslider-footer-buttons"},S=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=r.useFlowApiConfig(),s=e.ref({}),f=e.shallowRef([]),m=e.shallowRef([]),y=e.shallowRef(!1),v=e.ref(),k=e.ref(),b=e.computed(()=>f.value.filter(t=>r.isBuiltinUsageVariable(t))),w=e.computed(()=>b.value.length>0||m.value.length>0),_=e.computed(()=>[...f.value].sort((t,o)=>(t.index??0)-(o.index??0)).map(t=>{const o=Object.prototype.hasOwnProperty.call(s.value,t.key)?s.value[t.key]:t.value;return{key:t.key,name:t.name||t.key,value:o,display:r.formatDebugValue(o),isComplex:r.isComplexDebugValue(o)}}));e.watch(()=>a.show,t=>{t&&(s.value=p.cloneDeep(a.initialValues??{}),B())});const B=async()=>{const t=j(a.schema,a.pipelineConstants),o=Object.values(t).filter(i=>typeof i=="object"&&i!==null&&i.show_type==="show");if(f.value=o,a.readonly||Object.keys(t).length<1){m.value=[];return}y.value=!0;try{m.value=await r.getInputFormsFromConstants(d,t)}catch(i){console.error("Failed to build debug input forms from schema:",i),m.value=[]}finally{y.value=!1}},C=t=>{s.value={...s.value,...p.cloneDeep(t)}},x=async()=>{const[t,o]=await Promise.all([Promise.resolve(typeof k.value?.validate=="function"?k.value.validate():!0),Promise.resolve(typeof v.value?.validate=="function"?v.value.validate():!0)]);!t||!o||n("confirm",p.cloneDeep(s.value))},h=()=>{n("close"),n("update:show",!1)};return(t,o)=>{const i=e.resolveComponent("bk-button"),E=e.resolveComponent("bk-sideslider"),N=e.resolveDirective("bkloading");return e.openBlock(),e.createBlock(E,{title:"调试参数","is-show":a.show,width:960,"quick-close":!0,"esc-close":!1,onClosed:h},e.createSlots({default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",q,[a.readonly?(e.openBlock(),e.createElementBlock("table",R,[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,[_.value.length===0?(e.openBlock(),e.createElementBlock("tr",L,[...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(_.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,O),e.createElementVNode("td",T,[u.isComplex?(e.openBlock(),e.createBlock(r.DebugJsonViewer,{key:0,value:u.value,"data-test":"json-viewer"},null,8,["value"])):(e.openBlock(),e.createElementBlock("pre",I,e.toDisplayString(u.display),1))])]))),128))])])):(e.openBlock(),e.createElementBlock("div",P,[b.value.length>0?(e.openBlock(),e.createBlock(e.unref(r.BuiltinVariableUsageForm),{key:0,ref_key:"builtinVariableFormRef",ref:k,modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=u=>s.value=u),variables:b.value},null,8,["modelValue","variables"])):e.createCommentVNode("",!0),m.value.length>0?(e.openBlock(),e.createBlock(r.RenderForm,{key:1,ref_key:"renderFormRef",ref:v,scheme:m.value,editable:"","form-option":{showRequired:!0,showGroup:!0,showLabel:!1,showHook:!1,showDesc:!0,formEdit:!0},"form-data":s.value,onChange:C},null,8,["scheme","form-data"])):e.createCommentVNode("",!0),w.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(r.EmptyException,{key:2,title:"暂无参数"}))]))])),[[N,{loading:y.value}]])]),_:2},[a.readonly?void 0:{name:"footer",fn:e.withCtx(()=>[e.createElementVNode("div",$,[e.createVNode(i,{theme:"primary","data-test":"save-and-run",loading:a.pending,onClick:x},{default:e.withCtx(()=>[...o[3]||(o[3]=[e.createTextVNode(" 保存并执行 ",-1)])]),_:1},8,["loading"]),e.createVNode(i,{disabled:a.pending,onClick:h},{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("取消",-1)])]),_:1},8,["disabled"])])]),key:"0"}]),1032,["is-show"])}}}),A=r._export_sfc(S,[["__scopeId","data-v-95858958"]]);exports.default=A;