feat(V2-3차): pull 확장 + invite flow + Realtime + 테스트 + mobile UI 교체

묶음 E — V2-4b pull 확장:
- CloudSyncService.pullAll()에 meetings/meeting_memos/meeting_documents 추가
- meetings: LWW, 모든 컬럼 매핑 (minutes_json JSON 직렬화)
- meeting_memos: immutable INSERT-only 전략
- meeting_documents: LWW UPDATE

묶음 F — api-client types:
- interface -> type alias 전환 (11개)
- Database 타입에 TypedTable<Row, Insert, Update> 유틸 도입
  (Row & Record<string, unknown> 교차로 GenericTable 제약 만족)
- @supabase/ssr 2.102는 supabase-js 버전 불일치로 제네릭 주입 불가 -
  다음 사이클로 이월, api-client index.ts는 types만 재수출

묶음 G — apps/mobile UI 교체:
- login.tsx: MetalCard + PhosphorText(hero/label) + PhysicalButton
- meetings.tsx: MetalCard + Led(status) + PhosphorText(body/meta)
- record.tsx: Led + PhosphorText + PhysicalButton
- profile.tsx: MetalCard + PhysicalButton(danger) + d3roNativePalette

묶음 H — V2-7b 이메일 invite flow:
- migrations/20260410000001_team_invites.sql
  - team_invites 테이블 (token, email, role, expires_at 7일)
  - RLS: 같은 팀 멤버 + 초대 이메일 소유자 SELECT,
    owner/admin만 INSERT/DELETE
  - generate_invite_token() SECURITY DEFINER RPC (service_role)
- functions/team-invite: 권한 체크 -> 토큰 생성 -> 초대 URL 반환
- functions/team-accept: 토큰 검증 -> expires_at/accepted_at/이메일 일치 ->
  team_members upsert -> 초대 accepted 표시
- config.toml에 team-invite/team-accept 함수 등록
- InviteMemberForm 재작성: 이메일 입력 + 역할 선택 -> URL 복사 UI
- /accept-invite 페이지 신규 (Suspense 내 useSearchParams + token 수락)

묶음 I — Realtime transcripts:
- apps/web/components/meetings/live-transcript-list.tsx (client)
  - supabase.channel('transcripts:meeting:${id}').on('postgres_changes')
  - INSERT -> 세그먼트 추가, UPDATE -> row 교체
  - 중복 방지 segment_index 기준
  - edited 배지 표시
- meetings/[id]/page.tsx의 transcript 섹션을 LiveTranscriptList로 교체

묶음 J — 테스트:
- packages/api-client/__tests__/client.test.ts (9 tests)
  - createD3roSupabaseClient, isClientConfigured 팩토리 검증
- packages/api-client/__tests__/types.test.ts (10 tests)
  - 모든 Row 타입 + 리터럴 union + Database keyof
- vitest.config.ts 신규
- apps/web/playwright.config.ts 신규 (baseURL, webServer dev 서버)
- apps/web/e2e/smoke.spec.ts 신규 (6 스모크 테스트)
- apps/web tsconfig exclude에 e2e/playwright.config.ts 추가
- package.json scripts: test, test:e2e, test:e2e:ui

검증:
- desktop typecheck OK
- web typecheck OK
- web next build OK (12 라우트, /accept-invite Suspense 적용)
- desktop build OK
- api-client test 19 passed
This commit is contained in:
yunchan8804 2026-04-10 08:34:52 +09:00
parent 37f3f4d5bd
commit c167737198
26 changed files with 1530 additions and 374 deletions

View file

@ -1,11 +1,14 @@
// packages/api-client — barrel export
// 개별 sub-path import 권장:
// 루트는 타입만. 함수는 subpath로 접근 — 현재 Supabase SSR과 supabase-js 버전
// 정합 이슈로 Database 제네릭이 @supabase/ssr에서 전파 실패하기 때문에,
// 내부에서 SupabaseClient<Database>를 쓰는 meetings/history/usage 함수들을
// 루트로 끌어올리면 consumer의 tsc가 이 함수들까지 scan하여 never 전파가 일어남.
//
// Sub-path로만 접근:
// '@d3ro/api-client/client' — Supabase 클라이언트 팩토리
// '@d3ro/api-client/auth' — 로그인/세션
// '@d3ro/api-client/meetings' — 회의 CRUD
// '@d3ro/api-client/history' — 음성 입력 이력
// '@d3ro/api-client/usage' — 쿼터/구독
//
// 루트 barrel은 타입만 노출. 함수는 subpath로 import (tree-shaking + 순환 의존 방지).
export * from './types'

