@nocobase/plugin-flow-engine 2.1.0-beta.15 → 2.1.0-beta.17
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/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/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 +11 -10
- 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/flow-surfaces/action-scope.d.ts +38 -0
- package/dist/server/flow-surfaces/action-scope.js +152 -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 +158 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1007 -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 +1029 -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 +3496 -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 +827 -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/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 +185 -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 +81 -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 +243 -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 +131 -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 +195 -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 +20 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +111 -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 +377 -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 +773 -0
- package/dist/server/flow-surfaces/service.js +13008 -0
- package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
- package/dist/server/flow-surfaces/support-matrix.js +259 -0
- package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
- package/dist/server/flow-surfaces/surface-context.js +437 -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/plugin.js +2 -0
- package/dist/swagger/flow-surfaces.d.ts +5964 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +1533 -0
- package/dist/swagger/flow-surfaces.examples.js +1758 -0
- package/dist/swagger/flow-surfaces.js +5315 -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 +2 -2
- /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,40 @@
|
|
|
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 { FlowSurfaceBindKey, FlowSurfaceReadLocator } from '../types';
|
|
10
|
+
import type { FlowSurfaceCompiledPlanStep, FlowSurfacePlanSurfaceContext, FlowSurfaceResolvedKey } from './types';
|
|
11
|
+
export declare const FLOW_SURFACE_SYSTEM_KEY = "surface";
|
|
12
|
+
export declare const FLOW_SURFACE_RESERVED_KEYS: Set<string>;
|
|
13
|
+
export declare const FLOW_SURFACE_INTERNAL_META_KEY = "__flowSurfaceMeta";
|
|
14
|
+
export declare const FLOW_SURFACE_DECLARED_KEY_KEY = "declaredKey";
|
|
15
|
+
export declare const FLOW_SURFACE_KEY_NOT_PERSISTABLE_CODE = "FLOW_SURFACE_KEY_NOT_PERSISTABLE";
|
|
16
|
+
export declare function getDeclaredKeyFromNode(node: any): string;
|
|
17
|
+
export declare function normalizeBindKeys(actionName: string, bindKeys: any, deps: {
|
|
18
|
+
normalizeGetTarget: (value: any) => FlowSurfaceReadLocator;
|
|
19
|
+
}): FlowSurfaceBindKey[];
|
|
20
|
+
export declare function collectDeclaredKeysFromTree(node: any, deps: {
|
|
21
|
+
actionName?: string;
|
|
22
|
+
buildPlanKeyKind: (node: any, resolvedKind?: string) => string;
|
|
23
|
+
}, carry?: Map<string, FlowSurfaceResolvedKey>): Map<string, FlowSurfaceResolvedKey>;
|
|
24
|
+
export declare function annotateTreeKey(tree: any, keyByUid: Map<string, string>): any;
|
|
25
|
+
export declare function buildSurfaceKeysObject(keyMap: Map<string, FlowSurfaceResolvedKey>): {
|
|
26
|
+
[k: string]: {
|
|
27
|
+
uid: string;
|
|
28
|
+
kind: string;
|
|
29
|
+
source: "declared" | "request" | "system";
|
|
30
|
+
locator: FlowSurfaceReadLocator;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare function buildSurfaceFingerprintKeysObject(keyMap: Map<string, FlowSurfaceResolvedKey>): {
|
|
34
|
+
[k: string]: {
|
|
35
|
+
uid: string;
|
|
36
|
+
kind: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare function getSurfaceSelectorRequestKey(context: FlowSurfacePlanSurfaceContext): FlowSurfaceResolvedKey;
|
|
40
|
+
export declare function collectRequestKeysToPersist(context: FlowSurfacePlanSurfaceContext, compiledSteps: FlowSurfaceCompiledPlanStep[]): Map<string, FlowSurfaceResolvedKey>;
|
|
@@ -0,0 +1,206 @@
|
|
|
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 key_registry_exports = {};
|
|
38
|
+
__export(key_registry_exports, {
|
|
39
|
+
FLOW_SURFACE_DECLARED_KEY_KEY: () => FLOW_SURFACE_DECLARED_KEY_KEY,
|
|
40
|
+
FLOW_SURFACE_INTERNAL_META_KEY: () => FLOW_SURFACE_INTERNAL_META_KEY,
|
|
41
|
+
FLOW_SURFACE_KEY_NOT_PERSISTABLE_CODE: () => FLOW_SURFACE_KEY_NOT_PERSISTABLE_CODE,
|
|
42
|
+
FLOW_SURFACE_RESERVED_KEYS: () => FLOW_SURFACE_RESERVED_KEYS,
|
|
43
|
+
FLOW_SURFACE_SYSTEM_KEY: () => FLOW_SURFACE_SYSTEM_KEY,
|
|
44
|
+
annotateTreeKey: () => annotateTreeKey,
|
|
45
|
+
buildSurfaceFingerprintKeysObject: () => buildSurfaceFingerprintKeysObject,
|
|
46
|
+
buildSurfaceKeysObject: () => buildSurfaceKeysObject,
|
|
47
|
+
collectDeclaredKeysFromTree: () => collectDeclaredKeysFromTree,
|
|
48
|
+
collectRequestKeysToPersist: () => collectRequestKeysToPersist,
|
|
49
|
+
getDeclaredKeyFromNode: () => getDeclaredKeyFromNode,
|
|
50
|
+
getSurfaceSelectorRequestKey: () => getSurfaceSelectorRequestKey,
|
|
51
|
+
normalizeBindKeys: () => normalizeBindKeys
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(key_registry_exports);
|
|
54
|
+
var import_lodash = __toESM(require("lodash"));
|
|
55
|
+
var import_errors = require("../errors");
|
|
56
|
+
var import_service_utils = require("../service-utils");
|
|
57
|
+
const FLOW_SURFACE_SYSTEM_KEY = "surface";
|
|
58
|
+
const FLOW_SURFACE_RESERVED_KEYS = /* @__PURE__ */ new Set([FLOW_SURFACE_SYSTEM_KEY]);
|
|
59
|
+
const FLOW_SURFACE_INTERNAL_META_KEY = "__flowSurfaceMeta";
|
|
60
|
+
const FLOW_SURFACE_DECLARED_KEY_KEY = "declaredKey";
|
|
61
|
+
const FLOW_SURFACE_KEY_NOT_PERSISTABLE_CODE = "FLOW_SURFACE_KEY_NOT_PERSISTABLE";
|
|
62
|
+
function getDeclaredKeyFromNode(node) {
|
|
63
|
+
const declaredKey = import_lodash.default.get(node, ["stepParams", FLOW_SURFACE_INTERNAL_META_KEY, FLOW_SURFACE_DECLARED_KEY_KEY]);
|
|
64
|
+
return typeof declaredKey === "string" && declaredKey.trim() ? declaredKey.trim() : void 0;
|
|
65
|
+
}
|
|
66
|
+
function normalizeBindKeys(actionName, bindKeys, deps) {
|
|
67
|
+
if (import_lodash.default.isUndefined(bindKeys)) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
if (!Array.isArray(bindKeys)) {
|
|
71
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} bindKeys must be an array`);
|
|
72
|
+
}
|
|
73
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
74
|
+
return bindKeys.map((item, index) => {
|
|
75
|
+
if (!import_lodash.default.isPlainObject(item)) {
|
|
76
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} bindKeys[${index}] must be an object`);
|
|
77
|
+
}
|
|
78
|
+
const key = String(item.key || "").trim();
|
|
79
|
+
if (!key) {
|
|
80
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} bindKeys[${index}].key is required`);
|
|
81
|
+
}
|
|
82
|
+
if (FLOW_SURFACE_RESERVED_KEYS.has(key)) {
|
|
83
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} bindKeys[${index}].key '${key}' is reserved`);
|
|
84
|
+
}
|
|
85
|
+
if (seenKeys.has(key)) {
|
|
86
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} bindKeys[${index}].key '${key}' is duplicated`);
|
|
87
|
+
}
|
|
88
|
+
seenKeys.add(key);
|
|
89
|
+
if (!import_lodash.default.isPlainObject(item.locator)) {
|
|
90
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} bindKeys[${index}].locator is required`);
|
|
91
|
+
}
|
|
92
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
93
|
+
key,
|
|
94
|
+
locator: deps.normalizeGetTarget(item.locator),
|
|
95
|
+
expectedKind: typeof item.expectedKind === "string" ? String(item.expectedKind).trim() : void 0,
|
|
96
|
+
rebind: item.rebind === true
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function collectDeclaredKeysFromTree(node, deps, carry = /* @__PURE__ */ new Map()) {
|
|
101
|
+
if (!node || typeof node !== "object") {
|
|
102
|
+
return carry;
|
|
103
|
+
}
|
|
104
|
+
if (node.uid) {
|
|
105
|
+
const declaredKey = getDeclaredKeyFromNode(node);
|
|
106
|
+
if (declaredKey && !FLOW_SURFACE_RESERVED_KEYS.has(declaredKey)) {
|
|
107
|
+
const existing = carry.get(declaredKey);
|
|
108
|
+
if (existing && existing.uid !== node.uid) {
|
|
109
|
+
(0, import_errors.throwConflict)(
|
|
110
|
+
`flowSurfaces ${deps.actionName || "describeSurface"} declared key '${declaredKey}' is duplicated on '${existing.uid}' and '${node.uid}'`,
|
|
111
|
+
"FLOW_SURFACE_DECLARED_KEY_CONFLICT"
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
carry.set(declaredKey, {
|
|
115
|
+
key: declaredKey,
|
|
116
|
+
uid: node.uid,
|
|
117
|
+
source: "declared",
|
|
118
|
+
kind: deps.buildPlanKeyKind(node),
|
|
119
|
+
locator: {
|
|
120
|
+
uid: node.uid
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const value of Object.values(node.subModels || {})) {
|
|
126
|
+
import_lodash.default.castArray(value).forEach((child) => collectDeclaredKeysFromTree(child, deps, carry));
|
|
127
|
+
}
|
|
128
|
+
return carry;
|
|
129
|
+
}
|
|
130
|
+
function annotateTreeKey(tree, keyByUid) {
|
|
131
|
+
const visit = (current) => {
|
|
132
|
+
if (!current || typeof current !== "object") {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const currentKey = current.uid ? keyByUid.get(current.uid) : void 0;
|
|
136
|
+
if (currentKey && typeof current.key === "undefined") {
|
|
137
|
+
current.key = currentKey;
|
|
138
|
+
}
|
|
139
|
+
for (const value of Object.values(current.subModels || {})) {
|
|
140
|
+
import_lodash.default.castArray(value).forEach((child) => visit(child));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
visit(tree);
|
|
144
|
+
return tree;
|
|
145
|
+
}
|
|
146
|
+
function buildSurfaceKeysObject(keyMap) {
|
|
147
|
+
return Object.fromEntries(
|
|
148
|
+
Array.from(keyMap.entries()).map(([key, info]) => [
|
|
149
|
+
key,
|
|
150
|
+
{
|
|
151
|
+
uid: info.uid,
|
|
152
|
+
kind: info.kind,
|
|
153
|
+
source: info.source,
|
|
154
|
+
locator: info.locator
|
|
155
|
+
}
|
|
156
|
+
])
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function buildSurfaceFingerprintKeysObject(keyMap) {
|
|
160
|
+
return Object.fromEntries(
|
|
161
|
+
Array.from(keyMap.entries()).map(([key, info]) => [
|
|
162
|
+
key,
|
|
163
|
+
{
|
|
164
|
+
uid: info.uid,
|
|
165
|
+
kind: info.kind
|
|
166
|
+
}
|
|
167
|
+
])
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function getSurfaceSelectorRequestKey(context) {
|
|
171
|
+
if (!context.surfaceSelector || !("key" in context.surfaceSelector)) {
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
return context.requestKeyMap.get(context.surfaceSelector.key);
|
|
175
|
+
}
|
|
176
|
+
function collectRequestKeysToPersist(context, compiledSteps) {
|
|
177
|
+
const keys = /* @__PURE__ */ new Map();
|
|
178
|
+
const surfaceRequestKey = getSurfaceSelectorRequestKey(context);
|
|
179
|
+
if (surfaceRequestKey) {
|
|
180
|
+
keys.set(surfaceRequestKey.key, surfaceRequestKey);
|
|
181
|
+
}
|
|
182
|
+
for (const compiled of compiledSteps) {
|
|
183
|
+
for (const keyInfo of compiled.usedKeys) {
|
|
184
|
+
if (keyInfo.source === "request") {
|
|
185
|
+
keys.set(keyInfo.key, keyInfo);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return keys;
|
|
190
|
+
}
|
|
191
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
192
|
+
0 && (module.exports = {
|
|
193
|
+
FLOW_SURFACE_DECLARED_KEY_KEY,
|
|
194
|
+
FLOW_SURFACE_INTERNAL_META_KEY,
|
|
195
|
+
FLOW_SURFACE_KEY_NOT_PERSISTABLE_CODE,
|
|
196
|
+
FLOW_SURFACE_RESERVED_KEYS,
|
|
197
|
+
FLOW_SURFACE_SYSTEM_KEY,
|
|
198
|
+
annotateTreeKey,
|
|
199
|
+
buildSurfaceFingerprintKeysObject,
|
|
200
|
+
buildSurfaceKeysObject,
|
|
201
|
+
collectDeclaredKeysFromTree,
|
|
202
|
+
collectRequestKeysToPersist,
|
|
203
|
+
getDeclaredKeyFromNode,
|
|
204
|
+
getSurfaceSelectorRequestKey,
|
|
205
|
+
normalizeBindKeys
|
|
206
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { FlowSurfaceDescribeValues, FlowSurfaceExecutorContext, FlowSurfaceMutateOp, FlowSurfacePlanRequestValues, FlowSurfaceReadLocator, FlowSurfaceReadTarget, FlowSurfaceResolvedTarget } from '../types';
|
|
10
|
+
import { type FlowSurfacePlanOnlyActionName } from './action-specs';
|
|
11
|
+
import type { FlowSurfacePlanSurfaceContext } from './types';
|
|
12
|
+
type FlowSurfacePlanningRuntimeDeps = {
|
|
13
|
+
normalizeGetTarget: (value: any) => FlowSurfaceReadLocator;
|
|
14
|
+
resolveLocator: (target: FlowSurfaceReadLocator, options?: {
|
|
15
|
+
transaction?: any;
|
|
16
|
+
}) => Promise<FlowSurfaceResolvedTarget>;
|
|
17
|
+
loadResolvedSurfaceTree: (resolved: FlowSurfaceResolvedTarget, transaction?: any) => Promise<any>;
|
|
18
|
+
stripInternalSurfaceMetaFromNodeTree: <T = any>(node: T) => T;
|
|
19
|
+
buildReadTargetSummary: (target: FlowSurfaceReadLocator, resolved: FlowSurfaceResolvedTarget) => FlowSurfaceReadTarget;
|
|
20
|
+
buildSurfaceContextFingerprint: (context: Pick<FlowSurfacePlanSurfaceContext, 'surfaceResolved' | 'publicTree' | 'keyMap'>) => string;
|
|
21
|
+
buildSurfaceReadPayload: (target: FlowSurfaceReadLocator, resolved: FlowSurfaceResolvedTarget, node: any, options?: {
|
|
22
|
+
transaction?: any;
|
|
23
|
+
}) => Promise<any>;
|
|
24
|
+
dispatchPlanOnlyAction: (action: FlowSurfacePlanOnlyActionName, payload: Record<string, any>, transaction?: any) => Promise<any>;
|
|
25
|
+
dispatchOp: (op: FlowSurfaceMutateOp, resolvedValues: Record<string, any>, currentCtx: FlowSurfaceExecutorContext) => Promise<any>;
|
|
26
|
+
};
|
|
27
|
+
export declare function describeSurface(values: FlowSurfaceDescribeValues, deps: FlowSurfacePlanningRuntimeDeps, options?: {
|
|
28
|
+
transaction?: any;
|
|
29
|
+
}): Promise<any>;
|
|
30
|
+
type FlowSurfaceInternalPlanExecutionValues = Pick<FlowSurfacePlanRequestValues, 'surface' | 'plan'>;
|
|
31
|
+
export type FlowSurfaceInternalPlanExecutionResult = {
|
|
32
|
+
results: Array<Record<string, any>>;
|
|
33
|
+
};
|
|
34
|
+
export declare function executeInternalPlan(values: FlowSurfaceInternalPlanExecutionValues, deps: FlowSurfacePlanningRuntimeDeps, options?: {
|
|
35
|
+
transaction?: any;
|
|
36
|
+
}): Promise<FlowSurfaceInternalPlanExecutionResult>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,259 @@
|
|
|
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 runtime_exports = {};
|
|
38
|
+
__export(runtime_exports, {
|
|
39
|
+
describeSurface: () => describeSurface,
|
|
40
|
+
executeInternalPlan: () => executeInternalPlan
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
43
|
+
var import_lodash = __toESM(require("lodash"));
|
|
44
|
+
var import_errors = require("../errors");
|
|
45
|
+
var import_executor = require("../executor");
|
|
46
|
+
var import_action_specs = require("./action-specs");
|
|
47
|
+
var import_context = require("./context");
|
|
48
|
+
var import_compiler = require("./compiler");
|
|
49
|
+
var import_key_kind = require("./key-kind");
|
|
50
|
+
var import_key_registry = require("./key-registry");
|
|
51
|
+
var import_created_keys = require("./created-keys");
|
|
52
|
+
var import_payload_shape = require("../payload-shape");
|
|
53
|
+
async function buildPlanSurfaceContext(surfaceSelectorInput, bindKeysInput, actionName, deps, options = {}) {
|
|
54
|
+
const bindKeys = (0, import_key_registry.normalizeBindKeys)(actionName, bindKeysInput, {
|
|
55
|
+
normalizeGetTarget: deps.normalizeGetTarget
|
|
56
|
+
});
|
|
57
|
+
if (import_lodash.default.isUndefined(surfaceSelectorInput) || import_lodash.default.isNil(surfaceSelectorInput)) {
|
|
58
|
+
return (0, import_context.buildPlanSurfaceContext)(
|
|
59
|
+
{
|
|
60
|
+
actionName,
|
|
61
|
+
bindKeys
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
resolveLocator: deps.resolveLocator,
|
|
65
|
+
loadResolvedSurfaceTree: deps.loadResolvedSurfaceTree,
|
|
66
|
+
stripInternalSurfaceMetaFromNodeTree: deps.stripInternalSurfaceMetaFromNodeTree,
|
|
67
|
+
buildReadTargetSummary: deps.buildReadTargetSummary,
|
|
68
|
+
buildSurfaceContextFingerprint: deps.buildSurfaceContextFingerprint,
|
|
69
|
+
buildPlanKeyKind: import_key_kind.buildPlanKeyKind,
|
|
70
|
+
assertBindKeyKind: import_key_kind.assertBindKeyKind,
|
|
71
|
+
collectDeclaredKeysFromTree: (node) => (0, import_key_registry.collectDeclaredKeysFromTree)(
|
|
72
|
+
node,
|
|
73
|
+
{
|
|
74
|
+
actionName,
|
|
75
|
+
buildPlanKeyKind: import_key_kind.buildPlanKeyKind
|
|
76
|
+
},
|
|
77
|
+
/* @__PURE__ */ new Map()
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
options
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const normalizedSurfaceSelector = (0, import_compiler.normalizePlanSelector)(
|
|
84
|
+
actionName,
|
|
85
|
+
surfaceSelectorInput,
|
|
86
|
+
{
|
|
87
|
+
normalizeGetTarget: deps.normalizeGetTarget
|
|
88
|
+
},
|
|
89
|
+
"surface",
|
|
90
|
+
{
|
|
91
|
+
allowKey: true
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
if ("step" in normalizedSurfaceSelector) {
|
|
95
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} surface only supports { key } or { locator }`);
|
|
96
|
+
}
|
|
97
|
+
return (0, import_context.buildPlanSurfaceContext)(
|
|
98
|
+
{
|
|
99
|
+
actionName,
|
|
100
|
+
surfaceSelector: normalizedSurfaceSelector,
|
|
101
|
+
bindKeys
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
resolveLocator: deps.resolveLocator,
|
|
105
|
+
loadResolvedSurfaceTree: deps.loadResolvedSurfaceTree,
|
|
106
|
+
stripInternalSurfaceMetaFromNodeTree: deps.stripInternalSurfaceMetaFromNodeTree,
|
|
107
|
+
buildReadTargetSummary: deps.buildReadTargetSummary,
|
|
108
|
+
buildSurfaceContextFingerprint: deps.buildSurfaceContextFingerprint,
|
|
109
|
+
buildPlanKeyKind: import_key_kind.buildPlanKeyKind,
|
|
110
|
+
assertBindKeyKind: import_key_kind.assertBindKeyKind,
|
|
111
|
+
collectDeclaredKeysFromTree: (node) => (0, import_key_registry.collectDeclaredKeysFromTree)(
|
|
112
|
+
node,
|
|
113
|
+
{
|
|
114
|
+
actionName,
|
|
115
|
+
buildPlanKeyKind: import_key_kind.buildPlanKeyKind
|
|
116
|
+
},
|
|
117
|
+
/* @__PURE__ */ new Map()
|
|
118
|
+
)
|
|
119
|
+
},
|
|
120
|
+
options
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
async function buildDescribeSurfaceResponse(context, deps, options = {}) {
|
|
124
|
+
if (!context.surfaceTarget || !context.surfaceResolved) {
|
|
125
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces describeSurface requires locator`);
|
|
126
|
+
}
|
|
127
|
+
const tree = import_lodash.default.cloneDeep(context.publicTree);
|
|
128
|
+
const keyByUid = /* @__PURE__ */ new Map();
|
|
129
|
+
context.keyMap.forEach((value, key) => {
|
|
130
|
+
if (!keyByUid.has(value.uid)) {
|
|
131
|
+
keyByUid.set(value.uid, key);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
(0, import_key_registry.annotateTreeKey)(tree, keyByUid);
|
|
135
|
+
const result = await deps.buildSurfaceReadPayload(context.surfaceTarget, context.surfaceResolved, tree, options);
|
|
136
|
+
result.fingerprint = context.fingerprint;
|
|
137
|
+
result.keys = (0, import_key_registry.buildSurfaceKeysObject)(context.keyMap);
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
function normalizePlanSteps(actionName, values, deps) {
|
|
141
|
+
return (0, import_compiler.normalizePlanSteps)(actionName, values, {
|
|
142
|
+
normalizeGetTarget: deps.normalizeGetTarget,
|
|
143
|
+
validatePayloadShape: import_payload_shape.validateFlowSurfacePayloadShape
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async function compilePlanStep(actionName, step, index, context, deps, priorStepIds, priorCreatedKeys, options = {}) {
|
|
147
|
+
return (0, import_compiler.compilePlanStep)(
|
|
148
|
+
actionName,
|
|
149
|
+
step,
|
|
150
|
+
index,
|
|
151
|
+
context,
|
|
152
|
+
{
|
|
153
|
+
normalizeGetTarget: deps.normalizeGetTarget,
|
|
154
|
+
resolveLocator: deps.resolveLocator,
|
|
155
|
+
buildPlanKeyKind: import_key_kind.buildPlanKeyKind
|
|
156
|
+
},
|
|
157
|
+
priorStepIds,
|
|
158
|
+
priorCreatedKeys,
|
|
159
|
+
options
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
async function executeCompiledPlanStep(compiled, deps, execCtx, transaction) {
|
|
163
|
+
var _a;
|
|
164
|
+
if (compiled.mutateOp) {
|
|
165
|
+
const mutateResults = await (0, import_executor.executeMutateOps)(
|
|
166
|
+
[compiled.mutateOp],
|
|
167
|
+
execCtx,
|
|
168
|
+
async (op, resolvedValues, currentCtx) => deps.dispatchOp(op, resolvedValues, currentCtx)
|
|
169
|
+
);
|
|
170
|
+
return (_a = mutateResults[0]) == null ? void 0 : _a.result;
|
|
171
|
+
}
|
|
172
|
+
if (!(0, import_action_specs.isFlowSurfacePlanOnlyAction)(compiled.action)) {
|
|
173
|
+
(0, import_errors.throwInternalError)(`flowSurfaces internal plan action '${compiled.action}' is not supported`);
|
|
174
|
+
}
|
|
175
|
+
const result = await deps.dispatchPlanOnlyAction(
|
|
176
|
+
compiled.action,
|
|
177
|
+
(0, import_executor.resolveFlowSurfaceValueKeys)(import_lodash.default.cloneDeep(compiled.payload), execCtx.keys),
|
|
178
|
+
transaction
|
|
179
|
+
);
|
|
180
|
+
if (compiled.id) {
|
|
181
|
+
execCtx.keys.set(compiled.id, result);
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
function assertBootstrapPlanConstraints(actionName, compiledSteps) {
|
|
186
|
+
for (const compiled of compiledSteps) {
|
|
187
|
+
for (const selector of Object.values(compiled.resolvedSelectors)) {
|
|
188
|
+
if (!selector) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (selector.source !== "step" && selector.source !== "created") {
|
|
192
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} bootstrap plan only supports step or created-key selectors`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async function describeSurface(values, deps, options = {}) {
|
|
198
|
+
if (!import_lodash.default.isPlainObject(values) || !import_lodash.default.isPlainObject(values.locator)) {
|
|
199
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces describeSurface requires locator`);
|
|
200
|
+
}
|
|
201
|
+
const locator = deps.normalizeGetTarget(values.locator);
|
|
202
|
+
const context = await buildPlanSurfaceContext({ locator }, values.bindKeys, "describeSurface", deps, options);
|
|
203
|
+
return buildDescribeSurfaceResponse(context, deps, options);
|
|
204
|
+
}
|
|
205
|
+
async function executeInternalPlan(values, deps, options = {}) {
|
|
206
|
+
if (!import_lodash.default.isPlainObject(values)) {
|
|
207
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint requires plan`);
|
|
208
|
+
}
|
|
209
|
+
const context = await buildPlanSurfaceContext(values.surface, void 0, "applyBlueprint", deps, options);
|
|
210
|
+
const steps = normalizePlanSteps("applyBlueprint", values, deps);
|
|
211
|
+
const compiledSteps = [];
|
|
212
|
+
const priorStepIds = /* @__PURE__ */ new Set();
|
|
213
|
+
const priorCreatedKeys = /* @__PURE__ */ new Set();
|
|
214
|
+
for (const [index, step] of steps.entries()) {
|
|
215
|
+
const compiled = await compilePlanStep(
|
|
216
|
+
"applyBlueprint",
|
|
217
|
+
step,
|
|
218
|
+
index,
|
|
219
|
+
context,
|
|
220
|
+
deps,
|
|
221
|
+
priorStepIds,
|
|
222
|
+
priorCreatedKeys,
|
|
223
|
+
options
|
|
224
|
+
);
|
|
225
|
+
compiledSteps.push(compiled);
|
|
226
|
+
if (step.id) {
|
|
227
|
+
priorStepIds.add(step.id);
|
|
228
|
+
}
|
|
229
|
+
for (const createdKey of compiled.createdKeys) {
|
|
230
|
+
priorCreatedKeys.add(createdKey.key);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!context.surfaceSelector) {
|
|
234
|
+
assertBootstrapPlanConstraints("applyBlueprint", compiledSteps);
|
|
235
|
+
}
|
|
236
|
+
const results = [];
|
|
237
|
+
const execCtx = {
|
|
238
|
+
transaction: options.transaction,
|
|
239
|
+
keys: new Map(Array.from(context.keyMap.entries()).map(([key, info]) => [key, info.uid])),
|
|
240
|
+
clientKeyToUid: {}
|
|
241
|
+
};
|
|
242
|
+
for (const compiled of compiledSteps) {
|
|
243
|
+
const result = await executeCompiledPlanStep(compiled, deps, execCtx, options.transaction);
|
|
244
|
+
const createdKeys = (0, import_created_keys.registerFlowSurfaceCreatedKeys)(result, compiled.createdKeys, execCtx.keys);
|
|
245
|
+
results.push({
|
|
246
|
+
index: compiled.index,
|
|
247
|
+
...compiled.id ? { id: compiled.id } : {},
|
|
248
|
+
action: compiled.action,
|
|
249
|
+
result,
|
|
250
|
+
...createdKeys.length ? { createdKeys } : {}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return { results };
|
|
254
|
+
}
|
|
255
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
256
|
+
0 && (module.exports = {
|
|
257
|
+
describeSurface,
|
|
258
|
+
executeInternalPlan
|
|
259
|
+
});
|
|
@@ -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 { isFlowSurfacePlanStepValue } from '../reference-guards';
|
|
10
|
+
import type { FlowSurfacePlanStepLink } from '../types';
|
|
11
|
+
export declare const isFlowSurfacePlanStepLink: typeof isFlowSurfacePlanStepValue;
|
|
12
|
+
export declare function normalizeFlowSurfacePlanStepLink(actionName: string, input: any, fieldName: string): FlowSurfacePlanStepLink;
|
|
13
|
+
export declare function assertFlowSurfaceKnownPlanStepLink(actionName: string, stepLink: FlowSurfacePlanStepLink, fieldName: string, knownStepIds?: Set<string>): void;
|
|
14
|
+
export declare function replaceFlowSurfacePlanStepLinks(actionName: string, input: any, path: string, knownStepIds?: Set<string>, knownRuntimeKeys?: Set<string>): any;
|
|
@@ -0,0 +1,104 @@
|
|
|
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 step_link_exports = {};
|
|
38
|
+
__export(step_link_exports, {
|
|
39
|
+
assertFlowSurfaceKnownPlanStepLink: () => assertFlowSurfaceKnownPlanStepLink,
|
|
40
|
+
isFlowSurfacePlanStepLink: () => isFlowSurfacePlanStepLink,
|
|
41
|
+
normalizeFlowSurfacePlanStepLink: () => normalizeFlowSurfacePlanStepLink,
|
|
42
|
+
replaceFlowSurfacePlanStepLinks: () => replaceFlowSurfacePlanStepLinks
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(step_link_exports);
|
|
45
|
+
var import_lodash = __toESM(require("lodash"));
|
|
46
|
+
var import_errors = require("../errors");
|
|
47
|
+
var import_reference_guards = require("../reference-guards");
|
|
48
|
+
var import_created_keys = require("./created-keys");
|
|
49
|
+
const isFlowSurfacePlanStepLink = import_reference_guards.isFlowSurfacePlanStepValue;
|
|
50
|
+
function normalizeFlowSurfacePlanStepLink(actionName, input, fieldName) {
|
|
51
|
+
return (0, import_reference_guards.normalizeFlowSurfacePlanStepValue)(actionName, input, fieldName);
|
|
52
|
+
}
|
|
53
|
+
function assertFlowSurfaceKnownPlanStepLink(actionName, stepLink, fieldName, knownStepIds) {
|
|
54
|
+
if (!knownStepIds || knownStepIds.has(stepLink.step)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${fieldName}.step '${stepLink.step}' is not a previous step id`);
|
|
58
|
+
}
|
|
59
|
+
function replaceFlowSurfacePlanStepLinks(actionName, input, path, knownStepIds, knownRuntimeKeys) {
|
|
60
|
+
if (Array.isArray(input)) {
|
|
61
|
+
return input.map(
|
|
62
|
+
(item, index) => replaceFlowSurfacePlanStepLinks(actionName, item, `${path}[${index}]`, knownStepIds, knownRuntimeKeys)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
66
|
+
return input;
|
|
67
|
+
}
|
|
68
|
+
(0, import_reference_guards.assertNoFlowSurfaceLegacyRef)(input, {
|
|
69
|
+
actionName,
|
|
70
|
+
path,
|
|
71
|
+
dollarRefAllowed: "{ step, path }",
|
|
72
|
+
refAllowed: "{ key } or { step, path }"
|
|
73
|
+
});
|
|
74
|
+
if (isFlowSurfacePlanStepLink(input)) {
|
|
75
|
+
const stepLink = normalizeFlowSurfacePlanStepLink(actionName, input, path);
|
|
76
|
+
assertFlowSurfaceKnownPlanStepLink(actionName, stepLink, path, knownStepIds);
|
|
77
|
+
return stepLink;
|
|
78
|
+
}
|
|
79
|
+
if ((0, import_created_keys.isFlowSurfacePureKeyObject)(input)) {
|
|
80
|
+
const runtimeKey = String(input.key || "").trim();
|
|
81
|
+
if (!runtimeKey) {
|
|
82
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${path}.key cannot be empty`);
|
|
83
|
+
}
|
|
84
|
+
if (!(knownRuntimeKeys == null ? void 0 : knownRuntimeKeys.has(runtimeKey))) {
|
|
85
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${path}.key '${runtimeKey}' is not defined`);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
key: runtimeKey
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return Object.fromEntries(
|
|
92
|
+
Object.entries(input).map(([key, value]) => [
|
|
93
|
+
key,
|
|
94
|
+
replaceFlowSurfacePlanStepLinks(actionName, value, `${path}.${key}`, knownStepIds, knownRuntimeKeys)
|
|
95
|
+
])
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
assertFlowSurfaceKnownPlanStepLink,
|
|
101
|
+
isFlowSurfacePlanStepLink,
|
|
102
|
+
normalizeFlowSurfacePlanStepLink,
|
|
103
|
+
replaceFlowSurfacePlanStepLinks
|
|
104
|
+
});
|