@forklaunch/implementation-billing-base 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 forklaunch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,411 @@
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
+
54
+ const zodUpdateBillingPortalSchema = ZodUpdateBillingPortalSchema(false);
55
+ const typeboxUpdateBillingPortalSchema =
56
+ TypeboxUpdateBillingPortalSchema(false);
57
+ const zodBillingPortalSchema = ZodBillingPortalSchema(false);
58
+ const typeboxBillingPortalSchema = TypeboxBillingPortalSchema(false);
59
+
60
+ const zodCreateCheckoutSessionSchema =
61
+ ZodCreateCheckoutSessionSchema(DummyEnum);
62
+ const typeboxCreateCheckoutSessionSchema =
63
+ TypeboxCreateCheckoutSessionSchema(DummyEnum);
64
+ const zodUpdateCheckoutSessionSchema =
65
+ ZodUpdateCheckoutSessionSchema(false)(DummyEnum);
66
+ const typeboxUpdateCheckoutSessionSchema =
67
+ TypeboxUpdateCheckoutSessionSchema(false)(DummyEnum);
68
+ const zodCheckoutSessionSchema = ZodCheckoutSessionSchema(false)(DummyEnum);
69
+ const typeboxCheckoutSessionSchema =
70
+ TypeboxCheckoutSessionSchema(false)(DummyEnum);
71
+
72
+ const zodCreatePaymentLinkSchema = ZodCreatePaymentLinkSchema(DummyEnum);
73
+ const typeboxCreatePaymentLinkSchema =
74
+ TypeboxCreatePaymentLinkSchema(DummyEnum);
75
+ const zodUpdatePaymentLinkSchema = ZodUpdatePaymentLinkSchema(false)(DummyEnum);
76
+ const typeboxUpdatePaymentLinkSchema =
77
+ TypeboxUpdatePaymentLinkSchema(false)(DummyEnum);
78
+ const zodPaymentLinkSchema = ZodPaymentLinkSchema(false)(DummyEnum);
79
+ const typeboxPaymentLinkSchema = TypeboxPaymentLinkSchema(false)(DummyEnum);
80
+
81
+ const zodCreatePlanSchema = ZodCreatePlanSchema(DummyEnum, DummyEnum);
82
+ const typeboxCreatePlanSchema = TypeboxCreatePlanSchema(DummyEnum, DummyEnum);
83
+ const zodUpdatePlanSchema = ZodUpdatePlanSchema(false)(DummyEnum, DummyEnum);
84
+ const typeboxUpdatePlanSchema = TypeboxUpdatePlanSchema(false)(
85
+ DummyEnum,
86
+ DummyEnum
87
+ );
88
+ const zodPlanSchema = ZodPlanSchema(false)(DummyEnum, DummyEnum);
89
+ const typeboxPlanSchema = TypeboxPlanSchema(false)(DummyEnum, DummyEnum);
90
+
91
+ const zodCreateSubscriptionSchema = ZodCreateSubscriptionSchema(
92
+ DummyEnum,
93
+ DummyEnum
94
+ );
95
+ const typeboxCreateSubscriptionSchema = TypeboxCreateSubscriptionSchema(
96
+ DummyEnum,
97
+ DummyEnum
98
+ );
99
+ const zodUpdateSubscriptionSchema = ZodUpdateSubscriptionSchema(false)(
100
+ DummyEnum,
101
+ DummyEnum
102
+ );
103
+ const typeboxUpdateSubscriptionSchema = TypeboxUpdateSubscriptionSchema(false)(
104
+ DummyEnum,
105
+ DummyEnum
106
+ );
107
+ const zodSubscriptionSchema = ZodSubscriptionSchema(false)(
108
+ DummyEnum,
109
+ DummyEnum
110
+ );
111
+ const typeboxSubscriptionSchema = TypeboxSubscriptionSchema(false)(
112
+ DummyEnum,
113
+ DummyEnum
114
+ );
115
+
116
+ describe('schema equality', () => {
117
+ it('should be equal for billing portal', () => {
118
+ expect(
119
+ isTrue(
120
+ testSchemaEquality(
121
+ ZodCreateBillingPortalSchema,
122
+ TypeboxCreateBillingPortalSchema,
123
+ {
124
+ customerId: 'test',
125
+ uri: 'https://example.com',
126
+ expiresAt: new Date()
127
+ }
128
+ )
129
+ )
130
+ ).toBeTruthy();
131
+
132
+ expect(
133
+ isTrue(
134
+ testSchemaEquality(
135
+ zodUpdateBillingPortalSchema,
136
+ typeboxUpdateBillingPortalSchema,
137
+ {
138
+ id: 'test',
139
+ uri: 'https://example.com',
140
+ expiresAt: new Date()
141
+ }
142
+ )
143
+ )
144
+ ).toBeTruthy();
145
+
146
+ expect(
147
+ isTrue(
148
+ testSchemaEquality(zodBillingPortalSchema, typeboxBillingPortalSchema, {
149
+ id: 'test',
150
+ customerId: 'test',
151
+ uri: 'https://example.com',
152
+ expiresAt: new Date(),
153
+ extraFields: {
154
+ test: 'test'
155
+ }
156
+ })
157
+ )
158
+ ).toBeTruthy();
159
+ });
160
+
161
+ it('should be equal for checkout session', () => {
162
+ expect(
163
+ isTrue(
164
+ testSchemaEquality(
165
+ zodCreateCheckoutSessionSchema,
166
+ typeboxCreateCheckoutSessionSchema,
167
+ {
168
+ customerId: 'test',
169
+ paymentMethods: [DummyEnum.A, DummyEnum.B],
170
+ successRedirectUri: 'https://example.com',
171
+ cancelRedirectUri: 'https://example.com',
172
+ extraFields: {
173
+ test: 'test'
174
+ }
175
+ }
176
+ )
177
+ )
178
+ ).toBeTruthy();
179
+
180
+ expect(
181
+ isTrue(
182
+ testSchemaEquality(
183
+ zodUpdateCheckoutSessionSchema,
184
+ typeboxUpdateCheckoutSessionSchema,
185
+ {
186
+ id: 'test',
187
+ customerId: 'test',
188
+ paymentMethods: [DummyEnum.A, DummyEnum.B],
189
+ successRedirectUri: 'https://example.com',
190
+ cancelRedirectUri: 'https://example.com',
191
+ extraFields: {
192
+ test: 'test'
193
+ }
194
+ }
195
+ )
196
+ )
197
+ ).toBeTruthy();
198
+
199
+ expect(
200
+ isTrue(
201
+ testSchemaEquality(
202
+ zodCheckoutSessionSchema,
203
+ typeboxCheckoutSessionSchema,
204
+ {
205
+ id: 'test',
206
+ customerId: 'test',
207
+ paymentMethods: [DummyEnum.A, DummyEnum.B],
208
+ successRedirectUri: 'https://example.com',
209
+ cancelRedirectUri: 'https://example.com',
210
+ extraFields: {
211
+ test: 'test'
212
+ }
213
+ }
214
+ )
215
+ )
216
+ ).toBeTruthy();
217
+ });
218
+
219
+ it('should be equal for payment link', () => {
220
+ expect(
221
+ isTrue(
222
+ testSchemaEquality(
223
+ zodCreatePaymentLinkSchema,
224
+ typeboxCreatePaymentLinkSchema,
225
+ {
226
+ amount: 100,
227
+ currency: DummyEnum.A,
228
+ successRedirectUri: 'https://example.com',
229
+ cancelRedirectUri: 'https://example.com',
230
+ description: 'test',
231
+ metadata: {
232
+ test: 'test'
233
+ },
234
+ extraFields: {
235
+ test: 'test'
236
+ }
237
+ }
238
+ )
239
+ )
240
+ ).toBeTruthy();
241
+
242
+ expect(
243
+ isTrue(
244
+ testSchemaEquality(
245
+ zodUpdatePaymentLinkSchema,
246
+ typeboxUpdatePaymentLinkSchema,
247
+ {
248
+ id: 'test',
249
+ amount: 100,
250
+ currency: DummyEnum.A,
251
+ successRedirectUri: 'https://example.com',
252
+ cancelRedirectUri: 'https://example.com',
253
+ description: 'test',
254
+ metadata: {
255
+ test: 'test'
256
+ },
257
+ extraFields: {
258
+ test: 'test'
259
+ }
260
+ }
261
+ )
262
+ )
263
+ );
264
+
265
+ expect(
266
+ isTrue(
267
+ testSchemaEquality(zodPaymentLinkSchema, typeboxPaymentLinkSchema, {
268
+ id: 'test',
269
+ amount: 100,
270
+ currency: DummyEnum.A,
271
+ successRedirectUri: 'https://example.com',
272
+ cancelRedirectUri: 'https://example.com',
273
+ description: 'test',
274
+ metadata: {
275
+ test: 'test'
276
+ },
277
+ extraFields: {
278
+ test: 'test'
279
+ }
280
+ })
281
+ )
282
+ ).toBeTruthy();
283
+ });
284
+
285
+ it('should be equal for plan', () => {
286
+ expect(
287
+ isTrue(
288
+ testSchemaEquality(zodCreatePlanSchema, typeboxCreatePlanSchema, {
289
+ name: 'test',
290
+ price: 100,
291
+ cadence: DummyEnum.A,
292
+ features: [DummyEnum.A, DummyEnum.B],
293
+ externalId: 'test',
294
+ active: true,
295
+ description: 'test',
296
+ extraFields: {
297
+ test: 'test'
298
+ }
299
+ })
300
+ )
301
+ ).toBeTruthy();
302
+
303
+ expect(
304
+ isTrue(
305
+ testSchemaEquality(zodUpdatePlanSchema, typeboxUpdatePlanSchema, {
306
+ id: 'test',
307
+ name: 'test',
308
+ price: 100,
309
+ cadence: DummyEnum.A,
310
+ features: [DummyEnum.A, DummyEnum.B],
311
+ externalId: 'test',
312
+ active: true,
313
+ description: 'test',
314
+ extraFields: {
315
+ test: 'test'
316
+ }
317
+ })
318
+ )
319
+ ).toBeTruthy();
320
+
321
+ expect(
322
+ isTrue(
323
+ testSchemaEquality(zodPlanSchema, typeboxPlanSchema, {
324
+ id: 'test',
325
+ name: 'test',
326
+ price: 100,
327
+ cadence: DummyEnum.A,
328
+ features: [DummyEnum.A, DummyEnum.B],
329
+ externalId: 'test',
330
+ active: true,
331
+ description: 'test',
332
+ extraFields: {
333
+ test: 'test'
334
+ }
335
+ })
336
+ )
337
+ ).toBeTruthy();
338
+ });
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
+
365
+ expect(
366
+ isTrue(
367
+ testSchemaEquality(
368
+ zodUpdateSubscriptionSchema,
369
+ typeboxUpdateSubscriptionSchema,
370
+ {
371
+ id: 'test',
372
+ partyId: 'test',
373
+ partyType: DummyEnum.A,
374
+ productId: 'test',
375
+ status: DummyEnum.A,
376
+ active: true,
377
+ externalId: 'test',
378
+ startDate: new Date(),
379
+ endDate: new Date(),
380
+ description: 'test',
381
+ extraFields: {
382
+ test: 'test'
383
+ },
384
+ billingProvider: DummyEnum.A
385
+ }
386
+ )
387
+ )
388
+ ).toBeTruthy();
389
+
390
+ expect(
391
+ isTrue(
392
+ testSchemaEquality(zodSubscriptionSchema, typeboxSubscriptionSchema, {
393
+ id: 'test',
394
+ partyId: 'test',
395
+ partyType: DummyEnum.A,
396
+ productId: 'test',
397
+ status: DummyEnum.A,
398
+ active: true,
399
+ externalId: 'test',
400
+ startDate: new Date(),
401
+ endDate: new Date(),
402
+ description: 'test',
403
+ extraFields: {
404
+ test: 'test'
405
+ },
406
+ billingProvider: DummyEnum.A
407
+ })
408
+ )
409
+ ).toBeTruthy();
410
+ });
411
+ });
package/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from './schemas/billingPortal.schema';
2
+ export * from './schemas/checkoutSession.schema';
3
+ export * from './schemas/paymentLink.schema';
4
+ export * from './schemas/plan.schema';
5
+ export * from './schemas/subscription.schema';
6
+ export * from './services/billingPortal.service';
7
+ export * from './services/checkoutSession.service';
8
+ export * from './services/paymentLink.service';
9
+ export * from './services/plan.service';
10
+ export * from './services/subscription.service';
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@forklaunch/implementation-billing-base",
3
+ "version": "0.1.0",
4
+ "description": "Billing basic implementation for forklaunch",
5
+ "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/forklaunch/forklaunch-js/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/forklaunch/forklaunch-js.git"
12
+ },
13
+ "license": "MIT",
14
+ "author": "Forklift Technologies, Inc.",
15
+ "main": "server.ts",
16
+ "dependencies": {
17
+ "@forklaunch/common": "^0.2.5",
18
+ "@forklaunch/core": "^0.6.0",
19
+ "@forklaunch/validator": "^0.4.8",
20
+ "@mikro-orm/core": "^6.4.11",
21
+ "@sinclair/typebox": "^0.34.33",
22
+ "ajv": "^8.17.1",
23
+ "zod": "^3.24.2",
24
+ "@forklaunch/interfaces-billing": "0.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "depcheck": "^1.4.7",
28
+ "prettier": "^3.5.3",
29
+ "typedoc": "^0.28.1"
30
+ },
31
+ "mikro-orm": {
32
+ "configPaths": [
33
+ "./mikro-orm.config.ts",
34
+ "./dist/mikro-orm.config.js"
35
+ ]
36
+ },
37
+ "scripts": {
38
+ "build": "tsc",
39
+ "clean": "rm -rf dist pnpm.lock.yaml node_modules",
40
+ "docs": "typedoc --out docs *",
41
+ "format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
42
+ "lint": "eslint . -c eslint.config.mjs",
43
+ "lint:fix": "eslint . -c eslint.config.mjs --fix",
44
+ "start": "ENV_FILE_PATH=.env.local NODE_OPTIONS='--import=tsx' node dist/server.js",
45
+ "start:bun": "bun run migrate:up && bun dist/server.js",
46
+ "test": "vitest --passWithNoTests"
47
+ }
48
+ }
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ BillingPortalSchema as TypeBoxBillingPortalSchema,
4
+ CreateBillingPortalSchema as TypeBoxCreateBillingPortalSchema,
5
+ UpdateBillingPortalSchema as TypeBoxUpdateBillingPortalSchema
6
+ } from './typebox/billingPortal.schema';
7
+ import {
8
+ BillingPortalSchema as ZodBillingPortalSchema,
9
+ CreateBillingPortalSchema as ZodCreateBillingPortalSchema,
10
+ UpdateBillingPortalSchema as ZodUpdateBillingPortalSchema
11
+ } from './zod/billingPortal.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreateBillingPortalSchema: TypeBoxCreateBillingPortalSchema,
15
+ UpdateBillingPortalSchema: TypeBoxUpdateBillingPortalSchema(uuidId),
16
+ BillingPortalSchema: TypeBoxBillingPortalSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreateBillingPortalSchema: ZodCreateBillingPortalSchema,
21
+ UpdateBillingPortalSchema: ZodUpdateBillingPortalSchema(uuidId),
22
+ BillingPortalSchema: ZodBillingPortalSchema(uuidId)
23
+ });
24
+
25
+ export const BaseBillingPortalServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ CheckoutSessionSchema as TypeBoxCheckoutSessionSchema,
4
+ CreateCheckoutSessionSchema as TypeBoxCreateCheckoutSessionSchema,
5
+ UpdateCheckoutSessionSchema as TypeBoxUpdateCheckoutSessionSchema
6
+ } from './typebox/checkoutSession.schema';
7
+ import {
8
+ CheckoutSessionSchema as ZodCheckoutSessionSchema,
9
+ CreateCheckoutSessionSchema as ZodCreateCheckoutSessionSchema,
10
+ UpdateCheckoutSessionSchema as ZodUpdateCheckoutSessionSchema
11
+ } from './zod/checkoutSession.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreateCheckoutSessionSchema: TypeBoxCreateCheckoutSessionSchema,
15
+ UpdateCheckoutSessionSchema: TypeBoxUpdateCheckoutSessionSchema(uuidId),
16
+ CheckoutSessionSchema: TypeBoxCheckoutSessionSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreateCheckoutSessionSchema: ZodCreateCheckoutSessionSchema,
21
+ UpdateCheckoutSessionSchema: ZodUpdateCheckoutSessionSchema(uuidId),
22
+ CheckoutSessionSchema: ZodCheckoutSessionSchema(uuidId)
23
+ });
24
+
25
+ export const BaseCheckoutSessionServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ CreatePaymentLinkSchema as TypeBoxCreatePaymentLinkSchema,
4
+ PaymentLinkSchema as TypeBoxPaymentLinkSchema,
5
+ UpdatePaymentLinkSchema as TypeBoxUpdatePaymentLinkSchema
6
+ } from './typebox/paymentLink.schema';
7
+ import {
8
+ CreatePaymentLinkSchema as ZodCreatePaymentLinkSchema,
9
+ PaymentLinkSchema as ZodPaymentLinkSchema,
10
+ UpdatePaymentLinkSchema as ZodUpdatePaymentLinkSchema
11
+ } from './zod/paymentLink.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreatePaymentLinkSchema: TypeBoxCreatePaymentLinkSchema,
15
+ UpdatePaymentLinkSchema: TypeBoxUpdatePaymentLinkSchema(uuidId),
16
+ PaymentLinkSchema: TypeBoxPaymentLinkSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreatePaymentLinkSchema: ZodCreatePaymentLinkSchema,
21
+ UpdatePaymentLinkSchema: ZodUpdatePaymentLinkSchema(uuidId),
22
+ PaymentLinkSchema: ZodPaymentLinkSchema(uuidId)
23
+ });
24
+
25
+ export const BasePaymentLinkServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ CreatePlanSchema as TypeBoxCreatePlanSchema,
4
+ PlanSchema as TypeBoxPlanSchema,
5
+ UpdatePlanSchema as TypeBoxUpdatePlanSchema
6
+ } from './typebox/plan.schema';
7
+ import {
8
+ CreatePlanSchema as ZodCreatePlanSchema,
9
+ PlanSchema as ZodPlanSchema,
10
+ UpdatePlanSchema as ZodUpdatePlanSchema
11
+ } from './zod/plan.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreatePlanSchema: TypeBoxCreatePlanSchema,
15
+ UpdatePlanSchema: TypeBoxUpdatePlanSchema(uuidId),
16
+ PlanSchema: TypeBoxPlanSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreatePlanSchema: ZodCreatePlanSchema,
21
+ UpdatePlanSchema: ZodUpdatePlanSchema(uuidId),
22
+ PlanSchema: ZodPlanSchema(uuidId)
23
+ });
24
+
25
+ export const BasePlanServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ CreateSubscriptionSchema as TypeBoxCreateSubscriptionSchema,
4
+ SubscriptionSchema as TypeBoxSubscriptionSchema,
5
+ UpdateSubscriptionSchema as TypeBoxUpdateSubscriptionSchema
6
+ } from './typebox/subscription.schema';
7
+ import {
8
+ CreateSubscriptionSchema as ZodCreateSubscriptionSchema,
9
+ SubscriptionSchema as ZodSubscriptionSchema,
10
+ UpdateSubscriptionSchema as ZodUpdateSubscriptionSchema
11
+ } from './zod/subscription.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreateSubscriptionSchema: TypeBoxCreateSubscriptionSchema,
15
+ UpdateSubscriptionSchema: TypeBoxUpdateSubscriptionSchema(uuidId),
16
+ SubscriptionSchema: TypeBoxSubscriptionSchema
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreateSubscriptionSchema: ZodCreateSubscriptionSchema,
21
+ UpdateSubscriptionSchema: ZodUpdateSubscriptionSchema(uuidId),
22
+ SubscriptionSchema: ZodSubscriptionSchema(uuidId)
23
+ });
24
+
25
+ export const BaseSubscriptionServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,29 @@
1
+ import {
2
+ date,
3
+ optional,
4
+ string,
5
+ unknown,
6
+ uuid
7
+ } from '@forklaunch/validator/typebox';
8
+
9
+ export const CreateBillingPortalSchema = {
10
+ customerId: string,
11
+ uri: string,
12
+ expiresAt: date
13
+ };
14
+
15
+ export const UpdateBillingPortalSchema = (uuidId: boolean) => ({
16
+ id: uuidId ? uuid : string,
17
+ uri: optional(string),
18
+ expiresAt: optional(date)
19
+ });
20
+
21
+ export const BillingPortalSchema = (uuidId: boolean) => ({
22
+ id: uuidId ? uuid : string,
23
+ customerId: string,
24
+ uri: string,
25
+ expiresAt: date,
26
+ extraFields: optional(unknown),
27
+ createdAt: optional(date),
28
+ updatedAt: optional(date)
29
+ });