@forklaunch/implementation-billing-base 0.1.12 → 0.1.13
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/__test__/schemaEquality.test.d.ts +2 -0
- package/lib/__test__/schemaEquality.test.d.ts.map +1 -0
- package/lib/__test__/schemaEquality.test.js +250 -0
- package/lib/eject/domain/schemas/billingPortal.schema.ts +37 -0
- package/lib/eject/domain/schemas/checkoutSession.schema.ts +55 -0
- package/lib/eject/domain/schemas/index.ts +5 -0
- package/lib/eject/domain/schemas/paymentLink.schema.ts +60 -0
- package/lib/eject/domain/schemas/plan.schema.ts +80 -0
- package/lib/eject/domain/schemas/subscription.schema.ts +86 -0
- package/lib/eject/services/billingPortal.service.ts +145 -0
- package/lib/eject/services/checkoutSession.service.ts +132 -0
- package/lib/eject/services/index.ts +5 -0
- package/lib/eject/services/paymentLink.service.ts +170 -0
- package/lib/eject/services/plan.service.ts +132 -0
- package/lib/eject/services/subscription.service.ts +239 -0
- package/lib/jest.config.d.ts +4 -0
- package/lib/jest.config.d.ts.map +1 -0
- package/lib/jest.config.js +19 -0
- package/lib/schemas/billingPortal.schema.d.ts +50 -0
- package/lib/schemas/billingPortal.schema.d.ts.map +1 -0
- package/lib/schemas/billingPortal.schema.js +4 -0
- package/lib/schemas/checkoutSession.schema.d.ts +64 -0
- package/lib/schemas/checkoutSession.schema.d.ts.map +1 -0
- package/lib/schemas/checkoutSession.schema.js +4 -0
- package/lib/schemas/index.d.ts +6 -0
- package/lib/schemas/index.d.ts.map +1 -0
- package/lib/schemas/index.js +5 -0
- package/lib/schemas/paymentLink.schema.d.ts +74 -0
- package/lib/schemas/paymentLink.schema.d.ts.map +1 -0
- package/lib/schemas/paymentLink.schema.js +4 -0
- package/lib/schemas/plan.schema.d.ts +86 -0
- package/lib/schemas/plan.schema.d.ts.map +1 -0
- package/lib/schemas/plan.schema.js +4 -0
- package/lib/schemas/subscription.schema.d.ts +98 -0
- package/lib/schemas/subscription.schema.d.ts.map +1 -0
- package/lib/schemas/subscription.schema.js +4 -0
- package/lib/schemas/typebox/billingPortal.schema.d.ts +47 -0
- package/lib/schemas/typebox/billingPortal.schema.d.ts.map +1 -0
- package/lib/schemas/typebox/billingPortal.schema.js +25 -0
- package/lib/schemas/typebox/checkoutSession.schema.d.ts +62 -0
- package/lib/schemas/typebox/checkoutSession.schema.d.ts.map +1 -0
- package/lib/schemas/typebox/checkoutSession.schema.js +32 -0
- package/lib/schemas/typebox/paymentLink.schema.d.ts +72 -0
- package/lib/schemas/typebox/paymentLink.schema.d.ts.map +1 -0
- package/lib/schemas/typebox/paymentLink.schema.js +37 -0
- package/lib/schemas/typebox/plan.schema.d.ts +84 -0
- package/lib/schemas/typebox/plan.schema.d.ts.map +1 -0
- package/lib/schemas/typebox/plan.schema.js +43 -0
- package/lib/schemas/typebox/subscription.schema.d.ts +96 -0
- package/lib/schemas/typebox/subscription.schema.d.ts.map +1 -0
- package/lib/schemas/typebox/subscription.schema.js +49 -0
- package/lib/schemas/zod/billingPortal.schema.d.ts +47 -0
- package/lib/schemas/zod/billingPortal.schema.d.ts.map +1 -0
- package/lib/schemas/zod/billingPortal.schema.js +25 -0
- package/lib/schemas/zod/checkoutSession.schema.d.ts +62 -0
- package/lib/schemas/zod/checkoutSession.schema.d.ts.map +1 -0
- package/lib/schemas/zod/checkoutSession.schema.js +32 -0
- package/lib/schemas/zod/paymentLink.schema.d.ts +72 -0
- package/lib/schemas/zod/paymentLink.schema.d.ts.map +1 -0
- package/lib/schemas/zod/paymentLink.schema.js +37 -0
- package/lib/schemas/zod/plan.schema.d.ts +84 -0
- package/lib/schemas/zod/plan.schema.d.ts.map +1 -0
- package/lib/schemas/zod/plan.schema.js +43 -0
- package/lib/schemas/zod/subscription.schema.d.ts +96 -0
- package/lib/schemas/zod/subscription.schema.d.ts.map +1 -0
- package/lib/schemas/zod/subscription.schema.js +49 -0
- package/lib/services/billingPortal.service.d.ts +45 -0
- package/lib/services/billingPortal.service.d.ts.map +1 -0
- package/lib/services/billingPortal.service.js +51 -0
- package/lib/services/checkoutSession.service.d.ts +46 -0
- package/lib/services/checkoutSession.service.d.ts.map +1 -0
- package/lib/services/checkoutSession.service.js +49 -0
- package/lib/services/index.d.ts +6 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +5 -0
- package/lib/services/paymentLink.service.d.ts +49 -0
- package/lib/services/paymentLink.service.d.ts.map +1 -0
- package/lib/services/paymentLink.service.js +72 -0
- package/lib/services/plan.service.d.ts +43 -0
- package/lib/services/plan.service.d.ts.map +1 -0
- package/lib/services/plan.service.js +43 -0
- package/lib/services/subscription.service.d.ts +53 -0
- package/lib/services/subscription.service.d.ts.map +1 -0
- package/lib/services/subscription.service.js +94 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/vitest.config.d.ts +3 -0
- package/lib/vitest.config.d.ts.map +1 -0
- package/lib/vitest.config.js +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IdDto } from '@forklaunch/common';
|
|
2
|
+
import { RequestDtoMapperConstructor, ResponseDtoMapperConstructor } from '@forklaunch/core/mappers';
|
|
3
|
+
import { MetricsDefinition, OpenTelemetryCollector } from '@forklaunch/core/http';
|
|
4
|
+
import { SubscriptionService } from '@forklaunch/interfaces-billing/interfaces';
|
|
5
|
+
import { CreateSubscriptionDto, SubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
|
|
6
|
+
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
7
|
+
import { EntityManager } from '@mikro-orm/core';
|
|
8
|
+
export declare class BaseSubscriptionService<SchemaValidator extends AnySchemaValidator, PartyType, BillingProviderType, Metrics extends MetricsDefinition = MetricsDefinition, Dto extends {
|
|
9
|
+
SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
10
|
+
CreateSubscriptionDtoMapper: CreateSubscriptionDto<PartyType, BillingProviderType>;
|
|
11
|
+
UpdateSubscriptionDtoMapper: UpdateSubscriptionDto<PartyType, BillingProviderType>;
|
|
12
|
+
} = {
|
|
13
|
+
SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
14
|
+
CreateSubscriptionDtoMapper: CreateSubscriptionDto<PartyType, BillingProviderType>;
|
|
15
|
+
UpdateSubscriptionDtoMapper: UpdateSubscriptionDto<PartyType, BillingProviderType>;
|
|
16
|
+
}, Entities extends {
|
|
17
|
+
SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
18
|
+
CreateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
19
|
+
UpdateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
20
|
+
} = {
|
|
21
|
+
SubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
22
|
+
CreateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
23
|
+
UpdateSubscriptionDtoMapper: SubscriptionDto<PartyType, BillingProviderType>;
|
|
24
|
+
}> implements SubscriptionService<PartyType, BillingProviderType> {
|
|
25
|
+
#private;
|
|
26
|
+
protected em: EntityManager;
|
|
27
|
+
protected readonly openTelemetryCollector: OpenTelemetryCollector<Metrics>;
|
|
28
|
+
protected readonly schemaValidator: SchemaValidator;
|
|
29
|
+
protected readonly mapperss: {
|
|
30
|
+
SubscriptionDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['SubscriptionDtoMapper'], Entities['SubscriptionDtoMapper']>;
|
|
31
|
+
CreateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateSubscriptionDtoMapper'], Entities['CreateSubscriptionDtoMapper']>;
|
|
32
|
+
UpdateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionDtoMapper'], Entities['UpdateSubscriptionDtoMapper']>;
|
|
33
|
+
};
|
|
34
|
+
constructor(em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<Metrics>, schemaValidator: SchemaValidator, mapperss: {
|
|
35
|
+
SubscriptionDtoMapper: ResponseDtoMapperConstructor<SchemaValidator, Dto['SubscriptionDtoMapper'], Entities['SubscriptionDtoMapper']>;
|
|
36
|
+
CreateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['CreateSubscriptionDtoMapper'], Entities['CreateSubscriptionDtoMapper']>;
|
|
37
|
+
UpdateSubscriptionDtoMapper: RequestDtoMapperConstructor<SchemaValidator, Dto['UpdateSubscriptionDtoMapper'], Entities['UpdateSubscriptionDtoMapper']>;
|
|
38
|
+
});
|
|
39
|
+
createSubscription(subscriptionDto: Dto['CreateSubscriptionDtoMapper'], em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
|
|
40
|
+
getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
|
|
41
|
+
getUserSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
|
|
42
|
+
getOrganizationSubscription({ id }: IdDto, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
|
|
43
|
+
updateSubscription(subscriptionDto: Dto['UpdateSubscriptionDtoMapper'], em?: EntityManager): Promise<Dto['SubscriptionDtoMapper']>;
|
|
44
|
+
deleteSubscription(idDto: {
|
|
45
|
+
id: string;
|
|
46
|
+
}, em?: EntityManager): Promise<void>;
|
|
47
|
+
listSubscriptions(idsDto: {
|
|
48
|
+
ids?: string[];
|
|
49
|
+
}, em?: EntityManager): Promise<Dto['SubscriptionDtoMapper'][]>;
|
|
50
|
+
cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
51
|
+
resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=subscription.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription.service.d.ts","sourceRoot":"","sources":["../../services/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|
|
|
1
|
+
import { transformIntoInternalDtoMapper } from '@forklaunch/core/mappers';
|
|
2
|
+
export class BaseSubscriptionService {
|
|
3
|
+
em;
|
|
4
|
+
openTelemetryCollector;
|
|
5
|
+
schemaValidator;
|
|
6
|
+
mapperss;
|
|
7
|
+
#mapperss;
|
|
8
|
+
constructor(em, openTelemetryCollector, schemaValidator, mapperss) {
|
|
9
|
+
this.em = em;
|
|
10
|
+
this.openTelemetryCollector = openTelemetryCollector;
|
|
11
|
+
this.schemaValidator = schemaValidator;
|
|
12
|
+
this.mapperss = mapperss;
|
|
13
|
+
this.#mapperss = transformIntoInternalDtoMapper(mapperss, this.schemaValidator);
|
|
14
|
+
}
|
|
15
|
+
async createSubscription(subscriptionDto, em) {
|
|
16
|
+
const subscription = this.#mapperss.CreateSubscriptionDtoMapper.deserializeDtoToEntity(subscriptionDto);
|
|
17
|
+
await (em ?? this.em).transactional(async (innerEm) => {
|
|
18
|
+
await innerEm.persist(subscription);
|
|
19
|
+
});
|
|
20
|
+
const createdSubscriptionDto = this.#mapperss.SubscriptionDtoMapper.serializeEntityToDto(subscription);
|
|
21
|
+
return createdSubscriptionDto;
|
|
22
|
+
}
|
|
23
|
+
async getSubscription(idDto, em) {
|
|
24
|
+
const subscription = await (em ?? this.em).findOneOrFail('Subscription', idDto);
|
|
25
|
+
return this.#mapperss.SubscriptionDtoMapper.serializeEntityToDto(subscription);
|
|
26
|
+
}
|
|
27
|
+
async getUserSubscription({ id }, em) {
|
|
28
|
+
const subscription = await (em ?? this.em).findOneOrFail('Subscription', {
|
|
29
|
+
partyId: id,
|
|
30
|
+
partyType: 'USER',
|
|
31
|
+
active: true
|
|
32
|
+
});
|
|
33
|
+
return this.#mapperss.SubscriptionDtoMapper.serializeEntityToDto(subscription);
|
|
34
|
+
}
|
|
35
|
+
async getOrganizationSubscription({ id }, em) {
|
|
36
|
+
const subscription = await (em ?? this.em).findOneOrFail('Subscription', {
|
|
37
|
+
partyId: id,
|
|
38
|
+
partyType: 'ORGANIZATION',
|
|
39
|
+
active: true
|
|
40
|
+
});
|
|
41
|
+
return this.#mapperss.SubscriptionDtoMapper.serializeEntityToDto(subscription);
|
|
42
|
+
}
|
|
43
|
+
async updateSubscription(subscriptionDto, em) {
|
|
44
|
+
const subscription = this.#mapperss.UpdateSubscriptionDtoMapper.deserializeDtoToEntity(subscriptionDto);
|
|
45
|
+
const updatedSubscription = await (em ?? this.em).upsert(subscription);
|
|
46
|
+
await (em ?? this.em).transactional(async (innerEm) => {
|
|
47
|
+
await innerEm.persist(updatedSubscription);
|
|
48
|
+
});
|
|
49
|
+
const updatedSubscriptionDto = this.#mapperss.SubscriptionDtoMapper.serializeEntityToDto(updatedSubscription);
|
|
50
|
+
return updatedSubscriptionDto;
|
|
51
|
+
}
|
|
52
|
+
async deleteSubscription(idDto, em) {
|
|
53
|
+
const subscription = await (em ?? this.em).findOne('Subscription', idDto);
|
|
54
|
+
if (!subscription) {
|
|
55
|
+
throw new Error('Subscription not found');
|
|
56
|
+
}
|
|
57
|
+
await (em ?? this.em).removeAndFlush(subscription);
|
|
58
|
+
}
|
|
59
|
+
async listSubscriptions(idsDto, em) {
|
|
60
|
+
const subscriptions = await (em ?? this.em).findAll('Subscription', {
|
|
61
|
+
where: idsDto.ids
|
|
62
|
+
? {
|
|
63
|
+
id: {
|
|
64
|
+
$in: idsDto.ids
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
: undefined
|
|
68
|
+
});
|
|
69
|
+
return subscriptions.map((subscription) => {
|
|
70
|
+
const subscriptionDto = this.#mapperss.SubscriptionDtoMapper.serializeEntityToDto(subscription);
|
|
71
|
+
return subscriptionDto;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async cancelSubscription(idDto, em) {
|
|
75
|
+
const subscription = await (em ?? this.em).findOne('Subscription', idDto);
|
|
76
|
+
if (!subscription) {
|
|
77
|
+
throw new Error('Subscription not found');
|
|
78
|
+
}
|
|
79
|
+
subscription.active = false;
|
|
80
|
+
await (em ?? this.em).transactional(async (innerEm) => {
|
|
81
|
+
await innerEm.persist(subscription);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async resumeSubscription(idDto, em) {
|
|
85
|
+
const subscription = await (em ?? this.em).findOne('Subscription', idDto);
|
|
86
|
+
if (!subscription) {
|
|
87
|
+
throw new Error('Subscription not found');
|
|
88
|
+
}
|
|
89
|
+
subscription.active = true;
|
|
90
|
+
await (em ?? this.em).transactional(async (innerEm) => {
|
|
91
|
+
await innerEm.persist(subscription);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|