@nocobase/plugin-workflow-sql 2.2.0-alpha.1 → 2.2.0-alpha.2

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/client-v2.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client-v2';
2
+ export { default } from './dist/client-v2';
package/client-v2.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client-v2/index.js');
@@ -0,0 +1,10 @@
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
+ "use strict";(self.webpackChunk_nocobase_plugin_workflow_sql=self.webpackChunk_nocobase_plugin_workflow_sql||[]).push([["241"],{624:function(e,t,n){n.d(t,{SQLFieldset:function(){return j}});var r=n(155),a=n.n(r),o=n(59),l=n(375),c=n(197),u=n(953),i=n(694),s=n(401);function f(){var e=(0,i.useFlowEngine)();return function(t,n){return e.context.t(t,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[s.C,"workflow","client"],nsMode:"fallback"},n))}}var m=n(625),p=n(485);function b(e){var t,n,r,l,c,u=(0,i.useFlowContext)(),s=(0,m.useRequest)(function(){var e,t,n;return null!=(e=null==(n=u.dataSourceManager)||null==(t=n.ensureLoaded)?void 0:t.call(n,{keys:["*"]}))?e:Promise.resolve()},{ready:!!u.dataSourceManager}).loading,f=(null!=(r=null==(c=u.dataSourceManager)||null==(l=c.getDataSources)?void 0:l.call(c))?r:[]).filter(function(e){var t;return(null==(t=e.options)?void 0:t.isDBInstance)||e.key===p.DEFAULT_DATA_SOURCE_KEY}).map(function(e){return{label:e.displayName||e.key,value:e.key}});return a().createElement(o.Select,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),n=n={loading:s||e.loading,options:f},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}function d(e){var t,n=null!=(t=e.paths)?t:[];return n.length?"{{".concat(n.join("."),"}}"):""}function y(e){var t=e.unsafeInjection,n=e.value,l=e.onChange,u=e.disabled,i=e.placeholder,s=o.theme.useToken().token,f=(0,c.useWorkflowVariableOptions)(),m=(0,r.useMemo)(function(){return function(){return f}},[f]),b=(0,r.useMemo)(function(){return{fontFamily:s.fontFamilyCode}},[s.fontFamilyCode]);return t?a().createElement(p.TextAreaWithContextSelector,{value:n,onChange:l,disabled:u,placeholder:i,rows:20,maxRows:20,style:b,metaTree:m,formatPathToValue:d}):a().createElement(o.Input.TextArea,{value:n,disabled:u,placeholder:i,rows:20,style:b,onChange:function(e){return null==l?void 0:l(e.target.value)}})}var g=n(768);function v(){var e=f(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","unsafeInjection"],t);return(null!=n?n:t.getFieldValue(["config","unsafeInjection"]))?a().createElement(o.Alert,{type:"error",showIcon:!0,message:e("Current node is using unsafe injection mode (legacy), which has SQL injection risks."),action:a().createElement(o.Button,{size:"small",type:"primary",onClick:function(){var e,n,r,a,o,l,c,u=t.getFieldValue("config");t.setFieldValue("config",(e=u.sql||"",r=Array.from(new Set(((n=(0,g.parse)(e)).parameters||[]).map(function(e){return e.key}).filter(function(e){return!!e}))),a={},r.forEach(function(e,t){var n=e.split(".").filter(Boolean);if(n.length){var r=a;n.slice(0,-1).forEach(function(e){var t=r[e];(!t||(void 0===t?"undefined":t&&"u">typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)!="object"||Array.isArray(t))&&(r[e]={}),r=r[e]}),r[n[n.length-1]]=":var".concat(t)}}),o=r.map(function(e,t){return{name:"var".concat(t),value:"{{".concat(e,"}}")}}),l=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},u),c=c={sql:n(a),variables:o,unsafeInjection:!1},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(c)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(c)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(c,e))}),l))}},e("Migrate to safe mode"))}):null}function O(){return a().createElement(u.Trans,{ns:s.C},"SQL query result could be used through ",a().createElement("a",{href:"https://docs-cn.nocobase.com/handbook/workflow-json-query",target:"_blank",rel:"noreferrer"},"JSON query node"),".")}function h(){var e=f(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","unsafeInjection"],t);return(null!=n?n:t.getFieldValue(["config","unsafeInjection"]))?null:a().createElement(o.Form.Item,{label:e("Parameters"),extra:e("SQL parameters. Use :name as placeholders in SQL and provide values here.")},a().createElement(o.Form.List,{name:["config","variables"]},function(t,n){var r=n.add,u=n.remove;return a().createElement(o.Flex,{vertical:!0,gap:"small"},t.map(function(t){return a().createElement(o.Flex,{key:t.key,gap:"small",align:"baseline"},a().createElement(o.Form.Item,{name:[t.name,"name"],rules:[{required:!0,message:e("Name")}],validateTrigger:["onBlur","onSubmit"],style:{flex:"1 1 0"}},a().createElement(o.Input,{placeholder:e("Name")})),a().createElement(o.Form.Item,{name:[t.name,"value"],rules:[{required:!0,message:e("Value")}],validateTrigger:["onBlur","onSubmit"],style:{flex:"2 1 0"}},a().createElement(c.WorkflowVariableInput,{placeholder:e("Value"),style:{width:"100%"}})),a().createElement(o.Button,{type:"text",icon:a().createElement(l.MinusCircleOutlined,null),"aria-label":e("Remove parameter"),onClick:function(){return u(t.name)}}))}),a().createElement(o.Button,{block:!0,type:"dashed",icon:a().createElement(l.PlusOutlined,null),onClick:function(){return r()}},e("Add parameter")))}))}function j(){var e=f(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","unsafeInjection"],t),l=null!=n?n:t.getFieldValue(["config","unsafeInjection"]);return(0,r.useEffect)(function(){void 0===t.getFieldValue(["config","dataSource"])&&t.setFieldValue(["config","dataSource"],"main")},[t]),a().createElement(a().Fragment,null,a().createElement(o.Form.Item,{name:["config","dataSource"],label:e("Data source"),extra:e("Select a data source to execute SQL."),rules:[{required:!0,message:e("Data source")}]},a().createElement(b,null)),a().createElement(o.Form.Item,{noStyle:!0,shouldUpdate:!0},function(){return a().createElement(v,null)}),a().createElement(o.Form.Item,{name:["config","sql"],label:"SQL",extra:a().createElement(O,null),rules:[{required:!0}]},a().createElement(y,{unsafeInjection:l})),a().createElement(h,null),a().createElement(o.Form.Item,{name:["config","withMeta"],valuePropName:"checked"},a().createElement(o.Checkbox,null,e("Include meta information of this query in result"))))}}}]);
@@ -6,140 +6,6 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { Instruction, WorkflowVariableInput } from '@nocobase/plugin-workflow/client';
10
- import React from 'react';
11
- declare function SQLTextArea(props: any): React.JSX.Element;
12
- declare function UnsafeInjectionWarning(): React.JSX.Element;
13
- export default class extends Instruction {
14
- title: string;
15
- type: string;
16
- group: string;
17
- description: string;
18
- icon: React.JSX.Element;
19
- fieldset: {
20
- dataSource: {
21
- type: string;
22
- required: boolean;
23
- title: string;
24
- description: string;
25
- 'x-decorator': string;
26
- 'x-component': string;
27
- 'x-component-props': {
28
- className: string;
29
- filter(item: any): any;
30
- };
31
- default: string;
32
- };
33
- unsafeInjection: {
34
- type: string;
35
- 'x-component': string;
36
- };
37
- sql: {
38
- type: string;
39
- required: boolean;
40
- title: string;
41
- description: string;
42
- 'x-decorator': string;
43
- 'x-component': string;
44
- 'x-component-props': {
45
- rows: number;
46
- className: string;
47
- };
48
- };
49
- variables: {
50
- type: string;
51
- title: string;
52
- description: string;
53
- 'x-decorator': string;
54
- 'x-component': string;
55
- 'x-reactions': {
56
- dependencies: string[];
57
- fulfill: {
58
- state: {
59
- visible: string;
60
- };
61
- };
62
- }[];
63
- items: {
64
- type: string;
65
- properties: {
66
- space1: {
67
- type: string;
68
- 'x-component': string;
69
- properties: {
70
- name: {
71
- type: string;
72
- 'x-decorator': string;
73
- 'x-component': string;
74
- 'x-component-props': {
75
- placeholder: string;
76
- };
77
- required: boolean;
78
- };
79
- value: {
80
- type: string;
81
- 'x-decorator': string;
82
- 'x-component': string;
83
- 'x-component-props': {
84
- rows: number;
85
- placeholder: string;
86
- };
87
- required: boolean;
88
- };
89
- remove: {
90
- type: string;
91
- 'x-decorator': string;
92
- 'x-component': string;
93
- };
94
- };
95
- };
96
- };
97
- };
98
- properties: {
99
- add: {
100
- type: string;
101
- 'x-component': string;
102
- title: string;
103
- };
104
- };
105
- };
106
- withMeta: {
107
- type: string;
108
- 'x-decorator': string;
109
- 'x-component': string;
110
- 'x-content': string;
111
- };
112
- };
113
- scope: {
114
- sqlDescription(): React.JSX.Element;
115
- };
116
- components: {
117
- SQLTextArea: typeof SQLTextArea;
118
- UnsafeInjectionWarning: typeof UnsafeInjectionWarning;
119
- WorkflowVariableInput: typeof WorkflowVariableInput;
120
- ArrayItems: import("@formily/react").ReactFC<React.HTMLAttributes<HTMLDivElement>> & import("@formily/antd-v5").ArrayBaseMixins & {
121
- Item: import("@formily/react").ReactFC<React.HTMLAttributes<HTMLDivElement> & {
122
- type?: "card" | "divide";
123
- }>;
124
- };
125
- Space: React.ForwardRefExoticComponent<import("antd").SpaceProps & React.RefAttributes<HTMLDivElement>> & {
126
- Compact: React.FC<import("antd/es/space/Compact").SpaceCompactProps>;
127
- };
128
- };
129
- useVariables({ key, title }: {
130
- key: any;
131
- title: any;
132
- }, { types, fieldNames }: {
133
- types: any;
134
- fieldNames?: {
135
- readonly label: "label";
136
- readonly value: "value";
137
- readonly children: "children";
138
- };
139
- }): {
140
- value: any;
141
- label: any;
142
- };
143
- testable: boolean;
9
+ import SQLInstruction from '../client-v2/SQLInstruction';
10
+ export default class SQLInstructionCompat extends SQLInstruction {
144
11
  }
145
- export {};
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@formily/antd-v5"),require("antd"),require("react"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-sql",["react-i18next","@formily/antd-v5","antd","react","@nocobase/client","@formily/react","@ant-design/icons","@nocobase/plugin-workflow/client","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-sql"]=t(require("react-i18next"),require("@formily/antd-v5"),require("antd"),require("react"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-workflow-sql"]=t(e["react-i18next"],e["@formily/antd-v5"],e.antd,e.react,e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/plugin-workflow/client"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,r,n,o,i,a,c,u,l){return function(){"use strict";var s={375:function(e){e.exports=a},418:function(e){e.exports=t},230:function(e){e.exports=i},342:function(e){e.exports=o},990:function(e){e.exports=c},768:function(e){e.exports=u},59:function(e){e.exports=r},773:function(e){e.exports=l},155:function(e){e.exports=n},953:function(t){t.exports=e}},f={};function p(e){var t=f[e];if(void 0!==t)return t.exports;var r=f[e]={exports:{}};return s[e](r,r.exports,p),r.exports}p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var r in t)p.o(t,r)&&!p.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(y=p.g.location+"");var y,b=p.g.document;if(!y&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(y=b.currentScript.src),!y)){var d=b.getElementsByTagName("script");if(d.length)for(var m=d.length-1;m>-1&&(!y||!/^http(s?):/.test(y));)y=d[m--].src}if(!y)throw Error("Automatic publicPath is not supported in this browser");p.p=y.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-sql/dist/client/")}if(!e){var n=window.__nocobase_modern_client_prefix__||"v",o="/"+(n=String(n).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",a=i.indexOf(o);e=a>=0?i.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+n+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-sql/dist/client/"}p.p=e}(),!function(){p.r(v),p.d(v,{default:function(){return P}});var e=p(342),t=p(418),r=p(230),n=p(59),o=p(768),i=p(773),a=p(990),c=p(155),u=p.n(c),l=p(375),s=p(953),f="@nocobase/plugin-workflow-sql";function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function w(){var e,t,r=(e=["\n font-size: 80%;\n font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return w=function(){return r},r}function g(e){return(0,r.useForm)().values.unsafeInjection?u().createElement(a.WorkflowVariableRawTextArea,e):u().createElement(n.Input.TextArea,e)}function x(){var e=(0,s.useTranslation)(f).t,t=(0,r.useForm)(),a=t.values;return!a.unsafeInjection||t.disabled?null:u().createElement(n.Alert,{type:"error",showIcon:!0,message:e("Current node is using unsafe injection mode (legacy), which has SQL injection risks."),action:u().createElement(n.Button,{size:"small",type:"primary",onClick:function(){var e,r=a.sql||"",n=(0,o.parse)(r),c=function(e){if(Array.isArray(e))return y(e)}(e=new Set((n.parameters||[]).map(function(e){return e.key}).filter(function(e){return e&&"string"==typeof e})))||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return y(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return y(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u={};c.forEach(function(e,t){(0,i.set)(u,e,":var".concat(t))});var l=c.map(function(e,t){return{name:"var".concat(t),value:"{{".concat(e,"}}")}}),s=n(u);t.setValues({sql:s,variables:l,unsafeInjection:!1})}},e("Migrate to safe mode")),style:{marginBottom:16}})}var S=function(r){var o;if("function"!=typeof r&&null!==r)throw TypeError("Super expression must either be null or a function");function i(){var r,o,c;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return o=i,c=arguments,o=d(o),b(r=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,h()?Reflect.construct(o,c||[],d(this).constructor):o.apply(this,c)),"title",'{{t("SQL action", { ns: "'.concat(f,'" })}}')),b(r,"type","sql"),b(r,"group","collection"),b(r,"description",'{{t("Execute a SQL statement in database.", { ns: "'.concat(f,'" })}}')),b(r,"icon",u().createElement(l.ConsoleSqlOutlined,{style:{}})),b(r,"fieldset",{dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:'{{t("Select a data source to execute SQL.", { ns: "'.concat(f,'" })}}'),"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter:function(t){return t.options.isDBInstance||t.key===e.DEFAULT_DATA_SOURCE_KEY}},default:"main"},unsafeInjection:{type:"void","x-component":"UnsafeInjectionWarning"},sql:{type:"string",required:!0,title:"SQL",description:"{{sqlDescription()}}","x-decorator":"FormItem","x-component":"SQLTextArea","x-component-props":{rows:20,className:(0,e.css)(w())}},variables:{type:"array",title:'{{t("Parameters", { ns: "'.concat(f,'" })}}'),description:'{{t("SQL parameters. Use :name as placeholders in SQL and provide values here.", { ns: "'.concat(f,'" })}}'),"x-decorator":"FormItem","x-component":"ArrayItems","x-reactions":[{dependencies:["unsafeInjection"],fulfill:{state:{visible:"{{!$deps[0]}}"}}}],items:{type:"object",properties:{space1:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name", { ns: "'.concat(f,'" })}}')},required:!0},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{rows:1,placeholder:'{{t("Value", { ns: "'.concat(f,'" })}}')},required:!0},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void","x-component":"ArrayItems.Addition",title:'{{t("Add parameter", { ns: "'.concat(f,'" })}}')}}},withMeta:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Include meta information of this query in result", { ns: "'.concat(f,'" })}}')}}),b(r,"scope",{sqlDescription:function(){return u().createElement(s.Trans,{ns:f},"SQL query result could be used through ",u().createElement("a",{href:"https://docs-cn.nocobase.com/handbook/workflow-json-query",target:"_blank",rel:"noreferrer"},"JSON query node"),".")}}),b(r,"components",{SQLTextArea:g,UnsafeInjectionWarning:x,WorkflowVariableInput:a.WorkflowVariableInput,ArrayItems:t.ArrayItems,Space:n.Space}),b(r,"testable",!0),r}return i.prototype=Object.create(r&&r.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),r&&m(i,r),o=[{key:"useVariables",value:function(e,t){var r,n=e.key,o=e.title,i=(t.types,t.fieldNames),c=void 0===i?a.defaultFieldNames:i;return b(r={},c.value,n),b(r,c.label,o),r}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(i.prototype,o),i}(a.Instruction);function j(e,t,r,n,o,i,a){try{var c=e[i](a),u=c.value}catch(e){r(e);return}c.done?t(u):Promise.resolve(u).then(n,o)}function _(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){j(i,n,o,a,c,"next",e)}function c(e){j(i,n,o,a,c,"throw",e)}a(void 0)})}}function q(e,t,r){return(q=A()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&k(o,r.prototype),o}).apply(null,arguments)}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){return(k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){var t="function"==typeof Map?new Map:void 0;return(I=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return q(e,arguments,O(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),k(r,e)})(e)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(A=function(){return!!e})()}function E(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:u(0)}),c(a,"throw",{value:u(1)}),c(a,"return",{value:u(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function u(c){return function(u){var l=[c,u];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var P=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=O(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,A()?Reflect.construct(e,t||[],O(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&k(r,e),t=[{key:"afterAdd",value:function(){return _(function(){return E(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return _(function(){return E(this,function(e){return[2]})})()}},{key:"load",value:function(){return _(function(){return E(this,function(e){return this.app.pm.get("workflow").registerInstruction("sql",S),[2]})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(I(e.Plugin))}(),v}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-sql",["ahooks","react-i18next","@nocobase/client-v2","react","antd","@nocobase/plugin-workflow/client-v2","@nocobase/client","@ant-design/icons","@nocobase/flow-engine","@nocobase/utils/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-sql"]=t(require("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):e["@nocobase/plugin-workflow-sql"]=t(e.ahooks,e["react-i18next"],e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@nocobase/client"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/utils/client"])}(self,function(e,t,n,r,o,i,u,c,a,l){return function(){"use strict";var f,s,p,b={401:function(e,t,n){n.d(t,{C:function(){return r},J:function(){return o}});var r="@nocobase/plugin-workflow-sql",o="sql"},375:function(e){e.exports=c},342:function(e){e.exports=u},485:function(e){e.exports=n},694:function(e){e.exports=a},197:function(e){e.exports=i},768:function(e){e.exports=l},625:function(t){t.exports=e},59:function(e){e.exports=o},155:function(e){e.exports=r},953:function(e){e.exports=t}},d={};function y(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return b[e](n,n.exports,y),n.exports}y.m=b,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+e+".e47c80d95803a13c.js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},v={},y.l=function(e,t,n,r){if(v[e])return void v[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-workflow-sql:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-rspack","@nocobase/plugin-workflow-sql:"+n),o.src=e),v[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=v[e];if(delete v[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.g.importScripts&&(h=y.g.location+"");var v,h,w=y.g.document;if(!h&&w&&(w.currentScript&&"SCRIPT"===w.currentScript.tagName.toUpperCase()&&(h=w.currentScript.src),!h)){var g=w.getElementsByTagName("script");if(g.length)for(var m=g.length-1;m>-1&&(!h||!/^http(s?):/.test(h));)h=g[m--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");y.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},y.f.j=function(e,t){var n=y.o(f,e)?f[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=f[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(f,e)&&(0!==(n=f[e])&&(f[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},s=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==f[e]})){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);u&&u(y)}for(e&&e(t);c<o.length;c++)r=o[c],y.o(f,r)&&f[r]&&f[r][0](),f[r]=0},(p=self.webpackChunk_nocobase_plugin_workflow_sql=self.webpackChunk_nocobase_plugin_workflow_sql||[]).forEach(s.bind(null,0)),p.push=s.bind(null,p.push.bind(p));var _={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-workflow-sql/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-sql/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var u=window.location.pathname||"/",c=u.indexOf(i);e=c>=0?u.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-sql/dist/client/"}y.p=e}(),!function(){y.r(_),y.d(_,{default:function(){return q}});var e=y(342),t=y(155),n=y.n(t),r=y(375),o=y(197),i=y(401);function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=function(e){return'{{t("'.concat(e,'", { ns: "').concat(i.C,'" })}}')},s={label:"label",value:"value"};function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}var v=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return e=t,n=arguments,e=p(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,d()?Reflect.construct(e,n||[],p(this).constructor):e.apply(this,n))}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e),t}(function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,t,a;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return t=o,a=arguments,t=c(t),u(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,l()?Reflect.construct(t,a||[],c(this).constructor):t.apply(this,a)),"title",f("SQL action")),u(e,"type",i.J),u(e,"group","collection"),u(e,"description",f("Execute a SQL statement in database.")),u(e,"icon",n().createElement(r.ConsoleSqlOutlined,null)),u(e,"testable",!0),u(e,"FieldsetLoader",function(){return y.e("241").then(y.bind(y,624)).then(function(e){return{default:e.SQLFieldset}})}),e}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&a(o,e),t=[{key:"createDefaultConfig",value:function(){return{dataSource:"main"}}},{key:"useVariables",value:function(e){var t,n=e.key,r=e.title,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.fieldNames,c=void 0===i?s:i;return u(t={},c.value,n),u(t,c.label,r),t}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(o.prototype,t),o}(o.Instruction));function h(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){h(i,r,o,u,c,"next",e)}function c(e){h(i,r,o,u,c,"throw",e)}u(void 0)})}}function g(e,t,n){return(g=j()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&O(o,n.prototype),o}).apply(null,arguments)}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function O(e,t){return(O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e){var t="function"==typeof Map?new Map:void 0;return(k=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return g(e,arguments,m(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),O(n,e)})(e)}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}function x(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(u,"next",{value:a(0)}),c(u,"throw",{value:a(1)}),c(u,"return",{value:a(2)}),"function"==typeof Symbol&&c(u,Symbol.iterator,{value:function(){return this}}),u;function a(c){return function(a){var l=[c,a];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var q=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=m(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,j()?Reflect.construct(e,t||[],m(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&O(n,e),t=[{key:"afterAdd",value:function(){return w(function(){return x(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return w(function(){return x(this,function(e){return[2]})})()}},{key:"load",value:function(){return w(function(){return x(this,function(e){return this.app.pm.get("workflow").registerInstruction("sql",v),[2]})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(k(e.Plugin))}(),_}()});
@@ -0,0 +1,10 @@
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
+ "use strict";(self.webpackChunk_nocobase_plugin_workflow_sql_client_v2=self.webpackChunk_nocobase_plugin_workflow_sql_client_v2||[]).push([["241"],{624:function(e,t,n){n.d(t,{SQLFieldset:function(){return j}});var r=n(155),a=n.n(r),o=n(59),l=n(375),c=n(197),u=n(953),i=n(694),s=n(401);function f(){var e=(0,i.useFlowEngine)();return function(t,n){return e.context.t(t,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[s.C,"workflow","client"],nsMode:"fallback"},n))}}var m=n(625),p=n(485);function b(e){var t,n,r,l,c,u=(0,i.useFlowContext)(),s=(0,m.useRequest)(function(){var e,t,n;return null!=(e=null==(n=u.dataSourceManager)||null==(t=n.ensureLoaded)?void 0:t.call(n,{keys:["*"]}))?e:Promise.resolve()},{ready:!!u.dataSourceManager}).loading,f=(null!=(r=null==(c=u.dataSourceManager)||null==(l=c.getDataSources)?void 0:l.call(c))?r:[]).filter(function(e){var t;return(null==(t=e.options)?void 0:t.isDBInstance)||e.key===p.DEFAULT_DATA_SOURCE_KEY}).map(function(e){return{label:e.displayName||e.key,value:e.key}});return a().createElement(o.Select,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),n=n={loading:s||e.loading,options:f},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}function d(e){var t,n=null!=(t=e.paths)?t:[];return n.length?"{{".concat(n.join("."),"}}"):""}function y(e){var t=e.unsafeInjection,n=e.value,l=e.onChange,u=e.disabled,i=e.placeholder,s=o.theme.useToken().token,f=(0,c.useWorkflowVariableOptions)(),m=(0,r.useMemo)(function(){return function(){return f}},[f]),b=(0,r.useMemo)(function(){return{fontFamily:s.fontFamilyCode}},[s.fontFamilyCode]);return t?a().createElement(p.TextAreaWithContextSelector,{value:n,onChange:l,disabled:u,placeholder:i,rows:20,maxRows:20,style:b,metaTree:m,formatPathToValue:d}):a().createElement(o.Input.TextArea,{value:n,disabled:u,placeholder:i,rows:20,style:b,onChange:function(e){return null==l?void 0:l(e.target.value)}})}var g=n(768);function v(){var e=f(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","unsafeInjection"],t);return(null!=n?n:t.getFieldValue(["config","unsafeInjection"]))?a().createElement(o.Alert,{type:"error",showIcon:!0,message:e("Current node is using unsafe injection mode (legacy), which has SQL injection risks."),action:a().createElement(o.Button,{size:"small",type:"primary",onClick:function(){var e,n,r,a,o,l,c,u=t.getFieldValue("config");t.setFieldValue("config",(e=u.sql||"",r=Array.from(new Set(((n=(0,g.parse)(e)).parameters||[]).map(function(e){return e.key}).filter(function(e){return!!e}))),a={},r.forEach(function(e,t){var n=e.split(".").filter(Boolean);if(n.length){var r=a;n.slice(0,-1).forEach(function(e){var t=r[e];(!t||(void 0===t?"undefined":t&&"u">typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)!="object"||Array.isArray(t))&&(r[e]={}),r=r[e]}),r[n[n.length-1]]=":var".concat(t)}}),o=r.map(function(e,t){return{name:"var".concat(t),value:"{{".concat(e,"}}")}}),l=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},u),c=c={sql:n(a),variables:o,unsafeInjection:!1},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(c)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(c)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(c,e))}),l))}},e("Migrate to safe mode"))}):null}function O(){return a().createElement(u.Trans,{ns:s.C},"SQL query result could be used through ",a().createElement("a",{href:"https://docs-cn.nocobase.com/handbook/workflow-json-query",target:"_blank",rel:"noreferrer"},"JSON query node"),".")}function h(){var e=f(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","unsafeInjection"],t);return(null!=n?n:t.getFieldValue(["config","unsafeInjection"]))?null:a().createElement(o.Form.Item,{label:e("Parameters"),extra:e("SQL parameters. Use :name as placeholders in SQL and provide values here.")},a().createElement(o.Form.List,{name:["config","variables"]},function(t,n){var r=n.add,u=n.remove;return a().createElement(o.Flex,{vertical:!0,gap:"small"},t.map(function(t){return a().createElement(o.Flex,{key:t.key,gap:"small",align:"baseline"},a().createElement(o.Form.Item,{name:[t.name,"name"],rules:[{required:!0,message:e("Name")}],validateTrigger:["onBlur","onSubmit"],style:{flex:"1 1 0"}},a().createElement(o.Input,{placeholder:e("Name")})),a().createElement(o.Form.Item,{name:[t.name,"value"],rules:[{required:!0,message:e("Value")}],validateTrigger:["onBlur","onSubmit"],style:{flex:"2 1 0"}},a().createElement(c.WorkflowVariableInput,{placeholder:e("Value"),style:{width:"100%"}})),a().createElement(o.Button,{type:"text",icon:a().createElement(l.MinusCircleOutlined,null),"aria-label":e("Remove parameter"),onClick:function(){return u(t.name)}}))}),a().createElement(o.Button,{block:!0,type:"dashed",icon:a().createElement(l.PlusOutlined,null),onClick:function(){return r()}},e("Add parameter")))}))}function j(){var e=f(),t=o.Form.useFormInstance(),n=o.Form.useWatch(["config","unsafeInjection"],t),l=null!=n?n:t.getFieldValue(["config","unsafeInjection"]);return(0,r.useEffect)(function(){void 0===t.getFieldValue(["config","dataSource"])&&t.setFieldValue(["config","dataSource"],"main")},[t]),a().createElement(a().Fragment,null,a().createElement(o.Form.Item,{name:["config","dataSource"],label:e("Data source"),extra:e("Select a data source to execute SQL."),rules:[{required:!0,message:e("Data source")}]},a().createElement(b,null)),a().createElement(o.Form.Item,{noStyle:!0,shouldUpdate:!0},function(){return a().createElement(v,null)}),a().createElement(o.Form.Item,{name:["config","sql"],label:"SQL",extra:a().createElement(O,null),rules:[{required:!0}]},a().createElement(y,{unsafeInjection:l})),a().createElement(h,null),a().createElement(o.Form.Item,{name:["config","withMeta"],valuePropName:"checked"},a().createElement(o.Checkbox,null,e("Include meta information of this query in result"))))}}}]);
@@ -0,0 +1,34 @@
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 React from 'react';
10
+ import { Instruction, type LoaderOf } from '@nocobase/plugin-workflow/client-v2';
11
+ export default class SQLInstruction extends Instruction {
12
+ title: string;
13
+ type: string;
14
+ group: string;
15
+ description: string;
16
+ icon: React.JSX.Element;
17
+ testable: boolean;
18
+ FieldsetLoader: LoaderOf;
19
+ createDefaultConfig(): {
20
+ dataSource: string;
21
+ };
22
+ useVariables({ key, title }: {
23
+ key: string;
24
+ title?: string;
25
+ }, { fieldNames }?: {
26
+ fieldNames?: {
27
+ readonly label: "label";
28
+ readonly value: "value";
29
+ };
30
+ }): {
31
+ value: string;
32
+ label: string;
33
+ };
34
+ }
@@ -0,0 +1,11 @@
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 React from 'react';
10
+ export declare function SQLFieldset(): React.JSX.Element;
11
+ export default SQLFieldset;
@@ -0,0 +1,11 @@
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 React from 'react';
10
+ import type { SelectProps } from 'antd';
11
+ export declare function SqlDataSourceSelect(props: SelectProps<string>): React.JSX.Element;
@@ -0,0 +1,18 @@
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 React from 'react';
10
+ type SqlEditorProps = {
11
+ value?: string;
12
+ onChange?: (value: string) => void;
13
+ disabled?: boolean;
14
+ placeholder?: string;
15
+ unsafeInjection?: boolean;
16
+ };
17
+ export declare function SqlEditor(props: SqlEditorProps): React.JSX.Element;
18
+ export {};
@@ -0,0 +1,10 @@
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 React from 'react';
10
+ export declare function UnsafeInjectionWarning(): React.JSX.Element;
@@ -0,0 +1,10 @@
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 = "@nocobase/plugin-workflow-sql";
10
+ export declare const SQL_INSTRUCTION_TYPE = "sql";
@@ -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 { Plugin } from '@nocobase/client-v2';
10
+ import SQLInstruction from './SQLInstruction';
11
+ export default class PluginWorkflowSQLClientV2 extends Plugin {
12
+ load(): Promise<void>;
13
+ }
14
+ export { SQLInstruction };
@@ -0,0 +1,10 @@
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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-sql/client-v2",["ahooks","react-i18next","@nocobase/client-v2","react","antd","@nocobase/plugin-workflow/client-v2","@ant-design/icons","@nocobase/flow-engine","@nocobase/utils/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-sql/client-v2"]=t(require("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/plugin-workflow/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):e["@nocobase/plugin-workflow-sql/client-v2"]=t(e.ahooks,e["react-i18next"],e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/plugin-workflow/client-v2"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/utils/client"])}(self,function(e,t,n,r,o,i,c,u,a){return function(){"use strict";var l,f,s,p={401:function(e,t,n){n.d(t,{C:function(){return r},J:function(){return o}});var r="@nocobase/plugin-workflow-sql",o="sql"},375:function(e){e.exports=c},485:function(e){e.exports=n},694:function(e){e.exports=u},197:function(e){e.exports=i},768:function(e){e.exports=a},625:function(t){t.exports=e},59:function(e){e.exports=o},155:function(e){e.exports=r},953:function(e){e.exports=t}},b={};function d(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return p[e](n,n.exports,d),n.exports}d.m=p,d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.f={},d.e=function(e){return Promise.all(Object.keys(d.f).reduce(function(t,n){return d.f[n](e,t),t},[]))},d.u=function(e){return""+e+".59422f75a3a57aa5.js"},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},v={},d.l=function(e,t,n,r){if(v[e])return void v[e].push(t);if(void 0!==n)for(var o,i,c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var a=c[u];if(a.getAttribute("src")==e||a.getAttribute("data-rspack")=="@nocobase/plugin-workflow-sql/client-v2:"+n){o=a;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,d.nc&&o.setAttribute("nonce",d.nc),o.setAttribute("data-rspack","@nocobase/plugin-workflow-sql/client-v2:"+n),o.src=e),v[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=v[e];if(delete v[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},d.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.g.importScripts&&(y=d.g.location+"");var v,y,h=d.g.document;if(!y&&h&&(h.currentScript&&"SCRIPT"===h.currentScript.tagName.toUpperCase()&&(y=h.currentScript.src),!y)){var g=h.getElementsByTagName("script");if(g.length)for(var w=g.length-1;w>-1&&(!y||!/^http(s?):/.test(y));)y=g[w--].src}if(!y)throw Error("Automatic publicPath is not supported in this browser");d.p=y.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),l={889:0},d.f.j=function(e,t){var n=d.o(l,e)?l[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=l[e]=[t,r]});t.push(n[2]=r);var o=d.p+d.u(e),i=Error();d.l(o,function(t){if(d.o(l,e)&&(0!==(n=l[e])&&(l[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},f=function(e,t){var n,r,o=t[0],i=t[1],c=t[2],u=0;if(o.some(function(e){return 0!==l[e]})){for(n in i)d.o(i,n)&&(d.m[n]=i[n]);c&&c(d)}for(e&&e(t);u<o.length;u++)r=o[u],d.o(l,r)&&l[r]&&l[r][0](),l[r]=0},(s=self.webpackChunk_nocobase_plugin_workflow_sql_client_v2=self.webpackChunk_nocobase_plugin_workflow_sql_client_v2||[]).forEach(f.bind(null,0)),s.push=f.bind(null,s.push.bind(s));var m={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-workflow-sql/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-sql/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var c=window.location.pathname||"/",u=c.indexOf(i);e=u>=0?c.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-sql/dist/client-v2/"}d.p=e}(),!function(){d.r(m),d.d(m,{SQLInstruction:function(){return p},default:function(){return _}});var e=d(485),t=d(155),n=d.n(t),r=d(375),o=d(197),i=d(401);function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=function(e){return'{{t("'.concat(e,'", { ns: "').concat(i.C,'" })}}')},s={label:"label",value:"value"},p=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,t,a;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return t=o,a=arguments,t=u(t),c(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,l()?Reflect.construct(t,a||[],u(this).constructor):t.apply(this,a)),"title",f("SQL action")),c(e,"type",i.J),c(e,"group","collection"),c(e,"description",f("Execute a SQL statement in database.")),c(e,"icon",n().createElement(r.ConsoleSqlOutlined,null)),c(e,"testable",!0),c(e,"FieldsetLoader",function(){return d.e("241").then(d.bind(d,624)).then(function(e){return{default:e.SQLFieldset}})}),e}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&a(o,e),t=[{key:"createDefaultConfig",value:function(){return{dataSource:"main"}}},{key:"useVariables",value:function(e){var t,n=e.key,r=e.title,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.fieldNames,u=void 0===i?s:i;return c(t={},u.value,n),c(t,u.label,r),t}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(o.prototype,t),o}(o.Instruction);function b(e,t,n,r,o,i,c){try{var u=e[i](c),a=u.value}catch(e){n(e);return}u.done?t(a):Promise.resolve(a).then(r,o)}function v(e,t,n){return(v=w()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&h(o,n.prototype),o}).apply(null,arguments)}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){var t="function"==typeof Map?new Map:void 0;return(g=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return v(e,arguments,y(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)})(e)}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}var _=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=y(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,w()?Reflect.construct(e,t||[],y(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&h(n,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(n){return null==(t=this.app.pm.get("workflow"))||null==(e=t.registerInstruction)||e.call(t,i.J,p),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){b(i,r,o,c,u,"next",e)}function u(e){b(i,r,o,c,u,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(g(e.Plugin))}(),m}()});
@@ -0,0 +1,12 @@
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 { NAMESPACE } from './constants';
10
+ export { NAMESPACE };
11
+ export declare function tExpr(key: string, options?: Record<string, unknown>): string;
12
+ export declare function useT(): (key: string, options?: Record<string, unknown>) => string;
@@ -0,0 +1,19 @@
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 type SQLVariable = {
10
+ name?: string;
11
+ value?: unknown;
12
+ };
13
+ export type SQLInstructionConfig = {
14
+ dataSource?: string;
15
+ sql?: string;
16
+ withMeta?: boolean;
17
+ unsafeInjection?: boolean;
18
+ variables?: SQLVariable[];
19
+ };
@@ -0,0 +1,10 @@
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 type { SQLInstructionConfig } from './types';
10
+ export declare function migrateUnsafeSqlConfig(config: SQLInstructionConfig): SQLInstructionConfig;
@@ -8,18 +8,18 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.2.0-alpha.1",
12
- "@formily/antd-v5": "1.2.3",
13
- "@formily/react": "2.3.7",
14
- "antd": "5.24.2",
15
- "@nocobase/utils": "2.2.0-alpha.1",
16
- "lodash": "4.18.1",
17
- "@nocobase/plugin-workflow": "2.2.0-alpha.1",
11
+ "@nocobase/client": "2.2.0-alpha.2",
18
12
  "react": "18.2.0",
19
13
  "@ant-design/icons": "5.6.1",
14
+ "@nocobase/plugin-workflow": "2.2.0-alpha.2",
15
+ "@nocobase/client-v2": "2.2.0-alpha.2",
16
+ "@nocobase/flow-engine": "2.2.0-alpha.2",
17
+ "@nocobase/utils": "2.2.0-alpha.2",
20
18
  "react-i18next": "11.18.6",
21
- "@nocobase/server": "2.2.0-alpha.1",
22
- "@nocobase/data-source-manager": "2.2.0-alpha.1",
23
- "@nocobase/plugin-workflow-test": "2.2.0-alpha.1",
24
- "@nocobase/test": "2.2.0-alpha.1"
19
+ "@nocobase/server": "2.2.0-alpha.2",
20
+ "@nocobase/data-source-manager": "2.2.0-alpha.2",
21
+ "@nocobase/plugin-workflow-test": "2.2.0-alpha.2",
22
+ "@nocobase/test": "2.2.0-alpha.2",
23
+ "antd": "5.24.2",
24
+ "ahooks": "3.7.8"
25
25
  };
@@ -13,5 +13,6 @@
13
13
  "Add parameter": "Add parameter",
14
14
  "SQL query result could be used through <1>JSON query node</1>.": "SQL query result could be used through <1>JSON query node</1>.",
15
15
  "Select a data source to execute SQL.": "Select a data source to execute SQL.",
16
- "Usage of SQL query result is not supported yet.": "Usage of SQL query result is not supported yet."
17
- }
16
+ "Usage of SQL query result is not supported yet.": "Usage of SQL query result is not supported yet.",
17
+ "Remove parameter": "Remove parameter"
18
+ }
@@ -13,5 +13,6 @@
13
13
  "Add parameter": "添加参数",
14
14
  "SQL query result could be used through <1>JSON query node</1>.": "SQL 执行的结果可在 <1>JSON 解析节点</1> 中使用。",
15
15
  "Select a data source to execute SQL.": "选择一个数据源来执行 SQL",
16
- "Usage of SQL query result is not supported yet.": "Usage of SQL query result is not supported yet."
16
+ "Usage of SQL query result is not supported yet.": "Usage of SQL query result is not supported yet.",
17
+ "Remove parameter": "移除参数"
17
18
  }
@@ -1 +1 @@
1
- {"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-06-10T18:13:32.469Z"}
1
+ {"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-06-26T03:51:50.640Z"}
@@ -7,6 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Processor, Instruction, FlowNodeModel } from '@nocobase/plugin-workflow';
10
+ import type WorkflowPlugin from '@nocobase/plugin-workflow';
10
11
  import Joi from 'joi';
11
12
  export type SQLInstructionConfig = {
12
13
  dataSource?: string;
@@ -15,10 +16,11 @@ export type SQLInstructionConfig = {
15
16
  unsafeInjection?: boolean;
16
17
  variables?: Array<{
17
18
  name: string;
18
- value: any;
19
+ value: unknown;
19
20
  }>;
20
21
  };
21
- export default class extends Instruction {
22
+ export default class SQLInstruction extends Instruction {
23
+ workflow: WorkflowPlugin;
22
24
  configSchema: Joi.ObjectSchema<any>;
23
25
  run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
24
26
  status: 1;
@@ -31,7 +33,7 @@ export default class extends Instruction {
31
33
  result: unknown[];
32
34
  status: 1;
33
35
  } | {
34
- result: any;
36
+ result: string;
35
37
  status: -2;
36
38
  }>;
37
39
  }
@@ -36,13 +36,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var SQLInstruction_exports = {};
38
38
  __export(SQLInstruction_exports, {
39
- default: () => SQLInstruction_default
39
+ default: () => SQLInstruction
40
40
  });
41
41
  module.exports = __toCommonJS(SQLInstruction_exports);
42
42
  var import_data_source_manager = require("@nocobase/data-source-manager");
43
43
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
44
44
  var import_joi = __toESM(require("joi"));
45
- class SQLInstruction_default extends import_plugin_workflow.Instruction {
45
+ class SQLInstruction extends import_plugin_workflow.Instruction {
46
46
  configSchema = import_joi.default.object({
47
47
  dataSource: import_joi.default.string(),
48
48
  sql: import_joi.default.string(),
@@ -81,8 +81,9 @@ class SQLInstruction_default extends import_plugin_workflow.Instruction {
81
81
  status: import_plugin_workflow.JOB_STATUS.RESOLVED
82
82
  };
83
83
  }
84
+ const transaction = processor.getScopeTransaction(node, dataSourceName) ?? this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction);
84
85
  const [result = null, meta = null] = await collectionManager.db.sequelize.query(sql, {
85
- transaction: this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction),
86
+ transaction,
86
87
  replacements
87
88
  // plain: true,
88
89
  // model: db.getCollection(node.config.collection).model
@@ -131,7 +132,7 @@ class SQLInstruction_default extends import_plugin_workflow.Instruction {
131
132
  };
132
133
  } catch (error) {
133
134
  return {
134
- result: error.message,
135
+ result: error instanceof Error ? error.message : String(error),
135
136
  status: import_plugin_workflow.JOB_STATUS.ERROR
136
137
  };
137
138
  }
@@ -8,6 +8,5 @@
8
8
  */
9
9
  import { Migration } from '@nocobase/server';
10
10
  export default class extends Migration {
11
- appVersion: string;
12
11
  up(): Promise<void>;
13
12
  }
@@ -32,7 +32,6 @@ module.exports = __toCommonJS(add_unsafe_injection_flag_exports);
32
32
  var import_server = require("@nocobase/server");
33
33
  var import_utils = require("@nocobase/utils");
34
34
  class add_unsafe_injection_flag_default extends import_server.Migration {
35
- appVersion = "<2.0.30";
36
35
  async up() {
37
36
  const { db } = this.context;
38
37
  const NodeRepo = db.getRepository("flow_nodes");
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Execute SQL statements in workflow.",
7
7
  "description.ru-RU": "Выполняет SQL-запросы в рамках рабочего процесса.",
8
8
  "description.zh-CN": "可用于在工作流中对数据库执行任意 SQL 语句。",
9
- "version": "2.2.0-alpha.1",
9
+ "version": "2.2.0-alpha.2",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-sql",
@@ -20,12 +20,13 @@
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@nocobase/client": "2.x",
23
+ "@nocobase/client-v2": "2.x",
23
24
  "@nocobase/database": "2.x",
24
25
  "@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
25
26
  "@nocobase/server": "2.x",
26
27
  "@nocobase/test": "2.x"
27
28
  },
28
- "gitHead": "303663aba6c6eefa27e6a6435b4c0352074ec40f",
29
+ "gitHead": "9dd5224bb8f6c1ac12d766b9f175bdc29bddd845",
29
30
  "keywords": [
30
31
  "Workflow"
31
32
  ]