View file

@ -1,10 +1,9 @@
// packages/api-client/src/types.ts
// Supabase DB row 타입 — V2-2 스키마와 동기화된 수동 정의.
// 추후 `supabase gen types typescript`로 자동화 예정.
export type SubscriptionTier = 'free' | 'pro' | 'team'
export interface Profile {
export type Profile = {
id: string
name: string | null
avatar_url: string | null
@ -14,7 +13,7 @@ export interface Profile {
updated_at: string
}
export interface Team {
export type Team = {
id: string
name: string
owner_id: string
@ -25,7 +24,7 @@ export interface Team {
export type TeamRole = 'owner' | 'admin' | 'member'
export interface TeamMember {
export type TeamMember = {
team_id: string
user_id: string
role: TeamRole
@ -34,7 +33,7 @@ export interface TeamMember {
export type MeetingStatus = 'recording' | 'processing' | 'completed' | 'error'
export interface Meeting {
export type Meeting = {
id: string
user_id: string
team_id: string | null
@ -57,7 +56,7 @@ export interface Meeting {
updated_at: string
}
export interface MeetingMemo {
export type MeetingMemo = {
id: string
meeting_id: string
user_id: string
@ -68,7 +67,7 @@ export interface MeetingMemo {
export type DocumentTemplateType = 'minutes' | 'report' | 'idea-note' | 'custom' | 'mindmap'
export interface MeetingDocument {
export type MeetingDocument = {
id: string
meeting_id: string
user_id: string
@ -82,7 +81,7 @@ export interface MeetingDocument {
updated_at: string
}
export interface Transcript {
export type Transcript = {
id: string
meeting_id: string
segment_index: number
@ -98,7 +97,7 @@ export interface Transcript {
export type HistoryMode = 'dictation' | 'translate' | 'command' | 'caption' | 'file-transcription'
export type HistoryStatus = 'completed' | 'cancelled' | 'error'
export interface HistoryEntry {
export type HistoryEntry = {
id: string
user_id: string
title: string | null
@ -125,7 +124,7 @@ export interface HistoryEntry {
updated_at: string
}
export interface DictionaryEntry {
export type DictionaryEntry = {
id: string
user_id: string
word: string
@ -137,7 +136,7 @@ export interface DictionaryEntry {
updated_at: string
}
export interface DailyUsage {
export type DailyUsage = {
id: number
user_id: string
date: string // YYYY-MM-DD
@ -145,7 +144,7 @@ export interface DailyUsage {
count: number
}
export interface Subscription {
export type Subscription = {
id: string
user_id: string
tier: SubscriptionTier
@ -159,97 +158,78 @@ export interface Subscription {
updated_at: string
}
/**
* 유틸: Supabase GenericTable (Row: Record<string, unknown>)
* Row/Insert/Update에 index signature를 .
* Profile specific type alias는 `Record<string, unknown>` subtype으로
* assign되지 , Database TypedTable로 .
*/
type TypedTable<TRow, TInsert, TUpdate> = {
Row: TRow & Record<string, unknown>
Insert: TInsert & Record<string, unknown>
Update: TUpdate & Record<string, unknown>
Relationships: []
}
/**
* DB SupabaseClient<Database> .
* Supabase CLI의 `supabase gen types typescript` .
* `@supabase/postgrest-js` GenericSchema constraint와 :
* { Tables: Record<string, GenericTable>; Views: ...; Functions: ... }
*/
export type Database = {
__InternalSupabase: {
PostgrestVersion: '12'
}
public: {
Tables: {
profiles: {
Row: Profile
Insert: Partial<Profile> & Pick<Profile, 'id'>
Update: Partial<Profile>
Relationships: []
}
teams: {
Row: Team
Insert: Omit<Team, 'id' | 'created_at' | 'updated_at'> & Partial<Pick<Team, 'id'>>
Update: Partial<Team>
Relationships: []
}
team_members: {
Row: TeamMember
Insert: Omit<TeamMember, 'joined_at'> & Partial<Pick<TeamMember, 'joined_at'>>
Update: Partial<TeamMember>
Relationships: []
}
meetings: {
Row: Meeting
Insert: Partial<Meeting> & Pick<Meeting, 'user_id'>
Update: Partial<Meeting>
Relationships: []
}
meeting_memos: {
Row: MeetingMemo
Insert: Omit<MeetingMemo, 'id' | 'created_at'> &
Partial<Pick<MeetingMemo, 'id' | 'created_at'>>
Update: Partial<MeetingMemo>
Relationships: []
}
meeting_documents: {
Row: MeetingDocument
Insert: Omit<MeetingDocument, 'id' | 'created_at' | 'updated_at'> &
Partial<Pick<MeetingDocument, 'id' | 'created_at' | 'updated_at'>>
Update: Partial<MeetingDocument>
Relationships: []
}
transcripts: {
Row: Transcript
Insert: Omit<Transcript, 'id' | 'created_at' | 'updated_at'> &
Partial<Pick<Transcript, 'id' | 'created_at' | 'updated_at'>>
Update: Partial<Transcript>
Relationships: []
}
history: {
Row: HistoryEntry
Insert: Partial<HistoryEntry> & Pick<HistoryEntry, 'user_id' | 'original_text' | 'duration'>
Update: Partial<HistoryEntry>
Relationships: []
}
dictionary: {
Row: DictionaryEntry
Insert: Partial<DictionaryEntry> & Pick<DictionaryEntry, 'user_id' | 'word'>
Update: Partial<DictionaryEntry>
Relationships: []
}
daily_usage: {
Row: DailyUsage
Insert: Omit<DailyUsage, 'id'>
Update: Partial<DailyUsage>
Relationships: []
}
subscriptions: {
Row: Subscription
Insert: Partial<Subscription> & Pick<Subscription, 'user_id'>
Update: Partial<Subscription>
Relationships: []
}
}
Views: {
[_ in never]: never
}
Functions: {
[_ in never]: never
}
Enums: {
[_ in never]: never
}
CompositeTypes: {
[_ in never]: never
profiles: TypedTable<Profile, Partial<Profile> & Pick<Profile, 'id'>, Partial<Profile>>
teams: TypedTable<
Team,
Omit<Team, 'id' | 'created_at' | 'updated_at'> & Partial<Pick<Team, 'id'>>,
Partial<Team>
>
team_members: TypedTable<
TeamMember,
Omit<TeamMember, 'joined_at'> & Partial<Pick<TeamMember, 'joined_at'>>,
Partial<TeamMember>
>
meetings: TypedTable<
Meeting,
Partial<Meeting> & Pick<Meeting, 'user_id'>,
Partial<Meeting>
>
meeting_memos: TypedTable<
MeetingMemo,
Omit<MeetingMemo, 'id' | 'created_at'> & Partial<Pick<MeetingMemo, 'id' | 'created_at'>>,
Partial<MeetingMemo>
>
meeting_documents: TypedTable<
MeetingDocument,
Omit<MeetingDocument, 'id' | 'created_at' | 'updated_at'> &
Partial<Pick<MeetingDocument, 'id' | 'created_at' | 'updated_at'>>,
Partial<MeetingDocument>
>
transcripts: TypedTable<
Transcript,
Omit<Transcript, 'id' | 'created_at' | 'updated_at'> &
Partial<Pick<Transcript, 'id' | 'created_at' | 'updated_at'>>,
Partial<Transcript>
>
history: TypedTable<
HistoryEntry,
Partial<HistoryEntry> & Pick<HistoryEntry, 'user_id' | 'original_text' | 'duration'>,
Partial<HistoryEntry>
>
dictionary: TypedTable<
DictionaryEntry,
Partial<DictionaryEntry> & Pick<DictionaryEntry, 'user_id' | 'word'>,
Partial<DictionaryEntry>
>
daily_usage: TypedTable<DailyUsage, Omit<DailyUsage, 'id'>, Partial<DailyUsage>>
subscriptions: TypedTable<
Subscription,
Partial<Subscription> & Pick<Subscription, 'user_id'>,
Partial<Subscription>
>
}
Views: Record<string, never>
Functions: Record<string, never>
}
}