@forklaunch/implementation-billing-base 0.5.8 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import { InstanceTypeRecord, IdDto, IdsDto } from '@forklaunch/common';
1
+ import { IdDto, IdsDto } from '@forklaunch/common';
2
2
  import { TtlCache } from '@forklaunch/core/cache';
3
3
  import {
4
- TelemetryOptions,
5
4
  OpenTelemetryCollector,
6
- MetricsDefinition
5
+ MetricsDefinition,
6
+ TelemetryOptions
7
7
  } from '@forklaunch/core/http';
8
8
  import {
9
9
  BillingPortalService,
@@ -13,238 +13,72 @@ import {
13
13
  SubscriptionService
14
14
  } from '@forklaunch/interfaces-billing/interfaces';
15
15
  import {
16
- BillingPortalDto,
17
16
  CreateBillingPortalDto,
18
17
  UpdateBillingPortalDto,
19
- CheckoutSessionDto,
20
18
  CreateCheckoutSessionDto,
21
- UpdateCheckoutSessionDto,
22
- PaymentLinkDto,
23
19
  CreatePaymentLinkDto,
24
20
  UpdatePaymentLinkDto,
25
- PlanDto,
26
21
  CreatePlanDto,
27
22
  UpdatePlanDto,
28
- SubscriptionDto,
29
23
  CreateSubscriptionDto,
30
24
  UpdateSubscriptionDto
31
25
  } from '@forklaunch/interfaces-billing/types';
32
- import {
33
- InternalMapper,
34
- ResponseMapperConstructor,
35
- RequestMapperConstructor
36
- } from '@forklaunch/internal';
37
26
  import { AnySchemaValidator } from '@forklaunch/validator';
38
27
  import { EntityManager } from '@mikro-orm/core';
39
-
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
- };
28
+ import {
29
+ BaseBillingEntities,
30
+ BaseBillingDtos,
31
+ BillingPortalMappers,
32
+ BaseCheckoutSessionEntities,
33
+ BaseCheckoutSessionDtos,
34
+ CheckoutSessionMappers,
35
+ BasePaymentLinkEntities,
36
+ BasePaymentLinkDtos,
37
+ PaymentLinkMappers,
38
+ BasePlanEntities,
39
+ BasePlanDtos,
40
+ PlanMappers,
41
+ BaseSubscriptionEntities,
42
+ BaseSubscriptionDtos,
43
+ SubscriptionMappers
44
+ } from '../domain/types/index.mjs';
154
45
 
155
46
  declare class BaseBillingPortalService<
156
47
  SchemaValidator extends AnySchemaValidator,
157
- Entities extends BaseBillingEntities,
158
- Dto extends BaseBillingDtos = BaseBillingDtos
48
+ MapperEntities extends BaseBillingEntities,
49
+ MapperDomains extends BaseBillingDtos = BaseBillingDtos
159
50
  > implements BillingPortalService
160
51
  {
161
- readonly options?:
162
- | {
163
- telemetry?: TelemetryOptions;
164
- 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
- };
52
+ private evaluatedTelemetryOptions;
173
53
  protected enableDatabaseBackup: boolean;
174
- protected em: EntityManager;
54
+ em: EntityManager;
175
55
  protected cache: TtlCache;
176
56
  protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
177
57
  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
- };
58
+ protected mappers: BillingPortalMappers<MapperEntities, MapperDomains>;
203
59
  constructor(
204
60
  em: EntityManager,
205
61
  cache: TtlCache,
206
62
  openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
207
63
  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
64
+ mappers: BillingPortalMappers<MapperEntities, MapperDomains>,
65
+ options?: {
66
+ telemetry?: TelemetryOptions;
67
+ enableDatabaseBackup?: boolean;
68
+ }
239
69
  );
240
70
  protected createCacheKey: (id: string) => string;
