@forklaunch/implementation-billing-base 0.1.11 → 0.1.12

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 (89) hide show
  1. package/package.json +5 -5
  2. package/lib/__test__/schemaEquality.test.d.ts +0 -2
  3. package/lib/__test__/schemaEquality.test.d.ts.map +0 -1
  4. package/lib/__test__/schemaEquality.test.js +0 -409
  5. package/lib/eject/domain/schemas/billingPortal.schema.ts +0 -31
  6. package/lib/eject/domain/schemas/checkoutSession.schema.ts +0 -55
  7. package/lib/eject/domain/schemas/index.ts +0 -5
  8. package/lib/eject/domain/schemas/paymentLink.schema.ts +0 -60
  9. package/lib/eject/domain/schemas/plan.schema.ts +0 -80
  10. package/lib/eject/domain/schemas/subscription.schema.ts +0 -86
  11. package/lib/eject/services/billingPortal.service.ts +0 -145
  12. package/lib/eject/services/checkoutSession.service.ts +0 -132
  13. package/lib/eject/services/index.ts +0 -5
  14. package/lib/eject/services/paymentLink.service.ts +0 -170
  15. package/lib/eject/services/plan.service.ts +0 -132
  16. package/lib/eject/services/subscription.service.ts +0 -239
  17. package/lib/jest.config.d.ts +0 -4
  18. package/lib/jest.config.d.ts.map +0 -1
  19. package/lib/jest.config.js +0 -19
  20. package/lib/schemas/billingPortal.schema.d.ts +0 -123
  21. package/lib/schemas/billingPortal.schema.d.ts.map +0 -1
  22. package/lib/schemas/billingPortal.schema.js +0 -7
  23. package/lib/schemas/checkoutSession.schema.d.ts +0 -179
  24. package/lib/schemas/checkoutSession.schema.d.ts.map +0 -1
  25. package/lib/schemas/checkoutSession.schema.js +0 -7
  26. package/lib/schemas/index.d.ts +0 -6
  27. package/lib/schemas/index.d.ts.map +0 -1
  28. package/lib/schemas/index.js +0 -5
  29. package/lib/schemas/paymentLink.schema.d.ts +0 -220
  30. package/lib/schemas/paymentLink.schema.d.ts.map +0 -1
  31. package/lib/schemas/paymentLink.schema.js +0 -7
  32. package/lib/schemas/plan.schema.d.ts +0 -336
  33. package/lib/schemas/plan.schema.d.ts.map +0 -1
  34. package/lib/schemas/plan.schema.js +0 -7
  35. package/lib/schemas/subscription.schema.d.ts +0 -374
  36. package/lib/schemas/subscription.schema.d.ts.map +0 -1
  37. package/lib/schemas/subscription.schema.js +0 -7
  38. package/lib/schemas/typebox/billingPortal.schema.d.ts +0 -181
  39. package/lib/schemas/typebox/billingPortal.schema.d.ts.map +0 -1
  40. package/lib/schemas/typebox/billingPortal.schema.js +0 -31
  41. package/lib/schemas/typebox/checkoutSession.schema.d.ts +0 -204
  42. package/lib/schemas/typebox/checkoutSession.schema.d.ts.map +0 -1
  43. package/lib/schemas/typebox/checkoutSession.schema.js +0 -44
  44. package/lib/schemas/typebox/paymentLink.schema.d.ts +0 -282
  45. package/lib/schemas/typebox/paymentLink.schema.d.ts.map +0 -1
  46. package/lib/schemas/typebox/paymentLink.schema.js +0 -49
  47. package/lib/schemas/typebox/plan.schema.d.ts +0 -416
  48. package/lib/schemas/typebox/plan.schema.d.ts.map +0 -1
  49. package/lib/schemas/typebox/plan.schema.js +0 -57
  50. package/lib/schemas/typebox/subscription.schema.d.ts +0 -488
  51. package/lib/schemas/typebox/subscription.schema.d.ts.map +0 -1
  52. package/lib/schemas/typebox/subscription.schema.js +0 -61
  53. package/lib/schemas/zod/billingPortal.schema.d.ts +0 -51
  54. package/lib/schemas/zod/billingPortal.schema.d.ts.map +0 -1
  55. package/lib/schemas/zod/billingPortal.schema.js +0 -31
  56. package/lib/schemas/zod/checkoutSession.schema.d.ts +0 -114
  57. package/lib/schemas/zod/checkoutSession.schema.d.ts.map +0 -1
  58. package/lib/schemas/zod/checkoutSession.schema.js +0 -44
  59. package/lib/schemas/zod/paymentLink.schema.d.ts +0 -106
  60. package/lib/schemas/zod/paymentLink.schema.d.ts.map +0 -1
  61. package/lib/schemas/zod/paymentLink.schema.js +0 -49
  62. package/lib/schemas/zod/plan.schema.d.ts +0 -184
  63. package/lib/schemas/zod/plan.schema.d.ts.map +0 -1
  64. package/lib/schemas/zod/plan.schema.js +0 -57
  65. package/lib/schemas/zod/subscription.schema.d.ts +0 -188
  66. package/lib/schemas/zod/subscription.schema.d.ts.map +0 -1
  67. package/lib/schemas/zod/subscription.schema.js +0 -61
  68. package/lib/services/billingPortal.service.d.ts +0 -94
  69. package/lib/services/billingPortal.service.d.ts.map +0 -1
  70. package/lib/services/billingPortal.service.js +0 -70
  71. package/lib/services/checkoutSession.service.d.ts +0 -94
  72. package/lib/services/checkoutSession.service.d.ts.map +0 -1
  73. package/lib/services/checkoutSession.service.js +0 -60
  74. package/lib/services/index.d.ts +0 -6
  75. package/lib/services/index.d.ts.map +0 -1
  76. package/lib/services/index.js +0 -5
  77. package/lib/services/paymentLink.service.d.ts +0 -99
  78. package/lib/services/paymentLink.service.d.ts.map +0 -1
  79. package/lib/services/paymentLink.service.js +0 -90
  80. package/lib/services/plan.service.d.ts +0 -90
  81. package/lib/services/plan.service.d.ts.map +0 -1
  82. package/lib/services/plan.service.js +0 -48
  83. package/lib/services/subscription.service.d.ts +0 -145
  84. package/lib/services/subscription.service.d.ts.map +0 -1
  85. package/lib/services/subscription.service.js +0 -117
  86. package/lib/tsconfig.tsbuildinfo +0 -1
  87. package/lib/vitest.config.d.ts +0 -3
  88. package/lib/vitest.config.d.ts.map +0 -1
  89. package/lib/vitest.config.js +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-billing-base",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Billing basic implementation for forklaunch",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -28,14 +28,14 @@
