ixc-orm 1.1.0 → 1.1.2
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 +1 -1
- package/dist/IXCClient.d.ts +4 -6
- package/dist/IXCClient.js +7 -9
- package/package.json +1 -1
- package/src/IXCClient.ts +7 -9
package/README.md
CHANGED
|
@@ -50,5 +50,5 @@ Para configurar a comunicação da biblioteca com seu servidor IXC, é necessár
|
|
|
50
50
|
|
|
51
51
|
`IXC_TOKEN`
|
|
52
52
|
|
|
53
|
-
> **IXC_HOST** deve conter a url do seu servidor IXC, no formato: `https://seudominio.com.br/webservice/v1
|
|
53
|
+
> **IXC_HOST** deve conter a url do seu servidor IXC, no formato: `https://seudominio.com.br/webservice/v1`\
|
|
54
54
|
> **IXC_TOKEN** deve conter um token de API gerado dentro do seu sistema IXCsoft.
|
package/dist/IXCClient.d.ts
CHANGED
|
@@ -14,10 +14,8 @@ export default abstract class IXCClient {
|
|
|
14
14
|
*
|
|
15
15
|
* @param whereClauses Um array de strings, no formato [coluna, operador, valor]
|
|
16
16
|
* Obs: se você passar um array no formato [coluna, valor] o operador será considerado como '='
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @returns
|
|
17
|
+
* Operadores válidos: =, !=, >, <, >=, <=, LIKE
|
|
18
|
+
* @returns A própria instância
|
|
21
19
|
*/
|
|
22
20
|
where(whereClauses: string[]): IXCClient;
|
|
23
21
|
/**
|
|
@@ -36,7 +34,7 @@ export default abstract class IXCClient {
|
|
|
36
34
|
get(pg?: number, rows?: number): Promise<null | IXCResponse | AxiosError>;
|
|
37
35
|
/**
|
|
38
36
|
*
|
|
39
|
-
* @param body Um objeto no formado "chave
|
|
37
|
+
* @param body Um objeto no formado "chave: valor" contendo as informações do novo registro
|
|
40
38
|
* a ser inserido no banco de dados do seu servidor IXC
|
|
41
39
|
* @returns Promise<null | IXCResponse | AxiosError>
|
|
42
40
|
*/
|
|
@@ -46,7 +44,7 @@ export default abstract class IXCClient {
|
|
|
46
44
|
/**
|
|
47
45
|
*
|
|
48
46
|
* @param id O id do registro que será alterado
|
|
49
|
-
* @param body Um objeto no formado "chave
|
|
47
|
+
* @param body Um objeto no formado "chave : valor" contendo as colunas que serão alteradas
|
|
50
48
|
* @returns Promise<null | IXCResponse | AxiosError>
|
|
51
49
|
*/
|
|
52
50
|
put(id: number, body?: {
|
package/dist/IXCClient.js
CHANGED
|
@@ -43,19 +43,17 @@ class IXCClient {
|
|
|
43
43
|
*
|
|
44
44
|
* @param whereClauses Um array de strings, no formato [coluna, operador, valor]
|
|
45
45
|
* Obs: se você passar um array no formato [coluna, valor] o operador será considerado como '='
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @returns
|
|
46
|
+
* Operadores válidos: =, !=, >, <, >=, <=, LIKE
|
|
47
|
+
* @returns A própria instância
|
|
50
48
|
*/
|
|
51
49
|
where(whereClauses) {
|
|
52
50
|
if (whereClauses.length > 3) {
|
|
53
|
-
throw new Error(
|
|
51
|
+
throw new Error(`> O array de cláusulas não pode conter mais de 3 elementos.`);
|
|
54
52
|
}
|
|
55
53
|
const [alwaysColumn, operatorOrValue, valueOrUndefined] = whereClauses;
|
|
56
54
|
const availableOperators = Object.keys(types_1.IXCOperator);
|
|
57
55
|
if (whereClauses.length > 2 && !availableOperators.includes(operatorOrValue)) {
|
|
58
|
-
throw new Error(
|
|
56
|
+
throw new Error(`> O operador ${operatorOrValue}, não faz parte dos operadores válidos: ${availableOperators}.`);
|
|
59
57
|
}
|
|
60
58
|
this.params.push({
|
|
61
59
|
TB: alwaysColumn,
|
|
@@ -88,7 +86,7 @@ class IXCClient {
|
|
|
88
86
|
const axios = (0, request_1.createAxiosInstance)('GET');
|
|
89
87
|
const payload = (0, request_1.createRequestPayload)(this.table, this.params, opts);
|
|
90
88
|
try {
|
|
91
|
-
const response = yield axios.get(this.table,
|
|
89
|
+
const response = yield axios.get(this.table, payload);
|
|
92
90
|
return response.data;
|
|
93
91
|
}
|
|
94
92
|
catch (error) {
|
|
@@ -111,7 +109,7 @@ class IXCClient {
|
|
|
111
109
|
}
|
|
112
110
|
/**
|
|
113
111
|
*
|
|
114
|
-
* @param body Um objeto no formado "chave
|
|
112
|
+
* @param body Um objeto no formado "chave: valor" contendo as informações do novo registro
|
|
115
113
|
* a ser inserido no banco de dados do seu servidor IXC
|
|
116
114
|
* @returns Promise<null | IXCResponse | AxiosError>
|
|
117
115
|
*/
|
|
@@ -137,7 +135,7 @@ class IXCClient {
|
|
|
137
135
|
/**
|
|
138
136
|
*
|
|
139
137
|
* @param id O id do registro que será alterado
|
|
140
|
-
* @param body Um objeto no formado "chave
|
|
138
|
+
* @param body Um objeto no formado "chave : valor" contendo as colunas que serão alteradas
|
|
141
139
|
* @returns Promise<null | IXCResponse | AxiosError>
|
|
142
140
|
*/
|
|
143
141
|
put(id, body) {
|
package/package.json
CHANGED
package/src/IXCClient.ts
CHANGED
|
@@ -35,16 +35,14 @@ export default abstract class IXCClient {
|
|
|
35
35
|
*
|
|
36
36
|
* @param whereClauses Um array de strings, no formato [coluna, operador, valor]
|
|
37
37
|
* Obs: se você passar um array no formato [coluna, valor] o operador será considerado como '='
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @returns
|
|
38
|
+
* Operadores válidos: =, !=, >, <, >=, <=, LIKE
|
|
39
|
+
* @returns A própria instância
|
|
42
40
|
*/
|
|
43
41
|
where(whereClauses: string[]) : IXCClient {
|
|
44
42
|
|
|
45
43
|
if (whereClauses.length > 3) {
|
|
46
44
|
throw new Error(
|
|
47
|
-
|
|
45
|
+
`> O array de cláusulas não pode conter mais de 3 elementos.`
|
|
48
46
|
);
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -58,7 +56,7 @@ export default abstract class IXCClient {
|
|
|
58
56
|
|
|
59
57
|
if (whereClauses.length > 2 && !availableOperators.includes(operatorOrValue)) {
|
|
60
58
|
throw new Error(
|
|
61
|
-
|
|
59
|
+
`> O operador ${ operatorOrValue }, não faz parte dos operadores válidos: ${ availableOperators }.`
|
|
62
60
|
);
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -105,7 +103,7 @@ export default abstract class IXCClient {
|
|
|
105
103
|
const payload = createRequestPayload(this.table, this.params, opts);
|
|
106
104
|
|
|
107
105
|
try {
|
|
108
|
-
const response = await axios.get<IXCResponse>(this.table,
|
|
106
|
+
const response = await axios.get<IXCResponse>(this.table, payload);
|
|
109
107
|
return response.data;
|
|
110
108
|
}
|
|
111
109
|
catch (error: any) {
|
|
@@ -131,7 +129,7 @@ export default abstract class IXCClient {
|
|
|
131
129
|
|
|
132
130
|
/**
|
|
133
131
|
*
|
|
134
|
-
* @param body Um objeto no formado "chave
|
|
132
|
+
* @param body Um objeto no formado "chave: valor" contendo as informações do novo registro
|
|
135
133
|
* a ser inserido no banco de dados do seu servidor IXC
|
|
136
134
|
* @returns Promise<null | IXCResponse | AxiosError>
|
|
137
135
|
*/
|
|
@@ -160,7 +158,7 @@ export default abstract class IXCClient {
|
|
|
160
158
|
/**
|
|
161
159
|
*
|
|
162
160
|
* @param id O id do registro que será alterado
|
|
163
|
-
* @param body Um objeto no formado "chave
|
|
161
|
+
* @param body Um objeto no formado "chave : valor" contendo as colunas que serão alteradas
|
|
164
162
|
* @returns Promise<null | IXCResponse | AxiosError>
|
|
165
163
|
*/
|
|
166
164
|
async put(id: number, body?: { [key: string]: any }) : Promise<null | IXCResponse | AxiosError> {
|