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
|
|
@ -20,6 +20,7 @@ import type {
|
|||
} from '@d3ro/core/types'
|
||||
import { Feature } from '@d3ro/core/types'
|
||||
import { normalizeEntitlementTier } from '@d3ro/core/entitlement'
|
||||
import { PLAN_QUOTA } from '@d3ro/core/plan-catalog'
|
||||
import { verifySignedLicenseKey, createDefaultTrialPayload } from '@d3ro/core/utils/crypto-license'
|
||||
|
||||
const logger = getLogger('license')
|
||||
|
|
@ -56,20 +57,22 @@ function generateMachineId(): string {
|
|||
// 클라이언트에서는 PREMIUM_LLM feature로 묶어서 canUse() 체크하고,
|
||||
// 실제 모델별 세분화는 서버 llm-proxy가 담당.
|
||||
// 여기의 값은 Settings UI 표시용 + upgrade 유도 시점 판단용.
|
||||
const QUOTA_LIMITS: Record<LicenseTier, Partial<Record<Feature, number>>> = {
|
||||
free: {
|
||||
// Haiku만, 250/주간. 클라이언트에서는 대략적 일환산(~36/일)으로 표시.
|
||||
[Feature.PREMIUM_LLM]: 250,
|
||||
},
|
||||
pro: {
|
||||
// 모델별: Haiku 1500 + Sonnet 300 + Opus 50 = 합산 표시
|
||||
[Feature.PREMIUM_LLM]: 1850,
|
||||
},
|
||||
pro_plus: {},
|
||||
team: {},
|
||||
enterprise: {},
|
||||
// 값의 정본은 @d3ro/core PLAN_QUOTA. PREMIUM_LLM은 모델별 한도의 합으로 표시하고,
|
||||
// 한 모델이라도 무제한이면 한도를 두지 않는다(Free는 Haiku 주 250회).
|
||||
function premiumLlmLimit(tier: LicenseTier): number | undefined {
|
||||
const quota = PLAN_QUOTA[tier]
|
||||
const models = [quota.llm_haiku, quota.llm_sonnet, quota.llm_opus].filter((q) => q.limit !== 0)
|
||||
if (models.some((q) => q.limit < 0)) return undefined
|
||||
return models.reduce((sum, q) => sum + q.limit, 0)
|
||||
}
|
||||
|
||||
const QUOTA_LIMITS: Record<LicenseTier, Partial<Record<Feature, number>>> = Object.fromEntries(
|
||||
(['free', 'pro', 'pro_plus', 'team', 'enterprise'] as const).map((tier) => {
|
||||
const limit = premiumLlmLimit(tier)
|
||||
return [tier, limit === undefined ? {} : { [Feature.PREMIUM_LLM]: limit }]
|
||||
}),
|
||||
) as Record<LicenseTier, Partial<Record<Feature, number>>>
|
||||
|
||||
// ── 기능별 최소 필요 티어 ──────────────────────────────────
|
||||
// 빅뱅 Phase 4: 모든 로컬 기능을 'free'로 해방.
|
||||
// 클라우드 기능(PREMIUM_LLM, CLOUD_SYNC)만 로그인 요구 + 티어 gate.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue