@nocobase/plugin-flow-engine 2.1.0-alpha.15 → 2.1.0-alpha.16

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.
Files changed (116) hide show
  1. package/dist/externalVersion.js +10 -10
  2. package/dist/node_modules/ses/package.json +1 -1
  3. package/dist/node_modules/zod/package.json +1 -1
  4. package/dist/server/flow-surfaces/{compiler.d.ts → apply/compiler.d.ts} +1 -10
  5. package/dist/server/flow-surfaces/{compiler.js → apply/compiler.js} +41 -280
  6. package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
  7. package/dist/server/flow-surfaces/apply/layout.js +175 -0
  8. package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
  9. package/dist/server/flow-surfaces/apply/matching.js +181 -0
  10. package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
  11. package/dist/server/flow-surfaces/association-title-field.js +158 -0
  12. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
  13. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +706 -0
  14. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
  15. package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
  16. package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
  17. package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
  18. package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
  19. package/dist/server/flow-surfaces/blueprint/index.js +44 -0
  20. package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
  21. package/dist/server/flow-surfaces/blueprint/normalize-document.js +296 -0
  22. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
  23. package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
  24. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +153 -0
  25. package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
  26. package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
  27. package/dist/server/flow-surfaces/catalog-smart.js +239 -0
  28. package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
  29. package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
  30. package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
  31. package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
  32. package/dist/server/flow-surfaces/catalog.d.ts +3 -0
  33. package/dist/server/flow-surfaces/catalog.js +163 -34
  34. package/dist/server/flow-surfaces/compose-compiler.d.ts +104 -0
  35. package/dist/server/flow-surfaces/compose-compiler.js +162 -0
  36. package/dist/server/flow-surfaces/compose-runtime.d.ts +89 -0
  37. package/dist/server/flow-surfaces/compose-runtime.js +338 -0
  38. package/dist/server/flow-surfaces/configure-options.js +12 -3
  39. package/dist/server/flow-surfaces/constants.d.ts +3 -2
  40. package/dist/server/flow-surfaces/constants.js +36 -3
  41. package/dist/server/flow-surfaces/default-action-popup.d.ts +52 -0
  42. package/dist/server/flow-surfaces/default-action-popup.js +258 -0
  43. package/dist/server/flow-surfaces/executor.d.ts +10 -0
  44. package/dist/server/flow-surfaces/executor.js +59 -24
  45. package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
  46. package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
  47. package/dist/server/flow-surfaces/field-semantics.d.ts +1 -1
  48. package/dist/server/flow-surfaces/index.js +75 -0
  49. package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
  50. package/dist/server/flow-surfaces/node-use-sets.js +114 -0
  51. package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
  52. package/dist/server/flow-surfaces/payload-shape.js +64 -0
  53. package/dist/server/flow-surfaces/placement.js +2 -6
  54. package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
  55. package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
  56. package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
  57. package/dist/server/flow-surfaces/planning/compiler.js +376 -0
  58. package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
  59. package/dist/server/flow-surfaces/planning/context.js +139 -0
  60. package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
  61. package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
  62. package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
  63. package/dist/server/flow-surfaces/planning/key-kind.js +86 -0
  64. package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
  65. package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
  66. package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
  67. package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
  68. package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
  69. package/dist/server/flow-surfaces/planning/runtime.js +259 -0
  70. package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
  71. package/dist/server/flow-surfaces/planning/step-link.js +104 -0
  72. package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
  73. package/dist/server/flow-surfaces/planning/types.js +24 -0
  74. package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
  75. package/dist/server/flow-surfaces/reaction/errors.js +69 -0
  76. package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
  77. package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
  78. package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
  79. package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
  80. package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
  81. package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
  82. package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
  83. package/dist/server/flow-surfaces/reaction/meta.js +451 -0
  84. package/dist/server/flow-surfaces/reaction/registry.d.ts +136 -0
  85. package/dist/server/flow-surfaces/reaction/registry.js +186 -0
  86. package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
  87. package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
  88. package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
  89. package/dist/server/flow-surfaces/reaction/types.js +24 -0
  90. package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
  91. package/dist/server/flow-surfaces/reaction/utils.js +67 -0
  92. package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
  93. package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
  94. package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
  95. package/dist/server/flow-surfaces/reference-guards.js +103 -0
  96. package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
  97. package/dist/server/flow-surfaces/service-helpers.js +377 -0
  98. package/dist/server/flow-surfaces/service-utils.d.ts +105 -0
  99. package/dist/server/flow-surfaces/service-utils.js +760 -0
  100. package/dist/server/flow-surfaces/service.d.ts +189 -103
  101. package/dist/server/flow-surfaces/service.js +3975 -1770
  102. package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
  103. package/dist/server/flow-surfaces/template-compatibility.js +189 -0
  104. package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
  105. package/dist/server/flow-surfaces/template-service-utils.js +281 -0
  106. package/dist/server/flow-surfaces/types.d.ts +129 -37
  107. package/dist/swagger/flow-surfaces.d.ts +3773 -1581
  108. package/dist/swagger/flow-surfaces.examples.d.ts +1215 -0
  109. package/dist/swagger/flow-surfaces.examples.js +1363 -0
  110. package/dist/swagger/flow-surfaces.js +2209 -1684
  111. package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
  112. package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
  113. package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
  114. package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
  115. package/dist/swagger/index.d.ts +3773 -1581
  116. package/package.json +2 -2
