@forklaunch/implementation-billing-base 0.4.0 → 0.5.1

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.
@@ -32,13 +32,42 @@ export class BaseBillingPortalService<
32
32
  tracing?: boolean;
33
33
  };
34
34
  protected enableDatabaseBackup: boolean;
35
+ protected em: EntityManager;
36
+ protected cache: TtlCache;
37
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
38
+ protected schemaValidator: SchemaValidator;
39
+ protected mappers: {
40
+ BillingPortalMapper: ResponseMapperConstructor<
41
+ SchemaValidator,
42
+ Dto['BillingPortalMapper'],
43
+ Entities['BillingPortalMapper']
44
+ >;
45
+ CreateBillingPortalMapper: RequestMapperConstructor<
46
+ SchemaValidator,
47
+ Dto['CreateBillingPortalMapper'],
48
+ Entities['CreateBillingPortalMapper'],
49
+ (
50
+ dto: Dto['CreateBillingPortalMapper'],
51
+ em: EntityManager
52
+ ) => Promise<Entities['CreateBillingPortalMapper']>
53
+ >;
54
+ UpdateBillingPortalMapper: RequestMapperConstructor<
55
+ SchemaValidator,
56
+ Dto['UpdateBillingPortalMapper'],
57
+ Entities['UpdateBillingPortalMapper'],
58
+ (
59
+ dto: Dto['UpdateBillingPortalMapper'],
60
+ em: EntityManager
61
+ ) => Promise<Entities['UpdateBillingPortalMapper']>
62
+ >;
63
+ };
35
64
 
