@nocobase/plugin-workflow-delay 0.19.0-alpha.2 → 0.19.0-alpha.4

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.
@@ -34,5 +34,11 @@ export default class extends Instruction {
34
34
  components: {
35
35
  Duration: typeof Duration;
36
36
  };
37
+ isAvailable({ engine, workflow, upstream, branchIndex }: {
38
+ engine: any;
39
+ workflow: any;
40
+ upstream: any;
41
+ branchIndex: any;
42
+ }): boolean;
37
43
  }
38
44
  export {};
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","antd","@nocobase/plugin-workflow/client","react-i18next"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@nocobase/plugin-workflow-delay"]={},e["@nocobase/client"],e.jsxRuntime,e.antd,e["@nocobase/plugin-workflow"]))})(this,function(e,t,n,p,s){"use strict";var v=Object.defineProperty;var S=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var l=(e,t,n)=>(S(e,typeof t!="symbol"?t+"":t,n),n);var w=(e,t,n)=>new Promise((p,s)=>{var a=o=>{try{d(n.next(o))}catch(c){s(c)}},f=o=>{try{d(n.throw(o))}catch(c){s(c)}},d=o=>o.done?p(o.value):Promise.resolve(o.value).then(a,f);d((n=n.apply(e,t)).next())});const a="workflow-delay",f=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function d(r){return f.slice().reverse().find(u=>!(r%u.value))}function o({value:r=6e4,onChange:u}){const x=t.useCompile(),m=d(r),b=Math.round(r/m.value);return n.jsxs("fieldset",{className:t.css`
1
+ (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","antd","@nocobase/plugin-workflow/client","react-i18next"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@nocobase/plugin-workflow-delay"]={},e["@nocobase/client"],e.jsxRuntime,e.antd,e["@nocobase/plugin-workflow"]))})(this,function(e,t,n,f,s){"use strict";var v=Object.defineProperty;var h=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var r=(e,t,n)=>(h(e,typeof t!="symbol"?t+"":t,n),n);var m=(e,t,n)=>new Promise((f,s)=>{var a=o=>{try{c(n.next(o))}catch(d){s(d)}},w=o=>{try{c(n.throw(o))}catch(d){s(d)}},c=o=>o.done?f(o.value):Promise.resolve(o.value).then(a,w);c((n=n.apply(e,t)).next())});const a="workflow-delay",w=[{value:1e3,label:`{{t('Seconds', { ns: "workflow" })}}`},{value:6e4,label:`{{t('Minutes', { ns: "workflow" })}}`},{value:36e5,label:`{{t('Hours', { ns: "workflow" })}}`},{value:864e5,label:`{{t('Days', { ns: "workflow" })}}`},{value:6048e5,label:`{{t('Weeks', { ns: "workflow" })}}`}];function c(u){return w.slice().reverse().find(i=>!(u%i.value))}function o({value:u=6e4,onChange:i}){const b=t.useCompile(),p=c(u),y=Math.round(u/p.value);return n.jsxs("fieldset",{className:t.css`
2
2
  display: flex;
3
3
  gap: 0.5em;
4
- `,children:[n.jsx(p.InputNumber,{min:1,value:b,onChange:i=>u(Math.round(i*m.value)),className:"auto-width"}),n.jsx(p.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:m.value,onChange:i=>u(Math.round(b*i)),className:"auto-width",options:f.map(i=>({value:i.value,label:x(i.label)}))})]})}class c extends s.Instruction{constructor(){super(...arguments);l(this,"title",`{{t("Delay", { ns: "${a}" })}}`);l(this,"type","delay");l(this,"group","control");l(this,"description",`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${a}" })}}`);l(this,"fieldset",{duration:{type:"number",title:`{{t("Duration", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End Status", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${a}" })}}`,value:s.JOB_STATUS.RESOLVED},{label:`{{t("Fail and exit", { ns: "${a}" })}}`,value:s.JOB_STATUS.FAILED}],required:!0,default:s.JOB_STATUS.RESOLVED}});l(this,"components",{Duration:o})}}class y extends t.Plugin{afterAdd(){return w(this,null,function*(){})}beforeLoad(){return w(this,null,function*(){})}load(){return w(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",c)})}}e.default=y,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
4
+ `,children:[n.jsx(f.InputNumber,{min:1,value:y,onChange:l=>i(Math.round(l*p.value)),className:"auto-width"}),n.jsx(f.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:p.value,onChange:l=>i(Math.round(y*l)),className:"auto-width",options:w.map(l=>({value:l.value,label:b(l.label)}))})]})}class d extends s.Instruction{constructor(){super(...arguments);r(this,"title",`{{t("Delay", { ns: "${a}" })}}`);r(this,"type","delay");r(this,"group","control");r(this,"description",`{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "${a}" })}}`);r(this,"fieldset",{duration:{type:"number",title:`{{t("Duration", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:`{{t("End status", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:`{{t("Succeed and continue", { ns: "${a}" })}}`,value:s.JOB_STATUS.RESOLVED},{label:`{{t("Fail and exit", { ns: "${a}" })}}`,value:s.JOB_STATUS.FAILED}],required:!0,default:s.JOB_STATUS.RESOLVED}});r(this,"components",{Duration:o})}isAvailable({engine:b,workflow:p,upstream:y,branchIndex:l}){return!b.isWorkflowSync(p)}}class x extends t.Plugin{afterAdd(){return m(this,null,function*(){})}beforeLoad(){return m(this,null,function*(){})}load(){return m(this,null,function*(){this.app.pm.get("workflow").registerInstruction("delay",d)})}}e.default=x,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
3
  "antd": "5.12.8",
4
- "@nocobase/client": "0.19.0-alpha.2",
5
- "@nocobase/plugin-workflow": "0.19.0-alpha.2",
4
+ "@nocobase/client": "0.19.0-alpha.4",
5
+ "@nocobase/plugin-workflow": "0.19.0-alpha.4",
6
6
  "react-i18next": "11.18.6",
7
- "@nocobase/server": "0.19.0-alpha.2"
7
+ "@nocobase/server": "0.19.0-alpha.4"
8
8
  };
@@ -2,7 +2,7 @@
2
2
  "Delay": "Delay",
3
3
  "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.": "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.",
4
4
  "Duration": "Duration",
5
- "End Status": "End Status",
5
+ "End status": "End status",
6
6
  "Select status": "Select status",
7
7
  "Succeed and continue": "Succeed and continue",
8
8
  "Fail and exit": "Fail and exit"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "Delay": "Retraso",
3
3
  "Duration": "Duración",
4
- "End Status": "Estado Final",
4
+ "End status": "Estado final",
5
5
  "Select status": "Seleccionar estado",
6
6
  "Succeed and continue": "Éxito y continuar",
7
7
  "Fail and exit": "Falla y sale"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "Delay": "Délai",
3
3
  "Duration": "Durée",
4
- "End Status": "Statut de fin",
4
+ "End status": "Statut de fin",
5
5
  "Select status": "Sélectionner un statut",
6
6
  "Succeed and continue": "Réussir et continuer",
7
7
  "Fail and exit": "Échouer et quitter"
@@ -0,0 +1,10 @@
1
+ {
2
+ "Delay": "지연",
3
+ "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.":
4
+ "일정 시간 동안 지연한 다음 프로세스를 계속하거나 종료합니다. 병렬 분기에서 대기 또는 타임아웃 시간을 설정하는 데 사용할 수 있습니다.",
5
+ "Duration": "기간",
6
+ "End Status": "종료 상태",
7
+ "Select status": "상태 선택",
8
+ "Succeed and continue": "성공하고 계속",
9
+ "Fail and exit": "실패하고 종료"
10
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "Delay": "Atraso",
3
3
  "Duration": "Duração",
4
- "End Status": "Status final",
4
+ "End status": "Status final",
5
5
  "Select status": "Selecionar status",
6
6
  "Succeed and continue": "Ter sucesso e continuar",
7
7
  "Fail and exit": "Falhar e sair"
@@ -2,7 +2,7 @@
2
2
  "Delay": "延时",
3
3
  "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.": "延时一段时间,然后继续或退出流程。可以用于并行分支中等待其他分支或设置超时时间。",
4
4
  "Duration": "时长",
5
- "End Status": "到时状态",
5
+ "End status": "到时状态",
6
6
  "Select status": "选择状态",
7
7
  "Succeed and continue": "通过并继续",
8
8
  "Fail and exit": "失败并退出"
@@ -91,6 +91,7 @@ class DelayInstruction_default extends import_plugin_workflow.Instruction {
91
91
  status: import_plugin_workflow.JOB_STATUS.PENDING,
92
92
  result: null,
93
93
  nodeId: node.id,
94
+ nodeKey: node.key,
94
95
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
95
96
  });
96
97
  job.node = node;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:延时节点",
5
5
  "description": "Could be used in workflow parallel branch for waiting other branches.",
6
6
  "description.zh-CN": "可用于工作流并行分支中等待其他分支执行完成。",
7
- "version": "0.19.0-alpha.2",
7
+ "version": "0.19.0-alpha.4",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -19,5 +19,5 @@
19
19
  "@nocobase/server": "0.x",
20
20
  "@nocobase/test": "0.x"
21
21
  },
22
- "gitHead": "cff5b77ecf12ccdb450d50d505b3aa44a68478c8"
22
+ "gitHead": "9583023f7bea828da5192384a5c002782c341b65"
23
23
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { InputNumber, Select } from 'antd';
3
- import { css, useCompile } from '@nocobase/client';
4
- import { Instruction, JOB_STATUS } from '@nocobase/plugin-workflow/client';
3
+ import { css, useCompile, usePlugin } from '@nocobase/client';
4
+ import WorkflowPlugin, { Instruction, JOB_STATUS } from '@nocobase/plugin-workflow/client';
5
5
 
6
6
  import { NAMESPACE } from '../locale';
7
7
 
@@ -70,7 +70,7 @@ export default class extends Instruction {
70
70
  },
71
71
  endStatus: {
72
72
  type: 'number',
73
- title: `{{t("End Status", { ns: "${NAMESPACE}" })}}`,
73
+ title: `{{t("End status", { ns: "${NAMESPACE}" })}}`,
74
74
  'x-decorator': 'FormItem',
75
75
  'x-component': 'Radio.Group',
76
76
  enum: [
@@ -84,4 +84,7 @@ export default class extends Instruction {
84
84
  components = {
85
85
  Duration,
86
86
  };
87
+ isAvailable({ engine, workflow, upstream, branchIndex }) {
88
+ return !engine.isWorkflowSync(workflow);
89
+ }
87
90
  }
@@ -2,7 +2,7 @@
2
2
  "Delay": "Delay",
3
3
  "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.": "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.",
4
4
  "Duration": "Duration",
5
- "End Status": "End Status",
5
+ "End status": "End status",
6
6
  "Select status": "Select status",
7
7
  "Succeed and continue": "Succeed and continue",
8
8
  "Fail and exit": "Fail and exit"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "Delay": "Retraso",
3
3
  "Duration": "Duración",
4
- "End Status": "Estado Final",
4
+ "End status": "Estado final",
5
5
  "Select status": "Seleccionar estado",
6
6
  "Succeed and continue": "Éxito y continuar",
7
7
  "Fail and exit": "Falla y sale"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "Delay": "Délai",
3
3
  "Duration": "Durée",
4
- "End Status": "Statut de fin",
4
+ "End status": "Statut de fin",
5
5
  "Select status": "Sélectionner un statut",
6
6
  "Succeed and continue": "Réussir et continuer",
7
7
  "Fail and exit": "Échouer et quitter"
@@ -0,0 +1,10 @@
1
+ {
2
+ "Delay": "지연",
3
+ "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.":
4
+ "일정 시간 동안 지연한 다음 프로세스를 계속하거나 종료합니다. 병렬 분기에서 대기 또는 타임아웃 시간을 설정하는 데 사용할 수 있습니다.",
5
+ "Duration": "기간",
6
+ "End Status": "종료 상태",
7
+ "Select status": "상태 선택",
8
+ "Succeed and continue": "성공하고 계속",
9
+ "Fail and exit": "실패하고 종료"
10
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "Delay": "Atraso",
3
3
  "Duration": "Duração",
4
- "End Status": "Status final",
4
+ "End status": "Status final",
5
5
  "Select status": "Selecionar status",
6
6
  "Succeed and continue": "Ter sucesso e continuar",
7
7
  "Fail and exit": "Falhar e sair"
@@ -2,7 +2,7 @@
2
2
  "Delay": "延时",
3
3
  "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.": "延时一段时间,然后继续或退出流程。可以用于并行分支中等待其他分支或设置超时时间。",
4
4
  "Duration": "时长",
5
- "End Status": "到时状态",
5
+ "End status": "到时状态",
6
6
  "Select status": "选择状态",
7
7
  "Succeed and continue": "通过并继续",
8
8
  "Fail and exit": "失败并退出"
@@ -91,6 +91,7 @@ export default class extends Instruction {
91
91
  status: JOB_STATUS.PENDING,
92
92
  result: null,
93
93
  nodeId: node.id,
94
+ nodeKey: node.key,
94
95
  upstreamId: prevJob?.id ?? null,
95
96
  });
96
97
  job.node = node;
@@ -86,7 +86,7 @@ describe('workflow > instructions > delay', () => {
86
86
  expect(j2.status).toBe(JOB_STATUS.FAILED);
87
87
  });
88
88
 
89
- it('delay to resolve and rollback in downstream node', async () => {
89
+ it('delay to resolve and downstream node error', async () => {
90
90
  const n1 = await workflow.createNode({
91
91
  type: 'delay',
92
92
  config: {
@@ -97,11 +97,9 @@ describe('workflow > instructions > delay', () => {
97
97
  const n2 = await workflow.createNode({
98
98
  type: 'create',
99
99
  config: {
100
- collection: 'comment',
100
+ collection: 'notExistsTable',
101
101
  params: {
102
- values: {
103
- status: 'should be number but use string to raise an error',
104
- },
102
+ values: {},
105
103
  },
106
104
  },
107
105
  upstreamId: n1.id,