@nocobase/plugin-workflow-sql 1.3.15-beta → 1.3.17-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/SQLInstruction.d.ts +6 -0
- package/dist/client/index.js +2 -2
- package/dist/externalVersion.js +6 -6
- package/dist/locale/zh-CN.json +2 -1
- package/dist/server/SQLInstruction.js +5 -6
- package/dist/server/migrations/20240902174913-add-raw-result-mode.d.ts +13 -0
- package/dist/server/migrations/20240902174913-add-raw-result-mode.js +58 -0
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(e,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@nocobase/plugin-workflow/client","react-i18next"],o):(e=typeof globalThis!="undefined"?globalThis:e||self,o(e["@nocobase/plugin-workflow-sql"]={},e["@nocobase/client"],e.jsxRuntime,e["@nocobase/plugin-workflow"],e["react-i18next"]))})(this,function(e,o,t,a,l){"use strict";var
|
|
10
|
+
(function(e,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@nocobase/plugin-workflow/client","react-i18next"],o):(e=typeof globalThis!="undefined"?globalThis:e||self,o(e["@nocobase/plugin-workflow-sql"]={},e["@nocobase/client"],e.jsxRuntime,e["@nocobase/plugin-workflow"],e["react-i18next"]))})(this,function(e,o,t,a,l){"use strict";var w=Object.defineProperty;var x=(e,o,t)=>o in e?w(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var r=(e,o,t)=>(x(e,typeof o!="symbol"?o+"":o,t),t);var d=(e,o,t)=>new Promise((a,l)=>{var s=n=>{try{i(t.next(n))}catch(c){l(c)}},p=n=>{try{i(t.throw(n))}catch(c){l(c)}},i=n=>n.done?a(n.value):Promise.resolve(n.value).then(s,p);i((t=t.apply(e,o)).next())});const s="@nocobase/plugin-workflow-sql";class p extends a.Instruction{constructor(){super(...arguments);r(this,"title",`{{t("SQL action", { ns: "${s}" })}}`);r(this,"type","sql");r(this,"group","collection");r(this,"description",`{{t("Execute a SQL statement in database.", { ns: "${s}" })}}`);r(this,"fieldset",{dataSource:{type:"string",required:!0,title:'{{t("Data source")}}',description:`{{t("Select a data source to execute SQL.", { ns: "${s}" })}}`,"x-decorator":"FormItem","x-component":"DataSourceSelect","x-component-props":{className:"auto-width",filter(u){return u.options.isDBInstance||u.key===o.DEFAULT_DATA_SOURCE_KEY}},default:"main"},sql:{type:"string",required:!0,title:"SQL",description:"{{sqlDescription()}}","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{rows:20,className:o.css`
|
|
11
11
|
font-size: 80%;
|
|
12
12
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
13
|
-
`}}});r(this,"scope",{sqlDescription(){return t.jsxs(l.Trans,{ns:s,children:["SQL query result could be used through ",t.jsx("a",{href:"https://docs-cn.nocobase.com/handbook/workflow-json-query",target:"_blank",rel:"noreferrer",children:"JSON query node"})," (Commercial plugin)."]})}});r(this,"components",{WorkflowVariableRawTextArea:a.WorkflowVariableRawTextArea})}useVariables({key:u,title:
|
|
13
|
+
`}},withMeta:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":`{{t("Include meta information of this query in result", { ns: "${s}" })}}`}});r(this,"scope",{sqlDescription(){return t.jsxs(l.Trans,{ns:s,children:["SQL query result could be used through ",t.jsx("a",{href:"https://docs-cn.nocobase.com/handbook/workflow-json-query",target:"_blank",rel:"noreferrer",children:"JSON query node"})," (Commercial plugin)."]})}});r(this,"components",{WorkflowVariableRawTextArea:a.WorkflowVariableRawTextArea})}useVariables({key:u,title:m},{types:b,fieldNames:f=a.defaultFieldNames}){return{[f.value]:u,[f.label]:m}}}class i extends o.Plugin{afterAdd(){return d(this,null,function*(){})}beforeLoad(){return d(this,null,function*(){})}load(){return d(this,null,function*(){this.app.pm.get("workflow").registerInstruction("sql",p)})}}e.default=i,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.3.
|
|
12
|
-
"@nocobase/plugin-workflow": "1.3.
|
|
11
|
+
"@nocobase/client": "1.3.17-beta",
|
|
12
|
+
"@nocobase/plugin-workflow": "1.3.17-beta",
|
|
13
13
|
"react": "18.2.0",
|
|
14
14
|
"react-i18next": "11.18.6",
|
|
15
|
-
"@nocobase/server": "1.3.
|
|
16
|
-
"@nocobase/plugin-workflow-test": "1.3.
|
|
17
|
-
"@nocobase/test": "1.3.
|
|
18
|
-
"@nocobase/utils": "1.3.
|
|
15
|
+
"@nocobase/server": "1.3.17-beta",
|
|
16
|
+
"@nocobase/plugin-workflow-test": "1.3.17-beta",
|
|
17
|
+
"@nocobase/test": "1.3.17-beta",
|
|
18
|
+
"@nocobase/utils": "1.3.17-beta"
|
|
19
19
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
"SQL action": "SQL 操作",
|
|
3
3
|
"Execute a SQL statement in database.": "在数据库中执行一个 SQL 语句",
|
|
4
4
|
"Select a data source to execute SQL.": "选择一个数据源来执行 SQL",
|
|
5
|
-
"SQL query result could be used through <1>JSON query node</1> (Commercial plugin).": "SQL 执行的结果可在 <1>JSON 解析节点</1> 中使用(商业插件)。"
|
|
5
|
+
"SQL query result could be used through <1>JSON query node</1> (Commercial plugin).": "SQL 执行的结果可在 <1>JSON 解析节点</1> 中使用(商业插件)。",
|
|
6
|
+
"Include meta information of this query in result": "在结果中包含此查询的元信息"
|
|
6
7
|
}
|
|
@@ -32,9 +32,8 @@ module.exports = __toCommonJS(SQLInstruction_exports);
|
|
|
32
32
|
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
33
33
|
class SQLInstruction_default extends import_plugin_workflow.Instruction {
|
|
34
34
|
async run(node, input, processor) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
).collectionManager;
|
|
35
|
+
const dataSourceName = node.config.dataSource || "main";
|
|
36
|
+
const { db } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager;
|
|
38
37
|
if (!db) {
|
|
39
38
|
throw new Error(`type of data source "${node.config.dataSource}" is not database`);
|
|
40
39
|
}
|
|
@@ -44,13 +43,13 @@ class SQLInstruction_default extends import_plugin_workflow.Instruction {
|
|
|
44
43
|
status: import_plugin_workflow.JOB_STATUS.RESOLVED
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
|
-
const result = await db.sequelize.query(sql, {
|
|
48
|
-
transaction: processor.transaction
|
|
46
|
+
const [result, meta] = await db.sequelize.query(sql, {
|
|
47
|
+
transaction: this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction)
|
|
49
48
|
// plain: true,
|
|
50
49
|
// model: db.getCollection(node.config.collection).model
|
|
51
50
|
});
|
|
52
51
|
return {
|
|
53
|
-
result,
|
|
52
|
+
result: node.config.withMeta ? [result, meta] : result,
|
|
54
53
|
status: import_plugin_workflow.JOB_STATUS.RESOLVED
|
|
55
54
|
};
|
|
56
55
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
appVersion: string;
|
|
12
|
+
up(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var add_raw_result_mode_exports = {};
|
|
28
|
+
__export(add_raw_result_mode_exports, {
|
|
29
|
+
default: () => add_raw_result_mode_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(add_raw_result_mode_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
class add_raw_result_mode_default extends import_server.Migration {
|
|
34
|
+
appVersion = "<1.3.16-beta";
|
|
35
|
+
async up() {
|
|
36
|
+
const { db } = this.context;
|
|
37
|
+
const NodeRepo = db.getRepository("flow_nodes");
|
|
38
|
+
await db.sequelize.transaction(async (transaction) => {
|
|
39
|
+
const nodes = await NodeRepo.find({
|
|
40
|
+
filter: {
|
|
41
|
+
type: "sql"
|
|
42
|
+
},
|
|
43
|
+
transaction
|
|
44
|
+
});
|
|
45
|
+
await nodes.reduce(
|
|
46
|
+
(promise, node) => promise.then(() => {
|
|
47
|
+
node.set("config", { ...node.config, withMeta: true });
|
|
48
|
+
node.changed("config", true);
|
|
49
|
+
return node.save({
|
|
50
|
+
silent: true,
|
|
51
|
+
transaction
|
|
52
|
+
});
|
|
53
|
+
}),
|
|
54
|
+
Promise.resolve()
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:SQL 节点",
|
|
5
5
|
"description": "Execute SQL statements in workflow.",
|
|
6
6
|
"description.zh-CN": "可用于在工作流中对数据库执行任意 SQL 语句。",
|
|
7
|
-
"version": "1.3.
|
|
7
|
+
"version": "1.3.17-beta",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow-sql",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@nocobase/server": "1.x",
|
|
22
22
|
"@nocobase/test": "1.x"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "9c2f4d3b7b8d920f75a6c1514de047f36ec66ecc",
|
|
25
25
|
"keywords": [
|
|
26
26
|
"Workflow"
|
|
27
27
|
]
|