241
71
  createBillingPortalSession(
242
- billingPortalDto: Dto['CreateBillingPortalMapper']
243
- ): Promise<Dto['BillingPortalMapper']>;
244
- getBillingPortalSession(idDto: IdDto): Promise<Dto['BillingPortalMapper']>;
72
+ billingPortalDto: CreateBillingPortalDto,
73
+ ...args: unknown[]
74
+ ): Promise<MapperDomains['BillingPortalMapper']>;
75
+ getBillingPortalSession(
76
+ idDto: IdDto
77
+ ): Promise<MapperDomains['BillingPortalMapper']>;
245
78
  updateBillingPortalSession(
246
- billingPortalDto: UpdateBillingPortalDto
247
- ): Promise<Dto['BillingPortalMapper']>;
79
+ billingPortalDto: UpdateBillingPortalDto,
80
+ ...args: unknown[]
81
+ ): Promise<MapperDomains['BillingPortalMapper']>;
248
82
  expireBillingPortalSession(idDto: IdDto): Promise<void>;
249
83
  }
250
84
 
@@ -253,102 +87,60 @@ declare class BaseCheckoutSessionService<
253
87
  PaymentMethodEnum,
254
88
  CurrencyEnum,
255
89
  StatusEnum,
256
- Entities extends BaseCheckoutSessionEntities<
90
+ MapperEntities extends BaseCheckoutSessionEntities<
257
91
  PaymentMethodEnum,
258
92
  CurrencyEnum,
259
93
  StatusEnum
260
94
  >,
261
- Dto extends BaseCheckoutSessionDtos<
95
+ MapperDomains extends BaseCheckoutSessionDtos<
262
96
  PaymentMethodEnum,
263
97
  CurrencyEnum,
264
98
  StatusEnum
265
99
  > = BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>
266
100
  > implements CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum>
267
101
  {
268
- readonly options?:
269
- | {
270
- enableDatabaseBackup?: boolean;
271
- 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
- };
102
+ private evaluatedTelemetryOptions;
280
103
  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
- };
104
+ em: EntityManager;
105
+ protected cache: TtlCache;
106
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
107
+ protected schemaValidator: SchemaValidator;
108
+ protected mappers: CheckoutSessionMappers<
109
+ PaymentMethodEnum,
110
+ CurrencyEnum,
111
+ StatusEnum,
112
+ MapperEntities,
113
+ MapperDomains
114
+ >;
310
115
  constructor(
311
116
  em: EntityManager,
312
117
  cache: TtlCache,
313
118
  openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
314
119
  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
120
+ mappers: CheckoutSessionMappers<
121
+ PaymentMethodEnum,
122
+ CurrencyEnum,
123
+ StatusEnum,
124
+ MapperEntities,
125
+ MapperDomains
126
+ >,
127
+ options?: {
128
+ telemetry?: TelemetryOptions;
129
+ enableDatabaseBackup?: boolean;
130
+ }
346
131
  );
347
132
  protected createCacheKey: (id: string) => string;
348
133
  createCheckoutSession(
349
- checkoutSessionDto: Dto['CreateCheckoutSessionMapper']
350
- ): Promise<Dto['CheckoutSessionMapper']>;
351
- getCheckoutSession({ id }: IdDto): Promise<Dto['CheckoutSessionMapper']>;
134
+ checkoutSessionDto: CreateCheckoutSessionDto<
135
+ PaymentMethodEnum,
136
+ CurrencyEnum,
137
+ StatusEnum
138
+ >,
139
+ ...args: unknown[]
140
+ ): Promise<MapperDomains['CheckoutSessionMapper']>;
141
+ getCheckoutSession({
142
+ id
143
+ }: IdDto): Promise<MapperDomains['CheckoutSessionMapper']>;
352
144
  expireCheckoutSession({ id }: IdDto): Promise<void>;
353
145
  handleCheckoutSuccess({ id }: IdDto): Promise<void>;
354
146
  handleCheckoutFailure({ id }: IdDto): Promise<void>;
@@ -359,110 +151,73 @@ declare class BasePaymentLinkService<
359
151
  PaymentMethodEnum,
360
152
  CurrencyEnum,
361
153
  StatusEnum,
362
- Entities extends BasePaymentLinkEntities<
154
+ MapperEntities extends BasePaymentLinkEntities<
363
155
  PaymentMethodEnum,
364
156
  CurrencyEnum,
365
157
  StatusEnum
366
158
  >,
367
- Dto extends BasePaymentLinkDtos<
159
+ MapperDomains extends BasePaymentLinkDtos<
368
160
  PaymentMethodEnum,
369
161
  CurrencyEnum,
370
162
  StatusEnum
371
163
  > = BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>
372
164
  > implements PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum>
373
165
  {
374
- readonly options?:
375
- | {
376
- enableDatabaseBackup?: boolean;
377
- 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
- };
166
+ private evaluatedTelemetryOptions;
386
167
  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
- };
168
+ em: EntityManager;
169
+ protected cache: TtlCache;
170
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
171
+ protected schemaValidator: SchemaValidator;
172
+ protected mappers: PaymentLinkMappers<
173
+ PaymentMethodEnum,
174
+ CurrencyEnum,
175
+ StatusEnum,
176
+ MapperEntities,
177
+ MapperDomains
178
+ >;
416
179
  constructor(
417
180
  em: EntityManager,
418
181
  cache: TtlCache,
419
182
  openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
420
183
  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
184
+ mappers: PaymentLinkMappers<
185
+ PaymentMethodEnum,
186
+ CurrencyEnum,
187
+ StatusEnum,
188
+ MapperEntities,
189
+ MapperDomains
190
+ >,
191
+ options?: {
192
+ telemetry?: TelemetryOptions;
193
+ enableDatabaseBackup?: boolean;
194
+ }
452
195
  );
453
196
  protected cacheKeyPrefix: string;
454
197
  protected createCacheKey: (id: string) => string;
455
198
  createPaymentLink(
456
- paymentLinkDto: Dto['CreatePaymentLinkMapper']
457
- ): Promise<Dto['PaymentLinkMapper']>;
199
+ paymentLinkDto: CreatePaymentLinkDto<
200
+ PaymentMethodEnum,
201
+ CurrencyEnum,
202
+ StatusEnum
203
+ >,
204
+ ...args: unknown[]
205
+ ): Promise<MapperDomains['PaymentLinkMapper']>;
458
206
  updatePaymentLink(
459
- paymentLinkDto: Dto['UpdatePaymentLinkMapper']
460
- ): Promise<Dto['PaymentLinkMapper']>;
461
- getPaymentLink({ id }: IdDto): Promise<Dto['PaymentLinkMapper']>;
207
+ paymentLinkDto: UpdatePaymentLinkDto<
208
+ PaymentMethodEnum,
209
+ CurrencyEnum,
210
+ StatusEnum
211
+ >,
212
+ ...args: unknown[]
213
+ ): Promise<MapperDomains['PaymentLinkMapper']>;
214
+ getPaymentLink({ id }: IdDto): Promise<MapperDomains['PaymentLinkMapper']>;
462
215
  expirePaymentLink({ id }: IdDto): Promise<void>;
463
216
  handlePaymentSuccess({ id }: IdDto): Promise<void>;
464
217
  handlePaymentFailure({ id }: IdDto): Promise<void>;
465
- listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkMapper'][]>;
218
+ listPaymentLinks(
219
+ idsDto?: IdsDto
220
+ ): Promise<MapperDomains['PaymentLinkMapper'][]>;
466
221
  }
467
222
 
468
223
  declare class BasePlanService<
@@ -470,102 +225,62 @@ declare class BasePlanService<
470
225
  PlanCadenceEnum,
471
226
  CurrencyEnum,
472
227
  BillingProviderEnum,
473
- Entities extends BasePlanEntities<
228
+ MapperEntities extends BasePlanEntities<
474
229
  PlanCadenceEnum,
475
230
  CurrencyEnum,
476
231
  BillingProviderEnum
477
232
  >,
478
- Dto extends BasePlanDtos<
233
+ MapperDomains extends BasePlanDtos<
479
234
  PlanCadenceEnum,
480
235
  CurrencyEnum,
481
236
  BillingProviderEnum
