@forklaunch/implementation-iam-base 0.8.11 → 0.8.13
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/eject/services/user.service.ts +50 -16
- package/lib/services/index.d.mts +12 -4
- package/lib/services/index.d.ts +12 -4
- package/lib/services/index.js +28 -12
- package/lib/services/index.mjs +28 -12
- package/package.json +2 -2
|
@@ -120,11 +120,11 @@ export class BaseUserService<
|
|
|
120
120
|
async getOrganizationIdByUserId(
|
|
121
121
|
idDto: IdDto,
|
|
122
122
|
em?: EntityManager
|
|
123
|
-
): Promise<string> {
|
|
124
|
-
const user = await (em ?? this.em).
|
|
123
|
+
): Promise<string | undefined> {
|
|
124
|
+
const user = await (em ?? this.em).findOne('User', idDto, {
|
|
125
125
|
populate: ['id', 'organization']
|
|
126
126
|
});
|
|
127
|
-
return user
|
|
127
|
+
return user?.organization?.id;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
async getUser(
|
|
@@ -143,22 +143,26 @@ export class BaseUserService<
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
async getBatchUsers(
|
|
146
|
-
idsDto: IdsDto
|
|
146
|
+
idsDto: IdsDto & FilterQuery<MapperEntities['UserMapper']>,
|
|
147
147
|
em?: EntityManager
|
|
148
148
|
): Promise<MapperDomains['UserMapper'][]> {
|
|
149
149
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
150
150
|
this.openTelemetryCollector.info('Getting batch users', idsDto);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
// Build filter with organization constraint if provided
|
|
154
|
+
const filter: FilterQuery<MapperEntities['UserMapper']> = {
|
|
155
|
+
id: { $in: idsDto.ids },
|
|
156
|
+
...((idsDto as any).organization && {
|
|
157
|
+
organization: (idsDto as any).organization
|
|
158
|
+
})
|
|
159
|
+
};
|
|
160
|
+
|
|
153
161
|
return Promise.all(
|
|
154
162
|
(
|
|
155
|
-
await (em ?? this.em).find(
|
|
156
|
-
'
|
|
157
|
-
|
|
158
|
-
{
|
|
159
|
-
populate: ['id', '*']
|
|
160
|
-
}
|
|
161
|
-
)
|
|
163
|
+
await (em ?? this.em).find('User', filter, {
|
|
164
|
+
populate: ['id', '*']
|
|
165
|
+
})
|
|
162
166
|
).map((user) =>
|
|
163
167
|
this.mappers.UserMapper.toDto(user as MapperEntities['UserMapper'])
|
|
164
168
|
)
|
|
@@ -219,18 +223,48 @@ export class BaseUserService<
|
|
|
219
223
|
);
|
|
220
224
|
}
|
|
221
225
|
|
|
222
|
-
async deleteUser(
|
|
226
|
+
async deleteUser(
|
|
227
|
+
idDto: IdDto & { organization?: { id: string } } & FilterQuery<
|
|
228
|
+
MapperEntities['UserMapper']
|
|
229
|
+
> &
|
|
230
|
+
object,
|
|
231
|
+
em?: EntityManager
|
|
232
|
+
): Promise<void> {
|
|
223
233
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
224
234
|
this.openTelemetryCollector.info('Deleting user', idDto);
|
|
225
235
|
}
|
|
226
|
-
|
|
236
|
+
|
|
237
|
+
const filter = {
|
|
238
|
+
...idDto,
|
|
239
|
+
id: idDto.id,
|
|
240
|
+
...(idDto.organization && {
|
|
241
|
+
organization: idDto.organization
|
|
242
|
+
})
|
|
243
|
+
} as FilterQuery<MapperEntities['UserMapper']>;
|
|
244
|
+
|
|
245
|
+
await (em ?? this.em).nativeDelete('User', filter);
|
|
227
246
|
}
|
|
228
247
|
|
|
229
|
-
async deleteBatchUsers(
|
|
248
|
+
async deleteBatchUsers(
|
|
249
|
+
idsDto: IdsDto & { organization?: { id: string } } & FilterQuery<
|
|
250
|
+
MapperEntities['UserMapper']
|
|
251
|
+
> &
|
|
252
|
+
object,
|
|
253
|
+
em?: EntityManager
|
|
254
|
+
): Promise<void> {
|
|
230
255
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
231
256
|
this.openTelemetryCollector.info('Deleting batch users', idsDto);
|
|
232
257
|
}
|
|
233
|
-
|
|
258
|
+
|
|
259
|
+
const filter = {
|
|
260
|
+
...idsDto,
|
|
261
|
+
id: { $in: idsDto.ids },
|
|
262
|
+
...(idsDto.organization && {
|
|
263
|
+
organization: idsDto.organization
|
|
264
|
+
})
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
await (em ?? this.em).nativeDelete('User', filter);
|
|
234
268
|
}
|
|
235
269
|
|
|
236
270
|
async surfaceRoles(
|
|
@@ -256,6 +290,6 @@ export class BaseUserService<
|
|
|
256
290
|
});
|
|
257
291
|
}
|
|
258
292
|
const user = await this.getUser(idDto, em);
|
|
259
|
-
return user.roles.
|
|
293
|
+
return user.roles.flatMap((role) => role.permissions);
|
|
260
294
|
}
|
|
261
295
|
}
|
package/lib/services/index.d.mts
CHANGED
|
@@ -82,13 +82,21 @@ declare class BaseUserService<SchemaValidator extends AnySchemaValidator, Organi
|
|
|
82
82
|
});
|
|
83
83
|
createUser(userDto: CreateUserDto, em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper']>;
|
|
84
84
|
createBatchUsers(userDtos: CreateUserDto[], em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper'][]>;
|
|
85
|
-
getOrganizationIdByUserId(idDto: IdDto, em?: EntityManager): Promise<string>;
|
|
85
|
+
getOrganizationIdByUserId(idDto: IdDto, em?: EntityManager): Promise<string | undefined>;
|
|
86
86
|
getUser(idDto: IdDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper']>;
|
|
87
|
-
getBatchUsers(idsDto: IdsDto
|
|
87
|
+
getBatchUsers(idsDto: IdsDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper'][]>;
|
|
88
88
|
updateUser(userDto: UpdateUserDto, em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper']>;
|
|
89
89
|
updateBatchUsers(userDtos: UpdateUserDto[], em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper'][]>;
|
|
90
|
-
deleteUser(idDto: IdDto
|
|
91
|
-
|
|
90
|
+
deleteUser(idDto: IdDto & {
|
|
91
|
+
organization?: {
|
|
92
|
+
id: string;
|
|
93
|
+
};
|
|
94
|
+
} & FilterQuery<MapperEntities['UserMapper']> & object, em?: EntityManager): Promise<void>;
|
|
95
|
+
deleteBatchUsers(idsDto: IdsDto & {
|
|
96
|
+
organization?: {
|
|
97
|
+
id: string;
|
|
98
|
+
};
|
|
99
|
+
} & FilterQuery<MapperEntities['UserMapper']> & object, em?: EntityManager): Promise<void>;
|
|
92
100
|
surfaceRoles(idDto: IdDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper']['roles']>;
|
|
93
101
|
surfacePermissions(idDto: IdDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper']['roles'][0]['permissions']>;
|
|
94
102
|
}
|
package/lib/services/index.d.ts
CHANGED
|
@@ -82,13 +82,21 @@ declare class BaseUserService<SchemaValidator extends AnySchemaValidator, Organi
|
|
|
82
82
|
});
|
|
83
83
|
createUser(userDto: CreateUserDto, em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper']>;
|
|
84
84
|
createBatchUsers(userDtos: CreateUserDto[], em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper'][]>;
|
|
85
|
-
getOrganizationIdByUserId(idDto: IdDto, em?: EntityManager): Promise<string>;
|
|
85
|
+
getOrganizationIdByUserId(idDto: IdDto, em?: EntityManager): Promise<string | undefined>;
|
|
86
86
|
getUser(idDto: IdDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper']>;
|
|
87
|
-
getBatchUsers(idsDto: IdsDto
|
|
87
|
+
getBatchUsers(idsDto: IdsDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper'][]>;
|
|
88
88
|
updateUser(userDto: UpdateUserDto, em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper']>;
|
|
89
89
|
updateBatchUsers(userDtos: UpdateUserDto[], em?: EntityManager, ...args: unknown[]): Promise<MapperDomains['UserMapper'][]>;
|
|
90
|
-
deleteUser(idDto: IdDto
|
|
91
|
-
|
|
90
|
+
deleteUser(idDto: IdDto & {
|
|
91
|
+
organization?: {
|
|
92
|
+
id: string;
|
|
93
|
+
};
|
|
94
|
+
} & FilterQuery<MapperEntities['UserMapper']> & object, em?: EntityManager): Promise<void>;
|
|
95
|
+
deleteBatchUsers(idsDto: IdsDto & {
|
|
96
|
+
organization?: {
|
|
97
|
+
id: string;
|
|
98
|
+
};
|
|
99
|
+
} & FilterQuery<MapperEntities['UserMapper']> & object, em?: EntityManager): Promise<void>;
|
|
92
100
|
surfaceRoles(idDto: IdDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper']['roles']>;
|
|
93
101
|
surfacePermissions(idDto: IdDto & FilterQuery<MapperEntities['UserMapper']>, em?: EntityManager): Promise<MapperDomains['UserMapper']['roles'][0]['permissions']>;
|
|
94
102
|
}
|
package/lib/services/index.js
CHANGED
|
@@ -572,10 +572,10 @@ var BaseUserService = class {
|
|
|
572
572
|
);
|
|
573
573
|
}
|
|
574
574
|
async getOrganizationIdByUserId(idDto, em) {
|
|
575
|
-
const user = await (em ?? this.em).
|
|
575
|
+
const user = await (em ?? this.em).findOne("User", idDto, {
|
|
576
576
|
populate: ["id", "organization"]
|
|
577
577
|
});
|
|
578
|
-
return user
|
|
578
|
+
return user?.organization?.id;
|
|
579
579
|
}
|
|
580
580
|
async getUser(idDto, em) {
|
|
581
581
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -590,14 +590,16 @@ var BaseUserService = class {
|
|
|
590
590
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
591
591
|
this.openTelemetryCollector.info("Getting batch users", idsDto);
|
|
592
592
|
}
|
|
593
|
+
const filter = {
|
|
594
|
+
id: { $in: idsDto.ids },
|
|
595
|
+
...idsDto.organization && {
|
|
596
|
+
organization: idsDto.organization
|
|
597
|
+
}
|
|
598
|
+
};
|
|
593
599
|
return Promise.all(
|
|
594
|
-
(await (em ?? this.em).find(
|
|
595
|
-
"
|
|
596
|
-
|
|
597
|
-
{
|
|
598
|
-
populate: ["id", "*"]
|
|
599
|
-
}
|
|
600
|
-
)).map(
|
|
600
|
+
(await (em ?? this.em).find("User", filter, {
|
|
601
|
+
populate: ["id", "*"]
|
|
602
|
+
})).map(
|
|
601
603
|
(user) => this.mappers.UserMapper.toDto(user)
|
|
602
604
|
)
|
|
603
605
|
);
|
|
@@ -644,13 +646,27 @@ var BaseUserService = class {
|
|
|
644
646
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
645
647
|
this.openTelemetryCollector.info("Deleting user", idDto);
|
|
646
648
|
}
|
|
647
|
-
|
|
649
|
+
const filter = {
|
|
650
|
+
...idDto,
|
|
651
|
+
id: idDto.id,
|
|
652
|
+
...idDto.organization && {
|
|
653
|
+
organization: idDto.organization
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
await (em ?? this.em).nativeDelete("User", filter);
|
|
648
657
|
}
|
|
649
658
|
async deleteBatchUsers(idsDto, em) {
|
|
650
659
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
651
660
|
this.openTelemetryCollector.info("Deleting batch users", idsDto);
|
|
652
661
|
}
|
|
653
|
-
|
|
662
|
+
const filter = {
|
|
663
|
+
...idsDto,
|
|
664
|
+
id: { $in: idsDto.ids },
|
|
665
|
+
...idsDto.organization && {
|
|
666
|
+
organization: idsDto.organization
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
await (em ?? this.em).nativeDelete("User", filter);
|
|
654
670
|
}
|
|
655
671
|
async surfaceRoles(idDto, em) {
|
|
656
672
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -668,7 +684,7 @@ var BaseUserService = class {
|
|
|
668
684
|
});
|
|
669
685
|
}
|
|
670
686
|
const user = await this.getUser(idDto, em);
|
|
671
|
-
return user.roles.
|
|
687
|
+
return user.roles.flatMap((role) => role.permissions);
|
|
672
688
|
}
|
|
673
689
|
};
|
|
674
690
|
|
package/lib/services/index.mjs
CHANGED
|
@@ -550,10 +550,10 @@ var BaseUserService = class {
|
|
|
550
550
|
);
|
|
551
551
|
}
|
|
552
552
|
async getOrganizationIdByUserId(idDto, em) {
|
|
553
|
-
const user = await (em ?? this.em).
|
|
553
|
+
const user = await (em ?? this.em).findOne("User", idDto, {
|
|
554
554
|
populate: ["id", "organization"]
|
|
555
555
|
});
|
|
556
|
-
return user
|
|
556
|
+
return user?.organization?.id;
|
|
557
557
|
}
|
|
558
558
|
async getUser(idDto, em) {
|
|
559
559
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -568,14 +568,16 @@ var BaseUserService = class {
|
|
|
568
568
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
569
569
|
this.openTelemetryCollector.info("Getting batch users", idsDto);
|
|
570
570
|
}
|
|
571
|
+
const filter = {
|
|
572
|
+
id: { $in: idsDto.ids },
|
|
573
|
+
...idsDto.organization && {
|
|
574
|
+
organization: idsDto.organization
|
|
575
|
+
}
|
|
576
|
+
};
|
|
571
577
|
return Promise.all(
|
|
572
|
-
(await (em ?? this.em).find(
|
|
573
|
-
"
|
|
574
|
-
|
|
575
|
-
{
|
|
576
|
-
populate: ["id", "*"]
|
|
577
|
-
}
|
|
578
|
-
)).map(
|
|
578
|
+
(await (em ?? this.em).find("User", filter, {
|
|
579
|
+
populate: ["id", "*"]
|
|
580
|
+
})).map(
|
|
579
581
|
(user) => this.mappers.UserMapper.toDto(user)
|
|
580
582
|
)
|
|
581
583
|
);
|
|
@@ -622,13 +624,27 @@ var BaseUserService = class {
|
|
|
622
624
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
623
625
|
this.openTelemetryCollector.info("Deleting user", idDto);
|
|
624
626
|
}
|
|
625
|
-
|
|
627
|
+
const filter = {
|
|
628
|
+
...idDto,
|
|
629
|
+
id: idDto.id,
|
|
630
|
+
...idDto.organization && {
|
|
631
|
+
organization: idDto.organization
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
await (em ?? this.em).nativeDelete("User", filter);
|
|
626
635
|
}
|
|
627
636
|
async deleteBatchUsers(idsDto, em) {
|
|
628
637
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
629
638
|
this.openTelemetryCollector.info("Deleting batch users", idsDto);
|
|
630
639
|
}
|
|
631
|
-
|
|
640
|
+
const filter = {
|
|
641
|
+
...idsDto,
|
|
642
|
+
id: { $in: idsDto.ids },
|
|
643
|
+
...idsDto.organization && {
|
|
644
|
+
organization: idsDto.organization
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
await (em ?? this.em).nativeDelete("User", filter);
|
|
632
648
|
}
|
|
633
649
|
async surfaceRoles(idDto, em) {
|
|
634
650
|
if (this.evaluatedTelemetryOptions.logging) {
|
|
@@ -646,7 +662,7 @@ var BaseUserService = class {
|
|
|
646
662
|
});
|
|
647
663
|
}
|
|
648
664
|
const user = await this.getUser(idDto, em);
|
|
649
|
-
return user.roles.
|
|
665
|
+
return user.roles.flatMap((role) => role.permissions);
|
|
650
666
|
}
|
|
651
667
|
};
|
|
652
668
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/implementation-iam-base",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.13",
|
|
4
4
|
"description": "IAM basic implementation for forklaunch",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@sinclair/typebox": "^0.34.48",
|
|
45
45
|
"ajv": "^8.17.1",
|
|
46
46
|
"zod": "^4.3.6",
|
|
47
|
-
"@forklaunch/interfaces-iam": "0.8.
|
|
47
|
+
"@forklaunch/interfaces-iam": "0.8.12"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@typescript/native-preview": "7.0.0-dev.20260204.1",
|