@tachybase/module-workflow 0.23.48 → 0.23.58

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.
Files changed (31) hide show
  1. package/dist/client/features/dynamic-calculation/DynamicCalculation.d.ts +12 -0
  2. package/dist/client/features/loop/LoopInstruction.d.ts +12 -0
  3. package/dist/client/features/parallel/ParallelInstruction.d.ts +12 -0
  4. package/dist/client/features/request/RequestInstruction.d.ts +1 -2
  5. package/dist/client/features/sql/SQLInstruction.d.ts +12 -0
  6. package/dist/client/features/variables/VariablesInstruction.d.ts +12 -0
  7. package/dist/client/index.js +10 -10
  8. package/dist/client/nodes/calculation.d.ts +12 -0
  9. package/dist/client/nodes/condition.d.ts +12 -0
  10. package/dist/client/nodes/end.d.ts +12 -0
  11. package/dist/client/variable.d.ts +1 -5
  12. package/dist/externalVersion.js +15 -15
  13. package/dist/locale/en-US.json +2 -0
  14. package/dist/locale/zh-CN.json +2 -0
  15. package/dist/node_modules/@babel/core/package.json +1 -1
  16. package/dist/node_modules/cron-parser/package.json +1 -1
  17. package/dist/node_modules/form-data/package.json +1 -1
  18. package/dist/node_modules/jsonata/package.json +1 -1
  19. package/dist/node_modules/lru-cache/package.json +1 -1
  20. package/dist/node_modules/mime-types/package.json +1 -1
  21. package/dist/node_modules/qrcode/package.json +1 -1
  22. package/dist/server/Plugin.js +21 -12
  23. package/dist/server/Processor.d.ts +1 -0
  24. package/dist/server/Processor.js +2 -1
  25. package/package.json +17 -17
  26. package/dist/server/features/webhook/Plugin.d.ts +0 -4
  27. package/dist/server/features/webhook/Plugin.js +0 -109
  28. package/dist/server/features/webhook/index.d.ts +0 -1
  29. package/dist/server/features/webhook/index.js +0 -27
  30. package/dist/server/features/webhook/webhooks.d.ts +0 -9
  31. package/dist/server/features/webhook/webhooks.js +0 -286
