FRE-4529: Transfer ShieldAI code from FrenoCorp repo
Transferred ShieldAI-related files mistakenly placed in ~/code/FrenoCorp:
- Services: spamshield (feature-flags, audit-logger, error-handler), voiceprint (config, service, feature-flags), darkwatch (pipeline, scan, scheduler, watchlist, webhook)
- Packages: shared-analytics, shared-auth, shared-ui, shared-utils (new); shared-billing, jobs supplemented with unique FC files
- Server: alerts (FC version newer), routes (spamshield, darkwatch, voiceprint)
- Config: turbo.json, tsconfig.base.json, vite/vitest configs, drizzle, Dockerfile
- VoicePrint ML service
- Examples
Pending: apps/{api,web,mobile}/ structured merge, shared-db/db mapping
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
81
packages/shared-auth/src/models/auth.models.ts
Normal file
81
packages/shared-auth/src/models/auth.models.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
// User schema
|
||||
export const userSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
email: z.string().email(),
|
||||
name: z.string().min(1),
|
||||
image: z.string().url().optional(),
|
||||
role: z.enum(['user', 'family_admin', 'family_member', 'support']),
|
||||
emailVerified: z.date().optional(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
});
|
||||
|
||||
export type User = z.infer<typeof userSchema>;
|
||||
|
||||
// Family group schema
|
||||
export const familyGroupSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
name: z.string().min(1).max(100),
|
||||
ownerId: z.string().uuid(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
});
|
||||
|
||||
export type FamilyGroup = z.infer<typeof familyGroupSchema>;
|
||||
|
||||
// Family member schema
|
||||
export const familyMemberSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
groupId: z.string().uuid(),
|
||||
userId: z.string().uuid(),
|
||||
role: z.enum(['owner', 'admin', 'member']),
|
||||
joinedAt: z.date(),
|
||||
});
|
||||
|
||||
export type FamilyMember = z.infer<typeof familyMemberSchema>;
|
||||
|
||||
// Session schema
|
||||
export const sessionSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
userId: z.string().uuid(),
|
||||
sessionToken: z.string(),
|
||||
expires: z.date(),
|
||||
createdAt: z.date(),
|
||||
});
|
||||
|
||||
export type Session = z.infer<typeof sessionSchema>;
|
||||
|
||||
// Account schema (for OAuth)
|
||||
export const accountSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
userId: z.string().uuid(),
|
||||
provider: z.string(),
|
||||
providerAccountId: z.string(),
|
||||
access_token: z.string().optional(),
|
||||
refresh_token: z.string().optional(),
|
||||
expires_at: z.number().optional(),
|
||||
token_type: z.string().optional(),
|
||||
scope: z.string().optional(),
|
||||
});
|
||||
|
||||
export type Account = z.infer<typeof accountSchema>;
|
||||
|
||||
// Validation schemas for API
|
||||
export const createUserSchema = z.object({
|
||||
email: z.string().email(),
|
||||
password: z.string().min(8),
|
||||
name: z.string().min(1),
|
||||
});
|
||||
|
||||
export const createFamilyGroupSchema = z.object({
|
||||
name: z.string().min(1).max(100),
|
||||
ownerId: z.string().uuid(),
|
||||
});
|
||||
|
||||
export const addFamilyMemberSchema = z.object({
|
||||
groupId: z.string().uuid(),
|
||||
userId: z.string().uuid(),
|
||||
role: z.enum(['admin', 'member']).default('member'),
|
||||
});
|
||||
Reference in New Issue
Block a user