@forklaunch/implementation-billing-base 0.3.2 → 0.3.3

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,253 +1,247 @@
1
- import { IdDto, IdsDto } from '@forklaunch/common';
1
+ import { InstanceTypeRecord, IdDto, IdsDto } from '@forklaunch/common';
2
2
  import { TtlCache } from '@forklaunch/core/cache';
3
- import { MetricsDefinition, OpenTelemetryCollector, TelemetryOptions } from '@forklaunch/core/http';
4
- import { ResponseDtoMapperConstructor, RequestDtoMapperConstructor } from '@forklaunch/core/mappers';
3
+ import { OpenTelemetryCollector, MetricsDefinition, TelemetryOptions } from '@forklaunch/core/http';
5
4
  import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService } from '@forklaunch/interfaces-billing/interfaces';
6
5
  import { BillingPortalDto, CreateBillingPortalDto, UpdateBillingPortalDto, CheckoutSessionDto, CreateCheckoutSessionDto, UpdateCheckoutSessionDto, PaymentLinkDto, CreatePaymentLinkDto, UpdatePaymentLinkDto, PlanDto, CreatePlanDto, UpdatePlanDto, SubscriptionDto, CreateSubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
6
+ import { ResponseMapperConstructor, RequestMapperConstructor, InternalMapper } from '@forklaunch/internal';
7
7
  import { AnySchemaValidator } from '@forklaunch/validator';
8
8
  import { EntityManager } from '@mikro-orm/core';
9
9
 
10
- declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidator, Metrics extends MetricsDefinition = MetricsDefinition, Dto extends {
11
- BillingPortalDtoMapper: BillingPortalDto;
12
- CreateBillingPortalDtoMapper: CreateBillingPortalDto;
13
- UpdateBillingPortalDtoMapper: UpdateBillingPortalDto;
14
- } = {
15
- BillingPortalDtoMapper: BillingPortalDto;
16
- CreateBillingPortalDtoMapper: CreateBillingPortalDto;
17
- UpdateBillingPortalDtoMapper: UpdateBillingPortalDto;
18
- }, Entities extends {
19
- BillingPortalDtoMapper: BillingPortalDto;
20
- CreateBillingPortalDtoMapper: BillingPortalDto;
21
- UpdateBillingPortalDtoMapper: BillingPortalDto;
22
- } = {
23
- BillingPortalDtoMapper: BillingPortalDto;
24
- CreateBillingPortalDtoMapper: BillingPortalDto;
25
- UpdateBillingPortalDtoMapper: BillingPortalDto;
26
- }> implements BillingPortalService {
27
- #private;
10
+ type BaseBillingDtos = {
11
+ BillingPortalMapper: BillingPortalDto;
12
+ CreateBillingPortalMapper: CreateBillingPortalDto;
13
+ UpdateBillingPortalMapper: UpdateBillingPortalDto;
14
+ };
15
+ type BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
16
+ CheckoutSessionMapper: CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
17
+ CreateCheckoutSessionMapper: CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
18
+ UpdateCheckoutSessionMapper: UpdateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
19
+ };
20
+ type BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
21
+ PaymentLinkMapper: PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
22
+ CreatePaymentLinkMapper: CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
23
+ UpdatePaymentLinkMapper: UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
24
+ };
25
+ type BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = {
26
+ PlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
27
+ CreatePlanMapper: CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
28
+ UpdatePlanMapper: UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
29
+ };
30
+ type BaseSubscriptionDtos<PartyType, BillingProviderType> = {
31
+ SubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
32
+ CreateSubscriptionMapper: CreateSubscriptionDto<PartyType, BillingProviderType>;
33
+ UpdateSubscriptionMapper: UpdateSubscriptionDto<PartyType, BillingProviderType>;
34
+ };
35
+
36
+ type BaseBillingEntities = {
37
+ BillingPortalMapper: BillingPortalDto;
38
+ CreateBillingPortalMapper: BillingPortalDto;
39
+ UpdateBillingPortalMapper: BillingPortalDto;
40
+ };
41
+ type BaseCheckoutSessionEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
42
+ CheckoutSessionMapper: CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
43
+ CreateCheckoutSessionMapper: CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
44
+ UpdateCheckoutSessionMapper: CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
45
+ };
46
+ type BasePaymentLinkEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
47
+ PaymentLinkMapper: PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
48
+ CreatePaymentLinkMapper: PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
49
+ UpdatePaymentLinkMapper: PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
50
+ };
51
+ type BasePlanEntities<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = {
52
+ PlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
53
+ CreatePlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
54
+ UpdatePlanMapper: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
55
+ };
56
+ type BaseSubscriptionEntities<PartyType, BillingProviderType> = {
57
+ SubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
58
+ CreateSubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
59
+ UpdateSubscriptionMapper: SubscriptionDto<PartyType, BillingProviderType>;
60
+ };
61
+
62
+ declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidator, Entities extends BaseBillingEntities, Dto extends BaseBillingDtos = BaseBillingDtos> implements BillingPortalService {
28
63
  protected em: EntityManager;
29
64
  protected cache: TtlCache;
30
- protected openTelemetryCollector: OpenTelemetryCollector<Metrics>;
65
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
31
66
  protected schemaValidator: SchemaValidator;
32
67
  protected mappers: {
33
- BillingPortalDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['BillingPortalDtoMapper'], Entities['BillingPortalDtoMapper']>;
34
- CreateBillingPortalDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateBillingPortalDtoMapper'], Entities['CreateBillingPortalDtoMapper']>;
35
- UpdateBillingPortalDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalDtoMapper'], Entities['UpdateBillingPortalDtoMapper']>;
68
+ BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
69
+ CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
70
+ UpdateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalMapper'], Entities['UpdateBillingPortalMapper'], (dto: Dto['UpdateBillingPortalMapper'], em: EntityManager) => Promise<Entities['UpdateBillingPortalMapper']>>;
36
71
  };
37
72
  readonly options?: {
38
73
  telemetry?: TelemetryOptions;
39
74
  enableDatabaseBackup?: boolean;
40
75
  } | undefined;
41
- private evaluatedTelemetryOptions;
42
- private enableDatabaseBackup;
43
- constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<Metrics>, schemaValidator: SchemaValidator, mappers: {
44
- BillingPortalDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['BillingPortalDtoMapper'], Entities['BillingPortalDtoMapper']>;
45
- CreateBillingPortalDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateBillingPortalDtoMapper'], Entities['CreateBillingPortalDtoMapper']>;
46
- UpdateBillingPortalDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalDtoMapper'], Entities['UpdateBillingPortalDtoMapper']>;
76
+ protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
77
+ protected evaluatedTelemetryOptions: {
78
+ logging?: boolean;
79
+ metrics?: boolean;
80
+ tracing?: boolean;
81
+ };
82
+ protected enableDatabaseBackup: boolean;
83
+ constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
84
+ BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
85
+ CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
86
+ UpdateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalMapper'], Entities['UpdateBillingPortalMapper'], (dto: Dto['UpdateBillingPortalMapper'], em: EntityManager) => Promise<Entities['UpdateBillingPortalMapper']>>;
47
87
  }, options?: {
48
88
  telemetry?: TelemetryOptions;
49
89
  enableDatabaseBackup?: boolean;
50
90
  } | undefined);
