@commet/node 8.0.1 → 9.1.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.
Files changed (294) hide show
  1. package/README.md +4 -4
  2. package/dist/index.d.mts +514 -206
  3. package/dist/index.d.ts +514 -206
  4. package/dist/index.js +202 -88
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +202 -88
  7. package/dist/index.mjs.map +1 -1
  8. package/docs/README.md +20 -0
  9. package/docs/ai-onboarding/ai-onboarding.md +90 -0
  10. package/docs/ai-onboarding/billing-best-practices-skill.md +29 -0
  11. package/docs/ai-onboarding/commet-skill.md +58 -0
  12. package/docs/ai-onboarding/mcp-server.md +207 -0
  13. package/docs/ai-onboarding/meta.json +17 -0
  14. package/docs/ai-onboarding/pricing-models-skill.md +29 -0
  15. package/docs/ai-onboarding/subscription-patterns-skill.md +29 -0
  16. package/docs/api-reference/addons.md +127 -0
  17. package/docs/api-reference/api-keys.md +57 -0
  18. package/docs/api-reference/credit-packs.md +80 -0
  19. package/docs/api-reference/customers.md +274 -0
  20. package/docs/api-reference/feature-access.md +36 -0
  21. package/docs/api-reference/features.md +94 -0
  22. package/docs/api-reference/generated-webhooks.md +120 -0
  23. package/docs/api-reference/index.md +31 -0
  24. package/docs/api-reference/invoices.md +123 -0
  25. package/docs/api-reference/markets.md +92 -0
  26. package/docs/api-reference/meta.json +7 -0
  27. package/docs/api-reference/offers.md +104 -0
  28. package/docs/api-reference/payments.md +106 -0
  29. package/docs/api-reference/payouts.md +66 -0
  30. package/docs/api-reference/plan-groups.md +157 -0
  31. package/docs/api-reference/plans.md +358 -0
  32. package/docs/api-reference/portal.md +30 -0
  33. package/docs/api-reference/promo-codes.md +86 -0
  34. package/docs/api-reference/provisioning.md +19 -0
  35. package/docs/api-reference/quota.md +120 -0
  36. package/docs/api-reference/seats.md +123 -0
  37. package/docs/api-reference/subscriptions.md +387 -0
  38. package/docs/api-reference/test-clock.md +59 -0
  39. package/docs/api-reference/transactions.md +78 -0
  40. package/docs/api-reference/usage.md +83 -0
  41. package/docs/documentation/api-versioning.md +100 -0
  42. package/docs/documentation/better-auth.md +361 -0
  43. package/docs/documentation/choose-a-billing-model.md +38 -0
  44. package/docs/documentation/cli.md +1024 -0
  45. package/docs/documentation/create-api-key.md +47 -0
  46. package/docs/documentation/customers/customer-credits.md +48 -0
  47. package/docs/documentation/customers/customer-portal.md +107 -0
  48. package/docs/documentation/customers/manage-customers.md +346 -0
  49. package/docs/documentation/customers/meta.json +5 -0
  50. package/docs/documentation/error-handling.md +239 -0
  51. package/docs/documentation/examples.md +37 -0
  52. package/docs/documentation/finance/acceptable-use.md +145 -0
  53. package/docs/documentation/finance/finance-overview.md +32 -0
  54. package/docs/documentation/finance/local-currency-taxes.md +40 -0
  55. package/docs/documentation/finance/merchant-of-record.md +48 -0
  56. package/docs/documentation/finance/meta.json +13 -0
  57. package/docs/documentation/finance/payouts-verification.md +186 -0
  58. package/docs/documentation/finance/payouts.md +41 -0
  59. package/docs/documentation/finance/supported-countries.md +28 -0
  60. package/docs/documentation/go/integrate-with-encore.md +229 -0
  61. package/docs/documentation/go/integrate-with-go.md +258 -0
  62. package/docs/documentation/go/meta.json +5 -0
  63. package/docs/documentation/introduction.md +58 -0
  64. package/docs/documentation/invoicing/handle-failed-payments.md +283 -0
  65. package/docs/documentation/invoicing/invoices-and-billing-cycles.md +73 -0
  66. package/docs/documentation/invoicing/manage-invoices.md +340 -0
  67. package/docs/documentation/invoicing/meta.json +9 -0
  68. package/docs/documentation/java/integrate-with-java.md +117 -0
  69. package/docs/documentation/java/meta.json +5 -0
  70. package/docs/documentation/meta.json +36 -0
  71. package/docs/documentation/nodejs/integrate-with-astro.md +129 -0
  72. package/docs/documentation/nodejs/integrate-with-bun.md +113 -0
  73. package/docs/documentation/nodejs/integrate-with-express.md +127 -0
  74. package/docs/documentation/nodejs/integrate-with-hono.md +141 -0
  75. package/docs/documentation/nodejs/integrate-with-nextjs.md +118 -0
  76. package/docs/documentation/nodejs/integrate-with-nuxt.md +125 -0
  77. package/docs/documentation/nodejs/integrate-with-remix.md +136 -0
  78. package/docs/documentation/nodejs/integrate-with-sveltekit.md +127 -0
  79. package/docs/documentation/nodejs/meta.json +14 -0
  80. package/docs/documentation/payments/accept-one-time-payments.md +314 -0
  81. package/docs/documentation/payments/meta.json +10 -0
  82. package/docs/documentation/payments/payment-orchestration.md +43 -0
  83. package/docs/documentation/payments/payment-providers.md +59 -0
  84. package/docs/documentation/payments/transactions-refunds-and-retries.md +199 -0
  85. package/docs/documentation/php/integrate-with-laravel.md +222 -0
  86. package/docs/documentation/php/integrate-with-php.md +103 -0
  87. package/docs/documentation/php/integrate-with-symfony.md +214 -0
  88. package/docs/documentation/php/meta.json +9 -0
  89. package/docs/documentation/plans/add-ons.md +257 -0
  90. package/docs/documentation/plans/balance-and-top-ups.md +169 -0
  91. package/docs/documentation/plans/configure-features.md +335 -0
  92. package/docs/documentation/plans/consumption-models.md +93 -0
  93. package/docs/documentation/plans/create-plans.md +162 -0
  94. package/docs/documentation/plans/credit-packs.md +89 -0
  95. package/docs/documentation/plans/meta.json +14 -0
  96. package/docs/documentation/plans/one-time-payments.md +142 -0
  97. package/docs/documentation/plans/plan-groups.md +31 -0
  98. package/docs/documentation/platform/custom-domains.md +27 -0
  99. package/docs/documentation/platform/dashboard-metrics-and-events.md +25 -0
  100. package/docs/documentation/platform/members-and-permissions.md +21 -0
  101. package/docs/documentation/platform/meta.json +10 -0
  102. package/docs/documentation/platform/organization-settings.md +29 -0
  103. package/docs/documentation/python/integrate-with-django.md +161 -0
  104. package/docs/documentation/python/integrate-with-fastapi.md +164 -0
  105. package/docs/documentation/python/integrate-with-flask.md +153 -0
  106. package/docs/documentation/python/integrate-with-python.md +90 -0
  107. package/docs/documentation/python/meta.json +10 -0
  108. package/docs/documentation/sales/card-promotions.md +41 -0
  109. package/docs/documentation/sales/introductory-offers.md +64 -0
  110. package/docs/documentation/sales/meta.json +13 -0
  111. package/docs/documentation/sales/offers.md +65 -0
  112. package/docs/documentation/sales/promo-codes.md +65 -0
  113. package/docs/documentation/sales/promotional-offers.md +58 -0
  114. package/docs/documentation/sales/regional-prices.md +100 -0
  115. package/docs/documentation/sales/trial-periods.md +88 -0
  116. package/docs/documentation/sdk-reference.md +68 -0
  117. package/docs/documentation/subscriptions/manage-subscriptions.md +505 -0
  118. package/docs/documentation/subscriptions/meta.json +9 -0
  119. package/docs/documentation/subscriptions/plan-grants.md +132 -0
  120. package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +35 -0
  121. package/docs/documentation/testing-sandbox.md +251 -0
  122. package/docs/documentation/usage/ai-token-billing.md +294 -0
  123. package/docs/documentation/usage/meta.json +10 -0
  124. package/docs/documentation/usage/quota-management.md +341 -0
  125. package/docs/documentation/usage/seat-management.md +377 -0
  126. package/docs/documentation/usage/track-usage.md +282 -0
  127. package/docs/errors/addon_already_active.md +22 -0
  128. package/docs/errors/addon_has_activations.md +22 -0
  129. package/docs/errors/addon_not_active.md +22 -0
  130. package/docs/errors/addon_not_found.md +22 -0
  131. package/docs/errors/already_has_active_subscription.md +22 -0
  132. package/docs/errors/already_scheduled.md +22 -0
  133. package/docs/errors/api_key_not_found.md +22 -0
  134. package/docs/errors/card_promotions_not_available.md +22 -0
  135. package/docs/errors/charge_failed.md +22 -0
  136. package/docs/errors/charge_in_progress.md +22 -0
  137. package/docs/errors/claim_not_pending.md +22 -0
  138. package/docs/errors/credit_pack_not_found.md +22 -0
  139. package/docs/errors/customer_not_found.md +22 -0
  140. package/docs/errors/duplicate.md +22 -0
  141. package/docs/errors/endpoint_deprecated.md +22 -0
  142. package/docs/errors/endpoint_not_available.md +22 -0
  143. package/docs/errors/feature_already_exists.md +22 -0
  144. package/docs/errors/feature_disabled.md +22 -0
  145. package/docs/errors/feature_in_use.md +22 -0
  146. package/docs/errors/feature_not_found.md +22 -0
  147. package/docs/errors/feature_not_in_plan.md +22 -0
  148. package/docs/errors/forbidden.md +22 -0
  149. package/docs/errors/free_plan_change_not_supported.md +22 -0
  150. package/docs/errors/idempotency_in_progress.md +22 -0
  151. package/docs/errors/idempotency_key_mismatch.md +22 -0
  152. package/docs/errors/idempotency_unavailable.md +22 -0
  153. package/docs/errors/included_limit_reached.md +22 -0
  154. package/docs/errors/index.md +89 -0
  155. package/docs/errors/insufficient_balance.md +22 -0
  156. package/docs/errors/insufficient_credits.md +22 -0
  157. package/docs/errors/insufficient_seats.md +22 -0
  158. package/docs/errors/internal_error.md +22 -0
  159. package/docs/errors/invalid_json.md +22 -0
  160. package/docs/errors/invalid_subscription_status.md +22 -0
  161. package/docs/errors/invoice_not_found.md +22 -0
  162. package/docs/errors/market_group_in_use.md +22 -0
  163. package/docs/errors/market_group_not_found.md +22 -0
  164. package/docs/errors/market_in_use.md +22 -0
  165. package/docs/errors/market_not_found.md +22 -0
  166. package/docs/errors/missing_regional_price.md +22 -0
  167. package/docs/errors/model_not_found.md +22 -0
  168. package/docs/errors/no_active_subscription.md +22 -0
  169. package/docs/errors/no_change_requested.md +22 -0
  170. package/docs/errors/no_outstanding_invoice.md +22 -0
  171. package/docs/errors/no_payment_method.md +22 -0
  172. package/docs/errors/no_prices_configured.md +22 -0
  173. package/docs/errors/not_found.md +22 -0
  174. package/docs/errors/not_scheduled_for_cancellation.md +22 -0
  175. package/docs/errors/offer_not_applicable.md +22 -0
  176. package/docs/errors/offer_not_found.md +22 -0
  177. package/docs/errors/one_time_subscription_not_cancelable.md +22 -0
  178. package/docs/errors/organization_already_claimed.md +22 -0
  179. package/docs/errors/payment_failed.md +22 -0
  180. package/docs/errors/payment_method_not_found.md +22 -0
  181. package/docs/errors/payment_not_cancelable.md +22 -0
  182. package/docs/errors/payment_not_found.md +22 -0
  183. package/docs/errors/payouts_not_available_in_sandbox.md +22 -0
  184. package/docs/errors/plan_change_scheduled.md +22 -0
  185. package/docs/errors/plan_group_not_found.md +22 -0
  186. package/docs/errors/plan_not_found.md +22 -0
  187. package/docs/errors/plan_unavailable.md +22 -0
  188. package/docs/errors/plans_not_in_same_group.md +22 -0
  189. package/docs/errors/price_in_use.md +22 -0
  190. package/docs/errors/price_not_found.md +22 -0
  191. package/docs/errors/pricing_mode_mismatch.md +22 -0
  192. package/docs/errors/promo_code_expired.md +22 -0
  193. package/docs/errors/promo_code_not_found.md +22 -0
  194. package/docs/errors/provider_unsupported.md +22 -0
  195. package/docs/errors/rate_limited.md +22 -0
  196. package/docs/errors/sandbox_only.md +22 -0
  197. package/docs/errors/seat_limit_exceeded.md +22 -0
  198. package/docs/errors/subscription_activation_failed.md +22 -0
  199. package/docs/errors/subscription_already_canceled.md +22 -0
  200. package/docs/errors/subscription_cancel_failed.md +22 -0
  201. package/docs/errors/subscription_creation_failed.md +22 -0
  202. package/docs/errors/subscription_has_open_dispute.md +22 -0
  203. package/docs/errors/subscription_not_active.md +22 -0
  204. package/docs/errors/subscription_not_found.md +22 -0
  205. package/docs/errors/subscription_required.md +22 -0
  206. package/docs/errors/subscription_uncancel_failed.md +22 -0
  207. package/docs/errors/transaction_not_found.md +22 -0
  208. package/docs/errors/unauthorized.md +22 -0
  209. package/docs/errors/validation_error.md +22 -0
  210. package/docs/errors/webhook_not_found.md +22 -0
  211. package/docs/errors.md +34 -0
  212. package/docs/getting-started.md +35 -0
  213. package/docs/knowledge-base/how-do-balance-and-top-ups-work.md +22 -0
  214. package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +20 -0
  215. package/docs/knowledge-base/how-do-discounts-work.md +65 -0
  216. package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +88 -0
  217. package/docs/knowledge-base/how-do-monthly-quarterly-and-yearly-billing-work.md +77 -0
  218. package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +20 -0
  219. package/docs/knowledge-base/how-do-trial-periods-work.md +54 -0
  220. package/docs/knowledge-base/how-does-billing-work.md +73 -0
  221. package/docs/knowledge-base/how-does-payment-routing-work.md +17 -0
  222. package/docs/knowledge-base/how-does-quota-based-billing-work.md +106 -0
  223. package/docs/knowledge-base/how-does-seat-based-billing-work.md +88 -0
  224. package/docs/knowledge-base/how-is-proration-calculated-when-changing-plans.md +89 -0
  225. package/docs/knowledge-base/meta.json +29 -0
  226. package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +110 -0
  227. package/docs/knowledge-base/what-happens-when-a-payment-fails.md +40 -0
  228. package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +74 -0
  229. package/docs/knowledge-base/what-happens-when-you-refund-or-retry-a-transaction.md +21 -0
  230. package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +101 -0
  231. package/docs/manifest.json +1677 -0
  232. package/docs/meta.json +11 -0
  233. package/docs/platform-documentation.md +175 -0
  234. package/docs/schemas.md +995 -0
  235. package/docs/webhooks/addon-activated.md +44 -0
  236. package/docs/webhooks/addon-deactivated.md +40 -0
  237. package/docs/webhooks/balance-depleted.md +37 -0
  238. package/docs/webhooks/balance-low.md +39 -0
  239. package/docs/webhooks/balance-topped-up.md +41 -0
  240. package/docs/webhooks/checkout-ready.md +43 -0
  241. package/docs/webhooks/credits-depleted.md +35 -0
  242. package/docs/webhooks/credits-expired.md +35 -0
  243. package/docs/webhooks/credits-granted.md +37 -0
  244. package/docs/webhooks/credits-low.md +39 -0
  245. package/docs/webhooks/credits-purchased.md +41 -0
  246. package/docs/webhooks/customer-created.md +49 -0
  247. package/docs/webhooks/customer-state-changed.md +134 -0
  248. package/docs/webhooks/customer-updated.md +49 -0
  249. package/docs/webhooks/introduction.md +499 -0
  250. package/docs/webhooks/invoice-created.md +45 -0
  251. package/docs/webhooks/invoice-overdue.md +53 -0
  252. package/docs/webhooks/invoice-upcoming.md +43 -0
  253. package/docs/webhooks/invoice-voided.md +53 -0
  254. package/docs/webhooks/meta.json +78 -0
  255. package/docs/webhooks/payment-dispute-resolved.md +52 -0
  256. package/docs/webhooks/payment-disputed.md +49 -0
  257. package/docs/webhooks/payment-failed.md +37 -0
  258. package/docs/webhooks/payment-link-canceled.md +41 -0
  259. package/docs/webhooks/payment-link-completed.md +47 -0
  260. package/docs/webhooks/payment-link-created.md +41 -0
  261. package/docs/webhooks/payment-link-failed.md +45 -0
  262. package/docs/webhooks/payment-method-attached.md +40 -0
  263. package/docs/webhooks/payment-method-updated.md +38 -0
  264. package/docs/webhooks/payment-received.md +45 -0
  265. package/docs/webhooks/payment-recovered.md +39 -0
  266. package/docs/webhooks/payment-refunded.md +47 -0
  267. package/docs/webhooks/payment-retry-failed.md +39 -0
  268. package/docs/webhooks/payout-available.md +33 -0
  269. package/docs/webhooks/payout-created.md +48 -0
  270. package/docs/webhooks/payout-failed.md +52 -0
  271. package/docs/webhooks/payout-paid.md +48 -0
  272. package/docs/webhooks/quota-exceeded.md +44 -0
  273. package/docs/webhooks/quota-threshold-reached.md +41 -0
  274. package/docs/webhooks/seats-limit-reached.md +39 -0
  275. package/docs/webhooks/seats-updated.md +39 -0
  276. package/docs/webhooks/subscription-activated.md +43 -0
  277. package/docs/webhooks/subscription-canceled.md +57 -0
  278. package/docs/webhooks/subscription-cancellation-revoked.md +37 -0
  279. package/docs/webhooks/subscription-cancellation-scheduled.md +45 -0
  280. package/docs/webhooks/subscription-created.md +35 -0
  281. package/docs/webhooks/subscription-past-due.md +43 -0
  282. package/docs/webhooks/subscription-plan-change-revoked.md +50 -0
  283. package/docs/webhooks/subscription-plan-change-scheduled.md +55 -0
  284. package/docs/webhooks/subscription-plan-changed.md +43 -0
  285. package/docs/webhooks/subscription-reactivated.md +53 -0
  286. package/docs/webhooks/subscription-updated.md +39 -0
  287. package/docs/webhooks/trial-checkout-ready.md +39 -0
  288. package/docs/webhooks/trial-converted.md +39 -0
  289. package/docs/webhooks/trial-expired.md +39 -0
  290. package/docs/webhooks/trial-started.md +46 -0
  291. package/docs/webhooks/trial-will-end.md +41 -0
  292. package/docs/webhooks/usage-recorded.md +41 -0
  293. package/docs/webhooks.md +782 -0
  294. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -128,6 +128,57 @@ var CustomersResource = class {
128
128
  constructor(httpClient) {
129
129
  this.httpClient = httpClient;
130
130
  }
131
+ /** Revoke the unallocated remainder of a customer credit grant. Applied invoice history is unchanged. */
132
+ async revokeCredit(params, options) {
133
+ const { id, creditId } = params;
134
+ return this.httpClient.post(
135
+ `/customers/${id}/credits/${creditId}/revoke`,
136
+ {},
137
+ options
138
+ );
139
+ }
140
+ /** List currency-specific invoice credit grants and their remaining balances for a customer. */
141
+ async listCredits(params, options) {
142
+ const { id } = params;
143
+ return this.httpClient.get(`/customers/${id}/credits`, void 0, options);
144
+ }
145
+ /** Grant monetary credit in one currency. Credit is applied FIFO before tax to eligible recurring invoices. */
146
+ async createCredit(params, options) {
147
+ const { id, ...rest } = params;
148
+ return this.httpClient.post(`/customers/${id}/credits`, rest, options);
149
+ }
150
+ /** End complimentary access immediately. The next full-price period becomes pending payment and requires checkout; no past period is billed retroactively. */
151
+ async revokePlanGrant(params, options) {
152
+ const { id, grantId, ...rest } = params;
153
+ return this.httpClient.post(
154
+ `/customers/${id}/plan-grants/${grantId}/revoke`,
155
+ rest,
156
+ options
157
+ );
158
+ }
159
+ /** Give the grant a remaining number of billing cycles, set an exact deadline, or keep it active until revoked. */
160
+ async updatePlanGrant(params, options) {
161
+ const { id, grantId, ...rest } = params;
162
+ return this.httpClient.patch(
163
+ `/customers/${id}/plan-grants/${grantId}`,
164
+ rest,
165
+ options
166
+ );
167
+ }
168
+ /** List the independent audit timeline for paid-plan access granted without checkout or payment credentials. */
169
+ async listPlanGrants(params, options) {
170
+ const { id } = params;
171
+ return this.httpClient.get(
172
+ `/customers/${id}/plan-grants`,
173
+ void 0,
174
+ options
175
+ );
176
+ }
177
+ /** Move an active free subscription to an eligible paid plan immediately without checkout, a card, or customer credit. The grant may last for exact billing cycles, until a date, or until revoked. */
178
+ async createPlanGrant(params, options) {
179
+ const { id, ...rest } = params;
180
+ return this.httpClient.post(`/customers/${id}/plan-grants`, rest, options);
181
+ }
131
182
  /** Retrieve a customer by their public ID, including subscription status and metadata. */
132
183
  async get(params, options) {
133
184
  const { id } = params;
@@ -233,31 +284,61 @@ var InvoicesResource = class {
233
284
  }
234
285
  };
235
286
 
287
+ // src/resources/markets.ts
288
+ var MarketsResource = class {
289
+ constructor(httpClient) {
290
+ this.httpClient = httpClient;
291
+ }
292
+ /** Get one reusable market. */
293
+ async get(params, options) {
294
+ const { id } = params;
295
+ return this.httpClient.get(`/markets/${id}`, void 0, options);
296
+ }
297
+ /** Replace the name, countries, and metadata of a market. */
298
+ async update(params, options) {
299
+ const { id, ...rest } = params;
300
+ return this.httpClient.patch(`/markets/${id}`, rest, options);
301
+ }
302
+ /** Delete an unused market. Markets referenced by prices or subscriptions cannot be deleted. */
303
+ async delete(params, options) {
304
+ const { id } = params;
305
+ return this.httpClient.delete(`/markets/${id}`, void 0, options);
306
+ }
307
+ /** List reusable country groups that resolve market-specific prices independently from currency. */
308
+ async list() {
309
+ return this.httpClient.get("/markets");
310
+ }
311
+ /** Create a reusable market without attaching it to a plan or price. Countries can belong to only one active market. */
312
+ async create(params, options) {
313
+ return this.httpClient.post("/markets", params, options);
314
+ }
315
+ };
316
+
236
317
  // src/resources/offers.ts
237
318
  var OffersResource = class {
238
319
  constructor(httpClient) {
239
320
  this.httpClient = httpClient;
240
321
  }
241
- /** Retrieve a canonical offer by its public ID. */
322
+ /** Retrieve reusable offer terms by public ID. */
242
323
  async get(params, options) {
243
324
  const { id } = params;
244
325
  return this.httpClient.get(`/offers/${id}`, void 0, options);
245
326
  }
246
- /** Replace an offer's catalog definition. Existing offer applications keep their immutable accepted terms. */
327
+ /** Replace reusable offer terms. Existing applications keep their immutable accepted terms. */
247
328
  async update(params, options) {
248
329
  const { id, ...rest } = params;
249
330
  return this.httpClient.patch(`/offers/${id}`, rest, options);
250
331
  }
251
- /** Soft-delete an offer. Existing applications and their accepted terms remain available for billing and audit. */
332
+ /** Soft-delete an Offer. Existing applications and their accepted terms remain available for billing and audit. */
252
333
  async delete(params, options) {
253
334
  const { id } = params;
254
335
  return this.httpClient.delete(`/offers/${id}`, void 0, options);
255
336
  }
256
- /** List the organization's canonical introductory and promotional offers. */
337
+ /** List reusable offer terms. Offers are independent from plans, prices, eligibility, and distribution channels. */
257
338
  async list(params, options) {
258
339
  return this.httpClient.get("/offers", params, options);
259
340
  }
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. */
341
+ /** Create reusable offer terms without assigning a plan, price, eligibility rule, or distribution channel. */
261
342
  async create(params, options) {
262
343
  return this.httpClient.post("/offers", params, options);
263
344
  }
@@ -305,9 +386,12 @@ var PayoutsResource = class {
305
386
  async request(params, options) {
306
387
  return this.httpClient.post("/payouts", params, options);
307
388
  }
308
- /** 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. */
309
- async completeVerification(params, options) {
310
- return this.httpClient.post("/payouts/verification", params, options);
389
+ /**
390
+ * Deprecated. Complete business and identity verification in the Commet dashboard. This endpoint no longer accepts or processes KYC data.
391
+ * @deprecated
392
+ */
393
+ async completeVerification(options) {
394
+ return this.httpClient.post("/payouts/verification", {}, options);
311
395
  }
312
396
  };
313
397
 
@@ -488,44 +572,6 @@ var PortalResource = class {
488
572
  }
489
573
  };
490
574
 
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);
526
- }
527
- };
528
-
529
575
  // src/resources/promo-codes.ts
