@timeax/digital-service-engine 0.3.5 → 0.3.6

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.
@@ -187,7 +187,7 @@ type NodeRef$1 = {
187
187
  };
188
188
  type NodeMap = Map<string, NodeRef$1>;
189
189
 
190
- type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
190
+ type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "bad_option_effect_key" | "bad_option_effect_target" | "bad_option_effect_option" | "option_include_exclude_conflict" | "visibility_dependency_cycle" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
191
191
  type ValidationError = {
192
192
  code: ValidationCode;
193
193
  message: string;
@@ -463,6 +463,22 @@ type FieldOption = {
463
463
  service_id?: ServiceIdRef;
464
464
  pricing_role?: PricingRole;
465
465
  meta?: Record<string, unknown> & UtilityMark & WithQuantityDefault;
466
+ children?: FieldOption[];
467
+ };
468
+ type OptionEffectForButton = {
469
+ /**
470
+ * If true, selecting this button/option may force the target field visible.
471
+ * If false/missing, the option filter only applies when the target field is already visible.
472
+ */
473
+ forceVisible?: boolean;
474
+ /**
475
+ * If present, only these option ids remain visible.
476
+ */
477
+ include?: string[];
478
+ /**
479
+ * Removed after include is applied.
480
+ */
481
+ exclude?: string[];
466
482
  };
467
483
  type Field = BaseFieldUI & {
468
484
  id: string;
@@ -516,6 +532,7 @@ type ServiceProps = {
516
532
  fields: Field[];
517
533
  includes_for_buttons?: Record<string, string[]>;
518
534
  excludes_for_buttons?: Record<string, string[]>;
535
+ option_effects_for_buttons?: Record<string, Record<string, OptionEffectForButton>>;
519
536
  schema_version?: string;
520
537
  fallbacks?: ServiceFallback;
521
538
  name?: string;
@@ -611,6 +628,12 @@ type CommentThread = {
611
628
  _sync?: "pending" | "synced" | "error";
612
629
  };
613
630
 
631
+ type ResolvedVisibility = {
632
+ fieldIds: string[];
633
+ optionsByFieldId: Record<string, string[]>;
634
+ forcedFieldIds: string[];
635
+ };
636
+
614
637
  /** Options you can set on the builder (used for validation/visibility) */
615
638
  type BuilderOptions = Omit<ValidatorOptions, "serviceMap"> & {
616
639
  serviceMap?: DgpServiceMap;
@@ -636,6 +659,8 @@ interface Builder {
636
659
  * NOTE: keys are “button ids”: either option.id or field.id for option-less buttons.
637
660
  */
638
661
  visibleFields(tagId: string, selectedOptionKeys?: string[]): string[];
662
+ /** Compute field ids plus option visibility under a tag. */
663
+ resolveVisibility(tagId: string, selectedOptionKeys?: string[]): ResolvedVisibility;
639
664
  /** Update builder options (validator context etc.) */
640
665
  setOptions(patch: Partial<BuilderOptions>): void;
641
666
  /** Access the current props (already normalised) */
@@ -716,6 +741,8 @@ type VisibleGroup = {
716
741
  tag?: Tag;
717
742
  fields: Field[];
718
743
  fieldIds: string[];
744
+ optionsByFieldId?: Record<string, string[]>;
745
+ forcedFieldIds?: string[];
719
746
  parentTags?: Tag[];
720
747
  childrenTags?: Tag[];
721
748
  /** In order of selection: tag base (unless overridden) then selected options */
@@ -765,11 +792,10 @@ declare class Selection {
765
792
  * What counts as a "button selection" (trigger key):
766
793
  * - field key where the field has button === true (e.g. "f:dripfeed")
767
794
  * - option key (e.g. "o:fast")
768
- * - composite key "fieldId::optionId" (e.g. "f:speed::o:fast")
769
795
  *
770
796
  * Grouping:
771
797
  * - button-field trigger groups under its own fieldId
772
- * - option/composite groups under the option's owning fieldId (from nodeMap)
798
+ * - option trigger groups under the option's owning fieldId (from nodeMap)
773
799
  *
774
800
  * Deterministic:
775
801
  * - preserves selection insertion order
@@ -780,7 +806,6 @@ declare class Selection {
780
806
  * Returns only selection keys that are valid "trigger buttons":
781
807
  * - field keys where field.button === true
782
808
  * - option keys
783
- * - composite keys "fieldId::optionId" (validated by optionId)
784
809
  * Excludes tags and non-button fields.
785
810
  */
786
811
  selectedButtons(): string[];
@@ -790,6 +815,7 @@ declare class Selection {
790
815
  private computeGroupForTag;
791
816
  private addServiceByRole;
792
817
  private findOptionById;
818
+ private isSelectedOptionVisible;
793
819
  }
794
820
 
795
821
  type CatalogId = string;
@@ -1531,11 +1557,18 @@ type Adapter = {
1531
1557
  getInputPropsFromField?: (props: AdapterCtx) => any;
1532
1558
  toValue?: (value: any) => any;
1533
1559
  };
1560
+ type InputChildOptionCapability = {
1561
+ supported?: boolean;
1562
+ autoCreate?: boolean;
1563
+ defaultLabel?: string;
1564
+ defaultValue?: string | number;
1565
+ };
1534
1566
  type InputOptionCapability = {
1535
1567
  supported?: boolean;
1536
1568
  autoCreate?: boolean;
1537
1569
  defaultLabel?: string;
1538
1570
  defaultValue?: string | number;
1571
+ children?: InputChildOptionCapability;
1539
1572
  };
1540
1573
  type InputMultiCapability = {
1541
1574
  supported?: boolean;
@@ -1679,6 +1712,14 @@ declare class Editor {
1679
1712
  clearFieldQuantityRule(id: string): void;
1680
1713
  include(receiverId: string, idOrIds: string | string[]): void;
1681
1714
  exclude(receiverId: string, idOrIds: string | string[]): void;
1715
+ setOptionEffect(triggerId: string, targetFieldId: string, effect: OptionEffectForButton | undefined | null): void;
1716
+ patchOptionEffect(triggerId: string, targetFieldId: string, patch: OptionEffectForButton): void;
1717
+ clearOptionEffect(triggerId: string, targetFieldId: string): void;
1718
+ clearOptionEffectsForTrigger(triggerId: string): void;
1719
+ clearOptionEffectsForTarget(targetFieldId: string): void;
1720
+ addOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
1721
+ removeOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
1722
+ setOptionEffectForceVisible(triggerId: string, targetFieldId: string, forceVisible: boolean | undefined): void;
1682
1723
  connect(kind: WireKind, fromId: string, toId: string): void;
1683
1724
  disconnect(kind: WireKind, fromId: string, toId: string): void;
1684
1725
  setConstraint(tagId: string, flag: string, value: boolean | undefined): void;
@@ -2039,6 +2080,8 @@ type UseOrderFlowReturn = {
2039
2080
  raw: ServiceProps;
2040
2081
  /** visibility is Selection-only */
2041
2082
  visibleGroup: VisibleGroup | null;
2083
+ visibleOptionsByFieldId: Record<string, string[]>;
2084
+ forcedFieldIds: string[];
2042
2085
  /**
2043
2086
  * Values are from form-palette (values()) and are already "visible-only"
2044
2087
  * because your UI mounts only visible fields.
@@ -2297,4 +2340,4 @@ type Props = {
2297
2340
  };
2298
2341
  declare function FallbackAddRegistrationDialog({ open, onClose, onSelect, }: Props): react_jsx_runtime.JSX.Element | null;
2299
2342
 
2300
- export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputDescriptor, type InputKind, type InputMultiCapability, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };
2343
+ export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputChildOptionCapability, type InputDescriptor, type InputKind, type InputMultiCapability, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };
@@ -187,7 +187,7 @@ type NodeRef$1 = {
187
187
  };
188
188
  type NodeMap = Map<string, NodeRef$1>;
189
189
 
190
- type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "option_include_exclude_conflict" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
190
+ type ValidationCode = "root_missing" | "cycle_in_tags" | "bad_bind_reference" | "duplicate_id" | "duplicate_tag_label" | "duplicate_field_name" | "label_missing" | "duplicate_visible_label" | "bad_option_key" | "bad_option_effect_key" | "bad_option_effect_target" | "bad_option_effect_option" | "option_include_exclude_conflict" | "visibility_dependency_cycle" | "service_field_missing_service_id" | "user_input_field_has_service_option" | "rate_mismatch_across_base" | "rate_coherence_violation" | "utility_without_base" | "unsupported_constraint" | "constraint_contradiction" | "custom_component_missing" | "policy_violation" | "field_unbound" | "constraint_overridden" | "unsupported_constraint_option" | "custom_component_unresolvable" | "quantity_multiple_markers" | "utility_with_service_id" | "utility_missing_rate" | "utility_invalid_mode" | "fallback_bad_node" | "fallback_unknown_service" | "fallback_cycle" | "fallback_no_primary" | "fallback_rate_violation" | "fallback_constraint_mismatch" | "fallback_no_tag_context" | "field_validation_invalid_rule" | "field_validation_invalid_op" | "field_validation_eval_missing_code" | "field_validation_between_missing_bounds" | "field_validation_match_missing_pattern" | "multiple_order_kinds_selected";
191
191
  type ValidationError = {
192
192
  code: ValidationCode;
193
193
  message: string;
@@ -463,6 +463,22 @@ type FieldOption = {
463
463
  service_id?: ServiceIdRef;
464
464
  pricing_role?: PricingRole;
465
465
  meta?: Record<string, unknown> & UtilityMark & WithQuantityDefault;
466
+ children?: FieldOption[];
467
+ };
468
+ type OptionEffectForButton = {
469
+ /**
470
+ * If true, selecting this button/option may force the target field visible.
471
+ * If false/missing, the option filter only applies when the target field is already visible.
472
+ */
473
+ forceVisible?: boolean;
474
+ /**
475
+ * If present, only these option ids remain visible.
476
+ */
477
+ include?: string[];
478
+ /**
479
+ * Removed after include is applied.
480
+ */
481
+ exclude?: string[];
466
482
  };
467
483
  type Field = BaseFieldUI & {
468
484
  id: string;
@@ -516,6 +532,7 @@ type ServiceProps = {
516
532
  fields: Field[];
517
533
  includes_for_buttons?: Record<string, string[]>;
518
534
  excludes_for_buttons?: Record<string, string[]>;
535
+ option_effects_for_buttons?: Record<string, Record<string, OptionEffectForButton>>;
519
536
  schema_version?: string;
520
537
  fallbacks?: ServiceFallback;
521
538
  name?: string;
@@ -611,6 +628,12 @@ type CommentThread = {
611
628
  _sync?: "pending" | "synced" | "error";
612
629
  };
613
630
 
631
+ type ResolvedVisibility = {
632
+ fieldIds: string[];
633
+ optionsByFieldId: Record<string, string[]>;
634
+ forcedFieldIds: string[];
635
+ };
636
+
614
637
  /** Options you can set on the builder (used for validation/visibility) */
615
638
  type BuilderOptions = Omit<ValidatorOptions, "serviceMap"> & {
616
639
  serviceMap?: DgpServiceMap;
@@ -636,6 +659,8 @@ interface Builder {
636
659
  * NOTE: keys are “button ids”: either option.id or field.id for option-less buttons.
637
660
  */
638
661
  visibleFields(tagId: string, selectedOptionKeys?: string[]): string[];
662
+ /** Compute field ids plus option visibility under a tag. */
663
+ resolveVisibility(tagId: string, selectedOptionKeys?: string[]): ResolvedVisibility;
639
664
  /** Update builder options (validator context etc.) */
640
665
  setOptions(patch: Partial<BuilderOptions>): void;
641
666
  /** Access the current props (already normalised) */
@@ -716,6 +741,8 @@ type VisibleGroup = {
716
741
  tag?: Tag;
717
742
  fields: Field[];
718
743
  fieldIds: string[];
744
+ optionsByFieldId?: Record<string, string[]>;
745
+ forcedFieldIds?: string[];
719
746
  parentTags?: Tag[];
720
747
  childrenTags?: Tag[];
721
748
  /** In order of selection: tag base (unless overridden) then selected options */
@@ -765,11 +792,10 @@ declare class Selection {
765
792
  * What counts as a "button selection" (trigger key):
766
793
  * - field key where the field has button === true (e.g. "f:dripfeed")
767
794
  * - option key (e.g. "o:fast")
768
- * - composite key "fieldId::optionId" (e.g. "f:speed::o:fast")
769
795
  *
770
796
  * Grouping:
771
797
  * - button-field trigger groups under its own fieldId
772
- * - option/composite groups under the option's owning fieldId (from nodeMap)
798
+ * - option trigger groups under the option's owning fieldId (from nodeMap)
773
799
  *
774
800
  * Deterministic:
775
801
  * - preserves selection insertion order
@@ -780,7 +806,6 @@ declare class Selection {
780
806
  * Returns only selection keys that are valid "trigger buttons":
781
807
  * - field keys where field.button === true
782
808
  * - option keys
783
- * - composite keys "fieldId::optionId" (validated by optionId)
784
809
  * Excludes tags and non-button fields.
785
810
  */
786
811
  selectedButtons(): string[];
@@ -790,6 +815,7 @@ declare class Selection {
790
815
  private computeGroupForTag;
791
816
  private addServiceByRole;
792
817
  private findOptionById;
818
+ private isSelectedOptionVisible;
793
819
  }
794
820
 
795
821
  type CatalogId = string;
@@ -1531,11 +1557,18 @@ type Adapter = {
1531
1557
  getInputPropsFromField?: (props: AdapterCtx) => any;
1532
1558
  toValue?: (value: any) => any;
1533
1559
  };
1560
+ type InputChildOptionCapability = {
1561
+ supported?: boolean;
1562
+ autoCreate?: boolean;
1563
+ defaultLabel?: string;
1564
+ defaultValue?: string | number;
1565
+ };
1534
1566
  type InputOptionCapability = {
1535
1567
  supported?: boolean;
1536
1568
  autoCreate?: boolean;
1537
1569
  defaultLabel?: string;
1538
1570
  defaultValue?: string | number;
1571
+ children?: InputChildOptionCapability;
1539
1572
  };
1540
1573
  type InputMultiCapability = {
1541
1574
  supported?: boolean;
@@ -1679,6 +1712,14 @@ declare class Editor {
1679
1712
  clearFieldQuantityRule(id: string): void;
1680
1713
  include(receiverId: string, idOrIds: string | string[]): void;
1681
1714
  exclude(receiverId: string, idOrIds: string | string[]): void;
1715
+ setOptionEffect(triggerId: string, targetFieldId: string, effect: OptionEffectForButton | undefined | null): void;
1716
+ patchOptionEffect(triggerId: string, targetFieldId: string, patch: OptionEffectForButton): void;
1717
+ clearOptionEffect(triggerId: string, targetFieldId: string): void;
1718
+ clearOptionEffectsForTrigger(triggerId: string): void;
1719
+ clearOptionEffectsForTarget(targetFieldId: string): void;
1720
+ addOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
1721
+ removeOptionEffectOptions(triggerId: string, targetFieldId: string, kind: "include" | "exclude", optionIds: readonly string[]): void;
1722
+ setOptionEffectForceVisible(triggerId: string, targetFieldId: string, forceVisible: boolean | undefined): void;
1682
1723
  connect(kind: WireKind, fromId: string, toId: string): void;
1683
1724
  disconnect(kind: WireKind, fromId: string, toId: string): void;
1684
1725
  setConstraint(tagId: string, flag: string, value: boolean | undefined): void;
@@ -2039,6 +2080,8 @@ type UseOrderFlowReturn = {
2039
2080
  raw: ServiceProps;
2040
2081
  /** visibility is Selection-only */
2041
2082
  visibleGroup: VisibleGroup | null;
2083
+ visibleOptionsByFieldId: Record<string, string[]>;
2084
+ forcedFieldIds: string[];
2042
2085
  /**
2043
2086
  * Values are from form-palette (values()) and are already "visible-only"
2044
2087
  * because your UI mounts only visible fields.
@@ -2297,4 +2340,4 @@ type Props = {
2297
2340
  };
2298
2341
  declare function FallbackAddRegistrationDialog({ open, onClose, onSelect, }: Props): react_jsx_runtime.JSX.Element | null;
2299
2342
 
2300
- export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputDescriptor, type InputKind, type InputMultiCapability, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };
2343
+ export { type Adapter, type AdapterCtx, CanvasAPI, type EditorSettings, EventBus, type EventMap, FallbackAddCandidatesDialog, FallbackAddRegistrationDialog, FallbackDetailsPanel, FallbackEditor, type FallbackEditorData, FallbackEditorHeader, FallbackEditorProvider, type FallbackEditorProviderProps, FallbackRegistrationsPanel, FallbackServiceSidebar, FallbackSettingsPanel, type FormApi, FormProvider, type FormProviderProps, type FormSnapshot, type InputChildOptionCapability, type InputDescriptor, type InputKind, type InputMultiCapability, type InputOptionCapability, type InputVariant, type InputWrapperProps, OrderFlowProvider, Provider, type RegistrationItem, type RegistrationScope, type Registry, type ServiceSummary, type ValidationMessage, type ValidationTone, VirtualServiceList, Wrapper, createInputRegistry, registerEntries, resolveInputDescriptor, useActiveFallbackRegistrations, useEligibleServiceList, useFallbackEditor, useFallbackEditorContext, useFormApi, useInputs, useInputsMaybe, useOptionalFormApi, useOrderFlow, useOrderFlowContext, usePrimaryServiceList };