feat: add collaborative shopping lists with items and invitations
Some checks failed
CI / Verify (push) Has been cancelled
Some checks failed
CI / Verify (push) Has been cancelled
API: lists, items and invitations modules (list, create, get, update, set-primary, items create/list, invitation create/accept/list-pending), BetterAuth session helper, list membership, mailer and Prisma schema plus migrations. Web: lists overview, list detail (items) and list management (settings) views, item and invitation forms/hooks, sign-up and invitation accept pages. Shared: shopping list DTOs. Tooling: ignore the generated TanStack Router cache (apps/web/.tanstack).
This commit is contained in:
99
packages/shared/src/shopping-list.ts
Normal file
99
packages/shared/src/shopping-list.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Shared DTOs for collaborative shopping lists. The API serializes these shapes
|
||||
* and the web app consumes them, so they live here instead of being duplicated.
|
||||
*/
|
||||
|
||||
export type ListRole = 'owner' | 'collaborator'
|
||||
|
||||
export type InvitationStatus = 'pending' | 'accepted' | 'revoked' | 'expired'
|
||||
|
||||
/** A member of a list, as seen in the list detail. */
|
||||
export type ListMember = {
|
||||
id: string
|
||||
role: ListRole
|
||||
isPrimary: boolean
|
||||
user: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
image: string | null
|
||||
}
|
||||
}
|
||||
|
||||
/** A list as returned by the collection endpoint (`GET /lists`). */
|
||||
export type ShoppingListSummary = {
|
||||
id: string
|
||||
name: string
|
||||
role: ListRole
|
||||
isPrimary: boolean
|
||||
memberCount: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
/** A list with its members, as returned by `GET /lists/:listId`. */
|
||||
export type ShoppingListDetail = {
|
||||
id: string
|
||||
name: string
|
||||
role: ListRole
|
||||
isPrimary: boolean
|
||||
members: ListMember[]
|
||||
invitations: ListInvitation[]
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
/** An invitation attached to a list (pending or historical). */
|
||||
export type ListInvitation = {
|
||||
id: string
|
||||
email: string
|
||||
status: InvitationStatus
|
||||
expiresAt: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
/** A pending invitation from the invited user's point of view. */
|
||||
export type PendingInvitation = {
|
||||
id: string
|
||||
email: string
|
||||
status: InvitationStatus
|
||||
expiresAt: string
|
||||
createdAt: string
|
||||
list: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
invitedBy: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of creating an invitation: `added` when the email already had an
|
||||
* account (membership granted immediately) or `invited` when a pending
|
||||
* invitation was emailed.
|
||||
*/
|
||||
export type CreateInvitationResult = {
|
||||
status: 'added' | 'invited'
|
||||
email: string
|
||||
}
|
||||
|
||||
/** Result of accepting an invitation, used to navigate to the shared list. */
|
||||
export type AcceptInvitationResult = {
|
||||
listId: string
|
||||
listName: string
|
||||
}
|
||||
|
||||
/** An item inside a shopping list, as returned by the items endpoints. */
|
||||
export type ListItem = {
|
||||
id: string
|
||||
listId: string
|
||||
name: string
|
||||
completed: boolean
|
||||
quantity: string | null
|
||||
notes: string | null
|
||||
order: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
Reference in New Issue
Block a user