@seidor-cloud-produtos/orbit-backend-lib 0.0.69 → 0.0.71

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.
Files changed (162) hide show
  1. package/README.md +0 -0
  2. package/dist/clean-arch/application/cache/cache.d.ts +2 -2
  3. package/dist/clean-arch/application/cache/cache.js +2 -6
  4. package/dist/clean-arch/application/cache/client.d.ts +1 -1
  5. package/dist/clean-arch/application/cache/client.js +0 -0
  6. package/dist/clean-arch/application/orbit-http-client/orbit-http-client-dto.d.ts +27 -0
  7. package/dist/clean-arch/application/orbit-http-client/orbit-http-client-dto.js +2 -0
  8. package/dist/clean-arch/application/orbit-http-client/orbit-http-client.d.ts +7 -0
  9. package/dist/clean-arch/application/orbit-http-client/orbit-http-client.js +5 -0
  10. package/dist/clean-arch/application/queue/handler.d.ts +0 -0
  11. package/dist/clean-arch/application/queue/handler.js +0 -0
  12. package/dist/clean-arch/application/queue/messages-in-memory.d.ts +0 -0
  13. package/dist/clean-arch/application/queue/messages-in-memory.js +0 -0
  14. package/dist/clean-arch/application/queue/queue-connection.d.ts +0 -0
  15. package/dist/clean-arch/application/queue/queue-connection.js +0 -0
  16. package/dist/clean-arch/application/queue/queue.d.ts +0 -0
  17. package/dist/clean-arch/application/queue/queue.js +0 -0
  18. package/dist/clean-arch/domain/entities/aggregate-root.d.ts +0 -0
  19. package/dist/clean-arch/domain/entities/aggregate-root.js +0 -0
  20. package/dist/clean-arch/domain/entities/common-dto.d.ts +0 -0
  21. package/dist/clean-arch/domain/entities/common-dto.js +0 -0
  22. package/dist/clean-arch/domain/entities/entity.d.ts +0 -0
  23. package/dist/clean-arch/domain/entities/entity.js +0 -0
  24. package/dist/clean-arch/domain/entities/unique-entity-id.d.ts +0 -0
  25. package/dist/clean-arch/domain/entities/unique-entity-id.js +0 -0
  26. package/dist/clean-arch/domain/entities/value-object.d.ts +0 -0
  27. package/dist/clean-arch/domain/entities/value-object.js +0 -0
  28. package/dist/clean-arch/domain/entities/watched-list.d.ts +0 -0
  29. package/dist/clean-arch/domain/entities/watched-list.js +0 -0
  30. package/dist/clean-arch/domain/entities/watched-list.spec.d.ts +0 -0
  31. package/dist/clean-arch/domain/entities/watched-list.spec.js +0 -0
  32. package/dist/clean-arch/domain/errors/application-error.d.ts +0 -0
  33. package/dist/clean-arch/domain/errors/application-error.js +0 -0
  34. package/dist/clean-arch/domain/errors/domain-error.d.ts +0 -0
  35. package/dist/clean-arch/domain/errors/domain-error.js +0 -0
  36. package/dist/clean-arch/domain/errors/http-error.d.ts +11 -0
  37. package/dist/clean-arch/domain/errors/http-error.js +10 -0
  38. package/dist/clean-arch/domain/errors/invalid-password-algorithm-error.d.ts +0 -0
  39. package/dist/clean-arch/domain/errors/invalid-password-algorithm-error.js +0 -0
  40. package/dist/clean-arch/domain/errors/invalid-password-length-error.d.ts +0 -0
  41. package/dist/clean-arch/domain/errors/invalid-password-length-error.js +0 -0
  42. package/dist/clean-arch/domain/errors/validation-error.d.ts +0 -0
  43. package/dist/clean-arch/domain/errors/validation-error.js +0 -0
  44. package/dist/clean-arch/domain/events/domain-event.d.ts +0 -0
  45. package/dist/clean-arch/domain/events/domain-event.js +0 -0
  46. package/dist/clean-arch/domain/factories/create-password-factory.d.ts +0 -0
  47. package/dist/clean-arch/domain/factories/create-password-factory.js +0 -0
  48. package/dist/clean-arch/domain/factories/random-password-temporary-factory.d.ts +0 -0
  49. package/dist/clean-arch/domain/factories/random-password-temporary-factory.js +0 -0
  50. package/dist/clean-arch/domain/types/optional.d.ts +0 -0
  51. package/dist/clean-arch/domain/types/optional.js +0 -0
  52. package/dist/clean-arch/domain/value-objects/password.d.ts +0 -0
  53. package/dist/clean-arch/domain/value-objects/password.js +0 -0
  54. package/dist/clean-arch/domain/value-objects/pbkdf2-password.d.ts +0 -0
  55. package/dist/clean-arch/domain/value-objects/pbkdf2-password.js +0 -0
  56. package/dist/clean-arch/domain/value-objects/sha1-password.d.ts +0 -0
  57. package/dist/clean-arch/domain/value-objects/sha1-password.js +0 -0
  58. package/dist/clean-arch/infra/adapters/express-adapter.d.ts +0 -0
  59. package/dist/clean-arch/infra/adapters/express-adapter.js +0 -0
  60. package/dist/clean-arch/infra/adapters/fastify-adapter.d.ts +0 -0
  61. package/dist/clean-arch/infra/adapters/fastify-adapter.js +0 -0
  62. package/dist/clean-arch/infra/authorizations/authorization.d.ts +0 -0
  63. package/dist/clean-arch/infra/authorizations/authorization.js +0 -0
  64. package/dist/clean-arch/infra/authorizations/authorizer.d.ts +0 -0
  65. package/dist/clean-arch/infra/authorizations/authorizer.js +0 -0
  66. package/dist/clean-arch/infra/authorizations/authorizer.spec.d.ts +0 -0
  67. package/dist/clean-arch/infra/authorizations/authorizer.spec.js +0 -0
  68. package/dist/clean-arch/infra/authorizations/not-allowed.d.ts +0 -0
  69. package/dist/clean-arch/infra/authorizations/not-allowed.js +0 -0
  70. package/dist/clean-arch/infra/cache/clients/node-cache.d.ts +0 -0
  71. package/dist/clean-arch/infra/cache/clients/node-cache.js +0 -0
  72. package/dist/clean-arch/infra/cache/clients/redis.d.ts +1 -1
  73. package/dist/clean-arch/infra/cache/clients/redis.js +11 -5
  74. package/dist/clean-arch/infra/environment/env.d.ts +0 -0
  75. package/dist/clean-arch/infra/environment/env.js +0 -0
  76. package/dist/clean-arch/infra/environment/environment.d.ts +0 -0
  77. package/dist/clean-arch/infra/environment/environment.js +0 -0
  78. package/dist/clean-arch/infra/errors/infra-error.d.ts +0 -0
  79. package/dist/clean-arch/infra/errors/infra-error.js +0 -0
  80. package/dist/clean-arch/infra/http/controller.d.ts +0 -0
  81. package/dist/clean-arch/infra/http/controller.js +0 -0
  82. package/dist/clean-arch/infra/http/handle-bool-filter.d.ts +0 -0
  83. package/dist/clean-arch/infra/http/handle-bool-filter.js +0 -0
  84. package/dist/clean-arch/infra/http/handle-is-active-query.d.ts +0 -0
  85. package/dist/clean-arch/infra/http/handle-is-active-query.js +0 -0
  86. package/dist/clean-arch/infra/http/handle-sort-param-query.d.ts +0 -0
  87. package/dist/clean-arch/infra/http/handle-sort-param-query.js +0 -0
  88. package/dist/clean-arch/infra/http/handle-user-headers.d.ts +0 -0
  89. package/dist/clean-arch/infra/http/handle-user-headers.js +0 -0
  90. package/dist/clean-arch/infra/http/health-connections.d.ts +0 -0
  91. package/dist/clean-arch/infra/http/health-connections.js +0 -0
  92. package/dist/clean-arch/infra/http/http.d.ts +0 -0
  93. package/dist/clean-arch/infra/http/http.js +0 -0
  94. package/dist/clean-arch/infra/orbit-http-client/orbit-axios-client/orbit-axios-client.d.ts +14 -0
  95. package/dist/clean-arch/infra/orbit-http-client/orbit-axios-client/orbit-axios-client.js +54 -0
  96. package/dist/clean-arch/infra/queue/create-consumers.d.ts +0 -0
  97. package/dist/clean-arch/infra/queue/create-consumers.js +0 -0
  98. package/dist/clean-arch/infra/queue/in-memory/in-memory-queue.d.ts +0 -0
  99. package/dist/clean-arch/infra/queue/in-memory/in-memory-queue.js +0 -0
  100. package/dist/clean-arch/infra/queue/queue-controller.d.ts +0 -0
  101. package/dist/clean-arch/infra/queue/queue-controller.js +0 -0
  102. package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.d.ts +0 -0
  103. package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.js +0 -0
  104. package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.spec.d.ts +0 -0
  105. package/dist/clean-arch/infra/queue/rabbitmq/amqp-lib.spec.js +0 -0
  106. package/dist/clean-arch/shared/pagination/dto-response.d.ts +0 -0
  107. package/dist/clean-arch/shared/pagination/dto-response.js +0 -0
  108. package/dist/clean-arch/shared/pagination/get-take-and-skip.d.ts +0 -0
  109. package/dist/clean-arch/shared/pagination/get-take-and-skip.js +0 -0
  110. package/dist/clean-arch/shared/pagination/pagination.d.ts +0 -0
  111. package/dist/clean-arch/shared/pagination/pagination.js +0 -0
  112. package/dist/frameworks/express/api-gateway/mapping-model.d.ts +0 -0
  113. package/dist/frameworks/express/api-gateway/mapping-model.js +0 -0
  114. package/dist/frameworks/express/api-gateway/mapping-model.spec.d.ts +0 -0
  115. package/dist/frameworks/express/api-gateway/mapping-model.spec.js +0 -0
  116. package/dist/frameworks/express/api-gateway/middleware-express.d.ts +0 -0
  117. package/dist/frameworks/express/api-gateway/middleware-express.js +0 -0
  118. package/dist/frameworks/express/authorizations/authorization-express.d.ts +0 -0
  119. package/dist/frameworks/express/authorizations/authorization-express.js +0 -0
  120. package/dist/frameworks/express/authorizations/authorization-express.spec.d.ts +0 -0
  121. package/dist/frameworks/express/authorizations/authorization-express.spec.js +0 -0
  122. package/dist/frameworks/express/authorizations/middleware-express.d.ts +0 -0
  123. package/dist/frameworks/express/authorizations/middleware-express.js +0 -0
  124. package/dist/frameworks/express/compression/middleware-express.d.ts +0 -0
  125. package/dist/frameworks/express/compression/middleware-express.js +0 -0
  126. package/dist/frameworks/express/types.d.ts +0 -0
  127. package/dist/frameworks/express/types.js +0 -0
  128. package/dist/frameworks/nest/authorizations/authorization-nest.d.ts +0 -0
  129. package/dist/frameworks/nest/authorizations/authorization-nest.js +0 -0
  130. package/dist/frameworks/nest/authorizations/guard-nest.d.ts +0 -0
  131. package/dist/frameworks/nest/authorizations/guard-nest.js +0 -0
  132. package/dist/frameworks/nest/authorizations/not-allowed-nest.d.ts +0 -0
  133. package/dist/frameworks/nest/authorizations/not-allowed-nest.js +0 -0
  134. package/dist/index.d.ts +0 -0
  135. package/dist/index.js +0 -0
  136. package/dist/infra/authorizations/auth-matcher.d.ts +0 -0
  137. package/dist/infra/authorizations/auth-matcher.js +0 -0
  138. package/dist/infra/authorizations/auth-matcher.spec.d.ts +0 -0
  139. package/dist/infra/authorizations/auth-matcher.spec.js +0 -0
  140. package/dist/infra/authorizations/validator/api/api-validator.d.ts +0 -0
  141. package/dist/infra/authorizations/validator/api/api-validator.js +0 -0
  142. package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.d.ts +0 -0
  143. package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.js +0 -0
  144. package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.spec.d.ts +0 -0
  145. package/dist/infra/authorizations/validator/api/factories/unauthorized-response-factory.spec.js +0 -0
  146. package/dist/infra/authorizations/validator/auth-validator.d.ts +0 -0
  147. package/dist/infra/authorizations/validator/auth-validator.js +0 -0
  148. package/dist/infra/authorizations/validator/auth-validator.spec.d.ts +0 -0
  149. package/dist/infra/authorizations/validator/auth-validator.spec.js +0 -0
  150. package/dist/infra/http/api-gateway/mapping-model.d.ts +0 -0
  151. package/dist/infra/http/api-gateway/mapping-model.js +0 -0
  152. package/dist/infra/http/api-gateway/mapping-model.spec.d.ts +0 -0
  153. package/dist/infra/http/api-gateway/mapping-model.spec.js +0 -0
  154. package/dist/infra/http/compression/filter.d.ts +0 -0
  155. package/dist/infra/http/compression/filter.js +0 -0
  156. package/dist/infra/http/errors/api-common-error.d.ts +0 -0
  157. package/dist/infra/http/errors/api-common-error.js +0 -0
  158. package/dist/infra/http/errors/api-error.d.ts +0 -0
  159. package/dist/infra/http/errors/api-error.js +0 -0
  160. package/dist/infra/http/errors/unauthorized-response.d.ts +0 -0
  161. package/dist/infra/http/errors/unauthorized-response.js +0 -0
  162. package/package.json +2 -1
