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:
parent
37f3f4d5bd
commit
c167737198
26 changed files with 1530 additions and 374 deletions
74
server/supabase/migrations/20260410000001_team_invites.sql
Normal file
74
server/supabase/migrations/20260410000001_team_invites.sql
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
-- ============================================================================
|
||||
-- Phase V2-7b: 팀 초대 플로우 — team_invites 테이블
|
||||
-- 이메일 기반 초대 토큰. accept endpoint에서 토큰 검증 후 team_members에 추가.
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE public.team_invites (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
team_id uuid NOT NULL REFERENCES public.teams(id) ON DELETE CASCADE,
|
||||
invited_by uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
|
||||
email text NOT NULL,
|
||||
role text NOT NULL CHECK (role IN ('admin', 'member')) DEFAULT 'member',
|
||||
token text NOT NULL UNIQUE,
|
||||
accepted_at timestamptz,
|
||||
accepted_by uuid REFERENCES auth.users(id) ON DELETE SET NULL,
|
||||
expires_at timestamptz NOT NULL DEFAULT (now() + interval '7 days'),
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_team_invites_team_id ON public.team_invites(team_id);
|
||||
CREATE INDEX idx_team_invites_token ON public.team_invites(token);
|
||||
CREATE INDEX idx_team_invites_email ON public.team_invites(email);
|
||||
|
||||
-- RLS
|
||||
ALTER TABLE public.team_invites ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- SELECT: 같은 팀 멤버는 초대 목록 조회 가능, 본인 이메일로 온 초대도 조회 가능
|
||||
CREATE POLICY "team_invites_read" ON public.team_invites
|
||||
FOR SELECT USING (
|
||||
team_id IN (SELECT team_id FROM public.team_members WHERE user_id = auth.uid())
|
||||
OR lower(email) = lower((SELECT email FROM auth.users WHERE id = auth.uid()))
|
||||
);
|
||||
|
||||
-- INSERT: 팀 owner/admin만 초대 생성
|
||||
CREATE POLICY "team_invites_insert_admin" ON public.team_invites
|
||||
FOR INSERT WITH CHECK (
|
||||
invited_by = auth.uid()
|
||||
AND team_id IN (
|
||||
SELECT team_id FROM public.team_members
|
||||
WHERE user_id = auth.uid() AND role IN ('owner', 'admin')
|
||||
)
|
||||
);
|
||||
|
||||
-- DELETE: owner/admin 또는 초대 당사자 취소
|
||||
CREATE POLICY "team_invites_delete" ON public.team_invites
|
||||
FOR DELETE USING (
|
||||
invited_by = auth.uid()
|
||||
OR team_id IN (
|
||||
SELECT team_id FROM public.team_members
|
||||
WHERE user_id = auth.uid() AND role IN ('owner', 'admin')
|
||||
)
|
||||
);
|
||||
|
||||
-- UPDATE는 Edge Function(service_role)에서 accepted_at/accepted_by 세팅용
|
||||
|
||||
-- ============================================================================
|
||||
-- 토큰 생성 헬퍼 (service_role RPC) — 암호학적 난수
|
||||
-- ============================================================================
|
||||
CREATE OR REPLACE FUNCTION public.generate_invite_token()
|
||||
RETURNS text
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
AS $$
|
||||
DECLARE
|
||||
v_token text;
|
||||
BEGIN
|
||||
v_token := encode(gen_random_bytes(24), 'base64');
|
||||
-- URL-safe 문자로 변환
|
||||
v_token := replace(replace(replace(v_token, '+', '-'), '/', '_'), '=', '');
|
||||
RETURN v_token;
|
||||
END;
|
||||
$$;
|
||||
|
||||
REVOKE ALL ON FUNCTION public.generate_invite_token FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION public.generate_invite_token TO service_role;
|
||||
Loading…
Add table
Add a link
Reference in a new issue