@nocobase/plugin-workflow-notification 2.1.0-alpha.13 → 2.1.0-alpha.15

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.
@@ -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("react-i18next"),require("@nocobase/client"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-notification",["react","react-i18next","@nocobase/client","@nocobase/plugin-notification-manager/client","@ant-design/icons","@nocobase/plugin-workflow/client"],e):"object"==typeof exports?exports["@nocobase/plugin-workflow-notification"]=e(require("react"),require("react-i18next"),require("@nocobase/client"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):t["@nocobase/plugin-workflow-notification"]=e(t.react,t["react-i18next"],t["@nocobase/client"],t["@nocobase/plugin-notification-manager/client"],t["@ant-design/icons"],t["@nocobase/plugin-workflow/client"])}(self,function(t,e,n,o,r,i){return function(){"use strict";var c={375:function(t){t.exports=r},342:function(t){t.exports=n},486:function(t){t.exports=o},990:function(t){t.exports=i},155:function(e){e.exports=t},953:function(t){t.exports=e}},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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.g.importScripts&&(l=a.g.location+"");var l,f=a.g.document;if(!l&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(l=f.currentScript.src),!l)){var s=f.getElementsByTagName("script");if(s.length)for(var p=s.length-1;p>-1&&(!l||!/^http(s?):/.test(l));)l=s[p--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");a.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var b={},y=window.__nocobase_public_path__||"";if(!y&&window.location&&window.location.pathname){var d=window.location.pathname||"/",h=d.indexOf("/v2/");y=h>=0?d.slice(0,h+1):"/"}return y&&(y=y.replace(/\/v2\/?$/,"/")),y||(y="/"),"/"!==y.charAt(y.length-1)&&(y+="/"),a.p=y+"static/plugins/@nocobase/plugin-workflow-notification/dist/client/",!function(){a.r(b),a.d(b,{default:function(){return _}});var t=a(342),e=a(155),n=a.n(e),o=a(375),r=a(990),i=a(486);a(953);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 f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(s=function(){return!!t})()}var p=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)&&"u">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,s()?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:p}),u(t,"testable",!0),t}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(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 h(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 v(t,e,n){return(v=O()?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 v(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 O(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(O=function(){return!!t})()}function x(t,e){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:a(0)}),u(c,"throw",{value:a(1)}),u(c,"return",{value:a(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function a(u){return function(a){var l=[u,a];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=e.call(t,i)}catch(t){l=[6,t],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var _=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)&&"u">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,O()?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 h(function(){return x(this,function(t){return[2]})})()}},{key:"beforeLoad",value:function(){return h(function(){return x(this,function(t){return[2]})})()}},{key:"load",value:function(){return h(function(){return x(this,function(t){return this.app.pm.get("workflow").registerInstruction("notification",y),[2]})}).call(this)}}],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))}(),b}()});
10
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-i18next"),require("@nocobase/client"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-notification",["react","react-i18next","@nocobase/client","@nocobase/plugin-notification-manager/client","@ant-design/icons","@nocobase/plugin-workflow/client"],e):"object"==typeof exports?exports["@nocobase/plugin-workflow-notification"]=e(require("react"),require("react-i18next"),require("@nocobase/client"),require("@nocobase/plugin-notification-manager/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):t["@nocobase/plugin-workflow-notification"]=e(t.react,t["react-i18next"],t["@nocobase/client"],t["@nocobase/plugin-notification-manager/client"],t["@ant-design/icons"],t["@nocobase/plugin-workflow/client"])}(self,function(t,e,n,o,r,i){return function(){"use strict";var c={375:function(t){t.exports=r},342:function(t){t.exports=n},486:function(t){t.exports=o},990:function(t){t.exports=i},155:function(e){e.exports=t},953:function(t){t.exports=e}},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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.r=function(t){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.g.importScripts&&(l=a.g.location+"");var l,f=a.g.document;if(!l&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(l=f.currentScript.src),!l)){var p=f.getElementsByTagName("script");if(p.length)for(var s=p.length-1;s>-1&&(!l||!/^http(s?):/.test(l));)l=p[s--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");a.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var b={};return!function(){var t="",e="u">typeof document?document.currentScript:null;if(e&&e.src&&(t=e.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!t){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),t=n+"static/plugins/@nocobase/plugin-workflow-notification/dist/client/")}if(!t){if(!(t=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var o=window.location.pathname||"/",r=o.indexOf("/v2/");t=r>=0?o.slice(0,r+1):"/"}t&&(t=t.replace(/\/v2\/?$/,"/")),t||(t="/"),"/"!==t.charAt(t.length-1)&&(t+="/"),t+="static/plugins/@nocobase/plugin-workflow-notification/dist/client/"}a.p=t}(),!function(){a.r(b),a.d(b,{default:function(){return x}});var t=a(342),e=a(155),n=a.n(e),o=a(375),r=a(990),i=a(486);a(953);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 f(t,e){return(f=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 s=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)&&"u">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:s}),u(t,"testable",!0),t}return e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(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 h(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 v(t,e,n){return(v=O()?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 v(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 O(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(O=function(){return!!t})()}function _(t,e){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:a(0)}),u(c,"throw",{value:a(1)}),u(c,"return",{value:a(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function a(u){return function(a){var l=[u,a];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){i.label=l[1];break}if(6===l[0]&&i.label<r[1]){i.label=r[1],r=l;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(l);break}r[2]&&i.ops.pop(),i.trys.pop();continue}l=e.call(t,i)}catch(t){l=[6,t],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var x=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)&&"u">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,O()?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 h(function(){return _(this,function(t){return[2]})})()}},{key:"beforeLoad",value:function(){return h(function(){return _(this,function(t){return[2]})})()}},{key:"load",value:function(){return h(function(){return _(this,function(t){return this.app.pm.get("workflow").registerInstruction("notification",y),[2]})}).call(this)}}],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))}(),b}()});
@@ -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.1.0-alpha.13",
14
- "@nocobase/plugin-notification-manager": "2.1.0-alpha.13",
15
- "@nocobase/client": "2.1.0-alpha.13",
13
+ "@nocobase/plugin-workflow": "2.1.0-alpha.15",
14
+ "@nocobase/plugin-notification-manager": "2.1.0-alpha.15",
15
+ "@nocobase/client": "2.1.0-alpha.15",
16
16
  "react-i18next": "11.18.6",
