feat(api): add activities + work_sessions domain schema and shared contracts
This commit is contained in:
@@ -16,3 +16,50 @@ export const MeResponse = z.object({
|
||||
user: PublicUser,
|
||||
});
|
||||
export type MeResponse = z.infer<typeof MeResponse>;
|
||||
|
||||
export const InsoleType = z.enum(['Kurk', 'Berk', '3D']);
|
||||
export type InsoleType = z.infer<typeof InsoleType>;
|
||||
|
||||
export const Activity = z.object({
|
||||
id: z.number().int(),
|
||||
name: z.string(),
|
||||
insole_types: z.array(InsoleType),
|
||||
created_at: z.string(), // ISO-8601
|
||||
});
|
||||
export type Activity = z.infer<typeof Activity>;
|
||||
|
||||
export const CreateActivityInput = z.object({
|
||||
name: z.string().trim().min(1),
|
||||
insole_types: z.array(InsoleType).default(['Kurk', 'Berk', '3D']),
|
||||
});
|
||||
export type CreateActivityInput = z.infer<typeof CreateActivityInput>;
|
||||
|
||||
export const UpdateActivityInput = CreateActivityInput;
|
||||
export type UpdateActivityInput = z.infer<typeof UpdateActivityInput>;
|
||||
|
||||
export const SessionStatus = z.enum(['active', 'completed', 'discarded']);
|
||||
export type SessionStatus = z.infer<typeof SessionStatus>;
|
||||
|
||||
export const WorkSession = z.object({
|
||||
id: z.number().int(),
|
||||
user_id: z.string(),
|
||||
activity_id: z.number().int(),
|
||||
activity_name: z.string().optional(), // present on history/active joins
|
||||
insole_type: InsoleType.nullable(),
|
||||
pair_count: z.number().int(),
|
||||
start_time: z.string(), // ISO-8601
|
||||
end_time: z.string().nullable(),
|
||||
duration_seconds: z.number().int().nullable(),
|
||||
status: SessionStatus,
|
||||
source: z.enum(['app', 'manual']),
|
||||
notes: z.string().nullable(),
|
||||
created_at: z.string(),
|
||||
});
|
||||
export type WorkSession = z.infer<typeof WorkSession>;
|
||||
|
||||
export const StartSessionInput = z.object({
|
||||
activity_id: z.number().int(),
|
||||
insole_type: InsoleType,
|
||||
pair_count: z.number().int().min(1).default(2),
|
||||
});
|
||||
export type StartSessionInput = z.infer<typeof StartSessionInput>;
|
||||
|
||||
Reference in New Issue
Block a user