@nocobase/plugin-flow-engine 2.1.0-alpha.20 → 2.1.0-alpha.22

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 (50) hide show
  1. package/dist/externalVersion.js +11 -10
  2. package/dist/node_modules/ses/dist/ses.cjs +1 -1
  3. package/dist/node_modules/ses/package.json +1 -1
  4. package/dist/node_modules/zod/index.cjs +1 -1
  5. package/dist/node_modules/zod/package.json +1 -1
  6. package/dist/server/flow-surfaces/action-scope.d.ts +1 -0
  7. package/dist/server/flow-surfaces/action-scope.js +4 -0
  8. package/dist/server/flow-surfaces/apply/compiler.js +1 -1
  9. package/dist/server/flow-surfaces/approval/builder.js +8 -8
  10. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +192 -29
  11. package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
  12. package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
  13. package/dist/server/flow-surfaces/blueprint/index.d.ts +1 -1
  14. package/dist/server/flow-surfaces/blueprint/normalize-document.js +121 -1
  15. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +32 -0
  16. package/dist/server/flow-surfaces/builder.d.ts +2 -2
  17. package/dist/server/flow-surfaces/builder.js +148 -50
  18. package/dist/server/flow-surfaces/catalog.js +276 -34
  19. package/dist/server/flow-surfaces/compose-compiler.d.ts +2 -0
  20. package/dist/server/flow-surfaces/compose-compiler.js +5 -1
  21. package/dist/server/flow-surfaces/configure-options.js +88 -12
  22. package/dist/server/flow-surfaces/contract-guard.js +60 -69
  23. package/dist/server/flow-surfaces/default-action-popup.d.ts +11 -1
  24. package/dist/server/flow-surfaces/default-action-popup.js +72 -12
  25. package/dist/server/flow-surfaces/default-block-actions.js +8 -1
  26. package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
  27. package/dist/server/flow-surfaces/filter-group.js +94 -0
  28. package/dist/server/flow-surfaces/index.js +70 -2
  29. package/dist/server/flow-surfaces/node-use-sets.js +6 -1
  30. package/dist/server/flow-surfaces/placement.js +3 -0
  31. package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +20 -0
  32. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +111 -0
  33. package/dist/server/flow-surfaces/reaction/registry.d.ts +7 -0
  34. package/dist/server/flow-surfaces/reaction/registry.js +7 -0
  35. package/dist/server/flow-surfaces/service-utils.d.ts +7 -0
  36. package/dist/server/flow-surfaces/service-utils.js +58 -9
  37. package/dist/server/flow-surfaces/service.d.ts +73 -3
  38. package/dist/server/flow-surfaces/service.js +1794 -162
  39. package/dist/server/flow-surfaces/support-matrix.d.ts +5 -2
  40. package/dist/server/flow-surfaces/support-matrix.js +16 -3
  41. package/dist/server/flow-surfaces/surface-context.js +2 -1
  42. package/dist/server/flow-surfaces/template-display.d.ts +20 -0
  43. package/dist/server/flow-surfaces/template-display.js +289 -0
  44. package/dist/server/flow-surfaces/types.d.ts +1 -0
  45. package/dist/swagger/flow-surfaces.d.ts +160 -0
  46. package/dist/swagger/flow-surfaces.examples.d.ts +117 -11
  47. package/dist/swagger/flow-surfaces.examples.js +152 -1
  48. package/dist/swagger/flow-surfaces.js +141 -21
  49. package/dist/swagger/index.d.ts +160 -0
  50. package/package.json +2 -2
@@ -1 +1 @@
1
- {"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-04-20T10:43:11.885Z"}
1
+ {"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-04-24T10:04:46.979Z"}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { FlowSurfaceActionScope } from './types';
10
10
  export declare const TABLE_BLOCK_ACTION_CONTAINER_USES: string[];
11
+ export declare const CALENDAR_BLOCK_ACTION_CONTAINER_USES: string[];
11
12
  export declare const TABLE_ROW_ACTION_CONTAINER_USES: string[];
12
13
  export declare const LIST_BLOCK_ACTION_CONTAINER_USES: string[];
13
14
  export declare const LIST_RECORD_ACTION_CONTAINER_USES: string[];
