@forklaunch/implementation-billing-base 0.5.8 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,704 +1,121 @@
1
- import { InstanceTypeRecord, IdDto, IdsDto } from '@forklaunch/common';
1
+ import { IdDto, IdsDto } from '@forklaunch/common';
2
2
  import { TtlCache } from '@forklaunch/core/cache';
3
- import {
4
- TelemetryOptions,
5
- OpenTelemetryCollector,
6
- MetricsDefinition
7
- } from '@forklaunch/core/http';
8
- import {
9
- BillingPortalService,
10
- CheckoutSessionService,
11
- PaymentLinkService,
12
- PlanService,
13
- SubscriptionService
14
- } from '@forklaunch/interfaces-billing/interfaces';
15
- import {
16
- BillingPortalDto,
17
- CreateBillingPortalDto,
18
- UpdateBillingPortalDto,
19
- CheckoutSessionDto,
20
- CreateCheckoutSessionDto,
21
- UpdateCheckoutSessionDto,
22
- PaymentLinkDto,
23
- CreatePaymentLinkDto,
24
- UpdatePaymentLinkDto,
25
- PlanDto,
26
- CreatePlanDto,
27
- UpdatePlanDto,
28
- SubscriptionDto,
29
- CreateSubscriptionDto,
30
- UpdateSubscriptionDto
31
- } from '@forklaunch/interfaces-billing/types';
32
- import {
33
- InternalMapper,
34
- ResponseMapperConstructor,
35
- RequestMapperConstructor
36
- } from '@forklaunch/internal';
3
+ import { OpenTelemetryCollector, MetricsDefinition, TelemetryOptions } from '@forklaunch/core/http';
4
+ import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService } from '@forklaunch/interfaces-billing/interfaces';
5
+ import { CreateBillingPortalDto, UpdateBillingPortalDto, CreateCheckoutSessionDto, CreatePaymentLinkDto, UpdatePaymentLinkDto, CreatePlanDto, UpdatePlanDto, CreateSubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
37
6
  import { AnySchemaValidator } from '@forklaunch/validator';
38
7
  import { EntityManager } from '@mikro-orm/core';
8
+ import { BaseBillingEntities, BaseBillingDtos, BillingPortalMappers, BaseCheckoutSessionEntities, BaseCheckoutSessionDtos, CheckoutSessionMappers, BasePaymentLinkEntities, BasePaymentLinkDtos, PaymentLinkMappers, BasePlanEntities, BasePlanDtos, PlanMappers, BaseSubscriptionEntities, BaseSubscriptionDtos, SubscriptionMappers } from '../domain/types/index.mjs';
39
9
 
40
- type BaseBillingDtos = {
41
- BillingPortalMapper: BillingPortalDto;
42
- CreateBillingPortalMapper: CreateBillingPortalDto;
43
- UpdateBillingPortalMapper: UpdateBillingPortalDto;
44
- };
45
- type BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
46
- CheckoutSessionMapper: CheckoutSessionDto<
47
- PaymentMethodEnum,
48
- CurrencyEnum,
49
- StatusEnum
50
- >;
51
- CreateCheckoutSessionMapper: CreateCheckoutSessionDto<
52
- PaymentMethodEnum,
53
- CurrencyEnum,
54
- StatusEnum
55
- >;
56
- UpdateCheckoutSessionMapper: UpdateCheckoutSessionDto<
57
- PaymentMethodEnum,
58
- CurrencyEnum,
59
- StatusEnum
60
- >;
61
- };
62
- type BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
63
- PaymentLinkMapper: PaymentLinkDto<
64
- PaymentMethodEnum,
65
- CurrencyEnum,
66
- StatusEnum
67
- >;
68
- CreatePaymentLinkMapper: CreatePaymentLinkDto<
69
- PaymentMethodEnum,
70
- CurrencyEnum,
71
- StatusEnum
72
- >;
73
- UpdatePaymentLinkMapper: UpdatePaymentLinkDto<
74
- PaymentMethodEnum,
75
- CurrencyEnum,
76
- StatusEnum
77
- >;
78
- };
79
- type BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = {
80
- PlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
81
- CreatePlanMapper: CreatePlanDto<
82
- PlanCadenceEnum,
83
- CurrencyEnum,
84
- BillingProviderEnum
85
- >;
86
- UpdatePlanMapper: UpdatePlanDto<
87
- PlanCadenceEnum,
88
- CurrencyEnum,
89
- BillingProviderEnum
90
- >;
91
- };
92
- type BaseSubscriptionDtos<PartyType, BillingProviderType> = {
93
- SubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
94
- CreateSubscriptionMapper: CreateSubscriptionDto<
95
- PartyType,
96
- BillingProviderType
97
- >;
98
- UpdateSubscriptionMapper: UpdateSubscriptionDto<
99
- PartyType,
100
- BillingProviderType
101
- >;
102
- };
103
-
104
- type BaseBillingEntities = {
105
- BillingPortalMapper: BillingPortalDto;
106
- CreateBillingPortalMapper: BillingPortalDto;
107
- UpdateBillingPortalMapper: BillingPortalDto;
108
- };
109
- type BaseCheckoutSessionEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum> =
110
- {
111
- CheckoutSessionMapper: CheckoutSessionDto<
112
- PaymentMethodEnum,
113
- CurrencyEnum,
114
- StatusEnum
115
- >;
116
- CreateCheckoutSessionMapper: CheckoutSessionDto<
117
- PaymentMethodEnum,
118
- CurrencyEnum,
119
- StatusEnum
120
- >;
121
- UpdateCheckoutSessionMapper: CheckoutSessionDto<
122
- PaymentMethodEnum,
123
- CurrencyEnum,
124
- StatusEnum
125
- >;
126
- };
127
- type BasePaymentLinkEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
128
- PaymentLinkMapper: PaymentLinkDto<
129
- PaymentMethodEnum,
130
- CurrencyEnum,
131
- StatusEnum
132
- >;
133
- CreatePaymentLinkMapper: PaymentLinkDto<
134
- PaymentMethodEnum,
135
- CurrencyEnum,
136
- StatusEnum
137
- >;
138
- UpdatePaymentLinkMapper: PaymentLinkDto<
139
- PaymentMethodEnum,
140
- CurrencyEnum,
141
- StatusEnum
142
- >;
143
- };
144
- type BasePlanEntities<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = {
145
- PlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
146
- CreatePlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
147
- UpdatePlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
148
- };
149
- type BaseSubscriptionEntities<PartyType, BillingProviderType> = {
150
- SubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
151
- CreateSubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
152
- UpdateSubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
153
- };
154
-
155
- declare class BaseBillingPortalService<
156
- SchemaValidator extends AnySchemaValidator,
157
- Entities extends BaseBillingEntities,
158
- Dto extends BaseBillingDtos = BaseBillingDtos
159
- > implements BillingPortalService
160
- {
161
- readonly options?:
162
- | {
10
+ declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidator, MapperEntities extends BaseBillingEntities, MapperDomains extends BaseBillingDtos = BaseBillingDtos> implements BillingPortalService {
11
+ private evaluatedTelemetryOptions;
12
+ protected enableDatabaseBackup: boolean;
13
+ em: EntityManager;
14
+ protected cache: TtlCache;
15
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
16
+ protected schemaValidator: SchemaValidator;
17
+ protected mappers: BillingPortalMappers<MapperEntities, MapperDomains>;
18
+ constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: BillingPortalMappers<MapperEntities, MapperDomains>, options?: {
163
19
  telemetry?: TelemetryOptions;
164
20
  enableDatabaseBackup?: boolean;
165
- }
166
- | undefined;
167
- protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
168
- protected evaluatedTelemetryOptions: {
169
- logging?: boolean;
170
- metrics?: boolean;
171
- tracing?: boolean;
172
- };
173
- protected enableDatabaseBackup: boolean;
174
- protected em: EntityManager;
175
- protected cache: TtlCache;
176
- protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
177
- protected schemaValidator: SchemaValidator;
178
- protected mappers: {
179
- BillingPortalMapper: ResponseMapperConstructor<
180
- SchemaValidator,
181
- Dto['BillingPortalMapper'],
182
- Entities['BillingPortalMapper']
183
- >;
184
- CreateBillingPortalMapper: RequestMapperConstructor<
185
- SchemaValidator,
186
- Dto['CreateBillingPortalMapper'],
187
- Entities['CreateBillingPortalMapper'],
188
- (
189
- dto: Dto['CreateBillingPortalMapper'],
190
- em: EntityManager
191
- ) => Promise<Entities['CreateBillingPortalMapper']>
192
- >;
193
- UpdateBillingPortalMapper: RequestMapperConstructor<
194
- SchemaValidator,
195
- Dto['UpdateBillingPortalMapper'],
196
- Entities['UpdateBillingPortalMapper'],
197
- (
198
- dto: Dto['UpdateBillingPortalMapper'],
199
- em: EntityManager
200
- ) => Promise<Entities['UpdateBillingPortalMapper']>
201
- >;
202
- };
203
- constructor(
204
- em: EntityManager,
205
- cache: TtlCache,
206
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
207
- schemaValidator: SchemaValidator,
208
- mappers: {
209
- BillingPortalMapper: ResponseMapperConstructor<
210
- SchemaValidator,
211
- Dto['BillingPortalMapper'],
212
- Entities['BillingPortalMapper']
213
- >;
214
- CreateBillingPortalMapper: RequestMapperConstructor<
215
- SchemaValidator,
216
- Dto['CreateBillingPortalMapper'],
217
- Entities['CreateBillingPortalMapper'],
218
- (
219
- dto: Dto['CreateBillingPortalMapper'],
220
- em: EntityManager
221
- ) => Promise<Entities['CreateBillingPortalMapper']>
222
- >;
223
- UpdateBillingPortalMapper: RequestMapperConstructor<
224
- SchemaValidator,
225
- Dto['UpdateBillingPortalMapper'],
226
- Entities['UpdateBillingPortalMapper'],
227
- (
228
- dto: Dto['UpdateBillingPortalMapper'],
229
- em: EntityManager
230
- ) => Promise<Entities['UpdateBillingPortalMapper']>
231
- >;
232
- },
233
- options?:
234
- | {
235
- telemetry?: TelemetryOptions;
236
- enableDatabaseBackup?: boolean;
237
- }
238
- | undefined
239
- );
240
- protected createCacheKey: (id: string) => string;
241
- createBillingPortalSession(
242
- billingPortalDto: Dto['CreateBillingPortalMapper']
243
- ): Promise<Dto['BillingPortalMapper']>;
244
- getBillingPortalSession(idDto: IdDto): Promise<Dto['BillingPortalMapper']>;
245
- updateBillingPortalSession(
246
- billingPortalDto: UpdateBillingPortalDto
247
- ): Promise<Dto['BillingPortalMapper']>;
248
- expireBillingPortalSession(idDto: IdDto): Promise<void>;
21
+ });
22
+ protected createCacheKey: (id: string) => string;
23
+ createBillingPortalSession(billingPortalDto: CreateBillingPortalDto, ...args: unknown[]): Promise<MapperDomains['BillingPortalMapper']>;
24
+ getBillingPortalSession(idDto: IdDto): Promise<MapperDomains['BillingPortalMapper']>;
25
+ updateBillingPortalSession(billingPortalDto: UpdateBillingPortalDto, ...args: unknown[]): Promise<MapperDomains['BillingPortalMapper']>;
26
+ expireBillingPortalSession(idDto: IdDto): Promise<void>;
249
27
  }
