@forklaunch/interfaces-billing 0.2.3 → 0.3.1

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.
Files changed (56) hide show
  1. package/lib/eject/domain/interfaces/checkoutSession.service.interface.ts +7 -1
  2. package/lib/eject/domain/interfaces/paymentLink.service.interface.ts +3 -1
  3. package/lib/eject/domain/interfaces/plan.service.interface.ts +3 -1
  4. package/lib/eject/domain/types/billingPortal.service.types.ts +6 -6
  5. package/lib/eject/domain/types/checkoutSession.service.types.ts +32 -12
  6. package/lib/eject/domain/types/paymentLink.service.types.ts +31 -19
  7. package/lib/eject/domain/types/plan.service.types.ts +36 -20
  8. package/lib/eject/domain/types/subscription.service.types.ts +21 -17
  9. package/lib/interfaces/index.d.mts +50 -0
  10. package/lib/interfaces/index.d.ts +50 -6
  11. package/lib/interfaces/index.js +18 -5
  12. package/lib/interfaces/index.mjs +0 -0
  13. package/lib/types/index.d.mts +98 -0
  14. package/lib/types/index.d.ts +98 -6
  15. package/lib/types/index.js +18 -5
  16. package/lib/types/index.mjs +0 -0
  17. package/package.json +11 -7
  18. package/lib/interfaces/billingPortal.service.interface.d.ts +0 -16
  19. package/lib/interfaces/billingPortal.service.interface.d.ts.map +0 -1
  20. package/lib/interfaces/billingPortal.service.interface.js +0 -1
  21. package/lib/interfaces/checkoutSession.service.interface.d.ts +0 -20
  22. package/lib/interfaces/checkoutSession.service.interface.d.ts.map +0 -1
  23. package/lib/interfaces/checkoutSession.service.interface.js +0 -1
  24. package/lib/interfaces/index.d.ts.map +0 -1
  25. package/lib/interfaces/paymentLink.service.interface.d.ts +0 -24
  26. package/lib/interfaces/paymentLink.service.interface.d.ts.map +0 -1
  27. package/lib/interfaces/paymentLink.service.interface.js +0 -1
  28. package/lib/interfaces/plan.service.interface.d.ts +0 -29
  29. package/lib/interfaces/plan.service.interface.d.ts.map +0 -1
  30. package/lib/interfaces/plan.service.interface.js +0 -1
  31. package/lib/interfaces/subscription.service.interface.d.ts +0 -48
  32. package/lib/interfaces/subscription.service.interface.d.ts.map +0 -1
  33. package/lib/interfaces/subscription.service.interface.js +0 -1
  34. package/lib/jest.config.d.ts +0 -4
  35. package/lib/jest.config.d.ts.map +0 -1
  36. package/lib/jest.config.js +0 -19
  37. package/lib/tsconfig.tsbuildinfo +0 -1
  38. package/lib/types/billingPortal.service.types.d.ts +0 -18
  39. package/lib/types/billingPortal.service.types.d.ts.map +0 -1
  40. package/lib/types/billingPortal.service.types.js +0 -1
  41. package/lib/types/checkoutSession.service.types.d.ts +0 -25
  42. package/lib/types/checkoutSession.service.types.d.ts.map +0 -1
  43. package/lib/types/checkoutSession.service.types.js +0 -1
  44. package/lib/types/index.d.ts.map +0 -1
  45. package/lib/types/paymentLink.service.types.d.ts +0 -24
  46. package/lib/types/paymentLink.service.types.d.ts.map +0 -1
  47. package/lib/types/paymentLink.service.types.js +0 -1
  48. package/lib/types/plan.service.types.d.ts +0 -25
  49. package/lib/types/plan.service.types.d.ts.map +0 -1
  50. package/lib/types/plan.service.types.js +0 -1
  51. package/lib/types/subscription.service.types.d.ts +0 -27
  52. package/lib/types/subscription.service.types.d.ts.map +0 -1
  53. package/lib/types/subscription.service.types.js +0 -1
  54. package/lib/vitest.config.d.ts +0 -3
  55. package/lib/vitest.config.d.ts.map +0 -1
  56. package/lib/vitest.config.js +0 -7
@@ -1,11 +1,17 @@
1
1
  import { CheckoutSessionServiceParameters } from '../types/checkoutSession.service.types';
2
2
  export interface CheckoutSessionService<
3
3
  PaymentMethodEnum,
4
+ CurrencyEnum,
4
5
  StatusEnum,
5
6
  Params extends CheckoutSessionServiceParameters<
6
7
  PaymentMethodEnum,
