@nocobase/plugin-flow-engine 2.2.0-beta.1 → 2.2.0-beta.10

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 (70) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +9 -9
  3. package/dist/locale/en-US.json +1 -0
  4. package/dist/locale/index.d.ts +2 -0
  5. package/dist/locale/zh-CN.json +1 -0
  6. package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
  7. package/dist/node_modules/acorn/package.json +1 -1
  8. package/dist/node_modules/acorn-jsx/package.json +1 -1
  9. package/dist/node_modules/acorn-walk/package.json +1 -1
  10. package/dist/node_modules/ses/package.json +1 -1
  11. package/dist/node_modules/zod/package.json +1 -1
  12. package/dist/server/flow-surfaces/{runjs-authoring/blocked-global-stop/index.d.ts → approval/authoring-validation.d.ts} +1 -2
  13. package/dist/server/flow-surfaces/approval/authoring-validation.js +1151 -0
  14. package/dist/server/flow-surfaces/approval/blueprint-service.js +2 -0
  15. package/dist/server/flow-surfaces/authoring-validation.d.ts +2 -1
  16. package/dist/server/flow-surfaces/authoring-validation.js +495 -57
  17. package/dist/server/flow-surfaces/blueprint/compile-plan.js +19 -15
  18. package/dist/server/flow-surfaces/blueprint/export-document.d.ts +50 -0
  19. package/dist/server/flow-surfaces/blueprint/export-document.js +2510 -0
  20. package/dist/server/flow-surfaces/blueprint/normalize-document.js +2 -1
  21. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +1 -0
  22. package/dist/server/flow-surfaces/builder.js +40 -5
  23. package/dist/server/flow-surfaces/catalog.js +13 -2
  24. package/dist/server/flow-surfaces/configure-options.js +5 -3
  25. package/dist/server/flow-surfaces/constants.d.ts +9 -2
  26. package/dist/server/flow-surfaces/constants.js +1 -0
  27. package/dist/server/flow-surfaces/contract-guard.js +24 -2
  28. package/dist/server/flow-surfaces/default-action-popup.d.ts +2 -0
  29. package/dist/server/flow-surfaces/default-action-popup.js +27 -13
  30. package/dist/server/flow-surfaces/filter-group.d.ts +19 -2
  31. package/dist/server/flow-surfaces/filter-group.js +232 -3
  32. package/dist/server/flow-surfaces/planning/compiler.d.ts +1 -0
  33. package/dist/server/flow-surfaces/planning/compiler.js +205 -82
  34. package/dist/server/flow-surfaces/planning/key-registry.d.ts +1 -1
  35. package/dist/server/flow-surfaces/planning/runtime.js +1 -0
  36. package/dist/server/flow-surfaces/planning/step-link.d.ts +1 -1
  37. package/dist/server/flow-surfaces/planning/step-link.js +22 -3
  38. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +0 -9
  39. package/dist/server/flow-surfaces/reaction/field-value.d.ts +9 -0
  40. package/dist/server/flow-surfaces/reaction/field-value.js +51 -2
  41. package/dist/server/flow-surfaces/reaction/linkage.d.ts +6 -1
  42. package/dist/server/flow-surfaces/reaction/linkage.js +18 -3
  43. package/dist/server/flow-surfaces/reaction/meta.js +19 -1
  44. package/dist/server/flow-surfaces/reaction/types.d.ts +19 -0
  45. package/dist/server/flow-surfaces/relation-backing-foreign-key.d.ts +10 -0
  46. package/dist/server/flow-surfaces/relation-backing-foreign-key.js +79 -0
  47. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +1 -0
  48. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +20 -0
  49. package/dist/server/flow-surfaces/runjs-authoring/rules.js +0 -2
  50. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +0 -1
  51. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +11 -19
  52. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +0 -12
  53. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +12 -2
  54. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +0 -14
  55. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +10 -8
  56. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +0 -14
  57. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +18 -73
  58. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  59. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +9 -53
  60. package/dist/server/flow-surfaces/service.d.ts +53 -0
  61. package/dist/server/flow-surfaces/service.js +990 -122
  62. package/dist/server/flow-surfaces/types.d.ts +2 -1
  63. package/dist/server/variables/registry.js +3 -0
  64. package/dist/swagger/flow-surfaces.d.ts +193 -0
  65. package/dist/swagger/flow-surfaces.examples.d.ts +11 -0
  66. package/dist/swagger/flow-surfaces.examples.js +11 -0
  67. package/dist/swagger/flow-surfaces.js +179 -10
  68. package/dist/swagger/index.d.ts +193 -0
  69. package/package.json +2 -2
  70. package/dist/server/flow-surfaces/runjs-authoring/blocked-global-stop/index.js +0 -40
@@ -51,6 +51,7 @@ var import_association_title_field = require("./association-title-field");
51
51
  var import_chart_config = require("./chart-config");
52
52
  var import_public_data_surface_default_filter = require("./public-data-surface-default-filter");
53
53
  var import_default_action_popup = require("./default-action-popup");
54
+ var import_relation_backing_foreign_key = require("./relation-backing-foreign-key");
54
55
  var import_default_block_actions = require("./default-block-actions");
55
56
  var import_hidden_popup_contract = require("./hidden-popup-contract");
56
57
  var import_node_use_sets = require("./node-use-sets");
@@ -60,6 +61,7 @@ var import_association_interfaces = require("./association-interfaces");
60
61
  var import_defaults = require("./blueprint/defaults");
61
62
  var import_runjs_authoring = require("./runjs-authoring");
62
63
  var import_configure_options = require("./configure-options");
64
+ var import_context = require("./context");
63
65
  var import_filter_group = require("./filter-group");
