@nodaro/sdk 2.49.0 → 2.51.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.
- package/dist/{chunk-FIMBPKIH.cjs → chunk-4BAHF762.cjs} +43 -2
- package/dist/chunk-4BAHF762.cjs.map +1 -0
- package/dist/chunk-6FZN3QQO.cjs +146 -0
- package/dist/chunk-6FZN3QQO.cjs.map +1 -0
- package/dist/{chunk-5MOJSYHI.js → chunk-7QK2NXJA.js} +43 -2
- package/dist/chunk-7QK2NXJA.js.map +1 -0
- package/dist/{chunk-2JAKOBD3.js → chunk-EC6MC46Y.js} +5 -5
- package/dist/{chunk-2JAKOBD3.js.map → chunk-EC6MC46Y.js.map} +1 -1
- package/dist/{chunk-PPP6VZ3I.cjs → chunk-HPSENMVN.cjs} +8 -8
- package/dist/{chunk-PPP6VZ3I.cjs.map → chunk-HPSENMVN.cjs.map} +1 -1
- package/dist/{chunk-NOBQQTAG.cjs → chunk-OMX7JBGY.cjs} +3 -3
- package/dist/{chunk-NOBQQTAG.cjs.map → chunk-OMX7JBGY.cjs.map} +1 -1
- package/dist/chunk-WYYDWJFF.js +144 -0
- package/dist/chunk-WYYDWJFF.js.map +1 -0
- package/dist/{chunk-5MZYOJCJ.js → chunk-XISHBW5I.js} +3 -3
- package/dist/{chunk-5MZYOJCJ.js.map → chunk-XISHBW5I.js.map} +1 -1
- package/dist/entries/billing.cjs +2 -2
- package/dist/entries/billing.d.cts +202 -3
- package/dist/entries/billing.d.ts +202 -3
- package/dist/entries/billing.js +1 -1
- package/dist/entries/client.cjs +9 -9
- package/dist/entries/client.js +4 -4
- package/dist/entries/core.cjs +5 -5
- package/dist/entries/core.js +1 -1
- package/dist/entries/credits.cjs +2 -2
- package/dist/entries/credits.d.cts +179 -1
- package/dist/entries/credits.d.ts +179 -1
- package/dist/entries/credits.js +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-5MOJSYHI.js.map +0 -1
- package/dist/chunk-FIMBPKIH.cjs.map +0 -1
- package/dist/chunk-J4WFSKY6.js +0 -50
- package/dist/chunk-J4WFSKY6.js.map +0 -1
- package/dist/chunk-NGKODS3J.cjs +0 -52
- package/dist/chunk-NGKODS3J.cjs.map +0 -1
|
@@ -31,6 +31,47 @@ var CreditsResource = class {
|
|
|
31
31
|
query: { limit: options.limit, cursor: options.cursor }
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* `GET /v1/credits/usage-summary` → the period's credit usage summed the
|
|
36
|
+
* way a billing screen draws it: totals, the spend by model and by
|
|
37
|
+
* category, a series over time (`bucket`: day, week or month, no holes),
|
|
38
|
+
* and the spend by session and by workflow. The last 30 days unless
|
|
39
|
+
* `from` / `to` say otherwise; a period of at most a year (400 beyond).
|
|
40
|
+
* Cloud-only route: a self-hosted instance answers 404.
|
|
41
|
+
*/
|
|
42
|
+
async usageSummary(options = {}) {
|
|
43
|
+
const res = await this.client.request("GET", "/v1/credits/usage-summary", {
|
|
44
|
+
query: { from: options.from, to: options.to, bucket: options.bucket }
|
|
45
|
+
});
|
|
46
|
+
return res.data;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `GET /v1/credits/history` → one page of every movement of the balance,
|
|
50
|
+
* newest first — runs, purchases, grants, refunds, adjustments, expiries —
|
|
51
|
+
* each with the balance after it; a job's reserve row carries its model,
|
|
52
|
+
* its `charge` (the settled charge, the hold while the run is open, `0`
|
|
53
|
+
* once refunded — read that for spend, not `amount`) and its job. Filter by
|
|
54
|
+
* `kind`, `model`, `from` / `to` and `q`; pass the page's `nextCursor` (an
|
|
55
|
+
* opaque string) as `cursor` for the next page (`null` at the end).
|
|
56
|
+
* Cloud-only route: a self-hosted instance answers 404.
|
|
57
|
+
*/
|
|
58
|
+
history(options = {}) {
|
|
59
|
+
const { limit, cursor, ...filters } = options;
|
|
60
|
+
return this.client.request("GET", "/v1/credits/history", {
|
|
61
|
+
query: { limit, cursor, ...filters }
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* `GET /v1/credits/history?format=csv` → the whole filtered history as a
|
|
66
|
+
* CSV file (the same fields as {@link history}, one line per movement,
|
|
67
|
+
* newest first), at most 5,000 rows — the last line says when it was cut.
|
|
68
|
+
* Hand the text to the person as `credit-history.csv`.
|
|
69
|
+
*/
|
|
70
|
+
exportHistory(filters = {}) {
|
|
71
|
+
return this.client.requestText("GET", "/v1/credits/history", {
|
|
72
|
+
query: { ...filters, format: "csv" }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
34
75
|
/**
|
|
35
76
|
* `POST /v1/credits/model-costs` → per-identifier credit cost, for editor
|
|
36
77
|
* cost previews. Capped at the first {@link MODEL_COSTS_LIMIT} identifiers
|
|
@@ -104,5 +145,5 @@ var CreditsResource = class {
|
|
|
104
145
|
};
|
|
105
146
|
|
|
106
147
|
exports.CreditsResource = CreditsResource;
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
148
|
+
//# sourceMappingURL=chunk-4BAHF762.cjs.map
|
|
149
|
+
//# sourceMappingURL=chunk-4BAHF762.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources/credits.ts"],"names":[],"mappings":";;;AAwXA,IAAM,iBAAA,GAAoB,EAAA;AAEnB,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAoB,MAAA,EAA0B;AAA1B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA2B;AAAA,EAA3B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpB,MAAM,OAAA,GAAgC;AACpC,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA;AAAA,MAC5B,KAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA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ape of `GET /v1/user/credits`'s\n * `data` field. Mirrors the canonical `UserBalance` from the backend billing\n * module (`backend/src/ee/billing/credits.ts`), the source of truth: keep this\n * in sync if that interface changes.\n */\nexport interface UserBalance {\n total: number\n subscription: number\n topup: number\n dailySpent: number\n dailyLimit: number | null\n monthlyAllocation: number\n /** Stored billing tier. Display should prefer `effectiveTier`. */\n tier: string\n /** Derived entitlement tier: \"payg\" when stored-free with purchased credits. */\n effectiveTier: string\n features: Record<string, unknown>\n periodEnd: string | null\n /** Credits earned for app usage (free tier only — earned by running flows). */\n appCreditsAllowance: number\n /** Present when a deployment uses an external shared wallet. Raw credits;\n * null means unavailable. Do not substitute the personal `total` balance. */\n externalWallet?: { available: number | null }\n /**\n * Where the account's free signup grant stands. `\"withheld\"` means the\n * account works but the grant did not land — show the activation path.\n * Absent where the deployment has no signup grant.\n */\n freeGrantState?: FreeGrantState\n /**\n * Present only with `freeGrantState: \"withheld\"`, when the claim showed no\n * browser signals at all: the app may say \"free credits need a regular\n * browser — reload\", because a reload in one judges the account again.\n */\n freeGrantNotice?: \"browser_unmeasured\"\n /**\n * The welcome-credits opt-in. PRESENT only while the deployment has the\n * offer switched on — absent means \"no popup, no banner, no block\".\n */\n welcomeOffer?: WelcomeOfferState\n}\n\n/** Where an account's free signup grant stands. */\nexport type FreeGrantState = \"unclaimed\" | \"granted\" | \"withheld\" | \"revoked\"\n\n/** `UserBalance.welcomeOffer` — what an app needs to show the welcome offer. */\nexport interface WelcomeOfferState {\n /** The one-time popup was already shown (see `markWelcomeOfferSeen`). */\n popupSeen: boolean\n /**\n * The account already has its credits (granted elsewhere) but still owes\n * the email consent: the web apps block creation until it is given — the\n * claim records it.\n */\n consentPending: boolean\n /** The credits a claim grants. Name this figure in the offer; never hard-code it. */\n credits: number\n}\n\n/** What `claimWelcomeOffer` sends: the browser signals plus the app answering. */\nexport interface WelcomeOfferClaimInput extends SignupKeys {\n /**\n * The answering app's slug (lowercase letters, digits and `-`, up to 40\n * characters), recorded with the consent. A value outside that grammar is\n * stored as absent, never refused.\n */\n sourceApp?: string\n /**\n * The interface language the user answered in — the id of a language Nodaro\n * ships, such as `\"en\"`, `\"ja\"` or `\"pt-BR\"`. Matched exactly and\n * case-sensitively: `\"en-US\"` or `\"pt-br\"` is stored as absent, never refused.\n * Recorded with the consent as the language of the LATEST consent: a later\n * \"yes\" in another language replaces it.\n */\n locale?: string\n}\n\n/** The answer of `POST /v1/credits/welcome-offer/claim`. */\nexport interface WelcomeOfferClaimResult {\n /** The email consent is recorded. */\n consent: \"granted\"\n /** Where the free grant stands after the claim — `\"withheld\"` when the abuse gate refused it. */\n grant: FreeGrantState\n /** The grant's figure. A grant tops the subscription credits UP TO it (it is not added on top), so a claim that lands it leaves the subscription credits at no less than this. */\n credits: number\n}\n\n/** The answer of `POST /v1/credits/welcome-offer/seen`. */\nexport interface WelcomeOfferSeenResult {\n ok: true\n}\n\n/**\n * Result of `POST /v1/credits/model-costs` — a batch cost lookup for editor\n * cost previews. `data` maps each priced identifier → its credit cost.\n *\n * Per-model fault isolation (the route runs the lookups under\n * `Promise.allSettled`): identifiers with no pricing row are reported in\n * `missing` (undisplayable until an operator seeds a price) and lookup\n * failures in `errors`, instead of failing the whole batch. Callers typically\n * render `'—'` for any identifier that lands in `missing`. The hard-fail\n * policy still triggers at reservation time when the user actually runs the\n * node — this preview lookup is intentionally lenient.\n */\nexport interface ModelCostsResult {\n data: Record<string, number>\n missing: string[]\n errors: string[]\n /**\n * Why each identifier in `errors` has no price — today only\n * `llm_model_unpriced`: a metered LLM price key whose model has no rate on\n * the lane it would be served on (it cannot be run). Omitted when `errors`\n * is empty.\n */\n errorCodes?: Record<string, ModelCostError>\n /**\n * The identifiers in `data` whose figure is an ESTIMATE, not a fixed price:\n * metered LLM price keys (`llmPriceKey` from `@nodaro/shared/llm-models`,\n * `<feature>:<model>[:direct]`), charged on what the call actually uses.\n * Show these as `≈N`. Omitted when there are none, so a batch of fixed ids\n * answers exactly as it always has. A metered key that lands in `missing`\n * instead means the server is not pricing LLM calls per model — show no\n * price for it.\n */\n estimates?: string[]\n}\n\n/** {@link ModelCostsResult.errorCodes} — why an identifier has no price. */\nexport interface ModelCostError {\n /** Today only `llm_model_unpriced`; open to codes a newer server may add. */\n code: \"llm_model_unpriced\" | (string & {})\n /** A sentence to show the user. */\n message: string\n}\n\n/**\n * Result of `GET /v1/credits/model-cost?model=<id>` (`data`): the credits one\n * identifier is charged. `estimate: true` marks a metered LLM price key's\n * figure as an estimate (show it as `≈N`); such an answer is never cached.\n */\nexport interface ModelCostResult {\n model: string\n creditCost: number\n estimate?: true\n}\n\n/**\n * The two browser signals a claim reports — SHA-256 hex digests computed by\n * `@nodaro/sdk/signup-signals` (`collectSignupKeys`). Either may be absent:\n * a browser that cannot be measured still claims, and the server treats the\n * absence as what it is. Any other value is stored as absent server-side.\n */\nexport interface SignupKeys {\n browserKey?: string\n deviceKey?: string\n}\n\n/** The answer of `POST /v1/credits/claim-signup-grant`. */\nexport interface SignupGrantClaimResult {\n /** Where the account's free grant stands after this call. */\n state: FreeGrantState\n /** True only when THIS call moved the credits — a repeat is `false` with the same state. */\n granted: boolean\n}\n\n/**\n * One row of `GET /v1/credits/transactions` — a run's reservation and how it\n * settled.\n *\n * Which amount to read: a run first HOLDS credits and is then settled — charged\n * all or part of the hold, the rest returned. `credits_charged` is what the run\n * cost (`null` while the hold is still open, `0` once refunded); sum it for\n * spend. `credits_reserved` is the hold, which never changes. `credits_used`\n * is the same hold under its original name, kept for existing integrations.\n */\nexport interface CreditTransaction {\n id: string\n /** ISO-8601. Also the paging cursor: pass the last row's value as `cursor`. */\n created_at: string\n /** Settled charge; `null` while `status` is `\"reserved\"`, `0` when refunded. */\n credits_charged: number | null\n /** The hold taken when the run was accepted. */\n credits_reserved: number | null\n /** The hold, under its original name. Prefer `credits_charged`. */\n credits_used: number | null\n /** The model or operation the credits were for. */\n action: string | null\n provider: string | null\n /** Reservation lifecycle: `\"reserved\"`, `\"committed\"` or `\"refunded\"`. */\n status: string | null\n /** The caller's own billing details for the run (model, which pool paid, …). */\n metadata: Record<string, unknown>\n /** `\"workspace\"` when a class or team budget paid, not your balance. */\n payer: \"user\" | \"workspace\"\n workspaceId: string | null\n}\n\n/** A page of {@link CreditTransaction}s, newest first. */\nexport interface CreditTransactionsPage {\n data: CreditTransaction[]\n /** Pass as `cursor` for the next page; `null` when there are no more rows. */\n nextCursor: string | null\n}\n\nexport interface CreditTransactionsOptions {\n /** Rows per page, 1–50 (server default 20). */\n limit?: number\n /** The `nextCursor` of the previous page. */\n cursor?: string\n}\n\n/** How `credits.usageSummary()` groups the series over time. */\nexport type UsageSummaryBucket = \"day\" | \"week\" | \"month\"\n\nexport interface UsageSummaryOptions {\n /** An ISO-8601 timestamp, or a date alone (`\"2026-10-01\"`: that whole UTC day), inclusive; default the last 30 days up to now. A period of at most a year. */\n from?: string\n to?: string\n /** Default `\"day\"`. Buckets are UTC. */\n bucket?: UsageSummaryBucket\n}\n\nexport interface UsageSummaryTotals {\n /** Credits spent on runs in the period: each run's charge (a running hold counts; a refunded run does not). */\n used: number\n /** Credits bought: packs, loads, subscription grants. */\n purchased: number\n /** Credits granted free, net: sign-up and admin adjustments, a grant taken back subtracted. */\n granted: number\n /** Credits given back for a refunded run or by Stripe (a hold released when a run settled below it is not a refund). */\n refunded: number\n /** Runs that were charged or are still running. */\n runs: number\n /** `used / runs`, one decimal; 0 with no runs. */\n avgPerRun: number\n}\n\nexport interface UsageByModel {\n model: string\n provider: string | null\n credits: number\n runs: number\n /** Of `totals.used`, 0–1. */\n share: number\n}\n\nexport interface UsageByCategory {\n /** `\"image\"`, `\"video\"`, `\"audio\"` or `\"other\"`. */\n category: string\n credits: number\n runs: number\n}\n\nexport interface UsageOverTime {\n /** The bucket's first day in UTC (`\"2026-10-26\"`; a week by its Monday; a month as `\"2026-10\"`). The first bucket of a period may be a partial week or month. */\n bucket: string\n used: number\n purchased: number\n runs: number\n}\n\n/** The spend of one session or one workflow. */\nexport interface UsageByGroup {\n id: string\n /** The session's title or the workflow's name; `null` when it has none or is gone. */\n name: string | null\n /** The tool the session belongs to; `null` on a workflow. */\n tool: string | null\n credits: number\n runs: number\n /** The models used, by spend. */\n models: string[]\n /** ISO-8601: the latest run. */\n lastAt: string\n}\n\n/** The answer of `credits.usageSummary()`. */\nexport interface UsageSummary {\n period: { from: string; to: string; bucket: UsageSummaryBucket }\n totals: UsageSummaryTotals\n /** The model with the most spend; `null` with no runs. */\n mostUsed: UsageByModel | null\n /** By spend. */\n byModel: UsageByModel[]\n byCategory: UsageByCategory[]\n /** Every bucket of the period, empty ones included, oldest first. */\n overTime: UsageOverTime[]\n bySession: UsageByGroup[]\n byWorkflow: UsageByGroup[]\n /** A read hit the server's row cap: the figures under-report; narrow the period. */\n truncated: boolean\n /** A side read failed on the server (the jobs, or a session's or workflow's name): a grouping is missing or unnamed; the totals are whole. */\n partial: boolean\n}\n\n/** What a movement of the balance was; `app` is credits earned from, or paid for, a published app. */\nexport type CreditHistoryKind = \"usage\" | \"purchase\" | \"grant\" | \"refund\" | \"app\" | \"adjustment\" | \"expiry\"\n\n/** The job behind a usage row of {@link CreditHistoryEntry}. */\nexport interface CreditHistoryJob {\n id: string\n /** The node type that ran (`generate-image`, `image-to-video`, …); `null` when the job is gone. */\n type: string | null\n status: string | null\n startedAt: string | null\n completedAt: string | null\n /** From start to completion; `null` until it completes. */\n durationMs: number | null\n workflowId: string | null\n sessionId: string | null\n}\n\n/** One movement of the balance (`credits.history()`). */\nexport interface CreditHistoryEntry {\n id: string\n /** ISO-8601. Also the paging cursor. */\n at: string\n kind: CreditHistoryKind\n /** The ledger's own word: `usage`, `one_time_purchase`, `subscription_renewal`, `signup_grant`, `refund`, `admin_adjustment`, `expiry`, … */\n source: string\n /** The movement, signed: a run's hold negative, a purchase positive. */\n amount: number\n /** The balance right after this movement. */\n balanceAfter: number\n /** Which pool moved; `\"mixed\"` when both did. */\n pool: \"subscription\" | \"topup\" | \"mixed\"\n description: string | null\n /** The model that ran, on a row with a job; `null` otherwise. */\n model: string | null\n provider: string | null\n /**\n * The job's charge, on its reserve row only (the hold taken when the run\n * was accepted): the settled charge, the hold while the run is open, `0`\n * once refunded. `null` on every other row — a refund, a metered overrun\n * line, a purchase — so summing it over a list counts each job once. Read\n * this for spend, not `amount`.\n */\n charge: number | null\n /** The run's credit status (`\"reserved\"`, `\"committed\"` or `\"refunded\"`), beside `charge`; `null` elsewhere. */\n status: string | null\n /** On a row with a job; `type` and the rest `null` when the job is gone or not the person's. */\n job: CreditHistoryJob | null\n /** Stripe's hosted receipt, on a purchase that has one. */\n receiptUrl: string | null\n}\n\n/** A page of {@link CreditHistoryEntry}, newest first. */\nexport interface CreditHistoryPage {\n data: CreditHistoryEntry[]\n /** Pass as `cursor` for the next page; `null` when there are no more rows. */\n nextCursor: string | null\n}\n\n/** What narrows the history. */\nexport interface CreditHistoryFilters {\n kind?: CreditHistoryKind\n /** A model identifier: only runs of that model. */\n model?: string\n /** ISO-8601 bounds on `at`, inclusive. */\n from?: string\n to?: string\n /** Words looked for in the description, case-insensitively. */\n q?: string\n}\n\nexport interface CreditHistoryOptions extends CreditHistoryFilters {\n /** Rows per page, 1–100 (server default 50). */\n limit?: number\n /** The `nextCursor` of the previous page, as given (opaque; another string is refused with 400). */\n cursor?: string\n}\n\n/** Max identifiers per `model-costs` batch — the route caps the request at 50. */\nconst MODEL_COSTS_LIMIT = 50\n\nexport class CreditsResource {\n constructor(private client: NodaroClientCore) {}\n\n /**\n * `GET /v1/user/credits` → the authenticated user's credit balance and tier\n * info. Throws `UnauthorizedError` (401) when signed out, and the SDK's\n * other typed errors on the usual statuses.\n */\n async balance(): Promise<UserBalance> {\n const res = await this.client.request<{ data: UserBalance }>(\n \"GET\",\n \"/v1/user/credits\",\n )\n return res.data\n }\n\n /**\n * `GET /v1/credits/transactions` → one page of the caller's credit\n * transactions, newest first, with `nextCursor` for the next page (`null`\n * at the end). Read `credits_charged` for what each run cost — it can be\n * below the hold (`credits_reserved`) and is `null` while the hold is open.\n * Cloud-only route: a self-hosted instance answers 404.\n */\n transactions(options: CreditTransactionsOptions = {}): Promise<CreditTransactionsPage> {\n return this.client.request<CreditTransactionsPage>(\"GET\", \"/v1/credits/transactions\", {\n query: { limit: options.limit, cursor: options.cursor },\n })\n }\n\n /**\n * `GET /v1/credits/usage-summary` → the period's credit usage summed the\n * way a billing screen draws it: totals, the spend by model and by\n * category, a series over time (`bucket`: day, week or month, no holes),\n * and the spend by session and by workflow. The last 30 days unless\n * `from` / `to` say otherwise; a period of at most a year (400 beyond).\n * Cloud-only route: a self-hosted instance answers 404.\n */\n async usageSummary(options: UsageSummaryOptions = {}): Promise<UsageSummary> {\n const res = await this.client.request<{ data: UsageSummary }>(\"GET\", \"/v1/credits/usage-summary\", {\n query: { from: options.from, to: options.to, bucket: options.bucket },\n })\n return res.data\n }\n\n /**\n * `GET /v1/credits/history` → one page of every movement of the balance,\n * newest first — runs, purchases, grants, refunds, adjustments, expiries —\n * each with the balance after it; a job's reserve row carries its model,\n * its `charge` (the settled charge, the hold while the run is open, `0`\n * once refunded — read that for spend, not `amount`) and its job. Filter by\n * `kind`, `model`, `from` / `to` and `q`; pass the page's `nextCursor` (an\n * opaque string) as `cursor` for the next page (`null` at the end).\n * Cloud-only route: a self-hosted instance answers 404.\n */\n history(options: CreditHistoryOptions = {}): Promise<CreditHistoryPage> {\n const { limit, cursor, ...filters } = options\n return this.client.request<CreditHistoryPage>(\"GET\", \"/v1/credits/history\", {\n query: { limit, cursor, ...filters },\n })\n }\n\n /**\n * `GET /v1/credits/history?format=csv` → the whole filtered history as a\n * CSV file (the same fields as {@link history}, one line per movement,\n * newest first), at most 5,000 rows — the last line says when it was cut.\n * Hand the text to the person as `credit-history.csv`.\n */\n exportHistory(filters: CreditHistoryFilters = {}): Promise<string> {\n return this.client.requestText(\"GET\", \"/v1/credits/history\", {\n query: { ...filters, format: \"csv\" },\n })\n }\n\n /**\n * `POST /v1/credits/model-costs` → per-identifier credit cost, for editor\n * cost previews. Capped at the first {@link MODEL_COSTS_LIMIT} identifiers\n * (the route's request limit). Preserves the `{ data, missing, errors }`\n * fault-isolation shape verbatim, plus `estimates` / `errorCodes` when a\n * metered LLM price key was asked (see {@link ModelCostsResult}).\n */\n modelCosts(ids: string[]): Promise<ModelCostsResult> {\n return this.client.request<ModelCostsResult>(\"POST\", \"/v1/credits/model-costs\", {\n body: { models: ids.slice(0, MODEL_COSTS_LIMIT) },\n })\n }\n\n /**\n * `POST /v1/credits/claim-signup-grant` → claims the account's free signup\n * grant, once, with the browser signals of the page making the claim.\n *\n * Call it once per page load as soon as the session is known, and never\n * wait on it for rendering: it is idempotent (a decided account answers\n * with its state and `granted: false`), it costs the user nothing when it\n * fails (the next load asks again), and the signals are what make the\n * claim worth sending — collect them with `collectSignupKeys()` from\n * `@nodaro/sdk/signup-signals` and pass whatever came back, `{}` included.\n * Cloud-only route: a self-hosted instance answers 404.\n */\n claimSignupGrant(keys: SignupKeys = {}): Promise<SignupGrantClaimResult> {\n return this.client.request<SignupGrantClaimResult>(\"POST\", \"/v1/credits/claim-signup-grant\", {\n body: keys,\n })\n }\n\n /**\n * `POST /v1/credits/welcome-offer/claim` → the user's \"yes\" to the welcome\n * offer, as ONE server action: the marketing-email consent is recorded,\n * then the free signup grant is claimed with that consent. The abuse gate\n * still decides — consent is necessary, not sufficient — so read `grant`:\n * `\"granted\"` (the grant has landed: this call topped the subscription credits up to `credits` — not added on top — or it had landed before), `\"withheld\"` (refused), `\"revoked\"` (taken back earlier; nothing moves), `\"unclaimed\"` (nothing moved — treat as a failure and let the user retry).\n * Pass the browser signals from `collectSignupKeys()` and your app's slug.\n *\n * **Browser session only.** Usable from a first-party web app signed in\n * with a Supabase session (the consent is a person's choice in a browser);\n * an API key or OAuth app token is refused with 403. 409\n * `welcome_offer_disabled` while the deployment has the offer off — show\n * it only when `balance().welcomeOffer` is present. Cloud-only route: a\n * self-hosted instance answers 404.\n */\n claimWelcomeOffer(input: WelcomeOfferClaimInput = {}): Promise<WelcomeOfferClaimResult> {\n return this.client.request<WelcomeOfferClaimResult>(\"POST\", \"/v1/credits/welcome-offer/claim\", {\n body: input,\n })\n }\n\n /**\n * `POST /v1/credits/welcome-offer/seen` → records that the one-time welcome\n * popup was shown, so `balance().welcomeOffer.popupSeen` turns true on every\n * app. Idempotent (the first stamp wins); a failed call only means the popup\n * may show once more, so callers usually ignore errors.\n *\n * **Browser session only**, like {@link claimWelcomeOffer}: 403 for an API\n * key or OAuth app token, 409 `welcome_offer_disabled` while the offer is\n * off, 404 on a self-hosted instance.\n */\n markWelcomeOfferSeen(): Promise<WelcomeOfferSeenResult> {\n return this.client.request<WelcomeOfferSeenResult>(\"POST\", \"/v1/credits/welcome-offer/seen\")\n }\n\n // NOTE: no `estimate(...)` helper. The backend exposes\n // `POST /v1/credits/estimate-workflow` (body `{ nodes }` → `{ data: {\n // totalCredits, nodeCount, estimate?: true } }` — `estimate` when a metered\n // LLM node's estimate is in the total), but no consumer has a settled shape for it\n // yet (studio pre-checks `balance >= Σ modelCosts` client-side rather than\n // calling an estimate endpoint). Adding it now would be inventing an API\n // surface ahead of a real caller, so it's deliberately omitted — add it when\n // a consumer needs it, shaped to that need.\n}\n"]}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/resources/billing.ts
|
|
4
|
+
var BillingResource = class {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
client;
|
|
9
|
+
/**
|
|
10
|
+
* `GET /v1/billing/plans` → the plans and credit packs on sale, with their
|
|
11
|
+
* prices. Public: works with no credential, the same for every caller.
|
|
12
|
+
* Nodaro Cloud only — a self-hosted instance answers 404. Throws on `403
|
|
13
|
+
* self_serve_disabled` (this deployment does not sell to its users) and on
|
|
14
|
+
* `503` (`stripe_not_configured`, or prices briefly unavailable).
|
|
15
|
+
*/
|
|
16
|
+
plans() {
|
|
17
|
+
return this.client.request("GET", "/v1/billing/plans");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `GET /v1/billing/subscription` → the account's latest subscription
|
|
21
|
+
* (`null` when it never subscribed) and the tier its entitlements follow.
|
|
22
|
+
* Match `effectiveTier` to a {@link BillingPlan} `id` to mark the current
|
|
23
|
+
* plan (no match: pay-as-you-go, or a tier not on sale). Needs a signed-in
|
|
24
|
+
* session, a personal API token without a workflow limit, or an app's OAuth
|
|
25
|
+
* token. Nodaro Cloud only — a self-hosted instance answers 404.
|
|
26
|
+
*/
|
|
27
|
+
subscription() {
|
|
28
|
+
return this.client.request("GET", "/v1/billing/subscription");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `GET /v1/billing/surface` → how this deployment bills: whether it meters
|
|
32
|
+
* at all (`providerId !== "none"`) and in which unit costs display. Public,
|
|
33
|
+
* every edition.
|
|
34
|
+
*/
|
|
35
|
+
async surface() {
|
|
36
|
+
const res = await this.client.request("GET", "/v1/billing/surface");
|
|
37
|
+
return res.data;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/billing/account` → the caller's plan and balance as the
|
|
41
|
+
* deployment's billing provider reports them, in its display unit. `null`
|
|
42
|
+
* when the provider could not answer — not a zero balance. Every edition.
|
|
43
|
+
*/
|
|
44
|
+
async account() {
|
|
45
|
+
const res = await this.client.request("GET", "/v1/billing/account");
|
|
46
|
+
return res.data;
|
|
47
|
+
}
|
|
48
|
+
// ── Signed-in session only (ForbiddenError on an API key or an app token) ──
|
|
49
|
+
/**
|
|
50
|
+
* `GET /v1/billing/transactions` → the account's credit purchases, newest
|
|
51
|
+
* first: subscription payments and credit packs, each with its Stripe
|
|
52
|
+
* receipt link when one was captured. **Signed-in session only.**
|
|
53
|
+
*/
|
|
54
|
+
async purchases() {
|
|
55
|
+
const res = await this.client.request("GET", "/v1/billing/transactions");
|
|
56
|
+
return res.data;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `GET /v1/billing/invoices` → every payment as a document, newest first:
|
|
60
|
+
* a Stripe invoice (with its PDF) for each subscription payment, a hosted
|
|
61
|
+
* receipt for each credit pack or load. **Signed-in session only.**
|
|
62
|
+
*/
|
|
63
|
+
async invoices() {
|
|
64
|
+
const res = await this.client.request("GET", "/v1/billing/invoices");
|
|
65
|
+
return res.data;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `GET /v1/billing/payment-method` → the card and the billing details on
|
|
69
|
+
* file with Stripe; both `null` for an account that has not bought yet
|
|
70
|
+
* (never an error). **Signed-in session only.**
|
|
71
|
+
*/
|
|
72
|
+
async paymentMethod() {
|
|
73
|
+
const res = await this.client.request("GET", "/v1/billing/payment-method");
|
|
74
|
+
return res.data;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* `GET /v1/billing/auto-recharge` → the automatic top-up setting: when the
|
|
78
|
+
* balance falls under `thresholdCredits`, `amountUsd` is loaded from the
|
|
79
|
+
* saved card. **Signed-in session only.**
|
|
80
|
+
*/
|
|
81
|
+
async autoRecharge() {
|
|
82
|
+
const res = await this.client.request("GET", "/v1/billing/auto-recharge");
|
|
83
|
+
return res.data;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `PUT /v1/billing/auto-recharge` → changes the automatic top-up. Enabling
|
|
87
|
+
* needs both `thresholdCredits` (100–100,000) and `amountUsd` (a whole
|
|
88
|
+
* amount in the load range); the server answers `400` otherwise. A change
|
|
89
|
+
* clears the failure count. **Signed-in session only.**
|
|
90
|
+
*/
|
|
91
|
+
async setAutoRecharge(input) {
|
|
92
|
+
const res = await this.client.request("PUT", "/v1/billing/auto-recharge", { body: input });
|
|
93
|
+
return res.data;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `POST /v1/billing/create-checkout-session` → a Stripe Checkout page for a
|
|
97
|
+
* plan or a credit pack (`priceId` from {@link BillingPlansResult}): send
|
|
98
|
+
* the person to `url`. Pass `returnPath` (a path on your own origin, such
|
|
99
|
+
* as `"/billing"`) to have Stripe bring them back to your app with
|
|
100
|
+
* `checkout=success` or `checkout=cancelled` in the query; without it the
|
|
101
|
+
* Nodaro app's own pages are used. `ForbiddenError` with the code
|
|
102
|
+
* `self_serve_disabled` on a deployment that does not sell to its users.
|
|
103
|
+
* **Signed-in session only.**
|
|
104
|
+
*/
|
|
105
|
+
async checkout(input) {
|
|
106
|
+
const res = await this.client.request("POST", "/v1/billing/create-checkout-session", { body: input });
|
|
107
|
+
return res.data;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* `POST /v1/billing/create-load-session` → a Stripe Checkout page that loads
|
|
111
|
+
* a whole amount (`amountUsd`, within {@link BillingPlansResult.topUpRange})
|
|
112
|
+
* as credits at the packs' rate; `credits` is what it will grant. The card
|
|
113
|
+
* is saved for auto top-up. `returnPath` as in {@link checkout}.
|
|
114
|
+
* **Signed-in session only.**
|
|
115
|
+
*/
|
|
116
|
+
async loadCredits(input) {
|
|
117
|
+
const res = await this.client.request("POST", "/v1/billing/create-load-session", { body: input });
|
|
118
|
+
return res.data;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `POST /v1/billing/manage-subscription` → a Stripe Customer Portal page
|
|
122
|
+
* (the card, the billing address, the invoices, cancelling): send the person
|
|
123
|
+
* to `url`; `returnPath` is where the portal's Back goes (default the app's
|
|
124
|
+
* `/billing`). `NotFoundError` before a first purchase — Stripe does not
|
|
125
|
+
* know the account yet. **Signed-in session only.**
|
|
126
|
+
*/
|
|
127
|
+
async portal(input = {}) {
|
|
128
|
+
const res = await this.client.request("POST", "/v1/billing/manage-subscription", { body: input });
|
|
129
|
+
return res.data;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* `POST /v1/billing/change-plan` → moves the active subscription to another
|
|
133
|
+
* plan's price (`newPriceId`, a subscription price from the plans list),
|
|
134
|
+
* prorated by Stripe; the new tier applies at once. `NotFoundError` with no
|
|
135
|
+
* active subscription; `400` on a pack's price or the current one.
|
|
136
|
+
* **Signed-in session only.**
|
|
137
|
+
*/
|
|
138
|
+
async changePlan(input) {
|
|
139
|
+
const res = await this.client.request("POST", "/v1/billing/change-plan", { body: input });
|
|
140
|
+
return res.data;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
exports.BillingResource = BillingResource;
|
|
145
|
+
//# sourceMappingURL=chunk-6FZN3QQO.cjs.map
|
|
146
|
+
//# sourceMappingURL=chunk-6FZN3QQO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources/billing.ts"],"names":[],"mappings":";;;AA+KO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAoB,MAAA,EAA0B;AAA1B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA2B;AAAA,EAA3B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpB,KAAA,GAAqC;AACnC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAA4B,KAAA,EAAO,mBAAmB,CAAA;AAAA,EAC3E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,YAAA,GAAmD;AACjD,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,OAAA,CAAmC,KAAA,EAAO,0BAA0B,CAAA;AAAA,EACzF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,OAAA,GAAmC;AACvC,IAAA,MAAM,MAAM,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAkC,OAAO,qBAAqB,CAAA;AAC5F,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,OAAA,GAAiD;AACrD,IAAA,MAAM,MAAM,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAgD,OAAO,qBAAqB,CAAA;AAC1G,IAAA,OAAO,GAAA,CAAI,IAAA;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Q,qCAAA,EAAuC,EAAE,IAAA,EAAM,KAAA,EAAO,CAAA;AACtI,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,YAAY,KAAA,EAAsD;AACtE,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAsC,QAAQ,iCAAA,EAAmC,EAAE,IAAA,EAAM,KAAA,EAAO,CAAA;AAC9H,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,MAAA,CAAO,KAAA,GAA4B,EAAC,EAAkC;AAC1E,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAwC,QAAQ,iCAAA,EAAmC,EAAE,IAAA,EAAM,KAAA,EAAO,CAAA;AAChI,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,WAAW,KAAA,EAAiE;AAChF,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAA2C,QAAQ,yBAAA,EAA2B,EAAE,IAAA,EAAM,KAAA,EAAO,CAAA;AAC3H,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AACF","file":"chunk-6FZN3QQO.cjs","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 /** `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 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 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}\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"]}
|
|
@@ -29,6 +29,47 @@ var CreditsResource = class {
|
|
|
29
29
|
query: { limit: options.limit, cursor: options.cursor }
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* `GET /v1/credits/usage-summary` → the period's credit usage summed the
|
|
34
|
+
* way a billing screen draws it: totals, the spend by model and by
|
|
35
|
+
* category, a series over time (`bucket`: day, week or month, no holes),
|
|
36
|
+
* and the spend by session and by workflow. The last 30 days unless
|
|
37
|
+
* `from` / `to` say otherwise; a period of at most a year (400 beyond).
|
|
38
|
+
* Cloud-only route: a self-hosted instance answers 404.
|
|
39
|
+
*/
|
|
40
|
+
async usageSummary(options = {}) {
|
|
41
|
+
const res = await this.client.request("GET", "/v1/credits/usage-summary", {
|
|
42
|
+
query: { from: options.from, to: options.to, bucket: options.bucket }
|
|
43
|
+
});
|
|
44
|
+
return res.data;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* `GET /v1/credits/history` → one page of every movement of the balance,
|
|
48
|
+
* newest first — runs, purchases, grants, refunds, adjustments, expiries —
|
|
49
|
+
* each with the balance after it; a job's reserve row carries its model,
|
|
50
|
+
* its `charge` (the settled charge, the hold while the run is open, `0`
|
|
51
|
+
* once refunded — read that for spend, not `amount`) and its job. Filter by
|
|
52
|
+
* `kind`, `model`, `from` / `to` and `q`; pass the page's `nextCursor` (an
|
|
53
|
+
* opaque string) as `cursor` for the next page (`null` at the end).
|
|
54
|
+
* Cloud-only route: a self-hosted instance answers 404.
|
|
55
|
+
*/
|
|
56
|
+
history(options = {}) {
|
|
57
|
+
const { limit, cursor, ...filters } = options;
|
|
58
|
+
return this.client.request("GET", "/v1/credits/history", {
|
|
59
|
+
query: { limit, cursor, ...filters }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `GET /v1/credits/history?format=csv` → the whole filtered history as a
|
|
64
|
+
* CSV file (the same fields as {@link history}, one line per movement,
|
|
65
|
+
* newest first), at most 5,000 rows — the last line says when it was cut.
|
|
66
|
+
* Hand the text to the person as `credit-history.csv`.
|
|
67
|
+
*/
|
|
68
|
+
exportHistory(filters = {}) {
|
|
69
|
+
return this.client.requestText("GET", "/v1/credits/history", {
|
|
70
|
+
query: { ...filters, format: "csv" }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
32
73
|
/**
|
|
33
74
|
* `POST /v1/credits/model-costs` → per-identifier credit cost, for editor
|
|
34
75
|
* cost previews. Capped at the first {@link MODEL_COSTS_LIMIT} identifiers
|
|
@@ -102,5 +143,5 @@ var CreditsResource = class {
|
|
|
102
143
|
};
|
|
103
144
|
|
|
104
145
|
export { CreditsResource };
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-7QK2NXJA.js.map
|
|
147
|
+
//# sourceMappingURL=chunk-7QK2NXJA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources/credits.ts"],"names":[],"mappings":";AAwXA,IAAM,iBAAA,GAAoB,EAAA;AAEnB,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAoB,MAAA,EAA0B;AAA1B,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAA2B;AAAA,EAA3B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpB,MAAM,OAAA,GAAgC;AACpC,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,MAAA,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sourcesContent":["import type { NodaroClientCore } from \"../core.js\"\n\n/**\n * Authenticated user's credit balance — the shape of `GET /v1/user/credits`'s\n * `data` field. Mirrors the canonical `UserBalance` from the backend billing\n * module (`backend/src/ee/billing/credits.ts`), the source of truth: keep this\n * in sync if that interface changes.\n */\nexport interface UserBalance {\n total: number\n subscription: number\n topup: number\n dailySpent: number\n dailyLimit: number | null\n monthlyAllocation: number\n /** Stored billing tier. Display should prefer `effectiveTier`. */\n tier: string\n /** Derived entitlement tier: \"payg\" when stored-free with purchased credits. */\n effectiveTier: string\n features: Record<string, unknown>\n periodEnd: string | null\n /** Credits earned for app usage (free tier only — earned by running flows). */\n appCreditsAllowance: number\n /** Present when a deployment uses an external shared wallet. Raw credits;\n * null means unavailable. Do not substitute the personal `total` balance. */\n externalWallet?: { available: number | null }\n /**\n * Where the account's free signup grant stands. `\"withheld\"` means the\n * account works but the grant did not land — show the activation path.\n * Absent where the deployment has no signup grant.\n */\n freeGrantState?: FreeGrantState\n /**\n * Present only with `freeGrantState: \"withheld\"`, when the claim showed no\n * browser signals at all: the app may say \"free credits need a regular\n * browser — reload\", because a reload in one judges the account again.\n */\n freeGrantNotice?: \"browser_unmeasured\"\n /**\n * The welcome-credits opt-in. PRESENT only while the deployment has the\n * offer switched on — absent means \"no popup, no banner, no block\".\n */\n welcomeOffer?: WelcomeOfferState\n}\n\n/** Where an account's free signup grant stands. */\nexport type FreeGrantState = \"unclaimed\" | \"granted\" | \"withheld\" | \"revoked\"\n\n/** `UserBalance.welcomeOffer` — what an app needs to show the welcome offer. */\nexport interface WelcomeOfferState {\n /** The one-time popup was already shown (see `markWelcomeOfferSeen`). */\n popupSeen: boolean\n /**\n * The account already has its credits (granted elsewhere) but still owes\n * the email consent: the web apps block creation until it is given — the\n * claim records it.\n */\n consentPending: boolean\n /** The credits a claim grants. Name this figure in the offer; never hard-code it. */\n credits: number\n}\n\n/** What `claimWelcomeOffer` sends: the browser signals plus the app answering. */\nexport interface WelcomeOfferClaimInput extends SignupKeys {\n /**\n * The answering app's slug (lowercase letters, digits and `-`, up to 40\n * characters), recorded with the consent. A value outside that grammar is\n * stored as absent, never refused.\n */\n sourceApp?: string\n /**\n * The interface language the user answered in — the id of a language Nodaro\n * ships, such as `\"en\"`, `\"ja\"` or `\"pt-BR\"`. Matched exactly and\n * case-sensitively: `\"en-US\"` or `\"pt-br\"` is stored as absent, never refused.\n * Recorded with the consent as the language of the LATEST consent: a later\n * \"yes\" in another language replaces it.\n */\n locale?: string\n}\n\n/** The answer of `POST /v1/credits/welcome-offer/claim`. */\nexport interface WelcomeOfferClaimResult {\n /** The email consent is recorded. */\n consent: \"granted\"\n /** Where the free grant stands after the claim — `\"withheld\"` when the abuse gate refused it. */\n grant: FreeGrantState\n /** The grant's figure. A grant tops the subscription credits UP TO it (it is not added on top), so a claim that lands it leaves the subscription credits at no less than this. */\n credits: number\n}\n\n/** The answer of `POST /v1/credits/welcome-offer/seen`. */\nexport interface WelcomeOfferSeenResult {\n ok: true\n}\n\n/**\n * Result of `POST /v1/credits/model-costs` — a batch cost lookup for editor\n * cost previews. `data` maps each priced identifier → its credit cost.\n *\n * Per-model fault isolation (the route runs the lookups under\n * `Promise.allSettled`): identifiers with no pricing row are reported in\n * `missing` (undisplayable until an operator seeds a price) and lookup\n * failures in `errors`, instead of failing the whole batch. Callers typically\n * render `'—'` for any identifier that lands in `missing`. The hard-fail\n * policy still triggers at reservation time when the user actually runs the\n * node — this preview lookup is intentionally lenient.\n */\nexport interface ModelCostsResult {\n data: Record<string, number>\n missing: string[]\n errors: string[]\n /**\n * Why each identifier in `errors` has no price — today only\n * `llm_model_unpriced`: a metered LLM price key whose model has no rate on\n * the lane it would be served on (it cannot be run). Omitted when `errors`\n * is empty.\n */\n errorCodes?: Record<string, ModelCostError>\n /**\n * The identifiers in `data` whose figure is an ESTIMATE, not a fixed price:\n * metered LLM price keys (`llmPriceKey` from `@nodaro/shared/llm-models`,\n * `<feature>:<model>[:direct]`), charged on what the call actually uses.\n * Show these as `≈N`. Omitted when there are none, so a batch of fixed ids\n * answers exactly as it always has. A metered key that lands in `missing`\n * instead means the server is not pricing LLM calls per model — show no\n * price for it.\n */\n estimates?: string[]\n}\n\n/** {@link ModelCostsResult.errorCodes} — why an identifier has no price. */\nexport interface ModelCostError {\n /** Today only `llm_model_unpriced`; open to codes a newer server may add. */\n code: \"llm_model_unpriced\" | (string & {})\n /** A sentence to show the user. */\n message: string\n}\n\n/**\n * Result of `GET /v1/credits/model-cost?model=<id>` (`data`): the credits one\n * identifier is charged. `estimate: true` marks a metered LLM price key's\n * figure as an estimate (show it as `≈N`); such an answer is never cached.\n */\nexport interface ModelCostResult {\n model: string\n creditCost: number\n estimate?: true\n}\n\n/**\n * The two browser signals a claim reports — SHA-256 hex digests computed by\n * `@nodaro/sdk/signup-signals` (`collectSignupKeys`). Either may be absent:\n * a browser that cannot be measured still claims, and the server treats the\n * absence as what it is. Any other value is stored as absent server-side.\n */\nexport interface SignupKeys {\n browserKey?: string\n deviceKey?: string\n}\n\n/** The answer of `POST /v1/credits/claim-signup-grant`. */\nexport interface SignupGrantClaimResult {\n /** Where the account's free grant stands after this call. */\n state: FreeGrantState\n /** True only when THIS call moved the credits — a repeat is `false` with the same state. */\n granted: boolean\n}\n\n/**\n * One row of `GET /v1/credits/transactions` — a run's reservation and how it\n * settled.\n *\n * Which amount to read: a run first HOLDS credits and is then settled — charged\n * all or part of the hold, the rest returned. `credits_charged` is what the run\n * cost (`null` while the hold is still open, `0` once refunded); sum it for\n * spend. `credits_reserved` is the hold, which never changes. `credits_used`\n * is the same hold under its original name, kept for existing integrations.\n */\nexport interface CreditTransaction {\n id: string\n /** ISO-8601. Also the paging cursor: pass the last row's value as `cursor`. */\n created_at: string\n /** Settled charge; `null` while `status` is `\"reserved\"`, `0` when refunded. */\n credits_charged: number | null\n /** The hold taken when the run was accepted. */\n credits_reserved: number | null\n /** The hold, under its original name. Prefer `credits_charged`. */\n credits_used: number | null\n /** The model or operation the credits were for. */\n action: string | null\n provider: string | null\n /** Reservation lifecycle: `\"reserved\"`, `\"committed\"` or `\"refunded\"`. */\n status: string | null\n /** The caller's own billing details for the run (model, which pool paid, …). */\n metadata: Record<string, unknown>\n /** `\"workspace\"` when a class or team budget paid, not your balance. */\n payer: \"user\" | \"workspace\"\n workspaceId: string | null\n}\n\n/** A page of {@link CreditTransaction}s, newest first. */\nexport interface CreditTransactionsPage {\n data: CreditTransaction[]\n /** Pass as `cursor` for the next page; `null` when there are no more rows. */\n nextCursor: string | null\n}\n\nexport interface CreditTransactionsOptions {\n /** Rows per page, 1–50 (server default 20). */\n limit?: number\n /** The `nextCursor` of the previous page. */\n cursor?: string\n}\n\n/** How `credits.usageSummary()` groups the series over time. */\nexport type UsageSummaryBucket = \"day\" | \"week\" | \"month\"\n\nexport interface UsageSummaryOptions {\n /** An ISO-8601 timestamp, or a date alone (`\"2026-10-01\"`: that whole UTC day), inclusive; default the last 30 days up to now. A period of at most a year. */\n from?: string\n to?: string\n /** Default `\"day\"`. Buckets are UTC. */\n bucket?: UsageSummaryBucket\n}\n\nexport interface UsageSummaryTotals {\n /** Credits spent on runs in the period: each run's charge (a running hold counts; a refunded run does not). */\n used: number\n /** Credits bought: packs, loads, subscription grants. */\n purchased: number\n /** Credits granted free, net: sign-up and admin adjustments, a grant taken back subtracted. */\n granted: number\n /** Credits given back for a refunded run or by Stripe (a hold released when a run settled below it is not a refund). */\n refunded: number\n /** Runs that were charged or are still running. */\n runs: number\n /** `used / runs`, one decimal; 0 with no runs. */\n avgPerRun: number\n}\n\nexport interface UsageByModel {\n model: string\n provider: string | null\n credits: number\n runs: number\n /** Of `totals.used`, 0–1. */\n share: number\n}\n\nexport interface UsageByCategory {\n /** `\"image\"`, `\"video\"`, `\"audio\"` or `\"other\"`. */\n category: string\n credits: number\n runs: number\n}\n\nexport interface UsageOverTime {\n /** The bucket's first day in UTC (`\"2026-10-26\"`; a week by its Monday; a month as `\"2026-10\"`). The first bucket of a period may be a partial week or month. */\n bucket: string\n used: number\n purchased: number\n runs: number\n}\n\n/** The spend of one session or one workflow. */\nexport interface UsageByGroup {\n id: string\n /** The session's title or the workflow's name; `null` when it has none or is gone. */\n name: string | null\n /** The tool the session belongs to; `null` on a workflow. */\n tool: string | null\n credits: number\n runs: number\n /** The models used, by spend. */\n models: string[]\n /** ISO-8601: the latest run. */\n lastAt: string\n}\n\n/** The answer of `credits.usageSummary()`. */\nexport interface UsageSummary {\n period: { from: string; to: string; bucket: UsageSummaryBucket }\n totals: UsageSummaryTotals\n /** The model with the most spend; `null` with no runs. */\n mostUsed: UsageByModel | null\n /** By spend. */\n byModel: UsageByModel[]\n byCategory: UsageByCategory[]\n /** Every bucket of the period, empty ones included, oldest first. */\n overTime: UsageOverTime[]\n bySession: UsageByGroup[]\n byWorkflow: UsageByGroup[]\n /** A read hit the server's row cap: the figures under-report; narrow the period. */\n truncated: boolean\n /** A side read failed on the server (the jobs, or a session's or workflow's name): a grouping is missing or unnamed; the totals are whole. */\n partial: boolean\n}\n\n/** What a movement of the balance was; `app` is credits earned from, or paid for, a published app. */\nexport type CreditHistoryKind = \"usage\" | \"purchase\" | \"grant\" | \"refund\" | \"app\" | \"adjustment\" | \"expiry\"\n\n/** The job behind a usage row of {@link CreditHistoryEntry}. */\nexport interface CreditHistoryJob {\n id: string\n /** The node type that ran (`generate-image`, `image-to-video`, …); `null` when the job is gone. */\n type: string | null\n status: string | null\n startedAt: string | null\n completedAt: string | null\n /** From start to completion; `null` until it completes. */\n durationMs: number | null\n workflowId: string | null\n sessionId: string | null\n}\n\n/** One movement of the balance (`credits.history()`). */\nexport interface CreditHistoryEntry {\n id: string\n /** ISO-8601. Also the paging cursor. */\n at: string\n kind: CreditHistoryKind\n /** The ledger's own word: `usage`, `one_time_purchase`, `subscription_renewal`, `signup_grant`, `refund`, `admin_adjustment`, `expiry`, … */\n source: string\n /** The movement, signed: a run's hold negative, a purchase positive. */\n amount: number\n /** The balance right after this movement. */\n balanceAfter: number\n /** Which pool moved; `\"mixed\"` when both did. */\n pool: \"subscription\" | \"topup\" | \"mixed\"\n description: string | null\n /** The model that ran, on a row with a job; `null` otherwise. */\n model: string | null\n provider: string | null\n /**\n * The job's charge, on its reserve row only (the hold taken when the run\n * was accepted): the settled charge, the hold while the run is open, `0`\n * once refunded. `null` on every other row — a refund, a metered overrun\n * line, a purchase — so summing it over a list counts each job once. Read\n * this for spend, not `amount`.\n */\n charge: number | null\n /** The run's credit status (`\"reserved\"`, `\"committed\"` or `\"refunded\"`), beside `charge`; `null` elsewhere. */\n status: string | null\n /** On a row with a job; `type` and the rest `null` when the job is gone or not the person's. */\n job: CreditHistoryJob | null\n /** Stripe's hosted receipt, on a purchase that has one. */\n receiptUrl: string | null\n}\n\n/** A page of {@link CreditHistoryEntry}, newest first. */\nexport interface CreditHistoryPage {\n data: CreditHistoryEntry[]\n /** Pass as `cursor` for the next page; `null` when there are no more rows. */\n nextCursor: string | null\n}\n\n/** What narrows the history. */\nexport interface CreditHistoryFilters {\n kind?: CreditHistoryKind\n /** A model identifier: only runs of that model. */\n model?: string\n /** ISO-8601 bounds on `at`, inclusive. */\n from?: string\n to?: string\n /** Words looked for in the description, case-insensitively. */\n q?: string\n}\n\nexport interface CreditHistoryOptions extends CreditHistoryFilters {\n /** Rows per page, 1–100 (server default 50). */\n limit?: number\n /** The `nextCursor` of the previous page, as given (opaque; another string is refused with 400). */\n cursor?: string\n}\n\n/** Max identifiers per `model-costs` batch — the route caps the request at 50. */\nconst MODEL_COSTS_LIMIT = 50\n\nexport class CreditsResource {\n constructor(private client: NodaroClientCore) {}\n\n /**\n * `GET /v1/user/credits` → the authenticated user's credit balance and tier\n * info. Throws `UnauthorizedError` (401) when signed out, and the SDK's\n * other typed errors on the usual statuses.\n */\n async balance(): Promise<UserBalance> {\n const res = await this.client.request<{ data: UserBalance }>(\n \"GET\",\n \"/v1/user/credits\",\n )\n return res.data\n }\n\n /**\n * `GET /v1/credits/transactions` → one page of the caller's credit\n * transactions, newest first, with `nextCursor` for the next page (`null`\n * at the end). Read `credits_charged` for what each run cost — it can be\n * below the hold (`credits_reserved`) and is `null` while the hold is open.\n * Cloud-only route: a self-hosted instance answers 404.\n */\n transactions(options: CreditTransactionsOptions = {}): Promise<CreditTransactionsPage> {\n return this.client.request<CreditTransactionsPage>(\"GET\", \"/v1/credits/transactions\", {\n query: { limit: options.limit, cursor: options.cursor },\n })\n }\n\n /**\n * `GET /v1/credits/usage-summary` → the period's credit usage summed the\n * way a billing screen draws it: totals, the spend by model and by\n * category, a series over time (`bucket`: day, week or month, no holes),\n * and the spend by session and by workflow. The last 30 days unless\n * `from` / `to` say otherwise; a period of at most a year (400 beyond).\n * Cloud-only route: a self-hosted instance answers 404.\n */\n async usageSummary(options: UsageSummaryOptions = {}): Promise<UsageSummary> {\n const res = await this.client.request<{ data: UsageSummary }>(\"GET\", \"/v1/credits/usage-summary\", {\n query: { from: options.from, to: options.to, bucket: options.bucket },\n })\n return res.data\n }\n\n /**\n * `GET /v1/credits/history` → one page of every movement of the balance,\n * newest first — runs, purchases, grants, refunds, adjustments, expiries —\n * each with the balance after it; a job's reserve row carries its model,\n * its `charge` (the settled charge, the hold while the run is open, `0`\n * once refunded — read that for spend, not `amount`) and its job. Filter by\n * `kind`, `model`, `from` / `to` and `q`; pass the page's `nextCursor` (an\n * opaque string) as `cursor` for the next page (`null` at the end).\n * Cloud-only route: a self-hosted instance answers 404.\n */\n history(options: CreditHistoryOptions = {}): Promise<CreditHistoryPage> {\n const { limit, cursor, ...filters } = options\n return this.client.request<CreditHistoryPage>(\"GET\", \"/v1/credits/history\", {\n query: { limit, cursor, ...filters },\n })\n }\n\n /**\n * `GET /v1/credits/history?format=csv` → the whole filtered history as a\n * CSV file (the same fields as {@link history}, one line per movement,\n * newest first), at most 5,000 rows — the last line says when it was cut.\n * Hand the text to the person as `credit-history.csv`.\n */\n exportHistory(filters: CreditHistoryFilters = {}): Promise<string> {\n return this.client.requestText(\"GET\", \"/v1/credits/history\", {\n query: { ...filters, format: \"csv\" },\n })\n }\n\n /**\n * `POST /v1/credits/model-costs` → per-identifier credit cost, for editor\n * cost previews. Capped at the first {@link MODEL_COSTS_LIMIT} identifiers\n * (the route's request limit). Preserves the `{ data, missing, errors }`\n * fault-isolation shape verbatim, plus `estimates` / `errorCodes` when a\n * metered LLM price key was asked (see {@link ModelCostsResult}).\n */\n modelCosts(ids: string[]): Promise<ModelCostsResult> {\n return this.client.request<ModelCostsResult>(\"POST\", \"/v1/credits/model-costs\", {\n body: { models: ids.slice(0, MODEL_COSTS_LIMIT) },\n })\n }\n\n /**\n * `POST /v1/credits/claim-signup-grant` → claims the account's free signup\n * grant, once, with the browser signals of the page making the claim.\n *\n * Call it once per page load as soon as the session is known, and never\n * wait on it for rendering: it is idempotent (a decided account answers\n * with its state and `granted: false`), it costs the user nothing when it\n * fails (the next load asks again), and the signals are what make the\n * claim worth sending — collect them with `collectSignupKeys()` from\n * `@nodaro/sdk/signup-signals` and pass whatever came back, `{}` included.\n * Cloud-only route: a self-hosted instance answers 404.\n */\n claimSignupGrant(keys: SignupKeys = {}): Promise<SignupGrantClaimResult> {\n return this.client.request<SignupGrantClaimResult>(\"POST\", \"/v1/credits/claim-signup-grant\", {\n body: keys,\n })\n }\n\n /**\n * `POST /v1/credits/welcome-offer/claim` → the user's \"yes\" to the welcome\n * offer, as ONE server action: the marketing-email consent is recorded,\n * then the free signup grant is claimed with that consent. The abuse gate\n * still decides — consent is necessary, not sufficient — so read `grant`:\n * `\"granted\"` (the grant has landed: this call topped the subscription credits up to `credits` — not added on top — or it had landed before), `\"withheld\"` (refused), `\"revoked\"` (taken back earlier; nothing moves), `\"unclaimed\"` (nothing moved — treat as a failure and let the user retry).\n * Pass the browser signals from `collectSignupKeys()` and your app's slug.\n *\n * **Browser session only.** Usable from a first-party web app signed in\n * with a Supabase session (the consent is a person's choice in a browser);\n * an API key or OAuth app token is refused with 403. 409\n * `welcome_offer_disabled` while the deployment has the offer off — show\n * it only when `balance().welcomeOffer` is present. Cloud-only route: a\n * self-hosted instance answers 404.\n */\n claimWelcomeOffer(input: WelcomeOfferClaimInput = {}): Promise<WelcomeOfferClaimResult> {\n return this.client.request<WelcomeOfferClaimResult>(\"POST\", \"/v1/credits/welcome-offer/claim\", {\n body: input,\n })\n }\n\n /**\n * `POST /v1/credits/welcome-offer/seen` → records that the one-time welcome\n * popup was shown, so `balance().welcomeOffer.popupSeen` turns true on every\n * app. Idempotent (the first stamp wins); a failed call only means the popup\n * may show once more, so callers usually ignore errors.\n *\n * **Browser session only**, like {@link claimWelcomeOffer}: 403 for an API\n * key or OAuth app token, 409 `welcome_offer_disabled` while the offer is\n * off, 404 on a self-hosted instance.\n */\n markWelcomeOfferSeen(): Promise<WelcomeOfferSeenResult> {\n return this.client.request<WelcomeOfferSeenResult>(\"POST\", \"/v1/credits/welcome-offer/seen\")\n }\n\n // NOTE: no `estimate(...)` helper. The backend exposes\n // `POST /v1/credits/estimate-workflow` (body `{ nodes }` → `{ data: {\n // totalCredits, nodeCount, estimate?: true } }` — `estimate` when a metered\n // LLM node's estimate is in the total), but no consumer has a settled shape for it\n // yet (studio pre-checks `balance >= Σ modelCosts` client-side rather than\n // calling an estimate endpoint). Adding it now would be inventing an API\n // surface ahead of a real caller, so it's deliberately omitted — add it when\n // a consumer needs it, shaped to that need.\n}\n"]}
|
|
@@ -39,13 +39,13 @@ import { CollectionsResource } from './chunk-4WRDR4GN.js';
|
|
|
39
39
|
import { CommunityResource } from './chunk-SFB4YLCS.js';
|
|
40
40
|
import { CompetitorsResource } from './chunk-BU5A6K4C.js';
|
|
41
41
|
import { CopilotResource } from './chunk-D2ILCSOQ.js';
|
|
42
|
-
import { NodaroClientCore } from './chunk-
|
|
42
|
+
import { NodaroClientCore } from './chunk-XISHBW5I.js';
|
|
43
43
|
import { CreaturesResource } from './chunk-CK3AMMSC.js';
|
|
44
|
-
import { CreditsResource } from './chunk-
|
|
44
|
+
import { CreditsResource } from './chunk-7QK2NXJA.js';
|
|
45
45
|
import { DeveloperAppsResource } from './chunk-65E3JBFZ.js';
|
|
46
46
|
import { AppsResource } from './chunk-7LODCIQK.js';
|
|
47
47
|
import { AudioResource } from './chunk-3QFTP5P5.js';
|
|
48
|
-
import { BillingResource } from './chunk-
|
|
48
|
+
import { BillingResource } from './chunk-WYYDWJFF.js';
|
|
49
49
|
import { CastSwapResource } from './chunk-OCRUDBPG.js';
|
|
50
50
|
import { CatalogsResource } from './chunk-KG4R454Z.js';
|
|
51
51
|
import { CharactersResource } from './chunk-EJSGJDZY.js';
|
|
@@ -192,5 +192,5 @@ function createClient(opts) {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
export { NodaroClient, createClient };
|
|
195
|
-
//# sourceMappingURL=chunk-
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
195
|
+
//# sourceMappingURL=chunk-EC6MC46Y.js.map
|
|
196
|
+
//# sourceMappingURL=chunk-EC6MC46Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,gBAAA,CAAiB;AAAA,EACxC,SAAA;AAAA,EACA,QAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,KAAA;AAAA;AAAA,EAEA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA;AAAA,EAEA,OAAA;AAAA,EAC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AAA;AAC3C,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAI,qBAAA,CAAsB,IAAI,CAAA;AACnD,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,kBAAA,CAAmB,IAAI,CAAA;AAC7C,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,YAAA,CAAa,IAAI,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,cAAc,WAAA,EAA0C;AAMtD,IAAA,MAAM,aAAA,GAAgB,KAAK,eAAe,CAAA;AAC1C,IAAA,OAAO,IAAI,aAAA,CAAa;AAAA,MACtB,SAAS,IAAA,CAAK,OAAA;AAAA,MACd,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,GAAI,aAAA,GAAgB,EAAE,KAAA,EAAO,aAAA,KAAkB,EAAC;AAAA,MAChD,GAAI,KAAK,kBAAkB,CAAA,GAAI,EAAE,WAAA,EAAa,IAAA,CAAK,WAAA,EAAY,GAAI,EAAC;AAAA,MACpE,GAAI,WAAA,GAAc,EAAE,WAAA,KAAgB;AAAC,KACtC,CAAA;AAAA,EACH;AACF;AAGO,SAAS,aAAa,IAAA,EAAmC;AAC9D,EAAA,OAAO,IAAI,aAAa,IAAI,CAAA;AAC9B","file":"chunk-2JAKOBD3.js","sourcesContent":["import { WorkflowsResource } from \"./resources/workflows.js\"\nimport { ProjectsResource } from \"./resources/projects.js\"\nimport { SessionsResource } from \"./resources/sessions.js\"\nimport { TrashResource } from \"./resources/trash.js\"\nimport { JobsResource } from \"./resources/jobs.js\"\nimport { VideoProResource } from \"./resources/video-pro.js\"\nimport { ExecutionsResource } from \"./resources/executions.js\"\nimport { NodesResource } from \"./resources/nodes.js\"\nimport { Scene3DResource } from \"./resources/scene3d.js\"\nimport { DeveloperAppsResource } from \"./resources/developer-apps.js\"\nimport { OAuthResource } from \"./resources/oauth.js\"\nimport { WebhooksResource } from \"./resources/webhooks.js\"\nimport { AppsResource } from \"./resources/apps.js\"\nimport { CharactersResource } from \"./resources/characters.js\"\nimport { LocationsResource } from \"./resources/locations.js\"\nimport { ObjectsResource } from \"./resources/objects.js\"\nimport { CreaturesResource } from \"./resources/creatures.js\"\nimport { PipelinesResource } from \"./resources/pipelines.js\"\nimport { ReduceResource } from \"./resources/reduce.js\"\nimport { PromptHelperResource } from \"./resources/prompt-helper.js\"\nimport { VoicesResource } from \"./resources/voices.js\"\nimport { LlmResource } from \"./resources/llm.js\"\nimport { MediaResource } from \"./resources/media.js\"\nimport { AudioResource } from \"./resources/audio.js\"\nimport { CreditsResource } from \"./resources/credits.js\"\nimport { BillingResource } from \"./resources/billing.js\"\nimport { UploadsResource } from \"./resources/uploads.js\"\nimport { LibraryResource } from \"./resources/library.js\"\nimport { GalleryResource } from \"./resources/gallery.js\"\nimport { PresetsResource } from \"./resources/node-presets.js\"\nimport { SavedPostsResource } from \"./resources/saved-posts.js\"\nimport { CollectionsResource } from \"./resources/collections.js\"\nimport { PalettesResource } from \"./resources/palettes.js\"\nimport { MoodboardsResource } from \"./resources/moodboards.js\"\nimport { CompetitorsResource } from \"./resources/competitors.js\"\nimport { PickerCatalogsResource } from \"./resources/picker-catalogs.js\"\nimport { CatalogsResource } from \"./resources/catalogs.js\"\nimport { ModelsResource } from \"./resources/models.js\"\nimport { ShotsResource } from \"./resources/shots.js\"\nimport { RecastResource } from \"./resources/recast.js\"\nimport { CastSwapResource } from \"./resources/cast-swap.js\"\nimport { TrendsResource } from \"./resources/trends.js\"\nimport { StudioResource } from \"./resources/studio.js\"\nimport { CopilotResource } from \"./resources/copilot.js\"\nimport { CommunityResource } from \"./resources/community.js\"\nimport { TemplatesResource } from \"./resources/templates.js\"\nimport { TutorialsResource } from \"./resources/tutorials.js\"\nimport { OrganizationsResource } from \"./resources/organizations.js\"\nimport { WorkspacesResource } from \"./resources/workspaces.js\"\nimport { EditResource } from \"./resources/edit.js\"\nimport { NodaroClientCore, type ClientOptions } from \"./core.js\"\n\nexport { CLIENT_HEADER } from \"./core.js\"\nexport type { ClientOptions, UserIdentity, ConnectedApp } from \"./core.js\"\n\n/**\n * The full client: the core (`./core.ts` — config, transport, identity) and\n * every resource.\n */\nexport class NodaroClient extends NodaroClientCore {\n readonly workflows: WorkflowsResource\n readonly projects: ProjectsResource\n /** Generation sessions inside projects (Create Image / Video / Music). */\n readonly sessions: SessionsResource\n /** Your Trash: items removed from sessions and deleted jobs. */\n readonly trash: TrashResource\n readonly jobs: JobsResource\n readonly videoPro: VideoProResource\n readonly executions: ExecutionsResource\n readonly nodes: NodesResource\n readonly scene3d: Scene3DResource\n readonly developerApps: DeveloperAppsResource\n readonly oauth: OAuthResource\n /** Outbound webhooks: endpoints that receive your job.completed / job.failed. */\n readonly webhooks: WebhooksResource\n readonly apps: AppsResource\n readonly characters: CharactersResource\n readonly locations: LocationsResource\n readonly objects: ObjectsResource\n readonly creatures: CreaturesResource\n readonly pipelines: PipelinesResource\n readonly reduce: ReduceResource\n readonly promptHelper: PromptHelperResource\n readonly voices: VoicesResource\n readonly llm: LlmResource\n readonly media: MediaResource\n readonly audio: AudioResource\n readonly credits: CreditsResource\n /** Plans and prices, the subscription, and how this deployment bills. */\n readonly billing: BillingResource\n readonly uploads: UploadsResource\n readonly library: LibraryResource\n /** The public gallery and your favorites. */\n readonly gallery: GalleryResource\n readonly presets: PresetsResource\n readonly savedPosts: SavedPostsResource\n readonly collections: CollectionsResource\n /** Your colour palettes — a generate-image direction (`direction.colorLook: paletteDirectionId(id)`). */\n readonly palettes: PalettesResource\n /** Your moodboards — a generate-image direction (`direction.style: moodboardDirectionId(id)`). */\n readonly moodboards: MoodboardsResource\n readonly competitors: CompetitorsResource\n readonly pickerCatalogs: PickerCatalogsResource\n readonly catalogs: CatalogsResource\n readonly models: ModelsResource\n readonly shots: ShotsResource\n readonly recast: RecastResource\n /** Cast Swap: replace the people and/or location in a short video (Cloud). */\n readonly castSwap: CastSwapResource\n /** Trends: ready-made Cast Swap recipes you fill with your own pictures (Cloud). */\n readonly trends: TrendsResource\n readonly studio: StudioResource\n readonly copilot: CopilotResource\n readonly community: CommunityResource\n readonly templates: TemplatesResource\n readonly tutorials: TutorialsResource\n readonly organizations: OrganizationsResource\n readonly workspaces: WorkspacesResource\n readonly edit: EditResource\n\n constructor(opts: ClientOptions) {\n super(opts)\n\n this.workflows = new WorkflowsResource(this)\n this.projects = new ProjectsResource(this)\n this.sessions = new SessionsResource(this)\n this.trash = new TrashResource(this)\n this.jobs = new JobsResource(this)\n this.videoPro = new VideoProResource(this)\n this.executions = new ExecutionsResource(this)\n this.nodes = new NodesResource(this)\n this.scene3d = new Scene3DResource(this)\n this.developerApps = new DeveloperAppsResource(this)\n this.oauth = new OAuthResource(this)\n this.webhooks = new WebhooksResource(this)\n this.apps = new AppsResource(this)\n this.characters = new CharactersResource(this)\n this.locations = new LocationsResource(this)\n this.objects = new ObjectsResource(this)\n this.creatures = new CreaturesResource(this)\n this.pipelines = new PipelinesResource(this)\n this.reduce = new ReduceResource(this)\n this.promptHelper = new PromptHelperResource(this)\n this.voices = new VoicesResource(this)\n this.llm = new LlmResource(this)\n this.media = new MediaResource(this)\n this.audio = new AudioResource(this)\n this.credits = new CreditsResource(this)\n this.billing = new BillingResource(this)\n this.uploads = new UploadsResource(this)\n this.library = new LibraryResource(this)\n this.gallery = new GalleryResource(this)\n this.presets = new PresetsResource(this)\n this.savedPosts = new SavedPostsResource(this)\n this.collections = new CollectionsResource(this)\n this.palettes = new PalettesResource(this)\n this.moodboards = new MoodboardsResource(this)\n this.competitors = new CompetitorsResource(this)\n this.pickerCatalogs = new PickerCatalogsResource(this)\n this.catalogs = new CatalogsResource(this)\n this.models = new ModelsResource(this)\n this.shots = new ShotsResource(this)\n this.recast = new RecastResource(this)\n this.castSwap = new CastSwapResource(this)\n this.trends = new TrendsResource(this)\n this.studio = new StudioResource(this)\n this.copilot = new CopilotResource(this)\n this.community = new CommunityResource(this)\n this.templates = new TemplatesResource(this)\n this.tutorials = new TutorialsResource(this)\n this.organizations = new OrganizationsResource(this)\n this.workspaces = new WorkspacesResource(this)\n this.edit = new EditResource(this)\n }\n\n /**\n * A client that acts in `workspaceId`, sharing this one's auth and config.\n *\n * A NEW client rather than a setter, deliberately. A mutable selection is\n * the bug this whole axis exists to prevent: two concurrent operations\n * against one client would race over which workspace they were in, and the\n * loser would create work in the wrong place with nothing failing. A\n * per-workspace client cannot be raced.\n *\n * Pass `null` for the personal space.\n */\n withWorkspace(workspaceId: string | null): NodaroClient {\n // The two private settings are read by bracket access, which TypeScript\n // allows on a subclass and which adds no member to the declarations. Read\n // through `this` (not a side table keyed by the instance), so a client\n // wrapped in a Proxy (Vue/Pinia `reactive()`) or reached through\n // `Object.create(client)` still works.\n const fetchOverride = this[\"fetchOverride\"]\n return new NodaroClient({\n baseUrl: this.baseUrl,\n auth: this.auth,\n timeoutMs: this.timeoutMs,\n ...(fetchOverride ? { fetch: fetchOverride } : {}),\n ...(this[\"sendClientHeader\"] ? { clientLabel: this.clientLabel } : {}),\n ...(workspaceId ? { workspaceId } : {}),\n })\n }\n}\n\n/** Factory function — preferred entry point. */\nexport function createClient(opts: ClientOptions): NodaroClient {\n return new NodaroClient(opts)\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DO,IAAM,YAAA,GAAN,MAAM,aAAA,SAAqB,gBAAA,CAAiB;AAAA,EACxC,SAAA;AAAA,EACA,QAAA;AAAA;AAAA,EAEA,QAAA;AAAA;AAAA,EAEA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,KAAA;AAAA;AAAA,EAEA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;A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C,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAI,CAAA;AAC3C,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAI,CAAA;AAC3C,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,iBAAA,CAAkB,IAAI,CAAA;AAC3C,IAAA,IAAA,CAAK,aAAA,GAAgB,IAAI,qBAAA,CAAsB,IAAI,CAAA;AACnD,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,kBAAA,CAAmB,IAAI,CAAA;AAC7C,IAAA,IAAA,CAAK,IAAA,GAAO,IAAI,YAAA,CAAa,IAAI,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,cAAc,WAAA,EAA0C;AAMtD,IAAA,MAAM,aAAA,GAAgB,KAAK,eAAe,CAAA;AAC1C,IAAA,OAAO,IAAI,aAAA,CAAa;AAAA,MACtB,SAAS,IAAA,CAAK,OAAA;AAAA,MACd,MAAM,IAAA,CAAK,IAAA;AAAA,MACX,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,GAAI,aAAA,GAAgB,EAAE,KAAA,EAAO,aAAA,KAAkB,EAAC;AAAA,MAChD,GAAI,KAAK,kBAAkB,CAAA,GAAI,EAAE,WAAA,EAAa,IAAA,CAAK,WAAA,EAAY,GAAI,EAAC;AAAA,MACpE,GAAI,WAAA,GAAc,EAAE,WAAA,KAAgB;AAAC,KACtC,CAAA;AAAA,EACH;AACF;AAGO,SAAS,aAAa,IAAA,EAAmC;AAC9D,EAAA,OAAO,IAAI,aAAa,IAAI,CAAA;AAC9B","file":"chunk-EC6MC46Y.js","sourcesContent":["import { WorkflowsResource } from \"./resources/workflows.js\"\nimport { ProjectsResource } from \"./resources/projects.js\"\nimport { SessionsResource } from \"./resources/sessions.js\"\nimport { TrashResource } from \"./resources/trash.js\"\nimport { JobsResource } from \"./resources/jobs.js\"\nimport { VideoProResource } from \"./resources/video-pro.js\"\nimport { ExecutionsResource } from \"./resources/executions.js\"\nimport { NodesResource } from \"./resources/nodes.js\"\nimport { Scene3DResource } from \"./resources/scene3d.js\"\nimport { DeveloperAppsResource } from \"./resources/developer-apps.js\"\nimport { OAuthResource } from \"./resources/oauth.js\"\nimport { WebhooksResource } from \"./resources/webhooks.js\"\nimport { AppsResource } from \"./resources/apps.js\"\nimport { CharactersResource } from \"./resources/characters.js\"\nimport { LocationsResource } from \"./resources/locations.js\"\nimport { ObjectsResource } from \"./resources/objects.js\"\nimport { CreaturesResource } from \"./resources/creatures.js\"\nimport { PipelinesResource } from \"./resources/pipelines.js\"\nimport { ReduceResource } from \"./resources/reduce.js\"\nimport { PromptHelperResource } from \"./resources/prompt-helper.js\"\nimport { VoicesResource } from \"./resources/voices.js\"\nimport { LlmResource } from \"./resources/llm.js\"\nimport { MediaResource } from \"./resources/media.js\"\nimport { AudioResource } from \"./resources/audio.js\"\nimport { CreditsResource } from \"./resources/credits.js\"\nimport { BillingResource } from \"./resources/billing.js\"\nimport { UploadsResource } from \"./resources/uploads.js\"\nimport { LibraryResource } from \"./resources/library.js\"\nimport { GalleryResource } from \"./resources/gallery.js\"\nimport { PresetsResource } from \"./resources/node-presets.js\"\nimport { SavedPostsResource } from \"./resources/saved-posts.js\"\nimport { CollectionsResource } from \"./resources/collections.js\"\nimport { PalettesResource } from \"./resources/palettes.js\"\nimport { MoodboardsResource } from \"./resources/moodboards.js\"\nimport { CompetitorsResource } from \"./resources/competitors.js\"\nimport { PickerCatalogsResource } from \"./resources/picker-catalogs.js\"\nimport { CatalogsResource } from \"./resources/catalogs.js\"\nimport { ModelsResource } from \"./resources/models.js\"\nimport { ShotsResource } from \"./resources/shots.js\"\nimport { RecastResource } from \"./resources/recast.js\"\nimport { CastSwapResource } from \"./resources/cast-swap.js\"\nimport { TrendsResource } from \"./resources/trends.js\"\nimport { StudioResource } from \"./resources/studio.js\"\nimport { CopilotResource } from \"./resources/copilot.js\"\nimport { CommunityResource } from \"./resources/community.js\"\nimport { TemplatesResource } from \"./resources/templates.js\"\nimport { TutorialsResource } from \"./resources/tutorials.js\"\nimport { OrganizationsResource } from \"./resources/organizations.js\"\nimport { WorkspacesResource } from \"./resources/workspaces.js\"\nimport { EditResource } from \"./resources/edit.js\"\nimport { NodaroClientCore, type ClientOptions } from \"./core.js\"\n\nexport { CLIENT_HEADER } from \"./core.js\"\nexport type { ClientOptions, UserIdentity, ConnectedApp } from \"./core.js\"\n\n/**\n * The full client: the core (`./core.ts` — config, transport, identity) and\n * every resource.\n */\nexport class NodaroClient extends NodaroClientCore {\n readonly workflows: WorkflowsResource\n readonly projects: ProjectsResource\n /** Generation sessions inside projects (Create Image / Video / Music). */\n readonly sessions: SessionsResource\n /** Your Trash: items removed from sessions and deleted jobs. */\n readonly trash: TrashResource\n readonly jobs: JobsResource\n readonly videoPro: VideoProResource\n readonly executions: ExecutionsResource\n readonly nodes: NodesResource\n readonly scene3d: Scene3DResource\n readonly developerApps: DeveloperAppsResource\n readonly oauth: OAuthResource\n /** Outbound webhooks: endpoints that receive your job.completed / job.failed. */\n readonly webhooks: WebhooksResource\n readonly apps: AppsResource\n readonly characters: CharactersResource\n readonly locations: LocationsResource\n readonly objects: ObjectsResource\n readonly creatures: CreaturesResource\n readonly pipelines: PipelinesResource\n readonly reduce: ReduceResource\n readonly promptHelper: PromptHelperResource\n readonly voices: VoicesResource\n readonly llm: LlmResource\n readonly media: MediaResource\n readonly audio: AudioResource\n readonly credits: CreditsResource\n /** Plans and prices, the subscription, and how this deployment bills. */\n readonly billing: BillingResource\n readonly uploads: UploadsResource\n readonly library: LibraryResource\n /** The public gallery and your favorites. */\n readonly gallery: GalleryResource\n readonly presets: PresetsResource\n readonly savedPosts: SavedPostsResource\n readonly collections: CollectionsResource\n /** Your colour palettes — a generate-image direction (`direction.colorLook: paletteDirectionId(id)`). */\n readonly palettes: PalettesResource\n /** Your moodboards — a generate-image direction (`direction.style: moodboardDirectionId(id)`). */\n readonly moodboards: MoodboardsResource\n readonly competitors: CompetitorsResource\n readonly pickerCatalogs: PickerCatalogsResource\n readonly catalogs: CatalogsResource\n readonly models: ModelsResource\n readonly shots: ShotsResource\n readonly recast: RecastResource\n /** Cast Swap: replace the people and/or location in a short video (Cloud). */\n readonly castSwap: CastSwapResource\n /** Trends: ready-made Cast Swap recipes you fill with your own pictures (Cloud). */\n readonly trends: TrendsResource\n readonly studio: StudioResource\n readonly copilot: CopilotResource\n readonly community: CommunityResource\n readonly templates: TemplatesResource\n readonly tutorials: TutorialsResource\n readonly organizations: OrganizationsResource\n readonly workspaces: WorkspacesResource\n readonly edit: EditResource\n\n constructor(opts: ClientOptions) {\n super(opts)\n\n this.workflows = new WorkflowsResource(this)\n this.projects = new ProjectsResource(this)\n this.sessions = new SessionsResource(this)\n this.trash = new TrashResource(this)\n this.jobs = new JobsResource(this)\n this.videoPro = new VideoProResource(this)\n this.executions = new ExecutionsResource(this)\n this.nodes = new NodesResource(this)\n this.scene3d = new Scene3DResource(this)\n this.developerApps = new DeveloperAppsResource(this)\n this.oauth = new OAuthResource(this)\n this.webhooks = new WebhooksResource(this)\n this.apps = new AppsResource(this)\n this.characters = new CharactersResource(this)\n this.locations = new LocationsResource(this)\n this.objects = new ObjectsResource(this)\n this.creatures = new CreaturesResource(this)\n this.pipelines = new PipelinesResource(this)\n this.reduce = new ReduceResource(this)\n this.promptHelper = new PromptHelperResource(this)\n this.voices = new VoicesResource(this)\n this.llm = new LlmResource(this)\n this.media = new MediaResource(this)\n this.audio = new AudioResource(this)\n this.credits = new CreditsResource(this)\n this.billing = new BillingResource(this)\n this.uploads = new UploadsResource(this)\n this.library = new LibraryResource(this)\n this.gallery = new GalleryResource(this)\n this.presets = new PresetsResource(this)\n this.savedPosts = new SavedPostsResource(this)\n this.collections = new CollectionsResource(this)\n this.palettes = new PalettesResource(this)\n this.moodboards = new MoodboardsResource(this)\n this.competitors = new CompetitorsResource(this)\n this.pickerCatalogs = new PickerCatalogsResource(this)\n this.catalogs = new CatalogsResource(this)\n this.models = new ModelsResource(this)\n this.shots = new ShotsResource(this)\n this.recast = new RecastResource(this)\n this.castSwap = new CastSwapResource(this)\n this.trends = new TrendsResource(this)\n this.studio = new StudioResource(this)\n this.copilot = new CopilotResource(this)\n this.community = new CommunityResource(this)\n this.templates = new TemplatesResource(this)\n this.tutorials = new TutorialsResource(this)\n this.organizations = new OrganizationsResource(this)\n this.workspaces = new WorkspacesResource(this)\n this.edit = new EditResource(this)\n }\n\n /**\n * A client that acts in `workspaceId`, sharing this one's auth and config.\n *\n * A NEW client rather than a setter, deliberately. A mutable selection is\n * the bug this whole axis exists to prevent: two concurrent operations\n * against one client would race over which workspace they were in, and the\n * loser would create work in the wrong place with nothing failing. A\n * per-workspace client cannot be raced.\n *\n * Pass `null` for the personal space.\n */\n withWorkspace(workspaceId: string | null): NodaroClient {\n // The two private settings are read by bracket access, which TypeScript\n // allows on a subclass and which adds no member to the declarations. Read\n // through `this` (not a side table keyed by the instance), so a client\n // wrapped in a Proxy (Vue/Pinia `reactive()`) or reached through\n // `Object.create(client)` still works.\n const fetchOverride = this[\"fetchOverride\"]\n return new NodaroClient({\n baseUrl: this.baseUrl,\n auth: this.auth,\n timeoutMs: this.timeoutMs,\n ...(fetchOverride ? { fetch: fetchOverride } : {}),\n ...(this[\"sendClientHeader\"] ? { clientLabel: this.clientLabel } : {}),\n ...(workspaceId ? { workspaceId } : {}),\n })\n }\n}\n\n/** Factory function — preferred entry point. */\nexport function createClient(opts: ClientOptions): NodaroClient {\n return new NodaroClient(opts)\n}\n"]}
|
|
@@ -41,19 +41,19 @@ var chunkWK4VXPPZ_cjs = require('./chunk-WK4VXPPZ.cjs');
|
|
|
41
41
|
var chunk43FVH6LJ_cjs = require('./chunk-43FVH6LJ.cjs');
|
|
42
42
|
var chunkYFS2LMG4_cjs = require('./chunk-YFS2LMG4.cjs');
|
|
43
43
|
var chunkOSMKIRKI_cjs = require('./chunk-OSMKIRKI.cjs');
|
|
44
|
-
var
|
|
44
|
+
var chunkOMX7JBGY_cjs = require('./chunk-OMX7JBGY.cjs');
|
|
45
45
|
var chunkHGCVWOGK_cjs = require('./chunk-HGCVWOGK.cjs');
|
|
46
|
-
var
|
|
46
|
+
var chunk4BAHF762_cjs = require('./chunk-4BAHF762.cjs');
|
|
47
47
|
var chunkA3S55XGF_cjs = require('./chunk-A3S55XGF.cjs');
|
|
48
48
|
var chunkJOXZ4ZIF_cjs = require('./chunk-JOXZ4ZIF.cjs');
|
|
49
49
|
var chunkGA4LZZKQ_cjs = require('./chunk-GA4LZZKQ.cjs');
|
|
50
|
-
var
|
|
50
|
+
var chunk6FZN3QQO_cjs = require('./chunk-6FZN3QQO.cjs');
|
|
51
51
|
var chunkTY2S25W5_cjs = require('./chunk-TY2S25W5.cjs');
|
|
52
52
|
var chunkBPWUWUZ3_cjs = require('./chunk-BPWUWUZ3.cjs');
|
|
53
53
|
var chunkHAKYPZLB_cjs = require('./chunk-HAKYPZLB.cjs');
|
|
54
54
|
|
|
55
55
|
// src/client.ts
|
|
56
|
-
var NodaroClient = class _NodaroClient extends
|
|
56
|
+
var NodaroClient = class _NodaroClient extends chunkOMX7JBGY_cjs.NodaroClientCore {
|
|
57
57
|
workflows;
|
|
58
58
|
projects;
|
|
59
59
|
/** Generation sessions inside projects (Create Image / Video / Music). */
|
|
@@ -139,8 +139,8 @@ var NodaroClient = class _NodaroClient extends chunkNOBQQTAG_cjs.NodaroClientCor
|
|
|
139
139
|
this.llm = new chunkSS3B6PHT_cjs.LlmResource(this);
|
|
140
140
|
this.media = new chunk22P4X3N5_cjs.MediaResource(this);
|
|
141
141
|
this.audio = new chunkGA4LZZKQ_cjs.AudioResource(this);
|
|
142
|
-
this.credits = new
|
|
143
|
-
this.billing = new
|
|
142
|
+
this.credits = new chunk4BAHF762_cjs.CreditsResource(this);
|
|
143
|
+
this.billing = new chunk6FZN3QQO_cjs.BillingResource(this);
|
|
144
144
|
this.uploads = new chunkJTOEHQQJ_cjs.UploadsResource(this);
|
|
145
145
|
this.library = new chunk2DZWWIJ4_cjs.LibraryResource(this);
|
|
146
146
|
this.gallery = new chunkWUKIJJG2_cjs.GalleryResource(this);
|
|
@@ -195,5 +195,5 @@ function createClient(opts) {
|
|
|
195
195
|
|
|
196
196
|
exports.NodaroClient = NodaroClient;
|
|
197
197
|
exports.createClient = createClient;
|
|
198
|
-
//# sourceMappingURL=chunk-
|
|
199
|
-
//# sourceMappingURL=chunk-
|
|
198
|
+
//# sourceMappingURL=chunk-HPSENMVN.cjs.map
|
|
199
|
+
//# sourceMappingURL=chunk-HPSENMVN.cjs.map
|