@forklaunch/implementation-billing-base 0.2.3 → 0.3.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.
- package/lib/schemas/index.d.mts +402 -0
- package/lib/schemas/index.d.ts +402 -6
- package/lib/schemas/index.js +498 -5
- package/lib/schemas/index.mjs +547 -0
- package/lib/services/index.d.mts +255 -0
- package/lib/services/index.d.ts +255 -6
- package/lib/services/index.js +610 -5
- package/lib/services/index.mjs +599 -0
- package/package.json +6 -5
- package/lib/__test__/schemaEquality.test.d.ts +0 -2
- package/lib/__test__/schemaEquality.test.d.ts.map +0 -1
- package/lib/__test__/schemaEquality.test.js +0 -430
- package/lib/jest.config.d.ts +0 -4
- package/lib/jest.config.d.ts.map +0 -1
- package/lib/jest.config.js +0 -19
- package/lib/schemas/billingPortal.schema.d.ts +0 -119
- package/lib/schemas/billingPortal.schema.d.ts.map +0 -1
- package/lib/schemas/billingPortal.schema.js +0 -7
- package/lib/schemas/checkoutSession.schema.d.ts +0 -265
- package/lib/schemas/checkoutSession.schema.d.ts.map +0 -1
- package/lib/schemas/checkoutSession.schema.js +0 -7
- package/lib/schemas/index.d.ts.map +0 -1
- package/lib/schemas/paymentLink.schema.d.ts +0 -319
- package/lib/schemas/paymentLink.schema.d.ts.map +0 -1
- package/lib/schemas/paymentLink.schema.js +0 -7
- package/lib/schemas/plan.schema.d.ts +0 -338
- package/lib/schemas/plan.schema.d.ts.map +0 -1
- package/lib/schemas/plan.schema.js +0 -7
- package/lib/schemas/subscription.schema.d.ts +0 -366
- package/lib/schemas/subscription.schema.d.ts.map +0 -1
- package/lib/schemas/subscription.schema.js +0 -7
- package/lib/schemas/typebox/billingPortal.schema.d.ts +0 -161
- package/lib/schemas/typebox/billingPortal.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/billingPortal.schema.js +0 -31
- package/lib/schemas/typebox/checkoutSession.schema.d.ts +0 -316
- package/lib/schemas/typebox/checkoutSession.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/checkoutSession.schema.js +0 -50
- package/lib/schemas/typebox/paymentLink.schema.d.ts +0 -406
- package/lib/schemas/typebox/paymentLink.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/paymentLink.schema.js +0 -55
- package/lib/schemas/typebox/plan.schema.d.ts +0 -408
- package/lib/schemas/typebox/plan.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/plan.schema.js +0 -57
- package/lib/schemas/typebox/subscription.schema.d.ts +0 -456
- package/lib/schemas/typebox/subscription.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/subscription.schema.js +0 -61
- package/lib/schemas/zod/billingPortal.schema.d.ts +0 -63
- package/lib/schemas/zod/billingPortal.schema.d.ts.map +0 -1
- package/lib/schemas/zod/billingPortal.schema.js +0 -31
- package/lib/schemas/zod/checkoutSession.schema.d.ts +0 -176
- package/lib/schemas/zod/checkoutSession.schema.d.ts.map +0 -1
- package/lib/schemas/zod/checkoutSession.schema.js +0 -50
- package/lib/schemas/zod/paymentLink.schema.d.ts +0 -172
- package/lib/schemas/zod/paymentLink.schema.d.ts.map +0 -1
- package/lib/schemas/zod/paymentLink.schema.js +0 -55
- package/lib/schemas/zod/plan.schema.d.ts +0 -196
- package/lib/schemas/zod/plan.schema.d.ts.map +0 -1
- package/lib/schemas/zod/plan.schema.js +0 -57
- package/lib/schemas/zod/subscription.schema.d.ts +0 -204
- package/lib/schemas/zod/subscription.schema.d.ts.map +0 -1
- package/lib/schemas/zod/subscription.schema.js +0 -61
- package/lib/services/billingPortal.service.d.ts +0 -112
- package/lib/services/billingPortal.service.d.ts.map +0 -1
- package/lib/services/billingPortal.service.js +0 -128
- package/lib/services/checkoutSession.service.d.ts +0 -137
- package/lib/services/checkoutSession.service.d.ts.map +0 -1
- package/lib/services/checkoutSession.service.js +0 -111
- package/lib/services/index.d.ts.map +0 -1
- package/lib/services/paymentLink.service.d.ts +0 -118
- package/lib/services/paymentLink.service.d.ts.map +0 -1
- package/lib/services/paymentLink.service.js +0 -154
- package/lib/services/plan.service.d.ts +0 -102
- package/lib/services/plan.service.d.ts.map +0 -1
- package/lib/services/plan.service.js +0 -80
- package/lib/services/subscription.service.d.ts +0 -159
- package/lib/services/subscription.service.d.ts.map +0 -1
- package/lib/services/subscription.service.js +0 -169
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/vitest.config.d.ts +0 -3
- package/lib/vitest.config.d.ts.map +0 -1
- package/lib/vitest.config.js +0 -7
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { IdDto, IdsDto } from '@forklaunch/common';
|
|
2
|
+
import { TtlCache } from '@forklaunch/core/cache';
|
|
3
|
+
import { MetricsDefinition, OpenTelemetryCollector, TelemetryOptions } from '@forklaunch/core/http';
|
|
4
|
+
import { ResponseDtoMapperConstructor, RequestDtoMapperConstructor } from '@forklaunch/core/mappers';
|
|
5
|
+
import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService } from '@forklaunch/interfaces-billing/interfaces';
|
|
6
|
+
import { BillingPortalDto, CreateBillingPortalDto, UpdateBillingPortalDto, CheckoutSessionDto, CreateCheckoutSessionDto, UpdateCheckoutSessionDto, PaymentLinkDto, CreatePaymentLinkDto, UpdatePaymentLinkDto, PlanDto, CreatePlanDto, UpdatePlanDto, SubscriptionDto, CreateSubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
|
|
7
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
8
|
+
import { EntityManager } from '@mikro-orm/core';
|
|
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;
|
|
28
|
+
protected em: EntityManager;
|
|
29
|
+
protected cache: TtlCache;
|
|
30
|
+
protected openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
31
|
+
protected schemaValidator: SchemaValidator;
|
|
32
|
+
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']>;
|
|
36
|
+
};
|
|
37
|
+
readonly options?: {
|
|
38
|
+
telemetry?: TelemetryOptions;
|
|
39
|
+
enableDatabaseBackup?: boolean;
|
|
40
|
+
} | 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']>;
|
|
47
|
+
}, options?: {
|
|
48
|
+
telemetry?: TelemetryOptions;
|
|
49
|
+
enableDatabaseBackup?: boolean;
|
|
50
|
+
} | undefined);
|
|
51
|
+
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']>;
|
|
55
|
+
expireBillingPortalSession(idDto: IdDto): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
|
|
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;
|
|
76
|
+
protected readonly em: EntityManager;
|
|
77
|
+
protected readonly cache: TtlCache;
|
|
78
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
79
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
80
|
+
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']>;
|
|
84
|
+
};
|
|
85
|
+
readonly options?: {
|
|
86
|
+
enableDatabaseBackup?: boolean;
|
|
87
|
+
telemetry?: TelemetryOptions;
|
|
88
|
+
} | 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']>;
|
|
95
|
+
}, options?: {
|
|
96
|
+
enableDatabaseBackup?: boolean;
|
|
97
|
+
telemetry?: TelemetryOptions;
|
|
98
|
+
} | undefined);
|
|
99
|
+
protected createCacheKey: (id: string) => string;
|
|
100
|
+
createCheckoutSession(checkoutSessionDto: Dto['CreateCheckoutSessionDtoMapper']): Promise<Dto['CheckoutSessionDtoMapper']>;
|
|
101
|
+
getCheckoutSession({ id }: IdDto): Promise<Dto['CheckoutSessionDtoMapper']>;
|
|
102
|
+
expireCheckoutSession({ id }: IdDto): Promise<void>;
|
|
103
|
+
handleCheckoutSuccess({ id }: IdDto): Promise<void>;
|
|
104
|
+
handleCheckoutFailure({ id }: IdDto): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
|
|
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;
|
|
125
|
+
protected readonly em: EntityManager;
|
|
126
|
+
protected readonly cache: TtlCache;
|
|
127
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
128
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
129
|
+
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']>;
|
|
133
|
+
};
|
|
134
|
+
readonly options?: {
|
|
135
|
+
enableDatabaseBackup?: boolean;
|
|
136
|
+
telemetry?: TelemetryOptions;
|
|
137
|
+
} | 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']>;
|
|
144
|
+
}, options?: {
|
|
145
|
+
enableDatabaseBackup?: boolean;
|
|
146
|
+
telemetry?: TelemetryOptions;
|
|
147
|
+
} | undefined);
|
|
148
|
+
protected cacheKeyPrefix: string;
|
|
149
|
+
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']>;
|
|
153
|
+
expirePaymentLink({ id }: IdDto): Promise<void>;
|
|
154
|
+
handlePaymentSuccess({ id }: IdDto): Promise<void>;
|
|
155
|
+
handlePaymentFailure({ id }: IdDto): Promise<void>;
|
|
156
|
+
listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkDtoMapper'][]>;
|
|
157
|
+
}
|
|
158
|
+
|
|
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;
|
|
181
|
+
readonly options?: {
|
|
182
|
+
telemetry?: TelemetryOptions;
|
|
183
|
+
} | 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']>;
|
|
189
|
+
}, options?: {
|
|
190
|
+
telemetry?: TelemetryOptions;
|
|
191
|
+
} | 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']>;
|
|
196
|
+
deletePlan(idDto: {
|
|
197
|
+
id: string;
|
|
198
|
+
}, em?: EntityManager): Promise<void>;
|
|
199
|
+
}
|
|
200
|
+
|
|
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;
|
|
219
|
+
protected em: EntityManager;
|
|
220
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
221
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
222
|
+
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']>;
|
|
226
|
+
};
|
|
227
|
+
readonly options?: {
|
|
228
|
+
enableDatabaseBackup?: boolean;
|
|
229
|
+
telemetry?: TelemetryOptions;
|
|
230
|
+
} | 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']>;
|
|
236
|
+
}, options?: {
|
|
237
|
+
enableDatabaseBackup?: boolean;
|
|
238
|
+
telemetry?: TelemetryOptions;
|
|
239
|
+
} | 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']>;
|
|
245
|
+
deleteSubscription(idDto: {
|
|
246
|
+
id: string;
|
|
247
|
+
}, em?: EntityManager): Promise<void>;
|
|
248
|
+
listSubscriptions(idsDto: {
|
|
249
|
+
ids?: string[];
|
|
250
|
+
}, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper'][]>;
|
|
251
|
+
cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
252
|
+
resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export { BaseBillingPortalService, BaseCheckoutSessionService, BasePaymentLinkService, BasePlanService, BaseSubscriptionService };
|
package/lib/services/index.d.ts
CHANGED
|
@@ -1,6 +1,255 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { IdDto, IdsDto } from '@forklaunch/common';
|
|
2
|
+
import { TtlCache } from '@forklaunch/core/cache';
|
|
3
|
+
import { MetricsDefinition, OpenTelemetryCollector, TelemetryOptions } from '@forklaunch/core/http';
|
|
4
|
+
import { ResponseDtoMapperConstructor, RequestDtoMapperConstructor } from '@forklaunch/core/mappers';
|
|
5
|
+
import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService } from '@forklaunch/interfaces-billing/interfaces';
|
|
6
|
+
import { BillingPortalDto, CreateBillingPortalDto, UpdateBillingPortalDto, CheckoutSessionDto, CreateCheckoutSessionDto, UpdateCheckoutSessionDto, PaymentLinkDto, CreatePaymentLinkDto, UpdatePaymentLinkDto, PlanDto, CreatePlanDto, UpdatePlanDto, SubscriptionDto, CreateSubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
|
|
7
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
8
|
+
import { EntityManager } from '@mikro-orm/core';
|
|
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;
|
|
28
|
+
protected em: EntityManager;
|
|
29
|
+
protected cache: TtlCache;
|
|
30
|
+
protected openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
31
|
+
protected schemaValidator: SchemaValidator;
|
|
32
|
+
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']>;
|
|
36
|
+
};
|
|
37
|
+
readonly options?: {
|
|
38
|
+
telemetry?: TelemetryOptions;
|
|
39
|
+
enableDatabaseBackup?: boolean;
|
|
40
|
+
} | 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']>;
|
|
47
|
+
}, options?: {
|
|
48
|
+
telemetry?: TelemetryOptions;
|
|
49
|
+
enableDatabaseBackup?: boolean;
|
|
50
|
+
} | undefined);
|
|
51
|
+
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']>;
|
|
55
|
+
expireBillingPortalSession(idDto: IdDto): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
|
|
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;
|
|
76
|
+
protected readonly em: EntityManager;
|
|
77
|
+
protected readonly cache: TtlCache;
|
|
78
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
79
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
80
|
+
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']>;
|
|
84
|
+
};
|
|
85
|
+
readonly options?: {
|
|
86
|
+
enableDatabaseBackup?: boolean;
|
|
87
|
+
telemetry?: TelemetryOptions;
|
|
88
|
+
} | 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']>;
|
|
95
|
+
}, options?: {
|
|
96
|
+
enableDatabaseBackup?: boolean;
|
|
97
|
+
telemetry?: TelemetryOptions;
|
|
98
|
+
} | undefined);
|
|
99
|
+
protected createCacheKey: (id: string) => string;
|
|
100
|
+
createCheckoutSession(checkoutSessionDto: Dto['CreateCheckoutSessionDtoMapper']): Promise<Dto['CheckoutSessionDtoMapper']>;
|
|
101
|
+
getCheckoutSession({ id }: IdDto): Promise<Dto['CheckoutSessionDtoMapper']>;
|
|
102
|
+
expireCheckoutSession({ id }: IdDto): Promise<void>;
|
|
103
|
+
handleCheckoutSuccess({ id }: IdDto): Promise<void>;
|
|
104
|
+
handleCheckoutFailure({ id }: IdDto): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
|
|
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;
|
|
125
|
+
protected readonly em: EntityManager;
|
|
126
|
+
protected readonly cache: TtlCache;
|
|
127
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
128
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
129
|
+
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']>;
|
|
133
|
+
};
|
|
134
|
+
readonly options?: {
|
|
135
|
+
enableDatabaseBackup?: boolean;
|
|
136
|
+
telemetry?: TelemetryOptions;
|
|
137
|
+
} | 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']>;
|
|
144
|
+
}, options?: {
|
|
145
|
+
enableDatabaseBackup?: boolean;
|
|
146
|
+
telemetry?: TelemetryOptions;
|
|
147
|
+
} | undefined);
|
|
148
|
+
protected cacheKeyPrefix: string;
|
|
149
|
+
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']>;
|
|
153
|
+
expirePaymentLink({ id }: IdDto): Promise<void>;
|
|
154
|
+
handlePaymentSuccess({ id }: IdDto): Promise<void>;
|
|
155
|
+
handlePaymentFailure({ id }: IdDto): Promise<void>;
|
|
156
|
+
listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkDtoMapper'][]>;
|
|
157
|
+
}
|
|
158
|
+
|
|
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;
|
|
181
|
+
readonly options?: {
|
|
182
|
+
telemetry?: TelemetryOptions;
|
|
183
|
+
} | 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']>;
|
|
189
|
+
}, options?: {
|
|
190
|
+
telemetry?: TelemetryOptions;
|
|
191
|
+
} | 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']>;
|
|
196
|
+
deletePlan(idDto: {
|
|
197
|
+
id: string;
|
|
198
|
+
}, em?: EntityManager): Promise<void>;
|
|
199
|
+
}
|
|
200
|
+
|
|
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;
|
|
219
|
+
protected em: EntityManager;
|
|
220
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
221
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
222
|
+
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']>;
|
|
226
|
+
};
|
|
227
|
+
readonly options?: {
|
|
228
|
+
enableDatabaseBackup?: boolean;
|
|
229
|
+
telemetry?: TelemetryOptions;
|
|
230
|
+
} | 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']>;
|
|
236
|
+
}, options?: {
|
|
237
|
+
enableDatabaseBackup?: boolean;
|
|
238
|
+
telemetry?: TelemetryOptions;
|
|
239
|
+
} | 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']>;
|
|
245
|
+
deleteSubscription(idDto: {
|
|
246
|
+
id: string;
|
|
247
|
+
}, em?: EntityManager): Promise<void>;
|
|
248
|
+
listSubscriptions(idsDto: {
|
|
249
|
+
ids?: string[];
|
|
250
|
+
}, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper'][]>;
|
|
251
|
+
cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
252
|
+
resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export { BaseBillingPortalService, BaseCheckoutSessionService, BasePaymentLinkService, BasePlanService, BaseSubscriptionService };
|