@@ -0,0 +1,162 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var compose_compiler_exports = {};
28
+ __export(compose_compiler_exports, {
29
+ compileComposeExecutionPlan: () => compileComposeExecutionPlan,
30
+ resolveComposeFieldContainerSource: () => resolveComposeFieldContainerSource,
31
+ resolveComposeTargetKey: () => resolveComposeTargetKey
32
+ });
33
+ module.exports = __toCommonJS(compose_compiler_exports);
34
+ var import_errors = require("./errors");
35
+ const LIST_LIKE_COMPOSE_BLOCK_TYPES = /* @__PURE__ */ new Set(["list", "gridCard"]);
36
+ function compileComposeExecutionPlan(input) {
37
+ const blocks = compileComposeBlockTasks(input.gridUid, input.normalizedBlocks);
38
+ const fields = compileComposeFieldTasks(input.normalizedBlocks);
39
+ const actions = compileComposeActionTasks(input.normalizedBlocks);
40
+ const recordActions = compileComposeRecordActionTasks(input.normalizedBlocks);
41
+ return {
42
+ gridUid: input.gridUid,
43
+ mode: input.mode,
44
+ existingItemUids: Array.from(new Set((input.existingItemUids || []).filter(Boolean))),
45
+ blocks,
46
+ fields,
47
+ actions,
48
+ recordActions,
49
+ layoutPlan: buildComposeLayoutPlan({
50
+ mode: input.mode,
51
+ layout: input.layout,
52
+ hasBlocks: blocks.length > 0
53
+ })
54
+ };
55
+ }
56
+ function compileComposeBlockTasks(gridUid, normalizedBlocks) {
57
+ return normalizedBlocks.map((blockSpec) => ({
58
+ key: blockSpec.key,
59
+ spec: blockSpec,
60
+ payload: buildComposeBlockCreatePayload(gridUid, blockSpec)
61
+ }));
62
+ }
63
+ function compileComposeFieldTasks(normalizedBlocks) {
64
+ return normalizedBlocks.flatMap(
65
+ (blockSpec) => blockSpec.fields.map((fieldSpec) => ({
66
+ blockKey: blockSpec.key,
67
+ spec: fieldSpec,
68
+ containerSource: resolveComposeFieldContainerSource(blockSpec),
69
+ payload: buildComposeFieldCreatePayload(fieldSpec)
70
+ }))
71
+ );
72
+ }
73
+ function compileComposeActionTasks(normalizedBlocks) {
74
+ return normalizedBlocks.flatMap(
75
+ (blockSpec) => blockSpec.actions.map((actionSpec) => ({
76
+ blockKey: blockSpec.key,
77
+ spec: actionSpec,
78
+ payload: buildComposeActionCreatePayload(actionSpec)
79
+ }))
80
+ );
81
+ }
82
+ function compileComposeRecordActionTasks(normalizedBlocks) {
83
+ return normalizedBlocks.flatMap(
84
+ (blockSpec) => blockSpec.recordActions.map((actionSpec) => ({
85
+ blockKey: blockSpec.key,
86
+ spec: actionSpec,
87
+ payload: buildComposeRecordActionCreatePayload(actionSpec)
88
+ }))
89
+ );
90
+ }
91
+ function resolveComposeFieldContainerSource(blockSpec) {
92
+ return LIST_LIKE_COMPOSE_BLOCK_TYPES.has(blockSpec.type || "") ? "item" : "block";
93
+ }
94
+ function resolveComposeTargetKey(targetKey, keyMap, kind) {
95
+ var _a, _b;
96
+ const key = String(targetKey || "").trim();
97
+ if (!key) {
98
+ (0, import_errors.throwBadRequest)(`flowSurfaces compose ${kind} target key cannot be empty`);
99
+ }
100
+ if (!((_a = keyMap[key]) == null ? void 0 : _a.uid)) {
101
+ (0, import_errors.throwBadRequest)(`flowSurfaces compose ${kind} target '${key}' was not created in the current compose call`);
102
+ }
103
+ return (_b = keyMap[key]) == null ? void 0 : _b.uid;
104
+ }
105
+ function buildComposeBlockCreatePayload(gridUid, blockSpec) {
106
+ var _a, _b;
107
+ return {
108
+ target: {
109
+ uid: gridUid
110
+ },
111
+ ...blockSpec.key ? { key: blockSpec.key } : {},
112
+ ...blockSpec.type ? { type: blockSpec.type } : {},
113
+ ...((_a = blockSpec.resource) == null ? void 0 : _a.kind) === "semantic" ? { resource: blockSpec.resource.value } : {},
114
+ ...((_b = blockSpec.resource) == null ? void 0 : _b.kind) === "raw" ? { resourceInit: blockSpec.resource.value } : {},
115
+ ...blockSpec.template ? { template: blockSpec.template } : {}
116
+ };
117
+ }
118
+ function buildComposeFieldCreatePayload(fieldSpec) {
119
+ return {
120
+ ...fieldSpec.key ? { key: fieldSpec.key } : {},
121
+ ...fieldSpec.fieldPath ? { fieldPath: fieldSpec.fieldPath } : {},
122
+ ...fieldSpec.associationPathName ? { associationPathName: fieldSpec.associationPathName } : {},
123
+ ...fieldSpec.renderer ? { renderer: fieldSpec.renderer } : {},
124
+ ...fieldSpec.type ? { type: fieldSpec.type } : {},
125
+ ...fieldSpec.popup ? { popup: fieldSpec.popup } : {}
126
+ };
127
+ }
128
+ function buildComposeActionCreatePayload(actionSpec) {
129
+ return {
130
+ ...actionSpec.key ? { key: actionSpec.key } : {},
131
+ type: actionSpec.type
132
+ };
133
+ }
134
+ function buildComposeRecordActionCreatePayload(actionSpec) {
135
+ return {
136
+ ...actionSpec.key ? { key: actionSpec.key } : {},
137
+ type: actionSpec.type
138
+ };
139
+ }
140
+ function buildComposeLayoutPlan(input) {
141
+ var _a;
142
+ if (((_a = input.layout) == null ? void 0 : _a.rows) || input.mode === "replace") {
143
+ return {
144
+ kind: "explicit",
145
+ layout: input.layout
146
+ };
147
+ }
148
+ if (input.mode === "append" && input.hasBlocks) {
149
+ return {
150
+ kind: "append"
151
+ };
152
+ }
153
+ return {
154
+ kind: "none"
155
+ };
156
+ }
157
+ // Annotate the CommonJS export names for ESM import in node:
158
+ 0 && (module.exports = {
159
+ compileComposeExecutionPlan,
160
+ resolveComposeFieldContainerSource,
161
+ resolveComposeTargetKey
162
+ });
@@ -0,0 +1,89 @@
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 FlowSurfaceCompiledComposePlan, type FlowSurfaceComposeNormalizedActionSpec, type FlowSurfaceComposeNormalizedBlockSpec, type FlowSurfaceComposeNormalizedFieldSpec, type FlowSurfaceComposeObject, type FlowSurfaceComposeTargetKey } from './compose-compiler';
10
+ export type FlowSurfaceComposeBlockResult = {
11
+ uid: string;
12
+ gridUid?: string;
13
+ itemUid?: string;
14
+ itemGridUid?: string;
15
+ actionsColumnUid?: string;
16
+ };
17
+ export type FlowSurfaceComposeFieldResult = {
18
+ uid?: string;
19
+ wrapperUid?: string;
20
+ fieldUid?: string;
21
+ innerFieldUid?: string;
22
+ popupPageUid?: string;
23
+ popupTabUid?: string;
24
+ popupGridUid?: string;
25
+ };
26
+ export type FlowSurfaceComposeActionResult = {
27
+ uid: string;
28
+ parentUid?: string;
29
+ scope?: string;
30
+ };
31
+ export type FlowSurfaceComposeRuntimeBlockState = {
32
+ spec: FlowSurfaceComposeNormalizedBlockSpec;
33
+ result: FlowSurfaceComposeBlockResult;
34
+ fieldResults: Array<Record<string, unknown>>;
35
+ actionResults: Array<Record<string, unknown>>;
36
+ recordActionResults: Array<Record<string, unknown>>;
37
+ };
38
+ export type FlowSurfaceComposeRuntimeState = {
39
+ keyMap: Record<string, FlowSurfaceComposeTargetKey & Partial<FlowSurfaceComposeBlockResult>>;
40
+ blocks: FlowSurfaceComposeRuntimeBlockState[];
41
+ };
42
+ export type FlowSurfaceComposeExecutionResult = {
43
+ target: {
44
+ uid: string;
45
+ };
46
+ mode: FlowSurfaceCompiledComposePlan['mode'];
47
+ blocks: Array<{
48
+ key: string;
49
+ type?: string;
50
+ uid: string;
51
+ gridUid?: string;
52
+ itemUid?: string;
53
+ itemGridUid?: string;
54
+ actionsColumnUid?: string;
55
+ fields: Array<Record<string, unknown>>;
56
+ actions: Array<Record<string, unknown>>;
57
+ recordActions: Array<Record<string, unknown>>;
58
+ }>;
59
+ layout?: unknown;
60
+ };
61
+ export type FlowSurfaceComposeRuntimeDeps = {
62
+ removeExistingItem?: (uid: string) => Promise<void>;
63
+ createBlock: (payload: Record<string, unknown>, spec: FlowSurfaceComposeNormalizedBlockSpec) => Promise<FlowSurfaceComposeBlockResult>;
64
+ applyNodeSettings?: (actionName: string, targetUid: string | undefined, settings?: FlowSurfaceComposeObject) => Promise<void>;
65
+ createField: (payload: Record<string, unknown>, spec: FlowSurfaceComposeNormalizedFieldSpec, blockResult: FlowSurfaceComposeBlockResult) => Promise<FlowSurfaceComposeFieldResult | null>;
66
+ applyFieldSettings?: (actionName: string, result: FlowSurfaceComposeFieldResult, settings?: FlowSurfaceComposeObject) => Promise<void>;
67
+ onFieldError?: (input: {
68
+ error: unknown;
69
+ spec: FlowSurfaceComposeNormalizedFieldSpec;
70
+ blockSpec: FlowSurfaceComposeNormalizedBlockSpec;
71
+ blockResult: FlowSurfaceComposeBlockResult;
72
+ }) => Promise<'continue' | void> | 'continue' | void;
73
+ createAction: (payload: Record<string, unknown>, spec: FlowSurfaceComposeNormalizedActionSpec, blockResult: FlowSurfaceComposeBlockResult) => Promise<FlowSurfaceComposeActionResult>;
74
+ createRecordAction: (payload: Record<string, unknown>, spec: FlowSurfaceComposeNormalizedActionSpec, blockResult: FlowSurfaceComposeBlockResult) => Promise<FlowSurfaceComposeActionResult>;
75
+ applyActionPopup?: (actionName: string, actionUid: string, popup?: FlowSurfaceComposeObject) => Promise<void>;
76
+ collectActionKeys?: (actionUid: string) => Promise<Record<string, unknown>>;
77
+ buildExplicitLayoutPayload?: (input: {
78
+ layout?: FlowSurfaceComposeObject;
79
+ createdByKey: Record<string, FlowSurfaceComposeTargetKey & Partial<FlowSurfaceComposeBlockResult>>;
80
+ gridUid: string;
81
+ }) => Promise<Record<string, unknown>> | Record<string, unknown>;
82
+ buildAppendLayoutPayload?: (input: {
83
+ gridUid: string;
84
+ appendedItemUids: string[];
85
+ }) => Promise<Record<string, unknown>> | Record<string, unknown>;
86
+ setLayout?: (payload: Record<string, unknown>) => Promise<unknown>;
87
+ };
88
+ export declare function executeComposeRuntime(plan: FlowSurfaceCompiledComposePlan, deps: FlowSurfaceComposeRuntimeDeps): Promise<FlowSurfaceComposeExecutionResult>;
89
+ export declare function createComposeRuntimeState(): FlowSurfaceComposeRuntimeState;
@@ -0,0 +1,338 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var compose_runtime_exports = {};
28
+ __export(compose_runtime_exports, {
29
+ createComposeRuntimeState: () => createComposeRuntimeState,
30
+ executeComposeRuntime: () => executeComposeRuntime
31
+ });
32
+ module.exports = __toCommonJS(compose_runtime_exports);
33
+ var import_errors = require("./errors");
34
+ var import_default_action_popup = require("./default-action-popup");
35
+ var import_compose_compiler = require("./compose-compiler");
36
+ async function executeComposeRuntime(plan, deps) {
37
+ assertComposeRuntimeDeps(plan, deps);
38
+ const state = createComposeRuntimeState();
39
+ await removeExistingItemsForReplace(plan, deps);
40
+ await createBlocks(plan, deps, state);
41
+ await applyBlockSettings(deps, state);
42
+ await createFields(plan, deps, state);
43
+ await createActions(plan, deps, state);
44
+ await createRecordActions(plan, deps, state);
45
+ const layoutResult = await applyComposeLayout(plan, deps, state);
46
+ return {
47
+ target: {
48
+ uid: plan.gridUid
49
+ },
50
+ mode: plan.mode,
51
+ blocks: state.blocks.map((block) => ({
52
+ key: block.spec.key,
53
+ type: block.spec.type,
54
+ uid: block.result.uid,
55
+ gridUid: block.result.gridUid,
56
+ itemUid: block.result.itemUid,
57
+ itemGridUid: block.result.itemGridUid,
58
+ actionsColumnUid: block.result.actionsColumnUid,
59
+ fields: block.fieldResults,
60
+ actions: block.actionResults,
61
+ recordActions: block.recordActionResults
62
+ })),
63
+ ...typeof layoutResult === "undefined" ? {} : { layout: layoutResult }
64
+ };
65
+ }
66
+ function createComposeRuntimeState() {
67
+ return {
68
+ keyMap: {},
69
+ blocks: []
70
+ };
71
+ }
72
+ function shouldApplyActionPopupAfterEffect(spec) {
73
+ return hasPopupAfterEffect(spec.popup) || (0, import_default_action_popup.isFlowSurfaceDefaultActionPopupType)(spec.type);
74
+ }
75
+ function assertComposeRuntimeDeps(plan, deps) {
76
+ if (plan.mode === "replace" && plan.existingItemUids.length) {
77
+ requireComposeRuntimeDep("removeExistingItem", deps.removeExistingItem, "replace");
78
+ }
79
+ if (plan.blocks.some((block) => hasInlineSettings(block.spec.settings))) {
80
+ requireComposeRuntimeDep("applyNodeSettings", deps.applyNodeSettings, "block settings");
81
+ }
82
+ if (plan.fields.some((field) => hasInlineSettings(field.spec.settings))) {
83
+ requireComposeRuntimeDep("applyFieldSettings", deps.applyFieldSettings, "field settings");
84
+ }
85
+ if ([...plan.actions, ...plan.recordActions].some(
86
+ (action) => hasInlineSettings(action.spec.settings) || shouldApplyActionPopupAfterEffect(action.spec)
87
+ )) {
88
+ if ([...plan.actions, ...plan.recordActions].some((action) => hasInlineSettings(action.spec.settings))) {
89
+ requireComposeRuntimeDep("applyNodeSettings", deps.applyNodeSettings, "action settings");
90
+ }
91
+ if ([...plan.actions, ...plan.recordActions].some((action) => shouldApplyActionPopupAfterEffect(action.spec))) {
92
+ requireComposeRuntimeDep("applyActionPopup", deps.applyActionPopup, "action popup");
93
+ }
94
+ }
95
+ }
96
+ function requireComposeRuntimeDep(name, dep, stage) {
97
+ if (dep) {
98
+ return;
99
+ }
100
+ (0, import_errors.throwConflict)(
101
+ `flowSurfaces compose ${stage} runtime deps missing '${name}'`,
102
+ "FLOW_SURFACE_COMPOSE_RUNTIME_DEPS_MISSING"
103
+ );
104
+ }
105
+ async function removeExistingItemsForReplace(plan, deps) {
106
+ if (plan.mode !== "replace" || !plan.existingItemUids.length) {
107
+ return;
108
+ }
109
+ const removeExistingItem = deps.removeExistingItem;
110
+ requireComposeRuntimeDep("removeExistingItem", removeExistingItem, "replace");
111
+ for (const uid of plan.existingItemUids) {
112
+ await removeExistingItem(uid);
113
+ }
114
+ }
115
+ async function createBlocks(plan, deps, state) {
116
+ for (const blockTask of plan.blocks) {
117
+ const result = await deps.createBlock(blockTask.payload, blockTask.spec);
118
+ state.blocks.push({
119
+ spec: blockTask.spec,
120
+ result,
121
+ fieldResults: [],
122
+ actionResults: [],
123
+ recordActionResults: []
124
+ });
125
+ state.keyMap[blockTask.key] = {
126
+ uid: result.uid,
127
+ gridUid: result.gridUid,
128
+ itemUid: result.itemUid,
129
+ itemGridUid: result.itemGridUid,
130
+ actionsColumnUid: result.actionsColumnUid
131
+ };
132
+ }
133
+ }
134
+ async function applyBlockSettings(deps, state) {
135
+ const applyNodeSettings = deps.applyNodeSettings;
136
+ if (!applyNodeSettings) {
137
+ return;
138
+ }
139
+ for (const block of state.blocks) {
140
+ if (!hasInlineSettings(block.spec.settings)) {
141
+ continue;
142
+ }
143
+ await applyNodeSettings("compose block", block.result.uid, block.spec.settings);
144
+ }
145
+ }
146
+ async function createFields(plan, deps, state) {
147
+ for (const fieldTask of plan.fields) {
148
+ const block = requireBlockState(fieldTask.blockKey, state);
149
+ const targetUid = fieldTask.containerSource === "item" ? block.result.itemUid || block.result.uid : block.result.uid;
150
+ let createdField;
151
+ try {
152
+ createdField = await deps.createField(
153
+ {
154
+ target: {
155
+ uid: targetUid
156
+ },
157
+ ...fieldTask.payload,
158
+ ...readComposeFieldTargetKey(fieldTask.spec.target) ? {
159
+ defaultTargetUid: (0, import_compose_compiler.resolveComposeTargetKey)(
160
+ readComposeFieldTargetKey(fieldTask.spec.target),
161
+ state.keyMap,
162
+ "field"
163
+ )
164
+ } : {}
165
+ },
166
+ fieldTask.spec,
167
+ block.result
168
+ );
169
+ } catch (error) {
170
+ const decision = deps.onFieldError ? await deps.onFieldError({
171
+ error,
172
+ spec: fieldTask.spec,
173
+ blockSpec: block.spec,
174
+ blockResult: block.result
175
+ }) : void 0;
176
+ if (decision === "continue") {
177
+ continue;
178
+ }
179
+ throw error;
180
+ }
181
+ if (!createdField) {
182
+ continue;
183
+ }
184
+ if (deps.applyFieldSettings && hasInlineSettings(fieldTask.spec.settings)) {
185
+ await deps.applyFieldSettings("compose field", createdField, fieldTask.spec.settings);
186
+ }
187
+ block.fieldResults.push(buildFieldResultSummary(fieldTask.spec, createdField));
188
+ }
189
+ }
190
+ async function createActions(plan, deps, state) {
191
+ for (const actionTask of plan.actions) {
192
+ const block = requireBlockState(actionTask.blockKey, state);
193
+ const createdAction = await deps.createAction(
194
+ {
195
+ target: {
196
+ uid: block.result.uid
197
+ },
198
+ ...actionTask.payload
199
+ },
200
+ actionTask.spec,
201
+ block.result
202
+ );
203
+ if (deps.applyNodeSettings && hasInlineSettings(actionTask.spec.settings)) {
204
+ await deps.applyNodeSettings("compose action", createdAction.uid, actionTask.spec.settings);
205
+ }
206
+ if (deps.applyActionPopup && shouldApplyActionPopupAfterEffect(actionTask.spec)) {
207
+ await deps.applyActionPopup("compose action", createdAction.uid, actionTask.spec.popup);
208
+ }
209
+ const actionKeys = deps.collectActionKeys ? await deps.collectActionKeys(createdAction.uid) : {};
210
+ block.actionResults.push(buildActionResultSummary(actionTask.spec, createdAction, actionKeys));
211
+ }
212
+ }
213
+ async function createRecordActions(plan, deps, state) {
214
+ for (const recordActionTask of plan.recordActions) {
215
+ const block = requireBlockState(recordActionTask.blockKey, state);
216
+ const createdAction = await deps.createRecordAction(
217
+ {
218
+ target: {
219
+ uid: block.result.uid
220
+ },
221
+ ...recordActionTask.payload
222
+ },
223
+ recordActionTask.spec,
224
+ block.result
225
+ );
226
+ if (!block.result.actionsColumnUid && block.spec.type === "table" && createdAction.parentUid) {
227
+ block.result.actionsColumnUid = createdAction.parentUid;
228
+ state.keyMap[recordActionTask.blockKey] = {
229
+ ...state.keyMap[recordActionTask.blockKey],
230
+ actionsColumnUid: createdAction.parentUid
231
+ };
232
+ }
233
+ if (deps.applyNodeSettings && hasInlineSettings(recordActionTask.spec.settings)) {
234
+ await deps.applyNodeSettings("compose recordAction", createdAction.uid, recordActionTask.spec.settings);
235
+ }
236
+ if (deps.applyActionPopup && shouldApplyActionPopupAfterEffect(recordActionTask.spec)) {
237
+ await deps.applyActionPopup("compose recordAction", createdAction.uid, recordActionTask.spec.popup);
238
+ }
239
+ const actionKeys = deps.collectActionKeys ? await deps.collectActionKeys(createdAction.uid) : {};
240
+ block.recordActionResults.push(buildActionResultSummary(recordActionTask.spec, createdAction, actionKeys));
241
+ }
242
+ }
243
+ async function applyComposeLayout(plan, deps, state) {
244
+ if (plan.layoutPlan.kind === "none") {
245
+ return void 0;
246
+ }
247
+ if (plan.layoutPlan.kind === "explicit") {
248
+ const buildExplicitLayoutPayload = deps.buildExplicitLayoutPayload;
249
+ const setLayout2 = deps.setLayout;
250
+ requireComposeRuntimeDep("buildExplicitLayoutPayload", buildExplicitLayoutPayload, "explicit layout");
251
+ requireComposeRuntimeDep("setLayout", setLayout2, "explicit layout");
252
+ const layoutPayload2 = await buildExplicitLayoutPayload({
253
+ layout: plan.layoutPlan.layout,
254
+ createdByKey: state.keyMap,
255
+ gridUid: plan.gridUid
256
+ });
257
+ return setLayout2({
258
+ target: {
259
+ uid: plan.gridUid
260
+ },
261
+ ...layoutPayload2
262
+ });
263
+ }
264
+ const buildAppendLayoutPayload = deps.buildAppendLayoutPayload;
265
+ const setLayout = deps.setLayout;
266
+ requireComposeRuntimeDep("buildAppendLayoutPayload", buildAppendLayoutPayload, "append layout");
267
+ requireComposeRuntimeDep("setLayout", setLayout, "append layout");
268
+ const layoutPayload = await buildAppendLayoutPayload({
269
+ gridUid: plan.gridUid,
270
+ appendedItemUids: state.blocks.map((block) => block.result.uid)
271
+ });
272
+ return setLayout({
273
+ target: {
274
+ uid: plan.gridUid
275
+ },
276
+ ...layoutPayload
277
+ });
278
+ }
279
+ function requireBlockState(blockKey, state) {
280
+ const matched = state.blocks.find((block) => block.spec.key === blockKey);
281
+ if (!matched) {
282
+ (0, import_errors.throwConflict)(
283
+ `flowSurfaces compose block '${blockKey}' is missing from runtime state`,
284
+ "FLOW_SURFACE_COMPOSE_BLOCK_MISSING"
285
+ );
286
+ }
287
+ return matched;
288
+ }
289
+ function buildFieldResultSummary(spec, createdField) {
290
+ return {
291
+ key: spec.key,
292
+ uid: createdField.uid,
293
+ ...spec.type ? { type: spec.type } : {},
294
+ ...spec.renderer ? { renderer: spec.renderer } : {},
295
+ fieldPath: spec.fieldPath,
296
+ associationPathName: spec.associationPathName,
297
+ wrapperUid: createdField.wrapperUid,
298
+ fieldUid: createdField.fieldUid,
299
+ innerFieldUid: createdField.innerFieldUid,
300
+ popupPageUid: createdField.popupPageUid,
301
+ popupTabUid: createdField.popupTabUid,
302
+ popupGridUid: createdField.popupGridUid,
303
+ ...spec.target ? { target: spec.target } : {}
304
+ };
305
+ }
306
+ function buildActionResultSummary(spec, createdAction, actionKeys) {
307
+ return {
308
+ key: spec.key,
309
+ type: spec.type,
310
+ scope: createdAction.scope,
311
+ uid: createdAction.uid,
312
+ parentUid: createdAction.parentUid,
313
+ ...actionKeys
314
+ };
315
+ }
316
+ function hasInlineSettings(value) {
317
+ return !!value && Object.keys(value).length > 0;
318
+ }
319
+ function hasPopupAfterEffect(value) {
320
+ return typeof value !== "undefined";
321
+ }
322
+ function readComposeFieldTargetKey(target) {
323
+ if (typeof target === "string") {
324
+ const normalized2 = target.trim();
325
+ return normalized2 || void 0;
326
+ }
327
+ if (!target || typeof target !== "object") {
328
+ return void 0;
329
+ }
330
+ const key = typeof target.composeKey === "string" ? target.composeKey : target.key;
331
+ const normalized = typeof key === "string" ? key.trim() : "";
332
+ return normalized || void 0;
333
+ }
334
+ // Annotate the CommonJS export names for ESM import in node:
335
+ 0 && (module.exports = {
336
+ createComposeRuntimeState,
337
+ executeComposeRuntime
338
+ });
@@ -151,7 +151,10 @@ const FORM_COMMON_OPTIONS = {
151
151
  labelAlign: stringOption("Label alignment", { example: "left" }),
152
152
  labelWidth: stringOption("Label width", { example: "120px" }),
153
153
  labelWrap: booleanOption("Whether labels should wrap", { example: false }),
154
- assignRules: objectOption("Assignment rules", { example: {} }),
154
+ assignRules: objectOption(
155
+ "Raw assignment-rules payload. For AI/CLI authoring, prefer `getReactionMeta` + `setFieldValueRules` or blueprint `reaction.items[]` instead of guessing this configure key directly.",
156
+ { example: {} }
157
+ ),
155
158
  colon: booleanOption("Whether to display a colon after the label", { example: true })
156
159
  };
