@nocobase/plugin-workflow-action-trigger 1.2.12-alpha → 1.3.0-alpha.20240710084543

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/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.2.12-alpha",
7
+ "version": "1.3.0-alpha.20240710084543",
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": "553231d4882496cb7f1f17fa7541899ce82a27ab",
24
+ "gitHead": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4",
25
25
  "keywords": [
26
26
  "Workflow"
27
27
  ]
@@ -1,112 +0,0 @@
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 { SchemaInitializerItemType, useCollectionDataSource } from '@nocobase/client';
10
- import { Trigger, useWorkflowAnyExecuted, CheckboxGroupWithTooltip, RadioWithTooltip } from '@nocobase/plugin-workflow/client';
11
- declare function useVariables(config: any, options: any): import("@nocobase/plugin-workflow/client").VariableOption[];
12
- export default class extends Trigger {
13
- title: string;
14
- description: string;
15
- fieldset: {
16
- collection: {
17
- type: string;
18
- required: boolean;
19
- 'x-decorator': string;
20
- 'x-decorator-props': {
21
- tooltip: string;
22
- };
23
- 'x-component': string;
24
- 'x-disabled': string;
25
- title: string;
26
- 'x-reactions': {
27
- target: string;
28
- effects: string[];
29
- fulfill: {
30
- state: {
31
- value: any[];
32
- };
33
- };
34
- }[];
35
- };
36
- global: {
37
- type: string;
38
- title: string;
39
- 'x-decorator': string;
40
- 'x-component': string;
41
- 'x-component-props': {
42
- direction: string;
43
- options: {
44
- label: string;
45
- value: boolean;
46
- }[];
47
- };
48
- default: boolean;
49
- 'x-reactions': {
50
- dependencies: string[];
51
- fulfill: {
52
- state: {
53
- visible: string;
54
- };
55
- };
56
- }[];
57
- };
58
- actions: {
59
- type: string;
60
- title: string;
61
- 'x-decorator': string;
62
- 'x-component': string;
63
- 'x-component-props': {
64
- direction: string;
65
- options: {
66
- label: string;
67
- value: string;
68
- }[];
69
- };
70
- required: boolean;
71
- 'x-reactions': {
72
- dependencies: string[];
73
- fulfill: {
74
- state: {
75
- visible: string;
76
- };
77
- };
78
- }[];
79
- };
80
- appends: {
81
- type: string;
82
- title: string;
83
- description: string;
84
- 'x-decorator': string;
85
- 'x-component': string;
86
- 'x-component-props': {
87
- multiple: boolean;
88
- useCollection(): any;
89
- };
90
- 'x-reactions': {
91
- dependencies: string[];
92
- fulfill: {
93
- state: {
94
- visible: string;
95
- };
96
- };
97
- }[];
98
- };
99
- };
100
- scope: {
101
- useCollectionDataSource: typeof useCollectionDataSource;
102
- useWorkflowAnyExecuted: typeof useWorkflowAnyExecuted;
103
- };
104
- components: {
105
- RadioWithTooltip: typeof RadioWithTooltip;
106
- CheckboxGroupWithTooltip: typeof CheckboxGroupWithTooltip;
107
- };
108
- isActionTriggerable: (config: any, context: any) => boolean;
109
- useVariables: typeof useVariables;
110
- useInitializers(config: any): SchemaInitializerItemType | null;
111
- }
112
- export {};
@@ -1,12 +0,0 @@
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 { Plugin } from '@nocobase/client';
10
- export default class extends Plugin {
11
- load(): Promise<void>;
12
- }
@@ -1,10 +0,0 @@
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
- (function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(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"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o["@nocobase/plugin-workflow-action-trigger"]={},o["@nocobase/client"],o["@nocobase/plugin-workflow"],o["@formily/react"],o["react-i18next"]))})(this,function(o,t,e,f,p){"use strict";var v=Object.defineProperty,W=Object.defineProperties;var R=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var m=(o,t,e)=>t in o?v(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,b=(o,t)=>{for(var e in t||(t={}))I.call(t,e)&&m(o,e,t[e]);if(w)for(var e of w(t))O.call(t,e)&&m(o,e,t[e]);return o},h=(o,t)=>W(o,R(t));var a=(o,t,e)=>(m(o,typeof t!="symbol"?t+"":t,e),e);var C=(o,t,e)=>new Promise((f,p)=>{var i=r=>{try{u(e.next(r))}catch(d){p(d)}},c=r=>{try{u(e.throw(r))}catch(d){p(d)}},u=r=>r.done?f(r.value):Promise.resolve(r.value).then(i,c);u((e=e.apply(o,t)).next())});const i="workflow-action-trigger";function c(s,l={}){const{t:n}=u(l);return n(s)}function u(s){return p.useTranslation(i,s)}const r={CREATE:"create",UPDATE:"update",UPSERT:"updateOrCreate",DESTROY:"destroy"};function d(s,l){var x;const[n,g]=t.parseCollectionName(s.collection),T=t.useCompile(),A=e.useGetCollectionFields(n),S=e.useGetCollectionFields(),E=c("Trigger data"),F=c("User submitted action"),P=c("Role of user submitted action");return[...e.getCollectionFieldOptions(h(b({appends:["data",...((x=s.appends)==null?void 0:x.map($=>`data.${$}`))||[]]},l),{fields:[{collectionName:g,name:"data",type:"hasOne",target:g,uiSchema:{title:E}}],compile:T,getCollectionFields:A})),...e.getCollectionFieldOptions(h(b({appends:["user"]},l),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:F}},{name:"roleName",uiSchema:{title:P}}],compile:T,getCollectionFields:S}))]}class k extends e.Trigger{constructor(){super(...arguments);a(this,"title",`{{t("Post-action event", { ns: "${i}" })}}`);a(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}" })}}`);a(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}=f.useForm();return n==null?void 0:n.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}});a(this,"scope",{useCollectionDataSource:t.useCollectionDataSource,useWorkflowAnyExecuted:e.useWorkflowAnyExecuted});a(this,"components",{RadioWithTooltip:e.RadioWithTooltip,CheckboxGroupWithTooltip:e.CheckboxGroupWithTooltip});a(this,"isActionTriggerable",(n,g)=>!n.global&&["submit","customize:save","customize:update"].includes(g.buttonAction));a(this,"useVariables",d)}useInitializers(n){return n.collection?{name:"triggerData",type:"item",key:"triggerData",title:`{{t("Trigger data", { ns: "${i}" })}}`,Component:e.CollectionBlockInitializer,collection:n.collection,dataPath:"$context.data"}:null}}class y extends t.Plugin{load(){return C(this,null,function*(){this.app.pm.get("workflow").registerTrigger("action",k),this.app.addScopes({useTriggerWorkflowsActionProps:e.useTriggerWorkflowsActionProps,useRecordTriggerWorkflowsActionProps:e.useRecordTriggerWorkflowsActionProps})})}}o.default=y,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,24 +0,0 @@
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
- module.exports = {
11
- "@formily/react": "2.3.0",
12
- "@nocobase/client": "1.2.12-alpha",
13
- "@nocobase/plugin-workflow": "1.2.12-alpha",
14
- "react-i18next": "11.18.6",
15
- "lodash": "4.17.21",
16
- "sequelize": "6.35.2",
17
- "@nocobase/database": "1.2.12-alpha",
18
- "@nocobase/server": "1.2.12-alpha",
19
- "@nocobase/actions": "1.2.12-alpha",
20
- "@nocobase/data-source-manager": "1.2.12-alpha",
21
- "@nocobase/plugin-workflow-test": "1.2.12-alpha",
22
- "@nocobase/test": "1.2.12-alpha",
23
- "@nocobase/utils": "1.2.12-alpha"
24
- };
package/dist/index.d.ts DELETED
@@ -1,10 +0,0 @@
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
- export * from './server';
10
- export { default } from './server';
package/dist/index.js DELETED
@@ -1,48 +0,0 @@
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 __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var src_exports = {};
39
- __export(src_exports, {
40
- default: () => import_server.default
41
- });
42
- module.exports = __toCommonJS(src_exports);
43
- __reExport(src_exports, require("./server"), module.exports);
44
- var import_server = __toESM(require("./server"));
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- ...require("./server")
48
- });
@@ -1,9 +0,0 @@
1
- {
2
- "Form event": "Form event",
3
- "Event triggers when submitted a workflow bound form action.": "Event triggers when submitted a workflow bound form action.",
4
- "Form data model": "Form data model",
5
- "Use a collection to match form data.": "Use a collection to match form data.",
6
- "Associations to use": "Associations to use",
7
- "User submitted form": "User submitted form",
8
- "Role of user submitted form": "Role of user submitted form"
9
- }
@@ -1,11 +0,0 @@
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
- export declare const NAMESPACE = "workflow-action-trigger";
10
- export declare function useLang(key: string, options?: {}): string;
11
- export declare function usePluginTranslation(options: any): import("react-i18next").UseTranslationResponse<"workflow-action-trigger", undefined>;
@@ -1,48 +0,0 @@
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 locale_exports = {};
28
- __export(locale_exports, {
29
- NAMESPACE: () => NAMESPACE,
30
- useLang: () => useLang,
31
- usePluginTranslation: () => usePluginTranslation
32
- });
33
- module.exports = __toCommonJS(locale_exports);
34
- var import_react_i18next = require("react-i18next");
35
- const NAMESPACE = "workflow-action-trigger";
36
- function useLang(key, options = {}) {
37
- const { t } = usePluginTranslation(options);
38
- return t(key);
39
- }
40
- function usePluginTranslation(options) {
41
- return (0, import_react_i18next.useTranslation)(NAMESPACE, options);
42
- }
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- NAMESPACE,
46
- useLang,
47
- usePluginTranslation
48
- });
@@ -1,9 +0,0 @@
1
- {
2
- "Form event": "폼 이벤트",
3
- "Event triggers when submitted a workflow bound form action.": "작업 흐름에 바인딩된 폼 작업이 제출될 때 이벤트가 트리거됩니다.",
4
- "Form data model": "폼 데이터 모델",
5
- "Use a collection to match form data.": "폼 데이터를 일치시키기 위해 데이터 테이블을 사용합니다.",
6
- "Associations to use": "사용할 관련 데이터",
7
- "User submitted form": "사용자가 제출한 폼",
8
- "Role of user submitted form": "사용자 제출 폼의 역할"
9
- }
@@ -1,17 +0,0 @@
1
- {
2
- "Post-action event": "操作后事件",
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
- "Collection": "数据表",
6
- "The collection to which the triggered data belongs.": "触发数据所属的数据表。",
7
- "Trigger mode": "触发模式",
8
- "Local mode, triggered after the completion of actions bound to this workflow": "局部模式,绑定该工作流的操作执行完成后触发",
9
- "Global mode, triggered after the completion of the following actions": "全局模式,以下操作执行完成后都触发",
10
- "Select actions": "选择操作",
11
- "Create record action": "创建记录操作",
12
- "Update record action": "更新记录操作",
13
- "Associations to use": "待使用的关系数据",
14
- "Trigger data": "触发器数据",
15
- "User submitted action": "提交操作的用户",
16
- "Role of user submitted action": "提交操作用户的角色"
17
- }
@@ -1,26 +0,0 @@
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 { DefaultContext } from '@nocobase/server';
10
- import { Context as ActionContext, Next } from '@nocobase/actions';
11
- import WorkflowPlugin, { Trigger, WorkflowModel } from '@nocobase/plugin-workflow';
12
- interface Context extends ActionContext, DefaultContext {
13
- }
14
- export default class extends Trigger {
15
- static TYPE: string;
16
- constructor(workflow: WorkflowPlugin);
17
- /**
18
- * @deprecated
19
- */
20
- workflowTriggerAction(context: Context, next: Next): Promise<void>;
21
- middleware: (context: Context, next: Next) => Promise<void>;
22
- private collectionTriggerAction;
23
- on(workflow: WorkflowModel): void;
24
- off(workflow: WorkflowModel): void;
25
- }
26
- export {};
@@ -1,184 +0,0 @@
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 ActionTrigger_exports = {};
28
- __export(ActionTrigger_exports, {
29
- default: () => ActionTrigger_default
30
- });
31
- module.exports = __toCommonJS(ActionTrigger_exports);
32
- var import_lodash = require("lodash");
33
- var import_database = require("@nocobase/database");
34
- var import_plugin_workflow = require("@nocobase/plugin-workflow");
35
- var import_data_source_manager = require("@nocobase/data-source-manager");
36
- class ActionTrigger_default extends import_plugin_workflow.Trigger {
37
- static TYPE = "action";
38
- constructor(workflow) {
39
- super(workflow);
40
- workflow.app.dataSourceManager.use(this.middleware);
41
- }
42
- /**
43
- * @deprecated
44
- */
45
- async workflowTriggerAction(context, next) {
46
- const { triggerWorkflows } = context.action.params;
47
- if (!triggerWorkflows) {
48
- return context.throw(400);
49
- }
50
- context.status = 202;
51
- await next();
52
- return this.collectionTriggerAction(context);
53
- }
54
- middleware = async (context, next) => {
55
- const { resourceName, actionName } = context.action;
56
- if (resourceName === "workflows" && actionName === "trigger") {
57
- return this.workflowTriggerAction(context, next);
58
- }
59
- await next();
60
- if (!["create", "update"].includes(actionName)) {
61
- return;
62
- }
63
- return this.collectionTriggerAction(context);
64
- };
65
- async collectionTriggerAction(context) {
66
- const {
67
- resourceName,
68
- actionName,
69
- params: { triggerWorkflows = "", values }
70
- } = context.action;
71
- const dataSourceHeader = context.get("x-data-source") || "main";
72
- const collection = context.app.dataSourceManager.dataSources.get(dataSourceHeader).collectionManager.getCollection(resourceName);
73
- if (!collection) {
74
- return;
75
- }
76
- const fullCollectionName = (0, import_data_source_manager.joinCollectionName)(dataSourceHeader, collection.name);
77
- const { currentUser, currentRole } = context.state;
78
- const { model: UserModel } = this.workflow.db.getCollection("users");
79
- const userInfo = {
80
- user: UserModel.build(currentUser).desensitize(),
81
- roleName: currentRole
82
- };
83
- const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
84
- const triggersKeysMap = new Map(triggers);
85
- const workflows = Array.from(this.workflow.enabledCache.values()).filter(
86
- (item) => item.type === "action" && item.config.collection
87
- );
88
- const globalWorkflows = /* @__PURE__ */ new Map();
89
- const localWorkflows = /* @__PURE__ */ new Map();
90
- workflows.forEach((item) => {
91
- var _a;
92
- if (resourceName === "workflows" && actionName === "trigger") {
93
- localWorkflows.set(item.key, item);
94
- } else if (item.config.collection === fullCollectionName) {
95
- if (item.config.global) {
96
- if ((_a = item.config.actions) == null ? void 0 : _a.includes(actionName)) {
97
- globalWorkflows.set(item.key, item);
98
- }
99
- } else {
100
- localWorkflows.set(item.key, item);
101
- }
102
- }
103
- });
104
- const triggeringLocalWorkflows = [];
105
- const uniqueTriggersMap = /* @__PURE__ */ new Map();
106
- triggers.forEach((trigger) => {
107
- const [key] = trigger;
108
- const workflow = localWorkflows.get(key);
109
- if (workflow && !uniqueTriggersMap.has(key)) {
110
- triggeringLocalWorkflows.push(workflow);
111
- uniqueTriggersMap.set(key, true);
112
- }
113
- });
114
- const syncGroup = [];
115
- const asyncGroup = [];
116
- for (const workflow of triggeringLocalWorkflows.concat(...globalWorkflows.values())) {
117
- const { appends = [] } = workflow.config;
118
- const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(workflow.config.collection);
119
- const dataPath = triggersKeysMap.get(workflow.key);
120
- const event = [workflow];
121
- if (context.action.resourceName !== "workflows") {
122
- if (!context.body) {
123
- continue;
124
- }
125
- if (dataSourceName !== dataSourceHeader) {
126
- continue;
127
- }
128
- const { body: data } = context;
129
- for (const row of Array.isArray(data) ? data : [data]) {
130
- let payload = row;
131
- if (dataPath) {
132
- const paths = dataPath.split(".");
133
- for (const field of paths) {
134
- if (!payload) {
135
- break;
136
- }
137
- if (payload.get(field)) {
138
- payload = payload.get(field);
139
- } else {
140
- const association = (0, import_database.modelAssociationByKey)(payload, field);
141
- payload = await payload[association.accessors.get]();
142
- }
143
- }
144
- }
145
- if (payload instanceof import_database.Model) {
146
- const model = payload.constructor;
147
- if (collectionName !== model.collection.name) {
148
- continue;
149
- }
150
- if (appends.length) {
151
- payload = await model.collection.repository.findOne({
152
- filterByTk: payload.get(model.collection.filterTargetKey),
153
- appends
154
- });
155
- }
156
- }
157
- event.push({ data: (0, import_plugin_workflow.toJSON)(payload), ...userInfo });
158
- }
159
- } else {
160
- const { filterTargetKey, repository } = context.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
161
- let data = dataPath ? (0, import_lodash.get)(values, dataPath) : values;
162
- const pk = (0, import_lodash.get)(data, filterTargetKey);
163
- if (appends.length && pk != null) {
164
- data = await repository.findOne({
165
- filterByTk: pk,
166
- appends
167
- });
168
- }
169
- event.push({ data, ...userInfo });
170
- }
171
- (workflow.sync ? syncGroup : asyncGroup).push(event);
172
- }
173
- for (const event of syncGroup) {
174
- await this.workflow.trigger(event[0], event[1], { httpContext: context });
175
- }
176
- for (const event of asyncGroup) {
177
- this.workflow.trigger(event[0], event[1]);
178
- }
179
- }
180
- on(workflow) {
181
- }
182
- off(workflow) {
183
- }
184
- }
@@ -1,12 +0,0 @@
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 { Plugin } from '@nocobase/server';
10
- export default class extends Plugin {
11
- load(): Promise<void>;
12
- }
@@ -1,50 +0,0 @@
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 __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var Plugin_exports = {};
38
- __export(Plugin_exports, {
39
- default: () => Plugin_default
40
- });
41
- module.exports = __toCommonJS(Plugin_exports);
42
- var import_server = require("@nocobase/server");
43
- var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
44
- var import_ActionTrigger = __toESM(require("./ActionTrigger"));
45
- class Plugin_default extends import_server.Plugin {
46
- async load() {
47
- const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
48
- workflowPlugin.triggers.register("action", new import_ActionTrigger.default(workflowPlugin));
49
- }
50
- }
@@ -1,9 +0,0 @@
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
- export { default } from './Plugin';
@@ -1,42 +0,0 @@
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 __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var server_exports = {};
38
- __export(server_exports, {
39
- default: () => import_Plugin.default
40
- });
41
- module.exports = __toCommonJS(server_exports);
42
- var import_Plugin = __toESM(require("./Plugin"));
@@ -1,14 +0,0 @@
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
- }
@@ -1,51 +0,0 @@
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 change_name_exports = {};
28
- __export(change_name_exports, {
29
- default: () => change_name_default
30
- });
31
- module.exports = __toCommonJS(change_name_exports);
32
- var import_server = require("@nocobase/server");
33
- class change_name_default extends import_server.Migration {
34
- appVersion = "<0.20.0-alpha.7";
35
- on = "afterSync";
36
- async up() {
37
- const { db } = this.context;
38
- const WorkflowRepo = db.getRepository("workflows");
39
- await db.sequelize.transaction(async (transaction) => {
40
- await WorkflowRepo.update({
41
- filter: {
42
- type: "form"
43
- },
44
- values: {
45
- type: "action"
46
- },
47
- transaction
48
- });
49
- });
50
- }
51
- }
@@ -1,14 +0,0 @@
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
- }
@@ -1,71 +0,0 @@
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
- }