@timeax/digital-service-engine 0.2.6 → 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.
@@ -1840,10 +1840,19 @@ function validateOrderKinds(v) {
1840
1840
  }
1841
1841
 
1842
1842
  // src/core/validate/steps/service-vs-input.ts
1843
+ function hasButtonTriggerMap(v, fieldId) {
1844
+ var _a, _b;
1845
+ const includes = (_a = v.props.includes_for_buttons) == null ? void 0 : _a[fieldId];
1846
+ const excludes = (_b = v.props.excludes_for_buttons) == null ? void 0 : _b[fieldId];
1847
+ return Array.isArray(includes) && includes.length > 0 || Array.isArray(excludes) && excludes.length > 0;
1848
+ }
1843
1849
  function validateServiceVsUserInput(v) {
1844
1850
  for (const f of v.fields) {
1845
1851
  const anySvc = hasAnyServiceOption(f);
1846
1852
  const hasName = !!(f.name && f.name.trim());
1853
+ const isButton2 = f.button === true;
1854
+ const hasFieldService = f.service_id !== void 0 && f.service_id !== null;
1855
+ const hasTriggerMap = isButton2 && hasButtonTriggerMap(v, f.id);
1847
1856
  if (f.type === "custom" && anySvc) {
1848
1857
  v.errors.push({
1849
1858
  code: "user_input_field_has_service_option",
@@ -1854,14 +1863,15 @@ function validateServiceVsUserInput(v) {
1854
1863
  });
1855
1864
  }
1856
1865
  if (!hasName) {
1857
- if (!anySvc) {
1858
- v.errors.push({
1859
- code: "service_field_missing_service_id",
1860
- severity: "error",
1861
- message: `Service-backed field "${f.id}" has no "name" and must provide at least one option with a service_id.`,
1862
- nodeId: f.id
1863
- });
1866
+ if (hasFieldService || anySvc || hasTriggerMap) {
1867
+ continue;
1864
1868
  }
1869
+ v.errors.push({
1870
+ code: "service_field_missing_service_id",
1871
+ severity: "error",
1872
+ 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.`,
1873
+ nodeId: f.id
1874
+ });
1865
1875
  } else {
1866
1876
  if (anySvc) {
1867
1877
  v.errors.push({