@nocobase/plugin-workflow-action-trigger 1.0.0-alpha.5 → 1.0.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.
@@ -83,7 +83,6 @@ export default class extends Trigger {
83
83
  'x-decorator': string;
84
84
  'x-component': string;
85
85
  'x-component-props': {
86
- title: string;
87
86
  multiple: boolean;
88
87
  useCollection(): any;
89
88
  };
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("@formily/react"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","@formily/react","react-i18next"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-workflow-action-trigger"]={},o["@nocobase/client"],o["@nocobase/plugin-workflow"],o["@formily/react"],o["react-i18next"]))})(this,function(o,e,t,w,m){"use strict";var E=Object.defineProperty,$=Object.defineProperties;var M=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var k=(o,e,t)=>e in o?E(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,g=(o,e)=>{for(var t in e||(e={}))v.call(e,t)&&k(o,t,e[t]);if(S)for(var t of S(e))D.call(e,t)&&k(o,t,e[t]);return o},f=(o,e)=>$(o,M(e));var s=(o,e,t)=>(k(o,typeof e!="symbol"?e+"":e,t),t);var F=(o,e,t)=>new Promise((w,m)=>{var i=r=>{try{c(t.next(r))}catch(l){m(l)}},a=r=>{try{c(t.throw(r))}catch(l){m(l)}},c=r=>r.done?w(r.value):Promise.resolve(r.value).then(i,a);c((t=t.apply(o,e)).next())});const i="workflow-action-trigger";function a(u,A={}){const{t:n}=c(A);return n(u)}function c(u){return m.useTranslation(i,u)}const r={CREATE:"create",UPDATE:"update",UPSERT:"updateOrCreate",DESTROY:"destroy"};class l extends t.Trigger{constructor(){super(...arguments);s(this,"title",`{{t("Post-action event", { ns: "${i}" })}}`);s(this,"description",`{{t('Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or "submit to workflow". Suitable for data processing, sending notifications, etc., after actions are completed.', { ns: "${i}" })}}`);s(this,"fieldset",{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-decorator-props":{tooltip:`{{t("The collection to which the triggered data belongs.", { ns: "${i}" })}}`},"x-component":"DataSourceCollectionCascader","x-disabled":"{{ useWorkflowAnyExecuted() }}",title:`{{t("Collection", { ns: "${i}" })}}`,"x-reactions":[{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:`{{t("Trigger mode", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Local mode, triggered after the completion of actions bound to this workflow", { ns: "${i}" })}}`,value:!1},{label:`{{t("Global mode, triggered after the completion of the following actions", { ns: "${i}" })}}`,value:!0}]},default:!1,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},actions:{type:"number",title:`{{t("Select actions", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Create record action", { ns: "${i}" })}}`,value:r.CREATE},{label:`{{t("Update record action", { ns: "${i}" })}}`,value:r.UPDATE}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]},appends:{type:"array",title:`{{t("Associations to use", { ns: "${i}" })}}`,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: "workflow" })}}',"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{title:"Preload associations",multiple:!0,useCollection(){const{values:n}=w.useForm();return n==null?void 0:n.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}});s(this,"scope",{useCollectionDataSource:e.useCollectionDataSource,useWorkflowAnyExecuted:t.useWorkflowAnyExecuted});s(this,"components",{RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip});s(this,"isActionTriggerable",(n,d)=>d.action==="customize:triggerWorkflows"||["create","update","customize:update"].includes(d.action)&&!n.global)}useVariables(n,d){var y;const T=e.useCompile(),{getCollectionFields:I}=e.useCollectionManager_deprecated(),z=a("Trigger data"),x=a("User submitted action"),C=a("Role of user submitted action"),W=[{collectionName:n.collection,name:"data",type:"hasOne",target:n.collection,uiSchema:{title:z}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:x}},{name:"roleName",uiSchema:{title:C}}];return t.getCollectionFieldOptions(f(g({appends:["data","user",...((y=n.appends)==null?void 0:y.map(R=>`data.${R}`))||[]]},d),{fields:W,compile:T,getCollectionFields:I}))}useInitializers(n){return n.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${i}" })}}`,Component:t.CollectionBlockInitializer,collection:n.collection,dataPath:"$context.data"}:null}}const h={name:"submitToWorkflow",title:'{{t("Submit to workflow", { ns: "workflow" })}}',Component:"CustomizeActionInitializer",schema:{title:'{{t("Submit to workflow", { ns: "workflow" })}}',"x-component":"Action","x-use-component-props":"useTriggerWorkflowsActionProps","x-designer":"Action.Designer","x-action-settings":{skipValidator:!1,onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Submitted successfully")}}'},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},p={name:"submitToWorkflow",title:'{{t("Submit to workflow", { ns: "workflow" })}}',Component:"CustomizeActionInitializer",schema:{title:'{{t("Submit to workflow", { ns: "workflow" })}}',"x-component":"Action","x-use-component-props":"useRecordTriggerWorkflowsActionProps","x-designer":"Action.Designer","x-action-settings":{onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Submitted successfully")}}'},triggerWorkflows:[]},"x-action":"customize:triggerWorkflows"}},b=f(g({},p),{schema:f(g({},p.schema),{"x-component":"Action.Link"})});class P extends e.Plugin{load(){return F(this,null,function*(){this.app.pm.get("workflow").registerTrigger("action",l),this.app.addScopes({useTriggerWorkflowsActionProps:t.useTriggerWorkflowsActionProps,useRecordTriggerWorkflowsActionProps:t.useRecordTriggerWorkflowsActionProps}),this.app.schemaInitializerManager.get("FormActionInitializers").add("customize.submitToWorkflow",h),this.app.schemaInitializerManager.get("createForm:configureActions").add("customize.submitToWorkflow",h),this.app.schemaInitializerManager.get("editForm:configureActions").add("customize.submitToWorkflow",h),this.app.schemaInitializerManager.get("detailsWithPaging:configureActions").add("customize.submitToWorkflow",p),this.app.schemaInitializerManager.get("details:configureActions").add("customize.submitToWorkflow",p),this.app.schemaInitializerManager.get("table:configureItemActions").add("customize.submitToWorkflow",b),this.app.schemaInitializerManager.get("gridCard:configureItemActions").add("customize.submitToWorkflow",b),this.app.schemaInitializerManager.get("list:configureItemActions").add("customize.submitToWorkflow",b)})}}o.default=P,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
+ (function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("@formily/react"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","@formily/react","react-i18next"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-workflow-action-trigger"]={},o["@nocobase/client"],o["@nocobase/plugin-workflow"],o["@formily/react"],o["react-i18next"]))})(this,function(o,e,t,g,d){"use strict";var v=Object.defineProperty,W=Object.defineProperties;var R=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var m=(o,e,t)=>e in o?v(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,T=(o,e)=>{for(var t in e||(e={}))F.call(e,t)&&m(o,t,e[t]);if(b)for(var t of b(e))I.call(e,t)&&m(o,t,e[t]);return o},w=(o,e)=>W(o,R(e));var s=(o,e,t)=>(m(o,typeof e!="symbol"?e+"":e,t),t);var x=(o,e,t)=>new Promise((g,d)=>{var i=r=>{try{l(t.next(r))}catch(c){d(c)}},a=r=>{try{l(t.throw(r))}catch(c){d(c)}},l=r=>r.done?g(r.value):Promise.resolve(r.value).then(i,a);l((t=t.apply(o,e)).next())});const i="workflow-action-trigger";function a(u,f={}){const{t:n}=l(f);return n(u)}function l(u){return d.useTranslation(i,u)}const r={CREATE:"create",UPDATE:"update",UPSERT:"updateOrCreate",DESTROY:"destroy"};class c extends t.Trigger{constructor(){super(...arguments);s(this,"title",`{{t("Post-action event", { ns: "${i}" })}}`);s(this,"description",`{{t('Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, or deleting data. Suitable for data processing, sending notifications, etc., after actions are completed.', { ns: "${i}" })}}`);s(this,"fieldset",{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-decorator-props":{tooltip:`{{t("The collection to which the triggered data belongs.", { ns: "${i}" })}}`},"x-component":"DataSourceCollectionCascader","x-disabled":"{{ useWorkflowAnyExecuted() }}",title:`{{t("Collection", { ns: "${i}" })}}`,"x-reactions":[{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:`{{t("Trigger mode", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Local mode, triggered after the completion of actions bound to this workflow", { ns: "${i}" })}}`,value:!1},{label:`{{t("Global mode, triggered after the completion of the following actions", { ns: "${i}" })}}`,value:!0}]},default:!1,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},actions:{type:"number",title:`{{t("Select actions", { ns: "${i}" })}}`,"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Create record action", { ns: "${i}" })}}`,value:r.CREATE},{label:`{{t("Update record action", { ns: "${i}" })}}`,value:r.UPDATE}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]},appends:{type:"array",title:`{{t("Associations to use", { ns: "${i}" })}}`,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: "workflow" })}}',"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection(){const{values:n}=g.useForm();return n==null?void 0:n.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}});s(this,"scope",{useCollectionDataSource:e.useCollectionDataSource,useWorkflowAnyExecuted:t.useWorkflowAnyExecuted});s(this,"components",{RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip});s(this,"isActionTriggerable",(n,p)=>["create","update"].includes(p.formAction)&&["submit","customize:save"].includes(p.buttonAction)&&!n.global)}useVariables(n,p){var h;const k=e.useCompile(),{getCollectionFields:y}=e.useCollectionManager_deprecated(),A=a("Trigger data"),S=a("User submitted action"),E=a("Role of user submitted action"),P=[{collectionName:n.collection,name:"data",type:"hasOne",target:n.collection,uiSchema:{title:A}},{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:S}},{name:"roleName",uiSchema:{title:E}}];return t.getCollectionFieldOptions(w(T({appends:["data","user",...((h=n.appends)==null?void 0:h.map($=>`data.${$}`))||[]]},p),{fields:P,compile:k,getCollectionFields:y}))}useInitializers(n){return n.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${i}" })}}`,Component:t.CollectionBlockInitializer,collection:n.collection,dataPath:"$context.data"}:null}}class C extends e.Plugin{load(){return x(this,null,function*(){this.app.pm.get("workflow").registerTrigger("action",c),this.app.addScopes({useTriggerWorkflowsActionProps:t.useTriggerWorkflowsActionProps,useRecordTriggerWorkflowsActionProps:t.useRecordTriggerWorkflowsActionProps})})}}o.default=C,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -9,16 +9,16 @@
9
9
 
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.0",
12
- "@nocobase/client": "1.0.0-alpha.5",
13
- "@nocobase/plugin-workflow": "1.0.0-alpha.5",
12
+ "@nocobase/client": "1.0.0-alpha.8",
13
+ "@nocobase/plugin-workflow": "1.0.0-alpha.8",
14
14
  "react-i18next": "11.18.6",
