@commet/node 5.5.0 → 6.0.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/index.d.mts +1293 -996
- package/dist/index.d.ts +1293 -996
- package/dist/index.js +299 -297
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +299 -297
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -118,12 +118,6 @@ declare class CommetValidationError extends CommetError {
|
|
|
118
118
|
type CustomerID = string;
|
|
119
119
|
type EventID = `evt_${string}`;
|
|
120
120
|
type Currency = "USD" | "EUR" | "GBP" | "CAD" | "AUD" | "JPY" | "ARS" | "BRL" | "MXN" | "CLP";
|
|
121
|
-
interface ListParams extends Record<string, unknown> {
|
|
122
|
-
limit?: number;
|
|
123
|
-
cursor?: string;
|
|
124
|
-
startDate?: string;
|
|
125
|
-
endDate?: string;
|
|
126
|
-
}
|
|
127
121
|
interface RequestOptions {
|
|
128
122
|
apiVersion?: string;
|
|
129
123
|
idempotencyKey?: string;
|
|
@@ -143,366 +137,828 @@ type ResolvedPlanCode<TConfig> = [InferPlanCodes<TConfig>] extends [
|
|
|
143
137
|
never
|
|
144
138
|
] ? string : InferPlanCodes<TConfig>;
|
|
145
139
|
|
|
146
|
-
|
|
147
|
-
private config;
|
|
148
|
-
private retryConfig;
|
|
149
|
-
private telemetryEnabled;
|
|
150
|
-
private lastRequestMetrics;
|
|
151
|
-
constructor(config: CommetClientOptions);
|
|
152
|
-
get<T = unknown>(endpoint: string, params?: Record<string, unknown> | object, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
153
|
-
post<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
154
|
-
put<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
155
|
-
delete<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
156
|
-
private resolveApiVersion;
|
|
157
|
-
private static readonly BODY_METHODS;
|
|
158
|
-
private request;
|
|
159
|
-
/**
|
|
160
|
-
* Execute real API request with retry logic
|
|
161
|
-
*/
|
|
162
|
-
private executeRequest;
|
|
163
|
-
/**
|
|
164
|
-
* Build full URL from endpoint and params
|
|
165
|
-
*/
|
|
166
|
-
private buildURL;
|
|
167
|
-
private generateIdempotencyKey;
|
|
168
|
-
/**
|
|
169
|
-
* Sleep for specified milliseconds
|
|
170
|
-
*/
|
|
171
|
-
private sleep;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
type PlanID = `plan_${string}`;
|
|
140
|
+
type SubscriptionStatus = "draft" | "pending_payment" | "trialing" | "active" | "past_due" | "canceled";
|
|
175
141
|
type BillingInterval = "weekly" | "monthly" | "quarterly" | "yearly" | "one_time";
|
|
176
|
-
type FeatureType = "boolean" | "usage" | "seats" | "quota";
|
|
177
142
|
type ConsumptionModel = "metered" | "credits" | "balance";
|
|
143
|
+
type InvoiceType = "recurring" | "overage" | "plan_change" | "adjustment" | "credit_purchase" | "balance_topup" | "addon_activation";
|
|
144
|
+
type TransactionStatus = "pending" | "succeeded" | "failed" | "refunded" | "disputed";
|
|
145
|
+
type FeatureType = "boolean" | "usage" | "seats" | "quota";
|
|
178
146
|
type DiscountType = "percentage" | "amount";
|
|
179
|
-
|
|
180
|
-
|
|
147
|
+
type Timezone = "UTC" | "America/New_York" | "America/Chicago" | "America/Denver" | "America/Los_Angeles" | "America/Sao_Paulo" | "America/Mexico_City" | "America/Buenos_Aires" | "America/Santiago" | "America/Bogota" | "America/Lima" | "America/Asuncion" | "Europe/London" | "Europe/Paris" | "Europe/Berlin" | "Europe/Madrid" | "Asia/Tokyo" | "Asia/Shanghai" | "Asia/Singapore" | "Asia/Dubai" | "Australia/Sydney";
|
|
148
|
+
|
|
149
|
+
interface ActiveAddon {
|
|
150
|
+
slug: string;
|
|
151
|
+
name: string;
|
|
152
|
+
basePrice: number;
|
|
153
|
+
featureCode: string;
|
|
154
|
+
featureName: string;
|
|
155
|
+
featureType: FeatureType;
|
|
156
|
+
consumptionModel: "boolean" | "metered" | "credits" | "balance";
|
|
157
|
+
/** @format date-time */
|
|
158
|
+
activatedAt: string;
|
|
159
|
+
object: "addon";
|
|
160
|
+
livemode: boolean;
|
|
161
|
+
}
|
|
162
|
+
interface AddedPlanToGroup {
|
|
163
|
+
success: boolean;
|
|
164
|
+
object: "plan_group";
|
|
165
|
+
livemode: boolean;
|
|
166
|
+
}
|
|
167
|
+
interface Addon {
|
|
168
|
+
id: string;
|
|
169
|
+
name: string;
|
|
170
|
+
slug: string;
|
|
171
|
+
description: string | null;
|
|
172
|
+
basePrice: number;
|
|
173
|
+
consumptionModel: "boolean" | "metered" | "credits" | "balance";
|
|
174
|
+
featureCode: string;
|
|
175
|
+
featureName: string;
|
|
176
|
+
includedUnits: number | null;
|
|
177
|
+
overageRate: number | null;
|
|
178
|
+
creditCost: number | null;
|
|
179
|
+
/** @format date-time */
|
|
180
|
+
createdAt: string;
|
|
181
|
+
/** @format date-time */
|
|
182
|
+
updatedAt: string;
|
|
183
|
+
object: "addon";
|
|
184
|
+
livemode: boolean;
|
|
185
|
+
}
|
|
186
|
+
interface ApiKey {
|
|
187
|
+
id: string;
|
|
188
|
+
name: string;
|
|
189
|
+
prefix: string;
|
|
190
|
+
expiresAt: string | null;
|
|
191
|
+
lastUsedAt: string | null;
|
|
192
|
+
/** @format date-time */
|
|
193
|
+
createdAt: string;
|
|
194
|
+
object: "api_key";
|
|
195
|
+
livemode: boolean;
|
|
196
|
+
}
|
|
197
|
+
interface BalanceAdjustment {
|
|
198
|
+
amount: number;
|
|
199
|
+
newBalance: number;
|
|
200
|
+
reason: string | null;
|
|
201
|
+
object: "subscription";
|
|
202
|
+
livemode: boolean;
|
|
203
|
+
}
|
|
204
|
+
interface BalanceTopup {
|
|
205
|
+
amount: number;
|
|
206
|
+
object: "subscription";
|
|
207
|
+
livemode: boolean;
|
|
208
|
+
}
|
|
209
|
+
interface BulkSeatUpdate {
|
|
210
|
+
id: string;
|
|
211
|
+
featureCode: string;
|
|
212
|
+
previousBalance: number;
|
|
213
|
+
newBalance: number;
|
|
214
|
+
/** @format date-time */
|
|
215
|
+
ts: string;
|
|
216
|
+
/** @format date-time */
|
|
217
|
+
createdAt: string;
|
|
218
|
+
object: "seat";
|
|
219
|
+
livemode: boolean;
|
|
220
|
+
}
|
|
221
|
+
interface CanceledSubscription {
|
|
222
|
+
id: string;
|
|
223
|
+
customerId: string;
|
|
224
|
+
status: SubscriptionStatus;
|
|
225
|
+
/** @format date-time */
|
|
226
|
+
canceledAt: string;
|
|
227
|
+
cancelReason: string | null;
|
|
228
|
+
/** @format date-time */
|
|
229
|
+
scheduledCancellationDate: string;
|
|
230
|
+
/** @format date-time */
|
|
231
|
+
updatedAt: string;
|
|
232
|
+
object: "subscription";
|
|
233
|
+
livemode: boolean;
|
|
234
|
+
}
|
|
235
|
+
interface CreatedApiKey {
|
|
236
|
+
id: string;
|
|
237
|
+
name: string;
|
|
238
|
+
apiKey: string;
|
|
239
|
+
prefix: string;
|
|
240
|
+
/** @format date-time */
|
|
241
|
+
expiresAt: string;
|
|
242
|
+
/** @format date-time */
|
|
243
|
+
createdAt: string;
|
|
244
|
+
object: "api_key";
|
|
245
|
+
livemode: boolean;
|
|
246
|
+
}
|
|
247
|
+
interface CreatedInvoice {
|
|
248
|
+
id: string;
|
|
249
|
+
customerId: string;
|
|
250
|
+
invoiceNumber: string;
|
|
251
|
+
status: "draft" | "outstanding" | "paid" | "void" | "uncollectible";
|
|
252
|
+
invoiceType: InvoiceType;
|
|
253
|
+
currency: string;
|
|
254
|
+
subtotal: number;
|
|
255
|
+
taxAmount: number;
|
|
256
|
+
total: number;
|
|
257
|
+
/** @format date-time */
|
|
258
|
+
issueDate: string;
|
|
259
|
+
/** @format date-time */
|
|
260
|
+
dueDate: string;
|
|
261
|
+
memo: string | null;
|
|
262
|
+
metadata: Record<string, unknown>;
|
|
263
|
+
/** @format date-time */
|
|
264
|
+
createdAt: string;
|
|
265
|
+
/** @format date-time */
|
|
266
|
+
updatedAt: string;
|
|
267
|
+
object: "invoice";
|
|
268
|
+
livemode: boolean;
|
|
269
|
+
}
|
|
270
|
+
interface CreditGrant {
|
|
271
|
+
credits: number;
|
|
272
|
+
object: "subscription";
|
|
273
|
+
livemode: boolean;
|
|
274
|
+
}
|
|
275
|
+
interface CreditPack {
|
|
276
|
+
id: string;
|
|
277
|
+
name: string;
|
|
278
|
+
description: string | null;
|
|
279
|
+
credits: number;
|
|
181
280
|
price: number;
|
|
182
|
-
|
|
183
|
-
|
|
281
|
+
currency?: string;
|
|
282
|
+
isActive?: boolean;
|
|
283
|
+
/** @format date-time */
|
|
284
|
+
createdAt?: string;
|
|
285
|
+
/** @format date-time */
|
|
286
|
+
updatedAt?: string;
|
|
287
|
+
object: "credit_pack";
|
|
288
|
+
livemode: boolean;
|
|
184
289
|
}
|
|
185
|
-
interface
|
|
186
|
-
|
|
290
|
+
interface Customer {
|
|
291
|
+
id: string;
|
|
292
|
+
externalId: string | null;
|
|
293
|
+
fullName: string | null;
|
|
294
|
+
email: string;
|
|
295
|
+
timezone: string | null;
|
|
296
|
+
metadata: Record<string, unknown> | null;
|
|
297
|
+
/** @format date-time */
|
|
298
|
+
createdAt: string;
|
|
299
|
+
/** @format date-time */
|
|
300
|
+
updatedAt: string;
|
|
301
|
+
object: "customer";
|
|
302
|
+
livemode: boolean;
|
|
303
|
+
}
|
|
304
|
+
interface CustomerBatch {
|
|
305
|
+
successful: Array<{
|
|
306
|
+
id: string;
|
|
307
|
+
externalId: string | null;
|
|
308
|
+
email: string;
|
|
309
|
+
}>;
|
|
310
|
+
failed: Array<{
|
|
311
|
+
index: number;
|
|
312
|
+
error: string;
|
|
313
|
+
data: {
|
|
314
|
+
id?: string;
|
|
315
|
+
externalId?: string;
|
|
316
|
+
email: string;
|
|
317
|
+
fullName?: string | null;
|
|
318
|
+
timezone?: string;
|
|
319
|
+
metadata?: Record<string, unknown> | null;
|
|
320
|
+
address?: {
|
|
321
|
+
line1: string;
|
|
322
|
+
line2?: string;
|
|
323
|
+
city: string;
|
|
324
|
+
state?: string;
|
|
325
|
+
postalCode: string;
|
|
326
|
+
country: string;
|
|
327
|
+
region?: string;
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
}>;
|
|
331
|
+
object: "customer";
|
|
332
|
+
livemode: boolean;
|
|
333
|
+
}
|
|
334
|
+
interface DefaultPlanPrice {
|
|
335
|
+
id: string;
|
|
336
|
+
isDefault: true;
|
|
337
|
+
object: "plan";
|
|
338
|
+
livemode: boolean;
|
|
339
|
+
}
|
|
340
|
+
interface DeletedObject {
|
|
341
|
+
id: string;
|
|
342
|
+
deleted: true;
|
|
343
|
+
object: string;
|
|
344
|
+
livemode: boolean;
|
|
345
|
+
}
|
|
346
|
+
interface DeletedPlanRegionalPricing {
|
|
347
|
+
deleted: true;
|
|
348
|
+
object: "plan";
|
|
349
|
+
livemode: boolean;
|
|
350
|
+
}
|
|
351
|
+
interface DeletedSubscriptionAddon {
|
|
352
|
+
id: string;
|
|
353
|
+
status: "inactive";
|
|
354
|
+
deactivatedAt: string | null;
|
|
355
|
+
object: "subscription";
|
|
356
|
+
livemode: boolean;
|
|
357
|
+
}
|
|
358
|
+
interface Feature {
|
|
359
|
+
id: string;
|
|
187
360
|
name: string;
|
|
361
|
+
code: string;
|
|
188
362
|
type: FeatureType;
|
|
363
|
+
description: string | null;
|
|
189
364
|
unitName: string | null;
|
|
365
|
+
/** @format date-time */
|
|
366
|
+
createdAt: string;
|
|
367
|
+
/** @format date-time */
|
|
368
|
+
updatedAt: string;
|
|
369
|
+
object: "feature";
|
|
370
|
+
livemode: boolean;
|
|
371
|
+
}
|
|
372
|
+
interface FeatureAccess {
|
|
373
|
+
code: string;
|
|
374
|
+
name: string;
|
|
375
|
+
type: FeatureType;
|
|
376
|
+
allowed: boolean;
|
|
190
377
|
enabled?: boolean;
|
|
191
|
-
|
|
378
|
+
current?: number;
|
|
379
|
+
included?: number;
|
|
380
|
+
remaining?: number;
|
|
381
|
+
overageQuantity?: number;
|
|
382
|
+
overageUnitPrice?: number;
|
|
192
383
|
unlimited?: boolean;
|
|
193
384
|
overageEnabled?: boolean;
|
|
385
|
+
billedQuantity?: number;
|
|
386
|
+
object: "feature";
|
|
387
|
+
livemode: boolean;
|
|
388
|
+
}
|
|
389
|
+
interface FeatureLookup {
|
|
390
|
+
allowed: boolean;
|
|
391
|
+
code?: string;
|
|
392
|
+
name?: string;
|
|
393
|
+
type?: FeatureType;
|
|
394
|
+
enabled?: boolean;
|
|
395
|
+
current?: number;
|
|
396
|
+
included?: number;
|
|
397
|
+
remaining?: number;
|
|
398
|
+
overageQuantity?: number;
|
|
194
399
|
overageUnitPrice?: number;
|
|
400
|
+
unlimited?: boolean;
|
|
401
|
+
overageEnabled?: boolean;
|
|
402
|
+
billedQuantity?: number;
|
|
403
|
+
willBeCharged?: boolean;
|
|
404
|
+
reason?: string;
|
|
405
|
+
object: "feature";
|
|
406
|
+
livemode: boolean;
|
|
195
407
|
}
|
|
196
|
-
interface
|
|
197
|
-
id:
|
|
198
|
-
|
|
408
|
+
interface Invoice {
|
|
409
|
+
id: string;
|
|
410
|
+
customerId: string;
|
|
411
|
+
subscriptionId: string | null;
|
|
412
|
+
invoiceNumber: string;
|
|
413
|
+
status: "draft" | "outstanding" | "paid" | "void" | "uncollectible";
|
|
414
|
+
invoiceType: InvoiceType;
|
|
415
|
+
currency: string;
|
|
416
|
+
subtotal: number;
|
|
417
|
+
discountAmount: number;
|
|
418
|
+
creditApplied?: number;
|
|
419
|
+
taxAmount: number;
|
|
420
|
+
total: number;
|
|
421
|
+
/** @format date-time */
|
|
422
|
+
periodStart: string;
|
|
423
|
+
/** @format date-time */
|
|
424
|
+
periodEnd: string;
|
|
425
|
+
/** @format date-time */
|
|
426
|
+
issueDate: string;
|
|
427
|
+
/** @format date-time */
|
|
428
|
+
dueDate: string;
|
|
429
|
+
planName?: string | null;
|
|
430
|
+
memo: string | null;
|
|
431
|
+
poNumber?: string | null;
|
|
432
|
+
reference?: string | null;
|
|
433
|
+
metadata: Record<string, unknown>;
|
|
434
|
+
/** @format date-time */
|
|
435
|
+
createdAt: string;
|
|
436
|
+
/** @format date-time */
|
|
437
|
+
updatedAt: string;
|
|
438
|
+
lineItems?: Array<{
|
|
439
|
+
lineType: "plan_base" | "feature_overage" | "feature_seats" | "feature_quota" | "discount" | "promo_code_discount" | "credit" | "balance_overage" | "addon_base";
|
|
440
|
+
featureName: string | null;
|
|
441
|
+
description: string;
|
|
442
|
+
quantity: number;
|
|
443
|
+
unitAmount: number;
|
|
444
|
+
amount: number;
|
|
445
|
+
includedAmount: number | null;
|
|
446
|
+
usedAmount: number | null;
|
|
447
|
+
overageAmount: number | null;
|
|
448
|
+
discountType: string | null;
|
|
449
|
+
discountValue: number | null;
|
|
450
|
+
discountName: string | null;
|
|
451
|
+
chargeType: "standard" | "advance" | "true_up";
|
|
452
|
+
}>;
|
|
453
|
+
object: "invoice";
|
|
199
454
|
livemode: boolean;
|
|
200
|
-
|
|
455
|
+
}
|
|
456
|
+
interface InvoiceDownload {
|
|
457
|
+
url: string;
|
|
458
|
+
/** @format date-time */
|
|
459
|
+
expiresAt: string;
|
|
460
|
+
object: "invoice";
|
|
461
|
+
livemode: boolean;
|
|
462
|
+
}
|
|
463
|
+
interface InvoiceStatus {
|
|
464
|
+
id: string;
|
|
465
|
+
status: "draft" | "outstanding" | "paid" | "void" | "uncollectible";
|
|
466
|
+
/** @format date-time */
|
|
467
|
+
updatedAt: string;
|
|
468
|
+
object: "invoice";
|
|
469
|
+
livemode: boolean;
|
|
470
|
+
}
|
|
471
|
+
interface Payout {
|
|
472
|
+
id: string;
|
|
473
|
+
status: "pending" | "in_transit" | "paid" | "failed" | "canceled";
|
|
474
|
+
amount: number;
|
|
475
|
+
fee: number;
|
|
476
|
+
netAmount: number;
|
|
477
|
+
currency: string;
|
|
478
|
+
description: string | null;
|
|
479
|
+
providerTransferId: string;
|
|
480
|
+
/** @format date-time */
|
|
481
|
+
createdAt: string;
|
|
482
|
+
object: "payout";
|
|
483
|
+
livemode: boolean;
|
|
484
|
+
}
|
|
485
|
+
interface PayoutBankAccount {
|
|
486
|
+
id: string;
|
|
487
|
+
providerExternalAccountId: string | null;
|
|
488
|
+
holderName: string;
|
|
489
|
+
last4: string;
|
|
490
|
+
bankName: string | null;
|
|
491
|
+
country: string;
|
|
492
|
+
currency: string;
|
|
493
|
+
accountType: "checking" | "savings" | null;
|
|
494
|
+
isDefault: boolean;
|
|
495
|
+
status: "active" | "errored";
|
|
496
|
+
/** @format date-time */
|
|
497
|
+
createdAt: string;
|
|
498
|
+
object: "payout_bank_account";
|
|
499
|
+
livemode: boolean;
|
|
500
|
+
}
|
|
501
|
+
interface PayoutVerification {
|
|
502
|
+
providerAccountId: string;
|
|
503
|
+
status: "pending_verification" | "verified" | "restricted" | "disabled";
|
|
504
|
+
transfersEnabled: boolean;
|
|
505
|
+
alreadyExists?: boolean;
|
|
506
|
+
businessType?: "individual" | "company";
|
|
507
|
+
country?: string;
|
|
508
|
+
object: "payout_account";
|
|
509
|
+
livemode: boolean;
|
|
510
|
+
}
|
|
511
|
+
interface Plan {
|
|
512
|
+
id: string;
|
|
201
513
|
name: string;
|
|
514
|
+
code: string;
|
|
202
515
|
description: string | null;
|
|
516
|
+
consumptionModel: ConsumptionModel | null;
|
|
203
517
|
isPublic: boolean;
|
|
204
|
-
isFree: boolean;
|
|
205
518
|
isDefault: boolean;
|
|
519
|
+
isFree: boolean;
|
|
520
|
+
blockOnExhaustion: boolean | null;
|
|
206
521
|
sortOrder: number;
|
|
207
|
-
|
|
208
|
-
|
|
522
|
+
planGroupId: string | null;
|
|
523
|
+
metadata: Record<string, unknown> | null;
|
|
524
|
+
/** @format date-time */
|
|
525
|
+
createdAt: string;
|
|
526
|
+
/** @format date-time */
|
|
527
|
+
updatedAt: string;
|
|
528
|
+
features?: Array<{
|
|
529
|
+
code: string;
|
|
530
|
+
name: string;
|
|
531
|
+
type: FeatureType;
|
|
532
|
+
unitName: string | null;
|
|
533
|
+
enabled: boolean;
|
|
534
|
+
includedAmount: number | null;
|
|
535
|
+
unlimited: boolean;
|
|
536
|
+
overage: {
|
|
537
|
+
enabled: boolean;
|
|
538
|
+
model: "per_unit" | null;
|
|
539
|
+
unitPrice: number | null;
|
|
540
|
+
} | null;
|
|
541
|
+
regionalPrices?: Array<{
|
|
542
|
+
currency: string;
|
|
543
|
+
overageUnitPrice: number | null;
|
|
544
|
+
autoSynced: boolean;
|
|
545
|
+
}>;
|
|
546
|
+
}>;
|
|
547
|
+
prices?: Array<{
|
|
548
|
+
billingInterval: BillingInterval;
|
|
549
|
+
price: number;
|
|
550
|
+
isDefault: boolean;
|
|
551
|
+
trialDays: number;
|
|
552
|
+
includedBalance: number | null;
|
|
553
|
+
includedCredits: number | null;
|
|
554
|
+
introOffer: {
|
|
555
|
+
enabled: boolean;
|
|
556
|
+
discountType: DiscountType | null;
|
|
557
|
+
discountValue: number | null;
|
|
558
|
+
durationCycles: number | null;
|
|
559
|
+
} | null;
|
|
560
|
+
regionalPrices?: Array<{
|
|
561
|
+
currency: string;
|
|
562
|
+
price: number;
|
|
563
|
+
includedBalance: number | null;
|
|
564
|
+
autoSynced: boolean;
|
|
565
|
+
}>;
|
|
566
|
+
}>;
|
|
567
|
+
exchangeRates?: Array<{
|
|
568
|
+
currency: string;
|
|
569
|
+
exchangeRate: number;
|
|
570
|
+
}>;
|
|
571
|
+
object: "plan";
|
|
572
|
+
livemode: boolean;
|
|
573
|
+
}
|
|
574
|
+
interface PlanChange {
|
|
575
|
+
requiresCheckout?: boolean;
|
|
576
|
+
checkoutUrl?: string;
|
|
577
|
+
id?: string;
|
|
578
|
+
scheduled?: boolean;
|
|
579
|
+
/** @format date-time */
|
|
580
|
+
scheduledFor?: string;
|
|
581
|
+
changeType?: "subscription.plan_downgrade" | "subscription.interval_change" | "subscription.cancel";
|
|
582
|
+
customerId?: string;
|
|
583
|
+
newPlanId?: string;
|
|
584
|
+
newPlanName?: string;
|
|
585
|
+
newBillingInterval?: string;
|
|
586
|
+
previousPlan?: {
|
|
587
|
+
id: string;
|
|
588
|
+
name: string;
|
|
589
|
+
};
|
|
590
|
+
currentPlan?: {
|
|
591
|
+
id: string;
|
|
592
|
+
name: string;
|
|
593
|
+
price: number;
|
|
594
|
+
};
|
|
595
|
+
billingInterval?: string;
|
|
596
|
+
billing?: {
|
|
597
|
+
credit: number;
|
|
598
|
+
creditsApplied: number;
|
|
599
|
+
charge: number;
|
|
600
|
+
taxAmount: number;
|
|
601
|
+
netAmount: number;
|
|
602
|
+
totalCharged: number;
|
|
603
|
+
remainingCreditBalance: number;
|
|
604
|
+
};
|
|
605
|
+
invoiceId?: string;
|
|
606
|
+
object: "subscription";
|
|
607
|
+
livemode: boolean;
|
|
608
|
+
}
|
|
609
|
+
interface PlanFeature {
|
|
610
|
+
planId: string;
|
|
611
|
+
featureId: string;
|
|
612
|
+
enabled: boolean;
|
|
613
|
+
includedAmount: number;
|
|
614
|
+
unlimited: boolean;
|
|
615
|
+
overage: {
|
|
616
|
+
enabled: boolean;
|
|
617
|
+
unitPrice: number;
|
|
618
|
+
};
|
|
619
|
+
creditsPerUnit: number | null;
|
|
620
|
+
pricingMode: "fixed" | "ai_model";
|
|
621
|
+
margin: number | null;
|
|
622
|
+
object: "plan";
|
|
623
|
+
livemode: boolean;
|
|
624
|
+
}
|
|
625
|
+
interface PlanGroup {
|
|
626
|
+
id: string;
|
|
627
|
+
name: string;
|
|
628
|
+
description: string | null;
|
|
629
|
+
isPublic: boolean;
|
|
630
|
+
/** @format date-time */
|
|
209
631
|
createdAt: string;
|
|
632
|
+
/** @format date-time */
|
|
633
|
+
updatedAt: string;
|
|
634
|
+
plans?: Array<{
|
|
635
|
+
id: string;
|
|
636
|
+
name: string;
|
|
637
|
+
sortOrder: number;
|
|
638
|
+
}>;
|
|
639
|
+
object: "plan_group";
|
|
640
|
+
livemode: boolean;
|
|
210
641
|
}
|
|
211
|
-
interface
|
|
642
|
+
interface PlanPrice {
|
|
643
|
+
id: string;
|
|
644
|
+
planId: string;
|
|
212
645
|
billingInterval: BillingInterval;
|
|
213
646
|
price: number;
|
|
214
647
|
isDefault: boolean;
|
|
215
648
|
trialDays: number;
|
|
649
|
+
includedBalance: number | null;
|
|
650
|
+
includedCredits: number | null;
|
|
216
651
|
introOffer: {
|
|
217
652
|
enabled: boolean;
|
|
218
653
|
discountType: DiscountType | null;
|
|
219
654
|
discountValue: number | null;
|
|
220
655
|
durationCycles: number | null;
|
|
221
656
|
} | null;
|
|
657
|
+
/** @format date-time */
|
|
658
|
+
createdAt: string;
|
|
659
|
+
/** @format date-time */
|
|
660
|
+
updatedAt: string;
|
|
661
|
+
object: "plan";
|
|
662
|
+
livemode: boolean;
|
|
222
663
|
}
|
|
223
|
-
interface
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
664
|
+
interface PlanRegionalPricing {
|
|
665
|
+
priceId: string;
|
|
666
|
+
overrides: Array<{
|
|
667
|
+
currency: string;
|
|
668
|
+
price: number;
|
|
669
|
+
includedBalance?: number;
|
|
670
|
+
}>;
|
|
671
|
+
object: "plan";
|
|
672
|
+
livemode: boolean;
|
|
229
673
|
}
|
|
230
|
-
interface
|
|
231
|
-
|
|
674
|
+
interface PlanRegionalPricingResult {
|
|
675
|
+
planId: string;
|
|
676
|
+
currency: string;
|
|
677
|
+
exchangeRate: number;
|
|
678
|
+
pricesConfigured: number;
|
|
679
|
+
featuresConfigured: number;
|
|
232
680
|
object: "plan";
|
|
233
681
|
livemode: boolean;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
682
|
+
}
|
|
683
|
+
interface PlanVisibility {
|
|
684
|
+
id: string;
|
|
237
685
|
isPublic: boolean;
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
686
|
+
object: "plan";
|
|
687
|
+
livemode: boolean;
|
|
688
|
+
}
|
|
689
|
+
interface PortalAccess {
|
|
690
|
+
portalUrl: string;
|
|
691
|
+
object: "portal_session";
|
|
692
|
+
livemode: boolean;
|
|
693
|
+
}
|
|
694
|
+
interface PreviewChange {
|
|
695
|
+
currency: string;
|
|
696
|
+
currentPlanCredit: number;
|
|
697
|
+
newPlanCharge: number;
|
|
698
|
+
estimatedTotal: number;
|
|
699
|
+
/** @format date-time */
|
|
700
|
+
effectiveDate: string;
|
|
701
|
+
daysRemaining: number;
|
|
702
|
+
totalDays: number;
|
|
703
|
+
isUpgrade: boolean;
|
|
704
|
+
object: "subscription";
|
|
705
|
+
livemode: boolean;
|
|
706
|
+
}
|
|
707
|
+
interface PromoCode {
|
|
708
|
+
id: string;
|
|
709
|
+
code: string;
|
|
710
|
+
discountType: DiscountType;
|
|
711
|
+
discountValue: number;
|
|
712
|
+
durationCycles: number | null;
|
|
713
|
+
maxRedemptions: number | null;
|
|
714
|
+
expiresAt: string | null;
|
|
715
|
+
isActive: boolean;
|
|
716
|
+
redemptionCount: number;
|
|
717
|
+
/** @format date-time */
|
|
242
718
|
createdAt: string;
|
|
719
|
+
/** @format date-time */
|
|
243
720
|
updatedAt: string;
|
|
721
|
+
object: "promo_code";
|
|
722
|
+
livemode: boolean;
|
|
244
723
|
}
|
|
245
|
-
interface
|
|
246
|
-
includePrivate?: boolean;
|
|
247
|
-
}
|
|
248
|
-
interface PlanManage {
|
|
724
|
+
interface RemovedPlanFeature {
|
|
249
725
|
id: string;
|
|
726
|
+
removed: true;
|
|
250
727
|
object: "plan";
|
|
251
728
|
livemode: boolean;
|
|
729
|
+
}
|
|
730
|
+
interface RemovedPlanFromGroup {
|
|
731
|
+
id: string;
|
|
732
|
+
removed: boolean;
|
|
733
|
+
object: "plan_group";
|
|
734
|
+
livemode: boolean;
|
|
735
|
+
}
|
|
736
|
+
interface ReorderedPlans {
|
|
737
|
+
reordered: boolean;
|
|
738
|
+
object: "plan_group";
|
|
739
|
+
livemode: boolean;
|
|
740
|
+
}
|
|
741
|
+
interface SeatBalance {
|
|
742
|
+
current: number;
|
|
743
|
+
/** @format date-time */
|
|
744
|
+
asOf: string;
|
|
745
|
+
object: "seat";
|
|
746
|
+
livemode: boolean;
|
|
747
|
+
}
|
|
748
|
+
interface SeatBalanceListItem {
|
|
749
|
+
object: "seat";
|
|
750
|
+
livemode: boolean;
|
|
751
|
+
}
|
|
752
|
+
interface SeatEvent {
|
|
753
|
+
id: string;
|
|
754
|
+
customerId: string;
|
|
755
|
+
featureCode: string;
|
|
756
|
+
previousBalance: number;
|
|
757
|
+
newBalance: number;
|
|
758
|
+
/** @format date-time */
|
|
759
|
+
ts: string;
|
|
760
|
+
/** @format date-time */
|
|
761
|
+
createdAt: string;
|
|
762
|
+
object: "seat";
|
|
763
|
+
livemode: boolean;
|
|
764
|
+
}
|
|
765
|
+
interface SentInvoice {
|
|
766
|
+
sent: boolean;
|
|
767
|
+
/** @format date-time */
|
|
768
|
+
sentAt: string;
|
|
769
|
+
object: "invoice";
|
|
770
|
+
livemode: boolean;
|
|
771
|
+
}
|
|
772
|
+
interface Subscription {
|
|
773
|
+
id: string;
|
|
774
|
+
customerId: string;
|
|
775
|
+
plan: {
|
|
776
|
+
id: string;
|
|
777
|
+
name: string;
|
|
778
|
+
basePrice?: number;
|
|
779
|
+
};
|
|
252
780
|
name: string;
|
|
253
|
-
code: string;
|
|
254
781
|
description: string | null;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
782
|
+
status: SubscriptionStatus;
|
|
783
|
+
billingInterval: BillingInterval | null;
|
|
784
|
+
consumptionModel?: ConsumptionModel | null;
|
|
785
|
+
trialEndsAt: string | null;
|
|
786
|
+
currentPeriod: {
|
|
787
|
+
/** @format date-time */
|
|
788
|
+
start: string;
|
|
789
|
+
/** @format date-time */
|
|
790
|
+
end: string;
|
|
791
|
+
daysRemaining: number;
|
|
792
|
+
} | null;
|
|
793
|
+
features?: Array<{
|
|
794
|
+
code: string;
|
|
795
|
+
name: string;
|
|
796
|
+
type: FeatureType;
|
|
797
|
+
enabled?: boolean;
|
|
798
|
+
usage?: {
|
|
799
|
+
current: number;
|
|
800
|
+
included: number;
|
|
801
|
+
overageQuantity: number;
|
|
802
|
+
overageUnitPrice?: number;
|
|
803
|
+
};
|
|
804
|
+
}>;
|
|
805
|
+
credits?: {
|
|
806
|
+
remaining: number;
|
|
807
|
+
included: number;
|
|
808
|
+
purchased: number;
|
|
809
|
+
} | null;
|
|
810
|
+
balance?: {
|
|
811
|
+
remaining: number;
|
|
812
|
+
included: number;
|
|
813
|
+
currency: string;
|
|
814
|
+
} | null;
|
|
815
|
+
cancellation: {
|
|
816
|
+
/** @format date-time */
|
|
817
|
+
scheduledAt: string;
|
|
818
|
+
reason: string | null;
|
|
819
|
+
/** @format date-time */
|
|
820
|
+
effectiveAt: string;
|
|
821
|
+
} | null;
|
|
822
|
+
cancelAtPeriodEnd: boolean;
|
|
823
|
+
discount: {
|
|
824
|
+
type: DiscountType;
|
|
825
|
+
value: number;
|
|
826
|
+
name: string | null;
|
|
827
|
+
endsAt: string | null;
|
|
828
|
+
} | null;
|
|
829
|
+
/** @format date-time */
|
|
830
|
+
startDate: string;
|
|
831
|
+
endDate: string | null;
|
|
832
|
+
billingDayOfMonth: number | null;
|
|
833
|
+
nextBillingDate: string | null;
|
|
834
|
+
checkoutUrl: string | null;
|
|
835
|
+
/** @format date-time */
|
|
263
836
|
createdAt: string;
|
|
837
|
+
/** @format date-time */
|
|
264
838
|
updatedAt: string;
|
|
839
|
+
object: "subscription";
|
|
840
|
+
livemode: boolean;
|
|
265
841
|
}
|
|
266
|
-
interface
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
overageEnabled: boolean;
|
|
273
|
-
creditsPerUnit: number | null;
|
|
842
|
+
interface SubscriptionAddon {
|
|
843
|
+
addonId: string;
|
|
844
|
+
status: "active";
|
|
845
|
+
proratedCharge: number;
|
|
846
|
+
object: "subscription";
|
|
847
|
+
livemode: boolean;
|
|
274
848
|
}
|
|
275
|
-
interface
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
849
|
+
interface TestClock {
|
|
850
|
+
simulatedTime: string | null;
|
|
851
|
+
isActive: boolean;
|
|
852
|
+
/** @format date-time */
|
|
853
|
+
now: string;
|
|
854
|
+
object: "test_clock";
|
|
855
|
+
livemode: boolean;
|
|
279
856
|
}
|
|
280
|
-
interface
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
857
|
+
interface TestClockBilling {
|
|
858
|
+
customersFound: number;
|
|
859
|
+
enqueued: number;
|
|
860
|
+
failed: number;
|
|
861
|
+
object: "test_clock";
|
|
862
|
+
livemode: boolean;
|
|
284
863
|
}
|
|
285
|
-
|
|
286
|
-
interface PlanPriceManage {
|
|
864
|
+
interface Transaction {
|
|
287
865
|
id: string;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
introOfferDiscountType: DiscountType | null;
|
|
299
|
-
introOfferDiscountValue: number | null;
|
|
300
|
-
introOfferDurationCycles: number | null;
|
|
866
|
+
invoiceId: string | null;
|
|
867
|
+
grossAmount: number;
|
|
868
|
+
subtotal: number;
|
|
869
|
+
taxAmount: number;
|
|
870
|
+
currency: string;
|
|
871
|
+
status: TransactionStatus;
|
|
872
|
+
customerEmail: string | null;
|
|
873
|
+
customerName: string | null;
|
|
874
|
+
paidAt: string | null;
|
|
875
|
+
/** @format date-time */
|
|
301
876
|
createdAt: string;
|
|
877
|
+
/** @format date-time */
|
|
302
878
|
updatedAt: string;
|
|
879
|
+
availableAt?: string | null;
|
|
880
|
+
object: "transaction";
|
|
881
|
+
livemode: boolean;
|
|
303
882
|
}
|
|
304
|
-
interface
|
|
305
|
-
priceId: string;
|
|
306
|
-
overrides: Array<{
|
|
307
|
-
currency: string;
|
|
308
|
-
price: number;
|
|
309
|
-
}>;
|
|
310
|
-
}
|
|
311
|
-
interface DeleteResult {
|
|
883
|
+
interface TransactionRefund {
|
|
312
884
|
id: string;
|
|
313
|
-
|
|
885
|
+
status: "refunded";
|
|
886
|
+
object: "transaction";
|
|
887
|
+
livemode: boolean;
|
|
314
888
|
}
|
|
315
|
-
interface
|
|
889
|
+
interface TransactionRetry {
|
|
316
890
|
id: string;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
code: string;
|
|
322
|
-
description?: string;
|
|
323
|
-
consumptionModel?: ConsumptionModel;
|
|
324
|
-
isPublic?: boolean;
|
|
325
|
-
isFree?: boolean;
|
|
326
|
-
blockOnExhaustion?: boolean;
|
|
327
|
-
planGroupId?: string;
|
|
328
|
-
metadata?: Record<string, unknown>;
|
|
891
|
+
status: "processing";
|
|
892
|
+
retryInvoiceNumber: string;
|
|
893
|
+
object: "transaction";
|
|
894
|
+
livemode: boolean;
|
|
329
895
|
}
|
|
330
|
-
interface
|
|
896
|
+
interface UncanceledSubscription {
|
|
331
897
|
id: string;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
898
|
+
customerId: string;
|
|
899
|
+
status: SubscriptionStatus;
|
|
900
|
+
/** @format date-time */
|
|
901
|
+
updatedAt: string;
|
|
902
|
+
object: "subscription";
|
|
903
|
+
livemode: boolean;
|
|
336
904
|
}
|
|
337
|
-
interface
|
|
338
|
-
|
|
905
|
+
interface UsageQuota {
|
|
906
|
+
featureCode: string;
|
|
907
|
+
current: number;
|
|
908
|
+
included: number;
|
|
909
|
+
remaining: number | null;
|
|
910
|
+
billedQuantity: number;
|
|
911
|
+
unlimited: boolean;
|
|
912
|
+
overageEnabled: boolean;
|
|
913
|
+
asOf: string | null;
|
|
914
|
+
object: "usage_quota";
|
|
915
|
+
livemode: boolean;
|
|
339
916
|
}
|
|
340
|
-
interface
|
|
917
|
+
interface UsageQuotaEvent {
|
|
341
918
|
id: string;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
interface AddFixedPricingFeatureParams extends AddPlanFeatureBase {
|
|
354
|
-
pricingMode?: "fixed";
|
|
355
|
-
overageUnitPrice?: number;
|
|
356
|
-
}
|
|
357
|
-
interface AddAiModelPricingFeatureParams extends AddPlanFeatureBase {
|
|
358
|
-
pricingMode: "ai_model";
|
|
359
|
-
margin: number;
|
|
360
|
-
}
|
|
361
|
-
type AddPlanFeatureParams = AddFixedPricingFeatureParams | AddAiModelPricingFeatureParams;
|
|
362
|
-
interface UpdatePlanFeatureBase {
|
|
363
|
-
planId: string;
|
|
364
|
-
featureId: string;
|
|
365
|
-
enabled?: boolean;
|
|
366
|
-
includedAmount?: number;
|
|
367
|
-
unlimited?: boolean;
|
|
368
|
-
overageEnabled?: boolean;
|
|
369
|
-
creditsPerUnit?: number | null;
|
|
370
|
-
}
|
|
371
|
-
interface UpdateFixedPricingFeatureParams extends UpdatePlanFeatureBase {
|
|
372
|
-
pricingMode?: "fixed";
|
|
373
|
-
overageUnitPrice?: number;
|
|
374
|
-
}
|
|
375
|
-
interface UpdateAiModelPricingFeatureParams extends UpdatePlanFeatureBase {
|
|
376
|
-
pricingMode: "ai_model";
|
|
377
|
-
margin?: number;
|
|
378
|
-
}
|
|
379
|
-
type UpdatePlanFeatureParams = UpdateFixedPricingFeatureParams | UpdateAiModelPricingFeatureParams;
|
|
380
|
-
interface RemovePlanFeatureParams {
|
|
381
|
-
planId: string;
|
|
382
|
-
featureId: string;
|
|
383
|
-
}
|
|
384
|
-
interface AddPlanPriceParams {
|
|
385
|
-
planId: string;
|
|
386
|
-
billingInterval: BillingInterval;
|
|
387
|
-
price: number;
|
|
388
|
-
trialDays?: number;
|
|
389
|
-
isDefault?: boolean;
|
|
390
|
-
includedBalance?: number;
|
|
391
|
-
includedCredits?: number;
|
|
392
|
-
introOfferEnabled?: boolean;
|
|
393
|
-
introOfferDiscountType?: "percentage" | "amount";
|
|
394
|
-
introOfferDiscountValue?: number;
|
|
395
|
-
introOfferDurationCycles?: number;
|
|
396
|
-
}
|
|
397
|
-
interface UpdatePlanPriceParams {
|
|
398
|
-
planId: string;
|
|
399
|
-
priceId: string;
|
|
400
|
-
price?: number;
|
|
401
|
-
isDefault?: boolean;
|
|
402
|
-
trialDays?: number;
|
|
403
|
-
includedBalance?: number;
|
|
404
|
-
includedCredits?: number;
|
|
405
|
-
introOfferEnabled?: boolean;
|
|
406
|
-
introOfferDiscountType?: "percentage" | "amount" | null;
|
|
407
|
-
introOfferDiscountValue?: number | null;
|
|
408
|
-
introOfferDurationCycles?: number | null;
|
|
409
|
-
}
|
|
410
|
-
interface DeletePlanPriceParams {
|
|
411
|
-
planId: string;
|
|
412
|
-
priceId: string;
|
|
413
|
-
}
|
|
414
|
-
interface SetDefaultPriceParams {
|
|
415
|
-
planId: string;
|
|
416
|
-
priceId: string;
|
|
417
|
-
}
|
|
418
|
-
interface SetRegionalPricesParams {
|
|
419
|
-
planId: string;
|
|
420
|
-
priceId: string;
|
|
421
|
-
overrides: Array<{
|
|
422
|
-
currency: string;
|
|
423
|
-
price: number;
|
|
424
|
-
}>;
|
|
425
|
-
}
|
|
426
|
-
interface DeleteRegionalPricesParams {
|
|
427
|
-
planId: string;
|
|
428
|
-
priceId: string;
|
|
429
|
-
}
|
|
430
|
-
declare class PlansResource {
|
|
431
|
-
private httpClient;
|
|
432
|
-
constructor(httpClient: CommetHTTPClient);
|
|
433
|
-
list(params?: ListPlansParams): Promise<ApiResponse<Plan[]>>;
|
|
434
|
-
get(params: {
|
|
435
|
-
id: string;
|
|
436
|
-
}): Promise<ApiResponse<PlanDetail>>;
|
|
437
|
-
create(params: CreatePlanParams, options?: RequestOptions): Promise<ApiResponse<PlanManage>>;
|
|
438
|
-
update(params: UpdatePlanParams, options?: RequestOptions): Promise<ApiResponse<PlanManage>>;
|
|
439
|
-
delete(params: DeletePlanParams, options?: RequestOptions): Promise<ApiResponse<DeleteResult>>;
|
|
440
|
-
setVisibility(params: SetVisibilityParams, options?: RequestOptions): Promise<ApiResponse<PlanManage>>;
|
|
441
|
-
addFeature(params: AddPlanFeatureParams, options?: RequestOptions): Promise<ApiResponse<PlanFeatureManage>>;
|
|
442
|
-
updateFeature(params: UpdatePlanFeatureParams, options?: RequestOptions): Promise<ApiResponse<PlanFeatureManage>>;
|
|
443
|
-
removeFeature(params: RemovePlanFeatureParams, options?: RequestOptions): Promise<ApiResponse<RemoveResult>>;
|
|
444
|
-
addPrice(params: AddPlanPriceParams, options?: RequestOptions): Promise<ApiResponse<PlanPriceManage>>;
|
|
445
|
-
updatePrice(params: UpdatePlanPriceParams, options?: RequestOptions): Promise<ApiResponse<PlanPriceManage>>;
|
|
446
|
-
deletePrice(params: DeletePlanPriceParams, options?: RequestOptions): Promise<ApiResponse<DeleteResult>>;
|
|
447
|
-
setDefaultPrice(params: SetDefaultPriceParams, options?: RequestOptions): Promise<ApiResponse<PlanPriceManage>>;
|
|
448
|
-
setRegionalPrices(params: SetRegionalPricesParams, options?: RequestOptions): Promise<ApiResponse<RegionalPriceResult>>;
|
|
449
|
-
deleteRegionalPrices(params: DeleteRegionalPricesParams, options?: RequestOptions): Promise<ApiResponse<DeleteResult>>;
|
|
919
|
+
customerId: string;
|
|
920
|
+
featureCode: string;
|
|
921
|
+
previousBalance: number;
|
|
922
|
+
newBalance: number;
|
|
923
|
+
/** @format date-time */
|
|
924
|
+
ts: string;
|
|
925
|
+
/** @format date-time */
|
|
926
|
+
createdAt: string;
|
|
927
|
+
object: "usage_quota";
|
|
928
|
+
livemode: boolean;
|
|
450
929
|
}
|
|
451
930
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
931
|
+
declare class CommetHTTPClient {
|
|
932
|
+
private config;
|
|
933
|
+
private retryConfig;
|
|
934
|
+
private telemetryEnabled;
|
|
935
|
+
private lastRequestMetrics;
|
|
936
|
+
constructor(config: CommetClientOptions);
|
|
937
|
+
get<T = unknown>(endpoint: string, params?: Record<string, unknown> | object, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
938
|
+
post<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
939
|
+
put<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
940
|
+
delete<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
941
|
+
private resolveApiVersion;
|
|
942
|
+
private static readonly BODY_METHODS;
|
|
943
|
+
private request;
|
|
944
|
+
/**
|
|
945
|
+
* Execute real API request with retry logic
|
|
946
|
+
*/
|
|
947
|
+
private executeRequest;
|
|
948
|
+
/**
|
|
949
|
+
* Build full URL from endpoint and params
|
|
950
|
+
*/
|
|
951
|
+
private buildURL;
|
|
952
|
+
private generateIdempotencyKey;
|
|
953
|
+
/**
|
|
954
|
+
* Sleep for specified milliseconds
|
|
955
|
+
*/
|
|
956
|
+
private sleep;
|
|
464
957
|
}
|
|
958
|
+
|
|
465
959
|
interface ListActiveAddonsParams {
|
|
466
|
-
customerId
|
|
467
|
-
}
|
|
468
|
-
interface AddonBase {
|
|
469
|
-
id: string;
|
|
470
|
-
object: "addon";
|
|
471
|
-
livemode: boolean;
|
|
472
|
-
name: string;
|
|
473
|
-
slug: string;
|
|
474
|
-
description: string | null;
|
|
475
|
-
basePrice: number;
|
|
476
|
-
featureCode: string;
|
|
477
|
-
featureName: string;
|
|
478
|
-
createdAt: string;
|
|
479
|
-
updatedAt: string;
|
|
960
|
+
customerId?: string;
|
|
480
961
|
}
|
|
481
|
-
interface BooleanAddon extends AddonBase {
|
|
482
|
-
consumptionModel: "boolean";
|
|
483
|
-
includedUnits: null;
|
|
484
|
-
overageRate: null;
|
|
485
|
-
creditCost: null;
|
|
486
|
-
}
|
|
487
|
-
interface MeteredAddon extends AddonBase {
|
|
488
|
-
consumptionModel: "metered";
|
|
489
|
-
includedUnits: number;
|
|
490
|
-
overageRate: number;
|
|
491
|
-
creditCost: null;
|
|
492
|
-
}
|
|
493
|
-
interface CreditsAddon extends AddonBase {
|
|
494
|
-
consumptionModel: "credits";
|
|
495
|
-
includedUnits: null;
|
|
496
|
-
overageRate: null;
|
|
497
|
-
creditCost: number;
|
|
498
|
-
}
|
|
499
|
-
interface BalanceAddon extends AddonBase {
|
|
500
|
-
consumptionModel: "balance";
|
|
501
|
-
includedUnits: null;
|
|
502
|
-
overageRate: number;
|
|
503
|
-
creditCost: null;
|
|
504
|
-
}
|
|
505
|
-
type Addon = BooleanAddon | MeteredAddon | CreditsAddon | BalanceAddon;
|
|
506
962
|
interface ListAddonsParams {
|
|
507
963
|
limit?: number;
|
|
508
964
|
cursor?: string;
|
|
@@ -510,29 +966,16 @@ interface ListAddonsParams {
|
|
|
510
966
|
interface GetAddonParams {
|
|
511
967
|
id: string;
|
|
512
968
|
}
|
|
513
|
-
interface
|
|
969
|
+
interface CreateAddonParams {
|
|
514
970
|
name: string;
|
|
515
971
|
description?: string;
|
|
516
972
|
basePrice: number;
|
|
517
973
|
featureId: string;
|
|
974
|
+
consumptionModel: "boolean" | "metered" | "credits" | "balance";
|
|
975
|
+
includedUnits?: number;
|
|
976
|
+
overageRate?: number;
|
|
977
|
+
creditCost?: number;
|
|
518
978
|
}
|
|
519
|
-
interface CreateBooleanAddonParams extends CreateAddonBase {
|
|
520
|
-
consumptionModel: "boolean";
|
|
521
|
-
}
|
|
522
|
-
interface CreateMeteredAddonParams extends CreateAddonBase {
|
|
523
|
-
consumptionModel: "metered";
|
|
524
|
-
includedUnits: number;
|
|
525
|
-
overageRate: number;
|
|
526
|
-
}
|
|
527
|
-
interface CreateCreditsAddonParams extends CreateAddonBase {
|
|
528
|
-
consumptionModel: "credits";
|
|
529
|
-
creditCost: number;
|
|
530
|
-
}
|
|
531
|
-
interface CreateBalanceAddonParams extends CreateAddonBase {
|
|
532
|
-
consumptionModel: "balance";
|
|
533
|
-
overageRate: number;
|
|
534
|
-
}
|
|
535
|
-
type CreateAddonParams = CreateBooleanAddonParams | CreateMeteredAddonParams | CreateCreditsAddonParams | CreateBalanceAddonParams;
|
|
536
979
|
interface UpdateAddonParams {
|
|
537
980
|
id: string;
|
|
538
981
|
name?: string;
|
|
@@ -547,34 +990,24 @@ interface DeleteAddonParams {
|
|
|
547
990
|
declare class AddonsResource {
|
|
548
991
|
private httpClient;
|
|
549
992
|
constructor(httpClient: CommetHTTPClient);
|
|
550
|
-
|
|
551
|
-
|
|
993
|
+
/** List all active add-ons for a customer's subscription. */
|
|
994
|
+
listActive(params?: ListActiveAddonsParams, options?: RequestOptions): Promise<ApiResponse<Array<ActiveAddon>>>;
|
|
995
|
+
/** List all add-ons with cursor-based pagination. */
|
|
996
|
+
list(params?: ListAddonsParams, options?: RequestOptions): Promise<ApiResponse<Array<Addon>>>;
|
|
997
|
+
/** Retrieve an add-on by its public ID or slug. */
|
|
552
998
|
get(params: GetAddonParams, options?: RequestOptions): Promise<ApiResponse<Addon>>;
|
|
999
|
+
/** Create a new add-on linked to a feature. Each feature can only be assigned to one add-on. */
|
|
553
1000
|
create(params: CreateAddonParams, options?: RequestOptions): Promise<ApiResponse<Addon>>;
|
|
1001
|
+
/** Update an add-on's name, description, or pricing. */
|
|
554
1002
|
update(params: UpdateAddonParams, options?: RequestOptions): Promise<ApiResponse<Addon>>;
|
|
555
|
-
/** Fails if
|
|
556
|
-
delete(params: DeleteAddonParams, options?: RequestOptions): Promise<ApiResponse<
|
|
557
|
-
id: string;
|
|
558
|
-
deleted: true;
|
|
559
|
-
}>>;
|
|
1003
|
+
/** Soft-delete an add-on. Fails if the add-on has active subscriptions. */
|
|
1004
|
+
delete(params: DeleteAddonParams, options?: RequestOptions): Promise<ApiResponse<DeletedObject>>;
|
|
560
1005
|
}
|
|
561
1006
|
|
|
562
|
-
interface ApiKey {
|
|
563
|
-
id: string;
|
|
564
|
-
object: "api_key";
|
|
565
|
-
livemode: boolean;
|
|
566
|
-
name: string;
|
|
567
|
-
prefix: string;
|
|
568
|
-
expiresAt: string | null;
|
|
569
|
-
lastUsedAt: string | null;
|
|
570
|
-
createdAt: string;
|
|
571
|
-
}
|
|
572
|
-
interface ApiKeyCreated extends ApiKey {
|
|
573
|
-
apiKey: string;
|
|
574
|
-
}
|
|
575
1007
|
interface ListApiKeysParams {
|
|
576
|
-
|
|
1008
|
+
/** @format date-time */
|
|
577
1009
|
cursor?: string;
|
|
1010
|
+
limit?: number;
|
|
578
1011
|
}
|
|
579
1012
|
interface CreateApiKeyParams {
|
|
580
1013
|
name: string;
|
|
@@ -583,37 +1016,17 @@ interface CreateApiKeyParams {
|
|
|
583
1016
|
interface DeleteApiKeyParams {
|
|
584
1017
|
id: string;
|
|
585
1018
|
}
|
|
586
|
-
declare class ApiKeysResource {
|
|
587
|
-
private httpClient;
|
|
588
|
-
constructor(httpClient: CommetHTTPClient);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
object: "credit_pack";
|
|
598
|
-
livemode: boolean;
|
|
599
|
-
name: string;
|
|
600
|
-
description: string | null;
|
|
601
|
-
credits: number;
|
|
602
|
-
price: number;
|
|
603
|
-
currency: string;
|
|
604
|
-
}
|
|
605
|
-
interface CreditPackDetail {
|
|
606
|
-
id: string;
|
|
607
|
-
object: "credit_pack";
|
|
608
|
-
livemode: boolean;
|
|
609
|
-
name: string;
|
|
610
|
-
description: string | null;
|
|
611
|
-
credits: number;
|
|
612
|
-
price: number;
|
|
613
|
-
isActive: boolean;
|
|
614
|
-
createdAt: string;
|
|
615
|
-
updatedAt: string;
|
|
616
|
-
}
|
|
1019
|
+
declare class ApiKeysResource {
|
|
1020
|
+
private httpClient;
|
|
1021
|
+
constructor(httpClient: CommetHTTPClient);
|
|
1022
|
+
/** List API keys with cursor-based pagination. Keys are returned without the full secret. */
|
|
1023
|
+
list(params?: ListApiKeysParams, options?: RequestOptions): Promise<ApiResponse<Array<ApiKey>>>;
|
|
1024
|
+
/** Create a new API key. The full key is only returned once in the response. */
|
|
1025
|
+
create(params: CreateApiKeyParams, options?: RequestOptions): Promise<ApiResponse<CreatedApiKey>>;
|
|
1026
|
+
/** Permanently revoke and delete an API key. */
|
|
1027
|
+
delete(params: DeleteApiKeyParams, options?: RequestOptions): Promise<ApiResponse<DeletedObject>>;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
617
1030
|
interface CreateCreditPackParams {
|
|
618
1031
|
name: string;
|
|
619
1032
|
description?: string;
|
|
@@ -635,139 +1048,108 @@ interface DeleteCreditPackParams {
|
|
|
635
1048
|
declare class CreditPacksResource {
|
|
636
1049
|
private httpClient;
|
|
637
1050
|
constructor(httpClient: CommetHTTPClient);
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
1051
|
+
/** List all active credit packs. */
|
|
1052
|
+
list(): Promise<ApiResponse<Array<CreditPack>>>;
|
|
1053
|
+
/** Create a new credit pack. */
|
|
1054
|
+
create(params: CreateCreditPackParams, options?: RequestOptions): Promise<ApiResponse<CreditPack>>;
|
|
1055
|
+
/** Update a credit pack's name, description, credits, price, or active status. */
|
|
1056
|
+
update(params: UpdateCreditPackParams, options?: RequestOptions): Promise<ApiResponse<CreditPack>>;
|
|
1057
|
+
/** Soft-delete a credit pack. */
|
|
1058
|
+
delete(params: DeleteCreditPackParams, options?: RequestOptions): Promise<ApiResponse<DeletedObject>>;
|
|
645
1059
|
}
|
|
646
1060
|
|
|
647
|
-
interface
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
organizationId: string;
|
|
652
|
-
fullName?: string;
|
|
653
|
-
domain?: string;
|
|
654
|
-
website?: string;
|
|
655
|
-
billingEmail: string;
|
|
656
|
-
timezone?: string;
|
|
657
|
-
language?: string;
|
|
658
|
-
industry?: string;
|
|
659
|
-
employeeCount?: string;
|
|
660
|
-
metadata?: Record<string, unknown>;
|
|
661
|
-
createdAt: string;
|
|
662
|
-
updatedAt: string;
|
|
663
|
-
}
|
|
664
|
-
interface CustomerAddress {
|
|
665
|
-
line1: string;
|
|
666
|
-
line2?: string;
|
|
667
|
-
city: string;
|
|
668
|
-
state?: string;
|
|
669
|
-
postalCode: string;
|
|
670
|
-
country: string;
|
|
1061
|
+
interface ListCustomersParams {
|
|
1062
|
+
externalId?: string;
|
|
1063
|
+
limit?: number;
|
|
1064
|
+
cursor?: string;
|
|
671
1065
|
}
|
|
672
|
-
interface
|
|
673
|
-
email: string;
|
|
1066
|
+
interface CreateCustomerParams {
|
|
674
1067
|
id?: string;
|
|
1068
|
+
externalId?: string;
|
|
675
1069
|
fullName?: string;
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
1070
|
+
address?: {
|
|
1071
|
+
line1: string;
|
|
1072
|
+
line2?: string;
|
|
1073
|
+
city: string;
|
|
1074
|
+
state?: string;
|
|
1075
|
+
postalCode: string;
|
|
1076
|
+
country: string;
|
|
1077
|
+
region?: string;
|
|
1078
|
+
};
|
|
1079
|
+
addressId?: string;
|
|
1080
|
+
email: string;
|
|
1081
|
+
timezone?: Timezone;
|
|
681
1082
|
metadata?: Record<string, unknown>;
|
|
682
|
-
address?: CustomerAddress;
|
|
683
1083
|
}
|
|
684
1084
|
interface GetCustomerParams {
|
|
685
|
-
id:
|
|
1085
|
+
id: string;
|
|
686
1086
|
}
|
|
687
|
-
interface
|
|
688
|
-
id:
|
|
1087
|
+
interface UpdateCustomerParams {
|
|
1088
|
+
id: string;
|
|
689
1089
|
email?: string;
|
|
690
1090
|
fullName?: string;
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
timezone?: string;
|
|
694
|
-
language?: string;
|
|
695
|
-
industry?: string;
|
|
1091
|
+
externalId?: string;
|
|
1092
|
+
timezone?: Timezone;
|
|
696
1093
|
metadata?: Record<string, unknown>;
|
|
697
|
-
address?:
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
1094
|
+
address?: {
|
|
1095
|
+
line1: string;
|
|
1096
|
+
line2?: string;
|
|
1097
|
+
city: string;
|
|
1098
|
+
state?: string;
|
|
1099
|
+
postalCode: string;
|
|
1100
|
+
country: string;
|
|
1101
|
+
region?: string;
|
|
1102
|
+
};
|
|
701
1103
|
}
|
|
702
|
-
interface
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
1104
|
+
interface BatchCreateCustomersParams {
|
|
1105
|
+
customers: Array<{
|
|
1106
|
+
email: string;
|
|
1107
|
+
id?: string;
|
|
1108
|
+
externalId?: string;
|
|
1109
|
+
fullName?: string;
|
|
1110
|
+
timezone?: Timezone;
|
|
1111
|
+
metadata?: Record<string, unknown>;
|
|
1112
|
+
address?: {
|
|
1113
|
+
line1: string;
|
|
1114
|
+
line2?: string;
|
|
1115
|
+
city: string;
|
|
1116
|
+
state?: string;
|
|
1117
|
+
postalCode: string;
|
|
1118
|
+
country: string;
|
|
1119
|
+
region?: string;
|
|
1120
|
+
};
|
|
708
1121
|
}>;
|
|
709
1122
|
}
|
|
710
1123
|
declare class CustomersResource {
|
|
711
1124
|
private httpClient;
|
|
712
1125
|
constructor(httpClient: CommetHTTPClient);
|
|
713
|
-
/**
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
get(params: GetCustomerParams): Promise<ApiResponse<Customer>>;
|
|
719
|
-
|
|
720
|
-
|
|
1126
|
+
/** List customers with cursor-based pagination. */
|
|
1127
|
+
list(params?: ListCustomersParams, options?: RequestOptions): Promise<ApiResponse<Array<Customer>>>;
|
|
1128
|
+
/** Create a new customer. Idempotent when customerId is provided. */
|
|
1129
|
+
create(params: CreateCustomerParams, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
1130
|
+
/** Retrieve a customer by their public ID, including subscription status and metadata. */
|
|
1131
|
+
get(params: GetCustomerParams, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
1132
|
+
/** Update a customer's name, external ID, or metadata. */
|
|
1133
|
+
update(params: UpdateCustomerParams, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
1134
|
+
/** Create up to 100 customers in a single request. */
|
|
1135
|
+
createBatch(params: BatchCreateCustomersParams, options?: RequestOptions): Promise<ApiResponse<CustomerBatch>>;
|
|
721
1136
|
}
|
|
722
1137
|
|
|
723
|
-
interface GetFeatureParams {
|
|
724
|
-
customerId: CustomerID;
|
|
725
|
-
code: string;
|
|
726
|
-
}
|
|
727
|
-
interface CanUseFeatureParams {
|
|
728
|
-
customerId: CustomerID;
|
|
729
|
-
code: string;
|
|
730
|
-
}
|
|
731
1138
|
interface ListFeaturesParams {
|
|
732
|
-
customerId:
|
|
1139
|
+
customerId: string;
|
|
733
1140
|
}
|
|
734
|
-
interface
|
|
735
|
-
object: "feature";
|
|
736
|
-
livemode: boolean;
|
|
1141
|
+
interface GetFeatureAccessParams {
|
|
737
1142
|
code: string;
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
allowed: boolean;
|
|
741
|
-
enabled?: boolean;
|
|
742
|
-
current?: number;
|
|
743
|
-
included?: number;
|
|
744
|
-
remaining?: number;
|
|
745
|
-
overage?: number;
|
|
746
|
-
overageUnitPrice?: number;
|
|
747
|
-
billedQuantity?: number;
|
|
748
|
-
unlimited?: boolean;
|
|
749
|
-
overageEnabled?: boolean;
|
|
750
|
-
}
|
|
751
|
-
interface CanUseResult {
|
|
752
|
-
allowed: boolean;
|
|
753
|
-
willBeCharged: boolean;
|
|
754
|
-
reason?: string;
|
|
1143
|
+
customerId: string;
|
|
1144
|
+
action?: string;
|
|
755
1145
|
}
|
|
756
|
-
interface
|
|
757
|
-
id: string;
|
|
758
|
-
object: "feature";
|
|
759
|
-
livemode: boolean;
|
|
760
|
-
name: string;
|
|
1146
|
+
interface CanUseFeatureParams {
|
|
761
1147
|
code: string;
|
|
762
|
-
|
|
763
|
-
description: string | null;
|
|
764
|
-
unitName: string | null;
|
|
765
|
-
createdAt: string;
|
|
766
|
-
updatedAt: string;
|
|
1148
|
+
customerId: string;
|
|
767
1149
|
}
|
|
768
1150
|
interface CreateFeatureParams {
|
|
769
|
-
code: string;
|
|
770
1151
|
name: string;
|
|
1152
|
+
code: string;
|
|
771
1153
|
type: FeatureType;
|
|
772
1154
|
description?: string;
|
|
773
1155
|
unitName?: string;
|
|
@@ -775,8 +1157,8 @@ interface CreateFeatureParams {
|
|
|
775
1157
|
interface UpdateFeatureParams {
|
|
776
1158
|
code: string;
|
|
777
1159
|
name?: string;
|
|
778
|
-
description?: string;
|
|
779
|
-
unitName?: string;
|
|
1160
|
+
description?: string | null;
|
|
1161
|
+
unitName?: string | null;
|
|
780
1162
|
}
|
|
781
1163
|
interface DeleteFeatureParams {
|
|
782
1164
|
code: string;
|
|
@@ -784,117 +1166,38 @@ interface DeleteFeatureParams {
|
|
|
784
1166
|
declare class FeaturesResource {
|
|
785
1167
|
private httpClient;
|
|
786
1168
|
constructor(httpClient: CommetHTTPClient);
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
canUse
|
|
790
|
-
|
|
1169
|
+
/** List all features for a customer's active subscription. */
|
|
1170
|
+
list(params: ListFeaturesParams, options?: RequestOptions): Promise<ApiResponse<Array<FeatureAccess>>>;
|
|
1171
|
+
/** Get feature access details. Use action=canUse to check if customer can consume one more unit. */
|
|
1172
|
+
get(params: GetFeatureAccessParams, options?: RequestOptions): Promise<ApiResponse<FeatureLookup>>;
|
|
1173
|
+
/** Get feature access details. Use action=canUse to check if customer can consume one more unit. */
|
|
1174
|
+
canUse(params: CanUseFeatureParams, options?: RequestOptions): Promise<ApiResponse<FeatureLookup>>;
|
|
1175
|
+
/** Create a new feature. Code must be lowercase alphanumeric with underscores. */
|
|
791
1176
|
create(params: CreateFeatureParams, options?: RequestOptions): Promise<ApiResponse<Feature>>;
|
|
1177
|
+
/** Update a feature's name, description, or unit name. At least one field must be provided. */
|
|
792
1178
|
update(params: UpdateFeatureParams, options?: RequestOptions): Promise<ApiResponse<Feature>>;
|
|
793
|
-
/** Fails if feature is attached to active plans or has an active
|
|
794
|
-
delete(params: DeleteFeatureParams, options?: RequestOptions): Promise<ApiResponse<
|
|
795
|
-
id: string;
|
|
796
|
-
deleted: true;
|
|
797
|
-
}>>;
|
|
1179
|
+
/** Delete a feature. Fails if the feature is attached to active plans or has an active add-on. */
|
|
1180
|
+
delete(params: DeleteFeatureParams, options?: RequestOptions): Promise<ApiResponse<DeletedObject>>;
|
|
798
1181
|
}
|
|
799
1182
|
|
|
800
|
-
type InvoiceStatus = "draft" | "upcoming" | "outstanding" | "paid" | "void" | "uncollectible";
|
|
801
|
-
type InvoiceType = "recurring" | "overage" | "plan_change" | "adjustment" | "credit_purchase" | "balance_topup" | "addon_activation";
|
|
802
|
-
type InvoiceLineType = "plan_base" | "feature_overage" | "feature_seats" | "feature_quota" | "discount" | "credit" | "addon_base";
|
|
803
|
-
type ChargeType = "standard" | "advance" | "true_up";
|
|
804
|
-
interface InvoiceLineItem {
|
|
805
|
-
lineType: InvoiceLineType;
|
|
806
|
-
featureName: string | null;
|
|
807
|
-
description: string | null;
|
|
808
|
-
quantity: number;
|
|
809
|
-
unitAmount: number;
|
|
810
|
-
amount: number;
|
|
811
|
-
includedAmount: number | null;
|
|
812
|
-
usedAmount: number | null;
|
|
813
|
-
overageAmount: number | null;
|
|
814
|
-
discountType: DiscountType | null;
|
|
815
|
-
discountValue: number | null;
|
|
816
|
-
discountName: string | null;
|
|
817
|
-
chargeType: ChargeType | null;
|
|
818
|
-
}
|
|
819
|
-
interface InvoiceListItem {
|
|
820
|
-
id: string;
|
|
821
|
-
object: "invoice";
|
|
822
|
-
livemode: boolean;
|
|
823
|
-
customerId: string;
|
|
824
|
-
subscriptionId: string | null;
|
|
825
|
-
invoiceNumber: string;
|
|
826
|
-
status: InvoiceStatus;
|
|
827
|
-
invoiceType: InvoiceType;
|
|
828
|
-
currency: string;
|
|
829
|
-
subtotal: number;
|
|
830
|
-
discountAmount: number;
|
|
831
|
-
taxAmount: number;
|
|
832
|
-
total: number;
|
|
833
|
-
periodStart: string | null;
|
|
834
|
-
periodEnd: string | null;
|
|
835
|
-
issueDate: string;
|
|
836
|
-
dueDate: string | null;
|
|
837
|
-
memo: string | null;
|
|
838
|
-
metadata: Record<string, unknown> | null;
|
|
839
|
-
createdAt: string;
|
|
840
|
-
updatedAt: string;
|
|
841
|
-
}
|
|
842
|
-
interface InvoiceDetail extends InvoiceListItem {
|
|
843
|
-
creditApplied: number;
|
|
844
|
-
planName: string | null;
|
|
845
|
-
poNumber: string | null;
|
|
846
|
-
reference: string | null;
|
|
847
|
-
lineItems: InvoiceLineItem[];
|
|
848
|
-
}
|
|
849
|
-
interface InvoiceDownloadResult {
|
|
850
|
-
url: string;
|
|
851
|
-
expiresAt: string;
|
|
852
|
-
}
|
|
853
|
-
interface InvoiceSendResult {
|
|
854
|
-
sent: boolean;
|
|
855
|
-
sentAt: string;
|
|
856
|
-
}
|
|
857
|
-
interface InvoiceStatusResult {
|
|
858
|
-
id: string;
|
|
859
|
-
status: "paid" | "void";
|
|
860
|
-
updatedAt: string;
|
|
861
|
-
}
|
|
862
|
-
interface CreateAdjustmentResult {
|
|
863
|
-
id: string;
|
|
864
|
-
object: "invoice";
|
|
865
|
-
livemode: boolean;
|
|
866
|
-
customerId: string;
|
|
867
|
-
invoiceNumber: string;
|
|
868
|
-
status: "outstanding" | "paid";
|
|
869
|
-
invoiceType: InvoiceType;
|
|
870
|
-
currency: string;
|
|
871
|
-
subtotal: number;
|
|
872
|
-
taxAmount: number;
|
|
873
|
-
total: number;
|
|
874
|
-
issueDate: string;
|
|
875
|
-
dueDate: string | null;
|
|
876
|
-
memo: string | null;
|
|
877
|
-
metadata: Record<string, unknown> | null;
|
|
878
|
-
createdAt: string;
|
|
879
|
-
updatedAt: string;
|
|
880
|
-
}
|
|
881
1183
|
interface ListInvoicesParams {
|
|
882
1184
|
customerId?: string;
|
|
883
|
-
status?:
|
|
1185
|
+
status?: "draft" | "outstanding" | "paid" | "void" | "uncollectible";
|
|
884
1186
|
subscriptionId?: string;
|
|
885
|
-
|
|
1187
|
+
/** @format date-time */
|
|
886
1188
|
cursor?: string;
|
|
1189
|
+
limit?: number;
|
|
887
1190
|
}
|
|
888
1191
|
interface GetInvoiceParams {
|
|
889
1192
|
id: string;
|
|
890
1193
|
}
|
|
891
|
-
interface
|
|
1194
|
+
interface CreateAdjustmentInvoiceParams {
|
|
892
1195
|
customerId: string;
|
|
893
1196
|
amount: number;
|
|
894
|
-
description
|
|
1197
|
+
description: string;
|
|
895
1198
|
metadata?: Record<string, unknown>;
|
|
896
1199
|
}
|
|
897
|
-
interface
|
|
1200
|
+
interface DownloadInvoiceParams {
|
|
898
1201
|
id: string;
|
|
899
1202
|
}
|
|
900
1203
|
interface SendInvoiceParams {
|
|
@@ -907,35 +1210,88 @@ interface UpdateInvoiceStatusParams {
|
|
|
907
1210
|
declare class InvoicesResource {
|
|
908
1211
|
private httpClient;
|
|
909
1212
|
constructor(httpClient: CommetHTTPClient);
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
|
|
914
|
-
/**
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1213
|
+
/** List invoices with cursor-based pagination. Filter by customer, status, or subscription. */
|
|
1214
|
+
list(params?: ListInvoicesParams, options?: RequestOptions): Promise<ApiResponse<Array<Invoice>>>;
|
|
1215
|
+
/** Retrieve a single invoice by its public ID, including line items. */
|
|
1216
|
+
get(params: GetInvoiceParams, options?: RequestOptions): Promise<ApiResponse<Invoice>>;
|
|
1217
|
+
/** Create a one-off adjustment invoice. Use a negative amount for a credit. */
|
|
1218
|
+
createAdjustment(params: CreateAdjustmentInvoiceParams, options?: RequestOptions): Promise<ApiResponse<CreatedInvoice>>;
|
|
1219
|
+
/** Generate a signed URL to download the invoice as a PDF. The URL expires after 7 days. */
|
|
1220
|
+
getDownloadUrl(params: DownloadInvoiceParams, options?: RequestOptions): Promise<ApiResponse<InvoiceDownload>>;
|
|
1221
|
+
/** Send the invoice to the customer via email. */
|
|
1222
|
+
send(params: SendInvoiceParams, options?: RequestOptions): Promise<ApiResponse<SentInvoice>>;
|
|
1223
|
+
/** Mark an outstanding invoice as "paid" or "void". Cannot change the status of already paid or voided invoices. */
|
|
1224
|
+
updateStatus(params: UpdateInvoiceStatusParams, options?: RequestOptions): Promise<ApiResponse<InvoiceStatus>>;
|
|
919
1225
|
}
|
|
920
1226
|
|
|
921
|
-
interface
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1227
|
+
interface AddPayoutBankAccountParams {
|
|
1228
|
+
accountNumber: string;
|
|
1229
|
+
accountHolderName: string;
|
|
1230
|
+
routingNumber?: string;
|
|
1231
|
+
accountType?: "checking" | "savings";
|
|
1232
|
+
setDefault?: boolean;
|
|
1233
|
+
}
|
|
1234
|
+
interface RequestPayoutParams {
|
|
1235
|
+
amount: number;
|
|
1236
|
+
description?: string;
|
|
930
1237
|
}
|
|
931
|
-
interface
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1238
|
+
interface CompletePayoutVerificationParams {
|
|
1239
|
+
email: string;
|
|
1240
|
+
businessType: "individual" | "company";
|
|
1241
|
+
businessUrl: string;
|
|
1242
|
+
documentUrl: string;
|
|
1243
|
+
bank: {
|
|
1244
|
+
accountNumber: string;
|
|
1245
|
+
accountHolderName: string;
|
|
1246
|
+
routingNumber?: string;
|
|
1247
|
+
accountType?: "checking" | "savings";
|
|
1248
|
+
};
|
|
1249
|
+
individual?: {
|
|
1250
|
+
firstName: string;
|
|
1251
|
+
lastName: string;
|
|
1252
|
+
phone: string;
|
|
1253
|
+
dateOfBirth: string;
|
|
1254
|
+
ssnLast4?: string;
|
|
1255
|
+
idNumber?: string;
|
|
1256
|
+
address: {
|
|
1257
|
+
line1: string;
|
|
1258
|
+
line2?: string;
|
|
1259
|
+
city: string;
|
|
1260
|
+
state?: string;
|
|
1261
|
+
postalCode: string;
|
|
1262
|
+
country: string;
|
|
1263
|
+
};
|
|
1264
|
+
};
|
|
1265
|
+
company?: {
|
|
935
1266
|
name: string;
|
|
936
|
-
|
|
937
|
-
|
|
1267
|
+
taxId: string;
|
|
1268
|
+
address: {
|
|
1269
|
+
line1: string;
|
|
1270
|
+
line2?: string;
|
|
1271
|
+
city: string;
|
|
1272
|
+
state?: string;
|
|
1273
|
+
postalCode: string;
|
|
1274
|
+
country: string;
|
|
1275
|
+
};
|
|
1276
|
+
representative: {
|
|
1277
|
+
firstName: string;
|
|
1278
|
+
lastName: string;
|
|
1279
|
+
phone?: string;
|
|
1280
|
+
email?: string;
|
|
1281
|
+
};
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
declare class PayoutsResource {
|
|
1285
|
+
private httpClient;
|
|
1286
|
+
constructor(httpClient: CommetHTTPClient);
|
|
1287
|
+
/** Add an additional destination bank account to the organization's existing payout account. Country and currency are resolved from the organization. The full account number is never returned — only `last4`. */
|
|
1288
|
+
addBankAccount(params: AddPayoutBankAccountParams, options?: RequestOptions): Promise<ApiResponse<PayoutBankAccount>>;
|
|
1289
|
+
/** Withdraw available balance to the organization's verified payout account. `amount` is in cents (USD, minimum 1000 = $10). The payout is created in `pending` and settles to `paid` asynchronously as provider webhooks arrive. */
|
|
1290
|
+
request(params: RequestPayoutParams, options?: RequestOptions): Promise<ApiResponse<Payout>>;
|
|
1291
|
+
/** Provision the organization's payout account in a single call with the full KYC + bank payload. Uploads the identity document, persists the destination bank, and creates the connected account through the org's payout provider. The account starts `pending_verification` and flips to `verified` via the provider's webhook. Idempotent: returns the existing account if the org already has one. */
|
|
1292
|
+
completeVerification(params: CompletePayoutVerificationParams, options?: RequestOptions): Promise<ApiResponse<PayoutVerification>>;
|
|
938
1293
|
}
|
|
1294
|
+
|
|
939
1295
|
interface ListPlanGroupsParams {
|
|
940
1296
|
limit?: number;
|
|
941
1297
|
cursor?: string;
|
|
@@ -951,7 +1307,7 @@ interface CreatePlanGroupParams {
|
|
|
951
1307
|
interface UpdatePlanGroupParams {
|
|
952
1308
|
id: string;
|
|
953
1309
|
name?: string;
|
|
954
|
-
description?: string;
|
|
1310
|
+
description?: string | null;
|
|
955
1311
|
isPublic?: boolean;
|
|
956
1312
|
}
|
|
957
1313
|
interface DeletePlanGroupParams {
|
|
@@ -966,61 +1322,211 @@ interface RemovePlanFromGroupParams {
|
|
|
966
1322
|
id: string;
|
|
967
1323
|
planId: string;
|
|
968
1324
|
}
|
|
969
|
-
interface
|
|
1325
|
+
interface ReorderPlansInGroupParams {
|
|
970
1326
|
id: string;
|
|
971
|
-
planIds: string
|
|
1327
|
+
planIds: Array<string>;
|
|
972
1328
|
}
|
|
973
1329
|
declare class PlanGroupsResource {
|
|
974
1330
|
private httpClient;
|
|
975
1331
|
constructor(httpClient: CommetHTTPClient);
|
|
976
|
-
|
|
977
|
-
|
|
1332
|
+
/** List plan groups with cursor-based pagination. */
|
|
1333
|
+
list(params?: ListPlanGroupsParams, options?: RequestOptions): Promise<ApiResponse<Array<PlanGroup>>>;
|
|
1334
|
+
/** Retrieve a plan group by ID, including its plans ordered by sortOrder. */
|
|
1335
|
+
get(params: GetPlanGroupParams, options?: RequestOptions): Promise<ApiResponse<PlanGroup>>;
|
|
1336
|
+
/** Create a new plan group for organizing plans. */
|
|
978
1337
|
create(params: CreatePlanGroupParams, options?: RequestOptions): Promise<ApiResponse<PlanGroup>>;
|
|
1338
|
+
/** Update a plan group's name, description, or visibility. */
|
|
979
1339
|
update(params: UpdatePlanGroupParams, options?: RequestOptions): Promise<ApiResponse<PlanGroup>>;
|
|
980
|
-
/** Plans in the group are unlinked, not deleted. */
|
|
981
|
-
delete(params: DeletePlanGroupParams, options?: RequestOptions): Promise<ApiResponse<
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1340
|
+
/** Delete a plan group. Plans in the group are unlinked, not deleted. */
|
|
1341
|
+
delete(params: DeletePlanGroupParams, options?: RequestOptions): Promise<ApiResponse<DeletedObject>>;
|
|
1342
|
+
/** Add an existing plan to a plan group with optional sort order. */
|
|
1343
|
+
addPlan(params: AddPlanToGroupParams, options?: RequestOptions): Promise<ApiResponse<AddedPlanToGroup>>;
|
|
1344
|
+
/** Remove a plan from a plan group. */
|
|
1345
|
+
removePlan(params: RemovePlanFromGroupParams, options?: RequestOptions): Promise<ApiResponse<RemovedPlanFromGroup>>;
|
|
1346
|
+
/** Set the display order of plans within a group. All plan IDs in the group must be provided. */
|
|
1347
|
+
reorderPlans(params: ReorderPlansInGroupParams, options?: RequestOptions): Promise<ApiResponse<ReorderedPlans>>;
|
|
985
1348
|
}
|
|
986
1349
|
|
|
987
|
-
interface
|
|
988
|
-
|
|
989
|
-
message: string;
|
|
990
|
-
portalUrl: string;
|
|
1350
|
+
interface ListPlansParams {
|
|
1351
|
+
includePrivate?: "true" | "false";
|
|
991
1352
|
}
|
|
992
|
-
interface
|
|
993
|
-
|
|
994
|
-
email?: never;
|
|
1353
|
+
interface GetPlanParams {
|
|
1354
|
+
id: string;
|
|
995
1355
|
}
|
|
996
|
-
interface
|
|
997
|
-
|
|
998
|
-
|
|
1356
|
+
interface CreatePlanParams {
|
|
1357
|
+
name: string;
|
|
1358
|
+
code: string;
|
|
1359
|
+
description?: string;
|
|
1360
|
+
consumptionModel?: ConsumptionModel;
|
|
1361
|
+
isPublic?: boolean;
|
|
1362
|
+
isFree?: boolean;
|
|
1363
|
+
blockOnExhaustion?: boolean;
|
|
1364
|
+
planGroupId?: string;
|
|
1365
|
+
metadata?: Record<string, unknown>;
|
|
1366
|
+
}
|
|
1367
|
+
interface UpdatePlanParams {
|
|
1368
|
+
id: string;
|
|
1369
|
+
name?: string;
|
|
1370
|
+
description?: string | null;
|
|
1371
|
+
metadata?: Record<string, unknown>;
|
|
1372
|
+
isPublic?: boolean;
|
|
1373
|
+
}
|
|
1374
|
+
interface DeletePlanParams {
|
|
1375
|
+
id: string;
|
|
1376
|
+
}
|
|
1377
|
+
interface SetPlanVisibilityParams {
|
|
1378
|
+
id: string;
|
|
1379
|
+
isPublic: boolean;
|
|
1380
|
+
}
|
|
1381
|
+
interface AddPlanFeatureParams {
|
|
1382
|
+
id: string;
|
|
1383
|
+
featureId: string;
|
|
1384
|
+
enabled?: boolean;
|
|
1385
|
+
includedAmount?: number;
|
|
1386
|
+
unlimited?: boolean;
|
|
1387
|
+
overage?: {
|
|
1388
|
+
enabled: boolean;
|
|
1389
|
+
unitPrice: number;
|
|
1390
|
+
};
|
|
1391
|
+
creditsPerUnit?: number | null;
|
|
1392
|
+
pricingMode?: "fixed" | "ai_model";
|
|
1393
|
+
margin?: number | null;
|
|
1394
|
+
}
|
|
1395
|
+
interface UpdatePlanFeatureParams {
|
|
1396
|
+
id: string;
|
|
1397
|
+
featureId: string;
|
|
1398
|
+
enabled?: boolean;
|
|
1399
|
+
includedAmount?: number;
|
|
1400
|
+
unlimited?: boolean;
|
|
1401
|
+
overage?: {
|
|
1402
|
+
enabled?: boolean;
|
|
1403
|
+
unitPrice?: number;
|
|
1404
|
+
};
|
|
1405
|
+
creditsPerUnit?: number | null;
|
|
1406
|
+
}
|
|
1407
|
+
interface RemovePlanFeatureParams {
|
|
1408
|
+
id: string;
|
|
1409
|
+
featureId: string;
|
|
1410
|
+
}
|
|
1411
|
+
interface AddPlanPriceParams {
|
|
1412
|
+
id: string;
|
|
1413
|
+
billingInterval: BillingInterval;
|
|
1414
|
+
price: number;
|
|
1415
|
+
trialDays?: number;
|
|
1416
|
+
isDefault?: boolean;
|
|
1417
|
+
includedBalance?: number | null;
|
|
1418
|
+
includedCredits?: number | null;
|
|
1419
|
+
introOffer?: {
|
|
1420
|
+
enabled: boolean;
|
|
1421
|
+
discountType?: DiscountType | null;
|
|
1422
|
+
discountValue?: number | null;
|
|
1423
|
+
durationCycles?: number | null;
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
interface UpdatePlanPriceParams {
|
|
1427
|
+
id: string;
|
|
1428
|
+
priceId: string;
|
|
1429
|
+
price?: number;
|
|
1430
|
+
isDefault?: boolean;
|
|
1431
|
+
trialDays?: number;
|
|
1432
|
+
includedBalance?: number | null;
|
|
1433
|
+
includedCredits?: number | null;
|
|
1434
|
+
introOffer?: {
|
|
1435
|
+
enabled?: boolean;
|
|
1436
|
+
discountType?: DiscountType | null;
|
|
1437
|
+
discountValue?: number | null;
|
|
1438
|
+
durationCycles?: number | null;
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
interface DeletePlanPriceParams {
|
|
1442
|
+
id: string;
|
|
1443
|
+
priceId: string;
|
|
1444
|
+
}
|
|
1445
|
+
interface SetDefaultPlanPriceParams {
|
|
1446
|
+
id: string;
|
|
1447
|
+
priceId: string;
|
|
1448
|
+
}
|
|
1449
|
+
interface UpsertRegionalPricesParams {
|
|
1450
|
+
id: string;
|
|
1451
|
+
priceId: string;
|
|
1452
|
+
overrides: Array<{
|
|
1453
|
+
currency: string;
|
|
1454
|
+
price: number;
|
|
1455
|
+
includedBalance?: number;
|
|
1456
|
+
}>;
|
|
1457
|
+
}
|
|
1458
|
+
interface SetPlanRegionalPricingParams {
|
|
1459
|
+
id: string;
|
|
1460
|
+
currency: "ars" | "brl" | "clp" | "cop" | "pen" | "uyu" | "pyg" | "bob" | "mxn" | "cad" | "eur" | "jpy" | "cny" | "krw" | "hkd" | "sgd" | "twd" | "inr" | "thb";
|
|
1461
|
+
exchangeRate: number;
|
|
1462
|
+
prices?: Array<{
|
|
1463
|
+
priceId: string;
|
|
1464
|
+
price: number;
|
|
1465
|
+
includedBalance?: number;
|
|
1466
|
+
}>;
|
|
1467
|
+
features?: Array<{
|
|
1468
|
+
featureId: string;
|
|
1469
|
+
overageUnitPrice: number;
|
|
1470
|
+
}>;
|
|
1471
|
+
introOffers?: Array<{
|
|
1472
|
+
priceId: string;
|
|
1473
|
+
discountType: DiscountType;
|
|
1474
|
+
discountValue: number;
|
|
1475
|
+
durationCycles: number;
|
|
1476
|
+
}>;
|
|
1477
|
+
}
|
|
1478
|
+
interface DeleteRegionalPricesParams {
|
|
1479
|
+
id: string;
|
|
1480
|
+
priceId: string;
|
|
1481
|
+
}
|
|
1482
|
+
declare class PlansResource {
|
|
1483
|
+
private httpClient;
|
|
1484
|
+
constructor(httpClient: CommetHTTPClient);
|
|
1485
|
+
/** List all plans with their prices and features. Optionally include private plans. */
|
|
1486
|
+
list(params?: ListPlansParams, options?: RequestOptions): Promise<ApiResponse<Array<Plan>>>;
|
|
1487
|
+
/** Get detailed plan information by code or ID. */
|
|
1488
|
+
get(params: GetPlanParams, options?: RequestOptions): Promise<ApiResponse<Plan>>;
|
|
1489
|
+
/** Create a new plan with optional consumption model, visibility, and plan group assignment. */
|
|
1490
|
+
create(params: CreatePlanParams, options?: RequestOptions): Promise<ApiResponse<Plan>>;
|
|
1491
|
+
/** Update a plan's name, description, visibility, or metadata. */
|
|
1492
|
+
update(params: UpdatePlanParams, options?: RequestOptions): Promise<ApiResponse<Plan>>;
|
|
1493
|
+
/** Soft-delete a plan. */
|
|
1494
|
+
delete(params: DeletePlanParams, options?: RequestOptions): Promise<ApiResponse<DeletedObject>>;
|
|
1495
|
+
/** Toggle a plan between public and private. */
|
|
1496
|
+
setVisibility(params: SetPlanVisibilityParams, options?: RequestOptions): Promise<ApiResponse<PlanVisibility>>;
|
|
1497
|
+
/** Attach a feature to a plan with limits, overage, and credits configuration. */
|
|
1498
|
+
addFeature(params: AddPlanFeatureParams, options?: RequestOptions): Promise<ApiResponse<PlanFeature>>;
|
|
1499
|
+
/** Update limits, overage, or enabled status of a feature on a plan. */
|
|
1500
|
+
updateFeature(params: UpdatePlanFeatureParams, options?: RequestOptions): Promise<ApiResponse<PlanFeature>>;
|
|
1501
|
+
/** Detach a feature from a plan. */
|
|
1502
|
+
removeFeature(params: RemovePlanFeatureParams, options?: RequestOptions): Promise<ApiResponse<RemovedPlanFeature>>;
|
|
1503
|
+
/** Add a billing interval price to a plan with optional trial days and included balance/credits. */
|
|
1504
|
+
addPrice(params: AddPlanPriceParams, options?: RequestOptions): Promise<ApiResponse<PlanPrice>>;
|
|
1505
|
+
/** Update an existing price on a plan. */
|
|
1506
|
+
updatePrice(params: UpdatePlanPriceParams, options?: RequestOptions): Promise<ApiResponse<PlanPrice>>;
|
|
1507
|
+
/** Remove a price from a plan. */
|
|
1508
|
+
deletePrice(params: DeletePlanPriceParams, options?: RequestOptions): Promise<ApiResponse<DeletedObject>>;
|
|
1509
|
+
/** Set a specific price as the default for its plan. Unsets previous default. */
|
|
1510
|
+
setDefaultPrice(params: SetDefaultPlanPriceParams, options?: RequestOptions): Promise<ApiResponse<DefaultPlanPrice>>;
|
|
1511
|
+
/** Create or update regional currency price overrides for a plan price. */
|
|
1512
|
+
setRegionalPrices(params: UpsertRegionalPricesParams, options?: RequestOptions): Promise<ApiResponse<PlanRegionalPricing>>;
|
|
1513
|
+
/** Configure a plan's regional pricing for one currency. Sending only currency and exchangeRate derives every regional value (base price, included balance, feature overage, intro offer) from the USD value at that rate. Optional per-price and per-feature overrides are stored as manual values. */
|
|
1514
|
+
setRegionalPricing(params: SetPlanRegionalPricingParams, options?: RequestOptions): Promise<ApiResponse<PlanRegionalPricingResult>>;
|
|
1515
|
+
/** Remove all regional currency overrides for a plan price. */
|
|
1516
|
+
deleteRegionalPrices(params: DeleteRegionalPricesParams, options?: RequestOptions): Promise<ApiResponse<DeletedPlanRegionalPricing>>;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
interface RequestPortalAccessParams {
|
|
1520
|
+
email?: string;
|
|
1521
|
+
customerId?: string;
|
|
999
1522
|
}
|
|
1000
|
-
type GetUrlParams = GetUrlByCustomerId | GetUrlByEmail;
|
|
1001
1523
|
declare class PortalResource {
|
|
1002
1524
|
private httpClient;
|
|
1003
1525
|
constructor(httpClient: CommetHTTPClient);
|
|
1004
|
-
|
|
1526
|
+
/** Generate a customer portal URL. Exactly one identifier (email or customerId) is required. */
|
|
1527
|
+
getUrl(params?: RequestPortalAccessParams, options?: RequestOptions): Promise<ApiResponse<PortalAccess>>;
|
|
1005
1528
|
}
|
|
1006
1529
|
|
|
1007
|
-
interface PromoCode {
|
|
1008
|
-
id: string;
|
|
1009
|
-
object: "promo_code";
|
|
1010
|
-
livemode: boolean;
|
|
1011
|
-
code: string;
|
|
1012
|
-
discountType: "percentage" | "amount";
|
|
1013
|
-
discountValue: number;
|
|
1014
|
-
durationCycles: number | null;
|
|
1015
|
-
maxRedemptions: number | null;
|
|
1016
|
-
expiresAt: string | null;
|
|
1017
|
-
active: boolean;
|
|
1018
|
-
redemptionCount: number;
|
|
1019
|
-
createdAt: string;
|
|
1020
|
-
}
|
|
1021
|
-
interface PromoCodeDetail extends PromoCode {
|
|
1022
|
-
updatedAt: string;
|
|
1023
|
-
}
|
|
1024
1530
|
interface ListPromoCodesParams {
|
|
1025
1531
|
limit?: number;
|
|
1026
1532
|
cursor?: string;
|
|
@@ -1030,452 +1536,235 @@ interface GetPromoCodeParams {
|
|
|
1030
1536
|
}
|
|
1031
1537
|
interface CreatePromoCodeParams {
|
|
1032
1538
|
code: string;
|
|
1033
|
-
discountType:
|
|
1539
|
+
discountType: DiscountType;
|
|
1034
1540
|
discountValue: number;
|
|
1035
1541
|
durationCycles?: number;
|
|
1036
1542
|
maxRedemptions?: number;
|
|
1543
|
+
/** @format date-time */
|
|
1037
1544
|
expiresAt?: string;
|
|
1038
|
-
planIds?: string
|
|
1545
|
+
planIds?: Array<string>;
|
|
1039
1546
|
}
|
|
1040
1547
|
interface UpdatePromoCodeParams {
|
|
1041
1548
|
id: string;
|
|
1042
|
-
maxRedemptions?: number;
|
|
1043
|
-
expiresAt?: string;
|
|
1549
|
+
maxRedemptions?: number | null;
|
|
1550
|
+
expiresAt?: string | null;
|
|
1044
1551
|
active?: boolean;
|
|
1045
|
-
planIds?: string
|
|
1552
|
+
planIds?: Array<string>;
|
|
1046
1553
|
}
|
|
1047
1554
|
declare class PromoCodesResource {
|
|
1048
1555
|
private httpClient;
|
|
1049
1556
|
constructor(httpClient: CommetHTTPClient);
|
|
1050
|
-
|
|
1051
|
-
|
|
1557
|
+
/** List promo codes with cursor-based pagination. */
|
|
1558
|
+
list(params?: ListPromoCodesParams, options?: RequestOptions): Promise<ApiResponse<Array<PromoCode>>>;
|
|
1559
|
+
/** Retrieve a promo code by its public ID. */
|
|
1560
|
+
get(params: GetPromoCodeParams, options?: RequestOptions): Promise<ApiResponse<PromoCode>>;
|
|
1561
|
+
/** Create a new promo code. Optionally restrict to specific plans. */
|
|
1052
1562
|
create(params: CreatePromoCodeParams, options?: RequestOptions): Promise<ApiResponse<PromoCode>>;
|
|
1053
|
-
|
|
1563
|
+
/** Update a promo code's redemption limits, expiration, active status, or plan restrictions. */
|
|
1564
|
+
update(params: UpdatePromoCodeParams, options?: RequestOptions): Promise<ApiResponse<PromoCode>>;
|
|
1054
1565
|
}
|
|
1055
1566
|
|
|
1056
|
-
interface QuotaEvent {
|
|
1057
|
-
id: string;
|
|
1058
|
-
customerId: CustomerID;
|
|
1059
|
-
featureCode: string;
|
|
1060
|
-
previousBalance: number;
|
|
1061
|
-
newBalance: number;
|
|
1062
|
-
ts: string;
|
|
1063
|
-
createdAt: string;
|
|
1064
|
-
}
|
|
1065
|
-
interface QuotaAllowance {
|
|
1066
|
-
featureCode: string;
|
|
1067
|
-
current: number;
|
|
1068
|
-
included: number;
|
|
1069
|
-
remaining: number | null;
|
|
1070
|
-
billedQuantity?: number;
|
|
1071
|
-
unlimited: boolean;
|
|
1072
|
-
overageEnabled: boolean;
|
|
1073
|
-
asOf: string | null;
|
|
1074
|
-
}
|
|
1075
1567
|
interface AddQuotaParams {
|
|
1076
|
-
customerId
|
|
1568
|
+
customerId?: string;
|
|
1569
|
+
externalId?: string;
|
|
1077
1570
|
featureCode: string;
|
|
1078
1571
|
count?: number;
|
|
1572
|
+
idempotencyKey?: string;
|
|
1079
1573
|
}
|
|
1080
1574
|
interface SetQuotaParams {
|
|
1081
|
-
customerId
|
|
1575
|
+
customerId?: string;
|
|
1576
|
+
externalId?: string;
|
|
1082
1577
|
featureCode: string;
|
|
1083
1578
|
count: number;
|
|
1579
|
+
idempotencyKey?: string;
|
|
1084
1580
|
}
|
|
1085
1581
|
interface RemoveQuotaParams {
|
|
1086
|
-
customerId
|
|
1582
|
+
customerId?: string;
|
|
1583
|
+
externalId?: string;
|
|
1087
1584
|
featureCode: string;
|
|
1088
1585
|
count?: number;
|
|
1586
|
+
idempotencyKey?: string;
|
|
1089
1587
|
}
|
|
1090
|
-
interface
|
|
1091
|
-
customerId:
|
|
1588
|
+
interface GetQuotaAllowanceParams {
|
|
1589
|
+
customerId: string;
|
|
1092
1590
|
featureCode: string;
|
|
1093
1591
|
}
|
|
1094
|
-
interface
|
|
1095
|
-
customerId:
|
|
1592
|
+
interface GetAllQuotaAllowancesParams {
|
|
1593
|
+
customerId: string;
|
|
1096
1594
|
}
|
|
1097
1595
|
declare class QuotaResource {
|
|
1098
1596
|
private httpClient;
|
|
1099
1597
|
constructor(httpClient: CommetHTTPClient);
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1598
|
+
/** Add to a customer's quota allowance for a feature. Defaults to 1 if count is omitted. */
|
|
1599
|
+
add(params: AddQuotaParams, options?: RequestOptions): Promise<ApiResponse<UsageQuotaEvent>>;
|
|
1600
|
+
/** Set a customer's quota allowance for a feature to an exact value. */
|
|
1601
|
+
set(params: SetQuotaParams, options?: RequestOptions): Promise<ApiResponse<UsageQuotaEvent>>;
|
|
1602
|
+
/** Remove from a customer's quota allowance for a feature. Defaults to 1 if count is omitted. Returns 400 insufficient_balance if the balance would go negative. */
|
|
1603
|
+
remove(params: RemoveQuotaParams, options?: RequestOptions): Promise<ApiResponse<UsageQuotaEvent>>;
|
|
1604
|
+
/** Get the current quota allowance (used vs included) for a specific feature. */
|
|
1605
|
+
get(params: GetQuotaAllowanceParams, options?: RequestOptions): Promise<ApiResponse<UsageQuota>>;
|
|
1606
|
+
/** Get all quota allowances for a customer across every quota feature in their plan. */
|
|
1607
|
+
getAll(params: GetAllQuotaAllowancesParams, options?: RequestOptions): Promise<ApiResponse<Array<UsageQuota>>>;
|
|
1105
1608
|
}
|
|
1106
1609
|
|
|
1107
|
-
interface SeatEvent {
|
|
1108
|
-
id: string;
|
|
1109
|
-
object: "seat";
|
|
1110
|
-
livemode: boolean;
|
|
1111
|
-
organizationId: string;
|
|
1112
|
-
customerId: CustomerID;
|
|
1113
|
-
featureCode: string;
|
|
1114
|
-
eventType: "add" | "remove" | "set";
|
|
1115
|
-
quantity: number;
|
|
1116
|
-
previousBalance?: number;
|
|
1117
|
-
newBalance: number;
|
|
1118
|
-
ts: string;
|
|
1119
|
-
createdAt: string;
|
|
1120
|
-
}
|
|
1121
|
-
interface SeatBalance {
|
|
1122
|
-
current: number;
|
|
1123
|
-
asOf: string;
|
|
1124
|
-
}
|
|
1125
1610
|
interface AddSeatsParams {
|
|
1126
|
-
customerId:
|
|
1611
|
+
customerId: string;
|
|
1127
1612
|
featureCode: string;
|
|
1128
|
-
count
|
|
1613
|
+
count: number;
|
|
1129
1614
|
}
|
|
1130
|
-
interface
|
|
1131
|
-
customerId:
|
|
1615
|
+
interface SetSeatsParams {
|
|
1616
|
+
customerId: string;
|
|
1132
1617
|
featureCode: string;
|
|
1133
|
-
count
|
|
1618
|
+
count: number;
|
|
1134
1619
|
}
|
|
1135
|
-
interface
|
|
1136
|
-
customerId:
|
|
1620
|
+
interface RemoveSeatsParams {
|
|
1621
|
+
customerId: string;
|
|
1137
1622
|
featureCode: string;
|
|
1138
1623
|
count: number;
|
|
1139
1624
|
}
|
|
1140
|
-
interface
|
|
1141
|
-
customerId:
|
|
1625
|
+
interface BulkSetSeatsParams {
|
|
1626
|
+
customerId: string;
|
|
1142
1627
|
seats: Record<string, number>;
|
|
1143
1628
|
}
|
|
1144
|
-
interface
|
|
1145
|
-
customerId:
|
|
1629
|
+
interface GetSeatBalanceParams {
|
|
1630
|
+
customerId: string;
|
|
1146
1631
|
featureCode: string;
|
|
1147
1632
|
}
|
|
1148
|
-
interface
|
|
1149
|
-
customerId:
|
|
1633
|
+
interface GetAllSeatBalancesParams {
|
|
1634
|
+
customerId: string;
|
|
1150
1635
|
}
|
|
1151
1636
|
declare class SeatsResource {
|
|
1152
1637
|
private httpClient;
|
|
1153
1638
|
constructor(httpClient: CommetHTTPClient);
|
|
1154
|
-
/** Prorates charges for the current billing period. */
|
|
1639
|
+
/** Add seats to a customer's subscription. Prorates charges for the current billing period. */
|
|
1155
1640
|
add(params: AddSeatsParams, options?: RequestOptions): Promise<ApiResponse<SeatEvent>>;
|
|
1156
|
-
/**
|
|
1157
|
-
remove(params: RemoveSeatsParams, options?: RequestOptions): Promise<ApiResponse<SeatEvent>>;
|
|
1641
|
+
/** Set seats to an exact count. */
|
|
1158
1642
|
set(params: SetSeatsParams, options?: RequestOptions): Promise<ApiResponse<SeatEvent>>;
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1643
|
+
/** Remove seats from a customer's subscription. Takes effect at the end of the billing period. */
|
|
1644
|
+
remove(params: RemoveSeatsParams, options?: RequestOptions): Promise<ApiResponse<SeatEvent>>;
|
|
1645
|
+
/** Set all seat types at once. */
|
|
1646
|
+
setAll(params: BulkSetSeatsParams, options?: RequestOptions): Promise<ApiResponse<Array<BulkSeatUpdate>>>;
|
|
1647
|
+
/** Get current balance for a specific seat type. */
|
|
1648
|
+
getBalance(params: GetSeatBalanceParams, options?: RequestOptions): Promise<ApiResponse<SeatBalance>>;
|
|
1649
|
+
/** Get the current balance for all seat types in a customer's subscription. */
|
|
1650
|
+
getAllBalances(params: GetAllSeatBalancesParams, options?: RequestOptions): Promise<ApiResponse<SeatBalanceListItem>>;
|
|
1162
1651
|
}
|
|
1163
1652
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
name: string;
|
|
1168
|
-
type: FeatureType;
|
|
1169
|
-
enabled?: boolean;
|
|
1170
|
-
usage?: {
|
|
1171
|
-
current: number;
|
|
1172
|
-
included: number;
|
|
1173
|
-
overage: number;
|
|
1174
|
-
overageUnitPrice?: number;
|
|
1175
|
-
};
|
|
1176
|
-
}
|
|
1177
|
-
interface CreditsSummary {
|
|
1178
|
-
remaining: number;
|
|
1179
|
-
included: number;
|
|
1180
|
-
purchased: number;
|
|
1181
|
-
}
|
|
1182
|
-
interface BalanceSummary {
|
|
1183
|
-
remaining: number;
|
|
1184
|
-
included: number;
|
|
1185
|
-
currency: string;
|
|
1186
|
-
}
|
|
1187
|
-
interface CancellationSummary {
|
|
1188
|
-
scheduledAt: string;
|
|
1189
|
-
reason: string | null;
|
|
1190
|
-
effectiveAt: string;
|
|
1191
|
-
}
|
|
1192
|
-
interface DiscountSummary {
|
|
1193
|
-
type: "percentage" | "amount";
|
|
1194
|
-
value: number;
|
|
1195
|
-
name: string | null;
|
|
1196
|
-
endsAt: string | null;
|
|
1197
|
-
}
|
|
1198
|
-
interface ActiveSubscription {
|
|
1199
|
-
id: string;
|
|
1200
|
-
object: "subscription";
|
|
1201
|
-
livemode: boolean;
|
|
1202
|
-
customerId: string;
|
|
1203
|
-
plan: {
|
|
1204
|
-
id: string;
|
|
1205
|
-
name: string;
|
|
1206
|
-
basePrice: number;
|
|
1207
|
-
billingInterval: BillingInterval | null;
|
|
1208
|
-
};
|
|
1209
|
-
name: string;
|
|
1210
|
-
description: string | null;
|
|
1211
|
-
status: SubscriptionStatus;
|
|
1212
|
-
consumptionModel: ConsumptionModel | null;
|
|
1213
|
-
trialEndsAt: string | null;
|
|
1214
|
-
currentPeriod: {
|
|
1215
|
-
start: string;
|
|
1216
|
-
end: string;
|
|
1217
|
-
daysRemaining: number;
|
|
1218
|
-
};
|
|
1219
|
-
features: FeatureSummary[];
|
|
1220
|
-
credits: CreditsSummary | null;
|
|
1221
|
-
balance: BalanceSummary | null;
|
|
1222
|
-
cancellation: CancellationSummary | null;
|
|
1223
|
-
discount: DiscountSummary | null;
|
|
1224
|
-
startDate: string;
|
|
1225
|
-
endDate: string | null;
|
|
1226
|
-
billingDayOfMonth: number;
|
|
1227
|
-
nextBillingDate: string;
|
|
1228
|
-
checkoutUrl: string | null;
|
|
1229
|
-
createdAt: string;
|
|
1230
|
-
updatedAt: string;
|
|
1231
|
-
}
|
|
1232
|
-
interface CreatedSubscription {
|
|
1233
|
-
id: string;
|
|
1234
|
-
object: "subscription";
|
|
1235
|
-
livemode: boolean;
|
|
1236
|
-
customerId: string;
|
|
1237
|
-
planId: string;
|
|
1238
|
-
planName: string;
|
|
1239
|
-
name: string;
|
|
1240
|
-
status: SubscriptionStatus;
|
|
1241
|
-
billingInterval: BillingInterval | null;
|
|
1242
|
-
trialEndsAt: string | null;
|
|
1243
|
-
startDate: string;
|
|
1244
|
-
endDate: string | null;
|
|
1245
|
-
currentPeriodStart: string | null;
|
|
1246
|
-
currentPeriodEnd: string | null;
|
|
1247
|
-
billingDayOfMonth: number;
|
|
1248
|
-
checkoutUrl: string | null;
|
|
1249
|
-
createdAt: string;
|
|
1250
|
-
updatedAt: string;
|
|
1251
|
-
introOfferEndsAt: string | null;
|
|
1252
|
-
introOfferDiscountType: "percentage" | "amount" | null;
|
|
1253
|
-
introOfferDiscountValue: number | null;
|
|
1254
|
-
}
|
|
1255
|
-
interface Subscription {
|
|
1256
|
-
id: string;
|
|
1257
|
-
object: "subscription";
|
|
1258
|
-
livemode: boolean;
|
|
1259
|
-
customerId: string;
|
|
1260
|
-
planId: string;
|
|
1261
|
-
planName: string;
|
|
1262
|
-
name: string;
|
|
1263
|
-
description?: string;
|
|
1264
|
-
status: SubscriptionStatus;
|
|
1265
|
-
billingInterval: BillingInterval;
|
|
1266
|
-
trialEndsAt?: string;
|
|
1267
|
-
startDate: string;
|
|
1268
|
-
endDate?: string;
|
|
1269
|
-
currentPeriodStart?: string;
|
|
1270
|
-
currentPeriodEnd?: string;
|
|
1271
|
-
billingDayOfMonth: number;
|
|
1272
|
-
checkoutUrl?: string;
|
|
1273
|
-
createdAt: string;
|
|
1274
|
-
updatedAt: string;
|
|
1275
|
-
}
|
|
1276
|
-
type PlanIdentifier = {
|
|
1277
|
-
planCode: string;
|
|
1278
|
-
planId?: never;
|
|
1279
|
-
} | {
|
|
1280
|
-
planCode?: never;
|
|
1281
|
-
planId: string;
|
|
1282
|
-
};
|
|
1283
|
-
interface CustomIntroOffer {
|
|
1284
|
-
discountType: "percentage" | "amount";
|
|
1285
|
-
discountValue: number;
|
|
1286
|
-
durationCycles: number;
|
|
1653
|
+
interface ListSubscriptionsParams {
|
|
1654
|
+
customerId?: string;
|
|
1655
|
+
status?: SubscriptionStatus;
|
|
1287
1656
|
}
|
|
1288
|
-
|
|
1657
|
+
interface CreateSubscriptionParams {
|
|
1658
|
+
planId?: string;
|
|
1659
|
+
planCode?: string;
|
|
1289
1660
|
customerId: string;
|
|
1290
|
-
|
|
1291
|
-
billingInterval?: BillingInterval;
|
|
1661
|
+
billingInterval?: BillingInterval | null;
|
|
1292
1662
|
initialSeats?: Record<string, number>;
|
|
1293
1663
|
skipTrial?: boolean;
|
|
1664
|
+
introOffer?: {
|
|
1665
|
+
discountType: DiscountType;
|
|
1666
|
+
discountValue: number;
|
|
1667
|
+
durationCycles: number;
|
|
1668
|
+
};
|
|
1294
1669
|
name?: string;
|
|
1670
|
+
/** @format date-time */
|
|
1295
1671
|
startDate?: string;
|
|
1296
1672
|
successUrl?: string;
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1673
|
+
}
|
|
1674
|
+
interface GetSubscriptionParams {
|
|
1675
|
+
id: string;
|
|
1676
|
+
}
|
|
1677
|
+
interface GetActiveSubscriptionParams {
|
|
1300
1678
|
customerId: string;
|
|
1301
1679
|
}
|
|
1302
|
-
interface
|
|
1680
|
+
interface CancelSubscriptionParams {
|
|
1303
1681
|
id: string;
|
|
1304
1682
|
reason?: string;
|
|
1305
1683
|
immediate?: boolean;
|
|
1306
1684
|
}
|
|
1307
|
-
interface
|
|
1685
|
+
interface UncancelSubscriptionParams {
|
|
1308
1686
|
id: string;
|
|
1309
1687
|
}
|
|
1310
1688
|
interface ChangePlanParams {
|
|
1311
1689
|
id: string;
|
|
1312
1690
|
newPlanId?: string;
|
|
1313
|
-
newBillingInterval?:
|
|
1314
|
-
/** Where to redirect after checkout when a free→paid change requires payment. */
|
|
1691
|
+
newBillingInterval?: "weekly" | "monthly" | "quarterly" | "yearly";
|
|
1315
1692
|
successUrl?: string;
|
|
1316
1693
|
}
|
|
1317
|
-
interface
|
|
1318
|
-
id: string;
|
|
1319
|
-
scheduled: boolean;
|
|
1320
|
-
customerId?: string;
|
|
1321
|
-
previousPlan?: {
|
|
1322
|
-
id: string;
|
|
1323
|
-
name: string;
|
|
1324
|
-
};
|
|
1325
|
-
currentPlan?: {
|
|
1326
|
-
id: string;
|
|
1327
|
-
name: string;
|
|
1328
|
-
price: number;
|
|
1329
|
-
};
|
|
1330
|
-
billingInterval?: string;
|
|
1331
|
-
billing?: {
|
|
1332
|
-
credit: number;
|
|
1333
|
-
creditsApplied: number;
|
|
1334
|
-
charge: number;
|
|
1335
|
-
taxAmount: number;
|
|
1336
|
-
netAmount: number;
|
|
1337
|
-
totalCharged: number;
|
|
1338
|
-
remainingCreditBalance: number;
|
|
1339
|
-
};
|
|
1340
|
-
invoiceId?: string;
|
|
1341
|
-
scheduledFor?: string;
|
|
1342
|
-
changeType?: string;
|
|
1343
|
-
requiresCheckout?: boolean;
|
|
1344
|
-
checkoutUrl?: string;
|
|
1345
|
-
}
|
|
1346
|
-
interface ListSubscriptionsParams extends Record<string, unknown> {
|
|
1347
|
-
customerId?: string;
|
|
1348
|
-
status?: SubscriptionStatus;
|
|
1349
|
-
limit?: number;
|
|
1350
|
-
cursor?: string;
|
|
1351
|
-
}
|
|
1352
|
-
interface SubscriptionListItem {
|
|
1694
|
+
interface PreviewChangePlanParams {
|
|
1353
1695
|
id: string;
|
|
1354
|
-
object: "subscription";
|
|
1355
|
-
livemode: boolean;
|
|
1356
|
-
customerId: string;
|
|
1357
1696
|
planId: string;
|
|
1358
|
-
planName: string;
|
|
1359
|
-
name: string;
|
|
1360
|
-
status: SubscriptionStatus;
|
|
1361
|
-
startDate: string;
|
|
1362
|
-
endDate: string;
|
|
1363
|
-
billingDayOfMonth: number;
|
|
1364
|
-
createdAt: string;
|
|
1365
|
-
updatedAt: string;
|
|
1366
|
-
}
|
|
1367
|
-
interface PreviewChangeParams {
|
|
1368
|
-
id: string;
|
|
1369
|
-
planId?: string;
|
|
1370
1697
|
billingInterval?: BillingInterval;
|
|
1371
1698
|
}
|
|
1372
|
-
interface PreviewChangeResult {
|
|
1373
|
-
currentPlanCredit: number;
|
|
1374
|
-
newPlanCharge: number;
|
|
1375
|
-
estimatedTotal: number;
|
|
1376
|
-
effectiveDate: string;
|
|
1377
|
-
daysRemaining: number;
|
|
1378
|
-
totalDays: number;
|
|
1379
|
-
isUpgrade: boolean;
|
|
1380
|
-
}
|
|
1381
1699
|
interface ActivateAddonParams {
|
|
1382
1700
|
id: string;
|
|
1383
1701
|
addonId: string;
|
|
1384
1702
|
}
|
|
1385
|
-
interface ActivateAddonResult {
|
|
1386
|
-
addonId: string;
|
|
1387
|
-
status: string;
|
|
1388
|
-
proratedCharge: number;
|
|
1389
|
-
}
|
|
1390
1703
|
interface DeactivateAddonParams {
|
|
1391
1704
|
id: string;
|
|
1392
1705
|
addonId: string;
|
|
1393
1706
|
}
|
|
1394
|
-
interface DeactivateAddonResult {
|
|
1395
|
-
id: string;
|
|
1396
|
-
status: string;
|
|
1397
|
-
deactivatedAt: string;
|
|
1398
|
-
}
|
|
1399
1707
|
interface AdjustBalanceParams {
|
|
1400
1708
|
id: string;
|
|
1401
1709
|
amount: number;
|
|
1402
1710
|
reason?: string;
|
|
1403
|
-
type?: "
|
|
1404
|
-
}
|
|
1405
|
-
interface AdjustBalanceResult {
|
|
1406
|
-
amount: number;
|
|
1407
|
-
newBalance: number;
|
|
1408
|
-
reason: string | null;
|
|
1711
|
+
type?: "credits" | "balance";
|
|
1409
1712
|
}
|
|
1410
1713
|
interface TopupBalanceParams {
|
|
1411
1714
|
id: string;
|
|
1412
1715
|
amount: number;
|
|
1413
1716
|
}
|
|
1414
|
-
interface TopupBalanceResult {
|
|
1415
|
-
amount: number;
|
|
1416
|
-
}
|
|
1417
1717
|
interface PurchaseCreditsParams {
|
|
1418
1718
|
id: string;
|
|
1419
1719
|
creditPackId: string;
|
|
1420
1720
|
}
|
|
1421
|
-
interface PurchaseCreditsResult {
|
|
1422
|
-
credits: number;
|
|
1423
|
-
}
|
|
1424
|
-
/** Each customer can only have one active subscription at a time. */
|
|
1425
1721
|
declare class SubscriptionsResource {
|
|
1426
1722
|
private httpClient;
|
|
1427
1723
|
constructor(httpClient: CommetHTTPClient);
|
|
1428
|
-
/**
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
/**
|
|
1439
|
-
|
|
1440
|
-
/**
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1724
|
+
/** List all subscriptions. Filter by customer ID or status. */
|
|
1725
|
+
list(params?: ListSubscriptionsParams, options?: RequestOptions): Promise<ApiResponse<Array<Subscription>>>;
|
|
1726
|
+
/** Create a subscription for a customer. Requires planId or planCode plus customerId. */
|
|
1727
|
+
create(params: CreateSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
|
|
1728
|
+
/** Get a subscription by its public ID, regardless of status (including pending_payment and past_due). */
|
|
1729
|
+
get(params: GetSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
|
|
1730
|
+
/** Get the active subscription for a customer. Returns null if none. */
|
|
1731
|
+
getActive(params: GetActiveSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<Subscription | null>>;
|
|
1732
|
+
/** Cancel immediately or at period end. */
|
|
1733
|
+
cancel(params: CancelSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<CanceledSubscription>>;
|
|
1734
|
+
/** Revert a scheduled cancellation. Only works when canceledAt is set but status is not yet 'canceled'. */
|
|
1735
|
+
uncancel(params: UncancelSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<UncanceledSubscription>>;
|
|
1736
|
+
/** Upgrade, downgrade, or change billing interval. */
|
|
1737
|
+
changePlan(params: ChangePlanParams, options?: RequestOptions): Promise<ApiResponse<PlanChange>>;
|
|
1738
|
+
/** Preview proration details for an immediate plan change (an upgrade or a longer interval) without applying it. Returns credit, charge, and net amount. Downgrades — a cheaper plan in the same group, or a shorter interval — are scheduled for the end of the current period instead of being prorated, so they return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. */
|
|
1739
|
+
previewChange(params: PreviewChangePlanParams, options?: RequestOptions): Promise<ApiResponse<PreviewChange>>;
|
|
1740
|
+
/** Activate an add-on on a subscription. Charges a prorated amount for the current billing period. */
|
|
1741
|
+
activateAddon(params: ActivateAddonParams, options?: RequestOptions): Promise<ApiResponse<SubscriptionAddon>>;
|
|
1742
|
+
/** Deactivate an add-on from a subscription. */
|
|
1743
|
+
deactivateAddon(params: DeactivateAddonParams, options?: RequestOptions): Promise<ApiResponse<DeletedSubscriptionAddon>>;
|
|
1744
|
+
/** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */
|
|
1745
|
+
adjustBalance(params: AdjustBalanceParams, options?: RequestOptions): Promise<ApiResponse<BalanceAdjustment>>;
|
|
1746
|
+
/** Top up a subscription's balance. Charges the customer's payment method for the specified amount. */
|
|
1747
|
+
topupBalance(params: TopupBalanceParams, options?: RequestOptions): Promise<ApiResponse<BalanceTopup>>;
|
|
1748
|
+
/** Purchase a credit pack for a subscription. Charges the customer and adds credits to their balance. */
|
|
1749
|
+
purchaseCredits(params: PurchaseCreditsParams, options?: RequestOptions): Promise<ApiResponse<CreditGrant>>;
|
|
1448
1750
|
}
|
|
1449
1751
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
livemode: boolean;
|
|
1455
|
-
invoiceId: string;
|
|
1456
|
-
grossAmount: number;
|
|
1457
|
-
subtotal: number;
|
|
1458
|
-
taxAmount: number;
|
|
1459
|
-
currency: string;
|
|
1460
|
-
status: TransactionStatus;
|
|
1461
|
-
customerEmail: string;
|
|
1462
|
-
customerName: string | null;
|
|
1463
|
-
paidAt: string | null;
|
|
1464
|
-
createdAt: string;
|
|
1465
|
-
updatedAt: string;
|
|
1466
|
-
}
|
|
1467
|
-
interface TransactionDetail extends TransactionListItem {
|
|
1468
|
-
availableAt: string | null;
|
|
1469
|
-
}
|
|
1470
|
-
interface TransactionRefundResult {
|
|
1471
|
-
id: string;
|
|
1472
|
-
status: "refunded";
|
|
1752
|
+
interface AdvanceTestClockParams {
|
|
1753
|
+
advanceDays?: number;
|
|
1754
|
+
/** @format date-time */
|
|
1755
|
+
frozenTime?: string;
|
|
1473
1756
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1757
|
+
declare class TestClockResource {
|
|
1758
|
+
private httpClient;
|
|
1759
|
+
constructor(httpClient: CommetHTTPClient);
|
|
1760
|
+
/** Returns the organization's current test clock state. Sandbox only. */
|
|
1761
|
+
get(): Promise<ApiResponse<TestClock>>;
|
|
1762
|
+
/** Moves the test clock forward, by a number of days (advanceDays) or to an absolute instant (frozenTime). The clock can only move forward. Sandbox only. */
|
|
1763
|
+
advance(params?: AdvanceTestClockParams, options?: RequestOptions): Promise<ApiResponse<TestClock>>;
|
|
1764
|
+
/** Discovers customers due for billing at the org's current (simulated) time and enqueues a billing cycle for each — renewals, expired trials, pending cancellations. Enqueueing is asynchronous. Sandbox only. */
|
|
1765
|
+
processBilling(): Promise<ApiResponse<TestClockBilling>>;
|
|
1478
1766
|
}
|
|
1767
|
+
|
|
1479
1768
|
interface ListTransactionsParams {
|
|
1480
1769
|
status?: TransactionStatus;
|
|
1481
1770
|
customerEmail?: string;
|
|
@@ -1494,12 +1783,34 @@ interface RetryTransactionParams {
|
|
|
1494
1783
|
declare class TransactionsResource {
|
|
1495
1784
|
private httpClient;
|
|
1496
1785
|
constructor(httpClient: CommetHTTPClient);
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
/**
|
|
1500
|
-
|
|
1501
|
-
/**
|
|
1502
|
-
|
|
1786
|
+
/** List payment transactions with cursor-based pagination. Filter by status or customer email. */
|
|
1787
|
+
list(params?: ListTransactionsParams, options?: RequestOptions): Promise<ApiResponse<Array<Transaction>>>;
|
|
1788
|
+
/** Retrieve a single payment transaction by its public ID, including provider details. */
|
|
1789
|
+
get(params: GetTransactionParams, options?: RequestOptions): Promise<ApiResponse<Transaction>>;
|
|
1790
|
+
/** Issue a full refund for a payment transaction. */
|
|
1791
|
+
refund(params: RefundTransactionParams, options?: RequestOptions): Promise<ApiResponse<TransactionRefund>>;
|
|
1792
|
+
/** Retry a failed payment transaction. Creates a new invoice and initiates a new payment attempt. */
|
|
1793
|
+
retry(params: RetryTransactionParams, options?: RequestOptions): Promise<ApiResponse<TransactionRetry>>;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
declare class GeneratedResources {
|
|
1797
|
+
addons: AddonsResource;
|
|
1798
|
+
apiKeys: ApiKeysResource;
|
|
1799
|
+
creditPacks: CreditPacksResource;
|
|
1800
|
+
customers: CustomersResource;
|
|
1801
|
+
features: FeaturesResource;
|
|
1802
|
+
invoices: InvoicesResource;
|
|
1803
|
+
payouts: PayoutsResource;
|
|
1804
|
+
planGroups: PlanGroupsResource;
|
|
1805
|
+
plans: PlansResource;
|
|
1806
|
+
portal: PortalResource;
|
|
1807
|
+
promoCodes: PromoCodesResource;
|
|
1808
|
+
quota: QuotaResource;
|
|
1809
|
+
seats: SeatsResource;
|
|
1810
|
+
subscriptions: SubscriptionsResource;
|
|
1811
|
+
testClock: TestClockResource;
|
|
1812
|
+
transactions: TransactionsResource;
|
|
1813
|
+
protected initResources(http: CommetHTTPClient): void;
|
|
1503
1814
|
}
|
|
1504
1815
|
|
|
1505
1816
|
type UsageCheckDenialReason = "included_limit_reached" | "insufficient_credits" | "insufficient_balance";
|
|
@@ -1691,22 +2002,8 @@ declare class Webhooks {
|
|
|
1691
2002
|
test(params: TestWebhookParams, options?: RequestOptions): Promise<ApiResponse<WebhookTestResult>>;
|
|
1692
2003
|
}
|
|
1693
2004
|
|
|
1694
|
-
declare class Commet<_TConfig = unknown> {
|
|
2005
|
+
declare class Commet<_TConfig = unknown> extends GeneratedResources {
|
|
1695
2006
|
private httpClient;
|
|
1696
|
-
readonly addons: AddonsResource;
|
|
1697
|
-
readonly apiKeys: ApiKeysResource;
|
|
1698
|
-
readonly creditPacks: CreditPacksResource;
|
|
1699
|
-
readonly customers: CustomersResource;
|
|
1700
|
-
readonly features: FeaturesResource;
|
|
1701
|
-
readonly invoices: InvoicesResource;
|
|
1702
|
-
readonly planGroups: PlanGroupsResource;
|
|
1703
|
-
readonly plans: PlansResource;
|
|
1704
|
-
readonly portal: PortalResource;
|
|
1705
|
-
readonly promoCodes: PromoCodesResource;
|
|
1706
|
-
readonly quota: QuotaResource;
|
|
1707
|
-
readonly seats: SeatsResource;
|
|
1708
|
-
readonly subscriptions: SubscriptionsResource;
|
|
1709
|
-
readonly transactions: TransactionsResource;
|
|
1710
2007
|
readonly usage: UsageResource;
|
|
1711
2008
|
readonly webhooks: Webhooks;
|
|
1712
2009
|
constructor(config: CommetClientOptions);
|
|
@@ -1715,7 +2012,7 @@ declare function createCommet<const TConfig extends BillingConfig>(_billingConfi
|
|
|
1715
2012
|
|
|
1716
2013
|
declare function registerIntegration(name: string, version: string): void;
|
|
1717
2014
|
|
|
1718
|
-
declare const API_VERSION = "2026-
|
|
2015
|
+
declare const API_VERSION = "2026-06-07";
|
|
1719
2016
|
declare const SDK_VERSION: string;
|
|
1720
2017
|
|
|
1721
|
-
export { API_VERSION, type ActivateAddonParams, type
|
|
2018
|
+
export { API_VERSION, type ActivateAddonParams, type ActiveAddon, type AddPayoutBankAccountParams, type AddPlanFeatureParams, type AddPlanPriceParams, type AddPlanToGroupParams, type AddQuotaParams, type AddSeatsParams, type AddedPlanToGroup, type Addon, type AdjustBalanceParams, type AdvanceTestClockParams, type ApiErrorDetail, type ApiKey, type ApiResponse, type BalanceAdjustment, type BalanceTopup, type BatchCreateCustomersParams, type BillingConfig, type BillingInterval, type BulkSeatUpdate, type BulkSetSeatsParams, type CanUseFeatureParams, type CancelSubscriptionParams, type CanceledSubscription, type ChangePlanParams, type CheckUsageParams, Commet, CommetAPIError, type CommetClientOptions, CommetError, CommetValidationError, type CompletePayoutVerificationParams, type ConsumptionModel, type CreateAddonParams, type CreateAdjustmentInvoiceParams, type CreateApiKeyParams, type CreateCreditPackParams, type CreateCustomerParams, type CreateFeatureParams, type CreatePlanGroupParams, type CreatePlanParams, type CreatePromoCodeParams, type CreateSubscriptionParams, type CreateWebhookParams, type CreatedApiKey, type CreatedInvoice, type CreditGrant, type CreditPack, type Currency, type Customer, type CustomerBatch, type CustomerID, type DeactivateAddonParams, type DefaultPlanPrice, type DeleteAddonParams, type DeleteApiKeyParams, type DeleteCreditPackParams, type DeleteFeatureParams, type DeletePlanGroupParams, type DeletePlanParams, type DeletePlanPriceParams, type DeleteRegionalPricesParams, type DeleteWebhookParams, type DeletedObject, type DeletedPlanRegionalPricing, type DeletedSubscriptionAddon, type DiscountType, type DownloadInvoiceParams, type EventID, type Feature, type FeatureAccess, type FeatureDef, type FeatureLookup, type FeatureType, type GetActiveSubscriptionParams, type GetAddonParams, type GetAllQuotaAllowancesParams, type GetAllSeatBalancesParams, type GetCustomerParams, type GetFeatureAccessParams, type GetInvoiceParams, type GetPlanGroupParams, type GetPlanParams, type GetPromoCodeParams, type GetQuotaAllowanceParams, type GetSeatBalanceParams, type GetSubscriptionParams, type GetTransactionParams, type GetWebhookParams, type InferFeatureCodes, type InferPlanCodes, type InferSeatCodes, type InferUsageCodes, type Invoice, type InvoiceDownload, type InvoiceStatus, type InvoiceType, type ListActiveAddonsParams, type ListAddonsParams, type ListApiKeysParams, type ListCustomersParams, type ListFeaturesParams, type ListInvoicesParams, type ListPlanGroupsParams, type ListPlansParams, type ListPromoCodesParams, type ListSubscriptionsParams, type ListTransactionsParams, type ListWebhooksParams, type PaginatedList, type PaginatedResponse, type Payout, type PayoutBankAccount, type PayoutVerification, type Plan, type PlanChange, type PlanDef, type PlanFeature, type PlanFeatureValue, type PlanGroup, type PlanPrice, type PlanRegionalPricing, type PlanRegionalPricingResult, type PlanVisibility, type PortalAccess, type PreviewChange, type PreviewChangePlanParams, type PriceDef, type PromoCode, type PurchaseCreditsParams, type RefundTransactionParams, type RemovePlanFeatureParams, type RemovePlanFromGroupParams, type RemoveQuotaParams, type RemoveSeatsParams, type RemovedPlanFeature, type RemovedPlanFromGroup, type ReorderPlansInGroupParams, type ReorderedPlans, type RequestOptions, type RequestPayoutParams, type RequestPortalAccessParams, type ResolvedFeatureCode, type ResolvedPlanCode, type ResolvedSeatCode, type ResolvedUsageCode, type RetryTransactionParams, SDK_VERSION, type SeatBalance, type SeatBalanceListItem, type SeatEvent, type SendInvoiceParams, type SentInvoice, type SetDefaultPlanPriceParams, type SetPlanRegionalPricingParams, type SetPlanVisibilityParams, type SetQuotaParams, type SetSeatsParams, type Subscription, type SubscriptionAddon, type SubscriptionStatus, type TestClock, type TestClockBilling, type TestWebhookParams, type Timezone, type TopupBalanceParams, type TrackModelTokensParams, type TrackParams, type TrackUsageParams, type Transaction, type TransactionRefund, type TransactionRetry, type TransactionStatus, type UncancelSubscriptionParams, type UncanceledSubscription, type UpdateAddonParams, type UpdateCreditPackParams, type UpdateCustomerParams, type UpdateFeatureParams, type UpdateInvoiceStatusParams, type UpdatePlanFeatureParams, type UpdatePlanGroupParams, type UpdatePlanParams, type UpdatePlanPriceParams, type UpdatePromoCodeParams, type UpdateWebhookParams, type UpsertRegionalPricesParams, type UsageCheckDenialReason, type UsageCheckResult, type UsageEvent, type UsageEventProperty, type UsageQuota, type UsageQuotaEvent, type WebhookData, type WebhookEndpoint, type WebhookEndpointCreated, type WebhookEvent, type WebhookPayload, type WebhookTestResult, Webhooks, createCommet, Commet as default, defineConfig, registerIntegration };
|