@cargolift-cdi/types 0.1.45 → 0.1.47

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.
@@ -1 +1 @@
1
- {"version":3,"file":"integration-credential.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-credential.entity.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD;;;GAGG;AACH,qBAEa,qBAAqB;IAEhC,EAAE,EAAG,MAAM,CAAC;IAEZ,2DAA2D;IAE3D,IAAI,EAAG,MAAM,CAAC;IAEd,iCAAiC;IAEjC,MAAM,EAAG,OAAO,CAAC;IAEjB;;;OAGG;IAEH,IAAI,EAAG,QAAQ,CAAC;IAEhB;;;;;;OAMG;IAEH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAEpC;;;;;;OAMG;IAEH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAIrC,oDAAoD;IAEpD,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;IAGT,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
1
+ {"version":3,"file":"integration-credential.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-credential.entity.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD;;;GAGG;AACH,qBAEa,qBAAqB;IAEhC,EAAE,EAAG,MAAM,CAAC;IAGZ,2DAA2D;IAE3D,IAAI,EAAG,MAAM,CAAC;IAEd,iCAAiC;IAEjC,MAAM,EAAG,OAAO,CAAC;IAEjB;;;OAGG;IAEH,IAAI,EAAG,QAAQ,CAAC;IAEhB;;;;;;OAMG;IAEH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAEpC;;;;;;OAMG;IAEH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAIrC,oDAAoD;IAEpD,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;IAGT,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
@@ -4,13 +4,45 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  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;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ /**
8
+ * Representa um perfil de credenciais reutilizáveis para autenticação (API Key, Basic, Bearer, OAuth2).
9
+ *
10
+ * @remarks
11
+ * - Registra configurações não sensíveis em `config`.
12
+ * - Armazena segredos sensíveis em `secrets` (campo não selecionado por padrão).
13
+ * - Referencie este registro pela sua `id` (ex.: `credentialId` em IntegrationOutbound).
14
+ * - Entidade mapeada para a tabela "integration_credential".
15
+ *
16
+ * Campos:
17
+ * @property config: Configurações não sensíveis específicas do tipo de autenticação. Exemplos:
18
+ * - apiKey: { headerName?: string, queryName?: string, prefix?: string }
19
+ * - basic: { usernameField?: string }
20
+ * - bearer: { headerName?: string, prefix?: string }
21
+ * - oauth2: { tokenUrl: string, clientId: string, scopes?: string[], audience?: string, resource?: string, authStyle?: 'body'|'basic' }
22
+ * @property secrets: Segredos sensíveis (select: false). Exemplos:
23
+ * - apiKey: { value: string }
24
+ * - basic: { username: string, password: string }
25
+ * - bearer: { token: string }
26
+ * - oauth2: { clientSecret: string, username?: string, password?: string, privateKey?: string }
27
+ * => Nunca exponha `secrets` em logs ou respostas sem proteção. Recomendado encriptar em repouso e limitar leitura.
28
+ * - rotation: Metadados opcionais para rotação/expiração: { rotatedAt?: string, expiresAt?: string, notes?: string }.
29
+ * - createdAt / updatedAt: Carimbos de data de criação/atualização.
30
+ *
31
+ * Boas práticas de segurança:
32
+ * - Mantenha `secrets` com acesso restrito; carregue explicitamente quando necessário (ex.: query com select do campo).
33
+ * - Evite armazenar segredos em texto simples fora do banco ou em logs.
34
+ * - Implemente rotação periódica e registre `rotation.rotatedAt` / `rotation.expiresAt` quando aplicável.
35
+ *
36
+ *
37
+ * @see IntegrationOutbound - referenciar credenciais por credentialId
38
+ */
7
39
  import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm';
8
40
  /**
9
41
  * Perfil de credenciais reutilizáveis para autenticação (API Key, Basic, Bearer, OAuth2).
10
42
  * Utilize credentialId no IntegrationOutbound para referenciar estas credenciais.
11
43
  */
12
44
  let IntegrationCredential = class IntegrationCredential {
13
- id;
45
+ id; // manter string no TS para bigint seguro
14
46
  /** Nome amigável único (ex.: 'erp-prod', 'wms-staging') */
15
47
  name;
16
48
  /** Se a credencial está ativa */
@@ -42,7 +74,7 @@ let IntegrationCredential = class IntegrationCredential {
42
74
  updatedAt;
43
75
  };
44
76
  __decorate([
45
- PrimaryGeneratedColumn('uuid')
77
+ PrimaryGeneratedColumn("identity", { type: "bigint", generatedIdentity: "ALWAYS" })
46
78
  ], IntegrationCredential.prototype, "id", void 0);
47
79
  __decorate([
48
80
  Column({ type: 'varchar', length: 120 })
@@ -63,10 +95,10 @@ __decorate([
63
95
  Column({ type: 'jsonb', nullable: true })
64
96
  ], IntegrationCredential.prototype, "rotation", void 0);
65
97
  __decorate([
66
- CreateDateColumn({ name: "create_at", type: "timestamptz" })
98
+ CreateDateColumn({ name: "created_at", type: "timestamptz" })
67
99
  ], IntegrationCredential.prototype, "createdAt", void 0);
68
100
  __decorate([
69
- UpdateDateColumn({ name: "update_at", type: "timestamptz" })
101
+ UpdateDateColumn({ name: "updated_at", type: "timestamptz" })
70
102
  ], IntegrationCredential.prototype, "updatedAt", void 0);
71
103
  IntegrationCredential = __decorate([
72
104
  Entity({ name: 'integration_credential' }),
@@ -9,8 +9,9 @@ export declare class IntegrationEndpoint {
9
9
  system: string;
10
10
  /** Evento (chave) (e.g., 'driver' or 'driver.created') */
11
11
  event: string;
12
- /** Ação (e.g., 'create', 'update', 'delete', etc */
12
+ /** Ação (e.g., 'create', 'update', 'delete', etc) */
13
13
  action: string;
14
+ version: number;
14
15
  active: boolean;
15
16
  /** ===================== Target/Delivery (simplificado no próprio Outbound) ===================== */
16
17
  /**
@@ -25,7 +26,7 @@ export declare class IntegrationEndpoint {
25
26
  * - sqs/pubsub: pode ser arn/topic/queue ou projeto+tópico
26
27
  */
27
28
  endpoint: string;
28
- httpMethod: HttpMethod;
29
+ httpMethod: HttpMethod | null;
29
30
  /**
30
31
  * Config HTTP específica (quando transport = 'http'):
31
32
  * {
@@ -1 +1 @@
1
- {"version":3,"file":"integration-endpoint.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-endpoint.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGvE;;;GAGG;AACH,qBAGa,mBAAmB;IAE9B,EAAE,EAAG,MAAM,CAAC;IAEZ,8CAA8C;IAE9C,MAAM,EAAG,MAAM,CAAC;IAEhB,0DAA0D;IAE1D,KAAK,EAAG,MAAM,CAAC;IAEf,oDAAoD;IAEpD,MAAM,EAAG,MAAM,CAAC;IAGhB,MAAM,EAAG,OAAO,CAAC;IAEjB,qGAAqG;IAErG;;OAEG;IAEH,iBAAiB,EAAG,iBAAiB,CAAC;IAEtC;;;;;;OAMG;IAEH,QAAQ,EAAG,MAAM,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AAI,CAAC;IAET;;;OAGG;IAEH,SAAS,CAAC,EAAE;QACV,QAAQ,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC;QAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;IAET;;;OAGG;IAEH,aAAa,CAAC,EAAE;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,IAAI,CAAC;IAET;;;;OAIG;IAEH,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC;;;OAGG;IAEH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAGzC,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
@@ -5,22 +5,88 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  /**
8
+ * Definição de roteamento e configuração de entrega/saída para eventos de integração (Outbound).
9
+ *
10
+ * Representa uma rota/endpoint de destino para um evento específico, incluindo
11
+ * informações de transporte, endpoint, credenciais, políticas de retry, rate-limiting,
12
+ * circuit breaker, idempotência e configurações específicas por protocolo (HTTP, filas/streams).
13
+ *
14
+ * Observações importantes:
15
+ * - A combinação (system, event, action) é única. Há também um índice condicional que garante
16
+ * unicidade quando active = true (ou seja, apenas uma rota ativa por chave).
17
+ * - O campo `id` é um bigint no banco — no TypeScript é mantido como string para segurança.
18
+ *
19
+ * @remarks
20
+ * - Esta entidade centraliza tanto o roteamento (por sistema/evento/ação) quanto as políticas e
21
+ * configurações de entrega, permitindo múltiplos tipos de transporte e adaptações por destino.
22
+ * - Campos JSONB (httpConfig, queueConfig, tls, retryPolicy, rateLimit, breakerPolicy, idempotency)
23
+ * devem seguir os formatos esperados pelo componente de entrega para serem interpretados corretamente.*
24
+ *
25
+ * @property transportProtocol Protocolo de transporte usado para a entrega (ex.: 'REST', 'SOAP', 'AMQP', 'KAFKA').
26
+ * @property endpoint Endpoint principal/URI/host/connection string dependente do protocolo:
27
+ * - HTTP(S): baseUrl (ex.: https://api.exemplo.com)
28
+ * - AMQP: amqp://broker:5672
29
+ * - Kafka: broker1:9092,broker2:9092
30
+ * - SQS/PubSub: ARN, tópico ou projeto+tópico
31
+ *
32
+ * @property httpConfig Configurações específicas quando transportProtocol é HTTP/REST.
33
+ * Estrutura típica:
34
+ * {
35
+ * method?: 'POST'|'PUT'|'PATCH'|'GET'|'DELETE',
36
+ * pathTemplate?: string, // ex.: /v1/drivers/{{id}}
37
+ * headersTemplate?: Record<string,string>,
38
+ * queryTemplate?: Record<string,any>,
39
+ * bodyTemplate?: any, // JSONata / Liquid / Handlebars
40
+ * contentType?: string, // ex.: 'application/json'
41
+ * timeoutMs?: number,
42
+ * compression?: { type?: 'gzip'|'deflate'|'br' }
43
+ * }
44
+ *
45
+ * @property queueConfig Configurações para filas/streams quando transportProtocol é AMQP/Kafka/SQS/PubSub.
46
+ * Estrutura típica:
47
+ * {
48
+ * topic?: string,
49
+ * queue?: string,
50
+ * exchange?: string,
51
+ * routingKey?: string,
52
+ * partitionKey?: string,
53
+ * messageKey?: string,
54
+ * headersTemplate?: Record<string,string>,
55
+ * properties?: Record<string,any>, // propriedades específicas do broker
56
+ * payloadTemplate?: any
57
+ * }
58
+ *
59
+ * @example Exemplo de httpConfig:
60
+ * {
61
+ * method: 'POST',
62
+ * pathTemplate: '/v1/drivers/{{id}}',
63
+ * headersTemplate: { 'Authorization': 'Bearer {{token}}', 'Content-Type': 'application/json' },
64
+ * bodyTemplate: { id: '{{id}}', name: '{{name}}' },
65
+ * timeoutMs: 5000
66
+ * }
67
+ *
68
+ * @example Exemplo de queueConfig para Kafka:
69
+ * {
70
+ * topic: 'drivers.created',
71
+ * partitionKey: '{{id}}',
72
+ * headersTemplate: { correlationId: '{{correlationId}}' },
73
+ * payloadTemplate: { id: '{{id}}', payload: '{{payload}}' }
74
+ * }
8
75
  */
9
- // src/integration/entities/integration-outbound.entity.ts
10
- //
11
76
  import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn, } from "typeorm";
12
77
  /**
13
78
  * Definição de roteamento de saída por chave (evento) e destino.
14
79
  * Agora inclui também as configurações de Target/Delivery (protocolo, endpoint, templates, políticas, etc.).
15
80
  */
16
81
  let IntegrationEndpoint = class IntegrationEndpoint {
17
- id;
82
+ id; // manter string no TS para bigint seguro
18
83
  /** Sistema de destino (e.g., 'erp', 'wms') */
19
84
  system;
20
85
  /** Evento (chave) (e.g., 'driver' or 'driver.created') */
21
86
  event;
22
- /** Ação (e.g., 'create', 'update', 'delete', etc */
87
+ /** Ação (e.g., 'create', 'update', 'delete', etc) */
23
88
  action;
89
+ version;
24
90
  active;
25
91
  /** ===================== Target/Delivery (simplificado no próprio Outbound) ===================== */
26
92
  /**
@@ -100,7 +166,7 @@ let IntegrationEndpoint = class IntegrationEndpoint {
100
166
  updatedAt;
101
167
  };
102
168
  __decorate([
103
- PrimaryGeneratedColumn("uuid")
169
+ PrimaryGeneratedColumn("identity", { type: "bigint", generatedIdentity: "ALWAYS" })
104
170
  ], IntegrationEndpoint.prototype, "id", void 0);
105
171
  __decorate([
106
172
  Column({ name: "target_system", type: "varchar", length: 80 })
@@ -111,6 +177,9 @@ __decorate([
111
177
  __decorate([
112
178
  Column({ type: "varchar", length: 40 })
113
179
  ], IntegrationEndpoint.prototype, "action", void 0);
180
+ __decorate([
181
+ Column({ type: "int", default: 1 })
182
+ ], IntegrationEndpoint.prototype, "version", void 0);
114
183
  __decorate([
115
184
  Column({ type: "boolean", default: true })
116
185
  ], IntegrationEndpoint.prototype, "active", void 0);
@@ -121,7 +190,7 @@ __decorate([
121
190
  Column({ type: "varchar", length: 500 })
122
191
  ], IntegrationEndpoint.prototype, "endpoint", void 0);
123
192
  __decorate([
124
- Column({ name: "http_method", type: "varchar", length: 10, default: 'POST' })
193
+ Column({ name: "http_method", type: "varchar", length: 10, default: 'POST', nullable: true })
125
194
  ], IntegrationEndpoint.prototype, "httpMethod", void 0);
126
195
  __decorate([
127
196
  Column({ name: "http_config", type: "jsonb", nullable: true })
@@ -130,7 +199,7 @@ __decorate([
130
199
  Column({ name: "queue_config", type: "jsonb", nullable: true })
131
200
  ], IntegrationEndpoint.prototype, "queueConfig", void 0);
132
201
  __decorate([
133
- Column({ name: "credential_id", type: "uuid", nullable: true })
202
+ Column({ name: "credential_id", type: "bigint", nullable: true })
134
203
  ], IntegrationEndpoint.prototype, "credentialId", void 0);
135
204
  __decorate([
136
205
  Column({ type: "jsonb", nullable: true })
@@ -151,14 +220,16 @@ __decorate([
151
220
  Column({ type: "jsonb", nullable: true })
152
221
  ], IntegrationEndpoint.prototype, "idempotency", void 0);
153
222
  __decorate([
154
- CreateDateColumn({ name: "create_at", type: "timestamptz" })
223
+ CreateDateColumn({ name: "created_at", type: "timestamptz" })
155
224
  ], IntegrationEndpoint.prototype, "createdAt", void 0);
156
225
  __decorate([
157
- UpdateDateColumn({ name: "update_at", type: "timestamptz" })
226
+ UpdateDateColumn({ name: "updated_at", type: "timestamptz" })
158
227
  ], IntegrationEndpoint.prototype, "updatedAt", void 0);
159
228
  IntegrationEndpoint = __decorate([
160
229
  Entity({ name: "integration_endpoint" }),
161
- Index(["system", "event", "action"], { unique: true }),
162
- Index(["credentialId"])
230
+ Index("uq_integration_endpoint_active", ["system", "event", "action"], {
231
+ unique: true,
232
+ where: `"active" = true`,
233
+ })
163
234
  ], IntegrationEndpoint);
164
235
  export { IntegrationEndpoint };
@@ -18,11 +18,11 @@ export declare class IntegrationInbound {
18
18
  /** Descrição opcional amigável ao usuário */
19
19
  description?: string | null;
20
20
  /** Pré-validação do payload de origem */
21
- validation: Record<string, any>;
21
+ validation?: Record<string, any> | null;
22
22
  /** Expressão JSONata */
23
- transformation: string;
23
+ transformation?: string | null;
24
24
  /** Regra global (BRE RulesConfiguration) */
25
- rules: Record<string, any>;
25
+ rules?: Record<string, any> | null;
26
26
  /** Opções adicionais (reservado para uso futuro) */
27
27
  options?: Record<string, any> | null;
28
28
  createdAt: Date;
@@ -1 +1 @@
1
- {"version":3,"file":"integration-inbound.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-inbound.entity.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,qBAEa,kBAAkB;IAE7B,EAAE,EAAG,MAAM,CAAC;IAEZ,sCAAsC;IAEtC,MAAM,EAAG,MAAM,CAAC;IAEhB,8BAA8B;IAE9B,KAAK,EAAG,MAAM,CAAC;IAEb,oDAAoD;IAEtD,MAAM,EAAG,MAAM,CAAC;IAEhB,gHAAgH;IAEhH,OAAO,EAAG,MAAM,CAAC;IAEjB,0BAA0B;IAE1B,MAAM,EAAG,OAAO,CAAC;IAEjB,6CAA6C;IAE7C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,0CAA0C;IAE1C,UAAU,EAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEjC,yBAAyB;IAEzB,cAAc,EAAG,MAAM,CAAC;IAExB,4CAA4C;IAE5C,KAAK,EAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5B,oDAAoD;IAEpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAGrC,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
1
+ {"version":3,"file":"integration-inbound.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-inbound.entity.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,qBAOa,kBAAkB;IAE7B,EAAE,EAAG,MAAM,CAAC;IAEZ,sCAAsC;IAEtC,MAAM,EAAG,MAAM,CAAC;IAEhB,8BAA8B;IAE9B,KAAK,EAAG,MAAM,CAAC;IAEb,oDAAoD;IAEtD,MAAM,EAAG,MAAM,CAAC;IAEhB,gHAAgH;IAEhH,OAAO,EAAG,MAAM,CAAC;IAEjB,0BAA0B;IAE1B,MAAM,EAAG,OAAO,CAAC;IAEjB,6CAA6C;IAE7C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,0CAA0C;IAE1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAExC,yBAAyB;IAEzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B,4CAA4C;IAE5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAEnC,oDAAoD;IAEpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAGrC,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
@@ -4,6 +4,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  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;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ /**
8
+ * Representa uma rota de integração de entrada (inbound) que descreve como eventos externos
9
+ * devem ser validados, transformados e aplicados às regras globais antes do roteamento interno.
10
+ *
11
+ * @remarks
12
+ * - Cada combinação (system, event, action, version) é única.
13
+ * - Apenas uma versão por (system, event, action) pode estar ativa ao mesmo tempo.
14
+ * - Versões anteriores devem ser imutáveis após a publicação de novas versões.
15
+ * - Transformações usam expressões JSONata para mapear payloads externos ao formato canônico interno.
16
+ *
17
+
18
+ */
7
19
  import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn, } from "typeorm";
8
20
  /**
9
21
  * Eventos de integração (tms.driver) - Ocorre na integração de entrada (inbound) antes do roteamento.
@@ -11,7 +23,7 @@ import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, Update
11
23
  * Também armazena configurações de regras global (BRE) associadas ao evento.
12
24
  */
13
25
  let IntegrationInbound = class IntegrationInbound {
14
- id;
26
+ id; // manter string no TS para bigint seguro
15
27
  /** Sistema de origem (e.g., 'erp') */
16
28
  system;
17
29
  /** Evento (e.g., 'driver') */
@@ -36,7 +48,7 @@ let IntegrationInbound = class IntegrationInbound {
36
48
  updatedAt;
37
49
  };
38
50
  __decorate([
39
- PrimaryGeneratedColumn("uuid")
51
+ PrimaryGeneratedColumn("identity", { type: "bigint", generatedIdentity: "ALWAYS" })
40
52
  ], IntegrationInbound.prototype, "id", void 0);
41
53
  __decorate([
42
54
  Column({ type: "varchar", length: 80 })
@@ -69,13 +81,17 @@ __decorate([
69
81
  Column({ type: "jsonb", nullable: true })
70
82
  ], IntegrationInbound.prototype, "options", void 0);
71
83
  __decorate([
72
- CreateDateColumn({ name: "create_at", type: "timestamptz" })
84
+ CreateDateColumn({ name: "created_at", type: "timestamptz" })
73
85
  ], IntegrationInbound.prototype, "createdAt", void 0);
74
86
  __decorate([
75
- UpdateDateColumn({ name: "update_at", type: "timestamptz" })
87
+ UpdateDateColumn({ name: "updated_at", type: "timestamptz" })
76
88
  ], IntegrationInbound.prototype, "updatedAt", void 0);
77
89
  IntegrationInbound = __decorate([
78
90
  Entity({ name: "integration_inbound" }),
79
- Index(["system", "event", "action", "version"], { unique: true })
91
+ Index(["system", "event", "action", "version"], { unique: true }),
92
+ Index("uq_integration_inbound_active", ["system", "event", "action"], {
93
+ unique: true,
94
+ where: `"active" = true`,
95
+ })
80
96
  ], IntegrationInbound);
81
97
  export { IntegrationInbound };
@@ -1,14 +1,11 @@
1
- /**
2
- * Definição de roteamento de saída por chave (evento) e destino.
3
- * Agora inclui também as configurações de Target/Delivery (protocolo, endpoint, templates, políticas, etc.).
4
- */
5
1
  export declare class IntegrationOutbound {
2
+ /** Identificador único do sistema de integração */
6
3
  id: string;
7
4
  /** Sistema de origem (e.g., 'tms') */
8
5
  system: string;
9
6
  /** Evento (chave) (e.g., 'driver' or 'driver.created') */
10
7
  event: string;
11
- /** Ação (e.g., 'create', 'update', 'delete', etc */
8
+ /** Ação (e.g., 'create', 'update', 'delete', etc) */
12
9
  action: string;
13
10
  /** Sistema de destino (e.g., 'erp', 'wms') */
14
11
  targetSystem: string;
@@ -21,7 +18,6 @@ export declare class IntegrationOutbound {
21
18
  /** Regras (BRE RulesConfiguration) */
22
19
  rules?: Record<string, any>;
23
20
  /** Opções adicionais (reservado para uso futuro) */
24
- options?: Record<string, any> | null;
25
21
  createdAt: Date;
26
22
  updatedAt: Date;
27
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"integration-outbound.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-outbound.entity.ts"],"names":[],"mappings":"AAoCA;;;GAGG;AACH,qBAEa,mBAAmB;IAE9B,EAAE,EAAG,MAAM,CAAC;IAEZ,sCAAsC;IAEtC,MAAM,EAAG,MAAM,CAAC;IAEhB,0DAA0D;IAE1D,KAAK,EAAG,MAAM,CAAC;IAEb,oDAAoD;IAEtD,MAAM,EAAG,MAAM,CAAC;IAEhB,8CAA8C;IAE9C,YAAY,EAAG,MAAM,CAAC;IAGtB,gHAAgH;IAEhH,OAAO,EAAG,MAAM,CAAC;IAEjB,2BAA2B;IAE3B,MAAM,EAAG,OAAO,CAAC;IAGjB,gBAAgB;IAEhB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,sCAAsC;IAEtC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5B,oDAAoD;IAEpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAGrC,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
1
+ {"version":3,"file":"integration-outbound.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-outbound.entity.ts"],"names":[],"mappings":"AAuBA,qBAMa,mBAAmB;IAC9B,mDAAmD;IAEnD,EAAE,EAAG,MAAM,CAAC;IAEZ,sCAAsC;IAEtC,MAAM,EAAG,MAAM,CAAC;IAEhB,0DAA0D;IAE1D,KAAK,EAAG,MAAM,CAAC;IAEf,qDAAqD;IAErD,MAAM,EAAG,MAAM,CAAC;IAEhB,8CAA8C;IAE9C,YAAY,EAAG,MAAM,CAAC;IAGtB,gHAAgH;IAEhH,OAAO,EAAG,MAAM,CAAC;IAEjB,2BAA2B;IAE3B,MAAM,EAAG,OAAO,CAAC;IAGjB,gBAAgB;IAEhB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,sCAAsC;IAEtC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE5B,oDAAoD;IAKpD,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAGlB"}
@@ -15,33 +15,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
15
15
  * - Há um índice único composto por (system, event, targetSystem, version) garantindo que
16
16
  * não existam duplicatas de rota para a mesma combinação.
17
17
  * - Somente a versão mais recente de uma rota pode estar ativa; versões anteriores devem ser imutáveis.
18
- *
19
- * @property id UUID gerada automaticamente que identifica unicamente a rota.
20
- * @property system Sistema de origem (ex.: "tms"), usado para agrupar/filtrar rotas por emissor.
21
- * @property targetSystem Sistema de destino (ex.: "erp", "wms") para o qual o evento será encaminhado.
22
- * @property event Chave do evento (ex.: "driver", "driver.created") que aciona esta rota.
23
- * @property version Versão da rota. Versões anteriores não devem ser modificadas; apenas a última pode estar ativa.
24
- * @property description Texto descritivo opcional da rota (até 500 caracteres).
25
- * @property rules Configuração de regras (BRE) em formato JSONB utilizada para avaliar/executar o roteamento.
26
- * @property active Indicador se a rota está ativa e deve ser considerada pelo mecanismo de envio.
27
- * @property options Campo JSONB opcional para opções adicionais de roteamento (reservado para uso futuro).
28
- * @property createdAt Timestamp (timestamptz) de criação do registro.
29
- * @property updatedAt Timestamp (timestamptz) da última atualização do registro.
30
18
  */
31
- // src/integration/entities/integration-outbound.entity.ts
32
- //
33
19
  import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn, } from "typeorm";
34
- /**
35
- * Definição de roteamento de saída por chave (evento) e destino.
36
- * Agora inclui também as configurações de Target/Delivery (protocolo, endpoint, templates, políticas, etc.).
37
- */
38
20
  let IntegrationOutbound = class IntegrationOutbound {
39
- id;
21
+ /** Identificador único do sistema de integração */
22
+ id; // manter string no TS para bigint seguro
40
23
  /** Sistema de origem (e.g., 'tms') */
41
24
  system;
42
25
  /** Evento (chave) (e.g., 'driver' or 'driver.created') */
43
26
  event;
44
- /** Ação (e.g., 'create', 'update', 'delete', etc */
27
+ /** Ação (e.g., 'create', 'update', 'delete', etc) */
45
28
  action;
46
29
  /** Sistema de destino (e.g., 'erp', 'wms') */
47
30
  targetSystem;
@@ -54,12 +37,13 @@ let IntegrationOutbound = class IntegrationOutbound {
54
37
  /** Regras (BRE RulesConfiguration) */
55
38
  rules;
56
39
  /** Opções adicionais (reservado para uso futuro) */
57
- options;
40
+ // @Column({ type: "jsonb", nullable: true })
41
+ // options?: Record<string, any> | null;
58
42
  createdAt;
59
43
  updatedAt;
60
44
  };
61
45
  __decorate([
62
- PrimaryGeneratedColumn("uuid")
46
+ PrimaryGeneratedColumn("identity", { type: "bigint", generatedIdentity: "ALWAYS" })
63
47
  ], IntegrationOutbound.prototype, "id", void 0);
64
48
  __decorate([
65
49
  Column({ type: "varchar", length: 80 })
@@ -83,19 +67,20 @@ __decorate([
83
67
  Column({ type: "varchar", length: 500, nullable: true })
84
68
  ], IntegrationOutbound.prototype, "description", void 0);
85
69
  __decorate([
86
- Column({ type: "jsonb" })
70
+ Column({ type: "jsonb", default: () => "'{}'::jsonb" })
87
71
  ], IntegrationOutbound.prototype, "rules", void 0);
88
72
  __decorate([
89
- Column({ type: "jsonb", nullable: true })
90
- ], IntegrationOutbound.prototype, "options", void 0);
91
- __decorate([
92
- CreateDateColumn({ name: "create_at", type: "timestamptz" })
73
+ CreateDateColumn({ name: "created_at", type: "timestamptz" })
93
74
  ], IntegrationOutbound.prototype, "createdAt", void 0);
94
75
  __decorate([
95
- UpdateDateColumn({ name: "update_at", type: "timestamptz" })
76
+ UpdateDateColumn({ name: "updated_at", type: "timestamptz" })
96
77
  ], IntegrationOutbound.prototype, "updatedAt", void 0);
97
78
  IntegrationOutbound = __decorate([
98
79
  Entity({ name: "integration_outbound" }),
99
- Index(["system", "event", "action", "targetSystem", "version"], { unique: true })
80
+ Index(["system", "event", "action", "targetSystem", "version"], { unique: true }),
81
+ Index("uq_integration_outbound_active", ["system", "event", "action", "targetSystem"], {
82
+ unique: true,
83
+ where: `"active" = true`,
84
+ })
100
85
  ], IntegrationOutbound);
101
86
  export { IntegrationOutbound };
@@ -1 +1 @@
1
- {"version":3,"file":"integration-system.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-system.entity.ts"],"names":[],"mappings":"AAEA,qBACa,iBAAiB;IAC5B,mDAAmD;IAEnD,EAAE,EAAG,MAAM,CAAC;IAEZ,yDAAyD;IAGzD,MAAM,EAAG,MAAM,CAAC;IAEhB,8BAA8B;IAE9B,MAAM,EAAG,OAAO,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
1
+ {"version":3,"file":"integration-system.entity.d.ts","sourceRoot":"","sources":["../../../../src/db/entities/integration/integration-system.entity.ts"],"names":[],"mappings":"AAaA,qBAEa,iBAAiB;IAC5B,mDAAmD;IAEnD,EAAE,EAAG,MAAM,CAAC;IAEZ,yDAAyD;IAEzD,MAAM,EAAG,MAAM,CAAC;IAEhB,8BAA8B;IAE9B,MAAM,EAAG,OAAO,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAElB"}
@@ -4,10 +4,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  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;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ /**
8
+ * Representa um sistema de integração registrado na aplicação.
9
+ *
10
+ * Cada instância mapeia uma linha da tabela "integration_system".
11
+ *
12
+ * @property id Identificador único do sistema de integração (armazenado como bigint no banco). Mantém-se como string no TypeScript para evitar perda de precisão com bigints.
13
+ * @property system Nome único do sistema de integração (ex.: 'erp', 'tms'). Campo varchar com até 80 caracteres.
14
+ * @property active Flag que indica se o sistema está ativo. Valor booleano; padrão: true.
15
+ * @property createdAt Carimbo de data/hora de criação (timestamptz).
16
+ * @property updatedAt Carimbo de data/hora da última atualização (timestamptz).
17
+ */
7
18
  import { Column, Entity, PrimaryGeneratedColumn, Index, CreateDateColumn, UpdateDateColumn } from 'typeorm';
8
19
  let IntegrationSystem = class IntegrationSystem {
9
20
  /** Identificador único do sistema de integração */
10
- id;
21
+ id; // manter string no TS para bigint seguro
11
22
  /** Nome do sistema de integração (e.g., 'erp', 'tms') */
12
23
  system;
13
24
  /** Se o sistema está ativo */
@@ -16,22 +27,22 @@ let IntegrationSystem = class IntegrationSystem {
16
27
  updatedAt;
17
28
  };
18
29
  __decorate([
19
- PrimaryGeneratedColumn('uuid')
30
+ PrimaryGeneratedColumn("identity", { type: "bigint", generatedIdentity: "ALWAYS" })
20
31
  ], IntegrationSystem.prototype, "id", void 0);
21
32
  __decorate([
22
- Index({ unique: true }),
23
33
  Column({ type: 'varchar', length: 80 })
24
34
  ], IntegrationSystem.prototype, "system", void 0);
25
35
  __decorate([
26
36
  Column({ type: 'boolean', default: true })
27
37
  ], IntegrationSystem.prototype, "active", void 0);
28
38
  __decorate([
29
- CreateDateColumn({ name: "create_at", type: "timestamptz" })
39
+ CreateDateColumn({ name: "created_at", type: "timestamptz" })
30
40
  ], IntegrationSystem.prototype, "createdAt", void 0);
31
41
  __decorate([
32
- UpdateDateColumn({ name: "update_at", type: "timestamptz" })
42
+ UpdateDateColumn({ name: "updated_at", type: "timestamptz" })
33
43
  ], IntegrationSystem.prototype, "updatedAt", void 0);
34
44
  IntegrationSystem = __decorate([
35
- Entity({ name: 'integration_system' })
45
+ Entity({ name: 'integration_system' }),
46
+ Index(["system"], { unique: true })
36
47
  ], IntegrationSystem);
37
48
  export { IntegrationSystem };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cargolift-cdi/types",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "TypeScript types e interfaces comuns para projetos Cargolift CDI",
5
5
  "keywords": [
6
6
  "typescript",