64
66
  const MAIN_BLOCK_UNSUPPORTED_SECTIONS = {
65
67
  calendar: ["fields", "fieldGroups", "recordActions", "fieldsLayout"],
@@ -171,10 +173,17 @@ const GRID_CARD_ALLOWED_SETTINGS_KEYS = /* @__PURE__ */ new Set([
171
173
  const TABLE_ALLOWED_SETTINGS_KEYS = /* @__PURE__ */ new Set([...(0, import_configure_options.getConfigureOptionKeysForUse)("TableBlockModel"), "sort"]);
172
174
  const TABLE_INTERNAL_AUTHORING_KEYS = ["tableSettings", "defaultSorting", "stepParams"];
173
175
  const TABLE_SETTINGS_REPAIR_HINT = "Use public table settings keys such as settings.pageSize, settings.sorting, settings.dataScope, settings.density, settings.showRowNumbers, settings.treeTable, settings.dragSort, and settings.dragSortBy. Do not nest persisted tableSettings/defaultSorting/stepParams payloads.";
174
- const JS_BLOCK_ALLOWED_SETTINGS_KEYS = /* @__PURE__ */ new Set(["title", "description", "className", "code", "version"]);
176
+ const JS_BLOCK_ALLOWED_SETTINGS_KEYS = /* @__PURE__ */ new Set([
177
+ "title",
178
+ "description",
179
+ "className",
180
+ "showBlockCard",
181
+ "code",
182
+ "version"
183
+ ]);
175
184
  const JS_BLOCK_TOP_LEVEL_JS_KEYS = ["code", "version"];
176
185
  const JS_BLOCK_INTERNAL_AUTHORING_KEYS = ["props", "decoratorProps", "flowRegistry", "stepParams"];
177
- const JS_BLOCK_REPAIR_HINT = "This is a jsBlock payload shape problem. Repair this jsBlock using inline settings.code/settings.version, or applyBlueprint assets.scripts.<key>.code plus block.script. Do not change this block type to table, chart, actionPanel, gridCard, or another block type.";
186
+ const JS_BLOCK_REPAIR_HINT = "This is a jsBlock payload shape problem. Repair this jsBlock using inline settings.code/settings.version/settings.showBlockCard, or applyBlueprint assets.scripts.<key>.code plus block.script with optional settings.showBlockCard. Do not change this block type to table, chart, actionPanel, gridCard, or another block type.";
178
187
  const CHART_REPAIR_HINT = "This is a chart payload shape problem. Keep using chart and repair this chart using assets.charts.<key>.query/visual plus block.chart, or localized settings.query/settings.visual. Do not change this block type to table, jsBlock, actionPanel, gridCard, or another block type, and do not drop or defer the chart. KPI / summary numbers should use jsBlock; charts are for trends, distributions, rankings, and visual analysis.";
179
188
  const REPAIR_ALL_ERRORS_AGENT_INSTRUCTION = "If this response contains errors[], fix every listed error in one payload revision before retrying the same write. Do not fix only this error and immediately retry.";
180
189
  const JS_BLOCK_AGENT_INSTRUCTION = `${REPAIR_ALL_ERRORS_AGENT_INSTRUCTION} Do not skip, drop, defer, or replace this required jsBlock. Repair it as jsBlock.`;
@@ -472,7 +481,10 @@ async function collectFlowSurfaceAuthoringErrors(actionName, values, context = {
472
481
  blocks.forEach(({ block }) => collectLocalKeys(block, localKeys));
473
482
  }
474
483
  blocks.forEach(({ block, path }) => collectBlockErrors(block, path, errors, localKeys, validationContext));
475
- collectReactionErrors(values == null ? void 0 : values.reaction, "$.reaction", localKeys, errors);
484
+ collectReactionErrors(values == null ? void 0 : values.reaction, "$.reaction", localKeys, errors, {
485
+ values,
486
+ context: validationContext
487
+ });
476
488
  if (!validationContext.skipGeneratedPopupDefaultFieldGroups) {
477
489
  collectGeneratedPopupDefaultFieldGroupErrors(actionName, values, validationContext, errors);
478
490
  }
@@ -513,10 +525,13 @@ function pushChartBadRequestAuthoringError(errors, error, fallbackPath) {
513
525
  });
514
526
  }
515
527
  async function collectNavigationGroupErrors(actionName, values, context, errors) {
516
- var _a;
528
+ var _a, _b;
517
529
  if (actionName !== "applyBlueprint" || (values == null ? void 0 : values.mode) !== "create" || !_.isPlainObject((_a = values == null ? void 0 : values.navigation) == null ? void 0 : _a.group)) {
518
530
  return;
519
531
  }
532
+ if (await isApplyBlueprintMobileCreateNavigation(values, context)) {
533
+ return;
534
+ }
520
535
  if (!_.isUndefined(values.navigation.group.routeId) || !context.findMenuGroupRoutesByTitle) {
521
536
  return;
522
537
  }
@@ -524,7 +539,8 @@ async function collectNavigationGroupErrors(actionName, values, context, errors)
524
539
  if (!groupTitle) {
525
540
  return;
526
541
  }
527
- const matchedRoutes = await context.findMenuGroupRoutesByTitle(groupTitle, context.transaction);
542
+ const layoutUid = String(((_b = values == null ? void 0 : values.navigation) == null ? void 0 : _b.layoutUid) || "").trim() || void 0;
543
+ const matchedRoutes = await context.findMenuGroupRoutesByTitle(groupTitle, context.transaction, layoutUid);
528
544
  const rootMatchedRoutes = filterRootMenuGroupRoutes(matchedRoutes);
529
545
  if (rootMatchedRoutes.length <= 1) {
530
546
  return;
@@ -541,15 +557,17 @@ async function collectNavigationGroupErrors(actionName, values, context, errors)
541
557
  });
542
558
  }
543
559
  async function collectNavigationIconErrors(actionName, values, context, errors) {
544
- var _a, _b, _c;
560
+ var _a, _b, _c, _d;
545
561
  if (actionName !== "applyBlueprint" || (values == null ? void 0 : values.mode) !== "create") {
546
562
  return;
547
563
  }
564
+ const isMobileCreateNavigation = await isApplyBlueprintMobileCreateNavigation(values, context);
548
565
  const group = _.isPlainObject((_a = values == null ? void 0 : values.navigation) == null ? void 0 : _a.group) ? values.navigation.group : null;
549
566
  const groupRouteId = String((group == null ? void 0 : group.routeId) || "").trim();
550
- if (group && !groupRouteId && group.hideInMenu !== true) {
567
+ const layoutUid = String(((_b = values == null ? void 0 : values.navigation) == null ? void 0 : _b.layoutUid) || "").trim() || void 0;
568
+ if (!isMobileCreateNavigation && group && !groupRouteId && group.hideInMenu !== true) {
551
569
  const groupIcon = String(group.icon || "").trim();
552
- if (!groupIcon && await shouldRequireNewNavigationGroupIcon(group, context)) {
570
+ if (!groupIcon && await shouldRequireNewNavigationGroupIcon(group, context, layoutUid)) {
553
571
  pushAuthoringError(errors, {
554
572
  path: "$.navigation.group.icon",
555
573
  ruleId: "navigation-icon-required",
@@ -568,7 +586,7 @@ async function collectNavigationIconErrors(actionName, values, context, errors)
568
586
  }
569
587
  });
570
588
  }
571
- } else if (group && String(group.icon || "").trim() && !isValidAntDesignIconName(group.icon)) {
589
+ } else if (!isMobileCreateNavigation && group && String(group.icon || "").trim() && !isValidAntDesignIconName(group.icon)) {
572
590
  pushAuthoringError(errors, {
573
591
  path: "$.navigation.group.icon",
574
592
  ruleId: "navigation-icon-unknown",
@@ -578,7 +596,7 @@ async function collectNavigationIconErrors(actionName, values, context, errors)
578
596
  }
579
597
  });
580
598
  }
581
- const item = _.isPlainObject((_b = values == null ? void 0 : values.navigation) == null ? void 0 : _b.item) ? values.navigation.item : null;
599
+ const item = _.isPlainObject((_c = values == null ? void 0 : values.navigation) == null ? void 0 : _c.item) ? values.navigation.item : null;
582
600
  const itemIcon = String((item == null ? void 0 : item.icon) || "").trim();
583
601
  if (itemIcon && !isValidAntDesignIconName(itemIcon)) {
584
602
  pushAuthoringError(errors, {
@@ -590,7 +608,7 @@ async function collectNavigationIconErrors(actionName, values, context, errors)
590
608
  }
591
609
  });
592
610
  }
593
- const pageIcon = String(((_c = values == null ? void 0 : values.page) == null ? void 0 : _c.icon) || "").trim();
611
+ const pageIcon = String(((_d = values == null ? void 0 : values.page) == null ? void 0 : _d.icon) || "").trim();
594
612
  if (pageIcon && !isValidAntDesignIconName(pageIcon)) {
595
613
  pushAuthoringError(errors, {
596
614
  path: "$.page.icon",
@@ -602,12 +620,20 @@ async function collectNavigationIconErrors(actionName, values, context, errors)
602
620
  });
603
621
  }
604
622
  }
