@forklaunch/implementation-iam-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.
- package/package.json +5 -5
- package/lib/__test__/schemaEquality.test.d.ts +0 -2
- package/lib/__test__/schemaEquality.test.d.ts.map +0 -1
- package/lib/__test__/schemaEquality.test.js +0 -283
- package/lib/eject/domain/schemas/index.ts +0 -4
- package/lib/eject/domain/schemas/organization.schema.ts +0 -53
- package/lib/eject/domain/schemas/permission.schema.ts +0 -36
- package/lib/eject/domain/schemas/role.schema.ts +0 -37
- package/lib/eject/domain/schemas/user.schema.ts +0 -53
- package/lib/eject/services/index.ts +0 -4
- package/lib/eject/services/organization.service.ts +0 -143
- package/lib/eject/services/permission.service.ts +0 -345
- package/lib/eject/services/role.service.ts +0 -179
- package/lib/eject/services/user.service.ts +0 -224
- package/lib/jest.config.d.ts +0 -4
- package/lib/jest.config.d.ts.map +0 -1
- package/lib/jest.config.js +0 -19
- package/lib/schemas/index.d.ts +0 -5
- package/lib/schemas/index.d.ts.map +0 -1
- package/lib/schemas/index.js +0 -4
- package/lib/schemas/organization.schema.d.ts +0 -411
- package/lib/schemas/organization.schema.d.ts.map +0 -1
- package/lib/schemas/organization.schema.js +0 -7
- package/lib/schemas/permission.schema.d.ts +0 -104
- package/lib/schemas/permission.schema.d.ts.map +0 -1
- package/lib/schemas/permission.schema.js +0 -7
- package/lib/schemas/role.schema.d.ts +0 -163
- package/lib/schemas/role.schema.d.ts.map +0 -1
- package/lib/schemas/role.schema.js +0 -7
- package/lib/schemas/typebox/organization.schema.d.ts +0 -414
- package/lib/schemas/typebox/organization.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/organization.schema.js +0 -44
- package/lib/schemas/typebox/permission.schema.d.ts +0 -131
- package/lib/schemas/typebox/permission.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/permission.schema.js +0 -32
- package/lib/schemas/typebox/role.schema.d.ts +0 -199
- package/lib/schemas/typebox/role.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/role.schema.js +0 -33
- package/lib/schemas/typebox/user.schema.d.ts +0 -339
- package/lib/schemas/typebox/user.schema.d.ts.map +0 -1
- package/lib/schemas/typebox/user.schema.js +0 -49
- package/lib/schemas/user.schema.d.ts +0 -290
- package/lib/schemas/user.schema.d.ts.map +0 -1
- package/lib/schemas/user.schema.js +0 -7
- package/lib/schemas/zod/organization.schema.d.ts +0 -374
- package/lib/schemas/zod/organization.schema.d.ts.map +0 -1
- package/lib/schemas/zod/organization.schema.js +0 -44
- package/lib/schemas/zod/permission.schema.d.ts +0 -63
- package/lib/schemas/zod/permission.schema.d.ts.map +0 -1
- package/lib/schemas/zod/permission.schema.js +0 -32
- package/lib/schemas/zod/role.schema.d.ts +0 -113
- package/lib/schemas/zod/role.schema.d.ts.map +0 -1
- package/lib/schemas/zod/role.schema.js +0 -33
- package/lib/schemas/zod/user.schema.d.ts +0 -225
- package/lib/schemas/zod/user.schema.d.ts.map +0 -1
- package/lib/schemas/zod/user.schema.js +0 -49
- package/lib/services/index.d.ts +0 -5
- package/lib/services/index.d.ts.map +0 -1
- package/lib/services/index.js +0 -4
- package/lib/services/organization.service.d.ts +0 -118
- package/lib/services/organization.service.d.ts.map +0 -1
- package/lib/services/organization.service.js +0 -50
- package/lib/services/permission.service.d.ts +0 -138
- package/lib/services/permission.service.d.ts.map +0 -1
- package/lib/services/permission.service.js +0 -203
- package/lib/services/role.service.d.ts +0 -118
- package/lib/services/role.service.d.ts.map +0 -1
- package/lib/services/role.service.js +0 -73
- package/lib/services/user.service.d.ts +0 -138
- package/lib/services/user.service.d.ts.map +0 -1
- package/lib/services/user.service.js +0 -126
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/vitest.config.d.ts +0 -3
- package/lib/vitest.config.d.ts.map +0 -1
- package/lib/vitest.config.js +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/implementation-iam-base",
|
|
3
|
-
"version": "0.1.
|
|
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": "
|
|
32
|
-
"@forklaunch/core": "
|
|
33
|
-
"@forklaunch/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-iam": "0.1.
|
|
38
|
+
"@forklaunch/interfaces-iam": "0.1.12"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"depcheck": "^1.4.7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemaEquality.test.d.ts","sourceRoot":"","sources":["../../__test__/schemaEquality.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,283 +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
|
-
const zodUpdatePermissionSchema = ZodUpdatePermissionSchema({
|
|
44
|
-
uuidId: false
|
|
45
|
-
});
|
|
46
|
-
const typeboxUpdatePermissionSchema = TypeboxUpdatePermissionSchema({
|
|
47
|
-
uuidId: false
|
|
48
|
-
});
|
|
49
|
-
const zodPermissionSchema = ZodPermissionSchema({ uuidId: false });
|
|
50
|
-
const typeboxPermissionSchema = TypeboxPermissionSchema({ uuidId: false });
|
|
51
|
-
const zodUpdateRoleSchema = ZodUpdateRoleSchema({ uuidId: false });
|
|
52
|
-
const typeboxUpdateRoleSchema = TypeboxUpdateRoleSchema({ uuidId: false });
|
|
53
|
-
const zodRoleSchema = ZodRoleSchema({ uuidId: false });
|
|
54
|
-
const typeboxRoleSchema = TypeboxRoleSchema({ uuidId: false });
|
|
55
|
-
const zodUpdateUserSchema = ZodUpdateUserSchema({ uuidId: false });
|
|
56
|
-
const typeboxUpdateUserSchema = TypeboxUpdateUserSchema({ uuidId: false });
|
|
57
|
-
const zodUserSchema = ZodUserSchema({ uuidId: false });
|
|
58
|
-
const typeboxUserSchema = TypeboxUserSchema({ uuidId: false });
|
|
59
|
-
const zodUpdateOrganizationSchema = ZodUpdateOrganizationSchema({
|
|
60
|
-
uuidId: false
|
|
61
|
-
});
|
|
62
|
-
const typeboxUpdateOrganizationSchema = TypeboxUpdateOrganizationSchema({
|
|
63
|
-
uuidId: false
|
|
64
|
-
});
|
|
65
|
-
const zodOrganizationSchema = ZodOrganizationSchema({ uuidId: false })(
|
|
66
|
-
DummyEnum
|
|
67
|
-
);
|
|
68
|
-
const typeboxOrganizationSchema = TypeboxOrganizationSchema({ uuidId: false })(
|
|
69
|
-
DummyEnum
|
|
70
|
-
);
|
|
71
|
-
describe('schema equality', () => {
|
|
72
|
-
it('should be equal for permission', () => {
|
|
73
|
-
expect(
|
|
74
|
-
isTrue(
|
|
75
|
-
testSchemaEquality(
|
|
76
|
-
ZodCreatePermissionSchema,
|
|
77
|
-
TypeboxCreatePermissionSchema,
|
|
78
|
-
{
|
|
79
|
-
slug: 'test',
|
|
80
|
-
addToRolesIds: ['test'],
|
|
81
|
-
extraFields: {
|
|
82
|
-
test: 'test'
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
)
|
|
86
|
-
)
|
|
87
|
-
).toBeTruthy();
|
|
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
|
-
expect(
|
|
106
|
-
isTrue(
|
|
107
|
-
testSchemaEquality(zodPermissionSchema, typeboxPermissionSchema, {
|
|
108
|
-
id: 'test',
|
|
109
|
-
slug: 'test',
|
|
110
|
-
extraFields: {
|
|
111
|
-
test: 'test'
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
)
|
|
115
|
-
).toBeTruthy();
|
|
116
|
-
});
|
|
117
|
-
it('should be equal for role', () => {
|
|
118
|
-
expect(
|
|
119
|
-
isTrue(
|
|
120
|
-
testSchemaEquality(ZodCreateRoleSchema, TypeboxCreateRoleSchema, {
|
|
121
|
-
name: 'test',
|
|
122
|
-
permissionIds: ['test'],
|
|
123
|
-
extraFields: {
|
|
124
|
-
test: 'test'
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
)
|
|
128
|
-
).toBeTruthy();
|
|
129
|
-
expect(
|
|
130
|
-
isTrue(
|
|
131
|
-
testSchemaEquality(zodUpdateRoleSchema, typeboxUpdateRoleSchema, {
|
|
132
|
-
id: 'test',
|
|
133
|
-
name: 'test',
|
|
134
|
-
permissionIds: ['test'],
|
|
135
|
-
extraFields: {
|
|
136
|
-
test: 'test'
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
)
|
|
140
|
-
).toBeTruthy();
|
|
141
|
-
expect(
|
|
142
|
-
isTrue(
|
|
143
|
-
testSchemaEquality(zodRoleSchema, typeboxRoleSchema, {
|
|
144
|
-
id: 'test',
|
|
145
|
-
name: 'test',
|
|
146
|
-
permissions: [
|
|
147
|
-
{
|
|
148
|
-
id: 'test',
|
|
149
|
-
slug: 'test',
|
|
150
|
-
extraFields: { test: 'test' }
|
|
151
|
-
}
|
|
152
|
-
],
|
|
153
|
-
extraFields: {
|
|
154
|
-
test: 'test'
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
)
|
|
158
|
-
).toBeTruthy();
|
|
159
|
-
});
|
|
160
|
-
it('should be equal for user', () => {
|
|
161
|
-
expect(
|
|
162
|
-
isTrue(
|
|
163
|
-
testSchemaEquality(ZodCreateUserSchema, TypeboxCreateUserSchema, {
|
|
164
|
-
email: 'test@test.com',
|
|
165
|
-
password: 'test',
|
|
166
|
-
firstName: 'test',
|
|
167
|
-
lastName: 'test',
|
|
168
|
-
organizationId: 'test',
|
|
169
|
-
roleIds: ['test'],
|
|
170
|
-
phoneNumber: 'test',
|
|
171
|
-
subscription: 'test',
|
|
172
|
-
extraFields: {
|
|
173
|
-
test: 'test'
|
|
174
|
-
}
|
|
175
|
-
})
|
|
176
|
-
)
|
|
177
|
-
).toBeTruthy();
|
|
178
|
-
expect(
|
|
179
|
-
isTrue(
|
|
180
|
-
testSchemaEquality(zodUpdateUserSchema, typeboxUpdateUserSchema, {
|
|
181
|
-
id: 'test',
|
|
182
|
-
email: 'test@test.com',
|
|
183
|
-
password: 'test',
|
|
184
|
-
firstName: 'test',
|
|
185
|
-
lastName: 'test',
|
|
186
|
-
roleIds: ['test'],
|
|
187
|
-
phoneNumber: 'test',
|
|
188
|
-
subscription: 'test',
|
|
189
|
-
extraFields: {
|
|
190
|
-
test: 'test'
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
)
|
|
194
|
-
).toBeTruthy();
|
|
195
|
-
expect(
|
|
196
|
-
isTrue(
|
|
197
|
-
testSchemaEquality(zodUserSchema, typeboxUserSchema, {
|
|
198
|
-
id: 'test',
|
|
199
|
-
email: 'test@test.com',
|
|
200
|
-
firstName: 'test',
|
|
201
|
-
lastName: 'test',
|
|
202
|
-
roles: [
|
|
203
|
-
{
|
|
204
|
-
id: 'test',
|
|
205
|
-
name: 'test',
|
|
206
|
-
permissions: [{ id: 'test', slug: 'test' }],
|
|
207
|
-
extraFields: {
|
|
208
|
-
test: 'test'
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
],
|
|
212
|
-
phoneNumber: 'test',
|
|
213
|
-
subscription: 'test',
|
|
214
|
-
extraFields: {
|
|
215
|
-
test: 'test'
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
)
|
|
219
|
-
).toBeTruthy();
|
|
220
|
-
});
|
|
221
|
-
it('should be equal for organization', () => {
|
|
222
|
-
expect(
|
|
223
|
-
isTrue(
|
|
224
|
-
testSchemaEquality(
|
|
225
|
-
ZodCreateOrganizationSchema,
|
|
226
|
-
TypeboxCreateOrganizationSchema,
|
|
227
|
-
{
|
|
228
|
-
name: 'test',
|
|
229
|
-
domain: 'test',
|
|
230
|
-
subscription: 'test',
|
|
231
|
-
logoUrl: 'test',
|
|
232
|
-
extraFields: { test: 'test' }
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
)
|
|
236
|
-
).toBeTruthy();
|
|
237
|
-
expect(
|
|
238
|
-
isTrue(
|
|
239
|
-
testSchemaEquality(
|
|
240
|
-
zodUpdateOrganizationSchema,
|
|
241
|
-
typeboxUpdateOrganizationSchema,
|
|
242
|
-
{
|
|
243
|
-
id: 'test',
|
|
244
|
-
name: 'test',
|
|
245
|
-
domain: 'test',
|
|
246
|
-
subscription: 'test',
|
|
247
|
-
logoUrl: 'test',
|
|
248
|
-
extraFields: { test: 'test' }
|
|
249
|
-
}
|
|
250
|
-
)
|
|
251
|
-
)
|
|
252
|
-
).toBeTruthy();
|
|
253
|
-
expect(
|
|
254
|
-
isTrue(
|
|
255
|
-
testSchemaEquality(zodOrganizationSchema, typeboxOrganizationSchema, {
|
|
256
|
-
id: 'test',
|
|
257
|
-
name: 'test',
|
|
258
|
-
domain: 'test',
|
|
259
|
-
subscription: 'test',
|
|
260
|
-
logoUrl: 'test',
|
|
261
|
-
extraFields: { test: 'test' },
|
|
262
|
-
status: DummyEnum.A,
|
|
263
|
-
users: [
|
|
264
|
-
{
|
|
265
|
-
id: 'test',
|
|
266
|
-
email: 'test@test.com',
|
|
267
|
-
firstName: 'test',
|
|
268
|
-
lastName: 'test',
|
|
269
|
-
roles: [
|
|
270
|
-
{
|
|
271
|
-
id: 'test',
|
|
272
|
-
name: 'test',
|
|
273
|
-
permissions: [{ id: 'test', slug: 'test' }],
|
|
274
|
-
extraFields: { test: 'test' }
|
|
275
|
-
}
|
|
276
|
-
]
|
|
277
|
-
}
|
|
278
|
-
]
|
|
279
|
-
})
|
|
280
|
-
)
|
|
281
|
-
).toBeTruthy();
|
|
282
|
-
});
|
|
283
|
-
});
|
|
@@ -1,53 +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
|
-
import { UserSchema } from './user.schema';
|
|
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 }: { 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 }: { uuidId: boolean }) =>
|
|
32
|
-
<OrganizationStatus extends Record<string, LiteralSchema>>(
|
|
33
|
-
organizationStatus: OrganizationStatus
|
|
34
|
-
) => ({
|
|
35
|
-
id: uuidId ? uuid : string,
|
|
36
|
-
name: string,
|
|
37
|
-
users: array(UserSchema({ uuidId })),
|
|
38
|
-
domain: string,
|
|
39
|
-
subscription: string,
|
|
40
|
-
status: enum_(organizationStatus),
|
|
41
|
-
logoUrl: optional(string),
|
|
42
|
-
extraFields: optional(unknown),
|
|
43
|
-
createdAt: optional(date),
|
|
44
|
-
updatedAt: optional(date)
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export const BaseOrganizationServiceSchemas = (options: {
|
|
48
|
-
uuidId: boolean;
|
|
49
|
-
}) => ({
|
|
50
|
-
CreateOrganizationSchema,
|
|
51
|
-
UpdateOrganizationSchema: UpdateOrganizationSchema(options),
|
|
52
|
-
OrganizationSchema: OrganizationSchema(options)
|
|
53
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
array,
|
|
3
|
-
date,
|
|
4
|
-
optional,
|
|
5
|
-
string,
|
|
6
|
-
unknown,
|
|
7
|
-
uuid
|
|
8
|
-
} from '@{{app_name}}/core';
|
|
9
|
-
|
|
10
|
-
export const CreatePermissionSchema = {
|
|
11
|
-
slug: string,
|
|
12
|
-
addToRolesIds: optional(array(string)),
|
|
13
|
-
extraFields: optional(unknown)
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const UpdatePermissionSchema = ({ uuidId }: { 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 }: { uuidId: boolean }) => ({
|
|
25
|
-
id: uuidId ? uuid : string,
|
|
26
|
-
slug: string,
|
|
27
|
-
extraFields: optional(unknown),
|
|
28
|
-
createdAt: optional(date),
|
|
29
|
-
updatedAt: optional(date)
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export const BasePermissionServiceSchemas = (options: { uuidId: boolean }) => ({
|
|
33
|
-
CreatePermissionSchema,
|
|
34
|
-
UpdatePermissionSchema: UpdatePermissionSchema(options),
|
|
35
|
-
PermissionSchema: PermissionSchema(options)
|
|
36
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
array,
|
|
3
|
-
date,
|
|
4
|
-
optional,
|
|
5
|
-
string,
|
|
6
|
-
unknown,
|
|
7
|
-
uuid
|
|
8
|
-
} from '@{{app_name}}/core';
|
|
9
|
-
import { PermissionSchema } from './permission.schema';
|
|
10
|
-
|
|
11
|
-
export const CreateRoleSchema = {
|
|
12
|
-
name: string,
|
|
13
|
-
permissionIds: optional(array(string)),
|
|
14
|
-
extraFields: optional(unknown)
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const UpdateRoleSchema = ({ uuidId }: { uuidId: boolean }) => ({
|
|
18
|
-
id: uuidId ? uuid : string,
|
|
19
|
-
name: optional(string),
|
|
20
|
-
permissionIds: optional(array(string)),
|
|
21
|
-
extraFields: optional(unknown)
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const RoleSchema = ({ uuidId }: { uuidId: boolean }) => ({
|
|
25
|
-
id: uuidId ? uuid : string,
|
|
26
|
-
name: string,
|
|
27
|
-
permissions: array(PermissionSchema({ uuidId })),
|
|
28
|
-
extraFields: optional(unknown),
|
|
29
|
-
createdAt: optional(date),
|
|
30
|
-
updatedAt: optional(date)
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export const BaseRoleServiceSchemas = (options: { uuidId: boolean }) => ({
|
|
34
|
-
CreateRoleSchema,
|
|
35
|
-
UpdateRoleSchema: UpdateRoleSchema(options),
|
|
36
|
-
RoleSchema: RoleSchema(options)
|
|
37
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
array,
|
|
3
|
-
date,
|
|
4
|
-
email,
|
|
5
|
-
optional,
|
|
6
|
-
string,
|
|
7
|
-
unknown,
|
|
8
|
-
uuid
|
|
9
|
-
} from '@{{app_name}}/core';
|
|
10
|
-
import { RoleSchema } from './role.schema';
|
|
11
|
-
|
|
12
|
-
export const CreateUserSchema = {
|
|
13
|
-
email: email,
|
|
14
|
-
password: string,
|
|
15
|
-
firstName: string,
|
|
16
|
-
lastName: string,
|
|
17
|
-
organizationId: string,
|
|
18
|
-
roleIds: array(string),
|
|
19
|
-
phoneNumber: optional(string),
|
|
20
|
-
subscription: optional(string),
|
|
21
|
-
extraFields: optional(unknown)
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const UpdateUserSchema = ({ uuidId }: { uuidId: boolean }) => ({
|
|
25
|
-
id: uuidId ? uuid : string,
|
|
26
|
-
email: optional(email),
|
|
27
|
-
password: optional(string),
|
|
28
|
-
firstName: optional(string),
|
|
29
|
-
lastName: optional(string),
|
|
30
|
-
roleIds: optional(array(string)),
|
|
31
|
-
phoneNumber: optional(string),
|
|
32
|
-
subscription: optional(string),
|
|
33
|
-
extraFields: optional(unknown)
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const UserSchema = ({ uuidId }: { uuidId: boolean }) => ({
|
|
37
|
-
id: uuidId ? uuid : string,
|
|
38
|
-
email: email,
|
|
39
|
-
firstName: string,
|
|
40
|
-
lastName: string,
|
|
41
|
-
roles: array(RoleSchema({ uuidId })),
|
|
42
|
-
phoneNumber: optional(string),
|
|
43
|
-
subscription: optional(string),
|
|
44
|
-
extraFields: optional(unknown),
|
|
45
|
-
createdAt: optional(date),
|
|
46
|
-
updatedAt: optional(date)
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export const BaseUserServiceSchemas = (options: { uuidId: boolean }) => ({
|
|
50
|
-
CreateUserSchema,
|
|
51
|
-
UpdateUserSchema: UpdateUserSchema(options),
|
|
52
|
-
UserSchema: UserSchema(options)
|
|
53
|
-
});
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { IdDto, InstanceTypeRecord } from '@forklaunch/common';
|
|
2
|
-
import {
|
|
3
|
-
InternalDtoMapper,
|
|
4
|
-
RequestDtoMapperConstructor,
|
|
5
|
-
ResponseDtoMapperConstructor,
|
|
6
|
-
transformIntoInternalDtoMapper
|
|
7
|
-
} from '@forklaunch/core/mappers';
|
|
8
|
-
import {
|
|
9
|
-
MetricsDefinition,
|
|
10
|
-
OpenTelemetryCollector
|
|
11
|
-
} from '@forklaunch/core/http';
|
|
12
|
-
import { MapNestedDtoArraysToCollections } from '@forklaunch/core/services';
|
|
13
|
-
import { OrganizationService } from '@forklaunch/interfaces-iam/interfaces';
|
|
14
|
-
import {
|
|
15
|
-
CreateOrganizationDto,
|
|
16
|
-
OrganizationDto,
|
|
17
|
-
UpdateOrganizationDto
|
|
18
|
-
} from '@forklaunch/interfaces-iam/types';
|
|
19
|
-
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
20
|
-
import { EntityManager } from '@mikro-orm/core';
|
|
21
|
-
|
|
22
|
-
export class BaseOrganizationService<
|
|
23
|
-
SchemaValidator extends AnySchemaValidator,
|
|
24
|
-
OrganizationStatus,
|
|
25
|
-
Metrics extends MetricsDefinition = MetricsDefinition,
|
|
26
|
-
Dto extends {
|
|
27
|
-
OrganizationDtoMapper: OrganizationDto<OrganizationStatus>;
|
|
28
|
-
CreateOrganizationDtoMapper: CreateOrganizationDto;
|
|
29
|
-
UpdateOrganizationDtoMapper: UpdateOrganizationDto;
|
|
30
|
-
} = {
|
|
31
|
-
OrganizationDtoMapper: OrganizationDto<OrganizationStatus>;
|
|
32
|
-
CreateOrganizationDtoMapper: CreateOrganizationDto;
|
|
33
|
-
UpdateOrganizationDtoMapper: UpdateOrganizationDto;
|
|
34
|
-
},
|
|
35
|
-
Entities extends {
|
|
36
|
-
OrganizationDtoMapper: MapNestedDtoArraysToCollections<
|
|
37
|
-
OrganizationDto<OrganizationStatus>,
|
|
38
|
-
'users'
|
|
39
|
-
>;
|
|
40
|
-
CreateOrganizationDtoMapper: MapNestedDtoArraysToCollections<
|
|
41
|
-
OrganizationDto<OrganizationStatus>,
|
|
42
|
-
'users'
|
|
43
|
-
>;
|
|
44
|
-
UpdateOrganizationDtoMapper: MapNestedDtoArraysToCollections<
|
|
45
|
-
OrganizationDto<OrganizationStatus>,
|
|
46
|
-
'users'
|
|
47
|
-
>;
|
|
48
|
-
} = {
|
|
49
|
-
OrganizationDtoMapper: MapNestedDtoArraysToCollections<
|
|
50
|
-
OrganizationDto<OrganizationStatus>,
|
|
51
|
-
'users'
|
|
52
|
-
>;
|
|
53
|
-
CreateOrganizationDtoMapper: MapNestedDtoArraysToCollections<
|
|
54
|
-
OrganizationDto<OrganizationStatus>,
|
|
55
|
-
'users'
|
|
56
|
-
>;
|
|
57
|
-
UpdateOrganizationDtoMapper: MapNestedDtoArraysToCollections<
|
|
58
|
-
OrganizationDto<OrganizationStatus>,
|
|
59
|
-
'users'
|
|
60
|
-
>;
|
|
61
|
-
}
|
|
62
|
-
> implements OrganizationService<OrganizationStatus>
|
|
63
|
-
{
|
|
64
|
-
#mapperss: InternalDtoMapper<
|
|
65
|
-
InstanceTypeRecord<typeof this.mapperss>,
|
|
66
|
-
Entities,
|
|
67
|
-
Dto
|
|
68
|
-
>;
|
|
69
|
-
|
|
70
|
-
constructor(
|
|
71
|
-
public em: EntityManager,
|
|
72
|
-
protected openTelemetryCollector: OpenTelemetryCollector<Metrics>,
|
|
73
|
-
protected schemaValidator: SchemaValidator,
|
|
74
|
-
protected mapperss: {
|
|
75
|
-
OrganizationDtoMapper: ResponseDtoMapperConstructor<
|
|
76
|
-
SchemaValidator,
|
|
77
|
-
Dto['OrganizationDtoMapper'],
|
|
78
|
-
Entities['OrganizationDtoMapper']
|
|
79
|
-
>;
|
|
80
|
-
CreateOrganizationDtoMapper: RequestDtoMapperConstructor<
|
|
81
|
-
SchemaValidator,
|
|
82
|
-
Dto['CreateOrganizationDtoMapper'],
|
|
83
|
-
Entities['CreateOrganizationDtoMapper']
|
|
84
|
-
>;
|
|
85
|
-
UpdateOrganizationDtoMapper: RequestDtoMapperConstructor<
|
|
86
|
-
SchemaValidator,
|
|
87
|
-
Dto['UpdateOrganizationDtoMapper'],
|
|
88
|
-
Entities['UpdateOrganizationDtoMapper']
|
|
89
|
-
>;
|
|
90
|
-
}
|
|
91
|
-
) {
|
|
92
|
-
this.#mapperss = transformIntoInternalDtoMapper(mapperss, schemaValidator);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async createOrganization(
|
|
96
|
-
organizationDto: Dto['CreateOrganizationDtoMapper'],
|
|
97
|
-
em?: EntityManager
|
|
98
|
-
): Promise<Dto['OrganizationDtoMapper']> {
|
|
99
|
-
this.openTelemetryCollector.log('info', 'Creating organization');
|
|
100
|
-
const organization =
|
|
101
|
-
this.#mapperss.CreateOrganizationDtoMapper.deserializeDtoToEntity(
|
|
102
|
-
organizationDto
|
|
103
|
-
);
|
|
104
|
-
await (em ?? this.em).transactional(async (innerEm) => {
|
|
105
|
-
await innerEm.persist(organization);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
return this.#mapperss.OrganizationDtoMapper.serializeEntityToDto(
|
|
109
|
-
organization
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async getOrganization(
|
|
114
|
-
idDto: IdDto,
|
|
115
|
-
em?: EntityManager
|
|
116
|
-
): Promise<Dto['OrganizationDtoMapper']> {
|
|
117
|
-
const organization = await (em ?? this.em).findOneOrFail(
|
|
118
|
-
'Organization',
|
|
119
|
-
idDto
|
|
120
|
-
);
|
|
121
|
-
return this.#mapperss.OrganizationDtoMapper.serializeEntityToDto(
|
|
122
|
-
organization as Entities['OrganizationDtoMapper']
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async updateOrganization(
|
|
127
|
-
organizationDto: Dto['UpdateOrganizationDtoMapper'],
|
|
128
|
-
em?: EntityManager
|
|
129
|
-
): Promise<Dto['OrganizationDtoMapper']> {
|
|
130
|
-
const updatedOrganization =
|
|
131
|
-
this.#mapperss.UpdateOrganizationDtoMapper.deserializeDtoToEntity(
|
|
132
|
-
organizationDto
|
|
133
|
-
);
|
|
134
|
-
await (em ?? this.em).upsert(updatedOrganization);
|
|
135
|
-
return this.#mapperss.OrganizationDtoMapper.serializeEntityToDto(
|
|
136
|
-
updatedOrganization
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async deleteOrganization(idDto: IdDto, em?: EntityManager): Promise<void> {
|
|
141
|
-
await (em ?? this.em).nativeDelete('Organization', idDto);
|
|
142
|
-
}
|
|
143
|
-
}
|