@@ -414,7 +414,7 @@
414
414
  `}));function Xe(e){var n;const{styles:t}=rr();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:i,color:a}=e.statusMap[e.status];o=r.jsx(x.Tag,{color:a,children:i})}return r.jsx(x.Button,I(v({},e),{shape:"circle",size:"small",className:s.cx(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const de={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},pt=[{value:de.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(j.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:de.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(j.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:de.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(j.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:de.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:de.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:de.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(j.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:de.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:de.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:de.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(j.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],ut=pt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});var ye=(e=>(e[e.PENDING=0]="PENDING",e[e.RESOLVED=1]="RESOLVED",e[e.FAILED=-1]="FAILED",e[e.ERROR=-2]="ERROR",e[e.ABORTED=-3]="ABORTED",e[e.CANCELED=-4]="CANCELED",e[e.REJECTED=-5]="REJECTED",e[e.RETRY_NEEDED=-6]="RETRY_NEEDED",e))(ye||{});const mt=[{value:0,label:`{{t("Pending", { ns: "${m}" })}}`,color:"#FFD92D",icon:r.jsx(s.Icon,{type:"HistoryOutlined"})},{value:1,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"#2DCD22",icon:r.jsx(s.Icon,{type:"CheckOutlined"})},{value:-1,label:`{{t("Failed", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"ExclamationOutlined"})},{value:-2,label:`{{t("Error", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"CloseOutlined"})},{value:-3,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"#F45353",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:90})},{value:-4,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined",rotate:45})},{value:-5,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"MinusOutlined"})},{value:-6,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(s.Icon,{type:"RedoOutlined"})}],Re=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});function ft(e){const t=new Map;e.forEach(o=>t.set(o.id,o));for(const o of t.values())o.upstreamId&&(o.upstream=t.get(o.upstreamId)),o.downstreamId&&(o.downstream=t.get(o.downstreamId))}function ht(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return ht(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[i]=Object.keys(o[n]);return!(!i||typeof o[n][i]=="undefined")}):!1}function gt(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{gt(e.properties[o],t)})}function Be(e){return`/_admin/business-components/workflow/${e}/workflow`}function yt(e){return`/_admin/business-components/workflow/${e}/executions`}function sr(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const i=o.get(n.nodeId);i.jobs.push(n),n.node={id:i.id,key:i.key,title:i.title,type:i.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((i,a)=>i.id-a.id)})}function ir(){const{instructions:e}=s.usePlugin(Z),t=s.useCompile(),{viewJob:o,setViewJob:n}=q();if(!o)return;o.cost=tr(o.cost/1e3);const{styles:i}=ge(),{node:a={}}=o!=null?o:{},l=e.get(a.type);return r.jsx(s.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`${o==null?void 0:o.id}-${o==null?void 0:o.updatedAt}-modal`]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:I(v({},o),{result:JSON.stringify(o.result,null,2)})},"x-component":"Action.Modal",title:r.jsxs("div",{className:i.nodeTitleClass,children:[r.jsx(x.Tag,{children:t(l==null?void 0:l.title)}),r.jsx("strong",{children:a.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",a.id]})]}),properties:{status:{type:"number",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select",enum:mt,"x-read-pretty":!0},updatedAt:{type:"string",title:`{{t("Executed at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},cost:{type:"string",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input","x-read-pretty":!0},result:{type:"string",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CodeMirror","x-component-props":{defaultLanguage:"json"},"x-read-pretty":!0},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{copy:{type:"void",title:'{{t("Duplicate")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:c}=X.useTranslation();return{run(){return O(this,null,function*(){try{const p=JSON.stringify(o.result,null,2);yield navigator.clipboard.writeText(p),x.message.success(c("Copied"))}catch(p){x.message.error(c("Copy failed"))}})}}}}}}}}}}}})})}function ar(e){const{execution:t}=q(),o=s.useAPIClient(),n=oe.useNavigate(),{styles:i}=ge(),[a,l]=b.useState([]),[c,d]=b.useState([]);b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$lt:t.id}},sort:"-createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{l(u.data)}).catch(()=>{})},[t]),b.useEffect(()=>{t&&o.resource("executions").list({filter:{key:t.key,id:{$gt:t.id}},sort:"createdAt",pageSize:10,fields:["id","status","createdAt"]}).then(({data:u})=>{d(u.data.reverse())}).catch(()=>{})},[t]);const p=b.useCallback(({key:u})=>{u!==t.id&&n(yt(u))},[t]);return t?r.jsx(x.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:s.cx(i.dropdownClass,i.executionsDropdownRowClass),items:[...c,t,...a].map(u=>({key:u.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${u.id}`}),r.jsx("time",{children:W.str2moment(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Xe,{statusMap:ut,status:u.status})})}))},children:r.jsxs(x.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(j.DownOutlined,{})]})}):null}function lr(){var C;const{t:e}=X.useTranslation(),t=s.useCompile(),{data:o,loading:n,refresh:i}=s.useResourceActionContext(),{setTitle:a}=s.useDocumentTitle(),[l,c]=b.useState(null),d=s.useApp(),p=s.useAPIClient();b.useEffect(()=>{var B;const{workflow:P}=(B=o==null?void 0:o.data)!=null?B:{};a==null||a(`${P!=null&&P.title?`${P.title} - `:""}${F("Execution history")}`)},[o==null?void 0:o.data]);const u=b.useCallback(()=>{x.Modal.confirm({title:F("Cancel the execution"),icon:r.jsx(j.ExclamationCircleFilled,{}),content:F("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{x.message.success(e("Operation succeeded")),i()}).catch(P=>{console.error(P.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(x.Spin,{}):r.jsx(x.Result,{status:"404",title:"Not found"});const D=(C=o==null?void 0:o.data)!=null?C:{},{jobs:f=[],workflow:$={}}=D,E=$,{nodes:h=[],revisions:g=[]}=E,y=K(E,["nodes","revisions"]),w=K(D,["jobs","workflow"]);ft(h),sr(h,f);const A=h.find(P=>!P.upstream),T=ut[w.status];return r.jsxs(qe.Provider,{value:{workflow:y.type?y:null,nodes:h,execution:w,viewJob:l,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(go,{}),r.jsx(x.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:d.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx(oe.Link,{to:Be(y.id),children:y.title})},{title:r.jsx(ar,{})}]})]}),r.jsxs("aside",{children:[r.jsx(x.Tag,{color:T.color,children:t(T.label)}),w.status?null:r.jsx(x.Tooltip,{title:F("Cancel the execution"),children:r.jsx(x.Button,{type:"link",danger:!0,onClick:u,shape:"circle",size:"small",icon:r.jsx(j.StopOutlined,{})})}),r.jsx("time",{children:W.str2moment(w.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(ho,{entry:A}),r.jsx(ir,{})]})}const yo=()=>{const e=oe.useParams(),{styles:t}=ge();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`execution_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"executions",fields:[]},resourceName:"executions",request:{resource:"executions",action:"get",params:{filter:e,appends:["jobs","workflow","workflow.nodes"]}}},"x-component":"ExecutionCanvas"}}},components:{ExecutionCanvas:lr}})})};function cr(e){return["hasMany","belongsToMany"].includes(e.type)}function dr(){const e=s.useCompile();return[xt,bt].map(t=>{var n;const o=(n=t.useOptions({types:[cr],appends:null,depth:4}))==null?void 0:n.filter(Boolean);return{label:e(t.label),value:t.value,key:t.value,children:e(o),disabled:o&&!o.length}})}function pr(n){var i=n,{value:e,onChange:t}=i,o=K(i,["value","onChange"]);const{setValuesIn:a}=S.useForm(),{getCollection:l}=s.useCollectionManager_deprecated(),c=dr(),[d,p]=b.useState(c),{associatedKey:u="",name:f}=e!=null?e:{};let h=[];const g=u.match(/^{{(.*)}}$/);g&&(h=[...g[1].trim().split(".").slice(0,-1),f]);const y=A=>O(this,null,function*(){var C;const T=A[A.length-1];!((C=T.children)!=null&&C.length)&&!T.isLeaf&&T.loadChildren&&(yield T.loadChildren(T),p(D=>[...D]))});b.useEffect(()=>{O(this,null,function*(){var C;if(!h||d.length<=1)return;let T=null;for(let D=0;D<h.length;D++){const $=h[D];try{D===0?T=d.find(E=>E.value===$):(T.loadChildren&&!((C=T.children)!=null&&C.length)&&(yield T.loadChildren(T)),T=T.children.find(E=>E.value===$))}catch(E){console.error(E)}}p([...d])})},[e,d.length]);const w=b.useCallback((A,T)=>{if(!(A!=null&&A.length)){a("collection",null),t({});return}const{field:C}=T.pop();if(!C||!["hasMany","belongsToMany"].includes(C.type))return;const{collectionName:D,target:$,name:E,dataSourceKey:P}=C,_=l(D,P).fields.find(z=>z.primaryKey);a("collection",`${P}:${$}`),t({name:E,associatedKey:`{{${A.slice(0,-1).join(".")}.${_.name}}}`,associatedCollection:s.joinCollectionName(P,D)})},[t]);return r.jsx(x.Cascader,I(v({},o),{value:h,options:d,changeOnSelect:!0,onChange:w,loadData:y}))}class ur extends Q{constructor(){super(...arguments),this.title=`{{t("Aggregate", { ns: "${m}" })}}`,this.type="aggregate",this.group="collection",this.icon="SearchOutlined",this.color="#19e8aa",this.description=`{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${m}" })}}`,this.fieldset={aggregator:{type:"string",title:`{{t("Aggregator function", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:"count"},associated:{type:"boolean",title:`{{t("Target type", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Data of collection", { ns: "${m}" })}}`,value:!1},{label:`{{t("Data of associated collection", { ns: "${m}" })}}`,value:!0}],required:!0,default:!1,"x-reactions":[{target:"collection",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"association",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",title:`{{t("Data of collection", { ns: "${m}" })}}`,"x-reactions":[{dependencies:["associated"],fulfill:{state:{display:'{{$deps[0] ? "hidden" : "visible"}}'}}},{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}]},association:{type:"object",title:`{{t("Data of associated collection", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AssociatedConfig","x-component-props":{changeOnSelect:!0},"x-reactions":[{dependencies:["associated"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],required:!0}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:`{{t("Field to aggregate", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{filter(t){return!t.hidden&&t.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean",title:`{{t("Distinct", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}]},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:t}=S.useForm(),[o,n]=s.parseCollectionName(t==null?void 0:t.collection);return{options:s.useCollectionFilterOptions(n,o),className:s.css`
415
415
  position: relative;
416
416
  width: 100%;
417
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:De,FieldsSelect:et,ValueBlock:Se,AssociatedConfig:pr}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var n;const o=F("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:o}:null}}class mr extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",ur)})}}const xo=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function fr(e){return xo.slice().reverse().find(t=>!(e%t.value))}function hr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=fr(e),i=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(x.InputNumber,{min:1,value:i,onChange:a=>t(Math.round(a*n.value)),className:"auto-width"}),r.jsx(x.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:a=>t(Math.round(i*a)),className:"auto-width",options:xo.map(a=>({value:a.value,label:o(a.label)}))})]})}class gr extends Q{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",this.description=`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`,this.fieldset={duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:ye.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:ye.FAILED}],required:!0,default:ye.RESOLVED}},this.components={Duration:hr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}class yr extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",gr)})}}function xr(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function br({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),i=le({types:[xr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:i})}class vr extends Q{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",this.description=`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`,this.fieldset={expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}}},this.components={DynamicExpression:br,WorkflowVariableInput:ke,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:F("Calculation result")}}}const wr=S.observer(e=>{const{onChange:t}=e,o=S.useField(),n=S.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=b.useState(n.getValuesIn(a)),d=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();S.useFormEffects(()=>{S.onFormInitialValuesChange(f=>{c(f.getValuesIn(a))}),S.onFieldInputValueChange(a,f=>{c(f.value),t(null)})});const u=ue({collection:l,compile:d,getCollectionFields:p});return r.jsx(s.Variable.TextArea,I(v({},e),{scope:u}))},{displayName:"InternalExpression"});function Cr(e){const{t}=X.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=b.useMemo(()=>ue({collection:o.sourceCollection,compile:n,getCollectionFields:i}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,I(v({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:m})})}const kr=S.connect(wr,S.mapReadPretty(Cr)),{defaultProps:Sr}=s.interfacesProperties;class Ar extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=v({},Sr)}}class Ir extends s.Plugin{load(){return O(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([Ar]),this.app.addComponents({DynamicExpression:kr});const t=this.app.pm.get("workflow"),o=new vr;t.instructions.register(o.type,o)})}}function Fr(n){var i=n,{collection:e,dataPath:t}=i,o=K(i,["collection","dataPath"]);const{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[f,h]=s.parseCollectionName(e);p=c(h,f)}else p=e;function u(h){return O(this,arguments,function*({item:f}){const g=f.template?yield l(f):null,y={type:"void",name:S.uid(),title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};gt(y,w=>{w["x-uid"]&&delete w["x-uid"]}),a(y)})}return r.jsx(s.SchemaInitializerItem,I(v({},o),{onClick:u,items:d}))}function Te(e){var a;const t=s.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,i;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],i=l[1]}else i=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:i,children:r.jsx(Fr,v(v({},t),e))})}function Tr(e){const{execution:t,nodes:o}=q(),n=b.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),i=b.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return b.useMemo(()=>fe.get(i,e),[i,e])}function Vt({collection:e,dataPath:t,children:o}){const n=S.useField(),i=b.useRef(null),{getAssociationAppends:a}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=Tr(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const f=b.useMemo(()=>S.createForm({values:d,readPretty:!0}),[d]),h={appends:l},g={loading:!1,data:{data:d}},w=s.useAPIClient().resource(u),A=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:g,resource:w,__parent:A},children:r.jsx(s.FormBlockContext.Provider,{value:{params:h,form:f,field:n,service:g,updateAssociationValues:c,formBlockRef:i},children:o})})})})}function Nr(){return!0}const et=S.observer(e=>{const p=e,{filter:t=Nr}=p,o=K(p,["filter"]),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),{values:a}=S.useForm(),[l,c]=s.parseCollectionName(a==null?void 0:a.collection),d=i(c,l);return r.jsx(x.Select,I(v({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(u=>{var f;return{label:n((f=u.uiSchema)==null?void 0:f.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Dr(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}const pe={label:"label",value:"value",children:"children"},bo={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var a;const t=he(),n=s.usePlugin(Z).instructions.get(t.type);return((a=n.useCurrentFormVariables)==null?void 0:a.call(n,t,e))||[]}},xt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(Z),o=he(),n=Ee(o),i=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&i.push(c)}),i}},bt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var i,a;const{triggers:t}=s.usePlugin(Z),{workflow:o}=q(),n=t.get(o.type);return(a=(i=n==null?void 0:n.useVariables)==null?void 0:i.call(n,o.config,e))!=null?a:null}},Wt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=pe,current:o}=e,{instructions:n}=s.usePlugin(Z),i=he(),a=o!=null?o:i,l=Dr(a),c=[];return l.forEach(d=>{var f,h;const p=n.get(d.type),u=(f=p.useScopeVariables)==null?void 0:f.call(p,d,e);u&&c.push({key:d.key,[t.value]:d.key,[t.label]:(h=d.title)!=null?h:`#${d.id}`,[t.children]:u})}),c}},vo={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=pe}){return!e||e.includes("date")?[{key:"now",[t.label]:F("System time"),[t.value]:"now"}]:[]}},Ne={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function wo(e,t){var o,n,i,a,l,c;return typeof t=="string"?(o=Ne[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?jt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((i=t.options)==null?void 0:i.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function jt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function zt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Lt({fields:e,types:t,appends:o,depth:n=1,compile:i,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>wo(l,d)):!0;if(jt(l)){if(o===null)return n?c||Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:i,getCollectionFields:a}):!1;const d=zt(l,o),p=o.includes(l.name);return c?p:((d==null?void 0:d.length)||p)&&Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,appends:d,compile:i,getCollectionFields:a}).length}else return c})}function tt(e,t){var a,l;const o=s.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:i}=t;return{[i.label]:o(e.label),[i.value]:e.value,key:e[i.value],[i.children]:n,disabled:!n||!n.length}}function le(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(Wt,o),tt(xt,o),tt(bt,o),tt(vo,o)]}function Co(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(bo,o)]}function qt(e,{compile:t,getCollectionFields:o}){var d,p,u,f,h,g,y;const[n,i]=s.parseCollectionName(e),a=o(i,n),l=[],c=[];a.forEach(w=>{w.isForeignKey?l.push(w):c.push(w)});for(let w=c.length-1;w>=0;w--){const A=c[w];if(A.type==="belongsTo"){const T=l.find(C=>C.name===A.foreignKey);T?c.splice(w,0,I(v(v({},A),T),{uiSchema:I(v({},A.uiSchema),{title:(d=A.uiSchema)!=null&&d.title?`${t((p=A.uiSchema)==null?void 0:p.title)} ID`:T.name})})):c.splice(w,0,I(v({},A),{name:A.foreignKey,type:"bigInt",isForeignKey:!0,interface:A.interface,uiSchema:I(v({},A.uiSchema),{title:(u=A.uiSchema)!=null&&u.title?`${t((f=A.uiSchema)==null?void 0:f.title)} ID`:A.name})}))}else if(A.type==="context"&&A.collectionName==="users"){const T=(h=c.find(C=>C.type==="belongsTo"&&C.target==="users"&&C.foreignKey===A.name))!=null?h:{};c.splice(w,0,I(v({},A),{type:A.dataType,interface:T.interface,uiSchema:I(v({},T.uiSchema),{title:(g=T.uiSchema)!=null&&g.title?`${t((y=T.uiSchema)==null?void 0:y.title)} ID`:A.name})}))}}return c.filter(w=>w.interface&&!w.hidden)}function Or(e){const t=zt(e.field,e.appends),o=ue(v({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(i=>wo(e.field,i))||(e.disabled=!0))}function ue(e){const{fields:t,collection:o,types:n,appends:i=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=pe}=e,p=t!=null?t:qt(o,{compile:l,getCollectionFields:c}),u=Or.bind({compile:l,getCollectionFields:c,fieldNames:d});return Lt({fields:p,types:n,depth:a,appends:i,compile:l,getCollectionFields:c}).map(h=>{var A;const g=l(((A=h.uiSchema)==null?void 0:A.title)||h.name),y=zt(h,i),w=!jt(h)||y&&!y.length&&!i.includes(h.name)||!1;return{[d.label]:g,key:h.name,[d.value]:h.name,isLeaf:w,loadChildren:w?null:u,field:h,depth:a,appends:i,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.Input,v({scope:i},t))}function ot(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.TextArea,v({scope:i},t))}function ko(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.RawTextArea,v({scope:i},t))}function So(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.JSON,v({scope:i},t))}function Pr(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const{options:i=[]}=t,a=Co(e),l=le(e);return r.jsx(s.Variable.CodeMirror,v({scope:[...a,...l,...i]},t))}function De({value:e,onChange:t,renderSchemaComponent:o}){const n=le();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Oe(e){const a=e,{options:t=[],direction:o}=a,n=K(a,["options","direction"]),i=s.useCompile();return r.jsx(x.Radio.Group,I(v({},n),{children:r.jsx(x.Space,{direction:o,children:t.map(l=>r.jsxs(x.Radio,{value:l.value,children:[r.jsx("span",{className:s.css`
417
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={SchemaComponentContext:s.SchemaComponentContext,FilterDynamicComponent:De,FieldsSelect:et,ValueBlock:Se,AssociatedConfig:pr}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var n;const o=F("Query result");return t.config.collection?{name:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:o}:null}}class mr extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("aggregate",ur)})}}const xo=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function fr(e){return xo.slice().reverse().find(t=>!(e%t.value))}function hr({value:e=6e4,onChange:t}){const o=s.useCompile(),n=fr(e),i=Math.round(e/n.value);return r.jsxs("fieldset",{style:{display:"flex",gap:"0.5em"},children:[r.jsx(x.InputNumber,{min:1,value:i,onChange:a=>t(Math.round(a*n.value)),className:"auto-width"}),r.jsx(x.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:n.value,onChange:a=>t(Math.round(i*a)),className:"auto-width",options:xo.map(a=>({value:a.value,label:o(a.label)}))})]})}class gr extends Q{constructor(){super(...arguments),this.title=`{{t("Delay", { ns: "${m}" })}}`,this.type="delay",this.group="control",this.icon="ClockCircleOutlined",this.color="#cf9247",this.description=`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${m}" })}}`,this.fieldset={duration:{type:"number",title:`{{t("Duration", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${m}" })}}`,value:ye.RESOLVED},{label:`{{t("Fail and exit", { ns: "${m}" })}}`,value:ye.FAILED}],required:!0,default:ye.RESOLVED}},this.components={Duration:hr}}isAvailable({engine:t,workflow:o,upstream:n,branchIndex:i}){return!t.isWorkflowSync(o)}}class yr extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",gr)})}}function xr(e){var o;return["belongsTo","hasOne"].includes(e.type)?((o=this.getCollection(e.collectionName))==null?void 0:o.template)==="expression"?!0:this.getCollectionFields(e.target).some(n=>n.interface==="expression"):!1}function br({value:e,onChange:t}){const{getCollectionFields:o,getCollection:n}=s.useCollectionManager_deprecated(),i=le({types:[xr.bind({getCollectionFields:o,getCollection:n})]});return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:i})}class vr extends Q{constructor(){super(...arguments),this.title=`{{t("Dynamic Calculation", { ns: "${m}" })}}`,this.type="dynamic-calculation",this.group="extended",this.icon="CalculatorOutlined",this.color="#2f79b9",this.description=`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression is dynamic one from an expression collections.", { ns: "${m}" })}}`,this.fieldset={expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DynamicExpression",required:!0},scope:{type:"string",title:`{{t("Variable datasource", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,variableOptions:{types:[{type:"reference",options:{collection:"*",entity:!0}}]}},"x-reactions":{dependencies:["expression"],fulfill:{state:{visible:"{{$deps[0]}}"}}}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={DynamicExpression:br,WorkflowVariableInput:ke,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o;return{name:`#${t.id}`,type:"item",title:(o=t.title)!=null?o:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:F("Calculation result")}}}const wr=S.observer(e=>{const{onChange:t}=e,o=S.useField(),n=S.useForm(),a=[...o.path.segments.slice(0,-1),"sourceCollection"].join("."),[l,c]=b.useState(n.getValuesIn(a)),d=s.useCompile(),{getCollectionFields:p}=s.useCollectionManager_deprecated();S.useFormEffects(()=>{S.onFormInitialValuesChange(f=>{c(f.getValuesIn(a))}),S.onFieldInputValueChange(a,f=>{c(f.value),t(null)})});const u=ue({collection:l,compile:d,getCollectionFields:p});return r.jsx(s.Variable.TextArea,I(v({},e),{scope:u}))},{displayName:"InternalExpression"});function Cr(e){const{t}=X.useTranslation(),o=s.useRecord(),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=b.useMemo(()=>ue({collection:o.sourceCollection,compile:n,getCollectionFields:i}),[o.sourceCollection,o.sourceCollection]);return e.value?r.jsx(s.Variable.TextArea,I(v({},e),{scope:a})):r.jsx(x.Tag,{children:t("Unconfigured",{ns:m})})}const kr=S.connect(wr,S.mapReadPretty(Cr)),{defaultProps:Sr}=s.interfacesProperties;class Ar extends s.CollectionFieldInterface{constructor(){super(...arguments),this.name="expression",this.type="string",this.group="advanced",this.order=1,this.title=`{{t("Expression", { ns: "${m}" })}}`,this.description=`{{t("Used to store expressions for use in workflows so that different expressions can be called for different data.", { ns: "${m}" })}}`,this.sortable=!0,this.default={type:"text",uiSchema:{"x-component":"DynamicExpression"}},this.properties=v({},Sr)}}class Ir extends s.Plugin{load(){return O(this,null,function*(){this.app.dataSourceManager.addFieldInterfaces([Ar]),this.app.addComponents({DynamicExpression:kr});const t=this.app.pm.get("workflow"),o=new vr;t.instructions.register(o.type,o)})}}function Fr(n){var i=n,{collection:e,dataPath:t}=i,o=K(i,["collection","dataPath"]);const{insert:a}=s.useSchemaInitializer(),{getTemplateSchemaByMode:l}=s.useSchemaTemplateManager(),{getCollection:c}=s.useCollectionManager_deprecated(),d=s.useRecordCollectionDataSourceItems("FormItem");let p;if(typeof e=="string"){const[f,h]=s.parseCollectionName(e);p=c(h,f)}else p=e;function u(h){return O(this,arguments,function*({item:f}){const g=f.template?yield l(f):null,y={type:"void",name:S.uid(),title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataPath:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:{grid:g||{type:"void","x-component":"Grid","x-initializer":"details:configureFields",properties:{}}}}}};gt(y,w=>{w["x-uid"]&&delete w["x-uid"]}),a(y)})}return r.jsx(s.SchemaInitializerItem,I(v({},o),{onClick:u,items:d}))}function Te(e){var a;const t=s.useSchemaInitializerItem(),o=(a=e==null?void 0:e.collection)!=null?a:t.collection;let n,i;if(typeof o=="string"){const l=s.parseCollectionName(o);n=l[0],i=l[1]}else i=o;return r.jsx(s.CollectionProvider_deprecated,{dataSource:n,collection:i,children:r.jsx(Fr,v(v({},t),e))})}function Tr(e){const{execution:t,nodes:o}=q(),n=b.useMemo(()=>o.reduce((l,c)=>Object.assign(l,{[c.id]:c.key}),{}),[o]),i=b.useMemo(()=>{var l;return{$context:t==null?void 0:t.context,$jobsMapByNodeKey:((l=t==null?void 0:t.jobs)!=null?l:[]).reduce((c,d)=>Object.assign(c,{[n[d.nodeId]]:d.result}),{})}},[t==null?void 0:t.context,t==null?void 0:t.jobs,n]);return b.useMemo(()=>fe.get(i,e),[i,e])}function Vt({collection:e,dataPath:t,children:o}){const n=S.useField(),i=b.useRef(null),{getAssociationAppends:a}=s.useAssociationNames(),{appends:l,updateAssociationValues:c}=a(),d=Tr(t);let p,u;if(typeof e=="string"){const T=s.parseCollectionName(e);p=T[0],u=T[1]}else u=e;const f=b.useMemo(()=>S.createForm({values:d,readPretty:!0}),[d]),h={appends:l},g={loading:!1,data:{data:d}},w=s.useAPIClient().resource(u),A=s.useBlockRequestContext();return r.jsx(s.CollectionProvider_deprecated,{dataSource:p,collection:u,children:r.jsx(s.RecordProvider,{record:d,parent:null,children:r.jsx(s.BlockRequestContext_deprecated.Provider,{value:{block:"form",field:n,service:g,resource:w,__parent:A},children:r.jsx(s.FormBlockContext.Provider,{value:{params:h,form:f,field:n,service:g,updateAssociationValues:c,formBlockRef:i},children:o})})})})}function Nr(){return!0}const et=S.observer(e=>{const p=e,{filter:t=Nr}=p,o=K(p,["filter"]),n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),{values:a}=S.useForm(),[l,c]=s.parseCollectionName(a==null?void 0:a.collection),d=i(c,l);return r.jsx(x.Select,I(v({popupMatchSelectWidth:!1},o),{options:d.filter(t).map(u=>{var f;return{label:n((f=u.uiSchema)==null?void 0:f.title),value:u.name}})}))},{displayName:"FieldsSelect"});function Dr(e){const t=[];if(!e)return[];for(let o=e;o;o=o.upstream)o.upstream&&o.branchIndex!=null&&t.push(o.upstream);return t}const pe={label:"label",value:"value",children:"children"},bo={label:`{{t("Current form variables", { ns: "${m}" })}}`,value:"$currentForm",useOptions(e){var a;const t=he(),n=s.usePlugin(Z).instructions.get(t.type);return((a=n.useCurrentFormVariables)==null?void 0:a.call(n,t,e))||[]}},xt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=s.usePlugin(Z),o=he(),n=Ee(o),i=[];return n.forEach(a=>{var d;const l=t.get(a.type),c=(d=l.useVariables)==null?void 0:d.call(l,a,e);c&&i.push(c)}),i}},bt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var i,a;const{triggers:t}=s.usePlugin(Z),{workflow:o}=q(),n=t.get(o.type);return(a=(i=n==null?void 0:n.useVariables)==null?void 0:i.call(n,o.config,e))!=null?a:null}},Wt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=pe,current:o}=e,{instructions:n}=s.usePlugin(Z),i=he(),a=o!=null?o:i,l=Dr(a),c=[];return l.forEach(d=>{var f,h;const p=n.get(d.type),u=(f=p.useScopeVariables)==null?void 0:f.call(p,d,e);u&&c.push({key:d.key,[t.value]:d.key,[t.label]:(h=d.title)!=null?h:`#${d.id}`,[t.children]:u})}),c}},vo={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=pe}){return!e||e.includes("date")?[{key:"now",[t.label]:F("System time"),[t.value]:"now"}]:[]}},Ne={boolean:new Set(["checkbox"]),number:new Set(["integer","number","percent"]),string:new Set(["input","password","email","phone","select","radioGroup","text","markdown","richText","expression","time"]),date:new Set(["date","createdAt","updatedAt"])};function wo(e,t){var o,n,i,a,l,c;return typeof t=="string"?(o=Ne[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?jt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((i=t.options)==null?void 0:i.collection)||((a=t.options)==null?void 0:a.collection)==="*"):e.isForeignKey?e.collectionName===((l=t.options)==null?void 0:l.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function jt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function zt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function Lt({fields:e,types:t,appends:o,depth:n=1,compile:i,getCollectionFields:a}){return e.filter(l=>{const c=t!=null&&t.length?t.some(d=>wo(l,d)):!0;if(jt(l)){if(o===null)return n?c||Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,depth:n-1,appends:o,compile:i,getCollectionFields:a}):!1;const d=zt(l,o),p=o.includes(l.name);return c?p:((d==null?void 0:d.length)||p)&&Lt({fields:qt(l.target,{compile:i,getCollectionFields:a}),types:t,appends:d,compile:i,getCollectionFields:a}).length}else return c})}function tt(e,t){var a,l;const o=s.useCompile(),n=(l=(a=e.useOptions)==null?void 0:a.call(e,t))==null?void 0:l.filter(Boolean),{fieldNames:i}=t;return{[i.label]:o(e.label),[i.value]:e.value,key:e[i.value],[i.children]:n,disabled:!n||!n.length}}function le(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(Wt,o),tt(xt,o),tt(bt,o),tt(vo,o),s.useGlobalVariable("$env")].filter(Boolean)}function Co(e={}){var i;const t=Object.assign({},pe,(i=e.fieldNames)!=null?i:{}),o=Object.assign(e,{fieldNames:t});return[tt(bo,o)]}function qt(e,{compile:t,getCollectionFields:o}){var d,p,u,f,h,g,y;const[n,i]=s.parseCollectionName(e),a=o(i,n),l=[],c=[];a.forEach(w=>{w.isForeignKey?l.push(w):c.push(w)});for(let w=c.length-1;w>=0;w--){const A=c[w];if(A.type==="belongsTo"){const T=l.find(C=>C.name===A.foreignKey);T?c.splice(w,0,I(v(v({},A),T),{uiSchema:I(v({},A.uiSchema),{title:(d=A.uiSchema)!=null&&d.title?`${t((p=A.uiSchema)==null?void 0:p.title)} ID`:T.name})})):c.splice(w,0,I(v({},A),{name:A.foreignKey,type:"bigInt",isForeignKey:!0,interface:A.interface,uiSchema:I(v({},A.uiSchema),{title:(u=A.uiSchema)!=null&&u.title?`${t((f=A.uiSchema)==null?void 0:f.title)} ID`:A.name})}))}else if(A.type==="context"&&A.collectionName==="users"){const T=(h=c.find(C=>C.type==="belongsTo"&&C.target==="users"&&C.foreignKey===A.name))!=null?h:{};c.splice(w,0,I(v({},A),{type:A.dataType,interface:T.interface,uiSchema:I(v({},T.uiSchema),{title:(g=T.uiSchema)!=null&&g.title?`${t((y=T.uiSchema)==null?void 0:y.title)} ID`:A.name})}))}}return c.filter(w=>w.interface&&!w.hidden)}function Or(e){const t=zt(e.field,e.appends),o=ue(v({collection:`${e.field.dataSourceKey&&e.field.dataSourceKey!=="main"?`${e.field.dataSourceKey}:`:""}${e.field.target}`,types:e.types,appends:t,depth:e.depth-1},this));e.loadChildren=null,o.length?e.children=o:(e.isLeaf=!0,!e.types||e.types.some(i=>wo(e.field,i))||(e.disabled=!0))}function ue(e){const{fields:t,collection:o,types:n,appends:i=[],depth:a=1,compile:l,getCollectionFields:c,fieldNames:d=pe}=e,p=t!=null?t:qt(o,{compile:l,getCollectionFields:c}),u=Or.bind({compile:l,getCollectionFields:c,fieldNames:d});return Lt({fields:p,types:n,depth:a,appends:i,compile:l,getCollectionFields:c}).map(h=>{var A;const g=l(((A=h.uiSchema)==null?void 0:A.title)||h.name),y=zt(h,i),w=!jt(h)||y&&!y.length&&!i.includes(h.name)||!1;return{[d.label]:g,key:h.name,[d.value]:h.name,isLeaf:w,loadChildren:w?null:u,field:h,depth:a,appends:i,types:n}})}function ke(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.Input,v({scope:i},t))}function ot(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.TextArea,v({scope:i},t))}function ko(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.RawTextArea,v({scope:i},t))}function So(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const i=le(e);return r.jsx(s.Variable.JSON,v({scope:i},t))}function Pr(o){var n=o,{variableOptions:e}=n,t=K(n,["variableOptions"]);const{options:i=[]}=t,a=Co(e),l=le(e);return r.jsx(s.Variable.CodeMirror,v({scope:[...a,...l,...i]},t))}function De({value:e,onChange:t,renderSchemaComponent:o}){const n=le();return r.jsx(s.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Oe(e){const a=e,{options:t=[],direction:o}=a,n=K(a,["options","direction"]),i=s.useCompile();return r.jsx(x.Radio.Group,I(v({},n),{children:r.jsx(x.Space,{direction:o,children:t.map(l=>r.jsxs(x.Radio,{value:l.value,children:[r.jsx("span",{className:s.css`
418
418
  & + .anticon {
419
419
  margin-left: 0.25em;
420
420
  }
