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

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"),p=require("lodash"),i=require("./index-DOcgB3JP.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 a=k(t.key),o=u?p.cloneDeep(u):{},c=t.custom_type??o.custom_type??q[t.type]??"input";return{...o,key:a,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 a=t.constants;return a&&Object.keys(a).length>0?{...a}:Array.isArray(t.fields)&&t.fields.length>0?t.fields.reduce((o,c)=>{const l=k(c.key);return o[l]=D(c,u[l]),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},readonly:{type:Boolean,default:!1}},emits:["confirm","close","update:show"],setup(t,{emit:u}){const a=t,o=u,c=i.useFlowApiConfig(),l=e.ref({}),b=e.shallowRef([]),d=e.shallowRef([]),m=e.shallowRef(!1),f=e.ref(),v=e.ref(),y=e.computed(()=>b.value.filter(n=>i.isBuiltinUsageVariable(n))),g=e.computed(()=>y.value.length>0||d.value.length>0);e.watch(()=>a.show,n=>{n&&(l.value=p.cloneDeep(a.initialValues??{}),w())});const w=async()=>{const n=N(a.schema,a.pipelineConstants),s=Object.values(n).filter(r=>typeof r=="object"&&r!==null&&r.show_type==="show");if(b.value=s,Object.keys(n).length<1){d.value=[];return}m.value=!0;try{d.value=await i.getInputFormsFromConstants(c,n)}catch(r){console.error("Failed to build debug input forms from schema:",r),d.value=[]}finally{m.value=!1}},V=n=>{l.value={...l.value,...p.cloneDeep(n)}},C=async()=>{const[n,s]=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)]);!n||!s||o("confirm",p.cloneDeep(l.value))},h=()=>{o("close"),o("update:show",!1)};return(n,s)=>{const r=e.resolveComponent("bk-button"),x=e.resolveComponent("bk-sideslider"),B=e.resolveDirective("bkloading");return e.openBlock(),e.createBlock(x,{title:"调试参数","is-show":a.show,width:700,"quick-close":!0,"esc-close":!1,onClosed:h},e.createSlots({default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",R,[y.value.length>0?(e.openBlock(),e.createBlock(e.unref(i.BuiltinVariableUsageForm),{key:0,ref_key:"builtinVariableFormRef",ref:v,modelValue:l.value,"onUpdate:modelValue":s[0]||(s[0]=F=>l.value=F),variables:y.value,editable:!a.readonly},null,8,["modelValue","variables","editable"])):e.createCommentVNode("",!0),d.value.length>0?(e.openBlock(),e.createBlock(i.RenderForm,{key:1,ref_key:"renderFormRef",ref:f,scheme:d.value,editable:!a.readonly,"form-option":{showRequired:!0,showGroup:!0,showLabel:!1,showHook:!1,showDesc:!0,formEdit:!a.readonly},"form-data":l.value,onChange:V},null,8,["scheme","editable","form-option","form-data"])):e.createCommentVNode("",!0),g.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(i.EmptyException,{key:2,title:"暂无参数"}))])])),[[B,{loading:m.value}]])]),_:2},[a.readonly?void 0:{name:"footer",fn:e.withCtx(()=>[e.createElementVNode("div",E,[e.createVNode(r,{theme:"primary","data-test":"save-and-run",loading:a.pending,onClick:C},{default:e.withCtx(()=>[...s[1]||(s[1]=[e.createTextVNode(" 保存并执行 ",-1)])]),_:1},8,["loading"]),e.createVNode(r,{disabled:a.pending,onClick:h},{default:e.withCtx(()=>[...s[2]||(s[2]=[e.createTextVNode("取消",-1)])]),_:1},8,["disabled"])])]),key:"0"}]),1032,["is-show"])}}}),I=i._export_sfc(T,[["__scopeId","data-v-767dae0e"]]);exports.default=I;
@@ -0,0 +1,159 @@
1
+ import { defineComponent as T, ref as y, shallowRef as q, watch as I, resolveComponent as m, resolveDirective as J, openBlock as l, createBlock as k, withCtx as i, withDirectives as U, createElementBlock as _, Fragment as z, renderList as A, createVNode as b, createCommentVNode as h, createElementVNode as w, createTextVNode as V, toDisplayString as L } from "vue";
2
+ import { InfoBox as P } from "bkui-vue/lib";
3
+ import S from "bkui-vue/lib/message";
4
+ import { cloneDeep as W } from "lodash";
5
+ import { u as G, M as H, p as K, m as Q, r as x, f as X, a as Y, _ as Z } from "./index-C16qU3Yx.js";
6
+ const $ = {
7
+ key: 0,
8
+ class: "mock-data-sideslider__title-sep"
9
+ }, ee = ["title"], oe = { class: "mock-data-sideslider" }, te = { class: "mock-data-sideslider__footer" }, se = /* @__PURE__ */ T({
10
+ __name: "index",
11
+ props: {
12
+ show: { type: Boolean },
13
+ node: { default: null },
14
+ outputs: { default: () => ({}) },
15
+ pending: { type: Boolean, default: !1 }
16
+ },
17
+ emits: ["confirm", "close", "update:show"],
18
+ setup(C, { emit: F }) {
19
+ const o = C, f = F, M = G(), p = y(!1), d = q([]), u = y({}), v = y({}), B = async () => {
20
+ if (o.node) {
21
+ p.value = !0, v.value = {};
22
+ try {
23
+ const t = await K(M, o.node.component);
24
+ d.value = Q(t.outputs ?? []);
25
+ const e = o.outputs ?? {}, a = {};
26
+ d.value.forEach((s) => {
27
+ const r = Object.prototype.hasOwnProperty.call(e, s.key) ? e[s.key] : s.type === "object" ? {} : void 0, n = x(s);
28
+ a[s.key] = n === "json-editor" || n === "data-table" ? X(r) : r;
29
+ }), u.value = a;
30
+ } catch (t) {
31
+ console.error(t), d.value = [], u.value = {}, S({ theme: "error", message: "加载输出参数失败" });
32
+ } finally {
33
+ p.value = !1;
34
+ }
35
+ }
36
+ }, D = () => {
37
+ const t = {}, e = {};
38
+ return d.value.forEach((a) => {
39
+ const s = u.value[a.key], r = x(a);
40
+ if (r === "json-editor" || r === "data-table") {
41
+ const n = Y(s);
42
+ if (!n.valid) {
43
+ t[a.key] = n.message;
44
+ return;
45
+ }
46
+ n.value !== void 0 && (e[a.key] = n.value);
47
+ return;
48
+ }
49
+ s !== void 0 && s !== "" && (e[a.key] = s);
50
+ }), { errors: t, outputs: e };
51
+ }, j = (t) => {
52
+ P({
53
+ title: "确认 Mock 输出?",
54
+ content: "Mock 输出将覆盖当前输出参数,执行时跳过该节点并以 Mock 值替代实际输出",
55
+ confirmText: "确定",
56
+ cancelText: "取消",
57
+ width: 400,
58
+ onConfirm: () => {
59
+ t();
60
+ }
61
+ });
62
+ }, E = () => {
63
+ const { errors: t, outputs: e } = D();
64
+ v.value = t, !(Object.keys(t).length > 0) && j(() => f("confirm", { outputs: e }));
65
+ }, g = () => {
66
+ f("close"), f("update:show", !1);
67
+ };
68
+ return I(
69
+ () => [o.show, o.node?.id],
70
+ ([t]) => {
71
+ t && o.node && (u.value = W(o.outputs ?? {}), B());
72
+ },
73
+ { immediate: !0 }
74
+ ), (t, e) => {
75
+ const a = m("bk-form-item"), s = m("bk-form"), r = m("bk-exception"), n = m("bk-button"), N = m("bk-sideslider"), O = J("bkloading");
76
+ return l(), k(N, {
77
+ "is-show": o.show,
78
+ width: 640,
79
+ "quick-close": "",
80
+ "esc-close": !1,
81
+ onClosed: g
82
+ }, {
83
+ header: i(() => [
84
+ e[0] || (e[0] = w("span", { class: "mock-data-sideslider__title" }, "Mock输出", -1)),
85
+ o.node?.name ? (l(), _("span", $, "-")) : h("", !0),
86
+ o.node?.name ? (l(), _("span", {
87
+ key: 1,
88
+ class: "mock-data-sideslider__title-node",
89
+ title: o.node.name
90
+ }, L(o.node.name), 9, ee)) : h("", !0)
91
+ ]),
92
+ footer: i(() => [
93
+ w("div", te, [
94
+ b(n, {
95
+ theme: "primary",
96
+ "data-test": "mock-confirm",
97
+ loading: o.pending,
98
+ onClick: E
99
+ }, {
100
+ default: i(() => [...e[1] || (e[1] = [
101
+ V(" 确定 ", -1)
102
+ ])]),
103
+ _: 1
104
+ }, 8, ["loading"]),
105
+ b(n, {
106
+ disabled: o.pending,
107
+ onClick: g
108
+ }, {
109
+ default: i(() => [...e[2] || (e[2] = [
110
+ V("取消", -1)
111
+ ])]),
112
+ _: 1
113
+ }, 8, ["disabled"])
114
+ ])
115
+ ]),
116
+ default: i(() => [
117
+ U((l(), _("div", oe, [
118
+ d.value.length > 0 ? (l(), k(s, {
119
+ key: 0,
120
+ "form-type": "vertical",
121
+ "label-width": 120,
122
+ "data-test": "mock-outputs-form"
123
+ }, {
124
+ default: i(() => [
125
+ (l(!0), _(z, null, A(d.value, (c) => (l(), k(a, {
126
+ key: c.key,
127
+ label: c.name || c.key
128
+ }, {
129
+ default: i(() => [
130
+ b(H, {
131
+ modelValue: u.value[c.key],
132
+ "onUpdate:modelValue": (R) => u.value[c.key] = R,
133
+ field: c,
134
+ error: v.value[c.key]
135
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "field", "error"])
136
+ ]),
137
+ _: 2
138
+ }, 1032, ["label"]))), 128))
139
+ ]),
140
+ _: 1
141
+ })) : p.value ? h("", !0) : (l(), k(r, {
142
+ key: 1,
143
+ class: "mock-data-sideslider__exception",
144
+ scene: "part",
145
+ type: "empty",
146
+ title: "暂无输出参数"
147
+ }))
148
+ ])), [
149
+ [O, { loading: p.value }]
150
+ ])
151
+ ]),
152
+ _: 1
153
+ }, 8, ["is-show"]);
154
+ };
155
+ }
156
+ }), ie = /* @__PURE__ */ Z(se, [["__scopeId", "data-v-bccecd7f"]]);
157
+ export {
158
+ ie as default
159
+ };