Single source of truth for the Journal REST API: - API_VERSION semver constant (1.0.0) - Endpoint path constants (routes, activities, auth, uploads, push) - Zod schemas for all request/response shapes: - Routes: list, detail, create, update, compute - Activities: list, detail, create - Auth: token exchange, refresh, device management - Discovery: instance info + API version - Uploads: presigned URL flow - Errors: structured error response with field-level details - Cursor-based pagination schemas - TypeScript types inferred from Zod (z.infer) Used by Journal server (validation) and mobile client (type safety). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
677 B
TypeScript
26 lines
677 B
TypeScript
import { z } from "zod";
|
|
|
|
export const FieldErrorSchema = z.object({
|
|
field: z.string(),
|
|
message: z.string(),
|
|
});
|
|
|
|
export const ApiErrorResponseSchema = z.object({
|
|
error: z.string(),
|
|
code: z.string(),
|
|
fields: z.array(FieldErrorSchema).optional(),
|
|
});
|
|
|
|
export type FieldError = z.infer<typeof FieldErrorSchema>;
|
|
export type ApiErrorResponse = z.infer<typeof ApiErrorResponseSchema>;
|
|
|
|
/** Standard error codes */
|
|
export const ERROR_CODES = {
|
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
NOT_FOUND: "NOT_FOUND",
|
|
UNAUTHORIZED: "UNAUTHORIZED",
|
|
FORBIDDEN: "FORBIDDEN",
|
|
CONFLICT: "CONFLICT",
|
|
RATE_LIMITED: "RATE_LIMITED",
|
|
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
} as const;
|