import { z } from 'zod';

// ── Session Document ─────────────────────────────────────────

export type SessionPlatform = 'ios' | 'android' | 'desktop' | 'web' | 'watch' | 'unknown';

export interface SessionDoc {
  id: string;
  productId: string;
  userId: string;
  deviceId?: string;
  platform: SessionPlatform;
  ipAddress: string;
  userAgent: string;
  lastActiveAt: string;
  createdAt: string;
  expiresAt: string;
  revokedAt?: string;
  _ts?: number;
  _etag?: string;
}

// ── Schemas ──────────────────────────────────────────────────

export const CreateSessionSchema = z.object({
  platform: z.enum(['ios', 'android', 'desktop', 'web', 'watch', 'unknown']).default('unknown'),
  deviceId: z.string().optional(),
});

export const RevokeSessionSchema = z.object({
  reason: z.string().max(200).optional(),
});

export type CreateSessionInput = z.infer<typeof CreateSessionSchema>;