51
91
  protected createCacheKey: (id: string) => string;
52
- createBillingPortalSession(billingPortalDto: Dto['CreateBillingPortalDtoMapper']): Promise<Dto['BillingPortalDtoMapper']>;
53
- getBillingPortalSession(idDto: IdDto): Promise<Dto['BillingPortalDtoMapper']>;
54
- updateBillingPortalSession(billingPortalDto: UpdateBillingPortalDto): Promise<Dto['BillingPortalDtoMapper']>;
92
+ createBillingPortalSession(billingPortalDto: Dto['CreateBillingPortalMapper']): Promise<Dto['BillingPortalMapper']>;
93
+ getBillingPortalSession(idDto: IdDto): Promise<Dto['BillingPortalMapper']>;
94
+ updateBillingPortalSession(billingPortalDto: UpdateBillingPortalDto): Promise<Dto['BillingPortalMapper']>;
55
95
  expireBillingPortalSession(idDto: IdDto): Promise<void>;
56
96
  }
57
97
 
58
- declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, StatusEnum, Metrics extends MetricsDefinition = MetricsDefinition, Dto extends {
59
- CheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
60
- CreateCheckoutSessionDtoMapper: CreateCheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
61
- UpdateCheckoutSessionDtoMapper: UpdateCheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
62
- } = {
63
- CheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
64
- CreateCheckoutSessionDtoMapper: CreateCheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
65
- UpdateCheckoutSessionDtoMapper: UpdateCheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
66
- }, Entities extends {
67
- CheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
68
- CreateCheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
69
- UpdateCheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
70
- } = {
71
- CheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
72
- CreateCheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
73
- UpdateCheckoutSessionDtoMapper: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
74
- }> implements CheckoutSessionService<PaymentMethodEnum, StatusEnum> {
75
- #private;
98
+ declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities extends BaseCheckoutSessionEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, Dto extends BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
76
99
  protected readonly em: EntityManager;
77
100
  protected readonly cache: TtlCache;
78
- protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
101
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
79
102
  protected readonly schemaValidator: SchemaValidator;
80
103
  protected readonly mappers: {
81
- CheckoutSessionDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['CheckoutSessionDtoMapper'], Entities['CheckoutSessionDtoMapper']>;
82
- CreateCheckoutSessionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionDtoMapper'], Entities['CreateCheckoutSessionDtoMapper']>;
83
- UpdateCheckoutSessionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionDtoMapper'], Entities['UpdateCheckoutSessionDtoMapper']>;
104
+ CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
105
+ CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
106
+ UpdateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionMapper'], Entities['UpdateCheckoutSessionMapper'], (dto: Dto['UpdateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['UpdateCheckoutSessionMapper']>>;
84
107
  };
85
108
  readonly options?: {
86
109
  enableDatabaseBackup?: boolean;
87
110
  telemetry?: TelemetryOptions;
88
111
  } | undefined;
89
- private evaluatedTelemetryOptions;
90
- private enableDatabaseBackup;
91
- constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<Metrics>, schemaValidator: SchemaValidator, mappers: {
92
- CheckoutSessionDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['CheckoutSessionDtoMapper'], Entities['CheckoutSessionDtoMapper']>;
93
- CreateCheckoutSessionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionDtoMapper'], Entities['CreateCheckoutSessionDtoMapper']>;
94
- UpdateCheckoutSessionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionDtoMapper'], Entities['UpdateCheckoutSessionDtoMapper']>;
112
+ protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
113
+ protected evaluatedTelemetryOptions: {
114
+ logging?: boolean;
115
+ metrics?: boolean;
116
+ tracing?: boolean;
117
+ };
118
+ protected enableDatabaseBackup: boolean;
119
+ constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
120
+ CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
121
+ CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
122
+ UpdateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionMapper'], Entities['UpdateCheckoutSessionMapper'], (dto: Dto['UpdateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['UpdateCheckoutSessionMapper']>>;
95
123
  }, options?: {
96
124
  enableDatabaseBackup?: boolean;
97
125
  telemetry?: TelemetryOptions;
98
126
  } | undefined);
