feat(commands): multi-select ordered command pipeline with step reordering and single-pass composition (AI-05, AI-07)
This commit is contained in:
parent
f49acf0105
commit
10af20a0ad
157 changed files with 29455 additions and 913 deletions
|
|
@ -14,6 +14,11 @@ import {
|
|||
type BillingCatalog,
|
||||
type BillingCatalogPrice
|
||||
} from '@/lib/billing-catalog'
|
||||
import {
|
||||
isSupportedWebTier,
|
||||
resolveWebEntitlement,
|
||||
resolveWebProvider
|
||||
} from '@/lib/entitlement'
|
||||
|
||||
type BillingProvider = Subscription['provider']
|
||||
|
||||
|
|
@ -43,17 +48,6 @@ interface Plan {
|
|||
highlight?: boolean
|
||||
}
|
||||
|
||||
const VALID_TIERS = new Set<SubscriptionTier>(['free', 'pro', 'pro_plus'])
|
||||
// 'stripe' 는 결제 경로가 제거된 뒤에도 과거 구독 행(provider='stripe')을 읽기 위해 남긴다.
|
||||
const VALID_PROVIDERS = new Set<BillingProvider>([
|
||||
'none',
|
||||
'stripe',
|
||||
'payple',
|
||||
'google_play',
|
||||
'app_store',
|
||||
'admin'
|
||||
])
|
||||
|
||||
const PLANS: Plan[] = [
|
||||
{
|
||||
tier: 'free',
|
||||
|
|
@ -124,12 +118,12 @@ async function loadBillingState(): Promise<BillingState> {
|
|||
|
||||
if (error) throw new Error('subscription_lookup_failed')
|
||||
if (!data) throw new Error('subscription_not_initialized')
|
||||
if (!VALID_TIERS.has(data.tier)) throw new Error('subscription_tier_invalid')
|
||||
if (!isSupportedWebTier(data.tier)) throw new Error('subscription_tier_invalid')
|
||||
|
||||
const providerCandidate = data.provider === 'none' && data.payment_provider !== 'none'
|
||||
? data.payment_provider
|
||||
: data.provider
|
||||
if (!VALID_PROVIDERS.has(providerCandidate)) throw new Error('subscription_provider_invalid')
|
||||
const providerCandidate = resolveWebProvider(data.provider, data.payment_provider)
|
||||
if (!providerCandidate) throw new Error('subscription_provider_invalid')
|
||||
|
||||
const resolvedEntitlement = resolveWebEntitlement(data)
|
||||
|
||||
const { data: catalogData, error: catalogError } = await supabase.functions.invoke('billing-catalog', {
|
||||
body: {}
|
||||
|
|
@ -139,12 +133,12 @@ async function loadBillingState(): Promise<BillingState> {
|
|||
return {
|
||||
email: userData.user.email ?? '이메일 없음',
|
||||
subscription: {
|
||||
tier: data.tier,
|
||||
status: data.status,
|
||||
tier: resolvedEntitlement.tier,
|
||||
status: resolvedEntitlement.status,
|
||||
provider: providerCandidate,
|
||||
current_period_end: data.current_period_end,
|
||||
cancel_at: data.cancel_at,
|
||||
auto_renewing: data.auto_renewing
|
||||
current_period_end: resolvedEntitlement.currentPeriodEnd,
|
||||
cancel_at: resolvedEntitlement.cancelAt,
|
||||
auto_renewing: resolvedEntitlement.autoRenewing
|
||||
},
|
||||
catalog
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,10 @@ export default async function MeetingDetailPage({ params }: PageProps): Promise<
|
|||
<PhosphorText variant="heading" sx={{ mb: 2 }}>
|
||||
AUDIO
|
||||
</PhosphorText>
|
||||
<MeetingAudioPlayer storageKey={meeting.audio_storage_key ?? null} />
|
||||
<MeetingAudioPlayer
|
||||
storageKey={meeting.audio_storage_key ?? null}
|
||||
meetingId={id}
|
||||
/>
|
||||
</MetalCard>
|
||||
|
||||
{/* Transcript — Realtime 구독 or raw_transcript fallback */}
|
||||
|
|
@ -73,23 +76,14 @@ export default async function MeetingDetailPage({ params }: PageProps): Promise<
|
|||
<PhosphorText variant="heading" sx={{ mb: 2 }}>
|
||||
TRANSCRIPT {meeting.status === 'recording' ? '(LIVE)' : ''}
|
||||
</PhosphorText>
|
||||
{(transcripts ?? []).length > 0 || meeting.status === 'recording' ? (
|
||||
{(transcripts ?? []).length > 0
|
||||
|| meeting.status === 'recording'
|
||||
|| Boolean(meeting.edited_transcript || meeting.raw_transcript) ? (
|
||||
<LiveTranscriptList
|
||||
meetingId={id}
|
||||
initial={(transcripts ?? []) as unknown as TranscriptRow[]}
|
||||
fallbackTranscript={meeting.edited_transcript ?? meeting.raw_transcript ?? null}
|
||||
/>
|
||||
) : meeting.edited_transcript || meeting.raw_transcript ? (
|
||||
<Box
|
||||
sx={{
|
||||
whiteSpace: 'pre-wrap',
|
||||
color: d3roPalette.text.primary,
|
||||
fontSize: 13,
|
||||
lineHeight: 1.6,
|
||||
fontFamily: 'inherit'
|
||||
}}
|
||||
>
|
||||
{meeting.edited_transcript ?? meeting.raw_transcript}
|
||||
</Box>
|
||||
) : (
|
||||
<Box sx={{ color: d3roPalette.text.muted, fontSize: 13 }}>
|
||||
전사가 없습니다.
|
||||
|
|
|
|||
5
apps/web/src/app/(app)/team/page.tsx
Normal file
5
apps/web/src/app/(app)/team/page.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { redirect } from 'next/navigation'
|
||||
|
||||
export default function TeamAliasPage(): never {
|
||||
redirect('/teams')
|
||||
}
|
||||
237
apps/web/src/app/accept-invite/page.tsx
Normal file
237
apps/web/src/app/accept-invite/page.tsx
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
'use client'
|
||||
|
||||
import Link from 'next/link'
|
||||
import { Suspense, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useRouter, useSearchParams } from 'next/navigation'
|
||||
import { Alert, Box, CircularProgress, Stack, Typography } from '@mui/material'
|
||||
import { CheckCircle2, RefreshCw, ShieldAlert, Users } from 'lucide-react'
|
||||
import { MetalCard, PhysicalButton, TactileBadge } from '@d3ro/ui/components/ds'
|
||||
import { d3roFontMono, d3roFontSans } from '@d3ro/ui/theme'
|
||||
import { useAuth } from '@/components/providers/auth-provider'
|
||||
import { getSupabaseBrowserClient, isSupabaseConfigured } from '@/lib/supabase-browser'
|
||||
|
||||
const INVITE_TOKEN_PATTERN =
|
||||
/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[A-Za-z0-9_-]{32})$/i
|
||||
|
||||
interface TeamAcceptEdgePayload {
|
||||
data?: {
|
||||
team_id?: unknown
|
||||
role?: unknown
|
||||
}
|
||||
team_id?: unknown
|
||||
role?: unknown
|
||||
error?: {
|
||||
code?: unknown
|
||||
message?: unknown
|
||||
}
|
||||
}
|
||||
|
||||
type InviteAcceptState =
|
||||
| { status: 'checking'; message: string }
|
||||
| { status: 'accepting'; message: string }
|
||||
| { status: 'accepted'; teamId: string | null; role: string }
|
||||
| { status: 'invalid-token'; message: string }
|
||||
| { status: 'error'; message: string }
|
||||
|
||||
export function validateWebInviteToken(rawToken: string | null | undefined): string | null {
|
||||
const trimmed = rawToken?.trim() ?? ''
|
||||
return INVITE_TOKEN_PATTERN.test(trimmed) ? trimmed : null
|
||||
}
|
||||
|
||||
export function buildAcceptInviteLoginRedirect(token: string): string {
|
||||
const nextPath = `/app/accept-invite?token=${encodeURIComponent(token)}`
|
||||
return `/login?next=${encodeURIComponent(nextPath)}`
|
||||
}
|
||||
|
||||
function parseTeamAcceptResponse(payload: unknown): { teamId: string | null; role: string } {
|
||||
if (typeof payload !== 'object' || payload === null) {
|
||||
return { teamId: null, role: 'member' }
|
||||
}
|
||||
const record = payload as TeamAcceptEdgePayload
|
||||
const inner = record.data ?? record
|
||||
const teamId = typeof inner.team_id === 'string' && inner.team_id.trim() ? inner.team_id : null
|
||||
const role = typeof inner.role === 'string' && inner.role.trim() ? inner.role : 'member'
|
||||
return { teamId, role }
|
||||
}
|
||||
|
||||
function AcceptInviteContent(): React.ReactElement {
|
||||
const router = useRouter()
|
||||
const searchParams = useSearchParams()
|
||||
const { user, loading: authLoading } = useAuth()
|
||||
const rawToken = searchParams.get('token')
|
||||
const validToken = validateWebInviteToken(rawToken)
|
||||
const attemptedTokenRef = useRef<string | null>(null)
|
||||
|
||||
const [state, setState] = useState<InviteAcceptState>(() => (
|
||||
validToken
|
||||
? { status: 'checking', message: '로그인 세션과 초대 토큰을 확인하고 있습니다.' }
|
||||
: {
|
||||
status: 'invalid-token',
|
||||
message: '초대 링크가 없거나 형식이 올바르지 않습니다. 새 초대 링크를 요청해 주세요.'
|
||||
}
|
||||
))
|
||||
|
||||
const acceptInvite = useCallback(async (tokenToAccept: string): Promise<void> => {
|
||||
if (!isSupabaseConfigured()) {
|
||||
setState({
|
||||
status: 'error',
|
||||
message: 'Supabase 연결 설정을 확인할 수 없어 초대를 수락할 수 없습니다.'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
setState({
|
||||
status: 'accepting',
|
||||
message: '팀 초대 권한을 검증하고 워크스페이스에 참여하는 중입니다.'
|
||||
})
|
||||
|
||||
try {
|
||||
const supabase = getSupabaseBrowserClient()
|
||||
const { data, error } = await supabase.functions.invoke('team-accept', {
|
||||
body: { token: tokenToAccept }
|
||||
})
|
||||
|
||||
if (error) {
|
||||
setState({
|
||||
status: 'error',
|
||||
message: error.message || '팀 초대 수락에 실패했습니다. 만료되었거나 권한이 없는 초대일 수 있습니다.'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const parsed = parseTeamAcceptResponse(data)
|
||||
setState({
|
||||
status: 'accepted',
|
||||
teamId: parsed.teamId,
|
||||
role: parsed.role
|
||||
})
|
||||
router.replace('/team')
|
||||
} catch (invokeError) {
|
||||
setState({
|
||||
status: 'error',
|
||||
message: invokeError instanceof Error
|
||||
? invokeError.message
|
||||
: '팀 초대 수락 요청 중 오류가 발생했습니다.'
|
||||
})
|
||||
}
|
||||
}, [router])
|
||||
|
||||
useEffect(() => {
|
||||
if (!validToken) {
|
||||
setState({
|
||||
status: 'invalid-token',
|
||||
message: '초대 링크가 없거나 형식이 올바르지 않습니다. 새 초대 링크를 요청해 주세요.'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (authLoading) return
|
||||
|
||||
if (!user) {
|
||||
router.replace(buildAcceptInviteLoginRedirect(validToken))
|
||||
return
|
||||
}
|
||||
|
||||
if (attemptedTokenRef.current === validToken) return
|
||||
attemptedTokenRef.current = validToken
|
||||
void acceptInvite(validToken)
|
||||
}, [acceptInvite, authLoading, router, user, validToken])
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
minHeight: '100dvh',
|
||||
display: 'grid',
|
||||
placeItems: 'center',
|
||||
bgcolor: 'var(--d3-bg-app)',
|
||||
p: { xs: 2.5, md: 4 },
|
||||
fontFamily: d3roFontSans
|
||||
}}
|
||||
>
|
||||
<MetalCard sx={{ width: '100%', maxWidth: 520, p: { xs: 3, md: 4 } }}>
|
||||
<Stack spacing={2.5}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 1.5 }}>
|
||||
<TactileBadge ledColor="green" tone="accent">TEAM INVITE</TactileBadge>
|
||||
<Typography sx={{ fontFamily: d3roFontMono, fontSize: 11, color: 'var(--d3-text-label)' }}>
|
||||
{validToken ? `${validToken.slice(0, 8)}…${validToken.slice(-4)}` : 'NO TOKEN'}
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
||||
<Users size={22} color="var(--d3-accent-main)" />
|
||||
<Typography component="h1" sx={{ fontSize: 22, fontWeight: 600, color: 'var(--d3-text-primary)' }}>
|
||||
팀 초대 수락
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
{(state.status === 'checking' || state.status === 'accepting') && (
|
||||
<Box
|
||||
role="status"
|
||||
data-testid="accept-invite-loading"
|
||||
sx={{ display: 'flex', alignItems: 'center', gap: 2, py: 2 }}
|
||||
>
|
||||
<CircularProgress size={24} />
|
||||
<Typography sx={{ fontSize: 14, color: 'var(--d3-text-secondary)' }}>
|
||||
{state.message}
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{state.status === 'accepted' && (
|
||||
<Alert
|
||||
severity="success"
|
||||
icon={<CheckCircle2 size={18} />}
|
||||
data-testid="accept-invite-success"
|
||||
>
|
||||
팀 초대를 수락했습니다 ({state.role}). 팀 워크스페이스로 이동합니다.
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{(state.status === 'invalid-token' || state.status === 'error') && (
|
||||
<Alert
|
||||
severity="error"
|
||||
icon={<ShieldAlert size={18} />}
|
||||
data-testid="accept-invite-error"
|
||||
>
|
||||
{state.message}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={1.5} sx={{ pt: 1 }}>
|
||||
{state.status === 'error' && validToken && (
|
||||
<PhysicalButton
|
||||
tone="accent"
|
||||
data-testid="accept-invite-retry"
|
||||
onClick={() => {
|
||||
attemptedTokenRef.current = validToken
|
||||
void acceptInvite(validToken)
|
||||
}}
|
||||
>
|
||||
<RefreshCw size={14} /> 다시 시도
|
||||
</PhysicalButton>
|
||||
)}
|
||||
<Link href="/team" style={{ textDecoration: 'none' }}>
|
||||
<PhysicalButton tone="glass" data-testid="accept-invite-go-teams">
|
||||
팀 화면으로 이동
|
||||
</PhysicalButton>
|
||||
</Link>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</MetalCard>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
export default function AcceptInvitePage(): React.ReactElement {
|
||||
return (
|
||||
<Suspense
|
||||
fallback={(
|
||||
<Box sx={{ minHeight: '100dvh', display: 'grid', placeItems: 'center', bgcolor: 'var(--d3-bg-app)' }}>
|
||||
<CircularProgress aria-label="초대 정보 확인 중" />
|
||||
</Box>
|
||||
)}
|
||||
>
|
||||
<AcceptInviteContent />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue