@kelviq/mcp-server 0.2.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/LICENSE +21 -0
- package/README.md +322 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +45 -0
- package/dist/config.js.map +1 -0
- package/dist/docs/README.md +128 -0
- package/dist/docs/api-reference/authentication.md +41 -0
- package/dist/docs/backend-integration/node-sdk.md +1040 -0
- package/dist/docs/backend-integration/python-sdk.md +1198 -0
- package/dist/docs/changelog/app.md +80 -0
- package/dist/docs/changelog/checkout-api.md +59 -0
- package/dist/docs/changelog/js-promotions-ui.md +14 -0
- package/dist/docs/changelog/js-sdk.md +281 -0
- package/dist/docs/changelog/node-sdk.md +378 -0
- package/dist/docs/changelog/python-sdk.md +456 -0
- package/dist/docs/changelog/react-sdk.md +580 -0
- package/dist/docs/checkout/checkout-configuration.md +434 -0
- package/dist/docs/coustomers-management/overview.md +111 -0
- package/dist/docs/customer-portal/overview.md +81 -0
- package/dist/docs/frontend-integration/js-sdk.md +676 -0
- package/dist/docs/frontend-integration/promotions-ui-js.md +265 -0
- package/dist/docs/frontend-integration/react-promotions-ui.md +361 -0
- package/dist/docs/frontend-integration/react-sdk.md +1187 -0
- package/dist/docs/frontend-integration/react-ui.md +771 -0
- package/dist/docs/getstarted/fees.md +160 -0
- package/dist/docs/getstarted/introduction-to-kelviq.md +80 -0
- package/dist/docs/getstarted/merchant-of-record.md +64 -0
- package/dist/docs/getstarted/review-process.md +190 -0
- package/dist/docs/guides/subscription-integration-for-nextjs.md +512 -0
- package/dist/docs/guides/subscription-integration.md +291 -0
- package/dist/docs/guides/webhooks.md +963 -0
- package/dist/docs/legal/approved-prohibited-policy.md +252 -0
- package/dist/docs/legal/buyer-terms.md +177 -0
- package/dist/docs/legal/compliant-user-flow.md +216 -0
- package/dist/docs/legal/master-service-agreement.md +404 -0
- package/dist/docs/legal/payment-flow-diagram.md +188 -0
- package/dist/docs/legal/seller-terms.md +169 -0
- package/dist/docs/manifest.json +415 -0
- package/dist/docs/monetization/offerings.md +156 -0
- package/dist/docs/monetization/pricing-tables.md +226 -0
- package/dist/docs/monetization/targeting-rules.md +278 -0
- package/dist/docs/openapi.json +5479 -0
- package/dist/docs/payouts/overview.md +43 -0
- package/dist/docs/payouts/payout-account.md +12 -0
- package/dist/docs/payouts/transactions.md +23 -0
- package/dist/docs/product-catalog/digital-downloads.md +117 -0
- package/dist/docs/product-catalog/discounts.md +69 -0
- package/dist/docs/product-catalog/entitlements.md +428 -0
- package/dist/docs/product-catalog/free-and-trials.md +36 -0
- package/dist/docs/product-catalog/license-keys.md +324 -0
- package/dist/docs/product-catalog/links.md +92 -0
- package/dist/docs/product-catalog/location-based-pricing.md +41 -0
- package/dist/docs/product-catalog/one-time-payments.md +24 -0
- package/dist/docs/product-catalog/plans.md +199 -0
- package/dist/docs/product-catalog/products.md +60 -0
- package/dist/docs/product-catalog/subscriptions.md +29 -0
- package/dist/docs/product-catalog/tax-settings.md +37 -0
- package/dist/docs/product-catalog/usage-based-billing.md +119 -0
- package/dist/docs/promotions/create-a-promotion.md +75 -0
- package/dist/docs/promotions/customize-banner.md +41 -0
- package/dist/docs/promotions/integrate.md +38 -0
- package/dist/docs/promotions/overview.md +51 -0
- package/dist/docs/quickstart/core-concepts.md +146 -0
- package/dist/docs/quickstart/dashboard-setup.md +129 -0
- package/dist/docs/quickstart/integrate-with-your-app.md +149 -0
- package/dist/docs/sales/checkout-sessions.md +58 -0
- package/dist/docs/sales/orders.md +76 -0
- package/dist/http/client.d.ts +28 -0
- package/dist/http/client.js +76 -0
- package/dist/http/client.js.map +1 -0
- package/dist/http/errors.d.ts +20 -0
- package/dist/http/errors.js +58 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/resources/docs-index.d.ts +25 -0
- package/dist/resources/docs-index.js +109 -0
- package/dist/resources/docs-index.js.map +1 -0
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/index.js +73 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/schemas/kelviq.d.ts +1304 -0
- package/dist/schemas/kelviq.js +468 -0
- package/dist/schemas/kelviq.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +41 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/_util.d.ts +15 -0
- package/dist/tools/_util.js +15 -0
- package/dist/tools/_util.js.map +1 -0
- package/dist/tools/checkout.d.ts +3 -0
- package/dist/tools/checkout.js +18 -0
- package/dist/tools/checkout.js.map +1 -0
- package/dist/tools/customers.d.ts +3 -0
- package/dist/tools/customers.js +32 -0
- package/dist/tools/customers.js.map +1 -0
- package/dist/tools/docs.d.ts +2 -0
- package/dist/tools/docs.js +43 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/tools/entitlements.d.ts +3 -0
- package/dist/tools/entitlements.js +22 -0
- package/dist/tools/entitlements.js.map +1 -0
- package/dist/tools/features.d.ts +3 -0
- package/dist/tools/features.js +55 -0
- package/dist/tools/features.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +44 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/licenses.d.ts +3 -0
- package/dist/tools/licenses.js +44 -0
- package/dist/tools/licenses.js.map +1 -0
- package/dist/tools/media.d.ts +3 -0
- package/dist/tools/media.js +18 -0
- package/dist/tools/media.js.map +1 -0
- package/dist/tools/offerings.d.ts +3 -0
- package/dist/tools/offerings.js +21 -0
- package/dist/tools/offerings.js.map +1 -0
- package/dist/tools/partner.d.ts +3 -0
- package/dist/tools/partner.js +55 -0
- package/dist/tools/partner.js.map +1 -0
- package/dist/tools/plan-entitlements.d.ts +3 -0
- package/dist/tools/plan-entitlements.js +56 -0
- package/dist/tools/plan-entitlements.js.map +1 -0
- package/dist/tools/plan-files.d.ts +3 -0
- package/dist/tools/plan-files.js +43 -0
- package/dist/tools/plan-files.js.map +1 -0
- package/dist/tools/plans.d.ts +3 -0
- package/dist/tools/plans.js +120 -0
- package/dist/tools/plans.js.map +1 -0
- package/dist/tools/portal.d.ts +3 -0
- package/dist/tools/portal.js +18 -0
- package/dist/tools/portal.js.map +1 -0
- package/dist/tools/product-files.d.ts +3 -0
- package/dist/tools/product-files.js +31 -0
- package/dist/tools/product-files.js.map +1 -0
- package/dist/tools/product-settings.d.ts +3 -0
- package/dist/tools/product-settings.js +31 -0
- package/dist/tools/product-settings.js.map +1 -0
- package/dist/tools/products.d.ts +3 -0
- package/dist/tools/products.js +69 -0
- package/dist/tools/products.js.map +1 -0
- package/dist/tools/promotions.d.ts +3 -0
- package/dist/tools/promotions.js +19 -0
- package/dist/tools/promotions.js.map +1 -0
- package/dist/tools/subscriptions.d.ts +3 -0
- package/dist/tools/subscriptions.js +63 -0
- package/dist/tools/subscriptions.js.map +1 -0
- package/dist/tools/usage.d.ts +3 -0
- package/dist/tools/usage.js +18 -0
- package/dist/tools/usage.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Node SDK"
|
|
3
|
+
slug: "changelog/node-sdk"
|
|
4
|
+
section: "changelog"
|
|
5
|
+
description: "Changelog for @kelviq/node-sdk"
|
|
6
|
+
---
|
|
7
|
+
<Update label="v2.5.0" description="May 10, 2026">
|
|
8
|
+
|
|
9
|
+
### New Features
|
|
10
|
+
|
|
11
|
+
#### Subscription Update — `trialEnd` Parameter
|
|
12
|
+
|
|
13
|
+
`subscriptions.update()` now accepts an optional `trialEnd` field on `UpdateSubscriptionPayload` to control the trial period when updating a subscription.
|
|
14
|
+
|
|
15
|
+
Pass either:
|
|
16
|
+
|
|
17
|
+
- The literal string `"now"` to end any active trial immediately.
|
|
18
|
+
- An ISO 8601 datetime string (e.g. `"2025-12-31T23:59:59Z"`) to set a new trial end date. The datetime must be in the future. Naive datetimes (no timezone designator) are interpreted as UTC.
|
|
19
|
+
- Omit the field to preserve the existing trial behavior on the subscription.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { CHARGE_PERIOD_CHOICES } from '@kelviq/node-sdk';
|
|
23
|
+
|
|
24
|
+
// End the trial now
|
|
25
|
+
await client.subscriptions.update({
|
|
26
|
+
subscriptionId: "sub_node_78058918",
|
|
27
|
+
planIdentifier: "premium-plan-node",
|
|
28
|
+
chargePeriod: CHARGE_PERIOD_CHOICES.MONTHLY,
|
|
29
|
+
trialEnd: "now",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Extend the trial to a specific future date
|
|
33
|
+
await client.subscriptions.update({
|
|
34
|
+
subscriptionId: "sub_node_78058918",
|
|
35
|
+
planIdentifier: "premium-plan-node",
|
|
36
|
+
chargePeriod: CHARGE_PERIOD_CHOICES.MONTHLY,
|
|
37
|
+
trialEnd: "2025-12-31T23:59:59Z",
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The SDK validates `trialEnd` client-side — invalid datetime strings or past datetimes throw `InvalidRequestError` before the request is sent.
|
|
42
|
+
|
|
43
|
+
</Update>
|
|
44
|
+
|
|
45
|
+
<Update label="v2.4.0" description="May 4, 2026">
|
|
46
|
+
|
|
47
|
+
### New Features
|
|
48
|
+
|
|
49
|
+
#### Checkout Session — New Optional Parameters
|
|
50
|
+
|
|
51
|
+
Three new optional fields on `CreateCheckoutSessionPayload` give you more control over the hosted checkout page.
|
|
52
|
+
|
|
53
|
+
**`discountsEnabled`** — controls whether the coupon/discount code field is shown. Defaults to `true`.
|
|
54
|
+
|
|
55
|
+
**`lockEmail`** — when `true`, the email field is pre-filled and locked so the customer cannot change it. Defaults to `false`.
|
|
56
|
+
|
|
57
|
+
**`defaultBillingCountry`** — ISO 3166-1 alpha-2 country code (e.g. `"US"`, `"GB"`) used to pre-fill the billing address country field.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const response = await client.checkout.createSession({
|
|
61
|
+
planIdentifier: "plan-pro-monthly",
|
|
62
|
+
chargePeriod: "MONTHLY",
|
|
63
|
+
customerId: "cust_789",
|
|
64
|
+
successUrl: "https://example.com/success",
|
|
65
|
+
discountsEnabled: false,
|
|
66
|
+
lockEmail: true,
|
|
67
|
+
defaultBillingCountry: "US",
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
</Update>
|
|
72
|
+
|
|
73
|
+
<Update label="v2.3.0" description="April 25, 2026">
|
|
74
|
+
|
|
75
|
+
### New Features
|
|
76
|
+
|
|
77
|
+
#### Webhook Verification
|
|
78
|
+
|
|
79
|
+
A new `validateEvent` helper lets you securely verify incoming webhook requests from Kelviq in one step. It validates the HMAC-SHA256 signature using the three headers Kelviq attaches to every webhook delivery, then returns the parsed event object.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { validateEvent, WebhookVerificationError } from '@kelviq/node-sdk';
|
|
83
|
+
import express from 'express';
|
|
84
|
+
|
|
85
|
+
const app = express();
|
|
86
|
+
|
|
87
|
+
app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
|
|
88
|
+
try {
|
|
89
|
+
const event = validateEvent(
|
|
90
|
+
req.body,
|
|
91
|
+
req.headers,
|
|
92
|
+
'<YOUR_WEBHOOK_SECRET>',
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// Process the event
|
|
96
|
+
console.log('Event type:', event.type);
|
|
97
|
+
|
|
98
|
+
res.sendStatus(202);
|
|
99
|
+
} catch (err) {
|
|
100
|
+
if (err instanceof WebhookVerificationError) {
|
|
101
|
+
return res.sendStatus(403);
|
|
102
|
+
}
|
|
103
|
+
throw err;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**`validateEvent(payload, headers, secret)`**
|
|
109
|
+
|
|
110
|
+
- `payload` — Raw request body as a `string` or `Buffer`. Must be the unparsed body — do not pass a pre-parsed JSON object.
|
|
111
|
+
- `headers` — The request headers object (e.g. `req.headers` in Express). Header lookup is case-insensitive.
|
|
112
|
+
- `secret` — Your webhook signing secret (`kq_whsec_...`) from the Kelviq dashboard.
|
|
113
|
+
|
|
114
|
+
Returns the parsed event as `Record<string, unknown>`. Throws `WebhookVerificationError` if a required header is missing, the signature format is invalid, or the signature does not match.
|
|
115
|
+
|
|
116
|
+
#### `WebhookVerificationError`
|
|
117
|
+
|
|
118
|
+
New error class thrown by `validateEvent` when verification fails. Extends `Error`.
|
|
119
|
+
|
|
120
|
+
</Update>
|
|
121
|
+
|
|
122
|
+
<Update label="v2.2.0" description="April 13, 2026">
|
|
123
|
+
|
|
124
|
+
### New Features
|
|
125
|
+
|
|
126
|
+
#### License Management Module
|
|
127
|
+
|
|
128
|
+
A new `client.license` module provides full lifecycle management for software licenses.
|
|
129
|
+
|
|
130
|
+
**`license.activate({ licenseKey, customerId?, instanceName?, metadata? })`**
|
|
131
|
+
|
|
132
|
+
Activates a license key and creates a new instance. Returns a `LicenseActivateResponse` containing the `instanceId`, `activatedAt`, `expiresOn`, and the full `LicenseDetails` object.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
const response = await client.license.activate({
|
|
136
|
+
licenseKey: "LIC-XXXX-YYYY-ZZZZ",
|
|
137
|
+
customerId: "cust_789",
|
|
138
|
+
instanceName: "My MacBook Pro",
|
|
139
|
+
metadata: { os: "macOS", arch: "arm64" },
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
console.log(response.instanceId);
|
|
143
|
+
console.log(response.license.activationUsage); // e.g. 1
|
|
144
|
+
console.log(response.license.plan.product.name); // e.g. "Kelviq Engine"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**`license.deactivate({ licenseKey, instanceId })`**
|
|
148
|
+
|
|
149
|
+
Deactivates a specific license instance. Returns a `LicenseDeactivateResponse` with `message` and `deactivatedAt`.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const response = await client.license.deactivate({
|
|
153
|
+
licenseKey: "LIC-XXXX-YYYY-ZZZZ",
|
|
154
|
+
instanceId: "8f3e2b1a-5c6d-4e9f-8a0b-1c2d3e4f5g6h",
|
|
155
|
+
});
|
|
156
|
+
console.log(response.message); // "License instance deactivated successfully."
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**`license.validate({ licenseKey, instanceId? })`**
|
|
160
|
+
|
|
161
|
+
Validates a license key and optionally a specific instance. Returns a `LicenseValidateResponse` with `valid`, `code`, `detail`, `metadata`, and the full `LicenseDetails`.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const response = await client.license.validate({
|
|
165
|
+
licenseKey: "LIC-XXXX-YYYY-ZZZZ",
|
|
166
|
+
instanceId: "8f3e2b1a-5c6d-4e9f-8a0b-1c2d3e4f5g6h",
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (response.valid) {
|
|
170
|
+
console.log(`Valid — code: ${response.code}`);
|
|
171
|
+
} else {
|
|
172
|
+
console.log(`Invalid — ${response.detail}`);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### New TypeScript Interfaces
|
|
177
|
+
|
|
178
|
+
- **`LicenseDetails`** — Full license object with `id`, `licenseKey`, `activatedOn`, `expiresOn`, `activationUsage`, `activationLimit`, `enabled`, `customer`, `plan`, and `subscription`.
|
|
179
|
+
- **`LicenseCustomer`** — `{ customerId, name?, email? }` nested in `LicenseDetails`.
|
|
180
|
+
- **`LicensePlan`** — Expanded with `description`, `version`, `isLatest`, and `product` (nested `LicensePlanProduct`).
|
|
181
|
+
- **`LicensePlanProduct`** — `{ id, identifier, name, taxCode?, createdOn?, modifiedOn? }`.
|
|
182
|
+
- **`LicenseActivateResponse`**, **`LicenseDeactivateResponse`**, **`LicenseValidateResponse`** — Typed responses for each operation.
|
|
183
|
+
|
|
184
|
+
#### `SubscriptionData` New Fields
|
|
185
|
+
|
|
186
|
+
Three new fields derived from the subscription's `recurrence` string are now included in `SubscriptionData` (returned within `LicenseDetails.subscription` and customer subscription summaries):
|
|
187
|
+
|
|
188
|
+
- **`billingType`** — `"SUBSCRIPTION"` if the plan has a recurrence, `"ONE_TIME"` otherwise.
|
|
189
|
+
- **`recurrenceUnit`** — Integer unit from the recurrence string (e.g. `1` from `"1 month"`), or `null`.
|
|
190
|
+
- **`recurrenceType`** — Recurrence period in uppercase (e.g. `"MONTH"`), or `null`.
|
|
191
|
+
|
|
192
|
+
</Update>
|
|
193
|
+
|
|
194
|
+
<Update label="v2.1.0" description="April 2, 2026">
|
|
195
|
+
|
|
196
|
+
### New Features
|
|
197
|
+
|
|
198
|
+
#### Customer Portal Module
|
|
199
|
+
|
|
200
|
+
A new `client.portal` module lets you create pre-authenticated customer portal sessions server-side and redirect customers directly to their self-serve portal.
|
|
201
|
+
|
|
202
|
+
**`portal.createSession({ customerId })`**
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
const session = await client.portal.createSession({
|
|
206
|
+
customerId: "cust_789",
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Redirect the customer — no login required
|
|
210
|
+
res.redirect(session.customerPortalUrl);
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Returns `CreatePortalSessionResponse` with:
|
|
214
|
+
|
|
215
|
+
- `token` — Session token authenticating the portal session.
|
|
216
|
+
- `email` — The customer's email address.
|
|
217
|
+
- `customerPortalUrl` — Pre-authenticated URL to redirect the customer to.
|
|
218
|
+
|
|
219
|
+
</Update>
|
|
220
|
+
|
|
221
|
+
<Update label="v2.0.0" description="February 27, 2026">
|
|
222
|
+
|
|
223
|
+
### New Features
|
|
224
|
+
|
|
225
|
+
#### Entitlements Aggregation Engine
|
|
226
|
+
|
|
227
|
+
When a customer has multiple subscriptions, the API can return duplicate `featureId` entries. The SDK now automatically aggregates them into a single `Entitlement` object per feature:
|
|
228
|
+
|
|
229
|
+
- Numeric fields (`usageLimit`, `currentUsage`, `remaining`) are **summed** across all entries
|
|
230
|
+
- `hasAccess` is `true` if **any** raw entry grants access
|
|
231
|
+
- `hardLimit` is `true` if **any** entry sets it
|
|
232
|
+
- All raw entries are preserved in the `.items[]` array
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
const entitlement = await client.entitlements.getEntitlement({
|
|
236
|
+
customerId: "cust_123",
|
|
237
|
+
featureId: "email-sends",
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Aggregated values across all subscriptions
|
|
241
|
+
console.log(entitlement.hasAccess); // true
|
|
242
|
+
console.log(entitlement.usageLimit); // 1500 (e.g., 1000 from base plan + 500 from top-up)
|
|
243
|
+
console.log(entitlement.currentUsage); // 200
|
|
244
|
+
console.log(entitlement.remaining); // 1300
|
|
245
|
+
|
|
246
|
+
// Per-subscription details
|
|
247
|
+
entitlement.items.forEach(item => {
|
|
248
|
+
console.log(item.usageLimit, item.resetAt);
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### `Entitlement` Interface
|
|
253
|
+
|
|
254
|
+
New type representing an aggregated entitlement with an `items: EntitlementDetail[]` field containing the raw entries that were aggregated.
|
|
255
|
+
|
|
256
|
+
#### `getRawEntitlement({ customerId, featureId })`
|
|
257
|
+
|
|
258
|
+
Returns the raw API response for a specific feature (`CheckEntitlementsResponse` with `customerId` wrapper), without any aggregation:
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
const raw = await client.entitlements.getRawEntitlement({
|
|
262
|
+
customerId: "cust_123",
|
|
263
|
+
featureId: "email-sends",
|
|
264
|
+
});
|
|
265
|
+
// { customerId: "cust_123", entitlements: [/* raw entries for email-sends */] }
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
#### `getRawEntitlements({ customerId })`
|
|
269
|
+
|
|
270
|
+
Returns the raw API response for all entitlements, without any aggregation:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
const raw = await client.entitlements.getRawEntitlements({
|
|
274
|
+
customerId: "cust_123",
|
|
275
|
+
});
|
|
276
|
+
// { customerId: "cust_123", entitlements: [/* all raw entries */] }
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### `client.subscription` Deprecated Alias
|
|
280
|
+
|
|
281
|
+
A backward-compatible getter that maps `client.subscription` to `client.subscriptions`, so existing code continues to work during migration.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
### Breaking Changes
|
|
286
|
+
|
|
287
|
+
#### `client.subscription` Renamed to `client.subscriptions`
|
|
288
|
+
|
|
289
|
+
The subscriptions module now uses the plural form for consistency with other modules (`client.customers`, `client.entitlements`, etc.):
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
// Before
|
|
293
|
+
const sub = await client.subscription.get({ subscriptionId: "sub_123" });
|
|
294
|
+
|
|
295
|
+
// After
|
|
296
|
+
const sub = await client.subscriptions.get({ subscriptionId: "sub_123" });
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
The old `client.subscription` accessor still works as a deprecated alias.
|
|
300
|
+
|
|
301
|
+
#### `getEntitlement()` Returns `Entitlement | null`
|
|
302
|
+
|
|
303
|
+
Previously returned `CheckEntitlementsResponse` (the raw API shape with a `customerId` wrapper). Now returns a single aggregated `Entitlement` object with an `.items[]` array, or `null` if the feature is not found:
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
// Before
|
|
307
|
+
const response = await client.entitlements.getEntitlement({
|
|
308
|
+
customerId: "cust_123",
|
|
309
|
+
featureId: "email-sends",
|
|
310
|
+
});
|
|
311
|
+
// { customerId: "cust_123", entitlements: [...] }
|
|
312
|
+
|
|
313
|
+
// After
|
|
314
|
+
const entitlement = await client.entitlements.getEntitlement({
|
|
315
|
+
customerId: "cust_123",
|
|
316
|
+
featureId: "email-sends",
|
|
317
|
+
});
|
|
318
|
+
// { featureId: "email-sends", hasAccess: true, currentUsage: 200, ... }
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
For the original raw API response, use `getRawEntitlement()`.
|
|
322
|
+
|
|
323
|
+
#### `getAllEntitlements()` Removed
|
|
324
|
+
|
|
325
|
+
Replaced by `getEntitlements()`, which returns `Record<string, Entitlement>` — a record keyed by `featureId` with aggregated values and an `.items[]` array:
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
// Before
|
|
329
|
+
const response = await client.entitlements.getAllEntitlements({ customerId: "cust_123" });
|
|
330
|
+
|
|
331
|
+
// After
|
|
332
|
+
const entitlements = await client.entitlements.getEntitlements({ customerId: "cust_123" });
|
|
333
|
+
// { "email-sends": Entitlement, "api-calls": Entitlement, ... }
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
For the original raw API response, use `getRawEntitlements()`.
|
|
337
|
+
|
|
338
|
+
#### `FeatureType` Changed: `"LIMIT"` → `"CUSTOMIZABLE"`
|
|
339
|
+
|
|
340
|
+
The `FeatureType` union no longer includes `"LIMIT"`. Update any code that matches on this value:
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
// Before
|
|
344
|
+
if (entitlement.featureType === "LIMIT") { ... }
|
|
345
|
+
|
|
346
|
+
// After
|
|
347
|
+
if (entitlement.featureType === "CUSTOMIZABLE") { ... }
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
#### `resetAt` Removed from Aggregated `Entitlement`
|
|
351
|
+
|
|
352
|
+
Since `resetAt` can differ across subscriptions, it is only available on individual items:
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
// Before
|
|
356
|
+
console.log(entitlement.resetAt);
|
|
357
|
+
|
|
358
|
+
// After
|
|
359
|
+
entitlement.items.forEach(item => {
|
|
360
|
+
console.log(item.resetAt); // per-subscription reset date
|
|
361
|
+
});
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
### Fixed
|
|
367
|
+
|
|
368
|
+
- Fixed Python-style `try/except` syntax in subscription update documentation — replaced with JavaScript `try...catch`.
|
|
369
|
+
- Added missing `try/catch` error handling to subscription cancel documentation example.
|
|
370
|
+
- Removed invalid JSON comments (`// Server-generated UUID`) from documentation response blocks.
|
|
371
|
+
- Fixed trailing comma in checkout session JSON response example.
|
|
372
|
+
- Fixed `"Node SDK Use"` typo → `"Node SDK User"` in create customer documentation.
|
|
373
|
+
- Fixed `True` → `true`, `bool` → `boolean` in `hasAccess` documentation.
|
|
374
|
+
- Replaced "Pydantic model" references with "TypeScript Interface" or "Object".
|
|
375
|
+
- Replaced "Dictionary" with "Object" in parameter descriptions.
|
|
376
|
+
- Fixed Python-style `ACCESS_TOKEN = "..."` → `const ACCESS_TOKEN = "...";` in setup example.
|
|
377
|
+
|
|
378
|
+
</Update>
|