@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.
@@ -39,7 +39,7 @@ var BaseBillingPortalService = class {
39
39
  ...args[0] instanceof EntityManager ? args.slice(1) : args
40
40
  );
41
41
  if (this.enableDatabaseBackup) {
42
- await this.em.persistAndFlush(billingPortal);
42
+ await this.em.persist(billingPortal).flush();
43
43
  }
44
44
  const createdBillingPortalDto = await this.mappers.BillingPortalMapper.toDto(billingPortal);
45
45
  await this.cache.putRecord({
@@ -83,9 +83,9 @@ var BaseBillingPortalService = class {
83
83
  ...args[0] instanceof EntityManager ? args.slice(1) : args
84
84
  );
85
85
  if (this.enableDatabaseBackup) {
86
- await this.em.persistAndFlush({
86
+ await this.em.persist({
87
87
  billingPortal
88
- });
88
+ }).flush();
89
89
  }
90
90
  const updatedBillingPortalDto = {
91
91
  ...existingBillingPortal,
@@ -162,7 +162,7 @@ var BaseCheckoutSessionService = class {
162
162
  );
163
163
  const createdCheckoutSessionDto = await this.mappers.CheckoutSessionMapper.toDto(checkoutSession);
164
164
  if (this.enableDatabaseBackup) {
165
- await this.em.persistAndFlush(checkoutSession);
165
+ await this.em.persist(checkoutSession).flush();
166
166
  }
167
167
  await this.cache.putRecord({
168
168
  key: this.createCacheKey(createdCheckoutSessionDto.id),
@@ -199,11 +199,14 @@ var BaseCheckoutSessionService = class {
199
199
  this.openTelemetryCollector.info("Checkout success", { id });
200
200
  }
201
201
  if (this.enableDatabaseBackup) {
202
- const checkoutSession = await this.em.upsert("CheckoutSession", {
203
- id,
204
- status: "SUCCESS"
205
- });
206
- await this.em.persistAndFlush(checkoutSession);
202
+ const checkoutSession = await this.em.upsert(
203
+ this.mappers.CheckoutSessionMapper.entity,
204
+ {
205
+ id,
206
+ status: "SUCCESS"
207
+ }
208
+ );
209
+ await this.em.persist(checkoutSession).flush();
207
210
  }
208
211
  await this.cache.deleteRecord(this.createCacheKey(id));
209
212
  }
@@ -212,11 +215,14 @@ var BaseCheckoutSessionService = class {
212
215
  this.openTelemetryCollector.info("Checkout failure", { id });
213
216
  }
214
217
  if (this.enableDatabaseBackup) {
215
- const checkoutSession = await this.em.upsert("CheckoutSession", {
216
- id,
217
- status: "FAILED"
218
- });
219
- await this.em.persistAndFlush(checkoutSession);
218
+ const checkoutSession = await this.em.upsert(
219
+ this.mappers.CheckoutSessionMapper.entity,
220
+ {
221
+ id,
222
+ status: "FAILED"
223
+ }
224
+ );
225
+ await this.em.persist(checkoutSession).flush();
220
226
  }
221
227
  await this.cache.deleteRecord(this.createCacheKey(id));
222
228
  }
@@ -261,7 +267,7 @@ var BasePaymentLinkService = class {
261
267
  ...args[0] instanceof EntityManager3 ? args.slice(1) : args
262
268
  );
263
269
  if (this.enableDatabaseBackup) {
264
- await this.em.persistAndFlush(paymentLink);
270
+ await this.em.persist(paymentLink).flush();
265
271
  }
266
272
  const createdPaymentLinkDto = await this.mappers.PaymentLinkMapper.toDto(paymentLink);
267
273
  await this.cache.putRecord({
@@ -286,7 +292,7 @@ var BasePaymentLinkService = class {
286
292
  ...args[0] instanceof EntityManager3 ? 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 updatedLinkDto = {
292
298
  ...existingLink,
@@ -315,33 +321,42 @@ var BasePaymentLinkService = class {
315
321
  async expirePaymentLink({ id }) {
316
322
  this.openTelemetryCollector.info("Payment link expired", { id });
317
323
  if (this.enableDatabaseBackup) {
318
- const paymentLink = await this.em.upsert("PaymentLink", {
319
- id,
320
- status: "EXPIRED"
321
- });
322
- await this.em.removeAndFlush(paymentLink);
324
+ const paymentLink = await this.em.upsert(
325
+ this.mappers.PaymentLinkMapper.entity,
326
+ {
327
+ id,
328
+ status: "EXPIRED"
329
+ }
330
+ );
331
+ await this.em.remove(paymentLink).flush();
323
332
  }
324
333
  await this.cache.deleteRecord(this.createCacheKey(id));
325
334
  }
326
335
  async handlePaymentSuccess({ id }) {
327
336
  this.openTelemetryCollector.info("Payment link success", { id });
328
337
  if (this.enableDatabaseBackup) {
329
- const paymentLink = await this.em.upsert("PaymentLink", {
330
- id,
331
- status: "COMPLETED"
332
- });
333
- await this.em.removeAndFlush(paymentLink);
338
+ const paymentLink = await this.em.upsert(
339
+ this.mappers.PaymentLinkMapper.entity,
340
+ {
341
+ id,
342
+ status: "COMPLETED"
343
+ }
344
+ );
345
+ await this.em.remove(paymentLink).flush();
334
346
  }
335
347
  await this.cache.deleteRecord(this.createCacheKey(id));
336
348
  }
337
349
  async handlePaymentFailure({ id }) {
338
350
  this.openTelemetryCollector.info("Payment link failure", { id });
339
351
  if (this.enableDatabaseBackup) {
340
- const paymentLink = await this.em.upsert("PaymentLink", {
341
- id,
342
- status: "FAILED"
343
- });
344
- await this.em.removeAndFlush(paymentLink);
352
+ const paymentLink = await this.em.upsert(
353
+ this.mappers.PaymentLinkMapper.entity,
354
+ {
355
+ id,
356
+ status: "FAILED"
357
+ }
358
+ );
359
+ await this.em.remove(paymentLink).flush();
345
360
  }
346
361
  await this.cache.deleteRecord(this.createCacheKey(id));
347
362
  }
@@ -383,10 +398,15 @@ var BasePlanService = class {
383
398
  this.openTelemetryCollector.info("Listing plans", idsDto);
384
399
  }
385
400
  return Promise.all(
386
- (await (em ?? this.em).findAll("Plan", {
387
- where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
388
- })).map(
389
- (plan) => this.mappers.PlanMapper.toDto(plan)
401
+ (await (em ?? this.em).findAll(
402
+ this.mappers.PlanMapper.entity,
403
+ {
404
+ where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
405
+ }
406
+ )).map(
407
+ (plan) => this.mappers.PlanMapper.toDto(
408
+ plan
409
+ )
390
410
  )
391
411
  );
392
412
  }
@@ -408,8 +428,13 @@ var BasePlanService = class {
408
428
  if (this.evaluatedTelemetryOptions.logging) {
409
429
  this.openTelemetryCollector.info("Getting plan", idDto);
410
430
  }
411
- const plan = await (em ?? this.em).findOneOrFail("Plan", idDto);
412
- return this.mappers.PlanMapper.toDto(plan);
431
+ const plan = await (em ?? this.em).findOneOrFail(
432
+ this.mappers.PlanMapper.entity,
433
+ idDto
434
+ );
435
+ return this.mappers.PlanMapper.toDto(
436
+ plan
437
+ );
413
438
  }
414
439
  async updatePlan(planDto, em, ...args) {
415
440
  if (this.evaluatedTelemetryOptions.logging) {
@@ -431,7 +456,10 @@ var BasePlanService = class {
431
456
  if (this.evaluatedTelemetryOptions.logging) {
432
457
  this.openTelemetryCollector.info("Deleting plan", idDto);
433
458
  }
434
- await (em ?? this.em).nativeDelete("Plan", idDto);
459
+ await (em ?? this.em).nativeDelete(
460
+ this.mappers.PlanMapper.entity,
461
+ idDto
462
+ );
435
463
  }
436
464
  };
437
465
 
@@ -481,7 +509,7 @@ var BaseSubscriptionService = class {
481
509
  this.openTelemetryCollector.info("Getting subscription", idDto);
482
510
  }
483
511
  const subscription = await (em ?? this.em).findOneOrFail(
484
- "Subscription",
512
+ this.mappers.SubscriptionMapper.entity,
485
513
  idDto
486
514
  );
487
515
  return this.mappers.SubscriptionMapper.toDto(
@@ -492,11 +520,14 @@ var BaseSubscriptionService = class {
492
520
  if (this.evaluatedTelemetryOptions.logging) {
493
521
  this.openTelemetryCollector.info("Getting user subscription", id);
494
522
  }
495
- const subscription = await (em ?? this.em).findOneOrFail("Subscription", {
496
- partyId: id,
497
- partyType: "USER",
498
- active: true
499
- });
523
+ const subscription = await (em ?? this.em).findOneOrFail(
524
+ this.mappers.SubscriptionMapper.entity,
525
+ {
526
+ partyId: id,
527
+ partyType: "USER",
528
+ active: true
529
+ }
530
+ );
500
531
  return this.mappers.SubscriptionMapper.toDto(
501
532
  subscription
502
533
  );
@@ -505,11 +536,14 @@ var BaseSubscriptionService = class {
505
536
  if (this.evaluatedTelemetryOptions.logging) {
506
537
  this.openTelemetryCollector.info("Getting organization subscription", id);
507
538
  }
508
- const subscription = await (em ?? this.em).findOneOrFail("Subscription", {
509
- partyId: id,
510
- partyType: "ORGANIZATION",
511
- active: true
512
- });
539
+ const subscription = await (em ?? this.em).findOneOrFail(
540
+ this.mappers.SubscriptionMapper.entity,
541
+ {
542
+ partyId: id,
543
+ partyType: "ORGANIZATION",
544
+ active: true
545
+ }
546
+ );
513
547
  return this.mappers.SubscriptionMapper.toDto(
514
548
  subscription
515
549
  );
@@ -537,20 +571,26 @@ var BaseSubscriptionService = class {
537
571
  if (this.evaluatedTelemetryOptions.logging) {
538
572
  this.openTelemetryCollector.info("Deleting subscription", idDto);
539
573
  }
540
- const subscription = await (em ?? this.em).findOne("Subscription", idDto);
574
+ const subscription = await (em ?? this.em).findOne(
575
+ this.mappers.SubscriptionMapper.entity,
576
+ idDto
577
+ );
541
578
  if (!subscription) {
542
579
  throw new Error("Subscription not found");
543
580
  }
544
- await (em ?? this.em).removeAndFlush(subscription);
581
+ await (em ?? this.em).remove(subscription).flush();
545
582
  }
546
583
  async listSubscriptions(idsDto, em) {
547
584
  if (this.evaluatedTelemetryOptions.logging) {
548
585
  this.openTelemetryCollector.info("Listing subscriptions", idsDto);
549
586
  }
550
587
  return Promise.all(
551
- (await (em ?? this.em).findAll("Subscription", {
552
- where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
553
- })).map(
588
+ (await (em ?? this.em).findAll(
589
+ this.mappers.SubscriptionMapper.entity,
590
+ {
591
+ where: idsDto?.ids?.length ? { id: { $in: idsDto.ids } } : void 0
592
+ }
593
+ )).map(
554
594
  (subscription) => this.mappers.SubscriptionMapper.toDto(
555
595
  subscription
556
596
  )
@@ -561,7 +601,10 @@ var BaseSubscriptionService = class {
561
601
  if (this.evaluatedTelemetryOptions.logging) {
562
602
  this.openTelemetryCollector.info("Canceling subscription", idDto);
563
603
  }
564
- const subscription = await (em ?? this.em).findOne("Subscription", idDto);
604
+ const subscription = await (em ?? this.em).findOne(
605
+ this.mappers.SubscriptionMapper.entity,
606
+ idDto
607
+ );
565
608
  if (!subscription) {
566
609
  throw new Error("Subscription not found");
567
610
  }
@@ -574,7 +617,10 @@ var BaseSubscriptionService = class {
574
617
  if (this.evaluatedTelemetryOptions.logging) {
575
618
  this.openTelemetryCollector.info("Resuming subscription", idDto);
576
619
  }
577
- const subscription = await (em ?? this.em).findOne("Subscription", idDto);
620
+ const subscription = await (em ?? this.em).findOne(
621
+ this.mappers.SubscriptionMapper.entity,
622
+ idDto
623
+ );
578
624
  if (!subscription) {
579
625
  throw new Error("Subscription not found");
580
626
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-billing-base",
3
- "version": "0.8.23",
3
+ "version": "0.9.0",
4
4
  "description": "Billing basic implementation for forklaunch",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -36,18 +36,18 @@
36
36
  "lib/**"
37
37
  ],
38
38
  "dependencies": {
39
- "@forklaunch/common": "^0.6.38",
40
- "@forklaunch/core": "^0.18.15",
41
- "@forklaunch/internal": "^0.3.40",
42
- "@forklaunch/validator": "^0.10.38",
43
- "@mikro-orm/core": "6.6.9",
39
+ "@forklaunch/common": "^0.7.5",
40
+ "@forklaunch/core": "^0.19.5",
41
+ "@forklaunch/internal": "^0.4.5",
42
+ "@forklaunch/validator": "^0.11.5",
43
+ "@mikro-orm/core": "7.0.4",
44
44
  "@sinclair/typebox": "^0.34.48",
45
45
  "ajv": "^8.18.0",
46
46
  "zod": "^4.3.6",
47
- "@forklaunch/interfaces-billing": "0.8.23"
47
+ "@forklaunch/interfaces-billing": "0.9.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@typescript/native-preview": "7.0.0-dev.20260312.1",
50
+ "@typescript/native-preview": "7.0.0-dev.20260320.1",
51
51
  "depcheck": "^1.4.7",
52
52
  "prettier": "^3.8.1",
53
53
  "typedoc": "^0.28.17"