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:
Yun Chan 2026-09-26 15:48:18 +09:00
parent e689683b72
commit 88f24d84a1
21 changed files with 568 additions and 152 deletions

View file

@ -1,5 +1,6 @@
// src/shared/constants.ts
import type { LicenseTier } from './types'
import { PLAN_QUOTA, type PlanQuotaFeature, type PlanQuotaPeriod } from './plan-catalog'
/** 타이밍 상수 (Speakly 리버스엔지니어링 기반) */
export const TIMING = {
@ -51,39 +52,34 @@ export const AUDIO_FORMAT = {
BYTES_PER_SAMPLE: 2
} as const
/** Premium 모델별 쿼터 한도 (LicenseService QUOTA_LIMITS, 서버 quota.ts와 동기) */
/** Premium 모델별 쿼터 표시 행. 값의 정본은 plan-catalog.ts `PLAN_QUOTA`(서버 quota.ts도 같은 값을 생성 사본으로 읽는다). */
export interface PremiumModelQuota {
readonly model: string
readonly model: PlanQuotaFeature
readonly i18nKey: string
readonly limit: number // -1 = 무제한
readonly period: 'daily' | 'weekly'
readonly period: PlanQuotaPeriod
}
const PREMIUM_MODEL_ROWS: readonly { model: PlanQuotaFeature; i18nKey: string }[] = [
{ model: 'llm_haiku', i18nKey: 'license.modelHaiku' },
{ model: 'llm_sonnet', i18nKey: 'license.modelSonnet' },
{ model: 'llm_opus', i18nKey: 'license.modelOpus' },
]
function premiumModelLimits(tier: LicenseTier): readonly PremiumModelQuota[] {
// limit 0(사용 불가) 모델은 표시하지 않는다 — Free 는 Haiku 한 줄만 남는다.
return PREMIUM_MODEL_ROWS
.map(({ model, i18nKey }) => ({ model, i18nKey, ...PLAN_QUOTA[tier][model] }))
.filter((row) => row.limit !== 0)
}
export const PREMIUM_MODEL_LIMITS: Record<LicenseTier, readonly PremiumModelQuota[]> = {
free: [
{ model: 'llm_haiku', i18nKey: 'license.modelHaiku', limit: 250, period: 'weekly' },
],
pro: [
{ model: 'llm_haiku', i18nKey: 'license.modelHaiku', limit: 1500, period: 'daily' },
{ model: 'llm_sonnet', i18nKey: 'license.modelSonnet', limit: 300, period: 'daily' },
{ model: 'llm_opus', i18nKey: 'license.modelOpus', limit: 50, period: 'daily' },
],
pro_plus: [
{ model: 'llm_haiku', i18nKey: 'license.modelHaiku', limit: -1, period: 'daily' },
{ model: 'llm_sonnet', i18nKey: 'license.modelSonnet', limit: 1500, period: 'daily' },
{ model: 'llm_opus', i18nKey: 'license.modelOpus', limit: 300, period: 'daily' },
],
team: [
{ model: 'llm_haiku', i18nKey: 'license.modelHaiku', limit: -1, period: 'daily' },
{ model: 'llm_sonnet', i18nKey: 'license.modelSonnet', limit: 3000, period: 'daily' },
{ model: 'llm_opus', i18nKey: 'license.modelOpus', limit: 600, period: 'daily' },
],
enterprise: [
{ model: 'llm_haiku', i18nKey: 'license.modelHaiku', limit: -1, period: 'daily' },
{ model: 'llm_sonnet', i18nKey: 'license.modelSonnet', limit: -1, period: 'daily' },
{ model: 'llm_opus', i18nKey: 'license.modelOpus', limit: -1, period: 'daily' },
],
} as const
free: premiumModelLimits('free'),
pro: premiumModelLimits('pro'),
pro_plus: premiumModelLimits('pro_plus'),
team: premiumModelLimits('team'),
enterprise: premiumModelLimits('enterprise'),
}
/** 윈도우 크기 */
export const WINDOW_SIZE = {