Adds company-membership service with six operations (add, update, end, setPrimary, listByCompany, listByClient), the corresponding Zod validators, three socket events, and a unit-test suite covering the portId-scoping rules, the unique_cm_exact conflict path, and the atomic setPrimary transaction. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37 lines
949 B
TypeScript
37 lines
949 B
TypeScript
import { z } from 'zod';
|
|
|
|
export const ROLES = [
|
|
'director',
|
|
'officer',
|
|
'broker',
|
|
'representative',
|
|
'legal_counsel',
|
|
'employee',
|
|
'shareholder',
|
|
'other',
|
|
] as const;
|
|
|
|
export const addMembershipSchema = z.object({
|
|
clientId: z.string().min(1),
|
|
role: z.enum(ROLES),
|
|
roleDetail: z.string().optional(),
|
|
startDate: z.coerce.date(),
|
|
isPrimary: z.boolean().optional().default(false),
|
|
notes: z.string().optional(),
|
|
});
|
|
|
|
export const updateMembershipSchema = z.object({
|
|
role: z.enum(ROLES).optional(),
|
|
roleDetail: z.string().nullable().optional(),
|
|
notes: z.string().nullable().optional(),
|
|
isPrimary: z.boolean().optional(),
|
|
});
|
|
|
|
export const endMembershipSchema = z.object({
|
|
endDate: z.coerce.date(),
|
|
});
|
|
|
|
export type AddMembershipInput = z.infer<typeof addMembershipSchema>;
|
|
export type UpdateMembershipInput = z.infer<typeof updateMembershipSchema>;
|
|
export type EndMembershipInput = z.infer<typeof endMembershipSchema>;
|