99
127
  protected createCacheKey: (id: string) => string;
100
- createCheckoutSession(checkoutSessionDto: Dto['CreateCheckoutSessionDtoMapper']): Promise<Dto['CheckoutSessionDtoMapper']>;
101
- getCheckoutSession({ id }: IdDto): Promise<Dto['CheckoutSessionDtoMapper']>;
128
+ createCheckoutSession(checkoutSessionDto: Dto['CreateCheckoutSessionMapper']): Promise<Dto['CheckoutSessionMapper']>;
129
+ getCheckoutSession({ id }: IdDto): Promise<Dto['CheckoutSessionMapper']>;
102
130
  expireCheckoutSession({ id }: IdDto): Promise<void>;
103
131
  handleCheckoutSuccess({ id }: IdDto): Promise<void>;
104
132
  handleCheckoutFailure({ id }: IdDto): Promise<void>;
105
133
  }
106
134
 
107
- declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator, CurrencyEnum, StatusEnum, Metrics extends MetricsDefinition = MetricsDefinition, Dto extends {
108
- PaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
109
- CreatePaymentLinkDtoMapper: CreatePaymentLinkDto<CurrencyEnum, StatusEnum>;
110
- UpdatePaymentLinkDtoMapper: UpdatePaymentLinkDto<CurrencyEnum, StatusEnum>;
111
- } = {
112
- PaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
113
- CreatePaymentLinkDtoMapper: CreatePaymentLinkDto<CurrencyEnum, StatusEnum>;
114
- UpdatePaymentLinkDtoMapper: UpdatePaymentLinkDto<CurrencyEnum, StatusEnum>;
115
- }, Entities extends {
116
- PaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
117
- CreatePaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
118
- UpdatePaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
119
- } = {
120
- PaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
121
- CreatePaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
122
- UpdatePaymentLinkDtoMapper: PaymentLinkDto<CurrencyEnum, StatusEnum>;
123
- }> implements PaymentLinkService<CurrencyEnum, StatusEnum> {
124
- #private;
135
+ declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities extends BasePaymentLinkEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, Dto extends BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
125
136
  protected readonly em: EntityManager;
126
137
  protected readonly cache: TtlCache;
127
- protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
138
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
128
139
  protected readonly schemaValidator: SchemaValidator;
129
140
  protected readonly mappers: {
130
- PaymentLinkDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['PaymentLinkDtoMapper'], Entities['PaymentLinkDtoMapper']>;
131
- CreatePaymentLinkDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkDtoMapper'], Entities['CreatePaymentLinkDtoMapper']>;
132
- UpdatePaymentLinkDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkDtoMapper'], Entities['UpdatePaymentLinkDtoMapper']>;
141
+ PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
142
+ CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
143
+ UpdatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkMapper'], Entities['UpdatePaymentLinkMapper'], (dto: Dto['UpdatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['UpdatePaymentLinkMapper']>>;
133
144
  };
134
145
  readonly options?: {
135
146
  enableDatabaseBackup?: boolean;
136
147
  telemetry?: TelemetryOptions;
137
148
  } | undefined;
138
- private evaluatedTelemetryOptions;
139
- private enableDatabaseBackup;
140
- constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<Metrics>, schemaValidator: SchemaValidator, mappers: {
141
- PaymentLinkDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['PaymentLinkDtoMapper'], Entities['PaymentLinkDtoMapper']>;
142
- CreatePaymentLinkDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkDtoMapper'], Entities['CreatePaymentLinkDtoMapper']>;
143
- UpdatePaymentLinkDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkDtoMapper'], Entities['UpdatePaymentLinkDtoMapper']>;
149
+ protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
150
+ protected evaluatedTelemetryOptions: {
151
+ logging?: boolean;
152
+ metrics?: boolean;
153
+ tracing?: boolean;
154
+ };
155
+ protected enableDatabaseBackup: boolean;
156
+ constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
157
+ PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
158
+ CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
159
+ UpdatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkMapper'], Entities['UpdatePaymentLinkMapper'], (dto: Dto['UpdatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['UpdatePaymentLinkMapper']>>;
144
160
  }, options?: {
145
161
  enableDatabaseBackup?: boolean;
146
162
  telemetry?: TelemetryOptions;
147
163
  } | undefined);