482
237
  > = BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>
483
238
  > implements PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>
484
239
  {
485
- readonly options?:
486
- | {
487
- 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
- };
240
+ private evaluatedTelemetryOptions;
241
+ em: EntityManager;
242
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
243
+ protected schemaValidator: SchemaValidator;
244
+ protected mappers: PlanMappers<
245
+ PlanCadenceEnum,
246
+ CurrencyEnum,
247
+ BillingProviderEnum,
248
+ MapperEntities,
249
+ MapperDomains
250
+ >;
524
251
  constructor(
525
252
  em: EntityManager,
526
253
  openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
527
254
  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
255
+ mappers: PlanMappers<
256
+ PlanCadenceEnum,
257
+ CurrencyEnum,
258
+ BillingProviderEnum,
259
+ MapperEntities,
260
+ MapperDomains
261
+ >,
262
+ options?: {
263
+ telemetry?: TelemetryOptions;
264
+ }
558
265
  );
559
- listPlans(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['PlanMapper'][]>;
266
+ listPlans(
267
+ idsDto?: IdsDto,
268
+ em?: EntityManager
269
+ ): Promise<MapperDomains['PlanMapper'][]>;
560
270
  createPlan(
561
- planDto: Dto['CreatePlanMapper'],
271
+ planDto: CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>,
272
+ em?: EntityManager,
273
+ ...args: unknown[]
274
+ ): Promise<MapperDomains['PlanMapper']>;
275
+ getPlan(
276
+ idDto: IdDto,
562
277
  em?: EntityManager
563
- ): Promise<Dto['PlanMapper']>;
564
- getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
278
+ ): Promise<MapperDomains['PlanMapper']>;
565
279
  updatePlan(
566
- planDto: Dto['UpdatePlanMapper'],
567
- em?: EntityManager
568
- ): Promise<Dto['PlanMapper']>;
280
+ planDto: UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>,
281
+ em?: EntityManager,
282
+ ...args: unknown[]
283
+ ): Promise<MapperDomains['PlanMapper']>;
569
284
  deletePlan(
570
285
  idDto: {
571
286
  id: string;
@@ -590,7 +305,6 @@ declare class BaseSubscriptionService<
590
305
  telemetry?: TelemetryOptions;
591
306
  }
592
307
  | undefined;
593
- protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
594
308
  protected evaluatedTelemetryOptions: {
595
309
  logging?: boolean;
596
310
  metrics?: boolean;
@@ -599,60 +313,17 @@ declare class BaseSubscriptionService<
599
313
  protected em: EntityManager;
600
314
  protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
601
315
  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
- };
316
+ protected readonly mappers: SubscriptionMappers<
317
+ PartyType,
318
+ BillingProviderType,
319
+ Entities,
320
+ Dto
321
+ >;
627
322
  constructor(
628
323
  em: EntityManager,
629
324
  openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
630
325
  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
- },
326
+ mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>,
656
327
  options?:
657
328
  | {
658
329
  telemetry?: TelemetryOptions;
@@ -660,8 +331,9 @@ declare class BaseSubscriptionService<
660
331
  | undefined
661
332
  );
662
333
  createSubscription(
663
- subscriptionDto: Dto['CreateSubscriptionMapper'],
664
- em?: EntityManager
334
+ subscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>,
335
+ em?: EntityManager,
336
+ ...args: unknown[]
665
337
  ): Promise<Dto['SubscriptionMapper']>;
666
338
  getSubscription(
667
339
  idDto: IdDto,
@@ -676,8 +348,9 @@ declare class BaseSubscriptionService<
676
348
  em?: EntityManager
677
349
  ): Promise<Dto['SubscriptionMapper']>;
678
350
  updateSubscription(
679
- subscriptionDto: Dto['UpdateSubscriptionMapper'],
680
- em?: EntityManager
351
+ subscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>,
352
+ em?: EntityManager,
353
+ ...args: unknown[]
681
354
  ): Promise<Dto['SubscriptionMapper']>;
682
355
  deleteSubscription(
683
356
  idDto: {