Route and Activity existed three times: hand-written interfaces in packages/types, Zod contracts in packages/api, and Drizzle columns in packages/db — each with different fields and nullability. The hand-written ones had drifted so far they had zero importers; the Zod contracts were advisory because v1 handlers hand-rolled Response.json shapes nothing validated. - packages/types keeps only what both apps actually share (Waypoint, WaypointPoiTags) and documents where row types and wire contracts live; the dead Route/RouteMetadata/RouteVersion/Activity interfaces are gone - packages/db exports canonical inferred row types (RouteRow, ActivityRow, RouteVersionRow, UserRow) - packages/api contracts are reconciled with the real wire format (RouteVersionSchema gains the id and createdBy fields the endpoint has always returned) and gain Create*ResponseSchemas - apiJson(schema, payload) in api-guard parses every v1 response through its contract: drift is now a thrown ZodError in tests/CI, unknown keys are stripped, and payloads are compile-checked as z.input of the schema Enforcement immediately caught two real drifts: nullable DB descriptions could ship null where the contract promises string (now coalesced at the boundary), and GET /api/v1/activities/:id was missing the routeName and photos fields its contract declares. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
export { API_VERSION } from "./version.ts";
|
|
export { ENDPOINTS } from "./endpoints.ts";
|
|
|
|
// Error schemas
|
|
export {
|
|
ApiErrorResponseSchema, FieldErrorSchema, ERROR_CODES,
|
|
zodIssuesToFieldErrors,
|
|
type ApiErrorResponse, type FieldError,
|
|
} from "./errors.ts";
|
|
|
|
// Pagination
|
|
export {
|
|
PaginationQuerySchema, PaginatedResponseSchema,
|
|
type PaginationQuery, type PaginatedResponse,
|
|
} from "./pagination.ts";
|
|
|
|
// Discovery
|
|
export {
|
|
DiscoveryResponseSchema,
|
|
type DiscoveryResponse,
|
|
} from "./discovery.ts";
|
|
|
|
// Auth
|
|
export {
|
|
TokenExchangeRequestSchema, TokenResponseSchema,
|
|
DeviceSchema, DeviceListResponseSchema,
|
|
type TokenExchangeRequest, type TokenResponse,
|
|
type Device, type DeviceListResponse,
|
|
} from "./auth.ts";
|
|
|
|
// Routes
|
|
export {
|
|
RouteSummarySchema, RouteDetailSchema, RouteVersionSchema,
|
|
RouteListResponseSchema,
|
|
CreateRouteRequestSchema, UpdateRouteRequestSchema,
|
|
CreateRouteResponseSchema,
|
|
ComputeRouteRequestSchema,
|
|
type RouteSummary, type RouteDetail, type RouteVersion,
|
|
type RouteListResponse,
|
|
type CreateRouteRequest, type UpdateRouteRequest,
|
|
type CreateRouteResponse,
|
|
type ComputeRouteRequest,
|
|
} from "./routes.ts";
|
|
|
|
// Activities
|
|
export {
|
|
ActivitySummarySchema, ActivityDetailSchema,
|
|
ActivityListResponseSchema,
|
|
CreateActivityRequestSchema, CreateActivityResponseSchema,
|
|
type ActivitySummary, type ActivityDetail,
|
|
type ActivityListResponse,
|
|
type CreateActivityRequest, type CreateActivityResponse,
|
|
} from "./activities.ts";
|
|
|
|
// Uploads
|
|
export {
|
|
PresignedUploadRequestSchema, PresignedUploadResponseSchema,
|
|
type PresignedUploadRequest, type PresignedUploadResponse,
|
|
} from "./uploads.ts";
|