@forklaunch/implementation-billing-base 0.8.23 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,22 +11,23 @@ import {
11
11
  UpdateSubscriptionDto
12
12
  } from '@forklaunch/interfaces-billing/types';
13
13
  import { AnySchemaValidator } from '@forklaunch/validator';
14
- import { EntityManager } from '@mikro-orm/core';
14
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
15
15
  import { BaseSubscriptionDtos } from '../domain/types/baseBillingDto.types';
16
16
  import { BaseSubscriptionEntities } from '../domain/types/baseBillingEntity.types';
17
17
  import { SubscriptionMappers } from '../domain/types/subscription.mapper.types';
18
+ import { Subscription } from '../persistence/entities';
18
19
 
19
20
  export class BaseSubscriptionService<
20
21
  SchemaValidator extends AnySchemaValidator,
21
22
  PartyType,
22
23
  BillingProviderType,
23
- Entities extends BaseSubscriptionEntities<PartyType, BillingProviderType>,
24
- Dto extends BaseSubscriptionDtos<
24
+ MapperEntities extends BaseSubscriptionEntities<
25
25
  PartyType,
26
26
  BillingProviderType
27
- > = BaseSubscriptionDtos<PartyType, BillingProviderType>
28
- > implements SubscriptionService<PartyType, BillingProviderType>
29
- {
27
+ >,
28
+ Dto extends BaseSubscriptionDtos<PartyType, BillingProviderType> =
29
+ BaseSubscriptionDtos<PartyType, BillingProviderType>
30
+ > implements SubscriptionService<PartyType, BillingProviderType> {
30
31
  protected evaluatedTelemetryOptions: {
31
32
  logging?: boolean;
32
33
  metrics?: boolean;
@@ -38,7 +39,7 @@ export class BaseSubscriptionService<
38
39
  protected readonly mappers: SubscriptionMappers<
39
40
  PartyType,
40
41
  BillingProviderType,
41
- Entities,
42
+ MapperEntities,
42
43
  Dto
43
44
  >;
44
45
 
@@ -46,7 +47,12 @@ export class BaseSubscriptionService<
46
47
  em: EntityManager,
47
48
  openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
48
49
  schemaValidator: SchemaValidator,
49
- mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>,
50
+ mappers: SubscriptionMappers<
51
+ PartyType,
52
+ BillingProviderType,
53
+ MapperEntities,
54
+ Dto
55
+ >,
50
56
  readonly options?: {
51
57
  telemetry?: TelemetryOptions;
52
58
  }
@@ -96,11 +102,11 @@ export class BaseSubscriptionService<
96
102
  this.openTelemetryCollector.info('Getting subscription', idDto);
97
103
  }
98
104
  const subscription = await (em ?? this.em).findOneOrFail(
99
- 'Subscription',
105
+ this.mappers.SubscriptionMapper.entity as typeof Subscription,
100
106
  idDto
101
107
  );
102
108
  return this.mappers.SubscriptionMapper.toDto(
103
- subscription as Entities['SubscriptionMapper']
109
+ subscription as InferEntity<MapperEntities['SubscriptionMapper']>
104
110
  );
105
111
  }
106
112
 
@@ -111,14 +117,17 @@ export class BaseSubscriptionService<
111
117
  if (this.evaluatedTelemetryOptions.logging) {
112
118
  this.openTelemetryCollector.info('Getting user subscription', id);
113
119
  }
114
- const subscription = await (em ?? this.em).findOneOrFail('Subscription', {
115
- partyId: id,
116
- partyType: 'USER',
117
- active: true
118
- });
120
+ const subscription = await (em ?? this.em).findOneOrFail(
121
+ this.mappers.SubscriptionMapper.entity as typeof Subscription,
122
+ {
123
+ partyId: id,
124
+ partyType: 'USER',
125
+ active: true
126
+ }
127
+ );
119
128
 
120
129
  return this.mappers.SubscriptionMapper.toDto(
121
- subscription as Entities['SubscriptionMapper']
130
+ subscription as InferEntity<MapperEntities['SubscriptionMapper']>
122
131
  );
123
132
  }
