@cristian-israel/giganet_lib_conecta 1.0.35 → 1.0.37

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 CHANGED
@@ -1,189 +1,10 @@
1
- Perfeito! Aqui está a documentação atualizada, removendo completamente qualquer referência a `relations.ts` e refletindo que as relações agora são aplicadas automaticamente no `initModels` gerado pelo `sequelize-auto` ou no Service:
2
-
3
- ---
4
-
5
- # 📚 Documentação Atualizada — Lib de Conexões (MySQL + Mongo + IXC)
6
-
7
- ## 🎯 Objetivo
8
-
9
- Criar uma biblioteca desacoplada, escalável e tipada para:
10
-
11
- - Conexões com bancos MySQL e MongoDB
12
- - Reuso entre projetos
13
- - Padronização com logger
14
- - Estrutura modular e evolutiva
15
- - Singleton + Service pattern para acesso a dados
16
-
17
- ---
18
-
19
- # 🧱 Estrutura Geral
20
-
21
- ```
22
- /core
23
- ├── mysql.connection.ts
24
- ├── mongo.connection.ts
25
- ├── database.factory.ts
26
- ├── logger.ts
27
- ├── retry.ts
28
- ├── types.ts
29
-
30
- /databases
31
- └── ixc-soft
32
- ├── ixc-soft.service.ts
33
- ├── ixc-soft.connection.ts
34
- ├── ixc-soft.types.ts
35
- └── models/
36
- └── init-models.ts (gerado via sequelize-auto)
37
-
38
- /index.ts
39
- ```
40
-
41
- ---
42
-
43
- # ✅ 1. Conexões Base
44
-
45
- ## 1.1 MySQL Connection
46
-
47
- ```ts
48
- createMysqlConnection(config: MysqlConfig): Promise<Sequelize>
49
- ```
50
-
51
- - Validação de dados
52
- - Logger padronizado
53
- - Tratamento de erro
54
- - Timeout / timezone
55
- - Retorna instância Sequelize
56
-
57
- ---
58
-
59
- ## 1.2 Mongo Connection
60
-
61
- ```ts
62
- createMongoConnection(config: MongoConfig): Promise<Connection>
63
- ```
64
-
65
- - URI dinâmica
66
- - Suporte a authSource
67
- - Logger
68
- - Tratamento de erro
69
-
70
- ---
71
-
72
- # ✅ 2. Retry Pattern (Resiliência)
73
-
74
- ```ts
75
- retry(fn, { retries: number, delay: number, onRetry?: (error, attempt) => void })
76
- ```
77
-
78
- - Evita falha por instabilidade temporária
79
- - Reutilizável
80
- - Centralizado
81
-
82
- Exemplo com Mongo:
83
-
84
- ```ts
85
- const conn = await retry(async () => {
86
- const connection = createConnection(uri);
87
- return await new Promise((resolve, reject) => {
88
- connection.once("connected", () => resolve(connection));
89
- connection.once("error", reject);
90
- });
91
- });
92
- ```
93
-
94
- ---
95
-
96
- # ✅ 3. Factory de Conexões
97
-
98
- ```ts
99
- createConnectionFactory(factoryFn);
100
- ```
101
-
102
- - Singleton automático
103
- - Evita múltiplas instâncias
104
- - Centraliza criação de conexões
105
-
106
- ---
107
-
108
- # ✅ 4. Logger
109
-
110
- ```ts
111
- logger({
112
- level?: "INFO" | "WARN" | "ERROR",
113
- database: "MYSQL" | "MONGO",
114
- context: string,
115
- message: string
116
- });
117
- ```
118
-
119
- - Padronização
120
- - Observabilidade
121
- - Fácil debug
122
-
123
- ---
124
-
125
- # ✅ 5. Tipos Base
126
-
127
- ```ts
128
- type MysqlConfig
129
- type MongoConfig
130
- type ConfigCreationConnection
131
- ```
132
-
133
- - Tipagem das entradas
134
- - Segurança
135
- - Reuso
136
-
137
- ---
138
-
139
- # ✅ 6. Implementação IXC (MySQL)
140
-
141
- ## 6.1 Estrutura da conexão IXC
142
-
143
- ```ts
144
- async function createIXCConnection(): Promise<IXCSoftConnection>;
145
- ```
146
-
147
- Fluxo:
148
-
149
- 1. Cria conexão MySQL via `createMysqlConnection`
150
- 2. Inicializa models gerados via `sequelize-auto` (`initModels`)
151
- 3. Retorna conexão tipada (`IXCSoftConnection`)
152
-
153
- > Relações são aplicadas dentro de `initModels` automaticamente; **não há mais arquivo separado de relations**.
154
-
155
- ---
156
-
157
- ## 6.2 Tipagem dos Models (forte)
158
-
159
- ```ts
160
- export class IXCSoftCliente extends Model<
161
- InferAttributes<IXCSoftCliente>,
162
- InferCreationAttributes<IXCSoftCliente>
163
- > {
164
- declare id: CreationOptional<number>;
165
- declare razao: string;
166
- declare fantasia: string | null;
167
- declare ativo: string;
168
- }
169
- ```
170
-
171
- - Autocomplete real
172
- - Segurança no `create`/`update`
173
- - Menos bugs
174
- - Tipagem apenas dos campos relevantes
175
-
176
- ---
177
-
178
- ## 6.3 Geração automática de Models
179
-
180
- ### Ferramenta:
1
+ # Geração automática de Models
181
2
 
182
3
  ```bash
183
4
  sequelize-auto
184
5
  ```