36
65
  constructor(
37
- protected em: EntityManager,
38
- protected cache: TtlCache,
39
- protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
40
- protected schemaValidator: SchemaValidator,
41
- protected mappers: {
66
+ em: EntityManager,
67
+ cache: TtlCache,
68
+ openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
69
+ schemaValidator: SchemaValidator,
70
+ mappers: {
42
71
  BillingPortalMapper: ResponseMapperConstructor<
43
72
  SchemaValidator,
44
73
  Dto['BillingPortalMapper'],
@@ -68,6 +97,11 @@ export class BaseBillingPortalService<
68
97
  enableDatabaseBackup?: boolean;
69
98
  }
70
99
  ) {
100
+ this.em = em;
101
+ this.cache = cache;
102
+ this.openTelemetryCollector = openTelemetryCollector;
103
+ this.schemaValidator = schemaValidator;
104
+ this.mappers = mappers;
71
105
  this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
72
106
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
73
107
  this.evaluatedTelemetryOptions = options?.telemetry
@@ -42,13 +42,42 @@ export class BaseCheckoutSessionService<
42
42
  tracing?: boolean;
43
43
  };
44
44
  protected enableDatabaseBackup: boolean;
45
+ protected readonly em: EntityManager;
46
+ protected readonly cache: TtlCache;
47
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
48
+ protected readonly schemaValidator: SchemaValidator;
49
+ protected readonly mappers: {
50
+ CheckoutSessionMapper: ResponseMapperConstructor<
51
+ SchemaValidator,
52
+ Dto['CheckoutSessionMapper'],
53
+ Entities['CheckoutSessionMapper']
54
+ >;
55
+ CreateCheckoutSessionMapper: RequestMapperConstructor<
56
+ SchemaValidator,
57
+ Dto['CreateCheckoutSessionMapper'],
58
+ Entities['CreateCheckoutSessionMapper'],
59
+ (
60
+ dto: Dto['CreateCheckoutSessionMapper'],
61
+ em: EntityManager
62
+ ) => Promise<Entities['CreateCheckoutSessionMapper']>
63
+ >;
64
+ UpdateCheckoutSessionMapper: RequestMapperConstructor<
65
+ SchemaValidator,
66
+ Dto['UpdateCheckoutSessionMapper'],
67
+ Entities['UpdateCheckoutSessionMapper'],
68
+ (
69
+ dto: Dto['UpdateCheckoutSessionMapper'],
70
+ em: EntityManager
71
+ ) => Promise<Entities['UpdateCheckoutSessionMapper']>
72
+ >;
73
+ };
45
74
 
46
75
  constructor(
47
- protected readonly em: EntityManager,
48
- protected readonly cache: TtlCache,
49
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
50
- protected readonly schemaValidator: SchemaValidator,
51
- protected readonly mappers: {
76
+ em: EntityManager,
77
+ cache: TtlCache,
78
+ openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
79
+ schemaValidator: SchemaValidator,
80
+ mappers: {
52
81
  CheckoutSessionMapper: ResponseMapperConstructor<
53
82
  SchemaValidator,
54
83
  Dto['CheckoutSessionMapper'],
@@ -78,6 +107,11 @@ export class BaseCheckoutSessionService<
78
107
  telemetry?: TelemetryOptions;
79
108
  }
80
109
  ) {
110
+ this.em = em;
111
+ this.cache = cache;
112
+ this.openTelemetryCollector = openTelemetryCollector;
113
+ this.schemaValidator = schemaValidator;
114
+ this.mappers = mappers;
81
115
  this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
82
116
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
83
117
  this.evaluatedTelemetryOptions = options?.telemetry
@@ -42,13 +42,42 @@ export class BasePaymentLinkService<
42
42
  tracing?: boolean;
43
43
  };
44
44
  protected enableDatabaseBackup: boolean;
45
+ protected readonly em: EntityManager;
46
+ protected readonly cache: TtlCache;
47
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
48
+ protected readonly schemaValidator: SchemaValidator;
49
+ protected readonly mappers: {
50
+ PaymentLinkMapper: ResponseMapperConstructor<
51
+ SchemaValidator,
52
+ Dto['PaymentLinkMapper'],
53
+ Entities['PaymentLinkMapper']
54
+ >;
55
+ CreatePaymentLinkMapper: RequestMapperConstructor<
56
+ SchemaValidator,
57
+ Dto['CreatePaymentLinkMapper'],
58
+ Entities['CreatePaymentLinkMapper'],
59
+ (
60
+ dto: Dto['CreatePaymentLinkMapper'],
61
+ em: EntityManager
62
+ ) => Promise<Entities['CreatePaymentLinkMapper']>
63
+ >;
64
+ UpdatePaymentLinkMapper: RequestMapperConstructor<
65
+ SchemaValidator,
66
+ Dto['UpdatePaymentLinkMapper'],
67
+ Entities['UpdatePaymentLinkMapper'],
68
+ (
69
+ dto: Dto['UpdatePaymentLinkMapper'],
70
+ em: EntityManager
71
+ ) => Promise<Entities['UpdatePaymentLinkMapper']>
72
+ >;
73
+ };
45
74
 
46
75
  constructor(
47
- protected readonly em: EntityManager,
48
- protected readonly cache: TtlCache,
49
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
50
- protected readonly schemaValidator: SchemaValidator,
51
- protected readonly mappers: {
76
+ em: EntityManager,
77
+ cache: TtlCache,
78
+ openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
79
+ schemaValidator: SchemaValidator,
80
+ mappers: {
52
81
  PaymentLinkMapper: ResponseMapperConstructor<
53
82
  SchemaValidator,
54
83
  Dto['PaymentLinkMapper'],
@@ -78,6 +107,11 @@ export class BasePaymentLinkService<
78
107
  telemetry?: TelemetryOptions;
79
108
  }
80
109
  ) {
110
+ this.em = em;
111
+ this.cache = cache;
112
+ this.openTelemetryCollector = openTelemetryCollector;
113
+ this.schemaValidator = schemaValidator;
114
+ this.mappers = mappers;
81
115
  this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
82
116
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
83
117
  this.evaluatedTelemetryOptions = options?.telemetry
@@ -40,12 +40,40 @@ export class BasePlanService<
40
40
  metrics?: boolean;
41
41
  tracing?: boolean;
42
42
  };
43
+ protected em: EntityManager;
44
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
45
+ protected readonly schemaValidator: SchemaValidator;
46
+ protected readonly mappers: {
47
+ PlanMapper: ResponseMapperConstructor<
48
+ SchemaValidator,
49
+ Dto['PlanMapper'],
50
+ Entities['PlanMapper']
51
+ >;
52
+ CreatePlanMapper: RequestMapperConstructor<
53
+ SchemaValidator,
54
+ Dto['CreatePlanMapper'],
55
+ Entities['CreatePlanMapper'],
56
+ (
57
+ dto: Dto['CreatePlanMapper'],
58
+ em: EntityManager
59
+ ) => Promise<Entities['CreatePlanMapper']>
60
+ >;
61
+ UpdatePlanMapper: RequestMapperConstructor<
62
+ SchemaValidator,
63
+ Dto['UpdatePlanMapper'],
64
+ Entities['UpdatePlanMapper'],
65
+ (
66
+ dto: Dto['UpdatePlanMapper'],
67
+ em: EntityManager
68
+ ) => Promise<Entities['UpdatePlanMapper']>
69
+ >;
70
+ };
43
71
 
44
72
  constructor(
45
- protected em: EntityManager,
46
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
47
- protected readonly schemaValidator: SchemaValidator,
48
- protected readonly mappers: {
73
+ em: EntityManager,
74
+ openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
75
+ schemaValidator: SchemaValidator,
76
+ mappers: {
49
77
  PlanMapper: ResponseMapperConstructor<
50
78
  SchemaValidator,
51
79
  Dto['PlanMapper'],
@@ -74,6 +102,10 @@ export class BasePlanService<
74
102
  telemetry?: TelemetryOptions;
75
103
  }
76
104
  ) {
105
+ this.em = em;
106
+ this.openTelemetryCollector = openTelemetryCollector;
107
+ this.schemaValidator = schemaValidator;
108
+ this.mappers = mappers;
77
109
  this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
78
110
  this.evaluatedTelemetryOptions = options?.telemetry
79
111
  ? evaluateTelemetryOptions(options.telemetry).enabled
@@ -34,12 +34,40 @@ export class BaseSubscriptionService<
34
34
  metrics?: boolean;
35
35
  tracing?: boolean;
36
36
  };
37
+ protected em: EntityManager;
38
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
39
+ protected readonly schemaValidator: SchemaValidator;
40
+ protected readonly mappers: {
41
+ SubscriptionMapper: ResponseMapperConstructor<
42
+ SchemaValidator,
43
+ Dto['SubscriptionMapper'],
44
+ Entities['SubscriptionMapper']
45
+ >;
46
+ CreateSubscriptionMapper: RequestMapperConstructor<
47
+ SchemaValidator,
48
+ Dto['CreateSubscriptionMapper'],
49
+ Entities['CreateSubscriptionMapper'],
50
+ (
51
+ dto: Dto['CreateSubscriptionMapper'],
52
+ em: EntityManager
53
+ ) => Promise<Entities['CreateSubscriptionMapper']>
54
+ >;
55
+ UpdateSubscriptionMapper: RequestMapperConstructor<
56
+ SchemaValidator,
57
+ Dto['UpdateSubscriptionMapper'],
58
+ Entities['UpdateSubscriptionMapper'],
59
+ (
60
+ dto: Dto['UpdateSubscriptionMapper'],
61
+ em: EntityManager
62
+ ) => Promise<Entities['UpdateSubscriptionMapper']>
63
+ >;
64
+ };
37
65
 
38
66
  constructor(
39
- protected em: EntityManager,
40
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
41
- protected readonly schemaValidator: SchemaValidator,
42
- protected readonly mappers: {
67
+ em: EntityManager,
68
+ openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
69
+ schemaValidator: SchemaValidator,
70
+ mappers: {
43
71
  SubscriptionMapper: ResponseMapperConstructor<
44
72
  SchemaValidator,
45
73
  Dto['SubscriptionMapper'],
@@ -68,6 +96,10 @@ export class BaseSubscriptionService<
68
96
  telemetry?: TelemetryOptions;
69
97
  }
70
98
  ) {
99
+ this.em = em;
100
+ this.openTelemetryCollector = openTelemetryCollector;
101
+ this.schemaValidator = schemaValidator;
102
+ this.mappers = mappers;
71
103
  this._mappers = transformIntoInternalMapper(mappers, this.schemaValidator);
72
104
  this.evaluatedTelemetryOptions = options?.telemetry
73
105
  ? evaluateTelemetryOptions(options.telemetry).enabled
@@ -1,9 +1,9 @@
1
1
  import { InstanceTypeRecord, IdDto, IdsDto } from '@forklaunch/common';
2
2
  import { TtlCache } from '@forklaunch/core/cache';
3
- import { OpenTelemetryCollector, MetricsDefinition, TelemetryOptions } from '@forklaunch/core/http';
3
+ import { TelemetryOptions, OpenTelemetryCollector, MetricsDefinition } from '@forklaunch/core/http';
4
4
  import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService } from '@forklaunch/interfaces-billing/interfaces';
5
5
  import { BillingPortalDto, CreateBillingPortalDto, UpdateBillingPortalDto, CheckoutSessionDto, CreateCheckoutSessionDto, UpdateCheckoutSessionDto, PaymentLinkDto, CreatePaymentLinkDto, UpdatePaymentLinkDto, PlanDto, CreatePlanDto, UpdatePlanDto, SubscriptionDto, CreateSubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
6
- import { ResponseMapperConstructor, RequestMapperConstructor, InternalMapper } from '@forklaunch/internal';
6
+ import { InternalMapper, ResponseMapperConstructor, RequestMapperConstructor } from '@forklaunch/internal';
7
7
  import { AnySchemaValidator } from '@forklaunch/validator';
8
8
  import { EntityManager } from '@mikro-orm/core';
9
9
 
@@ -60,15 +60,6 @@ type BaseSubscriptionEntities<PartyType, BillingProviderType> = {
60
60
  };
61
61
 
62
62
  declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidator, Entities extends BaseBillingEntities, Dto extends BaseBillingDtos = BaseBillingDtos> implements BillingPortalService {
63
- protected em: EntityManager;
64
- protected cache: TtlCache;
65
- protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
66
- protected schemaValidator: SchemaValidator;
67
- protected mappers: {
68
- BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
69
- CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
70
- UpdateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalMapper'], Entities['UpdateBillingPortalMapper'], (dto: Dto['UpdateBillingPortalMapper'], em: EntityManager) => Promise<Entities['UpdateBillingPortalMapper']>>;
71
- };
72
63
  readonly options?: {
73
64
  telemetry?: TelemetryOptions;
74
65
  enableDatabaseBackup?: boolean;
@@ -80,6 +71,15 @@ declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidato
80
71
  tracing?: boolean;
81
72
  };
82
73
  protected enableDatabaseBackup: boolean;
74
+ protected em: EntityManager;
75
+ protected cache: TtlCache;
76
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
77
+ protected schemaValidator: SchemaValidator;
78
+ protected mappers: {
79
+ BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
80
+ CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
81
+ UpdateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalMapper'], Entities['UpdateBillingPortalMapper'], (dto: Dto['UpdateBillingPortalMapper'], em: EntityManager) => Promise<Entities['UpdateBillingPortalMapper']>>;
82
+ };
83
83
  constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
84
84
  BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
85
85
  CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
@@ -96,15 +96,6 @@ declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidato
96
96
  }
97
97
 
98
98
  declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities extends BaseCheckoutSessionEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, Dto extends BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
99
- protected readonly em: EntityManager;
100
- protected readonly cache: TtlCache;
101
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
102
- protected readonly schemaValidator: SchemaValidator;
103
- protected readonly mappers: {
104
- CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
105
- CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
106
- UpdateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionMapper'], Entities['UpdateCheckoutSessionMapper'], (dto: Dto['UpdateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['UpdateCheckoutSessionMapper']>>;
107
- };
108
99
  readonly options?: {
109
100
  enableDatabaseBackup?: boolean;
110
101
  telemetry?: TelemetryOptions;
@@ -116,6 +107,15 @@ declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValida
116
107
  tracing?: boolean;
117
108
  };
118
109
  protected enableDatabaseBackup: boolean;
110
+ protected readonly em: EntityManager;
111
+ protected readonly cache: TtlCache;
112
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
113
+ protected readonly schemaValidator: SchemaValidator;
114
+ protected readonly mappers: {
115
+ CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
116
+ CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
117
+ UpdateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionMapper'], Entities['UpdateCheckoutSessionMapper'], (dto: Dto['UpdateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['UpdateCheckoutSessionMapper']>>;
118
+ };
119
119
  constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
120
120
  CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
121
121
  CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
@@ -133,15 +133,6 @@ declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValida
133
133
  }
134
134
 
135
135
  declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities extends BasePaymentLinkEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, Dto extends BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
136
- protected readonly em: EntityManager;
137
- protected readonly cache: TtlCache;
138
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
139
- protected readonly schemaValidator: SchemaValidator;
140
- protected readonly mappers: {
141
- PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
142
- CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
143
- UpdatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkMapper'], Entities['UpdatePaymentLinkMapper'], (dto: Dto['UpdatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['UpdatePaymentLinkMapper']>>;
144
- };
145
136
  readonly options?: {
146
137
  enableDatabaseBackup?: boolean;
147
138
  telemetry?: TelemetryOptions;
@@ -153,6 +144,15 @@ declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator,
153
144
  tracing?: boolean;
154
145
  };
155
146
  protected enableDatabaseBackup: boolean;
147
+ protected readonly em: EntityManager;
148
+ protected readonly cache: TtlCache;
149
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
150
+ protected readonly schemaValidator: SchemaValidator;
151
+ protected readonly mappers: {
152
+ PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
153
+ CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
154
+ UpdatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkMapper'], Entities['UpdatePaymentLinkMapper'], (dto: Dto['UpdatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['UpdatePaymentLinkMapper']>>;
155
+ };
156
156
  constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
157
157
  PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
158
158
  CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
@@ -173,14 +173,6 @@ declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator,
173
173
  }
174
174
 
175
175
  declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, Entities extends BasePlanEntities<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>, Dto extends BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> implements PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> {
176
- protected em: EntityManager;
177
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
178
- protected readonly schemaValidator: SchemaValidator;
179
- protected readonly mappers: {
180
- PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
181
- CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
182
- UpdatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePlanMapper'], Entities['UpdatePlanMapper'], (dto: Dto['UpdatePlanMapper'], em: EntityManager) => Promise<Entities['UpdatePlanMapper']>>;
183
- };
184
176
  readonly options?: {
185
177
  telemetry?: TelemetryOptions;
186
178
  } | undefined;
@@ -190,6 +182,14 @@ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCa
190
182
  metrics?: boolean;
191
183
  tracing?: boolean;
192
184
  };
185
+ protected em: EntityManager;
186
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
187
+ protected readonly schemaValidator: SchemaValidator;
188
+ protected readonly mappers: {
189
+ PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
190
+ CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
191
+ UpdatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePlanMapper'], Entities['UpdatePlanMapper'], (dto: Dto['UpdatePlanMapper'], em: EntityManager) => Promise<Entities['UpdatePlanMapper']>>;
192
+ };
193
193
  constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
194
194
  PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
195
195
  CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
@@ -207,14 +207,6 @@ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCa
207
207
  }
208
208
 
209
209
  declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator, PartyType, BillingProviderType, Entities extends BaseSubscriptionEntities<PartyType, BillingProviderType>, Dto extends BaseSubscriptionDtos<PartyType, BillingProviderType> = BaseSubscriptionDtos<PartyType, BillingProviderType>> implements SubscriptionService<PartyType, BillingProviderType> {
210
- protected em: EntityManager;
211
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
212
- protected readonly schemaValidator: SchemaValidator;
213
- protected readonly mappers: {
214
- SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
215
- CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
216
- UpdateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionMapper'], Entities['UpdateSubscriptionMapper'], (dto: Dto['UpdateSubscriptionMapper'], em: EntityManager) => Promise<Entities['UpdateSubscriptionMapper']>>;
217
- };
218
210
  readonly options?: {
219
211
  telemetry?: TelemetryOptions;
220
212
  } | undefined;
@@ -224,6 +216,14 @@ declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator
224
216
  metrics?: boolean;
225
217
  tracing?: boolean;
226
218
  };
219
+ protected em: EntityManager;
220
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
221
+ protected readonly schemaValidator: SchemaValidator;
222
+ protected readonly mappers: {
223
+ SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
224
+ CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
225
+ UpdateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionMapper'], Entities['UpdateSubscriptionMapper'], (dto: Dto['UpdateSubscriptionMapper'], em: EntityManager) => Promise<Entities['UpdateSubscriptionMapper']>>;
226
+ };
227
227
  constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
228
228
  SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
229
229
  CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
@@ -1,9 +1,9 @@
1
1
  import { InstanceTypeRecord, IdDto, IdsDto } from '@forklaunch/common';
2
2
  import { TtlCache } from '@forklaunch/core/cache';
3
- import { OpenTelemetryCollector, MetricsDefinition, TelemetryOptions } from '@forklaunch/core/http';
3
+ import { TelemetryOptions, OpenTelemetryCollector, MetricsDefinition } from '@forklaunch/core/http';
4
4
  import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService } from '@forklaunch/interfaces-billing/interfaces';
5
5
  import { BillingPortalDto, CreateBillingPortalDto, UpdateBillingPortalDto, CheckoutSessionDto, CreateCheckoutSessionDto, UpdateCheckoutSessionDto, PaymentLinkDto, CreatePaymentLinkDto, UpdatePaymentLinkDto, PlanDto, CreatePlanDto, UpdatePlanDto, SubscriptionDto, CreateSubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
6
- import { ResponseMapperConstructor, RequestMapperConstructor, InternalMapper } from '@forklaunch/internal';
6
+ import { InternalMapper, ResponseMapperConstructor, RequestMapperConstructor } from '@forklaunch/internal';
7
7
  import { AnySchemaValidator } from '@forklaunch/validator';
8
8
  import { EntityManager } from '@mikro-orm/core';
9
9
 
@@ -60,15 +60,6 @@ type BaseSubscriptionEntities<PartyType, BillingProviderType> = {
60
60
  };
61
61
 
62
62
  declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidator, Entities extends BaseBillingEntities, Dto extends BaseBillingDtos = BaseBillingDtos> implements BillingPortalService {
63
- protected em: EntityManager;
64
- protected cache: TtlCache;
65
- protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
66
- protected schemaValidator: SchemaValidator;
67
- protected mappers: {
68
- BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
69
- CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
70
- UpdateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalMapper'], Entities['UpdateBillingPortalMapper'], (dto: Dto['UpdateBillingPortalMapper'], em: EntityManager) => Promise<Entities['UpdateBillingPortalMapper']>>;
71
- };
72
63
  readonly options?: {
73
64
  telemetry?: TelemetryOptions;
74
65
  enableDatabaseBackup?: boolean;
@@ -80,6 +71,15 @@ declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidato
80
71
  tracing?: boolean;
81
72
  };
82
73
  protected enableDatabaseBackup: boolean;
74
+ protected em: EntityManager;
75
+ protected cache: TtlCache;
76
+ protected openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
77
+ protected schemaValidator: SchemaValidator;
78
+ protected mappers: {
79
+ BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
80
+ CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
81
+ UpdateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateBillingPortalMapper'], Entities['UpdateBillingPortalMapper'], (dto: Dto['UpdateBillingPortalMapper'], em: EntityManager) => Promise<Entities['UpdateBillingPortalMapper']>>;
82
+ };
83
83
  constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
84
84
  BillingPortalMapper: ResponseMapperConstructor<SchemaValidator, Dto['BillingPortalMapper'], Entities['BillingPortalMapper']>;
85
85
  CreateBillingPortalMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateBillingPortalMapper'], Entities['CreateBillingPortalMapper'], (dto: Dto['CreateBillingPortalMapper'], em: EntityManager) => Promise<Entities['CreateBillingPortalMapper']>>;
@@ -96,15 +96,6 @@ declare class BaseBillingPortalService<SchemaValidator extends AnySchemaValidato
96
96
  }
97
97
 
98
98
  declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities extends BaseCheckoutSessionEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, Dto extends BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BaseCheckoutSessionDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
99
- protected readonly em: EntityManager;
100
- protected readonly cache: TtlCache;
101
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
102
- protected readonly schemaValidator: SchemaValidator;
103
- protected readonly mappers: {
104
- CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
105
- CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
106
- UpdateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionMapper'], Entities['UpdateCheckoutSessionMapper'], (dto: Dto['UpdateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['UpdateCheckoutSessionMapper']>>;
107
- };
108
99
  readonly options?: {
109
100
  enableDatabaseBackup?: boolean;
110
101
  telemetry?: TelemetryOptions;
@@ -116,6 +107,15 @@ declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValida
116
107
  tracing?: boolean;
117
108
  };
118
109
  protected enableDatabaseBackup: boolean;
110
+ protected readonly em: EntityManager;
111
+ protected readonly cache: TtlCache;
112
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
113
+ protected readonly schemaValidator: SchemaValidator;
114
+ protected readonly mappers: {
115
+ CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
116
+ CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
117
+ UpdateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateCheckoutSessionMapper'], Entities['UpdateCheckoutSessionMapper'], (dto: Dto['UpdateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['UpdateCheckoutSessionMapper']>>;
118
+ };
119
119
  constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
120
120
  CheckoutSessionMapper: ResponseMapperConstructor<SchemaValidator, Dto['CheckoutSessionMapper'], Entities['CheckoutSessionMapper']>;
121
121
  CreateCheckoutSessionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateCheckoutSessionMapper'], Entities['CreateCheckoutSessionMapper'], (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager) => Promise<Entities['CreateCheckoutSessionMapper']>>;
@@ -133,15 +133,6 @@ declare class BaseCheckoutSessionService<SchemaValidator extends AnySchemaValida
133
133
  }
134
134
 
135
135
  declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities extends BasePaymentLinkEntities<PaymentMethodEnum, CurrencyEnum, StatusEnum>, Dto extends BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum> = BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> implements PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum> {
136
- protected readonly em: EntityManager;
137
- protected readonly cache: TtlCache;
138
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
139
- protected readonly schemaValidator: SchemaValidator;
140
- protected readonly mappers: {
141
- PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
142
- CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
143
- UpdatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkMapper'], Entities['UpdatePaymentLinkMapper'], (dto: Dto['UpdatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['UpdatePaymentLinkMapper']>>;
144
- };
145
136
  readonly options?: {
146
137
  enableDatabaseBackup?: boolean;
147
138
  telemetry?: TelemetryOptions;
@@ -153,6 +144,15 @@ declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator,
153
144
  tracing?: boolean;
154
145
  };
155
146
  protected enableDatabaseBackup: boolean;
147
+ protected readonly em: EntityManager;
148
+ protected readonly cache: TtlCache;
149
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
150
+ protected readonly schemaValidator: SchemaValidator;
151
+ protected readonly mappers: {
152
+ PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
153
+ CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
154
+ UpdatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePaymentLinkMapper'], Entities['UpdatePaymentLinkMapper'], (dto: Dto['UpdatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['UpdatePaymentLinkMapper']>>;
155
+ };
156
156
  constructor(em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
157
157
  PaymentLinkMapper: ResponseMapperConstructor<SchemaValidator, Dto['PaymentLinkMapper'], Entities['PaymentLinkMapper']>;
158
158
  CreatePaymentLinkMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePaymentLinkMapper'], Entities['CreatePaymentLinkMapper'], (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager) => Promise<Entities['CreatePaymentLinkMapper']>>;
@@ -173,14 +173,6 @@ declare class BasePaymentLinkService<SchemaValidator extends AnySchemaValidator,
173
173
  }
174
174
 
175
175
  declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, Entities extends BasePlanEntities<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>, Dto extends BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = BasePlanDtos<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> implements PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> {
176
- protected em: EntityManager;
177
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
178
- protected readonly schemaValidator: SchemaValidator;
179
- protected readonly mappers: {
180
- PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
181
- CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
182
- UpdatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePlanMapper'], Entities['UpdatePlanMapper'], (dto: Dto['UpdatePlanMapper'], em: EntityManager) => Promise<Entities['UpdatePlanMapper']>>;
183
- };
184
176
  readonly options?: {
185
177
  telemetry?: TelemetryOptions;
186
178
  } | undefined;
@@ -190,6 +182,14 @@ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCa
190
182
  metrics?: boolean;
191
183
  tracing?: boolean;
192
184
  };
185
+ protected em: EntityManager;
186
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
187
+ protected readonly schemaValidator: SchemaValidator;
188
+ protected readonly mappers: {
189
+ PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
190
+ CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
191
+ UpdatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdatePlanMapper'], Entities['UpdatePlanMapper'], (dto: Dto['UpdatePlanMapper'], em: EntityManager) => Promise<Entities['UpdatePlanMapper']>>;
192
+ };
193
193
  constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
194
194
  PlanMapper: ResponseMapperConstructor<SchemaValidator, Dto['PlanMapper'], Entities['PlanMapper']>;
195
195
  CreatePlanMapper: RequestMapperConstructor<SchemaValidator, Dto['CreatePlanMapper'], Entities['CreatePlanMapper'], (dto: Dto['CreatePlanMapper'], em: EntityManager) => Promise<Entities['CreatePlanMapper']>>;
@@ -207,14 +207,6 @@ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCa
207
207
  }
208
208
 
209
209
  declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator, PartyType, BillingProviderType, Entities extends BaseSubscriptionEntities<PartyType, BillingProviderType>, Dto extends BaseSubscriptionDtos<PartyType, BillingProviderType> = BaseSubscriptionDtos<PartyType, BillingProviderType>> implements SubscriptionService<PartyType, BillingProviderType> {
210
- protected em: EntityManager;
211
- protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
212
- protected readonly schemaValidator: SchemaValidator;
213
- protected readonly mappers: {
214
- SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
215
- CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
216
- UpdateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionMapper'], Entities['UpdateSubscriptionMapper'], (dto: Dto['UpdateSubscriptionMapper'], em: EntityManager) => Promise<Entities['UpdateSubscriptionMapper']>>;
217
- };
218
210
  readonly options?: {
219
211
  telemetry?: TelemetryOptions;
220
212
  } | undefined;
@@ -224,6 +216,14 @@ declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator
224
216
  metrics?: boolean;
225
217
  tracing?: boolean;
226
218
  };
219
+ protected em: EntityManager;
220
+ protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
221
+ protected readonly schemaValidator: SchemaValidator;
222
+ protected readonly mappers: {
223
+ SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
224
+ CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
225
+ UpdateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionMapper'], Entities['UpdateSubscriptionMapper'], (dto: Dto['UpdateSubscriptionMapper'], em: EntityManager) => Promise<Entities['UpdateSubscriptionMapper']>>;
226
+ };
227
227
  constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: {
228
228
  SubscriptionMapper: ResponseMapperConstructor<SchemaValidator, Dto['SubscriptionMapper'], Entities['SubscriptionMapper']>;
229
229
  CreateSubscriptionMapper: RequestMapperConstructor<SchemaValidator, Dto['CreateSubscriptionMapper'], Entities['CreateSubscriptionMapper'], (dto: Dto['CreateSubscriptionMapper'], em: EntityManager) => Promise<Entities['CreateSubscriptionMapper']>>;
@@ -34,12 +34,12 @@ var import_http = require("@forklaunch/core/http");
34
34
  var import_internal = require("@forklaunch/internal");
35
35
  var BaseBillingPortalService = class {
36
36
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
37
+ this.options = options;
37
38
  this.em = em;
38
39
  this.cache = cache;
39
40
  this.openTelemetryCollector = openTelemetryCollector;
40
41
  this.schemaValidator = schemaValidator;
41
42
  this.mappers = mappers;
42
- this.options = options;
43
43
  this._mappers = (0, import_internal.transformIntoInternalMapper)(mappers, schemaValidator);
44
44
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
45
45
  this.evaluatedTelemetryOptions = options?.telemetry ? (0, import_http.evaluateTelemetryOptions)(options.telemetry).enabled : {
@@ -51,6 +51,11 @@ var BaseBillingPortalService = class {
51
51
  _mappers;
52
52
  evaluatedTelemetryOptions;
53
53
  enableDatabaseBackup;
54
+ em;
55
+ cache;
56
+ openTelemetryCollector;
57
+ schemaValidator;
58
+ mappers;
54
59
  createCacheKey = (0, import_cache.createCacheKey)("billing_portal_session");
55
60
  async createBillingPortalSession(billingPortalDto) {
56
61
  if (this.evaluatedTelemetryOptions.logging) {
@@ -144,12 +149,12 @@ var import_http2 = require("@forklaunch/core/http");
144
149
  var import_internal2 = require("@forklaunch/internal");
145
150
  var BaseCheckoutSessionService = class {
146
151
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
152
+ this.options = options;
147
153
  this.em = em;
148
154
  this.cache = cache;
149
155
  this.openTelemetryCollector = openTelemetryCollector;
150
156
  this.schemaValidator = schemaValidator;
151
157
  this.mappers = mappers;
152
- this.options = options;
153
158
  this._mappers = (0, import_internal2.transformIntoInternalMapper)(mappers, schemaValidator);
154
159
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
155
160
  this.evaluatedTelemetryOptions = options?.telemetry ? (0, import_http2.evaluateTelemetryOptions)(options.telemetry).enabled : {
@@ -161,6 +166,11 @@ var BaseCheckoutSessionService = class {
161
166
  _mappers;
162
167
  evaluatedTelemetryOptions;
163
168
  enableDatabaseBackup;
169
+ em;
170
+ cache;
171
+ openTelemetryCollector;
172
+ schemaValidator;
173
+ mappers;
164
174
  createCacheKey = (0, import_cache2.createCacheKey)("checkout_session");
165
175
  async createCheckoutSession(checkoutSessionDto) {
166
176
  if (this.evaluatedTelemetryOptions.logging) {
@@ -240,12 +250,12 @@ var import_http3 = require("@forklaunch/core/http");
240
250
  var import_internal3 = require("@forklaunch/internal");
241
251
  var BasePaymentLinkService = class {
242
252
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
253
+ this.options = options;
243
254
  this.em = em;
244
255
  this.cache = cache;
245
256
  this.openTelemetryCollector = openTelemetryCollector;
246
257
  this.schemaValidator = schemaValidator;
247
258
  this.mappers = mappers;
248
- this.options = options;
249
259
  this._mappers = (0, import_internal3.transformIntoInternalMapper)(mappers, schemaValidator);
250
260
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
251
261
  this.evaluatedTelemetryOptions = options?.telemetry ? (0, import_http3.evaluateTelemetryOptions)(options.telemetry).enabled : {
@@ -257,6 +267,11 @@ var BasePaymentLinkService = class {
257
267
  _mappers;
258
268
  evaluatedTelemetryOptions;
259
269
  enableDatabaseBackup;
270
+ em;
271
+ cache;
272
+ openTelemetryCollector;
273
+ schemaValidator;
274
+ mappers;
260
275
  cacheKeyPrefix = "payment_link";
261
276
  createCacheKey = (0, import_cache3.createCacheKey)(this.cacheKeyPrefix);
262
277
  async createPaymentLink(paymentLinkDto) {
@@ -372,11 +387,11 @@ var import_http4 = require("@forklaunch/core/http");
372
387
  var import_internal4 = require("@forklaunch/internal");
373
388
  var BasePlanService = class {
374
389
  constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
390
+ this.options = options;
375
391
  this.em = em;
376
392
  this.openTelemetryCollector = openTelemetryCollector;
377
393
  this.schemaValidator = schemaValidator;
378
394
  this.mappers = mappers;
379
- this.options = options;
380
395
  this._mappers = (0, import_internal4.transformIntoInternalMapper)(mappers, schemaValidator);
381
396
  this.evaluatedTelemetryOptions = options?.telemetry ? (0, import_http4.evaluateTelemetryOptions)(options.telemetry).enabled : {
382
397
  logging: false,
@@ -386,6 +401,10 @@ var BasePlanService = class {
386
401
  }
387
402
  _mappers;
388
403
  evaluatedTelemetryOptions;
404
+ em;
405
+ openTelemetryCollector;
406
+ schemaValidator;
407
+ mappers;
389
408
  async listPlans(idsDto, em) {
390
409
  if (this.evaluatedTelemetryOptions.logging) {
391
410
  this.openTelemetryCollector.info("Listing plans", idsDto);
@@ -450,11 +469,11 @@ var import_http5 = require("@forklaunch/core/http");
450
469
  var import_internal5 = require("@forklaunch/internal");
451
470
  var BaseSubscriptionService = class {
452
471
  constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
472
+ this.options = options;
453
473
  this.em = em;
454
474
  this.openTelemetryCollector = openTelemetryCollector;
455
475
  this.schemaValidator = schemaValidator;
456
476
  this.mappers = mappers;
457
- this.options = options;
458
477
  this._mappers = (0, import_internal5.transformIntoInternalMapper)(mappers, this.schemaValidator);
459
478
  this.evaluatedTelemetryOptions = options?.telemetry ? (0, import_http5.evaluateTelemetryOptions)(options.telemetry).enabled : {
460
479
  logging: false,
@@ -464,6 +483,10 @@ var BaseSubscriptionService = class {
464
483
  }
465
484
  _mappers;
466
485
  evaluatedTelemetryOptions;
486
+ em;
487
+ openTelemetryCollector;
488
+ schemaValidator;
489
+ mappers;
467
490
  async createSubscription(subscriptionDto, em) {
468
491
  if (this.evaluatedTelemetryOptions.logging) {
469
492
  this.openTelemetryCollector.info(
@@ -8,12 +8,12 @@ import {
8
8
  } from "@forklaunch/internal";
9
9
  var BaseBillingPortalService = class {
10
10
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
11
+ this.options = options;
11
12
  this.em = em;
12
13
  this.cache = cache;
13
14
  this.openTelemetryCollector = openTelemetryCollector;
14
15
  this.schemaValidator = schemaValidator;
15
16
  this.mappers = mappers;
16
- this.options = options;
17
17
  this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
18
18
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
19
19
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions(options.telemetry).enabled : {
@@ -25,6 +25,11 @@ var BaseBillingPortalService = class {
25
25
  _mappers;
26
26
  evaluatedTelemetryOptions;
27
27
  enableDatabaseBackup;
28
+ em;
29
+ cache;
30
+ openTelemetryCollector;
31
+ schemaValidator;
32
+ mappers;
28
33
  createCacheKey = createCacheKey("billing_portal_session");
29
34
  async createBillingPortalSession(billingPortalDto) {
30
35
  if (this.evaluatedTelemetryOptions.logging) {
@@ -122,12 +127,12 @@ import {
122
127
  } from "@forklaunch/internal";
123
128
  var BaseCheckoutSessionService = class {
124
129
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
130
+ this.options = options;
125
131
  this.em = em;
126
132
  this.cache = cache;
127
133
  this.openTelemetryCollector = openTelemetryCollector;
128
134
  this.schemaValidator = schemaValidator;
129
135
  this.mappers = mappers;
130
- this.options = options;
131
136
  this._mappers = transformIntoInternalMapper2(mappers, schemaValidator);
132
137
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
133
138
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions2(options.telemetry).enabled : {
@@ -139,6 +144,11 @@ var BaseCheckoutSessionService = class {
139
144
  _mappers;
140
145
  evaluatedTelemetryOptions;
141
146
  enableDatabaseBackup;
147
+ em;
148
+ cache;
149
+ openTelemetryCollector;
150
+ schemaValidator;
151
+ mappers;
142
152
  createCacheKey = createCacheKey2("checkout_session");
143
153
  async createCheckoutSession(checkoutSessionDto) {
144
154
  if (this.evaluatedTelemetryOptions.logging) {
@@ -222,12 +232,12 @@ import {
222
232
  } from "@forklaunch/internal";
223
233
  var BasePaymentLinkService = class {
224
234
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
235
+ this.options = options;
225
236
  this.em = em;
226
237
  this.cache = cache;
227
238
  this.openTelemetryCollector = openTelemetryCollector;
228
239
  this.schemaValidator = schemaValidator;
229
240
  this.mappers = mappers;
230
- this.options = options;
231
241
  this._mappers = transformIntoInternalMapper3(mappers, schemaValidator);
232
242
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
233
243
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions3(options.telemetry).enabled : {
@@ -239,6 +249,11 @@ var BasePaymentLinkService = class {
239
249
  _mappers;
240
250
  evaluatedTelemetryOptions;
241
251
  enableDatabaseBackup;
252
+ em;
253
+ cache;
254
+ openTelemetryCollector;
255
+ schemaValidator;
256
+ mappers;
242
257
  cacheKeyPrefix = "payment_link";
243
258
  createCacheKey = createCacheKey3(this.cacheKeyPrefix);
244
259
  async createPaymentLink(paymentLinkDto) {
@@ -358,11 +373,11 @@ import {
358
373
  } from "@forklaunch/internal";
359
374
  var BasePlanService = class {
360
375
  constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
376
+ this.options = options;
361
377
  this.em = em;
362
378
  this.openTelemetryCollector = openTelemetryCollector;
363
379
  this.schemaValidator = schemaValidator;
364
380
  this.mappers = mappers;
365
- this.options = options;
366
381
  this._mappers = transformIntoInternalMapper4(mappers, schemaValidator);
367
382
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions4(options.telemetry).enabled : {
368
383
  logging: false,
@@ -372,6 +387,10 @@ var BasePlanService = class {
372
387
  }
373
388
  _mappers;
374
389
  evaluatedTelemetryOptions;
390
+ em;
391
+ openTelemetryCollector;
392
+ schemaValidator;
393
+ mappers;
375
394
  async listPlans(idsDto, em) {
376
395
  if (this.evaluatedTelemetryOptions.logging) {
377
396
  this.openTelemetryCollector.info("Listing plans", idsDto);
@@ -440,11 +459,11 @@ import {
440
459
  } from "@forklaunch/internal";
441
460
  var BaseSubscriptionService = class {
442
461
  constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
462
+ this.options = options;
443
463
  this.em = em;
444
464
  this.openTelemetryCollector = openTelemetryCollector;
445
465
  this.schemaValidator = schemaValidator;
446
466
  this.mappers = mappers;
447
- this.options = options;
448
467
  this._mappers = transformIntoInternalMapper5(mappers, this.schemaValidator);
449
468
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions5(options.telemetry).enabled : {
450
469
  logging: false,
@@ -454,6 +473,10 @@ var BaseSubscriptionService = class {
454
473
  }
455
474
  _mappers;
456
475
  evaluatedTelemetryOptions;
476
+ em;
477
+ openTelemetryCollector;
478
+ schemaValidator;
479
+ mappers;
457
480
  async createSubscription(subscriptionDto, em) {
458
481
  if (this.evaluatedTelemetryOptions.logging) {
459
482
  this.openTelemetryCollector.info(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-billing-base",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Billing basic implementation for forklaunch",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -36,21 +36,21 @@
36
36
  "lib/**"
37
37
  ],
38
38
  "dependencies": {
39
- "@forklaunch/common": "^0.4.5",
40
- "@forklaunch/core": "^0.11.5",
41
- "@forklaunch/internal": "^0.1.7",
42
- "@forklaunch/validator": "^0.7.7",
39
+ "@forklaunch/common": "^0.4.6",
40
+ "@forklaunch/core": "^0.12.0",
41
+ "@forklaunch/internal": "^0.1.9",
42
+ "@forklaunch/validator": "^0.8.0",
43
43
  "@mikro-orm/core": "^6.4.16",
44
- "@sinclair/typebox": "^0.34.37",
44
+ "@sinclair/typebox": "^0.34.38",
45
45
  "ajv": "^8.17.1",
46
- "zod": "^4.0.5",
47
- "@forklaunch/interfaces-billing": "0.4.0"
46
+ "zod": "^4.0.14",
47
+ "@forklaunch/interfaces-billing": "0.5.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@typescript/native-preview": "7.0.0-dev.20250712.1",
50
+ "@typescript/native-preview": "7.0.0-dev.20250803.1",
51
51
  "depcheck": "^1.4.7",
52
52
  "prettier": "^3.6.2",
53
- "typedoc": "^0.28.7"
53
+ "typedoc": "^0.28.9"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "tsc --noEmit && tsup domain/schemas/index.ts services/index.ts domain/types/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean && if [ -f eject-package.bash ]; then pnpm package:eject; fi",