@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.
- package/README.md +4 -4
- package/dist/index.d.mts +514 -206
- package/dist/index.d.ts +514 -206
- package/dist/index.js +202 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -88
- package/dist/index.mjs.map +1 -1
- package/docs/README.md +20 -0
- package/docs/ai-onboarding/ai-onboarding.md +90 -0
- package/docs/ai-onboarding/billing-best-practices-skill.md +29 -0
- package/docs/ai-onboarding/commet-skill.md +58 -0
- package/docs/ai-onboarding/mcp-server.md +207 -0
- package/docs/ai-onboarding/meta.json +17 -0
- package/docs/ai-onboarding/pricing-models-skill.md +29 -0
- package/docs/ai-onboarding/subscription-patterns-skill.md +29 -0
- package/docs/api-reference/addons.md +127 -0
- package/docs/api-reference/api-keys.md +57 -0
- package/docs/api-reference/credit-packs.md +80 -0
- package/docs/api-reference/customers.md +274 -0
- package/docs/api-reference/feature-access.md +36 -0
- package/docs/api-reference/features.md +94 -0
- package/docs/api-reference/generated-webhooks.md +120 -0
- package/docs/api-reference/index.md +31 -0
- package/docs/api-reference/invoices.md +123 -0
- package/docs/api-reference/markets.md +92 -0
- package/docs/api-reference/meta.json +7 -0
- package/docs/api-reference/offers.md +104 -0
- package/docs/api-reference/payments.md +106 -0
- package/docs/api-reference/payouts.md +66 -0
- package/docs/api-reference/plan-groups.md +157 -0
- package/docs/api-reference/plans.md +358 -0
- package/docs/api-reference/portal.md +30 -0
- package/docs/api-reference/promo-codes.md +86 -0
- package/docs/api-reference/provisioning.md +19 -0
- package/docs/api-reference/quota.md +120 -0
- package/docs/api-reference/seats.md +123 -0
- package/docs/api-reference/subscriptions.md +387 -0
- package/docs/api-reference/test-clock.md +59 -0
- package/docs/api-reference/transactions.md +78 -0
- package/docs/api-reference/usage.md +83 -0
- package/docs/documentation/api-versioning.md +100 -0
- package/docs/documentation/better-auth.md +361 -0
- package/docs/documentation/choose-a-billing-model.md +38 -0
- package/docs/documentation/cli.md +1024 -0
- package/docs/documentation/create-api-key.md +47 -0
- package/docs/documentation/customers/customer-credits.md +48 -0
- package/docs/documentation/customers/customer-portal.md +107 -0
- package/docs/documentation/customers/manage-customers.md +346 -0
- package/docs/documentation/customers/meta.json +5 -0
- package/docs/documentation/error-handling.md +239 -0
- package/docs/documentation/examples.md +37 -0
- package/docs/documentation/finance/acceptable-use.md +145 -0
- package/docs/documentation/finance/finance-overview.md +32 -0
- package/docs/documentation/finance/local-currency-taxes.md +40 -0
- package/docs/documentation/finance/merchant-of-record.md +48 -0
- package/docs/documentation/finance/meta.json +13 -0
- package/docs/documentation/finance/payouts-verification.md +186 -0
- package/docs/documentation/finance/payouts.md +41 -0
- package/docs/documentation/finance/supported-countries.md +28 -0
- package/docs/documentation/go/integrate-with-encore.md +229 -0
- package/docs/documentation/go/integrate-with-go.md +258 -0
- package/docs/documentation/go/meta.json +5 -0
- package/docs/documentation/introduction.md +58 -0
- package/docs/documentation/invoicing/handle-failed-payments.md +283 -0
- package/docs/documentation/invoicing/invoices-and-billing-cycles.md +73 -0
- package/docs/documentation/invoicing/manage-invoices.md +340 -0
- package/docs/documentation/invoicing/meta.json +9 -0
- package/docs/documentation/java/integrate-with-java.md +117 -0
- package/docs/documentation/java/meta.json +5 -0
- package/docs/documentation/meta.json +36 -0
- package/docs/documentation/nodejs/integrate-with-astro.md +129 -0
- package/docs/documentation/nodejs/integrate-with-bun.md +113 -0
- package/docs/documentation/nodejs/integrate-with-express.md +127 -0
- package/docs/documentation/nodejs/integrate-with-hono.md +141 -0
- package/docs/documentation/nodejs/integrate-with-nextjs.md +118 -0
- package/docs/documentation/nodejs/integrate-with-nuxt.md +125 -0
- package/docs/documentation/nodejs/integrate-with-remix.md +136 -0
- package/docs/documentation/nodejs/integrate-with-sveltekit.md +127 -0
- package/docs/documentation/nodejs/meta.json +14 -0
- package/docs/documentation/payments/accept-one-time-payments.md +314 -0
- package/docs/documentation/payments/meta.json +10 -0
- package/docs/documentation/payments/payment-orchestration.md +43 -0
- package/docs/documentation/payments/payment-providers.md +59 -0
- package/docs/documentation/payments/transactions-refunds-and-retries.md +199 -0
- package/docs/documentation/php/integrate-with-laravel.md +222 -0
- package/docs/documentation/php/integrate-with-php.md +103 -0
- package/docs/documentation/php/integrate-with-symfony.md +214 -0
- package/docs/documentation/php/meta.json +9 -0
- package/docs/documentation/plans/add-ons.md +257 -0
- package/docs/documentation/plans/balance-and-top-ups.md +169 -0
- package/docs/documentation/plans/configure-features.md +335 -0
- package/docs/documentation/plans/consumption-models.md +93 -0
- package/docs/documentation/plans/create-plans.md +162 -0
- package/docs/documentation/plans/credit-packs.md +89 -0
- package/docs/documentation/plans/meta.json +14 -0
- package/docs/documentation/plans/one-time-payments.md +142 -0
- package/docs/documentation/plans/plan-groups.md +31 -0
- package/docs/documentation/platform/custom-domains.md +27 -0
- package/docs/documentation/platform/dashboard-metrics-and-events.md +25 -0
- package/docs/documentation/platform/members-and-permissions.md +21 -0
- package/docs/documentation/platform/meta.json +10 -0
- package/docs/documentation/platform/organization-settings.md +29 -0
- package/docs/documentation/python/integrate-with-django.md +161 -0
- package/docs/documentation/python/integrate-with-fastapi.md +164 -0
- package/docs/documentation/python/integrate-with-flask.md +153 -0
- package/docs/documentation/python/integrate-with-python.md +90 -0
- package/docs/documentation/python/meta.json +10 -0
- package/docs/documentation/sales/card-promotions.md +41 -0
- package/docs/documentation/sales/introductory-offers.md +64 -0
- package/docs/documentation/sales/meta.json +13 -0
- package/docs/documentation/sales/offers.md +65 -0
- package/docs/documentation/sales/promo-codes.md +65 -0
- package/docs/documentation/sales/promotional-offers.md +58 -0
- package/docs/documentation/sales/regional-prices.md +100 -0
- package/docs/documentation/sales/trial-periods.md +88 -0
- package/docs/documentation/sdk-reference.md +68 -0
- package/docs/documentation/subscriptions/manage-subscriptions.md +505 -0
- package/docs/documentation/subscriptions/meta.json +9 -0
- package/docs/documentation/subscriptions/plan-grants.md +132 -0
- package/docs/documentation/subscriptions/upgrade-and-downgrade-plans.md +35 -0
- package/docs/documentation/testing-sandbox.md +251 -0
- package/docs/documentation/usage/ai-token-billing.md +294 -0
- package/docs/documentation/usage/meta.json +10 -0
- package/docs/documentation/usage/quota-management.md +341 -0
- package/docs/documentation/usage/seat-management.md +377 -0
- package/docs/documentation/usage/track-usage.md +282 -0
- package/docs/errors/addon_already_active.md +22 -0
- package/docs/errors/addon_has_activations.md +22 -0
- package/docs/errors/addon_not_active.md +22 -0
- package/docs/errors/addon_not_found.md +22 -0
- package/docs/errors/already_has_active_subscription.md +22 -0
- package/docs/errors/already_scheduled.md +22 -0
- package/docs/errors/api_key_not_found.md +22 -0
- package/docs/errors/card_promotions_not_available.md +22 -0
- package/docs/errors/charge_failed.md +22 -0
- package/docs/errors/charge_in_progress.md +22 -0
- package/docs/errors/claim_not_pending.md +22 -0
- package/docs/errors/credit_pack_not_found.md +22 -0
- package/docs/errors/customer_not_found.md +22 -0
- package/docs/errors/duplicate.md +22 -0
- package/docs/errors/endpoint_deprecated.md +22 -0
- package/docs/errors/endpoint_not_available.md +22 -0
- package/docs/errors/feature_already_exists.md +22 -0
- package/docs/errors/feature_disabled.md +22 -0
- package/docs/errors/feature_in_use.md +22 -0
- package/docs/errors/feature_not_found.md +22 -0
- package/docs/errors/feature_not_in_plan.md +22 -0
- package/docs/errors/forbidden.md +22 -0
- package/docs/errors/free_plan_change_not_supported.md +22 -0
- package/docs/errors/idempotency_in_progress.md +22 -0
- package/docs/errors/idempotency_key_mismatch.md +22 -0
- package/docs/errors/idempotency_unavailable.md +22 -0
- package/docs/errors/included_limit_reached.md +22 -0
- package/docs/errors/index.md +89 -0
- package/docs/errors/insufficient_balance.md +22 -0
- package/docs/errors/insufficient_credits.md +22 -0
- package/docs/errors/insufficient_seats.md +22 -0
- package/docs/errors/internal_error.md +22 -0
- package/docs/errors/invalid_json.md +22 -0
- package/docs/errors/invalid_subscription_status.md +22 -0
- package/docs/errors/invoice_not_found.md +22 -0
- package/docs/errors/market_group_in_use.md +22 -0
- package/docs/errors/market_group_not_found.md +22 -0
- package/docs/errors/market_in_use.md +22 -0
- package/docs/errors/market_not_found.md +22 -0
- package/docs/errors/missing_regional_price.md +22 -0
- package/docs/errors/model_not_found.md +22 -0
- package/docs/errors/no_active_subscription.md +22 -0
- package/docs/errors/no_change_requested.md +22 -0
- package/docs/errors/no_outstanding_invoice.md +22 -0
- package/docs/errors/no_payment_method.md +22 -0
- package/docs/errors/no_prices_configured.md +22 -0
- package/docs/errors/not_found.md +22 -0
- package/docs/errors/not_scheduled_for_cancellation.md +22 -0
- package/docs/errors/offer_not_applicable.md +22 -0
- package/docs/errors/offer_not_found.md +22 -0
- package/docs/errors/one_time_subscription_not_cancelable.md +22 -0
- package/docs/errors/organization_already_claimed.md +22 -0
- package/docs/errors/payment_failed.md +22 -0
- package/docs/errors/payment_method_not_found.md +22 -0
- package/docs/errors/payment_not_cancelable.md +22 -0
- package/docs/errors/payment_not_found.md +22 -0
- package/docs/errors/payouts_not_available_in_sandbox.md +22 -0
- package/docs/errors/plan_change_scheduled.md +22 -0
- package/docs/errors/plan_group_not_found.md +22 -0
- package/docs/errors/plan_not_found.md +22 -0
- package/docs/errors/plan_unavailable.md +22 -0
- package/docs/errors/plans_not_in_same_group.md +22 -0
- package/docs/errors/price_in_use.md +22 -0
- package/docs/errors/price_not_found.md +22 -0
- package/docs/errors/pricing_mode_mismatch.md +22 -0
- package/docs/errors/promo_code_expired.md +22 -0
- package/docs/errors/promo_code_not_found.md +22 -0
- package/docs/errors/provider_unsupported.md +22 -0
- package/docs/errors/rate_limited.md +22 -0
- package/docs/errors/sandbox_only.md +22 -0
- package/docs/errors/seat_limit_exceeded.md +22 -0
- package/docs/errors/subscription_activation_failed.md +22 -0
- package/docs/errors/subscription_already_canceled.md +22 -0
- package/docs/errors/subscription_cancel_failed.md +22 -0
- package/docs/errors/subscription_creation_failed.md +22 -0
- package/docs/errors/subscription_has_open_dispute.md +22 -0
- package/docs/errors/subscription_not_active.md +22 -0
- package/docs/errors/subscription_not_found.md +22 -0
- package/docs/errors/subscription_required.md +22 -0
- package/docs/errors/subscription_uncancel_failed.md +22 -0
- package/docs/errors/transaction_not_found.md +22 -0
- package/docs/errors/unauthorized.md +22 -0
- package/docs/errors/validation_error.md +22 -0
- package/docs/errors/webhook_not_found.md +22 -0
- package/docs/errors.md +34 -0
- package/docs/getting-started.md +35 -0
- package/docs/knowledge-base/how-do-balance-and-top-ups-work.md +22 -0
- package/docs/knowledge-base/how-do-credits-credit-packs-and-customer-credits-differ.md +20 -0
- package/docs/knowledge-base/how-do-discounts-work.md +65 -0
- package/docs/knowledge-base/how-do-free-plans-work-without-payment.md +88 -0
- package/docs/knowledge-base/how-do-monthly-quarterly-and-yearly-billing-work.md +77 -0
- package/docs/knowledge-base/how-do-offers-promo-codes-and-card-promotions-work-together.md +20 -0
- package/docs/knowledge-base/how-do-trial-periods-work.md +54 -0
- package/docs/knowledge-base/how-does-billing-work.md +73 -0
- package/docs/knowledge-base/how-does-payment-routing-work.md +17 -0
- package/docs/knowledge-base/how-does-quota-based-billing-work.md +106 -0
- package/docs/knowledge-base/how-does-seat-based-billing-work.md +88 -0
- package/docs/knowledge-base/how-is-proration-calculated-when-changing-plans.md +89 -0
- package/docs/knowledge-base/meta.json +29 -0
- package/docs/knowledge-base/what-happens-when-a-customer-changes-plans.md +110 -0
- package/docs/knowledge-base/what-happens-when-a-payment-fails.md +40 -0
- package/docs/knowledge-base/what-happens-when-you-change-your-prices.md +74 -0
- package/docs/knowledge-base/what-happens-when-you-refund-or-retry-a-transaction.md +21 -0
- package/docs/knowledge-base/what-invoices-do-customers-receive-and-when.md +101 -0
- package/docs/manifest.json +1677 -0
- package/docs/meta.json +11 -0
- package/docs/platform-documentation.md +175 -0
- package/docs/schemas.md +995 -0
- package/docs/webhooks/addon-activated.md +44 -0
- package/docs/webhooks/addon-deactivated.md +40 -0
- package/docs/webhooks/balance-depleted.md +37 -0
- package/docs/webhooks/balance-low.md +39 -0
- package/docs/webhooks/balance-topped-up.md +41 -0
- package/docs/webhooks/checkout-ready.md +43 -0
- package/docs/webhooks/credits-depleted.md +35 -0
- package/docs/webhooks/credits-expired.md +35 -0
- package/docs/webhooks/credits-granted.md +37 -0
- package/docs/webhooks/credits-low.md +39 -0
- package/docs/webhooks/credits-purchased.md +41 -0
- package/docs/webhooks/customer-created.md +49 -0
- package/docs/webhooks/customer-state-changed.md +134 -0
- package/docs/webhooks/customer-updated.md +49 -0
- package/docs/webhooks/introduction.md +499 -0
- package/docs/webhooks/invoice-created.md +45 -0
- package/docs/webhooks/invoice-overdue.md +53 -0
- package/docs/webhooks/invoice-upcoming.md +43 -0
- package/docs/webhooks/invoice-voided.md +53 -0
- package/docs/webhooks/meta.json +78 -0
- package/docs/webhooks/payment-dispute-resolved.md +52 -0
- package/docs/webhooks/payment-disputed.md +49 -0
- package/docs/webhooks/payment-failed.md +37 -0
- package/docs/webhooks/payment-link-canceled.md +41 -0
- package/docs/webhooks/payment-link-completed.md +47 -0
- package/docs/webhooks/payment-link-created.md +41 -0
- package/docs/webhooks/payment-link-failed.md +45 -0
- package/docs/webhooks/payment-method-attached.md +40 -0
- package/docs/webhooks/payment-method-updated.md +38 -0
- package/docs/webhooks/payment-received.md +45 -0
- package/docs/webhooks/payment-recovered.md +39 -0
- package/docs/webhooks/payment-refunded.md +47 -0
- package/docs/webhooks/payment-retry-failed.md +39 -0
- package/docs/webhooks/payout-available.md +33 -0
- package/docs/webhooks/payout-created.md +48 -0
- package/docs/webhooks/payout-failed.md +52 -0
- package/docs/webhooks/payout-paid.md +48 -0
- package/docs/webhooks/quota-exceeded.md +44 -0
- package/docs/webhooks/quota-threshold-reached.md +41 -0
- package/docs/webhooks/seats-limit-reached.md +39 -0
- package/docs/webhooks/seats-updated.md +39 -0
- package/docs/webhooks/subscription-activated.md +43 -0
- package/docs/webhooks/subscription-canceled.md +57 -0
- package/docs/webhooks/subscription-cancellation-revoked.md +37 -0
- package/docs/webhooks/subscription-cancellation-scheduled.md +45 -0
- package/docs/webhooks/subscription-created.md +35 -0
- package/docs/webhooks/subscription-past-due.md +43 -0
- package/docs/webhooks/subscription-plan-change-revoked.md +50 -0
- package/docs/webhooks/subscription-plan-change-scheduled.md +55 -0
- package/docs/webhooks/subscription-plan-changed.md +43 -0
- package/docs/webhooks/subscription-reactivated.md +53 -0
- package/docs/webhooks/subscription-updated.md +39 -0
- package/docs/webhooks/trial-checkout-ready.md +39 -0
- package/docs/webhooks/trial-converted.md +39 -0
- package/docs/webhooks/trial-expired.md +39 -0
- package/docs/webhooks/trial-started.md +46 -0
- package/docs/webhooks/trial-will-end.md +41 -0
- package/docs/webhooks/usage-recorded.md +41 -0
- package/docs/webhooks.md +782 -0
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -82,6 +82,57 @@ var CustomersResource = class {
|
|
|
82
82
|
constructor(httpClient) {
|
|
83
83
|
this.httpClient = httpClient;
|
|
84
84
|
}
|
|
85
|
+
/** Revoke the unallocated remainder of a customer credit grant. Applied invoice history is unchanged. */
|
|
86
|
+
async revokeCredit(params, options) {
|
|
87
|
+
const { id, creditId } = params;
|
|
88
|
+
return this.httpClient.post(
|
|
89
|
+
`/customers/${id}/credits/${creditId}/revoke`,
|
|
90
|
+
{},
|
|
91
|
+
options
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
/** List currency-specific invoice credit grants and their remaining balances for a customer. */
|
|
95
|
+
async listCredits(params, options) {
|
|
96
|
+
const { id } = params;
|
|
97
|
+
return this.httpClient.get(`/customers/${id}/credits`, void 0, options);
|
|
98
|
+
}
|
|
99
|
+
/** Grant monetary credit in one currency. Credit is applied FIFO before tax to eligible recurring invoices. */
|
|
100
|
+
async createCredit(params, options) {
|
|
101
|
+
const { id, ...rest } = params;
|
|
102
|
+
return this.httpClient.post(`/customers/${id}/credits`, rest, options);
|
|
103
|
+
}
|
|
104
|
+
/** End complimentary access immediately. The next full-price period becomes pending payment and requires checkout; no past period is billed retroactively. */
|
|
105
|
+
async revokePlanGrant(params, options) {
|
|
106
|
+
const { id, grantId, ...rest } = params;
|
|
107
|
+
return this.httpClient.post(
|
|
108
|
+
`/customers/${id}/plan-grants/${grantId}/revoke`,
|
|
109
|
+
rest,
|
|
110
|
+
options
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
/** Give the grant a remaining number of billing cycles, set an exact deadline, or keep it active until revoked. */
|
|
114
|
+
async updatePlanGrant(params, options) {
|
|
115
|
+
const { id, grantId, ...rest } = params;
|
|
116
|
+
return this.httpClient.patch(
|
|
117
|
+
`/customers/${id}/plan-grants/${grantId}`,
|
|
118
|
+
rest,
|
|
119
|
+
options
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
/** List the independent audit timeline for paid-plan access granted without checkout or payment credentials. */
|
|
123
|
+
async listPlanGrants(params, options) {
|
|
124
|
+
const { id } = params;
|
|
125
|
+
return this.httpClient.get(
|
|
126
|
+
`/customers/${id}/plan-grants`,
|
|
127
|
+
void 0,
|
|
128
|
+
options
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
/** 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. */
|
|
132
|
+
async createPlanGrant(params, options) {
|
|
133
|
+
const { id, ...rest } = params;
|
|
134
|
+
return this.httpClient.post(`/customers/${id}/plan-grants`, rest, options);
|
|
135
|
+
}
|
|
85
136
|
/** Retrieve a customer by their public ID, including subscription status and metadata. */
|
|
86
137
|
async get(params, options) {
|
|
87
138
|
const { id } = params;
|
|
@@ -187,31 +238,61 @@ var InvoicesResource = class {
|
|
|
187
238
|
}
|
|
188
239
|
};
|
|
189
240
|
|
|
241
|
+
// src/resources/markets.ts
|
|
242
|
+
var MarketsResource = class {
|
|
243
|
+
constructor(httpClient) {
|
|
244
|
+
this.httpClient = httpClient;
|
|
245
|
+
}
|
|
246
|
+
/** Get one reusable market. */
|
|
247
|
+
async get(params, options) {
|
|
248
|
+
const { id } = params;
|
|
249
|
+
return this.httpClient.get(`/markets/${id}`, void 0, options);
|
|
250
|
+
}
|
|
251
|
+
/** Replace the name, countries, and metadata of a market. */
|
|
252
|
+
async update(params, options) {
|
|
253
|
+
const { id, ...rest } = params;
|
|
254
|
+
return this.httpClient.patch(`/markets/${id}`, rest, options);
|
|
255
|
+
}
|
|
256
|
+
/** Delete an unused market. Markets referenced by prices or subscriptions cannot be deleted. */
|
|
257
|
+
async delete(params, options) {
|
|
258
|
+
const { id } = params;
|
|
259
|
+
return this.httpClient.delete(`/markets/${id}`, void 0, options);
|
|
260
|
+
}
|
|
261
|
+
/** List reusable country groups that resolve market-specific prices independently from currency. */
|
|
262
|
+
async list() {
|
|
263
|
+
return this.httpClient.get("/markets");
|
|
264
|
+
}
|
|
265
|
+
/** Create a reusable market without attaching it to a plan or price. Countries can belong to only one active market. */
|
|
266
|
+
async create(params, options) {
|
|
267
|
+
return this.httpClient.post("/markets", params, options);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
190
271
|
// src/resources/offers.ts
|
|
191
272
|
var OffersResource = class {
|
|
192
273
|
constructor(httpClient) {
|
|
193
274
|
this.httpClient = httpClient;
|
|
194
275
|
}
|
|
195
|
-
/** Retrieve
|
|
276
|
+
/** Retrieve reusable offer terms by public ID. */
|
|
196
277
|
async get(params, options) {
|
|
197
278
|
const { id } = params;
|
|
198
279
|
return this.httpClient.get(`/offers/${id}`, void 0, options);
|
|
199
280
|
}
|
|
200
|
-
/** Replace
|
|
281
|
+
/** Replace reusable offer terms. Existing applications keep their immutable accepted terms. */
|
|
201
282
|
async update(params, options) {
|
|
202
283
|
const { id, ...rest } = params;
|
|
203
284
|
return this.httpClient.patch(`/offers/${id}`, rest, options);
|
|
204
285
|
}
|
|
205
|
-
/** Soft-delete an
|
|
286
|
+
/** Soft-delete an Offer. Existing applications and their accepted terms remain available for billing and audit. */
|
|
206
287
|
async delete(params, options) {
|
|
207
288
|
const { id } = params;
|
|
208
289
|
return this.httpClient.delete(`/offers/${id}`, void 0, options);
|
|
209
290
|
}
|
|
210
|
-
/** List
|
|
291
|
+
/** List reusable offer terms. Offers are independent from plans, prices, eligibility, and distribution channels. */
|
|
211
292
|
async list(params, options) {
|
|
212
293
|
return this.httpClient.get("/offers", params, options);
|
|
213
294
|
}
|
|
214
|
-
/** Create
|
|
295
|
+
/** Create reusable offer terms without assigning a plan, price, eligibility rule, or distribution channel. */
|
|
215
296
|
async create(params, options) {
|
|
216
297
|
return this.httpClient.post("/offers", params, options);
|
|
217
298
|
}
|
|
@@ -259,9 +340,12 @@ var PayoutsResource = class {
|
|
|
259
340
|
async request(params, options) {
|
|
260
341
|
return this.httpClient.post("/payouts", params, options);
|
|
261
342
|
}
|
|
262
|
-
/**
|
|
263
|
-
|
|
264
|
-
|
|
343
|
+
/**
|
|
344
|
+
* Deprecated. Complete business and identity verification in the Commet dashboard. This endpoint no longer accepts or processes KYC data.
|
|
345
|
+
* @deprecated
|
|
346
|
+
*/
|
|
347
|
+
async completeVerification(options) {
|
|
348
|
+
return this.httpClient.post("/payouts/verification", {}, options);
|
|
265
349
|
}
|
|
266
350
|
};
|
|
267
351
|
|
|
@@ -442,44 +526,6 @@ var PortalResource = class {
|
|
|
442
526
|
}
|
|
443
527
|
};
|
|
444
528
|
|
|
445
|
-
// src/resources/pricing.ts
|
|
446
|
-
var PricingResource = class {
|
|
447
|
-
constructor(httpClient) {
|
|
448
|
-
this.httpClient = httpClient;
|
|
449
|
-
}
|
|
450
|
-
/** Get one reusable pricing market group. */
|
|
451
|
-
async getMarketGroup(params, options) {
|
|
452
|
-
const { id } = params;
|
|
453
|
-
return this.httpClient.get(
|
|
454
|
-
`/pricing/market-groups/${id}`,
|
|
455
|
-
void 0,
|
|
456
|
-
options
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
/** Replace the name, countries, and metadata of a pricing market group. */
|
|
460
|
-
async updateMarketGroup(params, options) {
|
|
461
|
-
const { id, ...rest } = params;
|
|
462
|
-
return this.httpClient.patch(`/pricing/market-groups/${id}`, rest, options);
|
|
463
|
-
}
|
|
464
|
-
/** Delete an unused pricing market group. Groups referenced by prices or subscriptions cannot be deleted. */
|
|
465
|
-
async deleteMarketGroup(params, options) {
|
|
466
|
-
const { id } = params;
|
|
467
|
-
return this.httpClient.delete(
|
|
468
|
-
`/pricing/market-groups/${id}`,
|
|
469
|
-
void 0,
|
|
470
|
-
options
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
/** List reusable country groups used to resolve market-specific prices independently from currency. */
|
|
474
|
-
async listMarketGroups() {
|
|
475
|
-
return this.httpClient.get("/pricing/market-groups");
|
|
476
|
-
}
|
|
477
|
-
/** Create a reusable country group. Countries can belong to only one active group; each price chooses its currency independently. */
|
|
478
|
-
async createMarketGroup(params, options) {
|
|
479
|
-
return this.httpClient.post("/pricing/market-groups", params, options);
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
|
|
483
529
|
// src/resources/promo-codes.ts
|
|
484
530
|
var PromoCodesResource = class {
|
|
485
531
|
constructor(httpClient) {
|
|
@@ -499,7 +545,7 @@ var PromoCodesResource = class {
|
|
|
499
545
|
async list(params, options) {
|
|
500
546
|
return this.httpClient.get("/promo-codes", params, options);
|
|
501
547
|
}
|
|
502
|
-
/** Create a distribution code for an existing
|
|
548
|
+
/** Create a distribution code for an existing Offer. The referenced Offer owns the benefit and duration; the promo code owns redemption restrictions. */
|
|
503
549
|
async create(params, options) {
|
|
504
550
|
return this.httpClient.post("/promo-codes", params, options);
|
|
505
551
|
}
|
|
@@ -616,7 +662,7 @@ var SubscriptionsResource = class {
|
|
|
616
662
|
const { id, ...rest } = params;
|
|
617
663
|
return this.httpClient.post(`/subscriptions/${id}/cancel`, rest, options);
|
|
618
664
|
}
|
|
619
|
-
/** Upgrade or change billing interval immediately, optionally applying
|
|
665
|
+
/** Upgrade or change billing interval immediately, optionally applying an Offer. Scheduled changes do not accept offers. */
|
|
620
666
|
async changePlan(params, options) {
|
|
621
667
|
const { id, ...rest } = params;
|
|
622
668
|
return this.httpClient.post(
|
|
@@ -630,6 +676,20 @@ var SubscriptionsResource = class {
|
|
|
630
676
|
const { id, ...rest } = params;
|
|
631
677
|
return this.httpClient.post(`/subscriptions/${id}/credits`, rest, options);
|
|
632
678
|
}
|
|
679
|
+
/** 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. */
|
|
680
|
+
async applyOffer(params, options) {
|
|
681
|
+
const { id, ...rest } = params;
|
|
682
|
+
return this.httpClient.put(`/subscriptions/${id}/offer`, rest, options);
|
|
683
|
+
}
|
|
684
|
+
/** Remove the quoted direct Offer from a subscription's pending payment checkout. The existing checkout URL remains unchanged and returns to its undiscounted price. */
|
|
685
|
+
async removeOffer(params, options) {
|
|
686
|
+
const { id } = params;
|
|
687
|
+
return this.httpClient.delete(
|
|
688
|
+
`/subscriptions/${id}/offer`,
|
|
689
|
+
void 0,
|
|
690
|
+
options
|
|
691
|
+
);
|
|
692
|
+
}
|
|
633
693
|
/** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
|
|
634
694
|
async updatePaymentMethod(params, options) {
|
|
635
695
|
const { id, ...rest } = params;
|
|
@@ -639,7 +699,7 @@ var SubscriptionsResource = class {
|
|
|
639
699
|
options
|
|
640
700
|
);
|
|
641
701
|
}
|
|
642
|
-
/** Preview proration details for an immediate plan change
|
|
702
|
+
/** 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. */
|
|
643
703
|
async previewChange(params, options) {
|
|
644
704
|
const { id, ...rest } = params;
|
|
645
705
|
return this.httpClient.post(
|
|
@@ -648,7 +708,7 @@ var SubscriptionsResource = class {
|
|
|
648
708
|
options
|
|
649
709
|
);
|
|
650
710
|
}
|
|
651
|
-
/** 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
|
|
711
|
+
/** 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. */
|
|
652
712
|
async reactivate(params, options) {
|
|
653
713
|
const { id, ...rest } = params;
|
|
654
714
|
return this.httpClient.post(
|
|
@@ -684,7 +744,7 @@ var SubscriptionsResource = class {
|
|
|
684
744
|
async list(params, options) {
|
|
685
745
|
return this.httpClient.get("/subscriptions", params, options);
|
|
686
746
|
}
|
|
687
|
-
/** 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
|
|
747
|
+
/** 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. */
|
|
688
748
|
async create(params, options) {
|
|
689
749
|
return this.httpClient.post("/subscriptions", params, options);
|
|
690
750
|
}
|
|
@@ -695,15 +755,18 @@ var TestClockResource = class {
|
|
|
695
755
|
constructor(httpClient) {
|
|
696
756
|
this.httpClient = httpClient;
|
|
697
757
|
}
|
|
698
|
-
/**
|
|
758
|
+
/**
|
|
759
|
+
* Deprecated. POST /test-clock now advances time and processes every due billing deadline in one durable run.
|
|
760
|
+
* @deprecated
|
|
761
|
+
*/
|
|
699
762
|
async processBilling(options) {
|
|
700
763
|
return this.httpClient.post("/test-clock/process-billing", {}, options);
|
|
701
764
|
}
|
|
702
|
-
/** Returns the organization's current test clock state. Sandbox only. */
|
|
765
|
+
/** Returns the organization's current test clock state and latest durable run. Sandbox only. */
|
|
703
766
|
async get() {
|
|
704
767
|
return this.httpClient.get("/test-clock");
|
|
705
768
|
}
|
|
706
|
-
/**
|
|
769
|
+
/** 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. */
|
|
707
770
|
async advance(params, options) {
|
|
708
771
|
return this.httpClient.post("/test-clock", params, options);
|
|
709
772
|
}
|
|
@@ -764,13 +827,13 @@ var GeneratedResources = class {
|
|
|
764
827
|
this.featureAccess = new FeatureAccessResource(http);
|
|
765
828
|
this.features = new FeaturesResource(http);
|
|
766
829
|
this.invoices = new InvoicesResource(http);
|
|
830
|
+
this.markets = new MarketsResource(http);
|
|
767
831
|
this.offers = new OffersResource(http);
|
|
768
832
|
this.payments = new PaymentsResource(http);
|
|
769
833
|
this.payouts = new PayoutsResource(http);
|
|
770
834
|
this.planGroups = new PlanGroupsResource(http);
|
|
771
835
|
this.plans = new PlansResource(http);
|
|
772
836
|
this.portal = new PortalResource(http);
|
|
773
|
-
this.pricing = new PricingResource(http);
|
|
774
837
|
this.promoCodes = new PromoCodesResource(http);
|
|
775
838
|
this.provisioning = new ProvisioningResource(http);
|
|
776
839
|
this.quota = new QuotaResource(http);
|
|
@@ -872,37 +935,63 @@ var GeneratedWebhooksResource = class extends Webhooks {
|
|
|
872
935
|
|
|
873
936
|
// src/types/common.ts
|
|
874
937
|
var CommetError = class extends Error {
|
|
875
|
-
constructor(message, code, statusCode, details) {
|
|
938
|
+
constructor(message, code, statusCode, details, context) {
|
|
876
939
|
super(message);
|
|
877
940
|
this.code = code;
|
|
878
941
|
this.statusCode = statusCode;
|
|
879
942
|
this.details = details;
|
|
880
943
|
this.name = "CommetError";
|
|
944
|
+
this.type = context?.type;
|
|
945
|
+
this.param = context?.param;
|
|
946
|
+
this.requestId = context?.requestId;
|
|
947
|
+
this.docUrl = context?.docUrl;
|
|
948
|
+
}
|
|
949
|
+
toJSON() {
|
|
950
|
+
return {
|
|
951
|
+
name: this.name,
|
|
952
|
+
message: this.message,
|
|
953
|
+
type: this.type,
|
|
954
|
+
code: this.code,
|
|
955
|
+
statusCode: this.statusCode,
|
|
956
|
+
param: this.param,
|
|
957
|
+
details: this.details,
|
|
958
|
+
requestId: this.requestId,
|
|
959
|
+
docUrl: this.docUrl
|
|
960
|
+
};
|
|
881
961
|
}
|
|
882
962
|
};
|
|
883
963
|
var CommetAPIError = class extends CommetError {
|
|
884
|
-
constructor(message, statusCode, code, details, errorDetail) {
|
|
885
|
-
super(message, code, statusCode, details
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
964
|
+
constructor(message, statusCode, code, details, errorDetail, responseContext) {
|
|
965
|
+
super(message, code, statusCode, details, {
|
|
966
|
+
type: errorDetail?.type,
|
|
967
|
+
param: errorDetail?.param,
|
|
968
|
+
requestId: responseContext?.requestId,
|
|
969
|
+
docUrl: errorDetail?.doc_url
|
|
970
|
+
});
|
|
889
971
|
this.name = "CommetAPIError";
|
|
890
|
-
this.type = errorDetail?.type;
|
|
891
|
-
this.param = errorDetail?.param;
|
|
892
|
-
this.docUrl = errorDetail?.doc_url;
|
|
893
972
|
}
|
|
894
973
|
};
|
|
895
|
-
var CommetValidationError = class extends
|
|
896
|
-
constructor(message, validationErrors) {
|
|
897
|
-
super(
|
|
974
|
+
var CommetValidationError = class extends CommetAPIError {
|
|
975
|
+
constructor(message, validationErrors, statusCode = 422, errorDetail, responseContext) {
|
|
976
|
+
super(
|
|
977
|
+
message,
|
|
978
|
+
statusCode,
|
|
979
|
+
errorDetail?.code ?? "validation_error",
|
|
980
|
+
errorDetail?.details,
|
|
981
|
+
errorDetail,
|
|
982
|
+
responseContext
|
|
983
|
+
);
|
|
898
984
|
this.validationErrors = validationErrors;
|
|
899
985
|
this.name = "CommetValidationError";
|
|
900
986
|
}
|
|
987
|
+
toJSON() {
|
|
988
|
+
return { ...super.toJSON(), validationErrors: this.validationErrors };
|
|
989
|
+
}
|
|
901
990
|
};
|
|
902
991
|
|
|
903
992
|
// src/version.ts
|
|
904
|
-
var API_VERSION = "2026-07-
|
|
905
|
-
var SDK_VERSION = "
|
|
993
|
+
var API_VERSION = "2026-07-31";
|
|
994
|
+
var SDK_VERSION = "9.1.0";
|
|
906
995
|
|
|
907
996
|
// src/utils/telemetry.ts
|
|
908
997
|
var registeredIntegrations = /* @__PURE__ */ new Set();
|
|
@@ -1070,6 +1159,7 @@ var _CommetHTTPClient = class _CommetHTTPClient {
|
|
|
1070
1159
|
}
|
|
1071
1160
|
const requestStart = Date.now();
|
|
1072
1161
|
const response = await fetch(url, requestConfig);
|
|
1162
|
+
const responseContext = readResponseContext(response.headers);
|
|
1073
1163
|
if (this.config.debug) {
|
|
1074
1164
|
console.log(
|
|
1075
1165
|
`[Commet SDK] Response status: ${response.status} ${response.statusText}`
|
|
@@ -1096,7 +1186,9 @@ var _CommetHTTPClient = class _CommetHTTPClient {
|
|
|
1096
1186
|
`Invalid JSON response: ${response.status} ${response.statusText}`,
|
|
1097
1187
|
response.status,
|
|
1098
1188
|
"INVALID_JSON",
|
|
1099
|
-
{ responseText }
|
|
1189
|
+
{ responseText },
|
|
1190
|
+
void 0,
|
|
1191
|
+
responseContext
|
|
1100
1192
|
);
|
|
1101
1193
|
}
|
|
1102
1194
|
if (!response.ok) {
|
|
@@ -1118,38 +1210,47 @@ var _CommetHTTPClient = class _CommetHTTPClient {
|
|
|
1118
1210
|
JSON.stringify(responseData, null, 2)
|
|
1119
1211
|
);
|
|
1120
1212
|
}
|
|
1121
|
-
const
|
|
1122
|
-
const errorObj = typeof parsed.error === "object" && parsed.error !== null ? parsed.error : {};
|
|
1213
|
+
const errorObj = readObjectProperty(responseData, "error");
|
|
1123
1214
|
const errorDetail = {
|
|
1124
|
-
type: errorObj
|
|
1125
|
-
code: errorObj
|
|
1126
|
-
message: errorObj
|
|
1127
|
-
param: errorObj
|
|
1128
|
-
details: errorObj
|
|
1129
|
-
doc_url: errorObj
|
|
1215
|
+
type: readStringProperty(errorObj, "type") ?? "api_error",
|
|
1216
|
+
code: readStringProperty(errorObj, "code") ?? "unknown",
|
|
1217
|
+
message: readStringProperty(errorObj, "message") ?? `Request failed with status ${response.status}`,
|
|
1218
|
+
param: readStringProperty(errorObj, "param"),
|
|
1219
|
+
details: Reflect.get(errorObj, "details"),
|
|
1220
|
+
doc_url: readStringProperty(errorObj, "doc_url")
|
|
1130
1221
|
};
|
|
1131
1222
|
if (errorDetail.code === "validation_error" && Array.isArray(errorDetail.details)) {
|
|
1132
1223
|
const errors = {};
|
|
1133
1224
|
for (const detail of errorDetail.details) {
|
|
1134
|
-
|
|
1135
|
-
|
|
1225
|
+
const field = readStringProperty(detail, "field");
|
|
1226
|
+
const message = readStringProperty(detail, "message");
|
|
1227
|
+
if (!(field && message)) continue;
|
|
1228
|
+
if (!errors[field]) errors[field] = [];
|
|
1229
|
+
errors[field].push(message);
|
|
1136
1230
|
}
|
|
1137
|
-
throw new CommetValidationError(
|
|
1231
|
+
throw new CommetValidationError(
|
|
1232
|
+
errorDetail.message,
|
|
1233
|
+
errors,
|
|
1234
|
+
response.status,
|
|
1235
|
+
errorDetail,
|
|
1236
|
+
responseContext
|
|
1237
|
+
);
|
|
1138
1238
|
}
|
|
1139
1239
|
throw new CommetAPIError(
|
|
1140
1240
|
errorDetail.message,
|
|
1141
1241
|
response.status,
|
|
1142
1242
|
errorDetail.code,
|
|
1143
1243
|
errorDetail.details,
|
|
1144
|
-
errorDetail
|
|
1244
|
+
errorDetail,
|
|
1245
|
+
responseContext
|
|
1145
1246
|
);
|
|
1146
1247
|
}
|
|
1147
1248
|
if (this.config.debug) {
|
|
1148
1249
|
console.log("[Commet SDK] Response:", responseData);
|
|
1149
1250
|
}
|
|
1150
|
-
if (this.telemetryEnabled) {
|
|
1251
|
+
if (this.telemetryEnabled && responseContext.requestId) {
|
|
1151
1252
|
this.lastRequestMetrics = {
|
|
1152
|
-
requestId:
|
|
1253
|
+
requestId: responseContext.requestId,
|
|
1153
1254
|
durationMs: Date.now() - requestStart
|
|
1154
1255
|
};
|
|
1155
1256
|
}
|
|
@@ -1228,6 +1329,19 @@ var _CommetHTTPClient = class _CommetHTTPClient {
|
|
|
1228
1329
|
};
|
|
1229
1330
|
_CommetHTTPClient.BODY_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
|
|
1230
1331
|
var CommetHTTPClient = _CommetHTTPClient;
|
|
1332
|
+
function readResponseContext(headers) {
|
|
1333
|
+
return { requestId: headers.get("x-request-id") ?? void 0 };
|
|
1334
|
+
}
|
|
1335
|
+
function readObjectProperty(value, property) {
|
|
1336
|
+
if (typeof value !== "object" || value === null) return {};
|
|
1337
|
+
const propertyValue = Reflect.get(value, property);
|
|
1338
|
+
return typeof propertyValue === "object" && propertyValue !== null ? propertyValue : {};
|
|
1339
|
+
}
|
|
1340
|
+
function readStringProperty(value, property) {
|
|
1341
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
1342
|
+
const propertyValue = Reflect.get(value, property);
|
|
1343
|
+
return typeof propertyValue === "string" ? propertyValue : void 0;
|
|
1344
|
+
}
|
|
1231
1345
|
|
|
1232
1346
|
// src/utils/update-check.ts
|
|
1233
1347
|
var NPM_DIST_TAGS_URL = "https://registry.npmjs.org/-/package/%40commet%2Fnode/dist-tags";
|
|
@@ -1309,10 +1423,10 @@ function claimSdkUpdateCheck() {
|
|
|
1309
1423
|
Reflect.set(globalThis, UPDATE_CHECK_STATE_KEY, true);
|
|
1310
1424
|
return true;
|
|
1311
1425
|
}
|
|
1312
|
-
function shouldCheckForSdkUpdates() {
|
|
1313
|
-
if (
|
|
1314
|
-
if (
|
|
1315
|
-
return
|
|
1426
|
+
function shouldCheckForSdkUpdates(environment = process.env) {
|
|
1427
|
+
if (environment.NODE_ENV !== "development") return false;
|
|
1428
|
+
if (environment.CI) return false;
|
|
1429
|
+
return environment.COMMET_NO_UPDATE_CHECK !== "1";
|
|
1316
1430
|
}
|
|
1317
1431
|
async function checkForSdkUpdate(installedVersion) {
|
|
1318
1432
|
try {
|