@@ -457,7 +457,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
457
457
  .ant-input.null-value {
458
458
  width: 100%;
459
459
  }
460
- `},required:!0}},this.components={WorkflowVariableInput:ke}}Component({data:t}){var a;const{nodes:o}=q(),{styles:n}=ge(),i=o.find(l=>l.upstreamId===t.id&&l.branchIndex!=null);return r.jsx(nt,{data:t,children:r.jsx("div",{className:n.nodeSubtreeClass,children:r.jsxs("div",{className:s.cx(n.branchBlockClass,s.css`
460
+ `},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableInput:ke}}Component({data:t}){var a;const{nodes:o}=q(),{styles:n}=ge(),i=o.find(l=>l.upstreamId===t.id&&l.branchIndex!=null);return r.jsx(nt,{data:t,children:r.jsx("div",{className:n.nodeSubtreeClass,children:r.jsxs("div",{className:s.cx(n.branchBlockClass,s.css`
461
461
  padding-left: 20em;
462
462
  `),children:[r.jsx($e,{from:t,entry:i,branchIndex:(a=i==null?void 0:i.branchIndex)!=null?a:0}),r.jsxs("div",{className:n.branchClass,children:[r.jsx("div",{className:"workflow-branch-lines"}),r.jsx("div",{className:s.cx(n.addButtonClass,n.loopLineClass),children:r.jsx(j.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,o){const n=s.useCompile(),i=F("Loop target"),a=F("Loop index"),l=F("Loop length"),{target:c}=t.config;if(!c)return null;const{fieldNames:d=pe}=o;let p={key:"item",[d.value]:"item",[d.label]:i};if(typeof c=="string"&&c.startsWith("{{")&&c.endsWith("}}")){const u=c.slice(2,-2).split(".").map(g=>g.trim()),f=[Wt,xt,bt].map(g=>{const y=g.useOptions(I(v({},o),{current:t})).filter(Boolean);return{[d.label]:n(g.label),[d.value]:g.value,key:g.value,[d.children]:y,disabled:y&&!y.length}}),h=Qr(f,u);p=Object.assign({},h,p)}return[p,{key:"index",[d.value]:"index",[d.label]:a},{key:"length",[d.value]:"length",[d.label]:l}]}}class Xr extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",Zr)})}}function Rr(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function es({multiple:e=!1,value:t=[],onChange:o}){const n=le({types:[Rr]});return r.jsx(s.Variable.Input,{scope:n,value:t[0],onChange:i=>{o([i])},children:r.jsx(s.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:t[0],onChange:i=>{o(i!=null?[i]:[])}})})}function ts({value:e,onChange:t}){const o=r.jsx("fieldset",{children:r.jsx(be.FormLayout,{layout:"vertical",children:r.jsx(s.FormItem,{label:F("Negotiation"),children:r.jsxs(x.Radio.Group,{value:e,onChange:t,children:[r.jsx(x.Radio,{value:1,children:r.jsxs(x.Tooltip,{title:F("Everyone should pass"),placement:"bottom",children:[r.jsx("span",{children:F("All pass")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})}),r.jsx(x.Radio,{value:-1,children:r.jsxs(x.Tooltip,{title:F("Anyone pass"),placement:"bottom",children:[r.jsx("span",{children:F("Any pass")}),r.jsx(j.QuestionCircleOutlined,{style:{color:"#999"}})]})})]})})})});return r.jsxs("fieldset",{className:s.css`
