@commet/node 1.1.0 → 1.1.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 +27 -57
- package/dist/index.d.ts +27 -57
- package/dist/index.js +41 -156
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -156
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -697,82 +697,52 @@ declare class PortalResource {
|
|
|
697
697
|
*/
|
|
698
698
|
declare class CustomerContext {
|
|
699
699
|
private readonly externalId;
|
|
700
|
-
private readonly
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
700
|
+
private readonly featuresResource;
|
|
701
|
+
private readonly seatsResource;
|
|
702
|
+
private readonly usageResource;
|
|
703
|
+
private readonly subscriptionsResource;
|
|
704
|
+
private readonly portalResource;
|
|
705
|
+
constructor(externalId: string, resources: {
|
|
706
|
+
features: FeaturesResource;
|
|
707
|
+
seats: SeatsResource;
|
|
708
|
+
usage: UsageResource;
|
|
709
|
+
subscriptions: SubscriptionsResource;
|
|
710
|
+
portal: PortalResource;
|
|
711
|
+
});
|
|
712
|
+
/**
|
|
713
|
+
* Feature access methods - delegates to FeaturesResource
|
|
704
714
|
*/
|
|
705
715
|
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
|
-
*/
|
|
716
|
+
get: (code: string, options?: RequestOptions) => Promise<ApiResponse<FeatureAccess>>;
|
|
717
|
+
check: (code: string, options?: RequestOptions) => Promise<ApiResponse<CheckResult>>;
|
|
718
|
+
canUse: (code: string, options?: RequestOptions) => Promise<ApiResponse<CanUseResult>>;
|
|
721
719
|
list: (options?: RequestOptions) => Promise<ApiResponse<FeatureAccess[]>>;
|
|
722
720
|
};
|
|
723
721
|
/**
|
|
724
|
-
* Seat management methods
|
|
722
|
+
* Seat management methods - delegates to SeatsResource
|
|
725
723
|
*/
|
|
726
724
|
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>>;
|
|
725
|
+
add: (seatType: string, count?: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
726
|
+
remove: (seatType: string, count?: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
727
|
+
set: (seatType: string, count: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
728
|
+
getBalance: (seatType: string) => Promise<ApiResponse<SeatBalance>>;
|
|
743
729
|
};
|
|
744
730
|
/**
|
|
745
|
-
* Usage tracking methods
|
|
731
|
+
* Usage tracking methods - delegates to UsageResource
|
|
746
732
|
*/
|
|
747
733
|
usage: {
|
|
748
|
-
|
|
749
|
-
* Track a usage event
|
|
750
|
-
*/
|
|
751
|
-
track: (eventType: GeneratedEventType, properties?: Record<string, string>, options?: RequestOptions) => Promise<ApiResponse<UsageEvent>>;
|
|
734
|
+
track: (eventType: string, properties?: Record<string, string>, options?: RequestOptions) => Promise<ApiResponse<UsageEvent>>;
|
|
752
735
|
};
|
|
753
736
|
/**
|
|
754
|
-
* Subscription methods
|
|
737
|
+
* Subscription methods - delegates to SubscriptionsResource
|
|
755
738
|
*/
|
|
756
739
|
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>>;
|
|
740
|
+
get: () => Promise<ApiResponse<ActiveSubscription | null>>;
|
|
768
741
|
};
|
|
769
742
|
/**
|
|
770
|
-
* Portal methods
|
|
743
|
+
* Portal methods - delegates to PortalResource
|
|
771
744
|
*/
|
|
772
745
|
portal: {
|
|
773
|
-
/**
|
|
774
|
-
* Get customer portal URL
|
|
775
|
-
*/
|
|
776
746
|
getUrl: (options?: RequestOptions) => Promise<ApiResponse<PortalAccess>>;
|
|
777
747
|
};
|
|
778
748
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -697,82 +697,52 @@ declare class PortalResource {
|
|
|
697
697
|
*/
|
|
698
698
|
declare class CustomerContext {
|
|
699
699
|
private readonly externalId;
|
|
700
|
-
private readonly
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
700
|
+
private readonly featuresResource;
|
|
701
|
+
private readonly seatsResource;
|
|
702
|
+
private readonly usageResource;
|
|
703
|
+
private readonly subscriptionsResource;
|
|
704
|
+
private readonly portalResource;
|
|
705
|
+
constructor(externalId: string, resources: {
|
|
706
|
+
features: FeaturesResource;
|
|
707
|
+
seats: SeatsResource;
|
|
708
|
+
usage: UsageResource;
|
|
709
|
+
subscriptions: SubscriptionsResource;
|
|
710
|
+
portal: PortalResource;
|
|
711
|
+
});
|
|
712
|
+
/**
|
|
713
|
+
* Feature access methods - delegates to FeaturesResource
|
|
704
714
|
*/
|
|
705
715
|
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
|
-
*/
|
|
716
|
+
get: (code: string, options?: RequestOptions) => Promise<ApiResponse<FeatureAccess>>;
|
|
717
|
+
check: (code: string, options?: RequestOptions) => Promise<ApiResponse<CheckResult>>;
|
|
718
|
+
canUse: (code: string, options?: RequestOptions) => Promise<ApiResponse<CanUseResult>>;
|
|
721
719
|
list: (options?: RequestOptions) => Promise<ApiResponse<FeatureAccess[]>>;
|
|
722
720
|
};
|
|
723
721
|
/**
|
|
724
|
-
* Seat management methods
|
|
722
|
+
* Seat management methods - delegates to SeatsResource
|
|
725
723
|
*/
|
|
726
724
|
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>>;
|
|
725
|
+
add: (seatType: string, count?: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
726
|
+
remove: (seatType: string, count?: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
727
|
+
set: (seatType: string, count: number, options?: RequestOptions) => Promise<ApiResponse<SeatEvent>>;
|
|
728
|
+
getBalance: (seatType: string) => Promise<ApiResponse<SeatBalance>>;
|
|
743
729
|
};
|
|
744
730
|
/**
|
|
745
|
-
* Usage tracking methods
|
|
731
|
+
* Usage tracking methods - delegates to UsageResource
|
|
746
732
|
*/
|
|
747
733
|
usage: {
|
|
748
|
-
|
|
749
|
-
* Track a usage event
|
|
750
|
-
*/
|
|
751
|
-
track: (eventType: GeneratedEventType, properties?: Record<string, string>, options?: RequestOptions) => Promise<ApiResponse<UsageEvent>>;
|
|
734
|
+
track: (eventType: string, properties?: Record<string, string>, options?: RequestOptions) => Promise<ApiResponse<UsageEvent>>;
|
|
752
735
|
};
|
|
753
736
|
/**
|
|
754
|
-
* Subscription methods
|
|
737
|
+
* Subscription methods - delegates to SubscriptionsResource
|
|
755
738
|
*/
|
|
756
739
|
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>>;
|
|
740
|
+
get: () => Promise<ApiResponse<ActiveSubscription | null>>;
|
|
768
741
|
};
|
|
769
742
|
/**
|
|
770
|
-
* Portal methods
|
|
743
|
+
* Portal methods - delegates to PortalResource
|
|
771
744
|
*/
|
|
772
745
|
portal: {
|
|
773
|
-
/**
|
|
774
|
-
* Get customer portal URL
|
|
775
|
-
*/
|
|
776
746
|
getUrl: (options?: RequestOptions) => Promise<ApiResponse<PortalAccess>>;
|
|
777
747
|
};
|
|
778
748
|
}
|
package/dist/index.js
CHANGED
|
@@ -44,182 +44,61 @@ module.exports = __toCommonJS(index_exports);
|
|
|
44
44
|
|
|
45
45
|
// src/customer.ts
|
|
46
46
|
var CustomerContext = class {
|
|
47
|
-
constructor(
|
|
47
|
+
constructor(externalId, resources) {
|
|
48
48
|
/**
|
|
49
|
-
* Feature access methods -
|
|
49
|
+
* Feature access methods - delegates to FeaturesResource
|
|
50
50
|
*/
|
|
51
51
|
this.features = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return this.httpClient.get(
|
|
57
|
-
`/features/${code}`,
|
|
58
|
-
{ externalId: this.externalId },
|
|
59
|
-
options
|
|
60
|
-
);
|
|
61
|
-
},
|
|
62
|
-
/**
|
|
63
|
-
* Check if a boolean feature is enabled
|
|
64
|
-
*/
|
|
65
|
-
check: async (code, options) => {
|
|
66
|
-
const result = await this.httpClient.get(
|
|
67
|
-
`/features/${code}`,
|
|
68
|
-
{ externalId: this.externalId },
|
|
69
|
-
options
|
|
70
|
-
);
|
|
71
|
-
if (!result.success || !result.data) {
|
|
72
|
-
return {
|
|
73
|
-
success: false,
|
|
74
|
-
data: { allowed: false },
|
|
75
|
-
message: result.message
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
success: true,
|
|
80
|
-
data: { allowed: result.data.allowed },
|
|
81
|
-
message: result.message
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
/**
|
|
85
|
-
* Check if customer can use one more unit
|
|
86
|
-
*/
|
|
87
|
-
canUse: (code, options) => {
|
|
88
|
-
return this.httpClient.get(
|
|
89
|
-
`/features/${code}`,
|
|
90
|
-
{ externalId: this.externalId, action: "canUse" },
|
|
91
|
-
options
|
|
92
|
-
);
|
|
93
|
-
},
|
|
94
|
-
/**
|
|
95
|
-
* List all features
|
|
96
|
-
*/
|
|
97
|
-
list: (options) => {
|
|
98
|
-
return this.httpClient.get(
|
|
99
|
-
"/features",
|
|
100
|
-
{ externalId: this.externalId },
|
|
101
|
-
options
|
|
102
|
-
);
|
|
103
|
-
}
|
|
52
|
+
get: (code, options) => this.featuresResource.get(code, this.externalId, options),
|
|
53
|
+
check: (code, options) => this.featuresResource.check(code, this.externalId, options),
|
|
54
|
+
canUse: (code, options) => this.featuresResource.canUse(code, this.externalId, options),
|
|
55
|
+
list: (options) => this.featuresResource.list(this.externalId, options)
|
|
104
56
|
};
|
|
105
57
|
/**
|
|
106
|
-
* Seat management methods
|
|
58
|
+
* Seat management methods - delegates to SeatsResource
|
|
107
59
|
*/
|
|
108
60
|
this.seats = {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
remove: (seatType, count = 1, options) => {
|
|
123
|
-
return this.httpClient.post(
|
|
124
|
-
"/seats/remove",
|
|
125
|
-
{ externalId: this.externalId, seatType, count },
|
|
126
|
-
options
|
|
127
|
-
);
|
|
128
|
-
},
|
|
129
|
-
/**
|
|
130
|
-
* Set total seat count
|
|
131
|
-
*/
|
|
132
|
-
set: (seatType, count, options) => {
|
|
133
|
-
return this.httpClient.post(
|
|
134
|
-
"/seats/set",
|
|
135
|
-
{ externalId: this.externalId, seatType, count },
|
|
136
|
-
options
|
|
137
|
-
);
|
|
138
|
-
},
|
|
139
|
-
/**
|
|
140
|
-
* Get current seat balance
|
|
141
|
-
*/
|
|
142
|
-
getBalance: (seatType, options) => {
|
|
143
|
-
return this.httpClient.get(
|
|
144
|
-
"/seats/balance",
|
|
145
|
-
{ externalId: this.externalId, seatType },
|
|
146
|
-
options
|
|
147
|
-
);
|
|
148
|
-
}
|
|
61
|
+
add: (seatType, count = 1, options) => this.seatsResource.add(
|
|
62
|
+
{ externalId: this.externalId, seatType, count },
|
|
63
|
+
options
|
|
64
|
+
),
|
|
65
|
+
remove: (seatType, count = 1, options) => this.seatsResource.remove(
|
|
66
|
+
{ externalId: this.externalId, seatType, count },
|
|
67
|
+
options
|
|
68
|
+
),
|
|
69
|
+
set: (seatType, count, options) => this.seatsResource.set(
|
|
70
|
+
{ externalId: this.externalId, seatType, count },
|
|
71
|
+
options
|
|
72
|
+
),
|
|
73
|
+
getBalance: (seatType) => this.seatsResource.getBalance({ externalId: this.externalId, seatType })
|
|
149
74
|
};
|
|
150
75
|
/**
|
|
151
|
-
* Usage tracking methods
|
|
76
|
+
* Usage tracking methods - delegates to UsageResource
|
|
152
77
|
*/
|
|
153
78
|
this.usage = {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return this.httpClient.post(
|
|
159
|
-
"/usage",
|
|
160
|
-
{
|
|
161
|
-
externalId: this.externalId,
|
|
162
|
-
eventType,
|
|
163
|
-
properties
|
|
164
|
-
},
|
|
165
|
-
options
|
|
166
|
-
);
|
|
167
|
-
}
|
|
79
|
+
track: (eventType, properties, options) => this.usageResource.track(
|
|
80
|
+
{ externalId: this.externalId, eventType, properties },
|
|
81
|
+
options
|
|
82
|
+
)
|
|
168
83
|
};
|
|
169
84
|
/**
|
|
170
|
-
* Subscription methods
|
|
85
|
+
* Subscription methods - delegates to SubscriptionsResource
|
|
171
86
|
*/
|
|
172
87
|
this.subscription = {
|
|
173
|
-
|
|
174
|
-
* Get active subscription
|
|
175
|
-
*/
|
|
176
|
-
get: (options) => {
|
|
177
|
-
return this.httpClient.get(
|
|
178
|
-
"/subscriptions/active",
|
|
179
|
-
{ externalId: this.externalId },
|
|
180
|
-
options
|
|
181
|
-
);
|
|
182
|
-
},
|
|
183
|
-
/**
|
|
184
|
-
* Cancel subscription
|
|
185
|
-
*/
|
|
186
|
-
cancel: (params, options) => {
|
|
187
|
-
return this.httpClient.get(
|
|
188
|
-
"/subscriptions/active",
|
|
189
|
-
{ externalId: this.externalId }
|
|
190
|
-
).then((result) => {
|
|
191
|
-
if (!result.success || !result.data) {
|
|
192
|
-
return {
|
|
193
|
-
success: false,
|
|
194
|
-
data: null,
|
|
195
|
-
message: "No active subscription found"
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
return this.httpClient.post(
|
|
199
|
-
`/subscriptions/${result.data.id}/cancel`,
|
|
200
|
-
params || {},
|
|
201
|
-
options
|
|
202
|
-
);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
88
|
+
get: () => this.subscriptionsResource.get({ externalId: this.externalId })
|
|
205
89
|
};
|
|
206
90
|
/**
|
|
207
|
-
* Portal methods
|
|
91
|
+
* Portal methods - delegates to PortalResource
|
|
208
92
|
*/
|
|
209
93
|
this.portal = {
|
|
210
|
-
|
|
211
|
-
* Get customer portal URL
|
|
212
|
-
*/
|
|
213
|
-
getUrl: (options) => {
|
|
214
|
-
return this.httpClient.get(
|
|
215
|
-
"/portal/url",
|
|
216
|
-
{ externalId: this.externalId },
|
|
217
|
-
options
|
|
218
|
-
);
|
|
219
|
-
}
|
|
94
|
+
getUrl: (options) => this.portalResource.getUrl({ externalId: this.externalId }, options)
|
|
220
95
|
};
|
|
221
|
-
this.httpClient = httpClient;
|
|
222
96
|
this.externalId = externalId;
|
|
97
|
+
this.featuresResource = resources.features;
|
|
98
|
+
this.seatsResource = resources.seats;
|
|
99
|
+
this.usageResource = resources.usage;
|
|
100
|
+
this.subscriptionsResource = resources.subscriptions;
|
|
101
|
+
this.portalResource = resources.portal;
|
|
223
102
|
}
|
|
224
103
|
};
|
|
225
104
|
|
|
@@ -1059,7 +938,13 @@ var Commet = class {
|
|
|
1059
938
|
* ```
|
|
1060
939
|
*/
|
|
1061
940
|
customer(externalId) {
|
|
1062
|
-
return new CustomerContext(
|
|
941
|
+
return new CustomerContext(externalId, {
|
|
942
|
+
features: this.features,
|
|
943
|
+
seats: this.seats,
|
|
944
|
+
usage: this.usage,
|
|
945
|
+
subscriptions: this.subscriptions,
|
|
946
|
+
portal: this.portal
|
|
947
|
+
});
|
|
1063
948
|
}
|
|
1064
949
|
getEnvironment() {
|
|
1065
950
|
return this.environment;
|