@forklaunch/implementation-iam-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,293 @@
1
+ import { isTrue } from '@forklaunch/common';
2
+ import { DummyEnum, testSchemaEquality } from '@forklaunch/core/test';
3
+ import {
4
+ CreateOrganizationSchema as TypeboxCreateOrganizationSchema,
5
+ OrganizationSchema as TypeboxOrganizationSchema,
6
+ UpdateOrganizationSchema as TypeboxUpdateOrganizationSchema
7
+ } from '../schemas/typebox/organization.schema';
8
+ import {
9
+ CreatePermissionSchema as TypeboxCreatePermissionSchema,
10
+ PermissionSchema as TypeboxPermissionSchema,
11
+ UpdatePermissionSchema as TypeboxUpdatePermissionSchema
12
+ } from '../schemas/typebox/permission.schema';
13
+ import {
14
+ CreateRoleSchema as TypeboxCreateRoleSchema,
15
+ RoleSchema as TypeboxRoleSchema,
16
+ UpdateRoleSchema as TypeboxUpdateRoleSchema
17
+ } from '../schemas/typebox/role.schema';
18
+ import {
19
+ CreateUserSchema as TypeboxCreateUserSchema,
20
+ UpdateUserSchema as TypeboxUpdateUserSchema,
21
+ UserSchema as TypeboxUserSchema
22
+ } from '../schemas/typebox/user.schema';
23
+ import {
24
+ CreateOrganizationSchema as ZodCreateOrganizationSchema,
25
+ OrganizationSchema as ZodOrganizationSchema,
26
+ UpdateOrganizationSchema as ZodUpdateOrganizationSchema
27
+ } from '../schemas/zod/organization.schema';
28
+ import {
29
+ CreatePermissionSchema as ZodCreatePermissionSchema,
30
+ PermissionSchema as ZodPermissionSchema,
31
+ UpdatePermissionSchema as ZodUpdatePermissionSchema
32
+ } from '../schemas/zod/permission.schema';
33
+ import {
34
+ CreateRoleSchema as ZodCreateRoleSchema,
35
+ RoleSchema as ZodRoleSchema,
36
+ UpdateRoleSchema as ZodUpdateRoleSchema
37
+ } from '../schemas/zod/role.schema';
38
+ import {
39
+ CreateUserSchema as ZodCreateUserSchema,
40
+ UpdateUserSchema as ZodUpdateUserSchema,
41
+ UserSchema as ZodUserSchema
42
+ } from '../schemas/zod/user.schema';
43
+
44
+ const zodUpdatePermissionSchema = ZodUpdatePermissionSchema(false);
45
+ const typeboxUpdatePermissionSchema = TypeboxUpdatePermissionSchema(false);
46
+ const zodPermissionSchema = ZodPermissionSchema(false);
47
+ const typeboxPermissionSchema = TypeboxPermissionSchema(false);
48
+
49
+ const zodUpdateRoleSchema = ZodUpdateRoleSchema(false);
50
+ const typeboxUpdateRoleSchema = TypeboxUpdateRoleSchema(false);
51
+ const zodRoleSchema = ZodRoleSchema(false)(zodPermissionSchema);
52
+ const typeboxRoleSchema = TypeboxRoleSchema(false)(typeboxPermissionSchema);
53
+
54
+ const zodUpdateUserSchema = ZodUpdateUserSchema(false);
55
+ const typeboxUpdateUserSchema = TypeboxUpdateUserSchema(false);
56
+ const zodUserSchema = ZodUserSchema(false)(zodRoleSchema);
57
+ const typeboxUserSchema = TypeboxUserSchema(false)(typeboxRoleSchema);
58
+
59
+ const zodUpdateOrganizationSchema = ZodUpdateOrganizationSchema(false);
60
+ const typeboxUpdateOrganizationSchema = TypeboxUpdateOrganizationSchema(false);
61
+ const zodOrganizationSchema = ZodOrganizationSchema(false)(
62
+ zodUserSchema,
63
+ DummyEnum
64
+ );
65
+ const typeboxOrganizationSchema = TypeboxOrganizationSchema(false)(
66
+ typeboxUserSchema,
67
+ DummyEnum
68
+ );
69
+
70
+ describe('schema equality', () => {
71
+ it('should be equal for permission', () => {
72
+ expect(
73
+ isTrue(
74
+ testSchemaEquality(
75
+ ZodCreatePermissionSchema,
76
+ TypeboxCreatePermissionSchema,
77
+ {
78
+ slug: 'test',
79
+ addToRolesIds: ['test'],
80
+ extraFields: {
81
+ test: 'test'
82
+ }
83
+ }
84
+ )
85
+ )
86
+ ).toBeTruthy();
87
+
88
+ expect(
89
+ isTrue(
90
+ testSchemaEquality(
91
+ zodUpdatePermissionSchema,
92
+ typeboxUpdatePermissionSchema,
93
+ {
94
+ id: 'test',
95
+ slug: 'test',
96
+ addToRolesIds: ['test'],
97
+ removeFromRolesIds: ['test'],
98
+ extraFields: {
99
+ test: 'test'
100
+ }
101
+ }
102
+ )
103
+ )
104
+ ).toBeTruthy();
105
+
106
+ expect(
107
+ isTrue(
108
+ testSchemaEquality(zodPermissionSchema, typeboxPermissionSchema, {
109
+ id: 'test',
110
+ slug: 'test',
111
+ extraFields: {
112
+ test: 'test'
113
+ }
114
+ })
115
+ )
116
+ ).toBeTruthy();
117
+ });
118
+
119
+ it('should be equal for role', () => {
120
+ expect(
121
+ isTrue(
122
+ testSchemaEquality(ZodCreateRoleSchema, TypeboxCreateRoleSchema, {
123
+ name: 'test',
124
+ permissionIds: ['test'],
125
+ extraFields: {
126
+ test: 'test'
127
+ }
128
+ })
129
+ )
130
+ ).toBeTruthy();
131
+
132
+ expect(
133
+ isTrue(
134
+ testSchemaEquality(zodUpdateRoleSchema, typeboxUpdateRoleSchema, {
135
+ id: 'test',
136
+ name: 'test',
137
+ permissionIds: ['test'],
138
+ extraFields: {
139
+ test: 'test'
140
+ }
141
+ })
142
+ )
143
+ ).toBeTruthy();
144
+
145
+ expect(
146
+ isTrue(
147
+ testSchemaEquality(zodRoleSchema, typeboxRoleSchema, {
148
+ id: 'test',
149
+ name: 'test',
150
+ permissions: [
151
+ {
152
+ id: 'test',
153
+ slug: 'test',
154
+ extraFields: { test: 'test' }
155
+ }
156
+ ],
157
+ extraFields: {
158
+ test: 'test'
159
+ }
160
+ })
161
+ )
162
+ ).toBeTruthy();
163
+ });
164
+
165
+ it('should be equal for user', () => {
166
+ expect(
167
+ isTrue(
168
+ testSchemaEquality(ZodCreateUserSchema, TypeboxCreateUserSchema, {
169
+ email: 'test@test.com',
170
+ password: 'test',
171
+ firstName: 'test',
172
+ lastName: 'test',
173
+ organizationId: 'test',
174
+ roleIds: ['test'],
175
+ phoneNumber: 'test',
176
+ subscription: 'test',
177
+ extraFields: {
178
+ test: 'test'
179
+ }
180
+ })
181
+ )
182
+ ).toBeTruthy();
183
+
184
+ expect(
185
+ isTrue(
186
+ testSchemaEquality(zodUpdateUserSchema, typeboxUpdateUserSchema, {
187
+ id: 'test',
188
+ email: 'test@test.com',
189
+ password: 'test',
190
+ firstName: 'test',
191
+ lastName: 'test',
192
+ roleIds: ['test'],
193
+ phoneNumber: 'test',
194
+ subscription: 'test',
195
+ extraFields: {
196
+ test: 'test'
197
+ }
198
+ })
199
+ )
200
+ ).toBeTruthy();
201
+
202
+ expect(
203
+ isTrue(
204
+ testSchemaEquality(zodUserSchema, typeboxUserSchema, {
205
+ id: 'test',
206
+ email: 'test@test.com',
207
+ firstName: 'test',
208
+ lastName: 'test',
209
+ roles: [
210
+ {
211
+ id: 'test',
212
+ name: 'test',
213
+ permissions: [{ id: 'test', slug: 'test' }],
214
+ extraFields: {
215
+ test: 'test'
216
+ }
217
+ }
218
+ ],
219
+ phoneNumber: 'test',
220
+ subscription: 'test',
221
+ extraFields: {
222
+ test: 'test'
223
+ }
224
+ })
225
+ )
226
+ ).toBeTruthy();
227
+ });
228
+
229
+ it('should be equal for organization', () => {
230
+ expect(
231
+ isTrue(
232
+ testSchemaEquality(
233
+ ZodCreateOrganizationSchema,
234
+ TypeboxCreateOrganizationSchema,
235
+ {
236
+ name: 'test',
237
+ domain: 'test',
238
+ subscription: 'test',
239
+ logoUrl: 'test',
240
+ extraFields: { test: 'test' }
241
+ }
242
+ )
243
+ )
244
+ ).toBeTruthy();
245
+
246
+ expect(
247
+ isTrue(
248
+ testSchemaEquality(
249
+ zodUpdateOrganizationSchema,
250
+ typeboxUpdateOrganizationSchema,
251
+ {
252
+ id: 'test',
253
+ name: 'test',
254
+ domain: 'test',
255
+ subscription: 'test',
256
+ logoUrl: 'test',
257
+ extraFields: { test: 'test' }
258
+ }
259
+ )
260
+ )
261
+ ).toBeTruthy();
262
+
263
+ expect(
264
+ isTrue(
265
+ testSchemaEquality(zodOrganizationSchema, typeboxOrganizationSchema, {
266
+ id: 'test',
267
+ name: 'test',
268
+ domain: 'test',
269
+ subscription: 'test',
270
+ logoUrl: 'test',
271
+ extraFields: { test: 'test' },
272
+ status: DummyEnum.A,
273
+ users: [
274
+ {
275
+ id: 'test',
276
+ email: 'test@test.com',
277
+ firstName: 'test',
278
+ lastName: 'test',
279
+ roles: [
280
+ {
281
+ id: 'test',
282
+ name: 'test',
283
+ permissions: [{ id: 'test', slug: 'test' }],
284
+ extraFields: { test: 'test' }
285
+ }
286
+ ]
287
+ }
288
+ ]
289
+ })
290
+ )
291
+ ).toBeTruthy();
292
+ });
293
+ });
package/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ export * from './schemas/organization.schema';
2
+ export * from './schemas/permission.schema';
3
+ export * from './schemas/role.schema';
4
+ export * from './schemas/user.schema';
5
+ export * from './services/organization.service';
6
+ export * from './services/permission.service';
7
+ export * from './services/role.service';
8
+ export * from './services/user.service';
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@forklaunch/implementation-iam-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-iam": "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
+ CreateOrganizationSchema as TypeBoxCreateOrganizationSchema,
4
+ OrganizationSchema as TypeBoxOrganizationSchema,
5
+ UpdateOrganizationSchema as TypeBoxUpdateOrganizationSchema
6
+ } from './typebox/organization.schema';
7
+ import {
8
+ CreateOrganizationSchema as ZodCreateOrganizationSchema,
9
+ OrganizationSchema as ZodOrganizationSchema,
10
+ UpdateOrganizationSchema as ZodUpdateOrganizationSchema
11
+ } from './zod/organization.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreateOrganizationSchema: TypeBoxCreateOrganizationSchema,
15
+ UpdateOrganizationSchema: TypeBoxUpdateOrganizationSchema(uuidId),
16
+ OrganizationSchema: TypeBoxOrganizationSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreateOrganizationSchema: ZodCreateOrganizationSchema,
21
+ UpdateOrganizationSchema: ZodUpdateOrganizationSchema(uuidId),
22
+ OrganizationSchema: ZodOrganizationSchema(uuidId)
23
+ });
24
+
25
+ export const BaseOrganizationServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ CreatePermissionSchema as TypeBoxCreatePermissionSchema,
4
+ PermissionSchema as TypeBoxPermissionSchema,
5
+ UpdatePermissionSchema as TypeBoxUpdatePermissionSchema
6
+ } from './typebox/permission.schema';
7
+ import {
8
+ CreatePermissionSchema as ZodCreatePermissionSchema,
9
+ PermissionSchema as ZodPermissionSchema,
10
+ UpdatePermissionSchema as ZodUpdatePermissionSchema
11
+ } from './zod/permission.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreatePermissionSchema: TypeBoxCreatePermissionSchema,
15
+ UpdatePermissionSchema: TypeBoxUpdatePermissionSchema(uuidId),
16
+ PermissionSchema: TypeBoxPermissionSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreatePermissionSchema: ZodCreatePermissionSchema,
21
+ UpdatePermissionSchema: ZodUpdatePermissionSchema(uuidId),
22
+ PermissionSchema: ZodPermissionSchema(uuidId)
23
+ });
24
+
25
+ export const BasePermissionServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ CreateRoleSchema as TypeBoxCreateRoleSchema,
4
+ RoleSchema as TypeBoxRoleSchema,
5
+ UpdateRoleSchema as TypeBoxUpdateRoleSchema
6
+ } from './typebox/role.schema';
7
+ import {
8
+ CreateRoleSchema as ZodCreateRoleSchema,
9
+ RoleSchema as ZodRoleSchema,
10
+ UpdateRoleSchema as ZodUpdateRoleSchema
11
+ } from './zod/role.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreateRoleSchema: TypeBoxCreateRoleSchema,
15
+ UpdateRoleSchema: TypeBoxUpdateRoleSchema(uuidId),
16
+ RoleSchema: TypeBoxRoleSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreateRoleSchema: ZodCreateRoleSchema,
21
+ UpdateRoleSchema: ZodUpdateRoleSchema(uuidId),
22
+ RoleSchema: ZodRoleSchema(uuidId)
23
+ });
24
+
25
+ export const BaseRoleServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );
@@ -0,0 +1,49 @@
1
+ import { IdiomaticSchema, LiteralSchema } from '@forklaunch/validator';
2
+ import {
3
+ array,
4
+ date,
5
+ enum_,
6
+ optional,
7
+ string,
8
+ TypeboxSchemaValidator,
9
+ unknown,
10
+ uuid
11
+ } from '@forklaunch/validator/typebox';
12
+
13
+ export const CreateOrganizationSchema = {
14
+ name: string,
15
+ domain: string,
16
+ subscription: string,
17
+ logoUrl: optional(string),
18
+ extraFields: optional(unknown)
19
+ };
20
+
21
+ export const UpdateOrganizationSchema = (uuidId: boolean) => ({
22
+ id: uuidId ? uuid : string,
23
+ name: optional(string),
24
+ domain: optional(string),
25
+ subscription: optional(string),
26
+ logoUrl: optional(string),
27
+ extraFields: optional(unknown)
28
+ });
29
+
30
+ export const OrganizationSchema =
31
+ (uuidId: boolean) =>
32
+ <
33
+ UserDtoSchema extends IdiomaticSchema<TypeboxSchemaValidator>,
34
+ OrganizationStatus extends Record<string, LiteralSchema>
35
+ >(
36
+ UserDtoSchema: UserDtoSchema,
37
+ OrganizationStatus: OrganizationStatus
38
+ ) => ({
39
+ id: uuidId ? uuid : string,
40
+ name: string,
41
+ users: array(UserDtoSchema),
42
+ domain: string,
43
+ subscription: string,
44
+ status: enum_(OrganizationStatus),
45
+ logoUrl: optional(string),
46
+ extraFields: optional(unknown),
47
+ createdAt: optional(date),
48
+ updatedAt: optional(date)
49
+ });
@@ -0,0 +1,30 @@
1
+ import {
2
+ array,
3
+ date,
4
+ optional,
5
+ string,
6
+ unknown,
7
+ uuid
8
+ } from '@forklaunch/validator/typebox';
9
+
10
+ export const CreatePermissionSchema = {
11
+ slug: string,
12
+ addToRolesIds: optional(array(string)),
13
+ extraFields: optional(unknown)
14
+ };
15
+
16
+ export const UpdatePermissionSchema = (uuidId: boolean) => ({
17
+ id: uuidId ? uuid : string,
18
+ slug: optional(string),
19
+ extraFields: optional(unknown),
20
+ addToRolesIds: optional(array(string)),
21
+ removeFromRolesIds: optional(array(string))
22
+ });
23
+
24
+ export const PermissionSchema = (uuidId: boolean) => ({
25
+ id: uuidId ? uuid : string,
26
+ slug: string,
27
+ extraFields: optional(unknown),
28
+ createdAt: optional(date),
29
+ updatedAt: optional(date)
30
+ });
@@ -0,0 +1,36 @@
1
+ import { IdiomaticSchema } from '@forklaunch/validator';
2
+ import {
3
+ array,
4
+ date,
5
+ optional,
6
+ string,
7
+ TypeboxSchemaValidator,
8
+ unknown,
9
+ uuid
10
+ } from '@forklaunch/validator/typebox';
11
+
12
+ export const CreateRoleSchema = {
13
+ name: string,
14
+ permissionIds: optional(array(string)),
15
+ extraFields: optional(unknown)
16
+ };
17
+
18
+ export const UpdateRoleSchema = (uuidId: boolean) => ({
19
+ id: uuidId ? uuid : string,
20
+ name: optional(string),
21
+ permissionIds: optional(array(string)),
22
+ extraFields: optional(unknown)
23
+ });
24
+
25
+ export const RoleSchema =
26
+ (uuidId: boolean) =>
27
+ <PermissionSchema extends IdiomaticSchema<TypeboxSchemaValidator>>(
28
+ PermissionSchema: PermissionSchema
29
+ ) => ({
30
+ id: uuidId ? uuid : string,
31
+ name: string,
32
+ permissions: array(PermissionSchema),
33
+ extraFields: optional(unknown),
34
+ createdAt: optional(date),
35
+ updatedAt: optional(date)
36
+ });
@@ -0,0 +1,52 @@
1
+ import { IdiomaticSchema } from '@forklaunch/validator';
2
+ import {
3
+ array,
4
+ date,
5
+ email,
6
+ optional,
7
+ string,
8
+ TypeboxSchemaValidator,
9
+ unknown,
10
+ uuid
11
+ } from '@forklaunch/validator/typebox';
12
+
13
+ export const CreateUserSchema = {
14
+ email: email,
15
+ password: string,
16
+ firstName: string,
17
+ lastName: string,
18
+ organizationId: string,
19
+ roleIds: array(string),
20
+ phoneNumber: optional(string),
21
+ subscription: optional(string),
22
+ extraFields: optional(unknown)
23
+ };
24
+
25
+ export const UpdateUserSchema = (uuidId: boolean) => ({
26
+ id: uuidId ? uuid : string,
27
+ email: optional(email),
28
+ password: optional(string),
29
+ firstName: optional(string),
30
+ lastName: optional(string),
31
+ roleIds: optional(array(string)),
32
+ phoneNumber: optional(string),
33
+ subscription: optional(string),
34
+ extraFields: optional(unknown)
35
+ });
36
+
37
+ export const UserSchema =
38
+ (uuidId: boolean) =>
39
+ <RoleDtoSchema extends IdiomaticSchema<TypeboxSchemaValidator>>(
40
+ RoleDtoSchema: RoleDtoSchema
41
+ ) => ({
42
+ id: uuidId ? uuid : string,
43
+ email: email,
44
+ firstName: string,
45
+ lastName: string,
46
+ roles: array(RoleDtoSchema),
47
+ phoneNumber: optional(string),
48
+ subscription: optional(string),
49
+ extraFields: optional(unknown),
50
+ createdAt: optional(date),
51
+ updatedAt: optional(date)
52
+ });
@@ -0,0 +1,28 @@
1
+ import { serviceSchemaResolver } from '@forklaunch/core/dtoMapper';
2
+ import {
3
+ CreateUserSchema as TypeBoxCreateUserSchema,
4
+ UpdateUserSchema as TypeBoxUpdateUserSchema,
5
+ UserSchema as TypeBoxUserSchema
6
+ } from './typebox/user.schema';
7
+ import {
8
+ CreateUserSchema as ZodCreateUserSchema,
9
+ UpdateUserSchema as ZodUpdateUserSchema,
10
+ UserSchema as ZodUserSchema
11
+ } from './zod/user.schema';
12
+
13
+ const TypeBoxSchemas = (uuidId: boolean) => ({
14
+ CreateUserSchema: TypeBoxCreateUserSchema,
15
+ UpdateUserSchema: TypeBoxUpdateUserSchema(uuidId),
16
+ UserSchema: TypeBoxUserSchema(uuidId)
17
+ });
18
+
19
+ const ZodSchemas = (uuidId: boolean) => ({
20
+ CreateUserSchema: ZodCreateUserSchema,
21
+ UpdateUserSchema: ZodUpdateUserSchema(uuidId),
22
+ UserSchema: ZodUserSchema(uuidId)
23
+ });
24
+
25
+ export const BaseUserServiceSchemas = serviceSchemaResolver(
26
+ TypeBoxSchemas,
27
+ ZodSchemas
28
+ );