package/README.md CHANGED
File without changes
@@ -4,9 +4,9 @@ export declare abstract class Cache {
4
4
  protected DEFAULT_EXPIRATION_SECONDS: number;
5
5
  start(): Promise<void>;
6
6
  get(keyCache: string): Promise<any>;
7
- set(keyCache: string, data: any, expiration: number): Promise<void>;
7
+ set(keyCache: string, data: any, expiration?: number): Promise<void>;
8
8
  del(keyCache: string): Promise<void>;
9
- getKeys(pattern?: string): Promise<string[]>;
9
+ getKeys(pattern?: string): Promise<string[] | null>;
10
10
  delBatch(patterns: string[]): Promise<void>;
11
11
  isRunning(): Promise<any>;
12
12
  close(): Promise<void>;
@@ -17,12 +17,8 @@ class Cache {
17
17
  const dataFromCache = await this.client.get(keyCache);
18
18
  return dataFromCache ? dataFromCache : null;
19
19
  }
20
- async set(keyCache, data, expiration) {
21
- return await this.client.set(
22
- keyCache,
23
- JSON.stringify(data),
24
- expiration || this.DEFAULT_EXPIRATION_SECONDS,
25
- );
20
+ async set(keyCache, data, expiration = this.DEFAULT_EXPIRATION_SECONDS) {
21
+ return await this.client.set(keyCache, JSON.stringify(data), expiration);
26
22
  }
27
23
  async del(keyCache) {
28
24
  return await this.client.del(keyCache);
@@ -5,6 +5,6 @@ export declare abstract class CacheClient {
5
5
  abstract set(keyCache: string, data: any, expiration: number): Promise<void>;
6
6
  abstract del(keyCache: string): Promise<void>;
7
7
  abstract delBatch(keyCache: string[]): Promise<void>;
8
- abstract getKeys(pattern?: string): Promise<string[]>;
8
+ abstract getKeys(pattern?: string): Promise<string[] | null>;
9
9
  isRunning(): Promise<any>;
10
10
  }
File without changes
@@ -0,0 +1,27 @@
1
+ export type PostInput = {
2
+ body: any;
3
+ endpoint: string;
4
+ config: {
5
+ headers?: Record<string, string>;
6
+ };
7
+ };
8
+ export type PutInput = {
9
+ body: any;
10
+ endpoint: string;
11
+ config: {
12
+ headers?: Record<string, string>;
13
+ };
14
+ };
15
+ export type GetInput = {
16
+ endpoint: string;
17
+ config: {
18
+ headers?: Record<string, string>;
19
+ query?: Record<string, string>;
20
+ };
21
+ };
22
+ export type RequestOutput = {
23
+ code: number;
24
+ headers?: Record<string, string>;
25
+ body: any;
26
+ };
27
+ export type ActivateBranchOutput = void;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,7 @@
1
+ import { GetInput, PostInput, RequestOutput } from './orbit-http-client-dto';
2
+ export declare abstract class OrbitHTTPClient {
3
+ protected abstract getTarget(): string;
4
+ protected abstract getBaseUrl(): string;
5
+ protected abstract post(input: PostInput): Promise<RequestOutput>;
6
+ protected abstract get(input: GetInput): Promise<RequestOutput>;
7
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.OrbitHTTPClient = void 0;
4
+ class OrbitHTTPClient {}
5
+ exports.OrbitHTTPClient = OrbitHTTPClient;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,11 @@
1
+ type HTTPOutput = {
2
+ code?: number;
3
+ headers?: Record<string, string>;
4
+ body?: any;
5
+ };
6
+ export default class HttpError extends Error {
7
+ code: number;
8
+ response: HTTPOutput;
9
+ constructor(response: HTTPOutput);
10
+ }
11
+ export {};
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ class HttpError extends Error {
4
+ constructor(response) {
5
+ super(response.body.message || 'Integration error');
6
+ this.code = response.code || 400;
7
+ this.response = response;
8
+ }
9
+ }
10
+ exports.default = HttpError;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -10,6 +10,6 @@ export declare class Redis extends CacheClient {
10
10
  set(key: string, data: string, expiration: number): Promise<void>;
11
11
  del(keyCache: string): Promise<void>;
12
12
  delBatch(keyCache: string[]): Promise<void>;
13
- getKeys(pattern?: string | undefined): Promise<string[]>;
13
+ getKeys(pattern?: string | undefined): Promise<string[] | null>;
14
14
  close(): Promise<void>;
15
15
  }
@@ -35,15 +35,21 @@ class Redis extends client_1.CacheClient {
35
35
  await Promise.race([set(), Redis.delayOperation()]);
36
36
  }
37
37
  async del(keyCache) {
38
- await this.client.del(keyCache);
38
+ await Promise.race([this.client.del(keyCache), Redis.delayOperation()]);
39
39
  }
40
40
  async delBatch(keyCache) {
41
- const pipeline = this.client.pipeline();
42
- keyCache.forEach(key => pipeline.del(key));
43
- await pipeline.exec();
41
+ const delBatch = async () => {
42
+ const pipeline = this.client.pipeline();
43
+ keyCache.forEach(key => pipeline.del(key));
44
+ await pipeline.exec();
45
+ };
46
+ await Promise.race([delBatch(), Redis.delayOperation()]);
44
47
  }
45
48
  async getKeys(pattern) {
46
- return await this.client.keys(pattern || '*');
49
+ return await Promise.race([
50
+ this.client.keys(pattern || '*'),
51
+ Redis.delayOperation(),
52
+ ]);
47
53
  }
48
54
  async close() {
49
55
  await this.client.quit();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ import { OrbitHTTPClient } from '../../../application/orbit-http-client/orbit-http-client';
2
+ import { AxiosInstance } from 'axios';
3
+ import {
4
+ GetInput,
5
+ PostInput,
6
+ RequestOutput,
7
+ } from '../../../application/orbit-http-client/orbit-http-client-dto';
8
+ export declare abstract class OrbitAxiosClient extends OrbitHTTPClient {
9
+ protected httpClient: AxiosInstance;
10
+ protected post({ endpoint, body, config }: PostInput): Promise<RequestOutput>;
11
+ protected get({ endpoint, config }: GetInput): Promise<RequestOutput>;
12
+ private axiosErrorToHTTPError;
13
+ private axiosResponseToRequestOutput;
14
+ }
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', { value: true });
3
+ exports.OrbitAxiosClient = void 0;
4
+ const tslib_1 = require('tslib');
5
+ const orbit_http_client_1 = require('../../../application/orbit-http-client/orbit-http-client');
6
+ const axios_1 = tslib_1.__importDefault(require('axios'));
7
+ const http_error_1 = tslib_1.__importDefault(
8
+ require('../../../domain/errors/http-error'),
9
+ );
10
+ class OrbitAxiosClient extends orbit_http_client_1.OrbitHTTPClient {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.httpClient = axios_1.default.create({
14
+ baseURL: this.getBaseUrl(),
15
+ headers: {
16
+ target: this.getTarget(),
17
+ },
18
+ });
19
+ }
20
+ async post({ endpoint, body, config }) {
21
+ try {
22
+ const response = await this.httpClient.post(endpoint, body, config);
23
+ return this.axiosResponseToRequestOutput(response);
24
+ } catch (e) {
25
+ throw this.axiosErrorToHTTPError(e);
26
+ }
27
+ }
28
+ async get({ endpoint, config }) {
29
+ try {
30
+ const response = await this.httpClient.get(endpoint, {
31
+ headers: config.headers,
32
+ params: config.query,
33
+ });
34
+ return this.axiosResponseToRequestOutput(response);
35
+ } catch (e) {
36
+ throw this.axiosErrorToHTTPError(e);
37
+ }
38
+ }
39
+ axiosErrorToHTTPError(e) {
40
+ return new http_error_1.default({
41
+ body: e.response?.data,
42
+ headers: e.response?.headers,
43
+ code: e.response?.status,
44
+ });
45
+ }
46
+ axiosResponseToRequestOutput(response) {
47
+ return {
48
+ body: response.data,
49
+ code: response.status,
50
+ headers: response.headers,
51
+ };
52
+ }
53
+ }
54
+ exports.OrbitAxiosClient = OrbitAxiosClient;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seidor-cloud-produtos/orbit-backend-lib",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "description": "Internal lib for backend components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -80,6 +80,7 @@
80
80
  "@fastify/cors": "8.3.0",
81
81
  "@nestjs/common": "8.4.7",
82
82
  "amqplib": "0.10.4",
83
+ "axios": "1.7.7",
83
84
  "compression": "1.7.4",
84
85
  "express": "4.19.2",
85
86
  "fastify": "4.18.0",