@nodaro/sdk 2.49.0 → 2.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/{chunk-FIMBPKIH.cjs → chunk-4BAHF762.cjs} +43 -2
  2. package/dist/chunk-4BAHF762.cjs.map +1 -0
  3. package/dist/{chunk-5MOJSYHI.js → chunk-7QK2NXJA.js} +43 -2
  4. package/dist/chunk-7QK2NXJA.js.map +1 -0
  5. package/dist/{chunk-PPP6VZ3I.cjs → chunk-AY7XKACE.cjs} +12 -8
  6. package/dist/chunk-AY7XKACE.cjs.map +1 -0
  7. package/dist/{chunk-NOBQQTAG.cjs → chunk-FDTE4C5W.cjs} +3 -3
  8. package/dist/{chunk-NOBQQTAG.cjs.map → chunk-FDTE4C5W.cjs.map} +1 -1
  9. package/dist/chunk-ISKOLJJJ.cjs +4 -0
  10. package/dist/chunk-ISKOLJJJ.cjs.map +1 -0
  11. package/dist/chunk-K6BWJ7ZY.js +3 -0
  12. package/dist/chunk-K6BWJ7ZY.js.map +1 -0
  13. package/dist/chunk-LR5TGCJP.js +31 -0
  14. package/dist/chunk-LR5TGCJP.js.map +1 -0
  15. package/dist/{chunk-5MZYOJCJ.js → chunk-NFVYOMNV.js} +3 -3
  16. package/dist/{chunk-5MZYOJCJ.js.map → chunk-NFVYOMNV.js.map} +1 -1
  17. package/dist/chunk-TVPYDC5T.cjs +146 -0
  18. package/dist/chunk-TVPYDC5T.cjs.map +1 -0
  19. package/dist/chunk-UIDVH3GP.cjs +33 -0
  20. package/dist/chunk-UIDVH3GP.cjs.map +1 -0
  21. package/dist/{chunk-2JAKOBD3.js → chunk-WUVTKMAQ.js} +9 -5
  22. package/dist/chunk-WUVTKMAQ.js.map +1 -0
  23. package/dist/chunk-ZVKEPVDQ.js +144 -0
  24. package/dist/chunk-ZVKEPVDQ.js.map +1 -0
  25. package/dist/entries/billing.cjs +2 -2
  26. package/dist/entries/billing.d.cts +209 -3
  27. package/dist/entries/billing.d.ts +209 -3
  28. package/dist/entries/billing.js +1 -1
  29. package/dist/entries/client.cjs +10 -9
  30. package/dist/entries/client.d.cts +3 -0
  31. package/dist/entries/client.d.ts +3 -0
  32. package/dist/entries/client.js +5 -4
  33. package/dist/entries/core.cjs +5 -5
  34. package/dist/entries/core.js +1 -1
  35. package/dist/entries/credits.cjs +2 -2
  36. package/dist/entries/credits.d.cts +179 -1
  37. package/dist/entries/credits.d.ts +179 -1
  38. package/dist/entries/credits.js +1 -1
  39. package/dist/entries/user-settings.cjs +13 -0
  40. package/dist/entries/user-settings.cjs.map +1 -0
  41. package/dist/entries/user-settings.d.cts +115 -0
  42. package/dist/entries/user-settings.d.ts +115 -0
  43. package/dist/entries/user-settings.js +4 -0
  44. package/dist/entries/user-settings.js.map +1 -0
  45. package/dist/index.cjs +18 -12
  46. package/dist/index.d.cts +3 -2
  47. package/dist/index.d.ts +3 -2
  48. package/dist/index.js +6 -4
  49. package/package.json +6 -1
  50. package/dist/chunk-2JAKOBD3.js.map +0 -1
  51. package/dist/chunk-5MOJSYHI.js.map +0 -1
  52. package/dist/chunk-FIMBPKIH.cjs.map +0 -1
  53. package/dist/chunk-J4WFSKY6.js +0 -50
  54. package/dist/chunk-J4WFSKY6.js.map +0 -1
  55. package/dist/chunk-NGKODS3J.cjs +0 -52
  56. package/dist/chunk-NGKODS3J.cjs.map +0 -1
  57. package/dist/chunk-PPP6VZ3I.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resources/billing.ts"],"names":[],"mappings":"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","file":"chunk-ZVKEPVDQ.js","sourcesContent":["import type { NodaroClientCore } from \"../core.js\"\n\n/**\n * Plans and prices, the subscription, and the billing surface — the shapes of\n * the `/v1/billing/*` routes an app may call. Mirrors the backend routes\n * (`backend/src/ee/routes/billing.ts`, `backend/src/routes/billing-surface.ts`),\n * the source of truth: keep these in sync if they change.\n *\n * Buying, the plan, the payment settings, the receipts and the invoices answer\n * a SIGNED-IN SESSION only (`supabaseAuth`, the credential a first-party web\n * app holds): those routes refuse an API key and an app's OAuth token with\n * `403 forbidden` (`ForbiddenError`). Their methods are marked so below.\n */\n\n/** A sum of money in its currency's major unit (`12` = 12.00), with its ISO-4217 code (`\"USD\"`). */\nexport interface BillingMoney {\n amount: number\n currency: string\n}\n\n/** The credits a price grants, and how often. */\nexport interface BillingPriceCredits {\n amount: number\n per: \"month\" | \"year\"\n}\n\n/** A monthly price, and what it grants. */\nexport interface BillingMonthlyPrice extends BillingMoney {\n /** The Stripe price id: pass it to {@link BillingResource.checkout} or {@link BillingResource.changePlan}; match the subscription's `stripe_price_id` to it to learn the interval. */\n priceId: string\n /** `null` when the price does not state it. */\n credits: BillingPriceCredits | null\n}\n\n/** A yearly price, what it comes to per month, and what it grants. */\nexport interface BillingYearlyPrice extends BillingMoney {\n /** The Stripe price id: pass it to {@link BillingResource.checkout} or {@link BillingResource.changePlan}; match the subscription's `stripe_price_id` to it to learn the interval. */\n priceId: string\n /** The yearly amount spread over the months it pays for; `null` when that cannot be said. */\n perMonth: number | null\n /** What the price grants — the plan's credits every month, as a monthly price; `null` when the price does not state it. */\n credits: BillingPriceCredits | null\n}\n\nexport interface BillingPlanPrices {\n /** `null` = Stripe cannot sell this price right now: show it as unavailable, never as free. */\n monthly: BillingMonthlyPrice | null\n yearly: BillingYearlyPrice | null\n}\n\n/** One plan on sale. */\nexport interface BillingPlan {\n /** `\"free\"`, `\"basic\"`, `\"standard\"`, … — the stable id. */\n id: string\n name: string\n /** `null` for the free plan: there is nothing to pay. */\n prices: BillingPlanPrices | null\n /** The free plan's one-time grant at sign-up; `null` on a paid plan, whose credits come with each price. */\n signupCredits: number | null\n /** How many nodes of one workflow run at once. */\n parallelism: number\n /** Storage for your media, in bytes. */\n storageBytes: number\n}\n\n/** A credit pack: this many credits for this price. */\nexport interface BillingTopUp {\n /** The pack's own id (`\"topup-25\"`), not a Stripe id. */\n id: string\n credits: number\n /** `null` when the pack's price cannot be stated right now: show it as unavailable. */\n price: BillingMoney | null\n /** The Stripe price id for {@link BillingResource.checkout} (mode `\"payment\"`); `null` with the price. A pack can always be bought as a load of `price.amount` through {@link BillingResource.loadCredits}. */\n priceId: string | null\n}\n\n/** The answer of `GET /v1/billing/plans`. */\nexport interface BillingPlansResult {\n /** The free plan first, then each paid plan from the smallest. */\n data: BillingPlan[]\n /** The credit packs, from the smallest. */\n topUps: BillingTopUp[]\n /** Any whole amount in this range can be loaded as credits, at the same rate as the packs. */\n topUpRange: { min: number; max: number; currency: string }\n}\n\n/** The account's latest subscription record. */\nexport interface BillingSubscription {\n id: string\n stripe_subscription_id: string | null\n /** The plan id: `\"basic\"`, `\"standard\"`, … */\n tier: string\n /** `\"active\"`, `\"trialing\"`, `\"past_due\"`, `\"paused\"`, `\"canceled\"`, `\"incomplete\"` or `\"expired\"`. */\n status: string\n stripe_price_id: string | null\n /** ISO-8601. */\n current_period_start: string | null\n /** ISO-8601: when the current period ends (and renews, unless cancelled). */\n current_period_end: string | null\n /** True when the subscription ends at `current_period_end` instead of renewing. */\n cancel_at_period_end: boolean\n /** ISO-8601: when a scheduled cancellation takes effect. */\n cancel_at: string | null\n /** ISO-8601: when it was cancelled. */\n canceled_at: string | null\n}\n\n/** The answer of `GET /v1/billing/subscription`. */\nexport interface BillingSubscriptionResult {\n /** `null` when the account never subscribed. */\n data: BillingSubscription | null\n /**\n * The tier the account's entitlements follow: usually a plan id from\n * `plans()` (`\"free\"` included); `\"payg\"` — no subscription, but credits\n * bought (every model, no watermark); or a tier that is not on sale, such\n * as `\"enterprise\"`.\n */\n effectiveTier: string\n}\n\n/** How this deployment bills, the same for every caller (`GET /v1/billing/surface`). */\nexport interface BillingSurface {\n /** The billing-surface contract version (an integer). */\n contract: number\n /** The registered billing provider; `\"none\"` = this deployment meters nothing. */\n providerId: string\n /** The unit costs display in by default (`\"credits\"`, `\"usd\"`, or a deployment's own label). */\n displayUnit: string\n canReport: boolean\n canQuote: boolean\n canAccount: boolean\n /** Whether a cost view belongs on this deployment. */\n mountCostTab: boolean\n /** One billing account pays for every user here. */\n deploymentPayer: boolean\n}\n\n/** One row of {@link BillingAccountSummary.byCategory}. */\nexport interface BillingUsageCategory {\n category: string\n count: number\n /** Spend in the display unit; `null` = unavailable, never 0. */\n amount: number | null\n spent: BillingMoney | null\n}\n\n/**\n * The caller's account as the deployment's billing provider sees it\n * (`GET /v1/billing/account`). Money and amounts are `null` when the provider\n * could not say: show that distinctly, never as 0. A field the provider leaves\n * out is a concept it does not have.\n */\nexport interface BillingAccountSummary {\n /** A plain string; `\"unknown\"` is a real answer. */\n plan: string\n balance: number | null\n dailyAllowance: number | null\n unit: string\n /** `\"external_wallet\"` when the balance comes from a wallet outside Nodaro. */\n balanceSource?: \"external_wallet\"\n /** ISO-8601 start of the current usage period. */\n periodStart?: string | null\n /** Generations this period. */\n generations?: number | null\n /** Money spent this period. */\n spent?: BillingMoney | null\n /** Pay-as-you-go state. */\n payg?: {\n enabled: boolean\n reserve: number | null\n rate: { creditsPerUnit: number; currency: string } | null\n monthlyCap: BillingMoney | null\n } | null\n /** The daily cap and when it resets; prefer it over `dailyAllowance` when present. `limit: 0` means blocked. */\n daily?: { limit: number; used: number; remaining: number; resetsAt: string } | null\n /** Money value of the pay-as-you-go reserve. */\n reserveValue?: BillingMoney | null\n byCategory?: BillingUsageCategory[] | null\n /** The total the balance is drawn from, where the provider grants each user an allocation. */\n allocated?: number | null\n}\n\nexport class BillingResource {\n constructor(private client: NodaroClientCore) {}\n\n /**\n * `GET /v1/billing/plans` → the plans and credit packs on sale, with their\n * prices. Public: works with no credential, the same for every caller.\n * Nodaro Cloud only — a self-hosted instance answers 404. Throws on `403\n * self_serve_disabled` (this deployment does not sell to its users) and on\n * `503` (`stripe_not_configured`, or prices briefly unavailable).\n */\n plans(): Promise<BillingPlansResult> {\n return this.client.request<BillingPlansResult>(\"GET\", \"/v1/billing/plans\")\n }\n\n /**\n * `GET /v1/billing/subscription` → the account's latest subscription\n * (`null` when it never subscribed) and the tier its entitlements follow.\n * Match `effectiveTier` to a {@link BillingPlan} `id` to mark the current\n * plan (no match: pay-as-you-go, or a tier not on sale). Needs a signed-in\n * session, a personal API token without a workflow limit, or an app's OAuth\n * token. Nodaro Cloud only — a self-hosted instance answers 404.\n */\n subscription(): Promise<BillingSubscriptionResult> {\n return this.client.request<BillingSubscriptionResult>(\"GET\", \"/v1/billing/subscription\")\n }\n\n /**\n * `GET /v1/billing/surface` → how this deployment bills: whether it meters\n * at all (`providerId !== \"none\"`) and in which unit costs display. Public,\n * every edition.\n */\n async surface(): Promise<BillingSurface> {\n const res = await this.client.request<{ data: BillingSurface }>(\"GET\", \"/v1/billing/surface\")\n return res.data\n }\n\n /**\n * `GET /v1/billing/account` → the caller's plan and balance as the\n * deployment's billing provider reports them, in its display unit. `null`\n * when the provider could not answer — not a zero balance. Every edition.\n */\n async account(): Promise<BillingAccountSummary | null> {\n const res = await this.client.request<{ data: BillingAccountSummary | null }>(\"GET\", \"/v1/billing/account\")\n return res.data\n }\n\n // ── Signed-in session only (ForbiddenError on an API key or an app token) ──\n\n /**\n * `GET /v1/billing/transactions` → the account's credit purchases, newest\n * first: subscription payments and credit packs, each with its Stripe\n * receipt link when one was captured. **Signed-in session only.**\n */\n async purchases(): Promise<BillingPurchase[]> {\n const res = await this.client.request<{ data: BillingPurchase[] }>(\"GET\", \"/v1/billing/transactions\")\n return res.data\n }\n\n /**\n * `GET /v1/billing/invoices` → every payment as a document, newest first:\n * a Stripe invoice (with its PDF) for each subscription payment, a hosted\n * receipt for each credit pack or load. **Signed-in session only.**\n */\n async invoices(): Promise<BillingDocument[]> {\n const res = await this.client.request<{ data: BillingDocument[] }>(\"GET\", \"/v1/billing/invoices\")\n return res.data\n }\n\n /**\n * `GET /v1/billing/payment-method` → the card and the billing details on\n * file with Stripe; both `null` for an account that has not bought yet\n * (never an error). **Signed-in session only.**\n */\n async paymentMethod(): Promise<BillingPaymentMethod> {\n const res = await this.client.request<{ data: BillingPaymentMethod }>(\"GET\", \"/v1/billing/payment-method\")\n return res.data\n }\n\n /**\n * `GET /v1/billing/auto-recharge` → the automatic top-up setting: when the\n * balance falls under `thresholdCredits`, `amountUsd` is loaded from the\n * saved card. **Signed-in session only.**\n */\n async autoRecharge(): Promise<BillingAutoRecharge> {\n const res = await this.client.request<{ data: BillingAutoRecharge }>(\"GET\", \"/v1/billing/auto-recharge\")\n return res.data\n }\n\n /**\n * `PUT /v1/billing/auto-recharge` → changes the automatic top-up. Enabling\n * needs both `thresholdCredits` (100–100,000) and `amountUsd` (a whole\n * amount in the load range); the server answers `400` otherwise. A change\n * clears the failure count. **Signed-in session only.**\n */\n async setAutoRecharge(input: BillingAutoRechargeInput): Promise<BillingAutoRechargeSaved> {\n const res = await this.client.request<{ data: BillingAutoRechargeSaved }>(\"PUT\", \"/v1/billing/auto-recharge\", { body: input })\n return res.data\n }\n\n /**\n * `POST /v1/billing/create-checkout-session` → a Stripe Checkout page for a\n * plan or a credit pack (`priceId` from {@link BillingPlansResult}): send\n * the person to `url`. Pass `returnPath` (a path on your own origin, such\n * as `\"/billing\"`) to have Stripe bring them back to your app with\n * `checkout=success` or `checkout=cancelled` in the query; without it the\n * Nodaro app's own pages are used. `ForbiddenError` with the code\n * `self_serve_disabled` on a deployment that does not sell to its users.\n * **Signed-in session only.**\n */\n async checkout(input: BillingCheckoutInput): Promise<BillingCheckoutSession> {\n const res = await this.client.request<{ data: BillingCheckoutSession }>(\"POST\", \"/v1/billing/create-checkout-session\", { body: input })\n return res.data\n }\n\n /**\n * `POST /v1/billing/create-load-session` → a Stripe Checkout page that loads\n * a whole amount (`amountUsd`, within {@link BillingPlansResult.topUpRange})\n * as credits at the packs' rate; `credits` is what it will grant. The card\n * is saved for auto top-up. `returnPath` as in {@link checkout}.\n * **Signed-in session only.**\n */\n async loadCredits(input: BillingLoadInput): Promise<BillingLoadSession> {\n const res = await this.client.request<{ data: BillingLoadSession }>(\"POST\", \"/v1/billing/create-load-session\", { body: input })\n return res.data\n }\n\n /**\n * `POST /v1/billing/manage-subscription` → a Stripe Customer Portal page\n * (the card, the billing address, the invoices, cancelling): send the person\n * to `url`; `returnPath` is where the portal's Back goes (default the app's\n * `/billing`). `NotFoundError` before a first purchase — Stripe does not\n * know the account yet. **Signed-in session only.**\n */\n async portal(input: BillingPortalInput = {}): Promise<BillingPortalSession> {\n const res = await this.client.request<{ data: BillingPortalSession }>(\"POST\", \"/v1/billing/manage-subscription\", { body: input })\n return res.data\n }\n\n /**\n * `POST /v1/billing/change-plan` → moves the active subscription to another\n * plan's price (`newPriceId`, a subscription price from the plans list),\n * prorated by Stripe; the new tier applies at once. `NotFoundError` with no\n * active subscription; `400` on a pack's price or the current one.\n * **Signed-in session only.**\n */\n async changePlan(input: BillingChangePlanInput): Promise<BillingChangePlanResult> {\n const res = await this.client.request<{ data: BillingChangePlanResult }>(\"POST\", \"/v1/billing/change-plan\", { body: input })\n return res.data\n }\n}\n\n// ── Types of the signed-in-session methods ──\n\n/** One credit purchase (`billing.purchases()`), as the `transactions` row names it. */\nexport interface BillingPurchase {\n id: string\n /** The Stripe payment or subscription id. */\n stripe_transaction_id: string | null\n /** `\"subscription\"` (a plan payment), `\"topup\"` (a credit pack or a load) or `\"refund\"` (money given back: `credits_granted` negative). */\n type: string\n /** What was paid, in US dollars (on a refund, the sum given back). */\n amount_usd: number\n /** Negative on a refund. */\n credits_granted: number\n /** The plan paid for, on a subscription payment. */\n tier: string | null\n /** ISO-8601. */\n created_at: string\n /** Stripe's hosted receipt; `null` when none was captured. */\n receipt_url: string | null\n}\n\n/** A payment document: a Stripe invoice (a subscription payment) or a receipt (a credit purchase). */\nexport interface BillingDocument {\n id: string\n kind: \"invoice\" | \"receipt\"\n /** The invoice number Stripe printed; `null` on a receipt. */\n number: string | null\n /** ISO-8601. */\n at: string\n amount: BillingMoney\n /** The credits the payment granted; `null` on an invoice (the plan's credits come with the period). Negative on a refund. */\n credits: number | null\n /** `\"paid\"`, `\"open\"`, `\"void\"`, `\"uncollectible\"`, or `\"refunded\"` (a receipt for money given back: `amount` and `credits` negative). */\n status: string\n description: string | null\n /** The PDF, on an invoice; `null` on a receipt. */\n pdfUrl: string | null\n /** The hosted page: Stripe's invoice page, or the receipt. */\n url: string | null\n}\n\n/** The card on file, as Stripe shows it. */\nexport interface BillingCard {\n /** `\"visa\"`, `\"mastercard\"`, … */\n brand: string\n last4: string\n expMonth: number\n expYear: number\n}\n\n/** The name, email and country on file. */\nexport interface BillingDetails {\n name: string | null\n email: string | null\n /** ISO-3166 alpha-2. */\n country: string | null\n}\n\n/** The answer of `billing.paymentMethod()`: both `null` before a first purchase. */\nexport interface BillingPaymentMethod {\n card: BillingCard | null\n billingDetails: BillingDetails | null\n}\n\n/** The automatic top-up setting (`billing.autoRecharge()`). */\nexport interface BillingAutoRecharge {\n enabled: boolean\n /** Load when the balance falls under this many credits; `null` when never set. */\n thresholdCredits: number | null\n /** The whole dollar amount loaded each time; `null` when never set. */\n amountUsd: number | null\n /** Failed attempts in a row; the server stops trying after a few, until the setting is saved again. */\n failureCount: number\n /** ISO-8601; `null` before the first attempt. */\n lastAttemptAt: string | null\n /** Whether a card is saved to charge; without one, enabling cannot work. */\n hasSavedCard: boolean\n}\n\n/** What `billing.setAutoRecharge()` sends; `thresholdCredits` and `amountUsd` are both required to enable. */\nexport interface BillingAutoRechargeInput {\n enabled: boolean\n thresholdCredits?: number\n amountUsd?: number\n}\n\n/** What `billing.setAutoRecharge()` answers: the fields as sent (`null` for one left out, even when a stored value remains); read {@link BillingResource.autoRecharge} for the whole setting. */\nexport interface BillingAutoRechargeSaved {\n enabled: boolean\n thresholdCredits: number | null\n amountUsd: number | null\n}\n\n/** What `billing.checkout()` sends. */\nexport interface BillingCheckoutInput {\n /** A plan's monthly or yearly price id, or a credit pack's (`BillingTopUp.id`). */\n priceId: string\n /** Inferred from the price when omitted. */\n mode?: \"subscription\" | \"payment\"\n /** A path on the calling origin Stripe brings the person back to (`\"/billing\"`, a query allowed): one leading `/`, no host, no `#`. Wins over `embedded`. */\n returnPath?: string\n /** Set by an embedded first-party surface: return to the app's public checkout-complete page. */\n embedded?: boolean\n}\n\n/** A Stripe Checkout page to send the person to. */\nexport interface BillingCheckoutSession {\n url: string | null\n}\n\n/** What `billing.loadCredits()` sends. */\nexport interface BillingLoadInput {\n /** A whole dollar amount within `topUpRange`. */\n amountUsd: number\n /** As in {@link BillingCheckoutInput.returnPath}; wins over `embedded`. */\n returnPath?: string\n embedded?: boolean\n}\n\n/** A Stripe Checkout page for a load, and the credits it grants. */\nexport interface BillingLoadSession {\n url: string | null\n credits: number\n}\n\n/** What `billing.portal()` sends. */\nexport interface BillingPortalInput {\n /** Where the portal's Back goes: a path on the calling origin; default the app's `/billing`. */\n returnPath?: string\n}\n\n/** A Stripe Customer Portal page to send the person to. */\nexport interface BillingPortalSession {\n url: string\n}\n\n/** What `billing.changePlan()` sends. */\nexport interface BillingChangePlanInput {\n /** A subscription price id from the plans list. */\n newPriceId: string\n}\n\n/** What `billing.changePlan()` answers. */\nexport interface BillingChangePlanResult {\n subscriptionId: string\n /** The plan now in force: `\"basic\"`, `\"standard\"`, … */\n tier: string\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  require('../chunk-IS26FJO7.cjs');