8
+ CurrencyEnum,
7
9
  StatusEnum
8
- > = CheckoutSessionServiceParameters<PaymentMethodEnum, StatusEnum>
10
+ > = CheckoutSessionServiceParameters<
11
+ PaymentMethodEnum,
12
+ CurrencyEnum,
13
+ StatusEnum
14
+ >
9
15
  > {
10
16
  // for generating external links
11
17
  // store in cache, for permissions
@@ -1,12 +1,14 @@
1
1
  import { PaymentLinkServiceParameters } from '../types/paymentLink.service.types';
2
2
 
3
3
  export interface PaymentLinkService<
4
+ PaymentMethodEnum,
4
5
  CurrencyEnum,
5
6
  StatusEnum,
6
7
  Params extends PaymentLinkServiceParameters<
8
+ PaymentMethodEnum,
7
9
  CurrencyEnum,
8
10
  StatusEnum
9
- > = PaymentLinkServiceParameters<CurrencyEnum, StatusEnum>
11
+ > = PaymentLinkServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum>
10
12
  > {
11
13
  // for one off products that are not part of a subscription
12
14
  // think about how permissions work on payment links, but these should be ephemeral
@@ -3,11 +3,13 @@ import { PlanServiceParameters } from '../types/plan.service.types';
3
3
 
4
4
  export interface PlanService<
5
5
  PlanCadenceEnum,
6
+ CurrencyEnum,
6
7
  BillingProviderEnum,
7
8
  Params extends PlanServiceParameters<
8
9
  PlanCadenceEnum,
10
+ CurrencyEnum,
9
11
  BillingProviderEnum
10
- > = PlanServiceParameters<PlanCadenceEnum, BillingProviderEnum>
12
+ > = PlanServiceParameters<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>
11
13
  > {
12
14
  createPlan: (
13
15
  planDto: Params['CreatePlanDto'],
@@ -1,14 +1,14 @@
1
1
  import { IdDto, RecordTimingDto } from '@forklaunch/common';
2
2
 
3
- export type CreateBillingPortalDto = {
3
+ export type CreateBillingPortalDto = Partial<IdDto> & {
4
4
  customerId: string;
5
- uri: string;
5
+ uri?: string;
6
6
  expiresAt: Date;
7
- extraFields?: unknown;
7
+ providerFields?: unknown;
8
8
  };
9
- export type UpdateBillingPortalDto = IdDto & Partial<CreateBillingPortalDto>;
10
- export type BillingPortalDto = IdDto &
11
- CreateBillingPortalDto &
9
+ export type UpdateBillingPortalDto = Partial<CreateBillingPortalDto> & IdDto;
10
+ export type BillingPortalDto = CreateBillingPortalDto &
11
+ IdDto &
12
12
  Partial<RecordTimingDto>;
13
13
 
14
14
  export type BillingPortalServiceParameters = {
@@ -1,26 +1,46 @@
1
1
  import { IdDto, RecordTimingDto } from '@forklaunch/common';
2
2
 
3
- export type CreateCheckoutSessionDto<PaymentMethodEnum, StatusEnum> = {
3
+ export type CreateCheckoutSessionDto<
4
+ PaymentMethodEnum,
5
+ CurrencyEnum,
6
+ StatusEnum
7
+ > = Partial<IdDto> & {
4
8
  customerId: string;
5
9
  paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
6
- metadata?: unknown;
7
- successRedirectUri: string;
8
- cancelRedirectUri: string;
10
+ currency: CurrencyEnum[keyof CurrencyEnum];
11
+ successRedirectUri?: string;
12
+ cancelRedirectUri?: string;
9
13
  expiresAt: Date;
10
14
  status: StatusEnum[keyof StatusEnum];
11
- extraFields?: unknown;
15
+ providerFields?: unknown;
12
16
  };
13
- export type UpdateCheckoutSessionDto<PaymentMethodEnum, StatusEnum> = IdDto &
14
- Partial<CreateCheckoutSessionDto<PaymentMethodEnum, StatusEnum>>;
15
- export type CheckoutSessionDto<PaymentMethodEnum, StatusEnum> = IdDto &
16
- CreateCheckoutSessionDto<PaymentMethodEnum, StatusEnum> &
17
- Partial<RecordTimingDto>;
17
+ export type UpdateCheckoutSessionDto<
18
+ PaymentMethodEnum,
19
+ CurrencyEnum,
20
+ StatusEnum
21
+ > = Partial<
22
+ CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>
23
+ > &
24
+ IdDto;
25
+ export type CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> =
26
+ CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> &
27
+ IdDto &
28
+ Partial<RecordTimingDto>;
18
29
 
19
- export type CheckoutSessionServiceParameters<PaymentMethodEnum, StatusEnum> = {
30
+ export type CheckoutSessionServiceParameters<
31
+ PaymentMethodEnum,
32
+ CurrencyEnum,
33
+ StatusEnum
34
+ > = {
20
35
  CreateCheckoutSessionDto: CreateCheckoutSessionDto<
21
36
  PaymentMethodEnum,
37
+ CurrencyEnum,
38
+ StatusEnum
39
+ >;
40
+ CheckoutSessionDto: CheckoutSessionDto<
41
+ PaymentMethodEnum,
42
+ CurrencyEnum,
22
43
  StatusEnum
23
44
  >;
24
- CheckoutSessionDto: CheckoutSessionDto<PaymentMethodEnum, StatusEnum>;
25
45
  IdDto: IdDto;
26
46
  };
@@ -1,25 +1,37 @@
1
1
  import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
2
 
3
- export type CreatePaymentLinkDto<CurrencyEnum, StatusEnum> = {
4
- amount: number;
5
- currency: CurrencyEnum[keyof CurrencyEnum];
6
- metadata?: unknown;
7
- successRedirectUri: string;
8
- cancelRedirectUri: string;
9
- expiresAt: Date;
10
- status: StatusEnum[keyof StatusEnum];
11
- extraFields?: unknown;
12
- };
13
- export type UpdatePaymentLinkDto<CurrencyEnum, StatusEnum> = IdDto &
14
- Partial<CreatePaymentLinkDto<CurrencyEnum, StatusEnum>>;
15
- export type PaymentLinkDto<CurrencyEnum, StatusEnum> = IdDto &
16
- CreatePaymentLinkDto<CurrencyEnum, StatusEnum> &
17
- Partial<RecordTimingDto>;
3
+ export type CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> =
4
+ Partial<IdDto> & {
5
+ amount: number;
6
+ currency: CurrencyEnum[keyof CurrencyEnum];
7
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
8
+ status: StatusEnum[keyof StatusEnum];
9
+ providerFields?: unknown;
10
+ };
11
+ export type UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> =
12
+ Partial<CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>> &
13
+ IdDto;
14
+ export type PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> =
15
+ CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> &
16
+ IdDto &
17
+ Partial<RecordTimingDto>;
18
18
 
19
- export type PaymentLinkServiceParameters<CurrencyEnum, StatusEnum> = {
20
- CreatePaymentLinkDto: CreatePaymentLinkDto<CurrencyEnum, StatusEnum>;
21
- UpdatePaymentLinkDto: UpdatePaymentLinkDto<CurrencyEnum, StatusEnum>;
22
- PaymentLinkDto: PaymentLinkDto<CurrencyEnum, StatusEnum>;
19
+ export type PaymentLinkServiceParameters<
20
+ PaymentMethodEnum,
21
+ CurrencyEnum,
22
+ StatusEnum
23
+ > = {
24
+ CreatePaymentLinkDto: CreatePaymentLinkDto<
25
+ PaymentMethodEnum,
26
+ CurrencyEnum,
27
+ StatusEnum
28
+ >;
29
+ UpdatePaymentLinkDto: UpdatePaymentLinkDto<
30
+ PaymentMethodEnum,
31
+ CurrencyEnum,
32
+ StatusEnum
33
+ >;
34
+ PaymentLinkDto: PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
23
35
  IdDto: IdDto;
24
36
  IdsDto: IdsDto;
25
37
  };
@@ -1,26 +1,42 @@
1
1
  import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
2
 
3
- export type CreatePlanDto<PlanCadenceEnum, BillingProviderEnum> = {
4
- active: boolean;
5
- name: string;
6
- description?: string;
7
- price: number;
8
- cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
9
- features?: string[];
10
- extraFields?: unknown;
11
- externalId: string;
12
- billingProvider?: BillingProviderEnum[keyof BillingProviderEnum];
13
- };
14
- export type UpdatePlanDto<PlanCadenceEnum, BillingProviderEnum> = IdDto &
15
- Partial<CreatePlanDto<PlanCadenceEnum, BillingProviderEnum>>;
16
- export type PlanDto<PlanCadenceEnum, BillingProviderEnum> = IdDto &
17
- CreatePlanDto<PlanCadenceEnum, BillingProviderEnum> &
18
- Partial<RecordTimingDto>;
3
+ export type CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> =
4
+ Partial<IdDto> & {
5
+ active: boolean;
6
+ name: string;
7
+ description?: string;
8
+ price: number;
9
+ currency: CurrencyEnum[keyof CurrencyEnum];
10
+ cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
11
+ features?: string[];
12
+ providerFields?: unknown;
13
+ externalId: string;
14
+ billingProvider?: BillingProviderEnum[keyof BillingProviderEnum];
15
+ };
16
+ export type UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> =
17
+ Partial<CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> &
18
+ IdDto;
19
+ export type PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> =
20
+ CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> &
21
+ IdDto &
22
+ Partial<RecordTimingDto>;
19
23
 
20
- export type PlanServiceParameters<PlanCadenceEnum, BillingProviderEnum> = {
21
- CreatePlanDto: CreatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
22
- UpdatePlanDto: UpdatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
23
- PlanDto: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
24
+ export type PlanServiceParameters<
25
+ PlanCadenceEnum,
26
+ CurrencyEnum,
27
+ BillingProviderEnum
28
+ > = {
29
+ CreatePlanDto: CreatePlanDto<
30
+ PlanCadenceEnum,
31
+ CurrencyEnum,
32
+ BillingProviderEnum
33
+ >;
34
+ UpdatePlanDto: UpdatePlanDto<
35
+ PlanCadenceEnum,
36
+ CurrencyEnum,
37
+ BillingProviderEnum
38
+ >;
39
+ PlanDto: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
24
40
  IdDto: IdDto;
25
41
  IdsDto: IdsDto;
26
42
  };
@@ -1,23 +1,27 @@
1
1
  import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
2
 
3
- export type CreateSubscriptionDto<PartyType, BillingProviderType> = {
4
- partyId: string;
5
- partyType: PartyType[keyof PartyType];
6
- description?: string;
7
- active: boolean;
8
- productId: string;
9
- extraFields?: unknown;
10
- externalId: string;
11
- billingProvider?: BillingProviderType[keyof BillingProviderType];
12
- startDate: Date;
13
- endDate: Date;
14
- status: string;
15
- };
16
- export type UpdateSubscriptionDto<PartyType, BillingProviderType> = IdDto &
17
- Partial<CreateSubscriptionDto<PartyType, BillingProviderType>>;
18
- export type SubscriptionDto<PartyType, BillingProviderType> = IdDto &
3
+ export type CreateSubscriptionDto<PartyType, BillingProviderType> =
4
+ Partial<IdDto> & {
5
+ partyId: string;
6
+ partyType: PartyType[keyof PartyType];
7
+ description?: string;
8
+ active: boolean;
9
+ productId: string;
10
+ providerFields?: unknown;
11
+ externalId: string;
12
+ billingProvider?: BillingProviderType[keyof BillingProviderType];
13
+ startDate: Date;
14
+ endDate?: Date;
15
+ status: string;
16
+ };
17
+ export type UpdateSubscriptionDto<PartyType, BillingProviderType> = Partial<
18
+ CreateSubscriptionDto<PartyType, BillingProviderType>
19
+ > &
20
+ IdDto;
21
+ export type SubscriptionDto<PartyType, BillingProviderType> =
19
22
  CreateSubscriptionDto<PartyType, BillingProviderType> &
20
- Partial<RecordTimingDto>;
23
+ IdDto &
24
+ Partial<RecordTimingDto>;
21
25
 
22
26
  export type SubscriptionServiceParameters<PartyType, BillingProviderType> = {
23
27
  CreateSubscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>;
@@ -0,0 +1,50 @@
1
+ import { BillingPortalServiceParameters, CheckoutSessionServiceParameters, PaymentLinkServiceParameters, PlanServiceParameters, SubscriptionServiceParameters } from '../types/index.mjs';
2
+ import { EntityManager } from '@mikro-orm/core';
3
+ import '@forklaunch/common';
4
+
5
+ interface BillingPortalService<Params extends BillingPortalServiceParameters = BillingPortalServiceParameters> {
6
+ createBillingPortalSession: (billingPortalDto: Params['CreateBillingPortalDto']) => Promise<Params['BillingPortalDto']>;
7
+ getBillingPortalSession: (idDto: Params['IdDto']) => Promise<Params['BillingPortalDto']>;
8
+ updateBillingPortalSession: (billingPortalDto: Params['UpdateBillingPortalDto']) => Promise<Params['BillingPortalDto']>;
9
+ expireBillingPortalSession: (idDto: Params['IdDto']) => Promise<void>;
10
+ }
11
+
12
+ interface CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum, Params extends CheckoutSessionServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = CheckoutSessionServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum>> {
13
+ createCheckoutSession: (checkoutSessionDto: Params['CreateCheckoutSessionDto']) => Promise<Params['CheckoutSessionDto']>;
14
+ getCheckoutSession: (idDto: Params['IdDto']) => Promise<Params['CheckoutSessionDto']>;
15
+ expireCheckoutSession: (idDto: Params['IdDto']) => Promise<void>;
16
+ handleCheckoutSuccess: (idDto: Params['IdDto']) => Promise<void>;
17
+ handleCheckoutFailure: (idDto: Params['IdDto']) => Promise<void>;
18
+ }
19
+
20
+ interface PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum, Params extends PaymentLinkServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = PaymentLinkServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum>> {
21
+ createPaymentLink: (paymentLink: Params['CreatePaymentLinkDto']) => Promise<Params['PaymentLinkDto']>;
22
+ updatePaymentLink: (paymentLink: Params['UpdatePaymentLinkDto']) => Promise<Params['PaymentLinkDto']>;
23
+ getPaymentLink: (idDto: Params['IdDto']) => Promise<Params['PaymentLinkDto']>;
24
+ expirePaymentLink: (idDto: Params['IdDto']) => Promise<void>;
25
+ handlePaymentSuccess: (idDto: Params['IdDto']) => Promise<void>;
26
+ handlePaymentFailure: (idDto: Params['IdDto']) => Promise<void>;
27
+ listPaymentLinks: (idsDto?: Params['IdsDto']) => Promise<Params['PaymentLinkDto'][]>;
28
+ }
29
+
30
+ interface PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, Params extends PlanServiceParameters<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = PlanServiceParameters<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> {
31
+ createPlan: (planDto: Params['CreatePlanDto'], em?: EntityManager) => Promise<Params['PlanDto']>;
32
+ getPlan: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['PlanDto']>;
33
+ updatePlan: (planDto: Params['UpdatePlanDto'], em?: EntityManager) => Promise<Params['PlanDto']>;
34
+ deletePlan: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
35
+ listPlans: (idsDto?: Params['IdsDto'], em?: EntityManager) => Promise<Params['PlanDto'][]>;
36
+ }
37
+
38
+ interface SubscriptionService<PartyType, BillingProviderType, Params extends SubscriptionServiceParameters<PartyType, BillingProviderType> = SubscriptionServiceParameters<PartyType, BillingProviderType>> {
39
+ createSubscription: (subscriptionDto: Params['CreateSubscriptionDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
40
+ getSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
41
+ getUserSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
42
+ getOrganizationSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
43
+ updateSubscription: (subscriptionDto: Params['UpdateSubscriptionDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
44
+ deleteSubscription: (id: Params['IdDto'], em?: EntityManager) => Promise<void>;
45
+ listSubscriptions: (idsDto: Params['IdsDto'], em?: EntityManager) => Promise<Params['SubscriptionDto'][]>;
46
+ cancelSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
47
+ resumeSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
48
+ }
49
+
50
+ export type { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService };
@@ -1,6 +1,50 @@
1
- export * from './billingPortal.service.interface';
2
- export * from './checkoutSession.service.interface';
3
- export * from './paymentLink.service.interface';
4
- export * from './plan.service.interface';
5
- export * from './subscription.service.interface';
6
- //# sourceMappingURL=index.d.ts.map
1
+ import { BillingPortalServiceParameters, CheckoutSessionServiceParameters, PaymentLinkServiceParameters, PlanServiceParameters, SubscriptionServiceParameters } from '../types/index.js';
2
+ import { EntityManager } from '@mikro-orm/core';
3
+ import '@forklaunch/common';
4
+
5
+ interface BillingPortalService<Params extends BillingPortalServiceParameters = BillingPortalServiceParameters> {
6
+ createBillingPortalSession: (billingPortalDto: Params['CreateBillingPortalDto']) => Promise<Params['BillingPortalDto']>;
7
+ getBillingPortalSession: (idDto: Params['IdDto']) => Promise<Params['BillingPortalDto']>;
8
+ updateBillingPortalSession: (billingPortalDto: Params['UpdateBillingPortalDto']) => Promise<Params['BillingPortalDto']>;
9
+ expireBillingPortalSession: (idDto: Params['IdDto']) => Promise<void>;
10
+ }
11
+
12
+ interface CheckoutSessionService<PaymentMethodEnum, CurrencyEnum, StatusEnum, Params extends CheckoutSessionServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = CheckoutSessionServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum>> {
13
+ createCheckoutSession: (checkoutSessionDto: Params['CreateCheckoutSessionDto']) => Promise<Params['CheckoutSessionDto']>;
14
+ getCheckoutSession: (idDto: Params['IdDto']) => Promise<Params['CheckoutSessionDto']>;
15
+ expireCheckoutSession: (idDto: Params['IdDto']) => Promise<void>;
16
+ handleCheckoutSuccess: (idDto: Params['IdDto']) => Promise<void>;
17
+ handleCheckoutFailure: (idDto: Params['IdDto']) => Promise<void>;
18
+ }
19
+
20
+ interface PaymentLinkService<PaymentMethodEnum, CurrencyEnum, StatusEnum, Params extends PaymentLinkServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = PaymentLinkServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum>> {
21
+ createPaymentLink: (paymentLink: Params['CreatePaymentLinkDto']) => Promise<Params['PaymentLinkDto']>;
22
+ updatePaymentLink: (paymentLink: Params['UpdatePaymentLinkDto']) => Promise<Params['PaymentLinkDto']>;
23
+ getPaymentLink: (idDto: Params['IdDto']) => Promise<Params['PaymentLinkDto']>;
24
+ expirePaymentLink: (idDto: Params['IdDto']) => Promise<void>;
25
+ handlePaymentSuccess: (idDto: Params['IdDto']) => Promise<void>;
26
+ handlePaymentFailure: (idDto: Params['IdDto']) => Promise<void>;
27
+ listPaymentLinks: (idsDto?: Params['IdsDto']) => Promise<Params['PaymentLinkDto'][]>;
28
+ }
29
+
30
+ interface PlanService<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, Params extends PlanServiceParameters<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = PlanServiceParameters<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> {
31
+ createPlan: (planDto: Params['CreatePlanDto'], em?: EntityManager) => Promise<Params['PlanDto']>;
32
+ getPlan: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['PlanDto']>;
33
+ updatePlan: (planDto: Params['UpdatePlanDto'], em?: EntityManager) => Promise<Params['PlanDto']>;
34
+ deletePlan: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
35
+ listPlans: (idsDto?: Params['IdsDto'], em?: EntityManager) => Promise<Params['PlanDto'][]>;
36
+ }
37
+
38
+ interface SubscriptionService<PartyType, BillingProviderType, Params extends SubscriptionServiceParameters<PartyType, BillingProviderType> = SubscriptionServiceParameters<PartyType, BillingProviderType>> {
39
+ createSubscription: (subscriptionDto: Params['CreateSubscriptionDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
40
+ getSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
41
+ getUserSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
42
+ getOrganizationSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
43
+ updateSubscription: (subscriptionDto: Params['UpdateSubscriptionDto'], em?: EntityManager) => Promise<Params['SubscriptionDto']>;
44
+ deleteSubscription: (id: Params['IdDto'], em?: EntityManager) => Promise<void>;
45
+ listSubscriptions: (idsDto: Params['IdsDto'], em?: EntityManager) => Promise<Params['SubscriptionDto'][]>;
46
+ cancelSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
47
+ resumeSubscription: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
48
+ }
49
+
50
+ export type { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanService, SubscriptionService };
@@ -1,5 +1,18 @@
1
- export * from './billingPortal.service.interface';
2
- export * from './checkoutSession.service.interface';
3
- export * from './paymentLink.service.interface';
4
- export * from './plan.service.interface';
5
- export * from './subscription.service.interface';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // interfaces/index.ts
17
+ var interfaces_exports = {};
18
+ module.exports = __toCommonJS(interfaces_exports);
File without changes
@@ -0,0 +1,98 @@
1
+ import { IdDto, RecordTimingDto, IdsDto } from '@forklaunch/common';
2
+
3
+ type CreateBillingPortalDto = Partial<IdDto> & {
4
+ customerId: string;
5
+ uri?: string;
6
+ expiresAt: Date;
7
+ providerFields?: unknown;
8
+ };
9
+ type UpdateBillingPortalDto = Partial<CreateBillingPortalDto> & IdDto;
10
+ type BillingPortalDto = CreateBillingPortalDto & IdDto & Partial<RecordTimingDto>;
11
+ type BillingPortalServiceParameters = {
12
+ CreateBillingPortalDto: CreateBillingPortalDto;
13
+ UpdateBillingPortalDto: UpdateBillingPortalDto;
14
+ BillingPortalDto: BillingPortalDto;
15
+ IdDto: IdDto;
16
+ };
17
+
18
+ type CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<IdDto> & {
19
+ customerId: string;
20
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
21
+ currency: CurrencyEnum[keyof CurrencyEnum];
22
+ successRedirectUri?: string;
23
+ cancelRedirectUri?: string;
24
+ expiresAt: Date;
25
+ status: StatusEnum[keyof StatusEnum];
26
+ providerFields?: unknown;
27
+ };
28
+ type UpdateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>> & IdDto;
29
+ type CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> & IdDto & Partial<RecordTimingDto>;
30
+ type CheckoutSessionServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
31
+ CreateCheckoutSessionDto: CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
32
+ CheckoutSessionDto: CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
33
+ IdDto: IdDto;
34
+ };
35
+
36
+ type CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<IdDto> & {
37
+ amount: number;
38
+ currency: CurrencyEnum[keyof CurrencyEnum];
39
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
40
+ status: StatusEnum[keyof StatusEnum];
41
+ providerFields?: unknown;
42
+ };
43
+ type UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>> & IdDto;
44
+ type PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> & IdDto & Partial<RecordTimingDto>;
45
+ type PaymentLinkServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
46
+ CreatePaymentLinkDto: CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
47
+ UpdatePaymentLinkDto: UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
48
+ PaymentLinkDto: PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
49
+ IdDto: IdDto;
50
+ IdsDto: IdsDto;
51
+ };
52
+
53
+ type CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = Partial<IdDto> & {
54
+ active: boolean;
55
+ name: string;
56
+ description?: string;
57
+ price: number;
58
+ currency: CurrencyEnum[keyof CurrencyEnum];
59
+ cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
60
+ features?: string[];
61
+ providerFields?: unknown;
62
+ externalId: string;
63
+ billingProvider?: BillingProviderEnum[keyof BillingProviderEnum];
64
+ };
65
+ type UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = Partial<CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> & IdDto;
66
+ type PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> & IdDto & Partial<RecordTimingDto>;
67
+ type PlanServiceParameters<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = {
68
+ CreatePlanDto: CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
69
+ UpdatePlanDto: UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
70
+ PlanDto: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
71
+ IdDto: IdDto;
72
+ IdsDto: IdsDto;
73
+ };
74
+
75
+ type CreateSubscriptionDto<PartyType, BillingProviderType> = Partial<IdDto> & {
76
+ partyId: string;
77
+ partyType: PartyType[keyof PartyType];
78
+ description?: string;
79
+ active: boolean;
80
+ productId: string;
81
+ providerFields?: unknown;
82
+ externalId: string;
83
+ billingProvider?: BillingProviderType[keyof BillingProviderType];
84
+ startDate: Date;
85
+ endDate?: Date;
86
+ status: string;
87
+ };
88
+ type UpdateSubscriptionDto<PartyType, BillingProviderType> = Partial<CreateSubscriptionDto<PartyType, BillingProviderType>> & IdDto;
89
+ type SubscriptionDto<PartyType, BillingProviderType> = CreateSubscriptionDto<PartyType, BillingProviderType> & IdDto & Partial<RecordTimingDto>;
90
+ type SubscriptionServiceParameters<PartyType, BillingProviderType> = {
91
+ CreateSubscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>;
92
+ UpdateSubscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>;
93
+ SubscriptionDto: SubscriptionDto<PartyType, BillingProviderType>;
94
+ IdDto: IdDto;
95
+ IdsDto: IdsDto;
96
+ };
97
+
98
+ export type { BillingPortalDto, BillingPortalServiceParameters, CheckoutSessionDto, CheckoutSessionServiceParameters, CreateBillingPortalDto, CreateCheckoutSessionDto, CreatePaymentLinkDto, CreatePlanDto, CreateSubscriptionDto, PaymentLinkDto, PaymentLinkServiceParameters, PlanDto, PlanServiceParameters, SubscriptionDto, SubscriptionServiceParameters, UpdateBillingPortalDto, UpdateCheckoutSessionDto, UpdatePaymentLinkDto, UpdatePlanDto, UpdateSubscriptionDto };
@@ -1,6 +1,98 @@
1
- export * from './billingPortal.service.types';
2
- export * from './checkoutSession.service.types';
3
- export * from './paymentLink.service.types';
4
- export * from './plan.service.types';
5
- export * from './subscription.service.types';
6
- //# sourceMappingURL=index.d.ts.map
1
+ import { IdDto, RecordTimingDto, IdsDto } from '@forklaunch/common';
2
+
3
+ type CreateBillingPortalDto = Partial<IdDto> & {
4
+ customerId: string;
5
+ uri?: string;
6
+ expiresAt: Date;
7
+ providerFields?: unknown;
8
+ };
9
+ type UpdateBillingPortalDto = Partial<CreateBillingPortalDto> & IdDto;
10
+ type BillingPortalDto = CreateBillingPortalDto & IdDto & Partial<RecordTimingDto>;
11
+ type BillingPortalServiceParameters = {
12
+ CreateBillingPortalDto: CreateBillingPortalDto;
13
+ UpdateBillingPortalDto: UpdateBillingPortalDto;
14
+ BillingPortalDto: BillingPortalDto;
15
+ IdDto: IdDto;
16
+ };
17
+
18
+ type CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<IdDto> & {
19
+ customerId: string;
20
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
21
+ currency: CurrencyEnum[keyof CurrencyEnum];
22
+ successRedirectUri?: string;
23
+ cancelRedirectUri?: string;
24
+ expiresAt: Date;
25
+ status: StatusEnum[keyof StatusEnum];
26
+ providerFields?: unknown;
27
+ };
28
+ type UpdateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>> & IdDto;
29
+ type CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> & IdDto & Partial<RecordTimingDto>;
30
+ type CheckoutSessionServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
31
+ CreateCheckoutSessionDto: CreateCheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
32
+ CheckoutSessionDto: CheckoutSessionDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
33
+ IdDto: IdDto;
34
+ };
35
+
36
+ type CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<IdDto> & {
37
+ amount: number;
38
+ currency: CurrencyEnum[keyof CurrencyEnum];
39
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
40
+ status: StatusEnum[keyof StatusEnum];
41
+ providerFields?: unknown;
42
+ };
43
+ type UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = Partial<CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>> & IdDto;
44
+ type PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> = CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum> & IdDto & Partial<RecordTimingDto>;
45
+ type PaymentLinkServiceParameters<PaymentMethodEnum, CurrencyEnum, StatusEnum> = {
46
+ CreatePaymentLinkDto: CreatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
47
+ UpdatePaymentLinkDto: UpdatePaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
48
+ PaymentLinkDto: PaymentLinkDto<PaymentMethodEnum, CurrencyEnum, StatusEnum>;
49
+ IdDto: IdDto;
50
+ IdsDto: IdsDto;
51
+ };
52
+
53
+ type CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = Partial<IdDto> & {
54
+ active: boolean;
55
+ name: string;
56
+ description?: string;
57
+ price: number;
58
+ currency: CurrencyEnum[keyof CurrencyEnum];
59
+ cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
60
+ features?: string[];
61
+ providerFields?: unknown;
62
+ externalId: string;
63
+ billingProvider?: BillingProviderEnum[keyof BillingProviderEnum];
64
+ };
65
+ type UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = Partial<CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>> & IdDto;
66
+ type PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> & IdDto & Partial<RecordTimingDto>;
67
+ type PlanServiceParameters<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum> = {
68
+ CreatePlanDto: CreatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
69
+ UpdatePlanDto: UpdatePlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
70
+ PlanDto: PlanDto<PlanCadenceEnum, CurrencyEnum, BillingProviderEnum>;
71
+ IdDto: IdDto;
72
+ IdsDto: IdsDto;
73
+ };
74
+
75
+ type CreateSubscriptionDto<PartyType, BillingProviderType> = Partial<IdDto> & {
76
+ partyId: string;
77
+ partyType: PartyType[keyof PartyType];
78
+ description?: string;
79
+ active: boolean;
80
+ productId: string;
81
+ providerFields?: unknown;
82
+ externalId: string;
83
+ billingProvider?: BillingProviderType[keyof BillingProviderType];
84
+ startDate: Date;
85
+ endDate?: Date;
86
+ status: string;
87
+ };
88
+ type UpdateSubscriptionDto<PartyType, BillingProviderType> = Partial<CreateSubscriptionDto<PartyType, BillingProviderType>> & IdDto;
89
+ type SubscriptionDto<PartyType, BillingProviderType> = CreateSubscriptionDto<PartyType, BillingProviderType> & IdDto & Partial<RecordTimingDto>;
90
+ type SubscriptionServiceParameters<PartyType, BillingProviderType> = {
91
+ CreateSubscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>;
92
+ UpdateSubscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>;
93
+ SubscriptionDto: SubscriptionDto<PartyType, BillingProviderType>;
94
+ IdDto: IdDto;
95
+ IdsDto: IdsDto;
96
+ };
97
+
98
+ export type { BillingPortalDto, BillingPortalServiceParameters, CheckoutSessionDto, CheckoutSessionServiceParameters, CreateBillingPortalDto, CreateCheckoutSessionDto, CreatePaymentLinkDto, CreatePlanDto, CreateSubscriptionDto, PaymentLinkDto, PaymentLinkServiceParameters, PlanDto, PlanServiceParameters, SubscriptionDto, SubscriptionServiceParameters, UpdateBillingPortalDto, UpdateCheckoutSessionDto, UpdatePaymentLinkDto, UpdatePlanDto, UpdateSubscriptionDto };