@nocobase/plugin-workflow-loop 0.18.0-alpha.1 → 0.18.0-alpha.9

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(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@ant-design/icons","@nocobase/plugin-workflow/client","react-i18next"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-workflow-loop"]={},n["@nocobase/client"],n.jsxRuntime,n["@ant-design/icons"],n["@nocobase/plugin-workflow"],n["react-i18next"]))})(this,function(n,e,o,v,s,k){"use strict";var V=Object.defineProperty,W=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var I=(n,e,o)=>e in n?V(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,N=(n,e)=>{for(var o in e||(e={}))F.call(e,o)&&I(n,o,e[o]);if(O)for(var o of O(e))M.call(e,o)&&I(n,o,e[o]);return n},T=(n,e)=>W(n,P(e));var g=(n,e,o)=>(I(n,typeof e!="symbol"?e+"":e,o),o);var y=(n,e,o)=>new Promise((v,s)=>{var k=i=>{try{d(o.next(i))}catch(w){s(w)}},u=i=>{try{d(o.throw(i))}catch(w){s(w)}},d=i=>i.done?v(i.value):Promise.resolve(i.value).then(k,u);d((o=o.apply(n,e)).next())});const u="workflow-loop";function d(p,f={}){const{t}=i(f);return t(p)}function i(p){return k.useTranslation(u,p)}function w(p,f){let t=p,h=null;for(let a=0;a<f.length;a++){const c=f[a],r=t.find(m=>m.value===c);if(!r)return null;h=r,!r.isLeaf&&r.loadChildren&&r.loadChildren(r),r.children&&(t=r.children)}return h}class j extends s.Instruction{constructor(){super(...arguments);g(this,"title",`{{t("Loop", { ns: "${u}" })}}`);g(this,"type","loop");g(this,"group","control");g(this,"description",`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${u}" })}}`);g(this,"fieldset",{target:{type:"string",title:`{{t("Loop target", { ns: "${u}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:e.css`
1
+ (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@ant-design/icons","@nocobase/plugin-workflow/client","react-i18next"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-workflow-loop"]={},n["@nocobase/client"],n.jsxRuntime,n["@ant-design/icons"],n["@nocobase/plugin-workflow"],n["react-i18next"]))})(this,function(n,e,o,v,t,k){"use strict";var V=Object.defineProperty,W=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var I=(n,e,o)=>e in n?V(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,N=(n,e)=>{for(var o in e||(e={}))F.call(e,o)&&I(n,o,e[o]);if(O)for(var o of O(e))M.call(e,o)&&I(n,o,e[o]);return n},T=(n,e)=>W(n,P(e));var h=(n,e,o)=>(I(n,typeof e!="symbol"?e+"":e,o),o);var y=(n,e,o)=>new Promise((v,t)=>{var k=i=>{try{d(o.next(i))}catch(w){t(w)}},u=i=>{try{d(o.throw(i))}catch(w){t(w)}},d=i=>i.done?v(i.value):Promise.resolve(i.value).then(k,u);d((o=o.apply(n,e)).next())});const u="workflow-loop";function d(p,g={}){const{t:r}=i(g);return r(p)}function i(p){return k.useTranslation(u,p)}function w(p,g){let r=p,f=null;for(let a=0;a<g.length;a++){const c=g[a],s=r.find(m=>m.value===c);if(!s)return null;f=s,!s.isLeaf&&s.loadChildren&&s.loadChildren(s),s.children&&(r=s.children)}return f}class j extends t.Instruction{constructor(){super(...arguments);h(this,"title",`{{t("Loop", { ns: "${u}" })}}`);h(this,"type","loop");h(this,"group","control");h(this,"description",`{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "${u}" })}}`);h(this,"fieldset",{target:{type:"string",title:`{{t("Loop target", { ns: "${u}" })}}`,description:`{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "${u}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,useTypedConstant:["string","number","null"],className:e.css`
2
2
  width: 100%;
3
3
 
4
4
  .variable {
@@ -8,6 +8,6 @@
8
8
  .ant-input.null-value {
9
9
  width: 100%;
10
10
  }
11
- `},required:!0}});g(this,"components",{WorkflowVariableInput:s.WorkflowVariableInput})}Component({data:t}){var r;const{nodes:h}=s.useFlowContext(),{styles:a}=s.useStyles(),c=h.find(m=>m.upstreamId===t.id&&m.branchIndex!=null);return o.jsx(s.NodeDefaultView,{data:t,children:o.jsx("div",{className:a.nodeSubtreeClass,children:o.jsxs("div",{className:e.cx(a.branchBlockClass,e.css`
11
+ `},required:!0}});h(this,"components",{WorkflowVariableInput:t.WorkflowVariableInput})}Component({data:r}){var s;const{nodes:f}=t.useFlowContext(),{styles:a}=t.useStyles(),c=f.find(m=>m.upstreamId===r.id&&m.branchIndex!=null);return o.jsx(t.NodeDefaultView,{data:r,children:o.jsx("div",{className:a.nodeSubtreeClass,children:o.jsxs("div",{className:e.cx(a.branchBlockClass,e.css`
12
12
  padding-left: 20em;
13
- `),children:[o.jsx(s.Branch,{from:t,entry:c,branchIndex:(r=c==null?void 0:c.branchIndex)!=null?r:0}),o.jsxs("div",{className:a.branchClass,children:[o.jsx("div",{className:"workflow-branch-lines"}),o.jsx("div",{className:e.cx(a.addButtonClass,a.loopLineClass),children:o.jsx(v.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(t,h){const a=e.useCompile(),c=d("Loop target"),r=d("Loop index"),m=d("Loop length"),{target:x}=t.config;if(!x)return null;const{fieldNames:l=s.defaultFieldNames}=h;let L={key:"item",[l.value]:"item",[l.label]:c};if(typeof x=="string"&&x.startsWith("{{")&&x.endsWith("}}")){const S=x.slice(2,-2).split(".").map(b=>b.trim()),A=[s.scopeOptions,s.nodesOptions,s.triggerOptions].map(b=>{const C=b.useOptions(T(N({},h),{current:t})).filter(Boolean);return{[l.label]:a(b.label),[l.value]:b.value,key:b.value,[l.children]:C,disabled:C&&!C.length}}),B=w(A,S);L=Object.assign({},B,L)}return[L,{key:"index",[l.value]:"index",[l.label]:r},{key:"length",[l.value]:"length",[l.label]:m}]}}class q extends e.Plugin{afterAdd(){return y(this,null,function*(){})}beforeLoad(){return y(this,null,function*(){})}load(){return y(this,null,function*(){const f=this.app.pm.get("workflow"),t=new j;f.instructions.register(t.type,t)})}}n.default=q,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
13
+ `),children:[o.jsx(t.Branch,{from:r,entry:c,branchIndex:(s=c==null?void 0:c.branchIndex)!=null?s:0}),o.jsxs("div",{className:a.branchClass,children:[o.jsx("div",{className:"workflow-branch-lines"}),o.jsx("div",{className:e.cx(a.addButtonClass,a.loopLineClass),children:o.jsx(v.ArrowUpOutlined,{})})]})]})})})}useScopeVariables(r,f){const a=e.useCompile(),c=d("Loop target"),s=d("Loop index"),m=d("Loop length"),{target:x}=r.config;if(!x)return null;const{fieldNames:l=t.defaultFieldNames}=f;let L={key:"item",[l.value]:"item",[l.label]:c};if(typeof x=="string"&&x.startsWith("{{")&&x.endsWith("}}")){const S=x.slice(2,-2).split(".").map(b=>b.trim()),A=[t.scopeOptions,t.nodesOptions,t.triggerOptions].map(b=>{const C=b.useOptions(T(N({},f),{current:r})).filter(Boolean);return{[l.label]:a(b.label),[l.value]:b.value,key:b.value,[l.children]:C,disabled:C&&!C.length}}),B=w(A,S);L=Object.assign({},B,L)}return[L,{key:"index",[l.value]:"index",[l.label]:s},{key:"length",[l.value]:"length",[l.label]:m}]}}class q extends e.Plugin{afterAdd(){return y(this,null,function*(){})}beforeLoad(){return y(this,null,function*(){})}load(){return y(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",j)})}}n.default=q,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
3
  "@ant-design/icons": "5.2.6",
4
- "@nocobase/client": "0.18.0-alpha.1",
5
- "@nocobase/plugin-workflow": "0.18.0-alpha.1",
4
+ "@nocobase/client": "0.18.0-alpha.9",
5
+ "@nocobase/plugin-workflow": "0.18.0-alpha.9",
6
6
  "react-i18next": "11.18.6",
7
- "@nocobase/server": "0.18.0-alpha.1"
7
+ "@nocobase/server": "0.18.0-alpha.9"
8
8
  };
@@ -4,6 +4,5 @@
4
4
  "Loop index": "当前索引",
5
5
  "Loop length": "循环长度",
6
6
  "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.": "使用循环节点可以对多条数据进行同样的操作,多条数据的来源可以是查询节点的多条结果,或者一条数据的多条关系数据。也可以用于一定次数的循环,或者对字符串中每一个字符的循环处理。循环次数过高可能引起性能问题,请谨慎使用。",
7
- "Scope variables": "局域变量",
8
7
  "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.": "单一数字值将被视为循环次数,单一字符串值将被视为字符数组,其他非数组值将被转换为数组。达到循环次数,或者将数组循环完成后,循环节点结束。你也可以在循环中添加条件节点,以终止循环。"
9
8
  }
@@ -1,7 +1,7 @@
1
1
  import { Processor, Instruction, FlowNodeModel, JobModel } from '@nocobase/plugin-workflow';
2
2
  export default class extends Instruction {
3
3
  run(node: FlowNodeModel, prevJob: JobModel, processor: Processor): Promise<{
4
- status: number;
4
+ status: 1;
5
5
  result: number;
6
6
  }>;
7
7
  resume(node: FlowNodeModel, branchJob: any, processor: Processor): Promise<any>;
@@ -1,6 +1,4 @@
1
1
  import { Plugin } from '@nocobase/server';
2
- import { default as 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_LoopInstruction = __toESM(require("./LoopInstruction"));
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("loop", new import_LoopInstruction.default(workflowPlugin));
38
+ const workflowPlugin = this.app.getPlugin(import_plugin_workflow.default);
39
+ workflowPlugin.registerInstruction("loop", import_LoopInstruction.default);
41
40
  }
42
41
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:循环节点",
5
5
  "description": "Useful plugin for doing dynamic calculation based on expression collection records in workflow.",
6
6
  "description.zh-CN": "用于在工作流中进行基于数据行的动态表达式计算。",
7
- "version": "0.18.0-alpha.1",
7
+ "version": "0.18.0-alpha.9",
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": "0f5f1c0a37dc397a9dc4c8eec0c4ec20fd8107b0"
22
+ "gitHead": "34ca0df4eede2e83fc86297b0fe19eba970e2b1b"
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 loopInstruction = new LoopInstruction();
17
- workflow.instructions.register(loopInstruction.type, loopInstruction);
16
+ workflow.registerInstruction('loop', LoopInstruction);
18
17
  }
19
18
  }
@@ -4,6 +4,5 @@
4
4
  "Loop index": "当前索引",
5
5
  "Loop length": "循环长度",
6
6
  "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.": "使用循环节点可以对多条数据进行同样的操作,多条数据的来源可以是查询节点的多条结果,或者一条数据的多条关系数据。也可以用于一定次数的循环,或者对字符串中每一个字符的循环处理。循环次数过高可能引起性能问题,请谨慎使用。",
7
- "Scope variables": "局域变量",
8
7
  "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.": "单一数字值将被视为循环次数,单一字符串值将被视为字符数组,其他非数组值将被转换为数组。达到循环次数,或者将数组循环完成后,循环节点结束。你也可以在循环中添加条件节点,以终止循环。"
9
8
  }
@@ -4,11 +4,8 @@ import { default as WorkflowPlugin } from '@nocobase/plugin-workflow';
4
4
  import LoopInstruction from './LoopInstruction';
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('loop', new LoopInstruction(workflowPlugin));
8
+ const workflowPlugin = this.app.getPlugin<WorkflowPlugin>(WorkflowPlugin);
9
+ workflowPlugin.registerInstruction('loop', LoopInstruction);
13
10
  }
14
11
  }
@@ -1,6 +1,6 @@
1
1
  import Database from '@nocobase/database';
2
2
  import { Application } from '@nocobase/server';
3
- import { BRANCH_INDEX, EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
3
+ import { EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
4
4
  import { getApp, sleep } from '@nocobase/plugin-workflow-test';
5
5
 
6
6
  import Plugin from '..';
@@ -404,7 +404,7 @@ describe('workflow > instructions > loop', () => {
404
404
 
405
405
  const n2 = await workflow.createNode({
406
406
  type: 'loop',
407
- branchIndex: BRANCH_INDEX.ON_TRUE,
407
+ branchIndex: 1,
408
408
  upstreamId: n1.id,
409
409
  config: {
410
410
  target: 0,
@@ -442,7 +442,7 @@ describe('workflow > instructions > loop', () => {
442
442
 
443
443
  const n2 = await workflow.createNode({
444
444
  type: 'loop',
445
- branchIndex: BRANCH_INDEX.ON_TRUE,
445
+ branchIndex: 1,
446
446
  upstreamId: n1.id,
447
447
  config: {
448
448
  target: 2,