@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.
- package/lib/eject/domain/schemas/billingPortal.schema.ts +7 -5
- package/lib/eject/domain/schemas/checkoutSession.schema.ts +21 -13
- package/lib/eject/domain/schemas/paymentLink.schema.ts +22 -27
- package/lib/eject/domain/schemas/plan.schema.ts +21 -12
- package/lib/eject/domain/schemas/subscription.schema.ts +5 -5
- package/lib/eject/services/billingPortal.service.ts +42 -57
- package/lib/eject/services/checkoutSession.service.ts +48 -79
- package/lib/eject/services/paymentLink.service.ts +56 -67
- package/lib/eject/services/plan.service.ts +57 -67
- package/lib/eject/services/subscription.service.ts +55 -100
- package/lib/eject/types/baseBillingDto.types.ts +94 -0
- package/lib/eject/types/baseBillingEntity.types.ts +78 -0
- package/lib/schemas/index.d.mts +114 -124
- package/lib/schemas/index.d.ts +114 -124
- package/lib/schemas/index.js +102 -112
- package/lib/schemas/index.mjs +105 -113
- package/lib/services/index.d.mts +156 -162
- package/lib/services/index.d.ts +156 -162
- package/lib/services/index.js +42 -46
- package/lib/services/index.mjs +47 -51
- package/package.json +9 -8
package/lib/services/index.d.ts
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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<
|
|
65
|
+
protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
31
66
|
protected schemaValidator: SchemaValidator;
|
|
32
67
|
protected mappers: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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['
|
|
53
|
-
getBillingPortalSession(idDto: IdDto): Promise<Dto['
|
|
54
|
-
updateBillingPortalSession(billingPortalDto: UpdateBillingPortalDto): Promise<Dto['
|
|
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,
|
|
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<
|
|
101
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
79
102
|
protected readonly schemaValidator: SchemaValidator;
|
|
80
103
|
protected readonly mappers: {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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['
|
|
101
|
-
getCheckoutSession({ id }: IdDto): Promise<Dto['
|
|
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,
|
|
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<
|
|
138
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
128
139
|
protected readonly schemaValidator: SchemaValidator;
|
|
129
140
|
protected readonly mappers: {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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['
|
|
151
|
-
updatePaymentLink(paymentLinkDto: Dto['
|
|
152
|
-
getPaymentLink({ id }: IdDto): Promise<Dto['
|
|
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['
|
|
172
|
+
listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkMapper'][]>;
|
|
157
173
|
}
|
|
158
174
|
|
|
159
|
-
declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCadenceEnum, BillingProviderEnum,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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['
|
|
193
|
-
createPlan(planDto: Dto['
|
|
194
|
-
getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['
|
|
195
|
-
updatePlan(planDto: Dto['
|
|
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,
|
|
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<
|
|
211
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
221
212
|
protected readonly schemaValidator: SchemaValidator;
|
|
222
213
|
protected readonly mappers: {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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['
|
|
241
|
-
getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['
|
|
242
|
-
getUserSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['
|
|
243
|
-
getOrganizationSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['
|
|
244
|
-
updateSubscription(subscriptionDto: Dto['
|
|
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['
|
|
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
|
}
|