refactor(core): keep plan prices, cloud quotas and public URLs in one contract (WS-A)
Prices, quotas and site URLs were copied by hand into the edge functions, admin, desktop and the landing site, and the copies disagreed (Payple billed 9,900/29,900 KRW, admin labels said 12,900/24,900 KRW and $9.9/$19.9, the site said 2,900/8,900 KRW). - packages/core/src/plan-catalog.ts is the single source for PLAN_PRICE_KRW (Free 0 / Pro 2,900 / Pro+ 8,900 a month) and PLAN_QUOTA. - packages/core/src/web-urls.ts is the single source for the public origin, the /app web-app base path, SITE_URLS and billingUrl(). - Deno cannot bundle packages/core, so scripts/ci/sync-core-contract.mjs generates _shared/core-contract.generated.ts; `npm run contract:check` fails on drift (same pattern as version:sync). - Payple checkout, renewal and webhook amount checks now bill the catalog price, so existing subscribers move to the new price at their next renewal. quota.ts, team-contract.ts and the tests read the generated values. - Admin MRR/ARR is computed in KRW from the catalog; license labels, the release link and desktop PREMIUM_LLM limits derive from core; the site imports prices and quotas directly. Policy: docs/REFACTOR_POLICY.md Wave 3, W3-1 and W3-2.
This commit is contained in:
parent
e689683b72
commit
88f24d84a1
21 changed files with 568 additions and 152 deletions
|
|
@ -3,64 +3,25 @@
|
|||
// Free=Haiku 250/주간, Pro=모델별 일간, Pro+=Haiku 무제한
|
||||
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
import {
|
||||
PLAN_QUOTA,
|
||||
type PlanQuota,
|
||||
type PlanQuotaFeature,
|
||||
type PlanQuotaPeriod,
|
||||
type PlanQuotaTier,
|
||||
} from './core-contract.generated.ts'
|
||||
|
||||
export type Tier = 'free' | 'pro' | 'pro_plus' | 'team' | 'enterprise'
|
||||
export type Tier = PlanQuotaTier
|
||||
|
||||
/** 쿼터 추적 키 — 모델별 분리 */
|
||||
export type QuotaFeature =
|
||||
| 'stt_transcribe'
|
||||
| 'llm_haiku'
|
||||
| 'llm_sonnet'
|
||||
| 'llm_opus'
|
||||
| 'realtime_session'
|
||||
export type QuotaFeature = PlanQuotaFeature
|
||||
|
||||
export type QuotaPeriod = 'daily' | 'weekly'
|
||||
export type QuotaPeriod = PlanQuotaPeriod
|
||||
|
||||
interface ModelQuota {
|
||||
/** -1=무제한, 0=사용불가, 양수=한도 */
|
||||
limit: number
|
||||
period: QuotaPeriod
|
||||
}
|
||||
type ModelQuota = PlanQuota
|
||||
|
||||
/** 모델별 쿼터 정책 */
|
||||
const MODEL_QUOTA: Record<Tier, Record<QuotaFeature, ModelQuota>> = {
|
||||
free: {
|
||||
stt_transcribe: { limit: 250, period: 'weekly' },
|
||||
llm_haiku: { limit: 250, period: 'weekly' },
|
||||
llm_sonnet: { limit: 0, period: 'daily' }, // 사용불가
|
||||
llm_opus: { limit: 0, period: 'daily' }, // 사용불가
|
||||
realtime_session: { limit: 0, period: 'daily' }, // 사용불가
|
||||
},
|
||||
pro: {
|
||||
stt_transcribe: { limit: -1, period: 'daily' },
|
||||
llm_haiku: { limit: 1500, period: 'daily' },
|
||||
llm_sonnet: { limit: 300, period: 'daily' },
|
||||
llm_opus: { limit: 50, period: 'daily' },
|
||||
// 세션 수 기준 (~$0.016/분 mini — 세션당 평균 수 분 가정)
|
||||
realtime_session: { limit: 30, period: 'daily' },
|
||||
},
|
||||
pro_plus: {
|
||||
stt_transcribe: { limit: -1, period: 'daily' },
|
||||
llm_haiku: { limit: -1, period: 'daily' }, // 무제한
|
||||
llm_sonnet: { limit: 1500, period: 'daily' },
|
||||
llm_opus: { limit: 300, period: 'daily' },
|
||||
realtime_session: { limit: 120, period: 'daily' },
|
||||
},
|
||||
team: {
|
||||
stt_transcribe: { limit: -1, period: 'daily' },
|
||||
llm_haiku: { limit: -1, period: 'daily' }, // 무제한
|
||||
llm_sonnet: { limit: 3000, period: 'daily' },
|
||||
llm_opus: { limit: 600, period: 'daily' },
|
||||
realtime_session: { limit: 300, period: 'daily' },
|
||||
},
|
||||
enterprise: {
|
||||
stt_transcribe: { limit: -1, period: 'daily' },
|
||||
llm_haiku: { limit: -1, period: 'daily' }, // 무제한
|
||||
llm_sonnet: { limit: -1, period: 'daily' }, // 무제한
|
||||
llm_opus: { limit: -1, period: 'daily' }, // 무제한
|
||||
realtime_session: { limit: -1, period: 'daily' }, // 무제한
|
||||
},
|
||||
}
|
||||
/** 모델별 쿼터 정책. 정본은 packages/core/src/plan-catalog.ts `PLAN_QUOTA` (생성 사본 경유). */
|
||||
const MODEL_QUOTA: Readonly<Record<Tier, Readonly<Record<QuotaFeature, ModelQuota>>>> = PLAN_QUOTA
|
||||
|
||||
/** Anthropic 모델명 → 쿼터 키 매핑 */
|
||||
export function modelToQuotaKey(model: string): QuotaFeature {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue