Repository navigation
Conversation
With authScheme "publishable", getCatalog reads GET /api/public/catalog, the one route a pk_ key authorizes, and maps it to the SDK's catalogue (billing spec 14.5): the default monthly and annual flat fees become price and annualPrice, periods become intervals (quarterly is month x 3), metered prices keep their sale unit and exact decimal, and each plan lists the public add-ons that fit it. Public mode never falls back to GraphQL or the REST fan-out: both refuse a publishable key, and the key has no business being sent there. Every new field is optional, so the client stays on 1.x. The wire types are written by hand until contract-drift brings the route into contracts/. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tom Ribuot <tom.ribuot@kaiten.sh>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The client side of kaitencloud/kaiten#32: in public mode (
authScheme: "publishable", apk_key),components.getCatalog()now readsGET /api/public/catalog, the only route a publishable key authorizes. Before this, public mode asked GraphQL, which answers 401 to apk_.Stacked on #2 (
feat/billing).Behaviour
X-Kaiten-Publishable-Keyto/public/catalogand nowhere else. It never falls back to GraphQL or the REST fan-out: both refuse the key, and the key has no business being sent there (billing spec §14.6.1). A refused key rejects with the API's 401/403, andonDegradeddoes not fire.Mapping (§14.5)
unitAmountPlan.price/Plan.annualPrice, minor unitsbillingPeriodinterval, plus newintervalCount(quarterly = month × 3, semi-annual = month × 6)currencycurrencyCodefamilySlugPlan.familyIdlifecycleStatepublished,lifecycleStatetype+ innervalueEntitlementValue({ type: "number", value }),unlimited, presentation fieldscompatibleAddonFamiliesPlan.addOns, resolved against the public add-onsAll new fields are optional, so the client stays on 1.x:
PlanPrice:id,intervalCount,unitAmountDecimal,billingModel,meteredEntitlementSlug,saleUnitFactor,isDefault;Plan:pricingType,selfServe,selfServeCtaUrl,trialPeriodDays,requiresPaymentMethod;Addon:familySlug,maxQuantity;KaitenCatalog:addOns,capabilities.§14.5 says a fractional-minor-unit price (
unitAmountabsent, e.g. €0.005 per token) must never go intoamount. ButPlanPrice.amountis a requirednumber, and making it optional would break every consumer's types. So such a price carries the exact decimal inunitAmountDecimal, andamountis that same fraction as a number (0.5), documented on the field. Components must format metered prices fromunitAmountDecimal, per sale unit, and never add them to a headline. Flat fees are always whole minor units, soprice/annualPriceare unaffected.For the React SDK (
PricingTable)plan.selfServe: whenfalse, renderplan.selfServeCtaUrl("Contact us"), always forpricingType: "CUSTOM".billingModelUSAGE_BASED/OVERAGE. Render them "persaleUnitFactorunits", not as a monthly headline.catalog.capabilities.checkoutisfalseuntil customer sessions ship.Notes
src/client/public-catalog.ts, written by hand.contracts/openapi.yamlfollows released kaiten versions and this route is newer; when contract-drift brings it in, the generated types can replace them and the mapping stays.Tests
vp run -r build && vp check && vp test: 221 passing./public/catalogwith the key and noAuthorization;