15
15
  "lodash": "4.17.21",
16
16
  "sequelize": "6.35.2",
17
- "@nocobase/database": "1.0.0-alpha.5",
18
- "@nocobase/server": "1.0.0-alpha.5",
19
- "@nocobase/actions": "1.0.0-alpha.5",
20
- "@nocobase/data-source-manager": "1.0.0-alpha.5",
21
- "@nocobase/plugin-workflow-test": "1.0.0-alpha.5",
22
- "@nocobase/test": "1.0.0-alpha.5",
23
- "@nocobase/utils": "1.0.0-alpha.5"
17
+ "@nocobase/database": "1.0.0-alpha.8",
18
+ "@nocobase/server": "1.0.0-alpha.8",
19
+ "@nocobase/actions": "1.0.0-alpha.8",
20
+ "@nocobase/data-source-manager": "1.0.0-alpha.8",
21
+ "@nocobase/plugin-workflow-test": "1.0.0-alpha.8",
22
+ "@nocobase/test": "1.0.0-alpha.8",
23
+ "@nocobase/utils": "1.0.0-alpha.8"
24
24
  };
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "Post-action event": "操作后事件",
3
- "Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or \"submit to workflow\". Suitable for data processing, sending notifications, etc., after actions are completed.":
4
- "通过操作按钮或 API 发起请求并在执行完成后触发,比如新增、更新、删除数据或者“提交至工作流”之后。适用于在操作完成后进行数据处理、发送通知等。",
3
+ "Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, or deleting data. Suitable for data processing, sending notifications, etc., after actions are completed.":
4
+ "通过操作按钮或 API 发起请求时,在请求执行成功后触发该事件,比如新增、更新、删除操作之后。适用于在操作完成后进行数据处理、发送通知等。",
5
5
  "Collection": "数据表",
6
6
  "The collection to which the triggered data belongs.": "触发数据所属的数据表。",
7
7
  "Trigger mode": "触发模式",
8
8
  "Local mode, triggered after the completion of actions bound to this workflow": "局部模式,绑定该工作流的操作执行完成后触发",
9
9
  "Global mode, triggered after the completion of the following actions": "全局模式,以下操作执行完成后都触发",
10
- "Action to submit to workflow directly is only supported on bound buttons, and will not be affected under global mode.": "直接提交至工作流的操作仅支持使用按钮绑定,不受全局模式的影响。",
11
10
  "Select actions": "选择操作",
12
11
  "Create record action": "创建记录操作",
13
12
  "Update record action": "更新记录操作",
@@ -14,6 +14,9 @@ interface Context extends ActionContext, DefaultContext {
14
14
  export default class extends Trigger {
15
15
  static TYPE: string;
16
16
  constructor(workflow: WorkflowPlugin);
17
+ /**
18
+ * @deprecated
19
+ */
17
20
  workflowTriggerAction(context: Context, next: Next): Promise<void>;
18
21
  middleware: (context: Context, next: Next) => Promise<void>;
19
22
  private collectionTriggerAction;
@@ -39,6 +39,9 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
39
39
  super(workflow);
40
40
  workflow.app.use(this.middleware, { after: "dataSource" });
41
41
  }
42
+ /**
43
+ * @deprecated
44
+ */
42
45
  async workflowTriggerAction(context, next) {
43
46
  const { triggerWorkflows } = context.action.params;
44
47
  if (!triggerWorkflows) {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Migration } from '@nocobase/server';
10
+ export default class extends Migration {
11
+ appVersion: string;
12
+ on: string;
13
+ up(): Promise<void>;
14
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var deprecate_action_type_exports = {};
28
+ __export(deprecate_action_type_exports, {
29
+ default: () => deprecate_action_type_default
30
+ });
31
+ module.exports = __toCommonJS(deprecate_action_type_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class deprecate_action_type_default extends import_server.Migration {
34
+ appVersion = "<1.0.0-alpha.7";
35
+ on = "afterSync";
36
+ async up() {
37
+ const { db } = this.context;
38
+ const UiSchemaRepo = db.getRepository("uiSchemas");
39
+ await db.sequelize.transaction(async (transaction) => {
40
+ const nodes = await UiSchemaRepo.find({
41
+ filter: {
42
+ "schema.x-component": "Action",
43
+ "schema.x-designer": "Action.Designer",
44
+ "schema.x-action": "customize:triggerWorkflows",
45
+ $or: [
46
+ {
47
+ "schema.x-component-props.useProps": "useTriggerWorkflowsActionProps"
48
+ },
49
+ {
50
+ "schema.x-component-props.useProps": "useRecordTriggerWorkflowsActionProps"
51
+ },
52
+ {
53
+ "schema.x-use-component-props": "useTriggerWorkflowsActionProps"
54
+ },
55
+ {
56
+ "schema.x-use-component-props": "useRecordTriggerWorkflowsActionProps"
57
+ }
58
+ ]
59
+ },
60
+ transaction
61
+ });
62
+ for (const node of nodes) {
63
+ const schema = node.get("schema");
64
+ schema["x-action"] = "customize:triggerWorkflows_deprecated";
65
+ node.set("schema", { ...schema });
66
+ node.changed("schema", true);
67
+ await node.save({ transaction });
68
+ }
69
+ });
70
+ }
71
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:操作后事件",
5
5
  "description": "Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or \"submit to workflow\". Suitable for data processing, sending notifications, etc., after actions are completed.",
6
6
  "description.zh-CN": "通过操作按钮或 API 发起请求并在执行完成后触发,比如新增、更新、删除数据或者“提交至工作流”之后。适用于在操作完成后进行数据处理、发送通知等。",
7
- "version": "1.0.0-alpha.5",
7
+ "version": "1.0.0-alpha.8",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
@@ -21,7 +21,7 @@
21
21
  "@nocobase/server": "1.x",
22
22
  "@nocobase/test": "1.x"
23
23
  },
24
- "gitHead": "c85c3e8af1b57d7078aa0df4d4cdecb73269f2eb",
24
+ "gitHead": "3c4e978f6fc366c01621c9d625678e91f53f8662",
25
25
  "keywords": [
26
26
  "Workflow"
27
27
  ]