@nocobase/plugin-flow-engine 2.1.0-alpha.40 → 2.1.0-alpha.46

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 (105) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +9 -9
  3. package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
  4. package/dist/node_modules/acorn/package.json +1 -1
  5. package/dist/node_modules/acorn-jsx/package.json +1 -1
  6. package/dist/node_modules/acorn-walk/package.json +1 -1
  7. package/dist/node_modules/ses/package.json +1 -1
  8. package/dist/node_modules/zod/package.json +1 -1
  9. package/dist/server/flow-surfaces/apply/compiler.js +28 -14
  10. package/dist/server/flow-surfaces/apply/matching.js +2 -0
  11. package/dist/server/flow-surfaces/authoring-validation.d.ts +1 -0
  12. package/dist/server/flow-surfaces/authoring-validation.js +1453 -151
  13. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +21 -3
  14. package/dist/server/flow-surfaces/blueprint/compile-plan.js +9 -9
  15. package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -1
  16. package/dist/server/flow-surfaces/catalog.js +26 -9
  17. package/dist/server/flow-surfaces/chart-config.js +231 -14
  18. package/dist/server/flow-surfaces/compose-compiler.d.ts +2 -0
  19. package/dist/server/flow-surfaces/compose-compiler.js +2 -0
  20. package/dist/server/flow-surfaces/compose-runtime.js +4 -7
  21. package/dist/server/flow-surfaces/configure-options.js +19 -8
  22. package/dist/server/flow-surfaces/contract-guard.js +40 -6
  23. package/dist/server/flow-surfaces/default-block-actions.js +2 -0
  24. package/dist/server/flow-surfaces/errors.d.ts +15 -0
  25. package/dist/server/flow-surfaces/errors.js +49 -3
  26. package/dist/server/flow-surfaces/event-flow-normalizer.d.ts +19 -0
  27. package/dist/server/flow-surfaces/event-flow-normalizer.js +128 -0
  28. package/dist/server/flow-surfaces/filter-group.d.ts +9 -1
  29. package/dist/server/flow-surfaces/filter-group.js +402 -3
  30. package/dist/server/flow-surfaces/locator.js +16 -2
  31. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
  32. package/dist/server/flow-surfaces/route-sync.js +19 -2
  33. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
  34. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
  35. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
  36. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
  37. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
  38. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
  39. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
  40. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
  41. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
  42. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
  43. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
  44. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
  45. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
  46. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
  47. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
  48. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
  49. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
  50. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
  51. package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
  52. package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
  53. package/dist/server/flow-surfaces/runjs-authoring/ctx-libs-member-mismatch-stop/index.js +1 -1
  54. package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
  55. package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -7033
  56. package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
  57. package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
  58. package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
  59. package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
  60. package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
  61. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
  62. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
  63. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
  64. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
  65. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
  66. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
  67. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
  68. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
  69. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
  70. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
  71. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
  72. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
  73. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
  74. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
  75. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
  76. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
  77. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
  78. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
  79. package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
  80. package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
  81. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
  82. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
  83. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
  84. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
  85. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  86. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
  87. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
  88. package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
  89. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
  90. package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
  91. package/dist/server/flow-surfaces/service-helpers.js +105 -0
  92. package/dist/server/flow-surfaces/service-utils.d.ts +17 -3
  93. package/dist/server/flow-surfaces/service-utils.js +14 -5
  94. package/dist/server/flow-surfaces/service.d.ts +74 -15
  95. package/dist/server/flow-surfaces/service.js +1781 -193
  96. package/dist/server/flow-surfaces/template-service-utils.d.ts +1 -0
  97. package/dist/server/flow-surfaces/types.d.ts +3 -0
  98. package/dist/server/repository.d.ts +12 -1
  99. package/dist/server/repository.js +195 -23
  100. package/dist/swagger/flow-surfaces.d.ts +180 -2
  101. package/dist/swagger/flow-surfaces.examples.d.ts +11 -37
  102. package/dist/swagger/flow-surfaces.examples.js +6 -6
  103. package/dist/swagger/flow-surfaces.js +136 -54
  104. package/dist/swagger/index.d.ts +180 -2
  105. 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,
