@nocobase/plugin-flow-engine 2.1.0-beta.2 → 2.1.0-beta.20
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 +201 -661
- package/README.md +79 -9
- package/dist/ai/ai-employees/nathan/index.d.ts +10 -0
- package/dist/ai/ai-employees/nathan/index.js +41 -0
- package/dist/ai/ai-employees/nathan/prompt.md +132 -0
- package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +69 -0
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +2 -2
- package/dist/ai/docs/runjs/context/block-model.md +35 -35
- package/dist/ai/docs/runjs/context/collection-field.md +53 -51
- package/dist/ai/docs/runjs/context/collection.md +39 -39
- package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
- package/dist/ai/docs/runjs/context/data-source.md +52 -44
- package/dist/ai/docs/runjs/context/element.md +44 -38
- package/dist/ai/docs/runjs/context/exit-all.md +37 -35
- package/dist/ai/docs/runjs/context/exit.md +38 -35
- package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
- package/dist/ai/docs/runjs/context/form.md +57 -57
- package/dist/ai/docs/runjs/context/get-model.md +22 -21
- package/dist/ai/docs/runjs/context/get-value.md +20 -19
- package/dist/ai/docs/runjs/context/get-var.md +61 -55
- package/dist/ai/docs/runjs/context/i18n.md +17 -14
- package/dist/ai/docs/runjs/context/import-async.md +333 -45
- package/dist/ai/docs/runjs/context/init-resource.md +20 -20
- package/dist/ai/docs/runjs/context/libs.md +31 -31
- package/dist/ai/docs/runjs/context/location.md +34 -31
- package/dist/ai/docs/runjs/context/logger.md +41 -40
- package/dist/ai/docs/runjs/context/make-resource.md +27 -26
- package/dist/ai/docs/runjs/context/message.md +42 -41
- package/dist/ai/docs/runjs/context/modal.md +44 -44
- package/dist/ai/docs/runjs/context/model.md +36 -33
- package/dist/ai/docs/runjs/context/notification.md +41 -40
- package/dist/ai/docs/runjs/context/off.md +14 -14
- package/dist/ai/docs/runjs/context/on.md +30 -29
- package/dist/ai/docs/runjs/context/open-view.md +40 -40
- package/dist/ai/docs/runjs/context/render.md +37 -32
- package/dist/ai/docs/runjs/context/request.md +46 -45
- package/dist/ai/docs/runjs/context/require-async.md +28 -25
- package/dist/ai/docs/runjs/context/resource.md +34 -34
- package/dist/ai/docs/runjs/context/route.md +36 -34
- package/dist/ai/docs/runjs/context/router.md +43 -31
- package/dist/ai/docs/runjs/context/set-value.md +18 -17
- package/dist/ai/docs/runjs/context/sql.md +7 -15
- package/dist/ai/docs/runjs/context/t.md +20 -17
- package/dist/ai/docs/runjs/context/view.md +49 -46
- package/dist/ai/docs/runjs/document.md +1 -0
- package/dist/ai/docs/runjs/import-modules.md +32 -32
- package/dist/ai/docs/runjs/index.md +13 -13
- package/dist/ai/docs/runjs/jsx.md +19 -19
- package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
- package/dist/ai/docs/runjs/render.md +15 -15
- package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
- package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
- package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
- package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
- package/dist/ai/docs/runjs/window.md +5 -5
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +12 -11
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/ses/dist/ses.cjs +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/collections/flowsql.js +1 -0
- package/dist/server/flow-surfaces/action-scope.d.ts +39 -0
- package/dist/server/flow-surfaces/action-scope.js +156 -0
- package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
- package/dist/server/flow-surfaces/apply/compiler.js +969 -0
- package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
- package/dist/server/flow-surfaces/apply/layout.js +175 -0
- package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
- package/dist/server/flow-surfaces/apply/matching.js +181 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
- package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
- package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
- package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
- package/dist/server/flow-surfaces/approval/builder.js +384 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
- package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
- package/dist/server/flow-surfaces/approval/index.js +40 -0
- package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
- package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
- package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
- package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
- package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
- package/dist/server/flow-surfaces/association-title-field.js +192 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1029 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
- package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
- package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
- package/dist/server/flow-surfaces/blueprint/index.js +44 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.js +416 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
- package/dist/server/flow-surfaces/blueprint/public-types.d.ts +193 -0
- package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
- package/dist/server/flow-surfaces/builder.d.ts +211 -0
- package/dist/server/flow-surfaces/builder.js +1097 -0
- package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
- package/dist/server/flow-surfaces/catalog-smart.js +239 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
- package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
- package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
- package/dist/server/flow-surfaces/catalog.d.ts +78 -0
- package/dist/server/flow-surfaces/catalog.js +3577 -0
- package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
- package/dist/server/flow-surfaces/chart-config.js +1394 -0
- package/dist/server/flow-surfaces/compose-compiler.d.ts +108 -0
- package/dist/server/flow-surfaces/compose-compiler.js +167 -0
- package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
- package/dist/server/flow-surfaces/compose-runtime.js +375 -0
- package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
- package/dist/server/flow-surfaces/configure-options.js +860 -0
- package/dist/server/flow-surfaces/constants.d.ts +351 -0
- package/dist/server/flow-surfaces/constants.js +104 -0
- package/dist/server/flow-surfaces/context.d.ts +72 -0
- package/dist/server/flow-surfaces/context.js +556 -0
- package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
- package/dist/server/flow-surfaces/contract-guard.js +402 -0
- package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
- package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
- package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
- package/dist/server/flow-surfaces/default-action-popup.js +322 -0
- package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
- package/dist/server/flow-surfaces/default-block-actions.js +209 -0
- package/dist/server/flow-surfaces/errors.d.ts +47 -0
- package/dist/server/flow-surfaces/errors.js +145 -0
- package/dist/server/flow-surfaces/executor.d.ts +23 -0
- package/dist/server/flow-surfaces/executor.js +132 -0
- package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
- package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
- package/dist/server/flow-surfaces/field-semantics.js +83 -0
- package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
- package/dist/server/flow-surfaces/filter-group.js +94 -0
- package/dist/server/flow-surfaces/index.d.ts +11 -0
- package/dist/server/flow-surfaces/index.js +302 -0
- package/dist/server/flow-surfaces/locator.d.ts +28 -0
- package/dist/server/flow-surfaces/locator.js +240 -0
- package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
- package/dist/server/flow-surfaces/node-use-sets.js +134 -0
- package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
- package/dist/server/flow-surfaces/payload-shape.js +61 -0
- package/dist/server/flow-surfaces/placement.d.ts +33 -0
- package/dist/server/flow-surfaces/placement.js +198 -0
- package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
- package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
- package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/compiler.js +376 -0
- package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
- package/dist/server/flow-surfaces/planning/context.js +139 -0
- package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
- package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
- package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
- package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
- package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
- package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
- package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/runtime.js +259 -0
- package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
- package/dist/server/flow-surfaces/planning/step-link.js +104 -0
- package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
- package/dist/server/flow-surfaces/planning/types.js +24 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +24 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +152 -0
- package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
- package/dist/server/flow-surfaces/reaction/errors.js +69 -0
- package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
- package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
- package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
- package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
- package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
- package/dist/server/flow-surfaces/reaction/meta.js +451 -0
- package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
- package/dist/server/flow-surfaces/reaction/registry.js +206 -0
- package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
- package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
- package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
- package/dist/server/flow-surfaces/reaction/types.js +24 -0
- package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
- package/dist/server/flow-surfaces/reaction/utils.js +67 -0
- package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
- package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
- package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
- package/dist/server/flow-surfaces/reference-guards.js +103 -0
- package/dist/server/flow-surfaces/route-sync.d.ts +47 -0
- package/dist/server/flow-surfaces/route-sync.js +392 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
- package/dist/server/flow-surfaces/service-helpers.js +310 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +108 -0
- package/dist/server/flow-surfaces/service-utils.js +811 -0
- package/dist/server/flow-surfaces/service.d.ts +814 -0
- package/dist/server/flow-surfaces/service.js +14276 -0
- package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
- package/dist/server/flow-surfaces/support-matrix.js +271 -0
- package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
- package/dist/server/flow-surfaces/surface-context.js +440 -0
- package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
- package/dist/server/flow-surfaces/template-compatibility.js +189 -0
- package/dist/server/flow-surfaces/template-display.d.ts +20 -0
- package/dist/server/flow-surfaces/template-display.js +289 -0
- package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
- package/dist/server/flow-surfaces/template-service-utils.js +281 -0
- package/dist/server/flow-surfaces/types.d.ts +288 -0
- package/dist/server/flow-surfaces/types.js +24 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +7 -2
- package/dist/server/plugin.d.ts +0 -1
- package/dist/server/plugin.js +9 -34
- package/dist/server/repository.js +0 -5
- package/dist/server/variables/resolve.d.ts +21 -0
- package/dist/server/variables/resolve.js +79 -0
- package/dist/swagger/flow-surfaces.d.ts +5964 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +1572 -0
- package/dist/swagger/flow-surfaces.examples.js +1805 -0
- package/dist/swagger/flow-surfaces.js +5322 -0
- package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
- package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
- package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
- package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
- package/dist/swagger/index.d.ts +5969 -0
- package/dist/swagger/index.js +50 -0
- package/package.json +3 -3
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
|
@@ -0,0 +1,302 @@
|
|
|
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 flow_surfaces_exports = {};
|
|
28
|
+
__export(flow_surfaces_exports, {
|
|
29
|
+
registerFlowSurfacesResource: () => registerFlowSurfacesResource
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(flow_surfaces_exports);
|
|
32
|
+
var import_resourcer = require("@nocobase/resourcer");
|
|
33
|
+
var import_constants = require("./constants");
|
|
34
|
+
var import_errors = require("./errors");
|
|
35
|
+
var import_service = require("./service");
|
|
36
|
+
const FLOW_ENGINE_LOCALE_NAMESPACE = "flow-engine";
|
|
37
|
+
const FLOW_SURFACE_LOCALE_FALLBACK_NAMESPACES = [
|
|
38
|
+
FLOW_ENGINE_LOCALE_NAMESPACE,
|
|
39
|
+
"@nocobase/flow-engine",
|
|
40
|
+
"@nocobase/plugin-flow-engine",
|
|
41
|
+
"client"
|
|
42
|
+
];
|
|
43
|
+
const FLOW_SURFACE_LOCAL_TRANSLATIONS = {
|
|
44
|
+
"zh-CN": {
|
|
45
|
+
"Popup for Add New": "\u65B0\u589E\u5F39\u7A97",
|
|
46
|
+
"Popup for Edit": "\u7F16\u8F91\u5F39\u7A97",
|
|
47
|
+
"Popup for Details": "\u8BE6\u60C5\u5F39\u7A97",
|
|
48
|
+
"Auto generated": "\u81EA\u52A8\u751F\u6210",
|
|
49
|
+
'Automatically generated popup template for collection "{{collectionLabel}}" ({{popupLabel}}).': "\u4E3A\u6570\u636E\u8868\u201C{{collectionLabel}}\u201D\u81EA\u52A8\u751F\u6210\u7684\u5F39\u7A97\u6A21\u677F\uFF08{{popupLabel}}\uFF09\u3002",
|
|
50
|
+
'Automatically generated popup template for relation field "{{associationFieldLabel}}" in collection "{{sourceCollectionLabel}}", targeting "{{targetCollectionLabel}}" ({{popupLabel}}).': "\u4E3A\u6570\u636E\u8868\u201C{{sourceCollectionLabel}}\u201D\u4E2D\u7684\u5173\u7CFB\u5B57\u6BB5\u201C{{associationFieldLabel}}\u201D\u81EA\u52A8\u751F\u6210\u7684\u5F39\u7A97\u6A21\u677F\uFF0C\u76EE\u6807\u6570\u636E\u8868\u4E3A\u201C{{targetCollectionLabel}}\u201D\uFF08{{popupLabel}}\uFF09\u3002"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function getValues(ctx) {
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
55
|
+
const values = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? ((_c = ctx.action) == null ? void 0 : _c.params) ?? {};
|
|
56
|
+
const actionName = (_d = ctx.action) == null ? void 0 : _d.actionName;
|
|
57
|
+
if (isInvalidFlowSurfaceWritePayload(values) && actionName && !((_e = import_constants.FLOW_SURFACE_ACTION_DEFINITIONS[actionName]) == null ? void 0 : _e.read)) {
|
|
58
|
+
throw new import_errors.FlowSurfaceBadRequestError(getFlowSurfaceWritePayloadMessage(actionName));
|
|
59
|
+
}
|
|
60
|
+
return values;
|
|
61
|
+
}
|
|
62
|
+
function isImplicitEmptyValuesBag(value) {
|
|
63
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype && Object.keys(value).length === 0;
|
|
64
|
+
}
|
|
65
|
+
function getRawReadQuery(ctx) {
|
|
66
|
+
var _a;
|
|
67
|
+
const querystring = String(((_a = ctx.request) == null ? void 0 : _a.querystring) ?? "");
|
|
68
|
+
if (!querystring) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
return (0, import_resourcer.parseQuery)(querystring) || {};
|
|
73
|
+
} catch {
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function hasExplicitQueryWrapper(ctx, key) {
|
|
78
|
+
const query = getRawReadQuery(ctx);
|
|
79
|
+
return Object.prototype.hasOwnProperty.call(query, key);
|
|
80
|
+
}
|
|
81
|
+
function hasExplicitRequestBody(ctx) {
|
|
82
|
+
var _a;
|
|
83
|
+
const headers = ((_a = ctx.request) == null ? void 0 : _a.headers) ?? {};
|
|
84
|
+
const contentLength = headers["content-length"];
|
|
85
|
+
if (Array.isArray(contentLength)) {
|
|
86
|
+
return contentLength.some((value) => value !== "0");
|
|
87
|
+
}
|
|
88
|
+
if (typeof contentLength === "string") {
|
|
89
|
+
return contentLength !== "0";
|
|
90
|
+
}
|
|
91
|
+
return Boolean(headers["transfer-encoding"]);
|
|
92
|
+
}
|
|
93
|
+
function getReadValues(ctx) {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
if (((_b = (_a = ctx.request) == null ? void 0 : _a.method) == null ? void 0 : _b.toUpperCase()) !== "GET") {
|
|
96
|
+
(0, import_errors.throwBadRequest)(
|
|
97
|
+
`flowSurfaces:get only supports GET with root query locator fields like /api/flowSurfaces:get?uid=...`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (hasExplicitQueryWrapper(ctx, "target")) {
|
|
101
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces:get only accepts root locator fields; do not wrap them in 'target'`);
|
|
102
|
+
}
|
|
103
|
+
if (hasExplicitQueryWrapper(ctx, "values")) {
|
|
104
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces:get only accepts root locator fields; do not wrap them in 'values'`);
|
|
105
|
+
}
|
|
106
|
+
const params = ((_c = ctx.action) == null ? void 0 : _c.params) ?? {};
|
|
107
|
+
if (!Object.prototype.hasOwnProperty.call(params, "values")) {
|
|
108
|
+
return params;
|
|
109
|
+
}
|
|
110
|
+
const values = params.values;
|
|
111
|
+
if (typeof values !== "undefined" && !isImplicitEmptyValuesBag(values)) {
|
|
112
|
+
return params;
|
|
113
|
+
}
|
|
114
|
+
if (hasExplicitRequestBody(ctx)) {
|
|
115
|
+
return params;
|
|
116
|
+
}
|
|
117
|
+
const { values: _values, ...rest } = params;
|
|
118
|
+
return rest;
|
|
119
|
+
}
|
|
120
|
+
function writeFlowSurfaceErrorResponse(ctx, error) {
|
|
121
|
+
const normalized = (0, import_errors.normalizeFlowSurfaceError)(error);
|
|
122
|
+
ctx.withoutDataWrapping = true;
|
|
123
|
+
ctx.type = "application/json";
|
|
124
|
+
ctx.status = normalized.status;
|
|
125
|
+
ctx.body = normalized.toResponseBody();
|
|
126
|
+
}
|
|
127
|
+
function isFlowSurfaceWriteActionName(value) {
|
|
128
|
+
return Object.prototype.hasOwnProperty.call(import_constants.FLOW_SURFACE_ACTION_DEFINITIONS, value);
|
|
129
|
+
}
|
|
130
|
+
function getFlowSurfaceRequestActionName(ctx) {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
const actionName = String(((_a = ctx.action) == null ? void 0 : _a.actionName) || "").trim();
|
|
133
|
+
if (isFlowSurfaceWriteActionName(actionName)) {
|
|
134
|
+
return actionName;
|
|
135
|
+
}
|
|
136
|
+
const path = String(ctx.path || ((_b = ctx.request) == null ? void 0 : _b.path) || "").trim();
|
|
137
|
+
const match = path.match(/(?:^|\/)flowSurfaces:([^/?#]+)$/);
|
|
138
|
+
const rawActionName = String((match == null ? void 0 : match[1]) || "").trim();
|
|
139
|
+
return isFlowSurfaceWriteActionName(rawActionName) ? rawActionName : void 0;
|
|
140
|
+
}
|
|
141
|
+
function isFlowSurfaceWriteRequest(ctx) {
|
|
142
|
+
var _a;
|
|
143
|
+
if (String(((_a = ctx.request) == null ? void 0 : _a.method) || "").toUpperCase() !== "POST") {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const actionName = getFlowSurfaceRequestActionName(ctx);
|
|
147
|
+
return !!actionName && import_constants.FLOW_SURFACE_ACTION_DEFINITIONS[actionName].read === false;
|
|
148
|
+
}
|
|
149
|
+
function isInvalidFlowSurfaceWritePayload(value) {
|
|
150
|
+
if (!value || typeof value !== "object") {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
return Array.isArray(value);
|
|
154
|
+
}
|
|
155
|
+
function getFlowSurfaceWritePayloadMessage(actionName) {
|
|
156
|
+
const noun = actionName === "applyBlueprint" || actionName === "applyApprovalBlueprint" ? "payload" : "values";
|
|
157
|
+
return `flowSurfaces ${actionName} ${noun} must be an object`;
|
|
158
|
+
}
|
|
159
|
+
function isFlowSurfaceWriteBodyParserShapeError(error) {
|
|
160
|
+
const parserError = error;
|
|
161
|
+
return error instanceof SyntaxError && parserError.status === 400 && parserError.message === "invalid JSON, only supports object and array";
|
|
162
|
+
}
|
|
163
|
+
async function runFlowSurfaceWriteBodyParserErrorWrapper(ctx, next) {
|
|
164
|
+
try {
|
|
165
|
+
await next();
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (!isFlowSurfaceWriteRequest(ctx) || !isFlowSurfaceWriteBodyParserShapeError(error)) {
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
const actionName = getFlowSurfaceRequestActionName(ctx);
|
|
171
|
+
if (!actionName) {
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
writeFlowSurfaceErrorResponse(ctx, new import_errors.FlowSurfaceBadRequestError(getFlowSurfaceWritePayloadMessage(actionName)));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function isAclPermissionDeniedForFlowSurfaces(ctx, error) {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
const resourceName = ((_a = ctx.action) == null ? void 0 : _a.resourceName) ?? ((_b = ctx.permission) == null ? void 0 : _b.resourceName);
|
|
180
|
+
return resourceName === "flowSurfaces" && (error == null ? void 0 : error.status) === 403 && (error == null ? void 0 : error.message) === "No permissions";
|
|
181
|
+
}
|
|
182
|
+
function toFlowSurfaceForbiddenError(error) {
|
|
183
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
184
|
+
return new import_errors.FlowSurfaceForbiddenError(message);
|
|
185
|
+
}
|
|
186
|
+
async function runFlowSurfaceAclErrorWrapper(ctx, next) {
|
|
187
|
+
try {
|
|
188
|
+
await next();
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (!isAclPermissionDeniedForFlowSurfaces(ctx, error)) {
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
writeFlowSurfaceErrorResponse(ctx, toFlowSurfaceForbiddenError(error));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function runFlowSurfaceAction(ctx, next, handler) {
|
|
197
|
+
try {
|
|
198
|
+
ctx.body = await handler();
|
|
199
|
+
await next();
|
|
200
|
+
} catch (error) {
|
|
201
|
+
writeFlowSurfaceErrorResponse(ctx, error);
|
|
202
|
+
await next();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function invokeFlowSurfaceServiceAction(service, actionName, values, options = {}) {
|
|
206
|
+
const handler = service[actionName];
|
|
207
|
+
return handler.call(service, values, options);
|
|
208
|
+
}
|
|
209
|
+
function interpolateTranslation(value, options) {
|
|
210
|
+
return value.replace(/\{\{\s*([^}\s]+)\s*\}\}/g, (_match, name) => {
|
|
211
|
+
const replacement = options == null ? void 0 : options[name];
|
|
212
|
+
return replacement === null || typeof replacement === "undefined" ? "" : String(replacement);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function getResourceTranslation(ctx, key, options) {
|
|
216
|
+
var _a, _b, _c, _d;
|
|
217
|
+
const locale = ((_a = ctx.getCurrentLocale) == null ? void 0 : _a.call(ctx)) || ((_b = ctx.i18n) == null ? void 0 : _b.language);
|
|
218
|
+
const i18n = (_c = ctx.app) == null ? void 0 : _c.i18n;
|
|
219
|
+
if (!locale || !i18n) {
|
|
220
|
+
return void 0;
|
|
221
|
+
}
|
|
222
|
+
for (const ns of FLOW_SURFACE_LOCALE_FALLBACK_NAMESPACES) {
|
|
223
|
+
const value = (_d = i18n.getResource) == null ? void 0 : _d.call(i18n, locale, ns, key);
|
|
224
|
+
if (typeof value === "string") {
|
|
225
|
+
return interpolateTranslation(value, options);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return void 0;
|
|
229
|
+
}
|
|
230
|
+
function getLocalTranslation(ctx, key, options) {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
const locale = String(((_a = ctx.getCurrentLocale) == null ? void 0 : _a.call(ctx)) || ((_b = ctx.i18n) == null ? void 0 : _b.language) || "").trim();
|
|
233
|
+
const resources = FLOW_SURFACE_LOCAL_TRANSLATIONS[locale];
|
|
234
|
+
const value = resources == null ? void 0 : resources[key];
|
|
235
|
+
return typeof value === "string" ? interpolateTranslation(value, options) : void 0;
|
|
236
|
+
}
|
|
237
|
+
function getFlowSurfaceTranslate(ctx) {
|
|
238
|
+
var _a, _b, _c;
|
|
239
|
+
const translate = ((_b = (_a = ctx.i18n) == null ? void 0 : _a.t) == null ? void 0 : _b.bind(ctx.i18n)) || ((_c = ctx.t) == null ? void 0 : _c.bind(ctx));
|
|
240
|
+
if (typeof translate !== "function") {
|
|
241
|
+
return void 0;
|
|
242
|
+
}
|
|
243
|
+
return (key, options) => {
|
|
244
|
+
const resourceValue = getResourceTranslation(ctx, key, options);
|
|
245
|
+
if (typeof resourceValue === "string") {
|
|
246
|
+
return resourceValue;
|
|
247
|
+
}
|
|
248
|
+
const localValue = getLocalTranslation(ctx, key, options);
|
|
249
|
+
if (typeof localValue === "string") {
|
|
250
|
+
return localValue;
|
|
251
|
+
}
|
|
252
|
+
return translate(key, {
|
|
253
|
+
ns: [FLOW_ENGINE_LOCALE_NAMESPACE, "client"],
|
|
254
|
+
nsMode: "fallback",
|
|
255
|
+
...options || {}
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function registerFlowSurfacesResource(plugin) {
|
|
260
|
+
const service = new import_service.FlowSurfacesService(plugin);
|
|
261
|
+
const actions = Object.fromEntries(
|
|
262
|
+
import_constants.FLOW_SURFACES_ACTION_NAMES.map((actionName) => [
|
|
263
|
+
actionName,
|
|
264
|
+
async (ctx, next) => {
|
|
265
|
+
await runFlowSurfaceAction(ctx, next, async () => {
|
|
266
|
+
const definition = import_constants.FLOW_SURFACE_ACTION_DEFINITIONS[actionName];
|
|
267
|
+
const values = definition.valueSource === "read" ? getReadValues(ctx) : getValues(ctx);
|
|
268
|
+
const t = getFlowSurfaceTranslate(ctx);
|
|
269
|
+
if (definition.transaction) {
|
|
270
|
+
return service.transaction(
|
|
271
|
+
(transaction) => invokeFlowSurfaceServiceAction(service, actionName, values, { transaction, t })
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
return invokeFlowSurfaceServiceAction(service, actionName, values, { t });
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
])
|
|
278
|
+
);
|
|
279
|
+
plugin.app.acl.registerSnippet({
|
|
280
|
+
name: "ui.flowSurfaces",
|
|
281
|
+
actions: ["flowSurfaces:*"]
|
|
282
|
+
});
|
|
283
|
+
plugin.app.acl.allow("flowSurfaces", [...import_constants.FLOW_SURFACES_READ_ACTION_NAMES], "loggedIn");
|
|
284
|
+
plugin.app.acl.use(runFlowSurfaceAclErrorWrapper, {
|
|
285
|
+
tag: "flow-surfaces-acl-errors",
|
|
286
|
+
after: "allow-manager",
|
|
287
|
+
before: "core"
|
|
288
|
+
});
|
|
289
|
+
plugin.app.use(runFlowSurfaceWriteBodyParserErrorWrapper, {
|
|
290
|
+
tag: "flow-surfaces-write-body-errors",
|
|
291
|
+
before: "bodyParser"
|
|
292
|
+
});
|
|
293
|
+
plugin.app.resourceManager.define({
|
|
294
|
+
name: "flowSurfaces",
|
|
295
|
+
actions
|
|
296
|
+
});
|
|
297
|
+
return service;
|
|
298
|
+
}
|
|
299
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
300
|
+
0 && (module.exports = {
|
|
301
|
+
registerFlowSurfacesResource
|
|
302
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
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 FlowModelRepository from '../repository';
|
|
10
|
+
import type { FlowSurfaceResolveTarget, FlowSurfaceResolvedTarget } from './types';
|
|
11
|
+
export declare class SurfaceLocator {
|
|
12
|
+
private readonly db;
|
|
13
|
+
private readonly repository;
|
|
14
|
+
constructor(db: any, repository: FlowModelRepository);
|
|
15
|
+
resolve(target: FlowSurfaceResolveTarget, options?: {
|
|
16
|
+
transaction?: any;
|
|
17
|
+
}): Promise<FlowSurfaceResolvedTarget>;
|
|
18
|
+
findParentUid(uid: string, transaction?: any): Promise<any>;
|
|
19
|
+
findRouteBySchemaUid(schemaUid: string, transaction?: any): Promise<any>;
|
|
20
|
+
resolveCollectionContext(uid: string, transaction?: any): Promise<{
|
|
21
|
+
ownerUid: string;
|
|
22
|
+
model: any;
|
|
23
|
+
resourceInit: any;
|
|
24
|
+
}>;
|
|
25
|
+
private resolveByUid;
|
|
26
|
+
private resolvePageSchemaUid;
|
|
27
|
+
private findPageRouteFromModel;
|
|
28
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
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 locator_exports = {};
|
|
38
|
+
__export(locator_exports, {
|
|
39
|
+
SurfaceLocator: () => SurfaceLocator
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(locator_exports);
|
|
42
|
+
var import_lodash = __toESM(require("lodash"));
|
|
43
|
+
var import_approval = require("./approval");
|
|
44
|
+
var import_chart_config = require("./chart-config");
|
|
45
|
+
var import_errors = require("./errors");
|
|
46
|
+
class SurfaceLocator {
|
|
47
|
+
constructor(db, repository) {
|
|
48
|
+
this.db = db;
|
|
49
|
+
this.repository = repository;
|
|
50
|
+
}
|
|
51
|
+
async resolve(target, options = {}) {
|
|
52
|
+
var _a;
|
|
53
|
+
const transaction = options.transaction;
|
|
54
|
+
if (target.uid) {
|
|
55
|
+
return this.resolveByUid(target.uid, target, transaction);
|
|
56
|
+
}
|
|
57
|
+
if ("tabSchemaUid" in target && target.tabSchemaUid) {
|
|
58
|
+
return this.resolveByUid(target.tabSchemaUid, target, transaction);
|
|
59
|
+
}
|
|
60
|
+
if ("pageSchemaUid" in target && target.pageSchemaUid) {
|
|
61
|
+
return this.resolvePageSchemaUid(target.pageSchemaUid, target, transaction);
|
|
62
|
+
}
|
|
63
|
+
if ("routeId" in target && target.routeId) {
|
|
64
|
+
const route = await this.db.getRepository("desktopRoutes").findOne({
|
|
65
|
+
filterByTk: String(target.routeId),
|
|
66
|
+
transaction
|
|
67
|
+
});
|
|
68
|
+
if (isPageRoute(route)) {
|
|
69
|
+
return this.resolvePageSchemaUid(route.get("schemaUid"), target, transaction);
|
|
70
|
+
}
|
|
71
|
+
if ((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "schemaUid")) {
|
|
72
|
+
return this.resolveByUid(route.get("schemaUid"), target, transaction);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
throw new import_errors.FlowSurfaceBadRequestError("flowSurfaces target not found");
|
|
76
|
+
}
|
|
77
|
+
async findParentUid(uid, transaction) {
|
|
78
|
+
var _a;
|
|
79
|
+
const parentPath = await this.db.getRepository("flowModelTreePath").findOne({
|
|
80
|
+
filter: {
|
|
81
|
+
descendant: uid,
|
|
82
|
+
depth: 1
|
|
83
|
+
},
|
|
84
|
+
transaction
|
|
85
|
+
});
|
|
86
|
+
return ((_a = parentPath == null ? void 0 : parentPath.get) == null ? void 0 : _a.call(parentPath, "ancestor")) || null;
|
|
87
|
+
}
|
|
88
|
+
async findRouteBySchemaUid(schemaUid, transaction) {
|
|
89
|
+
return this.db.getRepository("desktopRoutes").findOne({
|
|
90
|
+
filter: {
|
|
91
|
+
schemaUid
|
|
92
|
+
},
|
|
93
|
+
transaction
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async resolveCollectionContext(uid, transaction) {
|
|
97
|
+
let cursor = uid;
|
|
98
|
+
while (cursor) {
|
|
99
|
+
const model = await this.repository.findModelById(cursor, { transaction, includeAsyncNode: true });
|
|
100
|
+
const resourceInit = import_lodash.default.get(model, ["stepParams", "resourceSettings", "init"]) || import_lodash.default.get(model, ["stepParams", "TriggerChildPageSettings", "init"]) || import_lodash.default.get(model, ["stepParams", "ApprovalChildPageSettings", "init"]) || ((model == null ? void 0 : model.use) === "ChartBlockModel" ? (0, import_chart_config.getChartBuilderResourceInit)(import_lodash.default.get(model, ["stepParams", "chartSettings", "configure"])) : null);
|
|
101
|
+
if ((resourceInit == null ? void 0 : resourceInit.dataSourceKey) && (resourceInit == null ? void 0 : resourceInit.collectionName)) {
|
|
102
|
+
return {
|
|
103
|
+
ownerUid: cursor,
|
|
104
|
+
model,
|
|
105
|
+
resourceInit
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const fieldInit = import_lodash.default.get(model, ["stepParams", "fieldSettings", "init"]);
|
|
109
|
+
if ((fieldInit == null ? void 0 : fieldInit.dataSourceKey) && (fieldInit == null ? void 0 : fieldInit.collectionName)) {
|
|
110
|
+
return {
|
|
111
|
+
ownerUid: cursor,
|
|
112
|
+
model,
|
|
113
|
+
resourceInit: {
|
|
114
|
+
dataSourceKey: fieldInit.dataSourceKey,
|
|
115
|
+
collectionName: fieldInit.collectionName,
|
|
116
|
+
associationPathName: fieldInit.associationPathName
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
cursor = await this.findParentUid(cursor, transaction);
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
async resolveByUid(uid, target, transaction) {
|
|
125
|
+
var _a, _b, _c, _d, _e;
|
|
126
|
+
const node = await this.repository.findModelById(uid, { transaction, includeAsyncNode: true });
|
|
127
|
+
const route = await this.findRouteBySchemaUid(uid, transaction);
|
|
128
|
+
if (!(node == null ? void 0 : node.uid) && !route) {
|
|
129
|
+
throw new import_errors.FlowSurfaceBadRequestError(`flowSurfaces uid '${uid}' not found`);
|
|
130
|
+
}
|
|
131
|
+
let pageRoute = null;
|
|
132
|
+
let tabRoute = null;
|
|
133
|
+
if (((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "type")) === "tabs") {
|
|
134
|
+
tabRoute = route;
|
|
135
|
+
pageRoute = route.get("parentId") ? await this.db.getRepository("desktopRoutes").findOne({
|
|
136
|
+
filterByTk: String(route.get("parentId")),
|
|
137
|
+
transaction
|
|
138
|
+
}) : null;
|
|
139
|
+
} else if (((_b = route == null ? void 0 : route.get) == null ? void 0 : _b.call(route, "type")) === "flowPage" || ((_c = route == null ? void 0 : route.get) == null ? void 0 : _c.call(route, "type")) === "page") {
|
|
140
|
+
pageRoute = route;
|
|
141
|
+
} else if (node == null ? void 0 : node.uid) {
|
|
142
|
+
pageRoute = await this.findPageRouteFromModel(node.uid, transaction).catch(() => {
|
|
143
|
+
return null;
|
|
144
|
+
}) || null;
|
|
145
|
+
tabRoute = await this.findRouteBySchemaUid(node.uid, transaction);
|
|
146
|
+
if (((_d = tabRoute == null ? void 0 : tabRoute.get) == null ? void 0 : _d.call(tabRoute, "type")) !== "tabs") {
|
|
147
|
+
tabRoute = null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
target,
|
|
152
|
+
uid: (node == null ? void 0 : node.uid) || uid,
|
|
153
|
+
kind: ((_e = tabRoute == null ? void 0 : tabRoute.get) == null ? void 0 : _e.call(tabRoute, "type")) === "tabs" ? "tab" : isPageRoute(pageRoute) ? "page" : inferKind(node == null ? void 0 : node.use),
|
|
154
|
+
node,
|
|
155
|
+
route,
|
|
156
|
+
pageRoute,
|
|
157
|
+
tabRoute
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async resolvePageSchemaUid(pageSchemaUid, target, transaction) {
|
|
161
|
+
var _a;
|
|
162
|
+
const pageModel = await this.repository.findModelByParentId(pageSchemaUid, {
|
|
163
|
+
transaction,
|
|
164
|
+
subKey: "page",
|
|
165
|
+
includeAsyncNode: true
|
|
166
|
+
});
|
|
167
|
+
const route = await this.db.getRepository("desktopRoutes").findOne({
|
|
168
|
+
filter: {
|
|
169
|
+
schemaUid: pageSchemaUid
|
|
170
|
+
},
|
|
171
|
+
transaction
|
|
172
|
+
});
|
|
173
|
+
if (pageModel == null ? void 0 : pageModel.uid) {
|
|
174
|
+
return {
|
|
175
|
+
target,
|
|
176
|
+
uid: pageModel.uid,
|
|
177
|
+
kind: "page",
|
|
178
|
+
node: pageModel,
|
|
179
|
+
route,
|
|
180
|
+
pageRoute: route,
|
|
181
|
+
pageModel
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if ((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "schemaUid")) {
|
|
185
|
+
return {
|
|
186
|
+
target,
|
|
187
|
+
uid: route.get("schemaUid"),
|
|
188
|
+
kind: "page",
|
|
189
|
+
route,
|
|
190
|
+
pageRoute: route,
|
|
191
|
+
pageModel
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
throw new import_errors.FlowSurfaceBadRequestError("flowSurfaces target not found");
|
|
195
|
+
}
|
|
196
|
+
async findPageRouteFromModel(uid, transaction) {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
let cursor = uid;
|
|
199
|
+
while (cursor) {
|
|
200
|
+
const route = await this.findRouteBySchemaUid(cursor, transaction);
|
|
201
|
+
if (((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "type")) === "flowPage" || ((_b = route == null ? void 0 : route.get) == null ? void 0 : _b.call(route, "type")) === "page") {
|
|
202
|
+
return route;
|
|
203
|
+
}
|
|
204
|
+
const parentUid = await this.findParentUid(cursor, transaction);
|
|
205
|
+
if (!parentUid) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
cursor = parentUid;
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function inferKind(use) {
|
|
214
|
+
const normalized = (0, import_approval.normalizeApprovalSemanticUse)(use);
|
|
215
|
+
if (normalized === "RouteModel") {
|
|
216
|
+
return "node";
|
|
217
|
+
}
|
|
218
|
+
if (normalized === "RootPageModel" || normalized === "ChildPageModel") {
|
|
219
|
+
return "page";
|
|
220
|
+
}
|
|
221
|
+
if (normalized === "RootPageTabModel" || normalized === "ChildPageTabModel") {
|
|
222
|
+
return "tab";
|
|
223
|
+
}
|
|
224
|
+
if (/GridModel$/.test(normalized || "")) {
|
|
225
|
+
return "grid";
|
|
226
|
+
}
|
|
227
|
+
if (/BlockModel$/.test(normalized || "")) {
|
|
228
|
+
return "block";
|
|
229
|
+
}
|
|
230
|
+
return "node";
|
|
231
|
+
}
|
|
232
|
+
function isPageRoute(route) {
|
|
233
|
+
var _a;
|
|
234
|
+
const type = ((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "type")) || (route == null ? void 0 : route.type);
|
|
235
|
+
return type === "flowPage" || type === "page";
|
|
236
|
+
}
|
|
237
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
238
|
+
0 && (module.exports = {
|
|
239
|
+
SurfaceLocator
|
|
240
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
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 COLLECTION_BLOCK_USES: Set<string>;
|
|
10
|
+
export declare const STATIC_CONTENT_BLOCK_USES: Set<string>;
|
|
11
|
+
export declare const FIELD_WRAPPER_USES: Set<string>;
|
|
12
|
+
export declare const CREATABLE_STANDALONE_FIELD_USES: Set<string>;
|
|
13
|
+
export declare const STANDALONE_FIELD_NODE_USES: Set<string>;
|
|
14
|
+
export declare const ACTION_BUTTON_USES: Set<string>;
|
|
15
|
+
export declare const JS_BLOCK_USES: Set<string>;
|