28
28
  "lib/**"
29
29
  ],
30
30
  "dependencies": {
31
- "@forklaunch/common": "link:../../../../framework/common",
32
- "@forklaunch/core": "link:../../../../framework/core",
33
- "@forklaunch/validator": "link:../../../../framework/validator",
31
+ "@forklaunch/common": "^0.2.11",
32
+ "@forklaunch/core": "^0.7.4",
33
+ "@forklaunch/validator": "^0.5.4",
34
34
  "@mikro-orm/core": "^6.4.13",
35
35
  "@sinclair/typebox": "^0.34.33",
36
36
  "ajv": "^8.17.1",
37
37
  "zod": "^3.24.3",
38
- "@forklaunch/interfaces-billing": "0.1.11"
38
+ "@forklaunch/interfaces-billing": "0.1.12"
39
39
  },
40
40
  "devDependencies": {
41
41
  "depcheck": "^1.4.7",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=schemaEquality.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemaEquality.test.d.ts","sourceRoot":"","sources":["../../__test__/schemaEquality.test.ts"],"names":[],"mappings":""}
@@ -1,409 +0,0 @@
1
- import { isTrue } from '@forklaunch/common';
2
- import { DummyEnum, testSchemaEquality } from '@forklaunch/core/test';
3
- import {
4
- BillingPortalSchema as TypeboxBillingPortalSchema,
5
- CreateBillingPortalSchema as TypeboxCreateBillingPortalSchema,
6
- UpdateBillingPortalSchema as TypeboxUpdateBillingPortalSchema
7
- } from '../schemas/typebox/billingPortal.schema';
8
- import {
9
- CheckoutSessionSchema as TypeboxCheckoutSessionSchema,
10
- CreateCheckoutSessionSchema as TypeboxCreateCheckoutSessionSchema,
11
- UpdateCheckoutSessionSchema as TypeboxUpdateCheckoutSessionSchema
12
- } from '../schemas/typebox/checkoutSession.schema';
13
- import {
14
- CreatePaymentLinkSchema as TypeboxCreatePaymentLinkSchema,
15
- PaymentLinkSchema as TypeboxPaymentLinkSchema,
16
- UpdatePaymentLinkSchema as TypeboxUpdatePaymentLinkSchema
17
- } from '../schemas/typebox/paymentLink.schema';
18
- import {
19
- CreatePlanSchema as TypeboxCreatePlanSchema,
20
- PlanSchema as TypeboxPlanSchema,
21
- UpdatePlanSchema as TypeboxUpdatePlanSchema
22
- } from '../schemas/typebox/plan.schema';
23
- import {
24
- CreateSubscriptionSchema as TypeboxCreateSubscriptionSchema,
25
- SubscriptionSchema as TypeboxSubscriptionSchema,
26
- UpdateSubscriptionSchema as TypeboxUpdateSubscriptionSchema
27
- } from '../schemas/typebox/subscription.schema';
28
- import {
29
- BillingPortalSchema as ZodBillingPortalSchema,
30
- CreateBillingPortalSchema as ZodCreateBillingPortalSchema,
31
- UpdateBillingPortalSchema as ZodUpdateBillingPortalSchema
32
- } from '../schemas/zod/billingPortal.schema';
33
- import {
34
- CheckoutSessionSchema as ZodCheckoutSessionSchema,
35
- CreateCheckoutSessionSchema as ZodCreateCheckoutSessionSchema,
36
- UpdateCheckoutSessionSchema as ZodUpdateCheckoutSessionSchema
37
- } from '../schemas/zod/checkoutSession.schema';
38
- import {
39
- CreatePaymentLinkSchema as ZodCreatePaymentLinkSchema,
40
- PaymentLinkSchema as ZodPaymentLinkSchema,
41
- UpdatePaymentLinkSchema as ZodUpdatePaymentLinkSchema
42
- } from '../schemas/zod/paymentLink.schema';
43
- import {
44
- CreatePlanSchema as ZodCreatePlanSchema,
45
- PlanSchema as ZodPlanSchema,
46
- UpdatePlanSchema as ZodUpdatePlanSchema
47
- } from '../schemas/zod/plan.schema';
48
- import {
49
- CreateSubscriptionSchema as ZodCreateSubscriptionSchema,
50
- SubscriptionSchema as ZodSubscriptionSchema,
51
- UpdateSubscriptionSchema as ZodUpdateSubscriptionSchema
52
- } from '../schemas/zod/subscription.schema';
53
- const zodUpdateBillingPortalSchema = ZodUpdateBillingPortalSchema({
54
- uuidId: false
55
- });
56
- const typeboxUpdateBillingPortalSchema = TypeboxUpdateBillingPortalSchema({
57
- uuidId: false
58
- });
59
- const zodBillingPortalSchema = ZodBillingPortalSchema({ uuidId: false });
60
- const typeboxBillingPortalSchema = TypeboxBillingPortalSchema({
61
- uuidId: false
62
- });
63
- const zodCreateCheckoutSessionSchema =
64
- ZodCreateCheckoutSessionSchema(DummyEnum);
65
- const typeboxCreateCheckoutSessionSchema =
66
- TypeboxCreateCheckoutSessionSchema(DummyEnum);
67
- const zodUpdateCheckoutSessionSchema = ZodUpdateCheckoutSessionSchema({
68
- uuidId: false
69
- })(DummyEnum);
70
- const typeboxUpdateCheckoutSessionSchema = TypeboxUpdateCheckoutSessionSchema({
71
- uuidId: false
72
- })(DummyEnum);
73
- const zodCheckoutSessionSchema = ZodCheckoutSessionSchema({ uuidId: true })(
74
- DummyEnum
75
- );
76
- const typeboxCheckoutSessionSchema = TypeboxCheckoutSessionSchema({
77
- uuidId: true
78
- })(DummyEnum);
79
- const zodCreatePaymentLinkSchema = ZodCreatePaymentLinkSchema(DummyEnum);
80
- const typeboxCreatePaymentLinkSchema =
81
- TypeboxCreatePaymentLinkSchema(DummyEnum);
82
- const zodUpdatePaymentLinkSchema = ZodUpdatePaymentLinkSchema({
83
- uuidId: false
84
- })(DummyEnum);
85
- const typeboxUpdatePaymentLinkSchema = TypeboxUpdatePaymentLinkSchema({
86
- uuidId: false
87
- })(DummyEnum);
88
- const zodPaymentLinkSchema = ZodPaymentLinkSchema({ uuidId: true })(DummyEnum);
89
- const typeboxPaymentLinkSchema = TypeboxPaymentLinkSchema({
90
- uuidId: false
91
- })(DummyEnum);
92
- const zodCreatePlanSchema = ZodCreatePlanSchema(DummyEnum, DummyEnum);
93
- const typeboxCreatePlanSchema = TypeboxCreatePlanSchema(DummyEnum, DummyEnum);
94
- const zodUpdatePlanSchema = ZodUpdatePlanSchema({ uuidId: false })(
95
- DummyEnum,
96
- DummyEnum
97
- );
98
- const typeboxUpdatePlanSchema = TypeboxUpdatePlanSchema({ uuidId: false })(
99
- DummyEnum,
100
- DummyEnum
101
- );
102
- const zodPlanSchema = ZodPlanSchema({ uuidId: true })(DummyEnum, DummyEnum);
103
- const typeboxPlanSchema = TypeboxPlanSchema({ uuidId: true })(
104
- DummyEnum,
105
- DummyEnum
106
- );
107
- const zodCreateSubscriptionSchema = ZodCreateSubscriptionSchema(
108
- DummyEnum,
109
- DummyEnum
110
- );
111
- const typeboxCreateSubscriptionSchema = TypeboxCreateSubscriptionSchema(
112
- DummyEnum,
113
- DummyEnum
114
- );
115
- const zodUpdateSubscriptionSchema = ZodUpdateSubscriptionSchema({
116
- uuidId: false
117
- })(DummyEnum, DummyEnum);
118
- const typeboxUpdateSubscriptionSchema = TypeboxUpdateSubscriptionSchema({
119
- uuidId: false
120
- })(DummyEnum, DummyEnum);
121
- const zodSubscriptionSchema = ZodSubscriptionSchema({ uuidId: true })(
122
- DummyEnum,
123
- DummyEnum
124
- );
125
- const typeboxSubscriptionSchema = TypeboxSubscriptionSchema({
126
- uuidId: true
127
- })(DummyEnum, DummyEnum);
128
- describe('schema equality', () => {
129
- it('should be equal for billing portal', () => {
130
- expect(
131
- isTrue(
132
- testSchemaEquality(
133
- ZodCreateBillingPortalSchema,
134
- TypeboxCreateBillingPortalSchema,
135
- {
136
- customerId: 'test',
137
- uri: 'https://example.com',
138
- expiresAt: new Date()
139
- }
140
- )
141
- )
142
- ).toBeTruthy();
143
- expect(
144
- isTrue(
145
- testSchemaEquality(
146
- zodUpdateBillingPortalSchema,
147
- typeboxUpdateBillingPortalSchema,
148
- {
149
- id: 'test',
150
- uri: 'https://example.com',
151
- expiresAt: new Date()
152
- }
153
- )
154
- )
155
- ).toBeTruthy();
156
- expect(
157
- isTrue(
158
- testSchemaEquality(zodBillingPortalSchema, typeboxBillingPortalSchema, {
159
- id: 'test',
160
- customerId: 'test',
161
- uri: 'https://example.com',
162
- expiresAt: new Date(),
163
- extraFields: {
164
- test: 'test'
165
- }
166
- })
167
- )
168
- ).toBeTruthy();
169
- });
170
- it('should be equal for checkout session', () => {
171
- expect(
172
- isTrue(
173
- testSchemaEquality(
174
- zodCreateCheckoutSessionSchema,
175
- typeboxCreateCheckoutSessionSchema,
176
- {
177
- customerId: 'test',
178
- paymentMethods: [DummyEnum.A, DummyEnum.B],
179
- successRedirectUri: 'https://example.com',
180
- cancelRedirectUri: 'https://example.com',
181
- extraFields: {
182
- test: 'test'
183
- }
184
- }
185
- )
186
- )
187
- ).toBeTruthy();
188
- expect(
189
- isTrue(
190
- testSchemaEquality(
191
- zodUpdateCheckoutSessionSchema,
192
- typeboxUpdateCheckoutSessionSchema,
193
- {
194
- id: 'test',
195
- customerId: 'test',
196
- paymentMethods: [DummyEnum.A, DummyEnum.B],
197
- successRedirectUri: 'https://example.com',
198
- cancelRedirectUri: 'https://example.com',
199
- extraFields: {
200
- test: 'test'
201
- }
202
- }
203
- )
204
- )
205
- ).toBeTruthy();
206
- expect(
207
- isTrue(
208
- testSchemaEquality(
209
- zodCheckoutSessionSchema,
210
- typeboxCheckoutSessionSchema,
211
- {
212
- id: 'test',
213
- customerId: 'test',
214
- paymentMethods: [DummyEnum.A, DummyEnum.B],
215
- successRedirectUri: 'https://example.com',
216
- cancelRedirectUri: 'https://example.com',
217
- extraFields: {
218
- test: 'test'
219
- }
220
- }
221
- )
222
- )
223
- ).toBeTruthy();
224
- });
225
- it('should be equal for payment link', () => {
226
- expect(
227
- isTrue(
228
- testSchemaEquality(
229
- zodCreatePaymentLinkSchema,
230
- typeboxCreatePaymentLinkSchema,
231
- {
232
- amount: 100,
233
- currency: DummyEnum.A,
234
- successRedirectUri: 'https://example.com',
235
- cancelRedirectUri: 'https://example.com',
236
- description: 'test',
237
- metadata: {
238
- test: 'test'
239
- },
240
- extraFields: {
241
- test: 'test'
242
- }
243
- }
244
- )
245
- )
246
- ).toBeTruthy();
247
- expect(
248
- isTrue(
249
- testSchemaEquality(
250
- zodUpdatePaymentLinkSchema,
251
- typeboxUpdatePaymentLinkSchema,
252
- {
253
- id: 'test',
254
- amount: 100,
255
- currency: DummyEnum.A,
256
- successRedirectUri: 'https://example.com',
257
- cancelRedirectUri: 'https://example.com',
258
- description: 'test',
259
- metadata: {
260
- test: 'test'
261
- },
262
- extraFields: {
263
- test: 'test'
264
- }
265
- }
266
- )
267
- )
268
- );
269
- expect(
270
- isTrue(
271
- testSchemaEquality(zodPaymentLinkSchema, typeboxPaymentLinkSchema, {
272
- id: 'test',
273
- amount: 100,
274
- currency: DummyEnum.A,
275
- successRedirectUri: 'https://example.com',
276
- cancelRedirectUri: 'https://example.com',
277
- description: 'test',
278
- metadata: {
279
- test: 'test'
280
- },
281
- extraFields: {
282
- test: 'test'
283
- }
284
- })
285
- )
286
- ).toBeTruthy();
287
- });
288
- it('should be equal for plan', () => {
289
- expect(
290
- isTrue(
291
- testSchemaEquality(zodCreatePlanSchema, typeboxCreatePlanSchema, {
292
- name: 'test',
293
- price: 100,
294
- cadence: DummyEnum.A,
295
- features: [DummyEnum.A, DummyEnum.B],
296
- externalId: 'test',
297
- active: true,
298
- description: 'test',
299
- extraFields: {
300
- test: 'test'
301
- }
302
- })
303
- )
304
- ).toBeTruthy();
305
- expect(
306
- isTrue(
307
- testSchemaEquality(zodUpdatePlanSchema, typeboxUpdatePlanSchema, {
308
- id: 'test',
309
- name: 'test',
310
- price: 100,
311
- cadence: DummyEnum.A,
312
- features: [DummyEnum.A, DummyEnum.B],
313
- externalId: 'test',
314
- active: true,
315
- description: 'test',
316
- extraFields: {
317
- test: 'test'
318
- }
319
- })
320
- )
321
- ).toBeTruthy();
322
- expect(
323
- isTrue(
324
- testSchemaEquality(zodPlanSchema, typeboxPlanSchema, {
325
- id: 'test',
326
- name: 'test',
327
- price: 100,
328
- cadence: DummyEnum.A,
329
- features: [DummyEnum.A, DummyEnum.B],
330
- externalId: 'test',
331
- active: true,
332
- description: 'test',
333
- extraFields: {
334
- test: 'test'
335
- }
336
- })
337
- )
338
- ).toBeTruthy();
339
- });
340
- it('should be equal for subscription', () => {
341
- expect(
342
- isTrue(
343
- testSchemaEquality(
344
- zodCreateSubscriptionSchema,
345
- typeboxCreateSubscriptionSchema,
346
- {
347
- partyId: 'test',
348
- partyType: DummyEnum.A,
349
- productId: 'test',
350
- status: DummyEnum.A,
351
- active: true,
352
- externalId: 'test',
353
- startDate: new Date(),
354
- endDate: new Date(),
355
- description: 'test',
356
- extraFields: {
357
- test: 'test'
358
- },
359
- billingProvider: DummyEnum.A
360
- }
361
- )
362
- )
363
- ).toBeTruthy();
364
- expect(
365
- isTrue(
366
- testSchemaEquality(
367
- zodUpdateSubscriptionSchema,
368
- typeboxUpdateSubscriptionSchema,
369
- {
370
- id: 'test',
371
- partyId: 'test',
372
- partyType: DummyEnum.A,
373
- productId: 'test',
374
- status: DummyEnum.A,
375
- active: true,
376
- externalId: 'test',
377
- startDate: new Date(),
378
- endDate: new Date(),
379
- description: 'test',
380
- extraFields: {
381
- test: 'test'
382
- },
383
- billingProvider: DummyEnum.A
384
- }
385
- )
386
- )
387
- ).toBeTruthy();
388
- expect(
389
- isTrue(
390
- testSchemaEquality(zodSubscriptionSchema, typeboxSubscriptionSchema, {
391
- id: 'test',
392
- partyId: 'test',
393
- partyType: DummyEnum.A,
394
- productId: 'test',
395
- status: DummyEnum.A,
396
- active: true,
397
- externalId: 'test',
398
- startDate: new Date(),
399
- endDate: new Date(),
400
- description: 'test',
401
- extraFields: {
402
- test: 'test'
403
- },
404
- billingProvider: DummyEnum.A
405
- })
406
- )
407
- ).toBeTruthy();
408
- });
409
- });
@@ -1,31 +0,0 @@
1
- import { date, optional, string, unknown, uuid } from '@{{app_name}}/core';
2
-
3
- export const CreateBillingPortalSchema = {
4
- customerId: string,
5
- uri: string,
6
- expiresAt: date
7
- };
8
-
9
- export const UpdateBillingPortalSchema = ({ uuidId }: { uuidId: boolean }) => ({
10
- id: uuidId ? uuid : string,
11
- uri: optional(string),
12
- expiresAt: optional(date)
13
- });
14
-
15
- export const BillingPortalSchema = ({ uuidId }: { uuidId: boolean }) => ({
16
- id: uuidId ? uuid : string,
17
- customerId: string,
18
- uri: string,
19
- expiresAt: date,
20
- extraFields: optional(unknown),
21
- createdAt: optional(date),
22
- updatedAt: optional(date)
23
- });
24
-
25
- export const BaseBillingPortalServiceSchemas = (options: {
26
- uuidId: boolean;
27
- }) => ({
28
- CreateBillingPortalSchema,
29
- UpdateBillingPortalSchema: UpdateBillingPortalSchema(options),
30
- BillingPortalSchema: BillingPortalSchema(options)
31
- });
@@ -1,55 +0,0 @@
1
- import { LiteralSchema } from '@forklaunch/validator';
2
- import {
3
- array,
4
- date,
5
- enum_,
6
- optional,
7
- string,
8
- unknown,
9
- uuid
10
- } from '@{{app_name}}/core';
11
-
12
- export const CreateCheckoutSessionSchema = <
13
- T extends Record<string, LiteralSchema>
14
- >(
15
- PaymentMethodEnum: T
16
- ) => ({
17
- customerId: string,
18
- paymentMethods: array(enum_(PaymentMethodEnum)),
19
- successRedirectUri: string,
20
- cancelRedirectUri: string,
21
- extraFields: optional(unknown)
22
- });
23
-
24
- export const UpdateCheckoutSessionSchema =
25
- ({ uuidId }: { uuidId: boolean }) =>
26
- <T extends Record<string, LiteralSchema>>(PaymentMethodEnum: T) => ({
27
- id: uuidId ? uuid : string,
28
- customerId: optional(string),
29
- paymentMethods: optional(array(enum_(PaymentMethodEnum))),
30
- successRedirectUri: optional(string),
31
- cancelRedirectUri: optional(string),
32
- extraFields: optional(unknown)
33
- });
34
-
35
- export const CheckoutSessionSchema =
36
- ({ uuidId }: { uuidId: boolean }) =>
37
- <T extends Record<string, LiteralSchema>>(PaymentMethodEnum: T) => ({
38
- id: uuidId ? uuid : string,
39
- customerId: string,
40
- metadata: optional(unknown),
41
- paymentMethods: array(enum_(PaymentMethodEnum)),
42
- successRedirectUri: string,
43
- cancelRedirectUri: string,
44
- extraFields: optional(unknown),
45
- createdAt: optional(date),
46
- updatedAt: optional(date)
47
- });
48
-
49
- export const BaseCheckoutSessionServiceSchemas = (options: {
50
- uuidId: boolean;
51
- }) => ({
52
- CreateCheckoutSessionSchema,
53
- UpdateCheckoutSessionSchema: UpdateCheckoutSessionSchema(options),
54
- CheckoutSessionSchema: CheckoutSessionSchema(options)
55
- });
@@ -1,5 +0,0 @@
1
- export * from './billingPortal.schema';
2
- export * from './checkoutSession.schema';
3
- export * from './paymentLink.schema';
4
- export * from './plan.schema';
5
- export * from './subscription.schema';
@@ -1,60 +0,0 @@
1
- import { LiteralSchema } from '@forklaunch/validator';
2
- import {
3
- date,
4
- enum_,
5
- number,
6
- optional,
7
- string,
8
- unknown,
9
- uuid
10
- } from '@{{app_name}}/core';
11
-
12
- export const CreatePaymentLinkSchema = <
13
- T extends Record<string, LiteralSchema>
14
- >(
15
- CurrencyEnum: T
16
- ) => ({
17
- amount: number,
18
- currency: enum_(CurrencyEnum),
19
- description: optional(string),
20
- metadata: optional(unknown),
21
- successRedirectUri: string,
22
- cancelRedirectUri: string,
23
- extraFields: optional(unknown)
24
- });
25
-
26
- export const UpdatePaymentLinkSchema =
27
- ({ uuidId }: { uuidId: boolean }) =>
28
- <T extends Record<string, LiteralSchema>>(CurrencyEnum: T) => ({
29
- id: uuidId ? uuid : string,
30
- amount: optional(number),
31
- currency: optional(enum_(CurrencyEnum)),
32
- description: optional(string),
33
- metadata: optional(unknown),
34
- successRedirectUri: optional(string),
35
- cancelRedirectUri: optional(string),
36
- extraFields: optional(unknown)
37
- });
38
-
39
- export const PaymentLinkSchema =
40
- ({ uuidId }: { uuidId: boolean }) =>
41
- <T extends Record<string, LiteralSchema>>(CurrencyEnum: T) => ({
42
- id: uuidId ? uuid : string,
43
- amount: number,
44
- currency: enum_(CurrencyEnum),
45
- description: optional(string),
46
- metadata: optional(unknown),
47
- successRedirectUri: string,
48
- cancelRedirectUri: string,
49
- extraFields: optional(unknown),
50
- createdAt: optional(date),
51
- updatedAt: optional(date)
52
- });
53
-
54
- export const BasePaymentLinkServiceSchemas = (options: {
55
- uuidId: boolean;
56
- }) => ({
57
- CreatePaymentLinkSchema,
58
- UpdatePaymentLinkSchema: UpdatePaymentLinkSchema(options),
59
- PaymentLinkSchema: PaymentLinkSchema(options)
60
- });
@@ -1,80 +0,0 @@
1
- import { LiteralSchema } from '@forklaunch/validator';
2
- import {
3
- array,
4
- boolean,
5
- date,
6
- enum_,
7
- number,
8
- optional,
9
- string,
10
- unknown,
11
- uuid
12
- } from '@{{app_name}}/core';
13
-
14
- export const CreatePlanSchema = <
15
- T extends Record<string, LiteralSchema>,
16
- U extends Record<string, LiteralSchema>
17
- >(
18
- PlanCadenceEnum: T,
19
- BillingProviderEnum: U
20
- ) => ({
21
- name: string,
22
- description: optional(string),
23
- price: number,
24
- cadence: enum_(PlanCadenceEnum),
25
- features: array(string),
26
- extraFields: optional(unknown),
27
- externalId: string,
28
- billingProvider: optional(enum_(BillingProviderEnum)),
29
- active: boolean
30
- });
31
-
32
- export const UpdatePlanSchema =
33
- ({ uuidId }: { uuidId: boolean }) =>
34
- <
35
- T extends Record<string, LiteralSchema>,
36
- U extends Record<string, LiteralSchema>
37
- >(
38
- PlanCadenceEnum: T,
39
- BillingProviderEnum: U
40
- ) => ({
41
- id: uuidId ? uuid : string,
42
- name: optional(string),
43
- description: optional(string),
44
- price: optional(number),
45
- cadence: optional(enum_(PlanCadenceEnum)),
46
- features: optional(array(string)),
47
- extraFields: optional(unknown),
48
- externalId: optional(string),
49
- billingProvider: optional(enum_(BillingProviderEnum)),
50
- active: optional(boolean)
51
- });
52
-
53
- export const PlanSchema =
54
- ({ uuidId }: { uuidId: boolean }) =>
55
- <
56
- T extends Record<string, LiteralSchema>,
57
- U extends Record<string, LiteralSchema>
58
- >(
59
- PlanCadenceEnum: T,
60
- BillingProviderEnum: U
61
- ) => ({
62
- id: uuidId ? uuid : string,
63
- name: string,
64
- description: optional(string),
65
- price: number,
66
- cadence: enum_(PlanCadenceEnum),
67
- features: optional(array(string)),
68
- extraFields: optional(unknown),
69
- externalId: string,
70
- billingProvider: optional(enum_(BillingProviderEnum)),
71
- active: boolean,
72
- createdAt: optional(date),
73
- updatedAt: optional(date)
74
- });
75
-
76
- export const BasePlanServiceSchemas = (options: { uuidId: boolean }) => ({
77
- CreatePlanSchema,
78
- UpdatePlanSchema: UpdatePlanSchema(options),
79
- PlanSchema: PlanSchema(options)
80
- });