463
463
  .ant-radio-group {
@@ -504,7 +504,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
504
504
  .ant-table-cell {
505
505
  text-align: center;
506
506
  }
507
- `},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:ie("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:ie("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:ie("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${Ie}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class Mi extends s.Plugin{load(){return O(this,null,function*(){this.app.addComponents({NoticeBlockProvider:gi,NoticeCenter:Oi})})}}function Go(){const e=W.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Yt,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const Ei=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=b.useCallback(()=>{const n=Go();e(n)},[e,Go]);return r.jsx(s.SchemaInitializerItem,I(v({},t),{onClick:o}))};class $i extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(Mi)})}load(){return O(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Ei}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ie("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class Bi extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(ci),yield this.app.pm.add($i)})}}class Vi extends Qe{constructor(){super(...arguments),this.title=N("General event"),this.description=N("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."),this.fieldset={bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=ue(I(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:F("User acted")}}],compile:n,getCollectionFields:i}));return[...ue({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}),...a,{label:F("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const Wi=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,I(v({},e),{schema:ji,item:e}))},ji={type:"void",title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},zi=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=S.useFieldSchema();return S.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],Li=new s.SchemaSettings({name:"actionSettings:APIRegular",items:zi}),qi=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),i=S.useFieldSchema(),a=b.useContext(S.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=X.useTranslation();oe.useNavigate(),s.useCompile();const p=S.useField(),{modal:u,notification:f}=x.App.useApp(),h=s.useVariables(),{name:g,getField:y}=s.useCollection_deprecated(),w=s.useLocalVariables(),{run:A}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",C=>{if(C.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(x.Progress,{percent:0}),duration:0});else if(C.msg==="progress"){const D=C.current+1,$=Math.floor(D/C.total*100)===100?3:0;f.info({key:"workflow:regular",message:`${d("Processing")}...`,description:r.jsx(x.Progress,{percent:Math.floor(D/C.total*100)}),duration:$})}else C.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(x.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return O(this,null,function*(){var Y,se,V,M,L,R,H;const C=(M=(V=(se=(Y=l.field)==null?void 0:Y.data)==null?void 0:se.selectedRowKeys)!=null?V:a==null?void 0:a.selectedRecordKeys)!=null?M:[],{filter:D}=(R=(L=n.params)==null?void 0:L[0])!=null?R:{},{bindWorkflow:$=!1,triggerWorkflows:E=!1,assignedValues:P={},updateMode:B}=(H=i==null?void 0:i["x-action-settings"])!=null?H:{},_=B==="selected",z={primaryKey:c||"id",targetKeys:C};if(p.data=e.data||{},p.data.loading=!0,!E&&!$)return u.info({title:F("Not bind workflow!")});const J=Object.keys(P).map(G=>O(this,null,function*(){const re=P[G],Le=y(G);if(s.isVariable(re)){const xe=yield h==null?void 0:h.parseVariable(re,w);xe&&s.transformVariableValue(xe,{targetCollectionField:Le})}}));yield Promise.all(J),u.confirm({title:F("Confirm",{ns:"core"}),content:F("Trigger workflow?"),onOk(){return O(this,null,function*(){if($){const G={filterByTk:$,updateData:encodeURIComponent(JSON.stringify(z))};A(G)}else E&&(_?yield t.trigger({filterByTk:C,triggerWorkflows:E&&E.length>0?E.map(G=>[G.workflowKey,G.context].filter(Boolean).join("!")).join(","):[]}):yield t.trigger({filter:D,triggerWorkflows:E&&E.length>0?E.map(G=>[G.workflowKey,G.context].filter(Boolean).join("!")).join(","):[]}));p.data.loading=!1})},onCancel(){return O(this,null,function*(){p.data.loading=!1})}})})}}};class Ui extends s.Plugin{load(){return O(this,null,function*(){this.app.addComponents({APIRegularInitializer:Wi}),this.app.addScopes({usePropsAPIRegular:qi}),this.app.schemaSettingsManager.add(Li),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:N("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function Ki(){const e=S.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=s.useFilterByTk(),l=oe.useNavigate(),c=S.useFieldSchema(),d=S.useField(),p=s.useCompile(),{modal:u}=x.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return O(this,null,function*(){var T,C;const{onSuccess:g,skipValidator:y,triggerWorkflows:w}=(c==null?void 0:c["x-action-settings"])||{};y||(yield e.submit());const A=yield f();d.data=t.data||{},d.data.loading=!0;try{const D=yield n.trigger({values:A,filterByTk:a,triggerWorkflows:w!=null&&w.length?w.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0});if(d.data.data=D,(C=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||C.call(T),i==null||i(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?u.success({title:p(g==null?void 0:g.successMessage),onOk:()=>O(this,null,function*(){return yield e.reset(),(g==null?void 0:g.redirecting)&&(g==null?void 0:g.redirectTo)&&(W.isURL(g.redirectTo)?window.location.href=g.redirectTo:l(g.redirectTo))})}):x.message.success(p(g==null?void 0:g.successMessage))}catch(D){console.error(D)}finally{d.data.loading=!1}})}}}function _i(){const e=s.useCompile(),t=s.useFilterByTk(),o=S.useField(),n=S.useFieldSchema(),{field:i,resource:a}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=x.App.useApp(),p=oe.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(g,y){return O(this,null,function*(){o.data=i.data||{},o.data.loading=!0;try{if(yield a.trigger({filterByTk:t,triggerWorkflows:f!=null&&f.length?f.map(w=>[w.workflowKey,w.context].filter(Boolean).join("!")).join(","):void 0}),y==null||y(),l==null||l(!1),c==null||c(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?d.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(W.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):x.message.success(e(u==null?void 0:u.successMessage))}catch(w){console.error(w)}finally{o.data.loading=!1}})}}}const Qt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},vt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Zt=I(v({},vt),{schema:I(v({},vt.schema),{"x-component":"Action.Link"})});class Gi extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(Ui)})}load(){return O(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Vi),this.app.addScopes({useFormWorkflowCustomActionProps:Ki,useRecordWorkflowCustomTriggerActionProps:_i}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Zt)})}}class Hi extends Q{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,this.fieldset={mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"}},this.components={RadioWithTooltip:Oe}}Component({data:t}){const{styles:o}=ge(),{id:n,config:{mode:i}}=t,{workflow:a,nodes:l}=q(),c=l.reduce((y,w)=>w.upstreamId===n&&w.branchIndex!=null?y.concat(w):y,[]).sort((y,w)=>y.branchIndex-w.branchIndex),[d,p]=b.useState(Math.max(2,c.length)),{getAriaLabel:u}=dt(t),f=F("Add branch"),h=Array(Math.max(0,d-c.length)).fill(null),g=c[c.length-1];return r.jsx(nt,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(y=>r.jsx($e,{from:t,entry:y,branchIndex:y.branchIndex},y.id)),h.map((y,w)=>r.jsx($e,{from:t,branchIndex:(g?g.branchIndex:0)+w+1,controller:c.length+w>1?r.jsx("div",{className:s.css`
507
+ `},properties:{action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:60},title:'{{t("Actions")}}',properties:{action:{"x-component":"ColumnAction"}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:80},title:ie("ID"),properties:{id:{type:"number","x-component":"Input","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:160},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},summary:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:ie("Summary"),properties:{summary:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},user:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:140},title:ie("The Notified Person"),properties:{user:{"x-component":"ColumnUser","x-read-pretty":!0}}},workflow:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:'{{t("Workflow", { ns: "workflow" })}}',properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},node:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:null},title:`{{t("Task node", { ns: "${Ie}" })}}`,properties:{node:{"x-component":"ColumnNode","x-read-pretty":!0}}}}}}};class Mi extends s.Plugin{load(){return O(this,null,function*(){this.app.addComponents({NoticeBlockProvider:gi,NoticeCenter:Oi})})}}function Go(){const e=W.uid();return{type:"void",name:e,"x-uid":e,"x-decorator-props":{collection:Yt,params:{appends:["user.id","user.nickname","node.id","node.title","job.id","job.status","job.result","workflow.id","workflow.title","workflow.enabled","execution.id","execution.status"]},action:"listCentralized"},"x-decorator":"NoticeBlockProvider","x-component":"CardItem","x-designer":"TableBlockDesigner","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{notice:{type:"void","x-component":"NoticeCenter"}}}}const Ei=()=>{const{insert:e}=s.useSchemaInitializer(),t=s.useSchemaInitializerItem(),o=b.useCallback(()=>{const n=Go();e(n)},[e,Go]);return r.jsx(s.SchemaInitializerItem,I(v({},t),{onClick:o}))};class $i extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(Mi)})}load(){return O(this,null,function*(){this.app.addComponents({NoticeBlockInitializer:Ei}),this.app.schemaInitializerManager.get("page:addBlock").add("otherBlocks.workflow.common.notice",{key:"noticeBlock",name:"noticeBlock",type:"item",title:ie("Notice Center"),Component:"NoticeBlockInitializer",icon:"NotificationOutlined"})})}}class Bi extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(ci),yield this.app.pm.add($i)})}}class Vi extends Qe{constructor(){super(...arguments),this.title=N("General event"),this.description=N("Omni Trigger is a versatile trigger. You can use it to trigger workflows in a table, trigger it from another workflow, or trigger it with a form button."),this.fieldset={bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={},this.isActionTriggerable=(t,o={})=>{const{buttonAction:n}=o;return[n==="customize:triggerWorkflows",n==="submit"].some(l=>l===!0)}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=ue(I(v({appends:["user"]},o),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:F("User acted")}}],compile:n,getCollectionFields:i}));return[...ue({appends:["data",...((l=t.appends)==null?void 0:l.map(c=>`data.${c}`))||[]],fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}),...a,{label:F("Role of user acted"),value:"roleName"}]}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:N("Trigger data"),Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const Wi=()=>{const e=s.useSchemaInitializerItem();return r.jsx(s.BlockInitializer,I(v({},e),{schema:ji,item:e}))},ji={type:"void",title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"usePropsAPIRegular","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:APIRegular","x-action":"customize:triggerWorkflows","x-action-settings":{bindWorkflow:!1,updateMode:"selected",triggerWorkflows:[]},"x-component-props":{icon:"CarryOutOutlined"}},zi=[{name:"editButton",Component:s.ActionDesigner.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"workflowConfig",Component:s.WorkflowConfig,useVisible(){var t;const e=S.useFieldSchema();return S.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.triggerWorkflows)}},{name:"remove",sort:100,Component:s.ActionDesigner.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}],Li=new s.SchemaSettings({name:"actionSettings:APIRegular",items:zi}),qi=()=>{const{field:e,resource:t,__parent:o,service:n}=s.useBlockRequestContext(),i=S.useFieldSchema(),a=b.useContext(S.SchemaExpressionScopeContext),l=s.useTableBlockContext(),{rowKey:c}=l,{t:d}=X.useTranslation();oe.useNavigate(),s.useCompile();const p=S.useField(),{modal:u,notification:f}=x.App.useApp(),h=s.useVariables(),{name:g,getField:y}=s.useCollection_deprecated(),w=s.useLocalVariables(),{run:A}=s.useRequest({resource:"workflows",action:"trigger"},{manual:!0});return s.useNoticeSub("workflow:regular",C=>{if(C.msg==="start")f.info({key:"workflow:regular",message:d("Start"),description:r.jsx(x.Progress,{percent:0}),duration:0});else if(C.msg==="progress"){const D=C.current+1,$=Math.floor(D/C.total*100)===100?3:0;f.info({key:"workflow:regular",message:`${d("Processing")}...`,description:r.jsx(x.Progress,{percent:Math.floor(D/C.total*100)}),duration:$})}else C.msg==="done"&&(f.success({key:"workflow:regular",message:d("Done"),description:r.jsx(x.Progress,{percent:100}),duration:3}),n.refresh())}),{onClick(){return O(this,null,function*(){var Y,se,V,M,L,R,H;const C=(M=(V=(se=(Y=l.field)==null?void 0:Y.data)==null?void 0:se.selectedRowKeys)!=null?V:a==null?void 0:a.selectedRecordKeys)!=null?M:[],{filter:D}=(R=(L=n.params)==null?void 0:L[0])!=null?R:{},{bindWorkflow:$=!1,triggerWorkflows:E=!1,assignedValues:P={},updateMode:B}=(H=i==null?void 0:i["x-action-settings"])!=null?H:{},_=B==="selected",z={primaryKey:c||"id",targetKeys:C};if(p.data=e.data||{},p.data.loading=!0,!E&&!$)return u.info({title:F("Not bind workflow!")});const J=Object.keys(P).map(G=>O(this,null,function*(){const re=P[G],Le=y(G);if(s.isVariable(re)){const xe=yield h==null?void 0:h.parseVariable(re,w);xe&&s.transformVariableValue(xe,{targetCollectionField:Le})}}));yield Promise.all(J),u.confirm({title:F("Confirm",{ns:"core"}),content:F("Trigger workflow?"),onOk(){return O(this,null,function*(){if($){const G={filterByTk:$,updateData:encodeURIComponent(JSON.stringify(z))};A(G)}else E&&(_?yield t.trigger({filterByTk:C,triggerWorkflows:E&&E.length>0?E.map(G=>[G.workflowKey,G.context].filter(Boolean).join("!")).join(","):[]}):yield t.trigger({filter:D,triggerWorkflows:E&&E.length>0?E.map(G=>[G.workflowKey,G.context].filter(Boolean).join("!")).join(","):[]}));p.data.loading=!1})},onCancel(){return O(this,null,function*(){p.data.loading=!1})}})})}}};class Ui extends s.Plugin{load(){return O(this,null,function*(){this.app.addComponents({APIRegularInitializer:Wi}),this.app.addScopes({usePropsAPIRegular:qi}),this.app.schemaSettingsManager.add(Li),["table","details"].forEach(t=>{this.app.schemaInitializerManager.addItem(`${t}:configureActions`,"customize.APIRegular",{title:N("Trigger workflow"),Component:"APIRegularInitializer",name:"apiRegular",useVisible(){const o=s.useCollection();return(o.template!=="view"||(o==null?void 0:o.writableView))&&o.template!=="file"&&o.template!=="sql"}})})})}}function Ki(){const e=S.useForm(),{field:t,__parent:o,resource:n}=s.useBlockRequestContext(),{setVisible:i}=s.useActionContext(),a=s.useFilterByTk(),l=oe.useNavigate(),c=S.useFieldSchema(),d=S.useField(),p=s.useCompile(),{modal:u}=x.App.useApp(),f=s.useCollectValuesToSubmit();return d.componentProps.filterKeys,{onClick(){return O(this,null,function*(){var T,C;const{onSuccess:g,skipValidator:y,triggerWorkflows:w}=(c==null?void 0:c["x-action-settings"])||{};y||(yield e.submit());const A=yield f();d.data=t.data||{},d.data.loading=!0;try{const D=yield n.trigger({values:A,filterByTk:a,triggerWorkflows:w!=null&&w.length?w.map($=>[$.workflowKey,$.context].filter(Boolean).join("!")).join(","):void 0});if(d.data.data=D,(C=(T=o==null?void 0:o.service)==null?void 0:T.refresh)==null||C.call(T),i==null||i(!1),!(g!=null&&g.successMessage))return;g!=null&&g.manualClose?u.success({title:p(g==null?void 0:g.successMessage),onOk:()=>O(this,null,function*(){return yield e.reset(),(g==null?void 0:g.redirecting)&&(g==null?void 0:g.redirectTo)&&(W.isURL(g.redirectTo)?window.location.href=g.redirectTo:l(g.redirectTo))})}):x.message.success(p(g==null?void 0:g.successMessage))}catch(D){console.error(D)}finally{d.data.loading=!1}})}}}function _i(){const e=s.useCompile(),t=s.useFilterByTk(),o=S.useField(),n=S.useFieldSchema(),{field:i,resource:a}=s.useBlockRequestContext(),{setVisible:l,setSubmitted:c}=s.useActionContext(),{modal:d}=x.App.useApp(),p=oe.useNavigate(),{onSuccess:u,triggerWorkflows:f}=(n==null?void 0:n["x-action-settings"])||{};return{onClick(g,y){return O(this,null,function*(){o.data=i.data||{},o.data.loading=!0;try{if(yield a.trigger({filterByTk:t,triggerWorkflows:f!=null&&f.length?f.map(w=>[w.workflowKey,w.context].filter(Boolean).join("!")).join(","):void 0}),y==null||y(),l==null||l(!1),c==null||c(!0),!(u!=null&&u.successMessage))return;u!=null&&u.manualClose?d.success({title:e(u==null?void 0:u.successMessage),onOk(){u!=null&&u.redirecting&&(u!=null&&u.redirectTo)&&(W.isURL(u.redirectTo)?window.location.href=u.redirectTo:p(u.redirectTo))}}):x.message.success(e(u==null?void 0:u.successMessage))}catch(w){console.error(w)}finally{o.data.loading=!1}})}}}const Qt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useFormWorkflowCustomActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},vt={name:"triggerWorkflow",title:N("Trigger workflow"),Component:"CustomizeActionInitializer",schema:{title:N("Trigger workflow"),"x-component":"Action","x-use-component-props":"useRecordWorkflowCustomTriggerActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:N("Submitted successfully")},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},Zt=I(v({},vt),{schema:I(v({},vt.schema),{"x-component":"Action.Link"})});class Gi extends s.Plugin{afterAdd(){return O(this,null,function*(){yield this.app.pm.add(Ui)})}load(){return O(this,null,function*(){this.app.pm.get("workflow").registerTrigger("general-action",Vi),this.app.addScopes({useFormWorkflowCustomActionProps:Ki,useRecordWorkflowCustomTriggerActionProps:_i}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.triggerWorkflow",Qt),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("details:configureActions").add("customize.triggerWorkflow",vt),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.triggerWorkflow",Zt),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.triggerWorkflow",Zt)})}}class Hi extends Q{constructor(){super(...arguments),this.title=`{{t("Parallel branch", { ns: "${m}" })}}`,this.type="parallel",this.group="control",this.icon="MergeOutlined",this.color="#6e93e8",this.description=`{{t("Run multiple branch processes in parallel.", { ns: "${m}" })}}`,this.fieldset={mode:{type:"string",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${m}" })}}`},{value:"allSettled",label:`{{t('All settled', { ns: "${m}" })}}`,tooltip:`{{t('Continue after all branches finished', { ns: "${m}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${m}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${m}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${m}" })}}`}]},default:"all"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={RadioWithTooltip:Oe}}Component({data:t}){const{styles:o}=ge(),{id:n,config:{mode:i}}=t,{workflow:a,nodes:l}=q(),c=l.reduce((y,w)=>w.upstreamId===n&&w.branchIndex!=null?y.concat(w):y,[]).sort((y,w)=>y.branchIndex-w.branchIndex),[d,p]=b.useState(Math.max(2,c.length)),{getAriaLabel:u}=dt(t),f=F("Add branch"),h=Array(Math.max(0,d-c.length)).fill(null),g=c[c.length-1];return r.jsx(nt,{data:t,children:r.jsxs("div",{className:o.nodeSubtreeClass,children:[r.jsxs("div",{className:o.branchBlockClass,children:[c.map(y=>r.jsx($e,{from:t,entry:y,branchIndex:y.branchIndex},y.id)),h.map((y,w)=>r.jsx($e,{from:t,branchIndex:(g?g.branchIndex:0)+w+1,controller:c.length+w>1?r.jsx("div",{className:s.css`
508
508
  padding-top: 2em;
509
509
 
510
510
  > button {
@@ -524,7 +524,7 @@ lib.log`},"x-component":"CodeMirror",required:!0},model:{type:"array",title:N("P
524
524
  transform-origin: center;
525
525
  transform: rotate(-45deg);
526
526
  }
527
- `,onClick:()=>p(d+1),disabled:a.executed})})]})})}}class Ji extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get(Z).registerInstruction("parallel",Hi)})}}class Yi extends Q{constructor(){super(...arguments),this.title=`{{t("HTTP request", { ns: "${m}" })}}`,this.type="request",this.group="extended",this.icon="ApiOutlined",this.color="#e1ed5b",this.description=`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${m}" })}}`,this.fieldset={method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.tachybase.com"}},needAuthorization:{type:"string",required:!0,title:`{{t("needAuthorization", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"是",value:!0},{label:"否",value:!1}],default:!0},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${m}" })}}`,description:`{{t('"Content-Type" only support "application/json and mutipart/form-data" ', { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${m}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${m}" })}}`},comment:{type:"string",title:`{{t("Comment", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input body comment", { ns: "${m}" })}}`}},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${m}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},this.components={ArrayItems:be.ArrayItems,WorkflowVariableInput:ke,WorkflowVariableTextArea:ot,WorkflowVariableJSON:So}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return{[i.value]:t,[i.label]:o}}}class Qi extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",Yi)})}}class Zi extends Q{constructor(){super(...arguments),this.title=N("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=N("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:N("Message content"),description:N("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"}},this.scope={},this.components={RadioWithTooltip:Oe,WorkflowVariableTextArea:ot,WorkflowVariableInput:ke}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class Xi extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",Zi)})}}class Ri extends Q{constructor(){super(...arguments),this.title=N("Data Mapping"),this.type=uo,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=N("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:N("Data source map"),description:N("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
527
+ `,onClick:()=>p(d+1),disabled:a.executed})})]})})}}class Ji extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get(Z).registerInstruction("parallel",Hi)})}}class Yi extends Q{constructor(){super(...arguments),this.title=`{{t("HTTP request", { ns: "${m}" })}}`,this.type="request",this.group="extended",this.icon="ApiOutlined",this.color="#e1ed5b",this.description=`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${m}" })}}`,this.fieldset={method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.tachybase.com"}},needAuthorization:{type:"string",required:!0,title:`{{t("needAuthorization", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"是",value:!0},{label:"否",value:!1}],default:!0},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${m}" })}}`,description:`{{t('"Content-Type" only support "application/json and mutipart/form-data" ', { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${m}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${m}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:`{{t("Body", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${m}" })}}`},description:`{{t("Only support standard JSON data", { ns: "${m}" })}}`},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${m}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}},this.components={ArrayItems:be.ArrayItems,WorkflowVariableInput:ke,WorkflowVariableTextArea:ot,WorkflowVariableJSON:So}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return{[i.value]:t,[i.label]:o}}}class Qi extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",Yi)})}}class Zi extends Q{constructor(){super(...arguments),this.title=N("Response message"),this.type="response-message",this.group="extended",this.icon="SunOutlined",this.color="#07d629",this.description=N("Add response message, will be send to client when process of request ends."),this.fieldset={message:{type:"string",title:N("Message content"),description:N("Supports variables in template.",{name:"{{name}}"}),"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea"},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={},this.components={RadioWithTooltip:Oe,WorkflowVariableTextArea:ot,WorkflowVariableInput:ke}}isAvailable({workflow:t}){return t.type==="request-interception"||["action","general-action"].includes(t.type)&&t.sync}}class Xi extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("response-message",Zi)})}}class Ri extends Q{constructor(){super(...arguments),this.title=N("Data Mapping"),this.type=uo,this.group="extended",this.icon="FunctionOutlined",this.color="#d93a13",this.isHot=!0,this.description=N("Get specific data from JSON result of any node BY js code or json code;"),this.fieldset={sourceArray:{type:"array",title:N("Data source map"),description:N("Data source map"),"x-decorator":"FormItem","x-component":"ArrayTable",items:{type:"object",properties:{keyName:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("keyName")},properties:{keyName:{type:"string",name:"keyName","x-decorator":"FormItem","x-component":"Input"}}},sourcePath:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:N("Property path")},properties:{sourcePath:{type:"string",name:"sourcePath",required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0}}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{dataIndex:"operations",fixed:"right",className:s.css`
528
528
  > *:not(:last-child) {
529
529
  margin-right: 0.5em;
530
530
  }
@@ -556,20 +556,20 @@ export default async function (
556
556
  `},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:N("Add property"),"x-component":"ArrayTable.Addition","x-component-props":{defaultValue:{}}}}}},this.components={ArrayTable:be.ArrayTable,WorkflowVariableInput:ke}}useVariables(t,o){const{key:n,title:i,config:a}=t,{types:l,fieldNames:c}=o,d=a.model||[];return{[c.label]:i,[c.value]:n,[c.children]:d.map(u=>({[c.label]:u.label,[c.value]:u.alias||u.path}))}}}class ea extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get(Z).registerInstruction(uo,Ri)})}}class ta extends Q{constructor(){super(...arguments),this.title=`{{t("SQL action", { ns: "${m}" })}}`,this.type="sql",this.group="collection",this.icon="ConsoleSqlOutlined",this.color="#e9bf36",this.description=`{{t("Execute a SQL statement in database.", { ns: "${m}" })}}`,this.fieldset={dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:`{{t("Select a data source to execute SQL.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter(t){return t.options.isDBInstance}},default:"main"},sql:{type:"string",required:!0,title:"SQL","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:s.css`
557
557
  font-size: 80%;
558
558
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
559
- `}}},this.components={WorkflowVariableRawTextArea:ko}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return{[i.value]:t,[i.label]:o}}}class oa extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",ta)})}}const na=()=>{const{workflow:e}=q();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class ra extends Q{constructor(){super(...arguments),this.title=N("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={workflowKey:{type:"string",title:N("Workflow"),name:"workflowKey","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"},"x-use-component-props":na,required:!0},bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}}class sa extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",ra)})}}const ia=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
559
+ `}},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.components={WorkflowVariableRawTextArea:ko}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return{[i.value]:t,[i.label]:o}}}class oa extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",ta)})}}const na=()=>{const{workflow:e}=q();return{filterSync:e==null?void 0:e.sync,filterKey:e!=null&&e.key?{$ne:e==null?void 0:e.key}:void 0}};class ra extends Q{constructor(){super(...arguments),this.title=N("Workflow"),this.type="trigger-instruction",this.group="extended",this.icon="NodeIndexOutlined",this.color="#0a72e9",this.fieldset={workflowKey:{type:"string",title:N("Workflow"),name:"workflowKey","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"},"x-use-component-props":na,required:!0},bindCollection:{type:"boolean",title:N("Bind collection?"),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:N("Yes"),value:!0},{label:N("No"),value:!1}],required:!0,default:!1},collection:{type:"string",title:N("Collection"),"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader",required:!0,"x-reactions":[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{dependencies:["bindCollection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},appends:{type:"array",title:N("Associations to use"),description:N("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution."),"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){var o;return(o=S.useForm().values)==null?void 0:o.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}}class sa extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("trigger-instruction",ra)})}}const ia=s.createStyles(({css:e,token:t})=>({nodeIdClass:e`
560
560
  color: ${t.colorTextDescription};
