All files / src/types domain.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
// ===== USER =====
export interface User {
  id: string;
  email: string;
  name: string | null;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date | null;
}
 
// ===== COLLECTION =====
export type CollectionStatus = "active" | "archived" | "deleted";
 
export interface Collection {
  id: string;
  ownerId: string;
  name: string;
  slug: string | null;
  description: string | null;
  status: CollectionStatus;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date | null;
}
 
// ===== COLLECTION MEMBERSHIP =====
export type MembershipRole = "owner" | "curator";
 
export interface CollectionMembership {
  id: string;
  collectionId: string;
  userId: string;
  // Populated only by the joined read path (findByCollection); the base-table
  // reads (findById/findByUser) leave these undefined.
  name?: string;
  email?: string;
  role: MembershipRole;
  createdAt: Date;
  updatedAt: Date;
}
 
// ===== INVITATION =====
export type InvitationStatus = "pending" | "accepted" | "revoked";
 
export interface Invitation {
  id: string;
  collectionId: string;
  email: string;
  token: string;
  status: InvitationStatus;
  createdAt: Date;
  updatedAt: Date;
  acceptedAt: Date | null;
}
 
// ===== ITEM =====
export interface Item {
  id: string;
  collectionId: string;
  name: string | null;
  brand: string | null;
  style: string | null;
  color: string | null;
  material: string | null;
  category: string | null;
  number: number | null;
  height: string | null;
  width: string | null;
  depth: string | null;
  weight: string | null;
  unit: string;
  status: string | null;
  notes: string | null;
  story: string | null;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date | null;
}
 
// ===== PHOTO =====
export interface Photo {
  id: string;
  itemId: string | null;
  collectionId: string;
  blobKey: string;
  filename: string;
  mimeType: string;
  fileSize: number | null;
  uploadedBy: string;
  isHero: boolean;
  /** Clockwise display rotation in degrees: 0 | 90 | 180 | 270 (non-destructive). */
  rotation: number;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date | null;
}
 
// ===== SESSION =====
export type SessionStatus = "active" | "paused" | "completed" | "abandoned" | "deleted";
 
export interface Session {
  id: string;
  collectionId: string;
  curatorId: string;
  number: number;
  status: SessionStatus;
  goal: string | null;
  createdAt: Date;
  updatedAt: Date;
  deletedAt: Date | null;
}
 
// ===== DECISION EVENT =====
export type DecisionType = "triage" | "pairwise_compare" | "usage";
export type TriageResult = "top" | "high" | "medium" | "low";
export type PairwiseResult = "item_a" | "item_b" | "tie" | "skip";
export type UsageResult = "uses" | "not_uses";
 
export interface DecisionEvent {
  id: string;
  sessionId: string;
  type: DecisionType;
  decision: TriageDecision | PairwiseDecision | UsageDecision;
  createdAt: Date;
}
 
export interface TriageDecision {
  itemId: string;
  result: TriageResult;
}
 
export interface PairwiseDecision {
  itemAId: string;
  itemBId: string;
  result: PairwiseResult;
}
 
// Deliberately no pass/skip member: absence of an event IS "undecided" — the
// type system cannot express a counted non-answer (Epic R, spec §2.1).
export interface UsageDecision {
  itemId: string;
  result: UsageResult;
}
 
// ===== AUDIT LOG =====
export type AuditAction =
  | "item.purge"
  | "collection.purge"
  | "account.delete"
  | "item.delete"
  | "photo.delete";
export type AuditTargetType = "item" | "collection" | "user" | "photo";
 
export interface AuditLog {
  id: string;
  actorId: string;
  action: AuditAction;
  targetType: AuditTargetType;
  targetId: string;
  collectionId: string;
  metadata: Record<string, number> | null;
  createdAt: Date;
}
 
// Insert DTO — id + createdAt are generated by the repo. Literal unions make
// an illegal action/targetType unrepresentable at the only construction sites.
export interface NewAuditLog {
  actorId: string;
  action: AuditAction;
  targetType: AuditTargetType;
  targetId: string;
  collectionId: string;
  metadata?: Record<string, number>;
}
 
// ===== COLLECTION PREFERENCE ITEM =====
export type RankBucket = "top" | "high" | "medium" | "low";
 
export interface CollectionPreferenceItem {
  id: string;
  collectionId: string;
  curatorId: string;
  itemId: string;
  score: number;
  confidence: number;
  rankBucket: RankBucket;
  comparisonCount: number;
  orderRank: number | null;
  lastSeen: Date;
  createdAt: Date;
  updatedAt: Date;
}
 
// ===== ITEM DISPOSITION =====
export type Disposition = "set_aside" | "deferred";
 
export interface ItemDisposition {
  id: string;
  collectionId: string;
  curatorId: string;
  itemId: string;
  disposition: Disposition;
  createdAt: Date;
  updatedAt: Date;
}
 
// ===== SORT RESULT =====
export type SortResultStatus = "draft" | "finalized";
 
export interface SortResult {
  id: string;
  collectionId: string;
  curatorId: string;
  number: number;
  status: SortResultStatus;
  name: string;
  createdAt: Date;
  updatedAt: Date;
  finalizedAt: Date | null;
}
 
// ===== SORT RESULT ITEM =====
export interface SortResultItem {
  id: string;
  sortResultId: string;
  itemId: string;
  computedRank: number;
  computedBucket: RankBucket;
  manualRank: number | null;
  manualBucket: RankBucket | null;
  // Epic S: usage standing snapshotted at materialization (fresh-folded on
  // revision). NULL = unknown at snapshot time (legacy/undecided).
  usage: UsageResult | null;
  createdAt: Date;
  updatedAt: Date;
}
 
// ===== SORT RESULT SHARE =====
export type ShareStatus = "active" | "revoked";
 
export interface SortResultShare {
  id: string;
  sortResultId: string;
  shareToken: string;
  status: ShareStatus;
  expiresAt: Date | null;
  createdAt: Date;
  updatedAt: Date;
}
 
// ===== API RESPONSE =====
export interface ApiResponse<T> {
  success: boolean;
  data?: T;
  error?: string;
}