@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.
Files changed (74) hide show
  1. package/lib/__test__/schemaEquality.test.js +44 -20
  2. package/lib/eject/{schemas → domain/schemas}/billingPortal.schema.ts +7 -5
  3. package/lib/eject/{schemas → domain/schemas}/checkoutSession.schema.ts +7 -5
  4. package/lib/eject/{schemas → domain/schemas}/paymentLink.schema.ts +7 -5
  5. package/lib/eject/{schemas → domain/schemas}/plan.schema.ts +5 -5
  6. package/lib/eject/{schemas → domain/schemas}/subscription.schema.ts +7 -5
  7. package/lib/eject/services/billingPortal.service.ts +10 -13
  8. package/lib/eject/services/checkoutSession.service.ts +8 -11
  9. package/lib/eject/services/paymentLink.service.ts +11 -14
  10. package/lib/eject/services/plan.service.ts +11 -14
  11. package/lib/eject/services/subscription.service.ts +15 -15
  12. package/lib/schemas/billingPortal.schema.d.ts +10 -2
  13. package/lib/schemas/billingPortal.schema.d.ts.map +1 -1
  14. package/lib/schemas/billingPortal.schema.js +3 -3
  15. package/lib/schemas/checkoutSession.schema.d.ts +10 -2
  16. package/lib/schemas/checkoutSession.schema.d.ts.map +1 -1
  17. package/lib/schemas/checkoutSession.schema.js +3 -3
  18. package/lib/schemas/paymentLink.schema.d.ts +10 -2
  19. package/lib/schemas/paymentLink.schema.d.ts.map +1 -1
  20. package/lib/schemas/paymentLink.schema.js +3 -3
  21. package/lib/schemas/plan.schema.d.ts +10 -2
  22. package/lib/schemas/plan.schema.d.ts.map +1 -1
  23. package/lib/schemas/plan.schema.js +3 -3
  24. package/lib/schemas/subscription.schema.d.ts +10 -2
  25. package/lib/schemas/subscription.schema.d.ts.map +1 -1
  26. package/lib/schemas/subscription.schema.js +3 -3
  27. package/lib/schemas/typebox/billingPortal.schema.d.ts +9 -3
  28. package/lib/schemas/typebox/billingPortal.schema.d.ts.map +1 -1
  29. package/lib/schemas/typebox/billingPortal.schema.js +5 -5
  30. package/lib/schemas/typebox/checkoutSession.schema.d.ts +9 -3
  31. package/lib/schemas/typebox/checkoutSession.schema.d.ts.map +1 -1
  32. package/lib/schemas/typebox/checkoutSession.schema.js +5 -5
  33. package/lib/schemas/typebox/paymentLink.schema.d.ts +9 -3
  34. package/lib/schemas/typebox/paymentLink.schema.d.ts.map +1 -1
  35. package/lib/schemas/typebox/paymentLink.schema.js +5 -5
  36. package/lib/schemas/typebox/plan.schema.d.ts +9 -3
  37. package/lib/schemas/typebox/plan.schema.d.ts.map +1 -1
  38. package/lib/schemas/typebox/plan.schema.js +5 -5
  39. package/lib/schemas/typebox/subscription.schema.d.ts +9 -3
  40. package/lib/schemas/typebox/subscription.schema.d.ts.map +1 -1
  41. package/lib/schemas/typebox/subscription.schema.js +5 -5
  42. package/lib/schemas/zod/billingPortal.schema.d.ts +9 -3
  43. package/lib/schemas/zod/billingPortal.schema.d.ts.map +1 -1
  44. package/lib/schemas/zod/billingPortal.schema.js +5 -5
  45. package/lib/schemas/zod/checkoutSession.schema.d.ts +9 -3
  46. package/lib/schemas/zod/checkoutSession.schema.d.ts.map +1 -1
  47. package/lib/schemas/zod/checkoutSession.schema.js +5 -5
  48. package/lib/schemas/zod/paymentLink.schema.d.ts +9 -3
  49. package/lib/schemas/zod/paymentLink.schema.d.ts.map +1 -1
  50. package/lib/schemas/zod/paymentLink.schema.js +5 -5
  51. package/lib/schemas/zod/plan.schema.d.ts +9 -3
  52. package/lib/schemas/zod/plan.schema.d.ts.map +1 -1
  53. package/lib/schemas/zod/plan.schema.js +5 -5
  54. package/lib/schemas/zod/subscription.schema.d.ts +9 -3
  55. package/lib/schemas/zod/subscription.schema.d.ts.map +1 -1
  56. package/lib/schemas/zod/subscription.schema.js +5 -5
  57. package/lib/services/billingPortal.service.d.ts +3 -3
  58. package/lib/services/billingPortal.service.d.ts.map +1 -1
  59. package/lib/services/billingPortal.service.js +11 -11
  60. package/lib/services/checkoutSession.service.d.ts +3 -3
  61. package/lib/services/checkoutSession.service.d.ts.map +1 -1
  62. package/lib/services/checkoutSession.service.js +9 -9
  63. package/lib/services/paymentLink.service.d.ts +3 -3
  64. package/lib/services/paymentLink.service.d.ts.map +1 -1
  65. package/lib/services/paymentLink.service.js +12 -12
  66. package/lib/services/plan.service.d.ts +3 -3
  67. package/lib/services/plan.service.d.ts.map +1 -1
  68. package/lib/services/plan.service.js +12 -12
  69. package/lib/services/subscription.service.d.ts +3 -3
  70. package/lib/services/subscription.service.d.ts.map +1 -1
  71. package/lib/services/subscription.service.js +14 -14
  72. package/lib/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +10 -8
  74. /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(false);
14
- const typeboxUpdateBillingPortalSchema = TypeboxUpdateBillingPortalSchema(false);
15
- const zodBillingPortalSchema = ZodBillingPortalSchema(false);
16
- const typeboxBillingPortalSchema = TypeboxBillingPortalSchema(false);
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(false)(DummyEnum);
20
- const typeboxUpdateCheckoutSessionSchema = TypeboxUpdateCheckoutSessionSchema(false)(DummyEnum);
21
- const zodCheckoutSessionSchema = ZodCheckoutSessionSchema(false)(DummyEnum);
22
- const typeboxCheckoutSessionSchema = TypeboxCheckoutSessionSchema(false)(DummyEnum);
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(false)(DummyEnum);
26
- const typeboxUpdatePaymentLinkSchema = TypeboxUpdatePaymentLinkSchema(false)(DummyEnum);
27
- const zodPaymentLinkSchema = ZodPaymentLinkSchema(false)(DummyEnum);
28
- const typeboxPaymentLinkSchema = TypeboxPaymentLinkSchema(false)(DummyEnum);
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(false)(DummyEnum, DummyEnum);
34
- const typeboxPlanSchema = TypeboxPlanSchema(false)(DummyEnum, DummyEnum);
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(false)(DummyEnum, DummyEnum);
38
- const typeboxUpdateSubscriptionSchema = TypeboxUpdateSubscriptionSchema(false)(DummyEnum, DummyEnum);
39
- const zodSubscriptionSchema = ZodSubscriptionSchema(false)(DummyEnum, DummyEnum);
40
- const typeboxSubscriptionSchema = TypeboxSubscriptionSchema(false)(DummyEnum, DummyEnum);
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 BaseBillingPortalSchemas = (uuidId: boolean) => ({
31
+ export const BaseBillingPortalServiceSchemas = (options: {
32
+ uuidId: boolean;
33
+ }) => ({
32
34
  CreateBillingPortalSchema,
33
- UpdateBillingPortalSchema: UpdateBillingPortalSchema(uuidId),
34
- BillingPortalSchema: BillingPortalSchema(uuidId)
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 BaseCheckoutSessionSchemas = (uuidId: boolean) => ({
48
+ export const BaseCheckoutSessionServiceSchemas = (options: {
49
+ uuidId: boolean;
50
+ }) => ({
49
51
  CreateCheckoutSessionSchema,
50
- UpdateCheckoutSessionSchema: UpdateCheckoutSessionSchema(uuidId),
51
- CheckoutSessionSchema: CheckoutSessionSchema(uuidId)
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 BasePaymentLinkSchemas = (uuidId: boolean) => ({
54
+ export const BasePaymentLinkServiceSchemas = (options: {
55
+ uuidId: boolean;
56
+ }) => ({
55
57
  CreatePaymentLinkSchema,
56
- UpdatePaymentLinkSchema: UpdatePaymentLinkSchema(uuidId),
57
- PaymentLinkSchema: PaymentLinkSchema(uuidId)
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 BasePlanSchemas = (uuidId: boolean) => ({
76
+ export const BasePlanServiceSchemas = (options: { uuidId: boolean }) => ({
77
77
  CreatePlanSchema,
78
- UpdatePlanSchema: UpdatePlanSchema(uuidId),
79
- PlanSchema: PlanSchema(uuidId)
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 BaseSubscriptionSchemas = (uuidId: boolean) => ({
80
+ export const BaseSubscriptionServiceSchemas = (options: {
81
+ uuidId: boolean;
82
+ }) => ({
81
83
  CreateSubscriptionSchema,
82
- UpdateSubscriptionSchema: UpdateSubscriptionSchema(uuidId),
83
- SubscriptionSchema: SubscriptionSchema(uuidId)
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/dtoMapper';
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
- #dtoMappers: InternalDtoMapper<
45
- InstanceTypeRecord<typeof this.dtoMappers>,
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 dtoMappers: {
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.#dtoMappers = transformIntoInternalDtoMapper(
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.#dtoMappers.CreateBillingPortalDtoMapper.deserializeDtoToEntity(
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.#dtoMappers.BillingPortalDtoMapper.serializeEntityToDto(
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.#dtoMappers.BillingPortalDtoMapper.serializeEntityToDto(
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.#dtoMappers.UpdateBillingPortalDtoMapper.deserializeDtoToEntity(
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.#dtoMappers.BillingPortalDtoMapper.serializeEntityToDto(
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/dtoMapper';
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
- #dtoMappers: InternalDtoMapper<
46
- InstanceTypeRecord<typeof this.dtoMappers>,
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 dtoMappers: {
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.#dtoMappers = transformIntoInternalDtoMapper(
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.#dtoMappers.CreateCheckoutSessionDtoMapper.deserializeDtoToEntity(
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.#dtoMappers.CheckoutSessionDtoMapper.serializeEntityToDto(
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.#dtoMappers.CheckoutSessionDtoMapper.serializeEntityToDto(
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/dtoMapper';
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
- #dtoMappers: InternalDtoMapper<
46
- InstanceTypeRecord<typeof this.dtoMappers>,
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 dtoMappers: {
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.#dtoMappers = transformIntoInternalDtoMapper(
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.#dtoMappers.CreatePaymentLinkDtoMapper.deserializeDtoToEntity(
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.#dtoMappers.PaymentLinkDtoMapper.serializeEntityToDto(
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.#dtoMappers.UpdatePaymentLinkDtoMapper.deserializeDtoToEntity(
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.#dtoMappers.PaymentLinkDtoMapper.serializeEntityToDto(
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.#dtoMappers.PaymentLinkDtoMapper.serializeEntityToDto(
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.#dtoMappers.PaymentLinkDtoMapper.serializeEntityToDto(
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/dtoMapper';
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
- #dtoMappers: InternalDtoMapper<
47
- InstanceTypeRecord<typeof this.dtoMappers>,
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 dtoMappers: {
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.#dtoMappers = transformIntoInternalDtoMapper(
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.#dtoMappers.PlanDtoMapper.serializeEntityToDto(
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.#dtoMappers.CreatePlanDtoMapper.deserializeDtoToEntity(planDto);
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.#dtoMappers.PlanDtoMapper.serializeEntityToDto(plan);
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.#dtoMappers.PlanDtoMapper.serializeEntityToDto(
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.#dtoMappers.UpdatePlanDtoMapper.deserializeDtoToEntity(planDto);
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.#dtoMappers.PlanDtoMapper.serializeEntityToDto(updatedPlan);
125
+ this.#mapperss.PlanDtoMapper.serializeEntityToDto(updatedPlan);
129
126
  return updatedPlanDto;
130
127
  }
131
128