ixc-orm 1.3.0 → 1.4.3

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,9 +1,19 @@
1
- # IXC-ORM
1
+ # IXC-ORM [![npm](https://img.shields.io/npm/dt/ixc-orm.svg)](https://www.npmjs.com/package/ixc-orm)
2
2
 
3
- Este ORM simples, visa facilitar o consumo de dados da API oficial do IXCsoft.\
3
+ Este ORM simples visa facilitar o consumo de dados da API oficial do IXCsoft.\
4
4
  Esta biblioteca não faz parte das bibliotecas oficiais da IXCsoft e foi desenvolvida de forma independente e sem fins lucrativos.
5
5
 
6
6
 
7
+ ## 🚀 Novidades
8
+
9
+ ### v1.4.1 - 14 de agosto de 2025
10
+
11
+ * **Corrigido:** Resolvido o bug de leitura das variáveis de ambiente no arquivo .env na pasta raiz.
12
+ * **Novo:** Foram adicionados 3 dos 44 recursos da API do IXC: `get_boleto`, `liberacao_temporaria` e `desbloqueio_confianca`. (Futuramente novos recursos serão adicionados)
13
+
14
+ > Consulte todos os recursos disponíveis: [Doc. API IXCSoft](https://wikiapiprovedor.ixcsoft.com.br/)
15
+
16
+
7
17
  ## Instalação
8
18
  ```bash
9
19
  npm install ixc-orm
@@ -0,0 +1,58 @@
1
+ import { IXCOptions, IXCQuery, IXCResponse, IXCSortOrder } from './types';
2
+ export default abstract class IXCClient {
3
+ protected table: string;
4
+ protected params: IXCQuery[];
5
+ protected options: IXCOptions;
6
+ /**
7
+ * @param table O nome da tabela correspondente ao banco de dados do seu servidor IXC
8
+ * @see {@link https://wikiapiprovedor.ixcsoft.com.br/index.php}
9
+ */
10
+ constructor(table: string);
11
+ /**
12
+ * Incrementa o array de parâmetros que serão trasformados no corpo de uma requisição
13
+ * e passados como filtro grid da API do IXC
14
+ *
15
+ * @param whereClauses Um array de strings, no formato [coluna, operador, valor]\
16
+ * `Obs`: se você passar um array no formato [coluna, valor] o operador será considerado como '='\
17
+ * Os operadores válidos são: =, !=, >, <, >=, <=, LIKE
18
+ * @returns A própria instância
19
+ */
20
+ where(whereClauses: string[]): IXCClient;
21
+ /**
22
+ * Define como a API do IXC ordenará os dados retornados
23
+ *
24
+ * @param column A coluna que será usada para ordenar a busca
25
+ * @param order A ordem da busca ('asc'ou 'desc')
26
+ * @returns A própria instância
27
+ */
28
+ orderBy(column: string, order: keyof typeof IXCSortOrder): IXCClient;
29
+ /**
30
+ * Envia uma solicitação GET para a API do IXC, com o header `ixcsoft` definico como `listar`
31
+ * Preenche o corpo da requisição com os dados passados pela função `where` no formado JSON
32
+ *
33
+ * @param pg O número da página que será solicitada ao IXC `padão = 1`
34
+ * @param rows A quantidade de linhas (registros) por página `padrão = 20`
35
+ * @returns Promise<IXCResponse>
36
+ */
37
+ get(pg?: number, rows?: number): Promise<IXCResponse>;
38
+ /**
39
+ * Envia uma requisição do tipo `POST` para a API do IXC, com o header `ixcsoft` vazio
40
+ *
41
+ * @param body Um objeto no formado "chave: valor" contendo as informações do novo registro
42
+ * a ser inserido no banco de dados do seu servidor IXC
43
+ * @returns Promise<IXCResponse>
44
+ */
45
+ post(body?: {
46
+ [key: string]: any;
47
+ }): Promise<IXCResponse>;
48
+ /**
49
+ * Envia uma requisição do tipo `PUT` para a API do IXC, com o header `ixcsoft` vazio
50
+ *
51
+ * @param id O id do registro que será alterado
52
+ * @param body Um objeto no formado "chave : valor" contendo as colunas que serão alteradas
53
+ * @returns Promise<IXCResponse>
54
+ */
55
+ put(id: number, body?: {
56
+ [key: string]: any;
57
+ }): Promise<IXCResponse>;
58
+ }
package/dist/IXCClient.js CHANGED
@@ -20,12 +20,11 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  return t;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- const axios_1 = require("axios");
24
23
  const request_1 = require("./request");
25
24
  const types_1 = require("./types");
25
+ const response_1 = require("./response");
26
26
  class IXCClient {
27
27
  /**
28
- *
29
28
  * @param table O nome da tabela correspondente ao banco de dados do seu servidor IXC
30
29
  * @see {@link https://wikiapiprovedor.ixcsoft.com.br/index.php}
31
30
  */
@@ -40,10 +39,12 @@ class IXCClient {
40
39
  };
41
40
  }
42
41
  /**
42
+ * Incrementa o array de parâmetros que serão trasformados no corpo de uma requisição
43
+ * e passados como filtro grid da API do IXC
43
44
  *
44
- * @param whereClauses Um array de strings, no formato [coluna, operador, valor]
45
- * Obs: se você passar um array no formato [coluna, valor] o operador será considerado como '='
46
- * Operadores válidos: =, !=, >, <, >=, <=, LIKE
45
+ * @param whereClauses Um array de strings, no formato [coluna, operador, valor]\
46
+ * `Obs`: se você passar um array no formato [coluna, valor] o operador será considerado como '='\
47
+ * Os operadores válidos são: =, !=, >, <, >=, <=, LIKE
47
48
  * @returns A própria instância
48
49
  */
49
50
  where(whereClauses) {
@@ -63,6 +64,7 @@ class IXCClient {
63
64
  return this;
64
65
  }
65
66
  /**
67
+ * Define como a API do IXC ordenará os dados retornados
66
68
  *
67
69
  * @param column A coluna que será usada para ordenar a busca
68
70
  * @param order A ordem da busca ('asc'ou 'desc')
@@ -74,27 +76,36 @@ class IXCClient {
74
76
  return this;
75
77
  }
76
78
  /**
79
+ * Envia uma solicitação GET para a API do IXC, com o header `ixcsoft` definico como `listar`
80
+ * Preenche o corpo da requisição com os dados passados pela função `where` no formado JSON
77
81
  *
78
- * @param pg O número da página que será solicitada ao IXC
79
- * @param rows A quantidade de linhas (registros) por página
80
- * @returns Promise<null | IXCResponse | AxiosError>
82
+ * @param pg O número da página que será solicitada ao IXC `padão = 1`
83
+ * @param rows A quantidade de linhas (registros) por página `padrão = 20`
84
+ * @returns Promise<IXCResponse>
81
85
  */
82
86
  get(pg, rows) {
83
87
  return __awaiter(this, void 0, void 0, function* () {
84
- const _a = this.options, { page, rowsPerPage } = _a, rest = __rest(_a, ["page", "rowsPerPage"]);
88
+ var _a, _b;
89
+ const _c = this.options, { page, rowsPerPage } = _c, rest = __rest(_c, ["page", "rowsPerPage"]);
85
90
  const opts = Object.assign({ page: pg !== null && pg !== void 0 ? pg : page, rowsPerPage: rows !== null && rows !== void 0 ? rows : rowsPerPage }, rest);
86
91
  const axios = (0, request_1.createAxiosInstance)('GET');
87
92
  const payload = (0, request_1.createRequestPayload)(this.table, this.params, opts);
88
93
  try {
89
94
  const response = yield axios.get(this.table, payload);
90
- return response.data;
95
+ if (response.status === 200) {
96
+ return response.data;
97
+ }
98
+ return (0, response_1.createResponse)({
99
+ error: true,
100
+ message: (_a = response.data) === null || _a === void 0 ? void 0 : _a.message
101
+ });
91
102
  }
92
103
  catch (error) {
93
104
  console.error(error);
94
- if (error instanceof axios_1.AxiosError) {
95
- return error;
96
- }
97
- return null;
105
+ return (0, response_1.createResponse)({
106
+ error: true,
107
+ message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message || 'Erro desconhecido'
108
+ });
98
109
  }
99
110
  finally {
100
111
  this.params = [];
@@ -108,24 +119,32 @@ class IXCClient {
108
119
  });
109
120
  }
110
121
  /**
122
+ * Envia uma requisição do tipo `POST` para a API do IXC, com o header `ixcsoft` vazio
111
123
  *
112
124
  * @param body Um objeto no formado "chave: valor" contendo as informações do novo registro
113
125
  * a ser inserido no banco de dados do seu servidor IXC
114
- * @returns Promise<null | IXCResponse | AxiosError>
126
+ * @returns Promise<IXCResponse>
115
127
  */
116
128
  post(body) {
117
129
  return __awaiter(this, void 0, void 0, function* () {
130
+ var _a, _b;
118
131
  const axios = (0, request_1.createAxiosInstance)('POST');
119
132
  try {
120
133
  const response = yield axios.post(this.table, { data: body });
121
- return response.data;
134
+ if (response.status === 200) {
135
+ return response.data;
136
+ }
137
+ return (0, response_1.createResponse)({
138
+ error: true,
139
+ message: (_a = response.data) === null || _a === void 0 ? void 0 : _a.message
140
+ });
122
141
  }
123
142
  catch (error) {
124
143
  console.error(error);
125
- if (error instanceof axios_1.AxiosError) {
126
- return error;
127
- }
128
- return null;
144
+ return (0, response_1.createResponse)({
145
+ error: true,
146
+ message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message || 'Erro desconhecido'
147
+ });
129
148
  }
130
149
  finally {
131
150
  this.params = [];
@@ -133,24 +152,32 @@ class IXCClient {
133
152
  });
134
153
  }
135
154
  /**
155
+ * Envia uma requisição do tipo `PUT` para a API do IXC, com o header `ixcsoft` vazio
136
156
  *
137
157
  * @param id O id do registro que será alterado
138
158
  * @param body Um objeto no formado "chave : valor" contendo as colunas que serão alteradas
139
- * @returns Promise<null | IXCResponse | AxiosError>
159
+ * @returns Promise<IXCResponse>
140
160
  */
141
161
  put(id, body) {
142
162
  return __awaiter(this, void 0, void 0, function* () {
163
+ var _a, _b;
143
164
  const axios = (0, request_1.createAxiosInstance)('PUT');
144
165
  try {
145
166
  const response = yield axios.put(`${this.table}/${id}`, { data: body });
146
- return response.data;
167
+ if (response.status === 200) {
168
+ return response.data;
169
+ }
170
+ return (0, response_1.createResponse)({
171
+ error: true,
172
+ message: (_a = response.data) === null || _a === void 0 ? void 0 : _a.message
173
+ });
147
174
  }
148
175
  catch (error) {
149
176
  console.error(error);
150
- if (error instanceof axios_1.AxiosError) {
151
- return error;
152
- }
153
- return null;
177
+ return (0, response_1.createResponse)({
178
+ error: true,
179
+ message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message || 'Erro desconhecido'
180
+ });
154
181
  }
155
182
  finally {
156
183
  this.params = [];
@@ -0,0 +1,4 @@
1
+ import IXCClient from './IXCClient';
2
+ import recursos from './recursos';
3
+ import { IXCOperator, IXCOptions, IXCQuery, IXCRequest, IXCRequestMethods, IXCResponse, IXCSortOrder } from './types';
4
+ export { IXCClient, IXCOperator, IXCOptions, IXCQuery, IXCRequest, IXCRequestMethods, IXCResponse, IXCSortOrder, recursos };
package/dist/index.js CHANGED
@@ -3,18 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IXCSortOrder = exports.IXCRequestMethods = exports.IXCOperator = exports.IXCClient = void 0;
6
+ exports.recursos = exports.IXCSortOrder = exports.IXCRequestMethods = exports.IXCOperator = exports.IXCClient = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const dotenv_1 = __importDefault(require("dotenv"));
9
9
  const IXCClient_1 = __importDefault(require("./IXCClient"));
10
10
  exports.IXCClient = IXCClient_1.default;
11
+ const recursos_1 = __importDefault(require("./recursos"));
12
+ exports.recursos = recursos_1.default;
11
13
  const types_1 = require("./types");
12
14
  Object.defineProperty(exports, "IXCOperator", { enumerable: true, get: function () { return types_1.IXCOperator; } });
13
15
  Object.defineProperty(exports, "IXCRequestMethods", { enumerable: true, get: function () { return types_1.IXCRequestMethods; } });
14
16
  Object.defineProperty(exports, "IXCSortOrder", { enumerable: true, get: function () { return types_1.IXCSortOrder; } });
15
- const env = dotenv_1.default.config({
16
- path: path_1.default.join(__dirname, `../.env`)
17
- });
17
+ const root = (__dirname.includes('\\node_modules\\'))
18
+ ? path_1.default.join(__dirname, `../../../.env`)
19
+ : path_1.default.join(__dirname, `../../.env`);
20
+ const env = dotenv_1.default.config({ path: root });
18
21
  if (env.error) {
19
22
  console.error(env.error);
20
23
  process.exit(-1);
@@ -0,0 +1,6 @@
1
+ import { IXCResponse } from '../types';
2
+ declare function execute(id_contrato: string | number): Promise<IXCResponse>;
3
+ declare const _default: {
4
+ readonly execute: typeof execute;
5
+ };
6
+ export default _default;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const recurso_1 = __importDefault(require("./recurso"));
16
+ const src = 'cliente_contrato_btn_lib_temp_24722';
17
+ function execute(id_contrato) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return yield (0, recurso_1.default)({
20
+ src,
21
+ data: { id_contrato }
22
+ });
23
+ });
24
+ }
25
+ exports.default = { execute };
@@ -0,0 +1,6 @@
1
+ import { IXCResponse } from '../types';
2
+ declare function execute(id_contrato: string | number): Promise<IXCResponse>;
3
+ declare const _default: {
4
+ readonly execute: typeof execute;
5
+ };
6
+ export default _default;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const recurso_1 = __importDefault(require("./recurso"));
16
+ const src = 'desbloqueio_confianca';
17
+ function execute(id_contrato) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return yield (0, recurso_1.default)({
20
+ src,
21
+ data: { id_contrato }
22
+ });
23
+ });
24
+ }
25
+ exports.default = { execute };
@@ -0,0 +1,6 @@
1
+ import { IXCRecursoResponse, IXCResponse } from '../types';
2
+ declare function execute(id_fatura: string | number): Promise<IXCResponse | IXCRecursoResponse>;
3
+ declare const _default: {
4
+ readonly execute: typeof execute;
5
+ };
6
+ export default _default;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const request_1 = require("../request");
13
+ const response_1 = require("../response");
14
+ const SRC = 'get_boleto';
15
+ function execute(id_fatura) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const axios = (0, request_1.createAxiosInstance)('PUT');
18
+ try {
19
+ const response = yield axios.get(SRC, {
20
+ data: {
21
+ boletos: id_fatura,
22
+ juro: 'S',
23
+ multa: 'S',
24
+ atualiza_boleto: 'S',
25
+ tipo_boleto: 'arquivo',
26
+ base64: 'S'
27
+ }
28
+ });
29
+ if (response.status === 200) {
30
+ return {
31
+ data: response.data
32
+ };
33
+ }
34
+ }
35
+ catch (error) {
36
+ console.error(`Erro ao executar recurso: ${SRC}\n`, error);
37
+ }
38
+ return (0, response_1.createResponse)({ error: true });
39
+ });
40
+ }
41
+ exports.default = { execute };
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ readonly desbloqueio_confianca: {
3
+ readonly execute: (id_contrato: string | number) => Promise<import("..").IXCResponse>;
4
+ };
5
+ readonly get_boleto: {
6
+ readonly execute: (id_fatura: string | number) => Promise<import("..").IXCResponse | import("../types").IXCRecursoResponse>;
7
+ };
8
+ readonly liberacao_temporaria: {
9
+ readonly execute: (id_contrato: string | number) => Promise<import("..").IXCResponse>;
10
+ };
11
+ };
12
+ export default _default;
@@ -0,0 +1,13 @@
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
+ const cliente_contrato_btn_lib_temp_24722_1 = __importDefault(require("./cliente_contrato_btn_lib_temp_24722"));
7
+ const desbloqueio_confianca_1 = __importDefault(require("./desbloqueio_confianca"));
8
+ const get_boleto_1 = __importDefault(require("./get_boleto"));
9
+ exports.default = {
10
+ desbloqueio_confianca: desbloqueio_confianca_1.default,
11
+ get_boleto: get_boleto_1.default,
12
+ liberacao_temporaria: cliente_contrato_btn_lib_temp_24722_1.default,
13
+ };
@@ -0,0 +1,7 @@
1
+ import { IXCResponse } from '../types';
2
+ export default function recurso({ src, data }: {
3
+ src: string;
4
+ data: {
5
+ [key: string]: any;
6
+ };
7
+ }): Promise<IXCResponse>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = recurso;
13
+ const request_1 = require("../request");
14
+ const response_1 = require("../response");
15
+ function recurso(_a) {
16
+ return __awaiter(this, arguments, void 0, function* ({ src, data }) {
17
+ const axios = (0, request_1.createAxiosInstance)('PUT');
18
+ try {
19
+ const response = yield axios.get(src, { data });
20
+ if (response.status === 200) {
21
+ const { data } = response;
22
+ if ((data === null || data === void 0 ? void 0 : data.type) === 'success' || (data === null || data === void 0 ? void 0 : data.tipo) === 'sucesso') {
23
+ return (0, response_1.createResponse)({
24
+ message: data.message || data.mensagem,
25
+ });
26
+ }
27
+ return (0, response_1.createResponse)({
28
+ error: true,
29
+ message: data.message || data.mensagem
30
+ });
31
+ }
32
+ }
33
+ catch (error) {
34
+ console.error(`Erro ao executar recurso: ${src}\n`, error);
35
+ }
36
+ return (0, response_1.createResponse)({ error: true });
37
+ });
38
+ }
@@ -0,0 +1,26 @@
1
+ export interface Boleto {
2
+ /**
3
+ * @property id da fatura
4
+ */
5
+ boletos: string | number;
6
+ /**
7
+ * @property // 'S'->SIM e 'N'->NÃO para cálculo de júro
8
+ */
9
+ juro: 'S' | 'N';
10
+ /**
11
+ * @property // 'S'->SIM e 'N'->NÃO para cálculo de multa
12
+ */
13
+ multa: 'S' | 'N';
14
+ /**
15
+ * @property // 'S'->SIM e 'N'->NÃO para atualizar o boleto
16
+ */
17
+ atualiza_boleto: 'S' | 'N';
18
+ /**
19
+ * @property // tipo de método que será executado
20
+ */
21
+ tipo_boleto: 'arquivo';
22
+ /**
23
+ * @property // 'S'->SIM e 'N'->NÃO para retornar o boleto em base64
24
+ */
25
+ base64: 'S' | 'N';
26
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import { AxiosInstance, AxiosRequestConfig } from 'axios';
2
+ import { IXCOptions, IXCQuery, IXCRequest, IXCRequestMethods } from './types';
3
+ /**
4
+ *
5
+ * @param method GET | POST | PUT | DELETE
6
+ * @returns A instância de um objeto do tipo AxiosInstance, pré-configurado com os cabeçalhos necessários
7
+ */
8
+ export declare function createAxiosInstance(method?: keyof typeof IXCRequestMethods): AxiosInstance;
9
+ /**
10
+ *
11
+ * @param table Nome da tabela do IXC onde será feita a busca, atualização, inserção ou remoção
12
+ * @param params Parâmetros da busca (desconsiderados quando a ação for a de inserir novos registros)
13
+ * @param options Parâmetros de formatação dos dados da responsta (página, ítens por página e ordenação)
14
+ * @returns
15
+ */
16
+ export declare function createRequestPayload(table: string, params: IXCQuery | IXCQuery[], options?: IXCOptions): AxiosRequestConfig<IXCRequest>;
@@ -0,0 +1,4 @@
1
+ import { IXCResponse } from './types';
2
+ export declare function createResponse(data: {
3
+ [key: string]: any;
4
+ }): IXCResponse;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createResponse = createResponse;
4
+ function createResponse(data) {
5
+ var _a, _b, _c, _d;
6
+ return {
7
+ error: data.error || false,
8
+ message: data.message || '',
9
+ id: (_a = data.id) !== null && _a !== void 0 ? _a : 0,
10
+ page: (_b = data.page) !== null && _b !== void 0 ? _b : 0,
11
+ total: (_c = data.total) !== null && _c !== void 0 ? _c : 0,
12
+ registros: (_d = data.registros) !== null && _d !== void 0 ? _d : []
13
+ };
14
+ }
@@ -1 +1 @@
1
- {"root":["../src/ixcclient.ts","../src/index.ts","../src/request.ts","../src/types.ts"],"version":"5.6.2"}
1
+ {"root":["../src/ixcclient.ts","../src/index.ts","../src/request.ts","../src/response.ts","../src/types.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/recursos/types.ts"],"version":"5.6.2"}
@@ -0,0 +1,54 @@
1
+ export declare const IXCOperator: {
2
+ '=': string;
3
+ '>': string;
4
+ '<': string;
5
+ '>=': string;
6
+ '<=': string;
7
+ '!=': string;
8
+ LIKE: string;
9
+ };
10
+ export declare const IXCSortOrder: {
11
+ asc: string;
12
+ desc: string;
13
+ };
14
+ export declare const IXCRequestMethods: {
15
+ GET: string;
16
+ POST: string;
17
+ PUT: string;
18
+ DELETE: string;
19
+ };
20
+ export interface IXCOptions {
21
+ page: number;
22
+ rowsPerPage?: number;
23
+ sortName?: string;
24
+ sortOrder?: keyof typeof IXCSortOrder;
25
+ }
26
+ export interface IXCQuery {
27
+ TB: string;
28
+ OP?: string;
29
+ P: string;
30
+ }
31
+ export interface IXCRequest {
32
+ qtype: string;
33
+ query: string;
34
+ oper: string;
35
+ page: number;
36
+ rp: number;
37
+ sortname: string;
38
+ sortorder: string;
39
+ grid_param?: string;
40
+ }
41
+ export interface IXCResponse {
42
+ error?: boolean | object;
43
+ message?: string | null;
44
+ id?: string | number;
45
+ page: number | string;
46
+ total: number;
47
+ registros: Array<{
48
+ [key: string]: any;
49
+ }>;
50
+ }
51
+ export interface IXCRecursoResponse {
52
+ error?: boolean | object;
53
+ data: any;
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ixc-orm",
3
- "version": "1.3.0",
3
+ "version": "1.4.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",
package/tsconfig.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "module": "commonjs",
5
5
  "outDir": "./dist",
6
6
  "strict": true,
7
+ "declaration": true,
7
8
  "noUnusedLocals": true,
8
9
  "noUnusedParameters": true,
9
10
  "noImplicitReturns": true,