124
133
 
@@ -129,13 +138,16 @@ export class BaseSubscriptionService<
129
138
  if (this.evaluatedTelemetryOptions.logging) {
130
139
  this.openTelemetryCollector.info('Getting organization subscription', id);
131
140
  }
132
- const subscription = await (em ?? this.em).findOneOrFail('Subscription', {
133
- partyId: id,
134
- partyType: 'ORGANIZATION',
135
- active: true
136
- });
141
+ const subscription = await (em ?? this.em).findOneOrFail(
142
+ this.mappers.SubscriptionMapper.entity as typeof Subscription,
143
+ {
144
+ partyId: id,
145
+ partyType: 'ORGANIZATION',
146
+ active: true
147
+ }
148
+ );
137
149
  return this.mappers.SubscriptionMapper.toDto(
138
- subscription as Entities['SubscriptionMapper']
150
+ subscription as InferEntity<MapperEntities['SubscriptionMapper']>
139
151
  );
140
152
  }
141
153
 
@@ -172,11 +184,14 @@ export class BaseSubscriptionService<
172
184
  if (this.evaluatedTelemetryOptions.logging) {
173
185
  this.openTelemetryCollector.info('Deleting subscription', idDto);
174
186
  }
175
- const subscription = await (em ?? this.em).findOne('Subscription', idDto);
187
+ const subscription = await (em ?? this.em).findOne(
188
+ this.mappers.SubscriptionMapper.entity as typeof Subscription,
189
+ idDto
190
+ );
176
191
  if (!subscription) {
177
192
  throw new Error('Subscription not found');
178
193
  }
179
- await (em ?? this.em).removeAndFlush(subscription);
194
+ await (em ?? this.em).remove(subscription).flush();
180
195
  }
181
196
 
182
197
  async listSubscriptions(
@@ -188,12 +203,15 @@ export class BaseSubscriptionService<
188
203
  }
189
204
  return Promise.all(
190
205
  (
191
- await (em ?? this.em).findAll('Subscription', {
192
- where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : undefined
193
- })
206
+ await (em ?? this.em).findAll(
207
+ this.mappers.SubscriptionMapper.entity as typeof Subscription,
208
+ {
209
+ where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : undefined
210
+ }
211
+ )
194
212
  ).map((subscription) =>
195
213
  this.mappers.SubscriptionMapper.toDto(
196
- subscription as Entities['SubscriptionMapper']
214
+ subscription as InferEntity<MapperEntities['SubscriptionMapper']>
197
215
  )
198
216
  )
199
217
  );
@@ -203,11 +221,14 @@ export class BaseSubscriptionService<
203
221
  if (this.evaluatedTelemetryOptions.logging) {
204
222
  this.openTelemetryCollector.info('Canceling subscription', idDto);
205
223
  }
206
- const subscription = await (em ?? this.em).findOne('Subscription', idDto);
224
+ const subscription = await (em ?? this.em).findOne(
225
+ this.mappers.SubscriptionMapper.entity as typeof Subscription,
226
+ idDto
227
+ );
207
228
  if (!subscription) {
208
229
  throw new Error('Subscription not found');
209
230
  }
210
- (subscription as Entities['SubscriptionMapper']).active = false;
231
+ subscription.active = false;
211
232
  await (em ?? this.em).transactional(async (innerEm) => {
212
233
  await innerEm.persist(subscription);
213
234
  });
@@ -217,11 +238,14 @@ export class BaseSubscriptionService<
217
238
  if (this.evaluatedTelemetryOptions.logging) {
218
239
  this.openTelemetryCollector.info('Resuming subscription', idDto);
219
240
  }
220
- const subscription = await (em ?? this.em).findOne('Subscription', idDto);
241
+ const subscription = await (em ?? this.em).findOne(
242
+ this.mappers.SubscriptionMapper.entity as typeof Subscription,
243
+ idDto
244
+ );
221
245
  if (!subscription) {
222
246
  throw new Error('Subscription not found');
223
247
  }