4
- var chunkNGKODS3J_cjs = require('../chunk-NGKODS3J.cjs');
4
+ var chunkTVPYDC5T_cjs = require('../chunk-TVPYDC5T.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "BillingResource", {
9
9
  enumerable: true,
10
- get: function () { return chunkNGKODS3J_cjs.BillingResource; }
10
+ get: function () { return chunkTVPYDC5T_cjs.BillingResource; }
11
11
  });
12
12
  //# sourceMappingURL=billing.cjs.map
13
13
  //# sourceMappingURL=billing.cjs.map
@@ -8,8 +8,10 @@ import '@nodaro/shared/organizations';
8
8
  * (`backend/src/ee/routes/billing.ts`, `backend/src/routes/billing-surface.ts`),
9
9
  * the source of truth: keep these in sync if they change.
10
10
  *
11
- * Buying, changing the plan and the payment settings stay in the Nodaro app:
12
- * those routes refuse API and app tokens, so they have no method here.
11
+ * Buying, the plan, the payment settings, the receipts and the invoices answer
12
+ * a SIGNED-IN SESSION only (`supabaseAuth`, the credential a first-party web
13
+ * app holds): those routes refuse an API key and an app's OAuth token with
14
+ * `403 forbidden` (`ForbiddenError`). Their methods are marked so below.
13
15
  */