530
576
  var PromoCodesResource = class {
531
577
  constructor(httpClient) {
@@ -545,7 +591,7 @@ var PromoCodesResource = class {
545
591
  async list(params, options) {
546
592
  return this.httpClient.get("/promo-codes", params, options);
547
593
  }
548
- /** Create a distribution code for an existing promotional offer. Offer economics remain owned by the referenced Offer. */
594
+ /** Create a distribution code for an existing Offer. The referenced Offer owns the benefit and duration; the promo code owns redemption restrictions. */
549
595
  async create(params, options) {
550
596
  return this.httpClient.post("/promo-codes", params, options);
551
597
  }
@@ -662,7 +708,7 @@ var SubscriptionsResource = class {
662
708
  const { id, ...rest } = params;
663
709
  return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);
664
710
  }
665
- /** Upgrade or change billing interval immediately, optionally applying a quoted Promotional Offer. Scheduled changes do not accept offers. */
711
+ /** Upgrade or change billing interval immediately, optionally applying an Offer. Scheduled changes do not accept offers. */
666
712
  async changePlan(params, options) {
667
713
  const { id, ...rest } = params;
668
714
  return this.httpClient.post(
@@ -676,6 +722,20 @@ var SubscriptionsResource = class {
676
722
  const { id, ...rest } = params;
677
723
  return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);
678
724
  }
725
+ /** Apply or replace a direct Offer on a subscription's pending payment checkout. The existing checkout URL remains unchanged. Offers whose first phase is a free trial cannot be applied after checkout creation. */
726
+ async applyOffer(params, options) {
727
+ const { id, ...rest } = params;
728
+ return this.httpClient.put(`/subscriptions/${id}/offer`, rest, options);
729
+ }
730
+ /** Remove the quoted direct Offer from a subscription's pending payment checkout. The existing checkout URL remains unchanged and returns to its undiscounted price. */
731
+ async removeOffer(params, options) {
732
+ const { id } = params;
733
+ return this.httpClient.delete(
734
+ `/subscriptions/${id}/offer`,
735
+ void 0,
736
+ options
737
+ );
738
+ }
679
739
  /** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
680
740
  async updatePaymentMethod(params, options) {
681
741
  const { id, ...rest } = params;
@@ -685,7 +745,7 @@ var SubscriptionsResource = class {
685
745
  options
686
746
  );
687
747
  }
688
- /** Preview proration details for an immediate plan change (a higher-sort-order plan 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 lower-sort-order 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. */
748
+ /** Preview proration details for an immediate plan change without applying it. Free-to-paid changes are never scheduled and the change-plan endpoint always returns hosted checkout for them. For paid plans, interval direction takes precedence: a longer interval is immediate and a shorter interval is scheduled. When the interval is unchanged, a higher-sort-order plan is immediate and a lower-sort-order plan is scheduled. A paid-to-free change is always scheduled. 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. Scheduled changes return a 400 with code `plan_change_scheduled`; apply those via the change-plan endpoint. Pass offerId to quote the destination plan with an Offer. */
689
749
  async previewChange(params, options) {
690
750
  const { id, ...rest } = params;
691
751
  return this.httpClient.post(
@@ -694,7 +754,7 @@ var SubscriptionsResource = class {
694
754
  options
695
755
  );
696
756
  }
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. */
757
+ /** 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 an Offer by offerId; past-due recovery cannot. */
698
758
  async reactivate(params, options) {
699
759
  const { id, ...rest } = params;
700
760
  return this.httpClient.post(
@@ -730,7 +790,7 @@ var SubscriptionsResource = class {
730
790
  async list(params, options) {
731
791
  return this.httpClient.get("/subscriptions", params, options);
732
792
  }
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. */
793
+ /** 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 offerId to apply an active compatible Offer directly, or cardPromotionId to preselect a card-eligible Promotional Offer for the initial checkout when card promotions are enabled for the organization. For the initial checkout, provider accepts either a processor name or an exact payment connection ID. */
734
794
  async create(params, options) {
735
795
  return this.httpClient.post("/subscriptions", params, options);
736
796
  }
@@ -741,15 +801,18 @@ var TestClockResource = class {
741
801
  constructor(httpClient) {
742
802
  this.httpClient = httpClient;
743
803
  }
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. */
804
+ /**
805
+ * Deprecated. POST /test-clock now advances time and processes every due billing deadline in one durable run.
806
+ * @deprecated
807
+ */
745
808
  async processBilling(options) {
746
809
  return this.httpClient.post("/test-clock/process-billing", {}, options);
747
810
  }
748
- /** Returns the organization's current test clock state. Sandbox only. */
811
+ /** Returns the organization's current test clock state and latest durable run. Sandbox only. */
749
812
  async get() {
750
813
  return this.httpClient.get("/test-clock");
751
814
  }
752
- /** 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. */
815
+ /** Starts a durable run that moves the test clock forward and processes every billing deadline due before the target time. Poll GET /test-clock for progress and terminal results. Sandbox only. */
753
816
  async advance(params, options) {
754
817
  return this.httpClient.post("/test-clock", params, options);
755
818
  }
@@ -810,13 +873,13 @@ var GeneratedResources = class {
810
873
  this.featureAccess = new FeatureAccessResource(http);
811
874
  this.features = new FeaturesResource(http);
812
875
  this.invoices = new InvoicesResource(http);
876
+ this.markets = new MarketsResource(http);
813
877
  this.offers = new OffersResource(http);
814
878
  this.payments = new PaymentsResource(http);
815
879
  this.payouts = new PayoutsResource(http);
816
880
  this.planGroups = new PlanGroupsResource(http);
817
881
  this.plans = new PlansResource(http);
818
882
  this.portal = new PortalResource(http);
819
- this.pricing = new PricingResource(http);
820
883
  this.promoCodes = new PromoCodesResource(http);
821
884
  this.provisioning = new ProvisioningResource(http);
822
885
  this.quota = new QuotaResource(http);
@@ -918,37 +981,63 @@ var GeneratedWebhooksResource = class extends Webhooks {
918
981
 
919
982
  // src/types/common.ts
920
983
  var CommetError = class extends Error {
921
- constructor(message, code, statusCode, details) {
984
+ constructor(message, code, statusCode, details, context) {
922
985
  super(message);
923
986
  this.code = code;
924
987
  this.statusCode = statusCode;
925
988
  this.details = details;
926
989
  this.name = "CommetError";
990
+ this.type = context?.type;
991
+ this.param = context?.param;
992
+ this.requestId = context?.requestId;
993
+ this.docUrl = context?.docUrl;
994
+ }
995
+ toJSON() {
996
+ return {
997
+ name: this.name,
998
+ message: this.message,
999
+ type: this.type,
1000
+ code: this.code,
1001
+ statusCode: this.statusCode,
1002
+ param: this.param,
1003
+ details: this.details,
1004
+ requestId: this.requestId,
1005
+ docUrl: this.docUrl
1006
+ };
927
1007
  }
928
1008
  };
929
1009
  var CommetAPIError = class extends CommetError {
930
- constructor(message, statusCode, code, details, errorDetail) {
931
- super(message, code, statusCode, details);
932
- this.statusCode = statusCode;
933
- this.code = code;
934
- this.details = details;
1010
+ constructor(message, statusCode, code, details, errorDetail, responseContext) {
1011
+ super(message, code, statusCode, details, {
1012
+ type: errorDetail?.type,
1013
+ param: errorDetail?.param,
1014
+ requestId: responseContext?.requestId,
1015
+ docUrl: errorDetail?.doc_url
1016
+ });
935
1017
  this.name = "CommetAPIError";
936
- this.type = errorDetail?.type;
937
- this.param = errorDetail?.param;
938
- this.docUrl = errorDetail?.doc_url;
939
1018
  }
940
1019
  };
941
- var CommetValidationError = class extends CommetError {
942
- constructor(message, validationErrors) {
943
- super(message);
1020
+ var CommetValidationError = class extends CommetAPIError {
1021
+ constructor(message, validationErrors, statusCode = 422, errorDetail, responseContext) {
1022
+ super(
1023
+ message,
1024
+ statusCode,
1025
+ errorDetail?.code ?? "validation_error",
1026
+ errorDetail?.details,
1027
+ errorDetail,
1028
+ responseContext
1029
+ );
944
1030
  this.validationErrors = validationErrors;
945
1031
  this.name = "CommetValidationError";
946
1032
  }
1033
+ toJSON() {
1034
+ return { ...super.toJSON(), validationErrors: this.validationErrors };
1035
+ }
947
1036
  };
948
1037
 
949
1038
  // src/version.ts
950
- var API_VERSION = "2026-07-24";
951
- var SDK_VERSION = "8.0.1";
1039
+ var API_VERSION = "2026-07-31";
1040
+ var SDK_VERSION = "9.1.0";
952
1041
 
953
1042
  // src/utils/telemetry.ts
954
1043
  var registeredIntegrations = /* @__PURE__ */ new Set();
@@ -1116,6 +1205,7 @@ var _CommetHTTPClient = class _CommetHTTPClient {
1116
1205
  }
1117
1206
  const requestStart = Date.now();
1118
1207
  const response = await fetch(url, requestConfig);
1208
+ const responseContext = readResponseContext(response.headers);
1119
1209
  if (this.config.debug) {
1120
1210
  console.log(
1121
1211
  `[Commet SDK] Response status: ${response.status} ${response.statusText}`
@@ -1142,7 +1232,9 @@ var _CommetHTTPClient = class _CommetHTTPClient {
1142
1232
  `Invalid JSON response: ${response.status} ${response.statusText}`,
1143
1233
  response.status,
1144
1234
  "INVALID_JSON",
1145
- { responseText }
1235
+ { responseText },
1236
+ void 0,
1237
+ responseContext
1146
1238
  );
1147
1239
  }
1148
1240
  if (!response.ok) {
@@ -1164,38 +1256,47 @@ var _CommetHTTPClient = class _CommetHTTPClient {
1164
1256
  JSON.stringify(responseData, null, 2)
1165
1257
  );
1166
1258
  }
1167
- const parsed = typeof responseData === "object" && responseData !== null ? responseData : {};
1168
- const errorObj = typeof parsed.error === "object" && parsed.error !== null ? parsed.error : {};
1259
+ const errorObj = readObjectProperty(responseData, "error");
1169
1260
  const errorDetail = {
1170
- type: errorObj.type ?? "api_error",
1171
- code: errorObj.code ?? "unknown",
1172
- message: errorObj.message ?? `Request failed with status ${response.status}`,
1173
- param: errorObj.param,
1174
- details: errorObj.details,
1175
- doc_url: errorObj.doc_url
1261
+ type: readStringProperty(errorObj, "type") ?? "api_error",
1262
+ code: readStringProperty(errorObj, "code") ?? "unknown",
1263
+ message: readStringProperty(errorObj, "message") ?? `Request failed with status ${response.status}`,
1264
+ param: readStringProperty(errorObj, "param"),
1265
+ details: Reflect.get(errorObj, "details"),
1266
+ doc_url: readStringProperty(errorObj, "doc_url")
1176
1267
  };
1177
1268
  if (errorDetail.code === "validation_error" && Array.isArray(errorDetail.details)) {
1178
1269
  const errors = {};
1179
1270
  for (const detail of errorDetail.details) {
1180
- if (!errors[detail.field]) errors[detail.field] = [];
1181
- errors[detail.field].push(detail.message);
1271
+ const field = readStringProperty(detail, "field");
1272
+ const message = readStringProperty(detail, "message");
1273
+ if (!(field && message)) continue;
1274
+ if (!errors[field]) errors[field] = [];
1275
+ errors[field].push(message);
1182
1276
  }
1183
- throw new CommetValidationError(errorDetail.message, errors);
1277
+ throw new CommetValidationError(
1278
+ errorDetail.message,
1279
+ errors,
1280
+ response.status,
1281
+ errorDetail,
1282
+ responseContext
1283
+ );
1184
1284
  }
1185
1285
  throw new CommetAPIError(
1186
1286
  errorDetail.message,
1187
1287
  response.status,
1188
1288
  errorDetail.code,
1189
1289
  errorDetail.details,
1190
- errorDetail
1290
+ errorDetail,
1291
+ responseContext
1191
1292
  );
1192
1293
  }
1193
1294
  if (this.config.debug) {
1194
1295
  console.log("[Commet SDK] Response:", responseData);
1195
1296
  }
1196
- if (this.telemetryEnabled) {
1297
+ if (this.telemetryEnabled && responseContext.requestId) {
1197
1298
  this.lastRequestMetrics = {
1198
- requestId: response.headers.get("x-request-id") ?? `req_${Date.now()}`,
1299
+ requestId: responseContext.requestId,
1199
1300
  durationMs: Date.now() - requestStart
1200
1301
  };
1201
1302
  }
@@ -1274,6 +1375,19 @@ var _CommetHTTPClient = class _CommetHTTPClient {
1274
1375
  };
1275
1376
  _CommetHTTPClient.BODY_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
1276
1377
  var CommetHTTPClient = _CommetHTTPClient;
1378
+ function readResponseContext(headers) {
1379
+ return { requestId: headers.get("x-request-id") ?? void 0 };
1380
+ }
1381
+ function readObjectProperty(value, property) {
1382
+ if (typeof value !== "object" || value === null) return {};
1383
+ const propertyValue = Reflect.get(value, property);
1384
+ return typeof propertyValue === "object" && propertyValue !== null ? propertyValue : {};
1385
+ }
1386
+ function readStringProperty(value, property) {
1387
+ if (typeof value !== "object" || value === null) return void 0;
1388
+ const propertyValue = Reflect.get(value, property);
1389
+ return typeof propertyValue === "string" ? propertyValue : void 0;
1390
+ }
1277
1391
 
1278
1392
  // src/utils/update-check.ts
1279
1393
  var NPM_DIST_TAGS_URL = "https://registry.npmjs.org/-/package/%40commet%2Fnode/dist-tags";
@@ -1355,10 +1469,10 @@ function claimSdkUpdateCheck() {
1355
1469
  Reflect.set(globalThis, UPDATE_CHECK_STATE_KEY, true);
1356
1470
  return true;
1357
1471
  }
1358
- function shouldCheckForSdkUpdates() {
1359
- if (process.env.NODE_ENV !== "development") return false;
1360
- if (process.env.CI) return false;
1361
- return process.env.COMMET_NO_UPDATE_CHECK !== "1";
1472
+ function shouldCheckForSdkUpdates(environment = process.env) {
1473
+ if (environment.NODE_ENV !== "development") return false;
1474
+ if (environment.CI) return false;
1475
+ return environment.COMMET_NO_UPDATE_CHECK !== "1";
1362
1476
  }
1363
1477
  async function checkForSdkUpdate(installedVersion) {
1364
1478
  try {