148
164
  protected cacheKeyPrefix: string;
149
165
  protected createCacheKey: (id: string) => string;
150
- createPaymentLink(paymentLinkDto: Dto['CreatePaymentLinkDtoMapper']): Promise<Dto['PaymentLinkDtoMapper']>;
151
- updatePaymentLink(paymentLinkDto: Dto['UpdatePaymentLinkDtoMapper']): Promise<Dto['PaymentLinkDtoMapper']>;
152
- getPaymentLink({ id }: IdDto): Promise<Dto['PaymentLinkDtoMapper']>;
166
+ createPaymentLink(paymentLinkDto: Dto['CreatePaymentLinkMapper']): Promise<Dto['PaymentLinkMapper']>;
167
+ updatePaymentLink(paymentLinkDto: Dto['UpdatePaymentLinkMapper']): Promise<Dto['PaymentLinkMapper']>;
168
+ getPaymentLink({ id }: IdDto): Promise<Dto['PaymentLinkMapper']>;
153
169
  expirePaymentLink({ id }: IdDto): Promise<void>;
154
170
  handlePaymentSuccess({ id }: IdDto): Promise<void>;
155
171
  handlePaymentFailure({ id }: IdDto): Promise<void>;
156
- listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkDtoMapper'][]>;
172
+ listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkMapper'][]>;
157
173
  }