17
- "@nocobase/server": "2.1.0-alpha.13"
17
+ "@nocobase/server": "2.1.0-alpha.15"
18
18
  };
@@ -10,7 +10,19 @@ import { Processor, Instruction, FlowNodeModel } from '@nocobase/plugin-workflow
10
10
  export default class extends Instruction {
11
11
  run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
12
12
  status: 1 | -1;
13
- result: any;
13
+ result: {
14
+ status: "success";
15
+ triggerFrom: string;
16
+ channelName: string;
17
+ receivers: import("@nocobase/plugin-notification-manager").ReceiversOptions;
18
+ queued: boolean;
19
+ } | {
20
+ status: "failure";
21
+ reason: string;
22
+ triggerFrom: string;
23
+ channelName: string;
24
+ receivers: import("@nocobase/plugin-notification-manager").ReceiversOptions;
25
+ };
14
26
  } | {
15
27
  status: 1 | -2;
16
28
  result: any;
@@ -53,62 +53,22 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
53
53
  data: scope
54
54
  };
55
55
  const notificationServer = this.workflow.pm.get(import_plugin_notification_manager.default);
56
- const { workflow } = processor.execution;
57
- const sync = this.workflow.isWorkflowSync(workflow);
58
- if (sync) {
59
- try {
60
- const result = await notificationServer.send(sendParams);
61
- if (result.status === "success") {
62
- return {
63
- status: import_plugin_workflow.JOB_STATUS.RESOLVED,
64
- result
65
- };
66
- } else {
67
- return {
68
- status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
69
- result
70
- };
71
- }
72
- } catch (error) {
73
- return {
74
- status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.ERROR,
75
- result: error
76
- };
77
- }
78
- }
79
- const { id } = processor.saveJob({
80
- status: import_plugin_workflow.JOB_STATUS.PENDING,
81
- nodeId: node.id,
82
- nodeKey: node.key,
83
- upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
84
- });
85
- await processor.exit();
86
- const jobDone = { status: import_plugin_workflow.JOB_STATUS.PENDING };
87
56
  try {
88
- processor.logger.info(`notification (#${node.id}) sent, waiting for response...`);
89
- const result = await notificationServer.send(sendParams);
90
- if (result.status === "success") {
91
- processor.logger.info(`notification (#${node.id}) sent successfully.`);
92
- jobDone.status = import_plugin_workflow.JOB_STATUS.RESOLVED;
93
- jobDone.result = result;
94
- } else {
95
- processor.logger.info(`notification (#${node.id}) sent failed.`);
96
- jobDone.status = ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED;
97
- jobDone.result = result;
98
- }
99
- } catch (error) {
100
- processor.logger.warn(`notification (#${node.id}) sent failed: ${error.message}`);
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
106
- });
107
- job.set(jobDone);
108
- processor.logger.debug(`notification (#${node.id}) sending ended, resume workflow...`);
109
- setImmediate(() => {
110
- this.workflow.resume(job);
57
+ processor.logger.info(`notification (#${node.id}) queued for delivery.`);
58
+ const result = await notificationServer.send({
59
+ ...sendParams,
60
+ transaction: processor.mainTransaction
111
61
  });
62
+ return {
63
+ status: result.status === "success" || ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
64
+ result
65
+ };
66
+ } catch (error) {
67
+ processor.logger.warn(`notification (#${node.id}) queue failed: ${error.message}`);
68
+ return {
69
+ status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.ERROR,
70
+ result: error
71
+ };
112
72
  }
113
73
  }
114
74
  async resume(node, job, processor) {
@@ -123,7 +83,7 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
123
83
  };
124
84
  const notificationServer = this.workflow.pm.get(import_plugin_notification_manager.default);
125
85
  try {
126
- const result = await notificationServer.send(sendParams);
86
+ const result = await notificationServer.sendNow(sendParams);
127
87
  if (result.status === "success") {
128
88
  return {
129
89
  status: import_plugin_workflow.JOB_STATUS.RESOLVED,
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Send notification in workflow.",
7
7
  "description.ru-RU": "Отправляет уведомления в рамках рабочего процесса.",
8
8
  "description.zh-CN": "可用于在工作流中发送各类通知。",
9
- "version": "2.1.0-alpha.13",
9
+ "version": "2.1.0-alpha.15",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-smtp-mailer",
@@ -19,6 +19,7 @@
19
19
  "peerDependencies": {
20
20
  "@nocobase/client": "2.x",
21
21
  "@nocobase/database": "2.x",
22
+ "@nocobase/plugin-notification-manager": "2.x",
22
23
  "@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
23
24
  "@nocobase/server": "2.x",
24
25
  "@nocobase/test": "2.x"
@@ -26,5 +27,5 @@
26
27
  "keywords": [
27
28
  "Workflow"
28
29
  ],
29
- "gitHead": "2807a8948412d9c235115a31a81a66f7c82dd173"
30
+ "gitHead": "7c86e75b0af4b9f532c8ebf5ef96a7423b0ab60e"
30
31
  }