224
- (subscription as Entities['SubscriptionMapper']).active = true;
248
+ subscription.active = true;
225
249
  await (em ?? this.em).transactional(async (innerEm) => {
226
250
  await innerEm.persist(subscription);
227
251
  });
@@ -89,7 +89,7 @@ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCa
89
89
  }, em?: EntityManager): Promise<void>;
90
90
  }
91
91
 
92
- 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> {
92
+ declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator, PartyType, BillingProviderType, MapperEntities extends BaseSubscriptionEntities<PartyType, BillingProviderType>, Dto extends BaseSubscriptionDtos<PartyType, BillingProviderType> = BaseSubscriptionDtos<PartyType, BillingProviderType>> implements SubscriptionService<PartyType, BillingProviderType> {
93
93
  readonly options?: {
94
94
  telemetry?: TelemetryOptions;
95
95
  } | undefined;
@@ -101,8 +101,8 @@ declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator
101
101
  protected em: EntityManager;
102
102
  protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
103
103
  protected readonly schemaValidator: SchemaValidator;
104
- protected readonly mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>;
105
- constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>, options?: {
104
+ protected readonly mappers: SubscriptionMappers<PartyType, BillingProviderType, MapperEntities, Dto>;
105
+ constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: SubscriptionMappers<PartyType, BillingProviderType, MapperEntities, Dto>, options?: {
106
106
  telemetry?: TelemetryOptions;
107
107
  } | undefined);
108
108
  createSubscription(subscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>, em?: EntityManager, ...args: unknown[]): Promise<Dto['SubscriptionMapper']>;
@@ -89,7 +89,7 @@ declare class BasePlanService<SchemaValidator extends AnySchemaValidator, PlanCa
89
89
  }, em?: EntityManager): Promise<void>;
90
90
  }
91
91
 
