@forklaunch/implementation-iam-base 0.5.8 → 0.6.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/lib/domain/types/index.d.mts +195 -0
- package/lib/domain/types/index.d.ts +195 -0
- package/lib/domain/types/index.js +22 -0
- package/lib/domain/types/index.mjs +0 -0
- package/lib/eject/domain/types/index.ts +6 -0
- package/lib/eject/domain/types/organization.mapper.types.ts +29 -0
- package/lib/eject/domain/types/permission.mapper.types.ts +35 -0
- package/lib/eject/domain/types/role.mapper.types.ts +28 -0
- package/lib/eject/domain/types/user.mapper.types.ts +28 -0
- package/lib/eject/services/organization.service.ts +40 -80
- package/lib/eject/services/permission.service.ts +69 -116
- package/lib/eject/services/role.service.ts +40 -97
- package/lib/eject/services/user.service.ts +47 -95
- package/lib/services/index.d.mts +108 -356
- package/lib/services/index.d.ts +108 -356
- package/lib/services/index.js +106 -112
- package/lib/services/index.mjs +106 -100
- package/package.json +9 -9
package/lib/services/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// services/organization.service.ts
|
|
2
2
|
import { evaluateTelemetryOptions } from '@forklaunch/core/http';
|
|
3
|
-
import { transformIntoInternalMapper } from '@forklaunch/internal';
|
|
4
3
|
var BaseOrganizationService = class {
|
|
5
|
-
_mappers
|
|
4
|
+
// protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
|
|
6
5
|
evaluatedTelemetryOptions;
|
|
7
6
|
em;
|
|
8
7
|
openTelemetryCollector;
|
|
@@ -13,7 +12,6 @@ var BaseOrganizationService = class {
|
|
|
13
12
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
14
13
|
this.schemaValidator = schemaValidator;
|
|
15
14
|
this.mappers = mappers;
|
|
16
|
-
this._mappers = transformIntoInternalMapper(mappers, schemaValidator);
|
|
17
15
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
18
16
|
? evaluateTelemetryOptions(options.telemetry).enabled
|
|
19
17
|
: {
|
|
@@ -22,24 +20,24 @@ var BaseOrganizationService = class {
|
|
|
22
20
|
tracing: false
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
|
-
async createOrganization(organizationDto, em) {
|
|
23
|
+
async createOrganization(organizationDto, em, ...args) {
|
|
26
24
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
27
25
|
this.openTelemetryCollector.info(
|
|
28
26
|
'Creating organization',
|
|
29
27
|
organizationDto
|
|
30
28
|
);
|
|
31
29
|
}
|
|
32
|
-
const organization =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const organization = await this.mappers.CreateOrganizationMapper.toEntity(
|
|
31
|
+
organizationDto,
|
|
32
|
+
em ?? this.em,
|
|
33
|
+
...args
|
|
34
|
+
);
|
|
37
35
|
if (em) {
|
|
38
36
|
await em.persist(organization);
|
|
39
37
|
} else {
|
|
40
38
|
await this.em.persistAndFlush(organization);
|
|
41
39
|
}
|
|
42
|
-
return this.
|
|
40
|
+
return this.mappers.OrganizationMapper.toDto(organization);
|
|
43
41
|
}
|
|
44
42
|
async getOrganization(idDto, em) {
|
|
45
43
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -52,9 +50,9 @@ var BaseOrganizationService = class {
|
|
|
52
50
|
populate: ['id', '*']
|
|
53
51
|
}
|
|
54
52
|
);
|
|
55
|
-
return this.
|
|
53
|
+
return this.mappers.OrganizationMapper.toDto(organization);
|
|
56
54
|
}
|
|
57
|
-
async updateOrganization(organizationDto, em) {
|
|
55
|
+
async updateOrganization(organizationDto, em, ...args) {
|
|
58
56
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
59
57
|
this.openTelemetryCollector.info(
|
|
60
58
|
'Updating organization',
|
|
@@ -62,18 +60,17 @@ var BaseOrganizationService = class {
|
|
|
62
60
|
);
|
|
63
61
|
}
|
|
64
62
|
const updatedOrganization =
|
|
65
|
-
await this.
|
|
63
|
+
await this.mappers.UpdateOrganizationMapper.toEntity(
|
|
66
64
|
organizationDto,
|
|
67
|
-
em ?? this.em
|
|
65
|
+
em ?? this.em,
|
|
66
|
+
...args
|
|
68
67
|
);
|
|
69
68
|
if (em) {
|
|
70
69
|
await em.persist(updatedOrganization);
|
|
71
70
|
} else {
|
|
72
71
|
await this.em.persistAndFlush(updatedOrganization);
|
|
73
72
|
}
|
|
74
|
-
return this.
|
|
75
|
-
updatedOrganization
|
|
76
|
-
);
|
|
73
|
+
return this.mappers.OrganizationMapper.toDto(updatedOrganization);
|
|
77
74
|
}
|
|
78
75
|
async deleteOrganization(idDto, em) {
|
|
79
76
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -89,9 +86,7 @@ var BaseOrganizationService = class {
|
|
|
89
86
|
|
|
90
87
|
// services/permission.service.ts
|
|
91
88
|
import { evaluateTelemetryOptions as evaluateTelemetryOptions2 } from '@forklaunch/core/http';
|
|
92
|
-
import { transformIntoInternalMapper as transformIntoInternalMapper2 } from '@forklaunch/internal';
|
|
93
89
|
var BasePermissionService = class {
|
|
94
|
-
_mappers;
|
|
95
90
|
evaluatedTelemetryOptions;
|
|
96
91
|
em;
|
|
97
92
|
roleServiceFactory;
|
|
@@ -111,7 +106,6 @@ var BasePermissionService = class {
|
|
|
111
106
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
112
107
|
this.schemaValidator = schemaValidator;
|
|
113
108
|
this.mappers = mappers;
|
|
114
|
-
this._mappers = transformIntoInternalMapper2(mappers, schemaValidator);
|
|
115
109
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
116
110
|
? evaluateTelemetryOptions2(options.telemetry).enabled
|
|
117
111
|
: {
|
|
@@ -145,7 +139,7 @@ var BasePermissionService = class {
|
|
|
145
139
|
(await this.roleServiceFactory().getBatchRoles(roles, em)).map(
|
|
146
140
|
async (role) => {
|
|
147
141
|
return (em ?? this.em).merge(
|
|
148
|
-
await this.
|
|
142
|
+
await this.mappers.RoleEntityMapper.toEntity(
|
|
149
143
|
role,
|
|
150
144
|
em ?? this.em
|
|
151
145
|
)
|
|
@@ -157,19 +151,20 @@ var BasePermissionService = class {
|
|
|
157
151
|
}
|
|
158
152
|
// end: global helper functions
|
|
159
153
|
// start: createPermission helper functions
|
|
160
|
-
async
|
|
154
|
+
async createPermissionEntity({ permission, addToRoles }) {
|
|
161
155
|
let roles = [];
|
|
162
156
|
if (addToRoles) {
|
|
163
157
|
roles = await this.updateRolesWithPermissions(addToRoles, [permission]);
|
|
164
158
|
}
|
|
165
159
|
return { permission, roles };
|
|
166
160
|
}
|
|
167
|
-
async
|
|
161
|
+
async extractCreatePermissionEntityToEntityData(permissionDto, em, ...args) {
|
|
168
162
|
return {
|
|
169
163
|
permission: (em ?? this.em).merge(
|
|
170
|
-
await this.
|
|
164
|
+
await this.mappers.CreatePermissionMapper.toEntity(
|
|
171
165
|
permissionDto,
|
|
172
|
-
em ?? this.em
|
|
166
|
+
em ?? this.em,
|
|
167
|
+
...args
|
|
173
168
|
)
|
|
174
169
|
),
|
|
175
170
|
addToRoles: permissionDto.addToRolesIds
|
|
@@ -178,22 +173,26 @@ var BasePermissionService = class {
|
|
|
178
173
|
};
|
|
179
174
|
}
|
|
180
175
|
// end: createPermission helper functions
|
|
181
|
-
async createPermission(
|
|
176
|
+
async createPermission(createPermissionEntity, em, ...args) {
|
|
182
177
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
183
178
|
this.openTelemetryCollector.info(
|
|
184
179
|
'Creating permission',
|
|
185
|
-
|
|
180
|
+
createPermissionEntity
|
|
186
181
|
);
|
|
187
182
|
}
|
|
188
|
-
const { permission, roles } = await this.
|
|
189
|
-
await this.
|
|
183
|
+
const { permission, roles } = await this.createPermissionEntity(
|
|
184
|
+
await this.extractCreatePermissionEntityToEntityData(
|
|
185
|
+
createPermissionEntity,
|
|
186
|
+
em,
|
|
187
|
+
...args
|
|
188
|
+
)
|
|
190
189
|
);
|
|
191
190
|
if (em) {
|
|
192
191
|
await em.persist([permission, ...roles]);
|
|
193
192
|
} else {
|
|
194
193
|
await this.em.persistAndFlush([permission, ...roles]);
|
|
195
194
|
}
|
|
196
|
-
return this.
|
|
195
|
+
return this.mappers.PermissionMapper.toDto(permission);
|
|
197
196
|
}
|
|
198
197
|
async createBatchPermissions(permissionDtos, em) {
|
|
199
198
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -204,13 +203,27 @@ var BasePermissionService = class {
|
|
|
204
203
|
}
|
|
205
204
|
const rolesCache = {};
|
|
206
205
|
const permissions = [];
|
|
207
|
-
permissionDtos.map(async (
|
|
208
|
-
const { permission, roles } = await this.
|
|
209
|
-
await this.
|
|
210
|
-
|
|
206
|
+
permissionDtos.map(async (createPermissionEntity) => {
|
|
207
|
+
const { permission, roles } = await this.createPermissionEntity(
|
|
208
|
+
await this.extractCreatePermissionEntityToEntityData(
|
|
209
|
+
createPermissionEntity,
|
|
211
210
|
em
|
|
212
211
|
)
|
|
213
212
|
);
|
|
213
|
+
await Promise.all(
|
|
214
|
+
roles.map(async (role) => {
|
|
215
|
+
if (role.permissions.isInitialized()) {
|
|
216
|
+
return role.permissions.init();
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
);
|
|
220
|
+
await Promise.all(
|
|
221
|
+
roles.map(async (role) => {
|
|
222
|
+
if (role.permissions.isInitialized()) {
|
|
223
|
+
return role.permissions.init();
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
);
|
|
214
227
|
roles.forEach((role) => {
|
|
215
228
|
if (
|
|
216
229
|
rolesCache[role.id] &&
|
|
@@ -235,7 +248,7 @@ var BasePermissionService = class {
|
|
|
235
248
|
}
|
|
236
249
|
return Promise.all(
|
|
237
250
|
permissions.map(async (permission) =>
|
|
238
|
-
this.
|
|
251
|
+
this.mappers.PermissionMapper.toDto(permission)
|
|
239
252
|
)
|
|
240
253
|
);
|
|
241
254
|
}
|
|
@@ -244,7 +257,7 @@ var BasePermissionService = class {
|
|
|
244
257
|
this.openTelemetryCollector.info('Getting permission', idDto);
|
|
245
258
|
}
|
|
246
259
|
const permission = await (em ?? this.em).findOneOrFail('Permission', idDto);
|
|
247
|
-
return this.
|
|
260
|
+
return this.mappers.PermissionMapper.toDto(permission);
|
|
248
261
|
}
|
|
249
262
|
async getBatchPermissions(idsDto, em) {
|
|
250
263
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -252,17 +265,17 @@ var BasePermissionService = class {
|
|
|
252
265
|
}
|
|
253
266
|
return Promise.all(
|
|
254
267
|
(await (em ?? this.em).find('Permission', idsDto)).map((permission) =>
|
|
255
|
-
this.
|
|
268
|
+
this.mappers.PermissionMapper.toDto(permission)
|
|
256
269
|
)
|
|
257
270
|
);
|
|
258
271
|
}
|
|
259
272
|
// start: updatePermission helper functions
|
|
260
|
-
updatePermissionDto = async (permissionDto, em) => {
|
|
261
|
-
const permission =
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
273
|
+
updatePermissionDto = async (permissionDto, em, ...args) => {
|
|
274
|
+
const permission = await this.mappers.UpdatePermissionMapper.toEntity(
|
|
275
|
+
permissionDto,
|
|
276
|
+
em ?? this.em,
|
|
277
|
+
...args
|
|
278
|
+
);
|
|
266
279
|
const addToRoles = permissionDto.addToRolesIds
|
|
267
280
|
? await this.getBatchRoles({ ids: permissionDto.addToRolesIds }, em)
|
|
268
281
|
: [];
|
|
@@ -293,7 +306,7 @@ var BasePermissionService = class {
|
|
|
293
306
|
} else {
|
|
294
307
|
await this.em.persistAndFlush(entities);
|
|
295
308
|
}
|
|
296
|
-
return this.
|
|
309
|
+
return this.mappers.PermissionMapper.toDto(permission);
|
|
297
310
|
}
|
|
298
311
|
async updateBatchPermissions(permissionDtos, em) {
|
|
299
312
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -333,7 +346,7 @@ var BasePermissionService = class {
|
|
|
333
346
|
});
|
|
334
347
|
return Promise.all(
|
|
335
348
|
permissions.map((permission) =>
|
|
336
|
-
this.
|
|
349
|
+
this.mappers.PermissionMapper.toDto(permission)
|
|
337
350
|
)
|
|
338
351
|
);
|
|
339
352
|
}
|
|
@@ -355,9 +368,7 @@ var BasePermissionService = class {
|
|
|
355
368
|
|
|
356
369
|
// services/role.service.ts
|
|
357
370
|
import { evaluateTelemetryOptions as evaluateTelemetryOptions3 } from '@forklaunch/core/http';
|
|
358
|
-
import { transformIntoInternalMapper as transformIntoInternalMapper3 } from '@forklaunch/internal';
|
|
359
371
|
var BaseRoleService = class {
|
|
360
|
-
_mappers;
|
|
361
372
|
evaluatedTelemetryOptions;
|
|
362
373
|
em;
|
|
363
374
|
openTelemetryCollector;
|
|
@@ -368,7 +379,6 @@ var BaseRoleService = class {
|
|
|
368
379
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
369
380
|
this.schemaValidator = schemaValidator;
|
|
370
381
|
this.mappers = mappers;
|
|
371
|
-
this._mappers = transformIntoInternalMapper3(mappers, schemaValidator);
|
|
372
382
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
373
383
|
? evaluateTelemetryOptions3(options.telemetry).enabled
|
|
374
384
|
: {
|
|
@@ -377,31 +387,29 @@ var BaseRoleService = class {
|
|
|
377
387
|
tracing: false
|
|
378
388
|
};
|
|
379
389
|
}
|
|
380
|
-
async createRole(roleDto, em) {
|
|
390
|
+
async createRole(roleDto, em, ...args) {
|
|
381
391
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
382
392
|
this.openTelemetryCollector.info('Creating role', roleDto);
|
|
383
393
|
}
|
|
384
|
-
const role = await this.
|
|
394
|
+
const role = await this.mappers.CreateRoleMapper.toEntity(
|
|
385
395
|
roleDto,
|
|
386
|
-
em ?? this.em
|
|
396
|
+
em ?? this.em,
|
|
397
|
+
...args
|
|
387
398
|
);
|
|
388
399
|
if (em) {
|
|
389
400
|
await em.persist(role);
|
|
390
401
|
} else {
|
|
391
402
|
await this.em.persistAndFlush(role);
|
|
392
403
|
}
|
|
393
|
-
return this.
|
|
404
|
+
return this.mappers.RoleMapper.toDto(role);
|
|
394
405
|
}
|
|
395
|
-
async createBatchRoles(roleDtos, em) {
|
|
406
|
+
async createBatchRoles(roleDtos, em, ...args) {
|
|
396
407
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
397
408
|
this.openTelemetryCollector.info('Creating batch roles', roleDtos);
|
|
398
409
|
}
|
|
399
410
|
const roles = await Promise.all(
|
|
400
411
|
roleDtos.map(async (roleDto) =>
|
|
401
|
-
this.
|
|
402
|
-
roleDto,
|
|
403
|
-
em ?? this.em
|
|
404
|
-
)
|
|
412
|
+
this.mappers.CreateRoleMapper.toEntity(roleDto, em ?? this.em, ...args)
|
|
405
413
|
)
|
|
406
414
|
);
|
|
407
415
|
if (em) {
|
|
@@ -410,7 +418,7 @@ var BaseRoleService = class {
|
|
|
410
418
|
await this.em.persistAndFlush(roles);
|
|
411
419
|
}
|
|
412
420
|
return Promise.all(
|
|
413
|
-
roles.map((role) => this.
|
|
421
|
+
roles.map((role) => this.mappers.RoleMapper.toDto(role))
|
|
414
422
|
);
|
|
415
423
|
}
|
|
416
424
|
async getRole({ id }, em) {
|
|
@@ -420,7 +428,7 @@ var BaseRoleService = class {
|
|
|
420
428
|
const role = await (em ?? this.em).findOneOrFail('Role', id, {
|
|
421
429
|
populate: ['id', '*']
|
|
422
430
|
});
|
|
423
|
-
return this.
|
|
431
|
+
return this.mappers.RoleMapper.toDto(role);
|
|
424
432
|
}
|
|
425
433
|
async getBatchRoles({ ids }, em) {
|
|
426
434
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -437,34 +445,32 @@ var BaseRoleService = class {
|
|
|
437
445
|
populate: ['id', '*']
|
|
438
446
|
}
|
|
439
447
|
)
|
|
440
|
-
).map((role) => this.
|
|
448
|
+
).map((role) => this.mappers.RoleMapper.toDto(role))
|
|
441
449
|
);
|
|
442
450
|
}
|
|
443
|
-
async updateRole(roleDto, em) {
|
|
451
|
+
async updateRole(roleDto, em, ...args) {
|
|
444
452
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
445
453
|
this.openTelemetryCollector.info('Updating role', roleDto);
|
|
446
454
|
}
|
|
447
|
-
const role = await this.
|
|
455
|
+
const role = await this.mappers.UpdateRoleMapper.toEntity(
|
|
448
456
|
roleDto,
|
|
449
|
-
em ?? this.em
|
|
457
|
+
em ?? this.em,
|
|
458
|
+
...args
|
|
450
459
|
);
|
|
451
460
|
if (em) {
|
|
452
461
|
await em.persist(role);
|
|
453
462
|
} else {
|
|
454
463
|
await this.em.persistAndFlush(role);
|
|
455
464
|
}
|
|
456
|
-
return this.
|
|
465
|
+
return this.mappers.RoleMapper.toDto(role);
|
|
457
466
|
}
|
|
458
|
-
async updateBatchRoles(roleDtos, em) {
|
|
467
|
+
async updateBatchRoles(roleDtos, em, ...args) {
|
|
459
468
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
460
469
|
this.openTelemetryCollector.info('Updating batch roles', roleDtos);
|
|
461
470
|
}
|
|
462
471
|
const roles = await Promise.all(
|
|
463
472
|
roleDtos.map(async (roleDto) =>
|
|
464
|
-
this.
|
|
465
|
-
roleDto,
|
|
466
|
-
em ?? this.em
|
|
467
|
-
)
|
|
473
|
+
this.mappers.UpdateRoleMapper.toEntity(roleDto, em ?? this.em, ...args)
|
|
468
474
|
)
|
|
469
475
|
);
|
|
470
476
|
if (em) {
|
|
@@ -473,7 +479,7 @@ var BaseRoleService = class {
|
|
|
473
479
|
await this.em.persistAndFlush(roles);
|
|
474
480
|
}
|
|
475
481
|
return Promise.all(
|
|
476
|
-
roles.map((role) => this.
|
|
482
|
+
roles.map((role) => this.mappers.RoleMapper.toDto(role))
|
|
477
483
|
);
|
|
478
484
|
}
|
|
479
485
|
async deleteRole(idDto, em) {
|
|
@@ -492,8 +498,15 @@ var BaseRoleService = class {
|
|
|
492
498
|
|
|
493
499
|
// services/user.service.ts
|
|
494
500
|
import { evaluateTelemetryOptions as evaluateTelemetryOptions4 } from '@forklaunch/core/http';
|
|
495
|
-
import { transformIntoInternalMapper as transformIntoInternalMapper4 } from '@forklaunch/internal';
|
|
496
501
|
var BaseUserService = class {
|
|
502
|
+
evaluatedTelemetryOptions;
|
|
503
|
+
em;
|
|
504
|
+
passwordEncryptionPublicKeyPath;
|
|
505
|
+
roleServiceFactory;
|
|
506
|
+
organizationServiceFactory;
|
|
507
|
+
openTelemetryCollector;
|
|
508
|
+
schemaValidator;
|
|
509
|
+
mappers;
|
|
497
510
|
constructor(
|
|
498
511
|
em,
|
|
499
512
|
passwordEncryptionPublicKeyPath,
|
|
@@ -504,7 +517,6 @@ var BaseUserService = class {
|
|
|
504
517
|
mappers,
|
|
505
518
|
options
|
|
506
519
|
) {
|
|
507
|
-
this.options = options;
|
|
508
520
|
this.em = em;
|
|
509
521
|
this.passwordEncryptionPublicKeyPath = passwordEncryptionPublicKeyPath;
|
|
510
522
|
this.roleServiceFactory = roleServiceFactory;
|
|
@@ -512,7 +524,6 @@ var BaseUserService = class {
|
|
|
512
524
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
513
525
|
this.schemaValidator = schemaValidator;
|
|
514
526
|
this.mappers = mappers;
|
|
515
|
-
this._mappers = transformIntoInternalMapper4(mappers, schemaValidator);
|
|
516
527
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
517
528
|
? evaluateTelemetryOptions4(options.telemetry).enabled
|
|
518
529
|
: {
|
|
@@ -521,39 +532,32 @@ var BaseUserService = class {
|
|
|
521
532
|
tracing: false
|
|
522
533
|
};
|
|
523
534
|
}
|
|
524
|
-
|
|
525
|
-
evaluatedTelemetryOptions;
|
|
526
|
-
em;
|
|
527
|
-
passwordEncryptionPublicKeyPath;
|
|
528
|
-
roleServiceFactory;
|
|
529
|
-
organizationServiceFactory;
|
|
530
|
-
openTelemetryCollector;
|
|
531
|
-
schemaValidator;
|
|
532
|
-
mappers;
|
|
533
|
-
async createUser(userDto, em) {
|
|
535
|
+
async createUser(userDto, em, ...args) {
|
|
534
536
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
535
537
|
this.openTelemetryCollector.info('Creating user', userDto);
|
|
536
538
|
}
|
|
537
|
-
const user = await this.
|
|
539
|
+
const user = await this.mappers.CreateUserMapper.toEntity(
|
|
538
540
|
userDto,
|
|
539
|
-
em ?? this.em
|
|
541
|
+
em ?? this.em,
|
|
542
|
+
...args
|
|
540
543
|
);
|
|
541
544
|
if (em) {
|
|
542
545
|
await em.persist(user);
|
|
543
546
|
} else {
|
|
544
547
|
await this.em.persistAndFlush(user);
|
|
545
548
|
}
|
|
546
|
-
return this.
|
|
549
|
+
return this.mappers.UserMapper.toDto(user);
|
|
547
550
|
}
|
|
548
|
-
async createBatchUsers(userDtos, em) {
|
|
551
|
+
async createBatchUsers(userDtos, em, ...args) {
|
|
549
552
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
550
553
|
this.openTelemetryCollector.info('Creating batch users', userDtos);
|
|
551
554
|
}
|
|
552
555
|
const users = await Promise.all(
|
|
553
556
|
userDtos.map(async (createUserDto) =>
|
|
554
|
-
this.
|
|
557
|
+
this.mappers.CreateUserMapper.toEntity(
|
|
555
558
|
createUserDto,
|
|
556
|
-
em ?? this.em
|
|
559
|
+
em ?? this.em,
|
|
560
|
+
...args
|
|
557
561
|
)
|
|
558
562
|
)
|
|
559
563
|
);
|
|
@@ -563,7 +567,7 @@ var BaseUserService = class {
|
|
|
563
567
|
await this.em.persistAndFlush(users);
|
|
564
568
|
}
|
|
565
569
|
return Promise.all(
|
|
566
|
-
users.map((user) => this.
|
|
570
|
+
users.map((user) => this.mappers.UserMapper.toDto(user))
|
|
567
571
|
);
|
|
568
572
|
}
|
|
569
573
|
async getUser(idDto, em) {
|
|
@@ -573,7 +577,7 @@ var BaseUserService = class {
|
|
|
573
577
|
const user = await (em ?? this.em).findOneOrFail('User', idDto, {
|
|
574
578
|
populate: ['id', '*']
|
|
575
579
|
});
|
|
576
|
-
return this.
|
|
580
|
+
return this.mappers.UserMapper.toDto(user);
|
|
577
581
|
}
|
|
578
582
|
async getBatchUsers(idsDto, em) {
|
|
579
583
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -584,33 +588,35 @@ var BaseUserService = class {
|
|
|
584
588
|
await (em ?? this.em).find('User', idsDto, {
|
|
585
589
|
populate: ['id', '*']
|
|
586
590
|
})
|
|
587
|
-
).map((user) => this.
|
|
591
|
+
).map((user) => this.mappers.UserMapper.toDto(user))
|
|
588
592
|
);
|
|
589
593
|
}
|
|
590
|
-
async updateUser(userDto, em) {
|
|
594
|
+
async updateUser(userDto, em, ...args) {
|
|
591
595
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
592
596
|
this.openTelemetryCollector.info('Updating user', userDto);
|
|
593
597
|
}
|
|
594
|
-
const user = await this.
|
|
598
|
+
const user = await this.mappers.UpdateUserMapper.toEntity(
|
|
595
599
|
userDto,
|
|
596
|
-
em ?? this.em
|
|
600
|
+
em ?? this.em,
|
|
601
|
+
...args
|
|
597
602
|
);
|
|
598
603
|
if (em) {
|
|
599
604
|
await em.persist(user);
|
|
600
605
|
} else {
|
|
601
606
|
await this.em.persistAndFlush(user);
|
|
602
607
|
}
|
|
603
|
-
return this.
|
|
608
|
+
return this.mappers.UserMapper.toDto(user);
|
|
604
609
|
}
|
|
605
|
-
async updateBatchUsers(userDtos, em) {
|
|
610
|
+
async updateBatchUsers(userDtos, em, ...args) {
|
|
606
611
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
607
612
|
this.openTelemetryCollector.info('Updating batch users', userDtos);
|
|
608
613
|
}
|
|
609
614
|
const users = await Promise.all(
|
|
610
615
|
userDtos.map(async (updateUserDto) =>
|
|
611
|
-
this.
|
|
616
|
+
this.mappers.UpdateUserMapper.toEntity(
|
|
612
617
|
updateUserDto,
|
|
613
|
-
em ?? this.em
|
|
618
|
+
em ?? this.em,
|
|
619
|
+
...args
|
|
614
620
|
)
|
|
615
621
|
)
|
|
616
622
|
);
|
|
@@ -620,7 +626,7 @@ var BaseUserService = class {
|
|
|
620
626
|
await this.em.persistAndFlush(users);
|
|
621
627
|
}
|
|
622
628
|
return Promise.all(
|
|
623
|
-
users.map((user) => this.
|
|
629
|
+
users.map((user) => this.mappers.UserMapper.toDto(user))
|
|
624
630
|
);
|
|
625
631
|
}
|
|
626
632
|
async deleteUser(idDto, em) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/implementation-iam-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Billing basic implementation for forklaunch",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"lib/**"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@forklaunch/common": "^0.
|
|
40
|
-
"@forklaunch/core": "^0.
|
|
41
|
-
"@forklaunch/internal": "^0.
|
|
42
|
-
"@forklaunch/validator": "^0.
|
|
43
|
-
"@mikro-orm/core": "^6.
|
|
39
|
+
"@forklaunch/common": "^0.6.3",
|
|
40
|
+
"@forklaunch/core": "^0.14.3",
|
|
41
|
+
"@forklaunch/internal": "^0.3.3",
|
|
42
|
+
"@forklaunch/validator": "^0.10.3",
|
|
43
|
+
"@mikro-orm/core": "^6.5.1",
|
|
44
44
|
"@sinclair/typebox": "^0.34.40",
|
|
45
45
|
"ajv": "^8.17.1",
|
|
46
|
-
"zod": "^4.1.
|
|
47
|
-
"@forklaunch/interfaces-iam": "0.
|
|
46
|
+
"zod": "^4.1.5",
|
|
47
|
+
"@forklaunch/interfaces-iam": "0.6.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
50
|
+
"@typescript/native-preview": "7.0.0-dev.20250828.1",
|
|
51
51
|
"depcheck": "^1.4.7",
|
|
52
52
|
"prettier": "^3.6.2",
|
|
53
53
|
"typedoc": "^0.28.11"
|