158
174
 
159
- declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCadenceEnum, BillingProviderEnum, Metrics extends MetricsDefinition = MetricsDefinition, Dto extends {
160
- PlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
161
- CreatePlanDtoMapper: CreatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
162
- UpdatePlanDtoMapper: UpdatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
163
- } = {
164
- PlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
165
- CreatePlanDtoMapper: CreatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
166
- UpdatePlanDtoMapper: UpdatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
167
- }, Entities extends {
168
- PlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
169
- CreatePlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
170
- UpdatePlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
171
- } = {
172
- PlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
173
- CreatePlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
174
- UpdatePlanDtoMapper: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
175
- }> implements PlanService<PlanCadenceEnum, BillingProviderEnum> {
176
- #private;
177
- private em;
178
- private readonly openTelemetryCollector;
179
- private readonly schemaValidator;
180
- private readonly mappers;
175
+ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, Entities extends BasePlanEntities<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>, Dto extends BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> implements PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> {
176
+ protected em: EntityManager;
177
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
178
+ protected readonly schemaValidator: SchemaValidator;
179
+ protected readonly mappers: {
180
+ PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
181
+ CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
182
+ UpdatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePlanMapper'], Entities['UpdatePlanMapper'], (dto: Dto['UpdatePlanMapper'], em: EntityManager) => Promise<Entities['UpdatePlanMapper']>>;
183
+ };
181
184
  readonly options?: {
182
185
  telemetry?: TelemetryOptions;
183
186
  } | undefined;
184
- private evaluatedTelemetryOptions;
185
- constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<Metrics>, schemaValidator: SchemaValidator, mappers: {
186
- PlanDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['PlanDtoMapper'], Entities['PlanDtoMapper']>;
187
- CreatePlanDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreatePlanDtoMapper'], Entities['CreatePlanDtoMapper']>;
188
- UpdatePlanDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdatePlanDtoMapper'], Entities['UpdatePlanDtoMapper']>;
187
+ protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
188
+ protected evaluatedTelemetryOptions: {
189
+ logging?: boolean;
190
+ metrics?: boolean;
191
+ tracing?: boolean;
192
+ };
193
+ constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
194
+ PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
195
+ CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
196
+ UpdatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePlanMapper'], Entities['UpdatePlanMapper'], (dto: Dto['UpdatePlanMapper'], em: EntityManager) => Promise<Entities['UpdatePlanMapper']>>;
189
197
  }, options?: {
190
198
  telemetry?: TelemetryOptions;
191
199
  } | undefined);
192
- listPlans(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['PlanDtoMapper'][]>;
193
- createPlan(planDto: Dto['CreatePlanDtoMapper'], em?: EntityManager): Promise<Dto['PlanDtoMapper']>;
194
- getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['PlanDtoMapper']>;
195
- updatePlan(planDto: Dto['UpdatePlanDtoMapper'], em?: EntityManager): Promise<Dto['PlanDtoMapper']>;
200
+ listPlans(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['PlanMapper'][]>;
201
+ createPlan(planDto: Dto['CreatePlanMapper'], em?: EntityManager): Promise<Dto['PlanMapper']>;
202
+ getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
203
+ updatePlan(planDto: Dto['UpdatePlanMapper'], em?: EntityManager): Promise<Dto['PlanMapper']>;
196
204
  deletePlan(idDto: {
197
205
  id: string;
198
206
  }, em?: EntityManager): Promise<void>;
199
207
  }
200
208
 
201
- declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator, PartyType, BillingProviderType, Metrics extends MetricsDefinition = MetricsDefinition, Dto extends {
202
- SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
203
- CreateSubscriptionDtoMapper: CreateSubscriptionDto<PartyType, BillingProviderType>;
204
- UpdateSubscriptionDtoMapper: UpdateSubscriptionDto<PartyType, BillingProviderType>;
205
- } = {
206
- SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
207
- CreateSubscriptionDtoMapper: CreateSubscriptionDto<PartyType, BillingProviderType>;
208
- UpdateSubscriptionDtoMapper: UpdateSubscriptionDto<PartyType, BillingProviderType>;
209
- }, Entities extends {
210
- SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
211
- CreateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
212
- UpdateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
213
- } = {
214
- SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
215
- CreateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
216
- UpdateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
217
- }> implements SubscriptionService<PartyType, BillingProviderType> {
218
- #private;
209
+ 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> {
219
210
  protected em: EntityManager;
220
- protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
211
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
221
212
  protected readonly schemaValidator: SchemaValidator;
222
213
  protected readonly mappers: {
223
- SubscriptionDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['SubscriptionDtoMapper'], Entities['SubscriptionDtoMapper']>;
224
- CreateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateSubscriptionDtoMapper'], Entities['CreateSubscriptionDtoMapper']>;
225
- UpdateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionDtoMapper'], Entities['UpdateSubscriptionDtoMapper']>;
214
+ SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
215
+ CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
216
+ UpdateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionMapper'], Entities['UpdateSubscriptionMapper'], (dto: Dto['UpdateSubscriptionMapper'], em: EntityManager) => Promise<Entities['UpdateSubscriptionMapper']>>;
226
217
  };
227
218
  readonly options?: {
228
- enableDatabaseBackup?: boolean;
229
219
  telemetry?: TelemetryOptions;
230
220
  } | undefined;
231
- private evaluatedTelemetryOptions;
232
- constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<Metrics>, schemaValidator: SchemaValidator, mappers: {
233
- SubscriptionDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['SubscriptionDtoMapper'], Entities['SubscriptionDtoMapper']>;
234
- CreateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateSubscriptionDtoMapper'], Entities['CreateSubscriptionDtoMapper']>;
235
- UpdateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionDtoMapper'], Entities['UpdateSubscriptionDtoMapper']>;
221
+ protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
222
+ protected evaluatedTelemetryOptions: {
223
+ logging?: boolean;
224
+ metrics?: boolean;
225
+ tracing?: boolean;
226
+ };
227
+ constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
228
+ SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
229
+ CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
230
+ UpdateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionMapper'], Entities['UpdateSubscriptionMapper'], (dto: Dto['UpdateSubscriptionMapper'], em: EntityManager) => Promise<Entities['UpdateSubscriptionMapper']>>;
236
231
  }, options?: {
237
- enableDatabaseBackup?: boolean;
238
232
  telemetry?: TelemetryOptions;
239
233
  } | undefined);
240
- createSubscription(subscriptionDto: Dto['CreateSubscriptionDtoMapper'], em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
241
- getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
242
- getUserSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
243
- getOrganizationSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
244
- updateSubscription(subscriptionDto: Dto['UpdateSubscriptionDtoMapper'], em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
234
+ createSubscription(subscriptionDto: Dto['CreateSubscriptionMapper'], em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
235
+ getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
236
+ getUserSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
237
+ getOrganizationSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
238
+ updateSubscription(subscriptionDto: Dto['UpdateSubscriptionMapper'], em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
245
239
  deleteSubscription(idDto: {
246
240
  id: string;
247
241
  }, em?: EntityManager): Promise<void>;
248
242
  listSubscriptions(idsDto: {
249
243
  ids?: string[];
250
- }, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper'][]>;
244
+ }, em?: EntityManager): Promise<Dto['SubscriptionMapper'][]>;
251
245
  cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
252
246
  resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
253
247
  }