@forklaunch/implementation-billing-base 0.1.6 → 0.1.8
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/__test__/schemaEquality.test.js +44 -20
- package/lib/eject/{schemas → domain/schemas}/billingPortal.schema.ts +7 -5
- package/lib/eject/{schemas → domain/schemas}/checkoutSession.schema.ts +7 -5
- package/lib/eject/{schemas → domain/schemas}/paymentLink.schema.ts +7 -5
- package/lib/eject/{schemas → domain/schemas}/plan.schema.ts +5 -5
- package/lib/eject/{schemas → domain/schemas}/subscription.schema.ts +7 -5
- package/lib/eject/services/billingPortal.service.ts +10 -13
- package/lib/eject/services/checkoutSession.service.ts +8 -11
- package/lib/eject/services/paymentLink.service.ts +11 -14
- package/lib/eject/services/plan.service.ts +11 -14
- package/lib/eject/services/subscription.service.ts +15 -15
- package/lib/schemas/billingPortal.schema.d.ts +10 -2
- package/lib/schemas/billingPortal.schema.d.ts.map +1 -1
- package/lib/schemas/billingPortal.schema.js +3 -3
- package/lib/schemas/checkoutSession.schema.d.ts +10 -2
- package/lib/schemas/checkoutSession.schema.d.ts.map +1 -1
- package/lib/schemas/checkoutSession.schema.js +3 -3
- package/lib/schemas/paymentLink.schema.d.ts +10 -2
- package/lib/schemas/paymentLink.schema.d.ts.map +1 -1
- package/lib/schemas/paymentLink.schema.js +3 -3
- package/lib/schemas/plan.schema.d.ts +10 -2
- package/lib/schemas/plan.schema.d.ts.map +1 -1
- package/lib/schemas/plan.schema.js +3 -3
- package/lib/schemas/subscription.schema.d.ts +10 -2
- package/lib/schemas/subscription.schema.d.ts.map +1 -1
- package/lib/schemas/subscription.schema.js +3 -3
- package/lib/schemas/typebox/billingPortal.schema.d.ts +9 -3
- package/lib/schemas/typebox/billingPortal.schema.d.ts.map +1 -1
- package/lib/schemas/typebox/billingPortal.schema.js +5 -5
- package/lib/schemas/typebox/checkoutSession.schema.d.ts +9 -3
- package/lib/schemas/typebox/checkoutSession.schema.d.ts.map +1 -1
- package/lib/schemas/typebox/checkoutSession.schema.js +5 -5
- package/lib/schemas/typebox/paymentLink.schema.d.ts +9 -3
- package/lib/schemas/typebox/paymentLink.schema.d.ts.map +1 -1
- package/lib/schemas/typebox/paymentLink.schema.js +5 -5
- package/lib/schemas/typebox/plan.schema.d.ts +9 -3
- package/lib/schemas/typebox/plan.schema.d.ts.map +1 -1
- package/lib/schemas/typebox/plan.schema.js +5 -5
- package/lib/schemas/typebox/subscription.schema.d.ts +9 -3
- package/lib/schemas/typebox/subscription.schema.d.ts.map +1 -1
- package/lib/schemas/typebox/subscription.schema.js +5 -5
- package/lib/schemas/zod/billingPortal.schema.d.ts +9 -3
- package/lib/schemas/zod/billingPortal.schema.d.ts.map +1 -1
- package/lib/schemas/zod/billingPortal.schema.js +5 -5
- package/lib/schemas/zod/checkoutSession.schema.d.ts +9 -3
- package/lib/schemas/zod/checkoutSession.schema.d.ts.map +1 -1
- package/lib/schemas/zod/checkoutSession.schema.js +5 -5
- package/lib/schemas/zod/paymentLink.schema.d.ts +9 -3
- package/lib/schemas/zod/paymentLink.schema.d.ts.map +1 -1
- package/lib/schemas/zod/paymentLink.schema.js +5 -5
- package/lib/schemas/zod/plan.schema.d.ts +9 -3
- package/lib/schemas/zod/plan.schema.d.ts.map +1 -1
- package/lib/schemas/zod/plan.schema.js +5 -5
- package/lib/schemas/zod/subscription.schema.d.ts +9 -3
- package/lib/schemas/zod/subscription.schema.d.ts.map +1 -1
- package/lib/schemas/zod/subscription.schema.js +5 -5
- package/lib/services/billingPortal.service.d.ts +3 -3
- package/lib/services/billingPortal.service.d.ts.map +1 -1
- package/lib/services/billingPortal.service.js +11 -11
- package/lib/services/checkoutSession.service.d.ts +3 -3
- package/lib/services/checkoutSession.service.d.ts.map +1 -1
- package/lib/services/checkoutSession.service.js +9 -9
- package/lib/services/paymentLink.service.d.ts +3 -3
- package/lib/services/paymentLink.service.d.ts.map +1 -1
- package/lib/services/paymentLink.service.js +12 -12
- package/lib/services/plan.service.d.ts +3 -3
- package/lib/services/plan.service.d.ts.map +1 -1
- package/lib/services/plan.service.js +12 -12
- package/lib/services/subscription.service.d.ts +3 -3
- package/lib/services/subscription.service.d.ts.map +1 -1
- package/lib/services/subscription.service.js +14 -14
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -8
- /package/lib/eject/{schemas → domain/schemas}/index.ts +0 -0
|
@@ -10,34 +10,58 @@ import { CheckoutSessionSchema as ZodCheckoutSessionSchema, CreateCheckoutSessio
|
|
|
10
10
|
import { CreatePaymentLinkSchema as ZodCreatePaymentLinkSchema, PaymentLinkSchema as ZodPaymentLinkSchema, UpdatePaymentLinkSchema as ZodUpdatePaymentLinkSchema } from '../schemas/zod/paymentLink.schema';
|
|
11
11
|
import { CreatePlanSchema as ZodCreatePlanSchema, PlanSchema as ZodPlanSchema, UpdatePlanSchema as ZodUpdatePlanSchema } from '../schemas/zod/plan.schema';
|
|
12
12
|
import { CreateSubscriptionSchema as ZodCreateSubscriptionSchema, SubscriptionSchema as ZodSubscriptionSchema, UpdateSubscriptionSchema as ZodUpdateSubscriptionSchema } from '../schemas/zod/subscription.schema';
|
|
13
|
-
const zodUpdateBillingPortalSchema = ZodUpdateBillingPortalSchema(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
13
|
+
const zodUpdateBillingPortalSchema = ZodUpdateBillingPortalSchema({
|
|
14
|
+
uuidId: false
|
|
15
|
+
});
|
|
16
|
+
const typeboxUpdateBillingPortalSchema = TypeboxUpdateBillingPortalSchema({
|
|
17
|
+
uuidId: false
|
|
18
|
+
});
|
|
19
|
+
const zodBillingPortalSchema = ZodBillingPortalSchema({ uuidId: false });
|
|
20
|
+
const typeboxBillingPortalSchema = TypeboxBillingPortalSchema({
|
|
21
|
+
uuidId: false
|
|
22
|
+
});
|
|
17
23
|
const zodCreateCheckoutSessionSchema = ZodCreateCheckoutSessionSchema(DummyEnum);
|
|
18
24
|
const typeboxCreateCheckoutSessionSchema = TypeboxCreateCheckoutSessionSchema(DummyEnum);
|
|
19
|
-
const zodUpdateCheckoutSessionSchema = ZodUpdateCheckoutSessionSchema(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
25
|
+
const zodUpdateCheckoutSessionSchema = ZodUpdateCheckoutSessionSchema({
|
|
26
|
+
uuidId: false
|
|
27
|
+
})(DummyEnum);
|
|
28
|
+
const typeboxUpdateCheckoutSessionSchema = TypeboxUpdateCheckoutSessionSchema({
|
|
29
|
+
uuidId: false
|
|
30
|
+
})(DummyEnum);
|
|
31
|
+
const zodCheckoutSessionSchema = ZodCheckoutSessionSchema({ uuidId: true })(DummyEnum);
|
|
32
|
+
const typeboxCheckoutSessionSchema = TypeboxCheckoutSessionSchema({
|
|
33
|
+
uuidId: true
|
|
34
|
+
})(DummyEnum);
|
|
23
35
|
const zodCreatePaymentLinkSchema = ZodCreatePaymentLinkSchema(DummyEnum);
|
|
24
36
|
const typeboxCreatePaymentLinkSchema = TypeboxCreatePaymentLinkSchema(DummyEnum);
|
|
25
|
-
const zodUpdatePaymentLinkSchema = ZodUpdatePaymentLinkSchema(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
37
|
+
const zodUpdatePaymentLinkSchema = ZodUpdatePaymentLinkSchema({
|
|
38
|
+
uuidId: false
|
|
39
|
+
})(DummyEnum);
|
|
40
|
+
const typeboxUpdatePaymentLinkSchema = TypeboxUpdatePaymentLinkSchema({
|
|
41
|
+
uuidId: false
|
|
42
|
+
})(DummyEnum);
|
|
43
|
+
const zodPaymentLinkSchema = ZodPaymentLinkSchema({ uuidId: true })(DummyEnum);
|
|
44
|
+
const typeboxPaymentLinkSchema = TypeboxPaymentLinkSchema({
|
|
45
|
+
uuidId: false
|
|
46
|
+
})(DummyEnum);
|
|
29
47
|
const zodCreatePlanSchema = ZodCreatePlanSchema(DummyEnum, DummyEnum);
|
|
30
48
|
const typeboxCreatePlanSchema = TypeboxCreatePlanSchema(DummyEnum, DummyEnum);
|
|
31
|
-
const zodUpdatePlanSchema = ZodUpdatePlanSchema(false)(DummyEnum, DummyEnum);
|
|
32
|
-
const typeboxUpdatePlanSchema = TypeboxUpdatePlanSchema(false)(DummyEnum, DummyEnum);
|
|
33
|
-
const zodPlanSchema = ZodPlanSchema(
|
|
34
|
-
const typeboxPlanSchema = TypeboxPlanSchema(
|
|
49
|
+
const zodUpdatePlanSchema = ZodUpdatePlanSchema({ uuidId: false })(DummyEnum, DummyEnum);
|
|
50
|
+
const typeboxUpdatePlanSchema = TypeboxUpdatePlanSchema({ uuidId: false })(DummyEnum, DummyEnum);
|
|
51
|
+
const zodPlanSchema = ZodPlanSchema({ uuidId: true })(DummyEnum, DummyEnum);
|
|
52
|
+
const typeboxPlanSchema = TypeboxPlanSchema({ uuidId: true })(DummyEnum, DummyEnum);
|
|
35
53
|
const zodCreateSubscriptionSchema = ZodCreateSubscriptionSchema(DummyEnum, DummyEnum);
|
|
36
54
|
const typeboxCreateSubscriptionSchema = TypeboxCreateSubscriptionSchema(DummyEnum, DummyEnum);
|
|
37
|
-
const zodUpdateSubscriptionSchema = ZodUpdateSubscriptionSchema(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
55
|
+
const zodUpdateSubscriptionSchema = ZodUpdateSubscriptionSchema({
|
|
56
|
+
uuidId: false
|
|
57
|
+
})(DummyEnum, DummyEnum);
|
|
58
|
+
const typeboxUpdateSubscriptionSchema = TypeboxUpdateSubscriptionSchema({
|
|
59
|
+
uuidId: false
|
|
60
|
+
})(DummyEnum, DummyEnum);
|
|
61
|
+
const zodSubscriptionSchema = ZodSubscriptionSchema({ uuidId: true })(DummyEnum, DummyEnum);
|
|
62
|
+
const typeboxSubscriptionSchema = TypeboxSubscriptionSchema({
|
|
63
|
+
uuidId: true
|
|
64
|
+
})(DummyEnum, DummyEnum);
|
|
41
65
|
describe('schema equality', () => {
|
|
42
66
|
it('should be equal for billing portal', () => {
|
|
43
67
|
expect(isTrue(testSchemaEquality(ZodCreateBillingPortalSchema, TypeboxCreateBillingPortalSchema, {
|
|
@@ -12,13 +12,13 @@ export const CreateBillingPortalSchema = {
|
|
|
12
12
|
expiresAt: date
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const UpdateBillingPortalSchema = (uuidId: boolean) => ({
|
|
15
|
+
export const UpdateBillingPortalSchema = ({ uuidId }: { uuidId: boolean }) => ({
|
|
16
16
|
id: uuidId ? uuid : string,
|
|
17
17
|
uri: optional(string),
|
|
18
18
|
expiresAt: optional(date)
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
export const BillingPortalSchema = (uuidId: boolean) => ({
|
|
21
|
+
export const BillingPortalSchema = ({ uuidId }: { uuidId: boolean }) => ({
|
|
22
22
|
id: uuidId ? uuid : string,
|
|
23
23
|
customerId: string,
|
|
24
24
|
uri: string,
|
|
@@ -28,8 +28,10 @@ export const BillingPortalSchema = (uuidId: boolean) => ({
|
|
|
28
28
|
updatedAt: optional(date)
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
export const
|
|
31
|
+
export const BaseBillingPortalServiceSchemas = (options: {
|
|
32
|
+
uuidId: boolean;
|
|
33
|
+
}) => ({
|
|
32
34
|
CreateBillingPortalSchema,
|
|
33
|
-
UpdateBillingPortalSchema: UpdateBillingPortalSchema(
|
|
34
|
-
BillingPortalSchema: BillingPortalSchema(
|
|
35
|
+
UpdateBillingPortalSchema: UpdateBillingPortalSchema(options),
|
|
36
|
+
BillingPortalSchema: BillingPortalSchema(options)
|
|
35
37
|
});
|
|
@@ -22,7 +22,7 @@ export const CreateCheckoutSessionSchema = <
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
export const UpdateCheckoutSessionSchema =
|
|
25
|
-
(uuidId: boolean) =>
|
|
25
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
26
26
|
<T extends Record<string, LiteralSchema>>(PaymentMethodEnum: T) => ({
|
|
27
27
|
id: uuidId ? uuid : string,
|
|
28
28
|
customerId: optional(string),
|
|
@@ -33,7 +33,7 @@ export const UpdateCheckoutSessionSchema =
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
export const CheckoutSessionSchema =
|
|
36
|
-
(uuidId: boolean) =>
|
|
36
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
37
37
|
<T extends Record<string, LiteralSchema>>(PaymentMethodEnum: T) => ({
|
|
38
38
|
id: uuidId ? uuid : string,
|
|
39
39
|
customerId: string,
|
|
@@ -45,8 +45,10 @@ export const CheckoutSessionSchema =
|
|
|
45
45
|
updatedAt: optional(date)
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
export const
|
|
48
|
+
export const BaseCheckoutSessionServiceSchemas = (options: {
|
|
49
|
+
uuidId: boolean;
|
|
50
|
+
}) => ({
|
|
49
51
|
CreateCheckoutSessionSchema,
|
|
50
|
-
UpdateCheckoutSessionSchema: UpdateCheckoutSessionSchema(
|
|
51
|
-
CheckoutSessionSchema: CheckoutSessionSchema(
|
|
52
|
+
UpdateCheckoutSessionSchema: UpdateCheckoutSessionSchema(options),
|
|
53
|
+
CheckoutSessionSchema: CheckoutSessionSchema(options)
|
|
52
54
|
});
|
|
@@ -24,7 +24,7 @@ export const CreatePaymentLinkSchema = <
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
export const UpdatePaymentLinkSchema =
|
|
27
|
-
(uuidId: boolean) =>
|
|
27
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
28
28
|
<T extends Record<string, LiteralSchema>>(CurrencyEnum: T) => ({
|
|
29
29
|
id: uuidId ? uuid : string,
|
|
30
30
|
amount: optional(number),
|
|
@@ -37,7 +37,7 @@ export const UpdatePaymentLinkSchema =
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
export const PaymentLinkSchema =
|
|
40
|
-
(uuidId: boolean) =>
|
|
40
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
41
41
|
<T extends Record<string, LiteralSchema>>(CurrencyEnum: T) => ({
|
|
42
42
|
id: uuidId ? uuid : string,
|
|
43
43
|
amount: number,
|
|
@@ -51,8 +51,10 @@ export const PaymentLinkSchema =
|
|
|
51
51
|
updatedAt: optional(date)
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
export const
|
|
54
|
+
export const BasePaymentLinkServiceSchemas = (options: {
|
|
55
|
+
uuidId: boolean;
|
|
56
|
+
}) => ({
|
|
55
57
|
CreatePaymentLinkSchema,
|
|
56
|
-
UpdatePaymentLinkSchema: UpdatePaymentLinkSchema(
|
|
57
|
-
PaymentLinkSchema: PaymentLinkSchema(
|
|
58
|
+
UpdatePaymentLinkSchema: UpdatePaymentLinkSchema(options),
|
|
59
|
+
PaymentLinkSchema: PaymentLinkSchema(options)
|
|
58
60
|
});
|
|
@@ -30,7 +30,7 @@ export const CreatePlanSchema = <
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
export const UpdatePlanSchema =
|
|
33
|
-
(uuidId: boolean) =>
|
|
33
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
34
34
|
<
|
|
35
35
|
T extends Record<string, LiteralSchema>,
|
|
36
36
|
U extends Record<string, LiteralSchema>
|
|
@@ -51,7 +51,7 @@ export const UpdatePlanSchema =
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
export const PlanSchema =
|
|
54
|
-
(uuidId: boolean) =>
|
|
54
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
55
55
|
<
|
|
56
56
|
T extends Record<string, LiteralSchema>,
|
|
57
57
|
U extends Record<string, LiteralSchema>
|
|
@@ -73,8 +73,8 @@ export const PlanSchema =
|
|
|
73
73
|
updatedAt: optional(date)
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
export const
|
|
76
|
+
export const BasePlanServiceSchemas = (options: { uuidId: boolean }) => ({
|
|
77
77
|
CreatePlanSchema,
|
|
78
|
-
UpdatePlanSchema: UpdatePlanSchema(
|
|
79
|
-
PlanSchema: PlanSchema(
|
|
78
|
+
UpdatePlanSchema: UpdatePlanSchema(options),
|
|
79
|
+
PlanSchema: PlanSchema(options)
|
|
80
80
|
});
|
|
@@ -30,7 +30,7 @@ export const CreateSubscriptionSchema = <
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
export const UpdateSubscriptionSchema =
|
|
33
|
-
(uuidId: boolean) =>
|
|
33
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
34
34
|
<
|
|
35
35
|
T extends Record<string, LiteralSchema>,
|
|
36
36
|
U extends Record<string, LiteralSchema>
|
|
@@ -53,7 +53,7 @@ export const UpdateSubscriptionSchema =
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
export const SubscriptionSchema =
|
|
56
|
-
(uuidId: boolean) =>
|
|
56
|
+
({ uuidId }: { uuidId: boolean }) =>
|
|
57
57
|
<
|
|
58
58
|
T extends Record<string, LiteralSchema>,
|
|
59
59
|
U extends Record<string, LiteralSchema>
|
|
@@ -77,8 +77,10 @@ export const SubscriptionSchema =
|
|
|
77
77
|
updatedAt: optional(date)
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
export const
|
|
80
|
+
export const BaseSubscriptionServiceSchemas = (options: {
|
|
81
|
+
uuidId: boolean;
|
|
82
|
+
}) => ({
|
|
81
83
|
CreateSubscriptionSchema,
|
|
82
|
-
UpdateSubscriptionSchema: UpdateSubscriptionSchema(
|
|
83
|
-
SubscriptionSchema: SubscriptionSchema(
|
|
84
|
+
UpdateSubscriptionSchema: UpdateSubscriptionSchema(options),
|
|
85
|
+
SubscriptionSchema: SubscriptionSchema(options)
|
|
84
86
|
});
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
RequestDtoMapperConstructor,
|
|
6
6
|
ResponseDtoMapperConstructor,
|
|
7
7
|
transformIntoInternalDtoMapper
|
|
8
|
-
} from '@forklaunch/core/
|
|
8
|
+
} from '@forklaunch/core/mappers';
|
|
9
9
|
import {
|
|
10
10
|
MetricsDefinition,
|
|
11
11
|
OpenTelemetryCollector
|
|
@@ -41,8 +41,8 @@ export class BaseBillingPortalService<
|
|
|
41
41
|
}
|
|
42
42
|
> implements BillingPortalService
|
|
43
43
|
{
|
|
44
|
-
#
|
|
45
|
-
InstanceTypeRecord<typeof this.
|
|
44
|
+
#mapperss: InternalDtoMapper<
|
|
45
|
+
InstanceTypeRecord<typeof this.mapperss>,
|
|
46
46
|
Entities,
|
|
47
47
|
Dto
|
|
48
48
|
>;
|
|
@@ -51,7 +51,7 @@ export class BaseBillingPortalService<
|
|
|
51
51
|
protected cache: TtlCache,
|
|
52
52
|
protected openTelemetryCollector: OpenTelemetryCollector<Metrics>,
|
|
53
53
|
protected schemaValidator: SchemaValidator,
|
|
54
|
-
protected
|
|
54
|
+
protected mapperss: {
|
|
55
55
|
BillingPortalDtoMapper: ResponseDtoMapperConstructor<
|
|
56
56
|
SchemaValidator,
|
|
57
57
|
Dto['BillingPortalDtoMapper'],
|
|
@@ -69,10 +69,7 @@ export class BaseBillingPortalService<
|
|
|
69
69
|
>;
|
|
70
70
|
}
|
|
71
71
|
) {
|
|
72
|
-
this.#
|
|
73
|
-
dtoMappers,
|
|
74
|
-
schemaValidator
|
|
75
|
-
);
|
|
72
|
+
this.#mapperss = transformIntoInternalDtoMapper(mapperss, schemaValidator);
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
protected createCacheKey = createCacheKey('billing_portal_session');
|
|
@@ -81,7 +78,7 @@ export class BaseBillingPortalService<
|
|
|
81
78
|
billingPortalDto: Dto['CreateBillingPortalDtoMapper']
|
|
82
79
|
): Promise<Dto['BillingPortalDtoMapper']> {
|
|
83
80
|
const billingPortalSession =
|
|
84
|
-
this.#
|
|
81
|
+
this.#mapperss.CreateBillingPortalDtoMapper.deserializeDtoToEntity(
|
|
85
82
|
billingPortalDto
|
|
86
83
|
);
|
|
87
84
|
|
|
@@ -96,7 +93,7 @@ export class BaseBillingPortalService<
|
|
|
96
93
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
97
94
|
});
|
|
98
95
|
|
|
99
|
-
return this.#
|
|
96
|
+
return this.#mapperss.BillingPortalDtoMapper.serializeEntityToDto(
|
|
100
97
|
billingPortalSession
|
|
101
98
|
);
|
|
102
99
|
}
|
|
@@ -111,7 +108,7 @@ export class BaseBillingPortalService<
|
|
|
111
108
|
throw new Error('Session not found');
|
|
112
109
|
}
|
|
113
110
|
|
|
114
|
-
return this.#
|
|
111
|
+
return this.#mapperss.BillingPortalDtoMapper.serializeEntityToDto(
|
|
115
112
|
billingPortalSessionDetails.value
|
|
116
113
|
);
|
|
117
114
|
}
|
|
@@ -120,7 +117,7 @@ export class BaseBillingPortalService<
|
|
|
120
117
|
billingPortalDto: UpdateBillingPortalDto
|
|
121
118
|
): Promise<Dto['BillingPortalDtoMapper']> {
|
|
122
119
|
const billingPortalSession =
|
|
123
|
-
this.#
|
|
120
|
+
this.#mapperss.UpdateBillingPortalDtoMapper.deserializeDtoToEntity(
|
|
124
121
|
billingPortalDto
|
|
125
122
|
);
|
|
126
123
|
// Save the updated session to your database or external service
|
|
@@ -130,7 +127,7 @@ export class BaseBillingPortalService<
|
|
|
130
127
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
131
128
|
});
|
|
132
129
|
|
|
133
|
-
return this.#
|
|
130
|
+
return this.#mapperss.BillingPortalDtoMapper.serializeEntityToDto(
|
|
134
131
|
billingPortalSession
|
|
135
132
|
);
|
|
136
133
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
RequestDtoMapperConstructor,
|
|
6
6
|
ResponseDtoMapperConstructor,
|
|
7
7
|
transformIntoInternalDtoMapper
|
|
8
|
-
} from '@forklaunch/core/
|
|
8
|
+
} from '@forklaunch/core/mappers';
|
|
9
9
|
import {
|
|
10
10
|
MetricsDefinition,
|
|
11
11
|
OpenTelemetryCollector
|
|
@@ -42,8 +42,8 @@ export class BaseCheckoutSessionService<
|
|
|
42
42
|
}
|
|
43
43
|
> implements CheckoutSessionService<PaymentMethodEnum>
|
|
44
44
|
{
|
|
45
|
-
#
|
|
46
|
-
InstanceTypeRecord<typeof this.
|
|
45
|
+
#mapperss: InternalDtoMapper<
|
|
46
|
+
InstanceTypeRecord<typeof this.mapperss>,
|
|
47
47
|
Entities,
|
|
48
48
|
Dto
|
|
49
49
|
>;
|
|
@@ -52,7 +52,7 @@ export class BaseCheckoutSessionService<
|
|
|
52
52
|
protected readonly cache: TtlCache,
|
|
53
53
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>,
|
|
54
54
|
protected readonly schemaValidator: SchemaValidator,
|
|
55
|
-
protected readonly
|
|
55
|
+
protected readonly mapperss: {
|
|
56
56
|
CheckoutSessionDtoMapper: ResponseDtoMapperConstructor<
|
|
57
57
|
SchemaValidator,
|
|
58
58
|
Dto['CheckoutSessionDtoMapper'],
|
|
@@ -70,10 +70,7 @@ export class BaseCheckoutSessionService<
|
|
|
70
70
|
>;
|
|
71
71
|
}
|
|
72
72
|
) {
|
|
73
|
-
this.#
|
|
74
|
-
dtoMappers,
|
|
75
|
-
schemaValidator
|
|
76
|
-
);
|
|
73
|
+
this.#mapperss = transformIntoInternalDtoMapper(mapperss, schemaValidator);
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
protected createCacheKey = createCacheKey('checkout_session');
|
|
@@ -82,7 +79,7 @@ export class BaseCheckoutSessionService<
|
|
|
82
79
|
checkoutSessionDto: Dto['CreateCheckoutSessionDtoMapper']
|
|
83
80
|
): Promise<Dto['CheckoutSessionDtoMapper']> {
|
|
84
81
|
const checkoutSession =
|
|
85
|
-
this.#
|
|
82
|
+
this.#mapperss.CreateCheckoutSessionDtoMapper.deserializeDtoToEntity(
|
|
86
83
|
checkoutSessionDto
|
|
87
84
|
);
|
|
88
85
|
|
|
@@ -93,7 +90,7 @@ export class BaseCheckoutSessionService<
|
|
|
93
90
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
94
91
|
});
|
|
95
92
|
|
|
96
|
-
return this.#
|
|
93
|
+
return this.#mapperss.CheckoutSessionDtoMapper.serializeEntityToDto(
|
|
97
94
|
checkoutSession
|
|
98
95
|
);
|
|
99
96
|
}
|
|
@@ -108,7 +105,7 @@ export class BaseCheckoutSessionService<
|
|
|
108
105
|
throw new Error('Session not found');
|
|
109
106
|
}
|
|
110
107
|
|
|
111
|
-
return this.#
|
|
108
|
+
return this.#mapperss.CheckoutSessionDtoMapper.serializeEntityToDto(
|
|
112
109
|
checkoutSessionDetails.value
|
|
113
110
|
);
|
|
114
111
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
RequestDtoMapperConstructor,
|
|
6
6
|
ResponseDtoMapperConstructor,
|
|
7
7
|
transformIntoInternalDtoMapper
|
|
8
|
-
} from '@forklaunch/core/
|
|
8
|
+
} from '@forklaunch/core/mappers';
|
|
9
9
|
import {
|
|
10
10
|
MetricsDefinition,
|
|
11
11
|
OpenTelemetryCollector
|
|
@@ -42,8 +42,8 @@ export class BasePaymentLinkService<
|
|
|
42
42
|
}
|
|
43
43
|
> implements PaymentLinkService<CurrencyEnum>
|
|
44
44
|
{
|
|
45
|
-
#
|
|
46
|
-
InstanceTypeRecord<typeof this.
|
|
45
|
+
#mapperss: InternalDtoMapper<
|
|
46
|
+
InstanceTypeRecord<typeof this.mapperss>,
|
|
47
47
|
Entities,
|
|
48
48
|
Dto
|
|
49
49
|
>;
|
|
@@ -52,7 +52,7 @@ export class BasePaymentLinkService<
|
|
|
52
52
|
protected readonly cache: TtlCache,
|
|
53
53
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>,
|
|
54
54
|
protected readonly schemaValidator: SchemaValidator,
|
|
55
|
-
protected readonly
|
|
55
|
+
protected readonly mapperss: {
|
|
56
56
|
PaymentLinkDtoMapper: ResponseDtoMapperConstructor<
|
|
57
57
|
SchemaValidator,
|
|
58
58
|
Dto['PaymentLinkDtoMapper'],
|
|
@@ -70,10 +70,7 @@ export class BasePaymentLinkService<
|
|
|
70
70
|
>;
|
|
71
71
|
}
|
|
72
72
|
) {
|
|
73
|
-
this.#
|
|
74
|
-
dtoMappers,
|
|
75
|
-
schemaValidator
|
|
76
|
-
);
|
|
73
|
+
this.#mapperss = transformIntoInternalDtoMapper(mapperss, schemaValidator);
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
protected cacheKeyPrefix = 'payment_link';
|
|
@@ -84,7 +81,7 @@ export class BasePaymentLinkService<
|
|
|
84
81
|
): Promise<Dto['PaymentLinkDtoMapper']> {
|
|
85
82
|
// TODO: Perform permission checks here
|
|
86
83
|
const paymentLink =
|
|
87
|
-
this.#
|
|
84
|
+
this.#mapperss.CreatePaymentLinkDtoMapper.deserializeDtoToEntity(
|
|
88
85
|
paymentLinkDto
|
|
89
86
|
);
|
|
90
87
|
await this.cache.putRecord({
|
|
@@ -93,7 +90,7 @@ export class BasePaymentLinkService<
|
|
|
93
90
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
94
91
|
});
|
|
95
92
|
|
|
96
|
-
return this.#
|
|
93
|
+
return this.#mapperss.PaymentLinkDtoMapper.serializeEntityToDto(
|
|
97
94
|
paymentLink
|
|
98
95
|
);
|
|
99
96
|
}
|
|
@@ -108,7 +105,7 @@ export class BasePaymentLinkService<
|
|
|
108
105
|
throw new Error('Payment link not found');
|
|
109
106
|
}
|
|
110
107
|
const paymentLink =
|
|
111
|
-
this.#
|
|
108
|
+
this.#mapperss.UpdatePaymentLinkDtoMapper.deserializeDtoToEntity(
|
|
112
109
|
paymentLinkDto
|
|
113
110
|
);
|
|
114
111
|
const updatedLink = { ...existingLink, ...paymentLink };
|
|
@@ -118,7 +115,7 @@ export class BasePaymentLinkService<
|
|
|
118
115
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
119
116
|
});
|
|
120
117
|
|
|
121
|
-
return this.#
|
|
118
|
+
return this.#mapperss.PaymentLinkDtoMapper.serializeEntityToDto(
|
|
122
119
|
updatedLink
|
|
123
120
|
);
|
|
124
121
|
}
|
|
@@ -131,7 +128,7 @@ export class BasePaymentLinkService<
|
|
|
131
128
|
throw new Error('Payment link not found');
|
|
132
129
|
}
|
|
133
130
|
|
|
134
|
-
return this.#
|
|
131
|
+
return this.#mapperss.PaymentLinkDtoMapper.serializeEntityToDto(
|
|
135
132
|
paymentLink.value
|
|
136
133
|
);
|
|
137
134
|
}
|
|
@@ -163,7 +160,7 @@ export class BasePaymentLinkService<
|
|
|
163
160
|
const paymentLink =
|
|
164
161
|
await this.cache.readRecord<Entities['PaymentLinkDtoMapper']>(key);
|
|
165
162
|
const paymentLinkDto =
|
|
166
|
-
this.#
|
|
163
|
+
this.#mapperss.PaymentLinkDtoMapper.serializeEntityToDto(
|
|
167
164
|
paymentLink.value
|
|
168
165
|
);
|
|
169
166
|
return paymentLinkDto;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
RequestDtoMapperConstructor,
|
|
5
5
|
ResponseDtoMapperConstructor,
|
|
6
6
|
transformIntoInternalDtoMapper
|
|
7
|
-
} from '@forklaunch/core/
|
|
7
|
+
} from '@forklaunch/core/mappers';
|
|
8
8
|
import {
|
|
9
9
|
MetricsDefinition,
|
|
10
10
|
OpenTelemetryCollector
|
|
@@ -43,8 +43,8 @@ export class BasePlanService<
|
|
|
43
43
|
}
|
|
44
44
|
> implements PlanService<PlanCadenceEnum, BillingProviderEnum>
|
|
45
45
|
{
|
|
46
|
-
#
|
|
47
|
-
InstanceTypeRecord<typeof this.
|
|
46
|
+
#mapperss: InternalDtoMapper<
|
|
47
|
+
InstanceTypeRecord<typeof this.mapperss>,
|
|
48
48
|
Entities,
|
|
49
49
|
Dto
|
|
50
50
|
>;
|
|
@@ -53,7 +53,7 @@ export class BasePlanService<
|
|
|
53
53
|
private em: EntityManager,
|
|
54
54
|
private readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>,
|
|
55
55
|
private readonly schemaValidator: SchemaValidator,
|
|
56
|
-
private readonly
|
|
56
|
+
private readonly mapperss: {
|
|
57
57
|
PlanDtoMapper: ResponseDtoMapperConstructor<
|
|
58
58
|
SchemaValidator,
|
|
59
59
|
Dto['PlanDtoMapper'],
|
|
@@ -71,10 +71,7 @@ export class BasePlanService<
|
|
|
71
71
|
>;
|
|
72
72
|
}
|
|
73
73
|
) {
|
|
74
|
-
this.#
|
|
75
|
-
dtoMappers,
|
|
76
|
-
schemaValidator
|
|
77
|
-
);
|
|
74
|
+
this.#mapperss = transformIntoInternalDtoMapper(mapperss, schemaValidator);
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
async listPlans(
|
|
@@ -86,7 +83,7 @@ export class BasePlanService<
|
|
|
86
83
|
filters: idsDto?.ids ? { id: { $in: idsDto.ids } } : undefined
|
|
87
84
|
})
|
|
88
85
|
).map((plan) =>
|
|
89
|
-
this.#
|
|
86
|
+
this.#mapperss.PlanDtoMapper.serializeEntityToDto(
|
|
90
87
|
plan as Entities['PlanDtoMapper']
|
|
91
88
|
)
|
|
92
89
|
);
|
|
@@ -97,11 +94,11 @@ export class BasePlanService<
|
|
|
97
94
|
em?: EntityManager
|
|
98
95
|
): Promise<Dto['PlanDtoMapper']> {
|
|
99
96
|
const plan =
|
|
100
|
-
this.#
|
|
97
|
+
this.#mapperss.CreatePlanDtoMapper.deserializeDtoToEntity(planDto);
|
|
101
98
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
102
99
|
await innerEm.persist(plan);
|
|
103
100
|
});
|
|
104
|
-
return this.#
|
|
101
|
+
return this.#mapperss.PlanDtoMapper.serializeEntityToDto(plan);
|
|
105
102
|
}
|
|
106
103
|
|
|
107
104
|
async getPlan(
|
|
@@ -109,7 +106,7 @@ export class BasePlanService<
|
|
|
109
106
|
em?: EntityManager
|
|
110
107
|
): Promise<Dto['PlanDtoMapper']> {
|
|
111
108
|
const plan = await (em ?? this.em).findOneOrFail('Plan', idDto);
|
|
112
|
-
return this.#
|
|
109
|
+
return this.#mapperss.PlanDtoMapper.serializeEntityToDto(
|
|
113
110
|
plan as Entities['PlanDtoMapper']
|
|
114
111
|
);
|
|
115
112
|
}
|
|
@@ -119,13 +116,13 @@ export class BasePlanService<
|
|
|
119
116
|
em?: EntityManager
|
|
120
117
|
): Promise<Dto['PlanDtoMapper']> {
|
|
121
118
|
const plan =
|
|
122
|
-
this.#
|
|
119
|
+
this.#mapperss.UpdatePlanDtoMapper.deserializeDtoToEntity(planDto);
|
|
123
120
|
const updatedPlan = await (em ?? this.em).upsert(plan);
|
|
124
121
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
125
122
|
await innerEm.persist(plan);
|
|
126
123
|
});
|
|
127
124
|
const updatedPlanDto =
|
|
128
|
-
this.#
|
|
125
|
+
this.#mapperss.PlanDtoMapper.serializeEntityToDto(updatedPlan);
|
|
129
126
|
return updatedPlanDto;
|
|
130
127
|
}
|
|
131
128
|
|