561
561
 
562
562
  &:before {
563
563
  content: '#';
564
564
  }
565
- `}));function aa({value:e,onChange:t}){const o=e==null,n=he(),i=Ee(n,d=>d.type==="variable"&&!d.config.target),{styles:a}=ia(),l=b.useCallback(({target:d})=>{if(d.value)return t(null);i.length&&t(i[0].key)},[t,i]),c=b.useCallback((d,p)=>p.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${p.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(x.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(x.Radio,{value:!0,children:F("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(x.Radio,{value:!1,disabled:!i.length,children:F("Assign value to an existing variable")}),!o&&r.jsx(x.Select,{options:i.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:p})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:a.nodeIdClass,children:p.data.id})]})})]})]})})})}class la extends Q{constructor(){super(...arguments),this.title=N("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=N("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:N("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:N("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={WorkflowVariableInput:ke,VariableTargetSelect:aa}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=pe}){return n.target?null:{[a.value]:t,[a.label]:o}}}class ca extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",la)})}}const Ho=e=>{const t=Ye.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
565
+ `}));function aa({value:e,onChange:t}){const o=e==null,n=he(),i=Ee(n,d=>d.type==="variable"&&!d.config.target),{styles:a}=ia(),l=b.useCallback(({target:d})=>{if(d.value)return t(null);i.length&&t(i[0].key)},[t,i]),c=b.useCallback((d,p)=>p.label.toLowerCase().indexOf(d.toLowerCase())>=0||`#${p.data.id}`.indexOf(d)>=0,[]);return r.jsx("fieldset",{children:r.jsx(x.Radio.Group,{value:o,onChange:l,children:r.jsxs(s.Space,{direction:"vertical",children:[r.jsx(x.Radio,{value:!0,children:F("Declare a new variable")}),r.jsxs(s.Space,{children:[r.jsx(x.Radio,{value:!1,disabled:!i.length,children:F("Assign value to an existing variable")}),!o&&r.jsx(x.Select,{options:i.map(d=>({label:d.title,value:d.key,data:d})),value:e,onChange:t,allowClear:!0,showSearch:!0,filterOption:c,optionRender:({label:d,data:p})=>r.jsxs(s.Space,{children:[r.jsx("span",{children:d}),r.jsx("span",{className:a.nodeIdClass,children:p.data.id})]})})]})]})})})}class la extends Q{constructor(){super(...arguments),this.title=N("Variable"),this.type="variable",this.group="control",this.icon="StrikethroughOutlined",this.color="#a35ae8",this.description=N("Assign value to a variable, for later use."),this.fieldset={target:{type:"string",title:N("Mode"),"x-decorator":"FormItem","x-component":"VariableTargetSelect"},value:{type:"string",title:N("Value"),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:!0,changeOnSelect:!0},default:""},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={WorkflowVariableInput:ke,VariableTargetSelect:aa}}useVariables({key:t,title:o,config:n},{types:i,fieldNames:a=pe}){return n.target?null:{[a.value]:t,[a.label]:o}}}class ca extends s.Plugin{load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("variable",la)})}}const Ho=e=>{const t=Ye.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:s.css`
566
566
  &:after {
567
567
  content: ':';
568
568
  }
569
569
  & + a {
570
570
  margin-left: 0.25em;
571
571
  }
572
- `,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class da extends Q{constructor(){super(...arguments),this.title=`{{t("Calculation", { ns: "${m}" })}}`,this.type="calculation",this.group="control",this.icon="PlusOutlined",this.color="#c3e584",this.description=`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${m}" })}}`,this.fieldset={engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ye.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=Ye.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},transString:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"解析字符串公式","x-reactions":[{dependencies:["engine"],fulfill:{state:{visible:"{{$deps[0] == `formula.js`}}"}}}]}},this.scope={renderEngineReference:Ho},this.components={WorkflowVariableTextArea:ot,RadioWithTooltip:Oe,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o,n;return{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:F("Calculation result")}}}const pa=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:i,children:a}=e,[l,c]=b.useState(!1),d=b.useMemo(()=>{const u=fe.cloneDeep(n.config);return S.createForm({initialValues:u,disabled:i.executed})},[n,i]),p=b.useCallback(u=>{o(u),u||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:p,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:a})})};function ua(){return{form:S.useForm()}}function ma(){const e=S.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),i=he(),{workflow:a}=q();return{run(){return O(this,null,function*(){var c,d;if(a.executed){x.message.error(F("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:i.id,values:{config:e.values}}),o.setFormValueChanged(!1),x.message.success("success"),n()})}}}const fa=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ke;return r.jsxs("div",{className:s.css`
572
+ `,children:s.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class da extends Q{constructor(){super(...arguments),this.title=`{{t("Calculation", { ns: "${m}" })}}`,this.type="calculation",this.group="control",this.icon="PlusOutlined",this.color="#c3e584",this.description=`{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression.", { ns: "${m}" })}}`,this.fieldset={engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:Ye.getOptions()},required:!0,default:"math.js"},expression:{type:"string",title:`{{t("Calculation expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{changeOnSelect:!0},"x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=Ye.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0},transString:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":"解析字符串公式","x-reactions":[{dependencies:["engine"],fulfill:{state:{visible:"{{$deps[0] == `formula.js`}}"}}}]},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.scope={renderEngineReference:Ho},this.components={WorkflowVariableTextArea:ot,RadioWithTooltip:Oe,ValueBlock:Se}}useVariables({key:t,title:o},{types:n,fieldNames:i=pe}){return n&&!n.some(a=>a in Ne||Object.values(Ne).some(l=>l.has(a)))?null:{[i.value]:t,[i.label]:o}}useInitializers(t){var o,n;return{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Se.Initializer,node:t,resultTitle:F("Calculation result")}}}const pa=e=>{const{editingConfig:t,setEditingConfig:o,data:n,workflow:i,children:a}=e,[l,c]=b.useState(!1),d=b.useMemo(()=>{const u=fe.cloneDeep(n.config);return S.createForm({initialValues:u,disabled:i.executed})},[n,i]),p=b.useCallback(u=>{o(u),u||d.reset()},[d]);return r.jsx(s.ActionContextProvider,{value:{visible:t,setVisible:p,formValueChanged:l,setFormValueChanged:c},children:r.jsx(s.FormProvider,{form:d,children:a})})};function ua(){return{form:S.useForm()}}function ma(){const e=S.useForm(),t=s.useAPIClient(),o=s.useActionContext(),{refresh:n}=s.useResourceActionContext(),i=he(),{workflow:a}=q();return{run(){return O(this,null,function*(){var c,d;if(a.executed){x.message.error(F("Node in executed workflow cannot be modified"));return}yield e.submit(),yield(d=(c=t.resource("flow_nodes")).update)==null?void 0:d.call(c,{filterByTk:i.id,values:{config:e.values}}),o.setFormValueChanged(!1),x.message.success("success"),n()})}}}const fa=e=>{const{data:t,instruction:o}=e,n=(o==null?void 0:o.group)===Ke;return r.jsxs("div",{className:s.css`
573
573
  display: flex;
574
574
  justify-content: space-between;
575
575
 
@@ -810,7 +810,7 @@ export default async function (
810
810
  margin-right: 1em;
811
811
  }
812
812
  }
813
- `,children:[r.jsx(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Oa({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(Yo,{value:o.group,onChange:n=>t(I(v({},o),{group:n}))})}class Pa extends Q{constructor(){super(...arguments),this.title=`{{t("Condition", { ns: "${m}" })}}`,this.type="condition",this.group="control",this.icon="QuestionOutlined",this.color="#1ab287",this.description=`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${m}" })}}`,this.fieldset={rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(Ye.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(v({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=Ye.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}},this.options=[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],this.scope={renderEngineReference:Ho,useWorkflowVariableOptions:le},this.components={CalculationConfig:Oa,WorkflowVariableTextArea:ot,RadioWithTooltip:Oe}}Component({data:t}){const{t:o}=X.useTranslation(),{nodes:n}=q(),{styles:i}=ge(),{id:a,config:{rejectOnFalse:l}}=t,c=n.find(p=>p.upstreamId===a&&p.branchIndex===1),d=n.find(p=>p.upstreamId===a&&p.branchIndex===0);return r.jsx(nt,{data:t,children:l?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx($e,{from:t,entry:c,branchIndex:1}),r.jsx($e,{from:t,entry:d,branchIndex:0})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("Yes")}),r.jsx("span",{style:{left:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("No")})]})]})})}}function Ma(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=S.useField(),n=o.segments[o.segments.length-1],{values:i}=S.useForm(),[a,l]=s.parseCollectionName(i==null?void 0:i.collection),c=t(l,a),{type:d}=c.find(f=>f.name===n),p=Array.isArray(e.value)?e.value.join(","):e.value;function u(f){const h=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?h:h.split(/[,\s]+/))}return r.jsx(x.Input,I(v({},e),{value:p,onChange:u}))}const Qo=S.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:i}=s.useToken(),{t:a}=X.useTranslation(),l=s.useCompile(),c=S.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),p=le(),{values:u}=c,[f,h]=s.parseCollectionName(u==null?void 0:u.collection),g=d(h,f).filter(C=>C.uiSchema),y=n?g.filter(n.bind(u)):g,w=b.useMemo(()=>y.filter(C=>!e||!(C.name in e)),[y,e]),A=t||c.disabled,T=b.useMemo(()=>({onClick:({key:C})=>{o(I(v({},e),{[C]:null}))},style:{maxHeight:300,overflowY:"auto"},items:w.map(C=>{var D,$;return{key:C.name,label:l(($=(D=C.uiSchema)==null?void 0:D.title)!=null?$:C.name)}})}),[o,w,e]);return r.jsx("fieldset",{className:s.css`
813
+ `,children:[r.jsx(x.Button,{type:"link",onClick:a,children:o("Add condition")}),r.jsx(x.Button,{type:"link",onClick:l,children:o("Add condition group")})]})]})}function Oa({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(Yo,{value:o.group,onChange:n=>t(I(v({},o),{group:n}))})}class Pa extends Q{constructor(){super(...arguments),this.title=`{{t("Condition", { ns: "${m}" })}}`,this.type="condition",this.group="control",this.icon="QuestionOutlined",this.color="#1ab287",this.description=`{{t('Based on boolean result of the calculation to determine whether to "continue" or "exit" the process, or continue on different branches of "yes" and "no".', { ns: "${m}" })}}`,this.fieldset={rejectOnFalse:{type:"boolean",title:`{{t("Mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{disabled:!0},enum:[{value:!0,label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`},{value:!1,label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`}]},engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[["basic",{label:`{{t("Basic", { ns: "${m}" })}}`}],...Array.from(Ye.evaluators.getEntities()).filter(([t])=>["math.js","formula.js"].includes(t))].reduce((t,[o,n])=>t.concat(v({value:o},n)),[])},required:!0,default:"basic"},calculation:{type:"string",title:`{{t("Condition", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"CalculationConfig","x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] === "basic"}}'}}},required:!0},expression:{type:"string",title:`{{t("Condition expression", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-validator"(t,o,{form:n}){const{values:i}=n,{evaluate:a}=Ye.evaluators.get(i.engine),l=t.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(l),""}catch(c){return F("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.options=[{label:`{{t('Continue when "Yes"', { ns: "${m}" })}}`,key:"rejectOnFalse",value:{rejectOnFalse:!0}},{label:`{{t('Branch into "Yes" and "No"', { ns: "${m}" })}}`,key:"branch",value:{rejectOnFalse:!1}}],this.scope={renderEngineReference:Ho,useWorkflowVariableOptions:le},this.components={CalculationConfig:Oa,WorkflowVariableTextArea:ot,RadioWithTooltip:Oe}}Component({data:t}){const{t:o}=X.useTranslation(),{nodes:n}=q(),{styles:i}=ge(),{id:a,config:{rejectOnFalse:l}}=t,c=n.find(p=>p.upstreamId===a&&p.branchIndex===1),d=n.find(p=>p.upstreamId===a&&p.branchIndex===0);return r.jsx(nt,{data:t,children:l?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx($e,{from:t,entry:c,branchIndex:1}),r.jsx($e,{from:t,entry:d,branchIndex:0})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("Yes")}),r.jsx("span",{style:{left:"4em",display:"inline-block",padding:"0.5em",textAlign:"center",backgroundColor:"white",borderRadius:"50%",color:"black",fontSize:"1em",lineHeight:"1em"},children:o("No")})]})]})})}}function Ma(e){const{getCollectionFields:t}=s.useCollectionManager_deprecated(),{path:o}=S.useField(),n=o.segments[o.segments.length-1],{values:i}=S.useForm(),[a,l]=s.parseCollectionName(i==null?void 0:i.collection),c=t(l,a),{type:d}=c.find(f=>f.name===n),p=Array.isArray(e.value)?e.value.join(","):e.value;function u(f){const h=f.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(d)?h:h.split(/[,\s]+/))}return r.jsx(x.Input,I(v({},e),{value:p,onChange:u}))}const Qo=S.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:i}=s.useToken(),{t:a}=X.useTranslation(),l=s.useCompile(),c=S.useForm(),{getCollectionFields:d}=s.useCollectionManager_deprecated(),p=le(),{values:u}=c,[f,h]=s.parseCollectionName(u==null?void 0:u.collection),g=d(h,f).filter(C=>C.uiSchema),y=n?g.filter(n.bind(u)):g,w=b.useMemo(()=>y.filter(C=>!e||!(C.name in e)),[y,e]),A=t||c.disabled,T=b.useMemo(()=>({onClick:({key:C})=>{o(I(v({},e),{[C]:null}))},style:{maxHeight:300,overflowY:"auto"},items:w.map(C=>{var D,$;return{key:C.name,label:l(($=(D=C.uiSchema)==null?void 0:D.title)!=null?$:C.name)}})}),[o,w,e]);return r.jsx("fieldset",{className:s.css`
814
814
  margin-top: 0.5em;
815
815
 
816
816
  > .ant-formily-item {
@@ -829,7 +829,7 @@ export default async function (
829
829
  `},"x-component":"CollectionFieldset"},wt={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const{values:e}=S.useForm(),[t,o]=s.parseCollectionName(e==null?void 0:e.collection);return{options:s.useCollectionFilterOptions(o,t),className:s.css`
830
830
  position: relative;
831
831
  width: 100%;
832
- `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Ea={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},$a={type:"void",properties:{paginate:{type:"boolean",title:N("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":N("Custom pagination(page number and count cannot be empty)"),default:!1},pagination:{type:"void","x-decorator":"FormItem","x-component":"Grid","x-reactions":[{dependencies:[".paginate"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}],properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}}}},rt={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=S.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Ba extends Q{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Zo,appends:rt}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:Qo}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class Va extends Q{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",this.description=`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:I(v({},wt),{"x-validator"(t){return ht(t)?"":F("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:De}}}class Wa extends Q{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,this.fieldset={endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:ye.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:ye.FAILED}],required:!0,default:ye.RESOLVED}},this.end=!0}}class ja extends Q{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:wt,sort:Ea,pagination:$a,appends:rt},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:i}=S.useForm();return o(i.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:be.ArrayItems,FilterDynamicComponent:De,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function za(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=S.useForm(),{collection:l}=a.values,c=i(l),d=S.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const h=c.reduce((g,y)=>(y.name in f.value&&(u.value||![].includes(y.type))&&(g[y.name]=f.value[y.name]),g),{});a.setValuesIn("params.values",h),e(u.value)}return r.jsx(Oe,I(v({},t),{onChange:p}))}class La extends Q{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:I(v({},wt),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return ht(t)?"":F("Please add at least one condition")}}),values:I(v({},Zo),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:De,CollectionFieldset:Qo,IndividualHooksRadioWithTooltip:za}}}const qa=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=S.useFieldSchema();return S.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),Ve={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Ua=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Ve.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Ve.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Ve.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Ve.DELETED}];class Ka extends Qe{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...ve["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:Ua,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.UPDATED})}}`}}}]},condition:I(v({},wt),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:I(v({},rt),{"x-reactions":[...rt["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ve.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Do},this.components={FieldsSelect:et}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}];return ue(I(v({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:a,compile:n,getCollectionFields:i}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const We={STATIC:0,DATE_FIELD:1};function _a(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Xo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=X.useTranslation(),[i,a]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
832
+ `}},"x-component-props":{dynamicComponent:"FilterDynamicComponent"}},Ea={type:"array",title:'{{t("Sort")}}',"x-decorator":"FormItem","x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:"{{useSortableFields()}}",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:'{{t("ASC")}}',value:"asc"},{label:'{{t("DESC")}}',value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add sort field")}}',"x-component":"ArrayItems.Addition"}}},$a={type:"void",properties:{paginate:{type:"boolean",title:N("Pagination"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":N("Custom pagination(page number and count cannot be empty)"),default:!1},pagination:{type:"void","x-decorator":"FormItem","x-component":"Grid","x-reactions":[{dependencies:[".paginate"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}],properties:{row:{type:"void","x-component":"Grid.Row",properties:{page:{type:"void","x-component":"Grid.Col",properties:{page:{type:"number",title:'{{t("Page number")}}',"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{useTypedConstant:["number","null"]},default:1}}},pageSize:{type:"void","x-component":"Grid.Col",properties:{pageSize:{type:"number",title:'{{t("Page size")}}',"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,max:100},default:20}}}}}}}}},rt={type:"array",title:`{{t("Preload associations", { ns: "${m}" })}}`,description:`{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:e}=S.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]};class Ba extends Q{constructor(){super(...arguments),this.title=`{{t("Create record", { ns: "${m}" })}}`,this.type="create",this.group="collection",this.icon="FileAddOutlined",this.color="#07fa0f",this.description=`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{values:Zo,appends:rt}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={CollectionFieldset:Qo}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return t.config.collection?{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}:null}}class Va extends Q{constructor(){super(...arguments),this.title='{{t("Delete record")}}',this.type="destroy",this.group="collection",this.icon="ClockCircleOutlined",this.color="#fa0b07",this.description=`{{t("Delete records of a collection. Could use variables in workflow context as filter. All records match the filter will be deleted.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{filter:I(v({},wt),{"x-validator"(t){return ht(t)?"":F("Please add at least one condition")}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:De}}}class Wa extends Q{constructor(){super(...arguments),this.title=`{{t("End process", { ns: "${m}" })}}`,this.type="end",this.group="control",this.icon="LogoutOutlined",this.color="#2659a1",this.description=`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`,this.fieldset={endStatus:{type:"number",title:`{{t("End status", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeeded", { ns: "${m}" })}}`,value:ye.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:ye.FAILED}],required:!0,default:ye.RESOLVED},remarks:{type:"string",title:`{{t("Remarks", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:3},placeholder:`{{t("Input remarks", { ns: "${m}" })}}`}}},this.end=!0}}class ja extends Q{constructor(){super(...arguments),this.title=`{{t("Query record", { ns: "${m}" })}}`,this.type="query",this.group="collection",this.icon="FileSearchOutlined",this.color="#55e2d1",this.description=`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",effects:["onFieldValueChange"],fulfill:{state:{visible:"{{!!$self.value}}",value:"{{Object.create({})}}"}}}]}),multiple:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow multiple records as result", { ns: "${m}" })}}`,description:`{{t("If checked, when there are multiple records in the query result, an array will be returned as the result, which can be operated on one by one using a loop node. Otherwise, only one record will be returned.", { ns: "${m}" })}}`},isTree:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Allow query for tree data", { ns: "${m}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:wt,sort:Ea,pagination:$a,appends:rt},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{$deps[0] != null}}"}}}]},failOnEmpty:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Exit when query result is null", { ns: "${m}" })}}`}},this.scope={useCollectionDataSource:s.useCollectionDataSource,useSortableFields(){const t=s.useCompile(),{getCollectionFields:o,getInterface:n}=s.useCollectionManager_deprecated(),{values:i}=S.useForm();return o(i.collection).filter(l=>{if(!l.interface)return!1;const c=n(l.interface);return!!(c!=null&&c.sortable)}).map(l=>{var c,d;return{value:l.name,label:(c=l==null?void 0:l.uiSchema)!=null&&c.title?t((d=l==null?void 0:l.uiSchema)==null?void 0:d.title):l.name}})}},this.components={ArrayItems:be.ArrayItems,FilterDynamicComponent:De,SchemaComponentContext:s.SchemaComponentContext,WorkflowVariableInput:ke}}useVariables({key:t,title:o,config:n},i){var d,p;const a=s.useCompile(),{getCollectionFields:l}=s.useCollectionManager_deprecated(),[c]=ue(I(v({appends:[t,...((p=(d=n.params)==null?void 0:d.appends)==null?void 0:p.map(u=>`${t}.${u}`))||[]]},i),{fields:[{collectionName:n.collection,name:t,type:"hasOne",target:n.collection,uiSchema:{title:o}}],compile:a,getCollectionFields:l}));return c}useInitializers(t){var o,n;return!t.config.collection||t.config.multiple?null:{name:(o=t.title)!=null?o:`#${t.id}`,type:"item",title:(n=t.title)!=null?n:`#${t.id}`,Component:Te,collection:t.config.collection,dataPath:`$jobsMapByNodeKey.${t.key}`}}}function za(o){var n=o,{onChange:e}=n,t=K(n,["onChange"]);const{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=S.useForm(),{collection:l}=a.values,c=i(l),d=S.useField();function p({target:u}){const f=d.query(".values").take();if(!f)return;const h=c.reduce((g,y)=>(y.name in f.value&&(u.value||![].includes(y.type))&&(g[y.name]=f.value[y.name]),g),{});a.setValuesIn("params.values",h),e(u.value)}return r.jsx(Oe,I(v({},t),{onChange:p}))}class La extends Q{constructor(){super(...arguments),this.title=`{{t("Update record", { ns: "${m}" })}}`,this.type="update",this.group="collection",this.icon="SignatureOutlined",this.color="#f4952f",this.description=`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-reactions":[...ve["x-reactions"],{target:"params",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}},{target:"params.values",effects:["onFieldValueChange"],fulfill:{state:{value:"{{Object.create({})}}"}}}]}),params:{type:"object",properties:{individualHooks:{type:"boolean",title:`{{t("Update mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"IndividualHooksRadioWithTooltip","x-component-props":{options:[{label:`{{t("Update in a batch", { ns: "${m}" })}}`,value:!1,tooltip:`{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${m}" })}}`},{label:`{{t("Update one by one", { ns: "${m}" })}}`,value:!0,tooltip:`{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${m}" })}}`}]},default:!1},filter:I(v({},wt),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(t){return ht(t)?"":F("Please add at least one condition")}}),values:I(v({},Zo),{"x-component-props":{filter(t){var o;return((o=this.params)==null?void 0:o.individualHooks)||![].includes(t.type)}}})}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={FilterDynamicComponent:De,CollectionFieldset:Qo,IndividualHooksRadioWithTooltip:za}}}const qa=new s.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:s.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=s.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:s.SecondConFirm},{name:"assignFieldValues",Component:s.AssignedFieldValues},{name:"skipRequiredValidation",Component:s.SkipValidation},{name:"afterSuccessfulSubmission",Component:s.AfterSuccess,useVisible(){var t;const e=S.useFieldSchema();return S.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:s.WorkflowConfig},{name:"delete",sort:100,Component:s.RemoveButton,useComponentProps(){const{removeButtonProps:e}=s.useSchemaToolbar();return e}}]}),Ve={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},Ua=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Ve.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Ve.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Ve.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Ve.DELETED}];class Ka extends Qe{constructor(){super(...arguments),this.title=`{{t("Collection event", { ns: "${m}" })}}`,this.description=`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`,this.fieldset={collection:I(v({},ve),{"x-disabled":"{{ useWorkflowAnyExecuted() }}","x-component-props":{dataSourceFilter(t){return t.options.key==="main"||t.options.isDBInstance}},"x-reactions":[...ve["x-reactions"],{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"blacklist",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}},{target:"condition",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]}),mode:{type:"number",title:`{{t("Trigger on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{popupMatchSelectWidth:!1,placeholder:`{{t("Trigger on", { ns: "${m}" })}}`,className:"auto-width"},enum:Ua,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},blacklist:{type:"array",title:`{{t("Changed fields - blacklist", { ns: "${m}" })}}`,description:`{{t("Triggered only if none of the selected fields changes. When record is added or deleted, this field has no effect.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.UPDATED})}}`}}}]},changed:{type:"array",title:`{{t("Changed fields", { ns: "${m}" })}}`,description:`{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"FieldsSelect","x-component-props":{mode:"multiple",placeholder:'{{t("Select field")}}',filter(t){return!t.hidden&&(t.uiSchema?!t.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(t.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Ve.UPDATED})}}`}}}]},condition:I(v({},wt),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:I(v({},rt),{"x-reactions":[...rt["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Ve.DELETED})}}`}}}]})},this.scope={useCollectionDataSource:s.useCollectionDataSource,useWorkflowAnyExecuted:Do},this.components={FieldsSelect:et}}useVariables(t,o){var c;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}];return ue(I(v({appends:["data",...((c=t.appends)==null?void 0:c.map(d=>`data.${d}`))||[]]},o),{fields:a,compile:n,getCollectionFields:i}))}useInitializers(t){return t.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const We={STATIC:0,DATE_FIELD:1};function _a(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function Xo({value:e,onChange:t}){const o=e!=null?e:{},{t:n}=X.useTranslation(),[i,a]=b.useState(o.offset?o.offset/Math.abs(o.offset):0);return r.jsxs("fieldset",{className:s.css`
833
833
  display: flex;
834
834
  gap: 0.5em;
835
835
  `,children:[r.jsx(et,{value:o.field,onChange:l=>t(I(v({},o),{field:l})),filter:_a,placeholder:n("Select field"),className:"auto-width"}),o.field?r.jsx(x.Select,{value:i,onChange:l=>{a(l),t(I(v({},o),{offset:Math.abs(o.offset)*l}))},options:[{value:0,label:F("Exactly at")},{value:-1,label:n("Before")},{value:1,label:n("After")}],className:"auto-width"}):null,i?r.jsxs(r.Fragment,{children:[r.jsx(x.InputNumber,{value:Math.abs(o.offset),onChange:l=>t(I(v({},o),{offset:(l!=null?l:0)*i}))}),r.jsx(x.Select,{value:o.unit||864e5,onChange:l=>t(I(v({},o),{unit:l})),options:[{value:864e5,label:F("Days")},{value:36e5,label:F("Hours")},{value:6e4,label:F("Minutes")},{value:1e3,label:F("Seconds")}],className:"auto-width"})]}):null]})}function Ga({value:e,onChange:t}){const{t:o}=Ce(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:s.css`
@@ -873,4 +873,4 @@ export default async function (
873
873
  .ant-picker {
874
874
  width: auto;
875
875
  }
876
- `},properties:sl[o]}}},components:{OnField:Xo,RepeatField:rl,EndsByField:Ga}})]})};class ll extends Qe{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:al}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&a.push({key:"date",value:"date",label:F("Trigger time")}),t.mode===We.DATE_FIELD){const[c]=ue(I(v({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}));c&&a.push(c)}return a}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const Xt={name:"executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=nr(e,t);return r.jsx(s.Input,{type:"text",value:o})},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.useActionContext();return r.jsx(oe.Link,{to:Be(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:pt}}]},fn=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:Xt,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=Ce(),{refresh:n,params:i}=s.useDataBlockRequest(),a=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return O(this,null,function*(){yield a.destroy({filter:i==null?void 0:i.filter}),x.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},Rt=fn();function cl(n){var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const{workflow:a}=q(),l=I(v({},o),{params:I(v({},e),{filter:I(v({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,v({},l))}function dl(){var se;const e=oe.useNavigate(),{t}=X.useTranslation(),o=s.useApp(),{data:n,refresh:i,loading:a}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,p]=b.useState(!1),[u,f]=b.useState(!1),[h,g]=b.useState(null),{styles:y}=ge(),{modal:w}=x.App.useApp();if(b.useEffect(()=>{var L;const{title:M}=(L=n==null?void 0:n.data)!=null?L:{};c==null||c(`${F("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(x.Spin,{}):r.jsx(x.Result,{status:"404",title:"Not found"});const V=(se=n==null?void 0:n.data)!=null?se:{},{nodes:A=[],revisions:T=[]}=V,C=K(V,["nodes","revisions"]);ft(A);const D=A.find(M=>!M.upstream);function $({key:M}){M!==C.id&&e(Be(M))}function E(M){return O(this,null,function*(){yield l.update({filterByTk:C.id,values:{enabled:M}}),i()})}function P(){return O(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:C.id,filter:{key:C.key}});e(yt(M.executionId))})}function B(){return O(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:C.id,filter:{key:C.key}});x.message.success(t("Operation succeeded")),e(Be(M.id))})}function _(){return O(this,null,function*(){const M=C.current?F("Delete a main version will cause all other revisions to be deleted too."):"";w.confirm({title:t("Are you sure you want to delete it?"),content:M,onOk(){return O(this,null,function*(){var R;yield l.destroy({filterByTk:C.id}),x.message.success(t("Operation succeeded")),e(C.current?o.systemSettingsManager.getRoutePath("workflow"):Be((R=T.find(H=>H.current))==null?void 0:R.id))})}})})}const z=()=>O(this,null,function*(){h?(yield l.moveWorkflow({id:C.id,targetKey:h}),x.message.success(F("Move success")),f(!1),C.key=h,i()):x.message.error(F("Select target workflow"))});function J(L){return O(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return P();case"revision":return B();case"delete":return _();case"move":g(null),f(!0);return}})}const Y=C.executed&&!T.find(M=>!M.executed&&new Date(M.createdAt)>new Date(C.createdAt));return r.jsxs(qe.Provider,{value:{workflow:C,nodes:A,refresh:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(go,{}),r.jsx(x.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx("strong",{children:C.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:$,defaultSelectedKeys:[`${C.id}`],className:s.cx(y.dropdownClass,y.workflowVersionDropdownClass),items:T.sort((M,L)=>L.id-M.id).map((M,L)=>({role:"button","aria-label":`version-${L}`,key:`${M.id}`,icon:M.current?r.jsx(j.RightOutlined,{}):null,className:s.cx({executed:M.executed,unexecuted:!M.executed,enabled:M.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${M.id}`}),r.jsx("time",{children:W.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:F("Version")}),r.jsx("span",{children:C!=null&&C.id?`#${C.id}`:null}),r.jsx(j.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:C.enabled,onChange:E,checkedChildren:F("On"),unCheckedChildren:F("Off")}),r.jsx(x.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:F("Execution history"),disabled:!C.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:F("Retry"),disabled:!C.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:F("Copy to new version"),disabled:!Y},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:F("Move"),disabled:C.current}],onClick:J},children:r.jsx(x.Button,{"aria-label":"more",type:"text",icon:r.jsx(j.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:Rt,components:{ExecutionResourceProvider:cl,ExecutionLink:Gt,ExecutionStatusColumn:Kt},scope:{ExecutionRetryAction:Ht}})})]})]}),r.jsx(ho,{entry:D}),r.jsxs(x.Modal,{title:F("Move workflow"),visible:u,onOk:z,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:F("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:h,filterType:C.type,filterSync:C.sync,filterKey:{$ne:C.key},onChange:M=>g(M)})]})]})}const hn=()=>{const e=oe.useParams(),{styles:t}=ge();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:dl}})})},pl=()=>{var a;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(a=e.config)==null?void 0:a.collection,n=t.getCollection(o),i=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:i})},ul=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:i,title:a}=e,l=n.find(c=>c.value===i);return r.jsx(x.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:a})})},ml=n=>{var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const a=s.useCollectionRecordData(),l=I(v({},o),{params:I(v({},e),{filter:I(v({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,v({},l))};var it=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},gn={exports:{}};(function(e,t){(function(o,n){n()})(it,function(){function o(p,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function n(p,u,f){var h=new XMLHttpRequest;h.open("GET",p),h.responseType="blob",h.onload=function(){d(h.response,u,f)},h.onerror=function(){console.error("could not download file")},h.send()}function i(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function a(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(f){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof it=="object"&&it.global===it?it:void 0,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(p,u,f){var h=l.URL||l.webkitURL,g=document.createElement("a");u=u||p.name||"download",g.download=u,g.rel="noopener",typeof p=="string"?(g.href=p,g.origin===location.origin?a(g):i(g.href)?n(p,u,f):a(g,g.target="_blank")):(g.href=h.createObjectURL(p),setTimeout(function(){h.revokeObjectURL(g.href)},4e4),setTimeout(function(){a(g)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,f){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,f),u);else if(i(p))n(p,u,f);else{var h=document.createElement("a");h.href=p,h.target="_blank",setTimeout(function(){a(h)})}}:function(p,u,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,f);var g=p.type==="application/octet-stream",y=/constructor/i.test(l.HTMLElement)||l.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||g&&y||c)&&typeof FileReader!="undefined"){var A=new FileReader;A.onloadend=function(){var D=A.result;D=w?D:D.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=D:location=D,h=null},A.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,C=T.createObjectURL(p);h?h.location=C:location.href=C,h=null,setTimeout(function(){T.revokeObjectURL(C)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})})(gn);var fl=gn.exports;const eo=S.observable({value:""}),yn=[{value:"0",label:"分类一"},{value:"1",label:"分类二"},{value:"2",label:"分类三"},{value:"3",label:"分类四"},{value:"4",label:"分类五"},{value:"5",label:"分类六"}],ze={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"array",name:"tags",interface:"multipleSelect",uiSchema:{title:'{{t("Tags")}}',type:"array",enum:yn,"x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:N("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},me={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${m}" }) }}`}]}},tags:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},xn={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${ze.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:ze},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:me.title,tags:me.tags,type:me.type,sync:me.sync,description:me.description,options:me.options}}}}}}}},bn={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${ze.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:ze},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:me.title,tags:me.tags,type:me.type,enabled:me.enabled,sync:me.sync,description:me.description,options:me.options}}}}}}}},hl={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=X.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=S.useForm();return{run(){return O(this,null,function*(){yield o.revision({filterByTk:i,values:a}),x.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},gl={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Test workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',description:`{{t("Data is the trigger variable, it can be { data: 0 }, or { data: { id: 0 }}", { ns: "${m}" })}}`,"x-decorator":"FormItem",default:{data:{}},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:20,maxRows:50}}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){X.useTranslation();const{refresh:e}=s.useDataBlockRequest(),t=s.useDataBlockResource(),{setVisible:o}=s.useActionContext(),n=s.useFilterByTk(),{values:i}=S.useForm();return{run(){return O(this,null,function*(){yield t.test({filterByTk:n,values:i.params}),e(),o(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},yl=({children:e})=>r.jsx(x.Tabs,{type:"card",onChange:t=>{eo.value=t},items:[{value:"",label:F("All")}].concat(yn).map(({label:t,value:o},n)=>({label:t,key:o,children:r.jsx(s.CardItem,{children:e})}))}),vn={type:"void",properties:{provider:{type:"void","x-decorator":S.observer(e=>{const t={collection:ze,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return eo.value&&(t.params.filter.tags={$anyOf:[eo.value]}),r.jsx(s.TableBlockProvider,v(v({},e),t))}),"x-component":yl,properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=X.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useFilterByTk(),{setVisible:a}=s.useActionContext(),{values:l}=S.useForm();return{run(){return O(this,null,function*(){const{data:d}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:i,values:I(v({},l),{workflow:d})}),x.message.success(e("Operation succeeded")),o(),a(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:xn}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},tags:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},title:'{{t("Tags")}}',properties:{tags:{type:"array","x-component":"CollectionField","x-read-pretty":!0}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:N("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return b.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Rt}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:bn,revision:hl,test:gl,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{t:e}=X.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return O(this,null,function*(){const{data:i}=yield t.dump({filterByTk:o}),a=new Blob([JSON.stringify(i.data,null,2)],{type:"application/json"});fl.saveAs(a,i.data.title+"-"+i.data.key+".json"),x.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},xl=()=>{const{t:e}=X.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:Be(t),onClick:()=>o(!1),children:e("Configure")})};function bl(e){const t=S.useField(),o=s.usePlugin(Z);return S.useFormEffects(()=>{S.onFieldChange("type",n=>{let i=!n.value;if(n.value){const a=o.triggers.get(n.value);a.sync!=null&&(i=!0,t.setValue(a.sync))}t.setPattern(i?"disabled":"editable")})}),r.jsx(Oe,v({},e))}function wn(e){const{schema:t=vn,components:o,scopes:n}=e,i=b.useContext(s.SchemaComponentContext),{getTriggersOptions:a}=s.usePlugin(Z);return r.jsx(s.ExtendCollectionsProvider,{collections:[ze,Xt],children:r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},i),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:v({WorkflowLink:xl,ExecutionResourceProvider:ml,ExecutionLink:Gt,OpenDrawer:Io,ExecutionStatusSelect:To,SyncOptionSelect:bl,ExecutionStatusColumn:Kt,ColumnShowTitle:ul,ColumnShowCollection:pl},o),scope:v({getTriggersOptions:a,ExecutionRetryAction:Ht},n)})})})}class Z extends s.Plugin{constructor(){super(...arguments),this.triggers=new W.Registry,this.instructions=new W.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(i=>{var[t,a]=i,l=a,{title:o}=l,n=K(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof Q)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return O(this,null,function*(){yield this.pm.add(oa),yield this.pm.add(Qi),yield this.pm.add(Ji),yield this.pm.add(Ls),yield this.pm.add(Xr),yield this.pm.add(Ir),yield this.pm.add(yr),yield this.pm.add(mr),yield this.pm.add(ea),yield this.pm.add(_r),yield this.pm.add(ca),yield this.pm.add(Xi),yield this.pm.add(Gi),yield this.pm.add(sa),yield this.pm.add(Bi),yield this.pm.add(Yr),yield this.pm.add(Hr)})}load(){return O(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:wn,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:hn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:yo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(qa),this.registerTrigger("collection",Ka),this.registerTrigger("schedule",ll),this.registerInstruction("calculation",da),this.registerInstruction("condition",Pa),this.registerInstruction("end",Wa),this.registerInstruction("query",ja),this.registerInstruction("create",Ba),this.registerInstruction("update",La),this.registerInstruction("destroy",Va)})}addComponents(){this.app.addComponents({WorkflowLink:zn,WorkflowPage:hn,ExecutionPage:yo})}}k.AddButton=Bt,k.AdditionNotifiedPerson=zr,k.AutoResizeInput=No,k.BaseTypeSets=Ne,k.Branch=$e,k.BuiltinGroupType=Ue,k.CheckboxGroupWithTooltip=Ao,k.CollectionBlockInitializer=Te,k.ConfigButtonMessage=qr,k.DetailsBlockProvider=Vt,k.EXECUTION_STATUS=de,k.ExecutionContextProvider=Ko,k.ExecutionLink=Gt,k.ExecutionRetryAction=Ht,k.ExecutionStatusColumn=Kt,k.ExecutionStatusOptions=pt,k.ExecutionStatusOptionsMap=ut,k.ExecutionStatusSelect=To,k.FieldsSelect=et,k.FilterDynamicComponent=De,k.FlowContext=qe,k.Instruction=Q,k.JOB_STATUS=ye,k.JobStatusOptions=mt,k.JobStatusOptionsMap=Re,k.Node=ao,k.NodeDefaultView=nt,k.OpenDrawer=Io,k.ProviderContextNode=io,k.RadioWithTooltip=Oe,k.SelectNotifiedPerson=Br,k.SimpleDesigner=Ut,k.Trigger=Qe,k.ValueBlock=Se,k.WorkflowPane=wn,k.WorkflowVariableCodeMirror=Pr,k.WorkflowVariableInput=ke,k.WorkflowVariableJSON=So,k.WorkflowVariableRawTextArea=ko,k.WorkflowVariableTextArea=ot,k.collectionWorkflows=ze,k.createWorkflow=xn,k.currentFormOptions=bo,k.default=Z,k.defaultFieldNames=pe,k.executionCollection=Xt,k.executionSchema=Rt,k.getCollectionFieldOptions=ue,k.getExecutionSchema=fn,k.getWorkflowDetailPath=Be,k.getWorkflowExecutionsPath=yt,k.isValidFilter=ht,k.linkNodes=ft,k.nodesOptions=xt,k.scopeOptions=Wt,k.systemOptions=vo,k.traverseSchema=gt,k.triggerOptions=bt,k.updateWorkflow=bn,k.useAvailableUpstreams=Ee,k.useContextNode=he,k.useFlowContext=q,k.useGetAriaLabelOfAddButton=dt,k.useRecordTriggerWorkflowsActionProps=Us,k.useStyles=ge,k.useTrigger=Ze,k.useTriggerWorkflowsActionProps=qs,k.useWorkflowAnyExecuted=Do,k.useWorkflowExecuted=_t,k.useWorkflowVariableFormOptions=Co,k.useWorkflowVariableOptions=le,k.workflowFieldset=me,k.workflowSchema=vn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
876
+ `},properties:sl[o]}}},components:{OnField:Xo,RepeatField:rl,EndsByField:Ga}})]})};class ll extends Qe{constructor(){super(...arguments),this.sync=!1,this.title=`{{t("Schedule event", { ns: "${m}" })}}`,this.description=`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`,this.fieldset={config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}},this.scope={useCollectionDataSource:s.useCollectionDataSource},this.components={ScheduleConfig:al}}useVariables(t,o){var l;const n=s.useCompile(),{getCollectionFields:i}=s.useCollectionManager_deprecated(),a=[];if((!(o!=null&&o.types)||o.types.includes("date"))&&a.push({key:"date",value:"date",label:F("Trigger time")}),t.mode===We.DATE_FIELD){const[c]=ue(I(v({appends:["data",...((l=t.appends)==null?void 0:l.map(d=>`data.${d}`))||[]]},o),{fields:[{collectionName:t.collection,name:"data",type:"hasOne",target:t.collection,uiSchema:{title:F("Trigger data")}}],compile:n,getCollectionFields:i}));c&&a.push(c)}return a}useInitializers(t){return t.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Te,collection:t.collection,dataPath:"$context.data"}:null}}const Xt={name:"executions",fields:[{interface:"id",type:"bigInt",name:"id",uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"createdAt",type:"datetime",name:"createdAt",uiSchema:{type:"datetime",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{interface:"bigInt",type:"bigInt",name:"executionCost",uiSchema:{type:"bigInt",title:`{{t("Execution time", { ns: "${m}" })}}`,"x-component":({value:e})=>{const t=s.useCollectionRecordData(),o=nr(e,t);return r.jsx(s.Input,{type:"text",value:o})},"x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=s.useActionContext();return r.jsx(oe.Link,{to:Be(e),onClick:()=>t(!1),children:`#${e}`})}}},{type:"number",name:"status",interface:"select",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string","x-component":"Select","x-decorator":"FormItem",enum:pt}}]},fn=e=>{const{isShowActionClear:t=!0}=e||{};return{type:"void",name:"executionHistoryDrawer",title:`{{t("Execution history", { ns: "${m}" })}}`,"x-component":"Action.Drawer",properties:{content:{type:"void","x-decorator":"ExecutionResourceProvider","x-decorator-props":{collection:Xt,dataSource:"main",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{isShow:t,useAction(){const{t:o}=Ce(),{refresh:n,params:i}=s.useDataBlockRequest(),a=s.useDataBlockResource(),{setVisible:l}=s.useActionContext();return{run(){return O(this,null,function*(){yield a.destroy({filter:i==null?void 0:i.filter}),x.message.success(o("Operation succeeded")),n(),l(!1)})}}},confirm:{title:`{{t("Clear all executions", { ns: "${m}" })}}`,content:`{{t("Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?", { ns: "${m}" })}}`}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{width:50},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"},retry:{type:"void",title:`{{t("Retry", { ns: "${m}" })}}`,"x-component":"Action.Link","x-use-component-props":"ExecutionRetryAction"}}}}},id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100},properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},executionCost:{type:"void",title:`{{t("Executed time", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{executionCost:{type:"bigInt","x-component":"CollectionField","x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void",title:`{{t("Status", { ns: "${m}" })}}`,"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}}},Rt=fn();function cl(n){var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const{workflow:a}=q(),l=I(v({},o),{params:I(v({},e),{filter:I(v({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,v({},l))}function dl(){var se;const e=oe.useNavigate(),{t}=X.useTranslation(),o=s.useApp(),{data:n,refresh:i,loading:a}=s.useResourceActionContext(),{resource:l}=s.useResourceContext(),{setTitle:c}=s.useDocumentTitle(),[d,p]=b.useState(!1),[u,f]=b.useState(!1),[h,g]=b.useState(null),{styles:y}=ge(),{modal:w}=x.App.useApp();if(b.useEffect(()=>{var L;const{title:M}=(L=n==null?void 0:n.data)!=null?L:{};c==null||c(`${F("Workflow")}${M?`: ${M}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return a?r.jsx(x.Spin,{}):r.jsx(x.Result,{status:"404",title:"Not found"});const V=(se=n==null?void 0:n.data)!=null?se:{},{nodes:A=[],revisions:T=[]}=V,C=K(V,["nodes","revisions"]);ft(A);const D=A.find(M=>!M.upstream);function $({key:M}){M!==C.id&&e(Be(M))}function E(M){return O(this,null,function*(){yield l.update({filterByTk:C.id,values:{enabled:M}}),i()})}function P(){return O(this,null,function*(){const{data:{data:M}}=yield l.retry({filterByTk:C.id,filter:{key:C.key}});e(yt(M.executionId))})}function B(){return O(this,null,function*(){const{data:{data:M}}=yield l.revision({filterByTk:C.id,filter:{key:C.key}});x.message.success(t("Operation succeeded")),e(Be(M.id))})}function _(){return O(this,null,function*(){const M=C.current?F("Delete a main version will cause all other revisions to be deleted too."):"";w.confirm({title:t("Are you sure you want to delete it?"),content:M,onOk(){return O(this,null,function*(){var R;yield l.destroy({filterByTk:C.id}),x.message.success(t("Operation succeeded")),e(C.current?o.systemSettingsManager.getRoutePath("workflow"):Be((R=T.find(H=>H.current))==null?void 0:R.id))})}})})}const z=()=>O(this,null,function*(){h?(yield l.moveWorkflow({id:C.id,targetKey:h}),x.message.success(F("Move success")),f(!1),C.key=h,i()):x.message.error(F("Select target workflow"))});function J(L){return O(this,arguments,function*({key:M}){switch(M){case"history":p(!0);return;case"Retry":return P();case"revision":return B();case"delete":return _();case"move":g(null),f(!0);return}})}const Y=C.executed&&!T.find(M=>!M.executed&&new Date(M.createdAt)>new Date(C.createdAt));return r.jsxs(qe.Provider,{value:{workflow:C,nodes:A,refresh:i},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsxs("header",{children:[r.jsx(go,{}),r.jsx(x.Breadcrumb,{items:[{title:r.jsx(oe.Link,{to:o.systemSettingsManager.getRoutePath(`business-components.${m}`),children:F("Workflow")})},{title:r.jsx("strong",{children:C.title})}]})]}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(x.Dropdown,{trigger:["click"],menu:{onClick:$,defaultSelectedKeys:[`${C.id}`],className:s.cx(y.dropdownClass,y.workflowVersionDropdownClass),items:T.sort((M,L)=>L.id-M.id).map((M,L)=>({role:"button","aria-label":`version-${L}`,key:`${M.id}`,icon:M.current?r.jsx(j.RightOutlined,{}):null,className:s.cx({executed:M.executed,unexecuted:!M.executed,enabled:M.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${M.id}`}),r.jsx("time",{children:W.str2moment(M.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(x.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:F("Version")}),r.jsx("span",{children:C!=null&&C.id?`#${C.id}`:null}),r.jsx(j.DownOutlined,{})]})})}),r.jsx(x.Switch,{checked:C.enabled,onChange:E,checkedChildren:F("On"),unCheckedChildren:F("Off")}),r.jsx(x.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:F("Execution history"),disabled:!C.allExecuted},{role:"button","aria-label":"Retry",key:"Retry",label:F("Retry"),disabled:!C.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:F("Copy to new version"),disabled:!Y},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")},{role:"button","aria-label":"move",key:"move",label:F("Move"),disabled:C.current}],onClick:J},children:r.jsx(x.Button,{"aria-label":"more",type:"text",icon:r.jsx(j.EllipsisOutlined,{})})}),r.jsx(s.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(s.SchemaComponent,{schema:Rt,components:{ExecutionResourceProvider:cl,ExecutionLink:Gt,ExecutionStatusColumn:Kt},scope:{ExecutionRetryAction:Ht}})})]})]}),r.jsx(ho,{entry:D}),r.jsxs(x.Modal,{title:F("Move workflow"),visible:u,onOk:z,onCancel:()=>{f(!1)},children:[r.jsx("p",{children:F("Move current version to another workflow")}),r.jsx(s.WorkflowSelect,{buttonAction:"submit",noCollection:!0,label:"title",actionType:"update",value:h,filterType:C.type,filterSync:C.sync,filterKey:{$ne:C.key},onChange:M=>g(M)})]})]})}const hn=()=>{const e=oe.useParams(),{styles:t}=ge();return r.jsx("div",{className:s.cx(t.workflowPageClass),children:r.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[`provider_${e.id}`]:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"workflows",fields:[]},resourceName:"workflows",request:{resource:"workflows",action:"get",params:{filter:{id:e.id},appends:["createdBy","nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:dl}})})},pl=()=>{var a;const e=s.useCollectionRecordData(),t=s.useCollectionManager(),o=(a=e.config)==null?void 0:a.collection,n=t.getCollection(o),i=o?`${n==null?void 0:n.options.title}(${o})`:"-";return r.jsx("div",{style:{textAlign:"left"},children:i})},ul=()=>{const e=s.useCollectionRecordData(),t=s.useCompile(),n=s.usePlugin("workflow").getTriggersOptions(),{type:i,title:a}=e,l=n.find(c=>c.value===i);return r.jsx(x.Tooltip,{title:t(l.label),placement:"right",color:"cyan",children:r.jsx("span",{style:{textAlign:"left",cursor:"pointer"},children:a})})},ml=n=>{var i=n,{params:e,filter:t={}}=i,o=K(i,["params","filter"]);const a=s.useCollectionRecordData(),l=I(v({},o),{params:I(v({},e),{filter:I(v({},e==null?void 0:e.filter),{key:a.key})})});return r.jsx(s.TableBlockProvider,v({},l))};var it=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},gn={exports:{}};(function(e,t){(function(o,n){n()})(it,function(){function o(p,u){return typeof u=="undefined"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function n(p,u,f){var h=new XMLHttpRequest;h.open("GET",p),h.responseType="blob",h.onload=function(){d(h.response,u,f)},h.onerror=function(){console.error("could not download file")},h.send()}function i(p){var u=new XMLHttpRequest;u.open("HEAD",p,!1);try{u.send()}catch(f){}return 200<=u.status&&299>=u.status}function a(p){try{p.dispatchEvent(new MouseEvent("click"))}catch(f){var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(u)}}var l=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof it=="object"&&it.global===it?it:void 0,c=l.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=l.saveAs||(typeof window!="object"||window!==l?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(p,u,f){var h=l.URL||l.webkitURL,g=document.createElement("a");u=u||p.name||"download",g.download=u,g.rel="noopener",typeof p=="string"?(g.href=p,g.origin===location.origin?a(g):i(g.href)?n(p,u,f):a(g,g.target="_blank")):(g.href=h.createObjectURL(p),setTimeout(function(){h.revokeObjectURL(g.href)},4e4),setTimeout(function(){a(g)},0))}:"msSaveOrOpenBlob"in navigator?function(p,u,f){if(u=u||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(o(p,f),u);else if(i(p))n(p,u,f);else{var h=document.createElement("a");h.href=p,h.target="_blank",setTimeout(function(){a(h)})}}:function(p,u,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof p=="string")return n(p,u,f);var g=p.type==="application/octet-stream",y=/constructor/i.test(l.HTMLElement)||l.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||g&&y||c)&&typeof FileReader!="undefined"){var A=new FileReader;A.onloadend=function(){var D=A.result;D=w?D:D.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=D:location=D,h=null},A.readAsDataURL(p)}else{var T=l.URL||l.webkitURL,C=T.createObjectURL(p);h?h.location=C:location.href=C,h=null,setTimeout(function(){T.revokeObjectURL(C)},4e4)}});l.saveAs=d.saveAs=d,e.exports=d})})(gn);var fl=gn.exports;const eo=S.observable({value:""}),yn=[{value:"0",label:"分类一"},{value:"1",label:"分类二"},{value:"2",label:"分类三"},{value:"3",label:"分类四"},{value:"4",label:"分类五"},{value:"5",label:"分类六"}],ze={name:"workflows",fields:[{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Trigger type", { ns: "${m}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{type:"array",name:"tags",interface:"multipleSelect",uiSchema:{title:'{{t("Tags")}}',type:"array",enum:yn,"x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:`{{t("Status", { ns: "${m}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${m}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${m}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${m}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:N("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"workflows",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},me={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem",default:"general-action","x-hidden":!0},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Queue Mode", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Transactional Mode", { ns: "${m}" }) }}`,value:!0,tooltip:`{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "${m}" }) }}`}]}},tags:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"fieldset",properties:{deleteExecutionOnStatus:{type:"array",title:`{{ t("Auto delete history when execution is on end status", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},xn={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${ze.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:ze},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:me.title,tags:me.tags,type:me.type,sync:me.sync,description:me.description,options:me.options}}}}}}}},bn={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${ze.name}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:ze},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"},"x-action-settings":{isDeltaChanged:!0}}}},title:me.title,tags:me.tags,type:me.type,enabled:me.enabled,sync:me.sync,description:me.description,options:me.options}}}}}}}},hl={type:"void",title:`{{t("Duplicate", { ns: "${m}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=X.useTranslation(),{refresh:t}=s.useDataBlockRequest(),o=s.useDataBlockResource(),{setVisible:n}=s.useActionContext(),i=s.useFilterByTk(),{values:a}=S.useForm();return{run(){return O(this,null,function*(){yield o.revision({filterByTk:i,values:a}),x.message.success(e("Operation succeeded")),t(),n(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},gl={type:"void",title:`{{t("Test", { ns: "${m}" })}}`,"x-component":"Action.Link",properties:{modal:{type:"void",title:`{{t("Test workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{params:{type:"string",title:'{{t("Input")}}',description:`{{t("Data is the trigger variable, it can be { data: 0 }, or { data: { id: 0 }}", { ns: "${m}" })}}`,"x-decorator":"FormItem",default:{data:{}},"x-component":"Input.JSON","x-component-props":{autoSize:{minRows:20,maxRows:50}}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){X.useTranslation();const{refresh:e}=s.useDataBlockRequest(),t=s.useDataBlockResource(),{setVisible:o}=s.useActionContext(),n=s.useFilterByTk(),{values:i}=S.useForm();return{run(){return O(this,null,function*(){yield t.test({filterByTk:n,values:i.params}),e(),o(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},yl=({children:e})=>r.jsx(x.Tabs,{type:"card",onChange:t=>{eo.value=t},items:[{value:"",label:F("All")}].concat(yn).map(({label:t,value:o},n)=>({label:t,key:o,children:r.jsx(s.CardItem,{children:e})}))}),vn={type:"void",properties:{provider:{type:"void","x-decorator":S.observer(e=>{const t={collection:ze,action:"list",params:{filter:{current:!0,type:{$not:"approval"}},sort:["-initAt"]},rowKey:"id"};return eo.value&&(t.params.filter.tags={$anyOf:[eo.value]}),r.jsx(s.TableBlockProvider,v(v({},e),t))}),"x-component":yl,properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},load:{type:"void",title:`{{t("Load", { ns: "${m}" })}}`,"x-component":"Action","x-component-props":{icon:"UploadOutlined",openSize:"small"},properties:{modal:{type:"void",title:`{{t("Load a workflow", { ns: "${m}" })}}`,"x-decorator":"FormV2","x-component":"Action.Modal",properties:{title:{type:"string",title:'{{t("Title")}}',"x-decorator":"FormItem","x-component":"Input"},file:{type:"object",title:'{{ t("File") }}',required:!0,"x-decorator":"FormItem","x-component":"Upload.Attachment","x-component-props":{action:"attachments:create",multiple:!1}},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction(){const{t:e}=X.useTranslation(),t=s.useAPIClient(),{refresh:o}=s.useDataBlockRequest(),n=s.useDataBlockResource(),i=s.useFilterByTk(),{setVisible:a}=s.useActionContext(),{values:l}=S.useForm();return{run(){return O(this,null,function*(){const{data:d}=yield t.request({url:l.file.url,baseURL:"/"});yield n.load({filterByTk:i,values:I(v({},l),{workflow:d})}),x.message.success(e("Operation succeeded")),o(),a(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"}}}}}}},create:xn}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0},title:'{{t("Name")}}',properties:{title:{type:"string","x-component":"ColumnShowTitle"}}},tags:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},title:'{{t("Tags")}}',properties:{tags:{type:"array","x-component":"CollectionField","x-read-pretty":!0}}},showCollection:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:N("Collection"),properties:{showCollection:{type:"string","x-component":"ColumnShowCollection"}}},enabled:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=s.useCollectionRecordData();return b.createElement("a",v({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:Rt}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"workflows.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:bn,revision:hl,test:gl,delete:{type:"void",title:'{{t("Delete")}}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},dump:{type:"void",title:'{{ t("Dump") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{t:e}=X.useTranslation(),t=s.useDataBlockResource(),o=s.useFilterByTk();return{run(){return O(this,null,function*(){const{data:i}=yield t.dump({filterByTk:o}),a=new Blob([JSON.stringify(i.data,null,2)],{type:"application/json"});fl.saveAs(a,i.data.title+"-"+i.data.key+".json"),x.message.success(e("Operation succeeded"))})}}}}}}}}}}}}}}},xl=()=>{const{t:e}=X.useTranslation(),{id:t}=s.useRecord(),{setVisible:o}=s.useActionContext(),{getAriaLabel:n}=s.useGetAriaLabelOfAction("Configure");return r.jsx(oe.Link,{"aria-label":n(),to:Be(t),onClick:()=>o(!1),children:e("Configure")})};function bl(e){const t=S.useField(),o=s.usePlugin(Z);return S.useFormEffects(()=>{S.onFieldChange("type",n=>{let i=!n.value;if(n.value){const a=o.triggers.get(n.value);a.sync!=null&&(i=!0,t.setValue(a.sync))}t.setPattern(i?"disabled":"editable")})}),r.jsx(Oe,v({},e))}function wn(e){const{schema:t=vn,components:o,scopes:n}=e,i=b.useContext(s.SchemaComponentContext),{getTriggersOptions:a}=s.usePlugin(Z);return r.jsx(s.ExtendCollectionsProvider,{collections:[ze,Xt],children:r.jsx(s.SchemaComponentContext.Provider,{value:I(v({},i),{designable:!1}),children:r.jsx(s.SchemaComponent,{schema:t,components:v({WorkflowLink:xl,ExecutionResourceProvider:ml,ExecutionLink:Gt,OpenDrawer:Io,ExecutionStatusSelect:To,SyncOptionSelect:bl,ExecutionStatusColumn:Kt,ColumnShowTitle:ul,ColumnShowCollection:pl},o),scope:v({getTriggersOptions:a,ExecutionRetryAction:Ht},n)})})})}class Z extends s.Plugin{constructor(){super(...arguments),this.triggers=new W.Registry,this.instructions=new W.Registry,this.getTriggersOptions=()=>Array.from(this.triggers.getEntities()).map(i=>{var[t,a]=i,l=a,{title:o}=l,n=K(l,["title"]);return{value:t,label:o,color:"gold",options:n}})}isWorkflowSync(t){var o;return(o=this.triggers.get(t.type).sync)!=null?o:t.sync}registerTrigger(t,o){if(typeof o=="function")this.triggers.register(t,new o);else if(o)this.triggers.register(t,o);else throw new TypeError("invalid trigger type to register")}registerInstruction(t,o){if(typeof o=="function")this.instructions.register(t,new o);else if(o instanceof Q)this.instructions.register(t,o);else throw new TypeError("invalid instruction type to register")}afterAdd(){return O(this,null,function*(){yield this.pm.add(oa),yield this.pm.add(Qi),yield this.pm.add(Ji),yield this.pm.add(Ls),yield this.pm.add(Xr),yield this.pm.add(Ir),yield this.pm.add(yr),yield this.pm.add(mr),yield this.pm.add(ea),yield this.pm.add(_r),yield this.pm.add(ca),yield this.pm.add(Xi),yield this.pm.add(Gi),yield this.pm.add(sa),yield this.pm.add(Bi),yield this.pm.add(Yr),yield this.pm.add(Hr)})}load(){return O(this,null,function*(){this.addComponents(),this.app.systemSettingsManager.add(`business-components.${m}`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:wn,aclSnippet:"pm.workflow.workflows",sort:-80}),this.app.systemSettingsManager.add(`business-components.${m}/:id`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.workflow`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:hn,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.systemSettingsManager.add(`business-components.${m}/:id.executions`,{icon:"workflow",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:yo,fullscreen:!0,groupKey:`business-components.${m}`}),this.app.schemaSettingsManager.add(qa),this.registerTrigger("collection",Ka),this.registerTrigger("schedule",ll),this.registerInstruction("calculation",da),this.registerInstruction("condition",Pa),this.registerInstruction("end",Wa),this.registerInstruction("query",ja),this.registerInstruction("create",Ba),this.registerInstruction("update",La),this.registerInstruction("destroy",Va)})}addComponents(){this.app.addComponents({WorkflowLink:zn,WorkflowPage:hn,ExecutionPage:yo})}}k.AddButton=Bt,k.AdditionNotifiedPerson=zr,k.AutoResizeInput=No,k.BaseTypeSets=Ne,k.Branch=$e,k.BuiltinGroupType=Ue,k.CheckboxGroupWithTooltip=Ao,k.CollectionBlockInitializer=Te,k.ConfigButtonMessage=qr,k.DetailsBlockProvider=Vt,k.EXECUTION_STATUS=de,k.ExecutionContextProvider=Ko,k.ExecutionLink=Gt,k.ExecutionRetryAction=Ht,k.ExecutionStatusColumn=Kt,k.ExecutionStatusOptions=pt,k.ExecutionStatusOptionsMap=ut,k.ExecutionStatusSelect=To,k.FieldsSelect=et,k.FilterDynamicComponent=De,k.FlowContext=qe,k.Instruction=Q,k.JOB_STATUS=ye,k.JobStatusOptions=mt,k.JobStatusOptionsMap=Re,k.Node=ao,k.NodeDefaultView=nt,k.OpenDrawer=Io,k.ProviderContextNode=io,k.RadioWithTooltip=Oe,k.SelectNotifiedPerson=Br,k.SimpleDesigner=Ut,k.Trigger=Qe,k.ValueBlock=Se,k.WorkflowPane=wn,k.WorkflowVariableCodeMirror=Pr,k.WorkflowVariableInput=ke,k.WorkflowVariableJSON=So,k.WorkflowVariableRawTextArea=ko,k.WorkflowVariableTextArea=ot,k.collectionWorkflows=ze,k.createWorkflow=xn,k.currentFormOptions=bo,k.default=Z,k.defaultFieldNames=pe,k.executionCollection=Xt,k.executionSchema=Rt,k.getCollectionFieldOptions=ue,k.getExecutionSchema=fn,k.getWorkflowDetailPath=Be,k.getWorkflowExecutionsPath=yt,k.isValidFilter=ht,k.linkNodes=ft,k.nodesOptions=xt,k.scopeOptions=Wt,k.systemOptions=vo,k.traverseSchema=gt,k.triggerOptions=bt,k.updateWorkflow=bn,k.useAvailableUpstreams=Ee,k.useContextNode=he,k.useFlowContext=q,k.useGetAriaLabelOfAddButton=dt,k.useRecordTriggerWorkflowsActionProps=Us,k.useStyles=ge,k.useTrigger=Ze,k.useTriggerWorkflowsActionProps=qs,k.useWorkflowAnyExecuted=Do,k.useWorkflowExecuted=_t,k.useWorkflowVariableFormOptions=Co,k.useWorkflowVariableOptions=le,k.workflowFieldset=me,k.workflowSchema=vn,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});