Skip to content

refactor(service): type safe pattern & journey - #76

Open
jumpy-cat wants to merge 3 commits into
docu/mostly-feature-completefrom
pattern-schema-and-sum-type-journey
Open

refactor(service): type safe pattern & journey#76
jumpy-cat wants to merge 3 commits into
docu/mostly-feature-completefrom
pattern-schema-and-sum-type-journey

Conversation

@jumpy-cat

@jumpy-cat jumpy-cat commented Aug 16, 2026

Copy link
Copy Markdown
Member

Description

Added zod validation of getpatterns bustime responses, allowing it to be processed in a fully typed way instead of as any. Added discriminated union type for journeys and refactored journey creation code accordingly. The final type is a setset of the flat object with many optional fields it was originally.

Type of Change

  • New feature (feat)
  • Bug fix (fix)
  • Refactor / code improvement
  • Dependency / build update
  • Documentation
  • Other (explain)

Related Issues

none

Changes Made

  • Backend (TypeScript):
    • JourneyLeg in McRaptor -> turned into discriminated union
    • new FormattedLeg type (also discriminated union)
    • changed the structure of how objects are constructed in leg formatting to satisfy the typechecker
    • new file bustimeTypes that contains the Pattern schema and type
    • removed checks obliviated by the presence of better types
    • removed any where it was possible
    • changes fetchPatterns to use zod validation

Testing Done

Flutter: none

  • pattern schema works w/ data from mock bustime servers

Screenshots / Demo (if UI or notification change)

Checklist

  • Commit messages follow Conventional Commits
  • PR title follows [type](scope): short description
  • PR target branch is not main and is our current working update branch (e.g. maizebus2.1)
  • No print() / debugPrint() / console.log() left in production code
  • Secrets / keys not committed

@jumpy-cat
jumpy-cat marked this pull request as ready for review August 16, 2026 02:29
jumpy-cat and others added 3 commits August 16, 2026 19:06
Replace the any returned by processJourneys with an actual type that models the two variant nature of the processed legs. Did a similar thing with the journey leg type in `McRaptorAlgorithm.ts`. Both changes should have no semantic difference but behavior and performance should ideally both be checked.
@jumpy-cat
jumpy-cat force-pushed the pattern-schema-and-sum-type-journey branch from a7dbe43 to 99f4c8e Compare August 17, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant