ixc-orm 1.7.0 → 1.8.0

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/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # 🔄 CHANGELOG
2
+ - [v1.8.0 - 18 de outubro de 2025](#v180)
3
+ - [v1.7.1 - 18 de outubro de 2025](#v171)
2
4
  - [v1.7.0 - 10 de outubro de 2025](#v170)
3
5
  - [v1.6.0 - 16 de agosto de 2025](#v150)
4
6
  - [v1.5.0 - 16 de agosto de 2025](#v150)
@@ -8,6 +10,13 @@
8
10
 
9
11
  ## 🚀 Novidades
10
12
 
13
+ ### v1.8.0
14
+ * **Melhoria:** O processo de carregamento do ambiente consegue detectar se as variáveis já foram carregas por um container Docker e interrompe o carregamento através do `.env`, evitando que a aplicação encerre o processo com erro..
15
+ * **Correção:** Corrigida incompatibilidade com o cache do `pnpm`. Ao tentar carregar as variáveis diretamente do arquivo `.env`, o ambiente buscará o arquivo de forma recursiva, para conseguir encontrá-lo mesmo quando a biblioteca interpretar a pasta `node_modules` como root. (ocorre em alguns cenários muito específicos, apenas com o `pnpm`), evitando que o processo seja encerrado com erro.
16
+
17
+ ### v1.7.1
18
+ * **Melhoria:** Adicionado o método `fail()` à classe <a href="https://github.com/SousaFelipe/ixc-orm/blob/main/src/IxcResponse.ts">IxcResponse</a>, para verificar se o IXC Provedor retornou uma resposta com erro.
19
+
11
20
  ### v1.7.0
12
21
  * **Atualização:** Novas classes adiconadas, para simplificar a manipulação dos filtros de busca e das respostas da API do **IXC Provedor**.
13
22
  * A nova classe <a href="https://github.com/SousaFelipe/ixc-orm/blob/builders/src/IxcOrm.ts">IxcOrm</a> pode substituir a classe `IXCCliente` e fornece uma maneira mais dinâmica de construir a query de busca, através dos métodos `where()`, `like()`, `exactly()`, `lessThan()`, `lessThanEquals()`, `greaterThan()` e `greaterThanEquals()`.
package/README.md CHANGED
@@ -6,19 +6,23 @@
6
6
  [![npm](https://img.shields.io/npm/dt/ixc-orm.svg?style=for-the-badge)](https://www.npmjs.com/package/ixc-orm)
7
7
  ![Status](https://img.shields.io/badge/Status-Stable-brightgreen?style=for-the-badge)
8
8
  ![NPM Version](https://img.shields.io/npm/v/ixc-orm?style=for-the-badge)
9
-
10
- Esse ORM visa facilitar o consumo de dados da API oficial do [IXC Provedor](https://ixcsoft.com/ixc-provedor).\
9
+
10
+ Esse ORM foi criado com o intuito de facilitar o consumo de dados da API oficial do [IXC Provedor](https://ixcsoft.com/ixc-provedor).\
11
11
  Essa biblioteca não faz parte das bibliotecas oficiais da [IXCsoft](https://ixcsoft.com/) e foi desenvolvida de forma independente e sem fins lucrativos.
12
12
 
13
13
  </div>
14
14
 
15
15
 
16
- ## Instalação
16
+ ## Download
17
17
 
18
18
  ```bash
19
19
  npm install ixc-orm
20
20
  ```
21
- ou
21
+
22
+ ```bash
23
+ pnpm add ixc-orm
24
+ ```
25
+
22
26
  ```bash
23
27
  yarn add ixc-orm
24
28
  ```
@@ -26,10 +30,47 @@ yarn add ixc-orm
26
30
 
27
31
  ## Como utilizar
28
32
 
29
- As classes que representarão as tabelas dentro do banco de dados do seu servidor IXC, deverão herdar da classe `IxcOrm` (nova versão), como no exemplo a seguir:
33
+ Para configurar a comunicação da biblioteca com seu servidor IXC Provedor, é necessário adicionar as seguintes variáveis de ambiente a um arquivo `.env`, que esteja localizado no diretório raiz do seu projeto.
34
+
35
+ > [!NOTE]\
36
+ > Versão 1.8.0 `stable`
37
+
38
+ - **IXC_ACCESS_TOKEN** Um token de API gerado dentro do IXC Provedor.
39
+ - **IXC_SERVER_DOMAIN** O domínio do seu servidor IXC Provedor.
40
+
41
+ ```ini
42
+ IXC_ACCESS_TOKEN=conteúdo-do-token-gerado-dentro-do-ixc
43
+ IXC_SERVER_DOMAIN=www.dominio-do-seu-servidor-ixc.com.br
44
+ ```
45
+
46
+ Você também poderá configurar para que o Docker carregue as variáveis, ao invés de carregá-las diretamente do arquivo `.env`, dessa forma:
47
+
48
+ ```yaml
49
+ services:
50
+ sua-aplicacao:
51
+ build: .
52
+ image: sua-imagem-docker
53
+ environment:
54
+ - IXC_ACCESS_TOKEN=${IXC_ACCESS_TOKEN}
55
+ - IXC_SERVER_DOMAIN=${IXC_SERVER_DOMAIN}
56
+ # Outras configurações do seu serviço
57
+ ```
58
+
59
+
60
+ > Versão 1.6.0 ou anterior:
61
+
62
+ - **IXC_HOST** A url do seu servidor IXC Provedor.
63
+ - **IXC_TOKEN** Um token de API gerado dentro do IXC Provedor.
64
+
65
+ ```ini
66
+ IXC_HOST="https://dominiodoservidorixc.com.br/webservice/v1"
67
+ IXC_TOKEN="8:k4n8wk1946j7mimthei869cq1zz2u940f2gqobqg081y2oefl80mzhtq2wud3gqp"
68
+ ```
69
+
70
+ As classes que representarão os diferentes tipos de registros no seu **IXC Provedor**, deverão herdar da classe `IxcOrm` (nova versão), como no exemplo a seguir:
30
71
 
31
72
  > [!NOTE]\
32
- > Versão 1.7.0 `stable`
73
+ > Versão 1.8.0 `stable`
33
74
 
34
75
  ```typescript
35
76
  import { IxcOrm } from 'ixc-orm';
@@ -56,7 +97,7 @@ class Contrato extends IXCClient {
56
97
  Após instanciar um objeto com o tipo que você criou (`Contrato, como no exemplo a cima`), você poderá acessar os métodos de construção da query de busca.
57
98
 
58
99
  > [!NOTE]\
59
- > Versão 1.7.0 `stable`
100
+ > Versão 1.8.0 `stable`
60
101
 
61
102
  ```typescript
62
103
  import { IxcResponse, Sort } from 'ixc-orm';
@@ -101,8 +142,8 @@ const contratos = await contrato.find(id_contrato)
101
142
  ## Recursos da API do IXC Provedor
102
143
 
103
144
  Existem alguns `endpoints` que a API do IXC disponibiliza, a fim de "encurtar o caminho" para chegar até algumas informações. Como por exemplo, obter o arquivo PDF de uma fatura.\
104
- Você não precisará se preocupar em criar uma classe `Boleto` que herde da classe `IXCClient`, por exemplo,\
105
- nem encadear chamadas `where`. Basta seguir o exemplo abaixo:
145
+ Para isso, você não precisará se preocupar em criar uma classe `Boleto` que herde da classe `IxcOrm`, por exemplo,\
146
+ nem encadear chamadas de filtros. Basta fazer como no exemplo a seguir:
106
147
 
107
148
  ```typescript
108
149
  import { Recurso } from 'ixc-orm';
@@ -112,36 +153,9 @@ const id_contrato = 45852;
112
153
  const response = await Recurso.desbloqueioDeConfianca(id_contrato);
113
154
  ```
114
155
 
115
- > Dos recursos disponibilizados pela API do **IXC Provedor**, esta biblioteca já implementou os seguintes recursos:\
156
+ > Dos recursos disponibilizados pela API do **IXC Provedor**, essa biblioteca já implementou:\
116
157
  > `get_boleto`, `desbloqueio_confianca` e `cliente_contrato_btn_lib_temp_24722`.\
117
- > Obs: Os nomes dos recursos estão de acordo com a API do **IXC Provedor** a fim de facilitar o estudo de sua documentação oficial.
118
-
119
-
120
- ## Variáveis de Ambiente
121
-
122
- Para configurar a comunicação da biblioteca com seu servidor IXC, é necessário adicionar as seguintes variáveis de ambiente a um arquivo `.env`, que esteja localizado no diretório raiz do seu projeto.
123
-
124
- > [!NOTE]\
125
- > Versão 1.7.0 `stable`
126
-
127
- - **IXC_ACCESS_TOKEN** Um token de API gerado dentro do IXC Provedor.
128
- - **IXC_SERVER_DOMAIN** O domínio do seu servidor IXC Provedor.
129
-
130
- ```ini
131
- IXC_ACCESS_TOKEN=conteúdo-do-token-gerado-dentro-do-ixC
132
- IXC_SERVER_DOMAIN=www.dominio-do-seu-servidor-ixc.com.br
133
- ```
134
-
135
-
136
- > Versão 1.6.0 ou anterior:
137
-
138
- - **IXC_HOST** A url do seu servidor **IXC Provedor**.
139
- - **IXC_TOKEN** Um token de API gerado dentro do **IXC Provedor**.
140
-
141
- ```ini
142
- IXC_HOST="https://dominiodoservidorixc.com.br/webservice/v1"
143
- IXC_TOKEN="8:k4n8wk1946j7mimthei869cq1zz2u940f2gqobqg081y2oefl80mzhtq2wud3gqp"
144
- ```
158
+ > Obs: Os nomes dos recursos estão de acordo com a API do **IXC Provedor** a fim de facilitar o estudo através da sua documentação oficial.
145
159
 
146
160
 
147
161
  # Contribuições
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', {targets: {node: 'current'}}],
4
+ '@babel/preset-typescript',
5
+ ],
6
+ };
@@ -1,18 +1,26 @@
1
1
  export default class IxcResponse {
2
2
  private data;
3
+ private text;
3
4
  /**
4
5
  * Cria um novo objeto no formato de uma resposta padrão do IXC Provedor.
5
6
  *
6
7
  * @param error Uma exceção capturada por um bloco try-catch.
7
8
  * @returns Um objeto de resposta do IXC Provedor.
8
9
  */
9
- static createPropsWithError(error: any): string;
10
+ static createResponseTextWithError(error: any): string;
10
11
  /**
11
12
  * Método construtor da classe.
12
13
  *
13
14
  * @param text O conteúdo da resposta do IXc Provedor, no formato de texto.
14
15
  */
15
16
  constructor(text: string);
17
+ /**
18
+ * Verifica se o IXC Provedor retornou uma mensagem de erro.
19
+ *
20
+ * @returns **true** se o corpo da mensagem estiver dentro de tags HTML e se a mensagem dentro das tags
21
+ * contiver a palavra "erro". Ou se o objeto da resposta possuir a propriedade { "type": "error", ... }.
22
+ */
23
+ fail(): boolean;
16
24
  /**
17
25
  * Obtém a quantidade total dos registros encontrados no banco de dados, além dos retornados na página atual.
18
26
  *
@@ -39,6 +47,7 @@ export default class IxcResponse {
39
47
  registros(): Array<{
40
48
  [key: string]: any;
41
49
  }>;
42
- private parseDataFromText;
43
- private parseDataFromHTML;
50
+ private responseTextHasHtml;
51
+ private createDataFromText;
52
+ private createDataFromHtml;
44
53
  }
@@ -8,7 +8,7 @@ class IxcResponse {
8
8
  * @param error Uma exceção capturada por um bloco try-catch.
9
9
  * @returns Um objeto de resposta do IXC Provedor.
10
10
  */
11
- static createPropsWithError(error) {
11
+ static createResponseTextWithError(error) {
12
12
  var _a;
13
13
  const response = {
14
14
  type: 'error',
@@ -25,7 +25,25 @@ class IxcResponse {
25
25
  * @param text O conteúdo da resposta do IXc Provedor, no formato de texto.
26
26
  */
27
27
  constructor(text) {
28
- this.data = this.parseDataFromText(text);
28
+ this.text = text;
29
+ this.data = this.createDataFromText();
30
+ }
31
+ /**
32
+ * Verifica se o IXC Provedor retornou uma mensagem de erro.
33
+ *
34
+ * @returns **true** se o corpo da mensagem estiver dentro de tags HTML e se a mensagem dentro das tags
35
+ * contiver a palavra "erro". Ou se o objeto da resposta possuir a propriedade { "type": "error", ... }.
36
+ */
37
+ fail() {
38
+ const hasHtml = this.responseTextHasHtml();
39
+ const hasError = this.message().includes('erro');
40
+ if (hasHtml && hasError) {
41
+ return true;
42
+ }
43
+ if (this.data && Object.keys(this.data).includes('type')) {
44
+ return this.data.type === 'error';
45
+ }
46
+ return false;
29
47
  }
30
48
  /**
31
49
  * Obtém a quantidade total dos registros encontrados no banco de dados, além dos retornados na página atual.
@@ -75,15 +93,18 @@ class IxcResponse {
75
93
  }
76
94
  return this.data.registros;
77
95
  }
78
- parseDataFromText(text) {
79
- const isValidHTML = (text === null || text === void 0 ? void 0 : text.length) && text.includes('<div style=');
80
- if (isValidHTML) {
81
- return this.parseDataFromHTML(text);
96
+ responseTextHasHtml() {
97
+ var _a;
98
+ return !(!((_a = this.text) === null || _a === void 0 ? void 0 : _a.length)) && this.text.startsWith('<div style=');
99
+ }
100
+ createDataFromText() {
101
+ if (this.responseTextHasHtml()) {
102
+ return this.createDataFromHtml();
82
103
  }
83
- return JSON.parse(text);
104
+ return JSON.parse(this.text);
84
105
  }
85
- parseDataFromHTML(html) {
86
- const dom = new jsdom_1.JSDOM(html);
106
+ createDataFromHtml() {
107
+ const dom = new jsdom_1.JSDOM(this.text);
87
108
  return {
88
109
  type: 'error',
89
110
  page: 0,
@@ -4,8 +4,10 @@ export default class Environment {
4
4
  private token;
5
5
  static getInstance(): Environment;
6
6
  private constructor();
7
+ private shouldToLoadDotEnvFile;
8
+ private loadedEnvVars;
9
+ private setDomain;
10
+ private setToken;
7
11
  getDomain(): string;
8
12
  getToken(): string;
9
- setDomain(domain?: string): void;
10
- setToken(token?: string): void;
11
13
  }
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = __importDefault(require("path"));
7
+ const dotenv_1 = __importDefault(require("dotenv"));
8
+ const utils_1 = __importDefault(require("../utils"));
3
9
  class Environment {
4
10
  static getInstance() {
5
11
  if (!Environment.instance) {
@@ -7,12 +13,31 @@ class Environment {
7
13
  }
8
14
  return Environment.instance;
9
15
  }
10
- constructor() { }
11
- getDomain() {
12
- return this.domain;
16
+ constructor() {
17
+ this.shouldToLoadDotEnvFile();
18
+ this.setToken(process.env.IXC_ACCESS_TOKEN);
19
+ this.setDomain(process.env.IXC_SERVER_DOMAIN);
13
20
  }
14
- getToken() {
15
- return this.token;
21
+ shouldToLoadDotEnvFile() {
22
+ if (this.loadedEnvVars()) {
23
+ return;
24
+ }
25
+ const fileUtil = new utils_1.default.File();
26
+ const envfile = fileUtil.findFile('.env');
27
+ const env = dotenv_1.default.config({
28
+ quiet: true,
29
+ path: path_1.default.resolve(envfile)
30
+ });
31
+ if (env.error) {
32
+ console.error(env.error);
33
+ process.exit(1);
34
+ }
35
+ }
36
+ loadedEnvVars() {
37
+ const allEnvVars = Object.keys(process.env);
38
+ return allEnvVars.some(envVar => {
39
+ return envVar.startsWith('IXC_');
40
+ });
16
41
  }
17
42
  setDomain(domain) {
18
43
  var _a;
@@ -30,5 +55,11 @@ class Environment {
30
55
  this.token = token;
31
56
  }
32
57
  }
58
+ getDomain() {
59
+ return this.domain;
60
+ }
61
+ getToken() {
62
+ return this.token;
63
+ }
33
64
  }
34
65
  exports.default = Environment;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Sort = void 0;
7
- const Utils_1 = __importDefault(require("./Utils"));
7
+ const utils_1 = __importDefault(require("../utils"));
8
8
  var Sort;
9
9
  (function (Sort) {
10
10
  Sort["ASC"] = "asc";
@@ -13,13 +13,13 @@ var Sort;
13
13
  ;
14
14
  class Ordering {
15
15
  static ascBy(table, column) {
16
- const normalizedTable = Utils_1.default.Text.normalize(table);
17
- const normalizedColumn = Utils_1.default.Text.normalize(column);
16
+ const normalizedTable = utils_1.default.Text.normalize(table);
17
+ const normalizedColumn = utils_1.default.Text.normalize(column);
18
18
  return new Ordering(`${normalizedTable}.${normalizedColumn}`, Sort.ASC);
19
19
  }
20
20
  static descBy(table, column) {
21
- const normalizedTable = Utils_1.default.Text.normalize(table);
22
- const normalizedColumn = Utils_1.default.Text.normalize(column);
21
+ const normalizedTable = utils_1.default.Text.normalize(table);
22
+ const normalizedColumn = utils_1.default.Text.normalize(column);
23
23
  return new Ordering(`${normalizedTable}.${normalizedColumn}`, Sort.DESC);
24
24
  }
25
25
  constructor(sortName, sortOrder) {
@@ -4,16 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Operators_1 = __importDefault(require("./Operators"));
7
- const Utils_1 = __importDefault(require("./Utils"));
7
+ const utils_1 = __importDefault(require("../utils"));
8
8
  class Parameter {
9
9
  constructor(table) {
10
- this.table = Utils_1.default.Text.normalize(table);
10
+ this.table = utils_1.default.Text.normalize(table);
11
11
  this.operator = Operators_1.default.EQUALS;
12
12
  this.type = this.table;
13
13
  this.value = '';
14
14
  }
15
15
  withType(type) {
16
- const normalizedType = Utils_1.default.Text.normalize(type);
16
+ const normalizedType = utils_1.default.Text.normalize(type);
17
17
  this.type = `${this.table}.${normalizedType}`;
18
18
  return this;
19
19
  }
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const Environment_1 = __importDefault(require("./Environment"));
27
27
  const IxcResponse_1 = __importDefault(require("../IxcResponse"));
28
- const Utils_1 = __importDefault(require("./Utils"));
28
+ const utils_1 = __importDefault(require("../utils"));
29
29
  class RequestEmitter {
30
30
  /**
31
31
  * Método construtor da classe.
@@ -33,7 +33,7 @@ class RequestEmitter {
33
33
  * @param table Representa o endpoint do IXC Provedor para o qual será enviada a requisição.
34
34
  */
35
35
  constructor(table) {
36
- this.table = Utils_1.default.Text.normalize(table);
36
+ this.table = utils_1.default.Text.normalize(table);
37
37
  this.headers = [];
38
38
  this.query = '';
39
39
  this.uri = '';
@@ -174,7 +174,7 @@ class RequestEmitter {
174
174
  return yield response.text();
175
175
  }
176
176
  catch (error) {
177
- return IxcResponse_1.default.createPropsWithError(error);
177
+ return IxcResponse_1.default.createResponseTextWithError(error);
178
178
  }
179
179
  });
180
180
  }
package/dist/index.d.ts CHANGED
@@ -5,8 +5,9 @@ import IxcOrm from './IxcOrm';
5
5
  import IxcResponse from './IxcResponse';
6
6
  import Operators from './api/Operators';
7
7
  import Ordering from './api/Ordering';
8
+ import Utils from './utils';
8
9
  import { IXCOperator, IXCOptions, IXCQuery, IXCRequest, IXCRequestMethods, IXCResponse, IXCSortOrder } from './types';
9
- export { IXCClient, IXCOperator, IXCOptions, IXCQuery, IXCRequest, IXCRequestMethods, IXCResponse, IXCSortOrder, Recurso, Environment, IxcOrm, IxcResponse, Operators, Ordering,
10
+ export { IXCClient, IXCOperator, IXCOptions, IXCQuery, IXCRequest, IXCRequestMethods, IXCResponse, IXCSortOrder, Recurso, Environment, IxcOrm, IxcResponse, Operators, Ordering, Utils,
10
11
  /**
11
12
  * @property RecursoIXC
12
13
  * @deprecated Acesse os recursos através da constante {@link Recurso}
package/dist/index.js CHANGED
@@ -36,9 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.RecursoIXC = exports.Ordering = exports.Operators = exports.IxcResponse = exports.IxcOrm = exports.Environment = exports.Recurso = exports.IXCSortOrder = exports.IXCRequestMethods = exports.IXCOperator = exports.IXCClient = void 0;
40
- const path_1 = __importDefault(require("path"));
41
- const dotenv_1 = __importDefault(require("dotenv"));
39
+ exports.RecursoIXC = exports.Utils = exports.Ordering = exports.Operators = exports.IxcResponse = exports.IxcOrm = exports.Environment = exports.Recurso = exports.IXCSortOrder = exports.IXCRequestMethods = exports.IXCOperator = exports.IXCClient = void 0;
42
40
  const IXCClient_1 = __importDefault(require("./IXCClient"));
43
41
  exports.IXCClient = IXCClient_1.default;
44
42
  const recursos_1 = __importStar(require("./recursos"));
@@ -54,20 +52,10 @@ const Operators_1 = __importDefault(require("./api/Operators"));
54
52
  exports.Operators = Operators_1.default;
55
53
  const Ordering_1 = __importDefault(require("./api/Ordering"));
56
54
  exports.Ordering = Ordering_1.default;
55
+ const utils_1 = __importDefault(require("./utils"));
56
+ exports.Utils = utils_1.default;
57
57
  const types_1 = require("./types");
58
58
  Object.defineProperty(exports, "IXCOperator", { enumerable: true, get: function () { return types_1.IXCOperator; } });
59
59
  Object.defineProperty(exports, "IXCRequestMethods", { enumerable: true, get: function () { return types_1.IXCRequestMethods; } });
60
60
  Object.defineProperty(exports, "IXCSortOrder", { enumerable: true, get: function () { return types_1.IXCSortOrder; } });
61
- const root = (__dirname.includes('\\node_modules\\'))
62
- ? path_1.default.join(__dirname, '../../../.env')
63
- : path_1.default.join(__dirname, '../.env');
64
- const env = dotenv_1.default.config({
65
- quiet: true,
66
- path: path_1.default.resolve(root)
67
- });
68
- if (env.error) {
69
- console.error(env.error);
70
- process.exit(1);
71
- }
72
- Environment_1.default.getInstance().setToken(process.env.IXC_ACCESS_TOKEN);
73
- Environment_1.default.getInstance().setDomain(process.env.IXC_SERVER_DOMAIN);
61
+ Environment_1.default.getInstance();
@@ -0,0 +1,6 @@
1
+ export declare class FileUtils {
2
+ private static LOOP_LIMIT;
3
+ private currentLoop;
4
+ findFile(fileName: string, currentDir?: string): any;
5
+ reachedLoopLimit(): boolean;
6
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FileUtils = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ class FileUtils {
10
+ findFile(fileName, currentDir = process.cwd()) {
11
+ const filePath = path_1.default.join(currentDir, fileName);
12
+ if (fs_1.default.existsSync(filePath)) {
13
+ return filePath;
14
+ }
15
+ const parentDir = path_1.default.dirname(currentDir);
16
+ if ((parentDir === currentDir) || this.reachedLoopLimit()) {
17
+ throw new Error(`O arquivo '${fileName}' não foi encontrado`);
18
+ }
19
+ this.currentLoop++;
20
+ return this.findFile(fileName, parentDir);
21
+ }
22
+ reachedLoopLimit() {
23
+ return this.currentLoop >= FileUtils.LOOP_LIMIT;
24
+ }
25
+ }
26
+ exports.FileUtils = FileUtils;
27
+ FileUtils.LOOP_LIMIT = 4;
@@ -0,0 +1,3 @@
1
+ export declare class TextUtils {
2
+ static normalize(text: string): string;
3
+ }
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextUtils = void 0;
3
4
  class TextUtils {
4
5
  static normalize(text) {
5
6
  return text.replace(/[^a-z0-9_]/gi, '').trim();
6
7
  }
7
8
  }
8
- const Utils = {
9
- Text: TextUtils
10
- };
11
- exports.default = Utils;
9
+ exports.TextUtils = TextUtils;
@@ -0,0 +1,7 @@
1
+ import { FileUtils } from './FileUtils';
2
+ import { TextUtils } from './TextUtils';
3
+ declare const Utils: {
4
+ File: typeof FileUtils;
5
+ Text: typeof TextUtils;
6
+ };
7
+ export default Utils;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const FileUtils_1 = require("./FileUtils");
4
+ const TextUtils_1 = require("./TextUtils");
5
+ const Utils = {
6
+ File: FileUtils_1.FileUtils,
7
+ Text: TextUtils_1.TextUtils,
8
+ };
9
+ exports.default = Utils;
package/jest.config.ts CHANGED
@@ -7,13 +7,14 @@ const config: Config = {
7
7
  collectCoverage: true,
8
8
  coverageDirectory: 'coverage',
9
9
  coverageProvider: 'v8',
10
+ testEnvironment: "node",
10
11
 
11
12
  transform: {
12
13
  '^.+\\.(ts|tsx)$': 'ts-jest'
13
14
  },
14
15
 
15
- coverageReporters: [
16
- 'json'
16
+ collectCoverageFrom: [
17
+ "**/src/**/*.(t|j)s"
17
18
  ],
18
19
 
19
20
  setupFiles: [
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "ixc-orm",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",
7
- "description": "ORM para consumo de dados da API oficial do IXCsoft",
7
+ "description": "ORM para consumo de dados da API do sistema IXC Provedor",
8
8
  "scripts": {
9
- "declare": "tsc --declaration",
10
- "build": "tsc --build",
11
9
  "dev": "nodemon --watch \"src//\" --exec \"ts-node src/index.ts\" -e ts",
12
- "test": "jest"
10
+ "test": "jest --coverage",
11
+ "build": "tsc --build"
13
12
  },
14
13
  "repository": {
15
14
  "type": "git",
@@ -22,27 +21,28 @@
22
21
  "IXC Provedor"
23
22
  ],
24
23
  "author": {
25
- "name": "Felipe Sousa",
24
+ "name": "Felipe S. Carmo",
26
25
  "email": "fscarmo@proton.me",
27
- "url": "https://github.com/SousaFelipe"
26
+ "url": "https://www.fscarmo.dev.br/"
28
27
  },
29
28
  "bugs": {
30
29
  "url": "https://github.com/SousaFelipe/ixc-orm/issues"
31
30
  },
32
31
  "dependencies": {
33
32
  "axios": "^1.12.2",
34
- "dotenv": "^17.2.2",
35
- "jsdom": "^27.0.0"
33
+ "dotenv": "^17.2.3",
34
+ "jsdom": "^27.0.1"
36
35
  },
37
36
  "devDependencies": {
37
+ "@babel/preset-typescript": "^7.27.1",
38
38
  "@jest/globals": "^30.2.0",
39
39
  "@types/jest": "^30.0.0",
40
40
  "@types/jsdom": "^27.0.0",
41
- "@types/node": "^24.5.2",
41
+ "@types/node": "^24.8.1",
42
42
  "jest": "^30.2.0",
43
43
  "nodemon": "^3.1.10",
44
44
  "ts-jest": "^29.4.5",
45
45
  "ts-node": "^10.9.2",
46
- "typescript": "^5.9.2"
46
+ "typescript": "^5.9.3"
47
47
  }
48
48
  }
@@ -1 +1 @@
1
- {"root":["./src/ixcclient.ts","./src/ixcorm.ts","./src/ixcresponse.ts","./src/index.ts","./src/request.ts","./src/response.ts","./src/types.ts","./src/api/environment.ts","./src/api/operators.ts","./src/api/ordering.ts","./src/api/pagination.ts","./src/api/parameter.ts","./src/api/requestemitter.ts","./src/api/utils.ts","./src/recursos/cliente_contrato_btn_lib_temp_24722.ts","./src/recursos/desbloqueio_confianca.ts","./src/recursos/get_boleto.ts","./src/recursos/index.ts","./src/recursos/recurso.ts"],"version":"5.9.2"}
1
+ {"root":["./src/ixcclient.ts","./src/ixcorm.ts","./src/ixcresponse.ts","./src/index.ts","./src/request.ts","./src/response.ts","./src/types.ts","./src/api/environment.ts","./src/api/operators.ts","./src/api/ordering.ts","./src/api/pagination.ts","./src/api/parameter.ts","./src/api/requestemitter.ts","./src/recursos/cliente_contrato_btn_lib_temp_24722.ts","./src/recursos/desbloqueio_confianca.ts","./src/recursos/get_boleto.ts","./src/recursos/index.ts","./src/recursos/recurso.ts","./src/utils/fileutils.ts","./src/utils/textutils.ts","./src/utils/index.ts"],"version":"5.9.3"}
@@ -1,7 +0,0 @@
1
- declare class TextUtils {
2
- static normalize(text: string): string;
3
- }
4
- declare const Utils: {
5
- Text: typeof TextUtils;
6
- };
7
- export default Utils;