@forklaunch/implementation-iam-base 0.1.2 → 0.1.5

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 (87) hide show
  1. package/lib/__test__/schemaEquality.test.d.ts +2 -0
  2. package/lib/__test__/schemaEquality.test.d.ts.map +1 -0
  3. package/lib/__test__/schemaEquality.test.js +175 -0
  4. package/lib/eject/schemas/index.ts +4 -0
  5. package/{schemas/typebox → lib/eject/schemas}/organization.schema.ts +13 -11
  6. package/{schemas/zod → lib/eject/schemas}/permission.schema.ts +7 -1
  7. package/lib/eject/schemas/role.schema.ts +37 -0
  8. package/{schemas/typebox → lib/eject/schemas}/user.schema.ts +20 -19
  9. package/lib/eject/services/index.ts +4 -0
  10. package/{services → lib/eject/services}/organization.service.ts +6 -6
  11. package/{services → lib/eject/services}/permission.service.ts +9 -6
  12. package/{services → lib/eject/services}/role.service.ts +6 -6
  13. package/{services → lib/eject/services}/user.service.ts +11 -9
  14. package/lib/jest.config.d.ts +4 -0
  15. package/lib/jest.config.d.ts.map +1 -0
  16. package/lib/jest.config.js +19 -0
  17. package/lib/schemas/index.d.ts +5 -0
  18. package/lib/schemas/index.d.ts.map +1 -0
  19. package/lib/schemas/index.js +4 -0
  20. package/lib/schemas/organization.schema.d.ts +192 -0
  21. package/lib/schemas/organization.schema.d.ts.map +1 -0
  22. package/lib/schemas/organization.schema.js +4 -0
  23. package/lib/schemas/permission.schema.d.ts +42 -0
  24. package/lib/schemas/permission.schema.d.ts.map +1 -0
  25. package/lib/schemas/permission.schema.js +4 -0
  26. package/lib/schemas/role.schema.d.ts +66 -0
  27. package/lib/schemas/role.schema.d.ts.map +1 -0
  28. package/lib/schemas/role.schema.js +4 -0
  29. package/lib/schemas/typebox/organization.schema.d.ts +106 -0
  30. package/lib/schemas/typebox/organization.schema.d.ts.map +1 -0
  31. package/lib/schemas/typebox/organization.schema.js +34 -0
  32. package/lib/schemas/typebox/permission.schema.d.ts +41 -0
  33. package/lib/schemas/typebox/permission.schema.d.ts.map +1 -0
  34. package/lib/schemas/typebox/permission.schema.js +25 -0
  35. package/lib/schemas/typebox/role.schema.d.ts +53 -0
  36. package/lib/schemas/typebox/role.schema.d.ts.map +1 -0
  37. package/lib/schemas/typebox/role.schema.js +26 -0
  38. package/lib/schemas/typebox/user.schema.d.ts +97 -0
  39. package/lib/schemas/typebox/user.schema.d.ts.map +1 -0
  40. package/lib/schemas/typebox/user.schema.js +41 -0
  41. package/lib/schemas/user.schema.d.ts +136 -0
  42. package/lib/schemas/user.schema.d.ts.map +1 -0
  43. package/lib/schemas/user.schema.js +4 -0
  44. package/lib/schemas/zod/organization.schema.d.ts +278 -0
  45. package/lib/schemas/zod/organization.schema.d.ts.map +1 -0
  46. package/lib/schemas/zod/organization.schema.js +34 -0
  47. package/lib/schemas/zod/permission.schema.d.ts +41 -0
  48. package/lib/schemas/zod/permission.schema.d.ts.map +1 -0
  49. package/lib/schemas/zod/permission.schema.js +25 -0
  50. package/lib/schemas/zod/role.schema.d.ts +77 -0
  51. package/lib/schemas/zod/role.schema.d.ts.map +1 -0
  52. package/lib/schemas/zod/role.schema.js +26 -0
  53. package/lib/schemas/zod/user.schema.d.ts +173 -0
  54. package/lib/schemas/zod/user.schema.d.ts.map +1 -0
  55. package/lib/schemas/zod/user.schema.js +41 -0
  56. package/lib/services/index.d.ts +5 -0
  57. package/lib/services/index.d.ts.map +1 -0
  58. package/lib/services/index.js +4 -0
  59. package/lib/services/organization.service.d.ts +45 -0
  60. package/lib/services/organization.service.d.ts.map +1 -0
  61. package/lib/services/organization.service.js +35 -0
  62. package/lib/services/permission.service.d.ts +62 -0
  63. package/lib/services/permission.service.d.ts.map +1 -0
  64. package/lib/services/permission.service.js +159 -0
  65. package/lib/services/role.service.d.ts +49 -0
  66. package/lib/services/role.service.d.ts.map +1 -0
  67. package/lib/services/role.service.js +57 -0
  68. package/lib/services/user.service.d.ts +54 -0
  69. package/lib/services/user.service.d.ts.map +1 -0
  70. package/lib/services/user.service.js +85 -0
  71. package/lib/tsconfig.tsbuildinfo +1 -0
  72. package/lib/vitest.config.d.ts +3 -0
  73. package/lib/vitest.config.d.ts.map +1 -0
  74. package/lib/vitest.config.js +7 -0
  75. package/package.json +22 -10
  76. package/__test__/schemaEquality.test.ts +0 -293
  77. package/index.ts +0 -8
  78. package/schemas/organization.schema.ts +0 -28
  79. package/schemas/permission.schema.ts +0 -28
  80. package/schemas/role.schema.ts +0 -28
  81. package/schemas/typebox/permission.schema.ts +0 -30
  82. package/schemas/typebox/role.schema.ts +0 -36
  83. package/schemas/user.schema.ts +0 -28
  84. package/schemas/zod/organization.schema.ts +0 -49
  85. package/schemas/zod/role.schema.ts +0 -36
  86. package/schemas/zod/user.schema.ts +0 -52
  87. package/tsconfig.json +0 -7
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
3
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAKG"}
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config';
2
+ export default defineConfig({
3
+ test: {
4
+ globals: true,
5
+ exclude: ['**/lib/**', '**/node_modules/**']
6
+ }
7
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-iam-base",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "description": "Billing basic implementation for forklaunch",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -12,30 +12,42 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "Forklift Technologies, Inc.",
15
- "types": "./lib/index.d.ts",
15
+ "exports": {
16
+ "./schemas": {
17
+ "import": "./lib/schemas/index.js",
18
+ "types": "./lib/schemas/index.d.ts"
19
+ },
20
+ "./services": {
21
+ "import": "./lib/services/index.js",
22
+ "types": "./lib/services/index.d.ts"
23
+ }
24
+ },
25
+ "files": [
26
+ "lib/**"
27
+ ],
16
28
  "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",
29
+ "@forklaunch/common": "^0.2.6",
30
+ "@forklaunch/core": "^0.6.2",
31
+ "@forklaunch/validator": "^0.4.10",
32
+ "@mikro-orm/core": "^6.4.12",
21
33
  "@sinclair/typebox": "^0.34.33",
22
34
  "ajv": "^8.17.1",
23
35
  "zod": "^3.24.2",
24
- "@forklaunch/interfaces-iam": "0.1.2"
36
+ "@forklaunch/interfaces-iam": "0.1.5"
25
37
  },
26
38
  "devDependencies": {
27
39
  "depcheck": "^1.4.7",
28
40
  "prettier": "^3.5.3",
29
- "typedoc": "^0.28.1"
41
+ "typedoc": "^0.28.2"
30
42
  },
31
43
  "scripts": {
32
44
  "build": "tsc && pnpm package:eject",
33
- "clean": "rm -rf dist pnpm.lock.yaml node_modules",
45
+ "clean": "rm -rf lib pnpm.lock.yaml node_modules",
34
46
  "docs": "typedoc --out docs *",
35
47
  "format": "prettier --ignore-path=.prettierignore --config .prettierrc '**/*.{ts,tsx,json}' --write",
36
48
  "lint": "eslint . -c eslint.config.mjs",
37
49
  "lint:fix": "eslint . -c eslint.config.mjs --fix",
38
- "package:eject": "mkdir -p lib/eject && cp -r schemas/zod lib/eject/schemas && cp -r services lib/eject/services",
50
+ "package:eject": "rm -rf lib/eject && mkdir -p lib/eject && cp -r schemas/zod lib/eject/schemas && cp schemas/index.ts lib/eject/schemas && cp -r services lib/eject/services && find lib/eject -type f -name '*.ts' -exec sed -i '' 's|@forklaunch/validator/zod|@{{app_name}}/core|g' {} +",
39
51
  "test": "vitest --passWithNoTests"
40
52
  }
41
53
  }
@@ -1,293 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
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';
@@ -1,28 +0,0 @@
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
- );
@@ -1,28 +0,0 @@
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
- );
@@ -1,28 +0,0 @@
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
- );
@@ -1,30 +0,0 @@
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
- });
@@ -1,36 +0,0 @@
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
- });
@@ -1,28 +0,0 @@
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
- );
@@ -1,49 +0,0 @@
1
- import { IdiomaticSchema, LiteralSchema } from '@forklaunch/validator';
2
- import {
3
- array,
4
- date,
5
- enum_,
6
- optional,
7
- string,
8
- unknown,
9
- uuid,
10
- ZodSchemaValidator
11
- } from '@forklaunch/validator/zod';
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<ZodSchemaValidator>,
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
- });
@@ -1,36 +0,0 @@
1
- import { IdiomaticSchema } from '@forklaunch/validator';
2
- import {
3
- array,
4
- date,
5
- optional,
6
- string,
7
- unknown,
8
- uuid,
9
- ZodSchemaValidator
10
- } from '@forklaunch/validator/zod';
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<ZodSchemaValidator>>(
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
- });