@commet/node 5.5.1 → 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 +1292 -996
- package/dist/index.d.ts +1292 -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.js
CHANGED
|
@@ -49,28 +49,29 @@ var AddonsResource = class {
|
|
|
49
49
|
constructor(httpClient) {
|
|
50
50
|
this.httpClient = httpClient;
|
|
51
51
|
}
|
|
52
|
+
/** List all active add-ons for a customer's subscription. */
|
|
52
53
|
async listActive(params, options) {
|
|
53
|
-
return this.httpClient.get(
|
|
54
|
-
"/addons/active",
|
|
55
|
-
{ customerId: params.customerId },
|
|
56
|
-
options
|
|
57
|
-
);
|
|
54
|
+
return this.httpClient.get("/addons/active", params, options);
|
|
58
55
|
}
|
|
56
|
+
/** List all add-ons with cursor-based pagination. */
|
|
59
57
|
async list(params, options) {
|
|
60
58
|
return this.httpClient.get("/addons", params, options);
|
|
61
59
|
}
|
|
60
|
+
/** Retrieve an add-on by its public ID or slug. */
|
|
62
61
|
async get(params, options) {
|
|
63
62
|
const { id } = params;
|
|
64
63
|
return this.httpClient.get(`/addons/${id}`, void 0, options);
|
|
65
64
|
}
|
|
65
|
+
/** Create a new add-on linked to a feature. Each feature can only be assigned to one add-on. */
|
|
66
66
|
async create(params, options) {
|
|
67
67
|
return this.httpClient.post("/addons", params, options);
|
|
68
68
|
}
|
|
69
|
+
/** Update an add-on's name, description, or pricing. */
|
|
69
70
|
async update(params, options) {
|
|
70
|
-
const { id, ...
|
|
71
|
-
return this.httpClient.put(`/addons/${id}`,
|
|
71
|
+
const { id, ...rest } = params;
|
|
72
|
+
return this.httpClient.put(`/addons/${id}`, rest, options);
|
|
72
73
|
}
|
|
73
|
-
/** Fails if
|
|
74
|
+
/** Soft-delete an add-on. Fails if the add-on has active subscriptions. */
|
|
74
75
|
async delete(params, options) {
|
|
75
76
|
const { id } = params;
|
|
76
77
|
return this.httpClient.delete(`/addons/${id}`, void 0, options);
|
|
@@ -82,15 +83,18 @@ var ApiKeysResource = class {
|
|
|
82
83
|
constructor(httpClient) {
|
|
83
84
|
this.httpClient = httpClient;
|
|
84
85
|
}
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
/** List API keys with cursor-based pagination. Keys are returned without the full secret. */
|
|
87
|
+
async list(params, options) {
|
|
88
|
+
return this.httpClient.get("/api-keys", params, options);
|
|
87
89
|
}
|
|
88
|
-
/**
|
|
90
|
+
/** Create a new API key. The full key is only returned once in the response. */
|
|
89
91
|
async create(params, options) {
|
|
90
92
|
return this.httpClient.post("/api-keys", params, options);
|
|
91
93
|
}
|
|
94
|
+
/** Permanently revoke and delete an API key. */
|
|
92
95
|
async delete(params, options) {
|
|
93
|
-
|
|
96
|
+
const { id } = params;
|
|
97
|
+
return this.httpClient.delete(`/api-keys/${id}`, void 0, options);
|
|
94
98
|
}
|
|
95
99
|
};
|
|
96
100
|
|
|
@@ -99,16 +103,20 @@ var CreditPacksResource = class {
|
|
|
99
103
|
constructor(httpClient) {
|
|
100
104
|
this.httpClient = httpClient;
|
|
101
105
|
}
|
|
106
|
+
/** List all active credit packs. */
|
|
102
107
|
async list() {
|
|
103
108
|
return this.httpClient.get("/credit-packs");
|
|
104
109
|
}
|
|
110
|
+
/** Create a new credit pack. */
|
|
105
111
|
async create(params, options) {
|
|
106
112
|
return this.httpClient.post("/credit-packs/manage", params, options);
|
|
107
113
|
}
|
|
114
|
+
/** Update a credit pack's name, description, credits, price, or active status. */
|
|
108
115
|
async update(params, options) {
|
|
109
|
-
const { id, ...
|
|
110
|
-
return this.httpClient.put(`/credit-packs/${id}`,
|
|
116
|
+
const { id, ...rest } = params;
|
|
117
|
+
return this.httpClient.put(`/credit-packs/${id}`, rest, options);
|
|
111
118
|
}
|
|
119
|
+
/** Soft-delete a credit pack. */
|
|
112
120
|
async delete(params, options) {
|
|
113
121
|
const { id } = params;
|
|
114
122
|
return this.httpClient.delete(`/credit-packs/${id}`, void 0, options);
|
|
@@ -120,62 +128,27 @@ var CustomersResource = class {
|
|
|
120
128
|
constructor(httpClient) {
|
|
121
129
|
this.httpClient = httpClient;
|
|
122
130
|
}
|
|
123
|
-
/**
|
|
131
|
+
/** List customers with cursor-based pagination. */
|
|
132
|
+
async list(params, options) {
|
|
133
|
+
return this.httpClient.get("/customers", params, options);
|
|
134
|
+
}
|
|
135
|
+
/** Create a new customer. Idempotent when customerId is provided. */
|
|
124
136
|
async create(params, options) {
|
|
125
|
-
return this.httpClient.post(
|
|
126
|
-
"/customers",
|
|
127
|
-
{
|
|
128
|
-
billingEmail: params.email,
|
|
129
|
-
id: params.id,
|
|
130
|
-
fullName: params.fullName,
|
|
131
|
-
domain: params.domain,
|
|
132
|
-
website: params.website,
|
|
133
|
-
timezone: params.timezone,
|
|
134
|
-
language: params.language,
|
|
135
|
-
industry: params.industry,
|
|
136
|
-
metadata: params.metadata,
|
|
137
|
-
address: params.address
|
|
138
|
-
},
|
|
139
|
-
options
|
|
140
|
-
);
|
|
137
|
+
return this.httpClient.post("/customers", params, options);
|
|
141
138
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
fullName: c.fullName,
|
|
147
|
-
domain: c.domain,
|
|
148
|
-
website: c.website,
|
|
149
|
-
timezone: c.timezone,
|
|
150
|
-
language: c.language,
|
|
151
|
-
industry: c.industry,
|
|
152
|
-
metadata: c.metadata,
|
|
153
|
-
address: c.address
|
|
154
|
-
}));
|
|
155
|
-
return this.httpClient.post("/customers/batch", { customers }, options);
|
|
156
|
-
}
|
|
157
|
-
async get(params) {
|
|
158
|
-
return this.httpClient.get(`/customers/${params.id}`);
|
|
139
|
+
/** Retrieve a customer by their public ID, including subscription status and metadata. */
|
|
140
|
+
async get(params, options) {
|
|
141
|
+
const { id } = params;
|
|
142
|
+
return this.httpClient.get(`/customers/${id}`, void 0, options);
|
|
159
143
|
}
|
|
144
|
+
/** Update a customer's name, external ID, or metadata. */
|
|
160
145
|
async update(params, options) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
billingEmail: params.email,
|
|
165
|
-
fullName: params.fullName,
|
|
166
|
-
domain: params.domain,
|
|
167
|
-
website: params.website,
|
|
168
|
-
timezone: params.timezone,
|
|
169
|
-
language: params.language,
|
|
170
|
-
industry: params.industry,
|
|
171
|
-
metadata: params.metadata,
|
|
172
|
-
address: params.address
|
|
173
|
-
},
|
|
174
|
-
options
|
|
175
|
-
);
|
|
146
|
+
const { id, ...rest } = params;
|
|
147
|
+
return this.httpClient.put(`/customers/${id}`, rest, options);
|
|
176
148
|
}
|
|
177
|
-
|
|
178
|
-
|
|
149
|
+
/** Create up to 100 customers in a single request. */
|
|
150
|
+
async createBatch(params, options) {
|
|
151
|
+
return this.httpClient.post("/customers/batch", params, options);
|
|
179
152
|
}
|
|
180
153
|
};
|
|
181
154
|
|
|
@@ -184,36 +157,34 @@ var FeaturesResource = class {
|
|
|
184
157
|
constructor(httpClient) {
|
|
185
158
|
this.httpClient = httpClient;
|
|
186
159
|
}
|
|
160
|
+
/** List all features for a customer's active subscription. */
|
|
161
|
+
async list(params, options) {
|
|
162
|
+
return this.httpClient.get("/features", params, options);
|
|
163
|
+
}
|
|
164
|
+
/** Get feature access details. Use action=canUse to check if customer can consume one more unit. */
|
|
187
165
|
async get(params, options) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{ customerId: params.customerId },
|
|
191
|
-
options
|
|
192
|
-
);
|
|
166
|
+
const { code, ...rest } = params;
|
|
167
|
+
return this.httpClient.get(`/features/${code}`, rest, options);
|
|
193
168
|
}
|
|
194
|
-
/**
|
|
169
|
+
/** Get feature access details. Use action=canUse to check if customer can consume one more unit. */
|
|
195
170
|
async canUse(params, options) {
|
|
171
|
+
const { code, ...rest } = params;
|
|
196
172
|
return this.httpClient.get(
|
|
197
|
-
`/features/${
|
|
198
|
-
{
|
|
199
|
-
options
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
async list(params, options) {
|
|
203
|
-
return this.httpClient.get(
|
|
204
|
-
"/features",
|
|
205
|
-
{ customerId: params.customerId },
|
|
173
|
+
`/features/${code}`,
|
|
174
|
+
{ ...rest, action: "canUse" },
|
|
206
175
|
options
|
|
207
176
|
);
|
|
208
177
|
}
|
|
178
|
+
/** Create a new feature. Code must be lowercase alphanumeric with underscores. */
|
|
209
179
|
async create(params, options) {
|
|
210
180
|
return this.httpClient.post("/features/manage", params, options);
|
|
211
181
|
}
|
|
182
|
+
/** Update a feature's name, description, or unit name. At least one field must be provided. */
|
|
212
183
|
async update(params, options) {
|
|
213
|
-
const { code, ...
|
|
214
|
-
return this.httpClient.put(`/features/${code}/manage`,
|
|
184
|
+
const { code, ...rest } = params;
|
|
185
|
+
return this.httpClient.put(`/features/${code}/manage`, rest, options);
|
|
215
186
|
}
|
|
216
|
-
/** Fails if feature is attached to active plans or has an active
|
|
187
|
+
/** Delete a feature. Fails if the feature is attached to active plans or has an active add-on. */
|
|
217
188
|
async delete(params, options) {
|
|
218
189
|
const { code } = params;
|
|
219
190
|
return this.httpClient.delete(
|
|
@@ -229,27 +200,52 @@ var InvoicesResource = class {
|
|
|
229
200
|
constructor(httpClient) {
|
|
230
201
|
this.httpClient = httpClient;
|
|
231
202
|
}
|
|
232
|
-
|
|
233
|
-
|
|
203
|
+
/** List invoices with cursor-based pagination. Filter by customer, status, or subscription. */
|
|
204
|
+
async list(params, options) {
|
|
205
|
+
return this.httpClient.get("/invoices", params, options);
|
|
234
206
|
}
|
|
235
|
-
|
|
236
|
-
|
|
207
|
+
/** Retrieve a single invoice by its public ID, including line items. */
|
|
208
|
+
async get(params, options) {
|
|
209
|
+
const { id } = params;
|
|
210
|
+
return this.httpClient.get(`/invoices/${id}`, void 0, options);
|
|
237
211
|
}
|
|
238
|
-
/**
|
|
212
|
+
/** Create a one-off adjustment invoice. Use a negative amount for a credit. */
|
|
239
213
|
async createAdjustment(params, options) {
|
|
240
214
|
return this.httpClient.post("/invoices", params, options);
|
|
241
215
|
}
|
|
242
|
-
/**
|
|
243
|
-
async getDownloadUrl(params) {
|
|
244
|
-
|
|
216
|
+
/** Generate a signed URL to download the invoice as a PDF. The URL expires after 7 days. */
|
|
217
|
+
async getDownloadUrl(params, options) {
|
|
218
|
+
const { id } = params;
|
|
219
|
+
return this.httpClient.get(`/invoices/${id}/download`, void 0, options);
|
|
245
220
|
}
|
|
221
|
+
/** Send the invoice to the customer via email. */
|
|
246
222
|
async send(params, options) {
|
|
247
|
-
|
|
223
|
+
const { id } = params;
|
|
224
|
+
return this.httpClient.post(`/invoices/${id}/send`, {}, options);
|
|
248
225
|
}
|
|
249
|
-
/**
|
|
226
|
+
/** Mark an outstanding invoice as "paid" or "void". Cannot change the status of already paid or voided invoices. */
|
|
250
227
|
async updateStatus(params, options) {
|
|
251
|
-
const { id, ...
|
|
252
|
-
return this.httpClient.put(`/invoices/${id}/status`,
|
|
228
|
+
const { id, ...rest } = params;
|
|
229
|
+
return this.httpClient.put(`/invoices/${id}/status`, rest, options);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// src/resources/payouts.ts
|
|
234
|
+
var PayoutsResource = class {
|
|
235
|
+
constructor(httpClient) {
|
|
236
|
+
this.httpClient = httpClient;
|
|
237
|
+
}
|
|
238
|
+
/** 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`. */
|
|
239
|
+
async addBankAccount(params, options) {
|
|
240
|
+
return this.httpClient.post("/payouts/bank-accounts", params, options);
|
|
241
|
+
}
|
|
242
|
+
/** 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. */
|
|
243
|
+
async request(params, options) {
|
|
244
|
+
return this.httpClient.post("/payouts", params, options);
|
|
245
|
+
}
|
|
246
|
+
/** 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. */
|
|
247
|
+
async completeVerification(params, options) {
|
|
248
|
+
return this.httpClient.post("/payouts/verification", params, options);
|
|
253
249
|
}
|
|
254
250
|
};
|
|
255
251
|
|
|
@@ -258,31 +254,35 @@ var PlanGroupsResource = class {
|
|
|
258
254
|
constructor(httpClient) {
|
|
259
255
|
this.httpClient = httpClient;
|
|
260
256
|
}
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
/** List plan groups with cursor-based pagination. */
|
|
258
|
+
async list(params, options) {
|
|
259
|
+
return this.httpClient.get("/plan-groups", params, options);
|
|
263
260
|
}
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
/** Retrieve a plan group by ID, including its plans ordered by sortOrder. */
|
|
262
|
+
async get(params, options) {
|
|
263
|
+
const { id } = params;
|
|
264
|
+
return this.httpClient.get(`/plan-groups/${id}`, void 0, options);
|
|
266
265
|
}
|
|
266
|
+
/** Create a new plan group for organizing plans. */
|
|
267
267
|
async create(params, options) {
|
|
268
268
|
return this.httpClient.post("/plan-groups", params, options);
|
|
269
269
|
}
|
|
270
|
+
/** Update a plan group's name, description, or visibility. */
|
|
270
271
|
async update(params, options) {
|
|
271
|
-
const { id, ...
|
|
272
|
-
return this.httpClient.put(`/plan-groups/${id}`,
|
|
272
|
+
const { id, ...rest } = params;
|
|
273
|
+
return this.httpClient.put(`/plan-groups/${id}`, rest, options);
|
|
273
274
|
}
|
|
274
|
-
/** Plans in the group are unlinked, not deleted. */
|
|
275
|
+
/** Delete a plan group. Plans in the group are unlinked, not deleted. */
|
|
275
276
|
async delete(params, options) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
void 0,
|
|
279
|
-
options
|
|
280
|
-
);
|
|
277
|
+
const { id } = params;
|
|
278
|
+
return this.httpClient.delete(`/plan-groups/${id}`, void 0, options);
|
|
281
279
|
}
|
|
280
|
+
/** Add an existing plan to a plan group with optional sort order. */
|
|
282
281
|
async addPlan(params, options) {
|
|
283
|
-
const { id, ...
|
|
284
|
-
return this.httpClient.post(`/plan-groups/${id}/plans`,
|
|
282
|
+
const { id, ...rest } = params;
|
|
283
|
+
return this.httpClient.post(`/plan-groups/${id}/plans`, rest, options);
|
|
285
284
|
}
|
|
285
|
+
/** Remove a plan from a plan group. */
|
|
286
286
|
async removePlan(params, options) {
|
|
287
287
|
const { id, planId } = params;
|
|
288
288
|
return this.httpClient.delete(
|
|
@@ -291,11 +291,12 @@ var PlanGroupsResource = class {
|
|
|
291
291
|
options
|
|
292
292
|
);
|
|
293
293
|
}
|
|
294
|
+
/** Set the display order of plans within a group. All plan IDs in the group must be provided. */
|
|
294
295
|
async reorderPlans(params, options) {
|
|
295
|
-
const { id, ...
|
|
296
|
+
const { id, ...rest } = params;
|
|
296
297
|
return this.httpClient.put(
|
|
297
298
|
`/plan-groups/${id}/plans/reorder`,
|
|
298
|
-
|
|
299
|
+
rest,
|
|
299
300
|
options
|
|
300
301
|
);
|
|
301
302
|
}
|
|
@@ -306,90 +307,104 @@ var PlansResource = class {
|
|
|
306
307
|
constructor(httpClient) {
|
|
307
308
|
this.httpClient = httpClient;
|
|
308
309
|
}
|
|
309
|
-
|
|
310
|
-
|
|
310
|
+
/** List all plans with their prices and features. Optionally include private plans. */
|
|
311
|
+
async list(params, options) {
|
|
312
|
+
return this.httpClient.get("/plans", params, options);
|
|
311
313
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
+
/** Get detailed plan information by code or ID. */
|
|
315
|
+
async get(params, options) {
|
|
316
|
+
const { id } = params;
|
|
317
|
+
return this.httpClient.get(`/plans/${id}`, void 0, options);
|
|
314
318
|
}
|
|
319
|
+
/** Create a new plan with optional consumption model, visibility, and plan group assignment. */
|
|
315
320
|
async create(params, options) {
|
|
316
321
|
return this.httpClient.post("/plans/manage", params, options);
|
|
317
322
|
}
|
|
323
|
+
/** Update a plan's name, description, visibility, or metadata. */
|
|
318
324
|
async update(params, options) {
|
|
319
|
-
const { id, ...
|
|
320
|
-
return this.httpClient.put(`/plans/${id}/manage`,
|
|
325
|
+
const { id, ...rest } = params;
|
|
326
|
+
return this.httpClient.put(`/plans/${id}/manage`, rest, options);
|
|
321
327
|
}
|
|
328
|
+
/** Soft-delete a plan. */
|
|
322
329
|
async delete(params, options) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
void 0,
|
|
326
|
-
options
|
|
327
|
-
);
|
|
330
|
+
const { id } = params;
|
|
331
|
+
return this.httpClient.delete(`/plans/${id}/manage`, void 0, options);
|
|
328
332
|
}
|
|
333
|
+
/** Toggle a plan between public and private. */
|
|
329
334
|
async setVisibility(params, options) {
|
|
330
|
-
const { id, ...
|
|
331
|
-
return this.httpClient.put(`/plans/${id}/visibility`,
|
|
335
|
+
const { id, ...rest } = params;
|
|
336
|
+
return this.httpClient.put(`/plans/${id}/visibility`, rest, options);
|
|
332
337
|
}
|
|
338
|
+
/** Attach a feature to a plan with limits, overage, and credits configuration. */
|
|
333
339
|
async addFeature(params, options) {
|
|
334
|
-
const {
|
|
335
|
-
return this.httpClient.post(`/plans/${
|
|
340
|
+
const { id, ...rest } = params;
|
|
341
|
+
return this.httpClient.post(`/plans/${id}/features`, rest, options);
|
|
336
342
|
}
|
|
343
|
+
/** Update limits, overage, or enabled status of a feature on a plan. */
|
|
337
344
|
async updateFeature(params, options) {
|
|
338
|
-
const {
|
|
345
|
+
const { id, featureId, ...rest } = params;
|
|
339
346
|
return this.httpClient.put(
|
|
340
|
-
`/plans/${
|
|
341
|
-
|
|
347
|
+
`/plans/${id}/features/${featureId}`,
|
|
348
|
+
rest,
|
|
342
349
|
options
|
|
343
350
|
);
|
|
344
351
|
}
|
|
352
|
+
/** Detach a feature from a plan. */
|
|
345
353
|
async removeFeature(params, options) {
|
|
346
|
-
const {
|
|
354
|
+
const { id, featureId } = params;
|
|
347
355
|
return this.httpClient.delete(
|
|
348
|
-
`/plans/${
|
|
356
|
+
`/plans/${id}/features/${featureId}`,
|
|
349
357
|
void 0,
|
|
350
358
|
options
|
|
351
359
|
);
|
|
352
360
|
}
|
|
361
|
+
/** Add a billing interval price to a plan with optional trial days and included balance/credits. */
|
|
353
362
|
async addPrice(params, options) {
|
|
354
|
-
const {
|
|
355
|
-
return this.httpClient.post(`/plans/${
|
|
363
|
+
const { id, ...rest } = params;
|
|
364
|
+
return this.httpClient.post(`/plans/${id}/prices`, rest, options);
|
|
356
365
|
}
|
|
366
|
+
/** Update an existing price on a plan. */
|
|
357
367
|
async updatePrice(params, options) {
|
|
358
|
-
const {
|
|
359
|
-
return this.httpClient.put(
|
|
360
|
-
`/plans/${planId}/prices/${priceId}`,
|
|
361
|
-
body,
|
|
362
|
-
options
|
|
363
|
-
);
|
|
368
|
+
const { id, priceId, ...rest } = params;
|
|
369
|
+
return this.httpClient.put(`/plans/${id}/prices/${priceId}`, rest, options);
|
|
364
370
|
}
|
|
371
|
+
/** Remove a price from a plan. */
|
|
365
372
|
async deletePrice(params, options) {
|
|
366
|
-
const {
|
|
373
|
+
const { id, priceId } = params;
|
|
367
374
|
return this.httpClient.delete(
|
|
368
|
-
`/plans/${
|
|
375
|
+
`/plans/${id}/prices/${priceId}`,
|
|
369
376
|
void 0,
|
|
370
377
|
options
|
|
371
378
|
);
|
|
372
379
|
}
|
|
380
|
+
/** Set a specific price as the default for its plan. Unsets previous default. */
|
|
373
381
|
async setDefaultPrice(params, options) {
|
|
374
|
-
const {
|
|
382
|
+
const { id, priceId } = params;
|
|
375
383
|
return this.httpClient.put(
|
|
376
|
-
`/plans/${
|
|
384
|
+
`/plans/${id}/prices/${priceId}/default`,
|
|
377
385
|
{},
|
|
378
386
|
options
|
|
379
387
|
);
|
|
380
388
|
}
|
|
389
|
+
/** Create or update regional currency price overrides for a plan price. */
|
|
381
390
|
async setRegionalPrices(params, options) {
|
|
382
|
-
const {
|
|
391
|
+
const { id, priceId, ...rest } = params;
|
|
383
392
|
return this.httpClient.put(
|
|
384
|
-
`/plans/${
|
|
385
|
-
|
|
393
|
+
`/plans/${id}/prices/${priceId}/regional`,
|
|
394
|
+
rest,
|
|
386
395
|
options
|
|
387
396
|
);
|
|
388
397
|
}
|
|
398
|
+
/** 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. */
|
|
399
|
+
async setRegionalPricing(params, options) {
|
|
400
|
+
const { id, ...rest } = params;
|
|
401
|
+
return this.httpClient.put(`/plans/${id}/regional`, rest, options);
|
|
402
|
+
}
|
|
403
|
+
/** Remove all regional currency overrides for a plan price. */
|
|
389
404
|
async deleteRegionalPrices(params, options) {
|
|
390
|
-
const {
|
|
405
|
+
const { id, priceId } = params;
|
|
391
406
|
return this.httpClient.delete(
|
|
392
|
-
`/plans/${
|
|
407
|
+
`/plans/${id}/prices/${priceId}/regional`,
|
|
393
408
|
void 0,
|
|
394
409
|
options
|
|
395
410
|
);
|
|
@@ -401,6 +416,7 @@ var PortalResource = class {
|
|
|
401
416
|
constructor(httpClient) {
|
|
402
417
|
this.httpClient = httpClient;
|
|
403
418
|
}
|
|
419
|
+
/** Generate a customer portal URL. Exactly one identifier (email or customerId) is required. */
|
|
404
420
|
async getUrl(params, options) {
|
|
405
421
|
return this.httpClient.post("/portal/request-access", params, options);
|
|
406
422
|
}
|
|
@@ -411,18 +427,23 @@ var PromoCodesResource = class {
|
|
|
411
427
|
constructor(httpClient) {
|
|
412
428
|
this.httpClient = httpClient;
|
|
413
429
|
}
|
|
414
|
-
|
|
415
|
-
|
|
430
|
+
/** List promo codes with cursor-based pagination. */
|
|
431
|
+
async list(params, options) {
|
|
432
|
+
return this.httpClient.get("/promo-codes", params, options);
|
|
416
433
|
}
|
|
417
|
-
|
|
418
|
-
|
|
434
|
+
/** Retrieve a promo code by its public ID. */
|
|
435
|
+
async get(params, options) {
|
|
436
|
+
const { id } = params;
|
|
437
|
+
return this.httpClient.get(`/promo-codes/${id}`, void 0, options);
|
|
419
438
|
}
|
|
439
|
+
/** Create a new promo code. Optionally restrict to specific plans. */
|
|
420
440
|
async create(params, options) {
|
|
421
441
|
return this.httpClient.post("/promo-codes", params, options);
|
|
422
442
|
}
|
|
443
|
+
/** Update a promo code's redemption limits, expiration, active status, or plan restrictions. */
|
|
423
444
|
async update(params, options) {
|
|
424
|
-
const { id, ...
|
|
425
|
-
return this.httpClient.put(`/promo-codes/${id}`,
|
|
445
|
+
const { id, ...rest } = params;
|
|
446
|
+
return this.httpClient.put(`/promo-codes/${id}`, rest, options);
|
|
426
447
|
}
|
|
427
448
|
};
|
|
428
449
|
|
|
@@ -431,49 +452,25 @@ var QuotaResource = class {
|
|
|
431
452
|
constructor(httpClient) {
|
|
432
453
|
this.httpClient = httpClient;
|
|
433
454
|
}
|
|
455
|
+
/** Add to a customer's quota allowance for a feature. Defaults to 1 if count is omitted. */
|
|
434
456
|
async add(params, options) {
|
|
435
|
-
return this.httpClient.post(
|
|
436
|
-
"/usage/quota",
|
|
437
|
-
{
|
|
438
|
-
customerId: params.customerId,
|
|
439
|
-
featureCode: params.featureCode,
|
|
440
|
-
count: params.count ?? 1
|
|
441
|
-
},
|
|
442
|
-
options
|
|
443
|
-
);
|
|
457
|
+
return this.httpClient.post("/usage/quota", params, options);
|
|
444
458
|
}
|
|
459
|
+
/** Set a customer's quota allowance for a feature to an exact value. */
|
|
445
460
|
async set(params, options) {
|
|
446
|
-
return this.httpClient.put(
|
|
447
|
-
"/usage/quota",
|
|
448
|
-
{
|
|
449
|
-
customerId: params.customerId,
|
|
450
|
-
featureCode: params.featureCode,
|
|
451
|
-
count: params.count
|
|
452
|
-
},
|
|
453
|
-
options
|
|
454
|
-
);
|
|
461
|
+
return this.httpClient.put("/usage/quota", params, options);
|
|
455
462
|
}
|
|
463
|
+
/** 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. */
|
|
456
464
|
async remove(params, options) {
|
|
457
|
-
return this.httpClient.delete(
|
|
458
|
-
"/usage/quota",
|
|
459
|
-
{
|
|
460
|
-
customerId: params.customerId,
|
|
461
|
-
featureCode: params.featureCode,
|
|
462
|
-
count: params.count ?? 1
|
|
463
|
-
},
|
|
464
|
-
options
|
|
465
|
-
);
|
|
465
|
+
return this.httpClient.delete("/usage/quota", params, options);
|
|
466
466
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
featureCode: params.featureCode
|
|
471
|
-
});
|
|
467
|
+
/** Get the current quota allowance (used vs included) for a specific feature. */
|
|
468
|
+
async get(params, options) {
|
|
469
|
+
return this.httpClient.get("/usage/quota", params, options);
|
|
472
470
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
});
|
|
471
|
+
/** Get all quota allowances for a customer across every quota feature in their plan. */
|
|
472
|
+
async getAll(params, options) {
|
|
473
|
+
return this.httpClient.get("/usage/quota/all", params, options);
|
|
477
474
|
}
|
|
478
475
|
};
|
|
479
476
|
|
|
@@ -482,54 +479,29 @@ var SeatsResource = class {
|
|
|
482
479
|
constructor(httpClient) {
|
|
483
480
|
this.httpClient = httpClient;
|
|
484
481
|
}
|
|
485
|
-
/** Prorates charges for the current billing period. */
|
|
482
|
+
/** Add seats to a customer's subscription. Prorates charges for the current billing period. */
|
|
486
483
|
async add(params, options) {
|
|
487
|
-
return this.httpClient.post(
|
|
488
|
-
"/seats",
|
|
489
|
-
{
|
|
490
|
-
customerId: params.customerId,
|
|
491
|
-
featureCode: params.featureCode,
|
|
492
|
-
count: params.count ?? 1
|
|
493
|
-
},
|
|
494
|
-
options
|
|
495
|
-
);
|
|
496
|
-
}
|
|
497
|
-
/** Removal takes effect at the end of the billing period. */
|
|
498
|
-
async remove(params, options) {
|
|
499
|
-
return this.httpClient.delete(
|
|
500
|
-
"/seats",
|
|
501
|
-
{
|
|
502
|
-
customerId: params.customerId,
|
|
503
|
-
featureCode: params.featureCode,
|
|
504
|
-
count: params.count ?? 1
|
|
505
|
-
},
|
|
506
|
-
options
|
|
507
|
-
);
|
|
484
|
+
return this.httpClient.post("/seats", params, options);
|
|
508
485
|
}
|
|
486
|
+
/** Set seats to an exact count. */
|
|
509
487
|
async set(params, options) {
|
|
510
|
-
return this.httpClient.put(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
count: params.count
|
|
516
|
-
},
|
|
517
|
-
options
|
|
518
|
-
);
|
|
488
|
+
return this.httpClient.put("/seats", params, options);
|
|
489
|
+
}
|
|
490
|
+
/** Remove seats from a customer's subscription. Takes effect at the end of the billing period. */
|
|
491
|
+
async remove(params, options) {
|
|
492
|
+
return this.httpClient.delete("/seats", params, options);
|
|
519
493
|
}
|
|
494
|
+
/** Set all seat types at once. */
|
|
520
495
|
async setAll(params, options) {
|
|
521
496
|
return this.httpClient.put("/seats/bulk", params, options);
|
|
522
497
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
featureCode: params.featureCode
|
|
527
|
-
});
|
|
498
|
+
/** Get current balance for a specific seat type. */
|
|
499
|
+
async getBalance(params, options) {
|
|
500
|
+
return this.httpClient.get("/seats/balance", params, options);
|
|
528
501
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
});
|
|
502
|
+
/** Get the current balance for all seat types in a customer's subscription. */
|
|
503
|
+
async getAllBalances(params, options) {
|
|
504
|
+
return this.httpClient.get("/seats/balances", params, options);
|
|
533
505
|
}
|
|
534
506
|
};
|
|
535
507
|
|
|
@@ -538,54 +510,57 @@ var SubscriptionsResource = class {
|
|
|
538
510
|
constructor(httpClient) {
|
|
539
511
|
this.httpClient = httpClient;
|
|
540
512
|
}
|
|
541
|
-
/**
|
|
513
|
+
/** List all subscriptions. Filter by customer ID or status. */
|
|
514
|
+
async list(params, options) {
|
|
515
|
+
return this.httpClient.get("/subscriptions", params, options);
|
|
516
|
+
}
|
|
517
|
+
/** Create a subscription for a customer. Requires planId or planCode plus customerId. */
|
|
542
518
|
async create(params, options) {
|
|
543
519
|
return this.httpClient.post("/subscriptions", params, options);
|
|
544
520
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
});
|
|
521
|
+
/** Get a subscription by its public ID, regardless of status (including pending_payment and past_due). */
|
|
522
|
+
async get(params, options) {
|
|
523
|
+
const { id } = params;
|
|
524
|
+
return this.httpClient.get(`/subscriptions/${id}`, void 0, options);
|
|
525
|
+
}
|
|
526
|
+
/** Get the active subscription for a customer. Returns null if none. */
|
|
527
|
+
async getActive(params, options) {
|
|
528
|
+
return this.httpClient.get("/subscriptions/active", params, options);
|
|
549
529
|
}
|
|
550
|
-
/**
|
|
530
|
+
/** Cancel immediately or at period end. */
|
|
551
531
|
async cancel(params, options) {
|
|
552
|
-
const { id, ...
|
|
553
|
-
return this.httpClient.post(`/subscriptions/${id}/cancel`,
|
|
532
|
+
const { id, ...rest } = params;
|
|
533
|
+
return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);
|
|
554
534
|
}
|
|
555
|
-
/** Only works
|
|
535
|
+
/** Revert a scheduled cancellation. Only works when canceledAt is set but status is not yet 'canceled'. */
|
|
556
536
|
async uncancel(params, options) {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
{},
|
|
560
|
-
options
|
|
561
|
-
);
|
|
537
|
+
const { id } = params;
|
|
538
|
+
return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);
|
|
562
539
|
}
|
|
563
|
-
/**
|
|
540
|
+
/** Upgrade, downgrade, or change billing interval. */
|
|
564
541
|
async changePlan(params, options) {
|
|
565
|
-
const { id, ...
|
|
542
|
+
const { id, ...rest } = params;
|
|
566
543
|
return this.httpClient.post(
|
|
567
544
|
`/subscriptions/${id}/change-plan`,
|
|
568
|
-
|
|
545
|
+
rest,
|
|
569
546
|
options
|
|
570
547
|
);
|
|
571
548
|
}
|
|
572
|
-
|
|
573
|
-
return this.httpClient.get("/subscriptions", params);
|
|
574
|
-
}
|
|
575
|
-
/** Dry-run: returns proration details without applying the change. */
|
|
549
|
+
/** 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. */
|
|
576
550
|
async previewChange(params, options) {
|
|
577
|
-
const { id, ...
|
|
551
|
+
const { id, ...rest } = params;
|
|
578
552
|
return this.httpClient.post(
|
|
579
553
|
`/subscriptions/${id}/preview-change`,
|
|
580
|
-
|
|
554
|
+
rest,
|
|
581
555
|
options
|
|
582
556
|
);
|
|
583
557
|
}
|
|
584
|
-
/**
|
|
558
|
+
/** Activate an add-on on a subscription. Charges a prorated amount for the current billing period. */
|
|
585
559
|
async activateAddon(params, options) {
|
|
586
|
-
const { id, ...
|
|
587
|
-
return this.httpClient.post(`/subscriptions/${id}/addons`,
|
|
560
|
+
const { id, ...rest } = params;
|
|
561
|
+
return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);
|
|
588
562
|
}
|
|
563
|
+
/** Deactivate an add-on from a subscription. */
|
|
589
564
|
async deactivateAddon(params, options) {
|
|
590
565
|
const { id, addonId } = params;
|
|
591
566
|
return this.httpClient.delete(
|
|
@@ -594,27 +569,47 @@ var SubscriptionsResource = class {
|
|
|
594
569
|
options
|
|
595
570
|
);
|
|
596
571
|
}
|
|
597
|
-
/**
|
|
572
|
+
/** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */
|
|
598
573
|
async adjustBalance(params, options) {
|
|
599
|
-
const { id, ...
|
|
574
|
+
const { id, ...rest } = params;
|
|
600
575
|
return this.httpClient.post(
|
|
601
576
|
`/subscriptions/${id}/balance/adjust`,
|
|
602
|
-
|
|
577
|
+
rest,
|
|
603
578
|
options
|
|
604
579
|
);
|
|
605
580
|
}
|
|
606
|
-
/** Charges the customer's payment method. */
|
|
581
|
+
/** Top up a subscription's balance. Charges the customer's payment method for the specified amount. */
|
|
607
582
|
async topupBalance(params, options) {
|
|
608
|
-
const { id, ...
|
|
583
|
+
const { id, ...rest } = params;
|
|
609
584
|
return this.httpClient.post(
|
|
610
585
|
`/subscriptions/${id}/balance/topup`,
|
|
611
|
-
|
|
586
|
+
rest,
|
|
612
587
|
options
|
|
613
588
|
);
|
|
614
589
|
}
|
|
590
|
+
/** Purchase a credit pack for a subscription. Charges the customer and adds credits to their balance. */
|
|
615
591
|
async purchaseCredits(params, options) {
|
|
616
|
-
const { id, ...
|
|
617
|
-
return this.httpClient.post(`/subscriptions/${id}/credits`,
|
|
592
|
+
const { id, ...rest } = params;
|
|
593
|
+
return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// src/resources/test-clock.ts
|
|
598
|
+
var TestClockResource = class {
|
|
599
|
+
constructor(httpClient) {
|
|
600
|
+
this.httpClient = httpClient;
|
|
601
|
+
}
|
|
602
|
+
/** Returns the organization's current test clock state. Sandbox only. */
|
|
603
|
+
async get() {
|
|
604
|
+
return this.httpClient.get("/test-clock");
|
|
605
|
+
}
|
|
606
|
+
/** 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. */
|
|
607
|
+
async advance(params, options) {
|
|
608
|
+
return this.httpClient.post("/test-clock", params, options);
|
|
609
|
+
}
|
|
610
|
+
/** 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. */
|
|
611
|
+
async processBilling() {
|
|
612
|
+
return this.httpClient.post("/test-clock/process-billing", {});
|
|
618
613
|
}
|
|
619
614
|
};
|
|
620
615
|
|
|
@@ -623,27 +618,46 @@ var TransactionsResource = class {
|
|
|
623
618
|
constructor(httpClient) {
|
|
624
619
|
this.httpClient = httpClient;
|
|
625
620
|
}
|
|
626
|
-
|
|
627
|
-
|
|
621
|
+
/** List payment transactions with cursor-based pagination. Filter by status or customer email. */
|
|
622
|
+
async list(params, options) {
|
|
623
|
+
return this.httpClient.get("/transactions", params, options);
|
|
628
624
|
}
|
|
629
|
-
|
|
630
|
-
|
|
625
|
+
/** Retrieve a single payment transaction by its public ID, including provider details. */
|
|
626
|
+
async get(params, options) {
|
|
627
|
+
const { id } = params;
|
|
628
|
+
return this.httpClient.get(`/transactions/${id}`, void 0, options);
|
|
631
629
|
}
|
|
632
|
-
/**
|
|
630
|
+
/** Issue a full refund for a payment transaction. */
|
|
633
631
|
async refund(params, options) {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
{},
|
|
637
|
-
options
|
|
638
|
-
);
|
|
632
|
+
const { id } = params;
|
|
633
|
+
return this.httpClient.post(`/transactions/${id}/refund`, {}, options);
|
|
639
634
|
}
|
|
640
|
-
/** Creates a new invoice and initiates a new payment attempt. */
|
|
635
|
+
/** Retry a failed payment transaction. Creates a new invoice and initiates a new payment attempt. */
|
|
641
636
|
async retry(params, options) {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
637
|
+
const { id } = params;
|
|
638
|
+
return this.httpClient.post(`/transactions/${id}/retry`, {}, options);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
// src/_generated_resources.ts
|
|
643
|
+
var GeneratedResources = class {
|
|
644
|
+
initResources(http) {
|
|
645
|
+
this.addons = new AddonsResource(http);
|
|
646
|
+
this.apiKeys = new ApiKeysResource(http);
|
|
647
|
+
this.creditPacks = new CreditPacksResource(http);
|
|
648
|
+
this.customers = new CustomersResource(http);
|
|
649
|
+
this.features = new FeaturesResource(http);
|
|
650
|
+
this.invoices = new InvoicesResource(http);
|
|
651
|
+
this.payouts = new PayoutsResource(http);
|
|
652
|
+
this.planGroups = new PlanGroupsResource(http);
|
|
653
|
+
this.plans = new PlansResource(http);
|
|
654
|
+
this.portal = new PortalResource(http);
|
|
655
|
+
this.promoCodes = new PromoCodesResource(http);
|
|
656
|
+
this.quota = new QuotaResource(http);
|
|
657
|
+
this.seats = new SeatsResource(http);
|
|
658
|
+
this.subscriptions = new SubscriptionsResource(http);
|
|
659
|
+
this.testClock = new TestClockResource(http);
|
|
660
|
+
this.transactions = new TransactionsResource(http);
|
|
647
661
|
}
|
|
648
662
|
};
|
|
649
663
|
|
|
@@ -778,8 +792,8 @@ var CommetValidationError = class extends CommetError {
|
|
|
778
792
|
};
|
|
779
793
|
|
|
780
794
|
// src/version.ts
|
|
781
|
-
var API_VERSION = "2026-
|
|
782
|
-
var SDK_VERSION = "
|
|
795
|
+
var API_VERSION = "2026-06-07";
|
|
796
|
+
var SDK_VERSION = "6.0.0";
|
|
783
797
|
|
|
784
798
|
// src/utils/telemetry.ts
|
|
785
799
|
var registeredIntegrations = /* @__PURE__ */ new Set();
|
|
@@ -1087,8 +1101,9 @@ _CommetHTTPClient.BODY_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"
|
|
|
1087
1101
|
var CommetHTTPClient = _CommetHTTPClient;
|
|
1088
1102
|
|
|
1089
1103
|
// src/client.ts
|
|
1090
|
-
var Commet = class {
|
|
1104
|
+
var Commet = class extends GeneratedResources {
|
|
1091
1105
|
constructor(config) {
|
|
1106
|
+
super();
|
|
1092
1107
|
if (!config.apiKey) {
|
|
1093
1108
|
throw new Error("Commet SDK: API key is required");
|
|
1094
1109
|
}
|
|
@@ -1098,20 +1113,7 @@ var Commet = class {
|
|
|
1098
1113
|
);
|
|
1099
1114
|
}
|
|
1100
1115
|
this.httpClient = new CommetHTTPClient(config);
|
|
1101
|
-
this.
|
|
1102
|
-
this.apiKeys = new ApiKeysResource(this.httpClient);
|
|
1103
|
-
this.creditPacks = new CreditPacksResource(this.httpClient);
|
|
1104
|
-
this.customers = new CustomersResource(this.httpClient);
|
|
1105
|
-
this.features = new FeaturesResource(this.httpClient);
|
|
1106
|
-
this.invoices = new InvoicesResource(this.httpClient);
|
|
1107
|
-
this.planGroups = new PlanGroupsResource(this.httpClient);
|
|
1108
|
-
this.plans = new PlansResource(this.httpClient);
|
|
1109
|
-
this.portal = new PortalResource(this.httpClient);
|
|
1110
|
-
this.promoCodes = new PromoCodesResource(this.httpClient);
|
|
1111
|
-
this.quota = new QuotaResource(this.httpClient);
|
|
1112
|
-
this.seats = new SeatsResource(this.httpClient);
|
|
1113
|
-
this.subscriptions = new SubscriptionsResource(this.httpClient);
|
|
1114
|
-
this.transactions = new TransactionsResource(this.httpClient);
|
|
1116
|
+
this.initResources(this.httpClient);
|
|
1115
1117
|
this.usage = new UsageResource(this.httpClient);
|
|
1116
1118
|
this.webhooks = new Webhooks(this.httpClient);
|
|
1117
1119
|
}
|