157
160
  const EDIT_FORM_OPTIONS = {
@@ -168,7 +171,10 @@ const DETAILS_OPTIONS = {
168
171
  colon: booleanOption("Whether to display a colon after the label", { example: true }),
169
172
  sorting: SORTING,
170
173
  dataScope: FILTER_GROUP,
171
- linkageRules: arrayOption("Linkage rules", { example: [] })
174
+ linkageRules: arrayOption(
175
+ "Raw linkage-rules payload. For AI/CLI authoring, prefer `getReactionMeta` + `setFieldLinkageRules` instead of guessing this configure key directly.",
176
+ { example: [] }
177
+ )
172
178
  };
173
179
  const FILTER_FORM_OPTIONS = {
174
180
  ...COMMON_BLOCK_TITLE_OPTIONS,
@@ -437,7 +443,10 @@ const ACTION_ASSIGN_OPTIONS = {
437
443
  updateMode: stringOption("Update mode", { example: "overwrite" })
438
444
  };
439
445
  const ACTION_LINKAGE_OPTIONS = {
440
- linkageRules: arrayOption("Linkage rules", { example: [] })
446
+ linkageRules: arrayOption(
447
+ "Raw linkage-rules payload. For AI/CLI authoring, prefer `getReactionMeta` + `setActionLinkageRules` instead of guessing this configure key directly.",
448
+ { example: [] }
449
+ )
441
450
  };
442
451
  const ACTION_JS_OPTIONS = {
443
452
  code: JS_CODE,
@@ -6,8 +6,9 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export declare const FLOW_SURFACES_ACTION_NAMES: readonly ["catalog", "context", "get", "compose", "configure", "createMenu", "updateMenu", "createPage", "destroyPage", "addTab", "updateTab", "moveTab", "removeTab", "addPopupTab", "updatePopupTab", "movePopupTab", "removePopupTab", "addBlock", "addBlocks", "addField", "addFields", "addAction", "addActions", "addRecordAction", "addRecordActions", "updateSettings", "setEventFlows", "setLayout", "moveNode", "removeNode", "mutate", "apply"];
9
+ export { FLOW_SURFACE_PLAN_STEP_ACTIONS } from './planning/action-specs';
10
+ export declare const FLOW_SURFACES_ACTION_NAMES: readonly ["catalog", "context", "get", "describeSurface", "getReactionMeta", "setFieldValueRules", "setBlockLinkageRules", "setFieldLinkageRules", "setActionLinkageRules", "applyBlueprint", "listTemplates", "getTemplate", "saveTemplate", "updateTemplate", "destroyTemplate", "convertTemplateToCopy", "compose", "configure", "createMenu", "updateMenu", "createPage", "destroyPage", "addTab", "updateTab", "moveTab", "removeTab", "addPopupTab", "updatePopupTab", "movePopupTab", "removePopupTab", "addBlock", "addBlocks", "addField", "addFields", "addAction", "addActions", "addRecordAction", "addRecordActions", "updateSettings", "setEventFlows", "setLayout", "moveNode", "removeNode", "mutate", "apply"];
10
11
  export type FlowSurfacesActionName = (typeof FLOW_SURFACES_ACTION_NAMES)[number];
11
- export declare const FLOW_SURFACES_READ_ACTION_NAMES: readonly ["catalog", "context", "get"];
12
+ export declare const FLOW_SURFACES_READ_ACTION_NAMES: readonly ["catalog", "context", "get", "describeSurface", "getReactionMeta", "listTemplates", "getTemplate"];
12
13
  export declare const FLOW_SURFACE_MUTATE_OP_TYPES: readonly ["createMenu", "updateMenu", "createPage", "destroyPage", "addTab", "updateTab", "moveTab", "removeTab", "addPopupTab", "updatePopupTab", "movePopupTab", "removePopupTab", "addBlock", "addField", "addAction", "addRecordAction", "updateSettings", "setEventFlows", "setLayout", "moveNode", "removeNode"];
13
14
  export declare const FLOW_SURFACES_ACTION_METHODS: Record<FlowSurfacesActionName, 'get' | 'post'>;