@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.js
CHANGED
|
@@ -33,9 +33,8 @@ module.exports = __toCommonJS(services_exports);
|
|
|
33
33
|
|
|
34
34
|
// services/organization.service.ts
|
|
35
35
|
var import_http = require('@forklaunch/core/http');
|
|
36
|
-
var import_internal = require('@forklaunch/internal');
|
|
37
36
|
var BaseOrganizationService = class {
|
|
38
|
-
_mappers
|
|
37
|
+
// protected _mappers: InternalMapper<InstanceTypeRecord<typeof this.mappers>>;
|
|
39
38
|
evaluatedTelemetryOptions;
|
|
40
39
|
em;
|
|
41
40
|
openTelemetryCollector;
|
|
@@ -46,10 +45,6 @@ var BaseOrganizationService = class {
|
|
|
46
45
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
47
46
|
this.schemaValidator = schemaValidator;
|
|
48
47
|
this.mappers = mappers;
|
|
49
|
-
this._mappers = (0, import_internal.transformIntoInternalMapper)(
|
|
50
|
-
mappers,
|
|
51
|
-
schemaValidator
|
|
52
|
-
);
|
|
53
48
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
54
49
|
? (0, import_http.evaluateTelemetryOptions)(options.telemetry).enabled
|
|
55
50
|
: {
|
|
@@ -58,24 +53,24 @@ var BaseOrganizationService = class {
|
|
|
58
53
|
tracing: false
|
|
59
54
|
};
|
|
60
55
|
}
|
|
61
|
-
async createOrganization(organizationDto, em) {
|
|
56
|
+
async createOrganization(organizationDto, em, ...args) {
|
|
62
57
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
63
58
|
this.openTelemetryCollector.info(
|
|
64
59
|
'Creating organization',
|
|
65
60
|
organizationDto
|
|
66
61
|
);
|
|
67
62
|
}
|
|
68
|
-
const organization =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
const organization = await this.mappers.CreateOrganizationMapper.toEntity(
|
|
64
|
+
organizationDto,
|
|
65
|
+
em ?? this.em,
|
|
66
|
+
...args
|
|
67
|
+
);
|
|
73
68
|
if (em) {
|
|
74
69
|
await em.persist(organization);
|
|
75
70
|
} else {
|
|
76
71
|
await this.em.persistAndFlush(organization);
|
|
77
72
|
}
|
|
78
|
-
return this.
|
|
73
|
+
return this.mappers.OrganizationMapper.toDto(organization);
|
|
79
74
|
}
|
|
80
75
|
async getOrganization(idDto, em) {
|
|
81
76
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -88,9 +83,9 @@ var BaseOrganizationService = class {
|
|
|
88
83
|
populate: ['id', '*']
|
|
89
84
|
}
|
|
90
85
|
);
|
|
91
|
-
return this.
|
|
86
|
+
return this.mappers.OrganizationMapper.toDto(organization);
|
|
92
87
|
}
|
|
93
|
-
async updateOrganization(organizationDto, em) {
|
|
88
|
+
async updateOrganization(organizationDto, em, ...args) {
|
|
94
89
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
95
90
|
this.openTelemetryCollector.info(
|
|
96
91
|
'Updating organization',
|
|
@@ -98,18 +93,17 @@ var BaseOrganizationService = class {
|
|
|
98
93
|
);
|
|
99
94
|
}
|
|
100
95
|
const updatedOrganization =
|
|
101
|
-
await this.
|
|
96
|
+
await this.mappers.UpdateOrganizationMapper.toEntity(
|
|
102
97
|
organizationDto,
|
|
103
|
-
em ?? this.em
|
|
98
|
+
em ?? this.em,
|
|
99
|
+
...args
|
|
104
100
|
);
|
|
105
101
|
if (em) {
|
|
106
102
|
await em.persist(updatedOrganization);
|
|
107
103
|
} else {
|
|
108
104
|
await this.em.persistAndFlush(updatedOrganization);
|
|
109
105
|
}
|
|
110
|
-
return this.
|
|
111
|
-
updatedOrganization
|
|
112
|
-
);
|
|
106
|
+
return this.mappers.OrganizationMapper.toDto(updatedOrganization);
|
|
113
107
|
}
|
|
114
108
|
async deleteOrganization(idDto, em) {
|
|
115
109
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -125,9 +119,7 @@ var BaseOrganizationService = class {
|
|
|
125
119
|
|
|
126
120
|
// services/permission.service.ts
|
|
127
121
|
var import_http2 = require('@forklaunch/core/http');
|
|
128
|
-
var import_internal2 = require('@forklaunch/internal');
|
|
129
122
|
var BasePermissionService = class {
|
|
130
|
-
_mappers;
|
|
131
123
|
evaluatedTelemetryOptions;
|
|
132
124
|
em;
|
|
133
125
|
roleServiceFactory;
|
|
@@ -147,10 +139,6 @@ var BasePermissionService = class {
|
|
|
147
139
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
148
140
|
this.schemaValidator = schemaValidator;
|
|
149
141
|
this.mappers = mappers;
|
|
150
|
-
this._mappers = (0, import_internal2.transformIntoInternalMapper)(
|
|
151
|
-
mappers,
|
|
152
|
-
schemaValidator
|
|
153
|
-
);
|
|
154
142
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
155
143
|
? (0, import_http2.evaluateTelemetryOptions)(options.telemetry).enabled
|
|
156
144
|
: {
|
|
@@ -184,7 +172,7 @@ var BasePermissionService = class {
|
|
|
184
172
|
(await this.roleServiceFactory().getBatchRoles(roles, em)).map(
|
|
185
173
|
async (role) => {
|
|
186
174
|
return (em ?? this.em).merge(
|
|
187
|
-
await this.
|
|
175
|
+
await this.mappers.RoleEntityMapper.toEntity(
|
|
188
176
|
role,
|
|
189
177
|
em ?? this.em
|
|
190
178
|
)
|
|
@@ -196,19 +184,20 @@ var BasePermissionService = class {
|
|
|
196
184
|
}
|
|
197
185
|
// end: global helper functions
|
|
198
186
|
// start: createPermission helper functions
|
|
199
|
-
async
|
|
187
|
+
async createPermissionEntity({ permission, addToRoles }) {
|
|
200
188
|
let roles = [];
|
|
201
189
|
if (addToRoles) {
|
|
202
190
|
roles = await this.updateRolesWithPermissions(addToRoles, [permission]);
|
|
203
191
|
}
|
|
204
192
|
return { permission, roles };
|
|
205
193
|
}
|
|
206
|
-
async
|
|
194
|
+
async extractCreatePermissionEntityToEntityData(permissionDto, em, ...args) {
|
|
207
195
|
return {
|
|
208
196
|
permission: (em ?? this.em).merge(
|
|
209
|
-
await this.
|
|
197
|
+
await this.mappers.CreatePermissionMapper.toEntity(
|
|
210
198
|
permissionDto,
|
|
211
|
-
em ?? this.em
|
|
199
|
+
em ?? this.em,
|
|
200
|
+
...args
|
|
212
201
|
)
|
|
213
202
|
),
|
|
214
203
|
addToRoles: permissionDto.addToRolesIds
|
|
@@ -217,22 +206,26 @@ var BasePermissionService = class {
|
|
|
217
206
|
};
|
|
218
207
|
}
|
|
219
208
|
// end: createPermission helper functions
|
|
220
|
-
async createPermission(
|
|
209
|
+
async createPermission(createPermissionEntity, em, ...args) {
|
|
221
210
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
222
211
|
this.openTelemetryCollector.info(
|
|
223
212
|
'Creating permission',
|
|
224
|
-
|
|
213
|
+
createPermissionEntity
|
|
225
214
|
);
|
|
226
215
|
}
|
|
227
|
-
const { permission, roles } = await this.
|
|
228
|
-
await this.
|
|
216
|
+
const { permission, roles } = await this.createPermissionEntity(
|
|
217
|
+
await this.extractCreatePermissionEntityToEntityData(
|
|
218
|
+
createPermissionEntity,
|
|
219
|
+
em,
|
|
220
|
+
...args
|
|
221
|
+
)
|
|
229
222
|
);
|
|
230
223
|
if (em) {
|
|
231
224
|
await em.persist([permission, ...roles]);
|
|
232
225
|
} else {
|
|
233
226
|
await this.em.persistAndFlush([permission, ...roles]);
|
|
234
227
|
}
|
|
235
|
-
return this.
|
|
228
|
+
return this.mappers.PermissionMapper.toDto(permission);
|
|
236
229
|
}
|
|
237
230
|
async createBatchPermissions(permissionDtos, em) {
|
|
238
231
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -243,13 +236,27 @@ var BasePermissionService = class {
|
|
|
243
236
|
}
|
|
244
237
|
const rolesCache = {};
|
|
245
238
|
const permissions = [];
|
|
246
|
-
permissionDtos.map(async (
|
|
247
|
-
const { permission, roles } = await this.
|
|
248
|
-
await this.
|
|
249
|
-
|
|
239
|
+
permissionDtos.map(async (createPermissionEntity) => {
|
|
240
|
+
const { permission, roles } = await this.createPermissionEntity(
|
|
241
|
+
await this.extractCreatePermissionEntityToEntityData(
|
|
242
|
+
createPermissionEntity,
|
|
250
243
|
em
|
|
251
244
|
)
|
|
252
245
|
);
|
|
246
|
+
await Promise.all(
|
|
247
|
+
roles.map(async (role) => {
|
|
248
|
+
if (role.permissions.isInitialized()) {
|
|
249
|
+
return role.permissions.init();
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
);
|
|
253
|
+
await Promise.all(
|
|
254
|
+
roles.map(async (role) => {
|
|
255
|
+
if (role.permissions.isInitialized()) {
|
|
256
|
+
return role.permissions.init();
|
|
257
|
+
}
|
|
258
|
+
})
|
|
259
|
+
);
|
|
253
260
|
roles.forEach((role) => {
|
|
254
261
|
if (
|
|
255
262
|
rolesCache[role.id] &&
|
|
@@ -274,7 +281,7 @@ var BasePermissionService = class {
|
|
|
274
281
|
}
|
|
275
282
|
return Promise.all(
|
|
276
283
|
permissions.map(async (permission) =>
|
|
277
|
-
this.
|
|
284
|
+
this.mappers.PermissionMapper.toDto(permission)
|
|
278
285
|
)
|
|
279
286
|
);
|
|
280
287
|
}
|
|
@@ -283,7 +290,7 @@ var BasePermissionService = class {
|
|
|
283
290
|
this.openTelemetryCollector.info('Getting permission', idDto);
|
|
284
291
|
}
|
|
285
292
|
const permission = await (em ?? this.em).findOneOrFail('Permission', idDto);
|
|
286
|
-
return this.
|
|
293
|
+
return this.mappers.PermissionMapper.toDto(permission);
|
|
287
294
|
}
|
|
288
295
|
async getBatchPermissions(idsDto, em) {
|
|
289
296
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -291,17 +298,17 @@ var BasePermissionService = class {
|
|
|
291
298
|
}
|
|
292
299
|
return Promise.all(
|
|
293
300
|
(await (em ?? this.em).find('Permission', idsDto)).map((permission) =>
|
|
294
|
-
this.
|
|
301
|
+
this.mappers.PermissionMapper.toDto(permission)
|
|
295
302
|
)
|
|
296
303
|
);
|
|
297
304
|
}
|
|
298
305
|
// start: updatePermission helper functions
|
|
299
|
-
updatePermissionDto = async (permissionDto, em) => {
|
|
300
|
-
const permission =
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
306
|
+
updatePermissionDto = async (permissionDto, em, ...args) => {
|
|
307
|
+
const permission = await this.mappers.UpdatePermissionMapper.toEntity(
|
|
308
|
+
permissionDto,
|
|
309
|
+
em ?? this.em,
|
|
310
|
+
...args
|
|
311
|
+
);
|
|
305
312
|
const addToRoles = permissionDto.addToRolesIds
|
|
306
313
|
? await this.getBatchRoles({ ids: permissionDto.addToRolesIds }, em)
|
|
307
314
|
: [];
|
|
@@ -332,7 +339,7 @@ var BasePermissionService = class {
|
|
|
332
339
|
} else {
|
|
333
340
|
await this.em.persistAndFlush(entities);
|
|
334
341
|
}
|
|
335
|
-
return this.
|
|
342
|
+
return this.mappers.PermissionMapper.toDto(permission);
|
|
336
343
|
}
|
|
337
344
|
async updateBatchPermissions(permissionDtos, em) {
|
|
338
345
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -372,7 +379,7 @@ var BasePermissionService = class {
|
|
|
372
379
|
});
|
|
373
380
|
return Promise.all(
|
|
374
381
|
permissions.map((permission) =>
|
|
375
|
-
this.
|
|
382
|
+
this.mappers.PermissionMapper.toDto(permission)
|
|
376
383
|
)
|
|
377
384
|
);
|
|
378
385
|
}
|
|
@@ -394,9 +401,7 @@ var BasePermissionService = class {
|
|
|
394
401
|
|
|
395
402
|
// services/role.service.ts
|
|
396
403
|
var import_http3 = require('@forklaunch/core/http');
|
|
397
|
-
var import_internal3 = require('@forklaunch/internal');
|
|
398
404
|
var BaseRoleService = class {
|
|
399
|
-
_mappers;
|
|
400
405
|
evaluatedTelemetryOptions;
|
|
401
406
|
em;
|
|
402
407
|
openTelemetryCollector;
|
|
@@ -407,10 +412,6 @@ var BaseRoleService = class {
|
|
|
407
412
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
408
413
|
this.schemaValidator = schemaValidator;
|
|
409
414
|
this.mappers = mappers;
|
|
410
|
-
this._mappers = (0, import_internal3.transformIntoInternalMapper)(
|
|
411
|
-
mappers,
|
|
412
|
-
schemaValidator
|
|
413
|
-
);
|
|
414
415
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
415
416
|
? (0, import_http3.evaluateTelemetryOptions)(options.telemetry).enabled
|
|
416
417
|
: {
|
|
@@ -419,31 +420,29 @@ var BaseRoleService = class {
|
|
|
419
420
|
tracing: false
|
|
420
421
|
};
|
|
421
422
|
}
|
|
422
|
-
async createRole(roleDto, em) {
|
|
423
|
+
async createRole(roleDto, em, ...args) {
|
|
423
424
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
424
425
|
this.openTelemetryCollector.info('Creating role', roleDto);
|
|
425
426
|
}
|
|
426
|
-
const role = await this.
|
|
427
|
+
const role = await this.mappers.CreateRoleMapper.toEntity(
|
|
427
428
|
roleDto,
|
|
428
|
-
em ?? this.em
|
|
429
|
+
em ?? this.em,
|
|
430
|
+
...args
|
|
429
431
|
);
|
|
430
432
|
if (em) {
|
|
431
433
|
await em.persist(role);
|
|
432
434
|
} else {
|
|
433
435
|
await this.em.persistAndFlush(role);
|
|
434
436
|
}
|
|
435
|
-
return this.
|
|
437
|
+
return this.mappers.RoleMapper.toDto(role);
|
|
436
438
|
}
|
|
437
|
-
async createBatchRoles(roleDtos, em) {
|
|
439
|
+
async createBatchRoles(roleDtos, em, ...args) {
|
|
438
440
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
439
441
|
this.openTelemetryCollector.info('Creating batch roles', roleDtos);
|
|
440
442
|
}
|
|
441
443
|
const roles = await Promise.all(
|
|
442
444
|
roleDtos.map(async (roleDto) =>
|
|
443
|
-
this.
|
|
444
|
-
roleDto,
|
|
445
|
-
em ?? this.em
|
|
446
|
-
)
|
|
445
|
+
this.mappers.CreateRoleMapper.toEntity(roleDto, em ?? this.em, ...args)
|
|
447
446
|
)
|
|
448
447
|
);
|
|
449
448
|
if (em) {
|
|
@@ -452,7 +451,7 @@ var BaseRoleService = class {
|
|
|
452
451
|
await this.em.persistAndFlush(roles);
|
|
453
452
|
}
|
|
454
453
|
return Promise.all(
|
|
455
|
-
roles.map((role) => this.
|
|
454
|
+
roles.map((role) => this.mappers.RoleMapper.toDto(role))
|
|
456
455
|
);
|
|
457
456
|
}
|
|
458
457
|
async getRole({ id }, em) {
|
|
@@ -462,7 +461,7 @@ var BaseRoleService = class {
|
|
|
462
461
|
const role = await (em ?? this.em).findOneOrFail('Role', id, {
|
|
463
462
|
populate: ['id', '*']
|
|
464
463
|
});
|
|
465
|
-
return this.
|
|
464
|
+
return this.mappers.RoleMapper.toDto(role);
|
|
466
465
|
}
|
|
467
466
|
async getBatchRoles({ ids }, em) {
|
|
468
467
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -479,34 +478,32 @@ var BaseRoleService = class {
|
|
|
479
478
|
populate: ['id', '*']
|
|
480
479
|
}
|
|
481
480
|
)
|
|
482
|
-
).map((role) => this.
|
|
481
|
+
).map((role) => this.mappers.RoleMapper.toDto(role))
|
|
483
482
|
);
|
|
484
483
|
}
|
|
485
|
-
async updateRole(roleDto, em) {
|
|
484
|
+
async updateRole(roleDto, em, ...args) {
|
|
486
485
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
487
486
|
this.openTelemetryCollector.info('Updating role', roleDto);
|
|
488
487
|
}
|
|
489
|
-
const role = await this.
|
|
488
|
+
const role = await this.mappers.UpdateRoleMapper.toEntity(
|
|
490
489
|
roleDto,
|
|
491
|
-
em ?? this.em
|
|
490
|
+
em ?? this.em,
|
|
491
|
+
...args
|
|
492
492
|
);
|
|
493
493
|
if (em) {
|
|
494
494
|
await em.persist(role);
|
|
495
495
|
} else {
|
|
496
496
|
await this.em.persistAndFlush(role);
|
|
497
497
|
}
|
|
498
|
-
return this.
|
|
498
|
+
return this.mappers.RoleMapper.toDto(role);
|
|
499
499
|
}
|
|
500
|
-
async updateBatchRoles(roleDtos, em) {
|
|
500
|
+
async updateBatchRoles(roleDtos, em, ...args) {
|
|
501
501
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
502
502
|
this.openTelemetryCollector.info('Updating batch roles', roleDtos);
|
|
503
503
|
}
|
|
504
504
|
const roles = await Promise.all(
|
|
505
505
|
roleDtos.map(async (roleDto) =>
|
|
506
|
-
this.
|
|
507
|
-
roleDto,
|
|
508
|
-
em ?? this.em
|
|
509
|
-
)
|
|
506
|
+
this.mappers.UpdateRoleMapper.toEntity(roleDto, em ?? this.em, ...args)
|
|
510
507
|
)
|
|
511
508
|
);
|
|
512
509
|
if (em) {
|
|
@@ -515,7 +512,7 @@ var BaseRoleService = class {
|
|
|
515
512
|
await this.em.persistAndFlush(roles);
|
|
516
513
|
}
|
|
517
514
|
return Promise.all(
|
|
518
|
-
roles.map((role) => this.
|
|
515
|
+
roles.map((role) => this.mappers.RoleMapper.toDto(role))
|
|
519
516
|
);
|
|
520
517
|
}
|
|
521
518
|
async deleteRole(idDto, em) {
|
|
@@ -534,8 +531,15 @@ var BaseRoleService = class {
|
|
|
534
531
|
|
|
535
532
|
// services/user.service.ts
|
|
536
533
|
var import_http4 = require('@forklaunch/core/http');
|
|
537
|
-
var import_internal4 = require('@forklaunch/internal');
|
|
538
534
|
var BaseUserService = class {
|
|
535
|
+
evaluatedTelemetryOptions;
|
|
536
|
+
em;
|
|
537
|
+
passwordEncryptionPublicKeyPath;
|
|
538
|
+
roleServiceFactory;
|
|
539
|
+
organizationServiceFactory;
|
|
540
|
+
openTelemetryCollector;
|
|
541
|
+
schemaValidator;
|
|
542
|
+
mappers;
|
|
539
543
|
constructor(
|
|
540
544
|
em,
|
|
541
545
|
passwordEncryptionPublicKeyPath,
|
|
@@ -546,7 +550,6 @@ var BaseUserService = class {
|
|
|
546
550
|
mappers,
|
|
547
551
|
options
|
|
548
552
|
) {
|
|
549
|
-
this.options = options;
|
|
550
553
|
this.em = em;
|
|
551
554
|
this.passwordEncryptionPublicKeyPath = passwordEncryptionPublicKeyPath;
|
|
552
555
|
this.roleServiceFactory = roleServiceFactory;
|
|
@@ -554,10 +557,6 @@ var BaseUserService = class {
|
|
|
554
557
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
555
558
|
this.schemaValidator = schemaValidator;
|
|
556
559
|
this.mappers = mappers;
|
|
557
|
-
this._mappers = (0, import_internal4.transformIntoInternalMapper)(
|
|
558
|
-
mappers,
|
|
559
|
-
schemaValidator
|
|
560
|
-
);
|
|
561
560
|
this.evaluatedTelemetryOptions = options?.telemetry
|
|
562
561
|
? (0, import_http4.evaluateTelemetryOptions)(options.telemetry).enabled
|
|
563
562
|
: {
|
|
@@ -566,39 +565,32 @@ var BaseUserService = class {
|
|
|
566
565
|
tracing: false
|
|
567
566
|
};
|
|
568
567
|
}
|
|
569
|
-
|
|
570
|
-
evaluatedTelemetryOptions;
|
|
571
|
-
em;
|
|
572
|
-
passwordEncryptionPublicKeyPath;
|
|
573
|
-
roleServiceFactory;
|
|
574
|
-
organizationServiceFactory;
|
|
575
|
-
openTelemetryCollector;
|
|
576
|
-
schemaValidator;
|
|
577
|
-
mappers;
|
|
578
|
-
async createUser(userDto, em) {
|
|
568
|
+
async createUser(userDto, em, ...args) {
|
|
579
569
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
580
570
|
this.openTelemetryCollector.info('Creating user', userDto);
|
|
581
571
|
}
|
|
582
|
-
const user = await this.
|
|
572
|
+
const user = await this.mappers.CreateUserMapper.toEntity(
|
|
583
573
|
userDto,
|
|
584
|
-
em ?? this.em
|
|
574
|
+
em ?? this.em,
|
|
575
|
+
...args
|
|
585
576
|
);
|
|
586
577
|
if (em) {
|
|
587
578
|
await em.persist(user);
|
|
588
579
|
} else {
|
|
589
580
|
await this.em.persistAndFlush(user);
|
|
590
581
|
}
|
|
591
|
-
return this.
|
|
582
|
+
return this.mappers.UserMapper.toDto(user);
|
|
592
583
|
}
|
|
593
|
-
async createBatchUsers(userDtos, em) {
|
|
584
|
+
async createBatchUsers(userDtos, em, ...args) {
|
|
594
585
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
595
586
|
this.openTelemetryCollector.info('Creating batch users', userDtos);
|
|
596
587
|
}
|
|
597
588
|
const users = await Promise.all(
|
|
598
589
|
userDtos.map(async (createUserDto) =>
|
|
599
|
-
this.
|
|
590
|
+
this.mappers.CreateUserMapper.toEntity(
|
|
600
591
|
createUserDto,
|
|
601
|
-
em ?? this.em
|
|
592
|
+
em ?? this.em,
|
|
593
|
+
...args
|
|
602
594
|
)
|
|
603
595
|
)
|
|
604
596
|
);
|
|
@@ -608,7 +600,7 @@ var BaseUserService = class {
|
|
|
608
600
|
await this.em.persistAndFlush(users);
|
|
609
601
|
}
|
|
610
602
|
return Promise.all(
|
|
611
|
-
users.map((user) => this.
|
|
603
|
+
users.map((user) => this.mappers.UserMapper.toDto(user))
|
|
612
604
|
);
|
|
613
605
|
}
|
|
614
606
|
async getUser(idDto, em) {
|
|
@@ -618,7 +610,7 @@ var BaseUserService = class {
|
|
|
618
610
|
const user = await (em ?? this.em).findOneOrFail('User', idDto, {
|
|
619
611
|
populate: ['id', '*']
|
|
620
612
|
});
|
|
621
|
-
return this.
|
|
613
|
+
return this.mappers.UserMapper.toDto(user);
|
|
622
614
|
}
|
|
623
615
|
async getBatchUsers(idsDto, em) {
|
|
624
616
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -629,33 +621,35 @@ var BaseUserService = class {
|
|
|
629
621
|
await (em ?? this.em).find('User', idsDto, {
|
|
630
622
|
populate: ['id', '*']
|
|
631
623
|
})
|
|
632
|
-
).map((user) => this.
|
|
624
|
+
).map((user) => this.mappers.UserMapper.toDto(user))
|
|
633
625
|
);
|
|
634
626
|
}
|
|
635
|
-
async updateUser(userDto, em) {
|
|
627
|
+
async updateUser(userDto, em, ...args) {
|
|
636
628
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
637
629
|
this.openTelemetryCollector.info('Updating user', userDto);
|
|
638
630
|
}
|
|
639
|
-
const user = await this.
|
|
631
|
+
const user = await this.mappers.UpdateUserMapper.toEntity(
|
|
640
632
|
userDto,
|
|
641
|
-
em ?? this.em
|
|
633
|
+
em ?? this.em,
|
|
634
|
+
...args
|
|
642
635
|
);
|
|
643
636
|
if (em) {
|
|
644
637
|
await em.persist(user);
|
|
645
638
|
} else {
|
|
646
639
|
await this.em.persistAndFlush(user);
|
|
647
640
|
}
|
|
648
|
-
return this.
|
|
641
|
+
return this.mappers.UserMapper.toDto(user);
|
|
649
642
|
}
|
|
650
|
-
async updateBatchUsers(userDtos, em) {
|
|
643
|
+
async updateBatchUsers(userDtos, em, ...args) {
|
|
651
644
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
652
645
|
this.openTelemetryCollector.info('Updating batch users', userDtos);
|
|
653
646
|
}
|
|
654
647
|
const users = await Promise.all(
|
|
655
648
|
userDtos.map(async (updateUserDto) =>
|
|
656
|
-
this.
|
|
649
|
+
this.mappers.UpdateUserMapper.toEntity(
|
|
657
650
|
updateUserDto,
|
|
658
|
-
em ?? this.em
|
|
651
|
+
em ?? this.em,
|
|
652
|
+
...args
|
|
659
653
|
)
|
|
660
654
|
)
|
|
661
655
|
);
|
|
@@ -665,7 +659,7 @@ var BaseUserService = class {
|
|
|
665
659
|
await this.em.persistAndFlush(users);
|
|
666
660
|
}
|
|
667
661
|
return Promise.all(
|
|
668
|
-
users.map((user) => this.
|
|
662
|
+
users.map((user) => this.mappers.UserMapper.toDto(user))
|
|
669
663
|
);
|
|
670
664
|
}
|
|
671
665
|
async deleteUser(idDto, em) {
|