@forklaunch/implementation-billing-base 0.3.2 → 0.3.3

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.
@@ -4,8 +4,8 @@ import {
4
4
  evaluateTelemetryOptions
5
5
  } from "@forklaunch/core/http";
6
6
  import {
7
- transformIntoInternalDtoMapper
8
- } from "@forklaunch/core/mappers";
7
+ transformIntoInternalMapper
8
+ } from "@forklaunch/internal";
9
9
  var BaseBillingPortalService = class {
10
10
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
11
11
  this.em = em;
@@ -14,7 +14,7 @@ var BaseBillingPortalService = class {
14
14
  this.schemaValidator = schemaValidator;
15
15
  this.mappers = mappers;
16
16
  this.options = options;
17
- this.#mappers = transformIntoInternalDtoMapper(mappers, schemaValidator);
17
+ this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
18
18
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
19
19
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions(options.telemetry).enabled : {
20
20
  logging: false,
@@ -22,7 +22,7 @@ var BaseBillingPortalService = class {
22
22
  tracing: false
23
23
  };
24
24
  }
25
- #mappers;
25
+ _mappers;
26
26
  evaluatedTelemetryOptions;
27
27
  enableDatabaseBackup;
28
28
  createCacheKey = createCacheKey("billing_portal_session");
@@ -33,14 +33,14 @@ var BaseBillingPortalService = class {
33
33
  billingPortalDto
34
34
  );
35
35
  }
36
- const billingPortal = await this.#mappers.CreateBillingPortalDtoMapper.deserializeDtoToEntity(
36
+ const billingPortal = await this._mappers.CreateBillingPortalMapper.deserializeDtoToEntity(
37
37
  billingPortalDto,
38
38
  this.em
39
39
  );
40
40
  if (this.enableDatabaseBackup) {
41
41
  await this.em.persistAndFlush(billingPortal);
42
42
  }
43
- const createdBillingPortalDto = await this.#mappers.BillingPortalDtoMapper.serializeEntityToDto(
43
+ const createdBillingPortalDto = await this._mappers.BillingPortalMapper.serializeEntityToDto(
44
44
  billingPortal
45
45
  );
46
46
  await this.cache.putRecord({
@@ -73,7 +73,7 @@ var BaseBillingPortalService = class {
73
73
  if (!existingBillingPortal) {
74
74
  throw new Error("Session not found");
75
75
  }
76
- const billingPortal = await this.#mappers.UpdateBillingPortalDtoMapper.deserializeDtoToEntity(
76
+ const billingPortal = await this._mappers.UpdateBillingPortalMapper.deserializeDtoToEntity(
77
77
  billingPortalDto,
78
78
  this.em
79
79
  );
@@ -84,7 +84,7 @@ var BaseBillingPortalService = class {
84
84
  }
85
85
  const updatedBillingPortalDto = {
86
86
  ...existingBillingPortal,
87
- ...await this.#mappers.BillingPortalDtoMapper.serializeEntityToDto(
87
+ ...await this._mappers.BillingPortalMapper.serializeEntityToDto(
88
88
  billingPortal
89
89
  )
90
90
  };
@@ -118,8 +118,8 @@ import {
118
118
  evaluateTelemetryOptions as evaluateTelemetryOptions2
119
119
  } from "@forklaunch/core/http";
120
120
  import {
121
- transformIntoInternalDtoMapper as transformIntoInternalDtoMapper2
122
- } from "@forklaunch/core/mappers";
121
+ transformIntoInternalMapper as transformIntoInternalMapper2
122
+ } from "@forklaunch/internal";
123
123
  var BaseCheckoutSessionService = class {
124
124
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
125
125
  this.em = em;
@@ -128,7 +128,7 @@ var BaseCheckoutSessionService = class {
128
128
  this.schemaValidator = schemaValidator;
129
129
  this.mappers = mappers;
130
130
  this.options = options;
131
- this.#mappers = transformIntoInternalDtoMapper2(mappers, schemaValidator);
131
+ this._mappers = transformIntoInternalMapper2(mappers, schemaValidator);
132
132
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
133
133
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions2(options.telemetry).enabled : {
134
134
  logging: false,
@@ -136,7 +136,7 @@ var BaseCheckoutSessionService = class {
136
136
  tracing: false
137
137
  };
138
138
  }
139
- #mappers;
139
+ _mappers;
140
140
  evaluatedTelemetryOptions;
141
141
  enableDatabaseBackup;
142
142
  createCacheKey = createCacheKey2("checkout_session");
@@ -147,11 +147,11 @@ var BaseCheckoutSessionService = class {
147
147
  checkoutSessionDto
148
148
  );
149
149
  }
150
- const checkoutSession = await this.#mappers.CreateCheckoutSessionDtoMapper.deserializeDtoToEntity(
150
+ const checkoutSession = await this._mappers.CreateCheckoutSessionMapper.deserializeDtoToEntity(
151
151
  checkoutSessionDto,
152
152
  this.em
153
153
  );
154
- const createdCheckoutSessionDto = await this.#mappers.CheckoutSessionDtoMapper.serializeEntityToDto(
154
+ const createdCheckoutSessionDto = await this._mappers.CheckoutSessionMapper.serializeEntityToDto(
155
155
  checkoutSession
156
156
  );
157
157
  if (this.enableDatabaseBackup) {
@@ -171,7 +171,7 @@ var BaseCheckoutSessionService = class {
171
171
  if (!checkoutSessionDetails) {
172
172
  throw new Error("Session not found");
173
173
  }
174
- return this.#mappers.CheckoutSessionDtoMapper.serializeEntityToDto(
174
+ return this._mappers.CheckoutSessionMapper.serializeEntityToDto(
175
175
  checkoutSessionDetails.value
176
176
  );
177
177
  }
@@ -218,8 +218,8 @@ import {
218
218
  evaluateTelemetryOptions as evaluateTelemetryOptions3
219
219
  } from "@forklaunch/core/http";
220
220
  import {
221
- transformIntoInternalDtoMapper as transformIntoInternalDtoMapper3
222
- } from "@forklaunch/core/mappers";
221
+ transformIntoInternalMapper as transformIntoInternalMapper3
222
+ } from "@forklaunch/internal";
223
223
  var BasePaymentLinkService = class {
224
224
  constructor(em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
225
225
  this.em = em;
@@ -228,7 +228,7 @@ var BasePaymentLinkService = class {
228
228
  this.schemaValidator = schemaValidator;
229
229
  this.mappers = mappers;
230
230
  this.options = options;
231
- this.#mappers = transformIntoInternalDtoMapper3(mappers, schemaValidator);
231
+ this._mappers = transformIntoInternalMapper3(mappers, schemaValidator);
232
232
  this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
233
233
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions3(options.telemetry).enabled : {
234
234
  logging: false,
@@ -236,7 +236,7 @@ var BasePaymentLinkService = class {
236
236
  tracing: false
237
237
  };
238
238
  }
239
- #mappers;
239
+ _mappers;
240
240
  evaluatedTelemetryOptions;
241
241
  enableDatabaseBackup;
242
242
  cacheKeyPrefix = "payment_link";
@@ -245,16 +245,14 @@ var BasePaymentLinkService = class {
245
245
  if (this.evaluatedTelemetryOptions.logging) {
246
246
  this.openTelemetryCollector.info("Creating payment link", paymentLinkDto);
247
247
  }
248
- const paymentLink = await this.#mappers.CreatePaymentLinkDtoMapper.deserializeDtoToEntity(
248
+ const paymentLink = await this._mappers.CreatePaymentLinkMapper.deserializeDtoToEntity(
249
249
  paymentLinkDto,
250
250
  this.em
251
251
  );
252
252
  if (this.enableDatabaseBackup) {
253
253
  await this.em.persistAndFlush(paymentLink);
254
254
  }
255
- const createdPaymentLinkDto = await this.#mappers.PaymentLinkDtoMapper.serializeEntityToDto(
256
- paymentLink
257
- );
255
+ const createdPaymentLinkDto = await this._mappers.PaymentLinkMapper.serializeEntityToDto(paymentLink);
258
256
  await this.cache.putRecord({
259
257
  key: this.createCacheKey(createdPaymentLinkDto.id),
260
258
  value: createdPaymentLinkDto,
@@ -271,7 +269,7 @@ var BasePaymentLinkService = class {
271
269
  if (!existingLink) {
272
270
  throw new Error("Payment link not found");
273
271
  }
274
- const paymentLink = await this.#mappers.UpdatePaymentLinkDtoMapper.deserializeDtoToEntity(
272
+ const paymentLink = await this._mappers.UpdatePaymentLinkMapper.deserializeDtoToEntity(
275
273
  paymentLinkDto,
276
274
  this.em
277
275
  );
@@ -280,7 +278,7 @@ var BasePaymentLinkService = class {
280
278
  }
281
279
  const updatedLinkDto = {
282
280
  ...existingLink,
283
- ...await this.#mappers.PaymentLinkDtoMapper.serializeEntityToDto(
281
+ ...await this._mappers.PaymentLinkMapper.serializeEntityToDto(
284
282
  paymentLink
285
283
  )
286
284
  };
@@ -300,7 +298,7 @@ var BasePaymentLinkService = class {
300
298
  if (!paymentLink) {
301
299
  throw new Error("Payment link not found");
302
300
  }
303
- return this.#mappers.PaymentLinkDtoMapper.serializeEntityToDto(
301
+ return this._mappers.PaymentLinkMapper.serializeEntityToDto(
304
302
  paymentLink.value
305
303
  );
306
304
  }
@@ -342,7 +340,7 @@ var BasePaymentLinkService = class {
342
340
  return Promise.all(
343
341
  keys.map(async (key) => {
344
342
  const paymentLink = await this.cache.readRecord(key);
345
- const paymentLinkDto = this.#mappers.PaymentLinkDtoMapper.serializeEntityToDto(
343
+ const paymentLinkDto = this._mappers.PaymentLinkMapper.serializeEntityToDto(
346
344
  paymentLink.value
347
345
  );
348
346
  return paymentLinkDto;
@@ -356,8 +354,8 @@ import {
356
354
  evaluateTelemetryOptions as evaluateTelemetryOptions4
357
355
  } from "@forklaunch/core/http";
358
356
  import {
359
- transformIntoInternalDtoMapper as transformIntoInternalDtoMapper4
360
- } from "@forklaunch/core/mappers";
357
+ transformIntoInternalMapper as transformIntoInternalMapper4
358
+ } from "@forklaunch/internal";
361
359
  var BasePlanService = class {
362
360
  constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
363
361
  this.em = em;
@@ -365,14 +363,14 @@ var BasePlanService = class {
365
363
  this.schemaValidator = schemaValidator;
366
364
  this.mappers = mappers;
367
365
  this.options = options;
368
- this.#mappers = transformIntoInternalDtoMapper4(mappers, schemaValidator);
366
+ this._mappers = transformIntoInternalMapper4(mappers, schemaValidator);
369
367
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions4(options.telemetry).enabled : {
370
368
  logging: false,
371
369
  metrics: false,
372
370
  tracing: false
373
371
  };
374
372
  }
375
- #mappers;
373
+ _mappers;
376
374
  evaluatedTelemetryOptions;
377
375
  async listPlans(idsDto, em) {
378
376
  if (this.evaluatedTelemetryOptions.logging) {
@@ -382,7 +380,7 @@ var BasePlanService = class {
382
380
  (await (em ?? this.em).findAll("Plan", {
383
381
  filters: idsDto?.ids ? { id: { $in: idsDto.ids } } : void 0
384
382
  })).map(
385
- (plan) => this.#mappers.PlanDtoMapper.serializeEntityToDto(
383
+ (plan) => this._mappers.PlanMapper.serializeEntityToDto(
386
384
  plan
387
385
  )
388
386
  )
@@ -392,21 +390,21 @@ var BasePlanService = class {
392
390
  if (this.evaluatedTelemetryOptions.logging) {
393
391
  this.openTelemetryCollector.info("Creating plan", planDto);
394
392
  }
395
- const plan = await this.#mappers.CreatePlanDtoMapper.deserializeDtoToEntity(
393
+ const plan = await this._mappers.CreatePlanMapper.deserializeDtoToEntity(
396
394
  planDto,
397
395
  em ?? this.em
398
396
  );
399
397
  await (em ?? this.em).transactional(async (innerEm) => {
400
398
  await innerEm.persist(plan);
401
399
  });
402
- return this.#mappers.PlanDtoMapper.serializeEntityToDto(plan);
400
+ return this._mappers.PlanMapper.serializeEntityToDto(plan);
403
401
  }
404
402
  async getPlan(idDto, em) {
405
403
  if (this.evaluatedTelemetryOptions.logging) {
406
404
  this.openTelemetryCollector.info("Getting plan", idDto);
407
405
  }
408
406
  const plan = await (em ?? this.em).findOneOrFail("Plan", idDto);
409
- return this.#mappers.PlanDtoMapper.serializeEntityToDto(
407
+ return this._mappers.PlanMapper.serializeEntityToDto(
410
408
  plan
411
409
  );
412
410
  }
@@ -414,7 +412,7 @@ var BasePlanService = class {
414
412
  if (this.evaluatedTelemetryOptions.logging) {
415
413
  this.openTelemetryCollector.info("Updating plan", planDto);
416
414
  }
417
- const plan = await this.#mappers.UpdatePlanDtoMapper.deserializeDtoToEntity(
415
+ const plan = await this._mappers.UpdatePlanMapper.deserializeDtoToEntity(
418
416
  planDto,
419
417
  em ?? this.em
420
418
  );
@@ -422,7 +420,7 @@ var BasePlanService = class {
422
420
  await (em ?? this.em).transactional(async (innerEm) => {
423
421
  await innerEm.persist(plan);
424
422
  });
425
- const updatedPlanDto = await this.#mappers.PlanDtoMapper.serializeEntityToDto(updatedPlan);
423
+ const updatedPlanDto = await this._mappers.PlanMapper.serializeEntityToDto(updatedPlan);
426
424
  return updatedPlanDto;
427
425
  }
428
426
  async deletePlan(idDto, em) {
@@ -438,8 +436,8 @@ import {
438
436
  evaluateTelemetryOptions as evaluateTelemetryOptions5
439
437
  } from "@forklaunch/core/http";
440
438
  import {
441
- transformIntoInternalDtoMapper as transformIntoInternalDtoMapper5
442
- } from "@forklaunch/core/mappers";
439
+ transformIntoInternalMapper as transformIntoInternalMapper5
440
+ } from "@forklaunch/internal";
443
441
  var BaseSubscriptionService = class {
444
442
  constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
445
443
  this.em = em;
@@ -447,14 +445,14 @@ var BaseSubscriptionService = class {
447
445
  this.schemaValidator = schemaValidator;
448
446
  this.mappers = mappers;
449
447
  this.options = options;
450
- this.#mappers = transformIntoInternalDtoMapper5(mappers, this.schemaValidator);
448
+ this._mappers = transformIntoInternalMapper5(mappers, this.schemaValidator);
451
449
  this.evaluatedTelemetryOptions = options?.telemetry ? evaluateTelemetryOptions5(options.telemetry).enabled : {
452
450
  logging: false,
453
451
  metrics: false,
454
452
  tracing: false
455
453
  };
456
454
  }
457
- #mappers;
455
+ _mappers;
458
456
  evaluatedTelemetryOptions;
459
457
  async createSubscription(subscriptionDto, em) {
460
458
  if (this.evaluatedTelemetryOptions.logging) {
@@ -463,16 +461,14 @@ var BaseSubscriptionService = class {
463
461
  subscriptionDto
464
462
  );
465
463
  }
466
- const subscription = await this.#mappers.CreateSubscriptionDtoMapper.deserializeDtoToEntity(
464
+ const subscription = await this._mappers.CreateSubscriptionMapper.deserializeDtoToEntity(
467
465
  subscriptionDto,
468
466
  em ?? this.em
469
467
  );
470
468
  await (em ?? this.em).transactional(async (innerEm) => {
471
469
  await innerEm.persist(subscription);
472
470
  });
473
- const createdSubscriptionDto = await this.#mappers.SubscriptionDtoMapper.serializeEntityToDto(
474
- subscription
475
- );
471
+ const createdSubscriptionDto = await this._mappers.SubscriptionMapper.serializeEntityToDto(subscription);
476
472
  return createdSubscriptionDto;
477
473
  }
478
474
  async getSubscription(idDto, em) {
@@ -483,7 +479,7 @@ var BaseSubscriptionService = class {
483
479
  "Subscription",
484
480
  idDto
485
481
  );
486
- return this.#mappers.SubscriptionDtoMapper.serializeEntityToDto(
482
+ return this._mappers.SubscriptionMapper.serializeEntityToDto(
487
483
  subscription
488
484
  );
489
485
  }
@@ -496,7 +492,7 @@ var BaseSubscriptionService = class {
496
492
  partyType: "USER",
497
493
  active: true
498
494
  });
499
- return this.#mappers.SubscriptionDtoMapper.serializeEntityToDto(
495
+ return this._mappers.SubscriptionMapper.serializeEntityToDto(
500
496
  subscription
501
497
  );
502
498
  }
@@ -509,7 +505,7 @@ var BaseSubscriptionService = class {
509
505
  partyType: "ORGANIZATION",
510
506
  active: true
511
507
  });
512
- return this.#mappers.SubscriptionDtoMapper.serializeEntityToDto(
508
+ return this._mappers.SubscriptionMapper.serializeEntityToDto(
513
509
  subscription
514
510
  );
515
511
  }
@@ -520,7 +516,7 @@ var BaseSubscriptionService = class {
520
516
  subscriptionDto
521
517
  );
522
518
  }
523
- const subscription = this.#mappers.UpdateSubscriptionDtoMapper.deserializeDtoToEntity(
519
+ const subscription = this._mappers.UpdateSubscriptionMapper.deserializeDtoToEntity(
524
520
  subscriptionDto,
525
521
  em ?? this.em
526
522
  );
@@ -528,7 +524,7 @@ var BaseSubscriptionService = class {
528
524
  await (em ?? this.em).transactional(async (innerEm) => {
529
525
  await innerEm.persist(updatedSubscription);
530
526
  });
531
- const updatedSubscriptionDto = await this.#mappers.SubscriptionDtoMapper.serializeEntityToDto(
527
+ const updatedSubscriptionDto = await this._mappers.SubscriptionMapper.serializeEntityToDto(
532
528
  updatedSubscription
533
529
  );
534
530
  return updatedSubscriptionDto;
@@ -556,7 +552,7 @@ var BaseSubscriptionService = class {
556
552
  });
557
553
  return Promise.all(
558
554
  subscriptions.map((subscription) => {
559
- const subscriptionDto = this.#mappers.SubscriptionDtoMapper.serializeEntityToDto(
555
+ const subscriptionDto = this._mappers.SubscriptionMapper.serializeEntityToDto(
560
556
  subscription
561
557
  );
562
558
  return subscriptionDto;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-billing-base",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Billing basic implementation for forklaunch",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -30,17 +30,18 @@
30
30
  "lib/**"
31
31
  ],
32
32
  "dependencies": {
33
- "@forklaunch/common": "^0.3.11",
34
- "@forklaunch/core": "^0.9.15",
35
- "@forklaunch/validator": "^0.6.13",
33
+ "@forklaunch/common": "^0.3.14",
34
+ "@forklaunch/core": "^0.9.21",
35
+ "@forklaunch/internal": "^0.0.7",
36
+ "@forklaunch/validator": "^0.6.16",
36
37
  "@mikro-orm/core": "^6.4.16",
37
- "@sinclair/typebox": "^0.34.33",
38
+ "@sinclair/typebox": "^0.34.35",
38
39
  "ajv": "^8.17.1",
39
- "zod": "^3.25.63",
40
- "@forklaunch/interfaces-billing": "0.3.0"
40
+ "zod": "^3.25.67",
41
+ "@forklaunch/interfaces-billing": "0.3.1"
41
42
  },
42
43
  "devDependencies": {
43
- "@typescript/native-preview": "7.0.0-dev.20250611.1",
44
+ "@typescript/native-preview": "7.0.0-dev.20250619.1",
44
45
  "depcheck": "^1.4.7",
45
46
  "prettier": "^3.5.3",
46
47
  "typedoc": "^0.28.5"