605
- async function shouldRequireNewNavigationGroupIcon(group, context) {
623
+ async function isApplyBlueprintMobileCreateNavigation(values, context) {
624
+ var _a;
625
+ const layoutUid = String(((_a = values == null ? void 0 : values.navigation) == null ? void 0 : _a.layoutUid) || "").trim();
626
+ if (!layoutUid || !context.getUiLayoutTypeByUid) {
627
+ return false;
628
+ }
629
+ return await context.getUiLayoutTypeByUid(layoutUid, context.transaction) === "mobile";
630
+ }
631
+ async function shouldRequireNewNavigationGroupIcon(group, context, layoutUid) {
606
632
  const groupTitle = String((group == null ? void 0 : group.title) || "").trim();
607
633
  if (!groupTitle || !context.findMenuGroupRoutesByTitle) {
608
634
  return true;
609
635
  }
610
- const matchedRoutes = await context.findMenuGroupRoutesByTitle(groupTitle, context.transaction);
636
+ const matchedRoutes = await context.findMenuGroupRoutesByTitle(groupTitle, context.transaction, layoutUid);
611
637
  return filterRootMenuGroupRoutes(matchedRoutes).length === 0;
612
638
  }
613
639
  function filterRootMenuGroupRoutes(routes) {
@@ -732,6 +758,7 @@ function withJsBlockRepairHint(details = {}) {
732
758
  inlineBlock: {
733
759
  type: "jsBlock",
734
760
  settings: {
761
+ showBlockCard: true,
735
762
  code: 'ctx.render("Replace this with the required rendered UI");'
736
763
  }
737
764
  },
@@ -745,7 +772,10 @@ function withJsBlockRepairHint(details = {}) {
745
772
  },
746
773
  block: {
747
774
  type: "jsBlock",
748
- script: "scriptKey"
775
+ script: "scriptKey",
776
+ settings: {
777
+ showBlockCard: true
778
+ }
749
779
  }
750
780
  }
751
781
  },
@@ -1177,47 +1207,69 @@ function collectBuilderChartAssetQueryErrors(query, path, context, errors) {
1177
1207
  errors,
1178
1208
  withChartRepairHint()
1179
1209
  );
1180
- collectChartQueryFilterOperatorErrors(query, `${path}.query`, errors);
1210
+ collectChartQueryFilterOperatorErrors(query, `${path}.query`, errors, context);
1181
1211
  collectBuilderChartAssetFieldErrors(query, path, context, errors);
1182
1212
  }
