Skip to content

Case state-transition metadata not exposed (selectable sub-states per type, AllowManualSuccess, system-only sub-states) #46

Description

@yusufaltunbicak

Summary

The SDK exposes CaseSubState as a flat enum but none of the state-machine rules that govern transitions, so every client re-implements Core logic (and drifts when Core changes). Three concrete pieces are missing.

(a) Which Fail_* sub-states are valid per CaseType. Core groups fail reasons by numeric range — common (1–6), sale (300s), complaint (600s), endorsement/cancel (900s). The contract gives a flat 16-member Fail* set with no per-type grouping.

(b) AllowManualSuccessState. Core CaseDetailModel exposes AllowManualSuccessState (true only for ComplaintCaseDetailModel) — only Complaint cases may be moved to SUCCESS manually. Not present on GetCaseByRefResult.

(c) Which in-progress sub-states are user-selectable vs system-only. IN_PROGRESS_UNDER_ANALYSIS is system-set-only; sending it as a manual transition is rejected by the backend with HTTP 422. The contract doesn't mark selectability.

Verified

  • @insurup/contracts@0.1.26 dist/cases.d.ts: CaseSubState flat enum L54–80; GetCaseByRefResultBase L1170–1401 has no per-type fail grouping and no allowManualSuccess flag.
  • Backend HTTP 422 on manual IN_PROGRESS_UNDER_ANALYSIS — verified against prod 2026-05-28.

Core source

  • InsurUp.Common.Models/src/Cases/CaseSubState.cs (numeric ranges).
  • …/CaseManagement/Detail/Models/CaseDetailModel.cs (AllowManualSuccessState → true only for ComplaintCaseDetailModel).

Impact / current workaround

agent-panel hardcodes all three in src/lib/case/display.ts (failSubStatesForType, subStatesForMainState, allowManualSuccess) with citations to the Core files above. Works today, but silently drifts the moment Core adds/moves a sub-state or changes the manual-success rule.

Proposed fix (any subset helps; rough priority)

  1. Add allowManualSuccess: boolean to GetCaseByRefResult — atomic, smallest fix for (b).
  2. Expose valid/selectable sub-states per (mainState, caseType) — e.g. a getCaseTransitionOptions(ref) call or static metadata keyed by case type — covering (a) and (c).
  3. At minimum, annotate each CaseSubState member with its main-state bucket + user-selectable flag in generated metadata.

Happy to split this into one issue per facet if you prefer.


Context: surfaced during the agent-panel Cases (Talepler) module migration (InsurUp/agent-panel#8).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions