@grupo-argenta/schema-kit-nest 0.0.20 → 0.0.21
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/config/naming-strategy.d.ts +6 -0
- package/config/naming-strategy.js +17 -0
- package/config/redis.constants.d.ts +1 -0
- package/config/redis.constants.js +4 -0
- package/context-logger.service.d.ts +4 -0
- package/context-logger.service.js +23 -0
- package/decorators/date-range.d.ts +4 -0
- package/decorators/date-range.js +17 -0
- package/decorators/encrypted.d.ts +10 -0
- package/decorators/encrypted.js +15 -0
- package/decorators/file-column.d.ts +17 -0
- package/decorators/file-column.js +20 -0
- package/decorators/get-user.decorator.d.ts +6 -0
- package/decorators/get-user.decorator.js +12 -0
- package/decorators/luxon.d.ts +6 -0
- package/decorators/luxon.js +20 -0
- package/decorators/multipart.decorator.d.ts +4 -0
- package/decorators/multipart.decorator.js +51 -0
- package/decorators/post-get.decorator.d.ts +10 -0
- package/decorators/post-get.decorator.js +25 -0
- package/decorators/query-or-body.decorator.d.ts +8 -0
- package/decorators/query-or-body.decorator.js +15 -0
- package/decorators/when.decorator.d.ts +8 -0
- package/decorators/when.decorator.js +16 -0
- package/html/components/badge.d.ts +13 -0
- package/html/components/badge.js +29 -0
- package/html/components/colors.d.ts +11 -0
- package/html/components/colors.js +15 -0
- package/html/components/component.d.ts +11 -0
- package/html/components/component.js +35 -0
- package/html/components/default/default-footer.d.ts +6 -0
- package/html/components/default/default-footer.js +18 -0
- package/html/components/default/default-header.d.ts +13 -0
- package/html/components/default/default-header.js +30 -0
- package/html/components/env-badge.d.ts +7 -0
- package/html/components/env-badge.js +29 -0
- package/html/components/grid.d.ts +17 -0
- package/html/components/grid.js +44 -0
- package/html/components/shell.d.ts +18 -0
- package/html/components/shell.js +423 -0
- package/html/components/table.d.ts +16 -0
- package/html/components/table.js +55 -0
- package/html/components/unordered-list.d.ts +6 -0
- package/html/components/unordered-list.js +21 -0
- package/index.d.ts +49 -0
- package/index.js +65 -0
- package/interfaces/paginated-result.d.ts +21 -0
- package/interfaces/paginated-result.js +12 -0
- package/modules/auth/access-token.d.ts +27 -0
- package/modules/auth/access-token.js +14 -0
- package/modules/auth/known-module.d.ts +45 -0
- package/modules/auth/known-module.js +46 -0
- package/modules/auth/refresh-token.d.ts +18 -0
- package/modules/auth/refresh-token.js +2 -0
- package/modules/auth/token-type.d.ts +4 -0
- package/modules/auth/token-type.js +8 -0
- package/modules/encrypted-column/encrypted-column.module.d.ts +16 -0
- package/modules/encrypted-column/encrypted-column.module.js +35 -0
- package/modules/pubsub/pubsub-dynamic-topic.service.d.ts +77 -0
- package/modules/pubsub/pubsub-dynamic-topic.service.js +324 -0
- package/modules/pubsub/pubsub-redeliver-subscriber.service.d.ts +14 -0
- package/modules/pubsub/pubsub-redeliver-subscriber.service.js +77 -0
- package/modules/pubsub/pubsub-redeliver.service.d.ts +22 -0
- package/modules/pubsub/pubsub-redeliver.service.js +48 -0
- package/modules/pubsub/pubsub.constants.d.ts +2 -0
- package/modules/pubsub/pubsub.constants.js +5 -0
- package/modules/pubsub/pubsub.methods.d.ts +18 -0
- package/modules/pubsub/pubsub.methods.js +18 -0
- package/modules/pubsub/pubsub.methods.redelivery.d.ts +3 -0
- package/modules/pubsub/pubsub.methods.redelivery.js +2 -0
- package/modules/redis/redis.module.d.ts +10 -0
- package/modules/redis/redis.module.js +59 -0
- package/modules/redis/redis.options.d.ts +7 -0
- package/modules/redis/redis.options.js +4 -0
- package/modules/storage/storage.service.d.ts +16 -0
- package/modules/storage/storage.service.js +61 -0
- package/monitoramento/http-request-log/http-request-log.controller.d.ts +184 -0
- package/monitoramento/http-request-log/http-request-log.controller.js +32 -0
- package/monitoramento/http-request-log/http-request-log.dto.d.ts +220 -0
- package/monitoramento/http-request-log/http-request-log.dto.js +42 -0
- package/monitoramento/http-request-log/http-request-log.entity.d.ts +17 -0
- package/monitoramento/http-request-log/http-request-log.entity.js +87 -0
- package/monitoramento/http-request-log/http-request-log.module.d.ts +2 -0
- package/monitoramento/http-request-log/http-request-log.module.js +26 -0
- package/monitoramento/http-request-log/http-request-log.service.d.ts +8 -0
- package/monitoramento/http-request-log/http-request-log.service.js +35 -0
- package/monitoramento/index.d.ts +17 -0
- package/monitoramento/index.js +33 -0
- package/monitoramento/migrations/1792689106394-create_http_request_logs_table.d.ts +5 -0
- package/monitoramento/migrations/1792689106394-create_http_request_logs_table.js +96 -0
- package/monitoramento/migrations/1792689106395-create_pubsub_message_logs_table.d.ts +5 -0
- package/monitoramento/migrations/1792689106395-create_pubsub_message_logs_table.js +157 -0
- package/monitoramento/monitoramento.constants.d.ts +2 -0
- package/monitoramento/monitoramento.constants.js +5 -0
- package/monitoramento/monitoramento.entities.d.ts +1 -0
- package/monitoramento/monitoramento.entities.js +7 -0
- package/monitoramento/monitoramento.module.d.ts +6 -0
- package/monitoramento/monitoramento.module.js +61 -0
- package/monitoramento/monitoramento.options.d.ts +15 -0
- package/monitoramento/monitoramento.options.js +2 -0
- package/monitoramento/outbound-request.interceptor.d.ts +14 -0
- package/monitoramento/outbound-request.interceptor.js +113 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.controller.d.ts +257 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.controller.js +34 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.dto.d.ts +320 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.dto.js +57 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.entity.d.ts +44 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.entity.js +152 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.module.d.ts +2 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.module.js +26 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.service.d.ts +20 -0
- package/monitoramento/pubsub-message-log/pubsub-message-log.service.js +99 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.controller.d.ts +9 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.controller.js +45 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.module.d.ts +11 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.module.js +41 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.options.d.ts +10 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.options.js +4 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.service.d.ts +68 -0
- package/monitoramento/pubsub-self-check/pubsub-self-check.service.js +213 -0
- package/package.json +1 -1
- package/schema/abstract.entity.d.ts +28 -0
- package/schema/abstract.entity.js +68 -0
- package/schema/schema-builder.d.ts +131 -0
- package/schema/schema-builder.js +162 -0
- package/schema/schema.controller.d.ts +51 -0
- package/schema/schema.controller.js +121 -0
- package/schema/schema.service.d.ts +81 -0
- package/schema/schema.service.js +305 -0
- package/schema/typeorm-extensions.d.ts +6 -0
- package/schema/typeorm-extensions.js +6 -0
- package/schema/zod-extensions/cnpj.validator.d.ts +28 -0
- package/schema/zod-extensions/cnpj.validator.js +133 -0
- package/schema/zod-extensions/cpf-cnpj.validator.d.ts +2 -0
- package/schema/zod-extensions/cpf-cnpj.validator.js +8 -0
- package/schema/zod-extensions/cpf.validator.d.ts +18 -0
- package/schema/zod-extensions/cpf.validator.js +166 -0
- package/schema/zod-extensions.d.ts +50 -0
- package/schema/zod-extensions.js +144 -0
- package/schema-kit.module.d.ts +2 -0
- package/schema-kit.module.js +23 -0
- package/transformers/date-range.transformer.d.ts +6 -0
- package/transformers/date-range.transformer.js +44 -0
- package/transformers/encrypted.transformer.d.ts +11 -0
- package/transformers/encrypted.transformer.js +35 -0
- package/transformers/luxon.transformer.d.ts +3 -0
- package/transformers/luxon.transformer.js +12 -0
- package/utils/utils.d.ts +49 -0
- package/utils/utils.js +79 -0
- package/validators/ip-validator.d.ts +3 -0
- package/validators/ip-validator.js +8 -0
- package/validators/pubsub-delete.validator.d.ts +6 -0
- package/validators/pubsub-delete.validator.js +11 -0
- package/validators/url-validator.d.ts +3 -0
- package/validators/url-validator.js +8 -0
- package/validators/uuid-validator.d.ts +3 -0
- package/validators/uuid-validator.js +8 -0
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HttpRequestLogModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const monitoramento_constants_1 = require("../monitoramento.constants");
|
|
13
|
+
const http_request_log_service_1 = require("./http-request-log.service");
|
|
14
|
+
const http_request_log_controller_1 = require("./http-request-log.controller");
|
|
15
|
+
const http_request_log_entity_1 = require("./http-request-log.entity");
|
|
16
|
+
let HttpRequestLogModule = class HttpRequestLogModule {
|
|
17
|
+
};
|
|
18
|
+
exports.HttpRequestLogModule = HttpRequestLogModule;
|
|
19
|
+
exports.HttpRequestLogModule = HttpRequestLogModule = __decorate([
|
|
20
|
+
(0, common_1.Module)({
|
|
21
|
+
imports: [typeorm_1.TypeOrmModule.forFeature([http_request_log_entity_1.HttpRequestLog], monitoramento_constants_1.MONITORAMENTO_CONNECTION)],
|
|
22
|
+
controllers: [http_request_log_controller_1.HttpRequestLogController],
|
|
23
|
+
providers: [http_request_log_service_1.HttpRequestLogService],
|
|
24
|
+
exports: [http_request_log_service_1.HttpRequestLogService],
|
|
25
|
+
})
|
|
26
|
+
], HttpRequestLogModule);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { SchemaService } from '../../schema/schema.service';
|
|
3
|
+
import { CreateHttpRequestLogDto, IndexHttpRequestLogParamsDto, PatchHttpRequestLogDto } from './http-request-log.dto';
|
|
4
|
+
import { HttpRequestLog } from './http-request-log.entity';
|
|
5
|
+
export declare class HttpRequestLogService extends SchemaService<HttpRequestLog, CreateHttpRequestLogDto, PatchHttpRequestLogDto, IndexHttpRequestLogParamsDto> {
|
|
6
|
+
private httpRequestLogRepository;
|
|
7
|
+
constructor(httpRequestLogRepository: Repository<HttpRequestLog>);
|
|
8
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.HttpRequestLogService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const schema_service_1 = require("../../schema/schema.service");
|
|
20
|
+
const monitoramento_constants_1 = require("../monitoramento.constants");
|
|
21
|
+
const http_request_log_dto_1 = require("./http-request-log.dto");
|
|
22
|
+
const http_request_log_entity_1 = require("./http-request-log.entity");
|
|
23
|
+
let HttpRequestLogService = class HttpRequestLogService extends schema_service_1.SchemaService {
|
|
24
|
+
httpRequestLogRepository;
|
|
25
|
+
constructor(httpRequestLogRepository) {
|
|
26
|
+
super(httpRequestLogRepository, http_request_log_dto_1.indexSchemaHttpRequestLog);
|
|
27
|
+
this.httpRequestLogRepository = httpRequestLogRepository;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.HttpRequestLogService = HttpRequestLogService;
|
|
31
|
+
exports.HttpRequestLogService = HttpRequestLogService = __decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
__param(0, (0, typeorm_1.InjectRepository)(http_request_log_entity_1.HttpRequestLog, monitoramento_constants_1.MONITORAMENTO_CONNECTION)),
|
|
34
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
35
|
+
], HttpRequestLogService);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './monitoramento.constants';
|
|
2
|
+
export * from './monitoramento.entities';
|
|
3
|
+
export * from './monitoramento.options';
|
|
4
|
+
export * from './monitoramento.module';
|
|
5
|
+
export * from './http-request-log/http-request-log.entity';
|
|
6
|
+
export * from './http-request-log/http-request-log.dto';
|
|
7
|
+
export * from './http-request-log/http-request-log.service';
|
|
8
|
+
export * from './http-request-log/http-request-log.module';
|
|
9
|
+
export * from './pubsub-message-log/pubsub-message-log.entity';
|
|
10
|
+
export * from './pubsub-message-log/pubsub-message-log.dto';
|
|
11
|
+
export * from './pubsub-message-log/pubsub-message-log.service';
|
|
12
|
+
export * from './pubsub-message-log/pubsub-message-log.module';
|
|
13
|
+
export * from './pubsub-self-check/pubsub-self-check.options';
|
|
14
|
+
export * from './pubsub-self-check/pubsub-self-check.service';
|
|
15
|
+
export * from './pubsub-self-check/pubsub-self-check.controller';
|
|
16
|
+
export * from './pubsub-self-check/pubsub-self-check.module';
|
|
17
|
+
export * from './outbound-request.interceptor';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./monitoramento.constants"), exports);
|
|
18
|
+
__exportStar(require("./monitoramento.entities"), exports);
|
|
19
|
+
__exportStar(require("./monitoramento.options"), exports);
|
|
20
|
+
__exportStar(require("./monitoramento.module"), exports);
|
|
21
|
+
__exportStar(require("./http-request-log/http-request-log.entity"), exports);
|
|
22
|
+
__exportStar(require("./http-request-log/http-request-log.dto"), exports);
|
|
23
|
+
__exportStar(require("./http-request-log/http-request-log.service"), exports);
|
|
24
|
+
__exportStar(require("./http-request-log/http-request-log.module"), exports);
|
|
25
|
+
__exportStar(require("./pubsub-message-log/pubsub-message-log.entity"), exports);
|
|
26
|
+
__exportStar(require("./pubsub-message-log/pubsub-message-log.dto"), exports);
|
|
27
|
+
__exportStar(require("./pubsub-message-log/pubsub-message-log.service"), exports);
|
|
28
|
+
__exportStar(require("./pubsub-message-log/pubsub-message-log.module"), exports);
|
|
29
|
+
__exportStar(require("./pubsub-self-check/pubsub-self-check.options"), exports);
|
|
30
|
+
__exportStar(require("./pubsub-self-check/pubsub-self-check.service"), exports);
|
|
31
|
+
__exportStar(require("./pubsub-self-check/pubsub-self-check.controller"), exports);
|
|
32
|
+
__exportStar(require("./pubsub-self-check/pubsub-self-check.module"), exports);
|
|
33
|
+
__exportStar(require("./outbound-request.interceptor"), exports);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateHttpRequestLogsTable1792689106394 = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
class CreateHttpRequestLogsTable1792689106394 {
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
8
|
+
name: 'http_request_logs',
|
|
9
|
+
columns: [
|
|
10
|
+
{
|
|
11
|
+
name: 'uuid',
|
|
12
|
+
type: 'uuid',
|
|
13
|
+
isPrimary: true,
|
|
14
|
+
default: 'uuidv7()',
|
|
15
|
+
isNullable: false,
|
|
16
|
+
},
|
|
17
|
+
// Request
|
|
18
|
+
{
|
|
19
|
+
name: 'method',
|
|
20
|
+
type: 'varchar',
|
|
21
|
+
length: '10',
|
|
22
|
+
isNullable: false,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'url',
|
|
26
|
+
type: 'text',
|
|
27
|
+
isNullable: false,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'request_headers',
|
|
31
|
+
type: 'jsonb',
|
|
32
|
+
isNullable: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'request_body',
|
|
36
|
+
type: 'jsonb',
|
|
37
|
+
isNullable: true,
|
|
38
|
+
},
|
|
39
|
+
// Response
|
|
40
|
+
{
|
|
41
|
+
name: 'response_status',
|
|
42
|
+
type: 'smallint',
|
|
43
|
+
isNullable: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'response_headers',
|
|
47
|
+
type: 'jsonb',
|
|
48
|
+
isNullable: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'response_body',
|
|
52
|
+
type: 'jsonb',
|
|
53
|
+
isNullable: true,
|
|
54
|
+
},
|
|
55
|
+
// Timing
|
|
56
|
+
{
|
|
57
|
+
name: 'started_at',
|
|
58
|
+
type: 'timestamptz',
|
|
59
|
+
default: 'now()',
|
|
60
|
+
isNullable: false,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'finished_at',
|
|
64
|
+
type: 'timestamptz',
|
|
65
|
+
isNullable: true,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'duration_ms',
|
|
69
|
+
type: 'integer',
|
|
70
|
+
isNullable: true,
|
|
71
|
+
},
|
|
72
|
+
// Errors
|
|
73
|
+
{
|
|
74
|
+
name: 'error_message',
|
|
75
|
+
type: 'text',
|
|
76
|
+
isNullable: true,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'error_stack',
|
|
80
|
+
type: 'text',
|
|
81
|
+
isNullable: true,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'created_at',
|
|
85
|
+
type: 'timestamptz',
|
|
86
|
+
default: 'now()',
|
|
87
|
+
isNullable: false,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
async down(queryRunner) {
|
|
93
|
+
await queryRunner.dropTable('http_request_logs', true);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.CreateHttpRequestLogsTable1792689106394 = CreateHttpRequestLogsTable1792689106394;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreatePubsubMessageLogsTable1792689106395 = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
class CreatePubsubMessageLogsTable1792689106395 {
|
|
6
|
+
async up(queryRunner) {
|
|
7
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
8
|
+
name: 'pubsub_message_logs',
|
|
9
|
+
columns: [
|
|
10
|
+
{
|
|
11
|
+
name: 'uuid',
|
|
12
|
+
type: 'uuid',
|
|
13
|
+
isPrimary: true,
|
|
14
|
+
default: 'uuidv7()',
|
|
15
|
+
isNullable: false,
|
|
16
|
+
},
|
|
17
|
+
// Direção: mensagem enviada ou recebida
|
|
18
|
+
{
|
|
19
|
+
name: 'direction',
|
|
20
|
+
type: 'varchar',
|
|
21
|
+
length: '10',
|
|
22
|
+
isNullable: false,
|
|
23
|
+
},
|
|
24
|
+
// Identificação / roteamento
|
|
25
|
+
{
|
|
26
|
+
name: 'topic',
|
|
27
|
+
type: 'text',
|
|
28
|
+
isNullable: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
// API que publicou a mensagem (`from` do envelope)
|
|
32
|
+
name: 'origin_api',
|
|
33
|
+
type: 'text',
|
|
34
|
+
isNullable: true,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
// NULL no publish
|
|
38
|
+
name: 'subscription',
|
|
39
|
+
type: 'text',
|
|
40
|
+
isNullable: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
// ID atribuído pelo broker (conhecido após o publish / no recebimento)
|
|
44
|
+
name: 'message_id',
|
|
45
|
+
type: 'text',
|
|
46
|
+
isNullable: true,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'ordering_key',
|
|
50
|
+
type: 'text',
|
|
51
|
+
isNullable: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
// Handler do consumer / função do publisher
|
|
55
|
+
name: 'handler',
|
|
56
|
+
type: 'text',
|
|
57
|
+
isNullable: true,
|
|
58
|
+
},
|
|
59
|
+
// Conteúdo
|
|
60
|
+
{
|
|
61
|
+
name: 'attributes',
|
|
62
|
+
type: 'jsonb',
|
|
63
|
+
isNullable: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'payload',
|
|
67
|
+
type: 'jsonb',
|
|
68
|
+
isNullable: true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'payload_size_bytes',
|
|
72
|
+
type: 'integer',
|
|
73
|
+
isNullable: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'content_type',
|
|
77
|
+
type: 'text',
|
|
78
|
+
isNullable: true,
|
|
79
|
+
},
|
|
80
|
+
// Entrega (lado do consumer)
|
|
81
|
+
{
|
|
82
|
+
name: 'publish_time',
|
|
83
|
+
type: 'timestamptz',
|
|
84
|
+
isNullable: true,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
// 1 na primeira entrega, incrementa a cada reentrega
|
|
88
|
+
name: 'delivery_attempt',
|
|
89
|
+
type: 'integer',
|
|
90
|
+
isNullable: true,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'ack_status',
|
|
94
|
+
type: 'varchar',
|
|
95
|
+
length: '20',
|
|
96
|
+
isNullable: true,
|
|
97
|
+
},
|
|
98
|
+
// Tracing
|
|
99
|
+
{
|
|
100
|
+
// Requisição HTTP ou job que originou a mensagem
|
|
101
|
+
name: 'correlation_id',
|
|
102
|
+
type: 'text',
|
|
103
|
+
isNullable: true,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'trace_id',
|
|
107
|
+
type: 'text',
|
|
108
|
+
isNullable: true,
|
|
109
|
+
},
|
|
110
|
+
// Timing
|
|
111
|
+
{
|
|
112
|
+
name: 'started_at',
|
|
113
|
+
type: 'timestamptz',
|
|
114
|
+
default: 'now()',
|
|
115
|
+
isNullable: false,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'finished_at',
|
|
119
|
+
type: 'timestamptz',
|
|
120
|
+
isNullable: true,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'duration_ms',
|
|
124
|
+
type: 'integer',
|
|
125
|
+
isNullable: true,
|
|
126
|
+
},
|
|
127
|
+
// Errors
|
|
128
|
+
{
|
|
129
|
+
name: 'error_message',
|
|
130
|
+
type: 'text',
|
|
131
|
+
isNullable: true,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'error_stack',
|
|
135
|
+
type: 'text',
|
|
136
|
+
isNullable: true,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'created_at',
|
|
140
|
+
type: 'timestamptz',
|
|
141
|
+
default: 'now()',
|
|
142
|
+
isNullable: false,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
checks: [
|
|
146
|
+
{
|
|
147
|
+
name: 'chk_pubsub_message_logs_ack_status',
|
|
148
|
+
expression: `ack_status IN ('ack', 'nack', 'dead_lettered', 'ignored')`,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
async down(queryRunner) {
|
|
154
|
+
await queryRunner.dropTable('pubsub_message_logs', true);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.CreatePubsubMessageLogsTable1792689106395 = CreatePubsubMessageLogsTable1792689106395;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MONITORAMENTO_MIGRATIONS_TABLE = exports.MONITORAMENTO_CONNECTION = void 0;
|
|
4
|
+
exports.MONITORAMENTO_CONNECTION = 'MONITORAMENTO_CONNECTION';
|
|
5
|
+
exports.MONITORAMENTO_MIGRATIONS_TABLE = 'monitoramento_migrations';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MONITORAMENTO_ENTITIES: Function[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MONITORAMENTO_ENTITIES = void 0;
|
|
4
|
+
const http_request_log_entity_1 = require("./http-request-log/http-request-log.entity");
|
|
5
|
+
const pubsub_message_log_entity_1 = require("./pubsub-message-log/pubsub-message-log.entity");
|
|
6
|
+
// Lista explícita (sem glob) para funcionar com o bundle do rspack e com o CLI do TypeORM
|
|
7
|
+
exports.MONITORAMENTO_ENTITIES = [http_request_log_entity_1.HttpRequestLog, pubsub_message_log_entity_1.PubsubMessageLog];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { IMonitoramentoOptions, IMonitoramentoModuleAsyncOptions } from './monitoramento.options';
|
|
3
|
+
export declare class MonitoramentoModule {
|
|
4
|
+
static forRoot(options: IMonitoramentoOptions): DynamicModule;
|
|
5
|
+
static forRootAsync(options: IMonitoramentoModuleAsyncOptions): DynamicModule;
|
|
6
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 MonitoramentoModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MonitoramentoModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
13
|
+
const naming_strategy_1 = require("../config/naming-strategy");
|
|
14
|
+
const monitoramento_constants_1 = require("./monitoramento.constants");
|
|
15
|
+
const monitoramento_entities_1 = require("./monitoramento.entities");
|
|
16
|
+
const http_request_log_module_1 = require("./http-request-log/http-request-log.module");
|
|
17
|
+
const pubsub_message_log_module_1 = require("./pubsub-message-log/pubsub-message-log.module");
|
|
18
|
+
const _1792689106394_create_http_request_logs_table_1 = require("./migrations/1792689106394-create_http_request_logs_table");
|
|
19
|
+
const _1792689106395_create_pubsub_message_logs_table_1 = require("./migrations/1792689106395-create_pubsub_message_logs_table");
|
|
20
|
+
let MonitoramentoModule = MonitoramentoModule_1 = class MonitoramentoModule {
|
|
21
|
+
static forRoot(options) {
|
|
22
|
+
return this.forRootAsync({ useFactory: () => options });
|
|
23
|
+
}
|
|
24
|
+
static forRootAsync(options) {
|
|
25
|
+
return {
|
|
26
|
+
module: MonitoramentoModule_1,
|
|
27
|
+
// Global para os PubSubDynamicTopicService de qualquer módulo receberem o PubsubMessageLogService
|
|
28
|
+
global: true,
|
|
29
|
+
imports: [
|
|
30
|
+
typeorm_1.TypeOrmModule.forRootAsync({
|
|
31
|
+
name: monitoramento_constants_1.MONITORAMENTO_CONNECTION,
|
|
32
|
+
imports: options.imports,
|
|
33
|
+
inject: options.inject,
|
|
34
|
+
useFactory: async (...args) => {
|
|
35
|
+
const { ssl, ...database } = await options.useFactory(...args);
|
|
36
|
+
return {
|
|
37
|
+
...database,
|
|
38
|
+
type: 'postgres',
|
|
39
|
+
name: monitoramento_constants_1.MONITORAMENTO_CONNECTION,
|
|
40
|
+
ssl: ssl ?? { rejectUnauthorized: false },
|
|
41
|
+
entities: monitoramento_entities_1.MONITORAMENTO_ENTITIES,
|
|
42
|
+
autoLoadEntities: false,
|
|
43
|
+
synchronize: false,
|
|
44
|
+
migrations: [_1792689106394_create_http_request_logs_table_1.CreateHttpRequestLogsTable1792689106394, _1792689106395_create_pubsub_message_logs_table_1.CreatePubsubMessageLogsTable1792689106395],
|
|
45
|
+
migrationsRun: true,
|
|
46
|
+
migrationsTableName: monitoramento_constants_1.MONITORAMENTO_MIGRATIONS_TABLE,
|
|
47
|
+
namingStrategy: new naming_strategy_1.SnakeCaseNamingStrategy(),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
http_request_log_module_1.HttpRequestLogModule,
|
|
52
|
+
pubsub_message_log_module_1.PubsubMessageLogModule,
|
|
53
|
+
],
|
|
54
|
+
exports: [http_request_log_module_1.HttpRequestLogModule, pubsub_message_log_module_1.PubsubMessageLogModule],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.MonitoramentoModule = MonitoramentoModule;
|
|
59
|
+
exports.MonitoramentoModule = MonitoramentoModule = MonitoramentoModule_1 = __decorate([
|
|
60
|
+
(0, common_1.Module)({})
|
|
61
|
+
], MonitoramentoModule);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
export interface IMonitoramentoOptions {
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
database: string;
|
|
8
|
+
ssl?: boolean | {
|
|
9
|
+
rejectUnauthorized: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface IMonitoramentoModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
13
|
+
inject?: any[];
|
|
14
|
+
useFactory: (...args: any[]) => IMonitoramentoOptions | Promise<IMonitoramentoOptions>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HttpClientInterceptor, HttpHandler, HttpRequest } from '@nestjs/http-client';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { ContextLogger } from '../context-logger.service';
|
|
4
|
+
import { HttpRequestLog } from './http-request-log/http-request-log.entity';
|
|
5
|
+
export declare class OutboundRequestInterceptor implements HttpClientInterceptor {
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private readonly httpReq;
|
|
8
|
+
constructor(logger: ContextLogger, httpReq: Repository<HttpRequestLog>);
|
|
9
|
+
intercept(request: HttpRequest, next: HttpHandler): Promise<Response>;
|
|
10
|
+
private searchParamsToRecord;
|
|
11
|
+
private parseRequestBody;
|
|
12
|
+
private readResponseBody;
|
|
13
|
+
private tryParseJson;
|
|
14
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OutboundRequestInterceptor = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("typeorm");
|
|
18
|
+
const typeorm_2 = require("@nestjs/typeorm");
|
|
19
|
+
const luxon_1 = require("luxon");
|
|
20
|
+
// Imports relativos: importar o barrel da própria lib gera dependência circular
|
|
21
|
+
const context_logger_service_1 = require("../context-logger.service");
|
|
22
|
+
const http_request_log_entity_1 = require("./http-request-log/http-request-log.entity");
|
|
23
|
+
const monitoramento_constants_1 = require("./monitoramento.constants");
|
|
24
|
+
let OutboundRequestInterceptor = class OutboundRequestInterceptor {
|
|
25
|
+
logger;
|
|
26
|
+
httpReq;
|
|
27
|
+
constructor(logger, httpReq) {
|
|
28
|
+
this.logger = logger;
|
|
29
|
+
this.httpReq = httpReq;
|
|
30
|
+
logger.setContext('OutboundRequestInterceptor');
|
|
31
|
+
}
|
|
32
|
+
async intercept(request, next) {
|
|
33
|
+
const startedAt = luxon_1.DateTime.now();
|
|
34
|
+
const newLog = this.httpReq.create({
|
|
35
|
+
method: request.method,
|
|
36
|
+
url: request.url.toString(),
|
|
37
|
+
requestHeaders: Object.fromEntries(request.headers.entries()),
|
|
38
|
+
requestBody: this.parseRequestBody(request.body),
|
|
39
|
+
startedAt,
|
|
40
|
+
});
|
|
41
|
+
this.logger.log(`Intercepting request: ${request.method} ${request.url}`);
|
|
42
|
+
try {
|
|
43
|
+
const response = await next(request);
|
|
44
|
+
this.logger.log(`Response received: ${response.status} ${response.statusText}`);
|
|
45
|
+
newLog.responseStatus = response.status;
|
|
46
|
+
newLog.responseHeaders = Object.fromEntries(response.headers.entries());
|
|
47
|
+
// Lê de um clone para não consumir o body que o HttpClient ainda vai ler
|
|
48
|
+
newLog.responseBody = await this.readResponseBody(response.clone());
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.logger.error('Error in OutboundRequestInterceptor:', error);
|
|
53
|
+
newLog.errorMessage = error instanceof Error ? error.message : String(error);
|
|
54
|
+
newLog.errorStack = error instanceof Error ? (error.stack ?? null) : null;
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
const finishedAt = luxon_1.DateTime.now();
|
|
59
|
+
newLog.finishedAt = finishedAt;
|
|
60
|
+
newLog.durationMs = Math.round(finishedAt.diff(startedAt).as('milliseconds'));
|
|
61
|
+
// Não aguarda o save para não atrasar a resposta ao chamador
|
|
62
|
+
this.httpReq.save(newLog).catch((error) => {
|
|
63
|
+
this.logger.error('Error saving HTTP request log:', error);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
searchParamsToRecord(params) {
|
|
68
|
+
const record = {};
|
|
69
|
+
params.forEach((value, key) => {
|
|
70
|
+
const current = record[key];
|
|
71
|
+
record[key] = current === undefined ? value : [...(Array.isArray(current) ? current : [current]), value];
|
|
72
|
+
});
|
|
73
|
+
return Object.keys(record).length ? record : null;
|
|
74
|
+
}
|
|
75
|
+
parseRequestBody(body) {
|
|
76
|
+
if (body == null)
|
|
77
|
+
return null;
|
|
78
|
+
if (typeof body === 'string')
|
|
79
|
+
return this.tryParseJson(body);
|
|
80
|
+
if (body instanceof URLSearchParams)
|
|
81
|
+
return this.searchParamsToRecord(body);
|
|
82
|
+
// Streams, buffers e FormData não são serializados
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
async readResponseBody(response) {
|
|
86
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
87
|
+
if (!/json|text|xml/i.test(contentType))
|
|
88
|
+
return null;
|
|
89
|
+
try {
|
|
90
|
+
const text = await response.text();
|
|
91
|
+
return text ? this.tryParseJson(text) : null;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
tryParseJson(text) {
|
|
98
|
+
try {
|
|
99
|
+
return JSON.parse(text);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// jsonb aceita string JSON
|
|
103
|
+
return text;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.OutboundRequestInterceptor = OutboundRequestInterceptor;
|
|
108
|
+
exports.OutboundRequestInterceptor = OutboundRequestInterceptor = __decorate([
|
|
109
|
+
(0, common_1.Injectable)(),
|
|
110
|
+
__param(1, (0, typeorm_2.InjectRepository)(http_request_log_entity_1.HttpRequestLog, monitoramento_constants_1.MONITORAMENTO_CONNECTION)),
|
|
111
|
+
__metadata("design:paramtypes", [context_logger_service_1.ContextLogger,
|
|
112
|
+
typeorm_1.Repository])
|
|
113
|
+
], OutboundRequestInterceptor);
|