@commet/node 1.1.0 → 1.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/README.md +4 -4
- package/dist/index.d.mts +169 -177
- package/dist/index.d.ts +169 -177
- package/dist/index.js +95 -193
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -193
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -129,6 +129,13 @@ declare class CommetHTTPClient {
|
|
|
129
129
|
private sleep;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
interface FeatureParams {
|
|
133
|
+
externalId: string;
|
|
134
|
+
code: GeneratedFeatureCode;
|
|
135
|
+
}
|
|
136
|
+
type GetFeatureParams = FeatureParams;
|
|
137
|
+
type CheckFeatureParams = FeatureParams;
|
|
138
|
+
type CanUseFeatureParams = FeatureParams;
|
|
132
139
|
interface FeatureAccess {
|
|
133
140
|
code: string;
|
|
134
141
|
name: string;
|
|
@@ -165,21 +172,24 @@ declare class FeaturesResource {
|
|
|
165
172
|
*
|
|
166
173
|
* @example
|
|
167
174
|
* ```typescript
|
|
168
|
-
* const seats = await commet.features.get("team_members", "user_123");
|
|
175
|
+
* const seats = await commet.features.get({ code: "team_members", externalId: "user_123" });
|
|
169
176
|
* console.log(seats.current, seats.included, seats.remaining);
|
|
170
177
|
* ```
|
|
171
178
|
*/
|
|
172
|
-
get(
|
|
179
|
+
get(params: GetFeatureParams, options?: RequestOptions): Promise<ApiResponse<FeatureAccess>>;
|
|
173
180
|
/**
|
|
174
181
|
* Check if a boolean feature is enabled for a customer
|
|
175
182
|
*
|
|
176
183
|
* @example
|
|
177
184
|
* ```typescript
|
|
178
|
-
* const { allowed } = await commet.features.check(
|
|
185
|
+
* const { allowed } = await commet.features.check({
|
|
186
|
+
* code: "custom_branding",
|
|
187
|
+
* externalId: "user_123"
|
|
188
|
+
* });
|
|
179
189
|
* if (!allowed) redirect("/upgrade");
|
|
180
190
|
* ```
|
|
181
191
|
*/
|
|
182
|
-
check(
|
|
192
|
+
check(params: CheckFeatureParams, options?: RequestOptions): Promise<ApiResponse<CheckResult>>;
|
|
183
193
|
/**
|
|
184
194
|
* Check if customer can use one more unit of a feature
|
|
185
195
|
*
|
|
@@ -188,7 +198,10 @@ declare class FeaturesResource {
|
|
|
188
198
|
*
|
|
189
199
|
* @example
|
|
190
200
|
* ```typescript
|
|
191
|
-
* const { allowed, willBeCharged } = await commet.features.canUse(
|
|
201
|
+
* const { allowed, willBeCharged } = await commet.features.canUse({
|
|
202
|
+
* code: "team_members",
|
|
203
|
+
* externalId: "user_123"
|
|
204
|
+
* });
|
|
192
205
|
*
|
|
193
206
|
* if (!allowed) {
|
|
194
207
|
* return { error: "Upgrade to add more members" };
|
|
@@ -199,13 +212,13 @@ declare class FeaturesResource {
|
|
|
199
212
|
* }
|
|
200
213
|
* ```
|
|
201
214
|
*/
|
|
202
|
-
canUse(
|
|
215
|
+
canUse(params: CanUseFeatureParams, options?: RequestOptions): Promise<ApiResponse<CanUseResult>>;
|
|
203
216
|
/**
|
|
204
217
|
* List all features for a customer's active subscription
|
|
205
218
|
*
|
|
206
219
|
* @example
|
|
207
220
|
* ```typescript
|
|
208
|
-
* const features = await commet.features.list("user_123");
|
|
221
|
+
* const features = await commet.features.list({ externalId: "user_123" });
|
|
209
222
|
* for (const feature of features) {
|
|
210
223
|
* console.log(feature.code, feature.allowed);
|
|
211
224
|
* }
|
|
@@ -214,6 +227,44 @@ declare class FeaturesResource {
|
|
|
214
227
|
list(externalId: string, options?: RequestOptions): Promise<ApiResponse<FeatureAccess[]>>;
|
|
215
228
|
}
|
|
216
229
|
|
|
230
|
+
interface PortalAccess {
|
|
231
|
+
success: boolean;
|
|
232
|
+
message: string;
|
|
233
|
+
portalUrl: string;
|
|
234
|
+
}
|
|
235
|
+
interface GetUrlByCustomerId {
|
|
236
|
+
customerId: CustomerID;
|
|
237
|
+
email?: never;
|
|
238
|
+
externalId?: never;
|
|
239
|
+
}
|
|
240
|
+
interface GetUrlByExternalId {
|
|
241
|
+
externalId: string;
|
|
242
|
+
email?: never;
|
|
243
|
+
customerId?: never;
|
|
244
|
+
}
|
|
245
|
+
interface GetUrlByEmail {
|
|
246
|
+
email: string;
|
|
247
|
+
customerId?: never;
|
|
248
|
+
externalId?: never;
|
|
249
|
+
}
|
|
250
|
+
type GetUrlParams = GetUrlByCustomerId | GetUrlByExternalId | GetUrlByEmail;
|
|
251
|
+
/**
|
|
252
|
+
* Portal resource - Generate customer portal access
|
|
253
|
+
*/
|
|
254
|
+
declare class PortalResource {
|
|
255
|
+
private httpClient;
|
|
256
|
+
constructor(httpClient: CommetHTTPClient);
|
|
257
|
+
/**
|
|
258
|
+
* Get a portal URL
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const portal = await commet.portal.getUrl({ externalId: 'user_123' });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
getUrl(params: GetUrlParams, options?: RequestOptions): Promise<ApiResponse<PortalAccess>>;
|
|
266
|
+
}
|
|
267
|
+
|
|
217
268
|
interface SeatEvent {
|
|
218
269
|
id: string;
|
|
219
270
|
organizationId: string;
|
|
@@ -344,78 +395,6 @@ declare class SeatsResource {
|
|
|
344
395
|
getAllBalances(params: GetAllBalancesParams): Promise<ApiResponse<Record<string, SeatBalance>>>;
|
|
345
396
|
}
|
|
346
397
|
|
|
347
|
-
interface UsageEvent {
|
|
348
|
-
id: EventID;
|
|
349
|
-
organizationId: string;
|
|
350
|
-
customerId: CustomerID;
|
|
351
|
-
eventType: GeneratedEventType;
|
|
352
|
-
idempotencyKey?: string;
|
|
353
|
-
ts: string;
|
|
354
|
-
properties?: UsageEventProperty[];
|
|
355
|
-
createdAt: string;
|
|
356
|
-
}
|
|
357
|
-
interface UsageEventProperty {
|
|
358
|
-
id: string;
|
|
359
|
-
usageEventId: EventID;
|
|
360
|
-
property: string;
|
|
361
|
-
value: string;
|
|
362
|
-
createdAt: string;
|
|
363
|
-
}
|
|
364
|
-
interface BatchResult$1<T> {
|
|
365
|
-
successful: T[];
|
|
366
|
-
failed: Array<{
|
|
367
|
-
index: number;
|
|
368
|
-
error: string;
|
|
369
|
-
data: TrackParams;
|
|
370
|
-
}>;
|
|
371
|
-
}
|
|
372
|
-
interface TrackParams {
|
|
373
|
-
eventType: GeneratedEventType;
|
|
374
|
-
customerId?: CustomerID;
|
|
375
|
-
externalId?: string;
|
|
376
|
-
idempotencyKey?: string;
|
|
377
|
-
value?: number;
|
|
378
|
-
timestamp?: string;
|
|
379
|
-
properties?: Record<string, string>;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Usage resource - Track consumption events for usage-based billing
|
|
383
|
-
*/
|
|
384
|
-
declare class UsageResource {
|
|
385
|
-
private httpClient;
|
|
386
|
-
constructor(httpClient: CommetHTTPClient);
|
|
387
|
-
/**
|
|
388
|
-
* Track a usage event
|
|
389
|
-
*
|
|
390
|
-
* @example
|
|
391
|
-
* ```typescript
|
|
392
|
-
* await commet.usage.track({
|
|
393
|
-
* externalId: 'user_123',
|
|
394
|
-
* eventType: 'api_call',
|
|
395
|
-
* idempotencyKey: `evt_${requestId}`,
|
|
396
|
-
* properties: { endpoint: '/users', method: 'GET' }
|
|
397
|
-
* });
|
|
398
|
-
* ```
|
|
399
|
-
*/
|
|
400
|
-
track(params: TrackParams, options?: RequestOptions): Promise<ApiResponse<UsageEvent>>;
|
|
401
|
-
/**
|
|
402
|
-
* Track multiple usage events in a batch
|
|
403
|
-
*
|
|
404
|
-
* @example
|
|
405
|
-
* ```typescript
|
|
406
|
-
* await commet.usage.trackBatch({
|
|
407
|
-
* events: [
|
|
408
|
-
* { externalId: 'user_123', eventType: 'api_call', idempotencyKey: 'evt_1' },
|
|
409
|
-
* { externalId: 'user_456', eventType: 'api_call', idempotencyKey: 'evt_2' }
|
|
410
|
-
* ]
|
|
411
|
-
* });
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
trackBatch(params: {
|
|
415
|
-
events: TrackParams[];
|
|
416
|
-
}, options?: RequestOptions): Promise<ApiResponse<BatchResult$1<UsageEvent>>>;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
398
|
type PlanID = `plan_${string}`;
|
|
420
399
|
type BillingInterval = "monthly" | "quarterly" | "yearly";
|
|
421
400
|
type FeatureType = "boolean" | "metered" | "seats";
|
|
@@ -579,13 +558,14 @@ type CreateSubscriptionParams = CustomerIdentifier & PlanIdentifier & {
|
|
|
579
558
|
startDate?: string;
|
|
580
559
|
};
|
|
581
560
|
type ChangePlanParams = PlanIdentifier & {
|
|
561
|
+
subscriptionId: string;
|
|
582
562
|
billingInterval?: BillingInterval;
|
|
583
563
|
};
|
|
584
564
|
interface CancelParams {
|
|
565
|
+
subscriptionId: string;
|
|
585
566
|
reason?: string;
|
|
586
567
|
immediate?: boolean;
|
|
587
568
|
}
|
|
588
|
-
type GetSubscriptionParams = CustomerIdentifier;
|
|
589
569
|
/**
|
|
590
570
|
* Subscription resource for managing subscriptions (plan-first model)
|
|
591
571
|
*
|
|
@@ -613,70 +593,106 @@ declare class SubscriptionsResource {
|
|
|
613
593
|
*
|
|
614
594
|
* @example
|
|
615
595
|
* ```typescript
|
|
616
|
-
* const sub = await commet.subscriptions.get(
|
|
596
|
+
* const sub = await commet.subscriptions.get('user_123');
|
|
617
597
|
* ```
|
|
618
598
|
*/
|
|
619
|
-
get(
|
|
599
|
+
get(externalId: string): Promise<ApiResponse<ActiveSubscription | null>>;
|
|
620
600
|
/**
|
|
621
601
|
* Change the plan of a subscription (upgrade/downgrade)
|
|
622
602
|
*
|
|
623
603
|
* @example
|
|
624
604
|
* ```typescript
|
|
625
|
-
* await commet.subscriptions.changePlan(
|
|
605
|
+
* await commet.subscriptions.changePlan({
|
|
606
|
+
* subscriptionId: 'sub_xxx',
|
|
626
607
|
* planCode: 'enterprise' // autocomplete works after `commet pull`
|
|
627
608
|
* });
|
|
628
609
|
* ```
|
|
629
610
|
*/
|
|
630
|
-
changePlan(
|
|
611
|
+
changePlan(params: ChangePlanParams, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
|
|
631
612
|
/**
|
|
632
613
|
* Cancel a subscription
|
|
633
614
|
*
|
|
634
615
|
* @example
|
|
635
616
|
* ```typescript
|
|
636
|
-
* await commet.subscriptions.cancel(
|
|
617
|
+
* await commet.subscriptions.cancel({
|
|
618
|
+
* subscriptionId: 'sub_xxx',
|
|
637
619
|
* reason: 'switched_to_competitor'
|
|
638
620
|
* });
|
|
639
621
|
* ```
|
|
640
622
|
*/
|
|
641
|
-
cancel(
|
|
623
|
+
cancel(params: CancelParams, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
|
|
642
624
|
}
|
|
643
625
|
|
|
644
|
-
interface
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
portalUrl: string;
|
|
648
|
-
}
|
|
649
|
-
interface GetUrlByCustomerId {
|
|
626
|
+
interface UsageEvent {
|
|
627
|
+
id: EventID;
|
|
628
|
+
organizationId: string;
|
|
650
629
|
customerId: CustomerID;
|
|
651
|
-
|
|
652
|
-
|
|
630
|
+
eventType: GeneratedEventType;
|
|
631
|
+
idempotencyKey?: string;
|
|
632
|
+
ts: string;
|
|
633
|
+
properties?: UsageEventProperty[];
|
|
634
|
+
createdAt: string;
|
|
653
635
|
}
|
|
654
|
-
interface
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
636
|
+
interface UsageEventProperty {
|
|
637
|
+
id: string;
|
|
638
|
+
usageEventId: EventID;
|
|
639
|
+
property: string;
|
|
640
|
+
value: string;
|
|
641
|
+
createdAt: string;
|
|
658
642
|
}
|
|
659
|
-
interface
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
643
|
+
interface BatchResult$1<T> {
|
|
644
|
+
successful: T[];
|
|
645
|
+
failed: Array<{
|
|
646
|
+
index: number;
|
|
647
|
+
error: string;
|
|
648
|
+
data: TrackParams;
|
|
649
|
+
}>;
|
|
650
|
+
}
|
|
651
|
+
interface TrackParams {
|
|
652
|
+
eventType: GeneratedEventType;
|
|
653
|
+
customerId?: CustomerID;
|
|
654
|
+
externalId?: string;
|
|
655
|
+
idempotencyKey?: string;
|
|
656
|
+
value?: number;
|
|
657
|
+
timestamp?: string;
|
|
658
|
+
properties?: Record<string, string>;
|
|
663
659
|
}
|
|
664
|
-
type GetUrlParams = GetUrlByCustomerId | GetUrlByExternalId | GetUrlByEmail;
|
|
665
660
|
/**
|
|
666
|
-
*
|
|
661
|
+
* Usage resource - Track consumption events for usage-based billing
|
|
667
662
|
*/
|
|
668
|
-
declare class
|
|
663
|
+
declare class UsageResource {
|
|
669
664
|
private httpClient;
|
|
670
665
|
constructor(httpClient: CommetHTTPClient);
|
|
671
666
|
/**
|
|
672
|
-
*
|
|
667
|
+
* Track a usage event
|
|
673
668
|
*
|
|
674
669
|
* @example
|
|
675
670
|
* ```typescript
|
|
676
|
-
*
|
|
671
|
+
* await commet.usage.track({
|
|
672
|
+
* externalId: 'user_123',
|
|
673
|
+
* eventType: 'api_call',
|
|
674
|
+
* idempotencyKey: `evt_${requestId}`,
|
|
675
|
+
* properties: { endpoint: '/users', method: 'GET' }
|
|
676
|
+
* });
|
|
677
677
|
* ```
|
|
678
678
|
*/
|
|
679
|
-
|
|
679
|
+
track(params: TrackParams, options?: RequestOptions): Promise<ApiResponse<UsageEvent>>;
|
|
680
|
+
/**
|
|
681
|
+
* Track multiple usage events in a batch
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```typescript
|
|
685
|
+
* await commet.usage.trackBatch({
|
|
686
|
+
* events: [
|
|
687
|
+
* { externalId: 'user_123', eventType: 'api_call', idempotencyKey: 'evt_1' },
|
|
688
|
+
* { externalId: 'user_456', eventType: 'api_call', idempotencyKey: 'evt_2' }
|
|
689
|
+
* ]
|
|
690
|
+
* });
|
|
691
|
+
* ```
|
|
692
|
+
*/
|
|
693
|
+
trackBatch(params: {
|
|
694
|
+
events: TrackParams[];
|
|
695
|
+
}, options?: RequestOptions): Promise<ApiResponse<BatchResult$1<UsageEvent>>>;
|
|
680
696
|
}
|
|
681
697
|
|
|
682
698
|
/**
|
|
@@ -697,82 +713,52 @@ declare class PortalResource {
|
|
|
697
713
|
*/
|
|
698
714
|
declare class CustomerContext {
|
|
699
715
|
private readonly externalId;
|
|
700
|
-
private readonly
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
716
|
+
private readonly featuresResource;
|
|
717
|
+
private readonly seatsResource;
|
|
718
|
+
private readonly usageResource;
|
|
719
|
+
private readonly subscriptionsResource;
|
|
720
|
+
private readonly portalResource;
|
|
721
|
+
constructor(externalId: string, resources: {
|
|
722
|
+
features: FeaturesResource;
|
|
723
|
+
seats: SeatsResource;
|
|
724
|
+
usage: UsageResource;
|
|
725
|
+
subscriptions: SubscriptionsResource;
|
|
726
|
+
portal: PortalResource;
|
|
727
|
+
});
|
|
728
|
+
/**
|
|
729
|
+
* Feature access methods - delegates to FeaturesResource
|
|
704
730
|
*/
|
|
705
731
|
features: {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
get: (code: GeneratedFeatureCode, options?: RequestOptions) => Promise<ApiResponse<FeatureAccess>>;
|
|
710
|
-
/**
|
|
711
|
-
* Check if a boolean feature is enabled
|
|
712
|
-
*/
|
|
713
|
-
check: (code: GeneratedFeatureCode, options?: RequestOptions) => Promise<ApiResponse<CheckResult>>;
|
|
714
|
-
/**
|
|
715
|
-
* Check if customer can use one more unit
|
|
716
|
-
*/
|
|
717
|
-
canUse: (code: GeneratedFeatureCode, options?: RequestOptions) => Promise<ApiResponse<CanUseResult>>;
|
|
718
|
-
/**
|
|
719
|
-
* List all features
|
|
720
|
-
*/
|
|
732
|
+
get: (code: string, options?: RequestOptions) => Promise<ApiResponse<FeatureAccess>>;
|
|
733
|
+
check: (code: string, options?: RequestOptions) => Promise<ApiResponse<CheckResult>>;
|
|
734
|
+
canUse: (code: string, options?: RequestOptions) => Promise<ApiResponse<CanUseResult>>;
|
|
721
735
|
list: (options?: RequestOptions) => Promise<ApiResponse<FeatureAccess[]>>;
|
|
722
736
|
};
|
|
723
737
|
/**
|
|
724
|
-
* Seat management methods
|
|
738
|
+
* Seat management methods - delegates to SeatsResource
|
|
725
739
|
*/
|
|
726
740
|
seats: {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* Remove seats
|
|
733
|
-
*/
|
|
734
|
-
remove: (seatType: GeneratedSeatType, count?: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
735
|
-
/**
|
|
736
|
-
* Set total seat count
|
|
737
|
-
*/
|
|
738
|
-
set: (seatType: GeneratedSeatType, count: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
739
|
-
/**
|
|
740
|
-
* Get current seat balance
|
|
741
|
-
*/
|
|
742
|
-
getBalance: (seatType: GeneratedSeatType, options?: RequestOptions) => Promise<ApiResponse<SeatBalance>>;
|
|
741
|
+
add: (seatType: string, count?: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
742
|
+
remove: (seatType: string, count?: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
743
|
+
set: (seatType: string, count: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
744
|
+
getBalance: (seatType: string) => Promise<ApiResponse<SeatBalance>>;
|
|
743
745
|
};
|
|
744
746
|
/**
|
|
745
|
-
* Usage tracking methods
|
|
747
|
+
* Usage tracking methods - delegates to UsageResource
|
|
746
748
|
*/
|
|
747
749
|
usage: {
|
|
748
|
-
|
|
749
|
-
* Track a usage event
|
|
750
|
-
*/
|
|
751
|
-
track: (eventType: GeneratedEventType, properties?: Record<string, string>, options?: RequestOptions) => Promise<ApiResponse<UsageEvent>>;
|
|
750
|
+
track: (eventType: string, properties?: Record<string, string>, options?: RequestOptions) => Promise<ApiResponse<UsageEvent>>;
|
|
752
751
|
};
|
|
753
752
|
/**
|
|
754
|
-
* Subscription methods
|
|
753
|
+
* Subscription methods - delegates to SubscriptionsResource
|
|
755
754
|
*/
|
|
756
755
|
subscription: {
|
|
757
|
-
|
|
758
|
-
* Get active subscription
|
|
759
|
-
*/
|
|
760
|
-
get: (options?: RequestOptions) => Promise<ApiResponse<ActiveSubscription | null>>;
|
|
761
|
-
/**
|
|
762
|
-
* Cancel subscription
|
|
763
|
-
*/
|
|
764
|
-
cancel: (params?: {
|
|
765
|
-
reason?: string;
|
|
766
|
-
immediate?: boolean;
|
|
767
|
-
}, options?: RequestOptions) => Promise<ApiResponse<Subscription>>;
|
|
756
|
+
get: () => Promise<ApiResponse<ActiveSubscription | null>>;
|
|
768
757
|
};
|
|
769
758
|
/**
|
|
770
|
-
* Portal methods
|
|
759
|
+
* Portal methods - delegates to PortalResource
|
|
771
760
|
*/
|
|
772
761
|
portal: {
|
|
773
|
-
/**
|
|
774
|
-
* Get customer portal URL
|
|
775
|
-
*/
|
|
776
762
|
getUrl: (options?: RequestOptions) => Promise<ApiResponse<PortalAccess>>;
|
|
777
763
|
};
|
|
778
764
|
}
|
|
@@ -817,6 +803,7 @@ interface CreateParams {
|
|
|
817
803
|
address?: CustomerAddress;
|
|
818
804
|
}
|
|
819
805
|
interface UpdateParams {
|
|
806
|
+
customerId: CustomerID;
|
|
820
807
|
externalId?: string;
|
|
821
808
|
email?: string;
|
|
822
809
|
legalName?: string;
|
|
@@ -864,7 +851,7 @@ declare class CustomersResource {
|
|
|
864
851
|
/**
|
|
865
852
|
* Update a customer
|
|
866
853
|
*/
|
|
867
|
-
update(
|
|
854
|
+
update(params: UpdateParams, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
868
855
|
/**
|
|
869
856
|
* List customers with optional filters
|
|
870
857
|
*/
|
|
@@ -902,6 +889,16 @@ interface WebhookData {
|
|
|
902
889
|
* Supported webhook events
|
|
903
890
|
*/
|
|
904
891
|
type WebhookEvent = "subscription.created" | "subscription.activated" | "subscription.canceled" | "subscription.updated";
|
|
892
|
+
interface VerifyParams {
|
|
893
|
+
payload: string;
|
|
894
|
+
signature: string | null;
|
|
895
|
+
secret: string;
|
|
896
|
+
}
|
|
897
|
+
interface VerifyAndParseParams {
|
|
898
|
+
rawBody: string;
|
|
899
|
+
signature: string | null;
|
|
900
|
+
secret: string;
|
|
901
|
+
}
|
|
905
902
|
/**
|
|
906
903
|
* Webhooks resource for signature verification
|
|
907
904
|
*/
|
|
@@ -939,7 +936,7 @@ declare class Webhooks {
|
|
|
939
936
|
* }
|
|
940
937
|
* ```
|
|
941
938
|
*/
|
|
942
|
-
verify(
|
|
939
|
+
verify(params: VerifyParams): boolean;
|
|
943
940
|
/**
|
|
944
941
|
* Generate HMAC-SHA256 signature (internal use)
|
|
945
942
|
* @internal
|
|
@@ -948,18 +945,13 @@ declare class Webhooks {
|
|
|
948
945
|
/**
|
|
949
946
|
* Parse and verify webhook payload in one step
|
|
950
947
|
*
|
|
951
|
-
* @param rawBody - Raw request body as string
|
|
952
|
-
* @param signature - Value from X-Commet-Signature header
|
|
953
|
-
* @param secret - Your webhook secret from Commet dashboard
|
|
954
|
-
* @returns Parsed payload if valid, null if invalid
|
|
955
|
-
*
|
|
956
948
|
* @example
|
|
957
949
|
* ```typescript
|
|
958
|
-
* const payload = commet.webhooks.verifyAndParse(
|
|
950
|
+
* const payload = commet.webhooks.verifyAndParse({
|
|
959
951
|
* rawBody,
|
|
960
952
|
* signature,
|
|
961
|
-
* process.env.COMMET_WEBHOOK_SECRET
|
|
962
|
-
* );
|
|
953
|
+
* secret: process.env.COMMET_WEBHOOK_SECRET
|
|
954
|
+
* });
|
|
963
955
|
*
|
|
964
956
|
* if (!payload) {
|
|
965
957
|
* return new Response('Invalid signature', { status: 401 });
|
|
@@ -971,7 +963,7 @@ declare class Webhooks {
|
|
|
971
963
|
* }
|
|
972
964
|
* ```
|
|
973
965
|
*/
|
|
974
|
-
verifyAndParse(
|
|
966
|
+
verifyAndParse(params: VerifyAndParseParams): WebhookPayload | null;
|
|
975
967
|
}
|
|
976
968
|
|
|
977
969
|
/**
|
|
@@ -1021,4 +1013,4 @@ declare function isProduction(environment: Environment): boolean;
|
|
|
1021
1013
|
* Commet SDK - Billing and usage tracking for SaaS
|
|
1022
1014
|
*/
|
|
1023
1015
|
|
|
1024
|
-
export { type ActiveSubscription, type AddParams as AddSeatsParams, type ApiResponse, type BillingInterval, type CanUseResult, type CancelParams, type ChangePlanParams, type CheckResult, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateParams as CreateCustomerParams, type CreateSubscriptionParams, type Currency, type Customer, type CustomerAddress, CustomerContext, type CustomerID, type BatchResult as CustomersBatchResult, type Environment, type EventID, type FeatureAccess, type FeatureSummary, type FeatureType, type GeneratedEventType, type GeneratedFeatureCode, type GeneratedPlanCode, type GeneratedSeatType, type GetAllBalancesParams, type GetBalanceParams, type
|
|
1016
|
+
export { type ActiveSubscription, type AddParams as AddSeatsParams, type ApiResponse, type BillingInterval, type CanUseFeatureParams, type CanUseResult, type CancelParams, type ChangePlanParams, type CheckFeatureParams, type CheckResult, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateParams as CreateCustomerParams, type CreateSubscriptionParams, type Currency, type Customer, type CustomerAddress, CustomerContext, type CustomerID, type BatchResult as CustomersBatchResult, type Environment, type EventID, type FeatureAccess, type FeatureSummary, type FeatureType, type GeneratedEventType, type GeneratedFeatureCode, type GeneratedPlanCode, type GeneratedSeatType, type GetAllBalancesParams, type GetBalanceParams, type GetFeatureParams, type GetUrlParams, type ListCustomersParams, type ListPlansParams, type PaginatedList, type PaginatedResponse, type Plan, type PlanDetail, type PlanFeature, type PlanID, type PlanPrice, type PortalAccess, type RemoveParams as RemoveSeatsParams, type RequestOptions, type SeatBalance, type SeatEvent, type SetAllParams as SetAllSeatsParams, type SetParams as SetSeatsParams, type Subscription, type SubscriptionStatus, type TrackParams, type UpdateParams as UpdateCustomerParams, type BatchResult$1 as UsageBatchResult, type UsageEvent, type UsageEventProperty, type WebhookData, type WebhookEvent, type WebhookPayload, Webhooks, Commet as default, isProduction, isSandbox };
|