tychat-contracts 1.6.81 → 1.6.82
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/.husky/commit-msg +11 -0
- package/dist/users/create-user.dto.d.ts +2 -1
- package/dist/users/create-user.dto.d.ts.map +1 -1
- package/dist/users/create-user.dto.js +19 -1
- package/dist/users/update-user-by-admin.dto.d.ts +2 -1
- package/dist/users/update-user-by-admin.dto.d.ts.map +1 -1
- package/dist/users/update-user-by-admin.dto.js +20 -3
- package/dist/users/updated-user.dto.d.ts +3 -1
- package/dist/users/updated-user.dto.d.ts.map +1 -1
- package/dist/users/updated-user.dto.js +14 -3
- package/dist/users/user-list-item.dto.d.ts +3 -1
- package/dist/users/user-list-item.dto.d.ts.map +1 -1
- package/dist/users/user-list-item.dto.js +14 -3
- package/dist/users/user-update-kafka-payloads.d.ts +3 -0
- package/dist/users/user-update-kafka-payloads.d.ts.map +1 -1
- package/package.json +32 -30
- package/src/users/create-user.dto.ts +25 -3
- package/src/users/update-user-by-admin.dto.ts +28 -4
- package/src/users/updated-user.dto.ts +13 -4
- package/src/users/user-list-item.dto.ts +13 -4
- package/src/users/user-update-kafka-payloads.ts +3 -0
|
@@ -7,6 +7,7 @@ export type CreatableUserRole = (typeof CREATABLE_USER_ROLES)[number];
|
|
|
7
7
|
export declare class CreateUserDto {
|
|
8
8
|
name: string;
|
|
9
9
|
email: string;
|
|
10
|
-
|
|
10
|
+
roles?: CreatableUserRole[];
|
|
11
|
+
role?: CreatableUserRole;
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=create-user.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-user.dto.d.ts","sourceRoot":"","sources":["../../src/users/create-user.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-user.dto.d.ts","sourceRoot":"","sources":["../../src/users/create-user.dto.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+CAAgD,CAAC;AAClF,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,qBAAa,aAAa;IASxB,IAAI,EAAE,MAAM,CAAC;IAWb,KAAK,EAAE,MAAM,CAAC;IAgBd,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAa5B,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B"}
|
|
@@ -20,6 +20,7 @@ exports.CREATABLE_USER_ROLES = ['attendant', 'health_professional'];
|
|
|
20
20
|
class CreateUserDto {
|
|
21
21
|
name;
|
|
22
22
|
email;
|
|
23
|
+
roles;
|
|
23
24
|
role;
|
|
24
25
|
}
|
|
25
26
|
exports.CreateUserDto = CreateUserDto;
|
|
@@ -48,10 +49,27 @@ __decorate([
|
|
|
48
49
|
], CreateUserDto.prototype, "email", void 0);
|
|
49
50
|
__decorate([
|
|
50
51
|
(0, swagger_1.ApiProperty)({
|
|
51
|
-
description: '
|
|
52
|
+
description: 'Papéis do usuário. Pelo menos um: atendente e/ou profissional de saúde.',
|
|
53
|
+
enum: exports.CREATABLE_USER_ROLES,
|
|
54
|
+
isArray: true,
|
|
55
|
+
example: ['attendant'],
|
|
56
|
+
}),
|
|
57
|
+
(0, class_validator_1.ValidateIf)((o) => o.role == null),
|
|
58
|
+
(0, class_validator_1.IsArray)({ message: 'roles deve ser um array' }),
|
|
59
|
+
(0, class_validator_1.ArrayMinSize)(1, { message: 'roles deve conter ao menos um papel' }),
|
|
60
|
+
(0, class_validator_1.IsIn)(exports.CREATABLE_USER_ROLES, {
|
|
61
|
+
each: true,
|
|
62
|
+
message: 'cada role deve ser attendant ou health_professional',
|
|
63
|
+
}),
|
|
64
|
+
__metadata("design:type", Array)
|
|
65
|
+
], CreateUserDto.prototype, "roles", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
68
|
+
description: 'Deprecated: use roles[]. Papel único; convertido internamente para roles com um elemento.',
|
|
52
69
|
enum: exports.CREATABLE_USER_ROLES,
|
|
53
70
|
default: 'attendant',
|
|
54
71
|
}),
|
|
72
|
+
(0, class_validator_1.IsOptional)(),
|
|
55
73
|
(0, class_validator_1.IsString)(),
|
|
56
74
|
(0, class_validator_1.IsIn)(exports.CREATABLE_USER_ROLES, {
|
|
57
75
|
message: 'role deve ser attendant ou health_professional',
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare const ALL_USER_ROLES: readonly ["administrator", "attendant", "health_professional"];
|
|
2
2
|
export type AllUserRole = (typeof ALL_USER_ROLES)[number];
|
|
3
|
-
/** Fields an administrator may change for any user (including
|
|
3
|
+
/** Fields an administrator may change for any user (including roles). */
|
|
4
4
|
export declare class UpdateUserByAdminDto {
|
|
5
5
|
_atLeastOne?: string;
|
|
6
6
|
name?: string;
|
|
7
7
|
email?: string;
|
|
8
|
+
roles?: AllUserRole[];
|
|
8
9
|
role?: AllUserRole;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=update-user-by-admin.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-user-by-admin.dto.d.ts","sourceRoot":"","sources":["../../src/users/update-user-by-admin.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update-user-by-admin.dto.d.ts","sourceRoot":"","sources":["../../src/users/update-user-by-admin.dto.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc,gEAIjB,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,yEAAyE;AACzE,qBAAa,oBAAoB;IAG/B,WAAW,CAAC,EAAE,MAAM,CAAC;IAWrB,IAAI,CAAC,EAAE,MAAM,CAAC;IAWd,KAAK,CAAC,EAAE,MAAM,CAAC;IAef,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IAYtB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB"}
|
|
@@ -18,17 +18,18 @@ exports.ALL_USER_ROLES = [
|
|
|
18
18
|
'attendant',
|
|
19
19
|
'health_professional',
|
|
20
20
|
];
|
|
21
|
-
/** Fields an administrator may change for any user (including
|
|
21
|
+
/** Fields an administrator may change for any user (including roles). */
|
|
22
22
|
class UpdateUserByAdminDto {
|
|
23
23
|
_atLeastOne;
|
|
24
24
|
name;
|
|
25
25
|
email;
|
|
26
|
+
roles;
|
|
26
27
|
role;
|
|
27
28
|
}
|
|
28
29
|
exports.UpdateUserByAdminDto = UpdateUserByAdminDto;
|
|
29
30
|
__decorate([
|
|
30
31
|
(0, swagger_1.ApiHideProperty)(),
|
|
31
|
-
(0, at_least_one_of_decorator_1.AtLeastOneOf)(['name', 'email', 'role']),
|
|
32
|
+
(0, at_least_one_of_decorator_1.AtLeastOneOf)(['name', 'email', 'role', 'roles']),
|
|
32
33
|
__metadata("design:type", String)
|
|
33
34
|
], UpdateUserByAdminDto.prototype, "_atLeastOne", void 0);
|
|
34
35
|
__decorate([
|
|
@@ -56,7 +57,23 @@ __decorate([
|
|
|
56
57
|
], UpdateUserByAdminDto.prototype, "email", void 0);
|
|
57
58
|
__decorate([
|
|
58
59
|
(0, swagger_1.ApiPropertyOptional)({
|
|
59
|
-
description: 'User role',
|
|
60
|
+
description: 'User roles (replaces the full role set when provided)',
|
|
61
|
+
enum: exports.ALL_USER_ROLES,
|
|
62
|
+
isArray: true,
|
|
63
|
+
example: ['attendant', 'health_professional'],
|
|
64
|
+
}),
|
|
65
|
+
(0, class_validator_1.IsOptional)(),
|
|
66
|
+
(0, class_validator_1.IsArray)(),
|
|
67
|
+
(0, class_validator_1.ArrayMinSize)(1, { message: 'roles must contain at least one role when provided' }),
|
|
68
|
+
(0, class_validator_1.IsIn)(exports.ALL_USER_ROLES, {
|
|
69
|
+
each: true,
|
|
70
|
+
message: 'each role must be administrator, attendant, or health_professional',
|
|
71
|
+
}),
|
|
72
|
+
__metadata("design:type", Array)
|
|
73
|
+
], UpdateUserByAdminDto.prototype, "roles", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
76
|
+
description: 'Deprecated: use roles[]. Single role replacement.',
|
|
60
77
|
enum: exports.ALL_USER_ROLES,
|
|
61
78
|
example: 'attendant',
|
|
62
79
|
}),
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ALL_USER_ROLES } from './update-user-by-admin.dto';
|
|
1
2
|
/** User payload returned after create or update (no password). */
|
|
2
3
|
export declare class UpdatedUserDto {
|
|
3
4
|
userId: string;
|
|
4
5
|
name: string;
|
|
5
6
|
email: string;
|
|
6
|
-
|
|
7
|
+
roles: (typeof ALL_USER_ROLES)[number][];
|
|
8
|
+
role?: (typeof ALL_USER_ROLES)[number];
|
|
7
9
|
createdAt: Date;
|
|
8
10
|
updatedAt: Date;
|
|
9
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updated-user.dto.d.ts","sourceRoot":"","sources":["../../src/users/updated-user.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updated-user.dto.d.ts","sourceRoot":"","sources":["../../src/users/updated-user.dto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,kEAAkE;AAClE,qBAAa,cAAc;IAMzB,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAQd,KAAK,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAOzC,IAAI,CAAC,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;IAGvC,SAAS,EAAE,IAAI,CAAC;IAGhB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -11,11 +11,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UpdatedUserDto = void 0;
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const update_user_by_admin_dto_1 = require("./update-user-by-admin.dto");
|
|
14
15
|
/** User payload returned after create or update (no password). */
|
|
15
16
|
class UpdatedUserDto {
|
|
16
17
|
userId;
|
|
17
18
|
name;
|
|
18
19
|
email;
|
|
20
|
+
roles;
|
|
19
21
|
role;
|
|
20
22
|
createdAt;
|
|
21
23
|
updatedAt;
|
|
@@ -39,11 +41,20 @@ __decorate([
|
|
|
39
41
|
], UpdatedUserDto.prototype, "email", void 0);
|
|
40
42
|
__decorate([
|
|
41
43
|
(0, swagger_1.ApiProperty)({
|
|
42
|
-
description: '
|
|
43
|
-
enum:
|
|
44
|
+
description: 'All roles assigned to the user',
|
|
45
|
+
enum: update_user_by_admin_dto_1.ALL_USER_ROLES,
|
|
46
|
+
isArray: true,
|
|
47
|
+
example: ['attendant'],
|
|
48
|
+
}),
|
|
49
|
+
__metadata("design:type", Array)
|
|
50
|
+
], UpdatedUserDto.prototype, "roles", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
53
|
+
description: 'Deprecated primary role alias (first role in roles[])',
|
|
54
|
+
enum: update_user_by_admin_dto_1.ALL_USER_ROLES,
|
|
44
55
|
example: 'attendant',
|
|
45
56
|
}),
|
|
46
|
-
__metadata("design:type",
|
|
57
|
+
__metadata("design:type", Object)
|
|
47
58
|
], UpdatedUserDto.prototype, "role", void 0);
|
|
48
59
|
__decorate([
|
|
49
60
|
(0, swagger_1.ApiProperty)({ description: 'Creation timestamp' }),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ALL_USER_ROLES } from './update-user-by-admin.dto';
|
|
1
2
|
/** Public user summary returned when an administrator lists users (no password). */
|
|
2
3
|
export declare class UserListItemDto {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
5
6
|
email: string;
|
|
6
|
-
|
|
7
|
+
roles: (typeof ALL_USER_ROLES)[number][];
|
|
8
|
+
role?: (typeof ALL_USER_ROLES)[number];
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=user-list-item.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-list-item.dto.d.ts","sourceRoot":"","sources":["../../src/users/user-list-item.dto.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-list-item.dto.d.ts","sourceRoot":"","sources":["../../src/users/user-list-item.dto.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,oFAAoF;AACpF,qBAAa,eAAe;IAM1B,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAQd,KAAK,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAOzC,IAAI,CAAC,EAAE,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;CACxC"}
|
|
@@ -11,11 +11,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.UserListItemDto = void 0;
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const update_user_by_admin_dto_1 = require("./update-user-by-admin.dto");
|
|
14
15
|
/** Public user summary returned when an administrator lists users (no password). */
|
|
15
16
|
class UserListItemDto {
|
|
16
17
|
id;
|
|
17
18
|
name;
|
|
18
19
|
email;
|
|
20
|
+
roles;
|
|
19
21
|
role;
|
|
20
22
|
}
|
|
21
23
|
exports.UserListItemDto = UserListItemDto;
|
|
@@ -37,9 +39,18 @@ __decorate([
|
|
|
37
39
|
], UserListItemDto.prototype, "email", void 0);
|
|
38
40
|
__decorate([
|
|
39
41
|
(0, swagger_1.ApiProperty)({
|
|
40
|
-
description: '
|
|
41
|
-
enum:
|
|
42
|
+
description: 'All roles assigned to the user',
|
|
43
|
+
enum: update_user_by_admin_dto_1.ALL_USER_ROLES,
|
|
44
|
+
isArray: true,
|
|
45
|
+
example: ['attendant'],
|
|
46
|
+
}),
|
|
47
|
+
__metadata("design:type", Array)
|
|
48
|
+
], UserListItemDto.prototype, "roles", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
51
|
+
description: 'Deprecated primary role alias (first role in roles[])',
|
|
52
|
+
enum: update_user_by_admin_dto_1.ALL_USER_ROLES,
|
|
42
53
|
example: 'attendant',
|
|
43
54
|
}),
|
|
44
|
-
__metadata("design:type",
|
|
55
|
+
__metadata("design:type", Object)
|
|
45
56
|
], UserListItemDto.prototype, "role", void 0);
|
|
@@ -19,6 +19,9 @@ export interface AuthUpdateUserAdminPayload {
|
|
|
19
19
|
targetUserId: string;
|
|
20
20
|
name?: string;
|
|
21
21
|
email?: string;
|
|
22
|
+
/** Replaces the full role set when provided. */
|
|
23
|
+
roles?: ('administrator' | 'attendant' | 'health_professional')[];
|
|
24
|
+
/** @deprecated Use roles[] */
|
|
22
25
|
role?: 'administrator' | 'attendant' | 'health_professional';
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-update-kafka-payloads.d.ts","sourceRoot":"","sources":["../../src/users/user-update-kafka-payloads.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,eAAe,GAAG,WAAW,GAAG,qBAAqB,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
1
|
+
{"version":3,"file":"user-update-kafka-payloads.d.ts","sourceRoot":"","sources":["../../src/users/user-update-kafka-payloads.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,KAAK,CAAC,EAAE,CAAC,eAAe,GAAG,WAAW,GAAG,qBAAqB,CAAC,EAAE,CAAC;IAClE,8BAA8B;IAC9B,IAAI,CAAC,EAAE,eAAe,GAAG,WAAW,GAAG,qBAAqB,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tychat-contracts",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "DTOs compartilhados com class-validator (API e microserviços)",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"private": false,
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"release": "npm version patch && npm publish",
|
|
11
|
-
"prepublishOnly": "npm run build"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"class-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"@
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "tychat-contracts",
|
|
3
|
+
"version": "1.6.82",
|
|
4
|
+
"description": "DTOs compartilhados com class-validator (API e microserviços)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"private": false,
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"release": "npm version patch && npm publish",
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"prepare": "husky"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"class-transformer": "^0.5.1",
|
|
16
|
+
"class-validator": "^0.14.1",
|
|
17
|
+
"ioredis": "^5.10.0",
|
|
18
|
+
"jest": "^30.3.0",
|
|
19
|
+
"reflect-metadata": "*"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@nestjs/swagger": "^11.2.6",
|
|
23
|
+
"@types/jest": "^30.0.0",
|
|
24
|
+
"husky": "^9.1.7",
|
|
25
|
+
"ts-jest": "^29.4.9",
|
|
26
|
+
"typescript": "^5.7.3"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@nestjs/swagger": "^11.2.6",
|
|
30
|
+
"reflect-metadata": "*"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
2
|
import {
|
|
3
3
|
IsEmail,
|
|
4
4
|
IsString,
|
|
5
5
|
IsIn,
|
|
6
6
|
MinLength,
|
|
7
7
|
MaxLength,
|
|
8
|
+
IsArray,
|
|
9
|
+
ArrayMinSize,
|
|
10
|
+
IsOptional,
|
|
11
|
+
ValidateIf,
|
|
8
12
|
} from 'class-validator';
|
|
9
13
|
|
|
10
14
|
/**
|
|
@@ -37,13 +41,31 @@ export class CreateUserDto {
|
|
|
37
41
|
email: string;
|
|
38
42
|
|
|
39
43
|
@ApiProperty({
|
|
40
|
-
description:
|
|
44
|
+
description:
|
|
45
|
+
'Papéis do usuário. Pelo menos um: atendente e/ou profissional de saúde.',
|
|
46
|
+
enum: CREATABLE_USER_ROLES,
|
|
47
|
+
isArray: true,
|
|
48
|
+
example: ['attendant'],
|
|
49
|
+
})
|
|
50
|
+
@ValidateIf((o: CreateUserDto) => o.role == null)
|
|
51
|
+
@IsArray({ message: 'roles deve ser um array' })
|
|
52
|
+
@ArrayMinSize(1, { message: 'roles deve conter ao menos um papel' })
|
|
53
|
+
@IsIn(CREATABLE_USER_ROLES, {
|
|
54
|
+
each: true,
|
|
55
|
+
message: 'cada role deve ser attendant ou health_professional',
|
|
56
|
+
})
|
|
57
|
+
roles?: CreatableUserRole[];
|
|
58
|
+
|
|
59
|
+
@ApiPropertyOptional({
|
|
60
|
+
description:
|
|
61
|
+
'Deprecated: use roles[]. Papel único; convertido internamente para roles com um elemento.',
|
|
41
62
|
enum: CREATABLE_USER_ROLES,
|
|
42
63
|
default: 'attendant',
|
|
43
64
|
})
|
|
65
|
+
@IsOptional()
|
|
44
66
|
@IsString()
|
|
45
67
|
@IsIn(CREATABLE_USER_ROLES, {
|
|
46
68
|
message: 'role deve ser attendant ou health_professional',
|
|
47
69
|
})
|
|
48
|
-
role
|
|
70
|
+
role?: CreatableUserRole;
|
|
49
71
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { ApiHideProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
IsEmail,
|
|
4
|
+
IsIn,
|
|
5
|
+
IsOptional,
|
|
6
|
+
IsString,
|
|
7
|
+
MaxLength,
|
|
8
|
+
MinLength,
|
|
9
|
+
IsArray,
|
|
10
|
+
ArrayMinSize,
|
|
11
|
+
} from 'class-validator';
|
|
3
12
|
import { AtLeastOneOf } from './at-least-one-of.decorator';
|
|
4
13
|
|
|
5
14
|
export const ALL_USER_ROLES = [
|
|
@@ -9,10 +18,10 @@ export const ALL_USER_ROLES = [
|
|
|
9
18
|
] as const;
|
|
10
19
|
export type AllUserRole = (typeof ALL_USER_ROLES)[number];
|
|
11
20
|
|
|
12
|
-
/** Fields an administrator may change for any user (including
|
|
21
|
+
/** Fields an administrator may change for any user (including roles). */
|
|
13
22
|
export class UpdateUserByAdminDto {
|
|
14
23
|
@ApiHideProperty()
|
|
15
|
-
@AtLeastOneOf(['name', 'email', 'role'])
|
|
24
|
+
@AtLeastOneOf(['name', 'email', 'role', 'roles'])
|
|
16
25
|
_atLeastOne?: string;
|
|
17
26
|
|
|
18
27
|
@ApiPropertyOptional({
|
|
@@ -38,7 +47,22 @@ export class UpdateUserByAdminDto {
|
|
|
38
47
|
email?: string;
|
|
39
48
|
|
|
40
49
|
@ApiPropertyOptional({
|
|
41
|
-
description: 'User role',
|
|
50
|
+
description: 'User roles (replaces the full role set when provided)',
|
|
51
|
+
enum: ALL_USER_ROLES,
|
|
52
|
+
isArray: true,
|
|
53
|
+
example: ['attendant', 'health_professional'],
|
|
54
|
+
})
|
|
55
|
+
@IsOptional()
|
|
56
|
+
@IsArray()
|
|
57
|
+
@ArrayMinSize(1, { message: 'roles must contain at least one role when provided' })
|
|
58
|
+
@IsIn(ALL_USER_ROLES, {
|
|
59
|
+
each: true,
|
|
60
|
+
message: 'each role must be administrator, attendant, or health_professional',
|
|
61
|
+
})
|
|
62
|
+
roles?: AllUserRole[];
|
|
63
|
+
|
|
64
|
+
@ApiPropertyOptional({
|
|
65
|
+
description: 'Deprecated: use roles[]. Single role replacement.',
|
|
42
66
|
enum: ALL_USER_ROLES,
|
|
43
67
|
example: 'attendant',
|
|
44
68
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { ALL_USER_ROLES } from './update-user-by-admin.dto';
|
|
2
3
|
|
|
3
4
|
/** User payload returned after create or update (no password). */
|
|
4
5
|
export class UpdatedUserDto {
|
|
@@ -16,11 +17,19 @@ export class UpdatedUserDto {
|
|
|
16
17
|
email: string;
|
|
17
18
|
|
|
18
19
|
@ApiProperty({
|
|
19
|
-
description: '
|
|
20
|
-
enum:
|
|
20
|
+
description: 'All roles assigned to the user',
|
|
21
|
+
enum: ALL_USER_ROLES,
|
|
22
|
+
isArray: true,
|
|
23
|
+
example: ['attendant'],
|
|
24
|
+
})
|
|
25
|
+
roles: (typeof ALL_USER_ROLES)[number][];
|
|
26
|
+
|
|
27
|
+
@ApiPropertyOptional({
|
|
28
|
+
description: 'Deprecated primary role alias (first role in roles[])',
|
|
29
|
+
enum: ALL_USER_ROLES,
|
|
21
30
|
example: 'attendant',
|
|
22
31
|
})
|
|
23
|
-
role
|
|
32
|
+
role?: (typeof ALL_USER_ROLES)[number];
|
|
24
33
|
|
|
25
34
|
@ApiProperty({ description: 'Creation timestamp' })
|
|
26
35
|
createdAt: Date;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { ALL_USER_ROLES } from './update-user-by-admin.dto';
|
|
2
3
|
|
|
3
4
|
/** Public user summary returned when an administrator lists users (no password). */
|
|
4
5
|
export class UserListItemDto {
|
|
@@ -16,9 +17,17 @@ export class UserListItemDto {
|
|
|
16
17
|
email: string;
|
|
17
18
|
|
|
18
19
|
@ApiProperty({
|
|
19
|
-
description: '
|
|
20
|
-
enum:
|
|
20
|
+
description: 'All roles assigned to the user',
|
|
21
|
+
enum: ALL_USER_ROLES,
|
|
22
|
+
isArray: true,
|
|
23
|
+
example: ['attendant'],
|
|
24
|
+
})
|
|
25
|
+
roles: (typeof ALL_USER_ROLES)[number][];
|
|
26
|
+
|
|
27
|
+
@ApiPropertyOptional({
|
|
28
|
+
description: 'Deprecated primary role alias (first role in roles[])',
|
|
29
|
+
enum: ALL_USER_ROLES,
|
|
21
30
|
example: 'attendant',
|
|
22
31
|
})
|
|
23
|
-
role
|
|
32
|
+
role?: (typeof ALL_USER_ROLES)[number];
|
|
24
33
|
}
|
|
@@ -20,6 +20,9 @@ export interface AuthUpdateUserAdminPayload {
|
|
|
20
20
|
targetUserId: string;
|
|
21
21
|
name?: string;
|
|
22
22
|
email?: string;
|
|
23
|
+
/** Replaces the full role set when provided. */
|
|
24
|
+
roles?: ('administrator' | 'attendant' | 'health_professional')[];
|
|
25
|
+
/** @deprecated Use roles[] */
|
|
23
26
|
role?: 'administrator' | 'attendant' | 'health_professional';
|
|
24
27
|
}
|
|
25
28
|
|