185
6
 
186
- ### Comando Exemplo:
7
+ ### Comando:
187
8
 
188
9
  ```bash
189
10
  npx sequelize-auto \
@@ -200,119 +21,3 @@ npx sequelize-auto \
200
21
  - Não editar arquivos gerados
201
22
  - Sempre regenerar quando schema mudar
202
23
  - Estrutura final acessível via `initModels(sequelize)`
203
-
204
- ---
205
-
206
- # ✅ 7. Service Pattern (Singleton + acesso aos models)
207
-
208
- ## 7.1 IXCSoftService
209
-
210
- ```ts
211
- const ixcs = IXCSoftService.getInstance();
212
- await ixcs.init();
213
- const { Cliente, ClienteContrato } = ixcs.models;
214
- ```
215
-
216
- ### Principais decisões:
217
-
218
- 1. **Singleton**: garante uma única instância por app
219
- 2. **Init obrigatório**: chama `ixcs.init()` antes de usar os models
220
- 3. **Models tipados**: `ixcs.models` retorna apenas os models do IXC
221
- 4. **Static vs Getter**:
222
- - `ixcs.models` (getter) → uso normal por instância
223
- - `IXCSoftService.getModels()` → conveniência estática (chama o singleton internamente)
224
-
225
- ---
226
-
227
- ### 7.2 Vantagens do Service
228
-
229
- - Protege acesso direto à connection
230
- - Abstrai inicialização e relações
231
- - Permite apenas usar models e fazer queries
232
- - Facilita testes e refatorações futuras
233
-
234
- ---
235
-
236
- # ✅ 8. Uso da lib no projeto
237
-
238
- ```ts
239
- import { IXCSoftService } from "giganet_conecta";
240
-
241
- async function main() {
242
- const ixcs = IXCSoftService.getInstance();
243
- await ixcs.init();
244
-
245
- const { Cliente, ClienteContrato } = ixcs.models;
246
-
247
- const clientesAtivos = await Cliente.findAll({ where: { ativo: "S" } });
248
- }
249
- ```
250
-
251
- - Não é necessário instanciar `connection` manualmente
252
- - O Service controla inicialização e singleton
253
- - Queries podem ser feitas diretamente nos models
254
-
255
- ---
256
-
257
- # ✅ 9. Exportação da lib
258
-
259
- **Index da lib (`src/index.ts`)**:
260
-
261
- ```ts
262
- export { IXCSoftService } from "./databases/ixc-soft/ixc-soft.service";
263
- export { OPAService } from "./databases/opa-suite/opa.service";
264
- // outros services que quiser expor
265
- ```
266
-
267
- - Expor apenas Services
268
- - Conexões internas (`connection`, `initModels`) ficam encapsuladas
269
-
270
- ---
271
-
272
- # 🧠 Arquitetura Atualizada (até 3.4)
273
-
274
- ```
275
- core/
276
- conexão + retry + logger
277
-
278
- databases/
279
- ixc-soft/
280
- service.ts (singleton + init + models)
281
- connection.ts (interna)
282
- types.ts
283
- models/ (gerados via sequelize-auto, com relations aplicadas)
284
-
285
- index.ts
286
- └── exporta apenas services
287
- ```
288
-
289
- ---
290
-
291
- # 📍 Status Atual
292
-
293
- | Etapa | Status |
294
- | ------------------------ | ------------------------------------------- |
295
- | 1 — Conexões base | ✅ Concluído |
296
- | 2 — Retry pattern | ✅ Concluído |
297
- | 3.1 — Estrutura IXC | ✅ Concluído |
298
- | 3.2 — Relations | ❌ Removido (agora integrado no initModels) |
299
- | 3.3 — Tipagem Models | ✅ Concluído |
300
- | 3.3.2 — Auto geração | ✅ Definido |
301
- | 3.4 — Service + Includes | ✅ Definido |
302
-
303
- ---
304
-
305
- # ⚡ Conclusão
306
-
307
- - Lib modular, escalável e tipada
308
- - Singleton + Service pattern protege inicialização
309
- - Geração automática de models via `sequelize-auto`
310
- - Queries podem ser feitas diretamente nos Services
311
- - Relações aplicadas automaticamente nos models
312
- - Base pronta para produção e fácil manutenção
313
-
314
- ---
315
-
316
- Se quiser, posso complementar a documentação com **exemplos práticos de queries tipadas com includes**, mostrando como usar `cliente.contratos` com autocomplete seguro e filtros avançados.
317
-
318
- Quer que eu faça isso agora?
package/dist/index.d.mts CHANGED
@@ -36623,7 +36623,7 @@ declare class RoutinesMongoService {
36623
36623
  getCollection<K extends keyof RoutinesMongoCollectionsModels>(key: K): RoutinesMongoCollectionsModels[K];
36624
36624
  }
36625
36625
 
36626
- type HttpAuthConfig = {
36626
+ type APIAuthConfig = {
36627
36627
  type: "bearer";
36628
36628
  token: string;
36629
36629
  } | {
@@ -36636,26 +36636,30 @@ type HttpAuthConfig = {
36636
36636
  } | {
36637
36637
  type: "none";
36638
36638
  };
36639
- interface HttpClientConfig {
36639
+ interface APIClientConfig {
36640
36640
  baseURL: string;
36641
- auth: HttpAuthConfig;
36641
+ auth: APIAuthConfig;
36642
36642
  timeout?: number;
36643
36643
  rejectUnauthorized?: boolean;
36644
36644
  /** Interceptor customizado de request — ex: adicionar headers extras */
36645
36645
  onRequest?: (config: AxiosRequestConfig) => AxiosRequestConfig;
36646
36646
  /** Interceptor customizado de erro — ex: logging específico do client */
36647
- onError?: (error: HttpClientError) => never;
36647
+ onError?: (error: APIClientError) => never;
36648
36648
  }
36649
- interface HttpClientError {
36649
+ interface APIClientError {
36650
36650
  status: number | null;
36651
36651
  message: string;
36652
36652
  raw: unknown;
36653
36653
  }
36654
+ interface APIConfigType {
36655
+ baseURL: string;
36656
+ token?: string;
36657
+ }
36654
36658
 
36655
- declare class HttpClient {
36659
+ declare class APIClient {
36656
36660
  private readonly config;
36657
36661
  protected readonly http: AxiosInstance;
36658
- constructor(config: HttpClientConfig);
36662
+ constructor(config: APIClientConfig);
36659
36663
  private applyAuthInterceptor;
36660
36664
  private applyErrorInterceptor;
36661
36665
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
@@ -36665,18 +36669,6 @@ declare class HttpClient {
36665
36669
  delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
36666
36670
  }
36667
36671
 
36668
- interface IXCSoftApiConfig {
36669
- /**
36670
- * URL base da API do IXC Soft.
36671
- */
36672
- baseURL?: string;
36673
- /**
36674
- * Token de autenticação da API.
36675
- * Será codificado em base64 automaticamente pelo cliente (Basic Auth).
36676
- */
36677
- token: string;
36678
- }
36679
-
36680
36672
  interface SuOssChamadoInput {
36681
36673
  tipo?: string;
36682
36674
  id_ticket?: string;
@@ -36774,7 +36766,7 @@ interface IxcSuOssChamadoResponse {
36774
36766
  declare class SuOssChamadoResource {
36775
36767
  private readonly client;
36776
36768
  private readonly endpoint;
36777
- constructor(client: HttpClient);
36769
+ constructor(client: APIClient);
36778
36770
  /**
36779
36771
  * Insere uma nova Ordem de Serviço (Chamado).
36780
36772
  */
@@ -36808,9 +36800,9 @@ declare class SuOssChamadoResource {
36808
36800
  }): Promise<IxcSuOssChamadoResponse>;
36809
36801
  }
36810
36802
 
36811
- declare class IXCSoftApiClient extends HttpClient {
36803
+ declare class IXCSoftAPIClient extends APIClient {
36812
36804
  readonly ordensDeServico: SuOssChamadoResource;
36813
- constructor(config: IXCSoftApiConfig);
36805
+ constructor(config: APIConfigType);
36814
36806
  }
36815
36807
 
36816
36808
  interface MonthlyFeesForClientInput {
@@ -36839,4 +36831,98 @@ declare namespace ixcSoftApi_types {
36839
36831
  export type { ixcSoftApi_types_IxcSuOssChamadoResponse as IxcSuOssChamadoResponse, ixcSoftApi_types_MonthlyFeesForClientInput as MonthlyFeesForClientInput, ixcSoftApi_types_MonthlyFeesForClientResponse as MonthlyFeesForClientResponse, ixcSoftApi_types_SuOssChamadoInput as SuOssChamadoInput, ixcSoftApi_types_SuOssChamadoListFilters as SuOssChamadoListFilters };
36840
36832
  }
36841
36833
 
36842
- export { IXCSoftApiClient, type IXCSoftMysqlModels, type IXCSoftMysqlModelsAttributes, IXCSoftMysqlService, ixcSoftApi_types as IXCSoftTypes, type OPASuiteMongoCollectionsModels, type OPASuiteMongoDocuments, OPASuiteMongoService, type RoutinesMongoCollectionsModels, type RoutinesMongoDocuments, RoutinesMongoService, type ToolsMongoCollectionsModels, type ToolsMongoDocuments, ToolsMongoService, logger, printSignature };
36834
+ interface RoutinesTasksCreateInput {
36835
+ name: string;
36836
+ description: string;
36837
+ cron_expression: string;
36838
+ triggered_by: string;
36839
+ }
36840
+ interface RoutinesTasksUpdateInput {
36841
+ triggered_by: string;
36842
+ name?: string;
36843
+ description?: string;
36844
+ cron_expression?: string;
36845
+ is_active?: boolean;
36846
+ }
36847
+ interface RoutinesTasksToggleActiveInput {
36848
+ triggered_by: string;
36849
+ is_active: boolean;
36850
+ }
36851
+ interface RoutinesTasksExecuteInput {
36852
+ triggered_by: string;
36853
+ }
36854
+ interface RoutinesTasksResponse {
36855
+ _id: string;
36856
+ name: string;
36857
+ description: string;
36858
+ cron_expression: string;
36859
+ is_active: boolean;
36860
+ created_at: string;
36861
+ updated_at: string;
36862
+ }
36863
+ interface RoutinesTasksLogResponse {
36864
+ _id: string;
36865
+ task_id: string;
36866
+ triggered_by: string;
36867
+ executed_at: string;
36868
+ success: boolean;
36869
+ message?: string;
36870
+ }
36871
+
36872
+ declare class RoutinesTasksResource {
36873
+ private readonly client;
36874
+ private readonly endpoint;
36875
+ constructor(client: APIClient);
36876
+ /**
36877
+ * POST /v1/tasks
36878
+ * Cria uma nova task agendada.
36879
+ */
36880
+ criar(data: RoutinesTasksCreateInput): Promise<RoutinesTasksResponse>;
36881
+ /**
36882
+ * GET /v1/tasks
36883
+ * Lista todas as tasks.
36884
+ */
36885
+ findAll(): Promise<RoutinesTasksResponse[]>;
36886
+ /**
36887
+ * GET /v1/tasks/:_id
36888
+ * Busca uma task pelo ID.
36889
+ */
36890
+ findOne(id: string): Promise<RoutinesTasksResponse>;
36891
+ /**
36892
+ * GET /v1/tasks/:_id/logs
36893
+ * Busca os logs de execução de uma task.
36894
+ */
36895
+ logs(id: string): Promise<RoutinesTasksLogResponse[]>;
36896
+ /**
36897
+ * PATCH /v1/tasks/:_id
36898
+ * Atualiza uma task existente.
36899
+ */
36900
+ update(id: string, data: RoutinesTasksUpdateInput): Promise<RoutinesTasksResponse>;
36901
+ /**
36902
+ * PATCH /v1/tasks/:_id/toggle-active
36903
+ * Ativa ou desativa uma task.
36904
+ */
36905
+ toggleActive(id: string, data: RoutinesTasksToggleActiveInput): Promise<RoutinesTasksResponse>;
36906
+ /**
36907
+ * POST /v1/tasks/:_id/execute
36908
+ * Dispara a execução manual de uma task.
36909
+ */
36910
+ execute(id: string, data: RoutinesTasksExecuteInput): Promise<RoutinesTasksResponse>;
36911
+ }
36912
+
36913
+ declare class RoutinesAPIClient extends APIClient {
36914
+ readonly routinesTasksResource: RoutinesTasksResource;
36915
+ constructor(config: APIConfigType);
36916
+ }
36917
+
36918
+ type routinesApi_types_RoutinesTasksCreateInput = RoutinesTasksCreateInput;
36919
+ type routinesApi_types_RoutinesTasksExecuteInput = RoutinesTasksExecuteInput;
36920
+ type routinesApi_types_RoutinesTasksLogResponse = RoutinesTasksLogResponse;
36921
+ type routinesApi_types_RoutinesTasksResponse = RoutinesTasksResponse;
36922
+ type routinesApi_types_RoutinesTasksToggleActiveInput = RoutinesTasksToggleActiveInput;
36923
+ type routinesApi_types_RoutinesTasksUpdateInput = RoutinesTasksUpdateInput;
36924
+ declare namespace routinesApi_types {
36925
+ export type { routinesApi_types_RoutinesTasksCreateInput as RoutinesTasksCreateInput, routinesApi_types_RoutinesTasksExecuteInput as RoutinesTasksExecuteInput, routinesApi_types_RoutinesTasksLogResponse as RoutinesTasksLogResponse, routinesApi_types_RoutinesTasksResponse as RoutinesTasksResponse, routinesApi_types_RoutinesTasksToggleActiveInput as RoutinesTasksToggleActiveInput, routinesApi_types_RoutinesTasksUpdateInput as RoutinesTasksUpdateInput };
36926
+ }
36927
+
36928
+ export { IXCSoftAPIClient, ixcSoftApi_types as IXCSoftAPITypes, type IXCSoftMysqlModels, type IXCSoftMysqlModelsAttributes, IXCSoftMysqlService, type OPASuiteMongoCollectionsModels, type OPASuiteMongoDocuments, OPASuiteMongoService, RoutinesAPIClient, routinesApi_types as RoutinesAPITypes, type RoutinesMongoCollectionsModels, type RoutinesMongoDocuments, RoutinesMongoService, type ToolsMongoCollectionsModels, type ToolsMongoDocuments, ToolsMongoService, logger, printSignature };
package/dist/index.d.ts CHANGED
@@ -36623,7 +36623,7 @@ declare class RoutinesMongoService {
36623
36623
  getCollection<K extends keyof RoutinesMongoCollectionsModels>(key: K): RoutinesMongoCollectionsModels[K];
36624
36624
  }
36625
36625
 
36626
- type HttpAuthConfig = {
36626
+ type APIAuthConfig = {
36627
36627
  type: "bearer";
36628
36628
  token: string;
36629
36629
  } | {
@@ -36636,26 +36636,30 @@ type HttpAuthConfig = {
36636
36636
  } | {
36637
36637
  type: "none";
36638
36638
  };
36639
- interface HttpClientConfig {
36639
+ interface APIClientConfig {
36640
36640
  baseURL: string;
36641
- auth: HttpAuthConfig;
36641
+ auth: APIAuthConfig;
36642
36642
  timeout?: number;
36643
36643
  rejectUnauthorized?: boolean;
36644
36644
  /** Interceptor customizado de request — ex: adicionar headers extras */
36645
36645
  onRequest?: (config: AxiosRequestConfig) => AxiosRequestConfig;
36646
36646
  /** Interceptor customizado de erro — ex: logging específico do client */
36647
- onError?: (error: HttpClientError) => never;
36647
+ onError?: (error: APIClientError) => never;
36648
36648
  }
36649
- interface HttpClientError {
36649
+ interface APIClientError {
36650
36650
  status: number | null;
36651
36651
  message: string;
36652
36652
  raw: unknown;
36653
36653
  }
36654
+ interface APIConfigType {
36655
+ baseURL: string;
36656
+ token?: string;
36657
+ }
36654
36658
 
36655
- declare class HttpClient {
36659
+ declare class APIClient {
36656
36660
  private readonly config;
36657
36661
  protected readonly http: AxiosInstance;
36658
- constructor(config: HttpClientConfig);
36662
+ constructor(config: APIClientConfig);
36659
36663
  private applyAuthInterceptor;
36660
36664
  private applyErrorInterceptor;
36661
36665
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
@@ -36665,18 +36669,6 @@ declare class HttpClient {
36665
36669
  delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
36666
36670
  }
36667
36671
 
36668
- interface IXCSoftApiConfig {
36669
- /**
36670
- * URL base da API do IXC Soft.
36671
- */
36672
- baseURL?: string;
36673
- /**
36674
- * Token de autenticação da API.
36675
- * Será codificado em base64 automaticamente pelo cliente (Basic Auth).
36676
- */
36677
- token: string;
36678
- }
36679
-
36680
36672
  interface SuOssChamadoInput {
36681
36673
  tipo?: string;
36682
36674
  id_ticket?: string;
@@ -36774,7 +36766,7 @@ interface IxcSuOssChamadoResponse {
36774
36766
  declare class SuOssChamadoResource {
36775
36767
  private readonly client;
36776
36768
  private readonly endpoint;
36777
- constructor(client: HttpClient);
36769
+ constructor(client: APIClient);
36778
36770
  /**
36779
36771
  * Insere uma nova Ordem de Serviço (Chamado).
36780
36772
  */
@@ -36808,9 +36800,9 @@ declare class SuOssChamadoResource {
36808
36800
  }): Promise<IxcSuOssChamadoResponse>;
36809
36801
  }
36810
36802
 
36811
- declare class IXCSoftApiClient extends HttpClient {
36803
+ declare class IXCSoftAPIClient extends APIClient {
36812
36804
  readonly ordensDeServico: SuOssChamadoResource;
36813
- constructor(config: IXCSoftApiConfig);
36805
+ constructor(config: APIConfigType);
36814
36806
  }
36815
36807
 
36816
36808
  interface MonthlyFeesForClientInput {
@@ -36839,4 +36831,98 @@ declare namespace ixcSoftApi_types {
36839
36831
  export type { ixcSoftApi_types_IxcSuOssChamadoResponse as IxcSuOssChamadoResponse, ixcSoftApi_types_MonthlyFeesForClientInput as MonthlyFeesForClientInput, ixcSoftApi_types_MonthlyFeesForClientResponse as MonthlyFeesForClientResponse, ixcSoftApi_types_SuOssChamadoInput as SuOssChamadoInput, ixcSoftApi_types_SuOssChamadoListFilters as SuOssChamadoListFilters };
36840
36832
  }
36841
36833
 
36842
- export { IXCSoftApiClient, type IXCSoftMysqlModels, type IXCSoftMysqlModelsAttributes, IXCSoftMysqlService, ixcSoftApi_types as IXCSoftTypes, type OPASuiteMongoCollectionsModels, type OPASuiteMongoDocuments, OPASuiteMongoService, type RoutinesMongoCollectionsModels, type RoutinesMongoDocuments, RoutinesMongoService, type ToolsMongoCollectionsModels, type ToolsMongoDocuments, ToolsMongoService, logger, printSignature };
36834
+ interface RoutinesTasksCreateInput {
36835
+ name: string;
36836
+ description: string;
36837
+ cron_expression: string;
36838
+ triggered_by: string;
36839
+ }
36840
+ interface RoutinesTasksUpdateInput {
36841
+ triggered_by: string;
36842
+ name?: string;
36843
+ description?: string;
36844
+ cron_expression?: string;
36845
+ is_active?: boolean;
36846
+ }
36847
+ interface RoutinesTasksToggleActiveInput {
36848
+ triggered_by: string;
36849
+ is_active: boolean;
36850
+ }
36851
+ interface RoutinesTasksExecuteInput {
36852
+ triggered_by: string;
36853
+ }
36854
+ interface RoutinesTasksResponse {
36855
+ _id: string;
36856
+ name: string;
36857
+ description: string;
36858
+ cron_expression: string;
36859
+ is_active: boolean;
36860
+ created_at: string;
36861
+ updated_at: string;
36862
+ }
36863
+ interface RoutinesTasksLogResponse {
36864
+ _id: string;
36865
+ task_id: string;
36866
+ triggered_by: string;
36867
+ executed_at: string;
36868
+ success: boolean;
36869
+ message?: string;
36870
+ }
36871
+
36872
+ declare class RoutinesTasksResource {
36873
+ private readonly client;
36874
+ private readonly endpoint;
36875
+ constructor(client: APIClient);
36876
+ /**
36877
+ * POST /v1/tasks
36878
+ * Cria uma nova task agendada.
36879
+ */
36880
+ criar(data: RoutinesTasksCreateInput): Promise<RoutinesTasksResponse>;
36881
+ /**
36882
+ * GET /v1/tasks
36883
+ * Lista todas as tasks.
36884
+ */
36885
+ findAll(): Promise<RoutinesTasksResponse[]>;
36886
+ /**
36887
+ * GET /v1/tasks/:_id
36888
+ * Busca uma task pelo ID.
36889
+ */
36890
+ findOne(id: string): Promise<RoutinesTasksResponse>;
36891
+ /**
36892
+ * GET /v1/tasks/:_id/logs
36893
+ * Busca os logs de execução de uma task.
36894
+ */
36895
+ logs(id: string): Promise<RoutinesTasksLogResponse[]>;
36896
+ /**
36897
+ * PATCH /v1/tasks/:_id
36898
+ * Atualiza uma task existente.
36899
+ */
36900
+ update(id: string, data: RoutinesTasksUpdateInput): Promise<RoutinesTasksResponse>;
36901
+ /**
36902
+ * PATCH /v1/tasks/:_id/toggle-active
36903
+ * Ativa ou desativa uma task.
36904
+ */
36905
+ toggleActive(id: string, data: RoutinesTasksToggleActiveInput): Promise<RoutinesTasksResponse>;
36906
+ /**
36907
+ * POST /v1/tasks/:_id/execute
36908
+ * Dispara a execução manual de uma task.
36909
+ */
36910
+ execute(id: string, data: RoutinesTasksExecuteInput): Promise<RoutinesTasksResponse>;
36911
+ }
36912
+
36913
+ declare class RoutinesAPIClient extends APIClient {
36914
+ readonly routinesTasksResource: RoutinesTasksResource;
36915
+ constructor(config: APIConfigType);
36916
+ }
36917
+
36918
+ type routinesApi_types_RoutinesTasksCreateInput = RoutinesTasksCreateInput;
36919
+ type routinesApi_types_RoutinesTasksExecuteInput = RoutinesTasksExecuteInput;
36920
+ type routinesApi_types_RoutinesTasksLogResponse = RoutinesTasksLogResponse;
36921
+ type routinesApi_types_RoutinesTasksResponse = RoutinesTasksResponse;
36922
+ type routinesApi_types_RoutinesTasksToggleActiveInput = RoutinesTasksToggleActiveInput;
36923
+ type routinesApi_types_RoutinesTasksUpdateInput = RoutinesTasksUpdateInput;
36924
+ declare namespace routinesApi_types {
36925
+ export type { routinesApi_types_RoutinesTasksCreateInput as RoutinesTasksCreateInput, routinesApi_types_RoutinesTasksExecuteInput as RoutinesTasksExecuteInput, routinesApi_types_RoutinesTasksLogResponse as RoutinesTasksLogResponse, routinesApi_types_RoutinesTasksResponse as RoutinesTasksResponse, routinesApi_types_RoutinesTasksToggleActiveInput as RoutinesTasksToggleActiveInput, routinesApi_types_RoutinesTasksUpdateInput as RoutinesTasksUpdateInput };
36926
+ }
36927
+
36928
+ export { IXCSoftAPIClient, ixcSoftApi_types as IXCSoftAPITypes, type IXCSoftMysqlModels, type IXCSoftMysqlModelsAttributes, IXCSoftMysqlService, type OPASuiteMongoCollectionsModels, type OPASuiteMongoDocuments, OPASuiteMongoService, RoutinesAPIClient, routinesApi_types as RoutinesAPITypes, type RoutinesMongoCollectionsModels, type RoutinesMongoDocuments, RoutinesMongoService, type ToolsMongoCollectionsModels, type ToolsMongoDocuments, ToolsMongoService, logger, printSignature };
package/dist/index.js CHANGED
@@ -30,10 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- IXCSoftApiClient: () => IXCSoftApiClient,
33
+ IXCSoftAPIClient: () => IXCSoftAPIClient,
34
+ IXCSoftAPITypes: () => ixc_soft_api_types_exports,
34
35
  IXCSoftMysqlService: () => IXCSoftMysqlService,
35
- IXCSoftTypes: () => ixc_soft_api_types_exports,
36
36
  OPASuiteMongoService: () => OPASuiteMongoService,
37
+ RoutinesAPIClient: () => RoutinesAPIClient,
38
+ RoutinesAPITypes: () => routines_api_types_exports,
37
39
  RoutinesMongoService: () => RoutinesMongoService,
38
40
  ToolsMongoService: () => ToolsMongoService,
39
41
  logger: () => logger,
@@ -91097,22 +91099,22 @@ var RoutinesMongoService = class _RoutinesMongoService {
91097
91099
  }
91098
91100
  };
91099
91101
 
91100
- // src/apis/core/http-client.ts
91102
+ // src/apis/core/api-client.ts
91101
91103
  var import_axios = __toESM(require("axios"));
91102
91104
  var https = __toESM(require("https"));
91103
91105
 
91104
- // src/apis/core/http-client.errors.ts
91105
- var HttpRequestError = class extends Error {
91106
+ // src/apis/core/api-client.errors.ts
91107
+ var APIRequestError = class extends Error {
91106
91108
  constructor(error) {
91107
91109
  super(error.message);
91108
- this.name = "HttpRequestError";
91110
+ this.name = "APIRequestError";
91109
91111
  this.status = error.status;
91110
91112
  this.raw = error.raw;
91111
91113
  }
91112
91114
  };
91113
91115
 
91114
- // src/apis/core/http-client.ts
91115
- var HttpClient = class {
91116
+ // src/apis/core/api-client.ts
91117
+ var APIClient = class {
91116
91118
  constructor(config) {
91117
91119
  this.config = config;
91118
91120
  this.http = import_axios.default.create({
@@ -91160,7 +91162,7 @@ var HttpClient = class {
91160
91162
  if (this.config.onError) {
91161
91163
  return this.config.onError(error);
91162
91164
  }
91163
- throw new HttpRequestError(error);
91165
+ throw new APIRequestError(error);
91164
91166
  }
91165
91167
  );
91166
91168
  }
@@ -91182,7 +91184,7 @@ var HttpClient = class {
91182
91184
  }
91183
91185
  };
91184
91186
 
91185
- // src/apis/clients/ixc-soft/resources/su-oss-chamado/su-oss-chamado.resource.ts
91187
+ // src/apis/clients/ixc-soft/resources/su-oss-chamado/ixc-soft-su-oss-chamado.resource.ts
91186
91188
  var SuOssChamadoResource = class {
91187
91189
  constructor(client) {
91188
91190
  this.client = client;
@@ -91278,7 +91280,7 @@ var SuOssChamadoResource = class {
91278
91280
  };
91279
91281
 
91280
91282
  // src/apis/clients/ixc-soft/ixc-soft-api.client.ts
91281
- var IXCSoftApiClient = class extends HttpClient {
91283
+ var IXCSoftAPIClient = class extends APIClient {
91282
91284
  constructor(config) {
91283
91285
  if (!config.baseURL || !config.token) {
91284
91286
  throw new Error("Base URL and Token are required");
@@ -91296,12 +91298,99 @@ var IXCSoftApiClient = class extends HttpClient {
91296
91298
 
91297
91299
  // src/apis/clients/ixc-soft/ixc-soft-api.types.ts
91298
91300
  var ixc_soft_api_types_exports = {};
91301
+
91302
+ // src/apis/clients/routines/resources/tasks/routines-tasks.resource.ts
91303
+ var RoutinesTasksResource = class {
91304
+ constructor(client) {
91305
+ this.client = client;
91306
+ this.endpoint = "/v1/tasks";
91307
+ }
91308
+ /**
91309
+ * POST /v1/tasks
91310
+ * Cria uma nova task agendada.
91311
+ */
91312
+ async criar(data) {
91313
+ return this.client.post(this.endpoint, data);
91314
+ }
91315
+ /**
91316
+ * GET /v1/tasks
91317
+ * Lista todas as tasks.
91318
+ */
91319
+ async findAll() {
91320
+ return this.client.get(this.endpoint);
91321
+ }
91322
+ /**
91323
+ * GET /v1/tasks/:_id
91324
+ * Busca uma task pelo ID.
91325
+ */
91326
+ async findOne(id) {
91327
+ return this.client.get(`${this.endpoint}/${id}`);
91328
+ }
91329
+ /**
91330
+ * GET /v1/tasks/:_id/logs
91331
+ * Busca os logs de execução de uma task.
91332
+ */
91333
+ async logs(id) {
91334
+ return this.client.get(
91335
+ `${this.endpoint}/${id}/logs`
91336
+ );
91337
+ }
91338
+ /**
91339
+ * PATCH /v1/tasks/:_id
91340
+ * Atualiza uma task existente.
91341
+ */
91342
+ async update(id, data) {
91343
+ return this.client.patch(
91344
+ `${this.endpoint}/${id}`,
91345
+ data
91346
+ );
91347
+ }
91348
+ /**
91349
+ * PATCH /v1/tasks/:_id/toggle-active
91350
+ * Ativa ou desativa uma task.
91351
+ */
91352
+ async toggleActive(id, data) {
91353
+ return this.client.patch(
91354
+ `${this.endpoint}/${id}/toggle-active`,
91355
+ data
91356
+ );
91357
+ }
91358
+ /**
91359
+ * POST /v1/tasks/:_id/execute
91360
+ * Dispara a execução manual de uma task.
91361
+ */
91362
+ async execute(id, data) {
91363
+ return this.client.post(
91364
+ `${this.endpoint}/${id}/execute`,
91365
+ data
91366
+ );
91367
+ }
91368
+ };
91369
+
91370
+ // src/apis/clients/routines/routines-api.client.ts
91371
+ var RoutinesAPIClient = class extends APIClient {
91372
+ constructor(config) {
91373
+ if (!config.baseURL) {
91374
+ throw new Error("Base URL required");
91375
+ }
91376
+ super({
91377
+ baseURL: config.baseURL,
91378
+ auth: { type: "none" }
91379
+ });
91380
+ this.routinesTasksResource = new RoutinesTasksResource(this);
91381
+ }
91382
+ };
91383
+
91384
+ // src/apis/clients/routines/routines-api.types.ts
91385
+ var routines_api_types_exports = {};
91299
91386
  // Annotate the CommonJS export names for ESM import in node:
91300
91387
  0 && (module.exports = {
91301
- IXCSoftApiClient,
91388
+ IXCSoftAPIClient,
91389
+ IXCSoftAPITypes,
91302
91390
  IXCSoftMysqlService,
91303
- IXCSoftTypes,
91304
91391
  OPASuiteMongoService,
91392
+ RoutinesAPIClient,
91393
+ RoutinesAPITypes,
91305
91394
  RoutinesMongoService,
91306
91395
  ToolsMongoService,
91307
91396
  logger,
package/dist/index.mjs CHANGED
@@ -91054,22 +91054,22 @@ var RoutinesMongoService = class _RoutinesMongoService {
91054
91054
  }
91055
91055
  };
91056
91056
 
91057
- // src/apis/core/http-client.ts
91057
+ // src/apis/core/api-client.ts
91058
91058
  import axios from "axios";
91059
91059
  import * as https from "https";
91060
91060
 
91061
- // src/apis/core/http-client.errors.ts
91062
- var HttpRequestError = class extends Error {
91061
+ // src/apis/core/api-client.errors.ts
91062
+ var APIRequestError = class extends Error {
91063
91063
  constructor(error) {
91064
91064
  super(error.message);
91065
- this.name = "HttpRequestError";
91065
+ this.name = "APIRequestError";
91066
91066
  this.status = error.status;
91067
91067
  this.raw = error.raw;
91068
91068
  }
91069
91069
  };
91070
91070
 
91071
- // src/apis/core/http-client.ts
91072
- var HttpClient = class {
91071
+ // src/apis/core/api-client.ts
91072
+ var APIClient = class {
91073
91073
  constructor(config) {
91074
91074
  this.config = config;
91075
91075
  this.http = axios.create({
@@ -91117,7 +91117,7 @@ var HttpClient = class {
91117
91117
  if (this.config.onError) {
91118
91118
  return this.config.onError(error);
91119
91119
  }
91120
- throw new HttpRequestError(error);
91120
+ throw new APIRequestError(error);
91121
91121
  }
91122
91122
  );
91123
91123
  }
@@ -91139,7 +91139,7 @@ var HttpClient = class {
91139
91139
  }
91140
91140
  };
91141
91141
 
91142
- // src/apis/clients/ixc-soft/resources/su-oss-chamado/su-oss-chamado.resource.ts
91142
+ // src/apis/clients/ixc-soft/resources/su-oss-chamado/ixc-soft-su-oss-chamado.resource.ts
91143
91143
  var SuOssChamadoResource = class {
91144
91144
  constructor(client) {
91145
91145
  this.client = client;
@@ -91235,7 +91235,7 @@ var SuOssChamadoResource = class {
91235
91235
  };
91236
91236
 
91237
91237
  // src/apis/clients/ixc-soft/ixc-soft-api.client.ts
91238
- var IXCSoftApiClient = class extends HttpClient {
91238
+ var IXCSoftAPIClient = class extends APIClient {
91239
91239
  constructor(config) {
91240
91240
  if (!config.baseURL || !config.token) {
91241
91241
  throw new Error("Base URL and Token are required");
@@ -91253,11 +91253,98 @@ var IXCSoftApiClient = class extends HttpClient {
91253
91253
 
91254
91254
  // src/apis/clients/ixc-soft/ixc-soft-api.types.ts
91255
91255
  var ixc_soft_api_types_exports = {};
91256
+
91257
+ // src/apis/clients/routines/resources/tasks/routines-tasks.resource.ts
91258
+ var RoutinesTasksResource = class {
91259
+ constructor(client) {
91260
+ this.client = client;
91261
+ this.endpoint = "/v1/tasks";
91262
+ }
91263
+ /**
91264
+ * POST /v1/tasks
91265
+ * Cria uma nova task agendada.
91266
+ */
91267
+ async criar(data) {
91268
+ return this.client.post(this.endpoint, data);
91269
+ }
91270
+ /**
91271
+ * GET /v1/tasks
91272
+ * Lista todas as tasks.
91273
+ */
91274
+ async findAll() {
91275
+ return this.client.get(this.endpoint);
91276
+ }
91277
+ /**
91278
+ * GET /v1/tasks/:_id
91279
+ * Busca uma task pelo ID.
91280
+ */
91281
+ async findOne(id) {
91282
+ return this.client.get(`${this.endpoint}/${id}`);
91283
+ }
91284
+ /**
91285
+ * GET /v1/tasks/:_id/logs
91286
+ * Busca os logs de execução de uma task.
91287
+ */
91288
+ async logs(id) {
91289
+ return this.client.get(
91290
+ `${this.endpoint}/${id}/logs`
91291
+ );
91292
+ }
91293
+ /**
91294
+ * PATCH /v1/tasks/:_id
91295
+ * Atualiza uma task existente.
91296
+ */
91297
+ async update(id, data) {
91298
+ return this.client.patch(
91299
+ `${this.endpoint}/${id}`,
91300
+ data
91301
+ );
91302
+ }
91303
+ /**
91304
+ * PATCH /v1/tasks/:_id/toggle-active
91305
+ * Ativa ou desativa uma task.
91306
+ */
91307
+ async toggleActive(id, data) {
91308
+ return this.client.patch(
91309
+ `${this.endpoint}/${id}/toggle-active`,
91310
+ data
91311
+ );
91312
+ }
91313
+ /**
91314
+ * POST /v1/tasks/:_id/execute
91315
+ * Dispara a execução manual de uma task.
91316
+ */
91317
+ async execute(id, data) {
91318
+ return this.client.post(
91319
+ `${this.endpoint}/${id}/execute`,
91320
+ data
91321
+ );
91322
+ }
91323
+ };
91324
+
91325
+ // src/apis/clients/routines/routines-api.client.ts
91326
+ var RoutinesAPIClient = class extends APIClient {
91327
+ constructor(config) {
91328
+ if (!config.baseURL) {
91329
+ throw new Error("Base URL required");
91330
+ }
91331
+ super({
91332
+ baseURL: config.baseURL,
91333
+ auth: { type: "none" }
91334
+ });
91335
+ this.routinesTasksResource = new RoutinesTasksResource(this);
91336
+ }
91337
+ };
91338
+
91339
+ // src/apis/clients/routines/routines-api.types.ts
91340
+ var routines_api_types_exports = {};
91256
91341
  export {
91257
- IXCSoftApiClient,
91342
+ IXCSoftAPIClient,
91343
+ ixc_soft_api_types_exports as IXCSoftAPITypes,
91258
91344
  IXCSoftMysqlService,
91259
- ixc_soft_api_types_exports as IXCSoftTypes,
91260
91345
  OPASuiteMongoService,
91346
+ RoutinesAPIClient,
91347
+ routines_api_types_exports as RoutinesAPITypes,
91261
91348
  RoutinesMongoService,
91262
91349
  ToolsMongoService,
91263
91350
  logger,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cristian-israel/giganet_lib_conecta",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Database Connector Layer",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",