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
|
|
@ -1,28 +1,23 @@
|
|||
// site/src/pricing.ts
|
||||
// 요금제 표시 SSOT. 결제 금액의 정본은 서버 결제 카탈로그
|
||||
// (server/supabase/functions/_shared/billing-catalog.ts, payple.ts)이며,
|
||||
// 여기 값은 그 카탈로그와 같아야 한다. 사용량 한도는
|
||||
// packages/core/src/constants.ts의 PREMIUM_MODEL_LIMITS와 같은 값이다.
|
||||
// 요금제 카드에 넣을 클라우드 사용량 표시값. 값의 정본은
|
||||
// packages/core/src/plan-catalog.ts `PLAN_QUOTA`(서버 quota.ts도 같은 값을 쓴다)이고,
|
||||
// 여기서는 i18n 문구의 {haiku}/{sonnet}/{opus} 자리표시자 이름으로 바꾸기만 한다.
|
||||
// 가격(PLAN_PRICE_KRW)과 결제 링크(billingUrl)는 Pricing.tsx 가 정본에서 직접 읽는다.
|
||||
|
||||
export type PaidTier = 'pro' | 'pro_plus'
|
||||
import { PLAN_QUOTA, type PlanQuotaFeature, type PlanTier } from '../../packages/core/src/plan-catalog'
|
||||
|
||||
/** 월 요금(원). */
|
||||
export const PLAN_PRICE_KRW = {
|
||||
free: 0,
|
||||
pro: 2900,
|
||||
proPlus: 8900,
|
||||
} as const
|
||||
const QUOTA_PLACEHOLDERS: ReadonlyArray<readonly [placeholder: string, feature: PlanQuotaFeature]> = [
|
||||
['haiku', 'llm_haiku'],
|
||||
['sonnet', 'llm_sonnet'],
|
||||
['opus', 'llm_opus'],
|
||||
]
|
||||
|
||||
/** 클라우드 다듬기 사용량. -1은 무제한. Free는 주간, 유료는 일간. */
|
||||
export const PLAN_CLOUD_QUOTA = {
|
||||
free: { haiku: 250 },
|
||||
pro: { haiku: 1500, sonnet: 300, opus: 50 },
|
||||
proPlus: { haiku: -1, sonnet: 1500, opus: 300 },
|
||||
} as const
|
||||
|
||||
/** 데스크톱 앱 결제 완료 URL과 같은 웹 결제 페이지. */
|
||||
const BILLING_URL = 'https://d3ro.chanpaca.net/billing'
|
||||
|
||||
export function billingUrl(tier: PaidTier): string {
|
||||
return `${BILLING_URL}?tier=${tier}`
|
||||
/** 클라우드 다듬기 사용량. -1은 무제한. Free는 주간, 유료는 일간. 사용 불가(0) 모델은 뺀다. */
|
||||
export function planCloudQuota(tier: PlanTier): Record<string, number> {
|
||||
const quota: Record<string, number> = {}
|
||||
for (const [placeholder, feature] of QUOTA_PLACEHOLDERS) {
|
||||
const { limit } = PLAN_QUOTA[tier][feature]
|
||||
if (limit !== 0) quota[placeholder] = limit
|
||||
}
|
||||
return quota
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ import { Container } from '../components/Container'
|
|||
import { SectionHeading } from '../components/SectionHeading'
|
||||
import { CheckIcon, ExternalIcon } from '../components/icons'
|
||||
import { fmt, useI18n, type PlanCopy } from '../i18n'
|
||||
import { PLAN_CLOUD_QUOTA, PLAN_PRICE_KRW, billingUrl } from '../pricing'
|
||||
import { PLAN_PRICE_KRW } from '../../../packages/core/src/plan-catalog'
|
||||
import { billingUrl } from '../../../packages/core/src/web-urls'
|
||||
import { planCloudQuota } from '../pricing'
|
||||
|
||||
interface PlanView {
|
||||
key: 'free' | 'pro' | 'proPlus'
|
||||
|
|
@ -22,9 +24,9 @@ export function Pricing() {
|
|||
const quotaValue = (n: number) => (n < 0 ? t.pricing.unlimited : count.format(n))
|
||||
|
||||
const plans: PlanView[] = [
|
||||
{ key: 'free', copy: t.pricing.free, price: PLAN_PRICE_KRW.free, quota: PLAN_CLOUD_QUOTA.free, href: '#download', external: false, emphasized: false },
|
||||
{ key: 'pro', copy: t.pricing.pro, price: PLAN_PRICE_KRW.pro, quota: PLAN_CLOUD_QUOTA.pro, href: billingUrl('pro'), external: true, emphasized: true },
|
||||
{ key: 'proPlus', copy: t.pricing.proPlus, price: PLAN_PRICE_KRW.proPlus, quota: PLAN_CLOUD_QUOTA.proPlus, href: billingUrl('pro_plus'), external: true, emphasized: false },
|
||||
{ key: 'free', copy: t.pricing.free, price: PLAN_PRICE_KRW.free, quota: planCloudQuota('free'), href: '#download', external: false, emphasized: false },
|
||||
{ key: 'pro', copy: t.pricing.pro, price: PLAN_PRICE_KRW.pro, quota: planCloudQuota('pro'), href: billingUrl({ tier: 'pro' }), external: true, emphasized: true },
|
||||
{ key: 'proPlus', copy: t.pricing.proPlus, price: PLAN_PRICE_KRW.pro_plus, quota: planCloudQuota('pro_plus'), href: billingUrl({ tier: 'pro_plus' }), external: true, emphasized: false },
|
||||
]
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue