@commet/node 7.10.0 → 8.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/README.md +3 -3
- package/dist/index.d.mts +2029 -940
- package/dist/index.d.ts +2029 -940
- package/dist/index.js +396 -342
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +396 -342
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53,29 +53,29 @@ var AddonsResource = class {
|
|
|
53
53
|
async listActive(params, options) {
|
|
54
54
|
return this.httpClient.get("/active-addons", params, options);
|
|
55
55
|
}
|
|
56
|
-
/** List all add-ons with cursor-based pagination. */
|
|
57
|
-
async list(params, options) {
|
|
58
|
-
return this.httpClient.get("/addons", params, options);
|
|
59
|
-
}
|
|
60
56
|
/** Retrieve an add-on by its public ID or slug. */
|
|
61
57
|
async get(params, options) {
|
|
62
58
|
const { id } = params;
|
|
63
59
|
return this.httpClient.get(`/addons/${id}`, void 0, options);
|
|
64
60
|
}
|
|
65
|
-
/** Create a new add-on linked to a feature. Each feature can only be assigned to one add-on. */
|
|
66
|
-
async create(params, options) {
|
|
67
|
-
return this.httpClient.post("/addons", params, options);
|
|
68
|
-
}
|
|
69
61
|
/** Update an add-on's name, description, or pricing. */
|
|
70
62
|
async update(params, options) {
|
|
71
63
|
const { id, ...rest } = params;
|
|
72
|
-
return this.httpClient.
|
|
64
|
+
return this.httpClient.patch(`/addons/${id}`, rest, options);
|
|
73
65
|
}
|
|
74
66
|
/** Soft-delete an add-on. Fails if the add-on has active subscriptions. */
|
|
75
67
|
async delete(params, options) {
|
|
76
68
|
const { id } = params;
|
|
77
69
|
return this.httpClient.delete(`/addons/${id}`, void 0, options);
|
|
78
70
|
}
|
|
71
|
+
/** List all add-ons with cursor-based pagination. */
|
|
72
|
+
async list(params, options) {
|
|
73
|
+
return this.httpClient.get("/addons", params, options);
|
|
74
|
+
}
|
|
75
|
+
/** Create a new add-on linked to a feature. Each feature can only be assigned to one add-on. */
|
|
76
|
+
async create(params, options) {
|
|
77
|
+
return this.httpClient.post("/addons", params, options);
|
|
78
|
+
}
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
// src/resources/api-keys.ts
|
|
@@ -83,6 +83,11 @@ var ApiKeysResource = class {
|
|
|
83
83
|
constructor(httpClient) {
|
|
84
84
|
this.httpClient = httpClient;
|
|
85
85
|
}
|
|
86
|
+
/** Permanently revoke and delete an API key. */
|
|
87
|
+
async delete(params, options) {
|
|
88
|
+
const { id } = params;
|
|
89
|
+
return this.httpClient.delete(`/api-keys/${id}`, void 0, options);
|
|
90
|
+
}
|
|
86
91
|
/** List API keys with cursor-based pagination. Keys are returned without the full secret. */
|
|
87
92
|
async list(params, options) {
|
|
88
93
|
return this.httpClient.get("/api-keys", params, options);
|
|
@@ -91,11 +96,6 @@ var ApiKeysResource = class {
|
|
|
91
96
|
async create(params, options) {
|
|
92
97
|
return this.httpClient.post("/api-keys", params, options);
|
|
93
98
|
}
|
|
94
|
-
/** Permanently revoke and delete an API key. */
|
|
95
|
-
async delete(params, options) {
|
|
96
|
-
const { id } = params;
|
|
97
|
-
return this.httpClient.delete(`/api-keys/${id}`, void 0, options);
|
|
98
|
-
}
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
// src/resources/credit-packs.ts
|
|
@@ -103,24 +103,24 @@ var CreditPacksResource = class {
|
|
|
103
103
|
constructor(httpClient) {
|
|
104
104
|
this.httpClient = httpClient;
|
|
105
105
|
}
|
|
106
|
-
/** List all active credit packs. */
|
|
107
|
-
async list() {
|
|
108
|
-
return this.httpClient.get("/credit-packs");
|
|
109
|
-
}
|
|
110
|
-
/** Create a new credit pack. */
|
|
111
|
-
async create(params, options) {
|
|
112
|
-
return this.httpClient.post("/credit-packs/manage", params, options);
|
|
113
|
-
}
|
|
114
106
|
/** Update a credit pack's name, description, credits, price, or active status. */
|
|
115
107
|
async update(params, options) {
|
|
116
108
|
const { id, ...rest } = params;
|
|
117
|
-
return this.httpClient.
|
|
109
|
+
return this.httpClient.patch(`/credit-packs/${id}`, rest, options);
|
|
118
110
|
}
|
|
119
111
|
/** Soft-delete a credit pack. */
|
|
120
112
|
async delete(params, options) {
|
|
121
113
|
const { id } = params;
|
|
122
114
|
return this.httpClient.delete(`/credit-packs/${id}`, void 0, options);
|
|
123
115
|
}
|
|
116
|
+
/** List all active credit packs. */
|
|
117
|
+
async list() {
|
|
118
|
+
return this.httpClient.get("/credit-packs");
|
|
119
|
+
}
|
|
120
|
+
/** Create a new credit pack. */
|
|
121
|
+
async create(params, options) {
|
|
122
|
+
return this.httpClient.post("/credit-packs", params, options);
|
|
123
|
+
}
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
// src/resources/customers.ts
|
|
@@ -128,14 +128,6 @@ var CustomersResource = class {
|
|
|
128
128
|
constructor(httpClient) {
|
|
129
129
|
this.httpClient = httpClient;
|
|
130
130
|
}
|
|
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. */
|
|
136
|
-
async create(params, options) {
|
|
137
|
-
return this.httpClient.post("/customers", params, options);
|
|
138
|
-
}
|
|
139
131
|
/** Retrieve a customer by their public ID, including subscription status and metadata. */
|
|
140
132
|
async get(params, options) {
|
|
141
133
|
const { id } = params;
|
|
@@ -144,12 +136,20 @@ var CustomersResource = class {
|
|
|
144
136
|
/** Update a customer's name, external ID, or metadata. */
|
|
145
137
|
async update(params, options) {
|
|
146
138
|
const { id, ...rest } = params;
|
|
147
|
-
return this.httpClient.
|
|
139
|
+
return this.httpClient.patch(`/customers/${id}`, rest, options);
|
|
148
140
|
}
|
|
149
141
|
/** Create up to 100 customers in a single request. */
|
|
150
142
|
async createBatch(params, options) {
|
|
151
143
|
return this.httpClient.post("/customers/batch", params, options);
|
|
152
144
|
}
|
|
145
|
+
/** List customers with cursor-based pagination. */
|
|
146
|
+
async list(params, options) {
|
|
147
|
+
return this.httpClient.get("/customers", params, options);
|
|
148
|
+
}
|
|
149
|
+
/** Create a new customer. Idempotent when customerId is provided. */
|
|
150
|
+
async create(params, options) {
|
|
151
|
+
return this.httpClient.post("/customers", params, options);
|
|
152
|
+
}
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
// src/resources/feature-access.ts
|
|
@@ -157,23 +157,14 @@ var FeatureAccessResource = class {
|
|
|
157
157
|
constructor(httpClient) {
|
|
158
158
|
this.httpClient = httpClient;
|
|
159
159
|
}
|
|
160
|
-
/**
|
|
161
|
-
async list(params, options) {
|
|
162
|
-
return this.httpClient.get("/feature-access", params, options);
|
|
163
|
-
}
|
|
164
|
-
/** Get feature access details for a customer. Use action=canUse to check if the customer can consume one more unit. */
|
|
160
|
+
/** Get one feature's access and current usage for a customer. To evaluate a prospective consumption, use POST /usage/check. */
|
|
165
161
|
async get(params, options) {
|
|
166
162
|
const { code, ...rest } = params;
|
|
167
163
|
return this.httpClient.get(`/feature-access/${code}`, rest, options);
|
|
168
164
|
}
|
|
169
|
-
/**
|
|
170
|
-
async
|
|
171
|
-
|
|
172
|
-
return this.httpClient.get(
|
|
173
|
-
`/feature-access/${code}`,
|
|
174
|
-
{ ...rest, action: "canUse" },
|
|
175
|
-
options
|
|
176
|
-
);
|
|
165
|
+
/** List a customer's feature access and current usage. */
|
|
166
|
+
async list(params, options) {
|
|
167
|
+
return this.httpClient.get("/feature-access", params, options);
|
|
177
168
|
}
|
|
178
169
|
};
|
|
179
170
|
|
|
@@ -182,32 +173,28 @@ var FeaturesResource = class {
|
|
|
182
173
|
constructor(httpClient) {
|
|
183
174
|
this.httpClient = httpClient;
|
|
184
175
|
}
|
|
185
|
-
/** List every feature defined in the organization. This is the organization's feature catalog (definitions), not a customer's feature access. */
|
|
186
|
-
async list() {
|
|
187
|
-
return this.httpClient.get("/features");
|
|
188
|
-
}
|
|
189
176
|
/** Get a single feature definition by code from the organization's feature catalog. */
|
|
190
177
|
async get(params, options) {
|
|
191
178
|
const { code } = params;
|
|
192
179
|
return this.httpClient.get(`/features/${code}`, void 0, options);
|
|
193
180
|
}
|
|
194
|
-
/** Create a new feature. Code must be lowercase alphanumeric with underscores. */
|
|
195
|
-
async create(params, options) {
|
|
196
|
-
return this.httpClient.post("/features/manage", params, options);
|
|
197
|
-
}
|
|
198
181
|
/** Update a feature's name, description, or unit name. At least one field must be provided. */
|
|
199
182
|
async update(params, options) {
|
|
200
183
|
const { code, ...rest } = params;
|
|
201
|
-
return this.httpClient.
|
|
184
|
+
return this.httpClient.patch(`/features/${code}`, rest, options);
|
|
202
185
|
}
|
|
203
186
|
/** Delete a feature. Fails if the feature is attached to active plans or has an active add-on. */
|
|
204
187
|
async delete(params, options) {
|
|
205
188
|
const { code } = params;
|
|
206
|
-
return this.httpClient.delete(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
);
|
|
189
|
+
return this.httpClient.delete(`/features/${code}`, void 0, options);
|
|
190
|
+
}
|
|
191
|
+
/** List every feature defined in the organization. This is the organization's feature catalog (definitions), not a customer's feature access. */
|
|
192
|
+
async list() {
|
|
193
|
+
return this.httpClient.get("/features");
|
|
194
|
+
}
|
|
195
|
+
/** Create a new feature. Code must be lowercase alphanumeric with underscores. */
|
|
196
|
+
async create(params, options) {
|
|
197
|
+
return this.httpClient.post("/features", params, options);
|
|
211
198
|
}
|
|
212
199
|
};
|
|
213
200
|
|
|
@@ -216,62 +203,92 @@ var InvoicesResource = class {
|
|
|
216
203
|
constructor(httpClient) {
|
|
217
204
|
this.httpClient = httpClient;
|
|
218
205
|
}
|
|
219
|
-
/**
|
|
220
|
-
async
|
|
221
|
-
|
|
206
|
+
/** Generate a signed URL to download the invoice as a PDF. The URL expires after 7 days. */
|
|
207
|
+
async getDownloadUrl(params, options) {
|
|
208
|
+
const { id } = params;
|
|
209
|
+
return this.httpClient.post(`/invoices/${id}/download-links`, {}, options);
|
|
222
210
|
}
|
|
223
211
|
/** Retrieve a single invoice by its public ID, including line items. */
|
|
224
212
|
async get(params, options) {
|
|
225
213
|
const { id } = params;
|
|
226
214
|
return this.httpClient.get(`/invoices/${id}`, void 0, options);
|
|
227
215
|
}
|
|
228
|
-
/** Create a one-off adjustment invoice. Use a negative amount for a credit. */
|
|
229
|
-
async createAdjustment(params, options) {
|
|
230
|
-
return this.httpClient.post("/invoices", params, options);
|
|
231
|
-
}
|
|
232
|
-
/** Generate a signed URL to download the invoice as a PDF. The URL expires after 7 days. */
|
|
233
|
-
async getDownloadUrl(params, options) {
|
|
234
|
-
const { id } = params;
|
|
235
|
-
return this.httpClient.get(`/invoices/${id}/download`, void 0, options);
|
|
236
|
-
}
|
|
237
216
|
/** Send the invoice to the customer via email. */
|
|
238
217
|
async send(params, options) {
|
|
239
218
|
const { id } = params;
|
|
240
219
|
return this.httpClient.post(`/invoices/${id}/send`, {}, options);
|
|
241
220
|
}
|
|
242
|
-
/** Mark an outstanding invoice as "paid" or "void". Cannot change the status of already paid or voided invoices. */
|
|
221
|
+
/** Mark an outstanding invoice as "paid" or "void" and return the updated invoice. Cannot change the status of already paid or voided invoices. */
|
|
243
222
|
async updateStatus(params, options) {
|
|
244
223
|
const { id, ...rest } = params;
|
|
245
|
-
return this.httpClient.
|
|
224
|
+
return this.httpClient.patch(`/invoices/${id}/status`, rest, options);
|
|
225
|
+
}
|
|
226
|
+
/** List invoices with cursor-based pagination. Filter by customer, status, or subscription. */
|
|
227
|
+
async list(params, options) {
|
|
228
|
+
return this.httpClient.get("/invoices", params, options);
|
|
229
|
+
}
|
|
230
|
+
/** Create a one-off adjustment invoice and return the created invoice. Use a negative amount for a credit. */
|
|
231
|
+
async createAdjustment(params, options) {
|
|
232
|
+
return this.httpClient.post("/invoices", params, options);
|
|
246
233
|
}
|
|
247
234
|
};
|
|
248
235
|
|
|
249
|
-
// src/resources/
|
|
250
|
-
var
|
|
236
|
+
// src/resources/offers.ts
|
|
237
|
+
var OffersResource = class {
|
|
251
238
|
constructor(httpClient) {
|
|
252
239
|
this.httpClient = httpClient;
|
|
253
240
|
}
|
|
254
|
-
/**
|
|
241
|
+
/** Retrieve a canonical offer by its public ID. */
|
|
242
|
+
async get(params, options) {
|
|
243
|
+
const { id } = params;
|
|
244
|
+
return this.httpClient.get(`/offers/${id}`, void 0, options);
|
|
245
|
+
}
|
|
246
|
+
/** Replace an offer's catalog definition. Existing offer applications keep their immutable accepted terms. */
|
|
247
|
+
async update(params, options) {
|
|
248
|
+
const { id, ...rest } = params;
|
|
249
|
+
return this.httpClient.patch(`/offers/${id}`, rest, options);
|
|
250
|
+
}
|
|
251
|
+
/** Soft-delete an offer. Existing applications and their accepted terms remain available for billing and audit. */
|
|
252
|
+
async delete(params, options) {
|
|
253
|
+
const { id } = params;
|
|
254
|
+
return this.httpClient.delete(`/offers/${id}`, void 0, options);
|
|
255
|
+
}
|
|
256
|
+
/** List the organization's canonical introductory and promotional offers. */
|
|
255
257
|
async list(params, options) {
|
|
256
|
-
return this.httpClient.get("/
|
|
258
|
+
return this.httpClient.get("/offers", params, options);
|
|
257
259
|
}
|
|
258
|
-
/** Create a
|
|
260
|
+
/** Create a canonical offer scoped to one or more plan prices. Currency-specific phases require an explicit USD value and never fall back across currencies. */
|
|
259
261
|
async create(params, options) {
|
|
260
|
-
return this.httpClient.post("/
|
|
262
|
+
return this.httpClient.post("/offers", params, options);
|
|
261
263
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// src/resources/payments.ts
|
|
267
|
+
var PaymentsResource = class {
|
|
268
|
+
constructor(httpClient) {
|
|
269
|
+
this.httpClient = httpClient;
|
|
270
|
+
}
|
|
271
|
+
/** Cancel a pending payment link so it can no longer be paid. Only a link that has not been paid or started processing can be canceled; canceling an already canceled link is a no-op. Charges cannot be canceled. */
|
|
272
|
+
async cancel(params, options) {
|
|
273
|
+
const { id } = params;
|
|
274
|
+
return this.httpClient.post(`/payments/${id}/cancel`, {}, options);
|
|
265
275
|
}
|
|
266
276
|
/** Retrieve a payment by its public ID. */
|
|
267
277
|
async get(params, options) {
|
|
268
278
|
const { id } = params;
|
|
269
279
|
return this.httpClient.get(`/payments/${id}`, void 0, options);
|
|
270
280
|
}
|
|
271
|
-
/**
|
|
272
|
-
async
|
|
273
|
-
|
|
274
|
-
|
|
281
|
+
/** Charge a customer's vaulted payment method off-session. Calculates tax, generates an invoice, and sends a receipt. Requires the customer to have a subscription in active, trialing, or past_due state. */
|
|
282
|
+
async charge(params, options) {
|
|
283
|
+
return this.httpClient.post("/payments/charge", params, options);
|
|
284
|
+
}
|
|
285
|
+
/** List payments with cursor-based pagination. Filter by customer. */
|
|
286
|
+
async list(params, options) {
|
|
287
|
+
return this.httpClient.get("/payments", params, options);
|
|
288
|
+
}
|
|
289
|
+
/** Create a hosted payment link. Returns a url the customer opens to pay with any card. Calculates tax, generates an invoice, and vaults the payment method on confirmation. No subscription or plan required. */
|
|
290
|
+
async create(params, options) {
|
|
291
|
+
return this.httpClient.post("/payments", params, options);
|
|
275
292
|
}
|
|
276
293
|
};
|
|
277
294
|
|
|
@@ -299,34 +316,6 @@ var PlanGroupsResource = class {
|
|
|
299
316
|
constructor(httpClient) {
|
|
300
317
|
this.httpClient = httpClient;
|
|
301
318
|
}
|
|
302
|
-
/** List plan groups with cursor-based pagination. */
|
|
303
|
-
async list(params, options) {
|
|
304
|
-
return this.httpClient.get("/plan-groups", params, options);
|
|
305
|
-
}
|
|
306
|
-
/** Retrieve a plan group by ID, including its plans ordered by sortOrder. */
|
|
307
|
-
async get(params, options) {
|
|
308
|
-
const { id } = params;
|
|
309
|
-
return this.httpClient.get(`/plan-groups/${id}`, void 0, options);
|
|
310
|
-
}
|
|
311
|
-
/** Create a new plan group for organizing plans. */
|
|
312
|
-
async create(params, options) {
|
|
313
|
-
return this.httpClient.post("/plan-groups", params, options);
|
|
314
|
-
}
|
|
315
|
-
/** Update a plan group's name, description, or visibility. */
|
|
316
|
-
async update(params, options) {
|
|
317
|
-
const { id, ...rest } = params;
|
|
318
|
-
return this.httpClient.put(`/plan-groups/${id}`, rest, options);
|
|
319
|
-
}
|
|
320
|
-
/** Delete a plan group. Plans in the group are unlinked, not deleted. */
|
|
321
|
-
async delete(params, options) {
|
|
322
|
-
const { id } = params;
|
|
323
|
-
return this.httpClient.delete(`/plan-groups/${id}`, void 0, options);
|
|
324
|
-
}
|
|
325
|
-
/** Add an existing plan to a plan group with optional sort order. */
|
|
326
|
-
async addPlan(params, options) {
|
|
327
|
-
const { id, ...rest } = params;
|
|
328
|
-
return this.httpClient.post(`/plan-groups/${id}/plans`, rest, options);
|
|
329
|
-
}
|
|
330
319
|
/** Remove a plan from a plan group. */
|
|
331
320
|
async removePlan(params, options) {
|
|
332
321
|
const { id, planId } = params;
|
|
@@ -345,50 +334,45 @@ var PlanGroupsResource = class {
|
|
|
345
334
|
options
|
|
346
335
|
);
|
|
347
336
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
constructor(httpClient) {
|
|
353
|
-
this.httpClient = httpClient;
|
|
354
|
-
}
|
|
355
|
-
/** List all plans with their prices and features. Optionally include private plans. */
|
|
356
|
-
async list(params, options) {
|
|
357
|
-
return this.httpClient.get("/plans", params, options);
|
|
337
|
+
/** Add an existing plan to a plan group with optional sort order. */
|
|
338
|
+
async addPlan(params, options) {
|
|
339
|
+
const { id, ...rest } = params;
|
|
340
|
+
return this.httpClient.post(`/plan-groups/${id}/plans`, rest, options);
|
|
358
341
|
}
|
|
359
|
-
/**
|
|
342
|
+
/** Retrieve a plan group by ID, including its plans ordered by sortOrder. */
|
|
360
343
|
async get(params, options) {
|
|
361
344
|
const { id } = params;
|
|
362
|
-
return this.httpClient.get(`/
|
|
363
|
-
}
|
|
364
|
-
/** Create a new plan with optional consumption model, visibility, and plan group assignment. */
|
|
365
|
-
async create(params, options) {
|
|
366
|
-
return this.httpClient.post("/plans/manage", params, options);
|
|
345
|
+
return this.httpClient.get(`/plan-groups/${id}`, void 0, options);
|
|
367
346
|
}
|
|
368
|
-
/** Update a plan's name, description,
|
|
347
|
+
/** Update a plan group's name, description, or visibility. */
|
|
369
348
|
async update(params, options) {
|
|
370
349
|
const { id, ...rest } = params;
|
|
371
|
-
return this.httpClient.
|
|
350
|
+
return this.httpClient.patch(`/plan-groups/${id}`, rest, options);
|
|
372
351
|
}
|
|
373
|
-
/**
|
|
352
|
+
/** Delete a plan group. Plans in the group are unlinked, not deleted. */
|
|
374
353
|
async delete(params, options) {
|
|
375
354
|
const { id } = params;
|
|
376
|
-
return this.httpClient.delete(`/
|
|
355
|
+
return this.httpClient.delete(`/plan-groups/${id}`, void 0, options);
|
|
377
356
|
}
|
|
378
|
-
/**
|
|
379
|
-
async
|
|
380
|
-
|
|
381
|
-
return this.httpClient.put(`/plans/${id}/visibility`, rest, options);
|
|
357
|
+
/** List plan groups with cursor-based pagination. */
|
|
358
|
+
async list(params, options) {
|
|
359
|
+
return this.httpClient.get("/plan-groups", params, options);
|
|
382
360
|
}
|
|
383
|
-
/**
|
|
384
|
-
async
|
|
385
|
-
|
|
386
|
-
|
|
361
|
+
/** Create a new plan group for organizing plans. */
|
|
362
|
+
async create(params, options) {
|
|
363
|
+
return this.httpClient.post("/plan-groups", params, options);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// src/resources/plans.ts
|
|
368
|
+
var PlansResource = class {
|
|
369
|
+
constructor(httpClient) {
|
|
370
|
+
this.httpClient = httpClient;
|
|
387
371
|
}
|
|
388
372
|
/** Update limits, overage, or enabled status of a feature on a plan. */
|
|
389
373
|
async updateFeature(params, options) {
|
|
390
374
|
const { id, featureId, ...rest } = params;
|
|
391
|
-
return this.httpClient.
|
|
375
|
+
return this.httpClient.patch(
|
|
392
376
|
`/plans/${id}/features/${featureId}`,
|
|
393
377
|
rest,
|
|
394
378
|
options
|
|
@@ -403,26 +387,12 @@ var PlansResource = class {
|
|
|
403
387
|
options
|
|
404
388
|
);
|
|
405
389
|
}
|
|
406
|
-
/**
|
|
407
|
-
async
|
|
390
|
+
/** Attach a feature to a plan with limits, overage, and credits configuration. */
|
|
391
|
+
async addFeature(params, options) {
|
|
408
392
|
const { id, ...rest } = params;
|
|
409
|
-
return this.httpClient.post(`/plans/${id}/
|
|
410
|
-
}
|
|
411
|
-
/** Update an existing price on a plan. */
|
|
412
|
-
async updatePrice(params, options) {
|
|
413
|
-
const { id, priceId, ...rest } = params;
|
|
414
|
-
return this.httpClient.put(`/plans/${id}/prices/${priceId}`, rest, options);
|
|
415
|
-
}
|
|
416
|
-
/** Remove a price from a plan. */
|
|
417
|
-
async deletePrice(params, options) {
|
|
418
|
-
const { id, priceId } = params;
|
|
419
|
-
return this.httpClient.delete(
|
|
420
|
-
`/plans/${id}/prices/${priceId}`,
|
|
421
|
-
void 0,
|
|
422
|
-
options
|
|
423
|
-
);
|
|
393
|
+
return this.httpClient.post(`/plans/${id}/features`, rest, options);
|
|
424
394
|
}
|
|
425
|
-
/** Set a specific price as the default
|
|
395
|
+
/** Set a specific price as the default and return the updated plan price. */
|
|
426
396
|
async setDefaultPrice(params, options) {
|
|
427
397
|
const { id, priceId } = params;
|
|
428
398
|
return this.httpClient.put(
|
|
@@ -440,12 +410,7 @@ var PlansResource = class {
|
|
|
440
410
|
options
|
|
441
411
|
);
|
|
442
412
|
}
|
|
443
|
-
/**
|
|
444
|
-
async setRegionalPricing(params, options) {
|
|
445
|
-
const { id, ...rest } = params;
|
|
446
|
-
return this.httpClient.put(`/plans/${id}/regional`, rest, options);
|
|
447
|
-
}
|
|
448
|
-
/** Remove all regional currency overrides for a plan price. */
|
|
413
|
+
/** Remove all regional currency overrides for a plan price. The request is rejected while billable subscriptions depend on an override. */
|
|
449
414
|
async deleteRegionalPrices(params, options) {
|
|
450
415
|
const { id, priceId } = params;
|
|
451
416
|
return this.httpClient.delete(
|
|
@@ -454,6 +419,62 @@ var PlansResource = class {
|
|
|
454
419
|
options
|
|
455
420
|
);
|
|
456
421
|
}
|
|
422
|
+
/** Update a base price or market price variant. Removing a base market override is rejected while a variant depends on it. Offer terms are managed through Offers. */
|
|
423
|
+
async updatePrice(params, options) {
|
|
424
|
+
const { id, priceId, ...rest } = params;
|
|
425
|
+
return this.httpClient.patch(
|
|
426
|
+
`/plans/${id}/prices/${priceId}`,
|
|
427
|
+
rest,
|
|
428
|
+
options
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
/** Archive a price for new subscriptions. Existing subscriptions that selected it continue using its current catalog value. */
|
|
432
|
+
async deletePrice(params, options) {
|
|
433
|
+
const { id, priceId } = params;
|
|
434
|
+
return this.httpClient.delete(
|
|
435
|
+
`/plans/${id}/prices/${priceId}`,
|
|
436
|
+
void 0,
|
|
437
|
+
options
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
/** Add a base price or a selectable market price variant. Variants inherit their base price outside the markets they override. Configure introductory and promotional benefits through Offers. */
|
|
441
|
+
async addPrice(params, options) {
|
|
442
|
+
const { id, ...rest } = params;
|
|
443
|
+
return this.httpClient.post(`/plans/${id}/prices`, rest, options);
|
|
444
|
+
}
|
|
445
|
+
/** Configure regional prices and feature overage values for one currency. Currency-specific offer terms are managed through Offers. */
|
|
446
|
+
async setRegionalPricing(params, options) {
|
|
447
|
+
const { id, ...rest } = params;
|
|
448
|
+
return this.httpClient.put(`/plans/${id}/regional`, rest, options);
|
|
449
|
+
}
|
|
450
|
+
/** Get a plan with public price IDs and their automatic introductory offer IDs. */
|
|
451
|
+
async get(params, options) {
|
|
452
|
+
const { id } = params;
|
|
453
|
+
return this.httpClient.get(`/plans/${id}`, void 0, options);
|
|
454
|
+
}
|
|
455
|
+
/** Update a plan's name, description, visibility, or metadata. */
|
|
456
|
+
async update(params, options) {
|
|
457
|
+
const { id, ...rest } = params;
|
|
458
|
+
return this.httpClient.patch(`/plans/${id}`, rest, options);
|
|
459
|
+
}
|
|
460
|
+
/** Soft-delete a plan. */
|
|
461
|
+
async delete(params, options) {
|
|
462
|
+
const { id } = params;
|
|
463
|
+
return this.httpClient.delete(`/plans/${id}`, void 0, options);
|
|
464
|
+
}
|
|
465
|
+
/** Set a plan's public visibility and return the updated plan. */
|
|
466
|
+
async setVisibility(params, options) {
|
|
467
|
+
const { id, ...rest } = params;
|
|
468
|
+
return this.httpClient.put(`/plans/${id}/visibility`, rest, options);
|
|
469
|
+
}
|
|
470
|
+
/** List plans with public price IDs and their automatic introductory offer IDs. */
|
|
471
|
+
async list(params, options) {
|
|
472
|
+
return this.httpClient.get("/plans", params, options);
|
|
473
|
+
}
|
|
474
|
+
/** Create a new plan with optional consumption model, visibility, and plan group assignment. */
|
|
475
|
+
async create(params, options) {
|
|
476
|
+
return this.httpClient.post("/plans", params, options);
|
|
477
|
+
}
|
|
457
478
|
};
|
|
458
479
|
|
|
459
480
|
// src/resources/portal.ts
|
|
@@ -463,7 +484,45 @@ var PortalResource = class {
|
|
|
463
484
|
}
|
|
464
485
|
/** Generate a customer portal URL. Exactly one identifier (email or customerId) is required. */
|
|
465
486
|
async getUrl(params, options) {
|
|
466
|
-
return this.httpClient.post("/portal/
|
|
487
|
+
return this.httpClient.post("/portal/sessions", params, options);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// src/resources/pricing.ts
|
|
492
|
+
var PricingResource = class {
|
|
493
|
+
constructor(httpClient) {
|
|
494
|
+
this.httpClient = httpClient;
|
|
495
|
+
}
|
|
496
|
+
/** Get one reusable pricing market group. */
|
|
497
|
+
async getMarketGroup(params, options) {
|
|
498
|
+
const { id } = params;
|
|
499
|
+
return this.httpClient.get(
|
|
500
|
+
`/pricing/market-groups/${id}`,
|
|
501
|
+
void 0,
|
|
502
|
+
options
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
/** Replace the name, countries, and metadata of a pricing market group. */
|
|
506
|
+
async updateMarketGroup(params, options) {
|
|
507
|
+
const { id, ...rest } = params;
|
|
508
|
+
return this.httpClient.patch(`/pricing/market-groups/${id}`, rest, options);
|
|
509
|
+
}
|
|
510
|
+
/** Delete an unused pricing market group. Groups referenced by prices or subscriptions cannot be deleted. */
|
|
511
|
+
async deleteMarketGroup(params, options) {
|
|
512
|
+
const { id } = params;
|
|
513
|
+
return this.httpClient.delete(
|
|
514
|
+
`/pricing/market-groups/${id}`,
|
|
515
|
+
void 0,
|
|
516
|
+
options
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
/** List reusable country groups used to resolve market-specific prices independently from currency. */
|
|
520
|
+
async listMarketGroups() {
|
|
521
|
+
return this.httpClient.get("/pricing/market-groups");
|
|
522
|
+
}
|
|
523
|
+
/** Create a reusable country group. Countries can belong to only one active group; each price chooses its currency independently. */
|
|
524
|
+
async createMarketGroup(params, options) {
|
|
525
|
+
return this.httpClient.post("/pricing/market-groups", params, options);
|
|
467
526
|
}
|
|
468
527
|
};
|
|
469
528
|
|
|
@@ -472,27 +531,23 @@ var PromoCodesResource = class {
|
|
|
472
531
|
constructor(httpClient) {
|
|
473
532
|
this.httpClient = httpClient;
|
|
474
533
|
}
|
|
475
|
-
/** List promo codes with cursor-based pagination. */
|
|
476
|
-
async list(params, options) {
|
|
477
|
-
return this.httpClient.get("/promo-codes", params, options);
|
|
478
|
-
}
|
|
479
534
|
/** Retrieve a promo code by its public ID. */
|
|
480
535
|
async get(params, options) {
|
|
481
536
|
const { id } = params;
|
|
482
537
|
return this.httpClient.get(`/promo-codes/${id}`, void 0, options);
|
|
483
538
|
}
|
|
484
|
-
/**
|
|
485
|
-
* Create a new promo code. Optionally restrict it to specific plans and a billing interval.
|
|
486
|
-
*
|
|
487
|
-
* **100% discounts are not supported.** Percentage codes must be strictly less than 100% (`discountValue` < 10000 basis points). For full waivers, use an introductory offer on the plan instead. At checkout, any code — percentage or fixed amount — that would reduce the total below the currency's minimum charge ($0.50 USD equivalent) is silently dropped.
|
|
488
|
-
*/
|
|
489
|
-
async create(params, options) {
|
|
490
|
-
return this.httpClient.post("/promo-codes", params, options);
|
|
491
|
-
}
|
|
492
539
|
/** Update a promo code's billing interval, redemption limits, expiration, active status, or plan restrictions. */
|
|
493
540
|
async update(params, options) {
|
|
494
541
|
const { id, ...rest } = params;
|
|
495
|
-
return this.httpClient.
|
|
542
|
+
return this.httpClient.patch(`/promo-codes/${id}`, rest, options);
|
|
543
|
+
}
|
|
544
|
+
/** List promo codes with cursor-based pagination. */
|
|
545
|
+
async list(params, options) {
|
|
546
|
+
return this.httpClient.get("/promo-codes", params, options);
|
|
547
|
+
}
|
|
548
|
+
/** Create a distribution code for an existing promotional offer. Offer economics remain owned by the referenced Offer. */
|
|
549
|
+
async create(params, options) {
|
|
550
|
+
return this.httpClient.post("/promo-codes", params, options);
|
|
496
551
|
}
|
|
497
552
|
};
|
|
498
553
|
|
|
@@ -512,25 +567,25 @@ var QuotaResource = class {
|
|
|
512
567
|
constructor(httpClient) {
|
|
513
568
|
this.httpClient = httpClient;
|
|
514
569
|
}
|
|
515
|
-
/**
|
|
516
|
-
async
|
|
517
|
-
return this.httpClient.
|
|
518
|
-
}
|
|
519
|
-
/** Set a customer's quota allowance for a feature to an exact value. */
|
|
520
|
-
async set(params, options) {
|
|
521
|
-
return this.httpClient.put("/usage/quota", params, options);
|
|
570
|
+
/** Get all quota allowances for a customer across every quota feature in their plan. */
|
|
571
|
+
async getAll(params, options) {
|
|
572
|
+
return this.httpClient.get("/usage/quota/all", params, options);
|
|
522
573
|
}
|
|
523
574
|
/** 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. */
|
|
524
575
|
async remove(params, options) {
|
|
525
|
-
return this.httpClient.
|
|
576
|
+
return this.httpClient.post("/usage/quota/remove", params, options);
|
|
526
577
|
}
|
|
527
578
|
/** Get the current quota allowance (used vs included) for a specific feature. */
|
|
528
579
|
async get(params, options) {
|
|
529
580
|
return this.httpClient.get("/usage/quota", params, options);
|
|
530
581
|
}
|
|
531
|
-
/**
|
|
532
|
-
async
|
|
533
|
-
return this.httpClient.
|
|
582
|
+
/** Add to a customer's quota allowance for a feature. Defaults to 1 if count is omitted. */
|
|
583
|
+
async add(params, options) {
|
|
584
|
+
return this.httpClient.post("/usage/quota", params, options);
|
|
585
|
+
}
|
|
586
|
+
/** Set a customer's quota allowance for a feature to an exact value. */
|
|
587
|
+
async set(params, options) {
|
|
588
|
+
return this.httpClient.put("/usage/quota", params, options);
|
|
534
589
|
}
|
|
535
590
|
};
|
|
536
591
|
|
|
@@ -539,22 +594,6 @@ var SeatsResource = class {
|
|
|
539
594
|
constructor(httpClient) {
|
|
540
595
|
this.httpClient = httpClient;
|
|
541
596
|
}
|
|
542
|
-
/** Add seats to a customer's subscription. Prorates charges for the current billing period. */
|
|
543
|
-
async add(params, options) {
|
|
544
|
-
return this.httpClient.post("/seats", params, options);
|
|
545
|
-
}
|
|
546
|
-
/** Set seats to an exact count. */
|
|
547
|
-
async set(params, options) {
|
|
548
|
-
return this.httpClient.put("/seats", params, options);
|
|
549
|
-
}
|
|
550
|
-
/** Remove seats from a customer's subscription. Takes effect at the end of the billing period. */
|
|
551
|
-
async remove(params, options) {
|
|
552
|
-
return this.httpClient.delete("/seats", params, options);
|
|
553
|
-
}
|
|
554
|
-
/** Set all seat types at once. */
|
|
555
|
-
async setAll(params, options) {
|
|
556
|
-
return this.httpClient.put("/seats/bulk", params, options);
|
|
557
|
-
}
|
|
558
597
|
/** Get current balance for a specific seat type. */
|
|
559
598
|
async getBalance(params, options) {
|
|
560
599
|
return this.httpClient.get("/seats/balance", params, options);
|
|
@@ -563,6 +602,22 @@ var SeatsResource = class {
|
|
|
563
602
|
async getAllBalances(params, options) {
|
|
564
603
|
return this.httpClient.get("/seats/balances", params, options);
|
|
565
604
|
}
|
|
605
|
+
/** Set all seat types at once. */
|
|
606
|
+
async setAll(params, options) {
|
|
607
|
+
return this.httpClient.put("/seats/bulk", params, options);
|
|
608
|
+
}
|
|
609
|
+
/** Remove seats from a customer's subscription. Takes effect at the end of the billing period. */
|
|
610
|
+
async remove(params, options) {
|
|
611
|
+
return this.httpClient.post("/seats/remove", params, options);
|
|
612
|
+
}
|
|
613
|
+
/** Add seats to a customer's subscription. Prorates charges for the current billing period. */
|
|
614
|
+
async add(params, options) {
|
|
615
|
+
return this.httpClient.post("/seats", params, options);
|
|
616
|
+
}
|
|
617
|
+
/** Set seats to an exact count. */
|
|
618
|
+
async set(params, options) {
|
|
619
|
+
return this.httpClient.put("/seats", params, options);
|
|
620
|
+
}
|
|
566
621
|
};
|
|
567
622
|
|
|
568
623
|
// src/resources/subscriptions.ts
|
|
@@ -570,57 +625,44 @@ var SubscriptionsResource = class {
|
|
|
570
625
|
constructor(httpClient) {
|
|
571
626
|
this.httpClient = httpClient;
|
|
572
627
|
}
|
|
573
|
-
/**
|
|
574
|
-
async
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
/** Get a subscription by its public ID, regardless of status (including pending_payment and past_due). */
|
|
582
|
-
async get(params, options) {
|
|
583
|
-
const { id } = params;
|
|
584
|
-
return this.httpClient.get(`/subscriptions/${id}`, void 0, options);
|
|
585
|
-
}
|
|
586
|
-
/** Get the active subscription for a customer. Returns null if none. */
|
|
587
|
-
async getActive(params, options) {
|
|
588
|
-
return this.httpClient.get("/subscriptions/active", params, options);
|
|
628
|
+
/** Deactivate an add-on from a subscription. */
|
|
629
|
+
async deactivateAddon(params, options) {
|
|
630
|
+
const { id, addonId } = params;
|
|
631
|
+
return this.httpClient.delete(
|
|
632
|
+
`/subscriptions/${id}/addons/${addonId}`,
|
|
633
|
+
void 0,
|
|
634
|
+
options
|
|
635
|
+
);
|
|
589
636
|
}
|
|
590
|
-
/**
|
|
591
|
-
async
|
|
637
|
+
/** Activate an add-on on a subscription. Charges a prorated amount for the current billing period. */
|
|
638
|
+
async activateAddon(params, options) {
|
|
592
639
|
const { id, ...rest } = params;
|
|
593
|
-
return this.httpClient.post(`/subscriptions/${id}/
|
|
594
|
-
}
|
|
595
|
-
/** Revert a scheduled cancellation. Only works when canceledAt is set but status is not yet 'canceled'. */
|
|
596
|
-
async uncancel(params, options) {
|
|
597
|
-
const { id } = params;
|
|
598
|
-
return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);
|
|
599
|
-
}
|
|
600
|
-
/** Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. */
|
|
601
|
-
async reactivate(params, options) {
|
|
602
|
-
const { id } = params;
|
|
603
|
-
return this.httpClient.post(`/subscriptions/${id}/reactivate`, {}, options);
|
|
640
|
+
return this.httpClient.post(`/subscriptions/${id}/addons`, rest, options);
|
|
604
641
|
}
|
|
605
|
-
/**
|
|
606
|
-
async
|
|
607
|
-
const { id } = params;
|
|
642
|
+
/** Adjust a subscription's balance or credits by a signed amount. Positive adds, negative subtracts. */
|
|
643
|
+
async adjustBalance(params, options) {
|
|
644
|
+
const { id, ...rest } = params;
|
|
608
645
|
return this.httpClient.post(
|
|
609
|
-
`/subscriptions/${id}/
|
|
610
|
-
|
|
646
|
+
`/subscriptions/${id}/balance/adjust`,
|
|
647
|
+
rest,
|
|
611
648
|
options
|
|
612
649
|
);
|
|
613
650
|
}
|
|
614
|
-
/**
|
|
615
|
-
async
|
|
651
|
+
/** Top up a subscription's balance. Charges the customer's payment method for the specified amount. */
|
|
652
|
+
async topupBalance(params, options) {
|
|
616
653
|
const { id, ...rest } = params;
|
|
617
654
|
return this.httpClient.post(
|
|
618
|
-
`/subscriptions/${id}/
|
|
655
|
+
`/subscriptions/${id}/balance/topup`,
|
|
619
656
|
rest,
|
|
620
657
|
options
|
|
621
658
|
);
|
|
622
659
|
}
|
|
623
|
-
/**
|
|
660
|
+
/** Cancel immediately or at period end and return the updated subscription. */
|
|
661
|
+
async cancel(params, options) {
|
|
662
|
+
const { id, ...rest } = params;
|
|
663
|
+
return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);
|
|
664
|
+
}
|
|
665
|
+
/** Upgrade or change billing interval immediately, optionally applying a quoted Promotional Offer. Scheduled changes do not accept offers. */
|
|
624
666
|
async changePlan(params, options) {
|
|
625
667
|
const { id, ...rest } = params;
|
|
626
668
|
return this.httpClient.post(
|
|
@@ -629,51 +671,68 @@ var SubscriptionsResource = class {
|
|
|
629
671
|
options
|
|
630
672
|
);
|
|
631
673
|
}
|
|
632
|
-
/**
|
|
633
|
-
async
|
|
674
|
+
/** Purchase a credit pack for a subscription. Charges the customer and adds credits to their balance. */
|
|
675
|
+
async purchaseCredits(params, options) {
|
|
676
|
+
const { id, ...rest } = params;
|
|
677
|
+
return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);
|
|
678
|
+
}
|
|
679
|
+
/** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
|
|
680
|
+
async updatePaymentMethod(params, options) {
|
|
634
681
|
const { id, ...rest } = params;
|
|
635
682
|
return this.httpClient.post(
|
|
636
|
-
`/subscriptions/${id}/
|
|
683
|
+
`/subscriptions/${id}/payment-method/update`,
|
|
637
684
|
rest,
|
|
638
685
|
options
|
|
639
686
|
);
|
|
640
687
|
}
|
|
641
|
-
/**
|
|
642
|
-
async
|
|
688
|
+
/** Preview proration details for an immediate plan change (an upgrade or a longer interval) without applying it. Returns credit, charge, and net amount. The target plan must belong to the same plan group as the current plan, otherwise a 400 with code `plans_not_in_same_group` is returned. A change between two free plans has nothing to prorate and returns a zero-amount estimate. 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. Pass offerId to quote the destination plan with a Promotional Offer. */
|
|
689
|
+
async previewChange(params, options) {
|
|
643
690
|
const { id, ...rest } = params;
|
|
644
|
-
return this.httpClient.post(
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
async deactivateAddon(params, options) {
|
|
648
|
-
const { id, addonId } = params;
|
|
649
|
-
return this.httpClient.delete(
|
|
650
|
-
`/subscriptions/${id}/addons/${addonId}`,
|
|
651
|
-
void 0,
|
|
691
|
+
return this.httpClient.post(
|
|
692
|
+
`/subscriptions/${id}/preview-change`,
|
|
693
|
+
rest,
|
|
652
694
|
options
|
|
653
695
|
);
|
|
654
696
|
}
|
|
655
|
-
/**
|
|
656
|
-
async
|
|
697
|
+
/** Reactivates a subscription. A past_due subscription retries its outstanding renewal charge (recovering to active on success). A canceled subscription generates a fresh invoice, charges the saved card, and resets the billing period. On a successful charge the subscription becomes active; a declined charge returns an error with a recoveryUrl in the error details that can be sent to the customer to update their card. A canceled subscription may apply a Promotional Offer by offerId; past-due recovery cannot. */
|
|
698
|
+
async reactivate(params, options) {
|
|
657
699
|
const { id, ...rest } = params;
|
|
658
700
|
return this.httpClient.post(
|
|
659
|
-
`/subscriptions/${id}/
|
|
701
|
+
`/subscriptions/${id}/reactivate`,
|
|
660
702
|
rest,
|
|
661
703
|
options
|
|
662
704
|
);
|
|
663
705
|
}
|
|
664
|
-
/**
|
|
665
|
-
async
|
|
666
|
-
const { id
|
|
706
|
+
/** Generates a hosted, signed recovery link that lets the customer pay the outstanding renewal charge for a past_due subscription. Unlike reactivate, which charges server-to-server, this returns a link the merchant can deliver through their own email, SMS, or dashboard. The link carries a self-contained signed token and stays valid until the charge is paid or the subscription is no longer past due. */
|
|
707
|
+
async createRecoveryLink(params, options) {
|
|
708
|
+
const { id } = params;
|
|
667
709
|
return this.httpClient.post(
|
|
668
|
-
`/subscriptions/${id}/
|
|
669
|
-
|
|
710
|
+
`/subscriptions/${id}/recovery-links`,
|
|
711
|
+
{},
|
|
670
712
|
options
|
|
671
713
|
);
|
|
672
714
|
}
|
|
673
|
-
/**
|
|
674
|
-
async
|
|
675
|
-
const { id
|
|
676
|
-
return this.httpClient.
|
|
715
|
+
/** Get a subscription by its public ID, regardless of status (including pending_payment and past_due). */
|
|
716
|
+
async get(params, options) {
|
|
717
|
+
const { id } = params;
|
|
718
|
+
return this.httpClient.get(`/subscriptions/${id}`, void 0, options);
|
|
719
|
+
}
|
|
720
|
+
/** Revert a scheduled cancellation and return the updated subscription. Only works before cancellation takes effect. */
|
|
721
|
+
async uncancel(params, options) {
|
|
722
|
+
const { id } = params;
|
|
723
|
+
return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);
|
|
724
|
+
}
|
|
725
|
+
/** Get the active subscription for a customer. Returns null if none. */
|
|
726
|
+
async getActive(params, options) {
|
|
727
|
+
return this.httpClient.get("/subscriptions/active", params, options);
|
|
728
|
+
}
|
|
729
|
+
/** List all subscriptions. Filter by customer ID or status. */
|
|
730
|
+
async list(params, options) {
|
|
731
|
+
return this.httpClient.get("/subscriptions", params, options);
|
|
732
|
+
}
|
|
733
|
+
/** Create a subscription for a customer. Commet selects the default price when priceId is omitted and resolves its market from the customer's billing country. Without an offer override, Commet applies the price's automatic introductory offer. Pass one Promotional Offer through offerId to override it. Experiment assignment remains external. */
|
|
734
|
+
async create(params, options) {
|
|
735
|
+
return this.httpClient.post("/subscriptions", params, options);
|
|
677
736
|
}
|
|
678
737
|
};
|
|
679
738
|
|
|
@@ -682,6 +741,10 @@ var TestClockResource = class {
|
|
|
682
741
|
constructor(httpClient) {
|
|
683
742
|
this.httpClient = httpClient;
|
|
684
743
|
}
|
|
744
|
+
/** Discovers customers due for billing at the org's current (simulated) time and enqueues a billing cycle for each — renewals, expired trials, pending cancellations. Also fires any dunning retry whose scheduled time has passed. Enqueueing is asynchronous. Sandbox only. */
|
|
745
|
+
async processBilling(options) {
|
|
746
|
+
return this.httpClient.post("/test-clock/process-billing", {}, options);
|
|
747
|
+
}
|
|
685
748
|
/** Returns the organization's current test clock state. Sandbox only. */
|
|
686
749
|
async get() {
|
|
687
750
|
return this.httpClient.get("/test-clock");
|
|
@@ -690,10 +753,6 @@ var TestClockResource = class {
|
|
|
690
753
|
async advance(params, options) {
|
|
691
754
|
return this.httpClient.post("/test-clock", params, options);
|
|
692
755
|
}
|
|
693
|
-
/** Discovers customers due for billing at the org's current (simulated) time and enqueues a billing cycle for each — renewals, expired trials, pending cancellations. Also fires any dunning retry whose scheduled time has passed. Enqueueing is asynchronous. Sandbox only. */
|
|
694
|
-
async processBilling(options) {
|
|
695
|
-
return this.httpClient.post("/test-clock/process-billing", {}, options);
|
|
696
|
-
}
|
|
697
756
|
};
|
|
698
757
|
|
|
699
758
|
// src/resources/transactions.ts
|
|
@@ -701,25 +760,44 @@ var TransactionsResource = class {
|
|
|
701
760
|
constructor(httpClient) {
|
|
702
761
|
this.httpClient = httpClient;
|
|
703
762
|
}
|
|
704
|
-
/**
|
|
705
|
-
async list(params, options) {
|
|
706
|
-
return this.httpClient.get("/transactions", params, options);
|
|
707
|
-
}
|
|
708
|
-
/** Retrieve a single payment transaction by its public ID, including provider details. */
|
|
709
|
-
async get(params, options) {
|
|
710
|
-
const { id } = params;
|
|
711
|
-
return this.httpClient.get(`/transactions/${id}`, void 0, options);
|
|
712
|
-
}
|
|
713
|
-
/** Issue a full refund for a payment transaction. */
|
|
763
|
+
/** Issue a full refund and return the provider-neutral refund resource with its actual status. */
|
|
714
764
|
async refund(params, options) {
|
|
715
765
|
const { id } = params;
|
|
716
766
|
return this.httpClient.post(`/transactions/${id}/refund`, {}, options);
|
|
717
767
|
}
|
|
718
|
-
/** Retry a failed subscription renewal
|
|
768
|
+
/** Retry a failed subscription renewal and return an honest retry result. The original failed transaction remains immutable. */
|
|
719
769
|
async retry(params, options) {
|
|
720
770
|
const { id } = params;
|
|
721
771
|
return this.httpClient.post(`/transactions/${id}/retry`, {}, options);
|
|
722
772
|
}
|
|
773
|
+
/** Retrieve a single payment transaction by its public ID, including provider details. */
|
|
774
|
+
async get(params, options) {
|
|
775
|
+
const { id } = params;
|
|
776
|
+
return this.httpClient.get(`/transactions/${id}`, void 0, options);
|
|
777
|
+
}
|
|
778
|
+
/** List payment transactions with cursor-based pagination. Filter by status or customer email. */
|
|
779
|
+
async list(params, options) {
|
|
780
|
+
return this.httpClient.get("/transactions", params, options);
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
// src/resources/usage.ts
|
|
785
|
+
var UsageResource = class {
|
|
786
|
+
constructor(httpClient) {
|
|
787
|
+
this.httpClient = httpClient;
|
|
788
|
+
}
|
|
789
|
+
/** Check if a customer can consume a feature before actual consumption. Returns availability and cost estimates based on the plan's consumption model. */
|
|
790
|
+
async check(params, options) {
|
|
791
|
+
return this.httpClient.post("/usage/check", params, options);
|
|
792
|
+
}
|
|
793
|
+
/** Track a usage event for a metered feature. Deducts from balance/credits if applicable. */
|
|
794
|
+
async track(params, options) {
|
|
795
|
+
return this.httpClient.post("/usage/events", params, options);
|
|
796
|
+
}
|
|
797
|
+
/** Set a metered feature's usage to an exact value for the current period. Use the Idempotency-Key header to make retries safe. */
|
|
798
|
+
async set(params, options) {
|
|
799
|
+
return this.httpClient.put("/usage", params, options);
|
|
800
|
+
}
|
|
723
801
|
};
|
|
724
802
|
|
|
725
803
|
// src/_generated_resources.ts
|
|
@@ -732,11 +810,13 @@ var GeneratedResources = class {
|
|
|
732
810
|
this.featureAccess = new FeatureAccessResource(http);
|
|
733
811
|
this.features = new FeaturesResource(http);
|
|
734
812
|
this.invoices = new InvoicesResource(http);
|
|
813
|
+
this.offers = new OffersResource(http);
|
|
735
814
|
this.payments = new PaymentsResource(http);
|
|
736
815
|
this.payouts = new PayoutsResource(http);
|
|
737
816
|
this.planGroups = new PlanGroupsResource(http);
|
|
738
817
|
this.plans = new PlansResource(http);
|
|
739
818
|
this.portal = new PortalResource(http);
|
|
819
|
+
this.pricing = new PricingResource(http);
|
|
740
820
|
this.promoCodes = new PromoCodesResource(http);
|
|
741
821
|
this.provisioning = new ProvisioningResource(http);
|
|
742
822
|
this.quota = new QuotaResource(http);
|
|
@@ -744,56 +824,14 @@ var GeneratedResources = class {
|
|
|
744
824
|
this.subscriptions = new SubscriptionsResource(http);
|
|
745
825
|
this.testClock = new TestClockResource(http);
|
|
746
826
|
this.transactions = new TransactionsResource(http);
|
|
747
|
-
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
// src/resources/usage.ts
|
|
751
|
-
var UsageResource = class {
|
|
752
|
-
constructor(httpClient) {
|
|
753
|
-
this.httpClient = httpClient;
|
|
754
|
-
}
|
|
755
|
-
/** Deducts from balance/credits if the plan uses consumption. Duplicate `idempotencyKey` is rejected. */
|
|
756
|
-
async track(params, options) {
|
|
757
|
-
const eventData = {
|
|
758
|
-
feature: params.feature,
|
|
759
|
-
customerId: params.customerId,
|
|
760
|
-
idempotencyKey: params.idempotencyKey,
|
|
761
|
-
timestamp: params.timestamp || (/* @__PURE__ */ new Date()).toISOString(),
|
|
762
|
-
properties: params.properties ? Object.entries(params.properties).map(([property, value]) => ({
|
|
763
|
-
property,
|
|
764
|
-
value
|
|
765
|
-
})) : void 0
|
|
766
|
-
};
|
|
767
|
-
if ("model" in params && params.model) {
|
|
768
|
-
eventData.model = params.model;
|
|
769
|
-
eventData.inputTokens = params.inputTokens;
|
|
770
|
-
eventData.outputTokens = params.outputTokens;
|
|
771
|
-
if (params.cacheReadTokens) {
|
|
772
|
-
eventData.cacheReadTokens = params.cacheReadTokens;
|
|
773
|
-
}
|
|
774
|
-
if (params.cacheWriteTokens) {
|
|
775
|
-
eventData.cacheWriteTokens = params.cacheWriteTokens;
|
|
776
|
-
}
|
|
777
|
-
} else {
|
|
778
|
-
eventData.value = params.value;
|
|
779
|
-
}
|
|
780
|
-
return this.httpClient.post("/usage/events", eventData, options);
|
|
781
|
-
}
|
|
782
|
-
/** Dry-run: checks if a usage event would be allowed without actually tracking it. */
|
|
783
|
-
async check(params, options) {
|
|
784
|
-
return this.httpClient.post("/usage/check", params, options);
|
|
785
|
-
}
|
|
786
|
-
/** Set a metered feature's usage to an exact value for the current period. */
|
|
787
|
-
async set(params, options) {
|
|
788
|
-
return this.httpClient.put("/usage", params, options);
|
|
827
|
+
this.usage = new UsageResource(http);
|
|
789
828
|
}
|
|
790
829
|
};
|
|
791
830
|
|
|
792
831
|
// src/resources/webhooks.ts
|
|
793
832
|
var import_node_crypto = __toESM(require("crypto"));
|
|
794
833
|
var Webhooks = class {
|
|
795
|
-
constructor(
|
|
796
|
-
this.httpClient = httpClient;
|
|
834
|
+
constructor() {
|
|
797
835
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
798
836
|
}
|
|
799
837
|
verify(params) {
|
|
@@ -840,27 +878,41 @@ var Webhooks = class {
|
|
|
840
878
|
if (handler) await handler(payload.data, payload);
|
|
841
879
|
return payload;
|
|
842
880
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/resources/generated-webhooks.ts
|
|
884
|
+
var GeneratedWebhooksResource = class extends Webhooks {
|
|
885
|
+
constructor(httpClient) {
|
|
886
|
+
super();
|
|
887
|
+
this.httpClient = httpClient;
|
|
848
888
|
}
|
|
889
|
+
/** Retrieve a webhook endpoint by its public ID. */
|
|
849
890
|
async get(params, options) {
|
|
850
891
|
const { id } = params;
|
|
851
892
|
return this.httpClient.get(`/webhooks/${id}`, void 0, options);
|
|
852
893
|
}
|
|
894
|
+
/** Update a webhook endpoint. Only the provided fields change. */
|
|
853
895
|
async update(params, options) {
|
|
854
|
-
const { id, ...
|
|
855
|
-
return this.httpClient.
|
|
896
|
+
const { id, ...rest } = params;
|
|
897
|
+
return this.httpClient.patch(`/webhooks/${id}`, rest, options);
|
|
856
898
|
}
|
|
899
|
+
/** Permanently delete a webhook endpoint. */
|
|
857
900
|
async delete(params, options) {
|
|
858
901
|
const { id } = params;
|
|
859
902
|
return this.httpClient.delete(`/webhooks/${id}`, void 0, options);
|
|
860
903
|
}
|
|
904
|
+
/** Send a test event to a webhook endpoint to verify connectivity. */
|
|
861
905
|
async test(params, options) {
|
|
862
906
|
const { id } = params;
|
|
863
|
-
return this.httpClient.post(`/webhooks/${id}/test`,
|
|
907
|
+
return this.httpClient.post(`/webhooks/${id}/test`, {}, options);
|
|
908
|
+
}
|
|
909
|
+
/** List webhook endpoints with cursor-based pagination. */
|
|
910
|
+
async list(params, options) {
|
|
911
|
+
return this.httpClient.get("/webhooks", params, options);
|
|
912
|
+
}
|
|
913
|
+
/** Create a new webhook endpoint. The response includes the signing secret which is only returned once. */
|
|
914
|
+
async create(params, options) {
|
|
915
|
+
return this.httpClient.post("/webhooks", params, options);
|
|
864
916
|
}
|
|
865
917
|
};
|
|
866
918
|
|
|
@@ -895,8 +947,8 @@ var CommetValidationError = class extends CommetError {
|
|
|
895
947
|
};
|
|
896
948
|
|
|
897
949
|
// src/version.ts
|
|
898
|
-
var API_VERSION = "2026-07-
|
|
899
|
-
var SDK_VERSION = "
|
|
950
|
+
var API_VERSION = "2026-07-24";
|
|
951
|
+
var SDK_VERSION = "8.0.0";
|
|
900
952
|
|
|
901
953
|
// src/utils/telemetry.ts
|
|
902
954
|
var registeredIntegrations = /* @__PURE__ */ new Set();
|
|
@@ -1006,6 +1058,9 @@ var _CommetHTTPClient = class _CommetHTTPClient {
|
|
|
1006
1058
|
async put(endpoint, data, options) {
|
|
1007
1059
|
return this.request("PUT", endpoint, data, options);
|
|
1008
1060
|
}
|
|
1061
|
+
async patch(endpoint, data, options) {
|
|
1062
|
+
return this.request("PATCH", endpoint, data, options);
|
|
1063
|
+
}
|
|
1009
1064
|
async delete(endpoint, data, options) {
|
|
1010
1065
|
return this.request("DELETE", endpoint, data, options);
|
|
1011
1066
|
}
|
|
@@ -1344,8 +1399,7 @@ var Commet = class extends GeneratedResources {
|
|
|
1344
1399
|
}
|
|
1345
1400
|
this.httpClient = new CommetHTTPClient(config);
|
|
1346
1401
|
this.initResources(this.httpClient);
|
|
1347
|
-
this.
|
|
1348
|
-
this.webhooks = new Webhooks(this.httpClient);
|
|
1402
|
+
this.webhooks = new GeneratedWebhooksResource(this.httpClient);
|
|
1349
1403
|
scheduleSdkUpdateCheck();
|
|
1350
1404
|
}
|
|
1351
1405
|
};
|