@nocobase/plugin-flow-engine 2.0.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/LICENSE +661 -0
- package/README.md +29 -0
- package/build.config.ts +22 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +15 -0
- package/dist/client/index.js +10 -0
- package/dist/externalVersion.js +21 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +61 -0
- package/dist/locale/index.d.ts +141 -0
- package/dist/locale/index.js +79 -0
- package/dist/locale/zh-CN.json +61 -0
- package/dist/node_modules/ses/LICENSE +201 -0
- package/dist/node_modules/ses/LICENSE-aura +16 -0
- package/dist/node_modules/ses/LICENSE-caja +13 -0
- package/dist/node_modules/ses/LICENSE-corejs +19 -0
- package/dist/node_modules/ses/LICENSE-v8 +9 -0
- package/dist/node_modules/ses/assert-shim.js +1 -0
- package/dist/node_modules/ses/compartment-shim.js +1 -0
- package/dist/node_modules/ses/console-shim.js +1 -0
- package/dist/node_modules/ses/dist/lockdown.cjs +13912 -0
- package/dist/node_modules/ses/dist/lockdown.umd.js +13912 -0
- package/dist/node_modules/ses/dist/lockdown.umd.min.js +1 -0
- package/dist/node_modules/ses/dist/ses-hermes.cjs +13912 -0
- package/dist/node_modules/ses/dist/ses.cjs +1 -0
- package/dist/node_modules/ses/dist/ses.umd.js +13912 -0
- package/dist/node_modules/ses/dist/ses.umd.min.js +1 -0
- package/dist/node_modules/ses/dist/types.d.cts +606 -0
- package/dist/node_modules/ses/index.js +18 -0
- package/dist/node_modules/ses/lockdown-shim.js +1 -0
- package/dist/node_modules/ses/lockdown.js +1 -0
- package/dist/node_modules/ses/package.json +1 -0
- package/dist/node_modules/ses/src/assert-shim.js +4 -0
- package/dist/node_modules/ses/src/assert-sloppy-mode.js +11 -0
- package/dist/node_modules/ses/src/cauterize-property.js +69 -0
- package/dist/node_modules/ses/src/commons.js +425 -0
- package/dist/node_modules/ses/src/compartment-evaluate.js +93 -0
- package/dist/node_modules/ses/src/compartment-shim.js +22 -0
- package/dist/node_modules/ses/src/compartment.js +477 -0
- package/dist/node_modules/ses/src/console-shim.js +50 -0
- package/dist/node_modules/ses/src/enable-property-overrides.js +211 -0
- package/dist/node_modules/ses/src/enablements.js +244 -0
- package/dist/node_modules/ses/src/error/assert.js +584 -0
- package/dist/node_modules/ses/src/error/console.js +541 -0
- package/dist/node_modules/ses/src/error/fatal-assert.js +54 -0
- package/dist/node_modules/ses/src/error/internal-types.js +98 -0
- package/dist/node_modules/ses/src/error/note-log-args.js +77 -0
- package/dist/node_modules/ses/src/error/stringify-utils.js +195 -0
- package/dist/node_modules/ses/src/error/tame-console.js +197 -0
- package/dist/node_modules/ses/src/error/tame-error-constructor.js +284 -0
- package/dist/node_modules/ses/src/error/tame-v8-error-constructor.js +386 -0
- package/dist/node_modules/ses/src/error/types.js +59 -0
- package/dist/node_modules/ses/src/error/unhandled-rejection.js +122 -0
- package/dist/node_modules/ses/src/eval-scope.js +89 -0
- package/dist/node_modules/ses/src/get-anonymous-intrinsics.js +181 -0
- package/dist/node_modules/ses/src/get-source-url.js +50 -0
- package/dist/node_modules/ses/src/global-object.js +175 -0
- package/dist/node_modules/ses/src/intrinsics.js +192 -0
- package/dist/node_modules/ses/src/lockdown-shim.js +37 -0
- package/dist/node_modules/ses/src/lockdown.js +558 -0
- package/dist/node_modules/ses/src/make-eval-function.js +28 -0
- package/dist/node_modules/ses/src/make-evaluate.js +110 -0
- package/dist/node_modules/ses/src/make-function-constructor.js +79 -0
- package/dist/node_modules/ses/src/make-hardener.js +275 -0
- package/dist/node_modules/ses/src/make-safe-evaluator.js +112 -0
- package/dist/node_modules/ses/src/module-instance.js +497 -0
- package/dist/node_modules/ses/src/module-link.js +159 -0
- package/dist/node_modules/ses/src/module-load.js +719 -0
- package/dist/node_modules/ses/src/module-proxy.js +200 -0
- package/dist/node_modules/ses/src/permits-intrinsics.js +291 -0
- package/dist/node_modules/ses/src/permits.js +1761 -0
- package/dist/node_modules/ses/src/reporting-types.d.ts +13 -0
- package/dist/node_modules/ses/src/reporting.js +105 -0
- package/dist/node_modules/ses/src/scope-constants.js +180 -0
- package/dist/node_modules/ses/src/shim-arraybuffer-transfer.js +85 -0
- package/dist/node_modules/ses/src/sloppy-globals-scope-terminator.js +61 -0
- package/dist/node_modules/ses/src/strict-scope-terminator.js +99 -0
- package/dist/node_modules/ses/src/tame-date-constructor.js +127 -0
- package/dist/node_modules/ses/src/tame-domains.js +41 -0
- package/dist/node_modules/ses/src/tame-faux-data-properties.js +210 -0
- package/dist/node_modules/ses/src/tame-function-constructors.js +140 -0
- package/dist/node_modules/ses/src/tame-function-tostring.js +50 -0
- package/dist/node_modules/ses/src/tame-harden.js +29 -0
- package/dist/node_modules/ses/src/tame-locale-methods.js +78 -0
- package/dist/node_modules/ses/src/tame-math-object.js +41 -0
- package/dist/node_modules/ses/src/tame-module-source.js +51 -0
- package/dist/node_modules/ses/src/tame-regenerator-runtime.js +29 -0
- package/dist/node_modules/ses/src/tame-regexp-constructor.js +65 -0
- package/dist/node_modules/ses/src/tame-symbol-constructor.js +64 -0
- package/dist/node_modules/ses/src/transforms.js +267 -0
- package/dist/node_modules/ses/tools.js +25 -0
- package/dist/node_modules/ses/types.d.ts +606 -0
- package/dist/server/actions/ui-schema-action.d.ts +27 -0
- package/dist/server/actions/ui-schema-action.js +118 -0
- package/dist/server/collections/flowModelTreePath.d.ts +11 -0
- package/dist/server/collections/flowModelTreePath.js +74 -0
- package/dist/server/collections/flowModels.d.ts +11 -0
- package/dist/server/collections/flowModels.js +57 -0
- package/dist/server/collections/flowsql.d.ts +10 -0
- package/dist/server/collections/flowsql.js +51 -0
- package/dist/server/dao/ui_schema_node_dao.d.ts +26 -0
- package/dist/server/dao/ui_schema_node_dao.js +24 -0
- package/dist/server/helper.d.ts +8 -0
- package/dist/server/helper.js +9 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/model.d.ts +12 -0
- package/dist/server/model.js +38 -0
- package/dist/server/plugin.d.ts +26 -0
- package/dist/server/plugin.js +270 -0
- package/dist/server/repository.d.ts +116 -0
- package/dist/server/repository.js +1209 -0
- package/dist/server/server.d.ts +16 -0
- package/dist/server/server.js +198 -0
- package/dist/server/template/contexts.d.ts +73 -0
- package/dist/server/template/contexts.js +233 -0
- package/dist/server/template/resolver.d.ts +30 -0
- package/dist/server/template/resolver.js +225 -0
- package/dist/server/variables/registry.d.ts +42 -0
- package/dist/server/variables/registry.js +299 -0
- package/package.json +28 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var plugin_exports = {};
|
|
38
|
+
__export(plugin_exports, {
|
|
39
|
+
PluginFlowEngineServer: () => PluginFlowEngineServer,
|
|
40
|
+
default: () => plugin_default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
43
|
+
var import_server2 = __toESM(require("./server"));
|
|
44
|
+
var import_contexts = require("./template/contexts");
|
|
45
|
+
var import_resolver = require("./template/resolver");
|
|
46
|
+
var import_registry = require("./variables/registry");
|
|
47
|
+
class PluginFlowEngineServer extends import_server2.default {
|
|
48
|
+
globalContext;
|
|
49
|
+
async afterAdd() {
|
|
50
|
+
}
|
|
51
|
+
async beforeLoad() {
|
|
52
|
+
await super.beforeLoad();
|
|
53
|
+
}
|
|
54
|
+
getDatabaseByDataSourceKey(dataSourceKey = "main") {
|
|
55
|
+
const dataSource = this.app.dataSourceManager.get(dataSourceKey);
|
|
56
|
+
const cm = dataSource.collectionManager;
|
|
57
|
+
if (!cm.db) {
|
|
58
|
+
throw new Error("no db");
|
|
59
|
+
}
|
|
60
|
+
return cm.db;
|
|
61
|
+
}
|
|
62
|
+
// 预取:构建“同记录”的字段/关联并集,一次查询写入 ctx.state.__varResolveBatchCache,供后续解析复用
|
|
63
|
+
async prefetchRecordsForResolve(koaCtx, items) {
|
|
64
|
+
var _a;
|
|
65
|
+
try {
|
|
66
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
67
|
+
const ensureGroup = (dataSourceKey, collection, filterByTk) => {
|
|
68
|
+
const groupKey = JSON.stringify({ ds: dataSourceKey, collection, tk: filterByTk });
|
|
69
|
+
let group = groupMap.get(groupKey);
|
|
70
|
+
if (!group) {
|
|
71
|
+
group = { dataSourceKey, collection, filterByTk, fields: /* @__PURE__ */ new Set(), appends: /* @__PURE__ */ new Set() };
|
|
72
|
+
groupMap.set(groupKey, group);
|
|
73
|
+
}
|
|
74
|
+
return group;
|
|
75
|
+
};
|
|
76
|
+
const normalizeNestedSeg = (segment) => /^\d+$/.test(segment) ? `[${segment}]` : segment;
|
|
77
|
+
const toFirstSeg = (path) => {
|
|
78
|
+
const m = path.match(/^([^.[]+|\[[^\]]+\])([\s\S]*)$/);
|
|
79
|
+
const segment = m ? m[1] : "";
|
|
80
|
+
const rest = m ? m[2] : "";
|
|
81
|
+
return { segment, hasDeep: rest.includes(".") || rest.includes("[") || rest.length > 0 };
|
|
82
|
+
};
|
|
83
|
+
for (const it of items) {
|
|
84
|
+
const template = (it == null ? void 0 : it.template) ?? {};
|
|
85
|
+
const contextParams = (it == null ? void 0 : it.contextParams) || {};
|
|
86
|
+
const usage = import_registry.variables.extractUsage(template);
|
|
87
|
+
for (const [cpKey, recordParams] of Object.entries(contextParams)) {
|
|
88
|
+
const parts = String(cpKey).split(".");
|
|
89
|
+
const varName = parts[0];
|
|
90
|
+
const nestedSeg = parts.slice(1).join(".");
|
|
91
|
+
const paths = (usage == null ? void 0 : usage[varName]) || [];
|
|
92
|
+
if (!paths.length) continue;
|
|
93
|
+
const segNorm = nestedSeg ? normalizeNestedSeg(nestedSeg) : "";
|
|
94
|
+
const remainders = [];
|
|
95
|
+
for (const p of paths) {
|
|
96
|
+
if (!segNorm) remainders.push(p);
|
|
97
|
+
else if (p === segNorm) remainders.push("");
|
|
98
|
+
else if (p.startsWith(`${segNorm}.`) || p.startsWith(`${segNorm}[`))
|
|
99
|
+
remainders.push(p.slice(segNorm.length + 1));
|
|
100
|
+
}
|
|
101
|
+
if (!remainders.length) continue;
|
|
102
|
+
const dataSourceKey = (recordParams == null ? void 0 : recordParams.dataSourceKey) || "main";
|
|
103
|
+
const collection = recordParams == null ? void 0 : recordParams.collection;
|
|
104
|
+
const filterByTk = recordParams == null ? void 0 : recordParams.filterByTk;
|
|
105
|
+
if (!collection || typeof filterByTk === "undefined") continue;
|
|
106
|
+
const group = ensureGroup(dataSourceKey, collection, filterByTk);
|
|
107
|
+
for (const r of remainders) {
|
|
108
|
+
const { segment, hasDeep } = toFirstSeg(r);
|
|
109
|
+
if (!segment) continue;
|
|
110
|
+
const key = segment.replace(/^\[(.+)\]$/, "$1");
|
|
111
|
+
if (hasDeep) group.appends.add(key);
|
|
112
|
+
else group.fields.add(key);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!groupMap.size) return;
|
|
117
|
+
const stateObj = koaCtx.state;
|
|
118
|
+
if (stateObj && !stateObj["__varResolveBatchCache"]) {
|
|
119
|
+
stateObj["__varResolveBatchCache"] = /* @__PURE__ */ new Map();
|
|
120
|
+
}
|
|
121
|
+
const cache = (_a = koaCtx.state) == null ? void 0 : _a["__varResolveBatchCache"];
|
|
122
|
+
for (const { dataSourceKey, collection, filterByTk, fields, appends } of groupMap.values()) {
|
|
123
|
+
try {
|
|
124
|
+
const dataSource = this.app.dataSourceManager.get(dataSourceKey);
|
|
125
|
+
const cm = dataSource.collectionManager;
|
|
126
|
+
if (!(cm == null ? void 0 : cm.db)) continue;
|
|
127
|
+
const repo = cm.db.getRepository(collection);
|
|
128
|
+
const fld = fields.size ? Array.from(fields) : void 0;
|
|
129
|
+
const app = appends.size ? Array.from(appends) : void 0;
|
|
130
|
+
const rec = await repo.findOne({ filterByTk, fields: fld, appends: app });
|
|
131
|
+
const json = rec ? rec.toJSON() : void 0;
|
|
132
|
+
if (cache) {
|
|
133
|
+
const key = JSON.stringify({ ds: dataSourceKey, c: collection, tk: filterByTk, f: fld, a: app });
|
|
134
|
+
cache.set(key, json);
|
|
135
|
+
}
|
|
136
|
+
} catch {
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
transformSQL(template) {
|
|
143
|
+
let index = 1;
|
|
144
|
+
const bind = {};
|
|
145
|
+
const sql = template.replace(/{{\s*([^}]+)\s*}}/g, (_, expr) => {
|
|
146
|
+
const key = `__var${index}`;
|
|
147
|
+
bind[key] = `{{${expr.trim()}}}`;
|
|
148
|
+
index++;
|
|
149
|
+
return `$${key}`;
|
|
150
|
+
});
|
|
151
|
+
return { sql, bind };
|
|
152
|
+
}
|
|
153
|
+
async load() {
|
|
154
|
+
var _a, _b;
|
|
155
|
+
await super.load();
|
|
156
|
+
this.globalContext = new import_contexts.GlobalContext((_b = (_a = this.app.environment) == null ? void 0 : _a.getVariables) == null ? void 0 : _b.call(_a));
|
|
157
|
+
this.app.acl.allow("flowSql", "runById", "loggedIn");
|
|
158
|
+
this.app.acl.allow("variables", "resolve", "loggedIn");
|
|
159
|
+
this.app.acl.allow("fieldAssignments", "apply", "loggedIn");
|
|
160
|
+
this.app.resourceManager.define({
|
|
161
|
+
name: "variables",
|
|
162
|
+
actions: {
|
|
163
|
+
// 解析 JSON 模板中的 ctx 变量
|
|
164
|
+
resolve: async (ctx, next) => {
|
|
165
|
+
var _a2, _b2;
|
|
166
|
+
const raw = ((_b2 = (_a2 = ctx.action) == null ? void 0 : _a2.params) == null ? void 0 : _b2.values) ?? {};
|
|
167
|
+
const values = typeof (raw == null ? void 0 : raw.values) !== "undefined" ? raw.values : raw;
|
|
168
|
+
if (Array.isArray(values == null ? void 0 : values.batch)) {
|
|
169
|
+
const batchItems = values.batch;
|
|
170
|
+
await this.prefetchRecordsForResolve(
|
|
171
|
+
ctx,
|
|
172
|
+
batchItems.map((it) => ({
|
|
173
|
+
template: it.template,
|
|
174
|
+
contextParams: it.contextParams || {}
|
|
175
|
+
}))
|
|
176
|
+
);
|
|
177
|
+
const results = [];
|
|
178
|
+
for (const item of batchItems) {
|
|
179
|
+
const template2 = (item == null ? void 0 : item.template) ?? {};
|
|
180
|
+
const contextParams2 = (item == null ? void 0 : item.contextParams) || {};
|
|
181
|
+
const requestCtx2 = new import_contexts.HttpRequestContext(ctx);
|
|
182
|
+
requestCtx2.delegate(this.globalContext);
|
|
183
|
+
await import_registry.variables.attachUsedVariables(requestCtx2, ctx, template2, contextParams2);
|
|
184
|
+
const resolved2 = await (0, import_resolver.resolveJsonTemplate)(template2, requestCtx2);
|
|
185
|
+
results.push({ id: item == null ? void 0 : item.id, data: resolved2 });
|
|
186
|
+
}
|
|
187
|
+
ctx.body = { results };
|
|
188
|
+
await next();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (typeof (values == null ? void 0 : values.template) === "undefined") {
|
|
192
|
+
ctx.throw(400, {
|
|
193
|
+
code: "INVALID_PAYLOAD",
|
|
194
|
+
message: "values.template is required when batch is not provided"
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const template = values.template;
|
|
198
|
+
const contextParams = (values == null ? void 0 : values.contextParams) || {};
|
|
199
|
+
await this.prefetchRecordsForResolve(ctx, [{ template, contextParams }]);
|
|
200
|
+
const requestCtx = new import_contexts.HttpRequestContext(ctx);
|
|
201
|
+
requestCtx.delegate(this.globalContext);
|
|
202
|
+
await import_registry.variables.attachUsedVariables(requestCtx, ctx, template, contextParams);
|
|
203
|
+
const resolved = await (0, import_resolver.resolveJsonTemplate)(template, requestCtx);
|
|
204
|
+
ctx.body = resolved;
|
|
205
|
+
await next();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
this.app.acl.registerSnippet({
|
|
210
|
+
name: "ui.flowSql",
|
|
211
|
+
actions: ["flowSql:*"]
|
|
212
|
+
});
|
|
213
|
+
this.app.resourceManager.registerActionHandlers({
|
|
214
|
+
"flowSql:runById": async (ctx, next) => {
|
|
215
|
+
const { uid, type, filter, bind, dataSourceKey = "main" } = ctx.action.params.values;
|
|
216
|
+
const r = this.db.getRepository("flowSql");
|
|
217
|
+
const record = await r.findOne({
|
|
218
|
+
filter: { uid }
|
|
219
|
+
});
|
|
220
|
+
const db = this.getDatabaseByDataSourceKey(record.dataSourceKey || dataSourceKey);
|
|
221
|
+
const result = this.transformSQL(record.sql);
|
|
222
|
+
ctx.body = await db.runSQL(result.sql, {
|
|
223
|
+
type,
|
|
224
|
+
filter,
|
|
225
|
+
bind
|
|
226
|
+
});
|
|
227
|
+
await next();
|
|
228
|
+
},
|
|
229
|
+
"flowSql:getBind": async (ctx, next) => {
|
|
230
|
+
const { uid } = ctx.action.params;
|
|
231
|
+
const r = this.db.getRepository("flowSql");
|
|
232
|
+
const record = await r.findOne({
|
|
233
|
+
filter: { uid }
|
|
234
|
+
});
|
|
235
|
+
const { bind } = this.transformSQL(record.sql);
|
|
236
|
+
ctx.body = bind;
|
|
237
|
+
await next();
|
|
238
|
+
},
|
|
239
|
+
"flowSql:save": async (ctx, next) => {
|
|
240
|
+
const { uid, sql, dataSourceKey } = ctx.action.params.values;
|
|
241
|
+
const r = this.db.getRepository("flowSql");
|
|
242
|
+
await r.updateOrCreate({
|
|
243
|
+
filterKeys: ["uid"],
|
|
244
|
+
values: { uid, sql, dataSourceKey }
|
|
245
|
+
});
|
|
246
|
+
ctx.body = "ok";
|
|
247
|
+
await next();
|
|
248
|
+
},
|
|
249
|
+
"flowSql:run": async (ctx, next) => {
|
|
250
|
+
const { sql, type, filter, bind, dataSourceKey } = ctx.action.params.values;
|
|
251
|
+
const db = this.getDatabaseByDataSourceKey(dataSourceKey);
|
|
252
|
+
ctx.body = await db.runSQL(sql, { type, filter, bind });
|
|
253
|
+
await next();
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
async install() {
|
|
258
|
+
}
|
|
259
|
+
async afterEnable() {
|
|
260
|
+
}
|
|
261
|
+
async afterDisable() {
|
|
262
|
+
}
|
|
263
|
+
async remove() {
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
var plugin_default = PluginFlowEngineServer;
|
|
267
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
268
|
+
0 && (module.exports = {
|
|
269
|
+
PluginFlowEngineServer
|
|
270
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
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 { Cache } from '@nocobase/cache';
|
|
10
|
+
import { Repository, Transaction, Transactionable } from '@nocobase/database';
|
|
11
|
+
import { ChildOptions, SchemaNode } from './dao/ui_schema_node_dao';
|
|
12
|
+
export interface GetJsonSchemaOptions {
|
|
13
|
+
includeAsyncNode?: boolean;
|
|
14
|
+
readFromCache?: boolean;
|
|
15
|
+
transaction?: Transaction;
|
|
16
|
+
}
|
|
17
|
+
export interface GetPropertiesOptions {
|
|
18
|
+
readFromCache?: boolean;
|
|
19
|
+
transaction?: Transaction;
|
|
20
|
+
}
|
|
21
|
+
type BreakRemoveOnType = {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
export interface removeParentOptions extends Transactionable {
|
|
25
|
+
removeParentsIfNoChildren?: boolean;
|
|
26
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
27
|
+
}
|
|
28
|
+
interface InsertAdjacentOptions extends removeParentOptions {
|
|
29
|
+
wrap?: any;
|
|
30
|
+
}
|
|
31
|
+
export declare function transaction(transactionAbleArgPosition?: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
32
|
+
export declare class FlowModelRepository extends Repository {
|
|
33
|
+
cache: Cache;
|
|
34
|
+
get flowModelsTableName(): any;
|
|
35
|
+
get flowModelTreePathTableName(): any;
|
|
36
|
+
static schemaToSingleNodes(schema: any, carry?: SchemaNode[], childOptions?: ChildOptions): SchemaNode[];
|
|
37
|
+
setCache(cache: Cache): void;
|
|
38
|
+
/**
|
|
39
|
+
* clear cache with xUid which in flowModelTreePath's Path
|
|
40
|
+
* @param {string} xUid
|
|
41
|
+
* @param {Transaction} transaction
|
|
42
|
+
* @returns {Promise<void>}
|
|
43
|
+
*/
|
|
44
|
+
clearXUidPathCache(xUid: string, transaction: Transaction): Promise<void>;
|
|
45
|
+
tableNameAdapter(tableName: any): any;
|
|
46
|
+
sqlAdapter(sql: string): string;
|
|
47
|
+
getProperties(uid: string, options?: GetPropertiesOptions): Promise<Partial<{
|
|
48
|
+
uid: any;
|
|
49
|
+
"x-async": boolean;
|
|
50
|
+
}>>;
|
|
51
|
+
getParentJsonSchema(uid: string, options?: GetJsonSchemaOptions): Promise<any>;
|
|
52
|
+
getParentProperty(uid: string, options?: GetPropertiesOptions): Promise<any>;
|
|
53
|
+
getJsonSchema(uid: string, options?: GetJsonSchemaOptions): Promise<any>;
|
|
54
|
+
nodesToSchema(nodes: any, rootUid: any): {
|
|
55
|
+
uid: any;
|
|
56
|
+
"x-async": boolean;
|
|
57
|
+
};
|
|
58
|
+
clearAncestor(uid: string, options?: Transactionable): Promise<void>;
|
|
59
|
+
emitAfterSaveEvent(s: any, options: any): Promise<void>;
|
|
60
|
+
patch(newSchema: any, options?: any): Promise<void>;
|
|
61
|
+
initializeActionContext(newSchema: any, options?: any): Promise<void>;
|
|
62
|
+
batchPatch(schemas: any[], options?: any): Promise<void>;
|
|
63
|
+
removeEmptyParents(options: Transactionable & {
|
|
64
|
+
uid: string;
|
|
65
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
recursivelyRemoveIfNoChildren(options: Transactionable & {
|
|
68
|
+
uid: string;
|
|
69
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
remove(uid: string, options?: Transactionable & removeParentOptions): Promise<void>;
|
|
72
|
+
insertAdjacent(position: 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd', target: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
73
|
+
duplicate(uid: string, options?: Transactionable): Promise<any>;
|
|
74
|
+
insert(schema: any, options?: Transactionable): Promise<any>;
|
|
75
|
+
insertNewSchema(schema: any, options?: Transactionable & {
|
|
76
|
+
returnNode?: boolean;
|
|
77
|
+
}): Promise<any>;
|
|
78
|
+
insertSingleNode(schema: SchemaNode, options: Transactionable & removeParentOptions): Promise<any>;
|
|
79
|
+
protected updateNode(uid: string, schema: any, transaction?: Transaction): Promise<void>;
|
|
80
|
+
protected childrenCount(uid: any, transaction: any): Promise<number>;
|
|
81
|
+
protected isLeafNode(uid: any, transaction: any): Promise<boolean>;
|
|
82
|
+
protected findParentUid(uid: any, transaction?: any): Promise<string>;
|
|
83
|
+
protected findNodeSchemaWithParent(uid: any, transaction: any): Promise<{
|
|
84
|
+
parentUid: string;
|
|
85
|
+
schema: any;
|
|
86
|
+
}>;
|
|
87
|
+
protected isSingleChild(uid: any, transaction: any): Promise<any>;
|
|
88
|
+
protected insertBeside(targetUid: string, schema: any, side: 'before' | 'after', options?: InsertAdjacentOptions): Promise<any>;
|
|
89
|
+
protected insertInner(targetUid: string, schema: any, position: 'first' | 'last', options?: InsertAdjacentOptions): Promise<any>;
|
|
90
|
+
protected insertAfterBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
91
|
+
protected insertBeforeEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
92
|
+
protected insertBeforeBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
93
|
+
protected insertAfterEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
94
|
+
protected insertNodes(nodes: SchemaNode[], options?: Transactionable): Promise<any[]>;
|
|
95
|
+
private doGetProperties;
|
|
96
|
+
findNodesById(uid: string, options?: GetJsonSchemaOptions): Promise<unknown[]>;
|
|
97
|
+
private doGetJsonSchema;
|
|
98
|
+
private ignoreSchemaProperties;
|
|
99
|
+
private breakOnMatched;
|
|
100
|
+
private schemaExists;
|
|
101
|
+
private regenerateUid;
|
|
102
|
+
private insertSchemaRecord;
|
|
103
|
+
private prepareSingleNodeForInsert;
|
|
104
|
+
static modelToSingleNodes(model: any, parentChildOptions?: any): SchemaNode[];
|
|
105
|
+
static nodeToModel(node: any): any;
|
|
106
|
+
static nodesToModel(nodes: any[], rootUid: string): any;
|
|
107
|
+
insertModel(model: any, options?: Transactionable): Promise<any>;
|
|
108
|
+
updateSingleNode(node: SchemaNode, options?: Transactionable): Promise<boolean>;
|
|
109
|
+
upsertModel(model: any, options?: Transactionable): Promise<string>;
|
|
110
|
+
findModelById(uid: string, options?: GetJsonSchemaOptions): Promise<any>;
|
|
111
|
+
findModelByParentId(parentUid: string, options?: GetJsonSchemaOptions & {
|
|
112
|
+
subKey?: string;
|
|
113
|
+
}): Promise<any>;
|
|
114
|
+
move(options: any): Promise<any>;
|
|
115
|
+
}
|
|
116
|
+
export default FlowModelRepository;
|