@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,882 @@
|
|
|
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 linkage_exports = {};
|
|
38
|
+
__export(linkage_exports, {
|
|
39
|
+
buildReactionFingerprint: () => buildReactionFingerprint,
|
|
40
|
+
compileActionLinkageCanonicalRules: () => compileActionLinkageCanonicalRules,
|
|
41
|
+
compileBlockLinkageCanonicalRules: () => compileBlockLinkageCanonicalRules,
|
|
42
|
+
compileFieldLinkageCanonicalRules: () => compileFieldLinkageCanonicalRules,
|
|
43
|
+
normalizeActionLinkageRules: () => normalizeActionLinkageRules,
|
|
44
|
+
normalizeBlockLinkageRules: () => normalizeBlockLinkageRules,
|
|
45
|
+
normalizeFieldLinkageRules: () => normalizeFieldLinkageRules,
|
|
46
|
+
validateActionLinkageRulesAgainstCapability: () => validateActionLinkageRulesAgainstCapability,
|
|
47
|
+
validateActionLinkageSceneSupport: () => validateActionLinkageSceneSupport,
|
|
48
|
+
validateBlockLinkageRulesAgainstCapability: () => validateBlockLinkageRulesAgainstCapability,
|
|
49
|
+
validateBlockLinkageSceneSupport: () => validateBlockLinkageSceneSupport,
|
|
50
|
+
validateFieldLinkageRulesAgainstCapability: () => validateFieldLinkageRulesAgainstCapability,
|
|
51
|
+
validateFieldLinkageSceneSupport: () => validateFieldLinkageSceneSupport
|
|
52
|
+
});
|
|
53
|
+
module.exports = __toCommonJS(linkage_exports);
|
|
54
|
+
var import_node_crypto = require("node:crypto");
|
|
55
|
+
var import_lodash = __toESM(require("lodash"));
|
|
56
|
+
var import_context = require("../context");
|
|
57
|
+
var import_errors = require("../errors");
|
|
58
|
+
var import_errors2 = require("./errors");
|
|
59
|
+
var import_registry = require("./registry");
|
|
60
|
+
const EMPTY_FILTER = {
|
|
61
|
+
logic: "$and",
|
|
62
|
+
items: []
|
|
63
|
+
};
|
|
64
|
+
const CONTEXT_EXPR_RE = /^\{\{\s*ctx(?:\.([^}]+?))?\s*\}\}$/;
|
|
65
|
+
const CTX_PREFIX_RE = /^ctx\./;
|
|
66
|
+
function buildStableFingerprintString(value) {
|
|
67
|
+
if (import_lodash.default.isNil(value)) {
|
|
68
|
+
return "null";
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(value)) {
|
|
71
|
+
return `[${value.map((item) => buildStableFingerprintString(item)).join(",")}]`;
|
|
72
|
+
}
|
|
73
|
+
if (import_lodash.default.isPlainObject(value)) {
|
|
74
|
+
const entries = Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${buildStableFingerprintString(value[key])}`);
|
|
75
|
+
return `{${entries.join(",")}}`;
|
|
76
|
+
}
|
|
77
|
+
return JSON.stringify(value);
|
|
78
|
+
}
|
|
79
|
+
function assertRuleArray(rules, label) {
|
|
80
|
+
if (!Array.isArray(rules)) {
|
|
81
|
+
(0, import_errors.throwBadRequest)(`${label} must be an array.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function normalizeKey(rawKey, fallbackPrefix, index) {
|
|
85
|
+
const trimmed = typeof rawKey === "string" ? rawKey.trim() : "";
|
|
86
|
+
return trimmed || `${fallbackPrefix}-${index + 1}`;
|
|
87
|
+
}
|
|
88
|
+
function normalizeTitle(rawTitle, index) {
|
|
89
|
+
const trimmed = typeof rawTitle === "string" ? rawTitle.trim() : "";
|
|
90
|
+
return trimmed || `Linkage rule ${index + 1}`;
|
|
91
|
+
}
|
|
92
|
+
function normalizeBoolean(rawValue, fallback = true) {
|
|
93
|
+
return typeof rawValue === "boolean" ? rawValue : fallback;
|
|
94
|
+
}
|
|
95
|
+
function extractBareContextPath(rawPath, fieldName = "condition.path") {
|
|
96
|
+
var _a;
|
|
97
|
+
if (typeof rawPath !== "string" || !rawPath.trim()) {
|
|
98
|
+
(0, import_errors.throwBadRequest)(`${fieldName} must be a non-empty string.`, import_errors2.FLOW_SURFACE_REACTION_INVALID_CONDITION_PATH);
|
|
99
|
+
}
|
|
100
|
+
const trimmed = rawPath.trim();
|
|
101
|
+
const templateMatch = trimmed.match(CONTEXT_EXPR_RE);
|
|
102
|
+
const bare = ((_a = templateMatch == null ? void 0 : templateMatch[1]) == null ? void 0 : _a.trim()) || (trimmed.startsWith("ctx.") ? trimmed.replace(CTX_PREFIX_RE, "") : trimmed);
|
|
103
|
+
if (!bare || !(0, import_context.isBareFlowContextPath)(bare)) {
|
|
104
|
+
(0, import_errors.throwBadRequest)(
|
|
105
|
+
`${fieldName} must be a bare flow context path such as "record.id".`,
|
|
106
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_CONDITION_PATH
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return bare;
|
|
110
|
+
}
|
|
111
|
+
function formatContextPath(path) {
|
|
112
|
+
return `{{ ctx.${path} }}`;
|
|
113
|
+
}
|
|
114
|
+
function clonePlain(value) {
|
|
115
|
+
return import_lodash.default.cloneDeep(value);
|
|
116
|
+
}
|
|
117
|
+
function normalizeFilterValue(value) {
|
|
118
|
+
if (import_lodash.default.isPlainObject(value) && value.source === "path" && typeof value.path === "string") {
|
|
119
|
+
return {
|
|
120
|
+
...value,
|
|
121
|
+
path: extractBareContextPath(value.path, "condition.value.path")
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (Array.isArray(value)) {
|
|
125
|
+
return value.map((item) => normalizeFilterValue(item));
|
|
126
|
+
}
|
|
127
|
+
if (import_lodash.default.isPlainObject(value)) {
|
|
128
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, normalizeFilterValue(item)]));
|
|
129
|
+
}
|
|
130
|
+
return clonePlain(value);
|
|
131
|
+
}
|
|
132
|
+
function compileFilterValue(value) {
|
|
133
|
+
if (import_lodash.default.isPlainObject(value) && value.source === "path" && typeof value.path === "string") {
|
|
134
|
+
return formatContextPath(extractBareContextPath(value.path, "condition.value.path"));
|
|
135
|
+
}
|
|
136
|
+
if (Array.isArray(value)) {
|
|
137
|
+
return value.map((item) => compileFilterValue(item));
|
|
138
|
+
}
|
|
139
|
+
if (import_lodash.default.isPlainObject(value)) {
|
|
140
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, compileFilterValue(item)]));
|
|
141
|
+
}
|
|
142
|
+
return clonePlain(value);
|
|
143
|
+
}
|
|
144
|
+
function normalizeReactionFilter(rawFilter) {
|
|
145
|
+
if (!rawFilter || !import_lodash.default.isPlainObject(rawFilter)) {
|
|
146
|
+
return clonePlain(EMPTY_FILTER);
|
|
147
|
+
}
|
|
148
|
+
const visit = (node) => {
|
|
149
|
+
if (!import_lodash.default.isPlainObject(node)) {
|
|
150
|
+
return node;
|
|
151
|
+
}
|
|
152
|
+
if (Array.isArray(node.items)) {
|
|
153
|
+
return {
|
|
154
|
+
...Object.fromEntries(Object.entries(node).filter(([key]) => key !== "items")),
|
|
155
|
+
items: node.items.map((item) => visit(item))
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const next = { ...node };
|
|
159
|
+
if ("path" in next) {
|
|
160
|
+
next.path = extractBareContextPath(next.path);
|
|
161
|
+
}
|
|
162
|
+
if ("value" in next) {
|
|
163
|
+
next.value = normalizeFilterValue(next.value);
|
|
164
|
+
}
|
|
165
|
+
return next;
|
|
166
|
+
};
|
|
167
|
+
return visit(rawFilter);
|
|
168
|
+
}
|
|
169
|
+
function compileReactionFilter(filter) {
|
|
170
|
+
const visit = (node) => {
|
|
171
|
+
if (!import_lodash.default.isPlainObject(node)) {
|
|
172
|
+
return clonePlain(node);
|
|
173
|
+
}
|
|
174
|
+
if (Array.isArray(node.items)) {
|
|
175
|
+
return {
|
|
176
|
+
...Object.fromEntries(Object.entries(node).filter(([key]) => key !== "items")),
|
|
177
|
+
items: node.items.map((item) => visit(item))
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const next = { ...node };
|
|
181
|
+
if ("path" in next && typeof next.path === "string") {
|
|
182
|
+
next.path = formatContextPath(extractBareContextPath(next.path));
|
|
183
|
+
}
|
|
184
|
+
if ("value" in next) {
|
|
185
|
+
next.value = compileFilterValue(next.value);
|
|
186
|
+
}
|
|
187
|
+
return next;
|
|
188
|
+
};
|
|
189
|
+
return visit(filter);
|
|
190
|
+
}
|
|
191
|
+
function isRunJsExpr(value) {
|
|
192
|
+
if (!import_lodash.default.isPlainObject(value)) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
const keys = Object.keys(value);
|
|
196
|
+
if (!keys.includes("code")) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
if (typeof value.code !== "string") {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
if ("version" in value && value.version != null && value.version !== "v1" && value.version !== "v2") {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return keys.every((key) => key === "code" || key === "version");
|
|
206
|
+
}
|
|
207
|
+
function normalizeValueExpr(value) {
|
|
208
|
+
if (import_lodash.default.isPlainObject(value) && value.source === "literal") {
|
|
209
|
+
return {
|
|
210
|
+
source: "literal",
|
|
211
|
+
value: clonePlain(value.value)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (import_lodash.default.isPlainObject(value) && value.source === "path") {
|
|
215
|
+
return {
|
|
216
|
+
source: "path",
|
|
217
|
+
path: extractBareContextPath(value.path, "value.path")
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (import_lodash.default.isPlainObject(value) && value.source === "runjs") {
|
|
221
|
+
if (typeof value.code !== "string") {
|
|
222
|
+
(0, import_errors.throwBadRequest)("runjs value.code must be a string.");
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
source: "runjs",
|
|
226
|
+
code: value.code,
|
|
227
|
+
...value.version ? { version: value.version } : {}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (import_lodash.default.isPlainObject(value) && "source" in value) {
|
|
231
|
+
(0, import_errors.throwBadRequest)(
|
|
232
|
+
`value.source "${String(value.source)}" is not supported. Expected one of "literal", "path", or "runjs".`,
|
|
233
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_VALUE_SOURCE
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
if (isRunJsExpr(value)) {
|
|
237
|
+
return {
|
|
238
|
+
source: "runjs",
|
|
239
|
+
code: value.code,
|
|
240
|
+
...value.version ? { version: value.version } : {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (typeof value === "string") {
|
|
244
|
+
const templateMatch = value.trim().match(CONTEXT_EXPR_RE);
|
|
245
|
+
if (templateMatch == null ? void 0 : templateMatch[1]) {
|
|
246
|
+
return {
|
|
247
|
+
source: "path",
|
|
248
|
+
path: extractBareContextPath(value, "value")
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
source: "literal",
|
|
254
|
+
value: clonePlain(value)
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function compileValueExpr(value) {
|
|
258
|
+
if ((value == null ? void 0 : value.source) === "path") {
|
|
259
|
+
return formatContextPath(extractBareContextPath(value.path, "value.path"));
|
|
260
|
+
}
|
|
261
|
+
if ((value == null ? void 0 : value.source) === "runjs") {
|
|
262
|
+
if (typeof value.code !== "string") {
|
|
263
|
+
(0, import_errors.throwBadRequest)("runjs value.code must be a string.");
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
code: value.code,
|
|
267
|
+
...value.version ? { version: value.version } : {}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return clonePlain(value == null ? void 0 : value.value);
|
|
271
|
+
}
|
|
272
|
+
function normalizeFieldPath(rawPath, fieldName) {
|
|
273
|
+
if (typeof rawPath !== "string" || !rawPath.trim()) {
|
|
274
|
+
(0, import_errors.throwBadRequest)(`${fieldName} must be a non-empty string.`);
|
|
275
|
+
}
|
|
276
|
+
return rawPath.trim();
|
|
277
|
+
}
|
|
278
|
+
function normalizeFieldPaths(rawPaths, fieldName) {
|
|
279
|
+
if (!Array.isArray(rawPaths)) {
|
|
280
|
+
(0, import_errors.throwBadRequest)(`${fieldName} must be an array of field paths.`);
|
|
281
|
+
}
|
|
282
|
+
return import_lodash.default.uniq(rawPaths.map((path, index) => normalizeFieldPath(path, `${fieldName}[${index}]`))).filter(Boolean);
|
|
283
|
+
}
|
|
284
|
+
function normalizeAssignItem(rawItem, index, prefix, fallbackMode) {
|
|
285
|
+
const rawTargetPath = (rawItem == null ? void 0 : rawItem.targetPath) ?? (typeof (rawItem == null ? void 0 : rawItem.field) === "string" || typeof (rawItem == null ? void 0 : rawItem.field) === "number" ? String(rawItem.field) : void 0);
|
|
286
|
+
const rawValue = "value" in (rawItem || {}) ? rawItem.value : fallbackMode === "default" ? rawItem == null ? void 0 : rawItem.initialValue : rawItem == null ? void 0 : rawItem.assignValue;
|
|
287
|
+
return {
|
|
288
|
+
key: normalizeKey(rawItem == null ? void 0 : rawItem.key, prefix, index),
|
|
289
|
+
enabled: normalizeBoolean((rawItem == null ? void 0 : rawItem.enabled) ?? (rawItem == null ? void 0 : rawItem.enable), true),
|
|
290
|
+
targetPath: normalizeFieldPath(rawTargetPath, `${prefix}[${index}].targetPath`),
|
|
291
|
+
when: normalizeReactionFilter((rawItem == null ? void 0 : rawItem.when) ?? (rawItem == null ? void 0 : rawItem.condition)),
|
|
292
|
+
value: normalizeValueExpr(rawValue)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function normalizeRuleCommon(rawRule, index, prefix) {
|
|
296
|
+
return {
|
|
297
|
+
key: normalizeKey(rawRule == null ? void 0 : rawRule.key, prefix, index),
|
|
298
|
+
title: normalizeTitle(rawRule == null ? void 0 : rawRule.title, index),
|
|
299
|
+
enabled: normalizeBoolean((rawRule == null ? void 0 : rawRule.enabled) ?? (rawRule == null ? void 0 : rawRule.enable), true),
|
|
300
|
+
when: normalizeReactionFilter((rawRule == null ? void 0 : rawRule.when) ?? (rawRule == null ? void 0 : rawRule.condition))
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function normalizeBlockAction(rawAction, index, prefix) {
|
|
304
|
+
var _a, _b, _c, _d, _e, _f;
|
|
305
|
+
const type = rawAction == null ? void 0 : rawAction.type;
|
|
306
|
+
if (type === "setBlockState") {
|
|
307
|
+
return {
|
|
308
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
309
|
+
type,
|
|
310
|
+
state: rawAction == null ? void 0 : rawAction.state
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
if (type === "runjs") {
|
|
314
|
+
return {
|
|
315
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
316
|
+
type,
|
|
317
|
+
code: String((rawAction == null ? void 0 : rawAction.code) ?? ""),
|
|
318
|
+
...(rawAction == null ? void 0 : rawAction.version) ? { version: rawAction.version } : {}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
switch (rawAction == null ? void 0 : rawAction.name) {
|
|
322
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.block.setBlockState:
|
|
323
|
+
return {
|
|
324
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
325
|
+
type: "setBlockState",
|
|
326
|
+
state: (_a = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _a.value
|
|
327
|
+
};
|
|
328
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.block.runjs:
|
|
329
|
+
case "runjs":
|
|
330
|
+
return {
|
|
331
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
332
|
+
type: "runjs",
|
|
333
|
+
code: String(((_c = (_b = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _b.value) == null ? void 0 : _c.script) ?? ((_d = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _d.code) ?? ""),
|
|
334
|
+
...((_f = (_e = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _e.value) == null ? void 0 : _f.version) ? { version: rawAction.params.value.version } : {}
|
|
335
|
+
};
|
|
336
|
+
default:
|
|
337
|
+
(0, import_errors.throwBadRequest)(`Unsupported block linkage action "${String((rawAction == null ? void 0 : rawAction.name) ?? (rawAction == null ? void 0 : rawAction.type) ?? "")}".`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function normalizeActionAction(rawAction, index, prefix) {
|
|
341
|
+
var _a, _b, _c, _d, _e, _f;
|
|
342
|
+
const type = rawAction == null ? void 0 : rawAction.type;
|
|
343
|
+
if (type === "setActionState") {
|
|
344
|
+
return {
|
|
345
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
346
|
+
type,
|
|
347
|
+
state: rawAction == null ? void 0 : rawAction.state
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
if (type === "runjs") {
|
|
351
|
+
return {
|
|
352
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
353
|
+
type,
|
|
354
|
+
code: String((rawAction == null ? void 0 : rawAction.code) ?? ""),
|
|
355
|
+
...(rawAction == null ? void 0 : rawAction.version) ? { version: rawAction.version } : {}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
switch (rawAction == null ? void 0 : rawAction.name) {
|
|
359
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.action.setActionState:
|
|
360
|
+
return {
|
|
361
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
362
|
+
type: "setActionState",
|
|
363
|
+
state: (_a = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _a.value
|
|
364
|
+
};
|
|
365
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.action.runjs:
|
|
366
|
+
case "runjs":
|
|
367
|
+
return {
|
|
368
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
369
|
+
type: "runjs",
|
|
370
|
+
code: String(((_c = (_b = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _b.value) == null ? void 0 : _c.script) ?? ((_d = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _d.code) ?? ""),
|
|
371
|
+
...((_f = (_e = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _e.value) == null ? void 0 : _f.version) ? { version: rawAction.params.value.version } : {}
|
|
372
|
+
};
|
|
373
|
+
default:
|
|
374
|
+
(0, import_errors.throwBadRequest)(`Unsupported action linkage action "${String((rawAction == null ? void 0 : rawAction.name) ?? (rawAction == null ? void 0 : rawAction.type) ?? "")}".`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function normalizeFieldStateAction(rawAction, index, prefix, resolveFieldPath) {
|
|
378
|
+
var _a, _b, _c, _d;
|
|
379
|
+
if ((rawAction == null ? void 0 : rawAction.type) === "setFieldState") {
|
|
380
|
+
return {
|
|
381
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
382
|
+
type: "setFieldState",
|
|
383
|
+
fieldPaths: normalizeFieldPaths(rawAction == null ? void 0 : rawAction.fieldPaths, `${prefix}[${index}].fieldPaths`),
|
|
384
|
+
state: rawAction == null ? void 0 : rawAction.state
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
const rawFields = (_b = (_a = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _a.value) == null ? void 0 : _b.fields;
|
|
388
|
+
return {
|
|
389
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
390
|
+
type: "setFieldState",
|
|
391
|
+
fieldPaths: normalizeFieldPaths(rawFields, `${prefix}[${index}].fieldPaths`).map(
|
|
392
|
+
(fieldUid) => (resolveFieldPath == null ? void 0 : resolveFieldPath(fieldUid)) || fieldUid
|
|
393
|
+
),
|
|
394
|
+
state: (_d = (_c = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _c.value) == null ? void 0 : _d.state
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function normalizeFieldAssignAction(rawAction, index, prefix, fallbackMode) {
|
|
398
|
+
var _a;
|
|
399
|
+
if ((rawAction == null ? void 0 : rawAction.type) === "assignField" || (rawAction == null ? void 0 : rawAction.type) === "setFieldDefaultValue") {
|
|
400
|
+
const nextType = fallbackMode === "default" || (rawAction == null ? void 0 : rawAction.type) === "setFieldDefaultValue" ? "setFieldDefaultValue" : "assignField";
|
|
401
|
+
return {
|
|
402
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
403
|
+
type: nextType,
|
|
404
|
+
items: Array.isArray(rawAction == null ? void 0 : rawAction.items) ? rawAction.items.map(
|
|
405
|
+
(item, itemIndex) => normalizeAssignItem(item, itemIndex, `${prefix}-${index + 1}-item`, fallbackMode)
|
|
406
|
+
) : []
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
const rawValue = (_a = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _a.value;
|
|
410
|
+
const items = Array.isArray(rawValue) ? rawValue.map(
|
|
411
|
+
(item, itemIndex) => normalizeAssignItem(item, itemIndex, `${prefix}-${index + 1}-item`, fallbackMode)
|
|
412
|
+
) : rawValue && typeof rawValue === "object" ? [normalizeAssignItem(rawValue, 0, `${prefix}-${index + 1}-item`, fallbackMode)] : [];
|
|
413
|
+
return {
|
|
414
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
415
|
+
type: fallbackMode === "default" ? "setFieldDefaultValue" : "assignField",
|
|
416
|
+
items
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function normalizeFieldRunJsAction(rawAction, index, prefix) {
|
|
420
|
+
var _a, _b, _c, _d, _e;
|
|
421
|
+
if ((rawAction == null ? void 0 : rawAction.type) === "runjs") {
|
|
422
|
+
return {
|
|
423
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
424
|
+
type: "runjs",
|
|
425
|
+
code: String((rawAction == null ? void 0 : rawAction.code) ?? ""),
|
|
426
|
+
...(rawAction == null ? void 0 : rawAction.version) ? { version: rawAction.version } : {}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
key: normalizeKey(rawAction == null ? void 0 : rawAction.key, prefix, index),
|
|
431
|
+
type: "runjs",
|
|
432
|
+
code: String(((_b = (_a = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _a.value) == null ? void 0 : _b.script) ?? ((_c = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _c.code) ?? ""),
|
|
433
|
+
...((_e = (_d = rawAction == null ? void 0 : rawAction.params) == null ? void 0 : _d.value) == null ? void 0 : _e.version) ? { version: rawAction.params.value.version } : {}
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function normalizeFieldAction(rawAction, index, prefix, options) {
|
|
437
|
+
switch (rawAction == null ? void 0 : rawAction.type) {
|
|
438
|
+
case "setFieldState":
|
|
439
|
+
return normalizeFieldStateAction(rawAction, index, prefix, options.resolveFieldPath);
|
|
440
|
+
case "assignField":
|
|
441
|
+
case "setFieldDefaultValue":
|
|
442
|
+
return normalizeFieldAssignAction(
|
|
443
|
+
rawAction,
|
|
444
|
+
index,
|
|
445
|
+
prefix,
|
|
446
|
+
rawAction.type === "setFieldDefaultValue" ? "default" : "assign"
|
|
447
|
+
);
|
|
448
|
+
case "runjs":
|
|
449
|
+
return normalizeFieldRunJsAction(rawAction, index, prefix);
|
|
450
|
+
default:
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
switch (rawAction == null ? void 0 : rawAction.name) {
|
|
454
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.form.setFieldState:
|
|
455
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.details.setFieldState:
|
|
456
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.subForm.setFieldState:
|
|
457
|
+
return normalizeFieldStateAction(rawAction, index, prefix, options.resolveFieldPath);
|
|
458
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.form.assignField:
|
|
459
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.subForm.assignField:
|
|
460
|
+
return normalizeFieldAssignAction(rawAction, index, prefix, "assign");
|
|
461
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.form.setFieldDefaultValue:
|
|
462
|
+
return normalizeFieldAssignAction(rawAction, index, prefix, "default");
|
|
463
|
+
case import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.form.runjs:
|
|
464
|
+
case "runjs":
|
|
465
|
+
return normalizeFieldRunJsAction(rawAction, index, prefix);
|
|
466
|
+
default:
|
|
467
|
+
(0, import_errors.throwBadRequest)(`Unsupported field linkage action "${String((rawAction == null ? void 0 : rawAction.name) ?? (rawAction == null ? void 0 : rawAction.type) ?? "")}".`);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
function compileBlockAction(action, index, prefix) {
|
|
471
|
+
if (action.type === "setBlockState") {
|
|
472
|
+
return {
|
|
473
|
+
key: normalizeKey(action.key, prefix, index),
|
|
474
|
+
name: import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.block.setBlockState,
|
|
475
|
+
params: {
|
|
476
|
+
value: action.state
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
return {
|
|
481
|
+
key: normalizeKey(action.key, prefix, index),
|
|
482
|
+
name: import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.block.runjs,
|
|
483
|
+
params: {
|
|
484
|
+
value: {
|
|
485
|
+
script: action.code,
|
|
486
|
+
...action.version ? { version: action.version } : {}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function compileActionAction(action, index, prefix) {
|
|
492
|
+
if (action.type === "setActionState") {
|
|
493
|
+
return {
|
|
494
|
+
key: normalizeKey(action.key, prefix, index),
|
|
495
|
+
name: import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.action.setActionState,
|
|
496
|
+
params: {
|
|
497
|
+
value: action.state
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
return {
|
|
502
|
+
key: normalizeKey(action.key, prefix, index),
|
|
503
|
+
name: import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES.action.runjs,
|
|
504
|
+
params: {
|
|
505
|
+
value: {
|
|
506
|
+
script: action.code,
|
|
507
|
+
...action.version ? { version: action.version } : {}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
function compileFieldAssignItems(items, fallbackMode) {
|
|
513
|
+
return items.map((item, itemIndex) => ({
|
|
514
|
+
key: normalizeKey(item.key, `${fallbackMode}-item`, itemIndex),
|
|
515
|
+
enable: normalizeBoolean(item.enabled, true),
|
|
516
|
+
targetPath: normalizeFieldPath(item.targetPath, `${fallbackMode}.targetPath`),
|
|
517
|
+
mode: fallbackMode,
|
|
518
|
+
condition: compileReactionFilter(normalizeReactionFilter(item.when)),
|
|
519
|
+
value: compileValueExpr(item.value)
|
|
520
|
+
}));
|
|
521
|
+
}
|
|
522
|
+
function compileFieldAction(action, index, prefix, options) {
|
|
523
|
+
const actionNames = import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES[options.scene];
|
|
524
|
+
if (action.type === "setFieldState") {
|
|
525
|
+
const actionName = actionNames.setFieldState;
|
|
526
|
+
return {
|
|
527
|
+
key: normalizeKey(action.key, prefix, index),
|
|
528
|
+
name: actionName,
|
|
529
|
+
params: {
|
|
530
|
+
value: {
|
|
531
|
+
fields: import_lodash.default.uniq(
|
|
532
|
+
action.fieldPaths.map(
|
|
533
|
+
(fieldPath) => {
|
|
534
|
+
var _a;
|
|
535
|
+
return ((_a = options.resolveFieldUid) == null ? void 0 : _a.call(options, fieldPath)) || normalizeFieldPath(fieldPath, "fieldPath");
|
|
536
|
+
}
|
|
537
|
+
)
|
|
538
|
+
),
|
|
539
|
+
state: action.state
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
if (action.type === "assignField") {
|
|
545
|
+
if (!("assignField" in actionNames)) {
|
|
546
|
+
(0, import_errors.throwBadRequest)(
|
|
547
|
+
`Field linkage action "${action.type}" is not supported in scene "${options.scene}".`,
|
|
548
|
+
import_errors2.FLOW_SURFACE_REACTION_UNSUPPORTED_ACTION_FOR_SCENE
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
key: normalizeKey(action.key, prefix, index),
|
|
553
|
+
name: actionNames.assignField,
|
|
554
|
+
params: {
|
|
555
|
+
value: compileFieldAssignItems(action.items, "assign")
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
if (action.type === "setFieldDefaultValue") {
|
|
560
|
+
if (!("setFieldDefaultValue" in actionNames)) {
|
|
561
|
+
(0, import_errors.throwBadRequest)(
|
|
562
|
+
`Field linkage action "${action.type}" is not supported in scene "${options.scene}".`,
|
|
563
|
+
import_errors2.FLOW_SURFACE_REACTION_UNSUPPORTED_ACTION_FOR_SCENE
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
key: normalizeKey(action.key, prefix, index),
|
|
568
|
+
name: actionNames.setFieldDefaultValue,
|
|
569
|
+
params: {
|
|
570
|
+
value: compileFieldAssignItems(action.items, "default")
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
return {
|
|
575
|
+
key: normalizeKey(action.key, prefix, index),
|
|
576
|
+
name: import_registry.FLOW_SURFACE_LINKAGE_CANONICAL_ACTION_NAMES[options.scene].runjs,
|
|
577
|
+
params: {
|
|
578
|
+
value: {
|
|
579
|
+
script: action.code,
|
|
580
|
+
...action.version ? { version: action.version } : {}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function assertScene(kind, scene) {
|
|
586
|
+
const expectedScene = kind === "blockLinkage" ? "block" : "action";
|
|
587
|
+
if (scene !== expectedScene) {
|
|
588
|
+
(0, import_errors.throwBadRequest)(
|
|
589
|
+
`${kind} only supports scene "${expectedScene}". Received "${scene}".`,
|
|
590
|
+
import_errors2.FLOW_SURFACE_REACTION_UNSUPPORTED_TARGET_KIND
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
function buildAllowedContextPathSet(operatorsByPath) {
|
|
595
|
+
return new Set(Object.keys(operatorsByPath || {}).filter(Boolean));
|
|
596
|
+
}
|
|
597
|
+
function formatAllowedValues(values) {
|
|
598
|
+
return values.length ? values.join(", ") : "(none)";
|
|
599
|
+
}
|
|
600
|
+
function validateContextBoundValuePath(rawPath, allowedContextPaths, fieldName, code = import_errors2.FLOW_SURFACE_REACTION_INVALID_VALUE_PATH) {
|
|
601
|
+
const path = extractBareContextPath(rawPath, `${fieldName}.path`);
|
|
602
|
+
if (!allowedContextPaths.has(path)) {
|
|
603
|
+
(0, import_errors.throwBadRequest)(`${fieldName}.path "${path}" is not available in the current reaction context.`, code);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
function validateContextBoundValue(value, allowedContextPaths, fieldName) {
|
|
607
|
+
if (import_lodash.default.isPlainObject(value) && value.source === "path") {
|
|
608
|
+
validateContextBoundValuePath(value.path, allowedContextPaths, fieldName);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (Array.isArray(value)) {
|
|
612
|
+
value.forEach((item, index) => validateContextBoundValue(item, allowedContextPaths, `${fieldName}[${index}]`));
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (import_lodash.default.isPlainObject(value)) {
|
|
616
|
+
for (const [key, item] of Object.entries(value)) {
|
|
617
|
+
validateContextBoundValue(item, allowedContextPaths, `${fieldName}.${key}`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
function validateReactionFilterAgainstCapability(filter, capability, prefix) {
|
|
622
|
+
var _a;
|
|
623
|
+
const operatorsByPath = ((_a = capability.conditionMeta) == null ? void 0 : _a.operatorsByPath) || {};
|
|
624
|
+
const allowedContextPaths = buildAllowedContextPathSet(operatorsByPath);
|
|
625
|
+
const visit = (node, currentPrefix) => {
|
|
626
|
+
if (!import_lodash.default.isPlainObject(node)) {
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
if (Array.isArray(node.items)) {
|
|
630
|
+
node.items.forEach((item, index) => visit(item, `${currentPrefix}.items[${index}]`));
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
const hasOperator = "operator" in node;
|
|
634
|
+
const hasValue = "value" in node;
|
|
635
|
+
const hasPath = "path" in node;
|
|
636
|
+
if (!hasOperator && !hasValue && !hasPath) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (!hasPath) {
|
|
640
|
+
(0, import_errors.throwBadRequest)(
|
|
641
|
+
`${currentPrefix}.path must be a non-empty string.`,
|
|
642
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_CONDITION_PATH
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
const path = extractBareContextPath(node.path, `${currentPrefix}.path`);
|
|
646
|
+
if (!allowedContextPaths.has(path)) {
|
|
647
|
+
(0, import_errors.throwBadRequest)(
|
|
648
|
+
`${currentPrefix}.path "${path}" is not available in the current reaction context.`,
|
|
649
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_CONDITION_PATH
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
const operator = typeof node.operator === "string" ? node.operator.trim() : "";
|
|
653
|
+
const allowedOperators = operatorsByPath[path] || [];
|
|
654
|
+
if (!operator) {
|
|
655
|
+
(0, import_errors.throwBadRequest)(
|
|
656
|
+
`${currentPrefix}.operator is required for path "${path}".`,
|
|
657
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_CONDITION_OPERATOR
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
if (!allowedOperators.includes(operator)) {
|
|
661
|
+
(0, import_errors.throwBadRequest)(
|
|
662
|
+
`${currentPrefix}.operator "${operator}" is not supported for path "${path}". Supported operators: ${formatAllowedValues(
|
|
663
|
+
allowedOperators
|
|
664
|
+
)}.`,
|
|
665
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_CONDITION_OPERATOR
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
if (hasValue) {
|
|
669
|
+
validateContextBoundValue(node.value, allowedContextPaths, `${currentPrefix}.value`);
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
visit(filter, prefix);
|
|
673
|
+
}
|
|
674
|
+
function validateFieldAssignItemValue(item, capability, prefix) {
|
|
675
|
+
var _a;
|
|
676
|
+
const supportedSources = ((_a = capability.valueExprMeta) == null ? void 0 : _a.supportedSources) || [];
|
|
677
|
+
if (!supportedSources.includes(item.value.source)) {
|
|
678
|
+
(0, import_errors.throwBadRequest)(
|
|
679
|
+
`${prefix}.value.source "${item.value.source}" is not supported. Supported sources: ${formatAllowedValues(
|
|
680
|
+
supportedSources
|
|
681
|
+
)}.`,
|
|
682
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_VALUE_SOURCE
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
if (item.value.source === "path") {
|
|
686
|
+
validateContextBoundValuePath(
|
|
687
|
+
item.value.path,
|
|
688
|
+
buildAllowedContextPathSet(capability.conditionMeta.operatorsByPath),
|
|
689
|
+
`${prefix}.value`
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
function validateFieldAssignItemTarget(item, capability, prefix, mode) {
|
|
694
|
+
const field = capability.targetFields.find((targetField) => targetField.path === item.targetPath);
|
|
695
|
+
if (!field) {
|
|
696
|
+
(0, import_errors.throwBadRequest)(
|
|
697
|
+
`${prefix}.targetPath "${item.targetPath}" is not available in the current target fields.`,
|
|
698
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_TARGET_FIELD
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
const supported = mode === "assign" ? field.supportsAssign : field.supportsDefault;
|
|
702
|
+
if (!supported) {
|
|
703
|
+
(0, import_errors.throwBadRequest)(
|
|
704
|
+
`${prefix}.targetPath "${item.targetPath}" does not support ${mode === "assign" ? "assignment" : "default values"} in the current scene.`,
|
|
705
|
+
import_errors2.FLOW_SURFACE_REACTION_INVALID_TARGET_FIELD
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function buildReactionFingerprint(value) {
|
|
710
|
+
return (0, import_node_crypto.createHash)("sha1").update(buildStableFingerprintString(value)).digest("hex");
|
|
711
|
+
}
|
|
712
|
+
function normalizeBlockLinkageRules(rawRules) {
|
|
713
|
+
assertRuleArray(rawRules, "Block linkage rules");
|
|
714
|
+
return rawRules.map((rawRule, index) => {
|
|
715
|
+
const common = normalizeRuleCommon(rawRule, index, "block-linkage-rule");
|
|
716
|
+
const rawActions = Array.isArray(rawRule == null ? void 0 : rawRule.then) ? rawRule.then : Array.isArray(rawRule == null ? void 0 : rawRule.actions) ? rawRule.actions : [];
|
|
717
|
+
return {
|
|
718
|
+
key: common.key,
|
|
719
|
+
title: common.title,
|
|
720
|
+
enabled: common.enabled,
|
|
721
|
+
when: common.when,
|
|
722
|
+
then: rawActions.map(
|
|
723
|
+
(rawAction, actionIndex) => normalizeBlockAction(rawAction, actionIndex, `${common.key}-action`)
|
|
724
|
+
)
|
|
725
|
+
};
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
function normalizeActionLinkageRules(rawRules) {
|
|
729
|
+
assertRuleArray(rawRules, "Action linkage rules");
|
|
730
|
+
return rawRules.map((rawRule, index) => {
|
|
731
|
+
const common = normalizeRuleCommon(rawRule, index, "action-linkage-rule");
|
|
732
|
+
const rawActions = Array.isArray(rawRule == null ? void 0 : rawRule.then) ? rawRule.then : Array.isArray(rawRule == null ? void 0 : rawRule.actions) ? rawRule.actions : [];
|
|
733
|
+
return {
|
|
734
|
+
key: common.key,
|
|
735
|
+
title: common.title,
|
|
736
|
+
enabled: common.enabled,
|
|
737
|
+
when: common.when,
|
|
738
|
+
then: rawActions.map(
|
|
739
|
+
(rawAction, actionIndex) => normalizeActionAction(rawAction, actionIndex, `${common.key}-action`)
|
|
740
|
+
)
|
|
741
|
+
};
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
function normalizeFieldLinkageRules(rawRules, options) {
|
|
745
|
+
assertRuleArray(rawRules, "Field linkage rules");
|
|
746
|
+
const normalized = rawRules.map((rawRule, index) => {
|
|
747
|
+
const common = normalizeRuleCommon(rawRule, index, "field-linkage-rule");
|
|
748
|
+
const rawActions = Array.isArray(rawRule == null ? void 0 : rawRule.then) ? rawRule.then : Array.isArray(rawRule == null ? void 0 : rawRule.actions) ? rawRule.actions : [];
|
|
749
|
+
return {
|
|
750
|
+
key: common.key,
|
|
751
|
+
title: common.title,
|
|
752
|
+
enabled: common.enabled,
|
|
753
|
+
when: common.when,
|
|
754
|
+
then: rawActions.map(
|
|
755
|
+
(rawAction, actionIndex) => normalizeFieldAction(rawAction, actionIndex, `${common.key}-action`, options)
|
|
756
|
+
)
|
|
757
|
+
};
|
|
758
|
+
});
|
|
759
|
+
validateFieldLinkageSceneSupport(options.scene, normalized);
|
|
760
|
+
return normalized;
|
|
761
|
+
}
|
|
762
|
+
function validateBlockLinkageSceneSupport(scene, rules) {
|
|
763
|
+
assertScene("blockLinkage", scene);
|
|
764
|
+
for (const rule of rules || []) {
|
|
765
|
+
for (const action of rule.then || []) {
|
|
766
|
+
if (action.type === "setBlockState" && !import_registry.FLOW_SURFACE_BLOCK_LINKAGE_STATES.includes(action.state)) {
|
|
767
|
+
(0, import_errors.throwBadRequest)(
|
|
768
|
+
`Block linkage state "${String(action.state)}" is not supported in scene "${scene}".`,
|
|
769
|
+
import_errors2.FLOW_SURFACE_REACTION_UNSUPPORTED_ACTION_FOR_SCENE
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function validateBlockLinkageRulesAgainstCapability(rules, capability) {
|
|
776
|
+
for (const [ruleIndex, rule] of (rules || []).entries()) {
|
|
777
|
+
validateReactionFilterAgainstCapability(rule.when, capability, `rules[${ruleIndex}].when`);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
function validateActionLinkageSceneSupport(scene, rules) {
|
|
781
|
+
assertScene("actionLinkage", scene);
|
|
782
|
+
for (const rule of rules || []) {
|
|
783
|
+
for (const action of rule.then || []) {
|
|
784
|
+
if (action.type === "setActionState" && !import_registry.FLOW_SURFACE_ACTION_LINKAGE_STATES.includes(action.state)) {
|
|
785
|
+
(0, import_errors.throwBadRequest)(
|
|
786
|
+
`Action linkage state "${String(action.state)}" is not supported in scene "${scene}".`,
|
|
787
|
+
import_errors2.FLOW_SURFACE_REACTION_UNSUPPORTED_ACTION_FOR_SCENE
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
function validateActionLinkageRulesAgainstCapability(rules, capability) {
|
|
794
|
+
for (const [ruleIndex, rule] of (rules || []).entries()) {
|
|
795
|
+
validateReactionFilterAgainstCapability(rule.when, capability, `rules[${ruleIndex}].when`);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
function validateFieldLinkageSceneSupport(scene, rules) {
|
|
799
|
+
const supportedActionTypes = import_registry.FLOW_SURFACE_FIELD_LINKAGE_ACTION_TYPES_BY_SCENE[scene];
|
|
800
|
+
const supportedStates = import_registry.FLOW_SURFACE_FIELD_LINKAGE_STATES_BY_SCENE[scene];
|
|
801
|
+
for (const rule of rules || []) {
|
|
802
|
+
for (const action of rule.then || []) {
|
|
803
|
+
if (!supportedActionTypes.includes(action.type)) {
|
|
804
|
+
(0, import_errors.throwBadRequest)(
|
|
805
|
+
`Field linkage action "${action.type}" is not supported in scene "${scene}".`,
|
|
806
|
+
import_errors2.FLOW_SURFACE_REACTION_UNSUPPORTED_ACTION_FOR_SCENE
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
if (action.type === "setFieldState" && !supportedStates.includes(action.state)) {
|
|
810
|
+
(0, import_errors.throwBadRequest)(
|
|
811
|
+
`Field linkage state "${String(action.state)}" is not supported in scene "${scene}".`,
|
|
812
|
+
import_errors2.FLOW_SURFACE_REACTION_UNSUPPORTED_ACTION_FOR_SCENE
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function validateFieldLinkageRulesAgainstCapability(rules, capability) {
|
|
819
|
+
for (const [ruleIndex, rule] of (rules || []).entries()) {
|
|
820
|
+
validateReactionFilterAgainstCapability(rule.when, capability, `rules[${ruleIndex}].when`);
|
|
821
|
+
for (const [actionIndex, action] of (rule.then || []).entries()) {
|
|
822
|
+
if (action.type !== "assignField" && action.type !== "setFieldDefaultValue") {
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
const mode = action.type === "assignField" ? "assign" : "default";
|
|
826
|
+
for (const [itemIndex, item] of (action.items || []).entries()) {
|
|
827
|
+
const itemPrefix = `rules[${ruleIndex}].then[${actionIndex}].items[${itemIndex}]`;
|
|
828
|
+
validateFieldAssignItemTarget(item, capability, itemPrefix, mode);
|
|
829
|
+
validateFieldAssignItemValue(item, capability, itemPrefix);
|
|
830
|
+
validateReactionFilterAgainstCapability(item.when, capability, `${itemPrefix}.when`);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
function compileBlockLinkageCanonicalRules(rules) {
|
|
836
|
+
validateBlockLinkageSceneSupport("block", rules);
|
|
837
|
+
return normalizeBlockLinkageRules(rules).map((rule, index) => ({
|
|
838
|
+
key: normalizeKey(rule.key, "block-linkage-rule", index),
|
|
839
|
+
title: normalizeTitle(rule.title, index),
|
|
840
|
+
enable: normalizeBoolean(rule.enabled, true),
|
|
841
|
+
condition: compileReactionFilter(normalizeReactionFilter(rule.when)),
|
|
842
|
+
actions: rule.then.map((action, actionIndex) => compileBlockAction(action, actionIndex, `${rule.key}-action`))
|
|
843
|
+
}));
|
|
844
|
+
}
|
|
845
|
+
function compileActionLinkageCanonicalRules(rules) {
|
|
846
|
+
validateActionLinkageSceneSupport("action", rules);
|
|
847
|
+
return normalizeActionLinkageRules(rules).map((rule, index) => ({
|
|
848
|
+
key: normalizeKey(rule.key, "action-linkage-rule", index),
|
|
849
|
+
title: normalizeTitle(rule.title, index),
|
|
850
|
+
enable: normalizeBoolean(rule.enabled, true),
|
|
851
|
+
condition: compileReactionFilter(normalizeReactionFilter(rule.when)),
|
|
852
|
+
actions: rule.then.map((action, actionIndex) => compileActionAction(action, actionIndex, `${rule.key}-action`))
|
|
853
|
+
}));
|
|
854
|
+
}
|
|
855
|
+
function compileFieldLinkageCanonicalRules(rules, options) {
|
|
856
|
+
validateFieldLinkageSceneSupport(options.scene, rules);
|
|
857
|
+
return normalizeFieldLinkageRules(rules, { scene: options.scene }).map((rule, index) => ({
|
|
858
|
+
key: normalizeKey(rule.key, "field-linkage-rule", index),
|
|
859
|
+
title: normalizeTitle(rule.title, index),
|
|
860
|
+
enable: normalizeBoolean(rule.enabled, true),
|
|
861
|
+
condition: compileReactionFilter(normalizeReactionFilter(rule.when)),
|
|
862
|
+
actions: rule.then.map(
|
|
863
|
+
(action, actionIndex) => compileFieldAction(action, actionIndex, `${rule.key}-action`, options)
|
|
864
|
+
)
|
|
865
|
+
}));
|
|
866
|
+
}
|
|
867
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
868
|
+
0 && (module.exports = {
|
|
869
|
+
buildReactionFingerprint,
|
|
870
|
+
compileActionLinkageCanonicalRules,
|
|
871
|
+
compileBlockLinkageCanonicalRules,
|
|
872
|
+
compileFieldLinkageCanonicalRules,
|
|
873
|
+
normalizeActionLinkageRules,
|
|
874
|
+
normalizeBlockLinkageRules,
|
|
875
|
+
normalizeFieldLinkageRules,
|
|
876
|
+
validateActionLinkageRulesAgainstCapability,
|
|
877
|
+
validateActionLinkageSceneSupport,
|
|
878
|
+
validateBlockLinkageRulesAgainstCapability,
|
|
879
|
+
validateBlockLinkageSceneSupport,
|
|
880
|
+
validateFieldLinkageRulesAgainstCapability,
|
|
881
|
+
validateFieldLinkageSceneSupport
|
|
882
|
+
});
|