@nocobase/plugin-workflow 0.19.0-alpha.9 → 0.20.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +3 -0
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.js +31 -31
- package/dist/client/settings/customizeSubmitToWorkflowActionSettings.d.ts +2 -0
- package/dist/externalVersion.js +10 -9
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/instructions/CreateInstruction.d.ts +1 -1
- package/dist/server/instructions/QueryInstruction.d.ts +1 -1
- package/dist/server/migrations/20230612021134-manual-collection-block.js +1 -1
- package/dist/server/migrations/20231122143143-split-to-plugins.js +0 -30
- package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +1 -1
- package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.js +21 -7
- package/dist/server/utils.d.ts +1 -2
- package/package.json +5 -5
package/dist/client/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './utils';
|
|
|
9
9
|
export * from './hooks/useGetAriaLabelOfAddButton';
|
|
10
10
|
export { default as useStyles } from './style';
|
|
11
11
|
export * from './variable';
|
|
12
|
-
export
|
|
12
|
+
export * from './hooks/useTriggerWorkflowActionProps';
|
|
13
13
|
import { Plugin } from '@nocobase/client';
|
|
14
14
|
import { Trigger } from './triggers';
|
|
15
15
|
import { Instruction } from './nodes';
|
|
@@ -32,7 +32,6 @@ export default class PluginWorkflowClient extends Plugin {
|
|
|
32
32
|
new (): Instruction;
|
|
33
33
|
}): void;
|
|
34
34
|
load(): Promise<void>;
|
|
35
|
-
addScopes(): void;
|
|
36
35
|
addComponents(): void;
|
|
37
36
|
addRoutes(): void;
|
|
38
37
|
}
|
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react"),require("antd"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react","antd","react-i18next","@formily/core","@formily/react","lodash","@nocobase/utils/client","react-router-dom","dayjs","@nocobase/evaluators/client","@formily/antd-v5"],r):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@ant-design/icons"],g["@nocobase/client"],g.react,g.antd,g["react-i18next"],g["@formily/core"],g["@formily/react"],g.lodash,g["@nocobase/utils"],g["react-router-dom"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"]))})(this,function(g,r,
|
|
1
|
+
(function(g,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/client"),require("react"),require("antd"),require("react-i18next"),require("@formily/core"),require("@formily/react"),require("lodash"),require("@nocobase/utils/client"),require("react-router-dom"),require("dayjs"),require("@nocobase/evaluators/client"),require("@formily/antd-v5"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@ant-design/icons","@nocobase/client","react","antd","react-i18next","@formily/core","@formily/react","lodash","@nocobase/utils/client","react-router-dom","dayjs","@nocobase/evaluators/client","@formily/antd-v5","@formily/shared"],r):(g=typeof globalThis!="undefined"?globalThis:g||self,r(g["@nocobase/plugin-workflow"]={},g.jsxRuntime,g["@ant-design/icons"],g["@nocobase/client"],g.react,g.antd,g["react-i18next"],g["@formily/core"],g["@formily/react"],g.lodash,g["@nocobase/utils"],g["react-router-dom"],g.dayjs,g["@nocobase/evaluators"],g["@formily/antd-v5"],g["@formily/shared"]))})(this,function(g,r,F,l,b,y,Q,ge,M,we,ae,re,Vo,De,jo,Wo){"use strict";var cr=Object.defineProperty,dr=Object.defineProperties;var ur=Object.getOwnPropertyDescriptors;var dt=Object.getOwnPropertySymbols;var Mo=Object.prototype.hasOwnProperty,Po=Object.prototype.propertyIsEnumerable;var Dt=(g,r,F)=>r in g?cr(g,r,{enumerable:!0,configurable:!0,writable:!0,value:F}):g[r]=F,w=(g,r)=>{for(var F in r||(r={}))Mo.call(r,F)&&Dt(g,F,r[F]);if(dt)for(var F of dt(r))Po.call(r,F)&&Dt(g,F,r[F]);return g},T=(g,r)=>dr(g,ur(r));var Bo=g=>typeof g=="symbol"?g:g+"",q=(g,r)=>{var F={};for(var l in g)Mo.call(g,l)&&r.indexOf(l)<0&&(F[l]=g[l]);if(g!=null&&dt)for(var l of dt(g))r.indexOf(l)<0&&Po.call(g,l)&&(F[l]=g[l]);return F};var v=(g,r,F)=>(Dt(g,typeof r!="symbol"?r+"":r,F),F);var _=(g,r,F)=>new Promise((l,b)=>{var y=M=>{try{ge(F.next(M))}catch(we){b(we)}},Q=M=>{try{ge(F.throw(M))}catch(we){b(we)}},ge=M=>M.done?l(M.value):Promise.resolve(M.value).then(y,Q);ge((F=F.apply(g,r)).next())});const Je=b.createContext({});function Z(){return b.useContext(Je)}const m="workflow";function E(e,t={}){return l.i18n.t(e,T(w({},t),{ns:m}))}function ut(){return Q.useTranslation(m)}const te=l.createStyles(({css:e,token:t})=>({workflowPageClass:e`
|
|
2
2
|
flex-grow: 1;
|
|
3
3
|
overflow: hidden;
|
|
4
4
|
display: flex;
|
|
@@ -350,12 +350,12 @@
|
|
|
350
350
|
border-radius: 50%;
|
|
351
351
|
background-color: ${t.colorText};
|
|
352
352
|
color: ${t.colorBgContainer};
|
|
353
|
-
`}));function Et(e){var h;const{upstream:t,branchIndex:o=null}=e,n=
|
|
353
|
+
`}));function Et(e){var h;const{upstream:t,branchIndex:o=null}=e,n=l.usePlugin(de),s=l.useCompile(),i=l.useAPIClient(),{workflow:a,refresh:c}=(h=Z())!=null?h:{},d=Array.from(n.instructions.getValues()),{styles:p}=te(),f=b.useMemo(()=>[{key:"control",label:`{{t("Control", { ns: "${m}" })}}`},{key:"collection",label:`{{t("Collection operations", { ns: "${m}" })}}`},{key:"manual",label:`{{t("Manual", { ns: "${m}" })}}`},{key:"extended",label:`{{t("Extended types", { ns: "${m}" })}}`}].map(u=>{const C=d.filter(O=>O.group===u.key&&(O.isAvailable?O.isAvailable({engine:n,workflow:a,upstream:t,branchIndex:o}):!0));return T(w({},u),{type:"group",children:C.map(O=>({role:"button","aria-label":O.type,key:O.type,label:O.title,type:O.options?"subMenu":null,children:O.options?O.options.map(P=>({role:"button","aria-label":P.key,key:P.key,label:P.label})):null}))})}).filter(u=>u.children.length),[o,n,d,t,a]),x=b.useCallback(C=>_(this,[C],function*({keyPath:u}){var z,H,$;const O=u.pop(),P={},[A]=u,B=n.instructions.get(O);if(A){const{value:N}=(H=(z=B.options)==null?void 0:z.find(S=>S.key===A))!=null?H:{};Object.assign(P,typeof N=="function"?N():N)}a&&(yield i.resource("workflows.nodes",a.id).create({values:{type:O,upstreamId:($=t==null?void 0:t.id)!=null?$:null,branchIndex:o,title:s(B.title),config:P}}),c())}),[i,o,n.instructions,c,t==null?void 0:t.id,a]),k=b.useMemo(()=>({onClick:x,items:s(f)}),[f,x]);return a?r.jsx("div",{className:p.addButtonClass,children:r.jsx(y.Dropdown,{trigger:["click"],menu:k,disabled:a.executed,overlayClassName:l.css`
|
|
354
354
|
.ant-dropdown-menu-root {
|
|
355
355
|
max-height: 30em;
|
|
356
356
|
overflow-y: auto;
|
|
357
357
|
}
|
|
358
|
-
`,children:r.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(
|
|
358
|
+
`,children:r.jsx(y.Button,{"aria-label":e["aria-label"]||"add-button",shape:"circle",icon:r.jsx(F.PlusOutlined,{})})})}):null}const pt=(e,t)=>({getAriaLabel:b.useCallback(n=>["add-button",e==null?void 0:e.type,e==null?void 0:e.title,t!=null?String(t):"",n].filter(Boolean).join("-"),[t,e==null?void 0:e.title,e==null?void 0:e.type])}),Lo=l.createStyles(({css:e,token:t})=>({container:e`
|
|
359
359
|
margin-bottom: 1.5em;
|
|
360
360
|
padding: 1em;
|
|
361
361
|
background-color: ${t.colorFillAlter};
|
|
@@ -380,11 +380,11 @@
|
|
|
380
380
|
p {
|
|
381
381
|
color: ${t.colorTextDescription};
|
|
382
382
|
}
|
|
383
|
-
`}));function Nt(e){const{label:t,title:o,description:n}=e,{styles:s}=Lo();return r.jsxs("div",{className:
|
|
383
|
+
`}));function Nt(e){const{label:t,title:o,description:n}=e,{styles:s}=Lo();return r.jsxs("div",{className:l.cx(s.container,e.className),children:[r.jsxs("dl",{children:[r.jsx("dt",{children:t}),r.jsx("dd",{children:r.jsx(y.Tag,{style:{background:"none"},children:o})})]}),n?r.jsx("p",{children:n}):null]})}function zo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var It={exports:{}};/*!
|
|
384
384
|
Copyright (c) 2018 Jed Watson.
|
|
385
385
|
Licensed under the MIT License (MIT), see
|
|
386
386
|
http://jedwatson.github.io/classnames
|
|
387
|
-
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var n=[],s=0;s<arguments.length;s++){var
|
|
387
|
+
*/(function(e){(function(){var t={}.hasOwnProperty;function o(){for(var n=[],s=0;s<arguments.length;s++){var i=arguments[s];if(i){var a=typeof i;if(a==="string"||a==="number")n.push(i);else if(Array.isArray(i)){if(i.length){var c=o.apply(null,i);c&&n.push(c)}}else if(a==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){n.push(i.toString());continue}for(var d in i)t.call(i,d)&&i[d]&&n.push(d)}}}return n.join(" ")}e.exports?(o.default=o,e.exports=o):window.classNames=o})()})(It);var Jo=It.exports;const Ho=zo(Jo),Uo=l.createStyles(({css:e,token:t})=>({statusButtonClass:e`
|
|
388
388
|
border: none;
|
|
389
389
|
.ant-tag {
|
|
390
390
|
width: 100%;
|
|
@@ -396,7 +396,7 @@
|
|
|
396
396
|
}
|
|
397
397
|
`,noStatusButtonClass:e`
|
|
398
398
|
border-width: 2px;
|
|
399
|
-
`}));function Ee(e){var n;const{styles:t}=
|
|
399
|
+
`}));function Ee(e){var n;const{styles:t}=Uo();let o=null;if(typeof e.status!="undefined"&&((n=e.statusMap)!=null&&n[e.status])){const{icon:s,color:i}=e.statusMap[e.status];o=r.jsx(y.Tag,{color:i,children:s})}return r.jsx(y.Button,T(w({},e),{shape:"circle",size:"small",className:Ho(o?t.statusButtonClass:t.noStatusButtonClass,e.className),children:o}))}const ce={QUEUEING:null,STARTED:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},He=[{value:ce.QUEUEING,label:`{{t("Queueing", { ns: "${m}" })}}`,color:"blue",icon:r.jsx(F.HourglassOutlined,{}),description:`{{t("Triggered but still waiting in queue to execute.", { ns: "${m}" })}}`},{value:ce.STARTED,label:`{{t("On going", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(F.LoadingOutlined,{}),description:`{{t("Started and executing, maybe waiting for an async callback (manual, delay etc.).", { ns: "${m}" })}}`},{value:ce.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(F.CheckOutlined,{}),description:`{{t("Successfully finished.", { ns: "${m}" })}}`},{value:ce.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(F.ExclamationOutlined,{}),description:`{{t("Failed to satisfy node configurations.", { ns: "${m}" })}}`},{value:ce.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(F.CloseOutlined,{}),description:`{{t("Some node meets error.", { ns: "${m}" })}}`},{value:ce.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(F.MinusOutlined,{rotate:90}),description:`{{t("Running of some node was aborted by program flow.", { ns: "${m}" })}}`},{value:ce.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{rotate:45}),description:`{{t("Manually canceled whole execution when waiting.", { ns: "${m}" })}}`},{value:ce.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{}),description:`{{t("Rejected from a manual node.", { ns: "${m}" })}}`},{value:ce.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(F.RedoOutlined,{}),description:`{{t("General failed but should do another try.", { ns: "${m}" })}}`}],Ue=He.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{}),se={PENDING:0,RESOLVED:1,FAILED:-1,ERROR:-2,ABORTED:-3,CANCELED:-4,REJECTED:-5,RETRY_NEEDED:-6},mt=[{value:se.PENDING,label:`{{t("Pending", { ns: "${m}" })}}`,color:"gold",icon:r.jsx(F.ClockCircleOutlined,{})},{value:se.RESOLVED,label:`{{t("Resolved", { ns: "${m}" })}}`,color:"green",icon:r.jsx(F.CheckOutlined,{})},{value:se.FAILED,label:`{{t("Failed", { ns: "${m}" })}}`,color:"red",icon:r.jsx(F.ExclamationOutlined,{})},{value:se.ERROR,label:`{{t("Error", { ns: "${m}" })}}`,color:"red",icon:r.jsx(F.CloseOutlined,{})},{value:se.ABORTED,label:`{{t("Aborted", { ns: "${m}" })}}`,color:"red",icon:r.jsx(F.MinusOutlined,{rotate:90})},{value:se.CANCELED,label:`{{t("Canceled", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{rotate:45})},{value:se.REJECTED,label:`{{t("Rejected", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(F.MinusOutlined,{})},{value:se.RETRY_NEEDED,label:`{{t("Retry needed", { ns: "${m}" })}}`,color:"volcano",icon:r.jsx(F.RedoOutlined,{})}],_e=mt.reduce((e,t)=>Object.assign(e,{[t.value]:t}),{});class fe{constructor(){v(this,"title");v(this,"type");v(this,"group");v(this,"description");v(this,"options");v(this,"fieldset");v(this,"view");v(this,"scope");v(this,"components");v(this,"end")}}function _o(){const e=M.useForm(),t=l.useAPIClient(),o=l.useActionContext(),{refresh:n}=l.useResourceActionContext(),s=Ce(),{workflow:i}=Z();return{run(){return _(this,null,function*(){var c,d;if(i.executed){y.message.error(E("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:s.id,values:{config:e.values}}),o.setFormValueChanged(!1),o.setVisible(!1),n()})}}}const ft=b.createContext({});function Ce(){return b.useContext(ft)}function Mt(e,t){const o=[];if(!e)return[];for(let n=e.upstream;n;n=n.upstream)(typeof t!="function"||t(n))&&o.push(n);return o}function Pt(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}function Bt({data:e}){const{styles:t}=te(),{getAriaLabel:o}=pt(e),n=l.usePlugin(de),{Component:s=ht,end:i}=n.instructions.get(e.type);return r.jsx(ft.Provider,{value:e,children:r.jsxs("div",{className:l.cx(t.nodeBlockClass),children:[r.jsx(s,{data:e}),!i||typeof i=="function"&&!i(e)?r.jsx(Et,{"aria-label":o(),upstream:e}):r.jsx("div",{className:"end-sign",children:r.jsx(F.CloseOutlined,{})})]})})}function Vt(){var p;const{t:e}=Q.useTranslation(),t=l.useAPIClient(),{workflow:o,nodes:n,refresh:s}=(p=Z())!=null?p:{},i=Ce(),{modal:a}=y.App.useApp();if(!o)return null;const c=t.resource("flow_nodes");function d(){return _(this,null,function*(){function f(){return _(this,null,function*(){var u;yield(u=c.destroy)==null?void 0:u.call(c,{filterByTk:i.id}),s()})}const x=n.filter(u=>u===i?!1:ae.parse(u.config).parameters.filter(({key:P})=>P.startsWith(`$jobsMapByNodeKey.${i.key}.`)||P===`$jobsMapByNodeKey.${i.key}`).length);if(x.length){a.error({title:E("Can not delete"),content:E("The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",{nodes:x.map(u=>`#${u.id}`).join(", ")})});return}const h=!n.find(u=>u.upstream===i&&u.branchIndex!=null)?e("Are you sure you want to delete it?"):E("This node contains branches, deleting will also be preformed to them, are you sure?");a.confirm({title:e("Delete"),content:h,onOk:f})})}return o.executed?null:r.jsx(y.Button,{type:"text",shape:"circle",icon:r.jsx(F.DeleteOutlined,{}),onClick:d,className:"workflow-node-remove-button"})}function jt(){var i;const{execution:e,setViewJob:t}=Z(),{jobs:o}=(i=Ce())!=null?i:{},{styles:n}=te();if(!e)return null;if(!o.length)return r.jsx(Ee,{className:n.nodeJobButtonClass,disabled:!0});function s({key:a}){const c=o.find(d=>d.id==a);t(c)}return o.length>1?r.jsx(y.Dropdown,{menu:{items:o.map(a=>({key:a.id,label:r.jsxs(r.Fragment,{children:[r.jsx(Ee,{statusMap:_e,status:a.status}),r.jsx("time",{children:ae.str2moment(a.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})})),onClick:s,className:n.dropdownClass},children:r.jsx(Ee,{statusMap:_e,status:o[o.length-1].status,className:n.nodeJobButtonClass})}):r.jsx(Ee,{statusMap:_e,status:o[0].status,onClick:()=>t(o[0]),className:n.nodeJobButtonClass})}function Yo(){return{form:M.useForm()}}function ht(e){var $,N;const{data:t,children:o}=e,n=l.useCompile(),s=l.useAPIClient(),{workflow:i,refresh:a}=($=Z())!=null?$:{},{styles:c}=te(),p=l.usePlugin(de).instructions.get(t.type),f=i.executed?'{{t("View")}}':'{{t("Configure")}}',x=n(p.title),[k,h]=b.useState((N=t.title)!=null?N:x),[u,C]=b.useState(!1),[O,P]=b.useState(!1),A=b.useMemo(()=>{const S=we.cloneDeep(t.config);return ge.createForm({initialValues:S,disabled:i.executed})},[t,i]),B=b.useCallback(S=>{C(S),S||A.reset()},[A]),z=b.useCallback(function(S){return _(this,null,function*(){var L,J;const I=S||x;h(I),I!==t.title&&(yield(J=(L=s.resource("flow_nodes")).update)==null?void 0:J.call(L,{filterByTk:t.id,values:{title:I}}),a())})},[t]),H=b.useCallback(function(S){if(S.target===S.currentTarget){C(!0);return}const I=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let L=S.target;L&&L!==S.currentTarget&&L!==document.documentElement;L=L.parentNode)if(Array.from(L.classList).some(J=>I.has(J))){C(!0),S.stopPropagation();return}},[]);return r.jsxs("div",{className:l.cx(c.nodeClass,`workflow-node-type-${t.type}`),children:[r.jsxs("div",{role:"button","aria-label":`${x}-${k}`,className:l.cx(c.nodeCardClass,{configuring:u}),onClick:H,children:[r.jsxs("div",{className:l.cx(c.nodeMetaClass,"workflow-node-meta"),children:[r.jsx(y.Tag,{children:x}),r.jsx("span",{className:"workflow-node-id",children:t.id})]}),r.jsx(y.Input.TextArea,{disabled:i.executed,value:k,onChange:S=>h(S.target.value),onBlur:S=>z(S.target.value),autoSize:!0}),r.jsx(Vt,{}),r.jsx(jt,{}),r.jsx(l.ActionContextProvider,{value:{visible:u,setVisible:B,formValueChanged:O,setFormValueChanged:P},children:r.jsx(l.FormProvider,{form:A,children:r.jsx(l.SchemaComponent,{scope:T(w({},p.scope),{useFormProviderProps:Yo}),components:p.components,schema:{type:"void",properties:T(w({},p.view?{view:p.view}:{}),{button:{type:"void","x-content":f,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},[t.id]:{type:"void",title:r.jsxs("div",{className:l.css`
|
|
400
400
|
display: flex;
|
|
401
401
|
justify-content: space-between;
|
|
402
402
|
|
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
code {
|
|
412
412
|
font-weight: normal;
|
|
413
413
|
}
|
|
414
|
-
`,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:E("Variable key of node"),children:r.jsx(y.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:
|
|
414
|
+
`,children:[r.jsx("strong",{children:t.title}),r.jsx(y.Tooltip,{title:E("Variable key of node"),children:r.jsx(y.Tag,{children:r.jsx("code",{children:t.key})})})]}),"x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},"x-component":"Action.Drawer",properties:T(w({},p.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:E("Node type"),title:p.title,description:p.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
415
415
|
.ant-input,
|
|
416
416
|
.ant-select,
|
|
417
417
|
.ant-cascader-picker,
|
|
@@ -423,44 +423,44 @@
|
|
|
423
423
|
min-width: 6em;
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
`},properties:
|
|
426
|
+
`},properties:p.fieldset},actions:i.executed?null:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:_o}}}}})}})}})})})]}),o]})}function Ye({from:e=null,entry:t=null,branchIndex:o=null,controller:n=null,className:s,end:i}){const{styles:a}=te(),{getAriaLabel:c}=pt(e,o),d=[];for(let p=t;p;p=p.downstream)d.push(p);return r.jsxs("div",{className:l.cx("workflow-branch",a.branchClass,s),children:[r.jsx("div",{className:"workflow-branch-lines"}),n,r.jsx(Et,{"aria-label":c(),upstream:e,branchIndex:o}),r.jsx("div",{className:"workflow-node-list",children:d.map(p=>r.jsx(Bt,{data:p},p.id))}),i?r.jsx("div",{className:"end-sign",children:r.jsx(F.CloseOutlined,{})}):null]})}function Go(){var i;const e=M.useForm(),t=l.useAPIClient(),{workflow:o}=(i=Z())!=null?i:{},n=l.useActionContext(),{refresh:s}=l.useResourceActionContext();return{run(){return _(this,null,function*(){if(o.executed){y.message.error(E("Trigger in executed workflow cannot be modified"));return}yield e.submit(),yield t.resource("workflows").update({filterByTk:o.id,values:{config:e.values}}),n.setFormValueChanged(!1),n.setVisible(!1),s()})}}}class yt{constructor(){v(this,"sync");v(this,"title");v(this,"description");v(this,"fieldset");v(this,"view");v(this,"scope");v(this,"components");v(this,"initializers");v(this,"isActionTriggerable")}}function qo(){const e=l.useCompile(),{workflow:t,execution:o}=Z(),{styles:n}=te(),s=gt();return o?r.jsx(l.SchemaComponent,{schema:{type:"void",name:"execution","x-component":"Action","x-component-props":{title:r.jsx(F.InfoOutlined,{}),shape:"circle",size:"small",className:n.nodeJobButtonClass,type:"primary"},properties:{[o.id]:{type:"void","x-decorator":"Form","x-decorator-props":{initialValue:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:l.cx(n.nodeTitleClass),children:[r.jsx(y.Tag,{children:e(s.title)}),r.jsx("strong",{children:t.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",o.id]})]}),properties:{createdAt:{type:"string",title:`{{t("Triggered at", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0},context:{type:"object",title:`{{t("Trigger variables", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:l.css`
|
|
427
427
|
padding: 1em;
|
|
428
428
|
background-color: #eee;
|
|
429
|
-
`},"x-read-pretty":!0}}}}}}):null}function
|
|
429
|
+
`},"x-read-pretty":!0}}}}}}):null}function Ko(){return{form:M.useForm()}}const Zo=()=>{const e=l.useAPIClient(),{workflow:t,refresh:o}=Z(),[n,s]=b.useState(""),[i,a]=b.useState(!1),[c,d]=b.useState(!1),{styles:p}=te(),f=l.useCompile(),x=gt(),k=f(x.title),{fieldset:h,scope:u,components:C}=x,O=t.executed?'{{t("View")}}':'{{t("Configure")}}',P=E("Trigger");b.useEffect(()=>{var $,N;t&&s((N=($=t.triggerTitle)!=null?$:t.title)!=null?N:k)},[t]);const A=b.useMemo(()=>{const $=we.cloneDeep(t.config);return ge.createForm({initialValues:$,disabled:t.executed})},[t]),B=b.useCallback($=>{a($),$||A.reset()},[A]),z=b.useCallback(function($){return _(this,null,function*(){const N=$||k;s(N),N!==t.triggerTitle&&(yield e.resource("workflows").update({filterByTk:t.id,values:{triggerTitle:N}}),o())})},[t]),H=b.useCallback(function($){var S;if($.target===$.currentTarget){a(!0);return}const N=new Set(["workflow-node-meta","workflow-node-config-button","ant-input-disabled"]);for(let I=$.target;I&&I!==$.currentTarget;I=I.parentNode)if(Array.from((S=I.classList)!=null?S:[]).some(L=>N.has(L))){a(!0),$.stopPropagation();return}},[]);return r.jsxs("div",{role:"button","aria-label":`${P}-${n}`,className:l.cx(p.nodeCardClass),onClick:H,children:[r.jsx("div",{className:l.cx(p.nodeMetaClass,"workflow-node-meta"),children:r.jsx(y.Tag,{color:"gold",children:P})}),r.jsx("div",{children:r.jsx(y.Input.TextArea,{value:n,onChange:$=>s($.target.value),onBlur:$=>z($.target.value),autoSize:!0})}),r.jsx(qo,{}),r.jsx(l.ActionContextProvider,{value:{visible:i,setVisible:B,formValueChanged:c,setFormValueChanged:d},children:r.jsx(l.FormProvider,{form:A,children:r.jsx(l.SchemaComponent,{scope:T(w({},u),{useFormProviderProps:Ko}),components:C,schema:{name:`workflow-trigger-${t.id}`,type:"void",properties:{config:{type:"void","x-content":O,"x-component":y.Button,"x-component-props":{type:"link",className:"workflow-node-config-button"}},drawer:{type:"void",title:P,"x-component":"Action.Drawer","x-decorator":"FormV2","x-decorator-props":{useProps:"{{ useFormProviderProps }}"},properties:T(w({},x.description?{description:{type:"void","x-component":Nt,"x-component-props":{label:E("Trigger type"),title:x.title,description:x.description}}}:{}),{fieldset:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
430
430
|
.ant-select.auto-width {
|
|
431
431
|
width: auto;
|
|
432
432
|
min-width: 6em;
|
|
433
433
|
}
|
|
434
|
-
`},properties:h},actions:w({},t.executed?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Go}}}})})}}}})})})]})};function gt(){const e=
|
|
434
|
+
`},properties:h},actions:w({},t.executed?{}:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:Go}}}})})}}}})})})]})};function gt(){const e=l.usePlugin(de),{workflow:t}=Z();return e.triggers.get(t.type)}const ke={label:"label",value:"value",children:"children"},Wt={label:`{{t("Node result", { ns: "${m}" })}}`,value:"$jobsMapByNodeKey",useOptions(e){const{instructions:t}=l.usePlugin(de),o=Ce(),n=Mt(o),s=[];return n.forEach(i=>{var d;const a=t.get(i.type),c=(d=a.useVariables)==null?void 0:d.call(a,i,e);c&&s.push(c)}),s}},Lt={label:`{{t("Trigger variables", { ns: "${m}" })}}`,value:"$context",useOptions(e){var s,i;const{triggers:t}=l.usePlugin(de),{workflow:o}=Z(),n=t.get(o.type);return(i=(s=n==null?void 0:n.useVariables)==null?void 0:s.call(n,o.config,e))!=null?i:null}},zt={label:`{{t("Scope variables", { ns: "${m}" })}}`,value:"$scopes",useOptions(e){const{fieldNames:t=ke,current:o}=e,{instructions:n}=l.usePlugin(de),s=Ce(),i=o!=null?o:s,a=Pt(i),c=[];return a.forEach(d=>{var x,k;const p=n.get(d.type),f=(x=p.useScopeVariables)==null?void 0:x.call(p,d,e);f&&c.push({key:d.key,[t.value]:d.key,[t.label]:(k=d.title)!=null?k:`#${d.id}`,[t.children]:f})}),c}},Jt={label:`{{t("System variables", { ns: "${m}" })}}`,value:"$system",useOptions({types:e,fieldNames:t=ke}){return[...!e||e.includes("date")?[{key:"now",[t.label]:E("System time"),[t.value]:"now"}]:[]]}},Ge={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 Ht(e,t){var o,n,s,i,a,c;return typeof t=="string"?(o=Ge[t])==null?void 0:o.has(e.interface):typeof t=="object"&&t.type==="reference"?bt(e)?((n=t.options)==null?void 0:n.entity)&&(e.collectionName===((s=t.options)==null?void 0:s.collection)||((i=t.options)==null?void 0:i.collection)==="*"):e.isForeignKey?e.collectionName===((a=t.options)==null?void 0:a.collection)&&e.name==="id"||e.target===((c=t.options)==null?void 0:c.collection):!1:typeof t=="function"?t(e):!1}function bt(e){return["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}function xt(e,t){if(t==null)return null;const o=`${e.name}.`;return t.filter(n=>n.startsWith(o)).map(n=>n.replace(o,""))}function vt({fields:e,types:t,appends:o,depth:n=1,compile:s,getCollectionFields:i}){return e.filter(a=>{const c=t!=null&&t.length?t.some(d=>Ht(a,d)):!0;if(bt(a)){if(o===null)return n?c||vt({fields:wt(a.target,{compile:s,getCollectionFields:i}),types:t,depth:n-1,appends:o,compile:s,getCollectionFields:i}):!1;const d=xt(a,o),p=o.includes(a.name);return c?p:((d==null?void 0:d.length)||p)&&vt({fields:wt(a.target,{compile:s,getCollectionFields:i}),types:t,appends:d,compile:s,getCollectionFields:i}).length}else return c})}function qe(e,t){var i,a;const o=l.useCompile(),n=(a=(i=e.useOptions)==null?void 0:i.call(e,t))==null?void 0:a.filter(Boolean),{fieldNames:s}=t;return{[s.label]:o(e.label),[s.value]:e.value,key:e[s.value],[s.children]:n,disabled:!n||!n.length}}function he(e={}){var s;const t=Object.assign({},ke,(s=e.fieldNames)!=null?s:{}),o=Object.assign(e,{fieldNames:t});return[qe(zt,o),qe(Wt,o),qe(Lt,o),qe(Jt,o)]}function wt(e,{compile:t,getCollectionFields:o}){var a,c,d,p,f,x,k;const n=o(e),s=[],i=[];n.forEach(h=>{h.isForeignKey?s.push(h):i.push(h)});for(let h=i.length-1;h>=0;h--){const u=i[h];if(u.type==="belongsTo"){const C=s.find(O=>O.name===u.foreignKey);C?i.splice(h,0,T(w(w({},u),C),{uiSchema:T(w({},u.uiSchema),{title:(a=u.uiSchema)!=null&&a.title?`${t((c=u.uiSchema)==null?void 0:c.title)} ID`:C.name})})):i.splice(h,0,T(w({},u),{name:u.foreignKey,type:"bigInt",isForeignKey:!0,interface:u.interface,uiSchema:T(w({},u.uiSchema),{title:(d=u.uiSchema)!=null&&d.title?`${t((p=u.uiSchema)==null?void 0:p.title)} ID`:u.name})}))}else if(u.type==="context"&&u.collectionName==="users"){const C=(f=i.find(O=>O.type==="belongsTo"&&O.target==="users"&&O.foreignKey===u.name))!=null?f:{};i.splice(h,0,T(w({},u),{type:u.dataType,interface:C.interface,uiSchema:T(w({},C.uiSchema),{title:(x=C.uiSchema)!=null&&x.title?`${t((k=C.uiSchema)==null?void 0:k.title)} ID`:u.name})}))}}return i.filter(h=>h.interface&&!h.hidden)}function Qo(e){const t=xt(e.field,e.appends),o=Se(w({collection: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(s=>Ht(e.field,s))||(e.disabled=!0))}function Se(e){const{fields:t,collection:o,types:n,appends:s=[],depth:i=1,compile:a,getCollectionFields:c,fieldNames:d=ke}=e,p=wt(o,{compile:a,getCollectionFields:c}),f=t!=null?t:p,x=Qo.bind({compile:a,getCollectionFields:c,fieldNames:d});return vt({fields:f,types:n,depth:i,appends:s,compile:a,getCollectionFields:c}).map(h=>{var P;const u=a(((P=h.uiSchema)==null?void 0:P.title)||h.name),C=xt(h,s),O=!bt(h)||C&&!C.length&&!s.includes(h.name)||!1;return{[d.label]:u,key:h.name,[d.value]:h.name,isLeaf:O,loadChildren:O?null:x,field:h,depth:i,appends:s,types:n}})}function Ut(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(l.Variable.Input,w({scope:s},t))}function Ct(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(l.Variable.TextArea,w({scope:s},t))}function Xo(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(l.Variable.RawTextArea,w({scope:s},t))}function Ro(o){var n=o,{variableOptions:e}=n,t=q(n,["variableOptions"]);const s=he(e);return r.jsx(l.Variable.JSON,w({scope:s},t))}function kt(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 Ke(e){const t=e.$and||e.$or;return t?t.some(o=>{if(o.$and||o.$or)return Ke(o);const[n]=Object.keys(o);if(!n||!o[n])return!1;const[s]=Object.keys(o[n]);return!(!s||typeof o[n][s]=="undefined")}):!1}function St(e,t){t(e),e.properties&&Object.keys(e.properties).forEach(o=>{St(e.properties[o],t)})}function en(n){var s=n,{collection:e,dataSource:t}=s,o=q(s,["collection","dataSource"]);const{insert:i}=l.useSchemaInitializer(),{getTemplateSchemaByMode:a}=l.useSchemaTemplateManager(),{getCollection:c}=l.useCollectionManager_deprecated(),d=l.useRecordCollectionDataSourceItems("FormItem"),p=c(e);function f(k){return _(this,arguments,function*({item:x}){const h=x.template?yield a(x):null,u={type:"void",name:p.name,title:p.title,"x-decorator":"DetailsBlockProvider","x-decorator-props":{collection:e,dataSource:t},"x-component":"CardItem","x-component-props":{title:o.title},"x-designer":"SimpleDesigner",properties:{grid:{type:"void","x-component":"FormV2","x-component-props":{useProps:"{{useDetailsBlockProps}}"},"x-read-pretty":!0,properties:{grid:h||{type:"void","x-component":"Grid","x-initializer":"ReadPrettyFormItemInitializers",properties:{}}}}}};St(u,C=>{C["x-uid"]&&delete C["x-uid"]}),i(u)})}return r.jsx(l.SchemaInitializerItem,T(w({},o),{onClick:f,items:d}))}function Ne(){const e=l.useSchemaInitializerItem();return r.jsx(l.CollectionProvider_deprecated,{collection:e.collection,children:r.jsx(en,w({},e))})}function tn(){return!0}const At=M.observer(e=>{const c=e,{filter:t=tn}=c,o=q(c,["filter"]),n=l.useCompile(),{getCollectionFields:s}=l.useCollectionManager_deprecated(),{values:i}=M.useForm(),a=s(i==null?void 0:i.collection);return r.jsx(y.Select,T(w({popupMatchSelectWidth:!1},o),{options:a.filter(t).map(d=>{var p;return{label:n((p=d.uiSchema)==null?void 0:p.title),value:d.name}})}))},{displayName:"FieldsSelect"});function Ze({value:e,onChange:t,renderSchemaComponent:o}){const n=he();return r.jsx(l.Variable.Input,{value:e,onChange:t,scope:n,children:o()})}function Ie(e){const i=e,{options:t=[],direction:o}=i,n=q(i,["options","direction"]),s=l.useCompile();return r.jsx(y.Radio.Group,T(w({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(a=>r.jsxs(y.Radio,{value:a.value,children:[r.jsx("span",{className:l.css`
|
|
435
435
|
& + .anticon {
|
|
436
436
|
margin-left: 0.25em;
|
|
437
437
|
}
|
|
438
|
-
`,children:s(
|
|
438
|
+
`,children:s(a.label)}),a.tooltip&&r.jsx(y.Tooltip,{title:s(a.tooltip),children:r.jsx(F.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))})}))}function on(e){const i=e,{options:t=[],direction:o}=i,n=q(i,["options","direction"]),s=l.useCompile();return r.jsx(y.Checkbox.Group,T(w({},n),{children:r.jsx(y.Space,{direction:o,children:t.map(a=>r.jsxs(y.Checkbox,{value:a.value,children:[r.jsx("span",{className:l.css`
|
|
439
439
|
& + .anticon {
|
|
440
440
|
margin-left: 0.25em;
|
|
441
441
|
}
|
|
442
|
-
`,children:s(
|
|
442
|
+
`,children:s(a.label)}),a.tooltip&&r.jsx(y.Tooltip,{title:s(a.tooltip),children:r.jsx(F.QuestionCircleOutlined,{style:{color:"#666"}})})]},a.value))})}))}const Me=()=>null;function nn(){const i=l.useSchemaInitializerItem(),{node:t,resultTitle:o}=i,n=q(i,["node","resultTitle"]),{insert:s}=l.useSchemaInitializer();return r.jsx(l.SchemaInitializerItem,T(w({},n),{onClick:()=>{var a;s({type:"void",name:t.id,title:t.title,"x-component":"CardItem","x-component-props":{title:(a=t.title)!=null?a:`#${t.id}`},"x-designer":"SimpleDesigner",properties:{result:{type:"void",title:o,"x-component":"ValueBlock.Result","x-component-props":{dataSource:`{{$jobsMapByNodeKey.${t.key}}}`}}}})}}))}function rn({dataSource:e}){var s;const t=M.useFieldSchema(),{execution:o}=Z();if(!o)return t.title;const n=ae.parse(e)({$jobsMapByNodeKey:((s=o.jobs)!=null?s:[]).reduce((i,a)=>Object.assign(i,{[a.nodeKey]:a.result}),{})});return r.jsx("pre",{className:l.css`
|
|
443
443
|
margin: 0;
|
|
444
|
-
`,children:JSON.stringify(n,null,2)})}Me.Initializer=
|
|
444
|
+
`,children:JSON.stringify(n,null,2)})}Me.Initializer=nn,Me.Result=rn;function sn(){const e=l.useAPIClient(),t=M.useForm(),{field:o,__parent:n}=l.useBlockRequestContext(),{setVisible:s}=l.useActionContext(),i=re.useNavigate(),a=M.useFieldSchema(),c=M.useField(),d=l.useCompile(),{modal:p}=y.App.useApp(),f=l.useCollectValuesToSubmit(),x=c.componentProps.filterKeys||[];return{onClick(){return _(this,null,function*(){var P,A,B;const{onSuccess:h,skipValidator:u,triggerWorkflows:C}=(P=a==null?void 0:a["x-action-settings"])!=null?P:{};u||(yield t.submit());const O=yield f();c.data=o.data||{},c.data.loading=!0;try{const z=yield e.resource("workflows").trigger({values:O,filterKeys:x,triggerWorkflows:C!=null&&C.length?C.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});if(c.data.loading=!1,c.data.data=z,(B=(A=n==null?void 0:n.service)==null?void 0:A.refresh)==null||B.call(A),s==null||s(!1),!(h!=null&&h.successMessage))return;h!=null&&h.manualClose?p.success({title:d(h==null?void 0:h.successMessage),onOk:()=>_(this,null,function*(){yield t.reset(),h!=null&&h.redirecting&&(h!=null&&h.redirectTo)&&(ae.isURL(h.redirectTo)?window.location.href=h.redirectTo:i(h.redirectTo))})}):y.message.success(d(h==null?void 0:h.successMessage))}catch(z){c.data.loading=!1}})}}}function ln(){var k;const e=l.useCompile(),t=l.useAPIClient(),o=l.useRecord(),n=M.useField(),s=M.useFieldSchema(),{field:i,__parent:a}=l.useBlockRequestContext(),{setVisible:c}=l.useActionContext(),{modal:d}=y.App.useApp(),p=re.useNavigate(),{onSuccess:f,triggerWorkflows:x}=(k=s==null?void 0:s["x-action-settings"])!=null?k:{};return{onClick(){return _(this,null,function*(){var u,C;n.data=i.data||{},n.data.loading=!0;try{if(yield t.resource("workflows").trigger({values:o,triggerWorkflows:x!=null&&x.length?x.map(O=>[O.workflowKey,O.context].filter(Boolean).join("!")).join(","):void 0}),(C=(u=a==null?void 0:a.service)==null?void 0:u.refresh)==null||C.call(u),c==null||c(!1),!(f!=null&&f.successMessage))return;if(f!=null&&f.manualClose){let O;d.success({title:e(f==null?void 0:f.successMessage),onOk(){return _(this,null,function*(){f!=null&&f.redirecting&&(f!=null&&f.redirectTo)&&(ae.isURL(f.redirectTo)?window.location.href=f.redirectTo:p(f.redirectTo))})}})}else y.message.success(e(f==null?void 0:f.successMessage))}catch(O){console.error(O)}finally{n.data.loading=!1}})}}}function _t({entry:e}){const{styles:t}=te(),{workflow:o}=Z(),[n,s]=b.useState(100);return r.jsxs("div",{className:"workflow-canvas-wrapper",children:[r.jsx("div",{className:"workflow-canvas",style:{zoom:n/100},children:r.jsx("div",{className:l.cx(t.branchBlockClass,l.css`
|
|
445
445
|
margin-top: 0 !important;
|
|
446
|
-
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(y.Alert,{type:"warning",message:E("Executed workflow cannot be modified"),showIcon:!0,className:
|
|
446
|
+
`),children:r.jsxs("div",{className:t.branchClass,children:[o!=null&&o.executed?r.jsx(y.Alert,{type:"warning",message:E("Executed workflow cannot be modified"),showIcon:!0,className:l.css`
|
|
447
447
|
margin-bottom: 1em;
|
|
448
|
-
`}):null,r.jsx(
|
|
448
|
+
`}):null,r.jsx(Zo,{}),r.jsx("div",{className:l.cx(t.branchBlockClass,l.css`
|
|
449
449
|
margin-top: 0 !important;
|
|
450
|
-
`),children:r.jsx(
|
|
450
|
+
`),children:r.jsx(Ye,{entry:e})}),r.jsx("div",{className:t.terminalClass,children:E("End")})]})})}),r.jsx("div",{className:"workflow-canvas-zoomer",children:r.jsx(y.Slider,{vertical:!0,reverse:!0,defaultValue:100,step:10,min:10,value:n,onChange:s})})]})}const Ae=e=>`/admin/workflow/workflows/${e}`,Ot=e=>`/admin/workflow/executions/${e}`;function an(e,t=[]){const o=new Map;e.forEach(n=>{n.jobs=[],o.set(n.id,n)}),t.forEach(n=>{const s=o.get(n.nodeId);s.jobs.push(n),n.node={id:s.id,key:s.key,title:s.title,type:s.type}}),e.forEach(n=>{n.jobs=n.jobs.sort((s,i)=>s.id-i.id)})}function cn(){const{instructions:e}=l.usePlugin(de),t=l.useCompile(),{viewJob:o,setViewJob:n}=Z(),{styles:s}=te(),{node:i={}}=o!=null?o:{},a=e.get(i.type);return r.jsx(l.ActionContextProvider,{value:{visible:!!o,setVisible:n},children:r.jsx(l.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:o},"x-component":"Action.Modal",title:r.jsxs("div",{className:s.nodeTitleClass,children:[r.jsx(y.Tag,{children:t(a==null?void 0:a.title)}),r.jsx("strong",{children:i.title}),r.jsxs("span",{className:"workflow-node-id",children:["#",i.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},result:{type:"object",title:`{{t("Node result", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{className:s.nodeJobResultClass},"x-read-pretty":!0}}}}}})})}function dn(e){const{execution:t}=Z(),o=l.useAPIClient(),n=re.useNavigate(),{styles:s}=te(),[i,a]=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:f})=>{a(f.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:f})=>{d(f.data.reverse())}).catch(()=>{})},[t]);const p=b.useCallback(({key:f})=>{f!=t.id&&n(Ot(f))},[t]);return t?r.jsx(y.Dropdown,{menu:{onClick:p,defaultSelectedKeys:[`${t.id}`],className:l.cx(s.dropdownClass,s.executionsDropdownRowClass),items:[...c,t,...i].map(f=>({key:f.id,label:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"id",children:`#${f.id}`}),r.jsx("time",{children:ae.str2moment(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),icon:r.jsx("span",{children:r.jsx(Ee,{statusMap:Ue,status:f.status})})}))},children:r.jsxs(y.Space,{children:[r.jsx("strong",{children:`#${t.id}`}),r.jsx(F.DownOutlined,{})]})}):null}function un(){var A;const{t:e}=Q.useTranslation(),t=l.useCompile(),{data:o,loading:n,refresh:s}=l.useResourceActionContext(),{setTitle:i}=l.useDocumentTitle(),[a,c]=b.useState(null),d=l.useApp(),p=l.useAPIClient();b.useEffect(()=>{var N;const{workflow:$}=(N=o==null?void 0:o.data)!=null?N:{};i==null||i(`${$!=null&&$.title?`${$.title} - `:""}${E("Execution history")}`)},[o==null?void 0:o.data]);const f=b.useCallback(()=>{y.Modal.confirm({title:E("Cancel the execution"),icon:r.jsx(F.ExclamationCircleFilled,{}),content:E("Are you sure you want to cancel the execution?"),onOk:()=>{p.resource("executions").cancel({filterByTk:o==null?void 0:o.data.id}).then(()=>{y.message.success(e("Operation succeeded")),s()}).catch($=>{console.error($.data.error)})}})},[o==null?void 0:o.data]);if(!(o!=null&&o.data))return n?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const B=(A=o==null?void 0:o.data)!=null?A:{},{jobs:x=[],workflow:z={}}=B,H=z,{nodes:k=[],revisions:h=[]}=H,u=q(H,["nodes","revisions"]),C=q(B,["jobs","workflow"]);kt(k),an(k,x);const O=k.find($=>!$.upstream),P=Ue[C.status];return r.jsxs(Je.Provider,{value:{workflow:u.type?u:null,nodes:k,execution:C,viewJob:a,setViewJob:c},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(re.Link,{to:d.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx(re.Link,{to:Ae(u.id),children:u.title})},{title:r.jsx(dn,{})}]})}),r.jsxs("aside",{children:[r.jsx(y.Tag,{color:P.color,children:t(P.label)}),C.status?null:r.jsx(y.Tooltip,{title:E("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:f,shape:"circle",size:"small",icon:r.jsx(F.StopOutlined,{})})}),r.jsx("time",{children:ae.str2moment(C.updatedAt).format("YYYY-MM-DD HH:mm:ss")})]})]}),r.jsx(_t,{entry:O}),r.jsx(cn,{})]})}const Yt=()=>{const e=re.useParams(),{styles:t}=te();return r.jsx("div",{className:l.cx(t.workflowPageClass),children:r.jsx(l.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:un}})})},Gt=()=>{const{t:e}=Q.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext();return r.jsx(re.Link,{to:Ot(t),onClick:()=>o(!1),children:e("View")})},pn={name:"execution-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:"m2o",type:"belongsTo",name:"workflowId",uiSchema:{type:"number",title:`{{t("Version", { ns: "${m}" })}}`,"x-component"({value:e}){const{setVisible:t}=l.useActionContext();return r.jsx(re.Link,{to:Ae(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:He}}]},qt={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:pn,resourceName:"executions",request:{resource:"executions",action:"list",params:{appends:["workflow.id","workflow.title"],pageSize:20,sort:["-createdAt"],filter:{}}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{clear:{type:"void",title:'{{t("Clear")}}',"x-component":"Action","x-component-props":{useAction(){const{t:e}=Q.useTranslation(),{refresh:t,defaultRequest:o}=l.useResourceActionContext(),{resource:n}=l.useResourceContext(),{setVisible:s}=l.useActionContext();return{run(){return _(this,null,function*(){var a;yield n.destroy({filter:(a=o.params)==null?void 0:a.filter}),y.message.success(e("Operation succeeded")),t(),s(!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:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},createdAt:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{createdAt:{type:"datetime","x-component":"CollectionField","x-component-props":{showTime:!0},"x-read-pretty":!0}}},workflowId:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{workflowId:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:`{{t("Status", { ns: "${m}" })}}`,properties:{status:{type:"number","x-decorator":"ExecutionStatusColumn","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{link:{type:"void","x-component":"ExecutionLink"}}}}}}}}}}};function Kt(e){var i;const o=l.useCompile()(e.label),n=b.useCallback(a=>{a.preventDefault(),a.stopPropagation()},[]),{color:s}=(i=Ue[e.value])!=null?i:{};return r.jsx(y.Tag,{color:s,onMouseDown:n,closable:e.closable,onClose:e.onClose,children:o})}function mn(e){const t=l.useCompile();return r.jsxs(r.Fragment,{children:[r.jsx(Kt,w({},e)),e.description?r.jsx("span",{children:t(e.description)}):null]})}function fn(t){var e=q(t,[]);const o=e.multiple?"multiple":null;return r.jsx(y.Select,T(w({role:"button","data-testid":`select-${o||"single"}`},e),{mode:o,optionLabelProp:"label",tagRender:Kt,children:He.filter(n=>!!n.value&&n.value!==ce.ABORTED).map(n=>r.jsx(y.Select.Option,T(w({},n),{children:r.jsx(mn,w({},n))}),n.value))}))}function Zt(e){const{t}=Q.useTranslation(),{refresh:o}=l.useResourceActionContext(),{resource:n}=l.useResourceContext(),s=l.useRecord(),i=b.useCallback(()=>{y.Modal.confirm({title:E("Cancel the execution"),icon:r.jsx(F.ExclamationCircleFilled,{}),content:E("Are you sure you want to cancel the execution?"),onOk:()=>{n.cancel({filterByTk:s.id}).then(()=>{y.message.success(t("Operation succeeded")),o()}).catch(a=>{console.error(a.data.error)})}})},[s]);return r.jsxs("div",{className:l.css`
|
|
451
451
|
display: flex;
|
|
452
|
-
`,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:E("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:l,shape:"circle",size:"small",icon:r.jsx(T.StopOutlined,{})})})]})}function pn(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:l}=Z(),i=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return r.jsx(a.ResourceActionProvider,w({},i))}function mn(){var $;const e=ie.useNavigate(),{t}=Q.useTranslation(),o=a.useApp(),{data:n,refresh:s,loading:l}=a.useResourceActionContext(),{resource:i}=a.useResourceContext(),{setTitle:c}=a.useDocumentTitle(),[u,d]=b.useState(!1),{styles:f}=te(),{modal:v}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:S}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${E("Workflow")}${S?`: ${S}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return l?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const N=($=n==null?void 0:n.data)!=null?$:{},{nodes:k=[],revisions:h=[]}=N,m=q(N,["nodes","revisions"]);kt(k);const C=k.find(S=>!S.upstream);function F({key:S}){S!=m.id&&e(Oe(S))}function M(S){return K(this,null,function*(){yield i.update({filterByTk:m.id,values:{enabled:S}}),s()})}function O(){return K(this,null,function*(){const{data:{data:S}}=yield i.revision({filterByTk:m.id,filter:{key:m.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${S.id}`)})}function B(){return K(this,null,function*(){const S=m.current?E("Delete a main version will cause all other revisions to be deleted too."):"";v.confirm({title:t("Are you sure you want to delete it?"),content:S,onOk(){return K(this,null,function*(){var W;yield i.destroy({filterByTk:m.id}),y.message.success(t("Operation succeeded")),e(m.current?o.pluginSettingsManager.getRoutePath("workflow"):Oe((W=h.find(J=>J.current))==null?void 0:W.id))})}})})}function z(I){return K(this,arguments,function*({key:S}){switch(S){case"history":d(!0);return;case"revision":return O();case"delete":return B()}})}const H=m.executed&&!h.find(S=>!S.executed&&new Date(S.createdAt)>new Date(m.createdAt));return r.jsxs(Je.Provider,{value:{workflow:m,nodes:k,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(ie.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx("strong",{children:m.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:F,defaultSelectedKeys:[`${m.id}`],className:a.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((S,I)=>I.id-S.id).map((S,I)=>({role:"button","aria-label":`version-${I}`,key:`${S.id}`,icon:S.current?r.jsx(T.RightOutlined,{}):null,className:a.cx({executed:S.executed,unexecuted:!S.executed,enabled:S.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${S.id}`}),r.jsx("time",{children:ue.str2moment(S.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:E("Version")}),r.jsx("span",{children:m!=null&&m.id?`#${m.id}`:null}),r.jsx(T.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:m.enabled,onChange:M,checkedChildren:E("On"),unCheckedChildren:E("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:E("Execution history"),disabled:!m.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:E("Copy to new version"),disabled:!H},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(y.Button,{"aria-label":"more",type:"text",icon:r.jsx(T.EllipsisOutlined,{})})}),r.jsx(a.ActionContextProvider,{value:{visible:u,setVisible:d},children:r.jsx(a.SchemaComponent,{schema:_t,components:{ExecutionResourceProvider:pn,ExecutionLink:qt,ExecutionStatusColumn:Zt}})})]})]}),r.jsx(Yt,{entry:C})]})}const Qt=()=>{const e=ie.useParams(),{styles:t}=te();return r.jsx("div",{className:a.cx(t.workflowPageClass),children:r.jsx(a.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:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:mn}})})},fn=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const l=a.useRecord(),i=A(w({},o),{request:A(w({},e),{params:A(w({},e==null?void 0:e.params),{filter:A(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:l.key})})})});return r.jsx(a.ResourceActionProvider,w({},i))},hn=()=>{const{t:e}=Q.useTranslation(),{id:t}=a.useRecord(),{setVisible:o}=a.useActionContext(),{getAriaLabel:n}=a.useGetAriaLabelOfAction("Configure");return r.jsx(ie.Link,{"aria-label":n(),to:Oe(t),onClick:()=>o(!1),children:e("Configure")})};function yn(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[l,i]=b.useState(!1),c=P.useFieldSchema();return r.jsxs(a.ActionContextProvider,{value:{visible:l,setVisible:i,fieldSchema:c},children:[b.createElement(e,A(w({},o),{onClick(){i(!0)}}),t),r.jsx(a.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const Xt={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: "${p}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:"{{getTriggersOptions()}}"},required:!0}},{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: "${p}" })}}`,type:"string",enum:[{label:`{{t("On", { ns: "${p}" })}}`,value:!0,color:"#52c41a"},{label:`{{t("Off", { ns: "${p}" })}}`,value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"number",name:"allExecuted",interface:"integer",uiSchema:{title:`{{t("Executed", { ns: "${p}" })}}`,type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{type:"object",name:"options"}]},de={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${p}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${p}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${p}" }) }}`},{label:`{{ t("Synchronously", { ns: "${p}" }) }}`,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: "${p}" }) }}`}]}},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: "${p}" }) }}`,"x-decorator":"FormItem","x-component":"ExecutionStatusSelect","x-component-props":{multiple:!0}}}}},gn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider","x-component-props":{collection:Xt},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-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:de.title,type:de.type,sync:de.sync,description:de.description,options:de.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=a.useRecord();return b.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:_t}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:de.title,enabled:de.enabled,sync:de.sync,description:de.description,options:de.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:`{{t("Duplicate", { ns: "${p}" })}}`,"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:`{{t("Duplicate to new workflow", { ns: "${p}" })}}`,"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}=Q.useTranslation(),{refresh:t}=a.useResourceActionContext(),{resource:o,targetKey:n}=a.useResourceContext(),{setVisible:s}=a.useActionContext(),{[n]:l}=a.useRecord(),{values:i}=P.useForm();return{run(){return K(this,null,function*(){yield o.revision({filterByTk:l,values:i}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function bn(e){const t=P.useField(),o=a.useRecord(),n=a.usePlugin(ce);return P.useFormEffects(s=>{ge.onFieldChange("type",l=>{let i=o.id||!l.value;if(l.value){const c=n.triggers.get(l.value);c.sync!=null?(i=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(i?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Ie,w({},e))}function xn(){const e=b.useContext(a.SchemaComponentContext),{getTriggersOptions:t}=a.usePlugin(ce);return r.jsx(y.Card,{bordered:!1,children:r.jsx(a.SchemaComponentContext.Provider,{value:A(w({},e),{designable:!1}),children:r.jsx(a.SchemaComponent,{schema:gn,components:{WorkflowLink:hn,ExecutionResourceProvider:fn,ExecutionLink:qt,OpenDrawer:yn,ExecutionStatusSelect:dn,SyncOptionSelect:bn,ExecutionStatusColumn:Zt},scope:{getTriggersOptions:t}})})})}const be={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Rt={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:a.css`
|
|
452
|
+
`,children:[e.children,s.status?null:r.jsx(y.Tooltip,{title:E("Cancel the execution"),children:r.jsx(y.Button,{type:"link",danger:!0,onClick:i,shape:"circle",size:"small",icon:r.jsx(F.StopOutlined,{})})})]})}function hn(n){var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const{workflow:i}=Z(),a=T(w({},o),{request:T(w({},e),{params:T(w({},e==null?void 0:e.params),{filter:T(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,w({},a))}function yn(){var $;const e=re.useNavigate(),{t}=Q.useTranslation(),o=l.useApp(),{data:n,refresh:s,loading:i}=l.useResourceActionContext(),{resource:a}=l.useResourceContext(),{setTitle:c}=l.useDocumentTitle(),[d,p]=b.useState(!1),{styles:f}=te(),{modal:x}=y.App.useApp();if(b.useEffect(()=>{var I;const{title:S}=(I=n==null?void 0:n.data)!=null?I:{};c==null||c(`${E("Workflow")}${S?`: ${S}`:""}`)},[n==null?void 0:n.data]),!(n!=null&&n.data))return i?r.jsx(y.Spin,{}):r.jsx(y.Result,{status:"404",title:"Not found"});const N=($=n==null?void 0:n.data)!=null?$:{},{nodes:k=[],revisions:h=[]}=N,u=q(N,["nodes","revisions"]);kt(k);const C=k.find(S=>!S.upstream);function O({key:S}){S!=u.id&&e(Ae(S))}function P(S){return _(this,null,function*(){yield a.update({filterByTk:u.id,values:{enabled:S}}),s()})}function A(){return _(this,null,function*(){const{data:{data:S}}=yield a.revision({filterByTk:u.id,filter:{key:u.key}});y.message.success(t("Operation succeeded")),e(`/admin/workflow/workflows/${S.id}`)})}function B(){return _(this,null,function*(){const S=u.current?E("Delete a main version will cause all other revisions to be deleted too."):"";x.confirm({title:t("Are you sure you want to delete it?"),content:S,onOk(){return _(this,null,function*(){var L;yield a.destroy({filterByTk:u.id}),y.message.success(t("Operation succeeded")),e(u.current?o.pluginSettingsManager.getRoutePath("workflow"):Ae((L=h.find(J=>J.current))==null?void 0:L.id))})}})})}function z(I){return _(this,arguments,function*({key:S}){switch(S){case"history":p(!0);return;case"revision":return A();case"delete":return B()}})}const H=u.executed&&!h.find(S=>!S.executed&&new Date(S.createdAt)>new Date(u.createdAt));return r.jsxs(Je.Provider,{value:{workflow:u,nodes:k,refresh:s},children:[r.jsxs("div",{className:"workflow-toolbar",children:[r.jsx("header",{children:r.jsx(y.Breadcrumb,{items:[{title:r.jsx(re.Link,{to:o.pluginSettingsManager.getRoutePath("workflow"),children:E("Workflow")})},{title:r.jsx("strong",{children:u.title})}]})}),r.jsxs("aside",{children:[r.jsx("div",{className:"workflow-versions",children:r.jsx(y.Dropdown,{trigger:["click"],menu:{onClick:O,defaultSelectedKeys:[`${u.id}`],className:l.cx(f.dropdownClass,f.workflowVersionDropdownClass),items:h.sort((S,I)=>I.id-S.id).map((S,I)=>({role:"button","aria-label":`version-${I}`,key:`${S.id}`,icon:S.current?r.jsx(F.RightOutlined,{}):null,className:l.cx({executed:S.executed,unexecuted:!S.executed,enabled:S.enabled}),label:r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:`#${S.id}`}),r.jsx("time",{children:ae.str2moment(S.createdAt).format("YYYY-MM-DD HH:mm:ss")})]})}))},children:r.jsxs(y.Button,{type:"text","aria-label":"version",children:[r.jsx("label",{children:E("Version")}),r.jsx("span",{children:u!=null&&u.id?`#${u.id}`:null}),r.jsx(F.DownOutlined,{})]})})}),r.jsx(y.Switch,{checked:u.enabled,onChange:P,checkedChildren:E("On"),unCheckedChildren:E("Off")}),r.jsx(y.Dropdown,{menu:{items:[{role:"button","aria-label":"history",key:"history",label:E("Execution history"),disabled:!u.allExecuted},{role:"button","aria-label":"revision",key:"revision",label:E("Copy to new version"),disabled:!H},{role:"button","aria-label":"delete",key:"delete",label:t("Delete")}],onClick:z},children:r.jsx(y.Button,{"aria-label":"more",type:"text",icon:r.jsx(F.EllipsisOutlined,{})})}),r.jsx(l.ActionContextProvider,{value:{visible:d,setVisible:p},children:r.jsx(l.SchemaComponent,{schema:qt,components:{ExecutionResourceProvider:hn,ExecutionLink:Gt,ExecutionStatusColumn:Zt}})})]})]}),r.jsx(_t,{entry:C})]})}const Qt=()=>{const e=re.useParams(),{styles:t}=te();return r.jsx("div",{className:l.cx(t.workflowPageClass),children:r.jsx(l.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:["nodes","revisions.id","revisions.createdAt","revisions.current","revisions.executed","revisions.enabled"]}}},"x-component":"WorkflowCanvas"}}},components:{WorkflowCanvas:yn}})})},gn=n=>{var s=n,{request:e,filter:t={}}=s,o=q(s,["request","filter"]);var c;const i=l.useRecord(),a=T(w({},o),{request:T(w({},e),{params:T(w({},e==null?void 0:e.params),{filter:T(w({},(c=e==null?void 0:e.params)==null?void 0:c.filter),{key:i.key})})})});return r.jsx(l.ResourceActionProvider,w({},a))},bn=()=>{const{t:e}=Q.useTranslation(),{id:t}=l.useRecord(),{setVisible:o}=l.useActionContext(),{getAriaLabel:n}=l.useGetAriaLabelOfAction("Configure");return r.jsx(re.Link,{"aria-label":n(),to:Ae(t),onClick:()=>o(!1),children:e("Configure")})};function xn(n){var s=n,{component:e="div",children:t}=s,o=q(s,["component","children"]);const[i,a]=b.useState(!1),c=M.useFieldSchema();return r.jsxs(l.ActionContextProvider,{value:{visible:i,setVisible:a,fieldSchema:c},children:[b.createElement(e,T(w({},o),{onClick(){a(!0)}}),t),r.jsx(l.SchemaComponent,{schema:c,onlyRenderProperties:!0})]})}const Xt={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:"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"}]},ue={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},sync:{type:"boolean",title:`{{ t("Execute mode", { ns: "${m}" }) }}`,description:`{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "${m}" }) }}`,"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:`{{ t("Asynchronously", { ns: "${m}" }) }}`,value:!1,tooltip:`{{ t("Will be executed in the background as a queued task.", { ns: "${m}" }) }}`},{label:`{{ t("Synchronously", { 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}" }) }}`}]}},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}}}}},vn={type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Xt,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Xt},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-component-props":{icon:"FilterOutlined",useProps:"{{ cm.useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:ue.title,type:ue.type,sync:ue.sync,description:ue.description,options:ue.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,default:!1}}},allExecuted:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{allExecuted:{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(t){const o=l.useRecord();return b.createElement("a",w({"aria-label":`executed-${o.title}`},t))}},"x-component":"CollectionField","x-read-pretty":!0,properties:{drawer:qt}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:ue.title,enabled:ue.enabled,sync:ue.sync,description:ue.description,options:ue.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{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}=Q.useTranslation(),{refresh:t}=l.useResourceActionContext(),{resource:o,targetKey:n}=l.useResourceContext(),{setVisible:s}=l.useActionContext(),{[n]:i}=l.useRecord(),{values:a}=M.useForm();return{run(){return _(this,null,function*(){yield o.revision({filterByTk:i,values:a}),y.message.success(e("Operation succeeded")),t(),s(!1)})}}}}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}};function wn(e){const t=M.useField(),o=l.useRecord(),n=l.usePlugin(de);return M.useFormEffects(s=>{ge.onFieldChange("type",i=>{let a=o.id||!i.value;if(i.value){const c=n.triggers.get(i.value);c.sync!=null?(a=!0,t.setValue(c.sync)):t.setInitialValue(!1)}t.setPattern(a?"disabled":"editable")})}),b.useEffect(()=>{if(o.id){t.setPattern("disabled");const s=n.triggers.get(o.type);s.sync!=null?t.setValue(s.sync):t.setInitialValue(!1)}},[o.id,t,n.triggers]),r.jsx(Ie,w({},e))}function Cn(){const e=b.useContext(l.SchemaComponentContext),{getTriggersOptions:t}=l.usePlugin(de);return r.jsx(y.Card,{bordered:!1,children:r.jsx(l.SchemaComponentContext.Provider,{value:T(w({},e),{designable:!1}),children:r.jsx(l.SchemaComponent,{schema:vn,components:{WorkflowLink:bn,ExecutionResourceProvider:gn,ExecutionLink:Gt,OpenDrawer:xn,ExecutionStatusSelect:fn,SyncOptionSelect:wn,ExecutionStatusColumn:Zt},scope:{getTriggersOptions:t}})})})}const be={type:"string",title:'{{t("Collection")}}',required:!0,"x-reactions":[],"x-decorator":"FormItem","x-component":"CollectionSelect","x-component-props":{className:"auto-width"}},Rt={type:"object",title:'{{t("Fields values")}}',"x-decorator":"FormItem","x-decorator-props":{labelAlign:"left",className:l.css`
|
|
453
453
|
flex-direction: column;
|
|
454
|
-
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${
|
|
454
|
+
`},"x-component":"CollectionFieldset",description:`{{t("Unassigned fields will be set to default values, and those without default values will be set to null.", { ns: "${m}" })}}`},Pe={type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{useProps(){const{values:e}=M.useForm();return{options:l.useCollectionFilterOptions(e==null?void 0:e.collection),className:l.css`
|
|
455
455
|
position: relative;
|
|
456
456
|
width: 100%;
|
|
457
|
-
`}},dynamicComponent:"FilterDynamicComponent"}},
|
|
457
|
+
`}},dynamicComponent:"FilterDynamicComponent"}},kn={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"}}},Sn={type:"void",title:'{{t("Pagination")}}',"x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",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}}}}}}},Be={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}=M.useForm();return e==null?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},Oe={CREATED:1,UPDATED:2,SAVED:3,DELETED:4},An=[{label:`{{t("After record added", { ns: "${m}" })}}`,value:Oe.CREATED},{label:`{{t("After record updated", { ns: "${m}" })}}`,value:Oe.UPDATED},{label:`{{t("After record added or updated", { ns: "${m}" })}}`,value:Oe.SAVED},{label:`{{t("After record deleted", { ns: "${m}" })}}`,value:Oe.DELETED}];class On extends yt{constructor(){super(...arguments);v(this,"title",`{{t("Collection event", { ns: "${m}" })}}`);v(this,"description",`{{t("Event will be triggered on collection data row created, updated or deleted.", { ns: "${m}" })}}`);v(this,"fieldset",{collection:T(w({},be),{"x-reactions":[...be["x-reactions"],{target:"changed",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:An,required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},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(o){return!o.hidden&&(o.uiSchema?!o.uiSchema["x-read-pretty"]:!0)&&!["linkTo","hasOne","hasMany","belongsToMany"].includes(o.type)}},"x-reactions":[{dependencies:["collection","mode"],fulfill:{state:{visible:`{{!!$deps[0] && ($deps[1] & ${Oe.UPDATED})}}`}}}]},condition:T(w({},Pe),{title:`{{t("Only triggers when match conditions", { ns: "${m}" })}}`,"x-component-props":{useProps:Pe["x-component-props"].useProps},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}),appends:T(w({},Be),{"x-reactions":[...Be["x-reactions"],{dependencies:["mode"],fulfill:{state:{visible:`{{!($deps[0] & ${Oe.DELETED})}}`}}}]})});v(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});v(this,"components",{FieldsSelect:At})}useVariables(o,n){var d;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager_deprecated(),a=[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}];return Se(T(w({appends:["data",...((d=o.appends)==null?void 0:d.map(p=>`data.${p}`))||[]]},n),{fields:a,compile:s,getCollectionFields:i}))}useInitializers(o){return o.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const xe={STATIC:0,DATE_FIELD:1};function Tn(e){return!e.hidden&&(e.uiSchema?e.type==="date":!1)}function eo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),[n,s]=b.useState(e.offset?e.offset/Math.abs(e.offset):0);return r.jsxs("fieldset",{className:l.css`
|
|
458
458
|
display: flex;
|
|
459
459
|
gap: 0.5em;
|
|
460
|
-
`,children:[r.jsx(
|
|
460
|
+
`,children:[r.jsx(At,{value:e.field,onChange:i=>t(T(w({},e),{field:i})),filter:Tn,placeholder:o("Select field"),className:"auto-width"}),e.field?r.jsx(y.Select,{value:n,onChange:i=>{s(i),t(T(w({},e),{offset:Math.abs(e.offset)*i}))},options:[{value:0,label:E("Exactly at")},{value:-1,label:o("Before")},{value:1,label:o("After")}],className:"auto-width"}):null,n?r.jsxs(r.Fragment,{children:[r.jsx(y.InputNumber,{value:Math.abs(e.offset),onChange:i=>t(T(w({},e),{offset:(i!=null?i:0)*n}))}),r.jsx(y.Select,{value:e.unit||864e5,onChange:i=>t(T(w({},e),{unit:i})),options:[{value:864e5,label:E("Days")},{value:36e5,label:E("Hours")},{value:6e4,label:E("Minutes")},{value:1e3,label:E("Seconds")}],className:"auto-width"})]}):null]})}function Fn({value:e,onChange:t}){const{t:o}=ut(),n=e!=null?typeof e=="object"&&!(e instanceof Date)?"field":"date":null;return r.jsxs("fieldset",{className:l.css`
|
|
461
461
|
display: flex;
|
|
462
462
|
gap: 0.5em;
|
|
463
|
-
`,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(eo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Vo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var oe=function(){return oe=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},oe.apply(this,arguments)};function to(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Qe(e,t,o){if(o||arguments.length===2)for(var n,s=0,l=t.length;s<l;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var An=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],ve=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function oo(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Xe(e){return e.sort(function(t,o){return t-o}),e}function no(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function se(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function ro(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||V.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function so(e,t,o,n,s,l,i,c,u,d,f,v,k,h){o&&o(void 0),t(!1);var m=!1;if(!e){if(n==="always"||l&&n==="for-default-value")return;m=!0}if(!m){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var C=An.find(function(O){return O.name===e});C&&(e=C.value)}try{var F=function(O){if(typeof O!="string")throw new Error("Invalid cron string");var B=O.replace(/\s+/g," ").trim().split(" ");if(B.length===5)return B.map(function(z,H){return function($,N){if($==="*"||$==="*/1")return[];var S=Xe(no(co(function(W,J,le){if(le){W=W.toUpperCase();for(var D=0;D<le.length;D++)W=W.replace(le[D],"".concat(D+J))}return W}($,N.min,N.alt).split(",").map(function(W){var J,le=W.split("/");if(le.length>2)throw new Error('Invalid value "'.concat($,' for "').concat(N.type,'"'));var D=le[0],j=le[1];J=D==="*"?oo(N.min,N.max):function(U,Y,X){var R=U.split("-");if(R.length===1){var je=Re(R[0]);if(isNaN(je))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));return[je]}if(R.length===2){var pe=Re(R[0]),Fe=Re(R[1]);if(isNaN(pe)||isNaN(Fe))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));if(Fe<pe)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(X.type));return oo(pe,Fe)}throw new Error('Invalid value "'.concat(U,'" for ').concat(X.type))}(D,$,N);var L=function(U,Y){if(U!==void 0){var X=Re(U);if(isNaN(X)||X<1)throw new Error('Invalid interval step value "'.concat(U,'" for ').concat(Y.type));return X}}(j,N),ne=function(U,Y){if(Y){var X=U[0];U=U.filter(function(R){return R%Y==X%Y||R===X})}return U}(J,L);return ne}).flat(),N))),I=uo(S,N);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(N.type));return S.length===N.total?[]:S}(z,ve[H])});throw new Error("Invalid cron string format")}(e),M=function(O){return O[3].length>0?"year":O[2].length>0?"month":O[4].length>0?"week":O[1].length>0?"day":O[0].length>0?"hour":"minute"}(F);h(M),u(F[0]),d(F[1]),f(F[2]),v(F[3]),k(F[4])}catch(O){m=!0}}m&&(s.current=e,t(!0),ro(o,i))}function lo(e,t,o,n,s,l,i){if(e==="reboot")return"@reboot";var c=function(u,d){return u.map(function(f,v){var k=ve[v];return io(ao(f,k),k,d)})}([e!=="minute"&&l?l:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],i);return c.join(" ")}function io(e,t,o,n,s){var l="";if(function(c,u){return c.length===u.max-u.min+1}(e,t)||e.length===0)l="*";else{var i=function(c){if(c.length>2){var u=c[1]-c[0];if(u>1)return u}}(e);l=i&&function(c,u){for(var d=1;d<c.length;d++){var f=c[d-1];if(c[d]-f!==u)return!1}return!0}(e,i)?function(c,u,d){var f=po(c),v=mo(c),k=c.length===(v-f)/d+1;return!!(f===u.min&&v+d>u.max&&k)}(e,t,i)?"*/".concat(i):"".concat(Te(po(e),t,o,n,s),"-").concat(Te(mo(e),t,o,n,s),"/").concat(i):function(c){var u=[],d=null;return c.forEach(function(f,v,k){f!==k[v+1]-1?d!==null?(u.push([d,f]),d=null):u.push(f):d===null&&(d=f)}),u}(e).map(function(c){return Array.isArray(c)?"".concat(Te(c[0],t,o,n,s),"-").concat(Te(c[1],t,o,n,s)):Te(c,t,o,n,s)}).join(",")}return l}function Te(e,t,o,n,s){var l=e.toString(),i=t.type,c=t.alt,u=t.min,d=n&&(n===!0||n.includes(i)),f=s==="24-hour-clock"&&(i==="hours"||i==="minutes");if(o&&i==="week-days"||o&&i==="months"?l=c[e-u]:e<10&&(d||f)&&(l=l.padStart(2,"0")),i==="hours"&&s==="12-hour-clock"){var v=e>=12?"PM":"AM",k=e%12||12;k<10&&d&&(k=k.toString().padStart(2,"0")),l="".concat(k).concat(v)}return l}function ao(e,t){var o=Xe(no(co(e,t)));if(o.length===0)return o;var n=uo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function co(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function uo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function po(e){return e[0]}function mo(e){return e[e.length-1]}function Ve(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,l=e.setValue,i=e.locale,c=e.className,u=e.humanizeLabels,d=e.disabled,f=e.readOnly,v=e.leadingZero,k=e.clockFormat,h=e.period,m=e.unit,C=e.periodicityOnDoubleClick,F=e.mode,M=to(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),O=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(D){return D.toString()})},[t]),B=b.useMemo(function(){return s?s.map(function(D,j){return{value:(m.min===0?j:j+1).toString(),label:D}}):Qe([],Array(m.total),!0).map(function(D,j){var L=m.min===0?j:j+1;return{value:L.toString(),label:Te(L,m,u,v,k)}})},[s,v,u,k]),z=JSON.stringify(i),H=b.useCallback(function(D){var j=D.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var L=io(ao(t,m),m,u,v,k),ne=L.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(i.everyText||V.everyText," ").concat(ne[1]):L})},[t,z,u,v,k]),$=b.useCallback(function(D){var j=Array.isArray(D)?Xe(D):[D],L=j;t&&(L=F==="single"?[]:Qe([],t,!0),j.forEach(function(ne){var U=Number(ne);L=t.some(function(Y){return Y===U})?L.filter(function(Y){return Y!==U}):Xe(Qe(Qe([],L,!0),[U],!1))})),L.length===m.total?l([]):l(L)},[l,t]),N=b.useCallback(function(D){if(D!==0&&D!==1){for(var j=m.total+m.min,L=[],ne=m.min;ne<j;ne++)ne%D==0&&L.push(ne);var U=t&&L&&t.length===L.length&&t.every(function(X,R){return X===L[R]}),Y=L.length===B.length;l(Y||U?[]:L)}else l([])},[t,B,l]),S=b.useRef([]),I=b.useCallback(function(D){if(!f){var j=S.current;j.push({time:new Date().getTime(),value:Number(D)});var L=window.setTimeout(function(){C&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?N(Number(D)):$([j[j.length-2].value,j[j.length-1].value]):$(Number(D)),S.current=[]},300);return function(){window.clearTimeout(L)}}},[S,$,N,f,C]),W=b.useCallback(function(){f||l([])},[l,f]),J=b.useMemo(function(){var D;return se(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),le=b.useMemo(function(){var D;return se(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(m.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=m.type==="minutes"&&h!=="hour"&&h!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=m.type==="minutes"&&(h==="day"||h==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=m.type==="hours"&&k==="12-hour-clock",D["react-js-cron-custom-select-dropdown-grid"]=!!n,D["".concat(c,"-select-dropdown")]=!!c,D["".concat(c,"-select-dropdown-").concat(m.type)]=!!c,D))},[c,n,k,h]);return r.jsx(y.Select,oe({mode:F!=="single"||C?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:O,onClear:W,tagRender:H,className:J,popupClassName:le,options:B,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:d,dropdownAlign:m.type!=="minutes"&&m.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(m.type)},M))}function Tn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||V.prefixHours}),r.jsx(Ve,{placeholder:n.emptyHours||V.emptyHours,value:t,unit:ve[1],setValue:o,locale:n,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v})]}))}function Fn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.leadingZero,u=e.clockFormat,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[d==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||V.prefixMinutes}),r.jsx(Ve,{placeholder:d==="hour"?n.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:n.emptyMinutes||V.emptyMinutes,value:t,unit:ve[0],setValue:o,locale:n,className:s,disabled:l,readOnly:i,leadingZero:c,clockFormat:u,period:d,periodicityOnDoubleClick:f,mode:v}),d==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function $n(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.weekDays,i=e.disabled,c=e.readOnly,u=e.leadingZero,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=!l||l.length===0,h=b.useMemo(function(){var F;return se(((F={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!k})["".concat(s,"-field")]=!!s,F["".concat(s,"-month-days")]=!!s,F))},[s,k]),m=JSON.stringify(n),C=b.useMemo(function(){return k?n.emptyMonthDays||V.emptyMonthDays:n.emptyMonthDaysShort||V.emptyMonthDaysShort},[k,m]);return!c||t&&t.length>0||(!t||t.length===0)&&(!l||l.length===0)?r.jsxs("div",oe({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ve,{placeholder:C,value:t,setValue:o,unit:ve[2],locale:n,className:s,disabled:i,readOnly:c,leadingZero:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function Dn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.humanizeLabels,i=e.disabled,c=e.readOnly,u=e.period,d=e.periodicityOnDoubleClick,f=e.mode,v=n.months||V.months,k=b.useMemo(function(){var h;return se(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||V.prefixMonths}),r.jsx(Ve,{placeholder:n.emptyMonths||V.emptyMonths,optionsList:v,grid:!1,value:t,unit:oe(oe({},ve[3]),{alt:n.altMonths||V.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:l,disabled:i,readOnly:c,period:u,periodicityOnDoubleClick:d,mode:f})]}))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.disabled,i=e.readOnly,c=e.shortcuts,u=e.allowedPeriods,d=[];u.includes("year")&&d.push({value:"year",label:n.yearOption||V.yearOption}),u.includes("month")&&d.push({value:"month",label:n.monthOption||V.monthOption}),u.includes("week")&&d.push({value:"week",label:n.weekOption||V.weekOption}),u.includes("day")&&d.push({value:"day",label:n.dayOption||V.dayOption}),u.includes("hour")&&d.push({value:"hour",label:n.hourOption||V.hourOption}),u.includes("minute")&&d.push({value:"minute",label:n.minuteOption||V.minuteOption}),u.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&d.push({value:"reboot",label:n.rebootOption||V.rebootOption});var f=b.useCallback(function(m){i||o(m)},[o,i]),v=b.useMemo(function(){var m;return se(((m={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,m["".concat(s,"-period")]=!!s,m))},[s]),k=b.useMemo(function(){var m;return se(((m={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,m))},[s,n.prefixPeriod]),h=b.useMemo(function(){var m;return se(((m={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,m["".concat(s,"-select-dropdown-period")]=!!s,m))},[s]);return r.jsxs("div",oe({className:v},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||V.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:d,className:k,popupClassName:h,disabled:l,showArrow:!i,open:!i&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Nn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,l=e.humanizeLabels,i=e.monthDays,c=e.disabled,u=e.readOnly,d=e.period,f=e.periodicityOnDoubleClick,v=e.mode,k=n.weekDays||V.weekDays,h=d==="week"||!i||i.length===0,m=b.useMemo(function(){var B;return se(((B={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,B["".concat(s,"-week-days")]=!!s,B))},[s,h]),C=JSON.stringify(n),F=b.useMemo(function(){return h?n.emptyWeekDays||V.emptyWeekDays:n.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,C]),M=d==="week"||!u||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0),O=!u||i&&i.length>0||(!i||i.length===0)&&(!t||t.length===0);return M?r.jsxs("div",oe({className:m},{children:[n.prefixWeekDays!==""&&(d==="week"||!O)&&r.jsx("span",{children:n.prefixWeekDays||V.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&d!=="week"&&O&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ve,{placeholder:F,optionsList:k,grid:!1,value:t,unit:oe(oe({},ve[4]),{alt:n.altWeekDays||V.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:l,disabled:c,readOnly:u,period:d,periodicityOnDoubleClick:f,mode:v})]})):null}function In(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,l=e.clearButtonAction,i=l===void 0?"fill-with-every":l,c=e.locale,u=c===void 0?V:c,d=e.value,f=d===void 0?"":d,v=e.setValue,k=e.displayError,h=k===void 0||k,m=e.onError,C=e.className,F=e.defaultPeriod,M=F===void 0?"day":F,O=e.allowEmpty,B=O===void 0?"for-default-value":O,z=e.humanizeLabels,H=z===void 0||z,$=e.humanizeValue,N=$!==void 0&&$,S=e.disabled,I=S!==void 0&&S,W=e.readOnly,J=W!==void 0&&W,le=e.leadingZero,D=le!==void 0&&le,j=e.shortcuts,L=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,U=e.periodicityOnDoubleClick,Y=U===void 0||U,X=e.mode,R=X===void 0?"multiple":X,je=e.allowedDropdowns,pe=je===void 0?["period","months","month-days","week-days","hours","minutes"]:je,Fe=e.allowedPeriods,or=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,$e=b.useRef(f),Tt=b.useRef(M),vo=b.useState(),ye=vo[0],et=vo[1],wo=b.useState(),Le=wo[0],tt=wo[1],Co=b.useState(),ot=Co[0],nt=Co[1],ko=b.useState(),We=ko[0],rt=ko[1],So=b.useState(),st=So[0],lt=So[1],Oo=b.useState(),it=Oo[0],at=Oo[1],Ao=b.useState(!1),Ft=Ao[0],ze=Ao[1],To=b.useState(!1),ct=To[0],Fo=To[1],nr=function(G){var me=b.useRef(G);return b.useEffect(function(){me.current=G},[G]),me.current}(ct),$o=JSON.stringify(u);b.useEffect(function(){so(f,ze,m,B,$e,!0,u,L,at,lt,tt,nt,rt,et)},[]),b.useEffect(function(){f!==$e.current&&so(f,ze,m,B,$e,!1,u,L,at,lt,tt,nt,rt,et)},[f,$e,$o,B,L]),b.useEffect(function(){if(!(ye||it||ot||Le||We||st)||ct||nr)ct&&Fo(!1);else{var G=ye||Tt.current,me=lo(G,ot,Le,We,st,it,N);v(me,{selectedPeriod:G}),$e.current=me,m&&m(void 0),ze(!1)}},[ye,Le,ot,We,st,it,N,ct]);var Do=b.useCallback(function(){tt(void 0),nt(void 0),rt(void 0),lt(void 0),at(void 0);var G="",me=ye!=="reboot"&&ye?ye:Tt.current;me!==ye&&et(me),i==="fill-with-every"&&(G=lo(me,void 0,void 0,void 0,void 0,void 0)),v(G,{selectedPeriod:me}),$e.current=G,Fo(!0),B==="never"&&i==="empty"?(ze(!0),ro(m,u)):(m&&m(void 0),ze(!1))},[ye,v,m,i]),rr=b.useMemo(function(){var G;return se(((G={"react-js-cron":!0,"react-js-cron-error":Ft&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(C)]=!!C,G["".concat(C,"-error")]=Ft&&h&&!!C,G["".concat(C,"-disabled")]=I&&!!C,G["".concat(C,"-read-only")]=J&&!!C,G))},[C,Ft,h,I,J]),$t=s.className,Eo=to(s,["className"]),No=b.useMemo(function(){var G;return se(((G={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,G["".concat($t)]=!!$t,G))},[C,$t]),sr=JSON.stringify(Eo),Io=b.useMemo(function(){return o&&!J?r.jsx(y.Button,oe({className:No,danger:!0,type:"primary",disabled:I},Eo,{onClick:Do},{children:u.clearButtonText||V.clearButtonText})):null},[o,J,$o,No,I,sr,Do]),ee=ye||Tt.current;return r.jsxs("div",oe({className:rr},{children:[pe.includes("period")&&r.jsx(En,{value:ee,setValue:et,locale:u,className:C,disabled:I,readOnly:J,shortcuts:L,allowedPeriods:or}),ee==="reboot"?Io:r.jsxs(r.Fragment,{children:[ee==="year"&&pe.includes("months")&&r.jsx(Dn,{value:ot,setValue:nt,locale:u,className:C,humanizeLabels:H,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month")&&pe.includes("month-days")&&r.jsx($n,{value:Le,setValue:tt,locale:u,className:C,weekDays:We,disabled:I,readOnly:J,leadingZero:D,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month"||ee==="week")&&pe.includes("week-days")&&r.jsx(Nn,{value:We,setValue:rt,locale:u,className:C,humanizeLabels:H,monthDays:Le,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),r.jsxs("div",{children:[ee!=="minute"&&ee!=="hour"&&pe.includes("hours")&&r.jsx(Tn,{value:st,setValue:lt,locale:u,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,period:ee,periodicityOnDoubleClick:Y,mode:R}),ee!=="minute"&&pe.includes("minutes")&&r.jsx(Fn,{value:it,setValue:at,locale:u,period:ee,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,periodicityOnDoubleClick:Y,mode:R}),Io]})]})]}))}const Mn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function ho(e){return fo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function Pn(e){let t;switch(typeof e){case"number":return t=ho(e),t?t.value:"none";case"string":return"cron"}return"none"}function Bn({value:e,onChange:t}){const{t:o}=dt(),n=ho(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Vn({value:e=null,onChange:t}){const{t:o}=dt(),n=Pn(e);function s(i){if(i==="none"){t(null);return}if(i==="cron"){t("0 * * * * *");return}t(i)}const l=Mn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:a.css`
|
|
463
|
+
`,children:[r.jsxs(y.Select,{value:n,onChange:s=>{t(s?s==="field"?{}:new Date:null)},className:"auto-width",children:[r.jsx(y.Select.Option,{value:null,children:o("No end")}),r.jsx(y.Select.Option,{value:"field",children:o("By field")}),r.jsx(y.Select.Option,{value:"date",children:o("By custom date")})]}),n==="field"?r.jsx(eo,{value:e,onChange:t}):null,n==="date"?r.jsx(y.DatePicker,{showTime:!0,value:Vo(e),onChange:s=>{t(s?s.toDate():null)}}):null]})}var oe=function(){return oe=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},oe.apply(this,arguments)};function to(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function"){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(o[n[s]]=e[n[s]])}return o}function Qe(e,t,o){if(o||arguments.length===2)for(var n,s=0,i=t.length;s<i;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}var $n=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],ve=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],V={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function oo(e,t){for(var o=[],n=e;n<=t;n++)o.push(n);return o}function Xe(e){return e.sort(function(t,o){return t-o}),e}function no(e){var t=[];return e.forEach(function(o){t.indexOf(o)<0&&t.push(o)}),t}function ie(e){return Object.entries(e).filter(function(t){var o=t[0],n=t[1];return o&&n}).map(function(t){return t[0]}).join(" ")}function ro(e,t){e&&e({type:"invalid_cron",description:t.errorInvalidCron||V.errorInvalidCron})}function Re(e){var t=parseInt(e,10),o=Number(e);return t===o?o:NaN}function so(e,t,o,n,s,i,a,c,d,p,f,x,k,h){o&&o(void 0),t(!1);var u=!1;if(!e){if(n==="always"||i&&n==="for-default-value")return;u=!0}if(!u){if(c&&(c===!0||c.includes(e))){if(e==="@reboot")return void h("reboot");var C=$n.find(function(A){return A.name===e});C&&(e=C.value)}try{var O=function(A){if(typeof A!="string")throw new Error("Invalid cron string");var B=A.replace(/\s+/g," ").trim().split(" ");if(B.length===5)return B.map(function(z,H){return function($,N){if($==="*"||$==="*/1")return[];var S=Xe(no(co(function(L,J,le){if(le){L=L.toUpperCase();for(var D=0;D<le.length;D++)L=L.replace(le[D],"".concat(D+J))}return L}($,N.min,N.alt).split(",").map(function(L){var J,le=L.split("/");if(le.length>2)throw new Error('Invalid value "'.concat($,' for "').concat(N.type,'"'));var D=le[0],j=le[1];J=D==="*"?oo(N.min,N.max):function(U,Y,X){var R=U.split("-");if(R.length===1){var je=Re(R[0]);if(isNaN(je))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));return[je]}if(R.length===2){var pe=Re(R[0]),Fe=Re(R[1]);if(isNaN(pe)||isNaN(Fe))throw new Error('Invalid value "'.concat(Y,'" for ').concat(X.type));if(Fe<pe)throw new Error('Max range is less than min range in "'.concat(U,'" for ').concat(X.type));return oo(pe,Fe)}throw new Error('Invalid value "'.concat(U,'" for ').concat(X.type))}(D,$,N);var W=function(U,Y){if(U!==void 0){var X=Re(U);if(isNaN(X)||X<1)throw new Error('Invalid interval step value "'.concat(U,'" for ').concat(Y.type));return X}}(j,N),ne=function(U,Y){if(Y){var X=U[0];U=U.filter(function(R){return R%Y==X%Y||R===X})}return U}(J,W);return ne}).flat(),N))),I=uo(S,N);if(I!==void 0)throw new Error('Value "'.concat(I,'" out of range for ').concat(N.type));return S.length===N.total?[]:S}(z,ve[H])});throw new Error("Invalid cron string format")}(e),P=function(A){return A[3].length>0?"year":A[2].length>0?"month":A[4].length>0?"week":A[1].length>0?"day":A[0].length>0?"hour":"minute"}(O);h(P),d(O[0]),p(O[1]),f(O[2]),x(O[3]),k(O[4])}catch(A){u=!0}}u&&(s.current=e,t(!0),ro(o,a))}function io(e,t,o,n,s,i,a){if(e==="reboot")return"@reboot";var c=function(d,p){return d.map(function(f,x){var k=ve[x];return lo(ao(f,k),k,p)})}([e!=="minute"&&i?i:[],e!=="minute"&&e!=="hour"&&s?s:[],e!=="year"&&e!=="month"||!o?[]:o,e==="year"&&t?t:[],e!=="year"&&e!=="month"&&e!=="week"||!n?[]:n],a);return c.join(" ")}function lo(e,t,o,n,s){var i="";if(function(c,d){return c.length===d.max-d.min+1}(e,t)||e.length===0)i="*";else{var a=function(c){if(c.length>2){var d=c[1]-c[0];if(d>1)return d}}(e);i=a&&function(c,d){for(var p=1;p<c.length;p++){var f=c[p-1];if(c[p]-f!==d)return!1}return!0}(e,a)?function(c,d,p){var f=po(c),x=mo(c),k=c.length===(x-f)/p+1;return!!(f===d.min&&x+p>d.max&&k)}(e,t,a)?"*/".concat(a):"".concat(Te(po(e),t,o,n,s),"-").concat(Te(mo(e),t,o,n,s),"/").concat(a):function(c){var d=[],p=null;return c.forEach(function(f,x,k){f!==k[x+1]-1?p!==null?(d.push([p,f]),p=null):d.push(f):p===null&&(p=f)}),d}(e).map(function(c){return Array.isArray(c)?"".concat(Te(c[0],t,o,n,s),"-").concat(Te(c[1],t,o,n,s)):Te(c,t,o,n,s)}).join(",")}return i}function Te(e,t,o,n,s){var i=e.toString(),a=t.type,c=t.alt,d=t.min,p=n&&(n===!0||n.includes(a)),f=s==="24-hour-clock"&&(a==="hours"||a==="minutes");if(o&&a==="week-days"||o&&a==="months"?i=c[e-d]:e<10&&(p||f)&&(i=i.padStart(2,"0")),a==="hours"&&s==="12-hour-clock"){var x=e>=12?"PM":"AM",k=e%12||12;k<10&&p&&(k=k.toString().padStart(2,"0")),i="".concat(k).concat(x)}return i}function ao(e,t){var o=Xe(no(co(e,t)));if(o.length===0)return o;var n=uo(o,t);if(n!==void 0)throw new Error('Value "'.concat(n,'" out of range for ').concat(t.type));return o}function co(e,t){return t.type==="week-days"&&(e=e.map(function(o){return o===7?0:o})),e}function uo(e,t){var o=e[0],n=e[e.length-1];return o<t.min?o:n>t.max?n:void 0}function po(e){return e[0]}function mo(e){return e[e.length-1]}function Ve(e){var t=e.value,o=e.grid,n=o===void 0||o,s=e.optionsList,i=e.setValue,a=e.locale,c=e.className,d=e.humanizeLabels,p=e.disabled,f=e.readOnly,x=e.leadingZero,k=e.clockFormat,h=e.period,u=e.unit,C=e.periodicityOnDoubleClick,O=e.mode,P=to(e,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode"]),A=b.useMemo(function(){if(t&&Array.isArray(t))return t.map(function(D){return D.toString()})},[t]),B=b.useMemo(function(){return s?s.map(function(D,j){return{value:(u.min===0?j:j+1).toString(),label:D}}):Qe([],Array(u.total),!0).map(function(D,j){var W=u.min===0?j:j+1;return{value:W.toString(),label:Te(W,u,d,x,k)}})},[s,x,d,k]),z=JSON.stringify(a),H=b.useCallback(function(D){var j=D.value;if(!t||t[0]!==Number(j))return r.jsx(r.Fragment,{});var W=lo(ao(t,u),u,d,x,k),ne=W.match(/^\*\/([0-9]+),?/)||[];return r.jsx("div",{children:ne[1]?"".concat(a.everyText||V.everyText," ").concat(ne[1]):W})},[t,z,d,x,k]),$=b.useCallback(function(D){var j=Array.isArray(D)?Xe(D):[D],W=j;t&&(W=O==="single"?[]:Qe([],t,!0),j.forEach(function(ne){var U=Number(ne);W=t.some(function(Y){return Y===U})?W.filter(function(Y){return Y!==U}):Xe(Qe(Qe([],W,!0),[U],!1))})),W.length===u.total?i([]):i(W)},[i,t]),N=b.useCallback(function(D){if(D!==0&&D!==1){for(var j=u.total+u.min,W=[],ne=u.min;ne<j;ne++)ne%D==0&&W.push(ne);var U=t&&W&&t.length===W.length&&t.every(function(X,R){return X===W[R]}),Y=W.length===B.length;i(Y||U?[]:W)}else i([])},[t,B,i]),S=b.useRef([]),I=b.useCallback(function(D){if(!f){var j=S.current;j.push({time:new Date().getTime(),value:Number(D)});var W=window.setTimeout(function(){C&&j.length>1&&j[j.length-1].time-j[j.length-2].time<300?j[j.length-1].value===j[j.length-2].value?N(Number(D)):$([j[j.length-2].value,j[j.length-1].value]):$(Number(D)),S.current=[]},300);return function(){window.clearTimeout(W)}}},[S,$,N,f,C]),L=b.useCallback(function(){f||i([])},[i,f]),J=b.useMemo(function(){var D;return ie(((D={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(c,"-select")]=!!c,D))},[c]),le=b.useMemo(function(){var D;return ie(((D={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(u.type)]=!0,D["react-js-cron-custom-select-dropdown"]=!0,D["react-js-cron-custom-select-dropdown-".concat(u.type)]=!0,D["react-js-cron-custom-select-dropdown-minutes-large"]=u.type==="minutes"&&h!=="hour"&&h!=="day",D["react-js-cron-custom-select-dropdown-minutes-medium"]=u.type==="minutes"&&(h==="day"||h==="hour"),D["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]=u.type==="hours"&&k==="12-hour-clock",D["react-js-cron-custom-select-dropdown-grid"]=!!n,D["".concat(c,"-select-dropdown")]=!!c,D["".concat(c,"-select-dropdown-").concat(u.type)]=!!c,D))},[c,n,k,h]);return r.jsx(y.Select,oe({mode:O!=="single"||C?"multiple":void 0,allowClear:!f,virtual:!1,open:!f&&void 0,value:A,onClear:L,tagRender:H,className:J,popupClassName:le,options:B,showSearch:!1,showArrow:!f,menuItemSelectedIcon:null,dropdownMatchSelectWidth:!1,onSelect:I,onDeselect:I,disabled:p,dropdownAlign:u.type!=="minutes"&&u.type!=="hours"||h==="day"||h==="hour"?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(u.type)},P))}function Dn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,k=b.useMemo(function(){var h;return ie(((h={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-hours")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixHours!==""&&r.jsx("span",{children:n.prefixHours||V.prefixHours}),r.jsx(Ve,{placeholder:n.emptyHours||V.emptyHours,value:t,unit:ve[1],setValue:o,locale:n,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:x})]}))}function En(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.leadingZero,d=e.clockFormat,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,k=b.useMemo(function(){var h;return ie(((h={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-minutes")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[p==="hour"?n.prefixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.prefixMinutesForHourPeriod||V.prefixMinutesForHourPeriod}):n.prefixMinutes!==""&&r.jsx("span",{children:n.prefixMinutes||V.prefixMinutes}),r.jsx(Ve,{placeholder:p==="hour"?n.emptyMinutesForHourPeriod||V.emptyMinutesForHourPeriod:n.emptyMinutes||V.emptyMinutes,value:t,unit:ve[0],setValue:o,locale:n,className:s,disabled:i,readOnly:a,leadingZero:c,clockFormat:d,period:p,periodicityOnDoubleClick:f,mode:x}),p==="hour"&&n.suffixMinutesForHourPeriod!==""&&r.jsx("span",{children:n.suffixMinutesForHourPeriod||V.suffixMinutesForHourPeriod})]}))}function Nn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.weekDays,a=e.disabled,c=e.readOnly,d=e.leadingZero,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,k=!i||i.length===0,h=b.useMemo(function(){var O;return ie(((O={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!k})["".concat(s,"-field")]=!!s,O["".concat(s,"-month-days")]=!!s,O))},[s,k]),u=JSON.stringify(n),C=b.useMemo(function(){return k?n.emptyMonthDays||V.emptyMonthDays:n.emptyMonthDaysShort||V.emptyMonthDaysShort},[k,u]);return!c||t&&t.length>0||(!t||t.length===0)&&(!i||i.length===0)?r.jsxs("div",oe({className:h},{children:[n.prefixMonthDays!==""&&r.jsx("span",{children:n.prefixMonthDays||V.prefixMonthDays}),r.jsx(Ve,{placeholder:C,value:t,setValue:o,unit:ve[2],locale:n,className:s,disabled:a,readOnly:c,leadingZero:d,period:p,periodicityOnDoubleClick:f,mode:x})]})):null}function In(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,a=e.disabled,c=e.readOnly,d=e.period,p=e.periodicityOnDoubleClick,f=e.mode,x=n.months||V.months,k=b.useMemo(function(){var h;return ie(((h={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(s,"-field")]=!!s,h["".concat(s,"-months")]=!!s,h))},[s]);return r.jsxs("div",oe({className:k},{children:[n.prefixMonths!==""&&r.jsx("span",{children:n.prefixMonths||V.prefixMonths}),r.jsx(Ve,{placeholder:n.emptyMonths||V.emptyMonths,optionsList:x,grid:!1,value:t,unit:oe(oe({},ve[3]),{alt:n.altMonths||V.altMonths}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:a,readOnly:c,period:d,periodicityOnDoubleClick:p,mode:f})]}))}function Mn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.disabled,a=e.readOnly,c=e.shortcuts,d=e.allowedPeriods,p=[];d.includes("year")&&p.push({value:"year",label:n.yearOption||V.yearOption}),d.includes("month")&&p.push({value:"month",label:n.monthOption||V.monthOption}),d.includes("week")&&p.push({value:"week",label:n.weekOption||V.weekOption}),d.includes("day")&&p.push({value:"day",label:n.dayOption||V.dayOption}),d.includes("hour")&&p.push({value:"hour",label:n.hourOption||V.hourOption}),d.includes("minute")&&p.push({value:"minute",label:n.minuteOption||V.minuteOption}),d.includes("reboot")&&c&&(c===!0||c.includes("@reboot"))&&p.push({value:"reboot",label:n.rebootOption||V.rebootOption});var f=b.useCallback(function(u){a||o(u)},[o,a]),x=b.useMemo(function(){var u;return ie(((u={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(s,"-field")]=!!s,u["".concat(s,"-period")]=!!s,u))},[s]),k=b.useMemo(function(){var u;return ie(((u={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":n.prefixPeriod===""})["".concat(s,"-select")]=!!s,u))},[s,n.prefixPeriod]),h=b.useMemo(function(){var u;return ie(((u={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(s,"-select-dropdown")]=!!s,u["".concat(s,"-select-dropdown-period")]=!!s,u))},[s]);return r.jsxs("div",oe({className:x},{children:[n.prefixPeriod!==""&&r.jsx("span",{children:n.prefixPeriod||V.prefixPeriod}),r.jsx(y.Select,{defaultValue:t,value:t,onChange:f,options:p,className:k,popupClassName:h,disabled:i,showArrow:!a,open:!a&&void 0,"data-testid":"select-period"},JSON.stringify(n))]}))}function Pn(e){var t=e.value,o=e.setValue,n=e.locale,s=e.className,i=e.humanizeLabels,a=e.monthDays,c=e.disabled,d=e.readOnly,p=e.period,f=e.periodicityOnDoubleClick,x=e.mode,k=n.weekDays||V.weekDays,h=p==="week"||!a||a.length===0,u=b.useMemo(function(){var B;return ie(((B={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!h})["".concat(s,"-field")]=!!s,B["".concat(s,"-week-days")]=!!s,B))},[s,h]),C=JSON.stringify(n),O=b.useMemo(function(){return h?n.emptyWeekDays||V.emptyWeekDays:n.emptyWeekDaysShort||V.emptyWeekDaysShort},[h,C]),P=p==="week"||!d||t&&t.length>0||(!t||t.length===0)&&(!a||a.length===0),A=!d||a&&a.length>0||(!a||a.length===0)&&(!t||t.length===0);return P?r.jsxs("div",oe({className:u},{children:[n.prefixWeekDays!==""&&(p==="week"||!A)&&r.jsx("span",{children:n.prefixWeekDays||V.prefixWeekDays}),n.prefixWeekDaysForMonthAndYearPeriod!==""&&p!=="week"&&A&&r.jsx("span",{children:n.prefixWeekDaysForMonthAndYearPeriod||V.prefixWeekDaysForMonthAndYearPeriod}),r.jsx(Ve,{placeholder:O,optionsList:k,grid:!1,value:t,unit:oe(oe({},ve[4]),{alt:n.altWeekDays||V.altWeekDays}),setValue:o,locale:n,className:s,humanizeLabels:i,disabled:c,readOnly:d,period:p,periodicityOnDoubleClick:f,mode:x})]})):null}function Bn(e){var t=e.clearButton,o=t===void 0||t,n=e.clearButtonProps,s=n===void 0?{}:n,i=e.clearButtonAction,a=i===void 0?"fill-with-every":i,c=e.locale,d=c===void 0?V:c,p=e.value,f=p===void 0?"":p,x=e.setValue,k=e.displayError,h=k===void 0||k,u=e.onError,C=e.className,O=e.defaultPeriod,P=O===void 0?"day":O,A=e.allowEmpty,B=A===void 0?"for-default-value":A,z=e.humanizeLabels,H=z===void 0||z,$=e.humanizeValue,N=$!==void 0&&$,S=e.disabled,I=S!==void 0&&S,L=e.readOnly,J=L!==void 0&&L,le=e.leadingZero,D=le!==void 0&&le,j=e.shortcuts,W=j===void 0?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:j,ne=e.clockFormat,U=e.periodicityOnDoubleClick,Y=U===void 0||U,X=e.mode,R=X===void 0?"multiple":X,je=e.allowedDropdowns,pe=je===void 0?["period","months","month-days","week-days","hours","minutes"]:je,Fe=e.allowedPeriods,sr=Fe===void 0?["year","month","week","day","hour","minute","reboot"]:Fe,$e=b.useRef(f),Tt=b.useRef(P),vo=b.useState(),ye=vo[0],et=vo[1],wo=b.useState(),We=wo[0],tt=wo[1],Co=b.useState(),ot=Co[0],nt=Co[1],ko=b.useState(),Le=ko[0],rt=ko[1],So=b.useState(),st=So[0],it=So[1],Ao=b.useState(),lt=Ao[0],at=Ao[1],Oo=b.useState(!1),Ft=Oo[0],ze=Oo[1],To=b.useState(!1),ct=To[0],Fo=To[1],ir=function(G){var me=b.useRef(G);return b.useEffect(function(){me.current=G},[G]),me.current}(ct),$o=JSON.stringify(d);b.useEffect(function(){so(f,ze,u,B,$e,!0,d,W,at,it,tt,nt,rt,et)},[]),b.useEffect(function(){f!==$e.current&&so(f,ze,u,B,$e,!1,d,W,at,it,tt,nt,rt,et)},[f,$e,$o,B,W]),b.useEffect(function(){if(!(ye||lt||ot||We||Le||st)||ct||ir)ct&&Fo(!1);else{var G=ye||Tt.current,me=io(G,ot,We,Le,st,lt,N);x(me,{selectedPeriod:G}),$e.current=me,u&&u(void 0),ze(!1)}},[ye,We,ot,Le,st,lt,N,ct]);var Do=b.useCallback(function(){tt(void 0),nt(void 0),rt(void 0),it(void 0),at(void 0);var G="",me=ye!=="reboot"&&ye?ye:Tt.current;me!==ye&&et(me),a==="fill-with-every"&&(G=io(me,void 0,void 0,void 0,void 0,void 0)),x(G,{selectedPeriod:me}),$e.current=G,Fo(!0),B==="never"&&a==="empty"?(ze(!0),ro(u,d)):(u&&u(void 0),ze(!1))},[ye,x,u,a]),lr=b.useMemo(function(){var G;return ie(((G={"react-js-cron":!0,"react-js-cron-error":Ft&&h,"react-js-cron-disabled":I,"react-js-cron-read-only":J})["".concat(C)]=!!C,G["".concat(C,"-error")]=Ft&&h&&!!C,G["".concat(C,"-disabled")]=I&&!!C,G["".concat(C,"-read-only")]=J&&!!C,G))},[C,Ft,h,I,J]),$t=s.className,Eo=to(s,["className"]),No=b.useMemo(function(){var G;return ie(((G={"react-js-cron-clear-button":!0})["".concat(C,"-clear-button")]=!!C,G["".concat($t)]=!!$t,G))},[C,$t]),ar=JSON.stringify(Eo),Io=b.useMemo(function(){return o&&!J?r.jsx(y.Button,oe({className:No,danger:!0,type:"primary",disabled:I},Eo,{onClick:Do},{children:d.clearButtonText||V.clearButtonText})):null},[o,J,$o,No,I,ar,Do]),ee=ye||Tt.current;return r.jsxs("div",oe({className:lr},{children:[pe.includes("period")&&r.jsx(Mn,{value:ee,setValue:et,locale:d,className:C,disabled:I,readOnly:J,shortcuts:W,allowedPeriods:sr}),ee==="reboot"?Io:r.jsxs(r.Fragment,{children:[ee==="year"&&pe.includes("months")&&r.jsx(In,{value:ot,setValue:nt,locale:d,className:C,humanizeLabels:H,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month")&&pe.includes("month-days")&&r.jsx(Nn,{value:We,setValue:tt,locale:d,className:C,weekDays:Le,disabled:I,readOnly:J,leadingZero:D,period:ee,periodicityOnDoubleClick:Y,mode:R}),(ee==="year"||ee==="month"||ee==="week")&&pe.includes("week-days")&&r.jsx(Pn,{value:Le,setValue:rt,locale:d,className:C,humanizeLabels:H,monthDays:We,disabled:I,readOnly:J,period:ee,periodicityOnDoubleClick:Y,mode:R}),r.jsxs("div",{children:[ee!=="minute"&&ee!=="hour"&&pe.includes("hours")&&r.jsx(Dn,{value:st,setValue:it,locale:d,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,period:ee,periodicityOnDoubleClick:Y,mode:R}),ee!=="minute"&&pe.includes("minutes")&&r.jsx(En,{value:lt,setValue:at,locale:d,period:ee,className:C,disabled:I,readOnly:J,leadingZero:D,clockFormat:ne,periodicityOnDoubleClick:Y,mode:R}),Io]})]})]}))}const Vn={"zh-CN":{everyText:"每",emptyMonths:"每月",emptyMonthDays:"每日(月)",emptyMonthDaysShort:"每日",emptyWeekDays:"每天(周)",emptyWeekDaysShort:"每天(周)",emptyHours:"每小时",emptyMinutes:"每分钟",emptyMinutesForHourPeriod:"每",yearOption:"年",monthOption:"月",weekOption:"周",dayOption:"天",hourOption:"小时",minuteOption:"分钟",rebootOption:"重启",prefixPeriod:"每",prefixMonths:"的",prefixMonthDays:"的",prefixWeekDays:"的",prefixWeekDaysForMonthAndYearPeriod:"或者",prefixHours:"的",prefixMinutes:":",prefixMinutesForHourPeriod:"的",suffixMinutesForHourPeriod:"分钟",errorInvalidCron:"不符合 cron 规则的表达式",clearButtonText:"清空",weekDays:["周日","周一","周二","周三","周四","周五","周六"],months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],altWeekDays:["周日","周一","周二","周三","周四","周五","周六"],altMonths:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]}},fo=[{value:"none",text:"No repeat"},{value:6e4,text:"By minute",unitText:"Minutes"},{value:36e5,text:"By hour",unitText:"Hours"},{value:864e5,text:"By day",unitText:"Days"},{value:6048e5,text:"By week",unitText:"Weeks"},{value:"cron",text:"Advanced"}];function ho(e){return fo.filter(o=>typeof o.value=="number").reverse().find(o=>!(e%o.value))}function jn(e){let t;switch(typeof e){case"number":return t=ho(e),t?t.value:"none";case"string":return"cron"}return"none"}function Wn({value:e,onChange:t}){const{t:o}=ut(),n=ho(e);return r.jsx(y.InputNumber,{value:e/n.value,onChange:s=>t(s*n.value),min:1,addonBefore:o("Every"),addonAfter:o(n.unitText),className:"auto-width"})}function Ln({value:e=null,onChange:t}){const{t:o}=ut(),n=jn(e);function s(a){if(a==="none"){t(null);return}if(a==="cron"){t("0 * * * * *");return}t(a)}const i=Vn[localStorage.getItem("NOCOBASE_LOCALE")||"en-US"];return r.jsxs("fieldset",{className:l.css`
|
|
464
464
|
display: flex;
|
|
465
465
|
flex-direction: ${n==="cron"?"column":"row"};
|
|
466
466
|
align-items: flex-start;
|
|
@@ -489,7 +489,7 @@
|
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
`,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:fo.map(
|
|
492
|
+
`,children:[r.jsx(y.Select,{value:n,onChange:s,className:"auto-width",children:fo.map(a=>r.jsx(y.Select.Option,{value:a.value,children:o(a.text)},a.value))}),typeof n=="number"?r.jsx(Wn,{value:e,onChange:t}):null,n==="cron"?r.jsx(Bn,{value:e.trim().split(/\s+/).slice(1).join(" "),setValue:a=>t(`0 ${a}`),clearButton:!1,locale:i}):null]})}const zn={[xe.STATIC]:{startsOn:{type:"datetime",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0},required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"datetime",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"DatePicker","x-component-props":{showTime:!0}},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}}},[xe.DATE_FIELD]:{collection:T(w({},be),{"x-reactions":[...be["x-reactions"],{target:"startsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}}]}),startsOn:{type:"object",title:`{{t("Starts on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"OnField","x-reactions":[{target:"repeat",fulfill:{state:{visible:"{{!!$self.value}}"}}}],required:!0},repeat:{type:"string",title:`{{t("Repeat mode", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RepeatField","x-reactions":[{target:"endsOn",fulfill:{state:{visible:"{{!!$self.value}}"}}},{target:"limit",fulfill:{state:{visible:"{{!!$self.value}}"}}}]},endsOn:{type:"object",title:`{{t("Ends on", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"EndsByField"},limit:{type:"number",title:`{{t("Repeat limit", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{placeholder:`{{t("No limit", { ns: "${m}" })}}`,min:0}},appends:T(w({},Be),{"x-reactions":[{dependencies:["mode","collection"],fulfill:{state:{visible:`{{$deps[0] === ${xe.DATE_FIELD} && $deps[1]}}`}}}]})}},Jn=[{value:xe.STATIC,label:`{{t("Based on certain date", { ns: "${m}" })}}`},{value:xe.DATE_FIELD,label:`{{t("Based on date field of collection", { ns: "${m}" })}}`}],Hn=()=>{const{values:e={},clearFormGraph:t}=M.useForm(),[o,n]=b.useState(e.mode);return M.useFormEffects(()=>{ge.onFieldValueChange("mode",s=>{n(s.value),t("collection"),t("startsOn"),t("repeat"),t("endsOn"),t("limit")})}),r.jsxs(r.Fragment,{children:[r.jsx(l.SchemaComponent,{schema:{type:"number",title:`{{t("Trigger mode", { ns: "${m}" })}}`,name:"mode","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:Jn},required:!0,default:xe.STATIC}}),r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[`mode-${o}`]:{type:"void","x-component":"fieldset","x-component-props":{className:l.css`
|
|
493
493
|
.ant-input-number {
|
|
494
494
|
width: auto;
|
|
495
495
|
min-width: 6em;
|
|
@@ -498,23 +498,23 @@
|
|
|
498
498
|
.ant-picker {
|
|
499
499
|
width: auto;
|
|
500
500
|
}
|
|
501
|
-
`},properties:
|
|
501
|
+
`},properties:zn[o]}}},components:{OnField:eo,RepeatField:Ln,EndsByField:Fn}})]})};class Un extends yt{constructor(){super(...arguments);v(this,"sync",!1);v(this,"title",`{{t("Schedule event", { ns: "${m}" })}}`);v(this,"description",`{{t("Event will be scheduled and triggered base on time conditions.", { ns: "${m}" })}}`);v(this,"fieldset",{config:{type:"void","x-component":"ScheduleConfig","x-component-props":{}}});v(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});v(this,"components",{ScheduleConfig:Hn})}useVariables(o,n){var c;const s=l.useCompile(),{getCollectionFields:i}=l.useCollectionManager_deprecated(),a=[];if((!(n!=null&&n.types)||n.types.includes("date"))&&a.push({key:"date",value:"date",label:E("Trigger time")}),o.mode===xe.DATE_FIELD){const[d]=Se(T(w({appends:["data",...((c=o.appends)==null?void 0:c.map(p=>`data.${p}`))||[]]},n),{fields:[{collectionName:o.collection,name:"data",type:"hasOne",target:o.collection,uiSchema:{title:E("Trigger data")}}],compile:s,getCollectionFields:i}));d&&a.push(d)}return a}useInitializers(o){return o.collection?{name:"triggerData",type:"item",title:`{{t("Trigger data", { ns: "${m}" })}}`,Component:Ne,collection:o.collection,dataSource:"{{$context.data}}"}:null}}const yo=e=>{const t=De.evaluators.get(e);return t&&t.link?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:l.css`
|
|
502
502
|
&:after {
|
|
503
503
|
content: ':';
|
|
504
504
|
}
|
|
505
505
|
& + a {
|
|
506
506
|
margin-left: 0.25em;
|
|
507
507
|
}
|
|
508
|
-
`,children:
|
|
508
|
+
`,children:l.i18n.t("Syntax references")}),r.jsx("a",{href:t.link,target:"_blank",rel:"noreferrer",children:t.label})]}):null};class _n extends fe{constructor(){super(...arguments);v(this,"title",`{{t("Calculation", { ns: "${m}" })}}`);v(this,"type","calculation");v(this,"group","control");v(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}" })}}`);v(this,"fieldset",{engine:{type:"string",title:`{{t("Calculation engine", { ns: "${m}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:De.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"(o,n,{form:s}){const{values:i}=s,{evaluate:a}=De.evaluators.get(i.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(c),""}catch(d){return E("Expression syntax error")}},"x-reactions":[{dependencies:["engine"],fulfill:{schema:{description:"{{renderEngineReference($deps[0])}}"}}}],required:!0}});v(this,"scope",{renderEngineReference:yo});v(this,"components",{WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie,ValueBlock:Me})}useVariables({key:o,title:n},{types:s,fieldNames:i=ke}){return s&&!s.some(a=>a in Ge||Object.values(Ge).some(c=>c.has(a)))?null:{[i.value]:o,[i.label]:n}}useInitializers(o){var n,s;return{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Me.Initializer,node:o,resultTitle:E("Calculation result")}}}const K=new ae.Registry;K.register("equal",{name:"=",type:"boolean",group:"boolean"}),K.register("notEqual",{name:"≠",type:"boolean",group:"boolean"}),K.register("gt",{name:">",type:"boolean",group:"boolean"}),K.register("gte",{name:"≥",type:"boolean",group:"boolean"}),K.register("lt",{name:"<",type:"boolean",group:"boolean"}),K.register("lte",{name:"≤",type:"boolean",group:"boolean"}),K.register("add",{name:"+",type:"number",group:"number"}),K.register("minus",{name:"-",type:"number",group:"number"}),K.register("multiple",{name:"*",type:"number",group:"number"}),K.register("divide",{name:"/",type:"number",group:"number"}),K.register("mod",{name:"%",type:"number",group:"number"}),K.register("includes",{name:'{{t("contains")}}',type:"boolean",group:"string"}),K.register("notIncludes",{name:'{{t("does not contain")}}',type:"boolean",group:"string"}),K.register("startsWith",{name:'{{t("starts with")}}',type:"boolean",group:"string"}),K.register("notStartsWith",{name:'{{t("not starts with")}}',type:"boolean",group:"string"}),K.register("endsWith",{name:'{{t("ends with")}}',type:"boolean",group:"string"}),K.register("notEndsWith",{name:'{{t("not ends with")}}',type:"boolean",group:"string"}),K.register("concat",{name:`{{t("concat", { ns: "${m}" })}}`,type:"string",group:"string"});const Yn=[{value:"boolean",title:'{{t("Comparision")}}'},{value:"number",title:`{{t("Arithmetic calculation", { ns: "${m}" })}}`},{value:"string",title:`{{t("String operation", { ns: "${m}" })}}`},{value:"date",title:`{{t("Date", { ns: "${m}" })}}`}];function go(e){return Array.from(K.getEntities()).filter(([t,o])=>o.group===e)}function Gn({calculator:e,operands:t=[],onChange:o}){const n=l.useCompile(),s=he();return r.jsxs("fieldset",{className:l.css`
|
|
509
509
|
display: flex;
|
|
510
510
|
gap: 0.5em;
|
|
511
511
|
align-items: center;
|
|
512
512
|
flex-wrap: wrap;
|
|
513
|
-
`,children:[r.jsx(
|
|
513
|
+
`,children:[r.jsx(l.Variable.Input,{value:t[0],onChange:i=>o({calculator:e,operands:[i,t[1]]}),scope:s,useTypedConstant:!0}),r.jsx(y.Select,{role:"button","aria-label":"select-operator-calc",value:e,onChange:i=>o({operands:t,calculator:i}),placeholder:E("Operator"),popupMatchSelectWidth:!1,className:"auto-width",children:Yn.filter(i=>!!go(i.value).length).map(i=>r.jsx(y.Select.OptGroup,{label:n(i.title),children:go(i.value).map(([a,{name:c}])=>r.jsx(y.Select.Option,{value:a,children:n(c)},a))},i.value))}),r.jsx(l.Variable.Input,{value:t[1],onChange:i=>o({calculator:e,operands:[t[0],i]}),scope:s,useTypedConstant:!0})]})}function qn({value:e,onChange:t,onRemove:o}){if(!e)return null;const{calculator:n,operands:s=[]}=e;return r.jsxs("div",{className:l.css`
|
|
514
514
|
display: flex;
|
|
515
515
|
position: relative;
|
|
516
516
|
margin: 0.5em 0;
|
|
517
|
-
`,children:[e.group?r.jsx(bo,{value:e.group,onChange:
|
|
517
|
+
`,children:[e.group?r.jsx(bo,{value:e.group,onChange:i=>t(T(w({},e),{group:i}))}):r.jsx(Gn,{operands:s,calculator:n,onChange:t}),r.jsx(y.Button,{"aria-label":"icon-close",onClick:o,type:"link",icon:r.jsx(F.CloseCircleOutlined,{})})]})}function bo({value:e,onChange:t}){const{t:o}=Q.useTranslation(),{type:n="and",calculations:s=[]}=e;function i(){t(T(w({},e),{calculations:[...s,{not:!1,calculator:"equal"}]}))}function a(){t(T(w({},e),{calculations:[...s,{not:!1,group:{type:"and",calculations:[]}}]}))}function c(p){s.splice(p,1),t(T(w({},e),{calculations:[...s]}))}function d(p,f){s.splice(p,1,f),t(T(w({},e),{calculations:[...s]}))}return r.jsxs("div",{className:l.cx("node-type-condition-group",l.css`
|
|
518
518
|
position: relative;
|
|
519
519
|
width: 100%;
|
|
520
520
|
.node-type-condition-group {
|
|
@@ -525,7 +525,7 @@
|
|
|
525
525
|
position: absolute;
|
|
526
526
|
right: 0;
|
|
527
527
|
}
|
|
528
|
-
`),children:[r.jsx("div",{className:
|
|
528
|
+
`),children:[r.jsx("div",{className:l.css`
|
|
529
529
|
display: flex;
|
|
530
530
|
align-items: center;
|
|
531
531
|
gap: 0.5em;
|
|
@@ -533,14 +533,14 @@
|
|
|
533
533
|
width: auto;
|
|
534
534
|
min-width: 6em;
|
|
535
535
|
}
|
|
536
|
-
`,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(y.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:
|
|
536
|
+
`,children:r.jsxs(Q.Trans,{children:["Meet ",r.jsxs(y.Select,{role:"button","data-testid":"filter-select-all-or-any",value:n,onChange:p=>t(T(w({},e),{type:p})),children:[r.jsx(y.Select.Option,{value:"and",children:"All"}),r.jsx(y.Select.Option,{value:"or",children:"Any"})]})," conditions in the group"]})}),r.jsx("div",{className:"calculation-items",children:s.map((p,f)=>r.jsx(qn,{value:p,onChange:d.bind(this,f),onRemove:()=>c(f)},`${p.calculator}_${f}`))}),r.jsxs("div",{className:l.css`
|
|
537
537
|
button {
|
|
538
538
|
padding: 0;
|
|
539
539
|
&:not(:last-child) {
|
|
540
540
|
margin-right: 1em;
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
`,children:[r.jsx(y.Button,{type:"link",onClick:
|
|
543
|
+
`,children:[r.jsx(y.Button,{type:"link",onClick:i,children:o("Add condition")}),r.jsx(y.Button,{type:"link",onClick:a,children:o("Add condition group")})]})]})}function Kn({value:e,onChange:t}){const o=e&&Object.keys(e).length?e:{group:{type:"and",calculations:[]}};return r.jsx(bo,{value:o.group,onChange:n=>t(T(w({},o),{group:n}))})}class Zn extends fe{constructor(){super(...arguments);v(this,"title",`{{t("Condition", { ns: "${m}" })}}`);v(this,"type","condition");v(this,"group","control");v(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}" })}}`);v(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(De.evaluators.getEntities())].reduce((o,[n,s])=>o.concat(w({value:n},s)),[])},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"(o,n,{form:s}){const{values:i}=s,{evaluate:a}=De.evaluators.get(i.engine),c=o.trim().replace(/{{([^{}]+)}}/g," 1 ");try{return a(c),""}catch(d){return E("Expression syntax error")}},"x-reactions":{dependencies:["engine"],fulfill:{state:{visible:'{{$deps[0] !== "basic"}}'},schema:{description:"{{renderEngineReference($deps[0])}}"}}},required:!0}});v(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}}]);v(this,"scope",{renderEngineReference:yo,useWorkflowVariableOptions:he});v(this,"components",{CalculationConfig:Kn,WorkflowVariableTextArea:Ct,RadioWithTooltip:Ie})}Component({data:o}){const{t:n}=Q.useTranslation(),{nodes:s}=Z(),{styles:i}=te(),{id:a,config:{rejectOnFalse:c}}=o,d=s.find(f=>f.upstreamId===a&&f.branchIndex===1),p=s.find(f=>f.upstreamId===a&&f.branchIndex===0);return r.jsx(ht,{data:o,children:c?null:r.jsxs("div",{className:i.nodeSubtreeClass,children:[r.jsxs("div",{className:i.branchBlockClass,children:[r.jsx(Ye,{from:o,entry:p,branchIndex:0}),r.jsx(Ye,{from:o,entry:d,branchIndex:1})]}),r.jsxs("div",{className:i.conditionClass,children:[r.jsx("span",{style:{right:"4em"},children:n("No")}),r.jsx("span",{style:{left:"4em"},children:n("Yes")})]})]})})}}class Qn extends fe{constructor(){super(...arguments);v(this,"title",`{{t("End process", { ns: "${m}" })}}`);v(this,"type","end");v(this,"group","control");v(this,"description",`{{t("End the process immediately, with set status.", { ns: "${m}" })}}`);v(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:se.RESOLVED},{label:`{{t("Failed", { ns: "${m}" })}}`,value:se.FAILED}],required:!0,default:se.RESOLVED}});v(this,"end",!0)}}class Xn extends fe{constructor(){super(...arguments);v(this,"title",`{{t("Query record", { ns: "${m}" })}}`);v(this,"type","query");v(this,"group","collection");v(this,"description",`{{t("Query records from a collection. You can use variables from upstream nodes as query conditions.", { ns: "${m}" })}}`);v(this,"fieldset",{collection:be,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}" })}}`},params:{type:"object","x-component":"fieldset",properties:{filter:Pe,sort:kn,pagination:Sn,appends:Be},"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}" })}}`}});v(this,"scope",{useCollectionDataSource:l.useCollectionDataSource,useSortableFields(){const o=l.useCompile(),{getCollectionFields:n,getInterface:s}=l.useCollectionManager_deprecated(),{values:i}=M.useForm();return n(i.collection).filter(c=>{if(!c.interface)return!1;const d=s(c.interface);return!!(d!=null&&d.sortable)}).map(c=>{var d,p;return{value:c.name,label:(d=c==null?void 0:c.uiSchema)!=null&&d.title?o((p=c==null?void 0:c.uiSchema)==null?void 0:p.title):c.name}})}});v(this,"components",{ArrayItems:jo.ArrayItems,FilterDynamicComponent:Ze,SchemaComponentContext:l.SchemaComponentContext,WorkflowVariableInput:Ut})}useVariables({key:o,title:n,config:s},i){var p,f;const a=l.useCompile(),{getCollectionFields:c}=l.useCollectionManager_deprecated(),[d]=Se(T(w({appends:[o,...((f=(p=s.params)==null?void 0:p.appends)==null?void 0:f.map(x=>`${o}.${x}`))||[]]},i),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:a,getCollectionFields:c}));return d}useInitializers(o){var n,s;return!o.config.collection||o.config.multiple?null:{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}}}function Rn(e){const{getCollectionFields:t}=l.useCollectionManager_deprecated(),{path:o}=M.useField(),n=o.segments[o.segments.length-1],{values:s}=M.useForm(),i=t(s==null?void 0:s.collection),{type:a}=i.find(p=>p.name===n),c=Array.isArray(e.value)?e.value.join(","):e.value;function d(p){const f=p.target.value.trim();e.onChange(["belongsTo","hasOne"].includes(a)?f:f.split(/[,\s]+/))}return r.jsx(y.Input,T(w({},e),{value:c,onChange:d}))}const xo=M.observer(({value:e,disabled:t,onChange:o,filter:n})=>{const{token:s}=l.useToken(),{t:i}=Q.useTranslation(),a=l.useCompile(),c=M.useForm(),{getCollection:d,getCollectionFields:p}=l.useCollectionManager_deprecated(),f=he(),{values:x}=c,k=x==null?void 0:x.collection,h=p(k).filter(A=>A.uiSchema),u=n?h.filter(n.bind(x)):h,C=b.useMemo(()=>u.filter(A=>!e||!(A.name in e)),[u,e]),O=t||c.disabled,P=b.useMemo(()=>({onClick:({key:A})=>{o(T(w({},e),{[A]:null}))},style:{maxHeight:300,overflowY:"auto"},items:C.map(A=>{var B,z;return{key:A.name,label:a((z=(B=A.uiSchema)==null?void 0:B.title)!=null?z:A.name)}})}),[o,C,e]);return r.jsx("fieldset",{className:l.css`
|
|
544
544
|
margin-top: 0.5em;
|
|
545
545
|
|
|
546
546
|
> .ant-formily-item {
|
|
@@ -550,8 +550,8 @@
|
|
|
550
550
|
line-height: 32px;
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
-
`,children:
|
|
553
|
+
`,children:u.length?r.jsxs(l.CollectionProvider_deprecated,{collection:d(k),children:[u.filter(A=>e&&A.name in e).map(A=>{var z,H;const B=["belongsTo","hasOne","hasMany","belongsToMany"].includes(A.type)?Rn:l.CollectionField;return r.jsxs(y.Form.Item,{label:a((H=(z=A.uiSchema)==null?void 0:z.title)!=null?H:A.name),labelAlign:"left",className:l.css`
|
|
554
554
|
.ant-form-item-control-input-content {
|
|
555
555
|
display: flex;
|
|
556
556
|
}
|
|
557
|
-
`,children:[r.jsx(
|
|
557
|
+
`,children:[r.jsx(l.Variable.Input,{scope:f,value:e[A.name],changeOnSelect:!0,onChange:$=>{o(T(w({},e),{[A.name]:$}))},children:r.jsx(l.SchemaComponent,{schema:{type:"void",properties:{[A.name]:{"x-component":B,"x-validator"(){return""}}}}})}),O?null:r.jsx(y.Button,{"aria-label":"icon-close",type:"link",icon:r.jsx(F.CloseCircleOutlined,{}),onClick:()=>{var S;const I=e,{[S=A.name]:$}=I,N=q(I,[Bo(S)]);o(N)}})]},A.name)}),C.length?r.jsx(y.Dropdown,{menu:P,children:r.jsx(y.Button,{icon:r.jsx(F.PlusOutlined,{}),children:i("Add field")})}):null]}):r.jsx("p",{style:{color:s.colorText},children:E("Please select collection first")})})},{displayName:"CollectionFieldSet"});class er extends fe{constructor(){super(...arguments);v(this,"title",`{{t("Create record", { ns: "${m}" })}}`);v(this,"type","create");v(this,"group","collection");v(this,"description",`{{t("Add new record to a collection. You can use variables from upstream nodes to assign values to fields.", { ns: "${m}" })}}`);v(this,"fieldset",{collection:be,params:{type:"object",properties:{values:Rt,appends:Be}}});v(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});v(this,"components",{CollectionFieldset:xo})}useVariables({key:o,title:n,config:s},i){var p,f;const a=l.useCompile(),{getCollectionFields:c}=l.useCollectionManager_deprecated(),[d]=Se(T(w({appends:[o,...((f=(p=s.params)==null?void 0:p.appends)==null?void 0:f.map(x=>`${o}.${x}`))||[]]},i),{fields:[{collectionName:s.collection,name:o,type:"hasOne",target:s.collection,uiSchema:{title:n}}],compile:a,getCollectionFields:c}));return d}useInitializers(o){var n,s;return o.config.collection?{name:(n=o.title)!=null?n:`#${o.id}`,type:"item",title:(s=o.title)!=null?s:`#${o.id}`,Component:Ne,collection:o.config.collection,dataSource:`{{$jobsMapByNodeKey.${o.key}}}`}:null}}function tr(o){var n=o,{onChange:e}=n,t=q(n,["onChange"]);const{getCollectionFields:s}=l.useCollectionManager_deprecated(),i=M.useForm(),{collection:a}=i.values,c=s(a),d=M.useField();function p({target:f}){const x=d.query(".values").take();if(!x)return;const k=c.reduce((h,u)=>(u.name in x.value&&(f.value||!["hasOne","hasMany","belongsToMany"].includes(u.type))&&(h[u.name]=x.value[u.name]),h),{});i.setValuesIn("params.values",k),e(f.value)}return r.jsx(Ie,T(w({},t),{onChange:p}))}class or extends fe{constructor(){super(...arguments);v(this,"title",`{{t("Update record", { ns: "${m}" })}}`);v(this,"type","update");v(this,"group","collection");v(this,"description",`{{t("Update records of a collection. You can use variables from upstream nodes as query conditions and field values.", { ns: "${m}" })}}`);v(this,"fieldset",{collection:be,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:T(w({},Pe),{title:`{{t("Only update records matching conditions", { ns: "${m}" })}}`,"x-validator"(o){return Ke(o)?"":E("Please add at least one condition")}}),values:T(w({},Rt),{"x-component-props":{filter(o){var n;return((n=this.params)==null?void 0:n.individualHooks)||!["hasOne","hasMany","belongsToMany"].includes(o.type)}}})}}});v(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});v(this,"components",{FilterDynamicComponent:Ze,CollectionFieldset:xo,IndividualHooksRadioWithTooltip:tr})}}class nr extends fe{constructor(){super(...arguments);v(this,"title",'{{t("Delete record")}}');v(this,"type","destroy");v(this,"group","collection");v(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}" })}}`);v(this,"fieldset",{collection:be,params:{type:"object",properties:{filter:T(w({},Pe),{"x-validator"(o){return Ke(o)?"":E("Please add at least one condition")}})}}});v(this,"scope",{useCollectionDataSource:l.useCollectionDataSource});v(this,"components",{FilterDynamicComponent:Ze})}}const rr=new l.SchemaSettings({name:"actionSettings:submitToWorkflow",items:[{name:"editButton",Component:l.ButtonEditor,useComponentProps(){const{buttonEditorProps:e}=l.useSchemaToolbar();return e}},{name:"secondConfirmation",Component:l.SecondConFirm},{name:"assignFieldValues",Component:l.AssignedFieldValues},{name:"skipRequiredValidation",Component:l.SkipValidation},{name:"afterSuccessfulSubmission",Component:l.AfterSuccess,useVisible(){var t;const e=M.useFieldSchema();return Wo.isValid((t=e==null?void 0:e["x-action-settings"])==null?void 0:t.onSuccess)}},{name:"bindWorkflow",Component:l.WorkflowConfig},{name:"delete",sort:100,Component:l.RemoveButton,useComponentProps(){const{removeButtonProps:e}=l.useSchemaToolbar();return e}}]});class de extends l.Plugin{constructor(){super(...arguments);v(this,"triggers",new ae.Registry);v(this,"instructions",new ae.Registry);v(this,"getTriggersOptions",()=>Array.from(this.triggers.getEntities()).map(i=>{var[o,a]=i,c=a,{title:n}=c,s=q(c,["title"]);return{value:o,label:n,color:"gold",options:s}}))}isWorkflowSync(o){var n;return(n=this.triggers.get(o.type).sync)!=null?n:o.sync}registerTrigger(o,n){if(typeof n=="function")this.triggers.register(o,new n);else if(n)this.triggers.register(o,n);else throw new TypeError("invalid trigger type to register")}registerInstruction(o,n){if(typeof n=="function")this.instructions.register(o,new n);else if(n instanceof fe)this.instructions.register(o,n);else throw new TypeError("invalid instruction type to register")}load(){return _(this,null,function*(){this.addRoutes(),this.addComponents(),this.app.pluginSettingsManager.add(m,{icon:"PartitionOutlined",title:`{{t("Workflow", { ns: "${m}" })}}`,Component:Cn,aclSnippet:"pm.workflow.workflows"}),this.app.schemaSettingsManager.add(rr),this.registerTrigger("collection",On),this.registerTrigger("schedule",Un),this.registerInstruction("calculation",_n),this.registerInstruction("condition",Zn),this.registerInstruction("end",Qn),this.registerInstruction("query",Xn),this.registerInstruction("create",er),this.registerInstruction("update",or),this.registerInstruction("destroy",nr)})}addComponents(){this.app.addComponents({WorkflowPage:Qt,ExecutionPage:Yt})}addRoutes(){this.app.router.add("admin.workflow.workflows.id",{path:Ae(":id"),element:r.jsx(Qt,{})}),this.app.router.add("admin.workflow.executions.id",{path:Ot(":id"),element:r.jsx(Yt,{})})}}g.BaseTypeSets=Ge,g.Branch=Ye,g.CheckboxGroupWithTooltip=on,g.CollectionBlockInitializer=Ne,g.EXECUTION_STATUS=ce,g.ExecutionStatusOptions=He,g.ExecutionStatusOptionsMap=Ue,g.FieldsSelect=At,g.FilterDynamicComponent=Ze,g.FlowContext=Je,g.Instruction=fe,g.JOB_STATUS=se,g.JobButton=jt,g.JobStatusOptions=mt,g.JobStatusOptionsMap=_e,g.Node=Bt,g.NodeContext=ft,g.NodeDefaultView=ht,g.RadioWithTooltip=Ie,g.RemoveButton=Vt,g.Trigger=yt,g.ValueBlock=Me,g.WorkflowVariableInput=Ut,g.WorkflowVariableJSON=Ro,g.WorkflowVariableRawTextArea=Xo,g.WorkflowVariableTextArea=Ct,g.default=de,g.defaultFieldNames=ke,g.getCollectionFieldOptions=Se,g.isValidFilter=Ke,g.linkNodes=kt,g.nodesOptions=Wt,g.scopeOptions=zt,g.systemOptions=Jt,g.traverseSchema=St,g.triggerOptions=Lt,g.useAvailableUpstreams=Mt,g.useFlowContext=Z,g.useGetAriaLabelOfAddButton=pt,g.useNodeContext=Ce,g.useRecordTriggerWorkflowsActionProps=ln,g.useStyles=te,g.useTrigger=gt,g.useTriggerWorkflowsActionProps=sn,g.useUpstreamScopes=Pt,g.useWorkflowVariableOptions=he,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -2,21 +2,22 @@ module.exports = {
|
|
|
2
2
|
"react": "18.2.0",
|
|
3
3
|
"antd": "5.12.8",
|
|
4
4
|
"@ant-design/icons": "5.2.6",
|
|
5
|
-
"@nocobase/client": "0.
|
|
5
|
+
"@nocobase/client": "0.20.0-alpha.10",
|
|
6
6
|
"react-router-dom": "6.21.0",
|
|
7
|
-
"@nocobase/utils": "0.
|
|
7
|
+
"@nocobase/utils": "0.20.0-alpha.10",
|
|
8
8
|
"react-i18next": "11.18.6",
|
|
9
9
|
"@formily/core": "2.3.0",
|
|
10
10
|
"@formily/react": "2.3.0",
|
|
11
|
-
"@nocobase/database": "0.
|
|
12
|
-
"@nocobase/server": "0.
|
|
13
|
-
"@nocobase/logger": "0.
|
|
14
|
-
"@nocobase/evaluators": "0.
|
|
11
|
+
"@nocobase/database": "0.20.0-alpha.10",
|
|
12
|
+
"@nocobase/server": "0.20.0-alpha.10",
|
|
13
|
+
"@nocobase/logger": "0.20.0-alpha.10",
|
|
14
|
+
"@nocobase/evaluators": "0.20.0-alpha.10",
|
|
15
15
|
"lodash": "4.17.21",
|
|
16
16
|
"@formily/antd-v5": "1.1.9",
|
|
17
|
-
"@
|
|
17
|
+
"@formily/shared": "2.3.0",
|
|
18
|
+
"@nocobase/actions": "0.20.0-alpha.10",
|
|
18
19
|
"sequelize": "6.35.2",
|
|
19
|
-
"@nocobase/plugin-workflow-test": "0.
|
|
20
|
-
"@nocobase/test": "0.
|
|
20
|
+
"@nocobase/plugin-workflow-test": "0.20.0-alpha.10",
|
|
21
|
+
"@nocobase/test": "0.20.0-alpha.10",
|
|
21
22
|
"dayjs": "1.11.10"
|
|
22
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-03-13T14:51:48.660Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-03-13T14:51:48.329Z"}
|
|
@@ -3,7 +3,7 @@ import type { FlowNodeModel } from '../types';
|
|
|
3
3
|
import { Instruction } from '.';
|
|
4
4
|
export declare class CreateInstruction extends Instruction {
|
|
5
5
|
run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
|
|
6
|
-
result:
|
|
6
|
+
result: any;
|
|
7
7
|
status: 1;
|
|
8
8
|
}>;
|
|
9
9
|
}
|
|
@@ -41,7 +41,7 @@ function findSchema(root, filter, onlyLeaf = false) {
|
|
|
41
41
|
function migrateSchema(schema = {}) {
|
|
42
42
|
const root = { properties: schema };
|
|
43
43
|
const collectionBlocks = findSchema(root, (item) => {
|
|
44
|
-
return item["x-component"] === "CardItem" && item["x-designer"] === "SimpleDesigner" && item["x-decorator"] === "
|
|
44
|
+
return item["x-component"] === "CardItem" && item["x-designer"] === "SimpleDesigner" && item["x-decorator"] === "CollectionProvider_deprecated";
|
|
45
45
|
});
|
|
46
46
|
collectionBlocks.forEach((block) => {
|
|
47
47
|
const id = (0, import_utils.uid)();
|
|
@@ -29,38 +29,8 @@ class split_to_plugins_default extends import_server.Migration {
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
const { db } = this.context;
|
|
32
|
-
const PluginModel = db.getModel("applicationPlugins");
|
|
33
32
|
const NodeRepo = db.getRepository("flow_nodes");
|
|
34
33
|
await db.sequelize.transaction(async (transaction) => {
|
|
35
|
-
await [
|
|
36
|
-
"@nocobase/plugin-workflow-aggregate",
|
|
37
|
-
"@nocobase/plugin-workflow-delay",
|
|
38
|
-
"@nocobase/plugin-workflow-dynamic-calculation",
|
|
39
|
-
"@nocobase/plugin-workflow-loop",
|
|
40
|
-
"@nocobase/plugin-workflow-manual",
|
|
41
|
-
"@nocobase/plugin-workflow-parallel",
|
|
42
|
-
"@nocobase/plugin-workflow-request",
|
|
43
|
-
"@nocobase/plugin-workflow-sql",
|
|
44
|
-
"@nocobase/plugin-workflow-form-trigger"
|
|
45
|
-
].reduce(
|
|
46
|
-
(promise, packageName) => promise.then(async () => {
|
|
47
|
-
const existed = await PluginModel.findOne({ where: { packageName }, transaction });
|
|
48
|
-
if (!existed) {
|
|
49
|
-
await PluginModel.create(
|
|
50
|
-
{
|
|
51
|
-
name: packageName,
|
|
52
|
-
packageName,
|
|
53
|
-
version: "0.17.0-alpha.1",
|
|
54
|
-
enabled: true,
|
|
55
|
-
installed: true,
|
|
56
|
-
builtin: true
|
|
57
|
-
},
|
|
58
|
-
{ transaction }
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
Promise.resolve()
|
|
63
|
-
);
|
|
64
34
|
const nodes = await NodeRepo.find({
|
|
65
35
|
transaction
|
|
66
36
|
});
|
|
@@ -323,7 +323,7 @@ class ScheduleTrigger {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
const { collection } = workflow.config;
|
|
326
|
-
const event = `${collection}.
|
|
326
|
+
const event = `${collection}.afterSaveWithAssociations`;
|
|
327
327
|
const name = getHookId(workflow, event);
|
|
328
328
|
if (this.events.has(name)) {
|
|
329
329
|
const listener = this.events.get(name);
|
|
@@ -32,6 +32,7 @@ __export(StaticScheduleTrigger_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(StaticScheduleTrigger_exports);
|
|
33
33
|
var import_cron_parser = __toESM(require("cron-parser"));
|
|
34
34
|
var import_utils = require("./utils");
|
|
35
|
+
const MAX_SAFE_INTERVAL = 2147483647;
|
|
35
36
|
class StaticScheduleTrigger {
|
|
36
37
|
constructor(workflow) {
|
|
37
38
|
this.workflow = workflow;
|
|
@@ -51,7 +52,6 @@ class StaticScheduleTrigger {
|
|
|
51
52
|
timers = /* @__PURE__ */ new Map();
|
|
52
53
|
inspect(workflows) {
|
|
53
54
|
const now = /* @__PURE__ */ new Date();
|
|
54
|
-
now.setMilliseconds(0);
|
|
55
55
|
workflows.forEach((workflow) => {
|
|
56
56
|
const nextTime = this.getNextTime(workflow, now);
|
|
57
57
|
if (nextTime) {
|
|
@@ -85,7 +85,8 @@ class StaticScheduleTrigger {
|
|
|
85
85
|
const next = interval.next();
|
|
86
86
|
return next.getTime();
|
|
87
87
|
} else if (typeof config.repeat === "number") {
|
|
88
|
-
|
|
88
|
+
const next = timestamp + config.repeat - (timestamp - startTime) % config.repeat;
|
|
89
|
+
return next;
|
|
89
90
|
} else {
|
|
90
91
|
return null;
|
|
91
92
|
}
|
|
@@ -97,16 +98,29 @@ class StaticScheduleTrigger {
|
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
schedule(workflow, nextTime, toggle = true) {
|
|
100
|
-
const key = `${workflow.id}@${nextTime}`;
|
|
101
101
|
if (toggle) {
|
|
102
|
+
const key = `${workflow.id}@${nextTime}`;
|
|
102
103
|
if (!this.timers.has(key)) {
|
|
103
104
|
const interval = Math.max(nextTime - Date.now(), 0);
|
|
104
|
-
|
|
105
|
+
if (interval > MAX_SAFE_INTERVAL) {
|
|
106
|
+
this.timers.set(
|
|
107
|
+
key,
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
this.timers.delete(key);
|
|
110
|
+
this.schedule(workflow, nextTime);
|
|
111
|
+
}, MAX_SAFE_INTERVAL)
|
|
112
|
+
);
|
|
113
|
+
} else {
|
|
114
|
+
this.timers.set(key, setTimeout(this.trigger.bind(this, workflow, nextTime), interval));
|
|
115
|
+
}
|
|
105
116
|
}
|
|
106
117
|
} else {
|
|
107
|
-
const timer
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
for (const [key, timer] of this.timers.entries()) {
|
|
119
|
+
if (key.startsWith(`${workflow.id}@`)) {
|
|
120
|
+
clearTimeout(timer);
|
|
121
|
+
this.timers.delete(key);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
126
|
async trigger(workflow, time) {
|
package/dist/server/utils.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function toJSON(data: Model | Model[]): object;
|
|
1
|
+
export declare function toJSON(data: any): any;
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
6
6
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.20.0-alpha.10",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
|
-
"homepage": "https://docs.nocobase.com/
|
|
11
|
-
"homepage.zh-CN": "https://docs-cn.nocobase.com/
|
|
10
|
+
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
11
|
+
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nocobase/plugin-workflow-test": "0.
|
|
13
|
+
"@nocobase/plugin-workflow-test": "0.20.0-alpha.10"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@ant-design/icons": "5.x",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@nocobase/test": "0.x",
|
|
46
46
|
"@nocobase/utils": "0.x"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "453e0774dae21750e96c7ddd2019c8889a0314d6",
|
|
49
49
|
"keywords": [
|
|
50
50
|
"Workflow"
|
|
51
51
|
]
|