tychat-contracts 1.0.5 → 1.0.7
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/README.md +30 -31
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tenants/index.d.ts +0 -3
- package/dist/tenants/index.d.ts.map +1 -1
- package/dist/tenants/index.js +1 -8
- package/dist/users/create-user.dto.d.ts +12 -0
- package/dist/users/create-user.dto.d.ts.map +1 -0
- package/dist/users/create-user.dto.js +59 -0
- package/dist/users/index.d.ts +2 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/users/index.js +6 -0
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/tenants/index.ts +1 -3
- package/src/users/create-user.dto.ts +47 -0
- package/src/users/index.ts +5 -0
- package/src/tenants/create-tenant.dto.ts +0 -55
- package/src/tenants/update-tenant-payload.dto.ts +0 -10
- package/src/tenants/update-tenant.dto.ts +0 -60
package/README.md
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
# tychat-contracts-dtos
|
|
2
|
-
|
|
3
|
-
DTOs compartilhados com **class-validator** usados pela **tychat-api** e pelos microserviços (ex.: **tychat-tenant-service**).
|
|
4
|
-
|
|
5
|
-
## Estrutura
|
|
6
|
-
|
|
7
|
-
- **auth**: `LoginDto`
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Após alterar os DTOs, rode `npm run build` no pacote e reinstale (ou use `npm link`) nos projetos que o utilizam.
|
|
1
|
+
# tychat-contracts-dtos
|
|
2
|
+
|
|
3
|
+
DTOs compartilhados com **class-validator** usados pela **tychat-api** e pelos microserviços (ex.: **tychat-tenant-service**).
|
|
4
|
+
|
|
5
|
+
## Estrutura
|
|
6
|
+
|
|
7
|
+
- **auth**: `LoginDto`
|
|
8
|
+
|
|
9
|
+
## Uso
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Build (gera dist/)
|
|
13
|
+
npm run build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Nos projetos que consomem (tychat-api, tychat-tenant-service):
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"tychat-contracts-dtos": "file:../tychat-contracts-dtos"
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { LoginDto } from 'tychat-contracts-dtos';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Desenvolvimento
|
|
29
|
+
|
|
30
|
+
Após alterar os DTOs, rode `npm run build` no pacote e reinstale (ou use `npm link`) nos projetos que o utilizam.
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./auth"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./users"), exports);
|
package/dist/tenants/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tenants/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tenants/index.ts"],"names":[],"mappings":""}
|
package/dist/tenants/index.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.UpdateTenantPayloadDto = exports.UpdateTenantDto = exports.CreateTenantDto = void 0;
|
|
4
|
-
var create_tenant_dto_1 = require("./create-tenant.dto");
|
|
5
|
-
Object.defineProperty(exports, "CreateTenantDto", { enumerable: true, get: function () { return create_tenant_dto_1.CreateTenantDto; } });
|
|
6
|
-
var update_tenant_dto_1 = require("./update-tenant.dto");
|
|
7
|
-
Object.defineProperty(exports, "UpdateTenantDto", { enumerable: true, get: function () { return update_tenant_dto_1.UpdateTenantDto; } });
|
|
8
|
-
var update_tenant_payload_dto_1 = require("./update-tenant-payload.dto");
|
|
9
|
-
Object.defineProperty(exports, "UpdateTenantPayloadDto", { enumerable: true, get: function () { return update_tenant_payload_dto_1.UpdateTenantPayloadDto; } });
|
|
2
|
+
// DTOs de tenants foram movidos para o próprio microserviço tychat-tenant-service
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Roles permitidas na criação de usuário por um administrador.
|
|
3
|
+
* Administrador não pode criar outros administradores.
|
|
4
|
+
*/
|
|
5
|
+
export declare const CREATABLE_USER_ROLES: readonly ["attendant", "health_professional"];
|
|
6
|
+
export type CreatableUserRole = (typeof CREATABLE_USER_ROLES)[number];
|
|
7
|
+
export declare class CreateUserDto {
|
|
8
|
+
username: string;
|
|
9
|
+
password: string;
|
|
10
|
+
role: CreatableUserRole;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=create-user.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-user.dto.d.ts","sourceRoot":"","sources":["../../src/users/create-user.dto.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+CAAgD,CAAC;AAClF,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,qBAAa,aAAa;IASxB,QAAQ,EAAE,MAAM,CAAC;IAUjB,QAAQ,EAAE,MAAM,CAAC;IAWjB,IAAI,EAAE,iBAAiB,CAAC;CACzB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CreateUserDto = exports.CREATABLE_USER_ROLES = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* Roles permitidas na criação de usuário por um administrador.
|
|
17
|
+
* Administrador não pode criar outros administradores.
|
|
18
|
+
*/
|
|
19
|
+
exports.CREATABLE_USER_ROLES = ['attendant', 'health_professional'];
|
|
20
|
+
class CreateUserDto {
|
|
21
|
+
username;
|
|
22
|
+
password;
|
|
23
|
+
role;
|
|
24
|
+
}
|
|
25
|
+
exports.CreateUserDto = CreateUserDto;
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, swagger_1.ApiProperty)({
|
|
28
|
+
description: 'Login do usuário (único no tenant)',
|
|
29
|
+
example: 'maria.silva',
|
|
30
|
+
maxLength: 255,
|
|
31
|
+
}),
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.MinLength)(1, { message: 'username não pode ser vazio' }),
|
|
34
|
+
(0, class_validator_1.MaxLength)(255),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], CreateUserDto.prototype, "username", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, swagger_1.ApiProperty)({
|
|
39
|
+
description: 'Senha (será hasheada com bcrypt)',
|
|
40
|
+
example: 'senha123',
|
|
41
|
+
minLength: 6,
|
|
42
|
+
}),
|
|
43
|
+
(0, class_validator_1.IsString)(),
|
|
44
|
+
(0, class_validator_1.MinLength)(6, { message: 'password deve ter no mínimo 6 caracteres' }),
|
|
45
|
+
(0, class_validator_1.MaxLength)(255),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], CreateUserDto.prototype, "password", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, swagger_1.ApiProperty)({
|
|
50
|
+
description: 'Papel do usuário. Apenas atendente ou profissional de saúde; administrador não pode criar outros administradores.',
|
|
51
|
+
enum: exports.CREATABLE_USER_ROLES,
|
|
52
|
+
default: 'attendant',
|
|
53
|
+
}),
|
|
54
|
+
(0, class_validator_1.IsString)(),
|
|
55
|
+
(0, class_validator_1.IsIn)(exports.CREATABLE_USER_ROLES, {
|
|
56
|
+
message: 'role deve ser attendant ou health_professional',
|
|
57
|
+
}),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], CreateUserDto.prototype, "role", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/users/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CREATABLE_USER_ROLES = exports.CreateUserDto = void 0;
|
|
4
|
+
var create_user_dto_1 = require("./create-user.dto");
|
|
5
|
+
Object.defineProperty(exports, "CreateUserDto", { enumerable: true, get: function () { return create_user_dto_1.CreateUserDto; } });
|
|
6
|
+
Object.defineProperty(exports, "CREATABLE_USER_ROLES", { enumerable: true, get: function () { return create_user_dto_1.CREATABLE_USER_ROLES; } });
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './auth';
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './auth';
|
|
2
|
+
export * from './users';
|
package/src/tenants/index.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import {
|
|
3
|
+
IsString,
|
|
4
|
+
IsIn,
|
|
5
|
+
MinLength,
|
|
6
|
+
MaxLength,
|
|
7
|
+
} from 'class-validator';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Roles permitidas na criação de usuário por um administrador.
|
|
11
|
+
* Administrador não pode criar outros administradores.
|
|
12
|
+
*/
|
|
13
|
+
export const CREATABLE_USER_ROLES = ['attendant', 'health_professional'] as const;
|
|
14
|
+
export type CreatableUserRole = (typeof CREATABLE_USER_ROLES)[number];
|
|
15
|
+
|
|
16
|
+
export class CreateUserDto {
|
|
17
|
+
@ApiProperty({
|
|
18
|
+
description: 'Login do usuário (único no tenant)',
|
|
19
|
+
example: 'maria.silva',
|
|
20
|
+
maxLength: 255,
|
|
21
|
+
})
|
|
22
|
+
@IsString()
|
|
23
|
+
@MinLength(1, { message: 'username não pode ser vazio' })
|
|
24
|
+
@MaxLength(255)
|
|
25
|
+
username: string;
|
|
26
|
+
|
|
27
|
+
@ApiProperty({
|
|
28
|
+
description: 'Senha (será hasheada com bcrypt)',
|
|
29
|
+
example: 'senha123',
|
|
30
|
+
minLength: 6,
|
|
31
|
+
})
|
|
32
|
+
@IsString()
|
|
33
|
+
@MinLength(6, { message: 'password deve ter no mínimo 6 caracteres' })
|
|
34
|
+
@MaxLength(255)
|
|
35
|
+
password: string;
|
|
36
|
+
|
|
37
|
+
@ApiProperty({
|
|
38
|
+
description: 'Papel do usuário. Apenas atendente ou profissional de saúde; administrador não pode criar outros administradores.',
|
|
39
|
+
enum: CREATABLE_USER_ROLES,
|
|
40
|
+
default: 'attendant',
|
|
41
|
+
})
|
|
42
|
+
@IsString()
|
|
43
|
+
@IsIn(CREATABLE_USER_ROLES, {
|
|
44
|
+
message: 'role deve ser attendant ou health_professional',
|
|
45
|
+
})
|
|
46
|
+
role: CreatableUserRole;
|
|
47
|
+
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import {
|
|
3
|
-
IsString,
|
|
4
|
-
IsOptional,
|
|
5
|
-
IsInt,
|
|
6
|
-
Min,
|
|
7
|
-
Max,
|
|
8
|
-
IsIn,
|
|
9
|
-
MaxLength,
|
|
10
|
-
MinLength,
|
|
11
|
-
} from 'class-validator';
|
|
12
|
-
|
|
13
|
-
export class CreateTenantDto {
|
|
14
|
-
@ApiProperty({ description: 'Identificador único do tenant na URL', example: 'acme', maxLength: 255 })
|
|
15
|
-
@IsString()
|
|
16
|
-
@MinLength(1, { message: 'slug não pode ser vazio' })
|
|
17
|
-
@MaxLength(255)
|
|
18
|
-
slug: string;
|
|
19
|
-
|
|
20
|
-
@ApiProperty({ description: 'Host do banco de dados do tenant', example: 'localhost', maxLength: 255 })
|
|
21
|
-
@IsString()
|
|
22
|
-
@MinLength(1, { message: 'dbHost não pode ser vazio' })
|
|
23
|
-
@MaxLength(255)
|
|
24
|
-
dbHost: string;
|
|
25
|
-
|
|
26
|
-
@ApiPropertyOptional({ description: 'Porta do banco de dados', example: 5432, minimum: 1, maximum: 65535, default: 5432 })
|
|
27
|
-
@IsOptional()
|
|
28
|
-
@IsInt()
|
|
29
|
-
@Min(1)
|
|
30
|
-
@Max(65535)
|
|
31
|
-
dbPort?: number;
|
|
32
|
-
|
|
33
|
-
@ApiProperty({ description: 'Nome do banco de dados', example: 'tychat_acme', maxLength: 255 })
|
|
34
|
-
@IsString()
|
|
35
|
-
@MinLength(1, { message: 'dbName não pode ser vazio' })
|
|
36
|
-
@MaxLength(255)
|
|
37
|
-
dbName: string;
|
|
38
|
-
|
|
39
|
-
@ApiProperty({ description: 'Usuário do banco de dados', example: 'tychat_user', maxLength: 255 })
|
|
40
|
-
@IsString()
|
|
41
|
-
@MinLength(1, { message: 'dbUser não pode ser vazio' })
|
|
42
|
-
@MaxLength(255)
|
|
43
|
-
dbUser: string;
|
|
44
|
-
|
|
45
|
-
@ApiProperty({ description: 'Senha do banco de dados', example: 'secret', maxLength: 255 })
|
|
46
|
-
@IsString()
|
|
47
|
-
@MinLength(1, { message: 'dbPassword não pode ser vazio' })
|
|
48
|
-
@MaxLength(255)
|
|
49
|
-
dbPassword: string;
|
|
50
|
-
|
|
51
|
-
@ApiPropertyOptional({ description: 'Status do tenant', enum: ['active', 'inactive'], default: 'active' })
|
|
52
|
-
@IsOptional()
|
|
53
|
-
@IsIn(['active', 'inactive'], { message: 'status deve ser active ou inactive' })
|
|
54
|
-
status?: 'active' | 'inactive';
|
|
55
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
-
import { IsInt } from 'class-validator';
|
|
3
|
-
import { UpdateTenantDto } from './update-tenant.dto';
|
|
4
|
-
|
|
5
|
-
/** Payload do Kafka para tenant.update: id + campos opcionais. */
|
|
6
|
-
export class UpdateTenantPayloadDto extends UpdateTenantDto {
|
|
7
|
-
@ApiProperty({ description: 'ID do tenant a ser atualizado', example: 1 })
|
|
8
|
-
@IsInt()
|
|
9
|
-
id: number;
|
|
10
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
-
import {
|
|
3
|
-
IsString,
|
|
4
|
-
IsOptional,
|
|
5
|
-
IsInt,
|
|
6
|
-
Min,
|
|
7
|
-
Max,
|
|
8
|
-
IsIn,
|
|
9
|
-
MaxLength,
|
|
10
|
-
MinLength,
|
|
11
|
-
} from 'class-validator';
|
|
12
|
-
|
|
13
|
-
export class UpdateTenantDto {
|
|
14
|
-
@ApiPropertyOptional({ description: 'Identificador único do tenant na URL', example: 'acme', maxLength: 255 })
|
|
15
|
-
@IsOptional()
|
|
16
|
-
@IsString()
|
|
17
|
-
@MinLength(1, { message: 'slug não pode ser vazio' })
|
|
18
|
-
@MaxLength(255)
|
|
19
|
-
slug?: string;
|
|
20
|
-
|
|
21
|
-
@ApiPropertyOptional({ description: 'Host do banco de dados do tenant', example: 'localhost', maxLength: 255 })
|
|
22
|
-
@IsOptional()
|
|
23
|
-
@IsString()
|
|
24
|
-
@MinLength(1, { message: 'dbHost não pode ser vazio' })
|
|
25
|
-
@MaxLength(255)
|
|
26
|
-
dbHost?: string;
|
|
27
|
-
|
|
28
|
-
@ApiPropertyOptional({ description: 'Porta do banco de dados', example: 5432, minimum: 1, maximum: 65535 })
|
|
29
|
-
@IsOptional()
|
|
30
|
-
@IsInt()
|
|
31
|
-
@Min(1)
|
|
32
|
-
@Max(65535)
|
|
33
|
-
dbPort?: number;
|
|
34
|
-
|
|
35
|
-
@ApiPropertyOptional({ description: 'Nome do banco de dados', example: 'tychat_acme', maxLength: 255 })
|
|
36
|
-
@IsOptional()
|
|
37
|
-
@IsString()
|
|
38
|
-
@MinLength(1, { message: 'dbName não pode ser vazio' })
|
|
39
|
-
@MaxLength(255)
|
|
40
|
-
dbName?: string;
|
|
41
|
-
|
|
42
|
-
@ApiPropertyOptional({ description: 'Usuário do banco de dados', example: 'tychat_user', maxLength: 255 })
|
|
43
|
-
@IsOptional()
|
|
44
|
-
@IsString()
|
|
45
|
-
@MinLength(1, { message: 'dbUser não pode ser vazio' })
|
|
46
|
-
@MaxLength(255)
|
|
47
|
-
dbUser?: string;
|
|
48
|
-
|
|
49
|
-
@ApiPropertyOptional({ description: 'Senha do banco de dados', example: 'secret', maxLength: 255 })
|
|
50
|
-
@IsOptional()
|
|
51
|
-
@IsString()
|
|
52
|
-
@MinLength(1, { message: 'dbPassword não pode ser vazio' })
|
|
53
|
-
@MaxLength(255)
|
|
54
|
-
dbPassword?: string;
|
|
55
|
-
|
|
56
|
-
@ApiPropertyOptional({ description: 'Status do tenant', enum: ['active', 'inactive'] })
|
|
57
|
-
@IsOptional()
|
|
58
|
-
@IsIn(['active', 'inactive'], { message: 'status deve ser active ou inactive' })
|
|
59
|
-
status?: 'active' | 'inactive';
|
|
60
|
-
}
|