1183
- function collectChartQueryFilterOperatorErrors(query, path, errors) {
1213
+ const AUTHORABLE_REACTION_SCALAR_CONTEXT_PATHS = /* @__PURE__ */ new Set(["role", "locale", "token", "deviceType"]);
1214
+ const AUTHORABLE_REACTION_CONTEXT_ROOTS = /* @__PURE__ */ new Set([
1215
+ "user",
1216
+ "collection",
1217
+ "formValues",
1218
+ "record",
1219
+ "item",
1220
+ "popup",
1221
+ "urlSearchParams"
1222
+ ]);
1223
+ function collectChartQueryFilterOperatorErrors(query, path, errors, context) {
1184
1224
  if (!_.isPlainObject(query) || !hasOwn(query, "filter")) {
1185
1225
  return;
1186
1226
  }
1187
- collectChartFilterOperatorErrors(query.filter, `${path}.filter`, errors);
1227
+ collectChartFilterOperatorErrors(
1228
+ query.filter,
1229
+ `${path}.filter`,
1230
+ errors,
1231
+ createChartQueryDateConditionFieldResolver(query, context)
1232
+ );
1188
1233
  }
1189
- function collectChartFilterOperatorErrors(filter, path, errors) {
1234
+ function collectChartFilterOperatorErrors(filter, path, errors, resolveField) {
1190
1235
  if (_.isUndefined(filter) || _.isNull(filter) || !_.isPlainObject(filter)) {
1191
1236
  return;
1192
1237
  }
1193
1238
  if (Array.isArray(filter.items)) {
1194
- collectChartFilterGroupOperatorErrors(filter.items, `${path}.items`, errors);
1239
+ collectChartFilterGroupOperatorErrors(filter.items, `${path}.items`, errors, resolveField);
1195
1240
  return;
1196
1241
  }
1197
- collectBackendQueryFilterOperatorErrors(filter, path, errors);
1242
+ collectBackendQueryFilterOperatorErrors(filter, path, errors, resolveField);
1198
1243
  }
1199
- function collectChartFilterGroupOperatorErrors(items, path, errors) {
1244
+ function collectChartFilterGroupOperatorErrors(items, path, errors, resolveField) {
1200
1245
  items.forEach((item, index) => {
1201
1246
  const itemPath = `${path}[${index}]`;
1202
1247
  if (!_.isPlainObject(item)) {
1203
1248
  return;
1204
1249
  }
1205
1250
  if (Array.isArray(item.items)) {
1206
- collectChartFilterGroupOperatorErrors(item.items, `${itemPath}.items`, errors);
1251
+ collectChartFilterGroupOperatorErrors(item.items, `${itemPath}.items`, errors, resolveField);
1207
1252
  return;
1208
1253
  }
1209
1254
  if (hasOwn(item, "operator")) {
1210
1255
  collectChartFilterOperatorError(item.operator, `${itemPath}.operator`, errors);
1211
- collectChartFilterDateValueError(item.operator, item.value, `${itemPath}.value`, errors);
1256
+ const fieldPath = String(item.path || item.field || "").trim();
1257
+ collectChartFilterDateValueError(
1258
+ item.operator,
1259
+ item.value,
1260
+ `${itemPath}.value`,
1261
+ errors,
1262
+ fieldPath ? (resolveField == null ? void 0 : resolveField(fieldPath)) || { fieldPath } : void 0
1263
+ );
1212
1264
  }
1213
1265
  });
1214
1266
  }
1215
- function collectBackendQueryFilterOperatorErrors(filter, path, errors) {
1267
+ function collectBackendQueryFilterOperatorErrors(filter, path, errors, resolveField) {
1216
1268
  Object.entries(filter).forEach(([field, condition]) => {
1217
1269
  const fieldPath = `${path}.${field}`;
1218
1270
  if ((field === "$and" || field === "$or") && Array.isArray(condition)) {
1219
1271
  condition.forEach(
1220
- (operand, index) => collectChartFilterOperatorErrors(operand, `${fieldPath}[${index}]`, errors)
1272
+ (operand, index) => collectChartFilterOperatorErrors(operand, `${fieldPath}[${index}]`, errors, resolveField)
1221
1273
  );
1222
1274
  return;
1223
1275
  }
@@ -1226,11 +1278,17 @@ function collectBackendQueryFilterOperatorErrors(filter, path, errors) {
1226
1278
  }
1227
1279
  Object.keys(condition).forEach((operator) => {
1228
1280
  if (operator === "$and" || operator === "$or") {
1229
- collectChartFilterOperatorErrors({ [operator]: condition[operator] }, fieldPath, errors);
1281
+ collectChartFilterOperatorErrors({ [operator]: condition[operator] }, fieldPath, errors, resolveField);
1230
1282
  return;
1231
1283
  }
1232
1284
  collectChartFilterOperatorError(operator, `${fieldPath}.${operator}`, errors);
1233
- collectChartFilterDateValueError(operator, condition[operator], `${fieldPath}.${operator}`, errors);
1285
+ collectChartFilterDateValueError(
1286
+ operator,
1287
+ condition[operator],
1288
+ `${fieldPath}.${operator}`,
1289
+ errors,
1290
+ (resolveField == null ? void 0 : resolveField(field)) || { fieldPath: field }
1291
+ );
1234
1292
  });
1235
1293
  });
1236
1294
  }
@@ -1245,9 +1303,18 @@ function collectChartFilterOperatorError(operator, path, errors) {
1245
1303
  throw error;
1246
1304
  }
1247
1305
  }
1248
- function collectChartFilterDateValueError(operator, value, path, errors) {
1306
+ function collectChartFilterDateValueError(operator, value, path, errors, fieldContext) {
1307
+ const fieldMeta = getDateConditionFieldContextMeta(fieldContext);
1308
+ const normalizedOperator = typeof operator === "string" ? operator.trim() : "";
1309
+ if (!import_filter_group.FLOW_SURFACE_DATE_FILTER_OPERATORS.has(normalizedOperator) && !(0, import_filter_group.isFlowSurfaceDateLikeFieldMeta)(fieldMeta)) {
1310
+ return;
1311
+ }
1249
1312
  try {
1250
- (0, import_filter_group.normalizeFlowSurfaceStrictFilterDateValue)(operator, value, path);
1313
+ (0, import_filter_group.normalizeFlowSurfaceDateConditionValue)(operator, value, path, {
1314
+ fieldPath: fieldContext == null ? void 0 : fieldContext.fieldPath,
1315
+ fieldType: fieldMeta.type,
1316
+ fieldInterface: fieldMeta.interface
1317
+ });
1251
1318
  } catch (error) {
1252
1319
  if (error instanceof import_errors.FlowSurfaceBadRequestError) {
1253
1320
  pushChartBadRequestAuthoringError(errors, error, path);
@@ -1256,6 +1323,38 @@ function collectChartFilterDateValueError(operator, value, path, errors) {
1256
1323
  throw error;
1257
1324
  }
1258
1325
  }
1326
+ function createChartQueryDateConditionFieldResolver(query, context) {
1327
+ const resource = _.isPlainObject(query == null ? void 0 : query.resource) ? query.resource : null;
1328
+ const collectionName = String((resource == null ? void 0 : resource.collectionName) || "").trim();
1329
+ if (!collectionName || typeof (context == null ? void 0 : context.getCollection) !== "function") {
1330
+ return null;
1331
+ }
1332
+ const dataSourceKey = String((resource == null ? void 0 : resource.dataSourceKey) || "main").trim() || "main";
1333
+ const collection = context.getCollection(dataSourceKey, collectionName);
1334
+ if (!collection) {
1335
+ return null;
1336
+ }
1337
+ return (fieldPath) => {
1338
+ const normalizedFieldPath = (0, import_service_helpers.normalizeFieldPath)(fieldPath);
1339
+ const resolved = resolveDefaultFilterFieldPath(collection, normalizedFieldPath, dataSourceKey, context);
1340
+ return {
1341
+ fieldPath,
1342
+ field: resolved.field
1343
+ };
1344
+ };
1345
+ }
1346
+ function getDateConditionFieldMeta(field) {
1347
+ return {
1348
+ type: (0, import_service_helpers.getFieldType)(field),
1349
+ interface: (0, import_service_helpers.getFieldInterface)(field)
1350
+ };
1351
+ }
1352
+ function getDateConditionFieldContextMeta(fieldContext) {
1353
+ return {
1354
+ ...getDateConditionFieldMeta(fieldContext == null ? void 0 : fieldContext.field),
1355
+ ...(fieldContext == null ? void 0 : fieldContext.fieldMeta) || {}
1356
+ };
1357
+ }
1259
1358
  function normalizeChartAssetFieldPath(input) {
1260
1359
  if (Array.isArray(input)) {
1261
1360
  return input.map((item) => String(item || "").trim()).filter(Boolean).join(".");
@@ -3616,6 +3715,9 @@ function getGeneratedPopupBusinessFieldCandidates(collection) {
3616
3715
  if (!fieldName || !(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupBusinessField)(field)) {
3617
3716
  return [];
3618
3717
  }
3718
+ if ((0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(collection, field)) {
3719
+ return [];
3720
+ }
3619
3721
  return [
3620
3722
  {
3621
3723
  field,
@@ -3730,11 +3832,15 @@ function getGeneratedPopupDefaultFormFieldPaths(candidates, fieldGroups) {
3730
3832
  }
3731
3833
  function getGeneratedPopupRuntimeFieldCandidates(input) {
3732
3834
  const candidateContext = DEFAULT_ACTION_POPUP_FIELD_CONTEXT_BY_TYPE[input.actionType];
3835
+ const explicitDefaultFieldPaths = (0, import_default_action_popup.collectFlowSurfaceDefaultActionPopupFieldGroupFieldPaths)(input.fieldGroups);
3733
3836
  return (0, import_service_helpers.getCollectionFields)(input.collection).flatMap((field) => {
3734
3837
  const fieldName = (0, import_service_helpers.getFieldName)(field);
3735
3838
  if (!fieldName || !(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupBusinessField)(field)) {
3736
3839
  return [];
3737
3840
  }
3841
+ if ((0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(input.collection, field) && !explicitDefaultFieldPaths.has(fieldName)) {
3842
+ return [];
3843
+ }
3738
3844
  const fieldInterface = (0, import_service_helpers.getFieldInterface)(field);
3739
3845
  const registeredBinding = (0, import_field_binding_registry.resolveRegisteredFieldBinding)({
3740
3846
  containerUse: candidateContext.ownerUse,
@@ -3958,9 +4064,16 @@ function collectBlockErrors(block, path, errors, localKeys, context) {
3958
4064
  collectChartDisplayTitleErrors(block, blockType, path, errors);
3959
4065
  collectTreeTableExplicitFieldsErrors(block, blockType, path, errors, context);
3960
4066
  collectTreeConnectFieldsErrors((_a = block.settings) == null ? void 0 : _a.connectFields, `${path}.settings.connectFields`, errors);
3961
- collectTableSettingsErrors(block, blockType, path, errors, {
3962
- deferPublicDataScopeErrors: context.authoringActionName === "addBlocks"
3963
- });
4067
+ collectTableSettingsErrors(
4068
+ block,
4069
+ blockType,
4070
+ path,
4071
+ errors,
4072
+ {
4073
+ deferPublicDataScopeErrors: context.authoringActionName === "addBlocks"
4074
+ },
4075
+ context
4076
+ );
3964
4077
  collectGridCardSettingsErrors(block, blockType, path, errors);
3965
4078
  const descendantContext = getBlockDescendantValidationContext(block, context);
3966
4079
  collectActionListErrors(block.actions, `${path}.actions`, errors, block, descendantContext, "actions");
@@ -3999,7 +4112,7 @@ function collectJsBlockPublicContractErrors(block, path, errors, context) {
3999
4112
  pushAuthoringError(errors, {
4000
4113
  path: `${path}.${key}`,
4001
4114
  ruleId: `jsBlock-top-level-${key}-unsupported`,
4002
- message: `flowSurfaces authoring ${path}.${key} is not accepted on public jsBlock blocks; use ${path}.settings.code and ${path}.settings.version for inline JS code`,
4115
+ message: `flowSurfaces authoring ${path}.${key} is not accepted on public jsBlock blocks; use ${path}.settings.code, ${path}.settings.version, and ${path}.settings.showBlockCard for public JS block settings`,
4003
4116
  details: withJsBlockRepairHint({ key })
4004
4117
  });
4005
4118
  });
@@ -4010,7 +4123,7 @@ function collectJsBlockPublicContractErrors(block, path, errors, context) {
4010
4123
  pushAuthoringError(errors, {
4011
4124
  path: `${path}.${key}`,
4012
4125
  ruleId: key === "stepParams" ? "jsBlock-stepParams-unsupported" : "jsBlock-internal-field-unsupported",
4013
- message: `flowSurfaces authoring ${path}.${key} is not accepted on public jsBlock blocks; use ${path}.settings.code and ${path}.settings.version instead of internal persisted fields`,
4126
+ message: `flowSurfaces authoring ${path}.${key} is not accepted on public jsBlock blocks; use ${path}.settings.code, ${path}.settings.version, and ${path}.settings.showBlockCard instead of internal persisted fields`,
4014
4127
  details: withJsBlockRepairHint({
4015
4128
  key
4016
4129
  })
@@ -4033,7 +4146,7 @@ function collectJsBlockPublicContractErrors(block, path, errors, context) {
4033
4146
  pushAuthoringError(errors, {
4034
4147
  path: `${path}.settings.${key}`,
4035
4148
  ruleId: "jsBlock-settings-unsupported-key",
4036
- message: `flowSurfaces authoring ${path}.settings.${key} is not part of the public jsBlock contract; use ${path}.settings.code and ${path}.settings.version for inline JS code`,
4149
+ message: `flowSurfaces authoring ${path}.settings.${key} is not part of the public jsBlock contract; use ${path}.settings.code, ${path}.settings.version, and ${path}.settings.showBlockCard for public JS block settings`,
4037
4150
  details: withJsBlockRepairHint({
4038
4151
  key,
4039
4152
  allowedKeys: Array.from(JS_BLOCK_ALLOWED_SETTINGS_KEYS)
@@ -4075,7 +4188,7 @@ function collectJsBlockConfigurePublicContractErrors(changes, path, errors) {
4075
4188
  pushAuthoringError(errors, {
4076
4189
  path: `${path}.${key}`,
4077
4190
  ruleId: key === "stepParams" ? "jsBlock-stepParams-unsupported" : "jsBlock-internal-field-unsupported",
4078
- message: `flowSurfaces authoring ${path}.${key} is not accepted on public jsBlock configure changes; use ${path}.code and ${path}.version instead of internal persisted fields`,
4191
+ message: `flowSurfaces authoring ${path}.${key} is not accepted on public jsBlock configure changes; use ${path}.code, ${path}.version, and ${path}.showBlockCard instead of internal persisted fields`,
4079
4192
  details: withJsBlockRepairHint({
4080
4193
  key
4081
4194
  })
@@ -4108,7 +4221,7 @@ function collectJsBlockConfigurePublicContractErrors(changes, path, errors) {
4108
4221
  pushAuthoringError(errors, {
4109
4222
  path: `${path}.settings`,
4110
4223
  ruleId: "jsBlock-settings-unsupported-key",
4111
- message: `flowSurfaces authoring ${path}.settings is not part of the public jsBlock configure contract; use ${path}.code and ${path}.version`,
4224
+ message: `flowSurfaces authoring ${path}.settings is not part of the public jsBlock configure contract; use ${path}.code, ${path}.version, and ${path}.showBlockCard`,
4112
4225
  details: withJsBlockRepairHint()
4113
4226
  });
4114
4227
  return;
@@ -4268,8 +4381,8 @@ async function collectConfigureErrors(values, errors, context) {
4268
4381
  collectCommentsBlockErrors(changesBlock, hostBlockType, "$.changes", errors, context);
4269
4382
  collectRecordHistoryBlockErrors(changesBlock, hostBlockType, "$.changes", errors, context);
4270
4383
  collectChartDisplayTitleErrors(changes, hostBlockType, "$.changes", errors);
4271
- collectChartConfigureFilterOperatorErrors(changes, hostBlockType, "$.changes", errors);
4272
- collectTableSettingsErrors(changes, hostBlockType, "$.changes", errors, { directSettings: true });
4384
+ collectChartConfigureFilterOperatorErrors(changes, hostBlockType, "$.changes", errors, context);
4385
+ collectTableSettingsErrors(changes, hostBlockType, "$.changes", errors, { directSettings: true }, context);
4273
4386
  collectGridCardSettingsErrors(changes, hostBlockType, "$.changes", errors, { directSettings: true });
4274
4387
  collectAssignValuesErrors(changes.assignValues, "$.changes.assignValues", errors, changesBlock, context);
4275
4388
  collectTriggerWorkflowsErrors(changes.triggerWorkflows, "$.changes.triggerWorkflows", errors);
@@ -4357,10 +4470,20 @@ function collectUnsupportedDefaultFilterOperatorError(operator, path, errors) {
4357
4470
  }
4358
4471
  });
4359
4472
  }
4360
- function collectDefaultFilterDateValueError(operator, value, path, errors) {
4473
+ function collectDefaultFilterDateValueError(operator, value, path, errors, fieldContext, options = {}) {
4361
4474
  var _a, _b, _c;
4475
+ const fieldMeta = getDateConditionFieldContextMeta(fieldContext);
4476
+ const normalizedOperator = typeof operator === "string" ? operator.trim() : "";
4477
+ if (!import_filter_group.FLOW_SURFACE_DATE_FILTER_OPERATORS.has(normalizedOperator) && !(0, import_filter_group.isFlowSurfaceDateLikeFieldMeta)(fieldMeta)) {
4478
+ return;
4479
+ }
4362
4480
  try {
4363
- (0, import_filter_group.normalizeFlowSurfaceStrictFilterDateValue)(operator, value, path);
4481
+ (0, import_filter_group.normalizeFlowSurfaceDateConditionValue)(operator, value, path, {
4482
+ fieldPath: fieldContext == null ? void 0 : fieldContext.fieldPath,
4483
+ fieldType: fieldMeta.type,
4484
+ fieldInterface: fieldMeta.interface,
4485
+ allowContextPathValue: options.allowContextPathValue
4486
+ });
4364
4487
  } catch (error) {
4365
4488
  if (!(error instanceof import_errors.FlowSurfaceBadRequestError)) {
4366
4489
  throw error;
@@ -5423,13 +5546,13 @@ function collectChartDisplayTitleErrors(block, blockType, blockPath, errors) {
5423
5546
  message: "Chart block settings do not support displayTitle in the current flowSurfaces runtime; keep settings.title and omit displayTitle."
5424
5547
  });
5425
5548
  }
5426
- function collectChartConfigureFilterOperatorErrors(changes, hostBlockType, path, errors) {
5549
+ function collectChartConfigureFilterOperatorErrors(changes, hostBlockType, path, errors, context) {
5427
5550
  if (hostBlockType !== "chart" || !_.isPlainObject(changes)) {
5428
5551
  return;
5429
5552
  }
5430
- collectChartQueryFilterOperatorErrors(changes.query, `${path}.query`, errors);
5553
+ collectChartQueryFilterOperatorErrors(changes.query, `${path}.query`, errors, context);
5431
5554
  if (_.isPlainObject(changes.configure)) {
5432
- collectChartQueryFilterOperatorErrors(changes.configure.query, `${path}.configure.query`, errors);
5555
+ collectChartQueryFilterOperatorErrors(changes.configure.query, `${path}.configure.query`, errors, context);
5433
5556
  }
5434
5557
  }
5435
5558
  function visitFilterItems(value, path, errors, block, context = {}) {
@@ -5446,7 +5569,13 @@ function visitFilterItems(value, path, errors, block, context = {}) {
5446
5569
  }
5447
5570
  if (typeof value.operator === "string") {
5448
5571
  collectUnsupportedDefaultFilterOperatorError(value.operator, `${path}.operator`, errors);
5449
- collectDefaultFilterDateValueError(value.operator, value.value, `${path}.value`, errors);
5572
+ collectDefaultFilterDateValueError(
5573
+ value.operator,
5574
+ value.value,
5575
+ `${path}.value`,
5576
+ errors,
5577
+ fieldRef ? resolveDefaultFilterDateConditionField(fieldRef.value, block, context) : void 0
5578
+ );
5450
5579
  }
5451
5580
  const filterItems = value.items;
5452
5581
  if (Array.isArray(filterItems)) {
@@ -5472,11 +5601,33 @@ function visitFilterItems(value, path, errors, block, context = {}) {
5472
5601
  if (_.isPlainObject(child)) {
5473
5602
  Object.entries(child).forEach(([operator, operatorValue]) => {
5474
5603
  collectUnsupportedDefaultFilterOperatorError(operator, `${path}.${key}.${operator}`, errors);
5475
- collectDefaultFilterDateValueError(operator, operatorValue, `${path}.${key}.${operator}`, errors);
5604
+ collectDefaultFilterDateValueError(
5605
+ operator,
5606
+ operatorValue,
5607
+ `${path}.${key}.${operator}`,
5608
+ errors,
5609
+ resolveDefaultFilterDateConditionField(key, block, context)
5610
+ );
5476
5611
  });
5477
5612
  }
5478
5613
  });
5479
5614
  }
5615
+ function resolveDefaultFilterDateConditionField(rawFieldPath, block, context) {
5616
+ const fieldPath = String(rawFieldPath || "").trim();
5617
+ if (!fieldPath || fieldPath.startsWith("$") || fieldPath.startsWith("{{")) {
5618
+ return null;
5619
+ }
5620
+ const collection = getBlockCollection(block, context);
5621
+ if (!collection) {
5622
+ return null;
5623
+ }
5624
+ const dataSourceKey = getBlockDataSourceKey(block, context);
5625
+ const resolved = resolveDefaultFilterFieldPath(collection, (0, import_service_helpers.normalizeFieldPath)(fieldPath), dataSourceKey, context);
5626
+ return {
5627
+ fieldPath,
5628
+ field: resolved.field
5629
+ };
5630
+ }
5480
5631
  function collectTreeConnectFieldsErrors(value, path, errors) {
5481
5632
  if (_.isUndefined(value)) {
5482
5633
  return [];
@@ -5825,7 +5976,7 @@ function getCollectionFilterTargetKey(collection) {
5825
5976
  function normalizeDataSourceKey(value) {
5826
5977
  return String(value || "main").trim() || "main";
5827
5978
  }
5828
- function collectTableSettingsErrors(block, blockType, blockPath, errors, options = {}) {
5979
+ function collectTableSettingsErrors(block, blockType, blockPath, errors, options = {}, context = {}) {
5829
5980
  if (blockType !== "table" || !_.isPlainObject(block)) {
5830
5981
  return;
5831
5982
  }
@@ -5836,6 +5987,9 @@ function collectTableSettingsErrors(block, blockType, blockPath, errors, options
5836
5987
  });
5837
5988
  const hasSettings = _.isPlainObject(block == null ? void 0 : block.settings);
5838
5989
  if (!hasSettings) {
5990
+ if (options.directSettings === true && !shouldDeferPublicDataScopeErrorsToBatchItem(blockPath, errors, options)) {
5991
+ collectPublicDataScopeErrors(block.dataScope, `${blockPath}.dataScope`, errors, block, context);
5992
+ }
5839
5993
  return;
5840
5994
  }
5841
5995
  const settings = block.settings;
@@ -5850,7 +6004,7 @@ function collectTableSettingsErrors(block, blockType, blockPath, errors, options
5850
6004
  pushTableSettingsUnsupportedError(errors, `${settingsPath}.${key}`, key);
5851
6005
  });
5852
6006
  if (!shouldDeferPublicDataScopeErrorsToBatchItem(blockPath, errors, options)) {
5853
- collectPublicDataScopeErrors(settings.dataScope, `${settingsPath}.dataScope`, errors);
6007
+ collectPublicDataScopeErrors(settings.dataScope, `${settingsPath}.dataScope`, errors, block, context);
5854
6008
  }
5855
6009
  }
5856
6010
  function pushTableSettingsUnsupportedError(errors, path, key) {
@@ -5865,7 +6019,7 @@ function pushTableSettingsUnsupportedError(errors, path, key) {
5865
6019
  }
5866
6020
  });
5867
6021
  }
5868
- function collectPublicDataScopeErrors(value, path, errors) {
6022
+ function collectPublicDataScopeErrors(value, path, errors, block, context) {
5869
6023
  if (_.isUndefined(value)) {
5870
6024
  return;
5871
6025
  }
@@ -5885,6 +6039,62 @@ function collectPublicDataScopeErrors(value, path, errors) {
5885
6039
  repairHint: 'Use settings.dataScope with logic/items, for example {"logic":"$and","items":[{"path":"status","operator":"$eq","value":"Active"}]}; do not use a field-name map.'
5886
6040
  }
5887
6041
  });
6042
+ return;
6043
+ }
6044
+ collectPublicDataScopeFieldPathErrors(validationValue, path, errors, block, context);
6045
+ collectFilterGroupDateConditionErrors(validationValue, path, errors, block, context);
6046
+ }
6047
+ function collectPublicDataScopeFieldPathErrors(value, path, errors, block, context) {
6048
+ if (!_.isPlainObject(value)) {
6049
+ return;
6050
+ }
6051
+ if (hasOwn(value, "operator")) {
6052
+ collectPublicDataScopeFieldPathError(value.path, `${path}.path`, block, context, errors);
6053
+ }
6054
+ if (Array.isArray(value.items)) {
6055
+ value.items.forEach(
6056
+ (item, index) => collectPublicDataScopeFieldPathErrors(item, `${path}.items[${index}]`, errors, block, context)
6057
+ );
6058
+ }
6059
+ }
6060
+ function collectPublicDataScopeFieldPathError(rawFieldPath, path, block, context, errors) {
6061
+ const fieldPath = String(rawFieldPath || "").trim();
6062
+ if (!fieldPath || fieldPath.startsWith("$") || fieldPath.startsWith("{{")) {
6063
+ return;
6064
+ }
6065
+ const collection = getBlockCollection(block, context);
6066
+ if (!collection) {
6067
+ return;
6068
+ }
6069
+ const resolved = resolveDefaultFilterFieldPath(
6070
+ collection,
6071
+ (0, import_service_helpers.normalizeFieldPath)(fieldPath),
6072
+ getBlockDataSourceKey(block, context),
6073
+ context
6074
+ );
6075
+ if (!resolved.field) {
6076
+ pushAuthoringError(errors, {
6077
+ path,
6078
+ ruleId: "field-path-unknown",
6079
+ message: `flowSurfaces authoring ${path} references unknown field '${fieldPath}'`,
6080
+ details: {
6081
+ fieldPath,
6082
+ collection: (0, import_service_helpers.getCollectionName)(resolved.collection || collection),
6083
+ availableFields: (0, import_service_helpers.getCollectionFields)(resolved.collection || collection).map((field) => String((0, import_service_helpers.getFieldName)(field) || "").trim()).filter(Boolean)
6084
+ }
6085
+ });
6086
+ return;
6087
+ }
6088
+ if ((0, import_service_helpers.isAssociationField)(resolved.field)) {
6089
+ pushAuthoringError(errors, {
6090
+ path,
6091
+ ruleId: "defaultFilter-relation-field-unsupported",
6092
+ message: `flowSurfaces authoring ${path} cannot use relation field '${fieldPath}' itself; use a scalar subfield instead`,
6093
+ details: {
6094
+ fieldPath,
6095
+ fieldName: (0, import_service_helpers.getFieldName)(resolved.field)
6096
+ }
6097
+ });
5888
6098
  }
5889
6099
  }
5890
6100
  function shouldDeferPublicDataScopeErrorsToBatchItem(blockPath, errors, options) {
@@ -5906,6 +6116,28 @@ function normalizePublicDataScopeValueForValidation(value) {
5906
6116
  }
5907
6117
  return value;
5908
6118
  }
6119
+ function collectFilterGroupDateConditionErrors(value, path, errors, block, context) {
6120
+ if (!_.isPlainObject(value)) {
6121
+ return;
6122
+ }
6123
+ if (Array.isArray(value.items)) {
6124
+ value.items.forEach(
6125
+ (item, index) => collectFilterGroupDateConditionErrors(item, `${path}.items[${index}]`, errors, block, context)
6126
+ );
6127
+ return;
6128
+ }
6129
+ if (!hasOwn(value, "operator")) {
6130
+ return;
6131
+ }
6132
+ const fieldPath = String(value.path || value.field || "").trim();
6133
+ collectDefaultFilterDateValueError(
6134
+ value.operator,
6135
+ value.value,
6136
+ `${path}.value`,
6137
+ errors,
6138
+ fieldPath ? resolveDefaultFilterDateConditionField(fieldPath, block, context) : void 0
6139
+ );
6140
+ }
5909
6141
  function collectGridCardSettingsErrors(block, blockType, blockPath, errors, options = {}) {
5910
6142
  const hasSettings = _.isPlainObject(block == null ? void 0 : block.settings);
5911
6143
  if (!hasSettings && options.directSettings !== true) {
@@ -6033,11 +6265,12 @@ function buildAuthoringAIEmployeeActionIdentity(settings) {
6033
6265
  return stableSerializeAuthoringValue(normalizeAuthoringAIEmployeePublicSettingsForIdentity(settings));
6034
6266
  }
6035
6267
  function normalizeAuthoringAIEmployeePublicSettingsForIdentity(settings) {
6268
+ const workContext = Object.prototype.hasOwnProperty.call(settings, "workContext") ? normalizeAuthoringAIEmployeeWorkContextForIdentity(settings.workContext) : [{ type: "flow-model", target: "self" }];
6036
6269
  return {
6037
6270
  username: String(settings.username || "").trim(),
6038
6271
  auto: typeof settings.auto === "boolean" ? settings.auto : false,
6039
- workContext: Object.prototype.hasOwnProperty.call(settings, "workContext") ? normalizeAuthoringAIEmployeeWorkContextForIdentity(settings.workContext) : [{ type: "flow-model", target: "self" }],
6040
- tasks: normalizeAuthoringAIEmployeeTasksForIdentity(settings.tasks),
6272
+ workContext,
6273
+ tasks: normalizeAuthoringAIEmployeeTasksForIdentity(settings.tasks, workContext),
6041
6274
  style: {
6042
6275
  ...AUTHORING_AI_EMPLOYEE_DEFAULT_STYLE,
6043
6276
  ..._.isPlainObject(settings.style) ? _.pick(settings.style, AUTHORING_AI_EMPLOYEE_STYLE_PUBLIC_KEYS) : {}
@@ -6056,7 +6289,14 @@ function normalizeAuthoringAIEmployeeWorkContextForIdentity(value) {
6056
6289
  return output;
6057
6290
  });
6058
6291
  }
6059
- function normalizeAuthoringAIEmployeeTasksForIdentity(value) {
6292
+ function normalizeAuthoringAIEmployeeTaskWorkContextForIdentity(value, defaultWorkContext) {
6293
+ const normalized = normalizeAuthoringAIEmployeeWorkContextForIdentity(value);
6294
+ if (Array.isArray(defaultWorkContext) && !normalized.length) {
6295
+ return _.cloneDeep(defaultWorkContext);
6296
+ }
6297
+ return normalized;
6298
+ }
6299
+ function normalizeAuthoringAIEmployeeTasksForIdentity(value, defaultWorkContext) {
6060
6300
  return _.castArray(value || []).map((task) => {
6061
6301
  if (!_.isPlainObject(task)) {
6062
6302
  return task;
@@ -6064,10 +6304,11 @@ function normalizeAuthoringAIEmployeeTasksForIdentity(value) {
6064
6304
  const output = _.pick(task, AUTHORING_AI_EMPLOYEE_TASK_PUBLIC_SETTING_KEYS);
6065
6305
  if (_.isPlainObject(output.message)) {
6066
6306
  output.message = _.pick(output.message, AUTHORING_AI_EMPLOYEE_TASK_MESSAGE_PUBLIC_KEYS);
6067
- if (_.isPlainObject(output.message.workContext)) {
6068
- output.message.workContext = normalizeAuthoringAIEmployeeWorkContextForIdentity(output.message.workContext);
6069
- } else if (Array.isArray(output.message.workContext)) {
6070
- output.message.workContext = normalizeAuthoringAIEmployeeWorkContextForIdentity(output.message.workContext);
6307
+ if (Object.prototype.hasOwnProperty.call(output.message, "workContext")) {
6308
+ output.message.workContext = normalizeAuthoringAIEmployeeTaskWorkContextForIdentity(
6309
+ output.message.workContext,
6310
+ defaultWorkContext
6311
+ );
6071
6312
  }
6072
6313
  }
6073
6314
  if (Object.prototype.hasOwnProperty.call(task, "prompt") && !Object.prototype.hasOwnProperty.call(output.message || {}, "user")) {
@@ -6076,6 +6317,13 @@ function normalizeAuthoringAIEmployeeTasksForIdentity(value) {
6076
6317
  user: task.prompt
6077
6318
  };
6078
6319
  }
6320
+ if (!_.isPlainObject(output.message) && Array.isArray(defaultWorkContext)) {
6321
+ output.message = {
6322
+ workContext: _.cloneDeep(defaultWorkContext)
6323
+ };
6324
+ } else if (_.isPlainObject(output.message) && !Object.prototype.hasOwnProperty.call(output.message, "workContext")) {
6325
+ output.message.workContext = _.cloneDeep(defaultWorkContext || []);
6326
+ }
6079
6327
  if (_.isPlainObject(output.model)) {
6080
6328
  output.model = _.pick(output.model, AUTHORING_AI_EMPLOYEE_TASK_MODEL_PUBLIC_KEYS);
6081
6329
  }
@@ -6516,7 +6764,7 @@ function collectNestedBlockErrors(blocks, path, errors, localKeys, context) {
6516
6764
  }
6517
6765
  blocks.forEach((block, index) => collectBlockErrors(block, `${path}[${index}]`, errors, localKeys, context));
6518
6766
  }
6519
- function collectReactionErrors(reaction, path, localKeys, errors) {
6767
+ function collectReactionErrors(reaction, path, localKeys, errors, options = {}) {
6520
6768
  const items = Array.isArray(reaction == null ? void 0 : reaction.items) ? reaction.items : [];
6521
6769
  items.forEach((item, index) => {
6522
6770
  const rawTarget = (item == null ? void 0 : item.target) ?? (item == null ? void 0 : item.targetKey) ?? (item == null ? void 0 : item.targetBlock);
@@ -6534,7 +6782,197 @@ function collectReactionErrors(reaction, path, localKeys, errors) {
6534
6782
  message: `flowSurfaces authoring ${path}.items[${index}].target references unknown local target '${target}'`
6535
6783
  });
6536
6784
  }
6785
+ collectReactionItemDateConditionErrors(item, `${path}.items[${index}]`, target, errors, options);
6786
+ });
6787
+ }
6788
+ function collectReactionItemDateConditionErrors(item, path, target, errors, options) {
6789
+ if (!_.isPlainObject(item) || !_.isPlainObject(options.values) || !options.context) {
6790
+ return;
6791
+ }
6792
+ const targetMatch = findApplyBlueprintReactionTargetBlock(options.values, target, options.context);
6793
+ if (!targetMatch) {
6794
+ return;
6795
+ }
6796
+ const type = String(item.type || "").trim();
6797
+ const conditionFieldMetaByPath = buildApplyBlueprintReactionConditionFieldMetaByPath(
6798
+ targetMatch.block,
6799
+ targetMatch.context
6800
+ );
6801
+ _.castArray(item.rules || []).forEach((rule, ruleIndex) => {
6802
+ collectReactionFilterDateConditionErrors(
6803
+ (rule == null ? void 0 : rule.when) ?? (rule == null ? void 0 : rule.condition),
6804
+ `${path}.rules[${ruleIndex}].when`,
6805
+ errors,
6806
+ targetMatch.block,
6807
+ targetMatch.context,
6808
+ conditionFieldMetaByPath
6809
+ );
6810
+ if (type !== "setFieldLinkageRules") {
6811
+ return;
6812
+ }
6813
+ _.castArray((rule == null ? void 0 : rule.then) || (rule == null ? void 0 : rule.actions) || []).forEach((action, actionIndex) => {
6814
+ _.castArray((action == null ? void 0 : action.items) || []).forEach((assignItem, itemIndex) => {
6815
+ collectReactionFilterDateConditionErrors(
6816
+ (assignItem == null ? void 0 : assignItem.when) ?? (assignItem == null ? void 0 : assignItem.condition),
6817
+ `${path}.rules[${ruleIndex}].then[${actionIndex}].items[${itemIndex}].when`,
6818
+ errors,
6819
+ targetMatch.block,
6820
+ targetMatch.context,
6821
+ conditionFieldMetaByPath
6822
+ );
6823
+ });
6824
+ });
6825
+ });
6826
+ }
6827
+ function collectReactionFilterDateConditionErrors(filter, path, errors, block, context, fieldMetaByPath = {}) {
6828
+ if (!_.isPlainObject(filter)) {
6829
+ return;
6830
+ }
6831
+ if (Array.isArray(filter.items)) {
6832
+ filter.items.forEach(
6833
+ (item, index) => collectReactionFilterDateConditionErrors(
6834
+ item,
6835
+ `${path}.items[${index}]`,
6836
+ errors,
6837
+ block,
6838
+ context,
6839
+ fieldMetaByPath
6840
+ )
6841
+ );
6842
+ return;
6843
+ }
6844
+ if (!hasOwn(filter, "operator")) {
6845
+ return;
6846
+ }
6847
+ const conditionPath = normalizeReactionConditionPath(filter.path);
6848
+ const fieldContext = resolveReactionConditionFieldContext(conditionPath, block, context, fieldMetaByPath);
6849
+ collectDefaultFilterDateValueError(filter.operator, filter.value, `${path}.value`, errors, fieldContext, {
6850
+ allowContextPathValue: true
6851
+ });
6852
+ }
6853
+ function normalizeReactionConditionPath(rawPath) {
6854
+ const value = String(rawPath || "").trim();
6855
+ const templateMatch = /^\{\{\s*ctx(?:\.([^}]+?))?\s*\}\}$/.exec(value);
6856
+ const path = templateMatch ? String(templateMatch[1] || "").trim() : value.replace(/^ctx\./, "");
6857
+ return path.split(".").map((segment) => segment.trim()).filter(Boolean).join(".");
6858
+ }
6859
+ function buildApplyBlueprintReactionConditionFieldMetaByPath(block, context) {
6860
+ var _a, _b;
6861
+ const collection = getBlockCollection(block, context);
6862
+ const dataSourceKey = getBlockDataSourceKey(block, context);
6863
+ const userCollection = ((_a = context.getCollection) == null ? void 0 : _a.call(context, "main", "users")) || ((_b = context.getCollection) == null ? void 0 : _b.call(context, dataSourceKey, "users")) || null;
6864
+ const response = (0, import_context.buildFlowSurfaceContextResponse)({
6865
+ semantic: {
6866
+ collection,
6867
+ userCollection,
6868
+ recordCollection: collection,
6869
+ formValuesCollection: collection,
6870
+ itemCollections: collection ? [collection] : [],
6871
+ itemRootCollection: collection || void 0,
6872
+ popupLevels: context.isPopupSurface || context.popupHasCurrentRecord ? [
6873
+ {
6874
+ recordCollection: collection,
6875
+ sourceRecordCollection: collection
6876
+ }
6877
+ ] : []
6878
+ },
6879
+ maxDepth: 4
6880
+ });
6881
+ const fieldMetaByPath = collectAuthorableReactionContextFieldMetaByPath(response);
6882
+ addCollectionFieldMetaAliases(fieldMetaByPath, collection, ["collection", "record", "formValues"]);
6883
+ addCollectionFieldMetaAliases(fieldMetaByPath, collection, ["item"], {
6884
+ preserveExisting: true,
6885
+ reservedKeys: /* @__PURE__ */ new Set(["index", "length", "value", "parentItem"])
6886
+ });
6887
+ if (userCollection) {
6888
+ addCollectionFieldMetaAliases(fieldMetaByPath, userCollection, ["user"]);
6889
+ }
6890
+ return fieldMetaByPath;
6891
+ }
6892
+ function collectAuthorableReactionContextFieldMetaByPath(context) {
6893
+ const fieldMetaByPath = {};
6894
+ const visit = (prefix, info) => {
6895
+ if (!prefix || !info) {
6896
+ return;
6897
+ }
6898
+ if (isAuthorableReactionContextPath(prefix)) {
6899
+ fieldMetaByPath[prefix] = {
6900
+ ...info.type ? { type: info.type } : {},
6901
+ ...info.interface ? { interface: info.interface } : {}
6902
+ };
6903
+ }
6904
+ if (info.dynamicProperties) {
6905
+ visit(`${prefix}.*`, info.dynamicProperties);
6906
+ }
6907
+ Object.entries(info.properties || {}).forEach(([key, child]) => visit(`${prefix}.${key}`, child));
6908
+ };
6909
+ Object.entries((context == null ? void 0 : context.vars) || {}).forEach(([key, info]) => visit(key, info));
6910
+ return fieldMetaByPath;
6911
+ }
6912
+ function isAuthorableReactionContextPath(path) {
6913
+ const segments = String(path || "").split(".").filter(Boolean);
6914
+ const root = segments[0];
6915
+ if (!root) {
6916
+ return false;
6917
+ }
6918
+ if (AUTHORABLE_REACTION_SCALAR_CONTEXT_PATHS.has(root)) {
6919
+ return segments.length === 1;
6920
+ }
6921
+ return AUTHORABLE_REACTION_CONTEXT_ROOTS.has(root);
6922
+ }
6923
+ function addCollectionFieldMetaAliases(fieldMetaByPath, collection, roots, options = {}) {
6924
+ var _a;
6925
+ for (const field of (0, import_service_helpers.getCollectionFields)(collection)) {
6926
+ const fieldName = (0, import_service_helpers.getFieldName)(field);
6927
+ if (!fieldName) {
6928
+ continue;
6929
+ }
6930
+ const fieldMeta = {
6931
+ ...(0, import_service_helpers.getFieldType)(field) ? { type: (0, import_service_helpers.getFieldType)(field) } : {},
6932
+ ...(0, import_service_helpers.getFieldInterface)(field) ? { interface: (0, import_service_helpers.getFieldInterface)(field) } : {}
6933
+ };
6934
+ for (const root of roots) {
6935
+ if ((_a = options.reservedKeys) == null ? void 0 : _a.has(fieldName)) {
6936
+ continue;
6937
+ }
6938
+ const aliasPath = `${root}.${fieldName}`;
6939
+ if (options.preserveExisting && fieldMetaByPath[aliasPath]) {
6940
+ continue;
6941
+ }
6942
+ fieldMetaByPath[aliasPath] = {
6943
+ ...fieldMetaByPath[aliasPath],
6944
+ ...fieldMeta
6945
+ };
6946
+ }
6947
+ }
6948
+ }
6949
+ function resolveReactionConditionFieldContext(path, block, context, fieldMetaByPath) {
6950
+ const normalized = String(path || "").trim();
6951
+ const contextMeta = resolveReactionConditionFieldMeta(normalized, fieldMetaByPath);
6952
+ if (contextMeta) {
6953
+ return {
6954
+ fieldPath: normalized,
6955
+ fieldMeta: contextMeta
6956
+ };
6957
+ }
6958
+ const fieldPath = resolveReactionConditionFieldPath(normalized);
6959
+ return fieldPath ? resolveDefaultFilterDateConditionField(fieldPath, block, context) || void 0 : void 0;
6960
+ }
6961
+ function resolveReactionConditionFieldMeta(path, fieldMetaByPath) {
6962
+ if (fieldMetaByPath[path]) {
6963
+ return fieldMetaByPath[path];
6964
+ }
6965
+ const wildcardPath = Object.keys(fieldMetaByPath).filter((candidate) => candidate.endsWith(".*")).sort((a, b) => b.length - a.length).find((candidate) => {
6966
+ const prefix = candidate.slice(0, -2);
6967
+ return path.startsWith(`${prefix}.`) && path.length > prefix.length + 1;
6537
6968
  });
6969
+ return wildcardPath ? fieldMetaByPath[wildcardPath] : void 0;
6970
+ }
6971
+ function resolveReactionConditionFieldPath(path) {
6972
+ const normalized = String(path || "").trim();
6973
+ const prefixes = ["formValues.", "record.", "item.value.", "item.", "popup.record.", "collection.", "user."];
6974
+ const prefix = prefixes.find((candidate) => normalized.startsWith(candidate));
6975
+ return prefix ? normalized.slice(prefix.length) : "";
6538
6976
  }
6539
6977
  function collectFieldListErrors(fields, path, errors, localKeys, context, block) {
6540
6978
  if (!Array.isArray(fields)) {