@@ -588,12 +588,16 @@ function prepareFlowSurfaceApplyBlueprintDocument(input) {
588
588
  if (tabs.length > 1 && (page == null ? void 0 : page.enableTabs) === false) {
589
589
  (0, import_errors.throwBadRequest)(`flowSurfaces applyBlueprint page.enableTabs cannot be false when tabs.length > 1`);
590
590
  }
591
+ const normalizedPage = tabs.length === 1 ? {
592
+ ...page || {},
593
+ enableTabs: false
594
+ } : page;
591
595
  return {
592
596
  version: "1",
593
597
  mode,
594
598
  ...target ? { target } : {},
595
599
  ...navigation ? { navigation } : {},
596
- ...page ? { page } : {},
600
+ ...normalizedPage ? { page: normalizedPage } : {},
597
601
  ...defaults ? { defaults } : {},
598
602
  tabs,
599
603
  assets,
@@ -119,6 +119,10 @@ const FILTER_GROUP_SCHEMA = {
119
119
  additionalProperties: false,
120
120
  "x-flowSurfaceFormat": "filter-group"
121
121
  };
122
+ const LINKAGE_RULES_SCHEMA = {
123
+ type: "array",
124
+ "x-flowSurfaceFormat": "linkage-rules"
125
+ };
122
126
  const DEFAULT_DIRECT_EVENTS = ["beforeRender"];
123
127
  const ACTION_DIRECT_EVENTS = ["click", "beforeRender"];
124
128
  const ACTION_OBJECT_EVENTS = ["click"];
@@ -207,7 +211,7 @@ const ACTION_BUTTON_SETTINGS_GROUP = {
207
211
  "general.type": STRING_SCHEMA,
208
212
  "general.danger": BOOLEAN_SCHEMA,
209
213
  "general.color": STRING_SCHEMA,
210
- "linkageRules.value": ARRAY_SCHEMA
214
+ "linkageRules.value": LINKAGE_RULES_SCHEMA
211
215
  }
212
216
  };
213
217
  const TRIGGER_WORKFLOWS_SETTINGS_GROUP = {
@@ -302,7 +306,7 @@ const EVENT_SETTINGS_GROUP = {
302
306
  allowedPaths: ["linkageRules.value"],
303
307
  eventBindingSteps: ["linkageRules"],
304
308
  pathSchemas: {
305
- "linkageRules.value": ARRAY_SCHEMA
309
+ "linkageRules.value": LINKAGE_RULES_SCHEMA
306
310
  }
307
311
  };
308
312
  const CREATE_FORM_SETTINGS_EVENT_ONLY_GROUP = {
@@ -323,7 +327,7 @@ const DETAILS_SETTINGS_GROUP = {
323
327
  ...FORM_LAYOUT_PATH_SCHEMAS,
324
328
  "dataScope.filter": FILTER_GROUP_SCHEMA,
325
329
  "defaultSorting.sort": ARRAY_SCHEMA,
326
- "linkageRules.value": ARRAY_SCHEMA
330
+ "linkageRules.value": LINKAGE_RULES_SCHEMA
327
331
  }
328
332
  };
329
333
  const FILTER_FORM_BLOCK_SETTINGS_GROUP = {
@@ -350,7 +354,7 @@ const BLOCK_CARD_SETTINGS_GROUP = {
350
354
  "titleDescription.description": STRING_SCHEMA,
351
355
  "blockHeight.heightMode": BLOCK_HEIGHT_MODE_SCHEMA,
352
356
  "blockHeight.height": NUMBER_SCHEMA,
353
- "linkageRules.value": ARRAY_SCHEMA
357
+ "linkageRules.value": LINKAGE_RULES_SCHEMA
354
358
  }
355
359
  };
356
360
  const CALENDAR_SETTINGS_GROUP = {
@@ -484,6 +488,7 @@ const KANBAN_SETTINGS_GROUP = {
484
488
  const TABLE_SETTINGS_GROUP = {
485
489
  allowedPaths: [
486
490
  "quickEdit.editable",
491
+ "enableRowSelection.enableRowSelection",
487
492
  "showRowNumbers.showIndex",
488
493
  "pageSize.pageSize",
489
494
  "dataScope.filter",
@@ -496,6 +501,7 @@ const TABLE_SETTINGS_GROUP = {
496
501
  ],
497
502
  eventBindingSteps: [
498
503
  "quickEdit",
504
+ "enableRowSelection",
499
505
  "showRowNumbers",
500
506
  "pageSize",
501
507
  "dataScope",
@@ -508,6 +514,7 @@ const TABLE_SETTINGS_GROUP = {
508
514
  ],
509
515
  pathSchemas: {
510
516
  "quickEdit.editable": BOOLEAN_SCHEMA,
517
+ "enableRowSelection.enableRowSelection": BOOLEAN_SCHEMA,
511
518
  "showRowNumbers.showIndex": BOOLEAN_SCHEMA,
512
519
  "pageSize.pageSize": NUMBER_SCHEMA,
513
520
  "dataScope.filter": FILTER_GROUP_SCHEMA,
@@ -2188,7 +2195,7 @@ CALENDAR_READONLY_ACTION_CONTRACT.domains.stepParams = groupedDomain({
2188
2195
  mergeStrategy: "deep",
2189
2196
  eventBindingSteps: ["linkageRules"],
2190
2197
  pathSchemas: {
2191
- "linkageRules.value": ARRAY_SCHEMA
2198
+ "linkageRules.value": LINKAGE_RULES_SCHEMA
2192
2199
  }
2193
2200
  }
2194
2201
  });
@@ -2441,16 +2448,26 @@ JS_ITEM_ACTION_CONTRACT.domains.stepParams = groupedDomain({
2441
2448
  jsSettings: RUN_JS_SETTINGS_GROUP
2442
2449
  });
2443
2450
  const AI_EMPLOYEE_ACTION_CONTRACT = createContract({
2444
- editableDomains: ["props"],
2445
- props: ["aiEmployee", "context", "auto", "tasks", "style"]
2451
+ editableDomains: ["props", "stepParams"],
2452
+ props: ["aiEmployee", "context", "auto", "style"],
2453
+ stepParams: ["shortcutSettings"]
2446
2454
  });
2447
- AI_EMPLOYEE_ACTION_CONTRACT.domains.props = keyedDomain(["aiEmployee", "context", "auto", "tasks", "style"], "deep", {
2455
+ AI_EMPLOYEE_ACTION_CONTRACT.domains.props = keyedDomain(["aiEmployee", "context", "auto", "style"], "deep", {
2448
2456
  aiEmployee: OBJECT_SCHEMA,
2449
2457
  context: OBJECT_SCHEMA,
2450
2458
  auto: BOOLEAN_SCHEMA,
2451
- tasks: ARRAY_SCHEMA,
2452
2459
  style: OBJECT_SCHEMA
2453
2460
  });
2461
+ AI_EMPLOYEE_ACTION_CONTRACT.domains.stepParams = groupedDomain({
2462
+ shortcutSettings: {
2463
+ allowedPaths: ["editTasks.tasks"],
2464
+ mergeStrategy: "deep",
2465
+ eventBindingSteps: ["editTasks"],
2466
+ pathSchemas: {
2467
+ "editTasks.tasks": ARRAY_SCHEMA
2468
+ }
2469
+ }
2470
+ });
2454
2471
  const APPROVAL_FORM_BLOCK_CONTRACT = createContract({
2455
2472
  editableDomains: ["props", "decoratorProps", "stepParams", "flowRegistry"],
2456
2473
  props: ["labelWidth", "labelWrap"],
@@ -64,6 +64,94 @@ __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
+ var import_filter_group = require("./filter-group");
68
+ 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.";
69
+ const CHART_FORBIDDEN_FALLBACKS = [
70
+ "table",
71
+ "list",
72
+ "jsBlock",
73
+ "actionPanel",
74
+ "gridCard",
75
+ "markdown",
76
+ "drop chart",
77
+ "defer chart"
78
+ ];
79
+ const CHART_REPAIR_STEPS = [
80
+ "Keep the block type as chart.",
81
+ "Repair the chart query and visual mappings on the current chart payload.",
82
+ "Retry the chart payload instead of replacing the chart with another block type, omitting it, or deferring it."
83
+ ];
84
+ const CHART_EXPECTED_SHAPE = {
85
+ settings: {
86
+ query: {
87
+ mode: "builder",
88
+ resource: {
89
+ dataSourceKey: "main",
90
+ collectionName: "employees"
91
+ },
92
+ measures: [
93
+ {
94
+ field: "id",
95
+ aggregation: "count",
96
+ alias: "employeeCount"
97
+ }
98
+ ]
99
+ },
100
+ visual: {
101
+ mode: "basic",
102
+ type: "bar",
103
+ mappings: {
104
+ x: "status",
105
+ y: "employeeCount"
106
+ }
107
+ }
108
+ }
109
+ };
110
+ function withChartRepairDetails(details = {}) {
111
+ return {
112
+ ...details,
113
+ requiredBlockType: "chart",
114
+ fixStrategy: "repair_same_block_type",
115
+ repairHint: CHART_REPAIR_HINT,
116
+ repairSteps: CHART_REPAIR_STEPS,
117
+ expectedShape: CHART_EXPECTED_SHAPE,
118
+ repairExample: {
119
+ settings: {
120
+ query: {
121
+ mode: "builder",
122
+ resource: {
123
+ dataSourceKey: "main",
124
+ collectionName: "<collectionName>"
125
+ },
126
+ measures: [
127
+ {
128
+ field: "id",
129
+ aggregation: "count",
130
+ alias: "recordCount"
131
+ }
132
+ ],
133
+ dimensions: [
134
+ {
135
+ field: "<dimensionField>"
136
+ }
137
+ ]
138
+ },
139
+ visual: {
140
+ mode: "basic",
141
+ type: "bar",
142
+ mappings: {
143
+ x: "<dimensionField>",
144
+ y: "recordCount"
145
+ }
146
+ }
147
+ }
148
+ },
149
+ forbiddenFallbacks: CHART_FORBIDDEN_FALLBACKS
150
+ };
151
+ }
152
+ function withChartRepairMessage(message) {
153
+ return `${message}. ${CHART_REPAIR_HINT}`;
154
+ }
67
155
  const CHART_DEFAULT_DATA_SOURCE_KEY = "main";
68
156
  const CHART_QUERY_MODES = ["builder", "sql"];
69
157
  const CHART_VISUAL_MODES = ["basic", "custom"];
@@ -82,10 +170,6 @@ const CHART_SORT_DIRECTIONS = ["asc", "desc"];
82
170
  const CHART_SORT_NULLS = ["default", "first", "last"];
83
171
  const CHART_LABEL_TYPES = ["value", "percent"];
84
172
  const CHART_FUNNEL_SORTS = ["descending", "ascending"];
85
- const EMPTY_FILTER_GROUP = {
86
- logic: "$and",
87
- items: []
88
- };
89
173
  const CHART_SAFE_DEFAULT_HINTS = [
90
174
  {
91
175
  key: "builder_basic_minimal",
@@ -371,6 +455,17 @@ function normalizeFieldPathValue(input, label, options = {}) {
371
455
  }
372
456
  throw new import_errors.FlowSurfaceBadRequestError(`${label} must be a string or string[]`);
373
457
  }
458
+ function normalizeChartQueryFieldPathValue(input, label, options = {}) {
459
+ const normalized = normalizeFieldPathValue(input, label, options);
460
+ if (typeof normalized !== "string" || !normalized.includes(".")) {
461
+ return normalized;
462
+ }
463
+ const segments = normalized.split(".").map((segment) => segment.trim());
464
+ if (segments.some((segment) => !segment)) {
465
+ throw new import_errors.FlowSurfaceBadRequestError(`${label} cannot contain empty path segments`);
466
+ }
467
+ return segments;
468
+ }
374
469
  function aliasOfFieldValue(input) {
375
470
  if (Array.isArray(input)) {
376
471
  return input.filter(Boolean).map((item) => String(item)).join(".");
@@ -402,7 +497,7 @@ function fromPersistedOrder(input) {
402
497
  return CHART_SORT_DIRECTION_SET.has(normalized) ? normalized : void 0;
403
498
  }
404
499
  function createEmptyFilterGroup() {
405
- return import_lodash.default.cloneDeep(EMPTY_FILTER_GROUP);
500
+ return import_lodash.default.cloneDeep(import_filter_group.FLOW_SURFACE_EMPTY_FILTER_GROUP);
406
501
  }
407
502
  function assertAllowedKeys(input, allowed, label) {
408
503
  const unknownKeys = Object.keys(input).filter((key) => !allowed.has(key));
@@ -478,25 +573,29 @@ function normalizeMergedChartResource(query, options = {}) {
478
573
  function normalizeChartMeasure(input, index) {
479
574
  const label = `chart query.measures[${index}]`;
480
575
  const normalized = ensurePlainObject(input, label);
576
+ const field = normalizeChartQueryFieldPathValue(normalized.field, `${label}.field`, { required: true });
577
+ const alias = normalizeOptionalTrimmedString(normalized.alias, `${label}.alias`);
481
578
  const aggregation = normalizeOptionalEnumValue(
482
579
  normalized.aggregation,
483
580
  CHART_QUERY_AGGREGATION_SET,
484
581
  `${label}.aggregation`
485
582
  );
486
583
  return buildDefinedObject({
487
- field: normalizeFieldPathValue(normalized.field, `${label}.field`, { required: true }),
584
+ field,
488
585
  aggregation,
489
- alias: normalizeOptionalTrimmedString(normalized.alias, `${label}.alias`),
586
+ alias: alias || (Array.isArray(field) && field.length > 1 ? aliasOfFieldValue(field) : void 0),
490
587
  distinct: normalizeOptionalBoolean(normalized.distinct, `${label}.distinct`)
491
588
  });
492
589
  }
493
590
  function normalizeChartDimension(input, index) {
494
591
  const label = `chart query.dimensions[${index}]`;
495
592
  const normalized = ensurePlainObject(input, label);
593
+ const field = normalizeChartQueryFieldPathValue(normalized.field, `${label}.field`, { required: true });
594
+ const alias = normalizeOptionalTrimmedString(normalized.alias, `${label}.alias`);
496
595
  return buildDefinedObject({
497
- field: normalizeFieldPathValue(normalized.field, `${label}.field`, { required: true }),
596
+ field,
498
597
  format: normalizeOptionalTrimmedString(normalized.format, `${label}.format`),
499
- alias: normalizeOptionalTrimmedString(normalized.alias, `${label}.alias`)
598
+ alias: alias || (Array.isArray(field) && field.length > 1 ? aliasOfFieldValue(field) : void 0)
500
599
  });
501
600
  }
502
601
  function normalizeBuilderCountMeasureFieldForRuntime(measure, dimensions) {
@@ -507,6 +606,12 @@ function normalizeBuilderCountMeasureFieldForRuntime(measure, dimensions) {
507
606
  if (!fallbackDimension) {
508
607
  return measure;
509
608
  }
609
+ if (Array.isArray(fallbackDimension.field) && fallbackDimension.field.length > 1) {
610
+ return measure;
611
+ }
612
+ if (typeof fallbackDimension.field === "string" && fallbackDimension.field.includes(".")) {
613
+ return measure;
614
+ }
510
615
  return {
511
616
  ...measure,
512
617
  field: import_lodash.default.cloneDeep(fallbackDimension.field)
@@ -521,18 +626,113 @@ function normalizeChartSortingItem(input, index) {
521
626
  `${label}.${hasOwn(normalized, "direction") ? "direction" : "order"}`
522
627
  );
523
628
  return buildDefinedObject({
524
- field: normalizeFieldPathValue(normalized.field, `${label}.field`, { required: true }),
629
+ field: normalizeChartQueryFieldPathValue(normalized.field, `${label}.field`, { required: true }),
525
630
  order: toPersistedOrder(direction),
526
631
  nulls: normalizeOptionalEnumValue(normalized.nulls, CHART_SORT_NULLS_SET, `${label}.nulls`)
527
632
  });
528
633
  }
634
+ function isFilterGroupLike(input) {
635
+ return import_lodash.default.isPlainObject(input) && isBackendQueryLogicKey(input.logic) && Array.isArray(input.items);
636
+ }
637
+ function assertFilterGroupKeys(input, label) {
638
+ if (!isFilterGroupLike(input)) {
639
+ return;
640
+ }
641
+ const unsupportedKeys = Object.keys(input).filter((key) => key !== "logic" && key !== "items");
642
+ if (unsupportedKeys.length) {
643
+ throw new import_errors.FlowSurfaceBadRequestError(`${label} does not support: ${unsupportedKeys.join(", ")}`);
644
+ }
645
+ if (Array.isArray(input.items)) {
646
+ input.items.forEach((item, index) => {
647
+ assertFilterGroupKeys(item, `${label}.items[${index}]`);
648
+ });
649
+ }
650
+ }
651
+ function isBackendQueryLogicKey(key) {
652
+ return key === "$and" || key === "$or";
653
+ }
654
+ function getBackendQueryLogicKey(input, label) {
655
+ const keys = Object.keys(input);
656
+ const logicKeys = keys.filter(isBackendQueryLogicKey);
657
+ if (!logicKeys.length) {
658
+ return void 0;
659
+ }
660
+ if (logicKeys.length > 1 || keys.length > 1) {
661
+ throw new import_errors.FlowSurfaceBadRequestError(
662
+ `${label}: cannot convert backend query filter with mixed logical and field conditions`
663
+ );
664
+ }
665
+ return logicKeys[0];
666
+ }
667
+ function convertBackendFieldConditionToFilterItems(field, condition, label) {
668
+ if (!field.trim() || field.startsWith("$")) {
669
+ throw new import_errors.FlowSurfaceBadRequestError(`${label}: cannot convert backend query filter field "${field}"`);
670
+ }
671
+ if (!import_lodash.default.isPlainObject(condition)) {
672
+ throw new import_errors.FlowSurfaceBadRequestError(`${label}.${field}: backend query filter condition must be an object`);
673
+ }
674
+ const operators = Object.keys(condition);
675
+ if (!operators.length) {
676
+ throw new import_errors.FlowSurfaceBadRequestError(`${label}.${field}: backend query filter condition cannot be empty`);
677
+ }
678
+ return operators.map((operator) => {
679
+ if (!operator.startsWith("$")) {
680
+ (0, import_filter_group.assertFlowSurfaceFilterOperator)(operator, `${label}.${field}.${operator}`);
681
+ }
682
+ if (!operator.startsWith("$") || isBackendQueryLogicKey(operator)) {
683
+ throw new import_errors.FlowSurfaceBadRequestError(
684
+ `${label}.${field}: cannot convert backend query filter operator "${operator}"`
685
+ );
686
+ }
687
+ return {
688
+ path: field,
689
+ operator,
690
+ value: import_lodash.default.cloneDeep(condition[operator])
691
+ };
692
+ });
693
+ }
694
+ function convertBackendQueryFilterToFilterGroup(input, label) {
695
+ const logicKey = getBackendQueryLogicKey(input, label);
696
+ if (logicKey) {
697
+ const operands = input[logicKey];
698
+ if (!Array.isArray(operands)) {
699
+ throw new import_errors.FlowSurfaceBadRequestError(`${label}.${logicKey}: backend query filter operands must be an array`);
700
+ }
701
+ return {
702
+ logic: logicKey,
703
+ items: operands.map(
704
+ (operand, index) => convertBackendQueryOperandToFilterItem(operand, `${label}.${logicKey}[${index}]`)
705
+ )
706
+ };
707
+ }
708
+ return {
709
+ logic: "$and",
710
+ items: Object.entries(input).flatMap(
711
+ ([field, condition]) => convertBackendFieldConditionToFilterItems(field, condition, label)
712
+ )
713
+ };
714
+ }
715
+ function convertBackendQueryOperandToFilterItem(input, label) {
716
+ if (isFilterGroupLike(input)) {
717
+ throw new import_errors.FlowSurfaceBadRequestError(`${label}: cannot mix filter groups with backend query filters`);
718
+ }
719
+ const group = convertBackendQueryFilterToFilterGroup(ensurePlainObject(input, label), label);
720
+ if (group.logic === "$and" && group.items.length === 1) {
721
+ return group.items[0];
722
+ }
723
+ return group;
724
+ }
529
725
  function normalizeFilterGroupValue(input, label) {
530
726
  if (import_lodash.default.isUndefined(input) || import_lodash.default.isNull(input)) {
531
727
  return void 0;
532
728
  }
533
729
  const normalized = ensurePlainObject(input, label);
534
- validateFilterGroupPaths(normalized, label);
535
- return import_lodash.default.cloneDeep(normalized);
730
+ assertFilterGroupKeys(normalized, label);
731
+ const filterGroup = !Object.keys(normalized).length || isFilterGroupLike(normalized) ? (0, import_filter_group.normalizeFlowSurfaceFilterGroupValue)(normalized, label, { strictDateValues: true }) : (0, import_filter_group.normalizeFlowSurfaceFilterGroupValue)(convertBackendQueryFilterToFilterGroup(normalized, label), label, {
732
+ strictDateValues: true
733
+ });
734
+ validateFilterGroupPaths(filterGroup, label);
735
+ return filterGroup;
536
736
  }
537
737
  function validateFilterGroupPaths(input, label) {
538
738
  const items = Array.isArray(input == null ? void 0 : input.items) ? input.items : [];
@@ -564,6 +764,7 @@ function inferQueryMode(query) {
564
764
  }
565
765
  function validateLooseChartQuery(query) {
566
766
  inferQueryMode(query);
767
+ validateChartQueryFilterOperators(query);
567
768
  if (!hasOwn(query, "resource") || !hasOwn(query, "collectionPath")) {
568
769
  return;
569
770
  }
@@ -578,6 +779,11 @@ function validateLooseChartQuery(query) {
578
779
  );
579
780
  }
580
781
  }
782
+ function validateChartQueryFilterOperators(query) {
783
+ if (hasOwn(query, "filter")) {
784
+ normalizeFilterGroupValue(query.filter, "chart query.filter");
785
+ }
786
+ }
581
787
  function canStrictNormalizeChartQuery(query) {
582
788
  validateLooseChartQuery(query);
583
789
  const mode = inferQueryMode(query);
@@ -601,7 +807,10 @@ function mergeChartQuerySection(current, patch) {
601
807
  const nextMode = inferQueryMode(normalizedPatch);
602
808
  const modeChanged = currentMode && currentMode !== nextMode;
603
809
  const base = modeChanged ? {} : current || {};
604
- const merged = mergeReplaceArrays(base, normalizedPatch);
810
+ const merged = mergeReplaceArrays(base, import_lodash.default.omit(normalizedPatch, ["filter"]));
811
+ if (hasOwn(normalizedPatch, "filter")) {
812
+ merged.filter = import_lodash.default.cloneDeep(normalizedPatch.filter);
813
+ }
605
814
  if (nextMode !== "builder") {
606
815
  return merged;
607
816
  }
@@ -1083,7 +1292,15 @@ function assertBasicVisualMappingsAgainstBuilderQuery(builderVisual, query) {
1083
1292
  for (const value of mappingValues) {
1084
1293
  if (!value || !allowedOutputs.has(value)) {
1085
1294
  throw new import_errors.FlowSurfaceBadRequestError(
1086
- `chart visual mappings only support query output fields: ${Array.from(allowedOutputs).join(", ")}`
1295
+ withChartRepairMessage(
1296
+ `chart visual mappings only support query output fields: ${Array.from(allowedOutputs).join(", ")}`
1297
+ ),
1298
+ void 0,
1299
+ {
1300
+ details: withChartRepairDetails({
1301
+ allowedOutputs: Array.from(allowedOutputs)
1302
+ })
1303
+ }
1087
1304
  );
1088
1305
  }
1089
1306
  }
@@ -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,20 +640,23 @@ 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
- skillSettings: { skills: [], tools: [] },
659
+ skillSettings: null,
649
660
  model: null,
650
661
  webSearch: false
651
662
  }