@forklaunch/implementation-billing-base 0.5.7 → 0.6.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.
- package/lib/domain/types/index.d.mts +326 -0
- package/lib/domain/types/index.d.ts +326 -0
- package/lib/domain/types/index.js +22 -0
- package/lib/domain/types/index.mjs +0 -0
- package/lib/eject/domain/types/billingPortal.mapper.types.ts +28 -0
- package/lib/eject/domain/types/checkoutSession.mapper.types.ts +39 -0
- package/lib/eject/domain/types/index.ts +7 -0
- package/lib/eject/domain/types/paymentLink.mapper.types.ts +39 -0
- package/lib/eject/domain/types/plan.mapper.types.ts +39 -0
- package/lib/eject/domain/types/subscription.mapper.types.ts +33 -0
- package/lib/eject/services/billingPortal.service.ts +33 -87
- package/lib/eject/services/checkoutSession.service.ts +40 -78
- package/lib/eject/services/paymentLink.service.ts +69 -97
- package/lib/eject/services/plan.service.ts +49 -86
- package/lib/eject/services/subscription.service.ts +36 -83
- package/lib/services/index.d.mts +168 -495
- package/lib/services/index.d.ts +168 -495
- package/lib/services/index.js +94 -139
- package/lib/services/index.mjs +94 -124
- package/package.json +10 -10
package/lib/services/index.mjs
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// services/billingPortal.service.ts
|
|
2
2
|
import { createCacheKey } from '@forklaunch/core/cache';
|
|
3
3
|
import { evaluateTelemetryOptions } from '@forklaunch/core/http';
|
|
4
|
-
import { transformIntoInternalMapper } from '@forklaunch/internal';
|
|
5
4
|
var BaseBillingPortalService = class {
|
|
5
|
+
evaluatedTelemetryOptions;
|
|
6
|
+
enableDatabaseBackup;
|
|
7
|
+
em;
|
|
8
|
+
cache;
|
|
9
|
+
openTelemetryCollector;
|
|
10
|
+
schemaValidator;
|
|
11
|
+
mappers;
|
|
6
12
|
constructor(
|
|
7
13
|
em,
|
|
8
14
|
cache,
|
|
@@ -11,13 +17,11 @@ var BaseBillingPortalService = class {
|
|
|
11
17
|
mappers,
|
|
12
18
|
options
|
|
13
19
|
) {
|
|
14
|
-
this.options = options;
|
|
15
20
|
this.em = em;
|
|
16
21
|
this.cache = cache;
|
|
17
22
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
18
23
|
this.schemaValidator = schemaValidator;
|
|
19
24
|
this.mappers = mappers;
|
|
20
|
-
this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
|
|
21
25
|
this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
|
|
22
26
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
23
27
|
? evaluateTelemetryOptions(options.telemetry).enabled
|
|
@@ -27,34 +31,24 @@ var BaseBillingPortalService = class {
|
|
|
27
31
|
tracing: false
|
|
28
32
|
};
|
|
29
33
|
}
|
|
30
|
-
_mappers;
|
|
31
|
-
evaluatedTelemetryOptions;
|
|
32
|
-
enableDatabaseBackup;
|
|
33
|
-
em;
|
|
34
|
-
cache;
|
|
35
|
-
openTelemetryCollector;
|
|
36
|
-
schemaValidator;
|
|
37
|
-
mappers;
|
|
38
34
|
createCacheKey = createCacheKey('billing_portal_session');
|
|
39
|
-
async createBillingPortalSession(billingPortalDto) {
|
|
35
|
+
async createBillingPortalSession(billingPortalDto, ...args) {
|
|
40
36
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
41
37
|
this.openTelemetryCollector.info(
|
|
42
38
|
'Creating billing portal session',
|
|
43
39
|
billingPortalDto
|
|
44
40
|
);
|
|
45
41
|
}
|
|
46
|
-
const billingPortal =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
const billingPortal = await this.mappers.CreateBillingPortalMapper.toEntity(
|
|
43
|
+
billingPortalDto,
|
|
44
|
+
this.em,
|
|
45
|
+
...args
|
|
46
|
+
);
|
|
51
47
|
if (this.enableDatabaseBackup) {
|
|
52
48
|
await this.em.persistAndFlush(billingPortal);
|
|
53
49
|
}
|
|
54
50
|
const createdBillingPortalDto =
|
|
55
|
-
await this.
|
|
56
|
-
billingPortal
|
|
57
|
-
);
|
|
51
|
+
await this.mappers.BillingPortalMapper.toDto(billingPortal);
|
|
58
52
|
await this.cache.putRecord({
|
|
59
53
|
key: this.createCacheKey(createdBillingPortalDto.id),
|
|
60
54
|
value: createdBillingPortalDto,
|
|
@@ -74,7 +68,7 @@ var BaseBillingPortalService = class {
|
|
|
74
68
|
}
|
|
75
69
|
return billingPortalDetails.value;
|
|
76
70
|
}
|
|
77
|
-
async updateBillingPortalSession(billingPortalDto) {
|
|
71
|
+
async updateBillingPortalSession(billingPortalDto, ...args) {
|
|
78
72
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
79
73
|
this.openTelemetryCollector.info(
|
|
80
74
|
'Updating billing portal session',
|
|
@@ -87,11 +81,11 @@ var BaseBillingPortalService = class {
|
|
|
87
81
|
if (!existingBillingPortal) {
|
|
88
82
|
throw new Error('Session not found');
|
|
89
83
|
}
|
|
90
|
-
const billingPortal =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
const billingPortal = await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
85
|
+
billingPortalDto,
|
|
86
|
+
this.em,
|
|
87
|
+
...args
|
|
88
|
+
);
|
|
95
89
|
if (this.enableDatabaseBackup) {
|
|
96
90
|
await this.em.persistAndFlush({
|
|
97
91
|
billingPortal
|
|
@@ -99,9 +93,7 @@ var BaseBillingPortalService = class {
|
|
|
99
93
|
}
|
|
100
94
|
const updatedBillingPortalDto = {
|
|
101
95
|
...existingBillingPortal,
|
|
102
|
-
...(await this.
|
|
103
|
-
billingPortal
|
|
104
|
-
))
|
|
96
|
+
...(await this.mappers.BillingPortalMapper.toDto(billingPortal))
|
|
105
97
|
};
|
|
106
98
|
await this.cache.putRecord({
|
|
107
99
|
key: this.createCacheKey(updatedBillingPortalDto.id),
|
|
@@ -130,8 +122,14 @@ var BaseBillingPortalService = class {
|
|
|
130
122
|
// services/checkoutSession.service.ts
|
|
131
123
|
import { createCacheKey as createCacheKey2 } from '@forklaunch/core/cache';
|
|
132
124
|
import { evaluateTelemetryOptions as evaluateTelemetryOptions2 } from '@forklaunch/core/http';
|
|
133
|
-
import { transformIntoInternalMapper as transformIntoInternalMapper2 } from '@forklaunch/internal';
|
|
134
125
|
var BaseCheckoutSessionService = class {
|
|
126
|
+
evaluatedTelemetryOptions;
|
|
127
|
+
enableDatabaseBackup;
|
|
128
|
+
em;
|
|
129
|
+
cache;
|
|
130
|
+
openTelemetryCollector;
|
|
131
|
+
schemaValidator;
|
|
132
|
+
mappers;
|
|
135
133
|
constructor(
|
|
136
134
|
em,
|
|
137
135
|
cache,
|
|
@@ -140,13 +138,11 @@ var BaseCheckoutSessionService = class {
|
|
|
140
138
|
mappers,
|
|
141
139
|
options
|
|
142
140
|
) {
|
|
143
|
-
this.options = options;
|
|
144
141
|
this.em = em;
|
|
145
142
|
this.cache = cache;
|
|
146
143
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
147
144
|
this.schemaValidator = schemaValidator;
|
|
148
145
|
this.mappers = mappers;
|
|
149
|
-
this._mappers = transformIntoInternalMapper2(mappers, schemaValidator);
|
|
150
146
|
this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
|
|
151
147
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
152
148
|
? evaluateTelemetryOptions2(options.telemetry).enabled
|
|
@@ -156,16 +152,8 @@ var BaseCheckoutSessionService = class {
|
|
|
156
152
|
tracing: false
|
|
157
153
|
};
|
|
158
154
|
}
|
|
159
|
-
_mappers;
|
|
160
|
-
evaluatedTelemetryOptions;
|
|
161
|
-
enableDatabaseBackup;
|
|
162
|
-
em;
|
|
163
|
-
cache;
|
|
164
|
-
openTelemetryCollector;
|
|
165
|
-
schemaValidator;
|
|
166
|
-
mappers;
|
|
167
155
|
createCacheKey = createCacheKey2('checkout_session');
|
|
168
|
-
async createCheckoutSession(checkoutSessionDto) {
|
|
156
|
+
async createCheckoutSession(checkoutSessionDto, ...args) {
|
|
169
157
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
170
158
|
this.openTelemetryCollector.info(
|
|
171
159
|
'Creating checkout session',
|
|
@@ -173,14 +161,13 @@ var BaseCheckoutSessionService = class {
|
|
|
173
161
|
);
|
|
174
162
|
}
|
|
175
163
|
const checkoutSession =
|
|
176
|
-
await this.
|
|
164
|
+
await this.mappers.CreateCheckoutSessionMapper.toEntity(
|
|
177
165
|
checkoutSessionDto,
|
|
178
|
-
this.em
|
|
166
|
+
this.em,
|
|
167
|
+
...args
|
|
179
168
|
);
|
|
180
169
|
const createdCheckoutSessionDto =
|
|
181
|
-
await this.
|
|
182
|
-
checkoutSession
|
|
183
|
-
);
|
|
170
|
+
await this.mappers.CheckoutSessionMapper.toDto(checkoutSession);
|
|
184
171
|
if (this.enableDatabaseBackup) {
|
|
185
172
|
await this.em.persistAndFlush(checkoutSession);
|
|
186
173
|
}
|
|
@@ -198,7 +185,7 @@ var BaseCheckoutSessionService = class {
|
|
|
198
185
|
if (!checkoutSessionDetails) {
|
|
199
186
|
throw new Error('Session not found');
|
|
200
187
|
}
|
|
201
|
-
return this.
|
|
188
|
+
return this.mappers.CheckoutSessionMapper.toDto(
|
|
202
189
|
checkoutSessionDetails.value
|
|
203
190
|
);
|
|
204
191
|
}
|
|
@@ -242,8 +229,14 @@ var BaseCheckoutSessionService = class {
|
|
|
242
229
|
// services/paymentLink.service.ts
|
|
243
230
|
import { createCacheKey as createCacheKey3 } from '@forklaunch/core/cache';
|
|
244
231
|
import { evaluateTelemetryOptions as evaluateTelemetryOptions3 } from '@forklaunch/core/http';
|
|
245
|
-
import { transformIntoInternalMapper as transformIntoInternalMapper3 } from '@forklaunch/internal';
|
|
246
232
|
var BasePaymentLinkService = class {
|
|
233
|
+
evaluatedTelemetryOptions;
|
|
234
|
+
enableDatabaseBackup;
|
|
235
|
+
em;
|
|
236
|
+
cache;
|
|
237
|
+
openTelemetryCollector;
|
|
238
|
+
schemaValidator;
|
|
239
|
+
mappers;
|
|
247
240
|
constructor(
|
|
248
241
|
em,
|
|
249
242
|
cache,
|
|
@@ -252,13 +245,11 @@ var BasePaymentLinkService = class {
|
|
|
252
245
|
mappers,
|
|
253
246
|
options
|
|
254
247
|
) {
|
|
255
|
-
this.options = options;
|
|
256
248
|
this.em = em;
|
|
257
249
|
this.cache = cache;
|
|
258
250
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
259
251
|
this.schemaValidator = schemaValidator;
|
|
260
252
|
this.mappers = mappers;
|
|
261
|
-
this._mappers = transformIntoInternalMapper3(mappers, schemaValidator);
|
|
262
253
|
this.enableDatabaseBackup = options?.enableDatabaseBackup ?? false;
|
|
263
254
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
264
255
|
? evaluateTelemetryOptions3(options.telemetry).enabled
|
|
@@ -268,30 +259,22 @@ var BasePaymentLinkService = class {
|
|
|
268
259
|
tracing: false
|
|
269
260
|
};
|
|
270
261
|
}
|
|
271
|
-
_mappers;
|
|
272
|
-
evaluatedTelemetryOptions;
|
|
273
|
-
enableDatabaseBackup;
|
|
274
|
-
em;
|
|
275
|
-
cache;
|
|
276
|
-
openTelemetryCollector;
|
|
277
|
-
schemaValidator;
|
|
278
|
-
mappers;
|
|
279
262
|
cacheKeyPrefix = 'payment_link';
|
|
280
263
|
createCacheKey = createCacheKey3(this.cacheKeyPrefix);
|
|
281
|
-
async createPaymentLink(paymentLinkDto) {
|
|
264
|
+
async createPaymentLink(paymentLinkDto, ...args) {
|
|
282
265
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
283
266
|
this.openTelemetryCollector.info('Creating payment link', paymentLinkDto);
|
|
284
267
|
}
|
|
285
|
-
const paymentLink =
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
268
|
+
const paymentLink = await this.mappers.CreatePaymentLinkMapper.toEntity(
|
|
269
|
+
paymentLinkDto,
|
|
270
|
+
this.em,
|
|
271
|
+
...args
|
|
272
|
+
);
|
|
290
273
|
if (this.enableDatabaseBackup) {
|
|
291
274
|
await this.em.persistAndFlush(paymentLink);
|
|
292
275
|
}
|
|
293
276
|
const createdPaymentLinkDto =
|
|
294
|
-
await this.
|
|
277
|
+
await this.mappers.PaymentLinkMapper.toDto(paymentLink);
|
|
295
278
|
await this.cache.putRecord({
|
|
296
279
|
key: this.createCacheKey(createdPaymentLinkDto.id),
|
|
297
280
|
value: createdPaymentLinkDto,
|
|
@@ -299,7 +282,7 @@ var BasePaymentLinkService = class {
|
|
|
299
282
|
});
|
|
300
283
|
return createdPaymentLinkDto;
|
|
301
284
|
}
|
|
302
|
-
async updatePaymentLink(paymentLinkDto) {
|
|
285
|
+
async updatePaymentLink(paymentLinkDto, ...args) {
|
|
303
286
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
304
287
|
this.openTelemetryCollector.info('Updating payment link', paymentLinkDto);
|
|
305
288
|
}
|
|
@@ -308,19 +291,17 @@ var BasePaymentLinkService = class {
|
|
|
308
291
|
if (!existingLink) {
|
|
309
292
|
throw new Error('Payment link not found');
|
|
310
293
|
}
|
|
311
|
-
const paymentLink =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
294
|
+
const paymentLink = await this.mappers.UpdatePaymentLinkMapper.toEntity(
|
|
295
|
+
paymentLinkDto,
|
|
296
|
+
this.em,
|
|
297
|
+
...args
|
|
298
|
+
);
|
|
316
299
|
if (this.enableDatabaseBackup) {
|
|
317
300
|
await this.em.persistAndFlush(paymentLink);
|
|
318
301
|
}
|
|
319
302
|
const updatedLinkDto = {
|
|
320
303
|
...existingLink,
|
|
321
|
-
...(await this.
|
|
322
|
-
paymentLink
|
|
323
|
-
))
|
|
304
|
+
...(await this.mappers.PaymentLinkMapper.toDto(paymentLink))
|
|
324
305
|
};
|
|
325
306
|
await this.cache.putRecord({
|
|
326
307
|
key: cacheKey,
|
|
@@ -338,9 +319,7 @@ var BasePaymentLinkService = class {
|
|
|
338
319
|
if (!paymentLink) {
|
|
339
320
|
throw new Error('Payment link not found');
|
|
340
321
|
}
|
|
341
|
-
return this.
|
|
342
|
-
paymentLink.value
|
|
343
|
-
);
|
|
322
|
+
return this.mappers.PaymentLinkMapper.toDto(paymentLink.value);
|
|
344
323
|
}
|
|
345
324
|
async expirePaymentLink({ id }) {
|
|
346
325
|
this.openTelemetryCollector.info('Payment link expired', { id });
|
|
@@ -382,10 +361,9 @@ var BasePaymentLinkService = class {
|
|
|
382
361
|
return Promise.all(
|
|
383
362
|
keys.map(async (key) => {
|
|
384
363
|
const paymentLink = await this.cache.readRecord(key);
|
|
385
|
-
const paymentLinkDto =
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
);
|
|
364
|
+
const paymentLinkDto = this.mappers.PaymentLinkMapper.toDto(
|
|
365
|
+
paymentLink.value
|
|
366
|
+
);
|
|
389
367
|
return paymentLinkDto;
|
|
390
368
|
})
|
|
391
369
|
);
|
|
@@ -394,15 +372,17 @@ var BasePaymentLinkService = class {
|
|
|
394
372
|
|
|
395
373
|
// services/plan.service.ts
|
|
396
374
|
import { evaluateTelemetryOptions as evaluateTelemetryOptions4 } from '@forklaunch/core/http';
|
|
397
|
-
import { transformIntoInternalMapper as transformIntoInternalMapper4 } from '@forklaunch/internal';
|
|
398
375
|
var BasePlanService = class {
|
|
376
|
+
evaluatedTelemetryOptions;
|
|
377
|
+
em;
|
|
378
|
+
openTelemetryCollector;
|
|
379
|
+
schemaValidator;
|
|
380
|
+
mappers;
|
|
399
381
|
constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
400
|
-
this.options = options;
|
|
401
382
|
this.em = em;
|
|
402
383
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
403
384
|
this.schemaValidator = schemaValidator;
|
|
404
385
|
this.mappers = mappers;
|
|
405
|
-
this._mappers = transformIntoInternalMapper4(mappers, schemaValidator);
|
|
406
386
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
407
387
|
? evaluateTelemetryOptions4(options.telemetry).enabled
|
|
408
388
|
: {
|
|
@@ -411,12 +391,6 @@ var BasePlanService = class {
|
|
|
411
391
|
tracing: false
|
|
412
392
|
};
|
|
413
393
|
}
|
|
414
|
-
_mappers;
|
|
415
|
-
evaluatedTelemetryOptions;
|
|
416
|
-
em;
|
|
417
|
-
openTelemetryCollector;
|
|
418
|
-
schemaValidator;
|
|
419
|
-
mappers;
|
|
420
394
|
async listPlans(idsDto, em) {
|
|
421
395
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
422
396
|
this.openTelemetryCollector.info('Listing plans', idsDto);
|
|
@@ -426,43 +400,44 @@ var BasePlanService = class {
|
|
|
426
400
|
await (em ?? this.em).findAll('Plan', {
|
|
427
401
|
filters: idsDto?.ids ? { id: { $in: idsDto.ids } } : void 0
|
|
428
402
|
})
|
|
429
|
-
).map((plan) => this.
|
|
403
|
+
).map((plan) => this.mappers.PlanMapper.toDto(plan))
|
|
430
404
|
);
|
|
431
405
|
}
|
|
432
|
-
async createPlan(planDto, em) {
|
|
406
|
+
async createPlan(planDto, em, ...args) {
|
|
433
407
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
434
408
|
this.openTelemetryCollector.info('Creating plan', planDto);
|
|
435
409
|
}
|
|
436
|
-
const plan = await this.
|
|
410
|
+
const plan = await this.mappers.CreatePlanMapper.toEntity(
|
|
437
411
|
planDto,
|
|
438
|
-
em ?? this.em
|
|
412
|
+
em ?? this.em,
|
|
413
|
+
...args
|
|
439
414
|
);
|
|
440
415
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
441
416
|
await innerEm.persist(plan);
|
|
442
417
|
});
|
|
443
|
-
return this.
|
|
418
|
+
return this.mappers.PlanMapper.toDto(plan);
|
|
444
419
|
}
|
|
445
420
|
async getPlan(idDto, em) {
|
|
446
421
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
447
422
|
this.openTelemetryCollector.info('Getting plan', idDto);
|
|
448
423
|
}
|
|
449
424
|
const plan = await (em ?? this.em).findOneOrFail('Plan', idDto);
|
|
450
|
-
return this.
|
|
425
|
+
return this.mappers.PlanMapper.toDto(plan);
|
|
451
426
|
}
|
|
452
|
-
async updatePlan(planDto, em) {
|
|
427
|
+
async updatePlan(planDto, em, ...args) {
|
|
453
428
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
454
429
|
this.openTelemetryCollector.info('Updating plan', planDto);
|
|
455
430
|
}
|
|
456
|
-
const plan = await this.
|
|
431
|
+
const plan = await this.mappers.UpdatePlanMapper.toEntity(
|
|
457
432
|
planDto,
|
|
458
|
-
em ?? this.em
|
|
433
|
+
em ?? this.em,
|
|
434
|
+
...args
|
|
459
435
|
);
|
|
460
436
|
const updatedPlan = await (em ?? this.em).upsert(plan);
|
|
461
437
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
462
438
|
await innerEm.persist(plan);
|
|
463
439
|
});
|
|
464
|
-
const updatedPlanDto =
|
|
465
|
-
await this._mappers.PlanMapper.serializeEntityToDto(updatedPlan);
|
|
440
|
+
const updatedPlanDto = await this.mappers.PlanMapper.toDto(updatedPlan);
|
|
466
441
|
return updatedPlanDto;
|
|
467
442
|
}
|
|
468
443
|
async deletePlan(idDto, em) {
|
|
@@ -475,7 +450,6 @@ var BasePlanService = class {
|
|
|
475
450
|
|
|
476
451
|
// services/subscription.service.ts
|
|
477
452
|
import { evaluateTelemetryOptions as evaluateTelemetryOptions5 } from '@forklaunch/core/http';
|
|
478
|
-
import { transformIntoInternalMapper as transformIntoInternalMapper5 } from '@forklaunch/internal';
|
|
479
453
|
var BaseSubscriptionService = class {
|
|
480
454
|
constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
481
455
|
this.options = options;
|
|
@@ -483,7 +457,6 @@ var BaseSubscriptionService = class {
|
|
|
483
457
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
484
458
|
this.schemaValidator = schemaValidator;
|
|
485
459
|
this.mappers = mappers;
|
|
486
|
-
this._mappers = transformIntoInternalMapper5(mappers, this.schemaValidator);
|
|
487
460
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
488
461
|
? evaluateTelemetryOptions5(options.telemetry).enabled
|
|
489
462
|
: {
|
|
@@ -492,29 +465,28 @@ var BaseSubscriptionService = class {
|
|
|
492
465
|
tracing: false
|
|
493
466
|
};
|
|
494
467
|
}
|
|
495
|
-
_mappers;
|
|
496
468
|
evaluatedTelemetryOptions;
|
|
497
469
|
em;
|
|
498
470
|
openTelemetryCollector;
|
|
499
471
|
schemaValidator;
|
|
500
472
|
mappers;
|
|
501
|
-
async createSubscription(subscriptionDto, em) {
|
|
473
|
+
async createSubscription(subscriptionDto, em, ...args) {
|
|
502
474
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
503
475
|
this.openTelemetryCollector.info(
|
|
504
476
|
'Creating subscription',
|
|
505
477
|
subscriptionDto
|
|
506
478
|
);
|
|
507
479
|
}
|
|
508
|
-
const subscription =
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
480
|
+
const subscription = await this.mappers.CreateSubscriptionMapper.toEntity(
|
|
481
|
+
subscriptionDto,
|
|
482
|
+
em ?? this.em,
|
|
483
|
+
...args
|
|
484
|
+
);
|
|
513
485
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
514
486
|
await innerEm.persist(subscription);
|
|
515
487
|
});
|
|
516
488
|
const createdSubscriptionDto =
|
|
517
|
-
await this.
|
|
489
|
+
await this.mappers.SubscriptionMapper.toDto(subscription);
|
|
518
490
|
return createdSubscriptionDto;
|
|
519
491
|
}
|
|
520
492
|
async getSubscription(idDto, em) {
|
|
@@ -525,7 +497,7 @@ var BaseSubscriptionService = class {
|
|
|
525
497
|
'Subscription',
|
|
526
498
|
idDto
|
|
527
499
|
);
|
|
528
|
-
return this.
|
|
500
|
+
return this.mappers.SubscriptionMapper.toDto(subscription);
|
|
529
501
|
}
|
|
530
502
|
async getUserSubscription({ id }, em) {
|
|
531
503
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -536,7 +508,7 @@ var BaseSubscriptionService = class {
|
|
|
536
508
|
partyType: 'USER',
|
|
537
509
|
active: true
|
|
538
510
|
});
|
|
539
|
-
return this.
|
|
511
|
+
return this.mappers.SubscriptionMapper.toDto(subscription);
|
|
540
512
|
}
|
|
541
513
|
async getOrganizationSubscription({ id }, em) {
|
|
542
514
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -547,28 +519,26 @@ var BaseSubscriptionService = class {
|
|
|
547
519
|
partyType: 'ORGANIZATION',
|
|
548
520
|
active: true
|
|
549
521
|
});
|
|
550
|
-
return this.
|
|
522
|
+
return this.mappers.SubscriptionMapper.toDto(subscription);
|
|
551
523
|
}
|
|
552
|
-
async updateSubscription(subscriptionDto, em) {
|
|
524
|
+
async updateSubscription(subscriptionDto, em, ...args) {
|
|
553
525
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
554
526
|
this.openTelemetryCollector.info(
|
|
555
527
|
'Updating subscription',
|
|
556
528
|
subscriptionDto
|
|
557
529
|
);
|
|
558
530
|
}
|
|
559
|
-
const subscription =
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
531
|
+
const subscription = await this.mappers.UpdateSubscriptionMapper.toEntity(
|
|
532
|
+
subscriptionDto,
|
|
533
|
+
em ?? this.em,
|
|
534
|
+
...args
|
|
535
|
+
);
|
|
564
536
|
const updatedSubscription = await (em ?? this.em).upsert(subscription);
|
|
565
537
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
566
538
|
await innerEm.persist(updatedSubscription);
|
|
567
539
|
});
|
|
568
540
|
const updatedSubscriptionDto =
|
|
569
|
-
await this.
|
|
570
|
-
updatedSubscription
|
|
571
|
-
);
|
|
541
|
+
await this.mappers.SubscriptionMapper.toDto(updatedSubscription);
|
|
572
542
|
return updatedSubscriptionDto;
|
|
573
543
|
}
|
|
574
544
|
async deleteSubscription(idDto, em) {
|
|
@@ -597,7 +567,7 @@ var BaseSubscriptionService = class {
|
|
|
597
567
|
return Promise.all(
|
|
598
568
|
subscriptions.map((subscription) => {
|
|
599
569
|
const subscriptionDto =
|
|
600
|
-
this.
|
|
570
|
+
this.mappers.SubscriptionMapper.toDto(subscription);
|
|
601
571
|
return subscriptionDto;
|
|
602
572
|
})
|
|
603
573
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/implementation-billing-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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.
|
|
40
|
-
"@forklaunch/core": "^0.
|
|
41
|
-
"@forklaunch/internal": "^0.
|
|
42
|
-
"@forklaunch/validator": "^0.
|
|
43
|
-
"@mikro-orm/core": "^6.
|
|
39
|
+
"@forklaunch/common": "^0.6.3",
|
|
40
|
+
"@forklaunch/core": "^0.14.3",
|
|
41
|
+
"@forklaunch/internal": "^0.3.3",
|
|
42
|
+
"@forklaunch/validator": "^0.10.3",
|
|
43
|
+
"@mikro-orm/core": "^6.5.1",
|
|
44
44
|
"@sinclair/typebox": "^0.34.40",
|
|
45
45
|
"ajv": "^8.17.1",
|
|
46
|
-
"zod": "^4.1.
|
|
47
|
-
"@forklaunch/interfaces-billing": "0.
|
|
46
|
+
"zod": "^4.1.5",
|
|
47
|
+
"@forklaunch/interfaces-billing": "0.6.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
50
|
+
"@typescript/native-preview": "7.0.0-dev.20250828.1",
|
|
51
51
|
"depcheck": "^1.4.7",
|
|
52
52
|
"prettier": "^3.6.2",
|
|
53
|
-
"typedoc": "^0.28.
|
|
53
|
+
"typedoc": "^0.28.11"
|
|
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",
|