@nocobase/plugin-workflow-delay 0.17.0-alpha.7 → 0.18.0-alpha.8

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.
@@ -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 r=(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{c(n.next(o))}catch(d){s(d)}},f=o=>{try{c(n.throw(o))}catch(d){s(d)}},c=o=>o.done?p(o.value):Promise.resolve(o.value).then(a,f);c((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 c(u){return f.slice().reverse().find(l=>!(u%l.value))}function o({value:u=6e4,onChange:l}){const m=t.useCompile(),b=c(u),y=Math.round(u/b.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,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`
2
2
  display: flex;
3
3
  gap: 0.5em;
4
- `,children:[n.jsx(p.InputNumber,{min:1,value:y,onChange:i=>l(Math.round(i*b.value)),className:"auto-width"}),n.jsx(p.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:b.value,onChange:i=>l(Math.round(y*i)),className:"auto-width",options:f.map(i=>({value:i.value,label:m(i.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})}}class x extends t.Plugin{afterAdd(){return w(this,null,function*(){})}beforeLoad(){return w(this,null,function*(){})}load(){return w(this,null,function*(){const l=this.app.pm.get("workflow"),m=new d;l.instructions.register(m.type,m)})}}e.default=x,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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"}})});
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
- "antd": "5.8.6",
4
- "@nocobase/client": "0.17.0-alpha.7",
5
- "@nocobase/plugin-workflow": "0.17.0-alpha.7",
3
+ "antd": "5.12.2",
4
+ "@nocobase/client": "0.18.0-alpha.8",
5
+ "@nocobase/plugin-workflow": "0.18.0-alpha.8",
6
6
  "react-i18next": "11.18.6",
7
- "@nocobase/server": "0.17.0-alpha.7"
7
+ "@nocobase/server": "0.18.0-alpha.8"
8
8
  };
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import WorkflowPlugin, { Processor, Instruction } from '@nocobase/plugin-workflow';
3
3
  export default class extends Instruction {
4
- plugin: WorkflowPlugin;
4
+ workflow: WorkflowPlugin;
5
5
  timers: Map<number, NodeJS.Timeout>;
6
- constructor(plugin: WorkflowPlugin);
6
+ constructor(workflow: WorkflowPlugin);
7
7
  load: () => Promise<void>;
8
8
  unload: () => void;
9
9
  schedule(job: any): void;
@@ -22,15 +22,15 @@ __export(DelayInstruction_exports, {
22
22
  module.exports = __toCommonJS(DelayInstruction_exports);
23
23
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
24
24
  class DelayInstruction_default extends import_plugin_workflow.Instruction {
25
- constructor(plugin) {
26
- super(plugin);
27
- this.plugin = plugin;
28
- plugin.app.on("afterStart", this.load);
29
- plugin.app.on("beforeStop", this.unload);
25
+ constructor(workflow) {
26
+ super(workflow);
27
+ this.workflow = workflow;
28
+ workflow.app.on("afterStart", this.load);
29
+ workflow.app.on("beforeStop", this.unload);
30
30
  }
31
31
  timers = /* @__PURE__ */ new Map();
32
32
  load = async () => {
33
- const { model } = this.plugin.db.getCollection("jobs");
33
+ const { model } = this.workflow.app.db.getCollection("jobs");
34
34
  const jobs = await model.findAll({
35
35
  where: {
36
36
  status: import_plugin_workflow.JOB_STATUS.PENDING
@@ -80,7 +80,7 @@ class DelayInstruction_default extends import_plugin_workflow.Instruction {
80
80
  job.execution = await job.getExecution();
81
81
  }
82
82
  if (job.execution.status === import_plugin_workflow.EXECUTION_STATUS.STARTED) {
83
- this.plugin.resume(job);
83
+ this.workflow.resume(job);
84
84
  }
85
85
  if (this.timers.get(job.id)) {
86
86
  this.timers.delete(job.id);
@@ -1,6 +1,4 @@
1
1
  import { Plugin } from '@nocobase/server';
2
- import WorkflowPlugin from '@nocobase/plugin-workflow';
3
2
  export default class extends Plugin {
4
- workflow: WorkflowPlugin;
5
3
  load(): Promise<void>;
6
4
  }
@@ -31,12 +31,11 @@ __export(Plugin_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(Plugin_exports);
33
33
  var import_server = require("@nocobase/server");
34
+ var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
34
35
  var import_DelayInstruction = __toESM(require("./DelayInstruction"));
35
36
  class Plugin_default extends import_server.Plugin {
36
- workflow;
37
37
  async load() {
38
- const workflowPlugin = this.app.getPlugin("workflow");
39
- this.workflow = workflowPlugin;
40
- workflowPlugin.instructions.register("delay", new import_DelayInstruction.default(workflowPlugin));
38
+ const workflowPlugin = this.app.getPlugin(import_plugin_workflow.default);
39
+ workflowPlugin.registerInstruction("delay", import_DelayInstruction.default);
41
40
  }
42
41
  }
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.17.0-alpha.7",
7
+ "version": "0.18.0-alpha.8",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -16,9 +16,8 @@
16
16
  "@nocobase/client": "0.x",
17
17
  "@nocobase/database": "0.x",
18
18
  "@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
19
- "@nocobase/plugin-workflow-test": ">=0.17.0-alpha.3",
20
19
  "@nocobase/server": "0.x",
21
20
  "@nocobase/test": "0.x"
22
21
  },
23
- "gitHead": "91377a3abd1124f79fb3819f2d0e80905e091a32"
22
+ "gitHead": "727d42f6f14e5f863831da3dbf3255ba1165b567"
24
23
  }
@@ -13,7 +13,6 @@ export default class extends Plugin {
13
13
  // You can get and modify the app instance here
14
14
  async load() {
15
15
  const workflow = this.app.pm.get('workflow') as WorkflowPlugin;
16
- const delayInstruction = new DelayInstruction();
17
- workflow.instructions.register(delayInstruction.type, delayInstruction);
16
+ workflow.registerInstruction('delay', DelayInstruction);
18
17
  }
19
18
  }
@@ -16,15 +16,15 @@ interface DelayConfig {
16
16
  export default class extends Instruction {
17
17
  timers: Map<number, NodeJS.Timeout> = new Map();
18
18
 
19
- constructor(public plugin: WorkflowPlugin) {
20
- super(plugin);
19
+ constructor(public workflow: WorkflowPlugin) {
20
+ super(workflow);
21
21
 
22
- plugin.app.on('afterStart', this.load);
23
- plugin.app.on('beforeStop', this.unload);
22
+ workflow.app.on('afterStart', this.load);
23
+ workflow.app.on('beforeStop', this.unload);
24
24
  }
25
25
 
26
26
  load = async () => {
27
- const { model } = this.plugin.db.getCollection('jobs');
27
+ const { model } = this.workflow.app.db.getCollection('jobs');
28
28
  const jobs = (await model.findAll({
29
29
  where: {
30
30
  status: JOB_STATUS.PENDING,
@@ -79,7 +79,7 @@ export default class extends Instruction {
79
79
  job.execution = await job.getExecution();
80
80
  }
81
81
  if (job.execution.status === EXECUTION_STATUS.STARTED) {
82
- this.plugin.resume(job);
82
+ this.workflow.resume(job);
83
83
  }
84
84
  if (this.timers.get(job.id)) {
85
85
  this.timers.delete(job.id);
@@ -4,11 +4,8 @@ import WorkflowPlugin from '@nocobase/plugin-workflow';
4
4
  import DelayInstruction from './DelayInstruction';
5
5
 
6
6
  export default class extends Plugin {
7
- workflow: WorkflowPlugin;
8
-
9
7
  async load() {
10
- const workflowPlugin = this.app.getPlugin('workflow') as WorkflowPlugin;
11
- this.workflow = workflowPlugin;
12
- workflowPlugin.instructions.register('delay', new DelayInstruction(workflowPlugin));
8
+ const workflowPlugin = this.app.getPlugin<WorkflowPlugin>(WorkflowPlugin);
9
+ workflowPlugin.registerInstruction('delay', DelayInstruction);
13
10
  }
14
11
  }