@nocobase/plugin-flow-engine 2.2.0-alpha.1 → 2.2.0-alpha.3

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 (66) 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.js +471 -47
  16. package/dist/server/flow-surfaces/blueprint/export-document.d.ts +50 -0
  17. package/dist/server/flow-surfaces/blueprint/export-document.js +2510 -0
  18. package/dist/server/flow-surfaces/builder.js +16 -1
  19. package/dist/server/flow-surfaces/catalog.js +13 -2
  20. package/dist/server/flow-surfaces/configure-options.js +5 -3
  21. package/dist/server/flow-surfaces/constants.d.ts +9 -2
  22. package/dist/server/flow-surfaces/constants.js +1 -0
  23. package/dist/server/flow-surfaces/contract-guard.js +24 -2
  24. package/dist/server/flow-surfaces/default-action-popup.d.ts +2 -0
  25. package/dist/server/flow-surfaces/default-action-popup.js +27 -13
  26. package/dist/server/flow-surfaces/filter-group.d.ts +19 -2
  27. package/dist/server/flow-surfaces/filter-group.js +232 -3
  28. package/dist/server/flow-surfaces/planning/compiler.d.ts +1 -0
  29. package/dist/server/flow-surfaces/planning/compiler.js +205 -82
  30. package/dist/server/flow-surfaces/planning/key-registry.d.ts +1 -1
  31. package/dist/server/flow-surfaces/planning/runtime.js +1 -0
  32. package/dist/server/flow-surfaces/planning/step-link.d.ts +1 -1
  33. package/dist/server/flow-surfaces/planning/step-link.js +22 -3
  34. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +0 -9
  35. package/dist/server/flow-surfaces/reaction/field-value.d.ts +9 -0
  36. package/dist/server/flow-surfaces/reaction/field-value.js +51 -2
  37. package/dist/server/flow-surfaces/reaction/linkage.d.ts +6 -1
  38. package/dist/server/flow-surfaces/reaction/linkage.js +18 -3
  39. package/dist/server/flow-surfaces/reaction/meta.js +19 -1
  40. package/dist/server/flow-surfaces/reaction/types.d.ts +19 -0
  41. package/dist/server/flow-surfaces/relation-backing-foreign-key.d.ts +10 -0
  42. package/dist/server/flow-surfaces/relation-backing-foreign-key.js +79 -0
  43. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +1 -0
  44. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +20 -0
  45. package/dist/server/flow-surfaces/runjs-authoring/rules.js +0 -2
  46. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +0 -1
  47. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +11 -19
  48. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +0 -12
  49. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +12 -2
  50. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +0 -14
  51. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +10 -8
  52. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +0 -14
  53. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +18 -73
  54. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  55. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +9 -53
  56. package/dist/server/flow-surfaces/service.d.ts +42 -0
  57. package/dist/server/flow-surfaces/service.js +741 -100
  58. package/dist/server/flow-surfaces/types.d.ts +2 -1
  59. package/dist/server/variables/registry.js +3 -0
  60. package/dist/swagger/flow-surfaces.d.ts +181 -0
  61. package/dist/swagger/flow-surfaces.examples.d.ts +11 -0
  62. package/dist/swagger/flow-surfaces.examples.js +11 -0
  63. package/dist/swagger/flow-surfaces.js +161 -4
  64. package/dist/swagger/index.d.ts +181 -0
  65. package/package.json +2 -2
  66. 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
  }
@@ -732,6 +744,7 @@ function withJsBlockRepairHint(details = {}) {
732
744
  inlineBlock: {
733
745
  type: "jsBlock",
734
746
  settings: {
747
+ showBlockCard: true,
735
748
  code: 'ctx.render("Replace this with the required rendered UI");'
736
749
  }
737
750
  },
@@ -745,7 +758,10 @@ function withJsBlockRepairHint(details = {}) {
745
758
  },
746
759
  block: {
747
760
  type: "jsBlock",
748
- script: "scriptKey"
761
+ script: "scriptKey",
762
+ settings: {
763
+ showBlockCard: true
764
+ }
749
765
  }
750
766
  }
751
767
  },
@@ -1177,47 +1193,69 @@ function collectBuilderChartAssetQueryErrors(query, path, context, errors) {
1177
1193
  errors,
1178
1194
  withChartRepairHint()
1179
1195
  );
1180
- collectChartQueryFilterOperatorErrors(query, `${path}.query`, errors);
1196
+ collectChartQueryFilterOperatorErrors(query, `${path}.query`, errors, context);
1181
1197
  collectBuilderChartAssetFieldErrors(query, path, context, errors);
1182
1198
  }
