@timeax/digital-service-engine 0.2.5 → 0.2.7

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.
@@ -1227,10 +1227,19 @@ function validateOrderKinds(v) {
1227
1227
  }
1228
1228
 
1229
1229
  // src/core/validate/steps/service-vs-input.ts
1230
+ function hasButtonTriggerMap(v, fieldId) {
1231
+ var _a, _b;
1232
+ const includes = (_a = v.props.includes_for_buttons) == null ? void 0 : _a[fieldId];
1233
+ const excludes = (_b = v.props.excludes_for_buttons) == null ? void 0 : _b[fieldId];
1234
+ return Array.isArray(includes) && includes.length > 0 || Array.isArray(excludes) && excludes.length > 0;
1235
+ }
1230
1236
  function validateServiceVsUserInput(v) {
1231
1237
  for (const f of v.fields) {
1232
1238
  const anySvc = hasAnyServiceOption(f);
1233
1239
  const hasName = !!(f.name && f.name.trim());
1240
+ const isButton2 = f.button === true;
1241
+ const hasFieldService = f.service_id !== void 0 && f.service_id !== null;
1242
+ const hasTriggerMap = isButton2 && hasButtonTriggerMap(v, f.id);
1234
1243
  if (f.type === "custom" && anySvc) {
1235
1244
  v.errors.push({
1236
1245
  code: "user_input_field_has_service_option",
@@ -1241,14 +1250,15 @@ function validateServiceVsUserInput(v) {
1241
1250
  });
1242
1251
  }
1243
1252
  if (!hasName) {
1244
- if (!anySvc) {
1245
- v.errors.push({
1246
- code: "service_field_missing_service_id",
1247
- severity: "error",
1248
- message: `Service-backed field "${f.id}" has no "name" and must provide at least one option with a service_id.`,
1249
- nodeId: f.id
1250
- });
1253
+ if (hasFieldService || anySvc || hasTriggerMap) {
1254
+ continue;
1251
1255
  }
1256
+ v.errors.push({
1257
+ code: "service_field_missing_service_id",
1258
+ severity: "error",
1259
+ message: isButton2 ? `Button field "${f.id}" has no "name", no "service_id", and no includes/excludes trigger map. Add a name, attach a service_id, or configure includes_for_buttons/excludes_for_buttons.` : `Service-backed field "${f.id}" has no "name" and must provide at least one option with a service_id.`,
1260
+ nodeId: f.id
1261
+ });
1252
1262
  } else {
1253
1263
  if (anySvc) {
1254
1264
  v.errors.push({
@@ -3394,7 +3404,7 @@ function createNodeIndex(builder) {
3394
3404
  for (const fieldId of visible) {
3395
3405
  const node = getField(fieldId);
3396
3406
  if (!node) continue;
3397
- const explicit = includes.has(fieldId) || isFieldBoundDirectToTag(fieldId, tagId);
3407
+ const explicit = includes.has(fieldId);
3398
3408
  results.push(explicit ? node : { ...node, isInherited: true });
3399
3409
  }
3400
3410
  return Object.freeze(results);