250
28
 
251
- declare class BaseCheckoutSessionService<
252
- SchemaValidator extends AnySchemaValidator,
253
- PaymentMethodEnum,
254
- CurrencyEnum,
255
- StatusEnum,
256
- Entities extends BaseCheckoutSessionEntities<
257
- PaymentMethodEnum,
258
- CurrencyEnum,
259
- StatusEnum
260
- >,
261
- Dto extends BaseCheckoutSessionDtos<
262
- PaymentMethodEnum,
263
- CurrencyEnum,
264
- StatusEnum
265
- > = BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>
266
- > implements CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum>
267
- {
268
- readonly options?:
269
- | {
270
- enableDatabaseBackup?: boolean;
29
+ declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities extends BaseCheckoutSessionEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, MapperDomains extends BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
30
+ private evaluatedTelemetryOptions;
31
+ protected enableDatabaseBackup: boolean;
32
+ em: EntityManager;
33
+ protected cache: TtlCache;
34
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
35
+ protected schemaValidator: SchemaValidator;
36
+ protected mappers: CheckoutSessionMappers<PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities, MapperDomains>;
37
+ constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: CheckoutSessionMappers<PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities, MapperDomains>, options?: {
271
38
  telemetry?: TelemetryOptions;
272
- }
273
- | undefined;
274
- protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
275
- protected evaluatedTelemetryOptions: {
276
- logging?: boolean;
277
- metrics?: boolean;
278
- tracing?: boolean;
279
- };
280
- protected enableDatabaseBackup: boolean;
281
- protected readonly em: EntityManager;
282
- protected readonly cache: TtlCache;
283
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
284
- protected readonly schemaValidator: SchemaValidator;
285
- protected readonly mappers: {
286
- CheckoutSessionMapper: ResponseMapperConstructor<
287
- SchemaValidator,
288
- Dto['CheckoutSessionMapper'],
289
- Entities['CheckoutSessionMapper']
290
- >;
291
- CreateCheckoutSessionMapper: RequestMapperConstructor<
292
- SchemaValidator,
293
- Dto['CreateCheckoutSessionMapper'],
294
- Entities['CreateCheckoutSessionMapper'],
295
- (
296
- dto: Dto['CreateCheckoutSessionMapper'],
297
- em: EntityManager
298
- ) => Promise<Entities['CreateCheckoutSessionMapper']>
299
- >;
300
- UpdateCheckoutSessionMapper: RequestMapperConstructor<
301
- SchemaValidator,
302
- Dto['UpdateCheckoutSessionMapper'],
303
- Entities['UpdateCheckoutSessionMapper'],
304
- (
305
- dto: Dto['UpdateCheckoutSessionMapper'],
306
- em: EntityManager
307
- ) => Promise<Entities['UpdateCheckoutSessionMapper']>
308
- >;
309
- };
310
- constructor(
311
- em: EntityManager,
312
- cache: TtlCache,
313
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
314
- schemaValidator: SchemaValidator,
315
- mappers: {
316
- CheckoutSessionMapper: ResponseMapperConstructor<
317
- SchemaValidator,
318
- Dto['CheckoutSessionMapper'],
319
- Entities['CheckoutSessionMapper']
320
- >;
321
- CreateCheckoutSessionMapper: RequestMapperConstructor<
322
- SchemaValidator,
323
- Dto['CreateCheckoutSessionMapper'],
324
- Entities['CreateCheckoutSessionMapper'],
325
- (
326
- dto: Dto['CreateCheckoutSessionMapper'],
327
- em: EntityManager
328
- ) => Promise<Entities['CreateCheckoutSessionMapper']>
329
- >;
330
- UpdateCheckoutSessionMapper: RequestMapperConstructor<
331
- SchemaValidator,
332
- Dto['UpdateCheckoutSessionMapper'],
333
- Entities['UpdateCheckoutSessionMapper'],
334
- (
335
- dto: Dto['UpdateCheckoutSessionMapper'],
336
- em: EntityManager
337
- ) => Promise<Entities['UpdateCheckoutSessionMapper']>
338
- >;
339
- },
340
- options?:
341
- | {
342
- enableDatabaseBackup?: boolean;
343
- telemetry?: TelemetryOptions;
344
- }
345
- | undefined
346
- );
347
- protected createCacheKey: (id: string) => string;
348
- createCheckoutSession(
349
- checkoutSessionDto: Dto['CreateCheckoutSessionMapper']
350
- ): Promise<Dto['CheckoutSessionMapper']>;
351
- getCheckoutSession({ id }: IdDto): Promise<Dto['CheckoutSessionMapper']>;
352
- expireCheckoutSession({ id }: IdDto): Promise<void>;
353
- handleCheckoutSuccess({ id }: IdDto): Promise<void>;
354
- handleCheckoutFailure({ id }: IdDto): Promise<void>;
39
+ enableDatabaseBackup?: boolean;
40
+ });
41
+ protected createCacheKey: (id: string) => string;
42
+ createCheckoutSession(checkoutSessionDto: CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>, ...args: unknown[]): Promise<MapperDomains['CheckoutSessionMapper']>;
43
+ getCheckoutSession({ id }: IdDto): Promise<MapperDomains['CheckoutSessionMapper']>;
44
+ expireCheckoutSession({ id }: IdDto): Promise<void>;
45
+ handleCheckoutSuccess({ id }: IdDto): Promise<void>;
46
+ handleCheckoutFailure({ id }: IdDto): Promise<void>;
355
47
  }