1183
- function collectChartQueryFilterOperatorErrors(query, path, errors) {
1199
+ const AUTHORABLE_REACTION_SCALAR_CONTEXT_PATHS = /* @__PURE__ */ new Set(["role", "locale", "token", "deviceType"]);
1200
+ const AUTHORABLE_REACTION_CONTEXT_ROOTS = /* @__PURE__ */ new Set([
1201
+ "user",
1202
+ "collection",
1203
+ "formValues",
1204
+ "record",
1205
+ "item",
1206
+ "popup",
1207
+ "urlSearchParams"
1208
+ ]);
1209
+ function collectChartQueryFilterOperatorErrors(query, path, errors, context) {
1184
1210
  if (!_.isPlainObject(query) || !hasOwn(query, "filter")) {
1185
1211
  return;
1186
1212
  }
1187
- collectChartFilterOperatorErrors(query.filter, `${path}.filter`, errors);
1213
+ collectChartFilterOperatorErrors(
1214
+ query.filter,
1215
+ `${path}.filter`,
1216
+ errors,
1217
+ createChartQueryDateConditionFieldResolver(query, context)
1218
+ );
1188
1219
  }
1189
- function collectChartFilterOperatorErrors(filter, path, errors) {
1220
+ function collectChartFilterOperatorErrors(filter, path, errors, resolveField) {
1190
1221
  if (_.isUndefined(filter) || _.isNull(filter) || !_.isPlainObject(filter)) {
1191
1222
  return;
1192
1223
  }
1193
1224
  if (Array.isArray(filter.items)) {
1194
- collectChartFilterGroupOperatorErrors(filter.items, `${path}.items`, errors);
1225
+ collectChartFilterGroupOperatorErrors(filter.items, `${path}.items`, errors, resolveField);
1195
1226
  return;
1196
1227
  }
1197
- collectBackendQueryFilterOperatorErrors(filter, path, errors);
1228
+ collectBackendQueryFilterOperatorErrors(filter, path, errors, resolveField);
1198
1229
  }
1199
- function collectChartFilterGroupOperatorErrors(items, path, errors) {
1230
+ function collectChartFilterGroupOperatorErrors(items, path, errors, resolveField) {
1200
1231
  items.forEach((item, index) => {
1201
1232
  const itemPath = `${path}[${index}]`;
1202
1233
  if (!_.isPlainObject(item)) {
1203
1234
  return;
1204
1235
  }
1205
1236
  if (Array.isArray(item.items)) {
1206
- collectChartFilterGroupOperatorErrors(item.items, `${itemPath}.items`, errors);
1237
+ collectChartFilterGroupOperatorErrors(item.items, `${itemPath}.items`, errors, resolveField);
1207
1238
  return;
1208
1239
  }
1209
1240
  if (hasOwn(item, "operator")) {
1210
1241
  collectChartFilterOperatorError(item.operator, `${itemPath}.operator`, errors);
1211
- collectChartFilterDateValueError(item.operator, item.value, `${itemPath}.value`, errors);
1242
+ const fieldPath = String(item.path || item.field || "").trim();
1243
+ collectChartFilterDateValueError(
1244
+ item.operator,
1245
+ item.value,
1246
+ `${itemPath}.value`,
1247
+ errors,
1248
+ fieldPath ? (resolveField == null ? void 0 : resolveField(fieldPath)) || { fieldPath } : void 0
1249
+ );
1212
1250
  }
1213
1251
  });
1214
1252
  }
1215
- function collectBackendQueryFilterOperatorErrors(filter, path, errors) {
1253
+ function collectBackendQueryFilterOperatorErrors(filter, path, errors, resolveField) {
1216
1254
  Object.entries(filter).forEach(([field, condition]) => {
1217
1255
  const fieldPath = `${path}.${field}`;
1218
1256
  if ((field === "$and" || field === "$or") && Array.isArray(condition)) {
1219
1257
  condition.forEach(
1220
- (operand, index) => collectChartFilterOperatorErrors(operand, `${fieldPath}[${index}]`, errors)
1258
+ (operand, index) => collectChartFilterOperatorErrors(operand, `${fieldPath}[${index}]`, errors, resolveField)
1221
1259
  );
1222
1260
  return;
1223
1261
  }
@@ -1226,11 +1264,17 @@ function collectBackendQueryFilterOperatorErrors(filter, path, errors) {
1226
1264
  }
1227
1265
  Object.keys(condition).forEach((operator) => {
1228
1266
  if (operator === "$and" || operator === "$or") {
1229
- collectChartFilterOperatorErrors({ [operator]: condition[operator] }, fieldPath, errors);
1267
+ collectChartFilterOperatorErrors({ [operator]: condition[operator] }, fieldPath, errors, resolveField);
1230
1268
  return;
1231
1269
  }
1232
1270
  collectChartFilterOperatorError(operator, `${fieldPath}.${operator}`, errors);
1233
- collectChartFilterDateValueError(operator, condition[operator], `${fieldPath}.${operator}`, errors);
1271
+ collectChartFilterDateValueError(
1272
+ operator,
1273
+ condition[operator],
1274
+ `${fieldPath}.${operator}`,
1275
+ errors,
1276
+ (resolveField == null ? void 0 : resolveField(field)) || { fieldPath: field }
1277
+ );
1234
1278
  });
1235
1279
  });
1236
1280
  }
@@ -1245,9 +1289,18 @@ function collectChartFilterOperatorError(operator, path, errors) {
1245
1289
  throw error;
1246
1290
  }
1247
1291
  }
1248
- function collectChartFilterDateValueError(operator, value, path, errors) {
1292
+ function collectChartFilterDateValueError(operator, value, path, errors, fieldContext) {
1293
+ const fieldMeta = getDateConditionFieldContextMeta(fieldContext);
1294
+ const normalizedOperator = typeof operator === "string" ? operator.trim() : "";
1295
+ if (!import_filter_group.FLOW_SURFACE_DATE_FILTER_OPERATORS.has(normalizedOperator) && !(0, import_filter_group.isFlowSurfaceDateLikeFieldMeta)(fieldMeta)) {
1296
+ return;
1297
+ }
1249
1298
  try {
1250
- (0, import_filter_group.normalizeFlowSurfaceStrictFilterDateValue)(operator, value, path);
1299
+ (0, import_filter_group.normalizeFlowSurfaceDateConditionValue)(operator, value, path, {
1300
+ fieldPath: fieldContext == null ? void 0 : fieldContext.fieldPath,
1301
+ fieldType: fieldMeta.type,
1302
+ fieldInterface: fieldMeta.interface
1303
+ });
1251
1304
  } catch (error) {
1252
1305
  if (error instanceof import_errors.FlowSurfaceBadRequestError) {
1253
1306
  pushChartBadRequestAuthoringError(errors, error, path);
@@ -1256,6 +1309,38 @@ function collectChartFilterDateValueError(operator, value, path, errors) {
1256
1309
  throw error;
1257
1310
  }
1258
1311
  }
1312
+ function createChartQueryDateConditionFieldResolver(query, context) {
1313
+ const resource = _.isPlainObject(query == null ? void 0 : query.resource) ? query.resource : null;
1314
+ const collectionName = String((resource == null ? void 0 : resource.collectionName) || "").trim();
1315
+ if (!collectionName || typeof (context == null ? void 0 : context.getCollection) !== "function") {
1316
+ return null;
1317
+ }
1318
+ const dataSourceKey = String((resource == null ? void 0 : resource.dataSourceKey) || "main").trim() || "main";
1319
+ const collection = context.getCollection(dataSourceKey, collectionName);
1320
+ if (!collection) {
1321
+ return null;
1322
+ }
1323
+ return (fieldPath) => {
1324
+ const normalizedFieldPath = (0, import_service_helpers.normalizeFieldPath)(fieldPath);
1325
+ const resolved = resolveDefaultFilterFieldPath(collection, normalizedFieldPath, dataSourceKey, context);
1326
+ return {
1327
+ fieldPath,
1328
+ field: resolved.field
1329
+ };
1330
+ };
1331
+ }
1332
+ function getDateConditionFieldMeta(field) {
1333
+ return {
1334
+ type: (0, import_service_helpers.getFieldType)(field),
1335
+ interface: (0, import_service_helpers.getFieldInterface)(field)
1336
+ };
1337
+ }
1338
+ function getDateConditionFieldContextMeta(fieldContext) {
1339
+ return {
1340
+ ...getDateConditionFieldMeta(fieldContext == null ? void 0 : fieldContext.field),
1341
+ ...(fieldContext == null ? void 0 : fieldContext.fieldMeta) || {}
1342
+ };
1343
+ }
1259
1344
  function normalizeChartAssetFieldPath(input) {
1260
1345
  if (Array.isArray(input)) {
1261
1346
  return input.map((item) => String(item || "").trim()).filter(Boolean).join(".");
@@ -3616,6 +3701,9 @@ function getGeneratedPopupBusinessFieldCandidates(collection) {
3616
3701
  if (!fieldName || !(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupBusinessField)(field)) {
3617
3702
  return [];
3618
3703
  }
3704
+ if ((0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(collection, field)) {
3705
+ return [];
3706
+ }
3619
3707
  return [
3620
3708
  {
3621
3709
  field,
@@ -3730,11 +3818,15 @@ function getGeneratedPopupDefaultFormFieldPaths(candidates, fieldGroups) {
3730
3818
  }
3731
3819
  function getGeneratedPopupRuntimeFieldCandidates(input) {
3732
3820
  const candidateContext = DEFAULT_ACTION_POPUP_FIELD_CONTEXT_BY_TYPE[input.actionType];
3821
+ const explicitDefaultFieldPaths = (0, import_default_action_popup.collectFlowSurfaceDefaultActionPopupFieldGroupFieldPaths)(input.fieldGroups);
3733
3822
  return (0, import_service_helpers.getCollectionFields)(input.collection).flatMap((field) => {
3734
3823
  const fieldName = (0, import_service_helpers.getFieldName)(field);
3735
3824
  if (!fieldName || !(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupBusinessField)(field)) {
3736
3825
  return [];
3737
3826
  }
3827
+ if ((0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(input.collection, field) && !explicitDefaultFieldPaths.has(fieldName)) {
3828
+ return [];
3829
+ }
3738
3830
  const fieldInterface = (0, import_service_helpers.getFieldInterface)(field);
3739
3831
  const registeredBinding = (0, import_field_binding_registry.resolveRegisteredFieldBinding)({
3740
3832
  containerUse: candidateContext.ownerUse,
@@ -3958,9 +4050,16 @@ function collectBlockErrors(block, path, errors, localKeys, context) {
3958
4050
  collectChartDisplayTitleErrors(block, blockType, path, errors);
3959
4051
  collectTreeTableExplicitFieldsErrors(block, blockType, path, errors, context);
3960
4052
  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
- });
4053
+ collectTableSettingsErrors(
4054
+ block,
4055
+ blockType,
4056
+ path,
4057
+ errors,
4058
+ {
4059
+ deferPublicDataScopeErrors: context.authoringActionName === "addBlocks"
4060
+ },
4061
+ context
4062
+ );
3964
4063
  collectGridCardSettingsErrors(block, blockType, path, errors);
3965
4064
  const descendantContext = getBlockDescendantValidationContext(block, context);
3966
4065
  collectActionListErrors(block.actions, `${path}.actions`, errors, block, descendantContext, "actions");
@@ -3999,7 +4098,7 @@ function collectJsBlockPublicContractErrors(block, path, errors, context) {
3999
4098
  pushAuthoringError(errors, {
4000
4099
  path: `${path}.${key}`,
4001
4100
  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`,
4101
+ 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
4102
  details: withJsBlockRepairHint({ key })
4004
4103
  });
4005
4104
  });
@@ -4010,7 +4109,7 @@ function collectJsBlockPublicContractErrors(block, path, errors, context) {
4010
4109
  pushAuthoringError(errors, {
4011
4110
  path: `${path}.${key}`,
4012
4111
  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`,
4112
+ 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
4113
  details: withJsBlockRepairHint({
4015
4114
  key
4016
4115
  })
@@ -4033,7 +4132,7 @@ function collectJsBlockPublicContractErrors(block, path, errors, context) {
4033
4132
  pushAuthoringError(errors, {
4034
4133
  path: `${path}.settings.${key}`,
4035
4134
  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`,
4135
+ 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
4136
  details: withJsBlockRepairHint({
4038
4137
  key,
4039
4138
  allowedKeys: Array.from(JS_BLOCK_ALLOWED_SETTINGS_KEYS)
@@ -4075,7 +4174,7 @@ function collectJsBlockConfigurePublicContractErrors(changes, path, errors) {
4075
4174
  pushAuthoringError(errors, {
4076
4175
  path: `${path}.${key}`,
4077
4176
  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`,
4177
+ 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
4178
  details: withJsBlockRepairHint({
4080
4179
  key
4081
4180
  })
@@ -4108,7 +4207,7 @@ function collectJsBlockConfigurePublicContractErrors(changes, path, errors) {
4108
4207
  pushAuthoringError(errors, {
4109
4208
  path: `${path}.settings`,
4110
4209
  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`,
4210
+ message: `flowSurfaces authoring ${path}.settings is not part of the public jsBlock configure contract; use ${path}.code, ${path}.version, and ${path}.showBlockCard`,
4112
4211
  details: withJsBlockRepairHint()
4113
4212
  });
4114
4213
  return;
@@ -4268,8 +4367,8 @@ async function collectConfigureErrors(values, errors, context) {
4268
4367
  collectCommentsBlockErrors(changesBlock, hostBlockType, "$.changes", errors, context);
4269
4368
  collectRecordHistoryBlockErrors(changesBlock, hostBlockType, "$.changes", errors, context);
4270
4369
  collectChartDisplayTitleErrors(changes, hostBlockType, "$.changes", errors);
4271
- collectChartConfigureFilterOperatorErrors(changes, hostBlockType, "$.changes", errors);
4272
- collectTableSettingsErrors(changes, hostBlockType, "$.changes", errors, { directSettings: true });
4370
+ collectChartConfigureFilterOperatorErrors(changes, hostBlockType, "$.changes", errors, context);
4371
+ collectTableSettingsErrors(changes, hostBlockType, "$.changes", errors, { directSettings: true }, context);
4273
4372
  collectGridCardSettingsErrors(changes, hostBlockType, "$.changes", errors, { directSettings: true });
4274
4373
  collectAssignValuesErrors(changes.assignValues, "$.changes.assignValues", errors, changesBlock, context);
4275
4374
  collectTriggerWorkflowsErrors(changes.triggerWorkflows, "$.changes.triggerWorkflows", errors);
@@ -4357,10 +4456,20 @@ function collectUnsupportedDefaultFilterOperatorError(operator, path, errors) {
4357
4456
  }
4358
4457
  });
4359
4458
  }
4360
- function collectDefaultFilterDateValueError(operator, value, path, errors) {
4459
+ function collectDefaultFilterDateValueError(operator, value, path, errors, fieldContext, options = {}) {
4361
4460
  var _a, _b, _c;
4461
+ const fieldMeta = getDateConditionFieldContextMeta(fieldContext);
4462
+ const normalizedOperator = typeof operator === "string" ? operator.trim() : "";
4463
+ if (!import_filter_group.FLOW_SURFACE_DATE_FILTER_OPERATORS.has(normalizedOperator) && !(0, import_filter_group.isFlowSurfaceDateLikeFieldMeta)(fieldMeta)) {
4464
+ return;
4465
+ }
4362
4466
  try {
4363
- (0, import_filter_group.normalizeFlowSurfaceStrictFilterDateValue)(operator, value, path);
4467
+ (0, import_filter_group.normalizeFlowSurfaceDateConditionValue)(operator, value, path, {
4468
+ fieldPath: fieldContext == null ? void 0 : fieldContext.fieldPath,
4469
+ fieldType: fieldMeta.type,
4470
+ fieldInterface: fieldMeta.interface,
4471
+ allowContextPathValue: options.allowContextPathValue
4472
+ });
4364
4473
  } catch (error) {
4365
4474
  if (!(error instanceof import_errors.FlowSurfaceBadRequestError)) {
4366
4475
  throw error;
@@ -5423,13 +5532,13 @@ function collectChartDisplayTitleErrors(block, blockType, blockPath, errors) {
5423
5532
  message: "Chart block settings do not support displayTitle in the current flowSurfaces runtime; keep settings.title and omit displayTitle."
5424
5533
  });
5425
5534
  }
5426
- function collectChartConfigureFilterOperatorErrors(changes, hostBlockType, path, errors) {
5535
+ function collectChartConfigureFilterOperatorErrors(changes, hostBlockType, path, errors, context) {
5427
5536
  if (hostBlockType !== "chart" || !_.isPlainObject(changes)) {
5428
5537
  return;
5429
5538
  }
5430
- collectChartQueryFilterOperatorErrors(changes.query, `${path}.query`, errors);
5539
+ collectChartQueryFilterOperatorErrors(changes.query, `${path}.query`, errors, context);
5431
5540
  if (_.isPlainObject(changes.configure)) {
5432
- collectChartQueryFilterOperatorErrors(changes.configure.query, `${path}.configure.query`, errors);
5541
+ collectChartQueryFilterOperatorErrors(changes.configure.query, `${path}.configure.query`, errors, context);
5433
5542
  }
5434
5543
  }
5435
5544
  function visitFilterItems(value, path, errors, block, context = {}) {
@@ -5446,7 +5555,13 @@ function visitFilterItems(value, path, errors, block, context = {}) {
5446
5555
  }
5447
5556
  if (typeof value.operator === "string") {
5448
5557
  collectUnsupportedDefaultFilterOperatorError(value.operator, `${path}.operator`, errors);
5449
- collectDefaultFilterDateValueError(value.operator, value.value, `${path}.value`, errors);
5558
+ collectDefaultFilterDateValueError(
5559
+ value.operator,
5560
+ value.value,
5561
+ `${path}.value`,
5562
+ errors,
5563
+ fieldRef ? resolveDefaultFilterDateConditionField(fieldRef.value, block, context) : void 0
5564
+ );
5450
5565
  }
5451
5566
  const filterItems = value.items;
5452
5567
  if (Array.isArray(filterItems)) {
@@ -5472,11 +5587,33 @@ function visitFilterItems(value, path, errors, block, context = {}) {
5472
5587
  if (_.isPlainObject(child)) {
5473
5588
  Object.entries(child).forEach(([operator, operatorValue]) => {
5474
5589
  collectUnsupportedDefaultFilterOperatorError(operator, `${path}.${key}.${operator}`, errors);
5475
- collectDefaultFilterDateValueError(operator, operatorValue, `${path}.${key}.${operator}`, errors);
5590
+ collectDefaultFilterDateValueError(
5591
+ operator,
5592
+ operatorValue,
5593
+ `${path}.${key}.${operator}`,
5594
+ errors,
5595
+ resolveDefaultFilterDateConditionField(key, block, context)
5596
+ );
5476
5597
  });
5477
5598
  }
5478
5599
  });
5479
5600
  }
5601
+ function resolveDefaultFilterDateConditionField(rawFieldPath, block, context) {
5602
+ const fieldPath = String(rawFieldPath || "").trim();
5603
+ if (!fieldPath || fieldPath.startsWith("$") || fieldPath.startsWith("{{")) {
5604
+ return null;
5605
+ }
5606
+ const collection = getBlockCollection(block, context);
5607
+ if (!collection) {
5608
+ return null;
5609
+ }
5610
+ const dataSourceKey = getBlockDataSourceKey(block, context);
5611
+ const resolved = resolveDefaultFilterFieldPath(collection, (0, import_service_helpers.normalizeFieldPath)(fieldPath), dataSourceKey, context);
5612
+ return {
5613
+ fieldPath,
5614
+ field: resolved.field
5615
+ };
5616
+ }
5480
5617
  function collectTreeConnectFieldsErrors(value, path, errors) {
5481
5618
  if (_.isUndefined(value)) {
5482
5619
  return [];
@@ -5825,7 +5962,7 @@ function getCollectionFilterTargetKey(collection) {
5825
5962
  function normalizeDataSourceKey(value) {
5826
5963
  return String(value || "main").trim() || "main";
5827
5964
  }
5828
- function collectTableSettingsErrors(block, blockType, blockPath, errors, options = {}) {
5965
+ function collectTableSettingsErrors(block, blockType, blockPath, errors, options = {}, context = {}) {
5829
5966
  if (blockType !== "table" || !_.isPlainObject(block)) {
5830
5967
  return;
5831
5968
  }
@@ -5836,6 +5973,9 @@ function collectTableSettingsErrors(block, blockType, blockPath, errors, options
5836
5973
  });
5837
5974
  const hasSettings = _.isPlainObject(block == null ? void 0 : block.settings);
5838
5975
  if (!hasSettings) {
5976
+ if (options.directSettings === true && !shouldDeferPublicDataScopeErrorsToBatchItem(blockPath, errors, options)) {
5977
+ collectPublicDataScopeErrors(block.dataScope, `${blockPath}.dataScope`, errors, block, context);
5978
+ }
5839
5979
  return;
5840
5980
  }
5841
5981
  const settings = block.settings;
@@ -5850,7 +5990,7 @@ function collectTableSettingsErrors(block, blockType, blockPath, errors, options
5850
5990
  pushTableSettingsUnsupportedError(errors, `${settingsPath}.${key}`, key);
5851
5991
  });
5852
5992
  if (!shouldDeferPublicDataScopeErrorsToBatchItem(blockPath, errors, options)) {
5853
- collectPublicDataScopeErrors(settings.dataScope, `${settingsPath}.dataScope`, errors);
5993
+ collectPublicDataScopeErrors(settings.dataScope, `${settingsPath}.dataScope`, errors, block, context);
5854
5994
  }
5855
5995
  }
5856
5996
  function pushTableSettingsUnsupportedError(errors, path, key) {
@@ -5865,7 +6005,7 @@ function pushTableSettingsUnsupportedError(errors, path, key) {
5865
6005
  }
5866
6006
  });
5867
6007
  }
5868
- function collectPublicDataScopeErrors(value, path, errors) {
6008
+ function collectPublicDataScopeErrors(value, path, errors, block, context) {
5869
6009
  if (_.isUndefined(value)) {
5870
6010
  return;
5871
6011
  }
@@ -5885,6 +6025,62 @@ function collectPublicDataScopeErrors(value, path, errors) {
5885
6025
  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
6026
  }
5887
6027
  });
6028
+ return;
6029
+ }
6030
+ collectPublicDataScopeFieldPathErrors(validationValue, path, errors, block, context);
6031
+ collectFilterGroupDateConditionErrors(validationValue, path, errors, block, context);
6032
+ }
6033
+ function collectPublicDataScopeFieldPathErrors(value, path, errors, block, context) {
6034
+ if (!_.isPlainObject(value)) {
6035
+ return;
6036
+ }
6037
+ if (hasOwn(value, "operator")) {
6038
+ collectPublicDataScopeFieldPathError(value.path, `${path}.path`, block, context, errors);
6039
+ }
6040
+ if (Array.isArray(value.items)) {
6041
+ value.items.forEach(
6042
+ (item, index) => collectPublicDataScopeFieldPathErrors(item, `${path}.items[${index}]`, errors, block, context)
6043
+ );
6044
+ }
6045
+ }
6046
+ function collectPublicDataScopeFieldPathError(rawFieldPath, path, block, context, errors) {
6047
+ const fieldPath = String(rawFieldPath || "").trim();
6048
+ if (!fieldPath || fieldPath.startsWith("$") || fieldPath.startsWith("{{")) {
6049
+ return;
6050
+ }
6051
+ const collection = getBlockCollection(block, context);
6052
+ if (!collection) {
6053
+ return;
6054
+ }
6055
+ const resolved = resolveDefaultFilterFieldPath(
6056
+ collection,
6057
+ (0, import_service_helpers.normalizeFieldPath)(fieldPath),
6058
+ getBlockDataSourceKey(block, context),
6059
+ context
6060
+ );
6061
+ if (!resolved.field) {
6062
+ pushAuthoringError(errors, {
6063
+ path,
6064
+ ruleId: "field-path-unknown",
6065
+ message: `flowSurfaces authoring ${path} references unknown field '${fieldPath}'`,
6066
+ details: {
6067
+ fieldPath,
6068
+ collection: (0, import_service_helpers.getCollectionName)(resolved.collection || collection),
6069
+ availableFields: (0, import_service_helpers.getCollectionFields)(resolved.collection || collection).map((field) => String((0, import_service_helpers.getFieldName)(field) || "").trim()).filter(Boolean)
6070
+ }
6071
+ });
6072
+ return;
6073
+ }
6074
+ if ((0, import_service_helpers.isAssociationField)(resolved.field)) {
6075
+ pushAuthoringError(errors, {
6076
+ path,
6077
+ ruleId: "defaultFilter-relation-field-unsupported",
6078
+ message: `flowSurfaces authoring ${path} cannot use relation field '${fieldPath}' itself; use a scalar subfield instead`,
6079
+ details: {
6080
+ fieldPath,
6081
+ fieldName: (0, import_service_helpers.getFieldName)(resolved.field)
6082
+ }
6083
+ });
5888
6084
  }
5889
6085
  }
5890
6086
  function shouldDeferPublicDataScopeErrorsToBatchItem(blockPath, errors, options) {
@@ -5906,6 +6102,28 @@ function normalizePublicDataScopeValueForValidation(value) {
5906
6102
  }
5907
6103
  return value;
5908
6104
  }
6105
+ function collectFilterGroupDateConditionErrors(value, path, errors, block, context) {
6106
+ if (!_.isPlainObject(value)) {
6107
+ return;
6108
+ }
6109
+ if (Array.isArray(value.items)) {
6110
+ value.items.forEach(
6111
+ (item, index) => collectFilterGroupDateConditionErrors(item, `${path}.items[${index}]`, errors, block, context)
6112
+ );
6113
+ return;
6114
+ }
6115
+ if (!hasOwn(value, "operator")) {
6116
+ return;
6117
+ }
6118
+ const fieldPath = String(value.path || value.field || "").trim();
6119
+ collectDefaultFilterDateValueError(
6120
+ value.operator,
6121
+ value.value,
6122
+ `${path}.value`,
6123
+ errors,
6124
+ fieldPath ? resolveDefaultFilterDateConditionField(fieldPath, block, context) : void 0
6125
+ );
6126
+ }
5909
6127
  function collectGridCardSettingsErrors(block, blockType, blockPath, errors, options = {}) {
5910
6128
  const hasSettings = _.isPlainObject(block == null ? void 0 : block.settings);
5911
6129
  if (!hasSettings && options.directSettings !== true) {
@@ -6033,11 +6251,12 @@ function buildAuthoringAIEmployeeActionIdentity(settings) {
6033
6251
  return stableSerializeAuthoringValue(normalizeAuthoringAIEmployeePublicSettingsForIdentity(settings));
6034
6252
  }
6035
6253
  function normalizeAuthoringAIEmployeePublicSettingsForIdentity(settings) {
6254
+ const workContext = Object.prototype.hasOwnProperty.call(settings, "workContext") ? normalizeAuthoringAIEmployeeWorkContextForIdentity(settings.workContext) : [{ type: "flow-model", target: "self" }];
6036
6255
  return {
6037
6256
  username: String(settings.username || "").trim(),
6038
6257
  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),
6258
+ workContext,
6259
+ tasks: normalizeAuthoringAIEmployeeTasksForIdentity(settings.tasks, workContext),
6041
6260
  style: {
6042
6261
  ...AUTHORING_AI_EMPLOYEE_DEFAULT_STYLE,
6043
6262
  ..._.isPlainObject(settings.style) ? _.pick(settings.style, AUTHORING_AI_EMPLOYEE_STYLE_PUBLIC_KEYS) : {}
@@ -6056,7 +6275,14 @@ function normalizeAuthoringAIEmployeeWorkContextForIdentity(value) {
6056
6275
  return output;
6057
6276
  });
6058
6277
  }
6059
- function normalizeAuthoringAIEmployeeTasksForIdentity(value) {
6278
+ function normalizeAuthoringAIEmployeeTaskWorkContextForIdentity(value, defaultWorkContext) {
6279
+ const normalized = normalizeAuthoringAIEmployeeWorkContextForIdentity(value);
6280
+ if (Array.isArray(defaultWorkContext) && !normalized.length) {
6281
+ return _.cloneDeep(defaultWorkContext);
6282
+ }
6283
+ return normalized;
6284
+ }
6285
+ function normalizeAuthoringAIEmployeeTasksForIdentity(value, defaultWorkContext) {
6060
6286
  return _.castArray(value || []).map((task) => {
6061
6287
  if (!_.isPlainObject(task)) {
6062
6288
  return task;
@@ -6064,10 +6290,11 @@ function normalizeAuthoringAIEmployeeTasksForIdentity(value) {
6064
6290
  const output = _.pick(task, AUTHORING_AI_EMPLOYEE_TASK_PUBLIC_SETTING_KEYS);
6065
6291
  if (_.isPlainObject(output.message)) {
6066
6292
  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);
6293
+ if (Object.prototype.hasOwnProperty.call(output.message, "workContext")) {
6294
+ output.message.workContext = normalizeAuthoringAIEmployeeTaskWorkContextForIdentity(
6295
+ output.message.workContext,
6296
+ defaultWorkContext
6297
+ );
6071
6298
  }
6072
6299
  }
6073
6300
  if (Object.prototype.hasOwnProperty.call(task, "prompt") && !Object.prototype.hasOwnProperty.call(output.message || {}, "user")) {
@@ -6076,6 +6303,13 @@ function normalizeAuthoringAIEmployeeTasksForIdentity(value) {
6076
6303
  user: task.prompt
6077
6304
  };
6078
6305
  }
6306
+ if (!_.isPlainObject(output.message) && Array.isArray(defaultWorkContext)) {
6307
+ output.message = {
6308
+ workContext: _.cloneDeep(defaultWorkContext)
6309
+ };
6310
+ } else if (_.isPlainObject(output.message) && !Object.prototype.hasOwnProperty.call(output.message, "workContext")) {
6311
+ output.message.workContext = _.cloneDeep(defaultWorkContext || []);
6312
+ }
6079
6313
  if (_.isPlainObject(output.model)) {
6080
6314
  output.model = _.pick(output.model, AUTHORING_AI_EMPLOYEE_TASK_MODEL_PUBLIC_KEYS);
6081
6315
  }
@@ -6516,7 +6750,7 @@ function collectNestedBlockErrors(blocks, path, errors, localKeys, context) {
6516
6750
  }
6517
6751
  blocks.forEach((block, index) => collectBlockErrors(block, `${path}[${index}]`, errors, localKeys, context));
6518
6752
  }
6519
- function collectReactionErrors(reaction, path, localKeys, errors) {
6753
+ function collectReactionErrors(reaction, path, localKeys, errors, options = {}) {
6520
6754
  const items = Array.isArray(reaction == null ? void 0 : reaction.items) ? reaction.items : [];
6521
6755
  items.forEach((item, index) => {
6522
6756
  const rawTarget = (item == null ? void 0 : item.target) ?? (item == null ? void 0 : item.targetKey) ?? (item == null ? void 0 : item.targetBlock);
@@ -6534,8 +6768,198 @@ function collectReactionErrors(reaction, path, localKeys, errors) {
6534
6768
  message: `flowSurfaces authoring ${path}.items[${index}].target references unknown local target '${target}'`
6535
6769
  });
6536
6770
  }
6771
+ collectReactionItemDateConditionErrors(item, `${path}.items[${index}]`, target, errors, options);
6772
+ });
6773
+ }
6774
+ function collectReactionItemDateConditionErrors(item, path, target, errors, options) {
6775
+ if (!_.isPlainObject(item) || !_.isPlainObject(options.values) || !options.context) {
6776
+ return;
6777
+ }
6778
+ const targetMatch = findApplyBlueprintReactionTargetBlock(options.values, target, options.context);
6779
+ if (!targetMatch) {
6780
+ return;
6781
+ }
6782
+ const type = String(item.type || "").trim();
6783
+ const conditionFieldMetaByPath = buildApplyBlueprintReactionConditionFieldMetaByPath(
6784
+ targetMatch.block,
6785
+ targetMatch.context
6786
+ );
6787
+ _.castArray(item.rules || []).forEach((rule, ruleIndex) => {
6788
+ collectReactionFilterDateConditionErrors(
6789
+ (rule == null ? void 0 : rule.when) ?? (rule == null ? void 0 : rule.condition),
6790
+ `${path}.rules[${ruleIndex}].when`,
6791
+ errors,
6792
+ targetMatch.block,
6793
+ targetMatch.context,
6794
+ conditionFieldMetaByPath
6795
+ );
6796
+ if (type !== "setFieldLinkageRules") {
6797
+ return;
6798
+ }
6799
+ _.castArray((rule == null ? void 0 : rule.then) || (rule == null ? void 0 : rule.actions) || []).forEach((action, actionIndex) => {
6800
+ _.castArray((action == null ? void 0 : action.items) || []).forEach((assignItem, itemIndex) => {
6801
+ collectReactionFilterDateConditionErrors(
6802
+ (assignItem == null ? void 0 : assignItem.when) ?? (assignItem == null ? void 0 : assignItem.condition),
6803
+ `${path}.rules[${ruleIndex}].then[${actionIndex}].items[${itemIndex}].when`,
6804
+ errors,
6805
+ targetMatch.block,
6806
+ targetMatch.context,
6807
+ conditionFieldMetaByPath
6808
+ );
6809
+ });
6810
+ });
6537
6811
  });
6538
6812
  }
6813
+ function collectReactionFilterDateConditionErrors(filter, path, errors, block, context, fieldMetaByPath = {}) {
6814
+ if (!_.isPlainObject(filter)) {
6815
+ return;
6816
+ }
6817
+ if (Array.isArray(filter.items)) {
6818
+ filter.items.forEach(
6819
+ (item, index) => collectReactionFilterDateConditionErrors(
6820
+ item,
6821
+ `${path}.items[${index}]`,
6822
+ errors,
6823
+ block,
6824
+ context,
6825
+ fieldMetaByPath
6826
+ )
6827
+ );
6828
+ return;
6829
+ }
6830
+ if (!hasOwn(filter, "operator")) {
6831
+ return;
6832
+ }
6833
+ const conditionPath = normalizeReactionConditionPath(filter.path);
6834
+ const fieldContext = resolveReactionConditionFieldContext(conditionPath, block, context, fieldMetaByPath);
6835
+ collectDefaultFilterDateValueError(filter.operator, filter.value, `${path}.value`, errors, fieldContext, {
6836
+ allowContextPathValue: true
6837
+ });
6838
+ }
6839
+ function normalizeReactionConditionPath(rawPath) {
6840
+ const value = String(rawPath || "").trim();
6841
+ const templateMatch = /^\{\{\s*ctx(?:\.([^}]+?))?\s*\}\}$/.exec(value);
6842
+ const path = templateMatch ? String(templateMatch[1] || "").trim() : value.replace(/^ctx\./, "");
6843
+ return path.split(".").map((segment) => segment.trim()).filter(Boolean).join(".");
6844
+ }
6845
+ function buildApplyBlueprintReactionConditionFieldMetaByPath(block, context) {
6846
+ var _a, _b;
6847
+ const collection = getBlockCollection(block, context);
6848
+ const dataSourceKey = getBlockDataSourceKey(block, context);
6849
+ 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;
6850
+ const response = (0, import_context.buildFlowSurfaceContextResponse)({
6851
+ semantic: {
6852
+ collection,
6853
+ userCollection,
6854
+ recordCollection: collection,
6855
+ formValuesCollection: collection,
6856
+ itemCollections: collection ? [collection] : [],
6857
+ itemRootCollection: collection || void 0,
6858
+ popupLevels: context.isPopupSurface || context.popupHasCurrentRecord ? [
6859
+ {
6860
+ recordCollection: collection,
6861
+ sourceRecordCollection: collection
6862
+ }
6863
+ ] : []
6864
+ },
6865
+ maxDepth: 4
6866
+ });
6867
+ const fieldMetaByPath = collectAuthorableReactionContextFieldMetaByPath(response);
6868
+ addCollectionFieldMetaAliases(fieldMetaByPath, collection, ["collection", "record", "formValues"]);
6869
+ addCollectionFieldMetaAliases(fieldMetaByPath, collection, ["item"], {
6870
+ preserveExisting: true,
6871
+ reservedKeys: /* @__PURE__ */ new Set(["index", "length", "value", "parentItem"])
6872
+ });
6873
+ if (userCollection) {
6874
+ addCollectionFieldMetaAliases(fieldMetaByPath, userCollection, ["user"]);
6875
+ }
6876
+ return fieldMetaByPath;
6877
+ }
6878
+ function collectAuthorableReactionContextFieldMetaByPath(context) {
6879
+ const fieldMetaByPath = {};
6880
+ const visit = (prefix, info) => {
6881
+ if (!prefix || !info) {
6882
+ return;
6883
+ }
6884
+ if (isAuthorableReactionContextPath(prefix)) {
6885
+ fieldMetaByPath[prefix] = {
6886
+ ...info.type ? { type: info.type } : {},
6887
+ ...info.interface ? { interface: info.interface } : {}
6888
+ };
6889
+ }
6890
+ if (info.dynamicProperties) {
6891
+ visit(`${prefix}.*`, info.dynamicProperties);
6892
+ }
6893
+ Object.entries(info.properties || {}).forEach(([key, child]) => visit(`${prefix}.${key}`, child));
6894
+ };
6895
+ Object.entries((context == null ? void 0 : context.vars) || {}).forEach(([key, info]) => visit(key, info));
6896
+ return fieldMetaByPath;
6897
+ }
6898
+ function isAuthorableReactionContextPath(path) {
6899
+ const segments = String(path || "").split(".").filter(Boolean);
6900
+ const root = segments[0];
6901
+ if (!root) {
6902
+ return false;
6903
+ }
6904
+ if (AUTHORABLE_REACTION_SCALAR_CONTEXT_PATHS.has(root)) {
6905
+ return segments.length === 1;
6906
+ }
6907
+ return AUTHORABLE_REACTION_CONTEXT_ROOTS.has(root);
6908
+ }
6909
+ function addCollectionFieldMetaAliases(fieldMetaByPath, collection, roots, options = {}) {
6910
+ var _a;
6911
+ for (const field of (0, import_service_helpers.getCollectionFields)(collection)) {
6912
+ const fieldName = (0, import_service_helpers.getFieldName)(field);
6913
+ if (!fieldName) {
6914
+ continue;
6915
+ }
6916
+ const fieldMeta = {
6917
+ ...(0, import_service_helpers.getFieldType)(field) ? { type: (0, import_service_helpers.getFieldType)(field) } : {},
6918
+ ...(0, import_service_helpers.getFieldInterface)(field) ? { interface: (0, import_service_helpers.getFieldInterface)(field) } : {}
6919
+ };
6920
+ for (const root of roots) {
6921
+ if ((_a = options.reservedKeys) == null ? void 0 : _a.has(fieldName)) {
6922
+ continue;
6923
+ }
6924
+ const aliasPath = `${root}.${fieldName}`;
6925
+ if (options.preserveExisting && fieldMetaByPath[aliasPath]) {
6926
+ continue;
6927
+ }
6928
+ fieldMetaByPath[aliasPath] = {
6929
+ ...fieldMetaByPath[aliasPath],
6930
+ ...fieldMeta
6931
+ };
6932
+ }
6933
+ }
6934
+ }
6935
+ function resolveReactionConditionFieldContext(path, block, context, fieldMetaByPath) {
6936
+ const normalized = String(path || "").trim();
6937
+ const contextMeta = resolveReactionConditionFieldMeta(normalized, fieldMetaByPath);
6938
+ if (contextMeta) {
6939
+ return {
6940
+ fieldPath: normalized,
6941
+ fieldMeta: contextMeta
6942
+ };
6943
+ }
6944
+ const fieldPath = resolveReactionConditionFieldPath(normalized);
6945
+ return fieldPath ? resolveDefaultFilterDateConditionField(fieldPath, block, context) || void 0 : void 0;
6946
+ }
6947
+ function resolveReactionConditionFieldMeta(path, fieldMetaByPath) {
6948
+ if (fieldMetaByPath[path]) {
6949
+ return fieldMetaByPath[path];
6950
+ }
6951
+ const wildcardPath = Object.keys(fieldMetaByPath).filter((candidate) => candidate.endsWith(".*")).sort((a, b) => b.length - a.length).find((candidate) => {
6952
+ const prefix = candidate.slice(0, -2);
6953
+ return path.startsWith(`${prefix}.`) && path.length > prefix.length + 1;
6954
+ });
6955
+ return wildcardPath ? fieldMetaByPath[wildcardPath] : void 0;
6956
+ }
6957
+ function resolveReactionConditionFieldPath(path) {
6958
+ const normalized = String(path || "").trim();
6959
+ const prefixes = ["formValues.", "record.", "item.value.", "item.", "popup.record.", "collection.", "user."];
6960
+ const prefix = prefixes.find((candidate) => normalized.startsWith(candidate));
6961
+ return prefix ? normalized.slice(prefix.length) : "";
6962
+ }
6539
6963
  function collectFieldListErrors(fields, path, errors, localKeys, context, block) {
6540
6964
  if (!Array.isArray(fields)) {
6541
6965
  return;