feat(types): adopt shared mokosh-types crate via HTTPS git dep (MAPPS-378) #445

Closed
nrupard wants to merge 1 commit from feat/MAPPS-378-adopt-mokosh-types into main
Owner

What

Completes MAPPS-378: mokosh-apps now depends on the shared mokosh-types crate and sources the cleanly-shareable client/server DTOs from it, superseding the interim hand field-sync merged in #443. This is the "make the compiler enforce the contract" half of the ticket.

Why

The hand-maintained DTO copies let client/server drift deserialize to serde defaults silently instead of failing the build. Depending on mokosh-types makes drift a compile error for the adopted types. The earlier adoption attempt failed only because it used the SSH git URL, which CI/docker cannot host-key-verify; this PR uses the anonymously-readable HTTPS git URL (the same way bunyip fetches dunite), pinned by rev. mokosh-types is wasm-safe (serde, serde_json, chrono, chrono-tz 0.9, uuid, validator 0.19, rust_decimal; no sqlx), which the gate confirms by wasm-compiling it.

Changes

  • Added mokosh-types = { git = "https://dev.a8n.run/psa-systems/mokosh-server.git", rev = "a317a14..." } to Cargo.toml (HTTPS, pinned) and the resolved entries to Cargo.lock.
  • auth: re-exported CurrentUser and UserRole from mokosh_types::auth, deleting the byte-identical local copies; dropped the unused local UserRole::parse_role shim (zero call sites). AuthState (which maps auth failure to the SPA's own AppError), User, UserResponse, UserStatus, and the request DTOs stay local.
  • tenants: re-exported the whole shared set (Tenant, TenantBranding, TenantStatus, CreateTenantRequest, UpdateTenantRequest, TenantResponse), which was byte-identical to the shared crate including TenantStatus::from_str/as_str and From<Tenant> for TenantResponse; the SPA-unused TenantUsage is intentionally not re-exported.
  • tickets: re-exported TicketNote and TicketNoteResponse (the created_by_contact_id drift this closes), deleting the local copies; the SPA-local NoteType, CreateNoteRequest, Ticket (its sla_status uses the SPA's quarter-window algorithm, deliberately kept local), and the other ticket types are unchanged.

Deferred (drift discovered at the pinned rev, out of scope here)

  • contacts: mokosh_types::contacts::Contact adds a company_name field and CompanyType adds an Internal variant that the client copies lack, so re-exporting would be a behaviour change (deserialization/exhaustiveness), not a drop-in. Left as local hand copies.
  • time_tracking: mokosh_types::time_tracking::TimeEntryResponse types billing_status/approval_status as enums (client uses String) and adds worked_minutes, task_id, ticket_number, and more; several timesheet DTOs also gained fields. Re-exporting would break the timesheet feature's construction and field-access sites. Left as local hand copies.
  • mileage_tracking: no client module exists, so there is nothing to adopt.
  • The vestigial TicketResponse/CreateTicketRequest/TicketCategory/Upsert* ticket types were deleted in #443 and have no client consumers, so they are not re-added (YAGNI); the SPA renders its own RemoteTicket subsets.

Reconciling the contacts and time_tracking drift is a separate follow-up, since it changes SPA behaviour rather than adopting a matching contract.

Tests

just pre-commit green in the repo Docker gate: cargo fmt --all --check, cargo clippy --all-targets -- -D warnings, cargo check --target wasm32-unknown-unknown, and cargo test --lib (223 passed, 0 failed).

## What Completes MAPPS-378: mokosh-apps now depends on the shared `mokosh-types` crate and sources the cleanly-shareable client/server DTOs from it, superseding the interim hand field-sync merged in #443. This is the "make the compiler enforce the contract" half of the ticket. ## Why The hand-maintained DTO copies let client/server drift deserialize to serde defaults silently instead of failing the build. Depending on `mokosh-types` makes drift a compile error for the adopted types. The earlier adoption attempt failed only because it used the SSH git URL, which CI/docker cannot host-key-verify; this PR uses the anonymously-readable HTTPS git URL (the same way bunyip fetches dunite), pinned by rev. `mokosh-types` is wasm-safe (serde, serde_json, chrono, chrono-tz 0.9, uuid, validator 0.19, rust_decimal; no sqlx), which the gate confirms by wasm-compiling it. ## Changes - Added `mokosh-types = { git = "https://dev.a8n.run/psa-systems/mokosh-server.git", rev = "a317a14..." }` to Cargo.toml (HTTPS, pinned) and the resolved entries to Cargo.lock. - auth: re-exported `CurrentUser` and `UserRole` from `mokosh_types::auth`, deleting the byte-identical local copies; dropped the unused local `UserRole::parse_role` shim (zero call sites). `AuthState` (which maps auth failure to the SPA's own `AppError`), `User`, `UserResponse`, `UserStatus`, and the request DTOs stay local. - tenants: re-exported the whole shared set (`Tenant`, `TenantBranding`, `TenantStatus`, `CreateTenantRequest`, `UpdateTenantRequest`, `TenantResponse`), which was byte-identical to the shared crate including `TenantStatus::from_str`/`as_str` and `From<Tenant> for TenantResponse`; the SPA-unused `TenantUsage` is intentionally not re-exported. - tickets: re-exported `TicketNote` and `TicketNoteResponse` (the `created_by_contact_id` drift this closes), deleting the local copies; the SPA-local `NoteType`, `CreateNoteRequest`, `Ticket` (its `sla_status` uses the SPA's quarter-window algorithm, deliberately kept local), and the other ticket types are unchanged. ## Deferred (drift discovered at the pinned rev, out of scope here) - contacts: `mokosh_types::contacts::Contact` adds a `company_name` field and `CompanyType` adds an `Internal` variant that the client copies lack, so re-exporting would be a behaviour change (deserialization/exhaustiveness), not a drop-in. Left as local hand copies. - time_tracking: `mokosh_types::time_tracking::TimeEntryResponse` types `billing_status`/`approval_status` as enums (client uses `String`) and adds `worked_minutes`, `task_id`, `ticket_number`, and more; several timesheet DTOs also gained fields. Re-exporting would break the timesheet feature's construction and field-access sites. Left as local hand copies. - mileage_tracking: no client module exists, so there is nothing to adopt. - The vestigial `TicketResponse`/`CreateTicketRequest`/`TicketCategory`/`Upsert*` ticket types were deleted in #443 and have no client consumers, so they are not re-added (YAGNI); the SPA renders its own `RemoteTicket` subsets. Reconciling the contacts and time_tracking drift is a separate follow-up, since it changes SPA behaviour rather than adopting a matching contract. ## Tests `just pre-commit` green in the repo Docker gate: `cargo fmt --all --check`, `cargo clippy --all-targets -- -D warnings`, `cargo check --target wasm32-unknown-unknown`, and `cargo test --lib` (223 passed, 0 failed).
feat(types): adopt shared mokosh-types crate via HTTPS git dep
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 1m36s
Create release / Create release from merged PR (pull_request) Has been skipped
7f8c0623e6
Completes MAPPS-378 by making mokosh-apps depend on the shared mokosh-types crate over an anonymously-readable HTTPS git URL pinned by rev, superseding the interim hand field-sync from #443 so the compiler enforces the client/server DTO contract instead of serde silently defaulting drifted fields.

The prior attempt failed only because an SSH git URL cannot be host-key-verified in CI/docker; the HTTPS URL fetches over anonymous read (the same way bunyip fetches dunite) and resolves plus wasm-compiles cleanly in the gate. mokosh-types is wasm-safe (serde, serde_json, chrono, chrono-tz 0.9, uuid, validator 0.19, rust_decimal, no sqlx).

Adopted (re-exported from mokosh-types, field- and behaviour-identical to the removed hand copies, so no construction site changes): auth CurrentUser and UserRole; tenants Tenant, TenantBranding, TenantStatus, CreateTenantRequest, UpdateTenantRequest, TenantResponse; tickets TicketNote and TicketNoteResponse. The unused local UserRole::parse_role shim (zero call sites) is dropped.

Deferred as local hand copies because they have diverged from the shared crate at this rev, so re-exporting them would be a behaviour change rather than a drop-in: contacts (mokosh-types Contact adds a company_name field and CompanyType adds an Internal variant) and time_tracking (mokosh-types TimeEntryResponse types billing_status and approval_status as enums and adds worked_minutes, task_id, and other fields the client subset omits). mileage_tracking has no client module. Reconciling that drift is a separate follow-up.

Gate: just pre-commit green (fmt, clippy -D warnings, wasm32 check, test --lib: 223 passed, 0 failed).

#MAPPS-378

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nrupard closed this pull request 2026-08-03 19:25:29 +02:00
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 1m36s
Required
Details
Create release / Create release from merged PR (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!445
No description provided.