92
- 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> {
92
+ declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator, PartyType, BillingProviderType, MapperEntities extends BaseSubscriptionEntities<PartyType, BillingProviderType>, Dto extends BaseSubscriptionDtos<PartyType, BillingProviderType> = BaseSubscriptionDtos<PartyType, BillingProviderType>> implements SubscriptionService<PartyType, BillingProviderType> {
93
93
  readonly options?: {
94
94
  telemetry?: TelemetryOptions;
95
95
  } | undefined;
@@ -101,8 +101,8 @@ declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator
101
101
  protected em: EntityManager;
102
102
  protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
103
103
  protected readonly schemaValidator: SchemaValidator;
104
- protected readonly mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>;
105
- constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: SubscriptionMappers<PartyType, BillingProviderType, Entities, Dto>, options?: {
104
+ protected readonly mappers: SubscriptionMappers<PartyType, BillingProviderType, MapperEntities, Dto>;
105
+ constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: SubscriptionMappers<PartyType, BillingProviderType, MapperEntities, Dto>, options?: {
106
106
  telemetry?: TelemetryOptions;
107
107
  } | undefined);
108
108
  createSubscription(subscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>, em?: EntityManager, ...args: unknown[]): Promise<Dto['SubscriptionMapper']>;
@@ -68,7 +68,7 @@ var BaseBillingPortalService = class {
68
68
  ...args[0] instanceof import_core.EntityManager ? args.slice(1) : args
69
69
  );
70
70
  if (this.enableDatabaseBackup) {
71
- await this.em.persistAndFlush(billingPortal);
71
+ await this.em.persist(billingPortal).flush();
72
72
  }
73
73
  const createdBillingPortalDto = await this.mappers.BillingPortalMapper.toDto(billingPortal);
74
74
  await this.cache.putRecord({
@@ -112,9 +112,9 @@ var BaseBillingPortalService = class {
112
112
  ...args[0] instanceof import_core.EntityManager ? args.slice(1) : args
113
113
  );
114
114
  if (this.enableDatabaseBackup) {
115
- await this.em.persistAndFlush({
115
+ await this.em.persist({
116
116
  billingPortal
117
- });
117
+ }).flush();
118
118
  }
119
119
  const updatedBillingPortalDto = {
120
120
  ...existingBillingPortal,
@@ -189,7 +189,7 @@ var BaseCheckoutSessionService = class {
189
189
  );
190
190
  const createdCheckoutSessionDto = await this.mappers.CheckoutSessionMapper.toDto(checkoutSession);
191
191
  if (this.enableDatabaseBackup) {
192
- await this.em.persistAndFlush(checkoutSession);
192
+ await this.em.persist(checkoutSession).flush();
193
193
  }
194
194
  await this.cache.putRecord({
195
195
  key: this.createCacheKey(createdCheckoutSessionDto.id),
@@ -226,11 +226,14 @@ var BaseCheckoutSessionService = class {
226
226
  this.openTelemetryCollector.info("Checkout success", { id });
227
227
  }
228
228
  if (this.enableDatabaseBackup) {
229
- const checkoutSession = await this.em.upsert("CheckoutSession", {
230
- id,
231
- status: "SUCCESS"
232
- });
233
- await this.em.persistAndFlush(checkoutSession);
229
+ const checkoutSession = await this.em.upsert(
230
+ this.mappers.CheckoutSessionMapper.entity,
231
+ {
232
+ id,
233
+ status: "SUCCESS"
234
+ }
235
+ );
236
+ await this.em.persist(checkoutSession).flush();
234
237
  }
235
238
  await this.cache.deleteRecord(this.createCacheKey(id));
236
239
  }
@@ -239,11 +242,14 @@ var BaseCheckoutSessionService = class {
239
242
  this.openTelemetryCollector.info("Checkout failure", { id });
240
243
  }
241
244
  if (this.enableDatabaseBackup) {
242
- const checkoutSession = await this.em.upsert("CheckoutSession", {
243
- id,
244
- status: "FAILED"
245
- });
246
- await this.em.persistAndFlush(checkoutSession);
245
+ const checkoutSession = await this.em.upsert(
246
+ this.mappers.CheckoutSessionMapper.entity,
247
+ {
248
+ id,
249
+ status: "FAILED"
250
+ }
251
+ );
252
+ await this.em.persist(checkoutSession).flush();
247
253
  }
248
254
  await this.cache.deleteRecord(this.createCacheKey(id));
249
255
  }
@@ -286,7 +292,7 @@ var BasePaymentLinkService = class {
286
292
  ...args[0] instanceof import_core3.EntityManager ? args.slice(1) : args
287
293
  );
288
294
  if (this.enableDatabaseBackup) {
289
- await this.em.persistAndFlush(paymentLink);
295
+ await this.em.persist(paymentLink).flush();
290
296
  }
291
297
  const createdPaymentLinkDto = await this.mappers.PaymentLinkMapper.toDto(paymentLink);
292
298
  await this.cache.putRecord({
@@ -311,7 +317,7 @@ var BasePaymentLinkService = class {
311
317
  ...args[0] instanceof import_core3.EntityManager ? args.slice(1) : args
312
318
  );
313
319
  if (this.enableDatabaseBackup) {
314
- await this.em.persistAndFlush(paymentLink);
320
+ await this.em.persist(paymentLink).flush();
315
321
  }
316
322
  const updatedLinkDto = {
317
323
  ...existingLink,
@@ -340,33 +346,42 @@ var BasePaymentLinkService = class {
340
346
  async expirePaymentLink({ id }) {
341
347
  this.openTelemetryCollector.info("Payment link expired", { id });
342
348
  if (this.enableDatabaseBackup) {
343
- const paymentLink = await this.em.upsert("PaymentLink", {
344
- id,
345
- status: "EXPIRED"
346
- });
347
- await this.em.removeAndFlush(paymentLink);
349
+ const paymentLink = await this.em.upsert(
350
+ this.mappers.PaymentLinkMapper.entity,
351
+ {
352
+ id,
353
+ status: "EXPIRED"
354
+ }
355
+ );
356
+ await this.em.remove(paymentLink).flush();
348
357
  }
349
358
  await this.cache.deleteRecord(this.createCacheKey(id));
350
359
  }
351
360
  async handlePaymentSuccess({ id }) {
352
361
  this.openTelemetryCollector.info("Payment link success", { id });
353
362
  if (this.enableDatabaseBackup) {
354
- const paymentLink = await this.em.upsert("PaymentLink", {
355
- id,
356
- status: "COMPLETED"
357
- });
358
- await this.em.removeAndFlush(paymentLink);
363
+ const paymentLink = await this.em.upsert(
364
+ this.mappers.PaymentLinkMapper.entity,
365
+ {
366
+ id,
367
+ status: "COMPLETED"
368
+ }
369
+ );
370
+ await this.em.remove(paymentLink).flush();
359
371
  }
360
372
  await this.cache.deleteRecord(this.createCacheKey(id));
361
373
  }
362
374
  async handlePaymentFailure({ id }) {
363
375
  this.openTelemetryCollector.info("Payment link failure", { id });
364
376
  if (this.enableDatabaseBackup) {
365
- const paymentLink = await this.em.upsert("PaymentLink", {
366
- id,
367
- status: "FAILED"
368
- });
369
- await this.em.removeAndFlush(paymentLink);
377
+ const paymentLink = await this.em.upsert(
378
+ this.mappers.PaymentLinkMapper.entity,
379
+ {
380
+ id,
381
+ status: "FAILED"
382
+ }
383
+ );
384
+ await this.em.remove(paymentLink).flush();
370
385
  }
371
386
  await this.cache.deleteRecord(this.createCacheKey(id));
372
387
  }
@@ -406,10 +421,15 @@ var BasePlanService = class {
406
421
  this.openTelemetryCollector.info("Listing plans", idsDto);
407
422
  }
408
423
  return Promise.all(
409
- (await (em ?? this.em).findAll("Plan", {
410
- where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
411
- })).map(
412
- (plan) => this.mappers.PlanMapper.toDto(plan)
424
+ (await (em ?? this.em).findAll(
425
+ this.mappers.PlanMapper.entity,
426
+ {
427
+ where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
428
+ }
429
+ )).map(
430
+ (plan) => this.mappers.PlanMapper.toDto(
431
+ plan
432
+ )
413
433
  )
414
434
  );
415
435
  }
@@ -431,8 +451,13 @@ var BasePlanService = class {
431
451
  if (this.evaluatedTelemetryOptions.logging) {
432
452
  this.openTelemetryCollector.info("Getting plan", idDto);
433
453
  }
434
- const plan = await (em ?? this.em).findOneOrFail("Plan", idDto);
435
- return this.mappers.PlanMapper.toDto(plan);
454
+ const plan = await (em ?? this.em).findOneOrFail(
455
+ this.mappers.PlanMapper.entity,
456
+ idDto
457
+ );
458
+ return this.mappers.PlanMapper.toDto(
459
+ plan
460
+ );
436
461
  }
437
462
  async updatePlan(planDto, em, ...args) {
438
463
  if (this.evaluatedTelemetryOptions.logging) {
@@ -454,7 +479,10 @@ var BasePlanService = class {
454
479
  if (this.evaluatedTelemetryOptions.logging) {
455
480
  this.openTelemetryCollector.info("Deleting plan", idDto);
456
481
  }
457
- await (em ?? this.em).nativeDelete("Plan", idDto);
482
+ await (em ?? this.em).nativeDelete(
483
+ this.mappers.PlanMapper.entity,
484
+ idDto
485
+ );
458
486
  }
459
487
  };
460
488
 
@@ -502,7 +530,7 @@ var BaseSubscriptionService = class {
502
530
  this.openTelemetryCollector.info("Getting subscription", idDto);
503
531
  }
504
532
  const subscription = await (em ?? this.em).findOneOrFail(
505
- "Subscription",
533
+ this.mappers.SubscriptionMapper.entity,
506
534
  idDto
507
535
  );
508
536
  return this.mappers.SubscriptionMapper.toDto(
@@ -513,11 +541,14 @@ var BaseSubscriptionService = class {
513
541
  if (this.evaluatedTelemetryOptions.logging) {
514
542
  this.openTelemetryCollector.info("Getting user subscription", id);
515
543
  }
516
- const subscription = await (em ?? this.em).findOneOrFail("Subscription", {
517
- partyId: id,
518
- partyType: "USER",
519
- active: true
520
- });
544
+ const subscription = await (em ?? this.em).findOneOrFail(
545
+ this.mappers.SubscriptionMapper.entity,
546
+ {
547
+ partyId: id,
548
+ partyType: "USER",
549
+ active: true
550
+ }
551
+ );
521
552
  return this.mappers.SubscriptionMapper.toDto(
522
553
  subscription
523
554
  );
@@ -526,11 +557,14 @@ var BaseSubscriptionService = class {
526
557
  if (this.evaluatedTelemetryOptions.logging) {
527
558
  this.openTelemetryCollector.info("Getting organization subscription", id);
528
559
  }
529
- const subscription = await (em ?? this.em).findOneOrFail("Subscription", {
530
- partyId: id,
531
- partyType: "ORGANIZATION",
532
- active: true
533
- });
560
+ const subscription = await (em ?? this.em).findOneOrFail(
561
+ this.mappers.SubscriptionMapper.entity,
562
+ {
563
+ partyId: id,
564
+ partyType: "ORGANIZATION",
565
+ active: true
566
+ }
567
+ );
534
568
  return this.mappers.SubscriptionMapper.toDto(
535
569
  subscription
536
570
  );
@@ -558,20 +592,26 @@ var BaseSubscriptionService = class {
558
592
  if (this.evaluatedTelemetryOptions.logging) {
559
593
  this.openTelemetryCollector.info("Deleting subscription", idDto);
560
594
  }
561
- const subscription = await (em ?? this.em).findOne("Subscription", idDto);
595
+ const subscription = await (em ?? this.em).findOne(
596
+ this.mappers.SubscriptionMapper.entity,
597
+ idDto
598
+ );
562
599
  if (!subscription) {
563
600
  throw new Error("Subscription not found");
564
601
  }
565
- await (em ?? this.em).removeAndFlush(subscription);
602
+ await (em ?? this.em).remove(subscription).flush();
566
603
  }
567
604
  async listSubscriptions(idsDto, em) {
568
605
  if (this.evaluatedTelemetryOptions.logging) {
569
606
  this.openTelemetryCollector.info("Listing subscriptions", idsDto);
570
607
  }
571
608
  return Promise.all(
572
- (await (em ?? this.em).findAll("Subscription", {
573
- where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
574
- })).map(
609
+ (await (em ?? this.em).findAll(
610
+ this.mappers.SubscriptionMapper.entity,
611
+ {
612
+ where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
613
+ }
614
+ )).map(
575
615
  (subscription) => this.mappers.SubscriptionMapper.toDto(
576
616
  subscription
577
617
  )
@@ -582,7 +622,10 @@ var BaseSubscriptionService = class {
582
622
  if (this.evaluatedTelemetryOptions.logging) {
583
623
  this.openTelemetryCollector.info("Canceling subscription", idDto);
584
624
  }
585
- const subscription = await (em ?? this.em).findOne("Subscription", idDto);
625
+ const subscription = await (em ?? this.em).findOne(
626
+ this.mappers.SubscriptionMapper.entity,
627
+ idDto
628
+ );
586
629
  if (!subscription) {
587
630
  throw new Error("Subscription not found");
588
631
  }
@@ -595,7 +638,10 @@ var BaseSubscriptionService = class {
595
638
  if (this.evaluatedTelemetryOptions.logging) {
596
639
  this.openTelemetryCollector.info("Resuming subscription", idDto);
597
640
  }
598
- const subscription = await (em ?? this.em).findOne("Subscription", idDto);
641
+ const subscription = await (em ?? this.em).findOne(
642
+ this.mappers.SubscriptionMapper.entity,
643
+ idDto
644
+ );
599
645
  if (!subscription) {
600
646
  throw new Error("Subscription not found");
601
647
  }