14
16
  /** A sum of money in its currency's major unit (`12` = 12.00), with its ISO-4217 code (`"USD"`). */
15
17
  interface BillingMoney {
@@ -23,11 +25,15 @@ interface BillingPriceCredits {
23
25
  }
24
26
  /** A monthly price, and what it grants. */
25
27
  interface BillingMonthlyPrice extends BillingMoney {
28
+ /** The Stripe price id: pass it to {@link BillingResource.checkout} or {@link BillingResource.changePlan}; match the subscription's `stripe_price_id` to it to learn the interval. */
29
+ priceId: string;
26
30
  /** `null` when the price does not state it. */
27
31
  credits: BillingPriceCredits | null;
28
32
  }
29
33
  /** A yearly price, what it comes to per month, and what it grants. */
30
34
  interface BillingYearlyPrice extends BillingMoney {
35
+ /** The Stripe price id: pass it to {@link BillingResource.checkout} or {@link BillingResource.changePlan}; match the subscription's `stripe_price_id` to it to learn the interval. */
36
+ priceId: string;
31
37
  /** The yearly amount spread over the months it pays for; `null` when that cannot be said. */
32
38
  perMonth: number | null;
33
39
  /** What the price grants — the plan's credits every month, as a monthly price; `null` when the price does not state it. */
@@ -54,10 +60,13 @@ interface BillingPlan {
54
60
  }
55
61
  /** A credit pack: this many credits for this price. */
56
62
  interface BillingTopUp {
63
+ /** The pack's own id (`"topup-25"`), not a Stripe id. */
57
64
  id: string;
58
65
  credits: number;
59
66
  /** `null` when the pack's price cannot be stated right now: show it as unavailable. */
60
67
  price: BillingMoney | null;
68
+ /** The Stripe price id for {@link BillingResource.checkout} (mode `"payment"`); `null` with the price. A pack can always be bought as a load of `price.amount` through {@link BillingResource.loadCredits}. */
69
+ priceId: string | null;
61
70
  }
62
71
  /** The answer of `GET /v1/billing/plans`. */
63
72
  interface BillingPlansResult {
@@ -203,6 +212,203 @@ declare class BillingResource {
203
212
  * when the provider could not answer — not a zero balance. Every edition.
204
213
  */
205
214
  account(): Promise<BillingAccountSummary | null>;
215
+ /**
216
+ * `GET /v1/billing/transactions` → the account's credit purchases, newest
217
+ * first: subscription payments and credit packs, each with its Stripe
218
+ * receipt link when one was captured. **Signed-in session only.**
219
+ */
220
+ purchases(): Promise<BillingPurchase[]>;
221
+ /**
222
+ * `GET /v1/billing/invoices` → every payment as a document, newest first:
223
+ * a Stripe invoice (with its PDF) for each subscription payment, a hosted
224
+ * receipt for each credit pack or load. **Signed-in session only.**
225
+ */
226
+ invoices(): Promise<BillingDocument[]>;
227
+ /**
228
+ * `GET /v1/billing/payment-method` → the card and the billing details on
229
+ * file with Stripe; both `null` for an account that has not bought yet
230
+ * (never an error). **Signed-in session only.**
231
+ */
232
+ paymentMethod(): Promise<BillingPaymentMethod>;
233
+ /**
234
+ * `GET /v1/billing/auto-recharge` → the automatic top-up setting: when the
235
+ * balance falls under `thresholdCredits`, `amountUsd` is loaded from the
236
+ * saved card. **Signed-in session only.**
237
+ */
238
+ autoRecharge(): Promise<BillingAutoRecharge>;
239
+ /**
240
+ * `PUT /v1/billing/auto-recharge` → changes the automatic top-up. Enabling
241
+ * needs both `thresholdCredits` (100–100,000) and `amountUsd` (a whole
242
+ * amount in the load range); the server answers `400` otherwise. A change
243
+ * clears the failure count. **Signed-in session only.**
244
+ */
245
+ setAutoRecharge(input: BillingAutoRechargeInput): Promise<BillingAutoRechargeSaved>;
246
+ /**
247
+ * `POST /v1/billing/create-checkout-session` → a Stripe Checkout page for a
248
+ * plan or a credit pack (`priceId` from {@link BillingPlansResult}): send
249
+ * the person to `url`. Pass `returnPath` (a path on your own origin, such
250
+ * as `"/billing"`) to have Stripe bring them back to your app with
251
+ * `checkout=success` or `checkout=cancelled` in the query; without it the
252
+ * Nodaro app's own pages are used. `ForbiddenError` with the code
253
+ * `self_serve_disabled` on a deployment that does not sell to its users.
254
+ * **Signed-in session only.**
255
+ */
256
+ checkout(input: BillingCheckoutInput): Promise<BillingCheckoutSession>;
257
+ /**
258
+ * `POST /v1/billing/create-load-session` → a Stripe Checkout page that loads
259
+ * a whole amount (`amountUsd`, within {@link BillingPlansResult.topUpRange})
260
+ * as credits at the packs' rate; `credits` is what it will grant. The card
261
+ * is saved for auto top-up. `returnPath` as in {@link checkout}.
262
+ * **Signed-in session only.**
263
+ */
264
+ loadCredits(input: BillingLoadInput): Promise<BillingLoadSession>;
265
+ /**
266
+ * `POST /v1/billing/manage-subscription` → a Stripe Customer Portal page
267
+ * (the card, the billing address, the invoices, cancelling): send the person
268
+ * to `url`; `returnPath` is where the portal's Back goes (default the app's
269
+ * `/billing`). `NotFoundError` before a first purchase — Stripe does not
270
+ * know the account yet. **Signed-in session only.**
271
+ */
272
+ portal(input?: BillingPortalInput): Promise<BillingPortalSession>;
273
+ /**
274
+ * `POST /v1/billing/change-plan` → moves the active subscription to another
275
+ * plan's price (`newPriceId`, a subscription price from the plans list),
276
+ * prorated by Stripe; the new tier applies at once. `NotFoundError` with no
277
+ * active subscription; `400` on a pack's price or the current one.
278
+ * **Signed-in session only.**
279
+ */
280
+ changePlan(input: BillingChangePlanInput): Promise<BillingChangePlanResult>;
281
+ }
282
+ /** One credit purchase (`billing.purchases()`), as the `transactions` row names it. */
283
+ interface BillingPurchase {
284
+ id: string;
285
+ /** The Stripe payment or subscription id. */
286
+ stripe_transaction_id: string | null;
287
+ /** `"subscription"` (a plan payment), `"topup"` (a credit pack or a load) or `"refund"` (money given back: `credits_granted` negative). */
288
+ type: string;
289
+ /** What was paid, in US dollars (on a refund, the sum given back). */
290
+ amount_usd: number;
291
+ /** Negative on a refund. */
292
+ credits_granted: number;
293
+ /** The plan paid for, on a subscription payment. */
294
+ tier: string | null;
295
+ /** ISO-8601. */
296
+ created_at: string;
297
+ /** Stripe's hosted receipt; `null` when none was captured. */
298
+ receipt_url: string | null;
299
+ }
300
+ /** A payment document: a Stripe invoice (a subscription payment) or a receipt (a credit purchase). */
301
+ interface BillingDocument {
302
+ id: string;
303
+ kind: "invoice" | "receipt";
304
+ /** The invoice number Stripe printed; `null` on a receipt. */
305
+ number: string | null;
306
+ /** ISO-8601. */
307
+ at: string;
308
+ amount: BillingMoney;
309
+ /** The credits the payment granted; `null` on an invoice (the plan's credits come with the period). Negative on a refund. */
310
+ credits: number | null;
311
+ /** `"paid"`, `"open"`, `"void"`, `"uncollectible"`, or `"refunded"` (a receipt for money given back: `amount` and `credits` negative). */
312
+ status: string;
313
+ description: string | null;
314
+ /** The PDF, on an invoice; `null` on a receipt. */
315
+ pdfUrl: string | null;
316
+ /** The hosted page: Stripe's invoice page, or the receipt. */
317
+ url: string | null;
318
+ }
319
+ /** The card on file, as Stripe shows it. */
320
+ interface BillingCard {
321
+ /** `"visa"`, `"mastercard"`, … */
322
+ brand: string;
323
+ last4: string;
324
+ expMonth: number;
325
+ expYear: number;
326
+ }
327
+ /** The name, email and country on file. */
328
+ interface BillingDetails {
329
+ name: string | null;
330
+ email: string | null;
331
+ /** ISO-3166 alpha-2. */
332
+ country: string | null;
333
+ }
334
+ /** The answer of `billing.paymentMethod()`: both `null` before a first purchase. */
335
+ interface BillingPaymentMethod {
336
+ card: BillingCard | null;
337
+ billingDetails: BillingDetails | null;
338
+ }
339
+ /** The automatic top-up setting (`billing.autoRecharge()`). */
340
+ interface BillingAutoRecharge {
341
+ enabled: boolean;
342
+ /** Load when the balance falls under this many credits; `null` when never set. */
343
+ thresholdCredits: number | null;
344
+ /** The whole dollar amount loaded each time; `null` when never set. */
345
+ amountUsd: number | null;
346
+ /** Failed attempts in a row; the server stops trying after a few, until the setting is saved again. */
347
+ failureCount: number;
348
+ /** ISO-8601; `null` before the first attempt. */
349
+ lastAttemptAt: string | null;
350
+ /** Whether a card is saved to charge; without one, enabling cannot work. */
351
+ hasSavedCard: boolean;
352
+ }
353
+ /** What `billing.setAutoRecharge()` sends; `thresholdCredits` and `amountUsd` are both required to enable. */
354
+ interface BillingAutoRechargeInput {
355
+ enabled: boolean;
356
+ thresholdCredits?: number;
357
+ amountUsd?: number;
358
+ }
359
+ /** What `billing.setAutoRecharge()` answers: the fields as sent (`null` for one left out, even when a stored value remains); read {@link BillingResource.autoRecharge} for the whole setting. */
360
+ interface BillingAutoRechargeSaved {
361
+ enabled: boolean;
362
+ thresholdCredits: number | null;
363
+ amountUsd: number | null;
364
+ }
365
+ /** What `billing.checkout()` sends. */
366
+ interface BillingCheckoutInput {
367
+ /** A plan's monthly or yearly price id, or a credit pack's (`BillingTopUp.id`). */
368
+ priceId: string;
369
+ /** Inferred from the price when omitted. */
370
+ mode?: "subscription" | "payment";
371
+ /** A path on the calling origin Stripe brings the person back to (`"/billing"`, a query allowed): one leading `/`, no host, no `#`. Wins over `embedded`. */
372
+ returnPath?: string;
373
+ /** Set by an embedded first-party surface: return to the app's public checkout-complete page. */
374
+ embedded?: boolean;
375
+ }
376
+ /** A Stripe Checkout page to send the person to. */
377
+ interface BillingCheckoutSession {
378
+ url: string | null;
379
+ }
380
+ /** What `billing.loadCredits()` sends. */
381
+ interface BillingLoadInput {
382
+ /** A whole dollar amount within `topUpRange`. */
383
+ amountUsd: number;
384
+ /** As in {@link BillingCheckoutInput.returnPath}; wins over `embedded`. */
385
+ returnPath?: string;
386
+ embedded?: boolean;
387
+ }
388
+ /** A Stripe Checkout page for a load, and the credits it grants. */
389
+ interface BillingLoadSession {
390
+ url: string | null;
391
+ credits: number;
392
+ }
393
+ /** What `billing.portal()` sends. */
394
+ interface BillingPortalInput {
395
+ /** Where the portal's Back goes: a path on the calling origin; default the app's `/billing`. */
396
+ returnPath?: string;
397
+ }
398
+ /** A Stripe Customer Portal page to send the person to. */
399
+ interface BillingPortalSession {
400
+ url: string;
401
+ }
402
+ /** What `billing.changePlan()` sends. */
403
+ interface BillingChangePlanInput {
404
+ /** A subscription price id from the plans list. */
405
+ newPriceId: string;
406
+ }
407
+ /** What `billing.changePlan()` answers. */
408
+ interface BillingChangePlanResult {
409
+ subscriptionId: string;
410
+ /** The plan now in force: `"basic"`, `"standard"`, … */
411
+ tier: string;
206
412
  }
207
413
 
208
- export { type BillingAccountSummary, type BillingMoney, type BillingMonthlyPrice, type BillingPlan, type BillingPlanPrices, type BillingPlansResult, type BillingPriceCredits, BillingResource, type BillingSubscription, type BillingSubscriptionResult, type BillingSurface, type BillingTopUp, type BillingUsageCategory, type BillingYearlyPrice };
414
+ export { type BillingAccountSummary, type BillingAutoRecharge, type BillingAutoRechargeInput, type BillingAutoRechargeSaved, type BillingCard, type BillingChangePlanInput, type BillingChangePlanResult, type BillingCheckoutInput, type BillingCheckoutSession, type BillingDetails, type BillingDocument, type BillingLoadInput, type BillingLoadSession, type BillingMoney, type BillingMonthlyPrice, type BillingPaymentMethod, type BillingPlan, type BillingPlanPrices, type BillingPlansResult, type BillingPortalInput, type BillingPortalSession, type BillingPriceCredits, type BillingPurchase, BillingResource, type BillingSubscription, type BillingSubscriptionResult, type BillingSurface, type BillingTopUp, type BillingUsageCategory, type BillingYearlyPrice };
@@ -8,8 +8,10 @@ import '@nodaro/shared/organizations';
8
8
  * (`backend/src/ee/routes/billing.ts`, `backend/src/routes/billing-surface.ts`),
9
9
  * the source of truth: keep these in sync if they change.
10
10
  *
11
- * Buying, changing the plan and the payment settings stay in the Nodaro app:
12
- * those routes refuse API and app tokens, so they have no method here.
11
+ * Buying, the plan, the payment settings, the receipts and the invoices answer
12
+ * a SIGNED-IN SESSION only (`supabaseAuth`, the credential a first-party web
13
+ * app holds): those routes refuse an API key and an app's OAuth token with
14
+ * `403 forbidden` (`ForbiddenError`). Their methods are marked so below.
13
15
  */
14
16
  /** A sum of money in its currency's major unit (`12` = 12.00), with its ISO-4217 code (`"USD"`). */
15
17
  interface BillingMoney {
@@ -23,11 +25,15 @@ interface BillingPriceCredits {
23
25
  }
24
26
  /** A monthly price, and what it grants. */
25
27
  interface BillingMonthlyPrice extends BillingMoney {
28
+ /** The Stripe price id: pass it to {@link BillingResource.checkout} or {@link BillingResource.changePlan}; match the subscription's `stripe_price_id` to it to learn the interval. */
29
+ priceId: string;
26
30
  /** `null` when the price does not state it. */
27
31
  credits: BillingPriceCredits | null;
28
32
  }
29
33
  /** A yearly price, what it comes to per month, and what it grants. */
30
34
  interface BillingYearlyPrice extends BillingMoney {
35
+ /** The Stripe price id: pass it to {@link BillingResource.checkout} or {@link BillingResource.changePlan}; match the subscription's `stripe_price_id` to it to learn the interval. */
36
+ priceId: string;
31
37
  /** The yearly amount spread over the months it pays for; `null` when that cannot be said. */
32
38
  perMonth: number | null;
33
39
  /** What the price grants — the plan's credits every month, as a monthly price; `null` when the price does not state it. */
@@ -54,10 +60,13 @@ interface BillingPlan {
54
60
  }
55
61
  /** A credit pack: this many credits for this price. */
56
62
  interface BillingTopUp {
63
+ /** The pack's own id (`"topup-25"`), not a Stripe id. */
57
64
  id: string;
58
65
  credits: number;
59
66
  /** `null` when the pack's price cannot be stated right now: show it as unavailable. */
60
67
  price: BillingMoney | null;
68
+ /** The Stripe price id for {@link BillingResource.checkout} (mode `"payment"`); `null` with the price. A pack can always be bought as a load of `price.amount` through {@link BillingResource.loadCredits}. */
69
+ priceId: string | null;
61
70
  }
62
71
  /** The answer of `GET /v1/billing/plans`. */
63
72
  interface BillingPlansResult {
@@ -203,6 +212,203 @@ declare class BillingResource {
203
212
  * when the provider could not answer — not a zero balance. Every edition.
204
213
  */
205
214
  account(): Promise<BillingAccountSummary | null>;
215
+ /**
216
+ * `GET /v1/billing/transactions` → the account's credit purchases, newest
217
+ * first: subscription payments and credit packs, each with its Stripe
218
+ * receipt link when one was captured. **Signed-in session only.**
219
+ */
220
+ purchases(): Promise<BillingPurchase[]>;
221
+ /**
222
+ * `GET /v1/billing/invoices` → every payment as a document, newest first:
223
+ * a Stripe invoice (with its PDF) for each subscription payment, a hosted
224
+ * receipt for each credit pack or load. **Signed-in session only.**
225
+ */
226
+ invoices(): Promise<BillingDocument[]>;
227
+ /**
228
+ * `GET /v1/billing/payment-method` → the card and the billing details on
229
+ * file with Stripe; both `null` for an account that has not bought yet
230
+ * (never an error). **Signed-in session only.**
231
+ */
232
+ paymentMethod(): Promise<BillingPaymentMethod>;
233
+ /**
234
+ * `GET /v1/billing/auto-recharge` → the automatic top-up setting: when the
235
+ * balance falls under `thresholdCredits`, `amountUsd` is loaded from the
236
+ * saved card. **Signed-in session only.**
237
+ */
238
+ autoRecharge(): Promise<BillingAutoRecharge>;
239
+ /**
240
+ * `PUT /v1/billing/auto-recharge` → changes the automatic top-up. Enabling
241
+ * needs both `thresholdCredits` (100–100,000) and `amountUsd` (a whole
242
+ * amount in the load range); the server answers `400` otherwise. A change
243
+ * clears the failure count. **Signed-in session only.**
244
+ */
245
+ setAutoRecharge(input: BillingAutoRechargeInput): Promise<BillingAutoRechargeSaved>;
246
+ /**
247
+ * `POST /v1/billing/create-checkout-session` → a Stripe Checkout page for a
248
+ * plan or a credit pack (`priceId` from {@link BillingPlansResult}): send
249
+ * the person to `url`. Pass `returnPath` (a path on your own origin, such
250
+ * as `"/billing"`) to have Stripe bring them back to your app with
251
+ * `checkout=success` or `checkout=cancelled` in the query; without it the
252
+ * Nodaro app's own pages are used. `ForbiddenError` with the code
253
+ * `self_serve_disabled` on a deployment that does not sell to its users.
254
+ * **Signed-in session only.**
255
+ */
256
+ checkout(input: BillingCheckoutInput): Promise<BillingCheckoutSession>;
257
+ /**
258
+ * `POST /v1/billing/create-load-session` → a Stripe Checkout page that loads
259
+ * a whole amount (`amountUsd`, within {@link BillingPlansResult.topUpRange})
260
+ * as credits at the packs' rate; `credits` is what it will grant. The card
261
+ * is saved for auto top-up. `returnPath` as in {@link checkout}.
262
+ * **Signed-in session only.**
263
+ */
264
+ loadCredits(input: BillingLoadInput): Promise<BillingLoadSession>;
265
+ /**
266
+ * `POST /v1/billing/manage-subscription` → a Stripe Customer Portal page
267
+ * (the card, the billing address, the invoices, cancelling): send the person
268
+ * to `url`; `returnPath` is where the portal's Back goes (default the app's
269
+ * `/billing`). `NotFoundError` before a first purchase — Stripe does not
270
+ * know the account yet. **Signed-in session only.**
271
+ */
272
+ portal(input?: BillingPortalInput): Promise<BillingPortalSession>;
273
+ /**
274
+ * `POST /v1/billing/change-plan` → moves the active subscription to another
275
+ * plan's price (`newPriceId`, a subscription price from the plans list),
276
+ * prorated by Stripe; the new tier applies at once. `NotFoundError` with no
277
+ * active subscription; `400` on a pack's price or the current one.
278
+ * **Signed-in session only.**
279
+ */
280
+ changePlan(input: BillingChangePlanInput): Promise<BillingChangePlanResult>;
281
+ }
282
+ /** One credit purchase (`billing.purchases()`), as the `transactions` row names it. */
283
+ interface BillingPurchase {
284
+ id: string;
285
+ /** The Stripe payment or subscription id. */
286
+ stripe_transaction_id: string | null;
287
+ /** `"subscription"` (a plan payment), `"topup"` (a credit pack or a load) or `"refund"` (money given back: `credits_granted` negative). */
288
+ type: string;
289
+ /** What was paid, in US dollars (on a refund, the sum given back). */
290
+ amount_usd: number;
291
+ /** Negative on a refund. */
292
+ credits_granted: number;
293
+ /** The plan paid for, on a subscription payment. */
294
+ tier: string | null;
295
+ /** ISO-8601. */
296
+ created_at: string;
297
+ /** Stripe's hosted receipt; `null` when none was captured. */
298
+ receipt_url: string | null;
299
+ }
300
+ /** A payment document: a Stripe invoice (a subscription payment) or a receipt (a credit purchase). */
301
+ interface BillingDocument {
302
+ id: string;
303
+ kind: "invoice" | "receipt";
304
+ /** The invoice number Stripe printed; `null` on a receipt. */
305
+ number: string | null;
306
+ /** ISO-8601. */
307
+ at: string;
308
+ amount: BillingMoney;
309
+ /** The credits the payment granted; `null` on an invoice (the plan's credits come with the period). Negative on a refund. */
310
+ credits: number | null;
311
+ /** `"paid"`, `"open"`, `"void"`, `"uncollectible"`, or `"refunded"` (a receipt for money given back: `amount` and `credits` negative). */
312
+ status: string;
313
+ description: string | null;
314
+ /** The PDF, on an invoice; `null` on a receipt. */
315
+ pdfUrl: string | null;
316
+ /** The hosted page: Stripe's invoice page, or the receipt. */
317
+ url: string | null;
318
+ }
319
+ /** The card on file, as Stripe shows it. */
320
+ interface BillingCard {
321
+ /** `"visa"`, `"mastercard"`, … */
322
+ brand: string;
323
+ last4: string;
324
+ expMonth: number;
325
+ expYear: number;
326
+ }
327
+ /** The name, email and country on file. */
328
+ interface BillingDetails {
329
+ name: string | null;
330
+ email: string | null;
331
+ /** ISO-3166 alpha-2. */
332
+ country: string | null;
333
+ }
334
+ /** The answer of `billing.paymentMethod()`: both `null` before a first purchase. */
335
+ interface BillingPaymentMethod {
336
+ card: BillingCard | null;
337
+ billingDetails: BillingDetails | null;
338
+ }
339
+ /** The automatic top-up setting (`billing.autoRecharge()`). */
340
+ interface BillingAutoRecharge {
341
+ enabled: boolean;
342
+ /** Load when the balance falls under this many credits; `null` when never set. */
343
+ thresholdCredits: number | null;
344
+ /** The whole dollar amount loaded each time; `null` when never set. */
345
+ amountUsd: number | null;
346
+ /** Failed attempts in a row; the server stops trying after a few, until the setting is saved again. */
347
+ failureCount: number;
348
+ /** ISO-8601; `null` before the first attempt. */
349
+ lastAttemptAt: string | null;
350
+ /** Whether a card is saved to charge; without one, enabling cannot work. */
351
+ hasSavedCard: boolean;
352
+ }
353
+ /** What `billing.setAutoRecharge()` sends; `thresholdCredits` and `amountUsd` are both required to enable. */
354
+ interface BillingAutoRechargeInput {
355
+ enabled: boolean;
356
+ thresholdCredits?: number;
357
+ amountUsd?: number;
358
+ }
359
+ /** What `billing.setAutoRecharge()` answers: the fields as sent (`null` for one left out, even when a stored value remains); read {@link BillingResource.autoRecharge} for the whole setting. */
360
+ interface BillingAutoRechargeSaved {
361
+ enabled: boolean;
362
+ thresholdCredits: number | null;
363
+ amountUsd: number | null;
364
+ }
365
+ /** What `billing.checkout()` sends. */
366
+ interface BillingCheckoutInput {
367
+ /** A plan's monthly or yearly price id, or a credit pack's (`BillingTopUp.id`). */
368
+ priceId: string;
369
+ /** Inferred from the price when omitted. */
370
+ mode?: "subscription" | "payment";
371
+ /** A path on the calling origin Stripe brings the person back to (`"/billing"`, a query allowed): one leading `/`, no host, no `#`. Wins over `embedded`. */
372
+ returnPath?: string;
373
+ /** Set by an embedded first-party surface: return to the app's public checkout-complete page. */
374
+ embedded?: boolean;
375
+ }
376
+ /** A Stripe Checkout page to send the person to. */
377
+ interface BillingCheckoutSession {
378
+ url: string | null;
379
+ }
380
+ /** What `billing.loadCredits()` sends. */
381
+ interface BillingLoadInput {
382
+ /** A whole dollar amount within `topUpRange`. */
383
+ amountUsd: number;
384
+ /** As in {@link BillingCheckoutInput.returnPath}; wins over `embedded`. */
385
+ returnPath?: string;
386
+ embedded?: boolean;
387
+ }
388
+ /** A Stripe Checkout page for a load, and the credits it grants. */
389
+ interface BillingLoadSession {
390
+ url: string | null;
391
+ credits: number;
392
+ }
393
+ /** What `billing.portal()` sends. */
394
+ interface BillingPortalInput {
395
+ /** Where the portal's Back goes: a path on the calling origin; default the app's `/billing`. */
396
+ returnPath?: string;
397
+ }
398
+ /** A Stripe Customer Portal page to send the person to. */
399
+ interface BillingPortalSession {
400
+ url: string;
401
+ }
402
+ /** What `billing.changePlan()` sends. */
403
+ interface BillingChangePlanInput {
404
+ /** A subscription price id from the plans list. */
405
+ newPriceId: string;
406
+ }
407
+ /** What `billing.changePlan()` answers. */
408
+ interface BillingChangePlanResult {
409
+ subscriptionId: string;
410
+ /** The plan now in force: `"basic"`, `"standard"`, … */
411
+ tier: string;
206
412
  }
207
413
 
208
- export { type BillingAccountSummary, type BillingMoney, type BillingMonthlyPrice, type BillingPlan, type BillingPlanPrices, type BillingPlansResult, type BillingPriceCredits, BillingResource, type BillingSubscription, type BillingSubscriptionResult, type BillingSurface, type BillingTopUp, type BillingUsageCategory, type BillingYearlyPrice };
414
+ export { type BillingAccountSummary, type BillingAutoRecharge, type BillingAutoRechargeInput, type BillingAutoRechargeSaved, type BillingCard, type BillingChangePlanInput, type BillingChangePlanResult, type BillingCheckoutInput, type BillingCheckoutSession, type BillingDetails, type BillingDocument, type BillingLoadInput, type BillingLoadSession, type BillingMoney, type BillingMonthlyPrice, type BillingPaymentMethod, type BillingPlan, type BillingPlanPrices, type BillingPlansResult, type BillingPortalInput, type BillingPortalSession, type BillingPriceCredits, type BillingPurchase, BillingResource, type BillingSubscription, type BillingSubscriptionResult, type BillingSurface, type BillingTopUp, type BillingUsageCategory, type BillingYearlyPrice };
@@ -1,4 +1,4 @@
1
1
  import '../chunk-M6Y5TOYE.js';
2
- export { BillingResource } from '../chunk-J4WFSKY6.js';
2
+ export { BillingResource } from '../chunk-ZVKEPVDQ.js';
3
3
  //# sourceMappingURL=billing.js.map
4
4
  //# sourceMappingURL=billing.js.map
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkPPP6VZ3I_cjs = require('../chunk-PPP6VZ3I.cjs');
3
+ var chunkAY7XKACE_cjs = require('../chunk-AY7XKACE.cjs');
4
4
  require('../chunk-JTOEHQQJ.cjs');
5
+ require('../chunk-UIDVH3GP.cjs');
5
6
  require('../chunk-W5VHATSR.cjs');
6
7
  require('../chunk-R63TTR35.cjs');
7
8
  require('../chunk-3B47IHB3.cjs');
@@ -43,14 +44,14 @@ require('../chunk-43FVH6LJ.cjs');
43
44
  require('../chunk-YFS2LMG4.cjs');
44
45
  require('../chunk-OSMKIRKI.cjs');
45
46
  require('../chunk-FRQJNGJS.cjs');
46
- var chunkNOBQQTAG_cjs = require('../chunk-NOBQQTAG.cjs');
47
+ var chunkFDTE4C5W_cjs = require('../chunk-FDTE4C5W.cjs');
47
48
  require('../chunk-FM2KM5TY.cjs');
48
49
  require('../chunk-HGCVWOGK.cjs');
49
- require('../chunk-FIMBPKIH.cjs');
50
+ require('../chunk-4BAHF762.cjs');
50
51
  require('../chunk-A3S55XGF.cjs');
51
52
  require('../chunk-JOXZ4ZIF.cjs');
52
53
  require('../chunk-GA4LZZKQ.cjs');
53
- require('../chunk-NGKODS3J.cjs');
54
+ require('../chunk-TVPYDC5T.cjs');
54
55
  require('../chunk-TY2S25W5.cjs');
55
56
  require('../chunk-BPWUWUZ3.cjs');
56
57
  require('../chunk-HAKYPZLB.cjs');
@@ -59,23 +60,23 @@ require('../chunk-HAKYPZLB.cjs');
59
60
 
60
61
  Object.defineProperty(exports, "NodaroClient", {
61
62
  enumerable: true,
62
- get: function () { return chunkPPP6VZ3I_cjs.NodaroClient; }
63
+ get: function () { return chunkAY7XKACE_cjs.NodaroClient; }
63
64
  });
64
65
  Object.defineProperty(exports, "createClient", {
65
66
  enumerable: true,
66
- get: function () { return chunkPPP6VZ3I_cjs.createClient; }
67
+ get: function () { return chunkAY7XKACE_cjs.createClient; }
67
68
  });
68
69
  Object.defineProperty(exports, "CallbackAuth", {
69
70
  enumerable: true,
70
- get: function () { return chunkNOBQQTAG_cjs.CallbackAuth; }
71
+ get: function () { return chunkFDTE4C5W_cjs.CallbackAuth; }
71
72
  });
72
73
  Object.defineProperty(exports, "StaticTokenAuth", {
73
74
  enumerable: true,
74
- get: function () { return chunkNOBQQTAG_cjs.StaticTokenAuth; }
75
+ get: function () { return chunkFDTE4C5W_cjs.StaticTokenAuth; }
75
76
  });
76
77
  Object.defineProperty(exports, "supabaseAuth", {
77
78
  enumerable: true,
78
- get: function () { return chunkNOBQQTAG_cjs.supabaseAuth; }
79
+ get: function () { return chunkFDTE4C5W_cjs.supabaseAuth; }
79
80
  });
80
81
  //# sourceMappingURL=client.cjs.map
81
82
  //# sourceMappingURL=client.cjs.map
@@ -25,6 +25,7 @@ import { MediaResource } from './media.cjs';
25
25
  import { AudioResource } from './audio.cjs';
26
26
  import { CreditsResource } from './credits.cjs';
27
27
  import { BillingResource } from './billing.cjs';
28
+ import { UserSettingsResource } from './user-settings.cjs';
28
29
  import { UploadsResource } from './uploads.cjs';
29
30
  import { LibraryResource } from './library.cjs';
30
31
  import { GalleryResource } from './gallery.cjs';
@@ -105,6 +106,8 @@ declare class NodaroClient extends NodaroClientCore {
105
106
  readonly media: MediaResource;
106
107
  readonly audio: AudioResource;
107
108
  readonly credits: CreditsResource;
109
+ /** The signed-in person's own settings (the interface language, the monthly statement opt-in, …). */
110
+ readonly userSettings: UserSettingsResource;
108
111
  /** Plans and prices, the subscription, and how this deployment bills. */
109
112
  readonly billing: BillingResource;
110
113
  readonly uploads: UploadsResource;