@gpt-platform/client 0.10.4 → 0.11.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/_internal/client/client.gen.d.ts +3 -0
- package/dist/_internal/client/client.gen.d.ts.map +1 -0
- package/dist/_internal/client/index.d.ts +9 -0
- package/dist/_internal/client/index.d.ts.map +1 -0
- package/dist/_internal/client/types.gen.d.ts +118 -0
- package/dist/_internal/client/types.gen.d.ts.map +1 -0
- package/dist/_internal/client/utils.gen.d.ts +34 -0
- package/dist/_internal/client/utils.gen.d.ts.map +1 -0
- package/dist/_internal/client.gen.d.ts +13 -0
- package/dist/_internal/client.gen.d.ts.map +1 -0
- package/dist/_internal/core/auth.gen.d.ts +19 -0
- package/dist/_internal/core/auth.gen.d.ts.map +1 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts +26 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/params.gen.d.ts +44 -0
- package/dist/_internal/core/params.gen.d.ts.map +1 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts +34 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/_internal/core/types.gen.d.ts +79 -0
- package/dist/_internal/core/types.gen.d.ts.map +1 -0
- package/dist/_internal/core/utils.gen.d.ts +20 -0
- package/dist/_internal/core/utils.gen.d.ts.map +1 -0
- package/dist/_internal/index.d.ts +3 -0
- package/dist/_internal/index.d.ts.map +1 -0
- package/dist/_internal/sdk.gen.d.ts +7053 -0
- package/dist/_internal/sdk.gen.d.ts.map +1 -0
- package/dist/_internal/types.gen.d.ts +146633 -0
- package/dist/_internal/types.gen.d.ts.map +1 -0
- package/dist/base-client.d.ts +199 -0
- package/dist/base-client.d.ts.map +1 -0
- package/dist/errors/index.d.ts +128 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events.d.ts +69 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/execution-events.d.ts +95 -0
- package/dist/execution-events.d.ts.map +1 -0
- package/dist/gpt-client.d.ts +2175 -0
- package/dist/gpt-client.d.ts.map +1 -0
- package/dist/index.d.ts +51 -30308
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +775 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +775 -14
- package/dist/index.mjs.map +1 -1
- package/dist/json-api.d.ts +26 -0
- package/dist/json-api.d.ts.map +1 -0
- package/dist/logging.d.ts +22 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/namespace-types.d.ts +79 -0
- package/dist/namespace-types.d.ts.map +1 -0
- package/dist/namespaces/access-grants.d.ts +71 -0
- package/dist/namespaces/access-grants.d.ts.map +1 -0
- package/dist/namespaces/agents.d.ts +1406 -0
- package/dist/namespaces/agents.d.ts.map +1 -0
- package/dist/namespaces/ai.d.ts +407 -0
- package/dist/namespaces/ai.d.ts.map +1 -0
- package/dist/namespaces/audit.d.ts +83 -0
- package/dist/namespaces/audit.d.ts.map +1 -0
- package/dist/namespaces/billing.d.ts +854 -0
- package/dist/namespaces/billing.d.ts.map +1 -0
- package/dist/namespaces/campaigns.d.ts +973 -0
- package/dist/namespaces/campaigns.d.ts.map +1 -0
- package/dist/namespaces/catalog.d.ts +964 -0
- package/dist/namespaces/catalog.d.ts.map +1 -0
- package/dist/namespaces/channels.d.ts +162 -0
- package/dist/namespaces/channels.d.ts.map +1 -0
- package/dist/namespaces/clinical.d.ts +2443 -0
- package/dist/namespaces/clinical.d.ts.map +1 -0
- package/dist/namespaces/communication.d.ts +439 -0
- package/dist/namespaces/communication.d.ts.map +1 -0
- package/dist/namespaces/compliance.d.ts +2310 -0
- package/dist/namespaces/compliance.d.ts.map +1 -0
- package/dist/namespaces/connectors.d.ts +1368 -0
- package/dist/namespaces/connectors.d.ts.map +1 -0
- package/dist/namespaces/content.d.ts +188 -0
- package/dist/namespaces/content.d.ts.map +1 -0
- package/dist/namespaces/crawler.d.ts +408 -0
- package/dist/namespaces/crawler.d.ts.map +1 -0
- package/dist/namespaces/crm-clusters.d.ts +31 -0
- package/dist/namespaces/crm-clusters.d.ts.map +1 -0
- package/dist/namespaces/crm.d.ts +1539 -0
- package/dist/namespaces/crm.d.ts.map +1 -0
- package/dist/namespaces/documents.d.ts +136 -0
- package/dist/namespaces/documents.d.ts.map +1 -0
- package/dist/namespaces/email.d.ts +550 -0
- package/dist/namespaces/email.d.ts.map +1 -0
- package/dist/namespaces/extraction.d.ts +1249 -0
- package/dist/namespaces/extraction.d.ts.map +1 -0
- package/dist/namespaces/identity.d.ts +411 -0
- package/dist/namespaces/identity.d.ts.map +1 -0
- package/dist/namespaces/imports.d.ts +177 -0
- package/dist/namespaces/imports.d.ts.map +1 -0
- package/dist/namespaces/index.d.ts +119 -0
- package/dist/namespaces/index.d.ts.map +1 -0
- package/dist/namespaces/memory.d.ts +105 -0
- package/dist/namespaces/memory.d.ts.map +1 -0
- package/dist/namespaces/models.d.ts +75 -0
- package/dist/namespaces/models.d.ts.map +1 -0
- package/dist/namespaces/permissions.d.ts +75 -0
- package/dist/namespaces/permissions.d.ts.map +1 -0
- package/dist/namespaces/pipeline-executions.d.ts +130 -0
- package/dist/namespaces/pipeline-executions.d.ts.map +1 -0
- package/dist/namespaces/pipelines.d.ts +120 -0
- package/dist/namespaces/pipelines.d.ts.map +1 -0
- package/dist/namespaces/platform.d.ts +1430 -0
- package/dist/namespaces/platform.d.ts.map +1 -0
- package/dist/namespaces/portal.d.ts +198 -0
- package/dist/namespaces/portal.d.ts.map +1 -0
- package/dist/namespaces/projects.d.ts +553 -0
- package/dist/namespaces/projects.d.ts.map +1 -0
- package/dist/namespaces/roles.d.ts +65 -0
- package/dist/namespaces/roles.d.ts.map +1 -0
- package/dist/namespaces/scheduling.d.ts +944 -0
- package/dist/namespaces/scheduling.d.ts.map +1 -0
- package/dist/namespaces/search.d.ts +224 -0
- package/dist/namespaces/search.d.ts.map +1 -0
- package/dist/namespaces/session-notes.d.ts +67 -0
- package/dist/namespaces/session-notes.d.ts.map +1 -0
- package/dist/namespaces/social.d.ts +330 -0
- package/dist/namespaces/social.d.ts.map +1 -0
- package/dist/namespaces/storage.d.ts +378 -0
- package/dist/namespaces/storage.d.ts.map +1 -0
- package/dist/namespaces/support.d.ts +427 -0
- package/dist/namespaces/support.d.ts.map +1 -0
- package/dist/namespaces/threads.d.ts +596 -0
- package/dist/namespaces/threads.d.ts.map +1 -0
- package/dist/namespaces/training.d.ts +358 -0
- package/dist/namespaces/training.d.ts.map +1 -0
- package/dist/namespaces/voice.d.ts +752 -0
- package/dist/namespaces/voice.d.ts.map +1 -0
- package/dist/namespaces/watcher.d.ts +425 -0
- package/dist/namespaces/watcher.d.ts.map +1 -0
- package/dist/namespaces/webhooks-ns.d.ts +3 -0
- package/dist/namespaces/webhooks-ns.d.ts.map +1 -0
- package/dist/pagination.d.ts +57 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/request-builder.d.ts +95 -0
- package/dist/request-builder.d.ts.map +1 -0
- package/dist/security.d.ts +32 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/streaming.d.ts +135 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/utils/retry.d.ts +63 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/webhook-signature.d.ts +109 -0
- package/dist/webhook-signature.d.ts.map +1 -0
- package/llms.txt +40 -1
- package/package.json +286 -36
- package/dist/index.d.mts +0 -30308
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
import type { CreditPackage, FeatureDefinition, FeatureUsage, Invoice, PaymentMethod, Plan, PlanFeatureAllocation, SeatInfo, Transaction, Wallet, FeatureSummary } from "../_internal/types.gen";
|
|
2
|
+
import type { RequestOptions } from "../base-client";
|
|
3
|
+
import { RequestBuilder } from "../request-builder";
|
|
4
|
+
/**
|
|
5
|
+
* A saved payment method as returned in wallet.payment_methods sideload.
|
|
6
|
+
* Use `billing.paymentMethods.list()` for full CRUD access.
|
|
7
|
+
*/
|
|
8
|
+
export interface WalletPaymentMethod {
|
|
9
|
+
id: string;
|
|
10
|
+
type: "card" | "bank_account";
|
|
11
|
+
last4?: string;
|
|
12
|
+
brand?: string;
|
|
13
|
+
exp_month?: number;
|
|
14
|
+
exp_year?: number;
|
|
15
|
+
nickname?: string;
|
|
16
|
+
is_default: boolean;
|
|
17
|
+
created_at: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A single day's credit usage entry, as returned in wallet.usage_history.
|
|
21
|
+
*/
|
|
22
|
+
export interface UsageHistoryEntry {
|
|
23
|
+
date: string;
|
|
24
|
+
credits_used: number;
|
|
25
|
+
operation_type: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A credit account within a wallet (subscription, purchased, promotional buckets).
|
|
29
|
+
*/
|
|
30
|
+
export interface BillingAccount {
|
|
31
|
+
id: string;
|
|
32
|
+
kind: string;
|
|
33
|
+
balance_credits: number;
|
|
34
|
+
}
|
|
35
|
+
/** Mutable fields on a saved payment method. */
|
|
36
|
+
export type PaymentMethodUpdateAttributes = {
|
|
37
|
+
/** Human-readable label for this card (e.g. "Business Visa"). */
|
|
38
|
+
nickname?: string;
|
|
39
|
+
/** When true, marks this card as the default for automatic charges. */
|
|
40
|
+
is_default?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** Attributes for saving a pre-tokenized payment method. */
|
|
43
|
+
export type PaymentMethodCreateAttributes = {
|
|
44
|
+
/** Provider token from a hosted fields flow (e.g. a payment provider's hosted iframe). Never pass raw card numbers here. */
|
|
45
|
+
provider_token: string;
|
|
46
|
+
type?: "card" | "bank_account";
|
|
47
|
+
last4?: string;
|
|
48
|
+
exp_month?: number;
|
|
49
|
+
exp_year?: number;
|
|
50
|
+
brand?: string;
|
|
51
|
+
nickname?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Attributes for S2S card tokenization (raw card details). The platform tokenizes
|
|
55
|
+
* these server-side using the configured payment provider.
|
|
56
|
+
*
|
|
57
|
+
* @remarks **PCI-DSS: All fields in this type are PCI-sensitive.**
|
|
58
|
+
* Never log, serialize, or persist any field from this type. The platform
|
|
59
|
+
* transmits these fields to the payment gateway over TLS and does not store them.
|
|
60
|
+
*/
|
|
61
|
+
export type PaymentMethodTokenizeAttributes = {
|
|
62
|
+
/**
|
|
63
|
+
* 13–19 digit Primary Account Number (PAN).
|
|
64
|
+
* @remarks **PCI-sensitive — do not log or store.**
|
|
65
|
+
*/
|
|
66
|
+
card_number: string;
|
|
67
|
+
exp_month: number;
|
|
68
|
+
exp_year: number;
|
|
69
|
+
/**
|
|
70
|
+
* 3–4 digit Card Verification Value.
|
|
71
|
+
* @remarks **PCI-sensitive — do not log or store.** PCI-DSS prohibits storing CVC post-authorization.
|
|
72
|
+
*/
|
|
73
|
+
cvc: string;
|
|
74
|
+
holder_name: string;
|
|
75
|
+
billing_address: string;
|
|
76
|
+
billing_city: string;
|
|
77
|
+
billing_state: string;
|
|
78
|
+
zip_code: string;
|
|
79
|
+
phone?: string;
|
|
80
|
+
nickname?: string;
|
|
81
|
+
customer_id?: string;
|
|
82
|
+
};
|
|
83
|
+
/** Attributes for updating a feature definition. */
|
|
84
|
+
export type UpdateFeatureDefinitionAttributes = {
|
|
85
|
+
name?: string;
|
|
86
|
+
metering_mode?: "unlimited" | "counted" | "credit_cost";
|
|
87
|
+
default_limit?: number;
|
|
88
|
+
credit_cost?: number;
|
|
89
|
+
platform_capability?: string;
|
|
90
|
+
metadata?: Record<string, unknown>;
|
|
91
|
+
};
|
|
92
|
+
/** Attributes for purchasing an addon plan. */
|
|
93
|
+
export type BuyAddonAttributes = {
|
|
94
|
+
addon_slug: string;
|
|
95
|
+
payment_method_id?: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Creates the billing namespace, providing access to wallet balances, subscription
|
|
99
|
+
* plans, transaction history, credit packages, and payment methods for the
|
|
100
|
+
* authenticated workspace.
|
|
101
|
+
*
|
|
102
|
+
* Accessed via `client.billing.*`.
|
|
103
|
+
*
|
|
104
|
+
* @param rb - The internal `RequestBuilder` instance used to execute API calls.
|
|
105
|
+
* @returns An object containing sub-namespaces: `wallet`, `plans`, `transactions`,
|
|
106
|
+
* `creditPackages`, and `paymentMethods`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function createBillingNamespace(rb: RequestBuilder): {
|
|
109
|
+
/**
|
|
110
|
+
* Sub-namespace for workspace wallet operations.
|
|
111
|
+
*
|
|
112
|
+
* The wallet holds the workspace's available credit balance. Credits are
|
|
113
|
+
* consumed by AI operations (LLM calls, embeddings, agent executions) and
|
|
114
|
+
* replenished via subscription plans or purchased credit packages. Use
|
|
115
|
+
* `wallet.get()` to check the current balance before submitting expensive
|
|
116
|
+
* operations.
|
|
117
|
+
*/
|
|
118
|
+
wallet: {
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves the current workspace wallet, including the available credit
|
|
121
|
+
* balance, usage totals, and any pending charges.
|
|
122
|
+
*/
|
|
123
|
+
get: (options?: RequestOptions) => Promise<Wallet>;
|
|
124
|
+
/**
|
|
125
|
+
* Preview the cost and effective date of a plan change before committing.
|
|
126
|
+
*
|
|
127
|
+
* @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
|
|
128
|
+
* @returns A projected `Wallet` representing the hypothetical post-change
|
|
129
|
+
* state — **not** the caller's current wallet. Do not cache or use this
|
|
130
|
+
* as live balance data. Call `wallet.get()` for authoritative state.
|
|
131
|
+
*/
|
|
132
|
+
previewPlanChange: (planSlug: string, options?: RequestOptions) => Promise<Wallet>;
|
|
133
|
+
/**
|
|
134
|
+
* Change the workspace's subscription plan.
|
|
135
|
+
*
|
|
136
|
+
* Two call signatures:
|
|
137
|
+
* - `changePlan(planSlug)` — fetches the wallet automatically (recommended)
|
|
138
|
+
* - `changePlan(walletId, planSlug)` — use when you already have the wallet ID
|
|
139
|
+
*
|
|
140
|
+
* Upgrades charge a prorated amount immediately against the default payment
|
|
141
|
+
* method. Downgrades are deferred to the end of the current billing period.
|
|
142
|
+
* Use `previewPlanChange` first to show the user a cost estimate.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // Simple form — no wallet ID needed
|
|
147
|
+
* await client.billing.wallet.changePlan("pro-monthly");
|
|
148
|
+
*
|
|
149
|
+
* // Explicit form — when walletId is already known
|
|
150
|
+
* await client.billing.wallet.changePlan(wallet.id, "pro-monthly");
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
changePlan: (walletIdOrSlug: string, planSlugOrOptions?: string | RequestOptions, options?: RequestOptions) => Promise<Wallet>;
|
|
154
|
+
/**
|
|
155
|
+
* Purchase a credit package to top up the workspace wallet immediately.
|
|
156
|
+
*
|
|
157
|
+
* Charges the specified (or default) payment method. Credits are added to
|
|
158
|
+
* the `purchased` bucket and never expire.
|
|
159
|
+
*
|
|
160
|
+
* @param walletId - The wallet UUID from `wallet.get()`.
|
|
161
|
+
* @param packageSlug - The slug of the credit package to purchase.
|
|
162
|
+
* @param paymentMethodId - Optional payment method UUID. Uses the default if omitted.
|
|
163
|
+
*/
|
|
164
|
+
buyCredits: (walletId: string, packageSlug: string, paymentMethodId?: string, options?: RequestOptions) => Promise<Wallet>;
|
|
165
|
+
/**
|
|
166
|
+
* Update the workspace's auto top-up settings.
|
|
167
|
+
*
|
|
168
|
+
* When enabled, the platform automatically purchases the specified credit
|
|
169
|
+
* package whenever the balance drops below `threshold`.
|
|
170
|
+
*
|
|
171
|
+
* @param walletId - The wallet UUID from `wallet.get()`.
|
|
172
|
+
* @param opts.enabled - Enable or disable auto top-up.
|
|
173
|
+
* @param opts.threshold - Credit balance floor that triggers a purchase.
|
|
174
|
+
* @param opts.amount - Credits to purchase per top-up event.
|
|
175
|
+
* @param opts.packageId - Credit package UUID to auto-purchase.
|
|
176
|
+
*/
|
|
177
|
+
updateAutoTopUp: (walletId: string, opts: {
|
|
178
|
+
enabled: boolean;
|
|
179
|
+
threshold?: number;
|
|
180
|
+
amount?: number;
|
|
181
|
+
packageId?: string;
|
|
182
|
+
}, options?: RequestOptions) => Promise<Wallet>;
|
|
183
|
+
/**
|
|
184
|
+
* Sub-namespace for invoice operations.
|
|
185
|
+
*
|
|
186
|
+
* Invoices are generated per billing period and carry a `pdf_url` for
|
|
187
|
+
* receipt download. Use `invoices.list()` for the transaction history page.
|
|
188
|
+
*/
|
|
189
|
+
invoices: {
|
|
190
|
+
/**
|
|
191
|
+
* Returns a single page of invoices for the current workspace.
|
|
192
|
+
*
|
|
193
|
+
* Each invoice includes `pdf_url` for receipt download.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* const invoices = await client.billing.wallet.invoices.list();
|
|
198
|
+
* const paidInvoices = invoices.filter(inv => inv.attributes?.status === "paid");
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
list: (options?: {
|
|
202
|
+
page?: number;
|
|
203
|
+
pageSize?: number;
|
|
204
|
+
} & RequestOptions) => Promise<Invoice[]>;
|
|
205
|
+
/**
|
|
206
|
+
* Fetches all invoices by automatically paginating through every page.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* const all = await client.billing.wallet.invoices.listAll();
|
|
211
|
+
* const downloadUrl = all[0].attributes?.pdf_url;
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
listAll: (options?: RequestOptions) => Promise<Invoice[]>;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Purchase an addon plan for the workspace.
|
|
218
|
+
*
|
|
219
|
+
* Addon plans provide additional capabilities or quota on top of the base
|
|
220
|
+
* subscription plan. Charges the specified (or default) payment method immediately.
|
|
221
|
+
*
|
|
222
|
+
* @param addonSlug - The slug of the addon plan to purchase (e.g. `"extra-seats-10"`).
|
|
223
|
+
* @param paymentMethodId - Optional payment method UUID. Uses the default if omitted.
|
|
224
|
+
*/
|
|
225
|
+
buyAddon: (addonSlug: string, paymentMethodId?: string, options?: RequestOptions) => Promise<Wallet>;
|
|
226
|
+
/**
|
|
227
|
+
* Cancel an active addon plan on the workspace.
|
|
228
|
+
*
|
|
229
|
+
* Cancellation takes effect at the end of the current billing period.
|
|
230
|
+
* The addon remains active until then.
|
|
231
|
+
*
|
|
232
|
+
* @param addonSlug - The slug of the addon plan to cancel.
|
|
233
|
+
*/
|
|
234
|
+
cancelAddon: (addonSlug: string, options?: RequestOptions) => Promise<Wallet>;
|
|
235
|
+
/**
|
|
236
|
+
* Cancel the current subscription plan.
|
|
237
|
+
*
|
|
238
|
+
* @param immediate - If true (default), cancel immediately. If false, cancel at end of billing period.
|
|
239
|
+
* @param options - Request options
|
|
240
|
+
* @returns Updated wallet with new subscription_status
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* // Cancel immediately
|
|
245
|
+
* const wallet = await client.billing.wallet.cancelPlan();
|
|
246
|
+
*
|
|
247
|
+
* // Cancel at end of period
|
|
248
|
+
* const wallet = await client.billing.wallet.cancelPlan(false);
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
cancelPlan: (immediateOrOptions?: boolean | RequestOptions, options?: RequestOptions) => Promise<Wallet>;
|
|
252
|
+
/**
|
|
253
|
+
* Retry a failed subscription payment.
|
|
254
|
+
*
|
|
255
|
+
* Only works when the subscription is in `past_due` status. Uses the
|
|
256
|
+
* default payment method on file. On success, restores the subscription
|
|
257
|
+
* to `active` status and clears the dunning state.
|
|
258
|
+
*
|
|
259
|
+
* @param options - Request options
|
|
260
|
+
* @returns Updated wallet with restored subscription status
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* const wallet = await client.billing.wallet.retryPayment();
|
|
265
|
+
* console.log(wallet.attributes?.subscription_status); // "active"
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
retryPayment: (options?: RequestOptions) => Promise<Wallet>;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Sub-namespace for seat billing info.
|
|
272
|
+
*
|
|
273
|
+
* Provides read access to seat-based billing information for tenants using
|
|
274
|
+
* seat billing mode. Returns seat counts, limits, and overage details.
|
|
275
|
+
*/
|
|
276
|
+
seats: {
|
|
277
|
+
/**
|
|
278
|
+
* Get seat billing info for the current tenant.
|
|
279
|
+
*
|
|
280
|
+
* Returns seat usage, limits, and availability for tenants on seat-based
|
|
281
|
+
* billing plans.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* const seatInfo = await client.billing.seats.get();
|
|
286
|
+
* console.log(`Using ${seatInfo.attributes?.seats_used} of ${seatInfo.attributes?.seats_limit} seats`);
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
get: (options?: RequestOptions) => Promise<SeatInfo>;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Sub-namespace for subscription plan operations.
|
|
293
|
+
*
|
|
294
|
+
* Plans represent the recurring subscription tiers available to tenants.
|
|
295
|
+
* Each plan defines its included credit allowance, feature entitlements,
|
|
296
|
+
* and pricing. Use `plans.list()` or `plans.listAll()` to display plan
|
|
297
|
+
* options to end users during onboarding or upgrade flows.
|
|
298
|
+
*/
|
|
299
|
+
plans: {
|
|
300
|
+
/**
|
|
301
|
+
* Returns a single page of available subscription plans.
|
|
302
|
+
*
|
|
303
|
+
* @param options - Optional pagination and request options.
|
|
304
|
+
* @param options.page - The 1-based page number to retrieve (default: 1).
|
|
305
|
+
* @param options.pageSize - The number of plans to return per page.
|
|
306
|
+
* @returns A promise resolving to an array of `Plan` objects for the
|
|
307
|
+
* requested page.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
312
|
+
*
|
|
313
|
+
* const plans = await client.billing.plans.list({ page: 1, pageSize: 10 });
|
|
314
|
+
* plans.forEach(plan => console.log(plan.name, plan.price));
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
list: (options?: {
|
|
318
|
+
page?: number;
|
|
319
|
+
pageSize?: number;
|
|
320
|
+
} & RequestOptions) => Promise<Plan[]>;
|
|
321
|
+
/**
|
|
322
|
+
* Fetches all available subscription plans by automatically iterating
|
|
323
|
+
* through every page until no more results remain.
|
|
324
|
+
*
|
|
325
|
+
* Use this method when you need the complete plan catalogue without
|
|
326
|
+
* manually managing pagination cursors.
|
|
327
|
+
*
|
|
328
|
+
* @param options - Optional request options such as custom headers or an
|
|
329
|
+
* abort signal.
|
|
330
|
+
* @returns A promise resolving to a flat array of all `Plan` objects
|
|
331
|
+
* across all pages.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
336
|
+
*
|
|
337
|
+
* const allPlans = await client.billing.plans.listAll();
|
|
338
|
+
* console.log(`Total plans available: ${allPlans.length}`);
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
listAll: (options?: RequestOptions) => Promise<Plan[]>;
|
|
342
|
+
/**
|
|
343
|
+
* Retrieves a single subscription plan by its unique identifier.
|
|
344
|
+
*
|
|
345
|
+
* @param id - The UUID of the plan to retrieve.
|
|
346
|
+
* @param options - Optional request options such as custom headers or an
|
|
347
|
+
* abort signal.
|
|
348
|
+
* @returns A promise resolving to the matching `Plan` object.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
353
|
+
*
|
|
354
|
+
* const plan = await client.billing.plans.get('plan_01HXYZ...');
|
|
355
|
+
* console.log(`Plan: ${plan.name}, Credits: ${plan.credits_per_month}`);
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
get: (id: string, options?: RequestOptions) => Promise<Plan>;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Sub-namespace for credit transaction history operations.
|
|
362
|
+
*
|
|
363
|
+
* Each transaction records a credit debit or credit event on the workspace
|
|
364
|
+
* wallet — for example, an LLM inference charge, a credit package purchase,
|
|
365
|
+
* or a subscription renewal. Transactions are immutable audit records.
|
|
366
|
+
* Use `transactions.list()` for paginated history or `transactions.listAll()`
|
|
367
|
+
* to export the complete ledger.
|
|
368
|
+
*/
|
|
369
|
+
transactions: {
|
|
370
|
+
/**
|
|
371
|
+
* Returns a single page of credit transactions for the current workspace,
|
|
372
|
+
* ordered by most recent first.
|
|
373
|
+
*
|
|
374
|
+
* @param options - Optional pagination and request options.
|
|
375
|
+
* @param options.page - The 1-based page number to retrieve (default: 1).
|
|
376
|
+
* @param options.pageSize - The number of transactions to return per page.
|
|
377
|
+
* @returns A promise resolving to an array of `Transaction` objects for the
|
|
378
|
+
* requested page.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
383
|
+
*
|
|
384
|
+
* const transactions = await client.billing.transactions.list({ pageSize: 25 });
|
|
385
|
+
* transactions.forEach(tx => console.log(tx.description, tx.amount));
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
list: (options?: {
|
|
389
|
+
page?: number;
|
|
390
|
+
pageSize?: number;
|
|
391
|
+
} & RequestOptions) => Promise<Transaction[]>;
|
|
392
|
+
/**
|
|
393
|
+
* Fetches the complete transaction history for the current workspace by
|
|
394
|
+
* automatically paginating through all result pages.
|
|
395
|
+
*
|
|
396
|
+
* Use this method when you need to export the full ledger or compute
|
|
397
|
+
* aggregate usage totals without manual pagination.
|
|
398
|
+
*
|
|
399
|
+
* @param options - Optional request options such as custom headers or an
|
|
400
|
+
* abort signal.
|
|
401
|
+
* @returns A promise resolving to a flat array of all `Transaction` objects
|
|
402
|
+
* across every page.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
407
|
+
*
|
|
408
|
+
* const allTransactions = await client.billing.transactions.listAll();
|
|
409
|
+
* const totalSpent = allTransactions.reduce((sum, tx) => sum + tx.amount, 0);
|
|
410
|
+
* console.log(`Total credits consumed: ${totalSpent}`);
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
listAll: (options?: RequestOptions) => Promise<Transaction[]>;
|
|
414
|
+
/**
|
|
415
|
+
* Retrieves a single transaction record by its unique identifier.
|
|
416
|
+
*
|
|
417
|
+
* @param id - The UUID of the transaction to retrieve.
|
|
418
|
+
* @param options - Optional request options such as custom headers or an
|
|
419
|
+
* abort signal.
|
|
420
|
+
* @returns A promise resolving to the matching `Transaction` object.
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```typescript
|
|
424
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
425
|
+
*
|
|
426
|
+
* const tx = await client.billing.transactions.get('txn_01HXYZ...');
|
|
427
|
+
* console.log(`Transaction: ${tx.description}, Amount: ${tx.amount}`);
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
get: (id: string, options?: RequestOptions) => Promise<Transaction>;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Sub-namespace for credit package operations.
|
|
434
|
+
*
|
|
435
|
+
* Credit packages are one-time purchasable bundles of credits that top up
|
|
436
|
+
* the workspace wallet outside of the subscription cycle. They are consumed
|
|
437
|
+
* after subscription credits are exhausted (waterfall charging order:
|
|
438
|
+
* subscription credits → prepaid credits → failure). Use this namespace to
|
|
439
|
+
* display available packages or look up a specific package before initiating
|
|
440
|
+
* a purchase.
|
|
441
|
+
*/
|
|
442
|
+
creditPackages: {
|
|
443
|
+
/**
|
|
444
|
+
* Returns a single page of purchasable credit packages.
|
|
445
|
+
*
|
|
446
|
+
* @param options - Optional pagination and request options.
|
|
447
|
+
* @param options.page - The 1-based page number to retrieve (default: 1).
|
|
448
|
+
* @param options.pageSize - The number of packages to return per page.
|
|
449
|
+
* @returns A promise resolving to an array of `CreditPackage` objects for
|
|
450
|
+
* the requested page.
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* ```typescript
|
|
454
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
455
|
+
*
|
|
456
|
+
* const packages = await client.billing.creditPackages.list({ pageSize: 10 });
|
|
457
|
+
* packages.forEach(pkg => console.log(pkg.name, pkg.credits, pkg.price));
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
list: (options?: {
|
|
461
|
+
page?: number;
|
|
462
|
+
pageSize?: number;
|
|
463
|
+
} & RequestOptions) => Promise<CreditPackage[]>;
|
|
464
|
+
/**
|
|
465
|
+
* Fetches all available credit packages by automatically paginating through
|
|
466
|
+
* every result page.
|
|
467
|
+
*
|
|
468
|
+
* @param options - Optional request options such as custom headers or an
|
|
469
|
+
* abort signal.
|
|
470
|
+
* @returns A promise resolving to a flat array of all `CreditPackage`
|
|
471
|
+
* objects.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```typescript
|
|
475
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
476
|
+
*
|
|
477
|
+
* const allPackages = await client.billing.creditPackages.listAll();
|
|
478
|
+
* const cheapest = allPackages.sort((a, b) => a.price - b.price)[0];
|
|
479
|
+
* console.log(`Most affordable package: ${cheapest.name}`);
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
listAll: (options?: RequestOptions) => Promise<CreditPackage[]>;
|
|
483
|
+
/**
|
|
484
|
+
* Retrieves a single credit package by its unique identifier.
|
|
485
|
+
*
|
|
486
|
+
* @param id - The UUID of the credit package to retrieve.
|
|
487
|
+
* @param options - Optional request options such as custom headers or an
|
|
488
|
+
* abort signal.
|
|
489
|
+
* @returns A promise resolving to the matching `CreditPackage` object.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
494
|
+
*
|
|
495
|
+
* const pkg = await client.billing.creditPackages.get('pkg_01HXYZ...');
|
|
496
|
+
* console.log(`Package: ${pkg.name}, Credits: ${pkg.credits}`);
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
get: (id: string, options?: RequestOptions) => Promise<CreditPackage>;
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* Sub-namespace for payment method operations.
|
|
503
|
+
*
|
|
504
|
+
* Payment methods represent the saved cards or bank accounts attached to
|
|
505
|
+
* a workspace for subscription renewals and credit package purchases. One
|
|
506
|
+
* method is designated as the default and will be charged automatically.
|
|
507
|
+
* Use `paymentMethods.setDefault()` to change which card is charged on
|
|
508
|
+
* the next billing cycle.
|
|
509
|
+
*/
|
|
510
|
+
paymentMethods: {
|
|
511
|
+
/**
|
|
512
|
+
* Permanently removes a payment method from the workspace.
|
|
513
|
+
*
|
|
514
|
+
* If the deleted method is currently the default, you must call
|
|
515
|
+
* `setDefault()` on another method before the next billing cycle or
|
|
516
|
+
* charges will fail.
|
|
517
|
+
*
|
|
518
|
+
* @param id - The UUID of the payment method to delete.
|
|
519
|
+
* @param options - Optional request options such as custom headers or an
|
|
520
|
+
* abort signal.
|
|
521
|
+
* @returns A promise resolving to `true` when the deletion succeeds.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```typescript
|
|
525
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
526
|
+
*
|
|
527
|
+
* await client.billing.paymentMethods.delete('pm_01HXYZ...');
|
|
528
|
+
* console.log('Payment method removed.');
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
532
|
+
/**
|
|
533
|
+
* Returns a single page of payment methods attached to the current
|
|
534
|
+
* workspace.
|
|
535
|
+
*
|
|
536
|
+
* @param options - Optional pagination and request options.
|
|
537
|
+
* @param options.page - The 1-based page number to retrieve (default: 1).
|
|
538
|
+
* @param options.pageSize - The number of payment methods to return per
|
|
539
|
+
* page.
|
|
540
|
+
* @returns A promise resolving to an array of `PaymentMethod` objects for
|
|
541
|
+
* the requested page.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```typescript
|
|
545
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
546
|
+
*
|
|
547
|
+
* const methods = await client.billing.paymentMethods.list();
|
|
548
|
+
* methods.forEach(pm => console.log(pm.last4, pm.is_default));
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
list: (options?: {
|
|
552
|
+
page?: number;
|
|
553
|
+
pageSize?: number;
|
|
554
|
+
} & RequestOptions) => Promise<PaymentMethod[]>;
|
|
555
|
+
/**
|
|
556
|
+
* Fetches all payment methods attached to the current workspace by
|
|
557
|
+
* automatically paginating through every result page.
|
|
558
|
+
*
|
|
559
|
+
* @param options - Optional request options such as custom headers or an
|
|
560
|
+
* abort signal.
|
|
561
|
+
* @returns A promise resolving to a flat array of all `PaymentMethod`
|
|
562
|
+
* objects.
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
567
|
+
*
|
|
568
|
+
* const allMethods = await client.billing.paymentMethods.listAll();
|
|
569
|
+
* const defaultMethod = allMethods.find(pm => pm.is_default);
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
listAll: (options?: RequestOptions) => Promise<PaymentMethod[]>;
|
|
573
|
+
/**
|
|
574
|
+
* Adds a new payment method to the workspace.
|
|
575
|
+
*
|
|
576
|
+
* The `attributes` object should include tokenized card details as returned
|
|
577
|
+
* by the platform's client-side payment tokenization flow (e.g., a Stripe
|
|
578
|
+
* payment method token). Never pass raw card numbers through this method.
|
|
579
|
+
*
|
|
580
|
+
* @param attributes - A record of payment method attributes, typically
|
|
581
|
+
* containing a tokenized payment reference and optional billing address.
|
|
582
|
+
* @param options - Optional request options such as custom headers or an
|
|
583
|
+
* abort signal.
|
|
584
|
+
* @returns A promise resolving to the newly created `PaymentMethod` object.
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```typescript
|
|
588
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
589
|
+
*
|
|
590
|
+
* const method = await client.billing.paymentMethods.create({
|
|
591
|
+
* provider_token: 'tok_visa_4242',
|
|
592
|
+
* type: 'card',
|
|
593
|
+
* last4: '4242',
|
|
594
|
+
* exp_month: 12,
|
|
595
|
+
* exp_year: 2027,
|
|
596
|
+
* brand: 'Visa',
|
|
597
|
+
* });
|
|
598
|
+
* console.log(`Added card ending in ${method.last4}`);
|
|
599
|
+
* ```
|
|
600
|
+
*/
|
|
601
|
+
create: (attributes: PaymentMethodCreateAttributes, options?: RequestOptions) => Promise<PaymentMethod>;
|
|
602
|
+
/**
|
|
603
|
+
* Tokenizes a raw card server-side and saves the resulting payment method.
|
|
604
|
+
*
|
|
605
|
+
* @remarks **SERVER-SIDE ONLY — PCI-DSS.**
|
|
606
|
+
* This method transmits raw card numbers (`card_number`, `cvc`) over the
|
|
607
|
+
* network. It **must only be called from a trusted server context** (Node.js,
|
|
608
|
+
* server-side rendering). Calling this method from browser/client-side code
|
|
609
|
+
* (React, Vue, browser fetch) is a **PCI-DSS violation** — raw card numbers
|
|
610
|
+
* must never pass through browser memory or JavaScript bundles.
|
|
611
|
+
*
|
|
612
|
+
* For browser flows, use the payment provider's hosted fields iframe to tokenize
|
|
613
|
+
* on the client side, then call `paymentMethods.create({ provider_token })` instead.
|
|
614
|
+
*
|
|
615
|
+
* The platform forwards `cardDetails` to the payment gateway over TLS and stores
|
|
616
|
+
* only the resulting token — raw card data is never persisted.
|
|
617
|
+
*
|
|
618
|
+
* @param cardDetails - Raw PCI-sensitive card fields. All fields must be treated
|
|
619
|
+
* as sensitive: do not log, serialize, or pass through error reporters.
|
|
620
|
+
*/
|
|
621
|
+
tokenize: (cardDetails: PaymentMethodTokenizeAttributes, options?: RequestOptions) => Promise<PaymentMethod>;
|
|
622
|
+
/**
|
|
623
|
+
* Updates the mutable attributes of an existing payment method.
|
|
624
|
+
*
|
|
625
|
+
* @param id - The UUID of the payment method to update.
|
|
626
|
+
* @param attributes - Fields to update. Only provided keys are changed.
|
|
627
|
+
* @param options - Optional request options such as custom headers or an
|
|
628
|
+
* abort signal.
|
|
629
|
+
* @returns A promise resolving to the updated `PaymentMethod` object.
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```typescript
|
|
633
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
634
|
+
*
|
|
635
|
+
* const updated = await client.billing.paymentMethods.update(
|
|
636
|
+
* 'pm_01HXYZ...',
|
|
637
|
+
* { nickname: 'Business Visa', is_default: true },
|
|
638
|
+
* );
|
|
639
|
+
* console.log(`Updated: ${updated.nickname}`);
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
update: (id: string, attributes: PaymentMethodUpdateAttributes, options?: RequestOptions) => Promise<PaymentMethod>;
|
|
643
|
+
/**
|
|
644
|
+
* Retrieves a single payment method by its unique identifier.
|
|
645
|
+
*
|
|
646
|
+
* @param id - The UUID of the payment method to retrieve.
|
|
647
|
+
* @param options - Optional request options such as custom headers or an
|
|
648
|
+
* abort signal.
|
|
649
|
+
* @returns A promise resolving to the matching `PaymentMethod` object.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```typescript
|
|
653
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
654
|
+
*
|
|
655
|
+
* const method = await client.billing.paymentMethods.get('pm_01HXYZ...');
|
|
656
|
+
* console.log(`Card ending in: ${method.last4}, Default: ${method.is_default}`);
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
get: (id: string, options?: RequestOptions) => Promise<PaymentMethod>;
|
|
660
|
+
/**
|
|
661
|
+
* Permanently marks the specified payment method as the default for the
|
|
662
|
+
* current workspace.
|
|
663
|
+
*
|
|
664
|
+
* The default payment method is charged automatically for subscription
|
|
665
|
+
* renewals and any credit package purchases initiated without an explicit
|
|
666
|
+
* payment method ID. Only one method can be the default at a time; calling
|
|
667
|
+
* this method clears the default flag from all other methods in the
|
|
668
|
+
* workspace.
|
|
669
|
+
*
|
|
670
|
+
* @param id - The UUID of the payment method to set as default.
|
|
671
|
+
* @param options - Optional request options such as custom headers or an
|
|
672
|
+
* abort signal.
|
|
673
|
+
* @returns A promise resolving to the updated `PaymentMethod` object with
|
|
674
|
+
* `is_default` set to `true`.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```typescript
|
|
678
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
679
|
+
*
|
|
680
|
+
* const method = await client.billing.paymentMethods.setDefault('pm_01HXYZ...');
|
|
681
|
+
* console.log(`Default card is now: **** ${method.last4}`);
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
setDefault: (id: string, options?: RequestOptions) => Promise<PaymentMethod>;
|
|
685
|
+
};
|
|
686
|
+
/**
|
|
687
|
+
* Feature definitions — ISV-defined features with metering modes.
|
|
688
|
+
*
|
|
689
|
+
* Feature definitions describe application-specific capabilities (e.g. "meal_plans",
|
|
690
|
+
* "report_generation") and how they are metered (unlimited, counted, or credit-cost).
|
|
691
|
+
*/
|
|
692
|
+
featureDefinitions: {
|
|
693
|
+
/** List all feature definitions for the application. */
|
|
694
|
+
list: (options?: RequestOptions) => Promise<FeatureDefinition[]>;
|
|
695
|
+
/** Get a feature definition by ID. */
|
|
696
|
+
get: (id: string, options?: RequestOptions) => Promise<FeatureDefinition>;
|
|
697
|
+
/** List feature definitions for a specific application. */
|
|
698
|
+
listByApplication: (applicationId: string, options?: RequestOptions) => Promise<FeatureDefinition[]>;
|
|
699
|
+
/** Create a new feature definition. */
|
|
700
|
+
create: (attrs: {
|
|
701
|
+
key: string;
|
|
702
|
+
name: string;
|
|
703
|
+
metering_mode: "unlimited" | "counted" | "credit_cost";
|
|
704
|
+
default_limit?: number;
|
|
705
|
+
credit_cost?: number;
|
|
706
|
+
platform_capability?: string;
|
|
707
|
+
metadata?: Record<string, unknown>;
|
|
708
|
+
}, options?: RequestOptions) => Promise<FeatureDefinition>;
|
|
709
|
+
/** Update a feature definition. */
|
|
710
|
+
update: (id: string, attrs: UpdateFeatureDefinitionAttributes, options?: RequestOptions) => Promise<FeatureDefinition>;
|
|
711
|
+
/** Delete a feature definition. */
|
|
712
|
+
delete: (id: string, options?: RequestOptions) => Promise<void>;
|
|
713
|
+
};
|
|
714
|
+
/**
|
|
715
|
+
* Feature usage records — per-tenant usage tracking for metered features.
|
|
716
|
+
*
|
|
717
|
+
* Access usage records that track how many times each tenant
|
|
718
|
+
* has used a feature in the current billing cycle, and increment usage.
|
|
719
|
+
*/
|
|
720
|
+
featureUsages: {
|
|
721
|
+
/** List all feature usage records. */
|
|
722
|
+
list: (options?: RequestOptions) => Promise<FeatureUsage[]>;
|
|
723
|
+
/** Get a feature usage record by ID. */
|
|
724
|
+
get: (id: string, options?: RequestOptions) => Promise<FeatureUsage>;
|
|
725
|
+
/** List usage records for a specific tenant. */
|
|
726
|
+
listByTenant: (tenantId: string, options?: RequestOptions) => Promise<FeatureUsage[]>;
|
|
727
|
+
/**
|
|
728
|
+
* Increment usage for a feature by key.
|
|
729
|
+
*
|
|
730
|
+
* Checks feature gate, enforces limits, charges credits for credit_cost
|
|
731
|
+
* features, and atomically increments the usage counter. Returns the
|
|
732
|
+
* updated usage count and remaining allowance.
|
|
733
|
+
*
|
|
734
|
+
* @param featureKey - The feature definition key (e.g., "meal_plans", "clients")
|
|
735
|
+
* @returns Object with `used` (current cycle count) and `remaining` (null if unlimited)
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```typescript
|
|
739
|
+
* const result = await client.billing.featureUsages.increment("meal_plans");
|
|
740
|
+
* console.log(`Used: ${result.used}, Remaining: ${result.remaining}`);
|
|
741
|
+
* ```
|
|
742
|
+
*/
|
|
743
|
+
increment: (featureKey: string, options?: RequestOptions) => Promise<{
|
|
744
|
+
used: number;
|
|
745
|
+
remaining: number | null;
|
|
746
|
+
}>;
|
|
747
|
+
};
|
|
748
|
+
/**
|
|
749
|
+
* Plan-feature allocations — per-plan overrides for feature definitions (read-only).
|
|
750
|
+
*
|
|
751
|
+
* Allocations link feature definitions to plans, specifying which features are
|
|
752
|
+
* enabled on each plan and any per-plan overrides for limits, credit costs,
|
|
753
|
+
* and activation costs. Use `listByPlan` to build plan comparison tables.
|
|
754
|
+
*/
|
|
755
|
+
planFeatureAllocations: {
|
|
756
|
+
/** List all plan-feature allocations for the current application. */
|
|
757
|
+
list: (options?: {
|
|
758
|
+
page?: number;
|
|
759
|
+
pageSize?: number;
|
|
760
|
+
} & RequestOptions) => Promise<PlanFeatureAllocation[]>;
|
|
761
|
+
/** Fetch all plan-feature allocations by paginating through every page. */
|
|
762
|
+
listAll: (options?: RequestOptions) => Promise<PlanFeatureAllocation[]>;
|
|
763
|
+
/** Get a plan-feature allocation by ID. */
|
|
764
|
+
get: (id: string, options?: RequestOptions) => Promise<PlanFeatureAllocation>;
|
|
765
|
+
/**
|
|
766
|
+
* List allocations for a specific plan.
|
|
767
|
+
*
|
|
768
|
+
* Use this to build a plan comparison table — returns all feature
|
|
769
|
+
* allocations (enabled/disabled, limits, costs) for one plan.
|
|
770
|
+
*
|
|
771
|
+
* @param planId - UUID of the plan to query.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```typescript
|
|
775
|
+
* const allocations = await client.billing.planFeatureAllocations.listByPlan(planId);
|
|
776
|
+
* const enabledFeatures = allocations.filter(a => a.attributes?.enabled);
|
|
777
|
+
* ```
|
|
778
|
+
*/
|
|
779
|
+
listByPlan: (planId: string, options?: RequestOptions) => Promise<PlanFeatureAllocation[]>;
|
|
780
|
+
};
|
|
781
|
+
/**
|
|
782
|
+
* Composite feature summary — definitions, allocations, and usage in one call.
|
|
783
|
+
*
|
|
784
|
+
* Eliminates the need to call featureDefinitions, planFeatureAllocations,
|
|
785
|
+
* and featureUsages separately. Returns everything the frontend needs for
|
|
786
|
+
* feature gating UI.
|
|
787
|
+
*/
|
|
788
|
+
featureSummary: {
|
|
789
|
+
/**
|
|
790
|
+
* Get all features with plan allocations and current usage for the tenant.
|
|
791
|
+
*
|
|
792
|
+
* Each item includes: key, name, enabled, metering_mode, limit,
|
|
793
|
+
* used_this_cycle, remaining, credit_cost, activation_cost, activated.
|
|
794
|
+
*
|
|
795
|
+
* @param options - Request options
|
|
796
|
+
* @returns Array of feature summaries with usage data
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* ```typescript
|
|
800
|
+
* const features = await client.billing.featureSummary.list();
|
|
801
|
+
* features.forEach(f => {
|
|
802
|
+
* console.log(`${f.attributes?.key}: ${f.attributes?.used_this_cycle}/${f.attributes?.limit}`);
|
|
803
|
+
* });
|
|
804
|
+
* ```
|
|
805
|
+
*/
|
|
806
|
+
list: (options?: RequestOptions) => Promise<FeatureSummary[]>;
|
|
807
|
+
};
|
|
808
|
+
/**
|
|
809
|
+
* Get capacity estimates for a plan's monthly credits.
|
|
810
|
+
*
|
|
811
|
+
* Returns how many of each ISV-defined feature the plan supports per month.
|
|
812
|
+
* No Bearer token required — uses application key only.
|
|
813
|
+
*
|
|
814
|
+
* @param planSlug - The plan slug to calculate capacity for.
|
|
815
|
+
* @param options - Optional request-level overrides.
|
|
816
|
+
* @returns Plan details and capacity breakdown per composite operation.
|
|
817
|
+
*
|
|
818
|
+
* @example
|
|
819
|
+
* ```typescript
|
|
820
|
+
* const result = await client.billing.capacityCalculator("pro-plan");
|
|
821
|
+
* console.log(`Plan: ${result.plan.name}`);
|
|
822
|
+
* for (const item of result.capacity) {
|
|
823
|
+
* console.log(`${item.display_name}: ~${item.estimated_monthly_count}/month`);
|
|
824
|
+
* }
|
|
825
|
+
* ```
|
|
826
|
+
*/
|
|
827
|
+
capacityCalculator: (planSlug: string, options?: RequestOptions) => Promise<CapacityCalculatorResponse>;
|
|
828
|
+
};
|
|
829
|
+
/** Response from the capacity-calculator endpoint. */
|
|
830
|
+
export interface CapacityCalculatorResponse {
|
|
831
|
+
plan: {
|
|
832
|
+
slug: string;
|
|
833
|
+
name: string;
|
|
834
|
+
monthly_credits: number;
|
|
835
|
+
};
|
|
836
|
+
capacity: Array<{
|
|
837
|
+
key: string;
|
|
838
|
+
display_name: string;
|
|
839
|
+
description: string | null;
|
|
840
|
+
credits_per_use: number;
|
|
841
|
+
estimated_monthly_count: number;
|
|
842
|
+
is_estimate: boolean;
|
|
843
|
+
components: Array<{
|
|
844
|
+
operation_key: string;
|
|
845
|
+
quantity: number;
|
|
846
|
+
unit: string;
|
|
847
|
+
credits_per_unit: number | null;
|
|
848
|
+
total_credits: number;
|
|
849
|
+
is_estimate: boolean;
|
|
850
|
+
}>;
|
|
851
|
+
}>;
|
|
852
|
+
is_estimate: boolean;
|
|
853
|
+
}
|
|
854
|
+
//# sourceMappingURL=billing.d.ts.map
|