356
48
 
357
- declare class BasePaymentLinkService<
358
- SchemaValidator extends AnySchemaValidator,
359
- PaymentMethodEnum,
360
- CurrencyEnum,
361
- StatusEnum,
362
- Entities extends BasePaymentLinkEntities<
363
- PaymentMethodEnum,
364
- CurrencyEnum,
365
- StatusEnum
366
- >,
367
- Dto extends BasePaymentLinkDtos<
368
- PaymentMethodEnum,
369
- CurrencyEnum,
370
- StatusEnum
371
- > = BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>
372
- > implements PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum>
373
- {
374
- readonly options?:
375
- | {
376
- enableDatabaseBackup?: boolean;
49
+ declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities extends BasePaymentLinkEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, MapperDomains extends BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
50
+ private evaluatedTelemetryOptions;
51
+ protected enableDatabaseBackup: boolean;
52
+ em: EntityManager;
53
+ protected cache: TtlCache;
54
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
55
+ protected schemaValidator: SchemaValidator;
56
+ protected mappers: PaymentLinkMappers<PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities, MapperDomains>;
57
+ constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: PaymentLinkMappers<PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities, MapperDomains>, options?: {
377
58
  telemetry?: TelemetryOptions;
378
- }
379
- | undefined;
380
- protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
381
- protected evaluatedTelemetryOptions: {
382
- logging?: boolean;
383
- metrics?: boolean;
384
- tracing?: boolean;
385
- };
386
- protected enableDatabaseBackup: boolean;
387
- protected readonly em: EntityManager;
388
- protected readonly cache: TtlCache;
389
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
390
- protected readonly schemaValidator: SchemaValidator;
391
- protected readonly mappers: {
392
- PaymentLinkMapper: ResponseMapperConstructor<
393
- SchemaValidator,
394
- Dto['PaymentLinkMapper'],
395
- Entities['PaymentLinkMapper']
396
- >;
397
- CreatePaymentLinkMapper: RequestMapperConstructor<
398
- SchemaValidator,
399
- Dto['CreatePaymentLinkMapper'],
400
- Entities['CreatePaymentLinkMapper'],
401
- (
402
- dto: Dto['CreatePaymentLinkMapper'],
403
- em: EntityManager
404
- ) => Promise<Entities['CreatePaymentLinkMapper']>
405
- >;
406
- UpdatePaymentLinkMapper: RequestMapperConstructor<
407
- SchemaValidator,
408
- Dto['UpdatePaymentLinkMapper'],
409
- Entities['UpdatePaymentLinkMapper'],
410
- (
411
- dto: Dto['UpdatePaymentLinkMapper'],
412
- em: EntityManager
413
- ) => Promise<Entities['UpdatePaymentLinkMapper']>
414
- >;
415
- };
416
- constructor(
417
- em: EntityManager,
418
- cache: TtlCache,
419
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
420
- schemaValidator: SchemaValidator,
421
- mappers: {
422
- PaymentLinkMapper: ResponseMapperConstructor<
423
- SchemaValidator,
424
- Dto['PaymentLinkMapper'],
425
- Entities['PaymentLinkMapper']
426
- >;
427
- CreatePaymentLinkMapper: RequestMapperConstructor<
428
- SchemaValidator,
429
- Dto['CreatePaymentLinkMapper'],
430
- Entities['CreatePaymentLinkMapper'],
431
- (
432
- dto: Dto['CreatePaymentLinkMapper'],
433
- em: EntityManager
434
- ) => Promise<Entities['CreatePaymentLinkMapper']>
435
- >;
436
- UpdatePaymentLinkMapper: RequestMapperConstructor<
437
- SchemaValidator,
438
- Dto['UpdatePaymentLinkMapper'],
439
- Entities['UpdatePaymentLinkMapper'],
440
- (
441
- dto: Dto['UpdatePaymentLinkMapper'],
442
- em: EntityManager
443
- ) => Promise<Entities['UpdatePaymentLinkMapper']>
444
- >;
445
- },
446
- options?:
447
- | {
448
- enableDatabaseBackup?: boolean;
449
- telemetry?: TelemetryOptions;
450
- }
451
- | undefined
452
- );
453
- protected cacheKeyPrefix: string;
454
- protected createCacheKey: (id: string) => string;
455
- createPaymentLink(
456
- paymentLinkDto: Dto['CreatePaymentLinkMapper']
457
- ): Promise<Dto['PaymentLinkMapper']>;
458
- updatePaymentLink(
459
- paymentLinkDto: Dto['UpdatePaymentLinkMapper']
460
- ): Promise<Dto['PaymentLinkMapper']>;
461
- getPaymentLink({ id }: IdDto): Promise<Dto['PaymentLinkMapper']>;
462
- expirePaymentLink({ id }: IdDto): Promise<void>;
463
- handlePaymentSuccess({ id }: IdDto): Promise<void>;
464
- handlePaymentFailure({ id }: IdDto): Promise<void>;
465
- listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkMapper'][]>;
59
+ enableDatabaseBackup?: boolean;
60
+ });
61
+ protected cacheKeyPrefix: string;
62
+ protected createCacheKey: (id: string) => string;
63
+ createPaymentLink(paymentLinkDto: CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>, ...args: unknown[]): Promise<MapperDomains['PaymentLinkMapper']>;
64
+ updatePaymentLink(paymentLinkDto: UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>, ...args: unknown[]): Promise<MapperDomains['PaymentLinkMapper']>;
65
+ getPaymentLink({ id }: IdDto): Promise<MapperDomains['PaymentLinkMapper']>;
66
+ expirePaymentLink({ id }: IdDto): Promise<void>;
67
+ handlePaymentSuccess({ id }: IdDto): Promise<void>;
68
+ handlePaymentFailure({ id }: IdDto): Promise<void>;
69
+ listPaymentLinks(idsDto?: IdsDto): Promise<MapperDomains['PaymentLinkMapper'][]>;
466
70
  }
