@ooneex/payment 0.0.17 → 0.0.19
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.ts +391 -20
- package/dist/index.js +2 -2
- package/dist/index.js.map +11 -4
- package/package.json +11 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
|
+
import { Exception } from "@ooneex/exception";
|
|
2
|
+
declare class PaymentException extends Exception {
|
|
3
|
+
constructor(message: string, data?: Record<string, unknown>);
|
|
4
|
+
}
|
|
1
5
|
import { ICategory } from "@ooneex/category";
|
|
2
6
|
import { CurrencyCodeType } from "@ooneex/currencies";
|
|
3
7
|
import { IImage } from "@ooneex/image";
|
|
4
8
|
import { ITag } from "@ooneex/tag";
|
|
5
9
|
import { IBase, ScalarType } from "@ooneex/types";
|
|
10
|
+
declare enum EPriceType {
|
|
11
|
+
FIXED = "fixed",
|
|
12
|
+
CUSTOM = "custom",
|
|
13
|
+
FREE = "free"
|
|
14
|
+
}
|
|
15
|
+
type PriceTypeType = `${EPriceType}`;
|
|
16
|
+
type PriceType = {
|
|
17
|
+
type: PriceTypeType;
|
|
18
|
+
priceCurrency?: string;
|
|
19
|
+
priceAmount?: number;
|
|
20
|
+
minimumAmount?: number;
|
|
21
|
+
maximumAmount?: number;
|
|
22
|
+
presetAmount?: number;
|
|
23
|
+
};
|
|
24
|
+
type CustomFieldType = {
|
|
25
|
+
customFieldId: string;
|
|
26
|
+
required: boolean;
|
|
27
|
+
};
|
|
6
28
|
declare enum EDiscountType {
|
|
7
29
|
PERCENTAGE = "percentage",
|
|
8
30
|
FIXED = "fixed"
|
|
9
31
|
}
|
|
32
|
+
declare enum EDiscountDuration {
|
|
33
|
+
ONCE = "once",
|
|
34
|
+
REPEATING = "repeating",
|
|
35
|
+
FOREVER = "forever"
|
|
36
|
+
}
|
|
37
|
+
type DiscountDurationType = `${EDiscountDuration}`;
|
|
10
38
|
declare enum ESubscriptionPeriod {
|
|
11
39
|
MONTHLY = "monthly",
|
|
12
40
|
YEARLY = "yearly",
|
|
@@ -15,16 +43,92 @@ declare enum ESubscriptionPeriod {
|
|
|
15
43
|
}
|
|
16
44
|
type DiscountType = `${EDiscountType}`;
|
|
17
45
|
type SubscriptionPeriodType = `${ESubscriptionPeriod}`;
|
|
46
|
+
declare enum EBenefitType {
|
|
47
|
+
CREDITS = "credits",
|
|
48
|
+
LICENSE_KEYS = "license_keys",
|
|
49
|
+
FILE_DOWNLOADS = "file_downloads",
|
|
50
|
+
GITHUB_REPOSITORY_ACCESS = "github_repository_access",
|
|
51
|
+
DISCORD_ACCESS = "discord_access",
|
|
52
|
+
CUSTOM = "custom"
|
|
53
|
+
}
|
|
54
|
+
type BenefitTypeType = `${EBenefitType}`;
|
|
55
|
+
declare enum EGitHubPermission {
|
|
56
|
+
READ = "read",
|
|
57
|
+
TRIAGE = "triage",
|
|
58
|
+
WRITE = "write",
|
|
59
|
+
MAINTAIN = "maintain",
|
|
60
|
+
ADMIN = "admin"
|
|
61
|
+
}
|
|
62
|
+
type GitHubPermissionType = `${EGitHubPermission}`;
|
|
63
|
+
type BenefitBaseType = {
|
|
64
|
+
type: BenefitTypeType;
|
|
65
|
+
name: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
isSelectable?: boolean;
|
|
68
|
+
isDeletable?: boolean;
|
|
69
|
+
organizationId?: string;
|
|
70
|
+
};
|
|
71
|
+
type CreditsBenefitType = BenefitBaseType & {
|
|
72
|
+
type: typeof EBenefitType.CREDITS;
|
|
73
|
+
amount: number;
|
|
74
|
+
rollover?: boolean;
|
|
75
|
+
};
|
|
76
|
+
type LicenseKeysBenefitType = BenefitBaseType & {
|
|
77
|
+
type: typeof EBenefitType.LICENSE_KEYS;
|
|
78
|
+
prefix?: string;
|
|
79
|
+
expiresInDays?: number;
|
|
80
|
+
expiresInMonths?: number;
|
|
81
|
+
expiresInYears?: number;
|
|
82
|
+
activationLimit?: number;
|
|
83
|
+
usageLimit?: number;
|
|
84
|
+
};
|
|
85
|
+
type FileDownloadsBenefitType = BenefitBaseType & {
|
|
86
|
+
type: typeof EBenefitType.FILE_DOWNLOADS;
|
|
87
|
+
files?: BenefitFileType[];
|
|
88
|
+
};
|
|
89
|
+
type BenefitFileType = {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
size: number;
|
|
93
|
+
mimeType?: string;
|
|
94
|
+
checksum?: string;
|
|
95
|
+
isEnabled?: boolean;
|
|
96
|
+
};
|
|
97
|
+
type GitHubRepositoryAccessBenefitType = BenefitBaseType & {
|
|
98
|
+
type: typeof EBenefitType.GITHUB_REPOSITORY_ACCESS;
|
|
99
|
+
repositoryOwner: string;
|
|
100
|
+
repositoryName: string;
|
|
101
|
+
permission?: GitHubPermissionType;
|
|
102
|
+
};
|
|
103
|
+
type DiscordAccessBenefitType = BenefitBaseType & {
|
|
104
|
+
type: typeof EBenefitType.DISCORD_ACCESS;
|
|
105
|
+
guildId: string;
|
|
106
|
+
roleId: string;
|
|
107
|
+
};
|
|
108
|
+
type CustomBenefitType = BenefitBaseType & {
|
|
109
|
+
type: typeof EBenefitType.CUSTOM;
|
|
110
|
+
note?: string;
|
|
111
|
+
};
|
|
112
|
+
type BenefitType = CreditsBenefitType | LicenseKeysBenefitType | FileDownloadsBenefitType | GitHubRepositoryAccessBenefitType | DiscordAccessBenefitType | CustomBenefitType;
|
|
18
113
|
interface IProduct extends IBase {
|
|
114
|
+
key?: string;
|
|
19
115
|
name: string;
|
|
20
116
|
description?: string;
|
|
21
117
|
categories?: ICategory[];
|
|
22
|
-
currency
|
|
23
|
-
price
|
|
118
|
+
currency?: CurrencyCodeType;
|
|
119
|
+
price?: number;
|
|
24
120
|
barcode?: string;
|
|
25
121
|
images?: IImage[];
|
|
26
122
|
attributes?: Record<string, ScalarType>;
|
|
27
123
|
tags?: ITag[];
|
|
124
|
+
isRecurring?: boolean;
|
|
125
|
+
isArchived?: boolean;
|
|
126
|
+
organizationId?: string;
|
|
127
|
+
recurringInterval?: SubscriptionPeriodType;
|
|
128
|
+
metadata?: Record<string, string | number | boolean>;
|
|
129
|
+
prices?: PriceType[];
|
|
130
|
+
benefits?: BenefitType[];
|
|
131
|
+
attachedCustomFields?: CustomFieldType[];
|
|
28
132
|
}
|
|
29
133
|
interface IFeature extends IBase {
|
|
30
134
|
name: string;
|
|
@@ -32,22 +136,6 @@ interface IFeature extends IBase {
|
|
|
32
136
|
isEnabled?: boolean;
|
|
33
137
|
limit?: number;
|
|
34
138
|
}
|
|
35
|
-
interface ICoupon extends IBase {
|
|
36
|
-
code: string;
|
|
37
|
-
name?: string;
|
|
38
|
-
description?: string;
|
|
39
|
-
discountType: EDiscountType;
|
|
40
|
-
discountValue: number;
|
|
41
|
-
currency?: CurrencyCodeType;
|
|
42
|
-
maxUses?: number;
|
|
43
|
-
usedCount?: number;
|
|
44
|
-
startAt?: Date;
|
|
45
|
-
endAt?: Date;
|
|
46
|
-
isActive?: boolean;
|
|
47
|
-
minimumAmount?: number;
|
|
48
|
-
applicableProducts?: IProduct[];
|
|
49
|
-
applicablePlans?: IPlan[];
|
|
50
|
-
}
|
|
51
139
|
interface IPlan extends IBase {
|
|
52
140
|
name: string;
|
|
53
141
|
description?: string;
|
|
@@ -66,7 +154,7 @@ interface ICredit extends IBase {
|
|
|
66
154
|
description?: string;
|
|
67
155
|
}
|
|
68
156
|
interface ISubscription extends IBase {
|
|
69
|
-
|
|
157
|
+
discounts?: IDiscount[];
|
|
70
158
|
plans?: IPlan[];
|
|
71
159
|
credits?: ICredit[];
|
|
72
160
|
startAt: Date;
|
|
@@ -74,4 +162,287 @@ interface ISubscription extends IBase {
|
|
|
74
162
|
isTrial?: boolean;
|
|
75
163
|
isActive?: boolean;
|
|
76
164
|
}
|
|
77
|
-
|
|
165
|
+
interface IDiscount extends IBase {
|
|
166
|
+
key?: string;
|
|
167
|
+
name: string;
|
|
168
|
+
description?: string;
|
|
169
|
+
code?: string;
|
|
170
|
+
type: DiscountType;
|
|
171
|
+
amount: number;
|
|
172
|
+
currency?: CurrencyCodeType;
|
|
173
|
+
duration: DiscountDurationType;
|
|
174
|
+
durationInMonths?: number;
|
|
175
|
+
startAt?: Date;
|
|
176
|
+
endAt?: Date;
|
|
177
|
+
maxUses?: number;
|
|
178
|
+
usedCount?: number;
|
|
179
|
+
maxRedemptions?: number;
|
|
180
|
+
redemptionsCount?: number;
|
|
181
|
+
isActive?: boolean;
|
|
182
|
+
minimumAmount?: number;
|
|
183
|
+
applicableProducts?: IProduct[];
|
|
184
|
+
applicablePlans?: IPlan[];
|
|
185
|
+
organizationId?: string;
|
|
186
|
+
metadata?: Record<string, string | number | boolean>;
|
|
187
|
+
}
|
|
188
|
+
declare enum ECheckoutStatus {
|
|
189
|
+
OPEN = "open",
|
|
190
|
+
EXPIRED = "expired",
|
|
191
|
+
CONFIRMED = "confirmed",
|
|
192
|
+
SUCCEEDED = "succeeded",
|
|
193
|
+
FAILED = "failed"
|
|
194
|
+
}
|
|
195
|
+
type CheckoutStatusType = `${ECheckoutStatus}`;
|
|
196
|
+
type CheckoutCustomerType = {
|
|
197
|
+
id?: string;
|
|
198
|
+
email?: string;
|
|
199
|
+
name?: string;
|
|
200
|
+
externalId?: string;
|
|
201
|
+
billingAddress?: CheckoutAddressType;
|
|
202
|
+
taxId?: string;
|
|
203
|
+
};
|
|
204
|
+
type CheckoutAddressType = {
|
|
205
|
+
line1?: string;
|
|
206
|
+
line2?: string;
|
|
207
|
+
city?: string;
|
|
208
|
+
state?: string;
|
|
209
|
+
postalCode?: string;
|
|
210
|
+
country?: string;
|
|
211
|
+
};
|
|
212
|
+
type CheckoutCreateType = {
|
|
213
|
+
products: string[];
|
|
214
|
+
customerExternalId?: string;
|
|
215
|
+
customerId?: string;
|
|
216
|
+
customerEmail?: string;
|
|
217
|
+
customerName?: string;
|
|
218
|
+
customerBillingAddress?: CheckoutAddressType;
|
|
219
|
+
customerTaxId?: string;
|
|
220
|
+
discountId?: string;
|
|
221
|
+
allowDiscountCodes?: boolean;
|
|
222
|
+
successUrl?: string;
|
|
223
|
+
embedOrigin?: string;
|
|
224
|
+
metadata?: Record<string, string | number | boolean>;
|
|
225
|
+
};
|
|
226
|
+
type CheckoutType = {
|
|
227
|
+
id: string;
|
|
228
|
+
url?: string;
|
|
229
|
+
embedId?: string;
|
|
230
|
+
status: CheckoutStatusType;
|
|
231
|
+
clientSecret: string;
|
|
232
|
+
createdAt?: Date;
|
|
233
|
+
updatedAt?: Date;
|
|
234
|
+
expiresAt?: Date;
|
|
235
|
+
successUrl?: string;
|
|
236
|
+
embedOrigin?: string;
|
|
237
|
+
amount?: number;
|
|
238
|
+
taxAmount?: number;
|
|
239
|
+
currency?: CurrencyCodeType;
|
|
240
|
+
subtotalAmount?: number;
|
|
241
|
+
totalAmount?: number;
|
|
242
|
+
productId?: string;
|
|
243
|
+
productPriceId?: string;
|
|
244
|
+
discountId?: string;
|
|
245
|
+
allowDiscountCodes?: boolean;
|
|
246
|
+
isDiscountApplicable?: boolean;
|
|
247
|
+
isPaymentRequired?: boolean;
|
|
248
|
+
customer?: CheckoutCustomerType;
|
|
249
|
+
metadata?: Record<string, string | number | boolean>;
|
|
250
|
+
};
|
|
251
|
+
type CustomerSessionCreateType = {
|
|
252
|
+
customerId: string;
|
|
253
|
+
};
|
|
254
|
+
type CustomerSessionType = {
|
|
255
|
+
id: string;
|
|
256
|
+
token: string;
|
|
257
|
+
customerPortalUrl: string;
|
|
258
|
+
createdAt?: Date;
|
|
259
|
+
expiresAt?: Date;
|
|
260
|
+
customerId?: string;
|
|
261
|
+
};
|
|
262
|
+
type CustomerAddressType = {
|
|
263
|
+
line1?: string;
|
|
264
|
+
line2?: string;
|
|
265
|
+
city?: string;
|
|
266
|
+
state?: string;
|
|
267
|
+
postalCode?: string;
|
|
268
|
+
country?: string;
|
|
269
|
+
};
|
|
270
|
+
type CustomerCreateType = {
|
|
271
|
+
email: string;
|
|
272
|
+
name?: string;
|
|
273
|
+
externalId?: string;
|
|
274
|
+
billingAddress?: CustomerAddressType;
|
|
275
|
+
taxId?: string;
|
|
276
|
+
organizationId?: string;
|
|
277
|
+
metadata?: Record<string, string | number | boolean>;
|
|
278
|
+
};
|
|
279
|
+
type CustomerUpdateType = {
|
|
280
|
+
email?: string;
|
|
281
|
+
name?: string;
|
|
282
|
+
billingAddress?: CustomerAddressType;
|
|
283
|
+
taxId?: string;
|
|
284
|
+
metadata?: Record<string, string | number | boolean>;
|
|
285
|
+
};
|
|
286
|
+
type CustomerType = {
|
|
287
|
+
id: string;
|
|
288
|
+
email: string;
|
|
289
|
+
emailVerified: boolean;
|
|
290
|
+
name?: string;
|
|
291
|
+
externalId?: string;
|
|
292
|
+
avatarUrl?: string;
|
|
293
|
+
billingAddress?: CustomerAddressType;
|
|
294
|
+
taxId?: string;
|
|
295
|
+
organizationId?: string;
|
|
296
|
+
metadata?: Record<string, string | number | boolean>;
|
|
297
|
+
createdAt?: Date;
|
|
298
|
+
updatedAt?: Date;
|
|
299
|
+
deletedAt?: Date;
|
|
300
|
+
};
|
|
301
|
+
type CustomerListOptionsType = {
|
|
302
|
+
organizationId?: string;
|
|
303
|
+
email?: string;
|
|
304
|
+
query?: string;
|
|
305
|
+
page?: number;
|
|
306
|
+
limit?: number;
|
|
307
|
+
};
|
|
308
|
+
type CustomerListResultType = {
|
|
309
|
+
items: CustomerType[];
|
|
310
|
+
pagination: {
|
|
311
|
+
totalCount: number;
|
|
312
|
+
maxPage: number;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
declare enum EAnalyticsInterval {
|
|
316
|
+
YEAR = "year",
|
|
317
|
+
MONTH = "month",
|
|
318
|
+
WEEK = "week",
|
|
319
|
+
DAY = "day",
|
|
320
|
+
HOUR = "hour"
|
|
321
|
+
}
|
|
322
|
+
type AnalyticsIntervalType = `${EAnalyticsInterval}`;
|
|
323
|
+
declare enum EBillingType {
|
|
324
|
+
ONE_TIME = "one_time",
|
|
325
|
+
RECURRING = "recurring"
|
|
326
|
+
}
|
|
327
|
+
type BillingTypeType = `${EBillingType}`;
|
|
328
|
+
type AnalyticsOptionsType = {
|
|
329
|
+
startDate: Date;
|
|
330
|
+
endDate: Date;
|
|
331
|
+
interval: AnalyticsIntervalType;
|
|
332
|
+
organizationId?: string | string[];
|
|
333
|
+
productId?: string | string[];
|
|
334
|
+
billingType?: BillingTypeType | BillingTypeType[];
|
|
335
|
+
customerId?: string | string[];
|
|
336
|
+
};
|
|
337
|
+
type AnalyticsPeriodType = {
|
|
338
|
+
timestamp: Date;
|
|
339
|
+
orders: number;
|
|
340
|
+
revenue: number;
|
|
341
|
+
cumulativeRevenue: number;
|
|
342
|
+
averageOrderValue: number;
|
|
343
|
+
oneTimeProducts: number;
|
|
344
|
+
oneTimeProductsRevenue: number;
|
|
345
|
+
newSubscriptions: number;
|
|
346
|
+
newSubscriptionsRevenue: number;
|
|
347
|
+
renewedSubscriptions: number;
|
|
348
|
+
renewedSubscriptionsRevenue: number;
|
|
349
|
+
activeSubscriptions: number;
|
|
350
|
+
monthlyRecurringRevenue: number;
|
|
351
|
+
};
|
|
352
|
+
type AnalyticsMetricInfoType = {
|
|
353
|
+
slug: string;
|
|
354
|
+
displayName: string;
|
|
355
|
+
type: string;
|
|
356
|
+
};
|
|
357
|
+
type AnalyticsMetricsType = {
|
|
358
|
+
orders: AnalyticsMetricInfoType;
|
|
359
|
+
revenue: AnalyticsMetricInfoType;
|
|
360
|
+
cumulativeRevenue: AnalyticsMetricInfoType;
|
|
361
|
+
averageOrderValue: AnalyticsMetricInfoType;
|
|
362
|
+
oneTimeProducts: AnalyticsMetricInfoType;
|
|
363
|
+
oneTimeProductsRevenue: AnalyticsMetricInfoType;
|
|
364
|
+
newSubscriptions: AnalyticsMetricInfoType;
|
|
365
|
+
newSubscriptionsRevenue: AnalyticsMetricInfoType;
|
|
366
|
+
renewedSubscriptions: AnalyticsMetricInfoType;
|
|
367
|
+
renewedSubscriptionsRevenue: AnalyticsMetricInfoType;
|
|
368
|
+
activeSubscriptions: AnalyticsMetricInfoType;
|
|
369
|
+
monthlyRecurringRevenue: AnalyticsMetricInfoType;
|
|
370
|
+
};
|
|
371
|
+
type AnalyticsResponseType = {
|
|
372
|
+
periods: AnalyticsPeriodType[];
|
|
373
|
+
metrics: AnalyticsMetricsType;
|
|
374
|
+
};
|
|
375
|
+
type AnalyticsIntervalLimitType = {
|
|
376
|
+
maxDays: number;
|
|
377
|
+
};
|
|
378
|
+
type AnalyticsIntervalsLimitsType = {
|
|
379
|
+
hour: AnalyticsIntervalLimitType;
|
|
380
|
+
day: AnalyticsIntervalLimitType;
|
|
381
|
+
week: AnalyticsIntervalLimitType;
|
|
382
|
+
month: AnalyticsIntervalLimitType;
|
|
383
|
+
year: AnalyticsIntervalLimitType;
|
|
384
|
+
};
|
|
385
|
+
type AnalyticsLimitsType = {
|
|
386
|
+
minDate: Date;
|
|
387
|
+
intervals: AnalyticsIntervalsLimitsType;
|
|
388
|
+
};
|
|
389
|
+
declare class PolarAnalytics {
|
|
390
|
+
private client;
|
|
391
|
+
constructor();
|
|
392
|
+
get(options: AnalyticsOptionsType): Promise<AnalyticsResponseType>;
|
|
393
|
+
getLimits(): Promise<AnalyticsLimitsType>;
|
|
394
|
+
private toRFCDate;
|
|
395
|
+
private mapPeriod;
|
|
396
|
+
private mapMetricInfo;
|
|
397
|
+
private mapMetrics;
|
|
398
|
+
private mapIntervalsLimits;
|
|
399
|
+
}
|
|
400
|
+
declare class PolarCheckout {
|
|
401
|
+
private client;
|
|
402
|
+
constructor();
|
|
403
|
+
create(data: CheckoutCreateType): Promise<CheckoutType>;
|
|
404
|
+
get(id: string): Promise<CheckoutType>;
|
|
405
|
+
private mapResponse;
|
|
406
|
+
}
|
|
407
|
+
declare class PolarCustomer {
|
|
408
|
+
private client;
|
|
409
|
+
constructor();
|
|
410
|
+
create(data: CustomerCreateType): Promise<CustomerType>;
|
|
411
|
+
update(id: string, data: CustomerUpdateType): Promise<CustomerType>;
|
|
412
|
+
remove(id: string): Promise<void>;
|
|
413
|
+
get(id: string): Promise<CustomerType>;
|
|
414
|
+
list(options?: CustomerListOptionsType): Promise<CustomerListResultType>;
|
|
415
|
+
getByExternalId(externalId: string): Promise<CustomerType>;
|
|
416
|
+
updateByExternalId(externalId: string, data: CustomerUpdateType): Promise<CustomerType>;
|
|
417
|
+
removeByExternalId(externalId: string): Promise<void>;
|
|
418
|
+
private toBillingAddress;
|
|
419
|
+
private mapResponse;
|
|
420
|
+
}
|
|
421
|
+
declare class PolarCustomerPortal {
|
|
422
|
+
private client;
|
|
423
|
+
constructor();
|
|
424
|
+
create(data: CustomerSessionCreateType): Promise<CustomerSessionType>;
|
|
425
|
+
getPortalUrl(organizationSlug: string): string;
|
|
426
|
+
private mapResponse;
|
|
427
|
+
}
|
|
428
|
+
declare class PolarDiscount {
|
|
429
|
+
private client;
|
|
430
|
+
constructor();
|
|
431
|
+
private toDiscountType;
|
|
432
|
+
private toDiscountDuration;
|
|
433
|
+
create(data: IDiscount): Promise<IDiscount>;
|
|
434
|
+
update(id: string, data: Partial<IDiscount>): Promise<IDiscount>;
|
|
435
|
+
remove(id: string): Promise<void>;
|
|
436
|
+
get(id: string): Promise<IDiscount>;
|
|
437
|
+
private mapResponse;
|
|
438
|
+
}
|
|
439
|
+
declare class PolarProduct {
|
|
440
|
+
private client;
|
|
441
|
+
constructor();
|
|
442
|
+
private toRecurringInterval;
|
|
443
|
+
create(data: IProduct): Promise<Omit<IProduct, "id">>;
|
|
444
|
+
update(id: string, data: Partial<IProduct>): Promise<Omit<IProduct, "id">>;
|
|
445
|
+
remove(id: string): Promise<void>;
|
|
446
|
+
private mapResponse;
|
|
447
|
+
}
|
|
448
|
+
export { SubscriptionPeriodType, PriceTypeType, PriceType, PolarProduct, PolarDiscount, PolarCustomerPortal, PolarCustomer, PolarCheckout, PolarAnalytics, PaymentException, LicenseKeysBenefitType, ISubscription, IProduct, IPlan, IFeature, IDiscount, ICredit, GitHubRepositoryAccessBenefitType, GitHubPermissionType, FileDownloadsBenefitType, ESubscriptionPeriod, EPriceType, EGitHubPermission, EDiscountType, EDiscountDuration, ECheckoutStatus, EBillingType, EBenefitType, EAnalyticsInterval, DiscountType, DiscountDurationType, DiscordAccessBenefitType, CustomerUpdateType, CustomerType, CustomerSessionType, CustomerSessionCreateType, CustomerListResultType, CustomerListOptionsType, CustomerCreateType, CustomerAddressType, CustomFieldType, CustomBenefitType, CreditsBenefitType, CheckoutType, CheckoutStatusType, CheckoutCustomerType, CheckoutCreateType, CheckoutAddressType, BillingTypeType, BenefitTypeType, BenefitType, BenefitFileType, BenefitBaseType, AnalyticsResponseType, AnalyticsPeriodType, AnalyticsOptionsType, AnalyticsMetricsType, AnalyticsMetricInfoType, AnalyticsLimitsType, AnalyticsIntervalsLimitsType, AnalyticsIntervalType, AnalyticsIntervalLimitType };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var t;((r)=>{r.PERCENTAGE="percentage";r.FIXED="fixed"})(t||={});var n;((e)=>{e.MONTHLY="monthly";e.YEARLY="yearly";e.WEEKLY="weekly";e.DAILY="daily"})(n||={});export{n as ESubscriptionPeriod,t as EDiscountType};
|
|
1
|
+
var a=function(e,t,i,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,i):n,c;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(e,t,i,n);else for(var b=e.length-1;b>=0;b--)if(c=e[b])r=(s<3?c(r):s>3?c(t,i,r):c(t,i))||r;return s>3&&r&&Object.defineProperty(t,i,r),r};var u=(e,t)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};import{Exception as A}from"@ooneex/exception";import{HttpStatus as I}from"@ooneex/http-status";class o extends A{constructor(e,t={}){super(e,{status:I.Code.InternalServerError,data:t});this.name="PaymentException"}}import{injectable as T}from"@ooneex/container";import{Polar as f}from"@polar-sh/sdk";class m{client;constructor(){let e=Bun.env.POLAR_ACCESS_TOKEN;if(!e)throw new o("Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.");this.client=new f({accessToken:e,server:Bun.env.POLAR_ENVIRONMENT||"production"})}async get(e){let t=await this.client.metrics.get({startDate:this.toRFCDate(e.startDate),endDate:this.toRFCDate(e.endDate),interval:e.interval,organizationId:e.organizationId??null,productId:e.productId??null,billingType:e.billingType??null,customerId:e.customerId??null});return{periods:t.periods.map((i)=>this.mapPeriod(i)),metrics:this.mapMetrics(t.metrics)}}async getLimits(){let e=await this.client.metrics.limits();return{minDate:new Date(e.minDate.toString()),intervals:this.mapIntervalsLimits(e.intervals)}}toRFCDate(e){let t=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${i}-${n}`}mapPeriod(e){return{timestamp:e.timestamp,orders:e.orders,revenue:e.revenue,cumulativeRevenue:e.cumulativeRevenue,averageOrderValue:e.averageOrderValue,oneTimeProducts:e.oneTimeProducts,oneTimeProductsRevenue:e.oneTimeProductsRevenue,newSubscriptions:e.newSubscriptions,newSubscriptionsRevenue:e.newSubscriptionsRevenue,renewedSubscriptions:e.renewedSubscriptions,renewedSubscriptionsRevenue:e.renewedSubscriptionsRevenue,activeSubscriptions:e.activeSubscriptions,monthlyRecurringRevenue:e.monthlyRecurringRevenue}}mapMetricInfo(e){return{slug:e.slug,displayName:e.displayName,type:e.type}}mapMetrics(e){return{orders:this.mapMetricInfo(e.orders),revenue:this.mapMetricInfo(e.revenue),cumulativeRevenue:this.mapMetricInfo(e.cumulativeRevenue),averageOrderValue:this.mapMetricInfo(e.averageOrderValue),oneTimeProducts:this.mapMetricInfo(e.oneTimeProducts),oneTimeProductsRevenue:this.mapMetricInfo(e.oneTimeProductsRevenue),newSubscriptions:this.mapMetricInfo(e.newSubscriptions),newSubscriptionsRevenue:this.mapMetricInfo(e.newSubscriptionsRevenue),renewedSubscriptions:this.mapMetricInfo(e.renewedSubscriptions),renewedSubscriptionsRevenue:this.mapMetricInfo(e.renewedSubscriptionsRevenue),activeSubscriptions:this.mapMetricInfo(e.activeSubscriptions),monthlyRecurringRevenue:this.mapMetricInfo(e.monthlyRecurringRevenue)}}mapIntervalsLimits(e){return{hour:{maxDays:e.hour.maxDays},day:{maxDays:e.day.maxDays},week:{maxDays:e.week.maxDays},month:{maxDays:e.month.maxDays},year:{maxDays:e.year.maxDays}}}}m=a([T(),u("design:paramtypes",[])],m);import{injectable as x}from"@ooneex/container";import{Polar as C}from"@polar-sh/sdk";class l{client;constructor(){let e=Bun.env.POLAR_ACCESS_TOKEN;if(!e)throw new o("Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.");this.client=new C({accessToken:e,server:Bun.env.POLAR_ENVIRONMENT||"production"})}async create(e){let t=await this.client.checkouts.create({products:e.products,customerExternalId:e.customerExternalId??null,customerId:e.customerId??null,customerEmail:e.customerEmail??null,customerName:e.customerName??null,customerBillingAddress:e.customerBillingAddress?.country?{country:e.customerBillingAddress.country,line1:e.customerBillingAddress.line1??null,line2:e.customerBillingAddress.line2??null,city:e.customerBillingAddress.city??null,state:e.customerBillingAddress.state??null,postalCode:e.customerBillingAddress.postalCode??null}:null,customerTaxId:e.customerTaxId??null,discountId:e.discountId??null,allowDiscountCodes:e.allowDiscountCodes??!0,successUrl:e.successUrl??null,embedOrigin:e.embedOrigin??null,metadata:e.metadata});return this.mapResponse(t)}async get(e){let t=await this.client.checkouts.get({id:e});return this.mapResponse(t)}mapResponse(e){let t={id:e.id,status:e.status,clientSecret:e.clientSecret};if(e.url)t.url=e.url;if(e.embedId)t.embedId=e.embedId;if(e.allowDiscountCodes!==void 0)t.allowDiscountCodes=e.allowDiscountCodes;if(e.isDiscountApplicable!==void 0)t.isDiscountApplicable=e.isDiscountApplicable;if(e.isPaymentRequired!==void 0)t.isPaymentRequired=e.isPaymentRequired;if(e.metadata)t.metadata=e.metadata;if(e.createdAt)t.createdAt=e.createdAt;if(e.modifiedAt)t.updatedAt=e.modifiedAt;if(e.expiresAt)t.expiresAt=e.expiresAt;if(e.successUrl)t.successUrl=e.successUrl;if(e.embedOrigin)t.embedOrigin=e.embedOrigin;if(e.amount!==void 0)t.amount=e.amount;if(e.taxAmount!==void 0)t.taxAmount=e.taxAmount;if(e.currency)t.currency=e.currency;if(e.subtotalAmount!==void 0)t.subtotalAmount=e.subtotalAmount;if(e.totalAmount!==void 0)t.totalAmount=e.totalAmount;if(e.productId)t.productId=e.productId;if(e.productPriceId)t.productPriceId=e.productPriceId;if(e.discountId)t.discountId=e.discountId;if(e.customer){if(t.customer={id:e.customer.id,email:e.customer.email,name:e.customer.name,externalId:e.customer.externalId,taxId:e.customer.taxId},e.customer.billingAddress)t.customer.billingAddress=e.customer.billingAddress}return t}}l=a([x(),u("design:paramtypes",[])],l);import{injectable as R}from"@ooneex/container";import{Polar as v}from"@polar-sh/sdk";class d{client;constructor(){let e=Bun.env.POLAR_ACCESS_TOKEN;if(!e)throw new o("Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.");this.client=new v({accessToken:e,server:Bun.env.POLAR_ENVIRONMENT||"production"})}async create(e){let t=await this.client.customers.create({email:e.email,name:e.name??null,externalId:e.externalId??null,billingAddress:e.billingAddress?this.toBillingAddress(e.billingAddress):null,taxId:e.taxId?[e.taxId,null]:null,organizationId:e.organizationId??null,metadata:e.metadata});return this.mapResponse(t)}async update(e,t){let i=await this.client.customers.update({id:e,customerUpdate:{email:t.email??null,name:t.name??null,billingAddress:t.billingAddress?this.toBillingAddress(t.billingAddress):null,taxId:t.taxId?[t.taxId,null]:null,metadata:t.metadata}});return this.mapResponse(i)}async remove(e){await this.client.customers.delete({id:e})}async get(e){let t=await this.client.customers.get({id:e});return this.mapResponse(t)}async list(e){let i=await this.client.customers.list({organizationId:e?.organizationId,email:e?.email,query:e?.query,page:e?.page??1,limit:e?.limit??10});return{items:i.result.items.map((n)=>this.mapResponse(n)),pagination:{totalCount:i.result.pagination.totalCount,maxPage:i.result.pagination.maxPage}}}async getByExternalId(e){let t=await this.client.customers.getExternal({externalId:e});return this.mapResponse(t)}async updateByExternalId(e,t){let i=await this.client.customers.updateExternal({externalId:e,customerUpdate:{email:t.email??null,name:t.name??null,billingAddress:t.billingAddress?this.toBillingAddress(t.billingAddress):null,taxId:t.taxId?[t.taxId,null]:null,metadata:t.metadata}});return this.mapResponse(i)}async removeByExternalId(e){await this.client.customers.deleteExternal({externalId:e})}toBillingAddress(e){return{country:e.country??"",line1:e.line1,line2:e.line2,city:e.city,state:e.state,postalCode:e.postalCode}}mapResponse(e){let t={id:e.id,email:e.email,emailVerified:e.emailVerified??!1};if(e.createdAt)t.createdAt=e.createdAt;if(e.modifiedAt)t.updatedAt=e.modifiedAt;if(e.deletedAt)t.deletedAt=e.deletedAt;if(e.name)t.name=e.name;if(e.externalId)t.externalId=e.externalId;if(e.avatarUrl)t.avatarUrl=e.avatarUrl;if(e.billingAddress){let i={};if(e.billingAddress.line1)i.line1=e.billingAddress.line1;if(e.billingAddress.line2)i.line2=e.billingAddress.line2;if(e.billingAddress.city)i.city=e.billingAddress.city;if(e.billingAddress.state)i.state=e.billingAddress.state;if(e.billingAddress.postalCode)i.postalCode=e.billingAddress.postalCode;if(e.billingAddress.country)i.country=e.billingAddress.country;t.billingAddress=i}if(e.taxId){let i=typeof e.taxId==="string"?e.taxId:e.taxId[1];t.taxId=i}if(e.organizationId)t.organizationId=e.organizationId;if(e.metadata)t.metadata=e.metadata;return t}}d=a([R(),u("design:paramtypes",[])],d);import{injectable as h}from"@ooneex/container";import{Polar as D}from"@polar-sh/sdk";class p{client;constructor(){let e=Bun.env.POLAR_ACCESS_TOKEN;if(!e)throw new o("Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.");this.client=new D({accessToken:e,server:Bun.env.POLAR_ENVIRONMENT||"production"})}async create(e){let t=await this.client.customerSessions.create({customerId:e.customerId});return this.mapResponse(t)}getPortalUrl(e){return`${Bun.env.POLAR_ENVIRONMENT==="sandbox"?"https://sandbox.polar.sh":"https://polar.sh"}/${e}/portal`}mapResponse(e){let t={id:e.id,token:e.token,customerPortalUrl:e.customerPortalUrl};if(e.createdAt)t.createdAt=e.createdAt;if(e.expiresAt)t.expiresAt=e.expiresAt;if(e.customerId)t.customerId=e.customerId;return t}}p=a([h(),u("design:paramtypes",[])],p);import{injectable as P}from"@ooneex/container";import{Polar as S}from"@polar-sh/sdk";class y{client;constructor(){let e=Bun.env.POLAR_ACCESS_TOKEN;if(!e)throw new o("Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.");this.client=new S({accessToken:e,server:Bun.env.POLAR_ENVIRONMENT||"production"})}toDiscountType(e){return e==="percentage"?"percentage":"fixed"}toDiscountDuration(e){switch(e){case"once":return"once";case"repeating":return"repeating";case"forever":return"forever";default:return"once"}}async create(e){let t=this.toDiscountType(e.type),i=this.toDiscountDuration(e.duration),n={name:e.name,code:e.code??null,startsAt:e.startAt??null,endsAt:e.endAt??null,maxRedemptions:e.maxRedemptions??null,organizationId:e.organizationId??null,metadata:e.metadata,products:e.applicableProducts?.map((r)=>r.id)??null},s;if(t==="percentage")if(i==="repeating")s=await this.client.discounts.create({...n,type:"percentage",basisPoints:e.amount*100,duration:"repeating",durationInMonths:e.durationInMonths??1});else s=await this.client.discounts.create({...n,type:"percentage",basisPoints:e.amount*100,duration:i});else if(i==="repeating")s=await this.client.discounts.create({...n,type:"fixed",amount:e.amount,currency:e.currency??"usd",duration:"repeating",durationInMonths:e.durationInMonths??1});else s=await this.client.discounts.create({...n,type:"fixed",amount:e.amount,currency:e.currency??"usd",duration:i});return this.mapResponse(s)}async update(e,t){let i=await this.client.discounts.update({id:e,discountUpdate:{name:t.name??null,code:t.code??null,startsAt:t.startAt??null,endsAt:t.endAt??null,maxRedemptions:t.maxRedemptions??null,metadata:t.metadata,products:t.applicableProducts?.map((n)=>n.id)??null}});return this.mapResponse(i)}async remove(e){await this.client.discounts.delete({id:e})}async get(e){let t=await this.client.discounts.get({id:e});return this.mapResponse(t)}mapResponse(e){let t={id:e.id,name:e.name,type:e.type,amount:e.type==="percentage"?(e.basisPoints??0)/100:e.amount??0,duration:e.duration,redemptionsCount:e.redemptionsCount,metadata:e.metadata};if(e.createdAt)t.createdAt=e.createdAt;if(e.modifiedAt)t.updatedAt=e.modifiedAt;if(e.code)t.code=e.code;if(e.startsAt)t.startAt=e.startsAt;if(e.endsAt)t.endAt=e.endsAt;if(e.maxRedemptions)t.maxRedemptions=e.maxRedemptions;if(e.durationInMonths)t.durationInMonths=e.durationInMonths;if(e.organizationId)t.organizationId=e.organizationId;if(e.currency)t.currency=e.currency;if(e.products)t.applicableProducts=e.products.map((i)=>({id:i.id,name:i.name}));return t}}y=a([P(),u("design:paramtypes",[])],y);import{injectable as w}from"@ooneex/container";import{Polar as E}from"@polar-sh/sdk";class g{client;constructor(){let e=Bun.env.POLAR_ACCESS_TOKEN;if(!e)throw new o("Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.");this.client=new E({accessToken:e,server:Bun.env.POLAR_ENVIRONMENT||"production"})}toRecurringInterval(e){if(!e)return null;switch(e){case"monthly":return"month";case"yearly":return"year";default:return null}}async create(e){let t=await this.client.products.create({name:e.name,description:e.description??null,recurringInterval:this.toRecurringInterval(e.recurringInterval),prices:e.prices?.map((i)=>({type:i.type,priceCurrency:i.priceCurrency??"usd",priceAmount:i.priceAmount,minimumAmount:i.minimumAmount,maximumAmount:i.maximumAmount,presetAmount:i.presetAmount}))??[],medias:e.images?.map((i)=>i.url)??null,organizationId:e.organizationId??null,metadata:e.metadata,attachedCustomFields:e.attachedCustomFields?.map((i)=>({customFieldId:i.customFieldId,required:i.required}))});return this.mapResponse(t)}async update(e,t){let i=await this.client.products.update({id:e,productUpdate:{name:t.name??null,description:t.description??null,isArchived:t.isArchived??null,recurringInterval:this.toRecurringInterval(t.recurringInterval),prices:t.prices?.map((n)=>({type:n.type,priceCurrency:n.priceCurrency??"usd",priceAmount:n.priceAmount,minimumAmount:n.minimumAmount,maximumAmount:n.maximumAmount,presetAmount:n.presetAmount}))??null,medias:t.images?.map((n)=>n.url)??null,metadata:t.metadata,attachedCustomFields:t.attachedCustomFields?.map((n)=>({customFieldId:n.customFieldId,required:n.required}))??null}});return this.mapResponse(i)}async remove(e){await this.client.products.update({id:e,productUpdate:{isArchived:!0}})}mapResponse(e){let t={key:e.id,name:e.name,isRecurring:e.isRecurring,isArchived:e.isArchived,organizationId:e.organizationId,metadata:e.metadata,prices:e.prices,benefits:e.benefits,attachedCustomFields:e.attachedCustomFields};if(e.createdAt)t.createdAt=e.createdAt;if(e.modifiedAt)t.updatedAt=e.modifiedAt;if(e.description)t.description=e.description;return t}}g=a([w(),u("design:paramtypes",[])],g);var O;((n)=>{n.FIXED="fixed";n.CUSTOM="custom";n.FREE="free"})(O||={});var B;((i)=>{i.PERCENTAGE="percentage";i.FIXED="fixed"})(B||={});var k;((n)=>{n.ONCE="once";n.REPEATING="repeating";n.FOREVER="forever"})(k||={});var N;((s)=>{s.MONTHLY="monthly";s.YEARLY="yearly";s.WEEKLY="weekly";s.DAILY="daily"})(N||={});var M;((c)=>{c.CREDITS="credits";c.LICENSE_KEYS="license_keys";c.FILE_DOWNLOADS="file_downloads";c.GITHUB_REPOSITORY_ACCESS="github_repository_access";c.DISCORD_ACCESS="discord_access";c.CUSTOM="custom"})(M||={});var L;((r)=>{r.READ="read";r.TRIAGE="triage";r.WRITE="write";r.MAINTAIN="maintain";r.ADMIN="admin"})(L||={});var _;((r)=>{r.OPEN="open";r.EXPIRED="expired";r.CONFIRMED="confirmed";r.SUCCEEDED="succeeded";r.FAILED="failed"})(_||={});var F;((r)=>{r.YEAR="year";r.MONTH="month";r.WEEK="week";r.DAY="day";r.HOUR="hour"})(F||={});var U;((i)=>{i.ONE_TIME="one_time";i.RECURRING="recurring"})(U||={});export{g as PolarProduct,y as PolarDiscount,p as PolarCustomerPortal,d as PolarCustomer,l as PolarCheckout,m as PolarAnalytics,o as PaymentException,N as ESubscriptionPeriod,O as EPriceType,L as EGitHubPermission,B as EDiscountType,k as EDiscountDuration,_ as ECheckoutStatus,U as EBillingType,M as EBenefitType,F as EAnalyticsInterval};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=55A36E2883BAC92E64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["src/types.ts"],
|
|
3
|
+
"sources": ["src/PaymentException.ts", "src/PolarAnalytics.ts", "src/PolarCheckout.ts", "src/PolarCustomer.ts", "src/PolarCustomerPortal.ts", "src/PolarDiscount.ts", "src/PolarProduct.ts", "src/types.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import
|
|
5
|
+
"import { Exception } from \"@ooneex/exception\";\nimport { HttpStatus } from \"@ooneex/http-status\";\n\nexport class PaymentException extends Exception {\n constructor(message: string, data: Record<string, unknown> = {}) {\n super(message, {\n status: HttpStatus.Code.InternalServerError,\n data,\n });\n\n this.name = \"PaymentException\";\n }\n}\n",
|
|
6
|
+
"import { injectable } from \"@ooneex/container\";\nimport { Polar } from \"@polar-sh/sdk\";\nimport type { RFCDate } from \"@polar-sh/sdk/types/rfcdate.js\";\nimport { PaymentException } from \"./PaymentException\";\nimport type {\n AnalyticsIntervalsLimitsType,\n AnalyticsLimitsType,\n AnalyticsMetricInfoType,\n AnalyticsMetricsType,\n AnalyticsOptionsType,\n AnalyticsPeriodType,\n AnalyticsResponseType,\n BillingTypeType,\n} from \"./types\";\n\n@injectable()\nexport class PolarAnalytics {\n private client: Polar;\n\n constructor() {\n const accessToken = Bun.env.POLAR_ACCESS_TOKEN;\n\n if (!accessToken) {\n throw new PaymentException(\n \"Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.\",\n );\n }\n\n this.client = new Polar({\n accessToken,\n server: (Bun.env.POLAR_ENVIRONMENT as \"sandbox\" | \"production\") || \"production\",\n });\n }\n\n public async get(options: AnalyticsOptionsType): Promise<AnalyticsResponseType> {\n const response = await this.client.metrics.get({\n startDate: this.toRFCDate(options.startDate),\n endDate: this.toRFCDate(options.endDate),\n interval: options.interval,\n organizationId: options.organizationId ?? null,\n productId: options.productId ?? null,\n billingType: (options.billingType as BillingTypeType) ?? null,\n customerId: options.customerId ?? null,\n });\n\n return {\n periods: response.periods.map((period) => this.mapPeriod(period)),\n metrics: this.mapMetrics(response.metrics),\n };\n }\n\n public async getLimits(): Promise<AnalyticsLimitsType> {\n const response = await this.client.metrics.limits();\n\n return {\n minDate: new Date(response.minDate.toString()),\n intervals: this.mapIntervalsLimits(response.intervals),\n };\n }\n\n private toRFCDate(date: Date): RFCDate {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const day = String(date.getDate()).padStart(2, \"0\");\n\n return `${year}-${month}-${day}` as unknown as RFCDate;\n }\n\n private mapPeriod(period: {\n timestamp: Date;\n orders: number;\n revenue: number;\n cumulativeRevenue: number;\n averageOrderValue: number;\n oneTimeProducts: number;\n oneTimeProductsRevenue: number;\n newSubscriptions: number;\n newSubscriptionsRevenue: number;\n renewedSubscriptions: number;\n renewedSubscriptionsRevenue: number;\n activeSubscriptions: number;\n monthlyRecurringRevenue: number;\n }): AnalyticsPeriodType {\n return {\n timestamp: period.timestamp,\n orders: period.orders,\n revenue: period.revenue,\n cumulativeRevenue: period.cumulativeRevenue,\n averageOrderValue: period.averageOrderValue,\n oneTimeProducts: period.oneTimeProducts,\n oneTimeProductsRevenue: period.oneTimeProductsRevenue,\n newSubscriptions: period.newSubscriptions,\n newSubscriptionsRevenue: period.newSubscriptionsRevenue,\n renewedSubscriptions: period.renewedSubscriptions,\n renewedSubscriptionsRevenue: period.renewedSubscriptionsRevenue,\n activeSubscriptions: period.activeSubscriptions,\n monthlyRecurringRevenue: period.monthlyRecurringRevenue,\n };\n }\n\n private mapMetricInfo(metric: { slug: string; displayName: string; type: string }): AnalyticsMetricInfoType {\n return {\n slug: metric.slug,\n displayName: metric.displayName,\n type: metric.type,\n };\n }\n\n private mapMetrics(metrics: {\n orders: { slug: string; displayName: string; type: string };\n revenue: { slug: string; displayName: string; type: string };\n cumulativeRevenue: { slug: string; displayName: string; type: string };\n averageOrderValue: { slug: string; displayName: string; type: string };\n oneTimeProducts: { slug: string; displayName: string; type: string };\n oneTimeProductsRevenue: { slug: string; displayName: string; type: string };\n newSubscriptions: { slug: string; displayName: string; type: string };\n newSubscriptionsRevenue: { slug: string; displayName: string; type: string };\n renewedSubscriptions: { slug: string; displayName: string; type: string };\n renewedSubscriptionsRevenue: { slug: string; displayName: string; type: string };\n activeSubscriptions: { slug: string; displayName: string; type: string };\n monthlyRecurringRevenue: { slug: string; displayName: string; type: string };\n }): AnalyticsMetricsType {\n return {\n orders: this.mapMetricInfo(metrics.orders),\n revenue: this.mapMetricInfo(metrics.revenue),\n cumulativeRevenue: this.mapMetricInfo(metrics.cumulativeRevenue),\n averageOrderValue: this.mapMetricInfo(metrics.averageOrderValue),\n oneTimeProducts: this.mapMetricInfo(metrics.oneTimeProducts),\n oneTimeProductsRevenue: this.mapMetricInfo(metrics.oneTimeProductsRevenue),\n newSubscriptions: this.mapMetricInfo(metrics.newSubscriptions),\n newSubscriptionsRevenue: this.mapMetricInfo(metrics.newSubscriptionsRevenue),\n renewedSubscriptions: this.mapMetricInfo(metrics.renewedSubscriptions),\n renewedSubscriptionsRevenue: this.mapMetricInfo(metrics.renewedSubscriptionsRevenue),\n activeSubscriptions: this.mapMetricInfo(metrics.activeSubscriptions),\n monthlyRecurringRevenue: this.mapMetricInfo(metrics.monthlyRecurringRevenue),\n };\n }\n\n private mapIntervalsLimits(intervals: {\n hour: { maxDays: number };\n day: { maxDays: number };\n week: { maxDays: number };\n month: { maxDays: number };\n year: { maxDays: number };\n }): AnalyticsIntervalsLimitsType {\n return {\n hour: { maxDays: intervals.hour.maxDays },\n day: { maxDays: intervals.day.maxDays },\n week: { maxDays: intervals.week.maxDays },\n month: { maxDays: intervals.month.maxDays },\n year: { maxDays: intervals.year.maxDays },\n };\n }\n}\n",
|
|
7
|
+
"import { injectable } from \"@ooneex/container\";\nimport type { CurrencyCodeType } from \"@ooneex/currencies\";\nimport { Polar } from \"@polar-sh/sdk\";\nimport { PaymentException } from \"./PaymentException\";\nimport type {\n CheckoutAddressType,\n CheckoutCreateType,\n CheckoutCustomerType,\n CheckoutStatusType,\n CheckoutType,\n} from \"./types\";\n\n@injectable()\nexport class PolarCheckout {\n private client: Polar;\n\n constructor() {\n const accessToken = Bun.env.POLAR_ACCESS_TOKEN;\n\n if (!accessToken) {\n throw new PaymentException(\n \"Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.\",\n );\n }\n\n this.client = new Polar({\n accessToken,\n server: (Bun.env.POLAR_ENVIRONMENT as \"sandbox\" | \"production\") || \"production\",\n });\n }\n\n public async create(data: CheckoutCreateType): Promise<CheckoutType> {\n const response = await this.client.checkouts.create({\n products: data.products,\n customerExternalId: data.customerExternalId ?? null,\n customerId: data.customerId ?? null,\n customerEmail: data.customerEmail ?? null,\n customerName: data.customerName ?? null,\n customerBillingAddress: data.customerBillingAddress?.country\n ? {\n country: data.customerBillingAddress.country,\n line1: data.customerBillingAddress.line1 ?? null,\n line2: data.customerBillingAddress.line2 ?? null,\n city: data.customerBillingAddress.city ?? null,\n state: data.customerBillingAddress.state ?? null,\n postalCode: data.customerBillingAddress.postalCode ?? null,\n }\n : null,\n customerTaxId: data.customerTaxId ?? null,\n discountId: data.discountId ?? null,\n allowDiscountCodes: data.allowDiscountCodes ?? true,\n successUrl: data.successUrl ?? null,\n embedOrigin: data.embedOrigin ?? null,\n metadata: data.metadata,\n });\n\n return this.mapResponse(response as unknown as CheckoutResponse);\n }\n\n public async get(id: string): Promise<CheckoutType> {\n const response = await this.client.checkouts.get({ id });\n\n return this.mapResponse(response as unknown as CheckoutResponse);\n }\n\n private mapResponse(response: CheckoutResponse): CheckoutType {\n const checkout: CheckoutType = {\n id: response.id,\n status: response.status as CheckoutStatusType,\n clientSecret: response.clientSecret,\n };\n\n if (response.url) {\n checkout.url = response.url;\n }\n\n if (response.embedId) {\n checkout.embedId = response.embedId;\n }\n\n if (response.allowDiscountCodes !== undefined) {\n checkout.allowDiscountCodes = response.allowDiscountCodes;\n }\n\n if (response.isDiscountApplicable !== undefined) {\n checkout.isDiscountApplicable = response.isDiscountApplicable;\n }\n\n if (response.isPaymentRequired !== undefined) {\n checkout.isPaymentRequired = response.isPaymentRequired;\n }\n\n if (response.metadata) {\n checkout.metadata = response.metadata;\n }\n\n if (response.createdAt) {\n checkout.createdAt = response.createdAt;\n }\n\n if (response.modifiedAt) {\n checkout.updatedAt = response.modifiedAt;\n }\n\n if (response.expiresAt) {\n checkout.expiresAt = response.expiresAt;\n }\n\n if (response.successUrl) {\n checkout.successUrl = response.successUrl;\n }\n\n if (response.embedOrigin) {\n checkout.embedOrigin = response.embedOrigin;\n }\n\n if (response.amount !== undefined) {\n checkout.amount = response.amount;\n }\n\n if (response.taxAmount !== undefined) {\n checkout.taxAmount = response.taxAmount;\n }\n\n if (response.currency) {\n checkout.currency = response.currency as CurrencyCodeType;\n }\n\n if (response.subtotalAmount !== undefined) {\n checkout.subtotalAmount = response.subtotalAmount;\n }\n\n if (response.totalAmount !== undefined) {\n checkout.totalAmount = response.totalAmount;\n }\n\n if (response.productId) {\n checkout.productId = response.productId;\n }\n\n if (response.productPriceId) {\n checkout.productPriceId = response.productPriceId;\n }\n\n if (response.discountId) {\n checkout.discountId = response.discountId;\n }\n\n if (response.customer) {\n checkout.customer = {\n id: response.customer.id,\n email: response.customer.email,\n name: response.customer.name,\n externalId: response.customer.externalId,\n taxId: response.customer.taxId,\n } as CheckoutCustomerType;\n\n if (response.customer.billingAddress) {\n checkout.customer.billingAddress = response.customer.billingAddress as CheckoutAddressType;\n }\n }\n\n return checkout;\n }\n}\n\ntype CheckoutResponse = {\n id: string;\n createdAt?: Date;\n modifiedAt?: Date;\n url?: string;\n embedId?: string;\n status: string;\n clientSecret: string;\n expiresAt?: Date;\n successUrl?: string;\n embedOrigin?: string;\n amount?: number;\n taxAmount?: number;\n currency?: string;\n subtotalAmount?: number;\n totalAmount?: number;\n productId?: string;\n productPriceId?: string;\n discountId?: string;\n allowDiscountCodes?: boolean;\n isDiscountApplicable?: boolean;\n isPaymentRequired?: boolean;\n customer?: {\n id?: string;\n email?: string;\n name?: string;\n externalId?: string;\n billingAddress?: {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n };\n taxId?: string;\n };\n metadata: Record<string, string | number | boolean>;\n};\n",
|
|
8
|
+
"import { injectable } from \"@ooneex/container\";\nimport { Polar } from \"@polar-sh/sdk\";\nimport type { Address } from \"@polar-sh/sdk/models/components/address.js\";\nimport { PaymentException } from \"./PaymentException\";\nimport type {\n CustomerAddressType,\n CustomerCreateType,\n CustomerListOptionsType,\n CustomerListResultType,\n CustomerType,\n CustomerUpdateType,\n} from \"./types\";\n\n@injectable()\nexport class PolarCustomer {\n private client: Polar;\n\n constructor() {\n const accessToken = Bun.env.POLAR_ACCESS_TOKEN;\n\n if (!accessToken) {\n throw new PaymentException(\n \"Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.\",\n );\n }\n\n this.client = new Polar({\n accessToken,\n server: (Bun.env.POLAR_ENVIRONMENT as \"sandbox\" | \"production\") || \"production\",\n });\n }\n\n public async create(data: CustomerCreateType): Promise<CustomerType> {\n const response = await this.client.customers.create({\n email: data.email,\n name: data.name ?? null,\n externalId: data.externalId ?? null,\n billingAddress: data.billingAddress ? this.toBillingAddress(data.billingAddress) : null,\n taxId: data.taxId ? [data.taxId, null] : null,\n organizationId: data.organizationId ?? null,\n metadata: data.metadata,\n });\n\n return this.mapResponse(response as unknown as CustomerResponse);\n }\n\n public async update(id: string, data: CustomerUpdateType): Promise<CustomerType> {\n const response = await this.client.customers.update({\n id,\n customerUpdate: {\n email: data.email ?? null,\n name: data.name ?? null,\n billingAddress: data.billingAddress ? this.toBillingAddress(data.billingAddress) : null,\n taxId: data.taxId ? [data.taxId, null] : null,\n metadata: data.metadata,\n },\n });\n\n return this.mapResponse(response as unknown as CustomerResponse);\n }\n\n public async remove(id: string): Promise<void> {\n await this.client.customers.delete({ id });\n }\n\n public async get(id: string): Promise<CustomerType> {\n const response = await this.client.customers.get({ id });\n\n return this.mapResponse(response as unknown as CustomerResponse);\n }\n\n public async list(options?: CustomerListOptionsType): Promise<CustomerListResultType> {\n const response = await this.client.customers.list({\n organizationId: options?.organizationId,\n email: options?.email,\n query: options?.query,\n page: options?.page ?? 1,\n limit: options?.limit ?? 10,\n });\n\n const result = response as unknown as CustomerListResponse;\n\n return {\n items: result.result.items.map((item) => this.mapResponse(item)),\n pagination: {\n totalCount: result.result.pagination.totalCount,\n maxPage: result.result.pagination.maxPage,\n },\n };\n }\n\n public async getByExternalId(externalId: string): Promise<CustomerType> {\n const response = await this.client.customers.getExternal({ externalId });\n\n return this.mapResponse(response as unknown as CustomerResponse);\n }\n\n public async updateByExternalId(externalId: string, data: CustomerUpdateType): Promise<CustomerType> {\n const response = await this.client.customers.updateExternal({\n externalId,\n customerUpdate: {\n email: data.email ?? null,\n name: data.name ?? null,\n billingAddress: data.billingAddress ? this.toBillingAddress(data.billingAddress) : null,\n taxId: data.taxId ? [data.taxId, null] : null,\n metadata: data.metadata,\n },\n });\n\n return this.mapResponse(response as unknown as CustomerResponse);\n }\n\n public async removeByExternalId(externalId: string): Promise<void> {\n await this.client.customers.deleteExternal({ externalId });\n }\n\n private toBillingAddress(address: CustomerAddressType): Address {\n return {\n country: address.country ?? \"\",\n line1: address.line1,\n line2: address.line2,\n city: address.city,\n state: address.state,\n postalCode: address.postalCode,\n };\n }\n\n private mapResponse(response: CustomerResponse): CustomerType {\n const customer: CustomerType = {\n id: response.id,\n email: response.email,\n emailVerified: response.emailVerified ?? false,\n };\n\n if (response.createdAt) {\n customer.createdAt = response.createdAt;\n }\n\n if (response.modifiedAt) {\n customer.updatedAt = response.modifiedAt;\n }\n\n if (response.deletedAt) {\n customer.deletedAt = response.deletedAt;\n }\n\n if (response.name) {\n customer.name = response.name;\n }\n\n if (response.externalId) {\n customer.externalId = response.externalId;\n }\n\n if (response.avatarUrl) {\n customer.avatarUrl = response.avatarUrl;\n }\n\n if (response.billingAddress) {\n const billingAddress: CustomerAddressType = {};\n if (response.billingAddress.line1) {\n billingAddress.line1 = response.billingAddress.line1;\n }\n if (response.billingAddress.line2) {\n billingAddress.line2 = response.billingAddress.line2;\n }\n if (response.billingAddress.city) {\n billingAddress.city = response.billingAddress.city;\n }\n if (response.billingAddress.state) {\n billingAddress.state = response.billingAddress.state;\n }\n if (response.billingAddress.postalCode) {\n billingAddress.postalCode = response.billingAddress.postalCode;\n }\n if (response.billingAddress.country) {\n billingAddress.country = response.billingAddress.country;\n }\n customer.billingAddress = billingAddress;\n }\n\n if (response.taxId) {\n const taxIdValue = typeof response.taxId === \"string\" ? response.taxId : response.taxId[1];\n customer.taxId = taxIdValue;\n }\n\n if (response.organizationId) {\n customer.organizationId = response.organizationId;\n }\n\n if (response.metadata) {\n customer.metadata = response.metadata;\n }\n\n return customer;\n }\n}\n\ntype CustomerResponse = {\n id: string;\n createdAt?: Date;\n modifiedAt?: Date;\n deletedAt?: Date;\n email: string;\n emailVerified?: boolean;\n name?: string;\n externalId?: string;\n avatarUrl?: string;\n billingAddress?: {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n };\n taxId?: string | [string, string];\n organizationId?: string;\n metadata?: Record<string, string | number | boolean>;\n};\n\ntype CustomerListResponse = {\n result: {\n items: CustomerResponse[];\n pagination: {\n totalCount: number;\n maxPage: number;\n };\n };\n};\n",
|
|
9
|
+
"import { injectable } from \"@ooneex/container\";\nimport { Polar } from \"@polar-sh/sdk\";\nimport { PaymentException } from \"./PaymentException\";\nimport type { CustomerSessionCreateType, CustomerSessionType } from \"./types\";\n\n@injectable()\nexport class PolarCustomerPortal {\n private client: Polar;\n\n constructor() {\n const accessToken = Bun.env.POLAR_ACCESS_TOKEN;\n\n if (!accessToken) {\n throw new PaymentException(\n \"Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.\",\n );\n }\n\n this.client = new Polar({\n accessToken,\n server: (Bun.env.POLAR_ENVIRONMENT as \"sandbox\" | \"production\") || \"production\",\n });\n }\n\n public async create(data: CustomerSessionCreateType): Promise<CustomerSessionType> {\n const response = await this.client.customerSessions.create({\n customerId: data.customerId,\n });\n\n return this.mapResponse(response as unknown as CustomerSessionResponse);\n }\n\n public getPortalUrl(organizationSlug: string): string {\n const baseUrl = Bun.env.POLAR_ENVIRONMENT === \"sandbox\" ? \"https://sandbox.polar.sh\" : \"https://polar.sh\";\n\n return `${baseUrl}/${organizationSlug}/portal`;\n }\n\n private mapResponse(response: CustomerSessionResponse): CustomerSessionType {\n const session: CustomerSessionType = {\n id: response.id,\n token: response.token,\n customerPortalUrl: response.customerPortalUrl,\n };\n\n if (response.createdAt) {\n session.createdAt = response.createdAt;\n }\n\n if (response.expiresAt) {\n session.expiresAt = response.expiresAt;\n }\n\n if (response.customerId) {\n session.customerId = response.customerId;\n }\n\n return session;\n }\n}\n\ntype CustomerSessionResponse = {\n id: string;\n token: string;\n customerPortalUrl: string;\n createdAt?: Date;\n expiresAt?: Date;\n customerId?: string;\n};\n",
|
|
10
|
+
"import { injectable } from \"@ooneex/container\";\nimport type { CurrencyCodeType } from \"@ooneex/currencies\";\nimport { Polar } from \"@polar-sh/sdk\";\nimport { PaymentException } from \"./PaymentException\";\nimport type { DiscountDurationType, DiscountType, IDiscount, IProduct } from \"./types\";\n\n@injectable()\nexport class PolarDiscount {\n private client: Polar;\n\n constructor() {\n const accessToken = Bun.env.POLAR_ACCESS_TOKEN;\n\n if (!accessToken) {\n throw new PaymentException(\n \"Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.\",\n );\n }\n\n this.client = new Polar({\n accessToken,\n server: (Bun.env.POLAR_ENVIRONMENT as \"sandbox\" | \"production\") || \"production\",\n });\n }\n\n private toDiscountType(type: DiscountType): \"percentage\" | \"fixed\" {\n return type === \"percentage\" ? \"percentage\" : \"fixed\";\n }\n\n private toDiscountDuration(duration: DiscountDurationType): \"once\" | \"repeating\" | \"forever\" {\n switch (duration) {\n case \"once\":\n return \"once\";\n case \"repeating\":\n return \"repeating\";\n case \"forever\":\n return \"forever\";\n default:\n return \"once\";\n }\n }\n\n public async create(data: IDiscount): Promise<IDiscount> {\n const discountType = this.toDiscountType(data.type);\n const duration = this.toDiscountDuration(data.duration);\n\n const basePayload = {\n name: data.name,\n code: data.code ?? null,\n startsAt: data.startAt ?? null,\n endsAt: data.endAt ?? null,\n maxRedemptions: data.maxRedemptions ?? null,\n organizationId: data.organizationId ?? null,\n metadata: data.metadata,\n products: data.applicableProducts?.map((p) => p.id as string) ?? null,\n };\n\n let response: unknown;\n\n if (discountType === \"percentage\") {\n if (duration === \"repeating\") {\n response = await this.client.discounts.create({\n ...basePayload,\n type: \"percentage\",\n basisPoints: data.amount * 100,\n duration: \"repeating\",\n durationInMonths: data.durationInMonths ?? 1,\n });\n } else {\n response = await this.client.discounts.create({\n ...basePayload,\n type: \"percentage\",\n basisPoints: data.amount * 100,\n duration: duration as \"once\" | \"forever\",\n });\n }\n } else {\n if (duration === \"repeating\") {\n response = await this.client.discounts.create({\n ...basePayload,\n type: \"fixed\",\n amount: data.amount,\n currency: data.currency ?? \"usd\",\n duration: \"repeating\",\n durationInMonths: data.durationInMonths ?? 1,\n });\n } else {\n response = await this.client.discounts.create({\n ...basePayload,\n type: \"fixed\",\n amount: data.amount,\n currency: data.currency ?? \"usd\",\n duration: duration as \"once\" | \"forever\",\n });\n }\n }\n\n return this.mapResponse(response as unknown as DiscountResponse);\n }\n\n public async update(id: string, data: Partial<IDiscount>): Promise<IDiscount> {\n const response = await this.client.discounts.update({\n id,\n discountUpdate: {\n name: data.name ?? null,\n code: data.code ?? null,\n startsAt: data.startAt ?? null,\n endsAt: data.endAt ?? null,\n maxRedemptions: data.maxRedemptions ?? null,\n metadata: data.metadata,\n products: data.applicableProducts?.map((p) => p.id as string) ?? null,\n },\n });\n\n return this.mapResponse(response as unknown as DiscountResponse);\n }\n\n public async remove(id: string): Promise<void> {\n await this.client.discounts.delete({ id });\n }\n\n public async get(id: string): Promise<IDiscount> {\n const response = await this.client.discounts.get({ id });\n\n return this.mapResponse(response as unknown as DiscountResponse);\n }\n\n private mapResponse(response: DiscountResponse): IDiscount {\n const discount: IDiscount = {\n id: response.id,\n name: response.name,\n type: response.type as DiscountType,\n amount: response.type === \"percentage\" ? (response.basisPoints ?? 0) / 100 : (response.amount ?? 0),\n duration: response.duration as DiscountDurationType,\n redemptionsCount: response.redemptionsCount,\n metadata: response.metadata,\n };\n\n if (response.createdAt) {\n discount.createdAt = response.createdAt;\n }\n\n if (response.modifiedAt) {\n discount.updatedAt = response.modifiedAt;\n }\n\n if (response.code) {\n discount.code = response.code;\n }\n\n if (response.startsAt) {\n discount.startAt = response.startsAt;\n }\n\n if (response.endsAt) {\n discount.endAt = response.endsAt;\n }\n\n if (response.maxRedemptions) {\n discount.maxRedemptions = response.maxRedemptions;\n }\n\n if (response.durationInMonths) {\n discount.durationInMonths = response.durationInMonths;\n }\n\n if (response.organizationId) {\n discount.organizationId = response.organizationId;\n }\n\n if (response.currency) {\n discount.currency = response.currency as CurrencyCodeType;\n }\n\n if (response.products) {\n discount.applicableProducts = response.products.map(\n (p: { id: string; name: string }) =>\n ({\n id: p.id,\n name: p.name,\n }) as IProduct,\n );\n }\n\n return discount;\n }\n}\n\ntype DiscountResponse = {\n id: string;\n createdAt?: Date;\n modifiedAt?: Date;\n name: string;\n code?: string;\n type: string;\n basisPoints?: number;\n amount?: number;\n currency?: string;\n duration: string;\n durationInMonths?: number;\n startsAt?: Date;\n endsAt?: Date;\n maxRedemptions?: number;\n redemptionsCount: number;\n organizationId?: string;\n metadata: Record<string, string | number | boolean>;\n products?: { id: string; name: string }[];\n};\n",
|
|
11
|
+
"import { injectable } from \"@ooneex/container\";\nimport { Polar } from \"@polar-sh/sdk\";\nimport type { SubscriptionRecurringInterval } from \"@polar-sh/sdk/models/components/subscriptionrecurringinterval.js\";\nimport { PaymentException } from \"./PaymentException\";\nimport type { BenefitType, CustomFieldType, IProduct, PriceType, SubscriptionPeriodType } from \"./types\";\n\n@injectable()\nexport class PolarProduct {\n private client: Polar;\n\n constructor() {\n const accessToken = Bun.env.POLAR_ACCESS_TOKEN;\n\n if (!accessToken) {\n throw new PaymentException(\n \"Polar access token is required. Please set the POLAR_ACCESS_TOKEN environment variable.\",\n );\n }\n\n this.client = new Polar({\n accessToken,\n server: (Bun.env.POLAR_ENVIRONMENT as \"sandbox\" | \"production\") || \"production\",\n });\n }\n\n private toRecurringInterval(period?: SubscriptionPeriodType): SubscriptionRecurringInterval | null {\n if (!period) return null;\n\n switch (period) {\n case \"monthly\":\n return \"month\";\n case \"yearly\":\n return \"year\";\n default:\n return null;\n }\n }\n\n public async create(data: IProduct): Promise<Omit<IProduct, \"id\">> {\n const response = await this.client.products.create({\n name: data.name,\n description: data.description ?? null,\n recurringInterval: this.toRecurringInterval(data.recurringInterval),\n prices:\n data.prices?.map((price) => ({\n type: price.type,\n priceCurrency: price.priceCurrency ?? \"usd\",\n priceAmount: price.priceAmount,\n minimumAmount: price.minimumAmount,\n maximumAmount: price.maximumAmount,\n presetAmount: price.presetAmount,\n })) ?? [],\n medias: data.images?.map((image) => image.url) ?? null,\n organizationId: data.organizationId ?? null,\n metadata: data.metadata,\n attachedCustomFields: data.attachedCustomFields?.map((field) => ({\n customFieldId: field.customFieldId,\n required: field.required,\n })),\n });\n\n return this.mapResponse(response);\n }\n\n public async update(id: string, data: Partial<IProduct>): Promise<Omit<IProduct, \"id\">> {\n const response = await this.client.products.update({\n id,\n productUpdate: {\n name: data.name ?? null,\n description: data.description ?? null,\n isArchived: data.isArchived ?? null,\n recurringInterval: this.toRecurringInterval(data.recurringInterval),\n prices:\n data.prices?.map((price) => ({\n type: price.type,\n priceCurrency: price.priceCurrency ?? \"usd\",\n priceAmount: price.priceAmount,\n minimumAmount: price.minimumAmount,\n maximumAmount: price.maximumAmount,\n presetAmount: price.presetAmount,\n })) ?? null,\n medias: data.images?.map((image) => image.url) ?? null,\n metadata: data.metadata,\n attachedCustomFields:\n data.attachedCustomFields?.map((field) => ({\n customFieldId: field.customFieldId,\n required: field.required,\n })) ?? null,\n },\n });\n\n return this.mapResponse(response);\n }\n\n public async remove(id: string): Promise<void> {\n await this.client.products.update({\n id,\n productUpdate: {\n isArchived: true,\n },\n });\n }\n\n private mapResponse(response: {\n id: string;\n createdAt: Date;\n modifiedAt: Date | null;\n name: string;\n description: string | null;\n isRecurring: boolean;\n isArchived: boolean;\n organizationId: string;\n metadata: Record<string, string | number | boolean>;\n prices: unknown[];\n benefits: unknown[];\n attachedCustomFields: unknown[];\n }): Omit<IProduct, \"id\"> {\n const product: Omit<IProduct, \"id\"> = {\n key: response.id,\n name: response.name,\n isRecurring: response.isRecurring,\n isArchived: response.isArchived,\n organizationId: response.organizationId,\n metadata: response.metadata,\n prices: response.prices as PriceType[],\n benefits: response.benefits as BenefitType[],\n attachedCustomFields: response.attachedCustomFields as CustomFieldType[],\n };\n\n if (response.createdAt) {\n product.createdAt = response.createdAt;\n }\n\n if (response.modifiedAt) {\n product.updatedAt = response.modifiedAt;\n }\n\n if (response.description) {\n product.description = response.description;\n }\n\n return product;\n }\n}\n",
|
|
12
|
+
"import type { ICategory } from \"@ooneex/category\";\nimport type { CurrencyCodeType } from \"@ooneex/currencies\";\nimport type { IImage } from \"@ooneex/image\";\nimport type { ITag } from \"@ooneex/tag\";\nimport type { IBase, ScalarType } from \"@ooneex/types\";\n\nexport enum EPriceType {\n FIXED = \"fixed\",\n CUSTOM = \"custom\",\n FREE = \"free\",\n}\n\nexport type PriceTypeType = `${EPriceType}`;\n\nexport type PriceType = {\n type: PriceTypeType;\n priceCurrency?: string;\n priceAmount?: number;\n minimumAmount?: number;\n maximumAmount?: number;\n presetAmount?: number;\n};\n\nexport type CustomFieldType = {\n customFieldId: string;\n required: boolean;\n};\n\nexport enum EDiscountType {\n PERCENTAGE = \"percentage\",\n FIXED = \"fixed\",\n}\n\nexport enum EDiscountDuration {\n ONCE = \"once\",\n REPEATING = \"repeating\",\n FOREVER = \"forever\",\n}\n\nexport type DiscountDurationType = `${EDiscountDuration}`;\n\nexport enum ESubscriptionPeriod {\n MONTHLY = \"monthly\",\n YEARLY = \"yearly\",\n WEEKLY = \"weekly\",\n DAILY = \"daily\",\n}\n\nexport type DiscountType = `${EDiscountType}`;\nexport type SubscriptionPeriodType = `${ESubscriptionPeriod}`;\n\nexport enum EBenefitType {\n CREDITS = \"credits\",\n LICENSE_KEYS = \"license_keys\",\n FILE_DOWNLOADS = \"file_downloads\",\n GITHUB_REPOSITORY_ACCESS = \"github_repository_access\",\n DISCORD_ACCESS = \"discord_access\",\n CUSTOM = \"custom\",\n}\n\nexport type BenefitTypeType = `${EBenefitType}`;\n\nexport enum EGitHubPermission {\n READ = \"read\",\n TRIAGE = \"triage\",\n WRITE = \"write\",\n MAINTAIN = \"maintain\",\n ADMIN = \"admin\",\n}\n\nexport type GitHubPermissionType = `${EGitHubPermission}`;\n\nexport type BenefitBaseType = {\n type: BenefitTypeType;\n name: string;\n description?: string;\n isSelectable?: boolean;\n isDeletable?: boolean;\n organizationId?: string;\n};\n\nexport type CreditsBenefitType = BenefitBaseType & {\n type: typeof EBenefitType.CREDITS;\n amount: number;\n rollover?: boolean;\n};\n\nexport type LicenseKeysBenefitType = BenefitBaseType & {\n type: typeof EBenefitType.LICENSE_KEYS;\n prefix?: string;\n expiresInDays?: number;\n expiresInMonths?: number;\n expiresInYears?: number;\n activationLimit?: number;\n usageLimit?: number;\n};\n\nexport type FileDownloadsBenefitType = BenefitBaseType & {\n type: typeof EBenefitType.FILE_DOWNLOADS;\n files?: BenefitFileType[];\n};\n\nexport type BenefitFileType = {\n id: string;\n name: string;\n size: number;\n mimeType?: string;\n checksum?: string;\n isEnabled?: boolean;\n};\n\nexport type GitHubRepositoryAccessBenefitType = BenefitBaseType & {\n type: typeof EBenefitType.GITHUB_REPOSITORY_ACCESS;\n repositoryOwner: string;\n repositoryName: string;\n permission?: GitHubPermissionType;\n};\n\nexport type DiscordAccessBenefitType = BenefitBaseType & {\n type: typeof EBenefitType.DISCORD_ACCESS;\n guildId: string;\n roleId: string;\n};\n\nexport type CustomBenefitType = BenefitBaseType & {\n type: typeof EBenefitType.CUSTOM;\n note?: string;\n};\n\nexport type BenefitType =\n | CreditsBenefitType\n | LicenseKeysBenefitType\n | FileDownloadsBenefitType\n | GitHubRepositoryAccessBenefitType\n | DiscordAccessBenefitType\n | CustomBenefitType;\n\nexport interface IProduct extends IBase {\n key?: string;\n name: string;\n description?: string;\n categories?: ICategory[];\n currency?: CurrencyCodeType;\n price?: number;\n barcode?: string;\n images?: IImage[];\n attributes?: Record<string, ScalarType>;\n tags?: ITag[];\n isRecurring?: boolean;\n isArchived?: boolean;\n organizationId?: string;\n recurringInterval?: SubscriptionPeriodType;\n metadata?: Record<string, string | number | boolean>;\n prices?: PriceType[];\n benefits?: BenefitType[];\n attachedCustomFields?: CustomFieldType[];\n}\n\nexport interface IFeature extends IBase {\n name: string;\n description?: string;\n isEnabled?: boolean;\n limit?: number;\n}\n\nexport interface IPlan extends IBase {\n name: string;\n description?: string;\n currency: CurrencyCodeType;\n price: number;\n period: ESubscriptionPeriod;\n periodCount?: number;\n features?: IFeature[];\n isActive?: boolean;\n trialDays?: number;\n}\n\nexport interface ICredit extends IBase {\n balance: number;\n currency?: CurrencyCodeType;\n expiresAt?: Date;\n description?: string;\n}\n\nexport interface ISubscription extends IBase {\n discounts?: IDiscount[];\n plans?: IPlan[];\n credits?: ICredit[];\n startAt: Date;\n endAt?: Date;\n isTrial?: boolean;\n isActive?: boolean;\n}\n\nexport interface IDiscount extends IBase {\n key?: string;\n name: string;\n description?: string;\n code?: string;\n type: DiscountType;\n amount: number;\n currency?: CurrencyCodeType;\n duration: DiscountDurationType;\n durationInMonths?: number;\n startAt?: Date;\n endAt?: Date;\n maxUses?: number;\n usedCount?: number;\n maxRedemptions?: number;\n redemptionsCount?: number;\n isActive?: boolean;\n minimumAmount?: number;\n applicableProducts?: IProduct[];\n applicablePlans?: IPlan[];\n organizationId?: string;\n metadata?: Record<string, string | number | boolean>;\n}\n\nexport enum ECheckoutStatus {\n OPEN = \"open\",\n EXPIRED = \"expired\",\n CONFIRMED = \"confirmed\",\n SUCCEEDED = \"succeeded\",\n FAILED = \"failed\",\n}\n\nexport type CheckoutStatusType = `${ECheckoutStatus}`;\n\nexport type CheckoutCustomerType = {\n id?: string;\n email?: string;\n name?: string;\n externalId?: string;\n billingAddress?: CheckoutAddressType;\n taxId?: string;\n};\n\nexport type CheckoutAddressType = {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n};\n\nexport type CheckoutCreateType = {\n products: string[];\n customerExternalId?: string;\n customerId?: string;\n customerEmail?: string;\n customerName?: string;\n customerBillingAddress?: CheckoutAddressType;\n customerTaxId?: string;\n discountId?: string;\n allowDiscountCodes?: boolean;\n successUrl?: string;\n embedOrigin?: string;\n metadata?: Record<string, string | number | boolean>;\n};\n\nexport type CheckoutType = {\n id: string;\n url?: string;\n embedId?: string;\n status: CheckoutStatusType;\n clientSecret: string;\n createdAt?: Date;\n updatedAt?: Date;\n expiresAt?: Date;\n successUrl?: string;\n embedOrigin?: string;\n amount?: number;\n taxAmount?: number;\n currency?: CurrencyCodeType;\n subtotalAmount?: number;\n totalAmount?: number;\n productId?: string;\n productPriceId?: string;\n discountId?: string;\n allowDiscountCodes?: boolean;\n isDiscountApplicable?: boolean;\n isPaymentRequired?: boolean;\n customer?: CheckoutCustomerType;\n metadata?: Record<string, string | number | boolean>;\n};\n\nexport type CustomerSessionCreateType = {\n customerId: string;\n};\n\nexport type CustomerSessionType = {\n id: string;\n token: string;\n customerPortalUrl: string;\n createdAt?: Date;\n expiresAt?: Date;\n customerId?: string;\n};\n\nexport type CustomerAddressType = {\n line1?: string;\n line2?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n country?: string;\n};\n\nexport type CustomerCreateType = {\n email: string;\n name?: string;\n externalId?: string;\n billingAddress?: CustomerAddressType;\n taxId?: string;\n organizationId?: string;\n metadata?: Record<string, string | number | boolean>;\n};\n\nexport type CustomerUpdateType = {\n email?: string;\n name?: string;\n billingAddress?: CustomerAddressType;\n taxId?: string;\n metadata?: Record<string, string | number | boolean>;\n};\n\nexport type CustomerType = {\n id: string;\n email: string;\n emailVerified: boolean;\n name?: string;\n externalId?: string;\n avatarUrl?: string;\n billingAddress?: CustomerAddressType;\n taxId?: string;\n organizationId?: string;\n metadata?: Record<string, string | number | boolean>;\n createdAt?: Date;\n updatedAt?: Date;\n deletedAt?: Date;\n};\n\nexport type CustomerListOptionsType = {\n organizationId?: string;\n email?: string;\n query?: string;\n page?: number;\n limit?: number;\n};\n\nexport type CustomerListResultType = {\n items: CustomerType[];\n pagination: {\n totalCount: number;\n maxPage: number;\n };\n};\n\nexport enum EAnalyticsInterval {\n YEAR = \"year\",\n MONTH = \"month\",\n WEEK = \"week\",\n DAY = \"day\",\n HOUR = \"hour\",\n}\n\nexport type AnalyticsIntervalType = `${EAnalyticsInterval}`;\n\nexport enum EBillingType {\n ONE_TIME = \"one_time\",\n RECURRING = \"recurring\",\n}\n\nexport type BillingTypeType = `${EBillingType}`;\n\nexport type AnalyticsOptionsType = {\n startDate: Date;\n endDate: Date;\n interval: AnalyticsIntervalType;\n organizationId?: string | string[];\n productId?: string | string[];\n billingType?: BillingTypeType | BillingTypeType[];\n customerId?: string | string[];\n};\n\nexport type AnalyticsPeriodType = {\n timestamp: Date;\n orders: number;\n revenue: number;\n cumulativeRevenue: number;\n averageOrderValue: number;\n oneTimeProducts: number;\n oneTimeProductsRevenue: number;\n newSubscriptions: number;\n newSubscriptionsRevenue: number;\n renewedSubscriptions: number;\n renewedSubscriptionsRevenue: number;\n activeSubscriptions: number;\n monthlyRecurringRevenue: number;\n};\n\nexport type AnalyticsMetricInfoType = {\n slug: string;\n displayName: string;\n type: string;\n};\n\nexport type AnalyticsMetricsType = {\n orders: AnalyticsMetricInfoType;\n revenue: AnalyticsMetricInfoType;\n cumulativeRevenue: AnalyticsMetricInfoType;\n averageOrderValue: AnalyticsMetricInfoType;\n oneTimeProducts: AnalyticsMetricInfoType;\n oneTimeProductsRevenue: AnalyticsMetricInfoType;\n newSubscriptions: AnalyticsMetricInfoType;\n newSubscriptionsRevenue: AnalyticsMetricInfoType;\n renewedSubscriptions: AnalyticsMetricInfoType;\n renewedSubscriptionsRevenue: AnalyticsMetricInfoType;\n activeSubscriptions: AnalyticsMetricInfoType;\n monthlyRecurringRevenue: AnalyticsMetricInfoType;\n};\n\nexport type AnalyticsResponseType = {\n periods: AnalyticsPeriodType[];\n metrics: AnalyticsMetricsType;\n};\n\nexport type AnalyticsIntervalLimitType = {\n maxDays: number;\n};\n\nexport type AnalyticsIntervalsLimitsType = {\n hour: AnalyticsIntervalLimitType;\n day: AnalyticsIntervalLimitType;\n week: AnalyticsIntervalLimitType;\n month: AnalyticsIntervalLimitType;\n year: AnalyticsIntervalLimitType;\n};\n\nexport type AnalyticsLimitsType = {\n minDate: Date;\n intervals: AnalyticsIntervalsLimitsType;\n};\n"
|
|
6
13
|
],
|
|
7
|
-
"mappings": "AAMO,IAAK,GAAL,CAAK,IAAL,CACL,aAAa,aACb,QAAQ,UAFE,QAKL,IAAK,GAAL,CAAK,IAAL,CACL,UAAU,UACV,SAAS,SACT,SAAS,SACT,QAAQ,UAJE",
|
|
8
|
-
"debugId": "
|
|
14
|
+
"mappings": "ybAAA,oBAAS,0BACT,qBAAS,4BAEF,MAAM,UAAyB,CAAU,CAC9C,WAAW,CAAC,EAAiB,EAAgC,CAAC,EAAG,CAC/D,MAAM,EAAS,CACb,OAAQ,EAAW,KAAK,oBACxB,MACF,CAAC,EAED,KAAK,KAAO,mBAEhB,CCZA,qBAAS,0BACT,gBAAS,sBAeF,MAAM,CAAe,CAClB,OAER,WAAW,EAAG,CACZ,IAAM,EAAc,IAAI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K,IAAL,CACL,OAAO,OACP,SAAS,SACT,QAAQ,QACR,WAAW,WACX,QAAQ,UALE,QA4JL,IAAK,GAAL,CAAK,IAAL,CACL,OAAO,OACP,UAAU,UACV,YAAY,YACZ,YAAY,YACZ,SAAS,WALC,QA6IL,IAAK,GAAL,CAAK,IAAL,CACL,OAAO,OACP,QAAQ,QACR,OAAO,OACP,MAAM,MACN,OAAO,SALG,QAUL,IAAK,GAAL,CAAK,IAAL,CACL,WAAW,WACX,YAAY,cAFF",
|
|
15
|
+
"debugId": "55A36E2883BAC92E64756E2164756E21",
|
|
9
16
|
"names": []
|
|
10
17
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ooneex/payment",
|
|
3
3
|
"description": "Payment and pricing types with currency support, product categorization, and image handling for e-commerce",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -26,13 +26,17 @@
|
|
|
26
26
|
"lint": "tsgo --noEmit && bunx biome lint",
|
|
27
27
|
"npm:publish": "bun publish --tolerate-republish --access public"
|
|
28
28
|
},
|
|
29
|
-
"dependencies": {
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@ooneex/exception": "0.0.17",
|
|
31
|
+
"@ooneex/http-status": "0.0.17",
|
|
32
|
+
"@polar-sh/sdk": "^0.30.0"
|
|
33
|
+
},
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@ooneex/category": "0.0.
|
|
32
|
-
"@ooneex/currencies": "0.0.
|
|
33
|
-
"@ooneex/image": "0.0.
|
|
34
|
-
"@ooneex/tag": "0.0.
|
|
35
|
-
"@ooneex/types": "0.0.
|
|
35
|
+
"@ooneex/category": "0.0.17",
|
|
36
|
+
"@ooneex/currencies": "0.0.17",
|
|
37
|
+
"@ooneex/image": "0.0.17",
|
|
38
|
+
"@ooneex/tag": "0.0.17",
|
|
39
|
+
"@ooneex/types": "0.0.17"
|
|
36
40
|
},
|
|
37
41
|
"keywords": [
|
|
38
42
|
"billing",
|