@nocobase/plugin-flow-engine 2.1.0-beta.37 → 2.1.0-beta.40

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 (31) hide show
  1. package/dist/externalVersion.js +9 -9
  2. package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
  3. package/dist/node_modules/acorn/package.json +1 -1
  4. package/dist/node_modules/acorn-jsx/package.json +1 -1
  5. package/dist/node_modules/acorn-walk/package.json +1 -1
  6. package/dist/node_modules/ses/package.json +1 -1
  7. package/dist/node_modules/zod/package.json +1 -1
  8. package/dist/server/flow-surfaces/apply/compiler.js +18 -3
  9. package/dist/server/flow-surfaces/apply/matching.js +2 -0
  10. package/dist/server/flow-surfaces/authoring-validation.js +621 -66
  11. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +21 -3
  12. package/dist/server/flow-surfaces/blueprint/compile-plan.js +9 -9
  13. package/dist/server/flow-surfaces/catalog.js +3 -0
  14. package/dist/server/flow-surfaces/chart-config.js +14 -1
  15. package/dist/server/flow-surfaces/compose-compiler.d.ts +2 -0
  16. package/dist/server/flow-surfaces/compose-compiler.js +2 -0
  17. package/dist/server/flow-surfaces/compose-runtime.js +4 -7
  18. package/dist/server/flow-surfaces/configure-options.js +18 -7
  19. package/dist/server/flow-surfaces/locator.js +16 -2
  20. package/dist/server/flow-surfaces/runjs-authoring/index.js +5909 -2214
  21. package/dist/server/flow-surfaces/service-utils.d.ts +2 -0
  22. package/dist/server/flow-surfaces/service-utils.js +8 -0
  23. package/dist/server/flow-surfaces/service.d.ts +22 -0
  24. package/dist/server/flow-surfaces/service.js +722 -59
  25. package/dist/server/flow-surfaces/template-service-utils.d.ts +1 -0
  26. package/dist/swagger/flow-surfaces.d.ts +4 -2
  27. package/dist/swagger/flow-surfaces.examples.d.ts +6 -17
  28. package/dist/swagger/flow-surfaces.examples.js +5 -5
  29. package/dist/swagger/flow-surfaces.js +5 -3
  30. package/dist/swagger/index.d.ts +4 -2
  31. package/package.json +2 -2
@@ -1305,6 +1305,19 @@ function attachDefaultActionPopupMetadata(popup, actionType, metadata) {
1305
1305
  const defaultPopup = actionType === "addChild" && import_lodash.default.isUndefined(popup) ? {} : popup;
1306
1306
  return attachCompiledPopupDefaults(defaultPopup, metadata);
1307
1307
  }
