ixc-orm 1.10.2 → 1.10.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/package.json +1 -1
- package/dist/IXCClient.d.ts +0 -67
- package/dist/IXCClient.js +0 -238
- package/dist/IxcOrm.d.ts +0 -81
- package/dist/IxcOrm.js +0 -186
- package/dist/IxcResponse.d.ts +0 -62
- package/dist/IxcResponse.js +0 -132
- package/dist/api/Environment.d.ts +0 -14
- package/dist/api/Environment.js +0 -66
- package/dist/api/Operators.d.ts +0 -9
- package/dist/api/Operators.js +0 -13
- package/dist/api/Ordering.d.ts +0 -13
- package/dist/api/Ordering.js +0 -40
- package/dist/api/Pagination.d.ts +0 -8
- package/dist/api/Pagination.js +0 -22
- package/dist/api/Parameter.d.ts +0 -18
- package/dist/api/Parameter.js +0 -41
- package/dist/api/RequestEmitter.d.ts +0 -90
- package/dist/api/RequestEmitter.js +0 -211
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -61
- package/dist/recursos/cliente_contrato_ativar_cliente.d.ts +0 -4
- package/dist/recursos/cliente_contrato_ativar_cliente.js +0 -28
- package/dist/recursos/cliente_contrato_btn_lib_temp_24722.d.ts +0 -4
- package/dist/recursos/cliente_contrato_btn_lib_temp_24722.js +0 -28
- package/dist/recursos/desbloqueio_confianca.d.ts +0 -4
- package/dist/recursos/desbloqueio_confianca.js +0 -28
- package/dist/recursos/get_boleto.d.ts +0 -3
- package/dist/recursos/get_boleto.js +0 -46
- package/dist/recursos/index.d.ts +0 -64
- package/dist/recursos/index.js +0 -84
- package/dist/recursos/radusuarios_25452.d.ts +0 -4
- package/dist/recursos/radusuarios_25452.js +0 -25
- package/dist/recursos/recurso.d.ts +0 -7
- package/dist/recursos/recurso.js +0 -48
- package/dist/request.d.ts +0 -20
- package/dist/request.js +0 -73
- package/dist/response.d.ts +0 -4
- package/dist/response.js +0 -14
- package/dist/types.d.ts +0 -56
- package/dist/types.js +0 -27
- package/dist/utils/FileUtils.d.ts +0 -6
- package/dist/utils/FileUtils.js +0 -27
- package/dist/utils/TextUtils.d.ts +0 -3
- package/dist/utils/TextUtils.js +0 -9
- package/dist/utils/index.d.ts +0 -7
- package/dist/utils/index.js +0 -9
package/package.json
CHANGED
package/dist/IXCClient.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
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 requisição GET para a API do IXC, com o header `ixcsoft` definico como `listar`\
|
|
31
|
-
* A `query` dessa requisição não será enviada para o IXC com o parâmetro `grid_param`\
|
|
32
|
-
* Ou seja, esta requisição executa uma busca simples, em vez do filtro de grid
|
|
33
|
-
*
|
|
34
|
-
* @param id O identificador numérico do registro que será buscado no IXC
|
|
35
|
-
* @returns Promise<IXCResponse>
|
|
36
|
-
*/
|
|
37
|
-
find(id: any): Promise<IXCResponse>;
|
|
38
|
-
/**
|
|
39
|
-
* Envia uma requisição GET para a API do IXC, com o header `ixcsoft` definico como `listar`
|
|
40
|
-
* Preenche o corpo da requisição com os dados passados pela função `where` no formado JSON
|
|
41
|
-
*
|
|
42
|
-
* @param pg O número da página que será solicitada ao IXC `padão = 1`
|
|
43
|
-
* @param rows A quantidade de linhas (registros) por página `padrão = 20`
|
|
44
|
-
* @returns Promise<IXCResponse>
|
|
45
|
-
*/
|
|
46
|
-
get(pg?: number, rows?: number): Promise<IXCResponse>;
|
|
47
|
-
/**
|
|
48
|
-
* Envia uma requisição do tipo `POST` para a API do IXC, com o header `ixcsoft` vazio
|
|
49
|
-
*
|
|
50
|
-
* @param body Um objeto no formado "chave: valor" contendo as informações do novo registro
|
|
51
|
-
* a ser inserido no banco de dados do seu servidor IXC
|
|
52
|
-
* @returns Promise<IXCResponse>
|
|
53
|
-
*/
|
|
54
|
-
post(body?: {
|
|
55
|
-
[key: string]: any;
|
|
56
|
-
}): Promise<IXCResponse>;
|
|
57
|
-
/**
|
|
58
|
-
* Envia uma requisição do tipo `PUT` para a API do IXC, com o header `ixcsoft` vazio
|
|
59
|
-
*
|
|
60
|
-
* @param id O id do registro que será alterado
|
|
61
|
-
* @param body Um objeto no formado "chave : valor" contendo as colunas que serão alteradas
|
|
62
|
-
* @returns Promise<IXCResponse>
|
|
63
|
-
*/
|
|
64
|
-
put(id: number, body?: {
|
|
65
|
-
[key: string]: any;
|
|
66
|
-
}): Promise<IXCResponse>;
|
|
67
|
-
}
|
package/dist/IXCClient.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
const request_1 = require("./request");
|
|
24
|
-
const types_1 = require("./types");
|
|
25
|
-
const response_1 = require("./response");
|
|
26
|
-
class IXCClient {
|
|
27
|
-
/**
|
|
28
|
-
* @param table O nome da tabela correspondente ao banco de dados do seu servidor IXC
|
|
29
|
-
* @see {@link https://wikiapiprovedor.ixcsoft.com.br/index.php}
|
|
30
|
-
*/
|
|
31
|
-
constructor(table) {
|
|
32
|
-
this.table = table;
|
|
33
|
-
this.params = [];
|
|
34
|
-
this.options = {
|
|
35
|
-
page: 1,
|
|
36
|
-
rowsPerPage: 20,
|
|
37
|
-
sortName: 'id',
|
|
38
|
-
sortOrder: 'asc'
|
|
39
|
-
};
|
|
40
|
-
}
|
|
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
|
|
44
|
-
*
|
|
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
|
|
48
|
-
* @returns A própria instância
|
|
49
|
-
*/
|
|
50
|
-
where(whereClauses) {
|
|
51
|
-
if (whereClauses.length > 3) {
|
|
52
|
-
throw new Error(`> As cláusulas não podem conter mais de 3 elementos.`);
|
|
53
|
-
}
|
|
54
|
-
const [alwaysColumn, operatorOrValue, valueOrUndefined] = whereClauses;
|
|
55
|
-
const availableOperators = Object.keys(types_1.IXCOperator);
|
|
56
|
-
if (whereClauses.length > 2 && !availableOperators.includes(operatorOrValue)) {
|
|
57
|
-
throw new Error(`> O operador ${operatorOrValue}, não faz parte dos operadores válidos: ${availableOperators}.`);
|
|
58
|
-
}
|
|
59
|
-
this.params.push({
|
|
60
|
-
TB: alwaysColumn,
|
|
61
|
-
OP: valueOrUndefined ? operatorOrValue : '=',
|
|
62
|
-
P: valueOrUndefined ? valueOrUndefined : operatorOrValue
|
|
63
|
-
});
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Define como a API do IXC ordenará os dados retornados
|
|
68
|
-
*
|
|
69
|
-
* @param column A coluna que será usada para ordenar a busca
|
|
70
|
-
* @param order A ordem da busca ('asc'ou 'desc')
|
|
71
|
-
* @returns A própria instância
|
|
72
|
-
*/
|
|
73
|
-
orderBy(column, order) {
|
|
74
|
-
this.options.sortName = column;
|
|
75
|
-
this.options.sortOrder = order;
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Envia uma requisição GET para a API do IXC, com o header `ixcsoft` definico como `listar`\
|
|
80
|
-
* A `query` dessa requisição não será enviada para o IXC com o parâmetro `grid_param`\
|
|
81
|
-
* Ou seja, esta requisição executa uma busca simples, em vez do filtro de grid
|
|
82
|
-
*
|
|
83
|
-
* @param id O identificador numérico do registro que será buscado no IXC
|
|
84
|
-
* @returns Promise<IXCResponse>
|
|
85
|
-
*/
|
|
86
|
-
find(id) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
const params = {
|
|
90
|
-
TB: 'id',
|
|
91
|
-
OP: '=',
|
|
92
|
-
P: id
|
|
93
|
-
};
|
|
94
|
-
const opts = {
|
|
95
|
-
page: 1,
|
|
96
|
-
rowsPerPage: 1,
|
|
97
|
-
};
|
|
98
|
-
const axios = (0, request_1.createAxiosInstance)('GET');
|
|
99
|
-
const data = (0, request_1.createRequestPayload)(this.table, params, opts);
|
|
100
|
-
try {
|
|
101
|
-
const response = yield axios.get(this.table, { data });
|
|
102
|
-
if (response.status === 200) {
|
|
103
|
-
return response.data;
|
|
104
|
-
}
|
|
105
|
-
return (0, response_1.createResponse)({
|
|
106
|
-
error: true,
|
|
107
|
-
message: (_a = response.data) === null || _a === void 0 ? void 0 : _a.message
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
console.error(error);
|
|
112
|
-
return (0, response_1.createResponse)({
|
|
113
|
-
error: true,
|
|
114
|
-
message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message || 'Erro desconhecido'
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
this.params = [];
|
|
119
|
-
this.options = {
|
|
120
|
-
page: 1,
|
|
121
|
-
rowsPerPage: 20,
|
|
122
|
-
sortName: 'id',
|
|
123
|
-
sortOrder: 'asc'
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Envia uma requisição GET para a API do IXC, com o header `ixcsoft` definico como `listar`
|
|
130
|
-
* Preenche o corpo da requisição com os dados passados pela função `where` no formado JSON
|
|
131
|
-
*
|
|
132
|
-
* @param pg O número da página que será solicitada ao IXC `padão = 1`
|
|
133
|
-
* @param rows A quantidade de linhas (registros) por página `padrão = 20`
|
|
134
|
-
* @returns Promise<IXCResponse>
|
|
135
|
-
*/
|
|
136
|
-
get(pg, rows) {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
var _a, _b;
|
|
139
|
-
const _c = this.options, { page, rowsPerPage } = _c, rest = __rest(_c, ["page", "rowsPerPage"]);
|
|
140
|
-
const opts = Object.assign({ page: pg !== null && pg !== void 0 ? pg : page, rowsPerPage: rows !== null && rows !== void 0 ? rows : rowsPerPage }, rest);
|
|
141
|
-
const axios = (0, request_1.createAxiosInstance)('GET');
|
|
142
|
-
const data = (0, request_1.createRequestPayload)(this.table, this.params, opts);
|
|
143
|
-
try {
|
|
144
|
-
const response = yield axios.get(this.table, { data });
|
|
145
|
-
if (response.status === 200) {
|
|
146
|
-
return response.data;
|
|
147
|
-
}
|
|
148
|
-
return (0, response_1.createResponse)({
|
|
149
|
-
error: true,
|
|
150
|
-
message: (_a = response.data) === null || _a === void 0 ? void 0 : _a.message
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
catch (error) {
|
|
154
|
-
console.error(error);
|
|
155
|
-
return (0, response_1.createResponse)({
|
|
156
|
-
error: true,
|
|
157
|
-
message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message || 'Erro desconhecido'
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
finally {
|
|
161
|
-
this.params = [];
|
|
162
|
-
this.options = {
|
|
163
|
-
page: 1,
|
|
164
|
-
rowsPerPage: 20,
|
|
165
|
-
sortName: 'id',
|
|
166
|
-
sortOrder: 'asc'
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Envia uma requisição do tipo `POST` para a API do IXC, com o header `ixcsoft` vazio
|
|
173
|
-
*
|
|
174
|
-
* @param body Um objeto no formado "chave: valor" contendo as informações do novo registro
|
|
175
|
-
* a ser inserido no banco de dados do seu servidor IXC
|
|
176
|
-
* @returns Promise<IXCResponse>
|
|
177
|
-
*/
|
|
178
|
-
post(body) {
|
|
179
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
var _a, _b;
|
|
181
|
-
const axios = (0, request_1.createAxiosInstance)('POST');
|
|
182
|
-
try {
|
|
183
|
-
const response = yield axios.post(this.table, { data: body });
|
|
184
|
-
if (response.status === 200) {
|
|
185
|
-
return response.data;
|
|
186
|
-
}
|
|
187
|
-
return (0, response_1.createResponse)({
|
|
188
|
-
error: true,
|
|
189
|
-
message: (_a = response.data) === null || _a === void 0 ? void 0 : _a.message
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
console.error(error);
|
|
194
|
-
return (0, response_1.createResponse)({
|
|
195
|
-
error: true,
|
|
196
|
-
message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message || 'Erro desconhecido'
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
finally {
|
|
200
|
-
this.params = [];
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Envia uma requisição do tipo `PUT` para a API do IXC, com o header `ixcsoft` vazio
|
|
206
|
-
*
|
|
207
|
-
* @param id O id do registro que será alterado
|
|
208
|
-
* @param body Um objeto no formado "chave : valor" contendo as colunas que serão alteradas
|
|
209
|
-
* @returns Promise<IXCResponse>
|
|
210
|
-
*/
|
|
211
|
-
put(id, body) {
|
|
212
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
var _a, _b;
|
|
214
|
-
const axios = (0, request_1.createAxiosInstance)('PUT');
|
|
215
|
-
try {
|
|
216
|
-
const response = yield axios.put(`${this.table}/${id}`, { data: body });
|
|
217
|
-
if (response.status === 200) {
|
|
218
|
-
return response.data;
|
|
219
|
-
}
|
|
220
|
-
return (0, response_1.createResponse)({
|
|
221
|
-
error: true,
|
|
222
|
-
message: (_a = response.data) === null || _a === void 0 ? void 0 : _a.message
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
catch (error) {
|
|
226
|
-
console.error(error);
|
|
227
|
-
return (0, response_1.createResponse)({
|
|
228
|
-
error: true,
|
|
229
|
-
message: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText) || error.message || 'Erro desconhecido'
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
finally {
|
|
233
|
-
this.params = [];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
exports.default = IXCClient;
|
package/dist/IxcOrm.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Sort } from './api/Ordering';
|
|
2
|
-
import RequestEmitter from './api/RequestEmitter';
|
|
3
|
-
export default abstract class IxcOrm extends RequestEmitter {
|
|
4
|
-
private ordering;
|
|
5
|
-
private pagination;
|
|
6
|
-
private parameters;
|
|
7
|
-
private parameterStub;
|
|
8
|
-
/**
|
|
9
|
-
* Método construtor da classe.
|
|
10
|
-
*
|
|
11
|
-
* @param table Representa o o nome da tabela que será manipulada, no IXC Provedor.
|
|
12
|
-
*/
|
|
13
|
-
protected constructor(table: string);
|
|
14
|
-
/**
|
|
15
|
-
* Inicia um novo objeto de parâmetro de busca do filtro da grid.
|
|
16
|
-
*
|
|
17
|
-
* @param column O nome da coluna onde o filtro de busca será executado.
|
|
18
|
-
* @returns A própria instância.
|
|
19
|
-
*/
|
|
20
|
-
where(column: string): IxcOrm;
|
|
21
|
-
/**
|
|
22
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**L**) = LIKE.
|
|
23
|
-
*
|
|
24
|
-
* @param value O valor a ser filtrado.
|
|
25
|
-
* @returns A própria instância.
|
|
26
|
-
*/
|
|
27
|
-
like(value: string | number): IxcOrm;
|
|
28
|
-
/**
|
|
29
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**=**) = EQUALS.
|
|
30
|
-
*
|
|
31
|
-
* @param value O valor a ser filtrado.
|
|
32
|
-
* @returns A própria instância.
|
|
33
|
-
*/
|
|
34
|
-
exactly(value: string | number): IxcOrm;
|
|
35
|
-
/**
|
|
36
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**<**) = LESS_THAN.
|
|
37
|
-
*
|
|
38
|
-
* @param value O valor a ser filtrado.
|
|
39
|
-
* @returns A própria instância.
|
|
40
|
-
*/
|
|
41
|
-
lessThan(value: string | number): IxcOrm;
|
|
42
|
-
/**
|
|
43
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**<=**) = LESS_THAN_EQUALS.
|
|
44
|
-
*
|
|
45
|
-
* @param value O valor a ser filtrado.
|
|
46
|
-
* @returns A própria instância.
|
|
47
|
-
*/
|
|
48
|
-
lessThanEquals(value: string | number): IxcOrm;
|
|
49
|
-
/**
|
|
50
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**>**) = GREATER_THAN.
|
|
51
|
-
*
|
|
52
|
-
* @param value O valor a ser filtrado.
|
|
53
|
-
* @returns A própria instância.
|
|
54
|
-
*/
|
|
55
|
-
greaterThan(value: string | number): IxcOrm;
|
|
56
|
-
/**
|
|
57
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**>=**) = GREATER_THAN_EQUALS.
|
|
58
|
-
*
|
|
59
|
-
* @param value O valor a ser filtrado.
|
|
60
|
-
* @returns A própria instância.
|
|
61
|
-
*/
|
|
62
|
-
greaterThanEquals(value: string | number): IxcOrm;
|
|
63
|
-
/**
|
|
64
|
-
* Define o número da página e a quantidade de registros por página que serão retornados pelo IXc Provedor.
|
|
65
|
-
*
|
|
66
|
-
* @param page A página a ser buscada.
|
|
67
|
-
* @param rows A quantidade de registros por página.
|
|
68
|
-
* @returns A própria instância.
|
|
69
|
-
*/
|
|
70
|
-
paginate(page: number, rows: number): this;
|
|
71
|
-
/**
|
|
72
|
-
* Define o tipo de ordenação dos registros retornados pela API do IXC Provedor.
|
|
73
|
-
*
|
|
74
|
-
* @param sort **ASC** ou **DESC**.
|
|
75
|
-
* @param column A coluna que será utilizada para ordenar os registros.
|
|
76
|
-
* @returns A própria instância.
|
|
77
|
-
*/
|
|
78
|
-
orderBy(column: string, sort: Sort): this;
|
|
79
|
-
private createQueryObject;
|
|
80
|
-
private addParamToGridAndResetStub;
|
|
81
|
-
}
|
package/dist/IxcOrm.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const Operators_1 = __importDefault(require("./api/Operators"));
|
|
40
|
-
const Ordering_1 = __importStar(require("./api/Ordering"));
|
|
41
|
-
const Pagination_1 = __importDefault(require("./api/Pagination"));
|
|
42
|
-
const Parameter_1 = __importDefault(require("./api/Parameter"));
|
|
43
|
-
const RequestEmitter_1 = __importDefault(require("./api/RequestEmitter"));
|
|
44
|
-
class IxcOrm extends RequestEmitter_1.default {
|
|
45
|
-
/**
|
|
46
|
-
* Método construtor da classe.
|
|
47
|
-
*
|
|
48
|
-
* @param table Representa o o nome da tabela que será manipulada, no IXC Provedor.
|
|
49
|
-
*/
|
|
50
|
-
constructor(table) {
|
|
51
|
-
super(table);
|
|
52
|
-
this.ordering = Ordering_1.default.ascBy(table, "id");
|
|
53
|
-
this.pagination = Pagination_1.default.defaults();
|
|
54
|
-
this.parameters = [];
|
|
55
|
-
this.parameterStub = new Parameter_1.default(table);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Inicia um novo objeto de parâmetro de busca do filtro da grid.
|
|
59
|
-
*
|
|
60
|
-
* @param column O nome da coluna onde o filtro de busca será executado.
|
|
61
|
-
* @returns A própria instância.
|
|
62
|
-
*/
|
|
63
|
-
where(column) {
|
|
64
|
-
this.parameterStub.withType(column);
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**L**) = LIKE.
|
|
69
|
-
*
|
|
70
|
-
* @param value O valor a ser filtrado.
|
|
71
|
-
* @returns A própria instância.
|
|
72
|
-
*/
|
|
73
|
-
like(value) {
|
|
74
|
-
this.parameterStub.withOperator(Operators_1.default.LIKE);
|
|
75
|
-
this.parameterStub.withValue(value);
|
|
76
|
-
this.addParamToGridAndResetStub();
|
|
77
|
-
super.setupQuery(this.createQueryObject());
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**=**) = EQUALS.
|
|
82
|
-
*
|
|
83
|
-
* @param value O valor a ser filtrado.
|
|
84
|
-
* @returns A própria instância.
|
|
85
|
-
*/
|
|
86
|
-
exactly(value) {
|
|
87
|
-
this.parameterStub.withOperator(Operators_1.default.EQUALS);
|
|
88
|
-
this.parameterStub.withValue(value);
|
|
89
|
-
this.addParamToGridAndResetStub();
|
|
90
|
-
super.setupQuery(this.createQueryObject());
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**<**) = LESS_THAN.
|
|
95
|
-
*
|
|
96
|
-
* @param value O valor a ser filtrado.
|
|
97
|
-
* @returns A própria instância.
|
|
98
|
-
*/
|
|
99
|
-
lessThan(value) {
|
|
100
|
-
this.parameterStub.withOperator(Operators_1.default.LESS_THAN);
|
|
101
|
-
this.parameterStub.withValue(value);
|
|
102
|
-
this.addParamToGridAndResetStub();
|
|
103
|
-
super.setupQuery(this.createQueryObject());
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**<=**) = LESS_THAN_EQUALS.
|
|
108
|
-
*
|
|
109
|
-
* @param value O valor a ser filtrado.
|
|
110
|
-
* @returns A própria instância.
|
|
111
|
-
*/
|
|
112
|
-
lessThanEquals(value) {
|
|
113
|
-
this.parameterStub.withOperator(Operators_1.default.LESS_THAN_EQUALS);
|
|
114
|
-
this.parameterStub.withValue(value);
|
|
115
|
-
this.addParamToGridAndResetStub();
|
|
116
|
-
super.setupQuery(this.createQueryObject());
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**>**) = GREATER_THAN.
|
|
121
|
-
*
|
|
122
|
-
* @param value O valor a ser filtrado.
|
|
123
|
-
* @returns A própria instância.
|
|
124
|
-
*/
|
|
125
|
-
greaterThan(value) {
|
|
126
|
-
this.parameterStub.withOperator(Operators_1.default.GREATER_THAN);
|
|
127
|
-
this.parameterStub.withValue(value);
|
|
128
|
-
this.addParamToGridAndResetStub();
|
|
129
|
-
super.setupQuery(this.createQueryObject());
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Adiciona, ao último objeto de parâmetro iniciado, um valor a ser filtrado com o operador (**>=**) = GREATER_THAN_EQUALS.
|
|
134
|
-
*
|
|
135
|
-
* @param value O valor a ser filtrado.
|
|
136
|
-
* @returns A própria instância.
|
|
137
|
-
*/
|
|
138
|
-
greaterThanEquals(value) {
|
|
139
|
-
this.parameterStub.withOperator(Operators_1.default.GREATER_THAN_EQUALS);
|
|
140
|
-
this.parameterStub.withValue(value);
|
|
141
|
-
this.addParamToGridAndResetStub();
|
|
142
|
-
super.setupQuery(this.createQueryObject());
|
|
143
|
-
return this;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Define o número da página e a quantidade de registros por página que serão retornados pelo IXc Provedor.
|
|
147
|
-
*
|
|
148
|
-
* @param page A página a ser buscada.
|
|
149
|
-
* @param rows A quantidade de registros por página.
|
|
150
|
-
* @returns A própria instância.
|
|
151
|
-
*/
|
|
152
|
-
paginate(page, rows) {
|
|
153
|
-
this.pagination = new Pagination_1.default(page, rows);
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Define o tipo de ordenação dos registros retornados pela API do IXC Provedor.
|
|
158
|
-
*
|
|
159
|
-
* @param sort **ASC** ou **DESC**.
|
|
160
|
-
* @param column A coluna que será utilizada para ordenar os registros.
|
|
161
|
-
* @returns A própria instância.
|
|
162
|
-
*/
|
|
163
|
-
orderBy(column, sort) {
|
|
164
|
-
this.ordering = (sort === Ordering_1.Sort.ASC)
|
|
165
|
-
? Ordering_1.default.ascBy(super.getTable(), column)
|
|
166
|
-
: Ordering_1.default.descBy(super.getTable(), column);
|
|
167
|
-
return this;
|
|
168
|
-
}
|
|
169
|
-
createQueryObject() {
|
|
170
|
-
return {
|
|
171
|
-
qtype: super.getTable(),
|
|
172
|
-
query: "",
|
|
173
|
-
oper: "",
|
|
174
|
-
page: this.pagination.getPage(),
|
|
175
|
-
rp: this.pagination.getRows(),
|
|
176
|
-
sortname: this.ordering.getSortName(),
|
|
177
|
-
sortorder: this.ordering.getSortOrder().toString(),
|
|
178
|
-
grid_param: JSON.stringify(this.parameters)
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
addParamToGridAndResetStub() {
|
|
182
|
-
this.parameters.push(this.parameterStub.toJsonObject());
|
|
183
|
-
this.parameterStub = new Parameter_1.default(super.getTable());
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
exports.default = IxcOrm;
|
package/dist/IxcResponse.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export default class IxcResponse {
|
|
2
|
-
private data;
|
|
3
|
-
private text;
|
|
4
|
-
/**
|
|
5
|
-
* Cria um novo objeto no formato de uma resposta padrão do IXC Provedor.
|
|
6
|
-
*
|
|
7
|
-
* @param error Uma exceção capturada por um bloco try-catch.
|
|
8
|
-
* @returns Um objeto de resposta do IXC Provedor.
|
|
9
|
-
*/
|
|
10
|
-
static createResponseTextWithError(error: any): string;
|
|
11
|
-
/**
|
|
12
|
-
* Método construtor da classe.
|
|
13
|
-
*
|
|
14
|
-
* @param text O conteúdo da resposta do IXc Provedor, no formato de texto.
|
|
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;
|
|
24
|
-
/**
|
|
25
|
-
* Obtém a quantidade total dos registros encontrados no banco de dados, além dos retornados na página atual.
|
|
26
|
-
*
|
|
27
|
-
* @returns O total de registros encontrados.
|
|
28
|
-
*/
|
|
29
|
-
total(): number;
|
|
30
|
-
/**
|
|
31
|
-
* Obtém o número da página atual dos registros retornados.
|
|
32
|
-
*
|
|
33
|
-
* @returns O valor numérico da página.
|
|
34
|
-
*/
|
|
35
|
-
page(): number;
|
|
36
|
-
/**
|
|
37
|
-
* Obtém uma mensagem retornada pelo IXC quando a requisição falha.
|
|
38
|
-
*
|
|
39
|
-
* @returns Uma mensagem de falha.
|
|
40
|
-
*/
|
|
41
|
-
message(): string;
|
|
42
|
-
/**
|
|
43
|
-
* Obtém a lista de registros retornados por uma consulta à API do IXC Provedor.
|
|
44
|
-
*
|
|
45
|
-
* @returns Uma lista de objetos.
|
|
46
|
-
*/
|
|
47
|
-
registros(): Array<{
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
}>;
|
|
50
|
-
/**
|
|
51
|
-
* Obtém o conteúdo bruto de uma resposta da API do IXC Provedor.
|
|
52
|
-
* Este método substitui o método `registros()`, quando a requisição é feita para um endpoint
|
|
53
|
-
* específico de recursos do IXC Provedor, mas apenas quando a API devolve uma resposta bruta ao
|
|
54
|
-
* invés de uma lista de registros, ou uma mensagem.
|
|
55
|
-
*
|
|
56
|
-
* @returns Uma string contendo o conteúdo da resposta da API do IXC Provedor.
|
|
57
|
-
*/
|
|
58
|
-
content(): string;
|
|
59
|
-
private responseTextHasHtml;
|
|
60
|
-
private createDataFromText;
|
|
61
|
-
private createDataFromHtml;
|
|
62
|
-
}
|