@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.
@@ -1904,10 +1904,19 @@ function validateOrderKinds(v) {
1904
1904
  }
1905
1905
 
1906
1906
  // src/core/validate/steps/service-vs-input.ts
1907
+ function hasButtonTriggerMap(v, fieldId) {
1908
+ var _a, _b;
1909
+ const includes = (_a = v.props.includes_for_buttons) == null ? void 0 : _a[fieldId];
1910
+ const excludes = (_b = v.props.excludes_for_buttons) == null ? void 0 : _b[fieldId];
1911
+ return Array.isArray(includes) && includes.length > 0 || Array.isArray(excludes) && excludes.length > 0;
1912
+ }
1907
1913
  function validateServiceVsUserInput(v) {
1908
1914
  for (const f of v.fields) {
1909
1915
  const anySvc = hasAnyServiceOption(f);
1910
1916
  const hasName = !!(f.name && f.name.trim());
1917
+ const isButton2 = f.button === true;
1918
+ const hasFieldService = f.service_id !== void 0 && f.service_id !== null;
1919
+ const hasTriggerMap = isButton2 && hasButtonTriggerMap(v, f.id);
1911
1920
  if (f.type === "custom" && anySvc) {
1912
1921
  v.errors.push({
1913
1922
  code: "user_input_field_has_service_option",
@@ -1918,14 +1927,15 @@ function validateServiceVsUserInput(v) {
1918
1927
  });
1919
1928
  }
1920
1929
  if (!hasName) {
1921
- if (!anySvc) {
1922
- v.errors.push({
1923
- code: "service_field_missing_service_id",
1924
- severity: "error",
1925
- message: `Service-backed field "${f.id}" has no "name" and must provide at least one option with a service_id.`,
1926
- nodeId: f.id
1927
- });
1930
+ if (hasFieldService || anySvc || hasTriggerMap) {
1931
+ continue;
1928
1932
  }
1933
+ v.errors.push({
1934
+ code: "service_field_missing_service_id",
1935
+ severity: "error",
1936
+ 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.`,
1937
+ nodeId: f.id
1938
+ });
1929
1939
  } else {
1930
1940
  if (anySvc) {
1931
1941
  v.errors.push({