467
71
 
468
- declare class BasePlanService<
469
- SchemaValidator extends AnySchemaValidator,
470
- PlanCadenceEnum,
471
- CurrencyEnum,
472
- BillingProviderEnum,
473
- Entities extends BasePlanEntities<
474
- PlanCadenceEnum,
475
- CurrencyEnum,
476
- BillingProviderEnum
477
- >,
478
- Dto extends BasePlanDtos<
479
- PlanCadenceEnum,
480
- CurrencyEnum,
481
- BillingProviderEnum
482
- > = BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>
483
- > implements PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>
484
- {
485
- readonly options?:
486
- | {
72
+ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, MapperEntities extends BasePlanEntities<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>, MapperDomains extends BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> implements PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> {
73
+ private evaluatedTelemetryOptions;
74
+ em: EntityManager;
75
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
76
+ protected schemaValidator: SchemaValidator;
77
+ protected mappers: PlanMappers<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, MapperEntities, MapperDomains>;
78
+ constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: PlanMappers<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, MapperEntities, MapperDomains>, options?: {
487
79
  telemetry?: TelemetryOptions;
488
- }
489
- | undefined;
490
- protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
491
- protected evaluatedTelemetryOptions: {
492
- logging?: boolean;
493
- metrics?: boolean;
494
- tracing?: boolean;
495
- };
496
- protected em: EntityManager;
497
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
498
- protected readonly schemaValidator: SchemaValidator;
499
- protected readonly mappers: {
500
- PlanMapper: ResponseMapperConstructor<
501
- SchemaValidator,
502
- Dto['PlanMapper'],
503
- Entities['PlanMapper']
504
- >;
505
- CreatePlanMapper: RequestMapperConstructor<
506
- SchemaValidator,
507
- Dto['CreatePlanMapper'],
508
- Entities['CreatePlanMapper'],
509
- (
510
- dto: Dto['CreatePlanMapper'],
511
- em: EntityManager
512
- ) => Promise<Entities['CreatePlanMapper']>
513
- >;
514
- UpdatePlanMapper: RequestMapperConstructor<
515
- SchemaValidator,
516
- Dto['UpdatePlanMapper'],
517
- Entities['UpdatePlanMapper'],
518
- (
519
- dto: Dto['UpdatePlanMapper'],
520
- em: EntityManager
521
- ) => Promise<Entities['UpdatePlanMapper']>
522
- >;
523
- };
524
- constructor(
525
- em: EntityManager,
526
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
527
- schemaValidator: SchemaValidator,
528
- mappers: {
529
- PlanMapper: ResponseMapperConstructor<
530
- SchemaValidator,
531
- Dto['PlanMapper'],
532
- Entities['PlanMapper']
533
- >;
534
- CreatePlanMapper: RequestMapperConstructor<
535
- SchemaValidator,
536
- Dto['CreatePlanMapper'],
537
- Entities['CreatePlanMapper'],
538
- (
539
- dto: Dto['CreatePlanMapper'],
540
- em: EntityManager
541
- ) => Promise<Entities['CreatePlanMapper']>
542
- >;
543
- UpdatePlanMapper: RequestMapperConstructor<
544
- SchemaValidator,
545
- Dto['UpdatePlanMapper'],
546
- Entities['UpdatePlanMapper'],
547
- (
548
- dto: Dto['UpdatePlanMapper'],
549
- em: EntityManager
550
- ) => Promise<Entities['UpdatePlanMapper']>
551
- >;
552
- },
553
- options?:
554
- | {
555
- telemetry?: TelemetryOptions;
556
- }
557
- | undefined
558
- );
559
- listPlans(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['PlanMapper'][]>;
560
- createPlan(
561
- planDto: Dto['CreatePlanMapper'],
562
- em?: EntityManager
563
- ): Promise<Dto['PlanMapper']>;
564
- getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
565
- updatePlan(
566
- planDto: Dto['UpdatePlanMapper'],
567
- em?: EntityManager
568
- ): Promise<Dto['PlanMapper']>;
569
- deletePlan(
570
- idDto: {
571
- id: string;
572
- },
573
- em?: EntityManager
574
- ): Promise<void>;
80
+ });
81
+ listPlans(idsDto?: IdsDto, em?: EntityManager): Promise<MapperDomains['PlanMapper'][]>;
82
+ createPlan(planDto: CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>, em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['PlanMapper']>;
83
+ getPlan(idDto: IdDto, em?: EntityManager): Promise<MapperDomains['PlanMapper']>;
84
+ updatePlan(planDto: UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>, em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['PlanMapper']>;
85
+ deletePlan(idDto: {
86
+ id: string;
87
+ }, em?: EntityManager): Promise<void>;
575
88
  }
576
89
 
577
- declare class BaseSubscriptionService<
578
- SchemaValidator extends AnySchemaValidator,
579
- PartyType,
580
- BillingProviderType,
581
- Entities extends BaseSubscriptionEntities<PartyType, BillingProviderType>,
582
- Dto extends BaseSubscriptionDtos<
583
- PartyType,
584
- BillingProviderType
585
- > = BaseSubscriptionDtos<PartyType, BillingProviderType>
586
- > implements SubscriptionService<PartyType, BillingProviderType>
587
- {
588
- readonly options?:
589
- | {
90
+ declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator, PartyType, BillingProviderType, Entities extends BaseSubscriptionEntities<PartyType, BillingProviderType>, Dto extends BaseSubscriptionDtos<PartyType, BillingProviderType> = BaseSubscriptionDtos<PartyType, BillingProviderType>> implements SubscriptionService<PartyType, BillingProviderType> {
91
+ readonly options?: {
92
+ telemetry?: TelemetryOptions;
93
+ } | undefined;
94
+ protected evaluatedTelemetryOptions: {
95
+ logging?: boolean;
96
+ metrics?: boolean;
97
+ tracing?: boolean;
98
+ };
99
+ protected em: EntityManager;
100
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
101
+ protected readonly schemaValidator: SchemaValidator;
102
+ protected readonly mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>;
103
+ constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>, options?: {
590
104
  telemetry?: TelemetryOptions;
591
- }
592
- | undefined;
593
- protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
594
- protected evaluatedTelemetryOptions: {
595
- logging?: boolean;
596
- metrics?: boolean;
597
- tracing?: boolean;
598
- };
599
- protected em: EntityManager;
600
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
601
- protected readonly schemaValidator: SchemaValidator;
602
- protected readonly mappers: {
603
- SubscriptionMapper: ResponseMapperConstructor<
604
- SchemaValidator,
605
- Dto['SubscriptionMapper'],
606
- Entities['SubscriptionMapper']
607
- >;
608
- CreateSubscriptionMapper: RequestMapperConstructor<
609
- SchemaValidator,
610
- Dto['CreateSubscriptionMapper'],
611
- Entities['CreateSubscriptionMapper'],
612
- (
613
- dto: Dto['CreateSubscriptionMapper'],
614
- em: EntityManager
615
- ) => Promise<Entities['CreateSubscriptionMapper']>
616
- >;
617
- UpdateSubscriptionMapper: RequestMapperConstructor<
618
- SchemaValidator,
619
- Dto['UpdateSubscriptionMapper'],
620
- Entities['UpdateSubscriptionMapper'],
621
- (
622
- dto: Dto['UpdateSubscriptionMapper'],
623
- em: EntityManager
624
- ) => Promise<Entities['UpdateSubscriptionMapper']>
625
- >;
626
- };
627
- constructor(
628
- em: EntityManager,
629
- openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
630
- schemaValidator: SchemaValidator,
631
- mappers: {
632
- SubscriptionMapper: ResponseMapperConstructor<
633
- SchemaValidator,
634
- Dto['SubscriptionMapper'],
635
- Entities['SubscriptionMapper']
636
- >;
637
- CreateSubscriptionMapper: RequestMapperConstructor<
638
- SchemaValidator,
639
- Dto['CreateSubscriptionMapper'],
640
- Entities['CreateSubscriptionMapper'],
641
- (
642
- dto: Dto['CreateSubscriptionMapper'],
643
- em: EntityManager
644
- ) => Promise<Entities['CreateSubscriptionMapper']>
645
- >;
646
- UpdateSubscriptionMapper: RequestMapperConstructor<
647
- SchemaValidator,
648
- Dto['UpdateSubscriptionMapper'],
649
- Entities['UpdateSubscriptionMapper'],
650
- (
651
- dto: Dto['UpdateSubscriptionMapper'],
652
- em: EntityManager
653
- ) => Promise<Entities['UpdateSubscriptionMapper']>
654
- >;
655
- },
656
- options?:
657
- | {
658
- telemetry?: TelemetryOptions;
659
- }
660
- | undefined
661
- );
662
- createSubscription(
663
- subscriptionDto: Dto['CreateSubscriptionMapper'],
664
- em?: EntityManager
665
- ): Promise<Dto['SubscriptionMapper']>;
666
- getSubscription(
667
- idDto: IdDto,
668
- em?: EntityManager
669
- ): Promise<Dto['SubscriptionMapper']>;
670
- getUserSubscription(
671
- { id }: IdDto,
672
- em?: EntityManager
673
- ): Promise<Dto['SubscriptionMapper']>;
674
- getOrganizationSubscription(
675
- { id }: IdDto,
676
- em?: EntityManager
677
- ): Promise<Dto['SubscriptionMapper']>;
678
- updateSubscription(
679
- subscriptionDto: Dto['UpdateSubscriptionMapper'],
680
- em?: EntityManager
681
- ): Promise<Dto['SubscriptionMapper']>;
682
- deleteSubscription(
683
- idDto: {
684
- id: string;
685
- },
686
- em?: EntityManager
687
- ): Promise<void>;
688
- listSubscriptions(
689
- idsDto: {
690
- ids?: string[];
691
- },
692
- em?: EntityManager
693
- ): Promise<Dto['SubscriptionMapper'][]>;
694
- cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
695
- resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
105
+ } | undefined);
106
+ createSubscription(subscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>, em?: EntityManager, ...args: unknown[]): Promise<Dto['SubscriptionMapper']>;
107
+ getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
108
+ getUserSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
109
+ getOrganizationSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
110
+ updateSubscription(subscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>, em?: EntityManager, ...args: unknown[]): Promise<Dto['SubscriptionMapper']>;
111
+ deleteSubscription(idDto: {
112
+ id: string;
113
+ }, em?: EntityManager): Promise<void>;
114
+ listSubscriptions(idsDto: {
115
+ ids?: string[];
116
+ }, em?: EntityManager): Promise<Dto['SubscriptionMapper'][]>;
117
+ cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
118
+ resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
696
119
  }
697
120
 
698
- export {
699
- BaseBillingPortalService,
700
- BaseCheckoutSessionService,
701
- BasePaymentLinkService,
702
- BasePlanService,
703
- BaseSubscriptionService
704
- };
121
+ export { BaseBillingPortalService, BaseCheckoutSessionService, BasePaymentLinkService, BasePlanService, BaseSubscriptionService };