@nocobase/plugin-workflow-notification 2.0.0-alpha.4 → 2.0.0-alpha.41
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/dist/client/NotificationInstruction.d.ts +6 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +4 -4
- package/dist/locale/zh-CN.json +2 -1
- package/dist/server/NotificationInstruction.d.ts +7 -1
- package/dist/server/NotificationInstruction.js +23 -22
- package/package.json +2 -2
|
@@ -19,6 +19,12 @@ export default class extends Instruction {
|
|
|
19
19
|
type: string;
|
|
20
20
|
'x-component': string;
|
|
21
21
|
};
|
|
22
|
+
ignoreFail: {
|
|
23
|
+
type: string;
|
|
24
|
+
'x-content': string;
|
|
25
|
+
'x-decorator': string;
|
|
26
|
+
'x-component': string;
|
|
27
|
+
};
|
|
22
28
|
};
|
|
23
29
|
components: {
|
|
24
30
|
LocalProvider: () => React.JSX.Element;
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-notification",["react","@nocobase/plugin-notification-manager/client","@ant-design/icons","@nocobase/client","@nocobase/plugin-workflow/client","react-i18next"],e):"object"==typeof exports?exports["@nocobase/plugin-workflow-notification"]=e(require("react"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):t["@nocobase/plugin-workflow-notification"]=e(t.react,t["@nocobase/plugin-notification-manager/client"],t["@ant-design/icons"],t["@nocobase/client"],t["@nocobase/plugin-workflow/client"],t["react-i18next"])}(self,function(t,e,n,o,r,i){return function(){"use strict";var c={482:function(t){t.exports=n},772:function(t){t.exports=o},786:function(t){t.exports=e},433:function(t){t.exports=r},156:function(e){e.exports=t},238:function(t){t.exports=i}},u={};function a(t){var e=u[t];if(void 0!==e)return e.exports;var n=u[t]={exports:{}};return c[t](n,n.exports,a),n.exports}a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,{a:e}),e},a.d=function(t,e){for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var f={};return!function(){a.r(f),a.d(f,{default:function(){return j}});var t=a(772),e=a(156),n=a.n(e),o=a(482),r=a(433),i=a(786);a(238);var c="workflow-notification";function u(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(p=function(){return!!t})()}var b=function(){var t=(0,r.useWorkflowVariableOptions)();return n().createElement(i.MessageConfigForm,{variableOptions:t})},y=function(t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function e(){var t,r,i;if(!(this instanceof e))throw TypeError("Cannot call a class as a function");return r=e,i=arguments,r=l(r),u(t=function(t,e){var n;if(e&&("object"==((n=e)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,p()?Reflect.construct(r,i||[],l(this).constructor):r.apply(this,i)),"title",'{{t("Notification", { ns: "'.concat(c,'" })}}')),u(t,"type","notification"),u(t,"group","extended"),u(t,"description",'{{t("Send notification. You can use the variables in the upstream nodes as content and ohter config.", { ns: "'.concat(c,'" })}}')),u(t,"icon",n().createElement(o.NotificationOutlined,null)),u(t,"fieldset",{message:{type:"void","x-component":"LocalProvider"}}),u(t,"components",{LocalProvider:b}),u(t,"testable",!0),t}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t),e}(r.Instruction);function d(t,e,n,o,r,i,c){try{var u=t[i](c),a=u.value}catch(t){n(t);return}u.done?e(a):Promise.resolve(a).then(o,r)}function v(t){return function(){var e=this,n=arguments;return new Promise(function(o,r){var i=t.apply(e,n);function c(t){d(i,o,r,c,u,"next",t)}function u(t){d(i,o,r,c,u,"throw",t)}c(void 0)})}}function h(t,e,n){return(h=
|
|
10
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-notification",["react","@nocobase/plugin-notification-manager/client","@ant-design/icons","@nocobase/client","@nocobase/plugin-workflow/client","react-i18next"],e):"object"==typeof exports?exports["@nocobase/plugin-workflow-notification"]=e(require("react"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):t["@nocobase/plugin-workflow-notification"]=e(t.react,t["@nocobase/plugin-notification-manager/client"],t["@ant-design/icons"],t["@nocobase/client"],t["@nocobase/plugin-workflow/client"],t["react-i18next"])}(self,function(t,e,n,o,r,i){return function(){"use strict";var c={482:function(t){t.exports=n},772:function(t){t.exports=o},786:function(t){t.exports=e},433:function(t){t.exports=r},156:function(e){e.exports=t},238:function(t){t.exports=i}},u={};function a(t){var e=u[t];if(void 0!==e)return e.exports;var n=u[t]={exports:{}};return c[t](n,n.exports,a),n.exports}a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,{a:e}),e},a.d=function(t,e){for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var f={};return!function(){a.r(f),a.d(f,{default:function(){return j}});var t=a(772),e=a(156),n=a.n(e),o=a(482),r=a(433),i=a(786);a(238);var c="workflow-notification";function u(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(p=function(){return!!t})()}var b=function(){var t=(0,r.useWorkflowVariableOptions)();return n().createElement(i.MessageConfigForm,{variableOptions:t})},y=function(t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function e(){var t,r,i;if(!(this instanceof e))throw TypeError("Cannot call a class as a function");return r=e,i=arguments,r=l(r),u(t=function(t,e){var n;if(e&&("object"==((n=e)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,p()?Reflect.construct(r,i||[],l(this).constructor):r.apply(this,i)),"title",'{{t("Notification", { ns: "'.concat(c,'" })}}')),u(t,"type","notification"),u(t,"group","extended"),u(t,"description",'{{t("Send notification. You can use the variables in the upstream nodes as content and ohter config.", { ns: "'.concat(c,'" })}}')),u(t,"icon",n().createElement(o.NotificationOutlined,null)),u(t,"fieldset",{message:{type:"void","x-component":"LocalProvider"},ignoreFail:{type:"boolean","x-content":'{{t("Ignore failure and continue workflow", { ns: "'.concat(c,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox"}}),u(t,"components",{LocalProvider:b}),u(t,"testable",!0),t}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t),e}(r.Instruction);function d(t,e,n,o,r,i,c){try{var u=t[i](c),a=u.value}catch(t){n(t);return}u.done?e(a):Promise.resolve(a).then(o,r)}function v(t){return function(){var e=this,n=arguments;return new Promise(function(o,r){var i=t.apply(e,n);function c(t){d(i,o,r,c,u,"next",t)}function u(t){d(i,o,r,c,u,"throw",t)}c(void 0)})}}function h(t,e,n){return(h=x()?Reflect.construct:function(t,e,n){var o=[null];o.push.apply(o,e);var r=new(Function.bind.apply(t,o));return n&&w(r,n.prototype),r}).apply(null,arguments)}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function w(t,e){return(w=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function m(t){var e="function"==typeof Map?new Map:void 0;return(m=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return h(t,arguments,g(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),w(n,t)})(t)}function x(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(x=function(){return!!t})()}function O(t,e){var n,o,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var a=[i,u];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,o=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){c.label=a[1];break}if(6===a[0]&&c.label<r[1]){c.label=r[1],r=a;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(a);break}r[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}var j=function(t){var e;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,e;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,e=arguments,t=g(t),function(t,e){var n;if(e&&("object"==((n=e)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof e))return e;if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(this,x()?Reflect.construct(t,e||[],g(this).constructor):t.apply(this,e))}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&w(n,t),e=[{key:"afterAdd",value:function(){return v(function(){return O(this,function(t){return[2]})})()}},{key:"beforeLoad",value:function(){return v(function(){return O(this,function(t){return[2]})})()}},{key:"load",value:function(){var t=this;return v(function(){return O(this,function(e){return t.app.pm.get("workflow").registerInstruction("notification",y),[2]})})()}}],function(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}(n.prototype,e),n}(m(t.Plugin))}(),f}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"@ant-design/icons": "5.6.1",
|
|
13
|
-
"@nocobase/plugin-workflow": "2.0.0-alpha.
|
|
14
|
-
"@nocobase/plugin-notification-manager": "2.0.0-alpha.
|
|
15
|
-
"@nocobase/client": "2.0.0-alpha.
|
|
13
|
+
"@nocobase/plugin-workflow": "2.0.0-alpha.41",
|
|
14
|
+
"@nocobase/plugin-notification-manager": "2.0.0-alpha.41",
|
|
15
|
+
"@nocobase/client": "2.0.0-alpha.41",
|
|
16
16
|
"react-i18next": "11.18.6",
|
|
17
|
-
"@nocobase/server": "2.0.0-alpha.
|
|
17
|
+
"@nocobase/server": "2.0.0-alpha.41"
|
|
18
18
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"Notification": "通知",
|
|
3
|
-
"Send notification. You can use the variables in the upstream nodes as content and ohter config.": "发送通知。您可以使用上游节点中的变量作为通知的内容和其他配置。"
|
|
3
|
+
"Send notification. You can use the variables in the upstream nodes as content and ohter config.": "发送通知。您可以使用上游节点中的变量作为通知的内容和其他配置。",
|
|
4
|
+
"Ignore failure and continue workflow": "忽略失败并继续工作流"
|
|
4
5
|
}
|
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Processor, Instruction, FlowNodeModel } from '@nocobase/plugin-workflow';
|
|
10
10
|
export default class extends Instruction {
|
|
11
|
-
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<
|
|
11
|
+
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
|
|
12
|
+
status: 1 | -1;
|
|
13
|
+
result: any;
|
|
14
|
+
} | {
|
|
15
|
+
status: 1 | -2;
|
|
16
|
+
result: any;
|
|
17
|
+
}>;
|
|
12
18
|
resume(node: FlowNodeModel, job: any, processor: Processor): Promise<any>;
|
|
13
19
|
test(config: any): Promise<{
|
|
14
20
|
status: 1;
|
|
@@ -43,11 +43,12 @@ var import_plugin_notification_manager = __toESM(require("@nocobase/plugin-notif
|
|
|
43
43
|
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
44
44
|
class NotificationInstruction_default extends import_plugin_workflow.Instruction {
|
|
45
45
|
async run(node, prevJob, processor) {
|
|
46
|
-
const
|
|
46
|
+
const { ignoreFail, ...config } = node.config;
|
|
47
|
+
const options = processor.getParsedValue(config, node.id);
|
|
47
48
|
const scope = processor.getScope(node.id);
|
|
48
49
|
const sendParams = {
|
|
49
50
|
channelName: options.channelName,
|
|
50
|
-
message: { ...options, content:
|
|
51
|
+
message: { ...options, content: config.content },
|
|
51
52
|
triggerFrom: "workflow",
|
|
52
53
|
data: scope
|
|
53
54
|
};
|
|
@@ -64,51 +65,51 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
|
|
|
64
65
|
};
|
|
65
66
|
} else {
|
|
66
67
|
return {
|
|
67
|
-
status: import_plugin_workflow.JOB_STATUS.FAILED,
|
|
68
|
+
status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
|
|
68
69
|
result
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
} catch (error) {
|
|
72
73
|
return {
|
|
73
|
-
status: import_plugin_workflow.JOB_STATUS.
|
|
74
|
+
status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.ERROR,
|
|
74
75
|
result: error
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
const
|
|
79
|
+
const { id } = processor.saveJob({
|
|
79
80
|
status: import_plugin_workflow.JOB_STATUS.PENDING,
|
|
80
81
|
nodeId: node.id,
|
|
81
82
|
nodeKey: node.key,
|
|
82
83
|
upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
|
|
83
84
|
});
|
|
84
|
-
|
|
85
|
+
await processor.exit();
|
|
86
|
+
const jobDone = { status: import_plugin_workflow.JOB_STATUS.PENDING };
|
|
87
|
+
try {
|
|
88
|
+
processor.logger.info(`notification (#${node.id}) sent, waiting for response...`);
|
|
89
|
+
const result = await notificationServer.send(sendParams);
|
|
85
90
|
if (result.status === "success") {
|
|
86
91
|
processor.logger.info(`notification (#${node.id}) sent successfully.`);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
result
|
|
90
|
-
});
|
|
92
|
+
jobDone.status = import_plugin_workflow.JOB_STATUS.RESOLVED;
|
|
93
|
+
jobDone.result = result;
|
|
91
94
|
} else {
|
|
92
95
|
processor.logger.info(`notification (#${node.id}) sent failed.`);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
result
|
|
96
|
-
});
|
|
96
|
+
jobDone.status = ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED;
|
|
97
|
+
jobDone.result = result;
|
|
97
98
|
}
|
|
98
|
-
}
|
|
99
|
+
} catch (error) {
|
|
99
100
|
processor.logger.warn(`notification (#${node.id}) sent failed: ${error.message}`);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
jobDone.status = ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED;
|
|
102
|
+
jobDone.result = error;
|
|
103
|
+
} finally {
|
|
104
|
+
const job = await this.workflow.app.db.getRepository("jobs").findOne({
|
|
105
|
+
filterByTk: id
|
|
103
106
|
});
|
|
104
|
-
|
|
107
|
+
job.set(jobDone);
|
|
105
108
|
processor.logger.debug(`notification (#${node.id}) sending ended, resume workflow...`);
|
|
106
109
|
setImmediate(() => {
|
|
107
110
|
this.workflow.resume(job);
|
|
108
111
|
});
|
|
109
|
-
}
|
|
110
|
-
processor.logger.info(`notification (#${node.id}) sent, waiting for response...`);
|
|
111
|
-
return processor.exit();
|
|
112
|
+
}
|
|
112
113
|
}
|
|
113
114
|
async resume(node, job, processor) {
|
|
114
115
|
return job;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:通知节点",
|
|
5
5
|
"description": "Send notification in workflow.",
|
|
6
6
|
"description.zh-CN": "可用于在工作流中发送各类通知。",
|
|
7
|
-
"version": "2.0.0-alpha.
|
|
7
|
+
"version": "2.0.0-alpha.41",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow-smtp-mailer",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"keywords": [
|
|
24
24
|
"Workflow"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "889e81eef0280c2e45571bd0a4b2db6aa004f8c1"
|
|
27
27
|
}
|