@@ -28,6 +28,7 @@ var action_scope_exports = {};
28
28
  __export(action_scope_exports, {
29
29
  ACTION_CONTAINER_SCOPE_BY_USE: () => ACTION_CONTAINER_SCOPE_BY_USE,
30
30
  ACTION_PANEL_ACTION_CONTAINER_USES: () => ACTION_PANEL_ACTION_CONTAINER_USES,
31
+ CALENDAR_BLOCK_ACTION_CONTAINER_USES: () => CALENDAR_BLOCK_ACTION_CONTAINER_USES,
31
32
  COLLECTION_BLOCK_ACTION_CONTAINER_USES: () => COLLECTION_BLOCK_ACTION_CONTAINER_USES,
32
33
  DETAILS_ACTION_CONTAINER_USES: () => DETAILS_ACTION_CONTAINER_USES,
33
34
  FILTER_FORM_ACTION_CONTAINER_USES: () => FILTER_FORM_ACTION_CONTAINER_USES,
@@ -48,6 +49,7 @@ var import_approval = require("./approval");
48
49
  var import_errors = require("./errors");
49
50
  const ACTION_SCOPE_SET = /* @__PURE__ */ new Set(["block", "record", "form", "filterForm", "actionPanel"]);
50
51
  const TABLE_BLOCK_ACTION_CONTAINER_USES = ["TableBlockModel"];
52
+ const CALENDAR_BLOCK_ACTION_CONTAINER_USES = ["CalendarBlockModel"];
51
53
  const TABLE_ROW_ACTION_CONTAINER_USES = ["TableActionsColumnModel"];
52
54
  const LIST_BLOCK_ACTION_CONTAINER_USES = ["ListBlockModel", "GridCardBlockModel"];
53
55
  const LIST_RECORD_ACTION_CONTAINER_USES = ["ListItemModel", "GridCardItemModel"];
@@ -57,6 +59,7 @@ const FILTER_FORM_ACTION_CONTAINER_USES = ["FilterFormBlockModel"];
57
59
  const ACTION_PANEL_ACTION_CONTAINER_USES = ["ActionPanelBlockModel"];
58
60
  const COLLECTION_BLOCK_ACTION_CONTAINER_USES = [
59
61
  ...TABLE_BLOCK_ACTION_CONTAINER_USES,
62
+ ...CALENDAR_BLOCK_ACTION_CONTAINER_USES,
60
63
  ...LIST_BLOCK_ACTION_CONTAINER_USES
61
64
  ];
62
65
  const RECORD_ACTION_CONTAINER_USES = [
@@ -131,6 +134,7 @@ function assertRequestedActionScope(input) {
131
134
  0 && (module.exports = {
132
135
  ACTION_CONTAINER_SCOPE_BY_USE,
133
136
  ACTION_PANEL_ACTION_CONTAINER_USES,
137
+ CALENDAR_BLOCK_ACTION_CONTAINER_USES,
134
138
  COLLECTION_BLOCK_ACTION_CONTAINER_USES,
135
139
  DETAILS_ACTION_CONTAINER_USES,
136
140
  FILTER_FORM_ACTION_CONTAINER_USES,
@@ -582,7 +582,7 @@ function createActionNode(ops, state, parentRef, desiredNode, currentParent) {
582
582
  function createFieldNode(ops, state, parentRef, desiredNode) {
583
583
  var _a;
584
584
  const popup = normalizeApplyPopup(desiredNode, `flowSurfaces apply field '${desiredNode.use}'`);
585
- const standaloneType = desiredNode.use === "JSColumnModel" ? "jsColumn" : desiredNode.use === "JSItemModel" ? "jsItem" : void 0;
585
+ const standaloneType = desiredNode.use === "JSColumnModel" ? "jsColumn" : desiredNode.use === "JSItemModel" ? "jsItem" : desiredNode.use === "DividerItemModel" ? "divider" : void 0;
586
586
  if (standaloneType) {
587
587
  if (popup) {
588
588
  throw new import_errors.FlowSurfaceBadRequestError(
@@ -148,7 +148,7 @@ function buildApprovalActionDefaults(use) {
148
148
  case "ApplyFormSubmitModel":
149
149
  return {
150
150
  props: {
151
- title: "Submit",
151
+ title: '{{t("Submit")}}',
152
152
  type: "primary",
153
153
  htmlType: "submit"
154
154
  }
@@ -156,7 +156,7 @@ function buildApprovalActionDefaults(use) {
156
156
  case "ApplyFormSaveDraftModel":
157
157
  return {
158
158
  props: {
159
- title: "Save draft",
159
+ title: '{{t("Save draft", { ns: "@nocobase/plugin-workflow-approval" })}}',
160
160
  type: "default",
161
161
  htmlType: "submit"
162
162
  }
@@ -164,7 +164,7 @@ function buildApprovalActionDefaults(use) {
164
164
  case "ApplyFormWithdrawModel":
165
165
  return {
166
166
  props: {
167
- title: "Withdraw",
167
+ title: '{{t("Withdraw", { ns: "@nocobase/plugin-workflow-approval" })}}',
168
168
  type: "default",
169
169
  htmlType: "submit"
170
170
  }
@@ -172,14 +172,14 @@ function buildApprovalActionDefaults(use) {
172
172
  case "ProcessFormApproveModel":
173
173
  return {
174
174
  props: {
175
- title: "Approve",
175
+ title: '{{t("Approve", { ns: "@nocobase/plugin-workflow-approval" })}}',
176
176
  type: "primary"
177
177
  }
178
178
  };
179
179
  case "ProcessFormRejectModel":
180
180
  return {
181
181
  props: {
182
- title: "Reject",
182
+ title: '{{t("Reject", { ns: "@nocobase/plugin-workflow-approval" })}}',
183
183
  type: "default",
184
184
  danger: true
185
185
  }
@@ -187,21 +187,21 @@ function buildApprovalActionDefaults(use) {
187
187
  case "ProcessFormReturnModel":
188
188
  return {
189
189
  props: {
190
- title: "Return",
190
+ title: '{{t("Return", { ns: "@nocobase/plugin-workflow-approval" })}}',
191
191
  type: "default"
192
192
  }
193
193
  };
194
194
  case "ProcessFormDelegateModel":
195
195
  return {
196
196
  props: {
197
- title: "Delegate",
197
+ title: '{{t("Delegate", { ns: "@nocobase/plugin-workflow-approval" })}}',
198
198
  type: "default"
199
199
  }
200
200
  };
201
201
  case "ProcessFormAddAssigneeModel":
202
202
  return {
203
203
  props: {
204
- title: "Add assignee",
204
+ title: '{{t("Add assignee", { ns: "@nocobase/plugin-workflow-approval" })}}',
205
205
  type: "default"
206
206
  }
207
207
  };
@@ -44,9 +44,12 @@ var import_lodash = __toESM(require("lodash"));
44
44
  var import_errors = require("../errors");
45
45
  var import_service_utils = require("../service-utils");
46
46
  var import_default_block_actions = require("../default-block-actions");
47
+ var import_public_data_surface_default_filter = require("../public-data-surface-default-filter");
48
+ var import_defaults = require("./defaults");
47
49
  var import_private_utils = require("./private-utils");
48
50
  const APPLY_BLUEPRINT_BLOCK_TYPE_ENUM = [
49
51
  "table",
52
+ "calendar",
50
53
  "createForm",
51
54
  "editForm",
52
55
  "details",
@@ -72,7 +75,9 @@ const APPLY_BLUEPRINT_BLOCK_ALLOWED_KEYS = [
72
75
  "template",
73
76
  "settings",
74
77
  "fields",
78
+ "fieldGroups",
75
79
  "fieldsLayout",
80
+ "defaultFilter",
76
81
  "actions",
77
82
  "recordActions",
78
83
  "script",
@@ -91,6 +96,7 @@ const APPLY_BLUEPRINT_FIELD_ALLOWED_KEYS = [
91
96
  "script",
92
97
  "chart"
93
98
  ];
99
+ const APPLY_BLUEPRINT_FIELD_GROUP_ALLOWED_KEYS = ["key", "title", "fields"];
94
100
  const APPLY_BLUEPRINT_ACTION_ALLOWED_KEYS = ["key", "type", "title", "settings", "popup", "script", "chart"];
95
101
  const APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS = [
96
102
  "title",
@@ -130,6 +136,7 @@ const APPLY_BLUEPRINT_BLOCK_RESOURCE_SHORTHAND_KEYS = [
130
136
  ];
131
137
  const APPLY_BLUEPRINT_RECORD_CAPABLE_BLOCK_TYPES = /* @__PURE__ */ new Set(["table", "details", "list", "gridCard"]);
132
138
  const APPLY_BLUEPRINT_FIELD_GRID_BLOCK_TYPES = /* @__PURE__ */ new Set(["createForm", "editForm", "details", "filterForm"]);
139
+ const APPLY_BLUEPRINT_FIELD_GROUP_BLOCK_TYPES = /* @__PURE__ */ new Set(["createForm", "editForm", "details"]);
133
140
  const APPLY_BLUEPRINT_AUTO_PROMOTED_RECORD_ACTION_TYPES = /* @__PURE__ */ new Set([
134
141
  "view",
135
142
  "edit",
@@ -137,6 +144,7 @@ const APPLY_BLUEPRINT_AUTO_PROMOTED_RECORD_ACTION_TYPES = /* @__PURE__ */ new Se
137
144
  "updateRecord",
138
145
  "duplicate"
139
146
  ]);
147
+ const APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_TYPES = /* @__PURE__ */ new Set(["addNew", "view", "edit"]);
140
148
  const APPLY_BLUEPRINT_BLOCK_TYPES = new Set(APPLY_BLUEPRINT_BLOCK_TYPE_ENUM);
141
149
  const APPLY_BLUEPRINT_ADD_CHILD_RECORD_ACTION_ERROR = "type 'addChild' must be authored under recordActions and is only valid when the live target catalog.recordActions exposes it for a tree collection table with treeTable enabled";
142
150
  function assertNoBlockLevelLayout(input, context) {
@@ -153,6 +161,26 @@ function assertApplyBlueprintFieldsLayoutHost(block, context) {
153
161
  }
154
162
  (0, import_errors.throwBadRequest)(`${context}.fieldsLayout is only supported on createForm, editForm, details or filterForm`);
155
163
  }
164
+ function assertApplyBlueprintCalendarMainContent(block, context) {
165
+ if ((0, import_private_utils.readOptionalString)(block.type) !== "calendar") {
166
+ return;
167
+ }
168
+ if (Object.prototype.hasOwnProperty.call(block, "fields")) {
169
+ (0, import_errors.throwBadRequest)(
170
+ `${context}.fields is not supported on calendar main blocks; add event fields under the quick-create or event-view popup host instead`
171
+ );
172
+ }
173
+ if (Object.prototype.hasOwnProperty.call(block, "fieldGroups")) {
174
+ (0, import_errors.throwBadRequest)(
175
+ `${context}.fieldGroups is not supported on calendar main blocks; add grouped fields under the quick-create or event-view popup host instead`
176
+ );
177
+ }
178
+ if (Object.prototype.hasOwnProperty.call(block, "recordActions")) {
179
+ (0, import_errors.throwBadRequest)(
180
+ `${context}.recordActions is not supported on calendar main blocks; configure event actions inside the event-view popup host instead`
181
+ );
182
+ }
183
+ }
156
184
  function assertApplyBlueprintBlockType(type, context) {
157
185
  if (!type) {
158
186
  return;
@@ -508,6 +536,107 @@ function compileScopedLayout(layout, keysByLocalKey, context, kind) {
508
536
  })
509
537
  };
510
538
  }
539
+ function buildCompactFieldLayoutRow(keys, blockType) {
540
+ const normalizedKeys = keys.filter(Boolean);
541
+ if (!normalizedKeys.length) {
542
+ return [];
543
+ }
544
+ if (blockType === "filterForm") {
545
+ const span = normalizedKeys.length === 1 ? 24 : normalizedKeys.length === 2 ? 12 : 8;
546
+ return normalizedKeys.map((key) => ({ key, span }));
547
+ }
548
+ if (normalizedKeys.length === 1) {
549
+ return [{ key: normalizedKeys[0], span: 24 }];
550
+ }
551
+ return normalizedKeys.map((key) => ({ key, span: 12 }));
552
+ }
553
+ function buildAutoCompiledFieldsLayout(fields, blockType) {
554
+ if (!APPLY_BLUEPRINT_FIELD_GRID_BLOCK_TYPES.has(blockType || "") || !fields.length) {
555
+ return void 0;
556
+ }
557
+ const rows = [];
558
+ const chunkSize = blockType === "filterForm" ? 3 : 2;
559
+ let pendingKeys = [];
560
+ const flushPending = () => {
561
+ if (!pendingKeys.length) {
562
+ return;
563
+ }
564
+ rows.push(buildCompactFieldLayoutRow(pendingKeys, blockType));
565
+ pendingKeys = [];
566
+ };
567
+ fields.forEach((field) => {
568
+ const key = (0, import_private_utils.readOptionalString)(field == null ? void 0 : field.key);
569
+ if (!key) {
570
+ return;
571
+ }
572
+ if ((0, import_private_utils.readOptionalString)(field == null ? void 0 : field.type) === "divider") {
573
+ flushPending();
574
+ rows.push([{ key, span: 24 }]);
575
+ return;
576
+ }
577
+ pendingKeys.push(key);
578
+ if (pendingKeys.length >= chunkSize) {
579
+ flushPending();
580
+ }
581
+ });
582
+ flushPending();
583
+ return rows.length ? { rows } : void 0;
584
+ }
585
+ function compileFieldGroups(fieldGroups, context) {
586
+ const expanded = [];
587
+ fieldGroups.forEach((group, groupIndex) => {
588
+ const groupContext = `${context}[${groupIndex}]`;
589
+ if (!import_lodash.default.isPlainObject(group)) {
590
+ (0, import_errors.throwBadRequest)(`${groupContext} must be an object`);
591
+ }
592
+ (0, import_private_utils.assertOnlyAllowedKeys)(group, groupContext, APPLY_BLUEPRINT_FIELD_GROUP_ALLOWED_KEYS);
593
+ const title = (0, import_private_utils.assertNonEmptyString)(group.title, `${groupContext}.title`);
594
+ const groupFields = readOptionalItems(group.fields, `${groupContext}.fields`);
595
+ if (!groupFields.length) {
596
+ (0, import_errors.throwBadRequest)(`${groupContext}.fields must be a non-empty array`);
597
+ }
598
+ const groupLocalKey = (0, import_private_utils.normalizeBlueprintLocalKey)(
599
+ group.key,
600
+ title || `group_${groupIndex + 1}`,
601
+ `${groupContext}.key`
602
+ );
603
+ expanded.push({
604
+ key: `${groupLocalKey}_divider`,
605
+ type: "divider",
606
+ settings: {
607
+ label: title,
608
+ orientation: "left"
609
+ }
610
+ });
611
+ expanded.push(...groupFields);
612
+ });
613
+ return expanded;
614
+ }
615
+ function resolveBlockFieldInputs(block, context) {
616
+ const hasFields = Object.prototype.hasOwnProperty.call(block, "fields");
617
+ const hasFieldGroups = Object.prototype.hasOwnProperty.call(block, "fieldGroups");
618
+ if (hasFields && hasFieldGroups) {
619
+ (0, import_errors.throwBadRequest)(`${context} cannot mix fields with fieldGroups`);
620
+ }
621
+ if (!hasFieldGroups) {
622
+ return readOptionalItems(block.fields, `${context}.fields`);
623
+ }
624
+ const blockType = (0, import_private_utils.readOptionalString)(block.type);
625
+ if (!APPLY_BLUEPRINT_FIELD_GROUP_BLOCK_TYPES.has(blockType || "")) {
626
+ (0, import_errors.throwBadRequest)(`${context}.fieldGroups is only supported on createForm, editForm or details`);
627
+ }
628
+ if (Object.prototype.hasOwnProperty.call(block, "fieldsLayout")) {
629
+ (0, import_errors.throwBadRequest)(`${context}.fieldsLayout cannot be combined with ${context}.fieldGroups`);
630
+ }
631
+ const fieldGroups = (0, import_private_utils.readOptionalArray)(
632
+ block.fieldGroups,
633
+ `${context}.fieldGroups`
634
+ );
635
+ if (!(fieldGroups == null ? void 0 : fieldGroups.length)) {
636
+ (0, import_errors.throwBadRequest)(`${context}.fieldGroups must be a non-empty array`);
637
+ }
638
+ return compileFieldGroups(fieldGroups, `${context}.fieldGroups`);
639
+ }
511
640
  function resolveApplyBlueprintFieldLocalKey(input, index, context) {
512
641
  if (typeof input === "string") {
513
642
  return (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
@@ -545,7 +674,13 @@ function buildCompiledFieldKeyMap(inputs, compiledFields, context) {
545
674
  });
546
675
  return fieldKeysByLocalKey;
547
676
  }
548
- function compilePopup(popup, scopePrefix, assets, context, options = {}) {
677
+ function shouldAttachDefaultPopupMetadata(popup, itemType, options = {}) {
678
+ return !import_lodash.default.isUndefined(popup) || options.autoRelationField || APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_TYPES.has(itemType || "");
679
+ }
680
+ function attachCompiledPopupDefaults(popup, metadata) {
681
+ return (0, import_defaults.attachFlowSurfaceApplyBlueprintPopupDefaults)(popup, metadata);
682
+ }
683
+ function compilePopup(popup, scopePrefix, assets, context, defaults, options = {}) {
549
684
  if (import_lodash.default.isUndefined(popup)) {
550
685
  return {};
551
686
  }
@@ -569,9 +704,6 @@ function compilePopup(popup, scopePrefix, assets, context, options = {}) {
569
704
  if (saveAsTemplate && template) {
570
705
  (0, import_errors.throwBadRequest)(`${context}.saveAsTemplate cannot be combined with ${context}.template`);
571
706
  }
572
- if (saveAsTemplate && !import_lodash.default.isUndefined(tryTemplate)) {
573
- (0, import_errors.throwBadRequest)(`${context}.saveAsTemplate cannot be combined with ${context}.tryTemplate`);
574
- }
575
707
  if (template) {
576
708
  return {
577
709
  popup: {
@@ -582,7 +714,7 @@ function compilePopup(popup, scopePrefix, assets, context, options = {}) {
582
714
  }
583
715
  const rawPopupBlocks = readOptionalItems(popup.blocks, `${context}.blocks`);
584
716
  const popupBlocks = options.ownerActionType === "edit" && rawPopupBlocks.length ? normalizeEditPopupBlocks(rawPopupBlocks, context) : rawPopupBlocks;
585
- if (saveAsTemplate && !popupBlocks.length) {
717
+ if (saveAsTemplate && !popupBlocks.length && tryTemplate !== true) {
586
718
  (0, import_errors.throwBadRequest)(`${context}.saveAsTemplate requires explicit popup.blocks`);
587
719
  }
588
720
  const compiledBlocks = popupBlocks.length ? compileBlocks(
@@ -590,6 +722,7 @@ function compilePopup(popup, scopePrefix, assets, context, options = {}) {
590
722
  scopePrefix,
591
723
  assets,
592
724
  `${context}.blocks`,
725
+ defaults,
593
726
  collectReferencedBlockKeys(popup.layout, `${context}.layout`)
594
727
  ) : { blocks: [], blockKeysByLocalKey: /* @__PURE__ */ new Map() };
595
728
  const layout = popupBlocks.length || popup.layout ? compileLayout(
@@ -625,13 +758,14 @@ function resolveTargetBlockKey(value, localBlockKeys, context) {
625
758
  }
626
759
  (0, import_errors.throwBadRequest)(`${context} must be a string block key`);
627
760
  }
628
- function compileField(input, index, scopePrefix, assets, localBlockKeys, context) {
761
+ function compileField(input, index, scopePrefix, assets, localBlockKeys, context, popupDefaultsMetadata, defaults) {
629
762
  if (typeof input === "string") {
630
763
  const fieldPath2 = (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
631
764
  return {
632
765
  key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, fieldPath2), `${context}[${index}]`),
633
766
  fieldPath: fieldPath2,
634
- __autoPopupForRelationField: true
767
+ __autoPopupForRelationField: true,
768
+ ...popupDefaultsMetadata ? { [import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]: import_lodash.default.cloneDeep(popupDefaultsMetadata) } : {}
635
769
  };
636
770
  }
637
771
  if (!import_lodash.default.isPlainObject(input)) {
@@ -656,8 +790,9 @@ function compileField(input, index, scopePrefix, assets, localBlockKeys, context
656
790
  if ((0, import_private_utils.readOptionalString)(input.label) && import_lodash.default.isUndefined(settings.label)) {
657
791
  settings.label = (0, import_private_utils.readOptionalString)(input.label);
658
792
  }
659
- const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`);
793
+ const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`, defaults);
660
794
  settings = resolvePopupTitleSettings(settings, popupResult.popupTitle);
795
+ const popup = shouldAttachDefaultPopupMetadata(input.popup, void 0) ? attachCompiledPopupDefaults(popupResult.popup, popupDefaultsMetadata) : popupResult.popup;
661
796
  return (0, import_service_utils.buildDefinedPayload)({
662
797
  key,
663
798
  fieldPath,
@@ -666,15 +801,16 @@ function compileField(input, index, scopePrefix, assets, localBlockKeys, context
666
801
  type: syntheticType,
667
802
  target: resolveTargetBlockKey(input.target, localBlockKeys, `${context}[${index}].target`),
668
803
  settings: Object.keys(settings).length ? settings : void 0,
669
- popup: popupResult.popup
804
+ popup
670
805
  });
671
806
  }
672
- function compileAction(input, index, scopePrefix, assets, context) {
807
+ function compileAction(input, index, scopePrefix, assets, context, popupDefaultsMetadata, defaults) {
673
808
  if (typeof input === "string") {
674
809
  const type2 = (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
675
810
  return {
676
811
  key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, `${type2}_${index + 1}`), `${context}[${index}]`),
677
- type: type2
812
+ type: type2,
813
+ ...APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_TYPES.has(type2) ? { popup: attachCompiledPopupDefaults(void 0, popupDefaultsMetadata) } : {}
678
814
  };
679
815
  }
680
816
  if (!import_lodash.default.isPlainObject(input)) {
@@ -688,36 +824,41 @@ function compileAction(input, index, scopePrefix, assets, context) {
688
824
  if ((0, import_private_utils.readOptionalString)(input.title) && import_lodash.default.isUndefined(settings.title)) {
689
825
  settings.title = (0, import_private_utils.readOptionalString)(input.title);
690
826
  }
691
- const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`, {
827
+ const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`, defaults, {
692
828
  ownerActionType: type
693
829
  });
694
830
  settings = resolvePopupTitleSettings(settings, popupResult.popupTitle);
831
+ const popup = shouldAttachDefaultPopupMetadata(input.popup, type) ? attachCompiledPopupDefaults(popupResult.popup, popupDefaultsMetadata) : popupResult.popup;
695
832
  return (0, import_service_utils.buildDefinedPayload)({
696
833
  key,
697
834
  type,
698
835
  settings: Object.keys(settings).length ? settings : void 0,
699
- popup: popupResult.popup
836
+ popup
700
837
  });
701
838
  }
702
- function compileInjectedDefaultAction(descriptor, scopePrefix, context, index) {
839
+ function compileInjectedDefaultAction(descriptor, scopePrefix, context, index, popupDefaultsMetadata) {
840
+ const descriptorPopup = descriptor.popup ? import_lodash.default.cloneDeep(descriptor.popup) : void 0;
841
+ const popup = shouldAttachDefaultPopupMetadata(descriptorPopup, descriptor.type) ? attachCompiledPopupDefaults(descriptorPopup, popupDefaultsMetadata) : void 0;
703
842
  return (0, import_service_utils.buildDefinedPayload)({
704
843
  key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)(
705
844
  (0, import_private_utils.buildScopedKey)(scopePrefix, `${descriptor.type}_default_${index + 1}`),
706
845
  `${context}[${index}]`
707
846
  ),
708
847
  type: descriptor.type,
709
- popup: descriptor.popup ? import_lodash.default.cloneDeep(descriptor.popup) : void 0
848
+ popup
710
849
  });
711
850
  }
712
- function compileBlocks(input, scopePrefix, assets, context, requiredExplicitBlockKeys = /* @__PURE__ */ new Set()) {
851
+ function compileBlocks(input, scopePrefix, assets, context, defaults, requiredExplicitBlockKeys = /* @__PURE__ */ new Set()) {
713
852
  const blockKeysByLocalKey = /* @__PURE__ */ new Map();
714
853
  const referencedBlockKeys = new Set(requiredExplicitBlockKeys);
715
854
  const rawBlocks = import_lodash.default.castArray(input || []);
855
+ const popupDefaultsMetadata = (0, import_defaults.buildFlowSurfaceApplyBlueprintPopupDefaultsMetadata)(defaults);
716
856
  rawBlocks.forEach((block, index) => {
717
857
  if (!import_lodash.default.isPlainObject(block)) {
718
858
  (0, import_errors.throwBadRequest)(`${context}[${index}] must be an object`);
719
859
  }
720
- const fields = readOptionalItems(block == null ? void 0 : block.fields, `${context}[${index}].fields`);
860
+ assertApplyBlueprintCalendarMainContent(block, `${context}[${index}]`);
861
+ const fields = resolveBlockFieldInputs(block, `${context}[${index}]`);
721
862
  fields.forEach((field, fieldIndex) => {
722
863
  if (typeof (field == null ? void 0 : field.target) !== "string" || !field.target.trim()) {
723
864
  return;
@@ -735,6 +876,7 @@ function compileBlocks(input, scopePrefix, assets, context, requiredExplicitBloc
735
876
  assertApplyBlueprintFieldsLayoutHost(block, `${context}[${index}]`);
736
877
  (0, import_private_utils.assertOnlyAllowedKeys)(block, `${context}[${index}]`, APPLY_BLUEPRINT_BLOCK_ALLOWED_KEYS);
737
878
  assertApplyBlueprintBlockType((0, import_private_utils.readOptionalString)(block.type), `${context}[${index}]`);
879
+ assertApplyBlueprintCalendarMainContent(block, `${context}[${index}]`);
738
880
  const explicitKey = (0, import_private_utils.readString)(block.key);
739
881
  const fallback = block.type ? `${block.type}_${index + 1}` : `block_${index + 1}`;
740
882
  const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(block.key, fallback, `${context}[${index}].key`);
@@ -764,30 +906,45 @@ function compileBlocks(input, scopePrefix, assets, context, requiredExplicitBloc
764
906
  if ((0, import_private_utils.readOptionalString)(block.title) && import_lodash.default.isUndefined(settings.title)) {
765
907
  settings.title = (0, import_private_utils.readOptionalString)(block.title);
766
908
  }
909
+ const blockType = (0, import_private_utils.readOptionalString)(block.type);
767
910
  const template = ensureOptionalTemplate(block.template, `${blockContext}.template`);
768
- const fieldInputs = readOptionalItems(block.fields, `${blockContext}.fields`);
911
+ const blockDefaultFilter = (0, import_public_data_surface_default_filter.normalizeFlowSurfacePublicBlockDefaultFilter)("applyBlueprint", block.defaultFilter, {
912
+ blockType,
913
+ template,
914
+ path: blockContext
915
+ });
916
+ const fieldInputs = resolveBlockFieldInputs(block, blockContext);
769
917
  const fields = fieldInputs.map(
770
- (field, fieldIndex) => compileField(field, fieldIndex, key, assets, blockKeysByLocalKey, `${blockContext}.fields`)
918
+ (field, fieldIndex) => compileField(
919
+ field,
920
+ fieldIndex,
921
+ key,
922
+ assets,
923
+ blockKeysByLocalKey,
924
+ `${blockContext}.fields`,
925
+ popupDefaultsMetadata,
926
+ defaults
927
+ )
771
928
  );
772
929
  const fieldsLayout = Object.prototype.hasOwnProperty.call(block, "fieldsLayout") ? compileScopedLayout(
773
930
  import_lodash.default.isUndefined(block.fieldsLayout) ? void 0 : import_lodash.default.isPlainObject(block.fieldsLayout) ? block.fieldsLayout : (0, import_errors.throwBadRequest)(`${blockContext}.fieldsLayout must be an object`),
774
931
  buildCompiledFieldKeyMap(fieldInputs, fields, `${blockContext}.fields`),
775
932
  `${blockContext}.fieldsLayout`,
776
933
  "field"
777
- ) : void 0;
934
+ ) : buildAutoCompiledFieldsLayout(fields, (0, import_private_utils.readOptionalString)(block.type));
778
935
  const { actions, recordActions } = splitApplyBlueprintBlockActionsByScope(block, blockContext);
779
936
  const explicitActions = actions.map(
780
- (action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.actions`)
937
+ (action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.actions`, popupDefaultsMetadata, defaults)
781
938
  );
782
939
  const explicitRecordActions = recordActions.map(
783
- (action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.recordActions`)
940
+ (action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.recordActions`, popupDefaultsMetadata, defaults)
784
941
  );
785
942
  const injectedActionIndexes = {
786
943
  actions: explicitActions.length,
787
944
  recordActions: explicitRecordActions.length
788
945
  };
789
946
  const mergedActions = (0, import_default_block_actions.mergeFlowSurfaceDefaultBlockActions)({
790
- blockType: (0, import_private_utils.readOptionalString)(block.type),
947
+ blockType,
791
948
  template,
792
949
  actions: explicitActions,
793
950
  recordActions: explicitRecordActions,
@@ -795,19 +952,24 @@ function compileBlocks(input, scopePrefix, assets, context, requiredExplicitBloc
795
952
  descriptor,
796
953
  key,
797
954
  `${blockContext}.${descriptor.scope}`,
798
- injectedActionIndexes[descriptor.scope]++
955
+ injectedActionIndexes[descriptor.scope]++,
956
+ popupDefaultsMetadata
799
957
  )
800
958
  });
959
+ const actionsWithDefaultFilter = (0, import_public_data_surface_default_filter.backfillFlowSurfaceFilterActionDefaultFilter)(
960
+ mergedActions.actions,
961
+ blockDefaultFilter
962
+ );
801
963
  return (0, import_service_utils.buildDefinedPayload)({
802
964
  key,
803
- type: (0, import_private_utils.readOptionalString)(block.type),
965
+ type: blockType,
804
966
  resource: buildBlockResource(block, blockContext),
805
967
  template,
806
968
  settings: Object.keys(settings).length ? settings : void 0,
807
- fields,
808
- fieldsLayout,
809
- actions: mergedActions.actions,
810
- recordActions: mergedActions.recordActions
969
+ fields: blockType === "calendar" ? void 0 : fields,
970
+ fieldsLayout: blockType === "calendar" ? void 0 : fieldsLayout,
971
+ actions: actionsWithDefaultFilter,
972
+ recordActions: blockType === "calendar" ? void 0 : mergedActions.recordActions
811
973
  });
812
974
  });
813
975
  return {
@@ -824,6 +986,7 @@ function compileTabComposeValues(tab, document, tabIndex, options) {
824
986
  tab.key,
825
987
  document.assets,
826
988
  blocksPath,
989
+ document.defaults,
827
990
  collectReferencedBlockKeys(tab.layout, layoutPath)
828
991
  );
829
992
  const layout = compileLayout(
@@ -0,0 +1,26 @@
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 { FlowSurfaceApplyBlueprintDefaultCollection, FlowSurfaceApplyBlueprintDefaults, FlowSurfaceApplyBlueprintDefaultPopupName } from './public-types';
10
+ export declare const FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY = "__flowSurfaceApplyBlueprintPopupDefaults";
11
+ export type FlowSurfaceApplyBlueprintPopupDefaultActionType = 'addNew' | 'view' | 'edit';
12
+ export type FlowSurfaceApplyBlueprintPopupDefaultsMetadata = {
13
+ collections?: FlowSurfaceApplyBlueprintDefaults['collections'];
14
+ };
15
+ export declare function hasFlowSurfaceApplyBlueprintDefaults(defaults?: FlowSurfaceApplyBlueprintDefaults): boolean;
16
+ export declare function buildFlowSurfaceApplyBlueprintPopupDefaultsMetadata(defaults?: FlowSurfaceApplyBlueprintDefaults): FlowSurfaceApplyBlueprintPopupDefaultsMetadata | undefined;
17
+ export declare function attachFlowSurfaceApplyBlueprintPopupDefaults<T extends Record<string, any> | undefined>(popup: T, metadata: FlowSurfaceApplyBlueprintPopupDefaultsMetadata | undefined): T | Record<string, any> | undefined;
18
+ export declare function readFlowSurfaceApplyBlueprintPopupDefaultsMetadata(value: Record<string, any> | undefined): FlowSurfaceApplyBlueprintPopupDefaultsMetadata | undefined;
19
+ export declare function getFlowSurfaceApplyBlueprintDefaultCollection(metadata: FlowSurfaceApplyBlueprintPopupDefaultsMetadata | undefined, collectionName?: string): FlowSurfaceApplyBlueprintDefaultCollection | undefined;
20
+ export declare function resolveFlowSurfaceApplyBlueprintDefaultPopupMetadata(input: {
21
+ metadata?: FlowSurfaceApplyBlueprintPopupDefaultsMetadata;
22
+ actionType?: FlowSurfaceApplyBlueprintPopupDefaultActionType;
23
+ sourceCollectionName?: string;
24
+ associationField?: string;
25
+ targetCollectionName?: string;
26
+ }): FlowSurfaceApplyBlueprintDefaultPopupName | undefined;