1308
+ function isFieldClickToOpenEnabled(settings) {
1309
+ if (!import_lodash.default.isPlainObject(settings) || !Object.prototype.hasOwnProperty.call(settings, "clickToOpen")) {
1310
+ return false;
1311
+ }
1312
+ const value = settings.clickToOpen;
1313
+ return value === true || import_lodash.default.isPlainObject(value) && value.clickToOpen === true;
1314
+ }
1315
+ function buildGeneratedDefaultFieldPopup() {
1316
+ return {
1317
+ tryTemplate: true,
1318
+ defaultType: "view"
1319
+ };
1320
+ }
1308
1321
  function hasNestedDefaultPopupMetadata(value) {
1309
1322
  if (Array.isArray(value)) {
1310
1323
  return value.some((item) => hasNestedDefaultPopupMetadata(item));
@@ -1640,7 +1653,10 @@ function compileField(input, index, scopePrefix, assets, localBlockKeys, context
1640
1653
  parentContext: parentResourceContext,
1641
1654
  getCollection
1642
1655
  });
1643
- const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`, defaults, {
1656
+ const shouldAutoCompleteClickPopup = import_lodash.default.isUndefined(input.popup) && isFieldClickToOpenEnabled(settings);
1657
+ const popupInput = shouldAutoCompleteClickPopup ? buildGeneratedDefaultFieldPopup() : input.popup;
1658
+ const shouldAutoRelationFieldPopup = import_lodash.default.isUndefined(input.popup) && !!fieldPath && !syntheticType;
1659
+ const popupResult = compilePopup(popupInput, `${key}.popup`, assets, `${context}[${index}].popup`, defaults, {
1644
1660
  getCollection,
1645
1661
  mode: popupOptions.mode,
1646
1662
  popupDepth: popupOptions.popupDepth,
@@ -1652,7 +1668,7 @@ function compileField(input, index, scopePrefix, assets, localBlockKeys, context
1652
1668
  associationName: popupOptions.associationName || (fieldAssociationContext == null ? void 0 : fieldAssociationContext.associationName)
1653
1669
  });
1654
1670
  settings = resolvePopupTitleSettings(settings, popupResult.popupTitle);
1655
- const popup = shouldAttachDefaultPopupMetadata(input.popup, void 0) ? attachCompiledPopupDefaults(popupResult.popup, popupDefaultsMetadata) : popupResult.popup;
1671
+ const popup = shouldAttachDefaultPopupMetadata(popupInput, void 0) ? attachCompiledPopupDefaults(popupResult.popup, popupDefaultsMetadata) : popupResult.popup;
1656
1672
  return (0, import_service_utils.buildDefinedPayload)({
1657
1673
  key,
1658
1674
  fieldPath,
@@ -1668,7 +1684,9 @@ function compileField(input, index, scopePrefix, assets, localBlockKeys, context
1668
1684
  showIndex: input.showIndex,
1669
1685
  target: resolveTargetBlockKey(input.target, localBlockKeys, `${context}[${index}].target`),
1670
1686
  settings: Object.keys(settings).length ? settings : void 0,
1671
- popup
1687
+ popup,
1688
+ __autoPopupForRelationField: shouldAutoRelationFieldPopup ? true : void 0,
1689
+ ...shouldAutoRelationFieldPopup && popupDefaultsMetadata ? { [import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]: import_lodash.default.cloneDeep(popupDefaultsMetadata) } : {}
1672
1690
  });
1673
1691
  }
1674
1692
  function compileAction(input, index, scopePrefix, assets, localBlockKeys, context, popupDefaultsMetadata, defaults, getCollection, options = {}) {
@@ -83,7 +83,7 @@ function buildTabSelectorFromUid(uid) {
83
83
  };
84
84
  }
85
85
  function compileCreatePlan(document, getCollection) {
86
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
86
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
87
87
  const steps = [];
88
88
  const chrome = buildPageChrome(document);
89
89
  if (import_lodash.default.isPlainObject((_a = document.navigation) == null ? void 0 : _a.group) && import_lodash.default.isUndefined(document.navigation.group.routeId)) {
@@ -105,10 +105,10 @@ function compileCreatePlan(document, getCollection) {
105
105
  values: (0, import_service_utils.buildDefinedPayload)({
106
106
  title: ((_k = (_j = document.navigation) == null ? void 0 : _j.item) == null ? void 0 : _k.title) || chrome.pageTitle,
107
107
  type: "item",
108
- icon: (_m = (_l = document.navigation) == null ? void 0 : _l.item) == null ? void 0 : _m.icon,
109
- tooltip: (_o = (_n = document.navigation) == null ? void 0 : _n.item) == null ? void 0 : _o.tooltip,
110
- hideInMenu: (_q = (_p = document.navigation) == null ? void 0 : _p.item) == null ? void 0 : _q.hideInMenu,
111
- parentMenuRouteId: import_lodash.default.isUndefined((_s = (_r = document.navigation) == null ? void 0 : _r.group) == null ? void 0 : _s.routeId) ? ((_u = (_t = document.navigation) == null ? void 0 : _t.group) == null ? void 0 : _u.title) ? { step: CREATE_MENU_GROUP_STEP_ID, path: "routeId" } : void 0 : (_w = (_v = document.navigation) == null ? void 0 : _v.group) == null ? void 0 : _w.routeId
108
+ icon: ((_m = (_l = document.navigation) == null ? void 0 : _l.item) == null ? void 0 : _m.icon) || ((_n = document.page) == null ? void 0 : _n.icon) || "FileOutlined",
109
+ tooltip: (_p = (_o = document.navigation) == null ? void 0 : _o.item) == null ? void 0 : _p.tooltip,
110
+ hideInMenu: (_r = (_q = document.navigation) == null ? void 0 : _q.item) == null ? void 0 : _r.hideInMenu,
111
+ parentMenuRouteId: import_lodash.default.isUndefined((_t = (_s = document.navigation) == null ? void 0 : _s.group) == null ? void 0 : _t.routeId) ? ((_v = (_u = document.navigation) == null ? void 0 : _u.group) == null ? void 0 : _v.title) ? { step: CREATE_MENU_GROUP_STEP_ID, path: "routeId" } : void 0 : (_x = (_w = document.navigation) == null ? void 0 : _w.group) == null ? void 0 : _x.routeId
112
112
  })
113
113
  });
114
114
  steps.push({
@@ -117,11 +117,11 @@ function compileCreatePlan(document, getCollection) {
117
117
  values: (0, import_service_utils.buildDefinedPayload)({
118
118
  menuRouteId: { step: CREATE_MENU_ITEM_STEP_ID, path: "routeId" },
119
119
  title: chrome.pageTitle,
120
- icon: (_x = document.page) == null ? void 0 : _x.icon,
121
- documentTitle: (_y = document.page) == null ? void 0 : _y.documentTitle,
122
- enableHeader: (_z = document.page) == null ? void 0 : _z.enableHeader,
120
+ icon: (_y = document.page) == null ? void 0 : _y.icon,
121
+ documentTitle: (_z = document.page) == null ? void 0 : _z.documentTitle,
122
+ enableHeader: (_A = document.page) == null ? void 0 : _A.enableHeader,
123
123
  enableTabs: chrome.enableTabs,
124
- displayTitle: (_A = document.page) == null ? void 0 : _A.displayTitle,
124
+ displayTitle: (_B = document.page) == null ? void 0 : _B.displayTitle,
125
125
  tabTitle: chrome.tabTitle,
126
126
  tabIcon: chrome.tabIcon,
127
127
  tabDocumentTitle: chrome.tabDocumentTitle,
@@ -484,6 +484,7 @@ const KANBAN_SETTINGS_GROUP = {
484
484
  const TABLE_SETTINGS_GROUP = {
485
485
  allowedPaths: [
486
486
  "quickEdit.editable",
487
+ "enableRowSelection.enableRowSelection",
487
488
  "showRowNumbers.showIndex",
488
489
  "pageSize.pageSize",
489
490
  "dataScope.filter",
@@ -496,6 +497,7 @@ const TABLE_SETTINGS_GROUP = {
496
497
  ],
497
498
  eventBindingSteps: [
498
499
  "quickEdit",
500
+ "enableRowSelection",
499
501
  "showRowNumbers",
500
502
  "pageSize",
501
503
  "dataScope",
@@ -508,6 +510,7 @@ const TABLE_SETTINGS_GROUP = {
508
510
  ],
509
511
  pathSchemas: {
510
512
  "quickEdit.editable": BOOLEAN_SCHEMA,
513
+ "enableRowSelection.enableRowSelection": BOOLEAN_SCHEMA,
511
514
  "showRowNumbers.showIndex": BOOLEAN_SCHEMA,
512
515
  "pageSize.pageSize": NUMBER_SCHEMA,
513
516
  "dataScope.filter": FILTER_GROUP_SCHEMA,
@@ -64,6 +64,10 @@ __export(chart_config_exports, {
64
64
  module.exports = __toCommonJS(chart_config_exports);
65
65
  var import_lodash = __toESM(require("lodash"));
66
66
  var import_errors = require("./errors");
67
+ const CHART_REPAIR_HINT = "This is a chart payload shape problem. Repair the current chart query/visual mappings and keep the chart block type. Do not change this block type to table, jsBlock, actionPanel, gridCard, or another block type. KPI / summary numbers should use jsBlock; charts are for trends, distributions, rankings, and visual analysis.";
68
+ function withChartRepairMessage(message) {
69
+ return `${message}. ${CHART_REPAIR_HINT}`;
70
+ }
67
71
  const CHART_DEFAULT_DATA_SOURCE_KEY = "main";
68
72
  const CHART_QUERY_MODES = ["builder", "sql"];
69
73
  const CHART_VISUAL_MODES = ["basic", "custom"];
@@ -1083,7 +1087,16 @@ function assertBasicVisualMappingsAgainstBuilderQuery(builderVisual, query) {
1083
1087
  for (const value of mappingValues) {
1084
1088
  if (!value || !allowedOutputs.has(value)) {
1085
1089
  throw new import_errors.FlowSurfaceBadRequestError(
1086
- `chart visual mappings only support query output fields: ${Array.from(allowedOutputs).join(", ")}`
1090
+ withChartRepairMessage(
1091
+ `chart visual mappings only support query output fields: ${Array.from(allowedOutputs).join(", ")}`
1092
+ ),
1093
+ void 0,
1094
+ {
1095
+ details: {
1096
+ repairHint: CHART_REPAIR_HINT,
1097
+ allowedOutputs: Array.from(allowedOutputs)
1098
+ }
1099
+ }
1087
1100
  );
1088
1101
  }
1089
1102
  }
@@ -31,6 +31,8 @@ export type FlowSurfaceComposeNormalizedFieldSpec = {
31
31
  pageSize?: number;
32
32
  showIndex?: boolean;
33
33
  target?: string | Record<string, unknown>;
34
+ defaultTargetUid?: string;
35
+ targetBlockUid?: string;
34
36
  settings?: FlowSurfaceComposeObject;
35
37
  popup?: FlowSurfaceComposeObject;
36
38
  __autoPopupForRelationField?: boolean;
@@ -130,6 +130,8 @@ function buildComposeFieldCreatePayload(fieldSpec) {
130
130
  ...fieldSpec.popupSize ? { popupSize: fieldSpec.popupSize } : {},
131
131
  ...typeof fieldSpec.pageSize !== "undefined" ? { pageSize: fieldSpec.pageSize } : {},
132
132
  ...typeof fieldSpec.showIndex !== "undefined" ? { showIndex: fieldSpec.showIndex } : {},
133
+ ...fieldSpec.defaultTargetUid ? { defaultTargetUid: fieldSpec.defaultTargetUid } : {},
134
+ ...fieldSpec.targetBlockUid ? { targetBlockUid: fieldSpec.targetBlockUid } : {},
133
135
  ...fieldSpec.popup ? { popup: fieldSpec.popup } : {},
134
136
  ...fieldSpec.__autoPopupForRelationField ? { __autoPopupForRelationField: true } : {},
135
137
  ...fieldSpec[import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY] ? {
@@ -150,6 +150,8 @@ async function createFields(plan, deps, state) {
150
150
  for (const fieldTask of plan.fields) {
151
151
  const block = requireBlockState(fieldTask.blockKey, state);
152
152
  const targetUid = fieldTask.containerSource === "item" ? block.result.itemUid || block.result.uid : block.result.uid;
153
+ const targetKey = readComposeFieldTargetKey(fieldTask.spec.target);
154
+ const resolvedTargetUid = targetKey ? (0, import_compose_compiler.resolveComposeTargetKey)(targetKey, state.keyMap, "field") : fieldTask.spec.defaultTargetUid || fieldTask.spec.targetBlockUid;
153
155
  let createdField;
154
156
  try {
155
157
  createdField = await deps.createField(
@@ -158,13 +160,8 @@ async function createFields(plan, deps, state) {
158
160
  uid: targetUid
159
161
  },
160
162
  ...fieldTask.payload,
161
- ...readComposeFieldTargetKey(fieldTask.spec.target) ? {
162
- defaultTargetUid: (0, import_compose_compiler.resolveComposeTargetKey)(
163
- readComposeFieldTargetKey(fieldTask.spec.target),
164
- state.keyMap,
165
- "field"
166
- )
167
- } : {}
163
+ ...resolvedTargetUid ? { defaultTargetUid: resolvedTargetUid } : {},
164
+ ...fieldTask.spec.targetBlockUid ? { targetBlockUid: fieldTask.spec.targetBlockUid } : {}
168
165
  },
169
166
  fieldTask.spec,
170
167
  block.result
@@ -163,6 +163,7 @@ const TABLE_OPTIONS = {
163
163
  resource: COMMON_RESOURCE,
164
164
  pageSize: numberOption("Page size", { example: 20 }),
165
165
  density: stringOption("Table density", { enum: ["large", "middle", "small"], example: "middle" }),
166
+ enableRowSelection: booleanOption("Whether to enable row selection checkboxes", { example: true }),
166
167
  showRowNumbers: booleanOption("Whether to display row numbers", { example: true }),
167
168
  sorting: SORTING,
168
169
  dataScope: FILTER_GROUP,
@@ -518,8 +519,15 @@ const FIELD_NODE_OPTIONS = {
518
519
  displayStyle: DISPLAY_STYLE,
519
520
  options: objectOption("Component options")
520
521
  };
522
+ function omitConfigureOptions(options, keys) {
523
+ const next = { ...options };
524
+ for (const key of keys) {
525
+ delete next[key];
526
+ }
527
+ return next;
528
+ }
521
529
  const JS_FIELD_NODE_OPTIONS = {
522
- ...FIELD_NODE_OPTIONS,
530
+ ...omitConfigureOptions(FIELD_NODE_OPTIONS, ["openView"]),
523
531
  code: JS_CODE,
524
532
  version: JS_VERSION
525
533
  };
@@ -632,17 +640,20 @@ const ACTION_EMAIL_OPTIONS = {
632
640
  const ACTION_AI_EMPLOYEE_OPTIONS = {
633
641
  username: stringOption("AI employee username", { example: "dex" }),
634
642
  auto: booleanOption("Whether the single configured task is prepared automatically", { example: false }),
635
- workContext: arrayOption("Top-level AI work context. Use target=self or a same-blueprint block key before write.", {
636
- example: [{ type: "flow-model", target: "self" }]
637
- }),
638
- tasks: arrayOption("AI employee task definitions", {
643
+ workContext: arrayOption(
644
+ "Top-level AI work context. Use target=self or a same-blueprint block key before write; type defaults to flow-model.",
645
+ {
646
+ example: [{ target: "self" }]
647
+ }
648
+ ),
649
+ tasks: arrayOption("AI employee task definitions. prompt is accepted as an alias for message.user.", {
639
650
  example: [
640
651
  {
641
652
  title: "Analyze current record",
653
+ prompt: "Analyze the current record and suggest next steps.",
642
654
  message: {
643
655
  system: "Use the current UI context.",
644
- user: "Analyze the current record and suggest next steps.",
645
- workContext: [{ type: "flow-model", target: "self" }]
656
+ workContext: [{ target: "self" }]
646
657
  },
647
658
  autoSend: false,
648
659
  skillSettings: null,
@@ -49,7 +49,7 @@ class SurfaceLocator {
49
49
  this.repository = repository;
50
50
  }
51
51
  async resolve(target, options = {}) {
52
- var _a;
52
+ var _a, _b;
53
53
  const transaction = options.transaction;
54
54
  if (target.uid) {
55
55
  return this.resolveByUid(target.uid, target, transaction);
@@ -68,7 +68,21 @@ class SurfaceLocator {
68
68
  if (isPageRoute(route)) {
69
69
  return this.resolvePageSchemaUid(route.get("schemaUid"), target, transaction);
70
70
  }
71
- if ((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "schemaUid")) {
71
+ if (((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "type")) === "group") {
72
+ throw new import_errors.FlowSurfaceBadRequestError(
73
+ `flowSurfaces routeId '${target.routeId}' points to a menu group, not a page surface. Menu group routeIds can be used directly as navigation.group.routeId; do not use flowSurfaces:get to check whether a menu group exists.`,
74
+ void 0,
75
+ {
76
+ ruleId: "route-id-points-to-menu-group",
77
+ details: {
78
+ routeId: String(target.routeId),
79
+ title: route.get("title") ?? null,
80
+ type: "group"
81
+ }
82
+ }
83
+ );
84
+ }
85
+ if ((_b = route == null ? void 0 : route.get) == null ? void 0 : _b.call(route, "schemaUid")) {
72
86
  return this.resolveByUid(route.get("schemaUid"), target, transaction);
73
87
  }
74
88
  }