@commet/node 1.5.0 → 1.6.1
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/dist/index.d.mts +97 -88
- package/dist/index.d.ts +97 -88
- package/dist/index.js +28 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -9,8 +9,9 @@ type CommetConfig = {
|
|
|
9
9
|
interface ApiResponse<T = unknown> {
|
|
10
10
|
success: boolean;
|
|
11
11
|
data?: T;
|
|
12
|
-
|
|
12
|
+
code?: string;
|
|
13
13
|
message?: string;
|
|
14
|
+
details?: unknown;
|
|
14
15
|
hasMore?: boolean;
|
|
15
16
|
nextCursor?: string;
|
|
16
17
|
}
|
|
@@ -57,39 +58,24 @@ interface RequestOptions {
|
|
|
57
58
|
* Generated types interface - augmented by CLI after 'commet pull'
|
|
58
59
|
*
|
|
59
60
|
* This interface gets filled by module augmentation when you run `commet pull`.
|
|
60
|
-
* The CLI generates a .commet.d.ts file that augments this interface with your
|
|
61
|
-
* organization's specific
|
|
61
|
+
* The CLI generates a .commet/types.d.ts file that augments this interface with your
|
|
62
|
+
* organization's specific feature codes, seat types, and plan codes.
|
|
62
63
|
*
|
|
63
64
|
* @example
|
|
64
65
|
* // After running `commet pull`, TypeScript will automatically know your types:
|
|
65
|
-
* await commet.usage.
|
|
66
|
-
*
|
|
67
|
-
*
|
|
66
|
+
* await commet.usage.track({
|
|
67
|
+
* feature: 'api_calls', // Autocomplete works!
|
|
68
|
+
* externalId: 'user_123'
|
|
68
69
|
* });
|
|
69
70
|
*/
|
|
70
71
|
interface CommetGeneratedTypes {
|
|
71
72
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Helper type that provides fallback to string if types are not generated
|
|
74
|
-
*/
|
|
75
|
-
type GeneratedEventType = CommetGeneratedTypes extends {
|
|
76
|
-
eventType: infer T;
|
|
77
|
-
} ? T : string;
|
|
78
|
-
/**
|
|
79
|
-
* Helper type that provides fallback to string if types are not generated
|
|
80
|
-
*/
|
|
81
73
|
type GeneratedSeatType = CommetGeneratedTypes extends {
|
|
82
74
|
seatType: infer T;
|
|
83
75
|
} ? T : string;
|
|
84
|
-
/**
|
|
85
|
-
* Helper type that provides fallback to string if types are not generated
|
|
86
|
-
*/
|
|
87
76
|
type GeneratedPlanCode = CommetGeneratedTypes extends {
|
|
88
77
|
planCode: infer T;
|
|
89
78
|
} ? T : string;
|
|
90
|
-
/**
|
|
91
|
-
* Helper type that provides fallback to string if types are not generated
|
|
92
|
-
*/
|
|
93
79
|
type GeneratedFeatureCode = CommetGeneratedTypes extends {
|
|
94
80
|
featureCode: infer T;
|
|
95
81
|
} ? T : string;
|
|
@@ -402,6 +388,7 @@ interface PlanPrice {
|
|
|
402
388
|
billingInterval: BillingInterval;
|
|
403
389
|
price: number;
|
|
404
390
|
isDefault: boolean;
|
|
391
|
+
trialDays: number;
|
|
405
392
|
}
|
|
406
393
|
interface PlanFeature {
|
|
407
394
|
code: string;
|
|
@@ -417,30 +404,46 @@ interface Plan {
|
|
|
417
404
|
id: PlanID;
|
|
418
405
|
code: string;
|
|
419
406
|
name: string;
|
|
420
|
-
description
|
|
407
|
+
description: string | null;
|
|
421
408
|
isPublic: boolean;
|
|
409
|
+
isFree: boolean;
|
|
422
410
|
isDefault: boolean;
|
|
423
|
-
trialDays: number;
|
|
424
411
|
sortOrder: number;
|
|
425
412
|
prices: PlanPrice[];
|
|
426
413
|
features: PlanFeature[];
|
|
427
414
|
createdAt: string;
|
|
428
415
|
}
|
|
429
|
-
interface
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
416
|
+
interface PlanDetailPrice {
|
|
417
|
+
billingInterval: BillingInterval;
|
|
418
|
+
price: number;
|
|
419
|
+
isDefault: boolean;
|
|
420
|
+
trialDays: number;
|
|
421
|
+
introOffer: {
|
|
422
|
+
enabled: boolean;
|
|
423
|
+
discountType: "percentage" | "amount" | null;
|
|
424
|
+
discountValue: number | null;
|
|
425
|
+
durationCycles: number | null;
|
|
426
|
+
} | null;
|
|
427
|
+
}
|
|
428
|
+
interface PlanDetailFeature extends PlanFeature {
|
|
429
|
+
unitName: string | null;
|
|
430
|
+
overage: {
|
|
431
|
+
enabled: boolean;
|
|
432
|
+
model: "per_unit" | "tiered" | null;
|
|
433
|
+
unitPrice: number | null;
|
|
434
|
+
} | null;
|
|
435
|
+
}
|
|
436
|
+
interface PlanDetail {
|
|
437
|
+
id: PlanID;
|
|
438
|
+
code: string;
|
|
439
|
+
name: string;
|
|
440
|
+
description: string | null;
|
|
441
|
+
isPublic: boolean;
|
|
442
|
+
isDefault: boolean;
|
|
443
|
+
sortOrder: number;
|
|
444
|
+
prices: PlanDetailPrice[];
|
|
445
|
+
features: PlanDetailFeature[];
|
|
446
|
+
createdAt: string;
|
|
444
447
|
updatedAt: string;
|
|
445
448
|
}
|
|
446
449
|
interface ListPlansParams extends ListParams {
|
|
@@ -498,12 +501,12 @@ interface ActiveSubscription {
|
|
|
498
501
|
id: string;
|
|
499
502
|
name: string;
|
|
500
503
|
basePrice: number;
|
|
501
|
-
billingInterval: BillingInterval;
|
|
504
|
+
billingInterval: BillingInterval | null;
|
|
502
505
|
};
|
|
503
506
|
name: string;
|
|
504
|
-
description
|
|
507
|
+
description: string | null;
|
|
505
508
|
status: SubscriptionStatus;
|
|
506
|
-
trialEndsAt
|
|
509
|
+
trialEndsAt: string | null;
|
|
507
510
|
currentPeriod: {
|
|
508
511
|
start: string;
|
|
509
512
|
end: string;
|
|
@@ -511,13 +514,35 @@ interface ActiveSubscription {
|
|
|
511
514
|
};
|
|
512
515
|
features: FeatureSummary[];
|
|
513
516
|
startDate: string;
|
|
514
|
-
endDate
|
|
517
|
+
endDate: string | null;
|
|
515
518
|
billingDayOfMonth: number;
|
|
516
519
|
nextBillingDate: string;
|
|
517
|
-
checkoutUrl
|
|
520
|
+
checkoutUrl: string | null;
|
|
518
521
|
createdAt: string;
|
|
519
522
|
updatedAt: string;
|
|
520
523
|
}
|
|
524
|
+
interface CreatedSubscription {
|
|
525
|
+
id: string;
|
|
526
|
+
customerId: string;
|
|
527
|
+
externalId: string;
|
|
528
|
+
planId: string;
|
|
529
|
+
planName: string;
|
|
530
|
+
name: string;
|
|
531
|
+
status: SubscriptionStatus;
|
|
532
|
+
billingInterval: BillingInterval | null;
|
|
533
|
+
trialEndsAt: string | null;
|
|
534
|
+
startDate: string;
|
|
535
|
+
endDate: string | null;
|
|
536
|
+
currentPeriodStart: string | null;
|
|
537
|
+
currentPeriodEnd: string | null;
|
|
538
|
+
billingDayOfMonth: number;
|
|
539
|
+
checkoutUrl: string | null;
|
|
540
|
+
createdAt: string;
|
|
541
|
+
updatedAt: string;
|
|
542
|
+
introOfferEndsAt: string | null;
|
|
543
|
+
introOfferDiscountType: "percentage" | "amount" | null;
|
|
544
|
+
introOfferDiscountValue: number | null;
|
|
545
|
+
}
|
|
521
546
|
interface Subscription {
|
|
522
547
|
id: string;
|
|
523
548
|
customerId: string;
|
|
@@ -559,10 +584,6 @@ type CreateSubscriptionParams = CustomerIdentifier & PlanIdentifier & {
|
|
|
559
584
|
startDate?: string;
|
|
560
585
|
successUrl?: string;
|
|
561
586
|
};
|
|
562
|
-
type ChangePlanParams = PlanIdentifier & {
|
|
563
|
-
subscriptionId: string;
|
|
564
|
-
billingInterval?: BillingInterval;
|
|
565
|
-
};
|
|
566
587
|
interface CancelParams {
|
|
567
588
|
subscriptionId: string;
|
|
568
589
|
reason?: string;
|
|
@@ -589,7 +610,7 @@ declare class SubscriptionsResource {
|
|
|
589
610
|
* });
|
|
590
611
|
* ```
|
|
591
612
|
*/
|
|
592
|
-
create(params: CreateSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<
|
|
613
|
+
create(params: CreateSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<CreatedSubscription>>;
|
|
593
614
|
/**
|
|
594
615
|
* Get the active subscription for a customer
|
|
595
616
|
*
|
|
@@ -599,18 +620,6 @@ declare class SubscriptionsResource {
|
|
|
599
620
|
* ```
|
|
600
621
|
*/
|
|
601
622
|
get(externalId: string): Promise<ApiResponse<ActiveSubscription | null>>;
|
|
602
|
-
/**
|
|
603
|
-
* Change the plan of a subscription (upgrade/downgrade)
|
|
604
|
-
*
|
|
605
|
-
* @example
|
|
606
|
-
* ```typescript
|
|
607
|
-
* await commet.subscriptions.changePlan({
|
|
608
|
-
* subscriptionId: 'sub_xxx',
|
|
609
|
-
* planCode: 'enterprise' // autocomplete works after `commet pull`
|
|
610
|
-
* });
|
|
611
|
-
* ```
|
|
612
|
-
*/
|
|
613
|
-
changePlan(params: ChangePlanParams, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
|
|
614
623
|
/**
|
|
615
624
|
* Cancel a subscription
|
|
616
625
|
*
|
|
@@ -651,7 +660,7 @@ interface BatchResult$1<T> {
|
|
|
651
660
|
}>;
|
|
652
661
|
}
|
|
653
662
|
interface TrackParams {
|
|
654
|
-
feature:
|
|
663
|
+
feature: GeneratedFeatureCode;
|
|
655
664
|
customerId?: CustomerID;
|
|
656
665
|
externalId?: string;
|
|
657
666
|
idempotencyKey?: string;
|
|
@@ -766,6 +775,32 @@ declare class CustomerContext {
|
|
|
766
775
|
};
|
|
767
776
|
}
|
|
768
777
|
|
|
778
|
+
interface CreditPack {
|
|
779
|
+
id: string;
|
|
780
|
+
name: string;
|
|
781
|
+
description: string | null;
|
|
782
|
+
credits: number;
|
|
783
|
+
price: number;
|
|
784
|
+
currency: string;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Credit Packs resource for listing available credit packs
|
|
788
|
+
*/
|
|
789
|
+
declare class CreditPacksResource {
|
|
790
|
+
private httpClient;
|
|
791
|
+
constructor(httpClient: CommetHTTPClient);
|
|
792
|
+
/**
|
|
793
|
+
* List all active credit packs
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```typescript
|
|
797
|
+
* const packs = await commet.creditPacks.list();
|
|
798
|
+
* console.log(packs.data); // [{ id: "cp_xxx", name: "100 Credits", ... }]
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
list(): Promise<ApiResponse<CreditPack[]>>;
|
|
802
|
+
}
|
|
803
|
+
|
|
769
804
|
interface Customer {
|
|
770
805
|
id: CustomerID;
|
|
771
806
|
organizationId: string;
|
|
@@ -862,32 +897,6 @@ declare class CustomersResource {
|
|
|
862
897
|
archive(customerId: CustomerID, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
863
898
|
}
|
|
864
899
|
|
|
865
|
-
interface CreditPack {
|
|
866
|
-
id: string;
|
|
867
|
-
name: string;
|
|
868
|
-
description: string | null;
|
|
869
|
-
credits: number;
|
|
870
|
-
price: number;
|
|
871
|
-
currency: string;
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Credit Packs resource for listing available credit packs
|
|
875
|
-
*/
|
|
876
|
-
declare class CreditPacksResource {
|
|
877
|
-
private httpClient;
|
|
878
|
-
constructor(httpClient: CommetHTTPClient);
|
|
879
|
-
/**
|
|
880
|
-
* List all active credit packs
|
|
881
|
-
*
|
|
882
|
-
* @example
|
|
883
|
-
* ```typescript
|
|
884
|
-
* const packs = await commet.creditPacks.list();
|
|
885
|
-
* console.log(packs.data); // [{ id: "cp_xxx", name: "100 Credits", ... }]
|
|
886
|
-
* ```
|
|
887
|
-
*/
|
|
888
|
-
list(): Promise<ApiResponse<CreditPack[]>>;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
900
|
/**
|
|
892
901
|
* Webhook payload structure from Commet
|
|
893
902
|
*/
|
|
@@ -1040,4 +1049,4 @@ declare function isProduction(environment: Environment): boolean;
|
|
|
1040
1049
|
* Commet SDK - Billing and usage tracking for SaaS
|
|
1041
1050
|
*/
|
|
1042
1051
|
|
|
1043
|
-
export { type ActiveSubscription, type AddParams as AddSeatsParams, type ApiResponse, type BillingInterval, type CanUseFeatureParams, type CanUseResult, type CancelParams, type
|
|
1052
|
+
export { type ActiveSubscription, type AddParams as AddSeatsParams, type ApiResponse, type BillingInterval, type CanUseFeatureParams, type CanUseResult, type CancelParams, type CheckFeatureParams, type CheckResult, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateParams as CreateCustomerParams, type CreateSubscriptionParams, type CreatedSubscription, type CreditPack, type Currency, type Customer, type CustomerAddress, CustomerContext, type CustomerID, type BatchResult as CustomersBatchResult, type Environment, type EventID, type FeatureAccess, type FeatureSummary, type FeatureType, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ type CommetConfig = {
|
|
|
9
9
|
interface ApiResponse<T = unknown> {
|
|
10
10
|
success: boolean;
|
|
11
11
|
data?: T;
|
|
12
|
-
|
|
12
|
+
code?: string;
|
|
13
13
|
message?: string;
|
|
14
|
+
details?: unknown;
|
|
14
15
|
hasMore?: boolean;
|
|
15
16
|
nextCursor?: string;
|
|
16
17
|
}
|
|
@@ -57,39 +58,24 @@ interface RequestOptions {
|
|
|
57
58
|
* Generated types interface - augmented by CLI after 'commet pull'
|
|
58
59
|
*
|
|
59
60
|
* This interface gets filled by module augmentation when you run `commet pull`.
|
|
60
|
-
* The CLI generates a .commet.d.ts file that augments this interface with your
|
|
61
|
-
* organization's specific
|
|
61
|
+
* The CLI generates a .commet/types.d.ts file that augments this interface with your
|
|
62
|
+
* organization's specific feature codes, seat types, and plan codes.
|
|
62
63
|
*
|
|
63
64
|
* @example
|
|
64
65
|
* // After running `commet pull`, TypeScript will automatically know your types:
|
|
65
|
-
* await commet.usage.
|
|
66
|
-
*
|
|
67
|
-
*
|
|
66
|
+
* await commet.usage.track({
|
|
67
|
+
* feature: 'api_calls', // Autocomplete works!
|
|
68
|
+
* externalId: 'user_123'
|
|
68
69
|
* });
|
|
69
70
|
*/
|
|
70
71
|
interface CommetGeneratedTypes {
|
|
71
72
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Helper type that provides fallback to string if types are not generated
|
|
74
|
-
*/
|
|
75
|
-
type GeneratedEventType = CommetGeneratedTypes extends {
|
|
76
|
-
eventType: infer T;
|
|
77
|
-
} ? T : string;
|
|
78
|
-
/**
|
|
79
|
-
* Helper type that provides fallback to string if types are not generated
|
|
80
|
-
*/
|
|
81
73
|
type GeneratedSeatType = CommetGeneratedTypes extends {
|
|
82
74
|
seatType: infer T;
|
|
83
75
|
} ? T : string;
|
|
84
|
-
/**
|
|
85
|
-
* Helper type that provides fallback to string if types are not generated
|
|
86
|
-
*/
|
|
87
76
|
type GeneratedPlanCode = CommetGeneratedTypes extends {
|
|
88
77
|
planCode: infer T;
|
|
89
78
|
} ? T : string;
|
|
90
|
-
/**
|
|
91
|
-
* Helper type that provides fallback to string if types are not generated
|
|
92
|
-
*/
|
|
93
79
|
type GeneratedFeatureCode = CommetGeneratedTypes extends {
|
|
94
80
|
featureCode: infer T;
|
|
95
81
|
} ? T : string;
|
|
@@ -402,6 +388,7 @@ interface PlanPrice {
|
|
|
402
388
|
billingInterval: BillingInterval;
|
|
403
389
|
price: number;
|
|
404
390
|
isDefault: boolean;
|
|
391
|
+
trialDays: number;
|
|
405
392
|
}
|
|
406
393
|
interface PlanFeature {
|
|
407
394
|
code: string;
|
|
@@ -417,30 +404,46 @@ interface Plan {
|
|
|
417
404
|
id: PlanID;
|
|
418
405
|
code: string;
|
|
419
406
|
name: string;
|
|
420
|
-
description
|
|
407
|
+
description: string | null;
|
|
421
408
|
isPublic: boolean;
|
|
409
|
+
isFree: boolean;
|
|
422
410
|
isDefault: boolean;
|
|
423
|
-
trialDays: number;
|
|
424
411
|
sortOrder: number;
|
|
425
412
|
prices: PlanPrice[];
|
|
426
413
|
features: PlanFeature[];
|
|
427
414
|
createdAt: string;
|
|
428
415
|
}
|
|
429
|
-
interface
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
416
|
+
interface PlanDetailPrice {
|
|
417
|
+
billingInterval: BillingInterval;
|
|
418
|
+
price: number;
|
|
419
|
+
isDefault: boolean;
|
|
420
|
+
trialDays: number;
|
|
421
|
+
introOffer: {
|
|
422
|
+
enabled: boolean;
|
|
423
|
+
discountType: "percentage" | "amount" | null;
|
|
424
|
+
discountValue: number | null;
|
|
425
|
+
durationCycles: number | null;
|
|
426
|
+
} | null;
|
|
427
|
+
}
|
|
428
|
+
interface PlanDetailFeature extends PlanFeature {
|
|
429
|
+
unitName: string | null;
|
|
430
|
+
overage: {
|
|
431
|
+
enabled: boolean;
|
|
432
|
+
model: "per_unit" | "tiered" | null;
|
|
433
|
+
unitPrice: number | null;
|
|
434
|
+
} | null;
|
|
435
|
+
}
|
|
436
|
+
interface PlanDetail {
|
|
437
|
+
id: PlanID;
|
|
438
|
+
code: string;
|
|
439
|
+
name: string;
|
|
440
|
+
description: string | null;
|
|
441
|
+
isPublic: boolean;
|
|
442
|
+
isDefault: boolean;
|
|
443
|
+
sortOrder: number;
|
|
444
|
+
prices: PlanDetailPrice[];
|
|
445
|
+
features: PlanDetailFeature[];
|
|
446
|
+
createdAt: string;
|
|
444
447
|
updatedAt: string;
|
|
445
448
|
}
|
|
446
449
|
interface ListPlansParams extends ListParams {
|
|
@@ -498,12 +501,12 @@ interface ActiveSubscription {
|
|
|
498
501
|
id: string;
|
|
499
502
|
name: string;
|
|
500
503
|
basePrice: number;
|
|
501
|
-
billingInterval: BillingInterval;
|
|
504
|
+
billingInterval: BillingInterval | null;
|
|
502
505
|
};
|
|
503
506
|
name: string;
|
|
504
|
-
description
|
|
507
|
+
description: string | null;
|
|
505
508
|
status: SubscriptionStatus;
|
|
506
|
-
trialEndsAt
|
|
509
|
+
trialEndsAt: string | null;
|
|
507
510
|
currentPeriod: {
|
|
508
511
|
start: string;
|
|
509
512
|
end: string;
|
|
@@ -511,13 +514,35 @@ interface ActiveSubscription {
|
|
|
511
514
|
};
|
|
512
515
|
features: FeatureSummary[];
|
|
513
516
|
startDate: string;
|
|
514
|
-
endDate
|
|
517
|
+
endDate: string | null;
|
|
515
518
|
billingDayOfMonth: number;
|
|
516
519
|
nextBillingDate: string;
|
|
517
|
-
checkoutUrl
|
|
520
|
+
checkoutUrl: string | null;
|
|
518
521
|
createdAt: string;
|
|
519
522
|
updatedAt: string;
|
|
520
523
|
}
|
|
524
|
+
interface CreatedSubscription {
|
|
525
|
+
id: string;
|
|
526
|
+
customerId: string;
|
|
527
|
+
externalId: string;
|
|
528
|
+
planId: string;
|
|
529
|
+
planName: string;
|
|
530
|
+
name: string;
|
|
531
|
+
status: SubscriptionStatus;
|
|
532
|
+
billingInterval: BillingInterval | null;
|
|
533
|
+
trialEndsAt: string | null;
|
|
534
|
+
startDate: string;
|
|
535
|
+
endDate: string | null;
|
|
536
|
+
currentPeriodStart: string | null;
|
|
537
|
+
currentPeriodEnd: string | null;
|
|
538
|
+
billingDayOfMonth: number;
|
|
539
|
+
checkoutUrl: string | null;
|
|
540
|
+
createdAt: string;
|
|
541
|
+
updatedAt: string;
|
|
542
|
+
introOfferEndsAt: string | null;
|
|
543
|
+
introOfferDiscountType: "percentage" | "amount" | null;
|
|
544
|
+
introOfferDiscountValue: number | null;
|
|
545
|
+
}
|
|
521
546
|
interface Subscription {
|
|
522
547
|
id: string;
|
|
523
548
|
customerId: string;
|
|
@@ -559,10 +584,6 @@ type CreateSubscriptionParams = CustomerIdentifier & PlanIdentifier & {
|
|
|
559
584
|
startDate?: string;
|
|
560
585
|
successUrl?: string;
|
|
561
586
|
};
|
|
562
|
-
type ChangePlanParams = PlanIdentifier & {
|
|
563
|
-
subscriptionId: string;
|
|
564
|
-
billingInterval?: BillingInterval;
|
|
565
|
-
};
|
|
566
587
|
interface CancelParams {
|
|
567
588
|
subscriptionId: string;
|
|
568
589
|
reason?: string;
|
|
@@ -589,7 +610,7 @@ declare class SubscriptionsResource {
|
|
|
589
610
|
* });
|
|
590
611
|
* ```
|
|
591
612
|
*/
|
|
592
|
-
create(params: CreateSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<
|
|
613
|
+
create(params: CreateSubscriptionParams, options?: RequestOptions): Promise<ApiResponse<CreatedSubscription>>;
|
|
593
614
|
/**
|
|
594
615
|
* Get the active subscription for a customer
|
|
595
616
|
*
|
|
@@ -599,18 +620,6 @@ declare class SubscriptionsResource {
|
|
|
599
620
|
* ```
|
|
600
621
|
*/
|
|
601
622
|
get(externalId: string): Promise<ApiResponse<ActiveSubscription | null>>;
|
|
602
|
-
/**
|
|
603
|
-
* Change the plan of a subscription (upgrade/downgrade)
|
|
604
|
-
*
|
|
605
|
-
* @example
|
|
606
|
-
* ```typescript
|
|
607
|
-
* await commet.subscriptions.changePlan({
|
|
608
|
-
* subscriptionId: 'sub_xxx',
|
|
609
|
-
* planCode: 'enterprise' // autocomplete works after `commet pull`
|
|
610
|
-
* });
|
|
611
|
-
* ```
|
|
612
|
-
*/
|
|
613
|
-
changePlan(params: ChangePlanParams, options?: RequestOptions): Promise<ApiResponse<Subscription>>;
|
|
614
623
|
/**
|
|
615
624
|
* Cancel a subscription
|
|
616
625
|
*
|
|
@@ -651,7 +660,7 @@ interface BatchResult$1<T> {
|
|
|
651
660
|
}>;
|
|
652
661
|
}
|
|
653
662
|
interface TrackParams {
|
|
654
|
-
feature:
|
|
663
|
+
feature: GeneratedFeatureCode;
|
|
655
664
|
customerId?: CustomerID;
|
|
656
665
|
externalId?: string;
|
|
657
666
|
idempotencyKey?: string;
|
|
@@ -766,6 +775,32 @@ declare class CustomerContext {
|
|
|
766
775
|
};
|
|
767
776
|
}
|
|
768
777
|
|
|
778
|
+
interface CreditPack {
|
|
779
|
+
id: string;
|
|
780
|
+
name: string;
|
|
781
|
+
description: string | null;
|
|
782
|
+
credits: number;
|
|
783
|
+
price: number;
|
|
784
|
+
currency: string;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Credit Packs resource for listing available credit packs
|
|
788
|
+
*/
|
|
789
|
+
declare class CreditPacksResource {
|
|
790
|
+
private httpClient;
|
|
791
|
+
constructor(httpClient: CommetHTTPClient);
|
|
792
|
+
/**
|
|
793
|
+
* List all active credit packs
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```typescript
|
|
797
|
+
* const packs = await commet.creditPacks.list();
|
|
798
|
+
* console.log(packs.data); // [{ id: "cp_xxx", name: "100 Credits", ... }]
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
list(): Promise<ApiResponse<CreditPack[]>>;
|
|
802
|
+
}
|
|
803
|
+
|
|
769
804
|
interface Customer {
|
|
770
805
|
id: CustomerID;
|
|
771
806
|
organizationId: string;
|
|
@@ -862,32 +897,6 @@ declare class CustomersResource {
|
|
|
862
897
|
archive(customerId: CustomerID, options?: RequestOptions): Promise<ApiResponse<Customer>>;
|
|
863
898
|
}
|
|
864
899
|
|
|
865
|
-
interface CreditPack {
|
|
866
|
-
id: string;
|
|
867
|
-
name: string;
|
|
868
|
-
description: string | null;
|
|
869
|
-
credits: number;
|
|
870
|
-
price: number;
|
|
871
|
-
currency: string;
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Credit Packs resource for listing available credit packs
|
|
875
|
-
*/
|
|
876
|
-
declare class CreditPacksResource {
|
|
877
|
-
private httpClient;
|
|
878
|
-
constructor(httpClient: CommetHTTPClient);
|
|
879
|
-
/**
|
|
880
|
-
* List all active credit packs
|
|
881
|
-
*
|
|
882
|
-
* @example
|
|
883
|
-
* ```typescript
|
|
884
|
-
* const packs = await commet.creditPacks.list();
|
|
885
|
-
* console.log(packs.data); // [{ id: "cp_xxx", name: "100 Credits", ... }]
|
|
886
|
-
* ```
|
|
887
|
-
*/
|
|
888
|
-
list(): Promise<ApiResponse<CreditPack[]>>;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
900
|
/**
|
|
892
901
|
* Webhook payload structure from Commet
|
|
893
902
|
*/
|
|
@@ -1040,4 +1049,4 @@ declare function isProduction(environment: Environment): boolean;
|
|
|
1040
1049
|
* Commet SDK - Billing and usage tracking for SaaS
|
|
1041
1050
|
*/
|
|
1042
1051
|
|
|
1043
|
-
export { type ActiveSubscription, type AddParams as AddSeatsParams, type ApiResponse, type BillingInterval, type CanUseFeatureParams, type CanUseResult, type CancelParams, type
|
|
1052
|
+
export { type ActiveSubscription, type AddParams as AddSeatsParams, type ApiResponse, type BillingInterval, type CanUseFeatureParams, type CanUseResult, type CancelParams, type CheckFeatureParams, type CheckResult, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateParams as CreateCustomerParams, type CreateSubscriptionParams, type CreatedSubscription, type CreditPack, type Currency, type Customer, type CustomerAddress, CustomerContext, type CustomerID, type BatchResult as CustomersBatchResult, type Environment, type EventID, type FeatureAccess, type FeatureSummary, type FeatureType, 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 };
|