mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-22 06:41:46 +00:00
Derive client domain types from the shared schema contracts
Add entity/response Zod schemas to @trek/shared (place, trip, assignment, day, budget, packing, reservation), each matched against the producing server service, and re-export them from client types.ts instead of the hand-written duplicates that had drifted (name/title, amount/total_price, owner_id/user_id, cover_url/cover_image, ...). Updates the call sites and test fixtures the corrected types surfaced; type-only, no runtime behaviour change.
This commit is contained in:
@@ -25,9 +25,17 @@ export function resetAllStores(): void {
|
||||
usePermissionsStore.setState(initialPermsState, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests routinely seed a store with a partially-populated slice of state,
|
||||
* including partial nested objects (e.g. only `settings.time_format`). The
|
||||
* store's own setState wants the exact field types, so seeding accepts a
|
||||
* deep-partial view and casts at the boundary.
|
||||
*/
|
||||
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
||||
|
||||
export function seedStore<T extends object>(
|
||||
store: { setState: (partial: Partial<T>, replace?: boolean) => void },
|
||||
state: Partial<T>,
|
||||
state: DeepPartial<T>,
|
||||
): void {
|
||||
store.setState(state);
|
||||
store.setState(state as Partial<T>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user