feat(11-01): schema, service, and tests for sort_order + reorderCandidates
- Add sortOrder REAL column to threadCandidates schema (default 0) - Add sort_order column to test helper CREATE TABLE - Add reorderCandidatesSchema to shared/schemas.ts - Add ReorderCandidates type to shared/types.ts - getThreadWithCandidates now orders candidates by sort_order ASC - createCandidate appends at max sort_order + 1000 (first = 1000) - Add reorderCandidates service function (transaction, active-only guard) - Add 5 new tests: ordering, appending, reorder success, resolved guard, missing thread
This commit is contained in:
@@ -63,6 +63,10 @@ export const resolveThreadSchema = z.object({
|
||||
candidateId: z.number().int().positive(),
|
||||
});
|
||||
|
||||
export const reorderCandidatesSchema = z.object({
|
||||
orderedIds: z.array(z.number().int().positive()).min(1),
|
||||
});
|
||||
|
||||
// Setup schemas
|
||||
export const createSetupSchema = z.object({
|
||||
name: z.string().min(1, "Setup name is required"),
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
createItemSchema,
|
||||
createSetupSchema,
|
||||
createThreadSchema,
|
||||
reorderCandidatesSchema,
|
||||
resolveThreadSchema,
|
||||
syncSetupItemsSchema,
|
||||
updateCandidateSchema,
|
||||
@@ -33,6 +34,7 @@ export type UpdateThread = z.infer<typeof updateThreadSchema>;
|
||||
export type CreateCandidate = z.infer<typeof createCandidateSchema>;
|
||||
export type UpdateCandidate = z.infer<typeof updateCandidateSchema>;
|
||||
export type ResolveThread = z.infer<typeof resolveThreadSchema>;
|
||||
export type ReorderCandidates = z.infer<typeof reorderCandidatesSchema>;
|
||||
|
||||
// Setup types
|
||||
export type CreateSetup = z.infer<typeof createSetupSchema>;
|
||||
|
||||
Reference in New Issue
Block a user