@forklaunch/implementation-billing-base 1.0.42 → 1.1.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/billingPortal.mapper.types.d.ts +2 -0
- package/lib/domain/types/billingPortal.mapper.types.d.ts.map +1 -1
- package/lib/domain/types/paymentLink.mapper.types.d.ts +4 -0
- package/lib/domain/types/paymentLink.mapper.types.d.ts.map +1 -1
- package/lib/domain/types/subscription.mapper.types.d.ts +5 -0
- package/lib/domain/types/subscription.mapper.types.d.ts.map +1 -1
- package/lib/eject/domain/types/billingPortal.mapper.types.ts +7 -0
- package/lib/eject/domain/types/paymentLink.mapper.types.ts +11 -0
- package/lib/eject/domain/types/subscription.mapper.types.ts +2 -0
- package/lib/eject/services/billingPortal.service.ts +38 -14
- package/lib/eject/services/checkoutSession.service.ts +4 -6
- package/lib/eject/services/paymentLink.service.ts +81 -6
- package/lib/eject/services/plan.service.ts +2 -2
- package/lib/eject/services/subscription.service.ts +24 -6
- package/lib/services/billingPortal.service.d.ts.map +1 -1
- package/lib/services/checkoutSession.service.d.ts.map +1 -1
- package/lib/services/index.js +116 -30
- package/lib/services/index.mjs +116 -30
- package/lib/services/paymentLink.service.d.ts +2 -1
- package/lib/services/paymentLink.service.d.ts.map +1 -1
- package/lib/services/subscription.service.d.ts +2 -0
- package/lib/services/subscription.service.d.ts.map +1 -1
- package/lib/utils/cachedSessionDto.d.ts +7 -0
- package/lib/utils/cachedSessionDto.d.ts.map +1 -0
- package/package.json +7 -7
|
@@ -12,6 +12,8 @@ export type BillingPortalMappers<MapperEntities extends BaseBillingEntities, Map
|
|
|
12
12
|
};
|
|
13
13
|
UpdateBillingPortalMapper: {
|
|
14
14
|
entity: MapperEntities['UpdateBillingPortalMapper'];
|
|
15
|
+
/** Cache-only DTO update; preserve session/customer identities. */
|
|
16
|
+
toCachedDto?: (dto: MapperDomains['UpdateBillingPortalMapper'], existing: MapperDomains['BillingPortalMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperDomains['BillingPortalMapper']>;
|
|
15
17
|
toEntity: (dto: MapperDomains['UpdateBillingPortalMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['UpdateBillingPortalMapper']>>;
|
|
16
18
|
};
|
|
17
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billingPortal.mapper.types.d.ts","sourceRoot":"","sources":["../../../domain/types/billingPortal.mapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,MAAM,oBAAoB,CAC9B,cAAc,SAAS,mBAAmB,EAC1C,aAAa,SAAS,eAAe,IACnC;IACF,mBAAmB,EAAE;QACnB,MAAM,EAAE,cAAc,CAAC,qBAAqB,CAAC,CAAC;QAC9C,KAAK,EAAE,CACL,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,KACvD,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC;KACpD,CAAC;IACF,yBAAyB,EAAE;QACzB,MAAM,EAAE,cAAc,CAAC,2BAA2B,CAAC,CAAC;QACpD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,2BAA2B,CAAC,EAC/C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;KACxE,CAAC;IACF,yBAAyB,EAAE;QACzB,MAAM,EAAE,cAAc,CAAC,2BAA2B,CAAC,CAAC;QACpD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,2BAA2B,CAAC,EAC/C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;KACxE,CAAC;CACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"billingPortal.mapper.types.d.ts","sourceRoot":"","sources":["../../../domain/types/billingPortal.mapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,MAAM,oBAAoB,CAC9B,cAAc,SAAS,mBAAmB,EAC1C,aAAa,SAAS,eAAe,IACnC;IACF,mBAAmB,EAAE;QACnB,MAAM,EAAE,cAAc,CAAC,qBAAqB,CAAC,CAAC;QAC9C,KAAK,EAAE,CACL,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,KACvD,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC;KACpD,CAAC;IACF,yBAAyB,EAAE;QACzB,MAAM,EAAE,cAAc,CAAC,2BAA2B,CAAC,CAAC;QACpD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,2BAA2B,CAAC,EAC/C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;KACxE,CAAC;IACF,yBAAyB,EAAE;QACzB,MAAM,EAAE,cAAc,CAAC,2BAA2B,CAAC,CAAC;QACpD,mEAAmE;QACnE,WAAW,CAAC,EAAE,CACZ,GAAG,EAAE,aAAa,CAAC,2BAA2B,CAAC,EAC/C,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,EAC9C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC;QACnD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,2BAA2B,CAAC,EAC/C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;KACxE,CAAC;CACH,CAAC"}
|
|
@@ -3,6 +3,8 @@ import { BasePaymentLinkDtos } from './baseBillingDto.types';
|
|
|
3
3
|
import { BasePaymentLinkEntities } from './baseBillingEntity.types';
|
|
4
4
|
export type PaymentLinkMappers<PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities extends BasePaymentLinkEntities, MapperDomains extends BasePaymentLinkDtos<PaymentMethodEnum, CurrencyEnum, StatusEnum>> = {
|
|
5
5
|
PaymentLinkMapper: {
|
|
6
|
+
/** Validate and restore declared DTO fields after a JSON cache read. */
|
|
7
|
+
normalizeCachedDto?: (value: MapperDomains['PaymentLinkMapper']) => MapperDomains['PaymentLinkMapper'];
|
|
6
8
|
entity: MapperEntities['PaymentLinkMapper'];
|
|
7
9
|
toDto: (entity: InferEntity<MapperEntities['PaymentLinkMapper']>) => Promise<MapperDomains['PaymentLinkMapper']>;
|
|
8
10
|
};
|
|
@@ -11,6 +13,8 @@ export type PaymentLinkMappers<PaymentMethodEnum, CurrencyEnum, StatusEnum, Mapp
|
|
|
11
13
|
toEntity: (dto: MapperDomains['CreatePaymentLinkMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['CreatePaymentLinkMapper']>>;
|
|
12
14
|
};
|
|
13
15
|
UpdatePaymentLinkMapper: {
|
|
16
|
+
/** Optional local cache-only mapping; never grants provider mutation authority. */
|
|
17
|
+
toCachedDto?: (dto: MapperDomains['UpdatePaymentLinkMapper'], existing: MapperDomains['PaymentLinkMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperDomains['PaymentLinkMapper']>;
|
|
14
18
|
entity: MapperEntities['UpdatePaymentLinkMapper'];
|
|
15
19
|
toEntity: (dto: MapperDomains['UpdatePaymentLinkMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['UpdatePaymentLinkMapper']>>;
|
|
16
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentLink.mapper.types.d.ts","sourceRoot":"","sources":["../../../domain/types/paymentLink.mapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,kBAAkB,CAC5B,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,cAAc,SAAS,uBAAuB,EAC9C,aAAa,SAAS,mBAAmB,CACvC,iBAAiB,EACjB,YAAY,EACZ,UAAU,CACX,IACC;IACF,iBAAiB,EAAE;QACjB,MAAM,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;QAC5C,KAAK,EAAE,CACL,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,KACrD,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;KAClD,CAAC;IACF,uBAAuB,EAAE;QACvB,MAAM,EAAE,cAAc,CAAC,yBAAyB,CAAC,CAAC;QAClD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,yBAAyB,CAAC,EAC7C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;KACtE,CAAC;IACF,uBAAuB,EAAE;QACvB,MAAM,EAAE,cAAc,CAAC,yBAAyB,CAAC,CAAC;QAClD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,yBAAyB,CAAC,EAC7C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;KACtE,CAAC;CACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"paymentLink.mapper.types.d.ts","sourceRoot":"","sources":["../../../domain/types/paymentLink.mapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,kBAAkB,CAC5B,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,cAAc,SAAS,uBAAuB,EAC9C,aAAa,SAAS,mBAAmB,CACvC,iBAAiB,EACjB,YAAY,EACZ,UAAU,CACX,IACC;IACF,iBAAiB,EAAE;QACjB,wEAAwE;QACxE,kBAAkB,CAAC,EAAE,CACnB,KAAK,EAAE,aAAa,CAAC,mBAAmB,CAAC,KACtC,aAAa,CAAC,mBAAmB,CAAC,CAAC;QACxC,MAAM,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC;QAC5C,KAAK,EAAE,CACL,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,KACrD,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;KAClD,CAAC;IACF,uBAAuB,EAAE;QACvB,MAAM,EAAE,cAAc,CAAC,yBAAyB,CAAC,CAAC;QAClD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,yBAAyB,CAAC,EAC7C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;KACtE,CAAC;IACF,uBAAuB,EAAE;QACvB,mFAAmF;QACnF,WAAW,CAAC,EAAE,CACZ,GAAG,EAAE,aAAa,CAAC,yBAAyB,CAAC,EAC7C,QAAQ,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAC5C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;QACjD,MAAM,EAAE,cAAc,CAAC,yBAAyB,CAAC,CAAC;QAClD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,yBAAyB,CAAC,EAC7C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;KACtE,CAAC;CACH,CAAC"}
|
|
@@ -3,6 +3,11 @@ import { BaseSubscriptionDtos } from './baseBillingDto.types';
|
|
|
3
3
|
import { BaseSubscriptionEntities } from './baseBillingEntity.types';
|
|
4
4
|
export type SubscriptionMappers<PartyType, BillingProviderType, MapperEntities extends BaseSubscriptionEntities, MapperDomains extends BaseSubscriptionDtos<PartyType, BillingProviderType>> = {
|
|
5
5
|
SubscriptionMapper: {
|
|
6
|
+
/** Trusted persisted party discriminators for local subscription lookups. */
|
|
7
|
+
partyTypes?: Readonly<{
|
|
8
|
+
user: string;
|
|
9
|
+
organization: string;
|
|
10
|
+
}>;
|
|
6
11
|
entity: MapperEntities['SubscriptionMapper'];
|
|
7
12
|
toDto: (entity: InferEntity<MapperEntities['SubscriptionMapper']>) => Promise<MapperDomains['SubscriptionMapper']>;
|
|
8
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.mapper.types.d.ts","sourceRoot":"","sources":["../../../domain/types/subscription.mapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,mBAAmB,CAC7B,SAAS,EACT,mBAAmB,EACnB,cAAc,SAAS,wBAAwB,EAC/C,aAAa,SAAS,oBAAoB,CAAC,SAAS,EAAE,mBAAmB,CAAC,IACxE;IACF,kBAAkB,EAAE;QAClB,MAAM,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;QAC7C,KAAK,EAAE,CACL,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,KACtD,OAAO,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAC;KACnD,CAAC;IACF,wBAAwB,EAAE;QACxB,MAAM,EAAE,cAAc,CAAC,0BAA0B,CAAC,CAAC;QACnD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC,EAC9C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;KACvE,CAAC;IACF,wBAAwB,EAAE;QACxB,MAAM,EAAE,cAAc,CAAC,0BAA0B,CAAC,CAAC;QACnD,QAAQ,EAAE,CACR,GAAG,EAAE,aAAa,CAAC,0BAA0B,CAAC,EAC9C,EAAE,EAAE,aAAa,EACjB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC;KACvE,CAAC;CACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"subscription.mapper.types.d.ts","sourceRoot":"","sources":["../../../domain/types/subscription.mapper.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAA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
|
|
|
22
22
|
};
|
|
23
23
|
UpdateBillingPortalMapper: {
|
|
24
24
|
entity: MapperEntities['UpdateBillingPortalMapper'];
|
|
25
|
+
/** Cache-only DTO update; preserve session/customer identities. */
|
|
26
|
+
toCachedDto?: (
|
|
27
|
+
dto: MapperDomains['UpdateBillingPortalMapper'],
|
|
28
|
+
existing: MapperDomains['BillingPortalMapper'],
|
|
29
|
+
em: EntityManager,
|
|
30
|
+
...args: unknown[]
|
|
31
|
+
) => Promise<MapperDomains['BillingPortalMapper']>;
|
|
25
32
|
toEntity: (
|
|
26
33
|
dto: MapperDomains['UpdateBillingPortalMapper'],
|
|
27
34
|
em: EntityManager,
|
|
@@ -14,6 +14,10 @@ export type PaymentLinkMappers<
|
|
|
14
14
|
>
|
|
15
15
|
> = {
|
|
16
16
|
PaymentLinkMapper: {
|
|
17
|
+
/** Validate and restore declared DTO fields after a JSON cache read. */
|
|
18
|
+
normalizeCachedDto?: (
|
|
19
|
+
value: MapperDomains['PaymentLinkMapper']
|
|
20
|
+
) => MapperDomains['PaymentLinkMapper'];
|
|
17
21
|
entity: MapperEntities['PaymentLinkMapper'];
|
|
18
22
|
toDto: (
|
|
19
23
|
entity: InferEntity<MapperEntities['PaymentLinkMapper']>
|
|
@@ -28,6 +32,13 @@ export type PaymentLinkMappers<
|
|
|
28
32
|
) => Promise<InferEntity<MapperEntities['CreatePaymentLinkMapper']>>;
|
|
29
33
|
};
|
|
30
34
|
UpdatePaymentLinkMapper: {
|
|
35
|
+
/** Optional local cache-only mapping; never grants provider mutation authority. */
|
|
36
|
+
toCachedDto?: (
|
|
37
|
+
dto: MapperDomains['UpdatePaymentLinkMapper'],
|
|
38
|
+
existing: MapperDomains['PaymentLinkMapper'],
|
|
39
|
+
em: EntityManager,
|
|
40
|
+
...args: unknown[]
|
|
41
|
+
) => Promise<MapperDomains['PaymentLinkMapper']>;
|
|
31
42
|
entity: MapperEntities['UpdatePaymentLinkMapper'];
|
|
32
43
|
toEntity: (
|
|
33
44
|
dto: MapperDomains['UpdatePaymentLinkMapper'],
|
|
@@ -9,6 +9,8 @@ export type SubscriptionMappers<
|
|
|
9
9
|
MapperDomains extends BaseSubscriptionDtos<PartyType, BillingProviderType>
|
|
10
10
|
> = {
|
|
11
11
|
SubscriptionMapper: {
|
|
12
|
+
/** Trusted persisted party discriminators for local subscription lookups. */
|
|
13
|
+
partyTypes?: Readonly<{ user: string; organization: string }>;
|
|
12
14
|
entity: MapperEntities['SubscriptionMapper'];
|
|
13
15
|
toDto: (
|
|
14
16
|
entity: InferEntity<MapperEntities['SubscriptionMapper']>
|
|
@@ -16,6 +16,7 @@ import { EntityManager } from '@mikro-orm/core';
|
|
|
16
16
|
import { BaseBillingDtos } from '../domain/types/baseBillingDto.types';
|
|
17
17
|
import { BaseBillingEntities } from '../domain/types/baseBillingEntity.types';
|
|
18
18
|
import { BillingPortalMappers } from '../domain/types/billingPortal.mapper.types';
|
|
19
|
+
import { cachedSessionDto } from '../utils/cachedSessionDto';
|
|
19
20
|
|
|
20
21
|
export class BaseBillingPortalService<
|
|
21
22
|
SchemaValidator extends AnySchemaValidator,
|
|
@@ -110,12 +111,9 @@ export class BaseBillingPortalService<
|
|
|
110
111
|
throw new Error('Session not found');
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.em
|
|
117
|
-
)
|
|
118
|
-
);
|
|
114
|
+
// Creation already mapped this DTO. A cache-only session has no database
|
|
115
|
+
// entity for the update mapper to load, and a read must not mutate one.
|
|
116
|
+
return cachedSessionDto(billingPortalDetails.value, idDto.id);
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
async updateBillingPortalSession(
|
|
@@ -130,7 +128,7 @@ export class BaseBillingPortalService<
|
|
|
130
128
|
}
|
|
131
129
|
|
|
132
130
|
const existingBillingPortal = (
|
|
133
|
-
await this.cache.readRecord<
|
|
131
|
+
await this.cache.readRecord<MapperDomains['BillingPortalMapper']>(
|
|
134
132
|
this.createCacheKey(billingPortalDto.id)
|
|
135
133
|
)
|
|
136
134
|
)?.value;
|
|
@@ -138,6 +136,37 @@ export class BaseBillingPortalService<
|
|
|
138
136
|
if (!existingBillingPortal) {
|
|
139
137
|
throw new Error('Session not found');
|
|
140
138
|
}
|
|
139
|
+
const existingBillingPortalDto = cachedSessionDto(
|
|
140
|
+
existingBillingPortal,
|
|
141
|
+
billingPortalDto.id
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Configured cache mappers update the DTO directly. Custom mappers without
|
|
145
|
+
// this optional hook retain their existing entity mapping behavior.
|
|
146
|
+
if (
|
|
147
|
+
!this.enableDatabaseBackup &&
|
|
148
|
+
this.mappers.UpdateBillingPortalMapper.toCachedDto
|
|
149
|
+
) {
|
|
150
|
+
const updated = await this.mappers.UpdateBillingPortalMapper.toCachedDto(
|
|
151
|
+
billingPortalDto,
|
|
152
|
+
existingBillingPortalDto,
|
|
153
|
+
args[0] instanceof EntityManager ? args[0] : this.em,
|
|
154
|
+
...(args[0] instanceof EntityManager ? args.slice(1) : args)
|
|
155
|
+
);
|
|
156
|
+
if (
|
|
157
|
+
updated.id !== existingBillingPortalDto.id ||
|
|
158
|
+
updated.customerId !== existingBillingPortalDto.customerId
|
|
159
|
+
) {
|
|
160
|
+
throw new Error('Cached session identity cannot change');
|
|
161
|
+
}
|
|
162
|
+
const updatedBillingPortalDto = cachedSessionDto(updated, billingPortalDto.id);
|
|
163
|
+
await this.cache.putRecord({
|
|
164
|
+
key: this.createCacheKey(updatedBillingPortalDto.id),
|
|
165
|
+
value: updatedBillingPortalDto,
|
|
166
|
+
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
167
|
+
});
|
|
168
|
+
return updatedBillingPortalDto;
|
|
169
|
+
}
|
|
141
170
|
|
|
142
171
|
const billingPortal = await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
143
172
|
billingPortalDto,
|
|
@@ -150,7 +179,7 @@ export class BaseBillingPortalService<
|
|
|
150
179
|
}
|
|
151
180
|
|
|
152
181
|
const updatedBillingPortalDto = {
|
|
153
|
-
...
|
|
182
|
+
...existingBillingPortalDto,
|
|
154
183
|
...(await this.mappers.BillingPortalMapper.toDto(billingPortal))
|
|
155
184
|
};
|
|
156
185
|
|
|
@@ -160,12 +189,7 @@ export class BaseBillingPortalService<
|
|
|
160
189
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
161
190
|
});
|
|
162
191
|
|
|
163
|
-
return
|
|
164
|
-
await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
165
|
-
billingPortal,
|
|
166
|
-
this.em
|
|
167
|
-
)
|
|
168
|
-
);
|
|
192
|
+
return updatedBillingPortalDto;
|
|
169
193
|
}
|
|
170
194
|
|
|
171
195
|
async expireBillingPortalSession(idDto: IdDto): Promise<void> {
|
|
@@ -14,6 +14,7 @@ import { CheckoutSession } from '../persistence/entities';
|
|
|
14
14
|
import { BaseCheckoutSessionDtos } from '../domain/types/baseBillingDto.types';
|
|
15
15
|
import { BaseCheckoutSessionEntities } from '../domain/types/baseBillingEntity.types';
|
|
16
16
|
import { CheckoutSessionMappers } from '../domain/types/checkoutSession.mapper.types';
|
|
17
|
+
import { cachedSessionDto } from '../utils/cachedSessionDto';
|
|
17
18
|
|
|
18
19
|
export class BaseCheckoutSessionService<
|
|
19
20
|
SchemaValidator extends AnySchemaValidator,
|
|
@@ -131,12 +132,9 @@ export class BaseCheckoutSessionService<
|
|
|
131
132
|
throw new Error('Session not found');
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.em
|
|
138
|
-
)
|
|
139
|
-
);
|
|
135
|
+
// Creation already mapped this DTO. A cache-only session has no database
|
|
136
|
+
// entity for the update mapper to load, and a read must not mutate one.
|
|
137
|
+
return cachedSessionDto(checkoutSessionDetails.value, id);
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
async expireCheckoutSession({ id }: IdDto): Promise<void> {
|
|
@@ -131,11 +131,34 @@ export class BasePaymentLinkService<
|
|
|
131
131
|
|
|
132
132
|
const cacheKey = this.createCacheKey(paymentLinkDto.id);
|
|
133
133
|
const existingLink = (
|
|
134
|
-
await this.cache.readRecord<
|
|
134
|
+
await this.cache.readRecord<MapperDomains['PaymentLinkMapper']>(cacheKey)
|
|
135
135
|
)?.value;
|
|
136
136
|
if (!existingLink) {
|
|
137
137
|
throw new Error('Payment link not found');
|
|
138
138
|
}
|
|
139
|
+
if (
|
|
140
|
+
!this.enableDatabaseBackup &&
|
|
141
|
+
this.mappers.UpdatePaymentLinkMapper.toCachedDto
|
|
142
|
+
) {
|
|
143
|
+
if (existingLink.id !== paymentLinkDto.id) {
|
|
144
|
+
throw new Error('Cached payment link identity cannot change');
|
|
145
|
+
}
|
|
146
|
+
const updated = await this.mappers.UpdatePaymentLinkMapper.toCachedDto(
|
|
147
|
+
paymentLinkDto,
|
|
148
|
+
existingLink,
|
|
149
|
+
args[0] instanceof EntityManager ? args[0] : this.em,
|
|
150
|
+
...(args[0] instanceof EntityManager ? args.slice(1) : args)
|
|
151
|
+
);
|
|
152
|
+
if (updated.id !== paymentLinkDto.id) {
|
|
153
|
+
throw new Error('Cached payment link identity cannot change');
|
|
154
|
+
}
|
|
155
|
+
await this.cache.putRecord({
|
|
156
|
+
key: cacheKey,
|
|
157
|
+
value: updated,
|
|
158
|
+
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
159
|
+
});
|
|
160
|
+
return updated;
|
|
161
|
+
}
|
|
139
162
|
const paymentLink = await this.mappers.UpdatePaymentLinkMapper.toEntity(
|
|
140
163
|
paymentLinkDto,
|
|
141
164
|
args[0] instanceof EntityManager ? args[0] : this.em,
|
|
@@ -160,6 +183,27 @@ export class BasePaymentLinkService<
|
|
|
160
183
|
return updatedLinkDto;
|
|
161
184
|
}
|
|
162
185
|
|
|
186
|
+
private normalizeCachedPaymentLink(
|
|
187
|
+
value: MapperDomains['PaymentLinkMapper'],
|
|
188
|
+
cacheKey: string
|
|
189
|
+
): MapperDomains['PaymentLinkMapper'] {
|
|
190
|
+
const normalize = this.mappers.PaymentLinkMapper.normalizeCachedDto;
|
|
191
|
+
if (!normalize) return value;
|
|
192
|
+
if (
|
|
193
|
+
!value ||
|
|
194
|
+
typeof value.id !== 'string' ||
|
|
195
|
+
!value.id.trim() ||
|
|
196
|
+
this.createCacheKey(value.id) !== cacheKey
|
|
197
|
+
) {
|
|
198
|
+
throw new Error('Cached payment link identity does not match');
|
|
199
|
+
}
|
|
200
|
+
const normalized = normalize(value);
|
|
201
|
+
if (normalized.id !== value.id) {
|
|
202
|
+
throw new Error('Cached payment link identity cannot change');
|
|
203
|
+
}
|
|
204
|
+
return normalized;
|
|
205
|
+
}
|
|
206
|
+
|
|
163
207
|
async getPaymentLink({
|
|
164
208
|
id
|
|
165
209
|
}: IdDto): Promise<MapperDomains['PaymentLinkMapper']> {
|
|
@@ -173,8 +217,7 @@ export class BasePaymentLinkService<
|
|
|
173
217
|
throw new Error('Payment link not found');
|
|
174
218
|
}
|
|
175
219
|
|
|
176
|
-
|
|
177
|
-
return paymentLink.value;
|
|
220
|
+
return this.normalizeCachedPaymentLink(paymentLink.value, cacheKey);
|
|
178
221
|
}
|
|
179
222
|
|
|
180
223
|
async expirePaymentLink({ id }: IdDto): Promise<void> {
|
|
@@ -224,19 +267,51 @@ export class BasePaymentLinkService<
|
|
|
224
267
|
}
|
|
225
268
|
|
|
226
269
|
async listPaymentLinks(
|
|
227
|
-
idsDto?: IdsDto
|
|
270
|
+
idsDto?: IdsDto,
|
|
271
|
+
maxValidatedRecords?: number
|
|
228
272
|
): Promise<MapperDomains['PaymentLinkMapper'][]> {
|
|
273
|
+
if (
|
|
274
|
+
maxValidatedRecords !== undefined &&
|
|
275
|
+
(!Number.isSafeInteger(maxValidatedRecords) ||
|
|
276
|
+
maxValidatedRecords < 1 ||
|
|
277
|
+
(idsDto?.ids?.length ?? 0) > maxValidatedRecords)
|
|
278
|
+
) {
|
|
279
|
+
throw new Error('Configured payment link list exceeds its record limit');
|
|
280
|
+
}
|
|
281
|
+
if (
|
|
282
|
+
maxValidatedRecords !== undefined &&
|
|
283
|
+
idsDto?.ids?.some((id) => typeof id !== 'string' || !id.trim())
|
|
284
|
+
) {
|
|
285
|
+
throw new Error('Invalid configured payment link identity');
|
|
286
|
+
}
|
|
229
287
|
const keys =
|
|
230
288
|
idsDto?.ids && idsDto.ids.length > 0
|
|
231
289
|
? idsDto?.ids.map((id) => this.createCacheKey(id))
|
|
232
290
|
: await this.cache.listKeys(this.cacheKeyPrefix);
|
|
233
291
|
|
|
234
|
-
|
|
292
|
+
if (
|
|
293
|
+
maxValidatedRecords !== undefined &&
|
|
294
|
+
keys.length > maxValidatedRecords
|
|
295
|
+
) {
|
|
296
|
+
throw new Error('Configured payment link list exceeds its record limit');
|
|
297
|
+
}
|
|
298
|
+
// The opt-in bound also validates identities before provider reads.
|
|
235
299
|
return Promise.all(
|
|
236
300
|
keys.map(async (key) => {
|
|
237
301
|
const paymentLink =
|
|
238
302
|
await this.cache.readRecord<MapperDomains['PaymentLinkMapper']>(key);
|
|
239
|
-
|
|
303
|
+
if (
|
|
304
|
+
maxValidatedRecords !== undefined &&
|
|
305
|
+
(!paymentLink?.value ||
|
|
306
|
+
typeof paymentLink.value.id !== 'string' ||
|
|
307
|
+
!paymentLink.value.id.trim() ||
|
|
308
|
+
this.createCacheKey(paymentLink.value.id) !== key)
|
|
309
|
+
) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
'Cached payment link is missing or its identity does not match'
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
return this.normalizeCachedPaymentLink(paymentLink.value, key);
|
|
240
315
|
})
|
|
241
316
|
);
|
|
242
317
|
}
|
|
@@ -111,7 +111,7 @@ export class BasePlanService<
|
|
|
111
111
|
...(args[0] instanceof EntityManager ? args.slice(1) : args)
|
|
112
112
|
);
|
|
113
113
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
114
|
-
|
|
114
|
+
innerEm.persist(plan);
|
|
115
115
|
});
|
|
116
116
|
return this.mappers.PlanMapper.toDto(plan);
|
|
117
117
|
}
|
|
@@ -147,7 +147,7 @@ export class BasePlanService<
|
|
|
147
147
|
);
|
|
148
148
|
const updatedPlan = await (em ?? this.em).upsert(plan);
|
|
149
149
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
150
|
-
|
|
150
|
+
innerEm.persist(plan);
|
|
151
151
|
});
|
|
152
152
|
const updatedPlanDto = await this.mappers.PlanMapper.toDto(updatedPlan);
|
|
153
153
|
return updatedPlanDto;
|
|
@@ -34,6 +34,8 @@ export class BaseSubscriptionService<
|
|
|
34
34
|
tracing?: boolean;
|
|
35
35
|
};
|
|
36
36
|
protected em: EntityManager;
|
|
37
|
+
private readonly userPartyType: string;
|
|
38
|
+
private readonly organizationPartyType: string;
|
|
37
39
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
38
40
|
protected readonly schemaValidator: SchemaValidator;
|
|
39
41
|
protected readonly mappers: SubscriptionMappers<
|
|
@@ -57,6 +59,22 @@ export class BaseSubscriptionService<
|
|
|
57
59
|
telemetry?: TelemetryOptions;
|
|
58
60
|
}
|
|
59
61
|
) {
|
|
62
|
+
const partyTypes = mappers.SubscriptionMapper.partyTypes;
|
|
63
|
+
if (
|
|
64
|
+
partyTypes !== undefined &&
|
|
65
|
+
(!partyTypes ||
|
|
66
|
+
Array.isArray(partyTypes) ||
|
|
67
|
+
typeof partyTypes.user !== 'string' ||
|
|
68
|
+
!partyTypes.user.trim() ||
|
|
69
|
+
typeof partyTypes.organization !== 'string' ||
|
|
70
|
+
!partyTypes.organization.trim() ||
|
|
71
|
+
partyTypes.user === partyTypes.organization)
|
|
72
|
+
) {
|
|
73
|
+
throw new Error('Invalid subscription party types');
|
|
74
|
+
}
|
|
75
|
+
// Copy trusted mapper metadata so later object changes cannot redirect reads.
|
|
76
|
+
this.userPartyType = partyTypes?.user ?? 'USER';
|
|
77
|
+
this.organizationPartyType = partyTypes?.organization ?? 'ORGANIZATION';
|
|
60
78
|
this.em = em;
|
|
61
79
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
62
80
|
this.schemaValidator = schemaValidator;
|
|
@@ -87,7 +105,7 @@ export class BaseSubscriptionService<
|
|
|
87
105
|
...(args[0] instanceof EntityManager ? args.slice(1) : args)
|
|
88
106
|
);
|
|
89
107
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
90
|
-
|
|
108
|
+
innerEm.persist(subscription);
|
|
91
109
|
});
|
|
92
110
|
const createdSubscriptionDto =
|
|
93
111
|
await this.mappers.SubscriptionMapper.toDto(subscription);
|
|
@@ -139,7 +157,7 @@ export class BaseSubscriptionService<
|
|
|
139
157
|
this.mappers.SubscriptionMapper.entity as typeof Subscription,
|
|
140
158
|
{
|
|
141
159
|
partyId: id,
|
|
142
|
-
partyType:
|
|
160
|
+
partyType: this.userPartyType,
|
|
143
161
|
active: true
|
|
144
162
|
}
|
|
145
163
|
);
|
|
@@ -160,7 +178,7 @@ export class BaseSubscriptionService<
|
|
|
160
178
|
this.mappers.SubscriptionMapper.entity as typeof Subscription,
|
|
161
179
|
{
|
|
162
180
|
partyId: id,
|
|
163
|
-
partyType:
|
|
181
|
+
partyType: this.organizationPartyType,
|
|
164
182
|
active: true
|
|
165
183
|
}
|
|
166
184
|
);
|
|
@@ -187,7 +205,7 @@ export class BaseSubscriptionService<
|
|
|
187
205
|
);
|
|
188
206
|
const updatedSubscription = await (em ?? this.em).upsert(subscription);
|
|
189
207
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
190
|
-
|
|
208
|
+
innerEm.persist(updatedSubscription);
|
|
191
209
|
});
|
|
192
210
|
const updatedSubscriptionDto =
|
|
193
211
|
await this.mappers.SubscriptionMapper.toDto(updatedSubscription);
|
|
@@ -248,7 +266,7 @@ export class BaseSubscriptionService<
|
|
|
248
266
|
}
|
|
249
267
|
subscription.active = false;
|
|
250
268
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
251
|
-
|
|
269
|
+
innerEm.persist(subscription);
|
|
252
270
|
});
|
|
253
271
|
}
|
|
254
272
|
|
|
@@ -265,7 +283,7 @@ export class BaseSubscriptionService<
|
|
|
265
283
|
}
|
|
266
284
|
subscription.active = true;
|
|
267
285
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
268
|
-
|
|
286
|
+
innerEm.persist(subscription);
|
|
269
287
|
});
|
|
270
288
|
}
|
|
271
289
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billingPortal.service.d.ts","sourceRoot":"","sources":["../../services/billingPortal.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAkB,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"billingPortal.service.d.ts","sourceRoot":"","sources":["../../services/billingPortal.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAkB,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,C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AAsB,EACxC,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CA4B/C;IAEK,uBAAuB,CAC3B,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAgB/C;IAEK,0BAA0B,CAC9B,gBAAgB,EAAE,sBAAsB,EACxC,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAuE/C;IAEK,0BAA0B,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB5D;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkoutSession.service.d.ts","sourceRoot":"","sources":["../../services/checkoutSession.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAkB,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"checkoutSession.service.d.ts","sourceRoot":"","sources":["../../services/checkoutSession.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CA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,EAAE,QAAQ,EACf,sBAAsB,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,EACjE,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,sBAAsB,CAC7B,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,CACd,EACD,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,gBAAgB,CAAC;QAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,EAeF;IAED,SAAS,CAAC,cAAc,yBAAsC;IAExD,qBAAqB,CACzB,kBAAkB,EAAE,wBAAwB,CAC1C,iBAAiB,EACjB,YAAY,EACZ,UAAU,CACX,EACD,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC,CA6BjD;IAEK,kBAAkB,CAAC,EACvB,EAAE,EACH,EAAE,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAWzD;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAQxD;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBxD;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBxD;CACF"}
|
package/lib/services/index.js
CHANGED
|
@@ -33,6 +33,31 @@ module.exports = __toCommonJS(services_exports);
|
|
|
33
33
|
var import_cache = require("@forklaunch/core/cache");
|
|
34
34
|
var import_http = require("@forklaunch/core/http");
|
|
35
35
|
var import_core = require("@mikro-orm/core");
|
|
36
|
+
|
|
37
|
+
// utils/cachedSessionDto.ts
|
|
38
|
+
function cachedSessionDto(value, expectedId) {
|
|
39
|
+
if (arguments.length > 1 && (typeof expectedId !== "string" || !expectedId.trim() || !value || value.id !== expectedId)) {
|
|
40
|
+
throw new Error("Cached session identity does not match");
|
|
41
|
+
}
|
|
42
|
+
const date = (input) => {
|
|
43
|
+
if (!(input instanceof Date) && typeof input !== "string" && typeof input !== "number") {
|
|
44
|
+
throw new Error("Cached session date is invalid");
|
|
45
|
+
}
|
|
46
|
+
const parsed = new Date(input instanceof Date ? input.getTime() : input);
|
|
47
|
+
if (!Number.isFinite(parsed.getTime())) {
|
|
48
|
+
throw new Error("Cached session date is invalid");
|
|
49
|
+
}
|
|
50
|
+
return parsed;
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
...value,
|
|
54
|
+
expiresAt: date(value.expiresAt),
|
|
55
|
+
...value.createdAt === void 0 ? {} : { createdAt: date(value.createdAt) },
|
|
56
|
+
...value.updatedAt === void 0 ? {} : { updatedAt: date(value.updatedAt) }
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// services/billingPortal.service.ts
|
|
36
61
|
var BaseBillingPortalService = class {
|
|
37
62
|
evaluatedTelemetryOptions;
|
|
38
63
|
enableDatabaseBackup;
|
|
@@ -86,12 +111,7 @@ var BaseBillingPortalService = class {
|
|
|
86
111
|
if (!billingPortalDetails) {
|
|
87
112
|
throw new Error("Session not found");
|
|
88
113
|
}
|
|
89
|
-
return
|
|
90
|
-
await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
91
|
-
billingPortalDetails.value,
|
|
92
|
-
this.em
|
|
93
|
-
)
|
|
94
|
-
);
|
|
114
|
+
return cachedSessionDto(billingPortalDetails.value, idDto.id);
|
|
95
115
|
}
|
|
96
116
|
async updateBillingPortalSession(billingPortalDto, ...args) {
|
|
97
117
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -106,6 +126,28 @@ var BaseBillingPortalService = class {
|
|
|
106
126
|
if (!existingBillingPortal) {
|
|
107
127
|
throw new Error("Session not found");
|
|
108
128
|
}
|
|
129
|
+
const existingBillingPortalDto = cachedSessionDto(
|
|
130
|
+
existingBillingPortal,
|
|
131
|
+
billingPortalDto.id
|
|
132
|
+
);
|
|
133
|
+
if (!this.enableDatabaseBackup && this.mappers.UpdateBillingPortalMapper.toCachedDto) {
|
|
134
|
+
const updated = await this.mappers.UpdateBillingPortalMapper.toCachedDto(
|
|
135
|
+
billingPortalDto,
|
|
136
|
+
existingBillingPortalDto,
|
|
137
|
+
args[0] instanceof import_core.EntityManager ? args[0] : this.em,
|
|
138
|
+
...args[0] instanceof import_core.EntityManager ? args.slice(1) : args
|
|
139
|
+
);
|
|
140
|
+
if (updated.id !== existingBillingPortalDto.id || updated.customerId !== existingBillingPortalDto.customerId) {
|
|
141
|
+
throw new Error("Cached session identity cannot change");
|
|
142
|
+
}
|
|
143
|
+
const updatedBillingPortalDto2 = cachedSessionDto(updated, billingPortalDto.id);
|
|
144
|
+
await this.cache.putRecord({
|
|
145
|
+
key: this.createCacheKey(updatedBillingPortalDto2.id),
|
|
146
|
+
value: updatedBillingPortalDto2,
|
|
147
|
+
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
148
|
+
});
|
|
149
|
+
return updatedBillingPortalDto2;
|
|
150
|
+
}
|
|
109
151
|
const billingPortal = await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
110
152
|
billingPortalDto,
|
|
111
153
|
args[0] instanceof import_core.EntityManager ? args[0] : this.em,
|
|
@@ -115,7 +157,7 @@ var BaseBillingPortalService = class {
|
|
|
115
157
|
await this.em.persist(billingPortal).flush();
|
|
116
158
|
}
|
|
117
159
|
const updatedBillingPortalDto = {
|
|
118
|
-
...
|
|
160
|
+
...existingBillingPortalDto,
|
|
119
161
|
...await this.mappers.BillingPortalMapper.toDto(billingPortal)
|
|
120
162
|
};
|
|
121
163
|
await this.cache.putRecord({
|
|
@@ -123,12 +165,7 @@ var BaseBillingPortalService = class {
|
|
|
123
165
|
value: updatedBillingPortalDto,
|
|
124
166
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
125
167
|
});
|
|
126
|
-
return
|
|
127
|
-
await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
128
|
-
billingPortal,
|
|
129
|
-
this.em
|
|
130
|
-
)
|
|
131
|
-
);
|
|
168
|
+
return updatedBillingPortalDto;
|
|
132
169
|
}
|
|
133
170
|
async expireBillingPortalSession(idDto) {
|
|
134
171
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -203,12 +240,7 @@ var BaseCheckoutSessionService = class {
|
|
|
203
240
|
if (!checkoutSessionDetails) {
|
|
204
241
|
throw new Error("Session not found");
|
|
205
242
|
}
|
|
206
|
-
return
|
|
207
|
-
await this.mappers.UpdateCheckoutSessionMapper.toEntity(
|
|
208
|
-
checkoutSessionDetails.value,
|
|
209
|
-
this.em
|
|
210
|
-
)
|
|
211
|
-
);
|
|
243
|
+
return cachedSessionDto(checkoutSessionDetails.value, id);
|
|
212
244
|
}
|
|
213
245
|
async expireCheckoutSession({ id }) {
|
|
214
246
|
const checkoutSessionDetails = await this.cache.readRecord(
|
|
@@ -309,6 +341,26 @@ var BasePaymentLinkService = class {
|
|
|
309
341
|
if (!existingLink) {
|
|
310
342
|
throw new Error("Payment link not found");
|
|
311
343
|
}
|
|
344
|
+
if (!this.enableDatabaseBackup && this.mappers.UpdatePaymentLinkMapper.toCachedDto) {
|
|
345
|
+
if (existingLink.id !== paymentLinkDto.id) {
|
|
346
|
+
throw new Error("Cached payment link identity cannot change");
|
|
347
|
+
}
|
|
348
|
+
const updated = await this.mappers.UpdatePaymentLinkMapper.toCachedDto(
|
|
349
|
+
paymentLinkDto,
|
|
350
|
+
existingLink,
|
|
351
|
+
args[0] instanceof import_core3.EntityManager ? args[0] : this.em,
|
|
352
|
+
...args[0] instanceof import_core3.EntityManager ? args.slice(1) : args
|
|
353
|
+
);
|
|
354
|
+
if (updated.id !== paymentLinkDto.id) {
|
|
355
|
+
throw new Error("Cached payment link identity cannot change");
|
|
356
|
+
}
|
|
357
|
+
await this.cache.putRecord({
|
|
358
|
+
key: cacheKey,
|
|
359
|
+
value: updated,
|
|
360
|
+
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
361
|
+
});
|
|
362
|
+
return updated;
|
|
363
|
+
}
|
|
312
364
|
const paymentLink = await this.mappers.UpdatePaymentLinkMapper.toEntity(
|
|
313
365
|
paymentLinkDto,
|
|
314
366
|
args[0] instanceof import_core3.EntityManager ? args[0] : this.em,
|
|
@@ -328,6 +380,18 @@ var BasePaymentLinkService = class {
|
|
|
328
380
|
});
|
|
329
381
|
return updatedLinkDto;
|
|
330
382
|
}
|
|
383
|
+
normalizeCachedPaymentLink(value, cacheKey) {
|
|
384
|
+
const normalize = this.mappers.PaymentLinkMapper.normalizeCachedDto;
|
|
385
|
+
if (!normalize) return value;
|
|
386
|
+
if (!value || typeof value.id !== "string" || !value.id.trim() || this.createCacheKey(value.id) !== cacheKey) {
|
|
387
|
+
throw new Error("Cached payment link identity does not match");
|
|
388
|
+
}
|
|
389
|
+
const normalized = normalize(value);
|
|
390
|
+
if (normalized.id !== value.id) {
|
|
391
|
+
throw new Error("Cached payment link identity cannot change");
|
|
392
|
+
}
|
|
393
|
+
return normalized;
|
|
394
|
+
}
|
|
331
395
|
async getPaymentLink({
|
|
332
396
|
id
|
|
333
397
|
}) {
|
|
@@ -339,7 +403,7 @@ var BasePaymentLinkService = class {
|
|
|
339
403
|
if (!paymentLink) {
|
|
340
404
|
throw new Error("Payment link not found");
|
|
341
405
|
}
|
|
342
|
-
return paymentLink.value;
|
|
406
|
+
return this.normalizeCachedPaymentLink(paymentLink.value, cacheKey);
|
|
343
407
|
}
|
|
344
408
|
async expirePaymentLink({ id }) {
|
|
345
409
|
this.openTelemetryCollector.info("Payment link expired", { id });
|
|
@@ -383,12 +447,26 @@ var BasePaymentLinkService = class {
|
|
|
383
447
|
}
|
|
384
448
|
await this.cache.deleteRecord(this.createCacheKey(id));
|
|
385
449
|
}
|
|
386
|
-
async listPaymentLinks(idsDto) {
|
|
450
|
+
async listPaymentLinks(idsDto, maxValidatedRecords) {
|
|
451
|
+
if (maxValidatedRecords !== void 0 && (!Number.isSafeInteger(maxValidatedRecords) || maxValidatedRecords < 1 || (idsDto?.ids?.length ?? 0) > maxValidatedRecords)) {
|
|
452
|
+
throw new Error("Configured payment link list exceeds its record limit");
|
|
453
|
+
}
|
|
454
|
+
if (maxValidatedRecords !== void 0 && idsDto?.ids?.some((id) => typeof id !== "string" || !id.trim())) {
|
|
455
|
+
throw new Error("Invalid configured payment link identity");
|
|
456
|
+
}
|
|
387
457
|
const keys = idsDto?.ids && idsDto.ids.length > 0 ? idsDto?.ids.map((id) => this.createCacheKey(id)) : await this.cache.listKeys(this.cacheKeyPrefix);
|
|
458
|
+
if (maxValidatedRecords !== void 0 && keys.length > maxValidatedRecords) {
|
|
459
|
+
throw new Error("Configured payment link list exceeds its record limit");
|
|
460
|
+
}
|
|
388
461
|
return Promise.all(
|
|
389
462
|
keys.map(async (key) => {
|
|
390
463
|
const paymentLink = await this.cache.readRecord(key);
|
|
391
|
-
|
|
464
|
+
if (maxValidatedRecords !== void 0 && (!paymentLink?.value || typeof paymentLink.value.id !== "string" || !paymentLink.value.id.trim() || this.createCacheKey(paymentLink.value.id) !== key)) {
|
|
465
|
+
throw new Error(
|
|
466
|
+
"Cached payment link is missing or its identity does not match"
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
return this.normalizeCachedPaymentLink(paymentLink.value, key);
|
|
392
470
|
})
|
|
393
471
|
);
|
|
394
472
|
}
|
|
@@ -441,7 +519,7 @@ var BasePlanService = class {
|
|
|
441
519
|
...args[0] instanceof import_core4.EntityManager ? args.slice(1) : args
|
|
442
520
|
);
|
|
443
521
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
444
|
-
|
|
522
|
+
innerEm.persist(plan);
|
|
445
523
|
});
|
|
446
524
|
return this.mappers.PlanMapper.toDto(plan);
|
|
447
525
|
}
|
|
@@ -468,7 +546,7 @@ var BasePlanService = class {
|
|
|
468
546
|
);
|
|
469
547
|
const updatedPlan = await (em ?? this.em).upsert(plan);
|
|
470
548
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
471
|
-
|
|
549
|
+
innerEm.persist(plan);
|
|
472
550
|
});
|
|
473
551
|
const updatedPlanDto = await this.mappers.PlanMapper.toDto(updatedPlan);
|
|
474
552
|
return updatedPlanDto;
|
|
@@ -490,6 +568,12 @@ var import_core5 = require("@mikro-orm/core");
|
|
|
490
568
|
var BaseSubscriptionService = class {
|
|
491
569
|
constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
492
570
|
this.options = options;
|
|
571
|
+
const partyTypes = mappers.SubscriptionMapper.partyTypes;
|
|
572
|
+
if (partyTypes !== void 0 && (!partyTypes || Array.isArray(partyTypes) || typeof partyTypes.user !== "string" || !partyTypes.user.trim() || typeof partyTypes.organization !== "string" || !partyTypes.organization.trim() || partyTypes.user === partyTypes.organization)) {
|
|
573
|
+
throw new Error("Invalid subscription party types");
|
|
574
|
+
}
|
|
575
|
+
this.userPartyType = partyTypes?.user ?? "USER";
|
|
576
|
+
this.organizationPartyType = partyTypes?.organization ?? "ORGANIZATION";
|
|
493
577
|
this.em = em;
|
|
494
578
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
495
579
|
this.schemaValidator = schemaValidator;
|
|
@@ -503,6 +587,8 @@ var BaseSubscriptionService = class {
|
|
|
503
587
|
options;
|
|
504
588
|
evaluatedTelemetryOptions;
|
|
505
589
|
em;
|
|
590
|
+
userPartyType;
|
|
591
|
+
organizationPartyType;
|
|
506
592
|
openTelemetryCollector;
|
|
507
593
|
schemaValidator;
|
|
508
594
|
mappers;
|
|
@@ -519,7 +605,7 @@ var BaseSubscriptionService = class {
|
|
|
519
605
|
...args[0] instanceof import_core5.EntityManager ? args.slice(1) : args
|
|
520
606
|
);
|
|
521
607
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
522
|
-
|
|
608
|
+
innerEm.persist(subscription);
|
|
523
609
|
});
|
|
524
610
|
const createdSubscriptionDto = await this.mappers.SubscriptionMapper.toDto(subscription);
|
|
525
611
|
return createdSubscriptionDto;
|
|
@@ -558,7 +644,7 @@ var BaseSubscriptionService = class {
|
|
|
558
644
|
this.mappers.SubscriptionMapper.entity,
|
|
559
645
|
{
|
|
560
646
|
partyId: id,
|
|
561
|
-
partyType:
|
|
647
|
+
partyType: this.userPartyType,
|
|
562
648
|
active: true
|
|
563
649
|
}
|
|
564
650
|
);
|
|
@@ -574,7 +660,7 @@ var BaseSubscriptionService = class {
|
|
|
574
660
|
this.mappers.SubscriptionMapper.entity,
|
|
575
661
|
{
|
|
576
662
|
partyId: id,
|
|
577
|
-
partyType:
|
|
663
|
+
partyType: this.organizationPartyType,
|
|
578
664
|
active: true
|
|
579
665
|
}
|
|
580
666
|
);
|
|
@@ -596,7 +682,7 @@ var BaseSubscriptionService = class {
|
|
|
596
682
|
);
|
|
597
683
|
const updatedSubscription = await (em ?? this.em).upsert(subscription);
|
|
598
684
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
599
|
-
|
|
685
|
+
innerEm.persist(updatedSubscription);
|
|
600
686
|
});
|
|
601
687
|
const updatedSubscriptionDto = await this.mappers.SubscriptionMapper.toDto(updatedSubscription);
|
|
602
688
|
return updatedSubscriptionDto;
|
|
@@ -644,7 +730,7 @@ var BaseSubscriptionService = class {
|
|
|
644
730
|
}
|
|
645
731
|
subscription.active = false;
|
|
646
732
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
647
|
-
|
|
733
|
+
innerEm.persist(subscription);
|
|
648
734
|
});
|
|
649
735
|
}
|
|
650
736
|
async resumeSubscription(idDto, em) {
|
|
@@ -660,7 +746,7 @@ var BaseSubscriptionService = class {
|
|
|
660
746
|
}
|
|
661
747
|
subscription.active = true;
|
|
662
748
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
663
|
-
|
|
749
|
+
innerEm.persist(subscription);
|
|
664
750
|
});
|
|
665
751
|
}
|
|
666
752
|
};
|
package/lib/services/index.mjs
CHANGED
|
@@ -4,6 +4,31 @@ import {
|
|
|
4
4
|
evaluateTelemetryOptions
|
|
5
5
|
} from "@forklaunch/core/http";
|
|
6
6
|
import { EntityManager } from "@mikro-orm/core";
|
|
7
|
+
|
|
8
|
+
// utils/cachedSessionDto.ts
|
|
9
|
+
function cachedSessionDto(value, expectedId) {
|
|
10
|
+
if (arguments.length > 1 && (typeof expectedId !== "string" || !expectedId.trim() || !value || value.id !== expectedId)) {
|
|
11
|
+
throw new Error("Cached session identity does not match");
|
|
12
|
+
}
|
|
13
|
+
const date = (input) => {
|
|
14
|
+
if (!(input instanceof Date) && typeof input !== "string" && typeof input !== "number") {
|
|
15
|
+
throw new Error("Cached session date is invalid");
|
|
16
|
+
}
|
|
17
|
+
const parsed = new Date(input instanceof Date ? input.getTime() : input);
|
|
18
|
+
if (!Number.isFinite(parsed.getTime())) {
|
|
19
|
+
throw new Error("Cached session date is invalid");
|
|
20
|
+
}
|
|
21
|
+
return parsed;
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
...value,
|
|
25
|
+
expiresAt: date(value.expiresAt),
|
|
26
|
+
...value.createdAt === void 0 ? {} : { createdAt: date(value.createdAt) },
|
|
27
|
+
...value.updatedAt === void 0 ? {} : { updatedAt: date(value.updatedAt) }
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// services/billingPortal.service.ts
|
|
7
32
|
var BaseBillingPortalService = class {
|
|
8
33
|
evaluatedTelemetryOptions;
|
|
9
34
|
enableDatabaseBackup;
|
|
@@ -57,12 +82,7 @@ var BaseBillingPortalService = class {
|
|
|
57
82
|
if (!billingPortalDetails) {
|
|
58
83
|
throw new Error("Session not found");
|
|
59
84
|
}
|
|
60
|
-
return
|
|
61
|
-
await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
62
|
-
billingPortalDetails.value,
|
|
63
|
-
this.em
|
|
64
|
-
)
|
|
65
|
-
);
|
|
85
|
+
return cachedSessionDto(billingPortalDetails.value, idDto.id);
|
|
66
86
|
}
|
|
67
87
|
async updateBillingPortalSession(billingPortalDto, ...args) {
|
|
68
88
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -77,6 +97,28 @@ var BaseBillingPortalService = class {
|
|
|
77
97
|
if (!existingBillingPortal) {
|
|
78
98
|
throw new Error("Session not found");
|
|
79
99
|
}
|
|
100
|
+
const existingBillingPortalDto = cachedSessionDto(
|
|
101
|
+
existingBillingPortal,
|
|
102
|
+
billingPortalDto.id
|
|
103
|
+
);
|
|
104
|
+
if (!this.enableDatabaseBackup && this.mappers.UpdateBillingPortalMapper.toCachedDto) {
|
|
105
|
+
const updated = await this.mappers.UpdateBillingPortalMapper.toCachedDto(
|
|
106
|
+
billingPortalDto,
|
|
107
|
+
existingBillingPortalDto,
|
|
108
|
+
args[0] instanceof EntityManager ? args[0] : this.em,
|
|
109
|
+
...args[0] instanceof EntityManager ? args.slice(1) : args
|
|
110
|
+
);
|
|
111
|
+
if (updated.id !== existingBillingPortalDto.id || updated.customerId !== existingBillingPortalDto.customerId) {
|
|
112
|
+
throw new Error("Cached session identity cannot change");
|
|
113
|
+
}
|
|
114
|
+
const updatedBillingPortalDto2 = cachedSessionDto(updated, billingPortalDto.id);
|
|
115
|
+
await this.cache.putRecord({
|
|
116
|
+
key: this.createCacheKey(updatedBillingPortalDto2.id),
|
|
117
|
+
value: updatedBillingPortalDto2,
|
|
118
|
+
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
119
|
+
});
|
|
120
|
+
return updatedBillingPortalDto2;
|
|
121
|
+
}
|
|
80
122
|
const billingPortal = await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
81
123
|
billingPortalDto,
|
|
82
124
|
args[0] instanceof EntityManager ? args[0] : this.em,
|
|
@@ -86,7 +128,7 @@ var BaseBillingPortalService = class {
|
|
|
86
128
|
await this.em.persist(billingPortal).flush();
|
|
87
129
|
}
|
|
88
130
|
const updatedBillingPortalDto = {
|
|
89
|
-
...
|
|
131
|
+
...existingBillingPortalDto,
|
|
90
132
|
...await this.mappers.BillingPortalMapper.toDto(billingPortal)
|
|
91
133
|
};
|
|
92
134
|
await this.cache.putRecord({
|
|
@@ -94,12 +136,7 @@ var BaseBillingPortalService = class {
|
|
|
94
136
|
value: updatedBillingPortalDto,
|
|
95
137
|
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
96
138
|
});
|
|
97
|
-
return
|
|
98
|
-
await this.mappers.UpdateBillingPortalMapper.toEntity(
|
|
99
|
-
billingPortal,
|
|
100
|
-
this.em
|
|
101
|
-
)
|
|
102
|
-
);
|
|
139
|
+
return updatedBillingPortalDto;
|
|
103
140
|
}
|
|
104
141
|
async expireBillingPortalSession(idDto) {
|
|
105
142
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -176,12 +213,7 @@ var BaseCheckoutSessionService = class {
|
|
|
176
213
|
if (!checkoutSessionDetails) {
|
|
177
214
|
throw new Error("Session not found");
|
|
178
215
|
}
|
|
179
|
-
return
|
|
180
|
-
await this.mappers.UpdateCheckoutSessionMapper.toEntity(
|
|
181
|
-
checkoutSessionDetails.value,
|
|
182
|
-
this.em
|
|
183
|
-
)
|
|
184
|
-
);
|
|
216
|
+
return cachedSessionDto(checkoutSessionDetails.value, id);
|
|
185
217
|
}
|
|
186
218
|
async expireCheckoutSession({ id }) {
|
|
187
219
|
const checkoutSessionDetails = await this.cache.readRecord(
|
|
@@ -284,6 +316,26 @@ var BasePaymentLinkService = class {
|
|
|
284
316
|
if (!existingLink) {
|
|
285
317
|
throw new Error("Payment link not found");
|
|
286
318
|
}
|
|
319
|
+
if (!this.enableDatabaseBackup && this.mappers.UpdatePaymentLinkMapper.toCachedDto) {
|
|
320
|
+
if (existingLink.id !== paymentLinkDto.id) {
|
|
321
|
+
throw new Error("Cached payment link identity cannot change");
|
|
322
|
+
}
|
|
323
|
+
const updated = await this.mappers.UpdatePaymentLinkMapper.toCachedDto(
|
|
324
|
+
paymentLinkDto,
|
|
325
|
+
existingLink,
|
|
326
|
+
args[0] instanceof EntityManager3 ? args[0] : this.em,
|
|
327
|
+
...args[0] instanceof EntityManager3 ? args.slice(1) : args
|
|
328
|
+
);
|
|
329
|
+
if (updated.id !== paymentLinkDto.id) {
|
|
330
|
+
throw new Error("Cached payment link identity cannot change");
|
|
331
|
+
}
|
|
332
|
+
await this.cache.putRecord({
|
|
333
|
+
key: cacheKey,
|
|
334
|
+
value: updated,
|
|
335
|
+
ttlMilliseconds: this.cache.getTtlMilliseconds()
|
|
336
|
+
});
|
|
337
|
+
return updated;
|
|
338
|
+
}
|
|
287
339
|
const paymentLink = await this.mappers.UpdatePaymentLinkMapper.toEntity(
|
|
288
340
|
paymentLinkDto,
|
|
289
341
|
args[0] instanceof EntityManager3 ? args[0] : this.em,
|
|
@@ -303,6 +355,18 @@ var BasePaymentLinkService = class {
|
|
|
303
355
|
});
|
|
304
356
|
return updatedLinkDto;
|
|
305
357
|
}
|
|
358
|
+
normalizeCachedPaymentLink(value, cacheKey) {
|
|
359
|
+
const normalize = this.mappers.PaymentLinkMapper.normalizeCachedDto;
|
|
360
|
+
if (!normalize) return value;
|
|
361
|
+
if (!value || typeof value.id !== "string" || !value.id.trim() || this.createCacheKey(value.id) !== cacheKey) {
|
|
362
|
+
throw new Error("Cached payment link identity does not match");
|
|
363
|
+
}
|
|
364
|
+
const normalized = normalize(value);
|
|
365
|
+
if (normalized.id !== value.id) {
|
|
366
|
+
throw new Error("Cached payment link identity cannot change");
|
|
367
|
+
}
|
|
368
|
+
return normalized;
|
|
369
|
+
}
|
|
306
370
|
async getPaymentLink({
|
|
307
371
|
id
|
|
308
372
|
}) {
|
|
@@ -314,7 +378,7 @@ var BasePaymentLinkService = class {
|
|
|
314
378
|
if (!paymentLink) {
|
|
315
379
|
throw new Error("Payment link not found");
|
|
316
380
|
}
|
|
317
|
-
return paymentLink.value;
|
|
381
|
+
return this.normalizeCachedPaymentLink(paymentLink.value, cacheKey);
|
|
318
382
|
}
|
|
319
383
|
async expirePaymentLink({ id }) {
|
|
320
384
|
this.openTelemetryCollector.info("Payment link expired", { id });
|
|
@@ -358,12 +422,26 @@ var BasePaymentLinkService = class {
|
|
|
358
422
|
}
|
|
359
423
|
await this.cache.deleteRecord(this.createCacheKey(id));
|
|
360
424
|
}
|
|
361
|
-
async listPaymentLinks(idsDto) {
|
|
425
|
+
async listPaymentLinks(idsDto, maxValidatedRecords) {
|
|
426
|
+
if (maxValidatedRecords !== void 0 && (!Number.isSafeInteger(maxValidatedRecords) || maxValidatedRecords < 1 || (idsDto?.ids?.length ?? 0) > maxValidatedRecords)) {
|
|
427
|
+
throw new Error("Configured payment link list exceeds its record limit");
|
|
428
|
+
}
|
|
429
|
+
if (maxValidatedRecords !== void 0 && idsDto?.ids?.some((id) => typeof id !== "string" || !id.trim())) {
|
|
430
|
+
throw new Error("Invalid configured payment link identity");
|
|
431
|
+
}
|
|
362
432
|
const keys = idsDto?.ids && idsDto.ids.length > 0 ? idsDto?.ids.map((id) => this.createCacheKey(id)) : await this.cache.listKeys(this.cacheKeyPrefix);
|
|
433
|
+
if (maxValidatedRecords !== void 0 && keys.length > maxValidatedRecords) {
|
|
434
|
+
throw new Error("Configured payment link list exceeds its record limit");
|
|
435
|
+
}
|
|
363
436
|
return Promise.all(
|
|
364
437
|
keys.map(async (key) => {
|
|
365
438
|
const paymentLink = await this.cache.readRecord(key);
|
|
366
|
-
|
|
439
|
+
if (maxValidatedRecords !== void 0 && (!paymentLink?.value || typeof paymentLink.value.id !== "string" || !paymentLink.value.id.trim() || this.createCacheKey(paymentLink.value.id) !== key)) {
|
|
440
|
+
throw new Error(
|
|
441
|
+
"Cached payment link is missing or its identity does not match"
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
return this.normalizeCachedPaymentLink(paymentLink.value, key);
|
|
367
445
|
})
|
|
368
446
|
);
|
|
369
447
|
}
|
|
@@ -418,7 +496,7 @@ var BasePlanService = class {
|
|
|
418
496
|
...args[0] instanceof EntityManager4 ? args.slice(1) : args
|
|
419
497
|
);
|
|
420
498
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
421
|
-
|
|
499
|
+
innerEm.persist(plan);
|
|
422
500
|
});
|
|
423
501
|
return this.mappers.PlanMapper.toDto(plan);
|
|
424
502
|
}
|
|
@@ -445,7 +523,7 @@ var BasePlanService = class {
|
|
|
445
523
|
);
|
|
446
524
|
const updatedPlan = await (em ?? this.em).upsert(plan);
|
|
447
525
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
448
|
-
|
|
526
|
+
innerEm.persist(plan);
|
|
449
527
|
});
|
|
450
528
|
const updatedPlanDto = await this.mappers.PlanMapper.toDto(updatedPlan);
|
|
451
529
|
return updatedPlanDto;
|
|
@@ -469,6 +547,12 @@ import { EntityManager as EntityManager5 } from "@mikro-orm/core";
|
|
|
469
547
|
var BaseSubscriptionService = class {
|
|
470
548
|
constructor(em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
471
549
|
this.options = options;
|
|
550
|
+
const partyTypes = mappers.SubscriptionMapper.partyTypes;
|
|
551
|
+
if (partyTypes !== void 0 && (!partyTypes || Array.isArray(partyTypes) || typeof partyTypes.user !== "string" || !partyTypes.user.trim() || typeof partyTypes.organization !== "string" || !partyTypes.organization.trim() || partyTypes.user === partyTypes.organization)) {
|
|
552
|
+
throw new Error("Invalid subscription party types");
|
|
553
|
+
}
|
|
554
|
+
this.userPartyType = partyTypes?.user ?? "USER";
|
|
555
|
+
this.organizationPartyType = partyTypes?.organization ?? "ORGANIZATION";
|
|
472
556
|
this.em = em;
|
|
473
557
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
474
558
|
this.schemaValidator = schemaValidator;
|
|
@@ -482,6 +566,8 @@ var BaseSubscriptionService = class {
|
|
|
482
566
|
options;
|
|
483
567
|
evaluatedTelemetryOptions;
|
|
484
568
|
em;
|
|
569
|
+
userPartyType;
|
|
570
|
+
organizationPartyType;
|
|
485
571
|
openTelemetryCollector;
|
|
486
572
|
schemaValidator;
|
|
487
573
|
mappers;
|
|
@@ -498,7 +584,7 @@ var BaseSubscriptionService = class {
|
|
|
498
584
|
...args[0] instanceof EntityManager5 ? args.slice(1) : args
|
|
499
585
|
);
|
|
500
586
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
501
|
-
|
|
587
|
+
innerEm.persist(subscription);
|
|
502
588
|
});
|
|
503
589
|
const createdSubscriptionDto = await this.mappers.SubscriptionMapper.toDto(subscription);
|
|
504
590
|
return createdSubscriptionDto;
|
|
@@ -537,7 +623,7 @@ var BaseSubscriptionService = class {
|
|
|
537
623
|
this.mappers.SubscriptionMapper.entity,
|
|
538
624
|
{
|
|
539
625
|
partyId: id,
|
|
540
|
-
partyType:
|
|
626
|
+
partyType: this.userPartyType,
|
|
541
627
|
active: true
|
|
542
628
|
}
|
|
543
629
|
);
|
|
@@ -553,7 +639,7 @@ var BaseSubscriptionService = class {
|
|
|
553
639
|
this.mappers.SubscriptionMapper.entity,
|
|
554
640
|
{
|
|
555
641
|
partyId: id,
|
|
556
|
-
partyType:
|
|
642
|
+
partyType: this.organizationPartyType,
|
|
557
643
|
active: true
|
|
558
644
|
}
|
|
559
645
|
);
|
|
@@ -575,7 +661,7 @@ var BaseSubscriptionService = class {
|
|
|
575
661
|
);
|
|
576
662
|
const updatedSubscription = await (em ?? this.em).upsert(subscription);
|
|
577
663
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
578
|
-
|
|
664
|
+
innerEm.persist(updatedSubscription);
|
|
579
665
|
});
|
|
580
666
|
const updatedSubscriptionDto = await this.mappers.SubscriptionMapper.toDto(updatedSubscription);
|
|
581
667
|
return updatedSubscriptionDto;
|
|
@@ -623,7 +709,7 @@ var BaseSubscriptionService = class {
|
|
|
623
709
|
}
|
|
624
710
|
subscription.active = false;
|
|
625
711
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
626
|
-
|
|
712
|
+
innerEm.persist(subscription);
|
|
627
713
|
});
|
|
628
714
|
}
|
|
629
715
|
async resumeSubscription(idDto, em) {
|
|
@@ -639,7 +725,7 @@ var BaseSubscriptionService = class {
|
|
|
639
725
|
}
|
|
640
726
|
subscription.active = true;
|
|
641
727
|
await (em ?? this.em).transactional(async (innerEm) => {
|
|
642
|
-
|
|
728
|
+
innerEm.persist(subscription);
|
|
643
729
|
});
|
|
644
730
|
}
|
|
645
731
|
};
|
|
@@ -24,10 +24,11 @@ export declare class BasePaymentLinkService<SchemaValidator extends AnySchemaVal
|
|
|
24
24
|
protected createCacheKey: (id: string) => string;
|
|
25
25
|
createPaymentLink(paymentLinkDto: CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>, ...args: unknown[]): Promise<MapperDomains['PaymentLinkMapper']>;
|
|
26
26
|
updatePaymentLink(paymentLinkDto: UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>, ...args: unknown[]): Promise<MapperDomains['PaymentLinkMapper']>;
|
|
27
|
+
private normalizeCachedPaymentLink;
|
|
27
28
|
getPaymentLink({ id }: IdDto): Promise<MapperDomains['PaymentLinkMapper']>;
|
|
28
29
|
expirePaymentLink({ id }: IdDto): Promise<void>;
|
|
29
30
|
handlePaymentSuccess({ id }: IdDto): Promise<void>;
|
|
30
31
|
handlePaymentFailure({ id }: IdDto): Promise<void>;
|
|
31
|
-
listPaymentLinks(idsDto?: IdsDto): Promise<MapperDomains['PaymentLinkMapper'][]>;
|
|
32
|
+
listPaymentLinks(idsDto?: IdsDto, maxValidatedRecords?: number): Promise<MapperDomains['PaymentLinkMapper'][]>;
|
|
32
33
|
}
|
|
33
34
|
//# sourceMappingURL=paymentLink.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentLink.service.d.ts","sourceRoot":"","sources":["../../services/paymentLink.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAkB,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,C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zB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,CACd,EACD,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,gBAAgB,CAAC;QAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,EAeF;IAED,SAAS,CAAC,cAAc,SAAkB;IAC1C,SAAS,CAAC,cAAc,yBAAuC;IAEzD,iBAAiB,CACrB,cAAc,EAAE,oBAAoB,CAClC,iBAAiB,EACjB,YAAY,EACZ,UAAU,CACX,EACD,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAyB7C;IAEK,iBAAiB,CACrB,cAAc,EAAE,oBAAoB,CAClC,iBAAiB,EACjB,YAAY,EACZ,UAAU,CACX,EACD,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"paymentLink.service.d.ts","sourceRoot":"","sources":["../../services/paymentLink.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAkB,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,kBAA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,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAyB7C;IAEK,iBAAiB,CACrB,cAAc,EAAE,oBAAoB,CAClC,iBAAiB,EACjB,YAAY,EACZ,UAAU,CACX,EACD,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAyD7C;IAED,OAAO,CAAC,0BAA0B;IAqB5B,cAAc,CAAC,EACnB,EAAE,EACH,EAAE,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAYrD;IAEK,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAcpD;IAEK,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAavD;IAEK,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAavD;IAEK,gBAAgB,CACpB,MAAM,CAAC,EAAE,MAAM,EACf,mBAAmB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,EAAE,CAAC,CA6C/C;CACF"}
|
|
@@ -17,6 +17,8 @@ export declare class BaseSubscriptionService<SchemaValidator extends AnySchemaVa
|
|
|
17
17
|
tracing?: boolean;
|
|
18
18
|
};
|
|
19
19
|
protected em: EntityManager;
|
|
20
|
+
private readonly userPartyType;
|
|
21
|
+
private readonly organizationPartyType;
|
|
20
22
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
21
23
|
protected readonly schemaValidator: SchemaValidator;
|
|
22
24
|
protected readonly mappers: SubscriptionMappers<PartyType, BillingProviderType, MapperEntities, Dto>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.service.d.ts","sourceRoot":"","sources":["../../services/subscription.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAe,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAGhF,qBAAa,uBAAuB,CAClC,eAAe,SAAS,kBAAkB,EAC1C,SAAS,EACT,mBAAmB,EACnB,cAAc,SAAS,wBAAwB,EAC/C,GAAG,SAAS,oBAAoB,CAC9B,SAAS,EACT,mBAAmB,CACpB,GAAG,oBAAoB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CACxD,YAAW,mBAAmB,CAAC,SAAS,EAAE,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"subscription.service.d.ts","sourceRoot":"","sources":["../../services/subscription.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAe,MAAM,iBAAi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MAAM,EACf,EAAE,CAAC,EAAE,aAAa,GACjB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAkBtC;IAEK,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAexE;IAEK,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAexE;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cachedSessionDto.d.ts","sourceRoot":"","sources":["../../utils/cachedSessionDto.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,IAAI,CAAA;CAAE,EAC9E,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,CAkClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/implementation-billing-base",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Billing basic implementation for forklaunch",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"lib/**"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@forklaunch/common": "^1.2.
|
|
49
|
-
"@forklaunch/core": "^3.
|
|
50
|
-
"@forklaunch/
|
|
51
|
-
"@forklaunch/
|
|
48
|
+
"@forklaunch/common": "^1.2.32",
|
|
49
|
+
"@forklaunch/core": "^3.3.0",
|
|
50
|
+
"@forklaunch/interfaces-billing": "^1.0.40",
|
|
51
|
+
"@forklaunch/internal": "^1.2.35",
|
|
52
|
+
"@forklaunch/validator": "^1.3.0",
|
|
52
53
|
"@mikro-orm/core": "7.2.5",
|
|
53
54
|
"@sinclair/typebox": "^0.34.52",
|
|
54
55
|
"ajv": "^8.20.0",
|
|
55
|
-
"zod": "^4.6.7"
|
|
56
|
-
"@forklaunch/interfaces-billing": "^1.0.39"
|
|
56
|
+
"zod": "^4.6.7"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"depcheck": "^1.4.7",
|