@zauru-sdk/services 2.0.218 → 2.0.220
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/dist/esm/common.js +15 -10
- package/dist/esm/index.js +1 -0
- package/dist/esm/zauru/4pinos-solicitud-eliminacion-po.js +42 -0
- package/dist/esm/zauru/zauru-web-app-tables.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/zauru/4pinos-solicitud-eliminacion-po.d.ts +6 -0
- package/dist/zauru/zauru-web-app-tables.d.ts +1 -1
- package/package.json +6 -6
package/dist/esm/common.js
CHANGED
|
@@ -106,15 +106,20 @@ async function getGraphQLToken(session) {
|
|
|
106
106
|
return handlePossibleAxiosErrors(async () => {
|
|
107
107
|
const token = (await session.get("graphqlToken"));
|
|
108
108
|
const headers = (await getHeaders(null, session));
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
// Check if token is missing or within one day of expiration
|
|
110
|
+
const now = Date.now();
|
|
111
|
+
let tokenHasExpired = true;
|
|
112
|
+
if (token && token.expires) {
|
|
113
|
+
const expiresAt = Date.parse(token.expires);
|
|
114
|
+
if (!isNaN(expiresAt)) {
|
|
115
|
+
const oneDayMs = 24 * 60 * 60 * 1000;
|
|
116
|
+
// Refresh if already expired or expires within the next 24 hours
|
|
117
|
+
tokenHasExpired = expiresAt <= now + oneDayMs;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// If there's no valid token or it's expiring soon, fetch a new one
|
|
121
|
+
if (tokenHasExpired) {
|
|
122
|
+
console.log(chalk.yellow(`=============== ⚠️ EL TOKEN GRAPHQL ESTÁ EXPIRADO O NO EXISTE ⚠️ ====================`));
|
|
118
123
|
const responseToken = await httpZauru.get("/apps/graphql.json", {
|
|
119
124
|
headers,
|
|
120
125
|
});
|
|
@@ -127,7 +132,7 @@ async function getGraphQLToken(session) {
|
|
|
127
132
|
console.log(chalk.red(`=============== ❗ NO HAY INFORMACIÓN OBTENIDA DEL REQUEST A ZAURU - GET_TOKEN ❗ ====================`));
|
|
128
133
|
throw new Error("No viene información en la solicitud de getGraphQLToken a Zauru");
|
|
129
134
|
}
|
|
130
|
-
//
|
|
135
|
+
// Return the existing valid token
|
|
131
136
|
return token;
|
|
132
137
|
});
|
|
133
138
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./zauru/httpCMS.js";
|
|
|
8
8
|
export * from "./zauru/httpGraphQL.js";
|
|
9
9
|
export * from "./zauru/httpOauth.js";
|
|
10
10
|
export * from "./zauru/httpZauru.js";
|
|
11
|
+
export * from "./zauru/4pinos-solicitud-eliminacion-po.js";
|
|
11
12
|
export * from "./zauru/zauru-agencies.js";
|
|
12
13
|
export * from "./zauru/zauru-automatic-numbers.js";
|
|
13
14
|
export * from "./zauru/zauru-bookings.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import { getVariablesByName } from "../common.js";
|
|
3
|
+
import { createWebAppTableRegister, deleteWebAppTableRegister, getWebAppTableRegisters, updateWebAppTableRegister, } from "./zauru-web-app-tables.js";
|
|
4
|
+
export async function get4pinosSolicitudEliminacionPO(headers, session) {
|
|
5
|
+
return handlePossibleAxiosErrors(async () => {
|
|
6
|
+
const { solicitud_eliminacion_po_webapp_table_id } = await getVariablesByName(headers, session, [
|
|
7
|
+
"solicitud_eliminacion_po_webapp_table_id",
|
|
8
|
+
]);
|
|
9
|
+
const response = await getWebAppTableRegisters(session, solicitud_eliminacion_po_webapp_table_id);
|
|
10
|
+
if (response.error || !response.data) {
|
|
11
|
+
throw new Error(response.userMsg);
|
|
12
|
+
}
|
|
13
|
+
return response?.data;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export async function delete4pinosSolicitudEliminacionPO(headers, session, id) {
|
|
17
|
+
return handlePossibleAxiosErrors(async () => {
|
|
18
|
+
const { solicitud_eliminacion_po_webapp_table_id } = await getVariablesByName(headers, session, [
|
|
19
|
+
"solicitud_eliminacion_po_webapp_table_id",
|
|
20
|
+
]);
|
|
21
|
+
const response = await deleteWebAppTableRegister(headers, solicitud_eliminacion_po_webapp_table_id, id);
|
|
22
|
+
return response;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export async function create4pinosSolicitudEliminacionPO(headers, session, body) {
|
|
26
|
+
return handlePossibleAxiosErrors(async () => {
|
|
27
|
+
const { solicitud_eliminacion_po_webapp_table_id } = await getVariablesByName(headers, session, [
|
|
28
|
+
"solicitud_eliminacion_po_webapp_table_id",
|
|
29
|
+
]);
|
|
30
|
+
const response = await createWebAppTableRegister(headers, solicitud_eliminacion_po_webapp_table_id, body);
|
|
31
|
+
return response;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export async function update4pinosSolicitudEliminacionPO(headers, session, id, body) {
|
|
35
|
+
return handlePossibleAxiosErrors(async () => {
|
|
36
|
+
const { solicitud_eliminacion_po_webapp_table_id } = await getVariablesByName(headers, session, [
|
|
37
|
+
"solicitud_eliminacion_po_webapp_table_id",
|
|
38
|
+
]);
|
|
39
|
+
const response = await updateWebAppTableRegister(headers, solicitud_eliminacion_po_webapp_table_id, id, body);
|
|
40
|
+
return response;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -26,11 +26,11 @@ export async function getWebAppRow(session, id) {
|
|
|
26
26
|
* @param webapp_table_id web app table id
|
|
27
27
|
* @returns
|
|
28
28
|
*/
|
|
29
|
-
export async function getWebAppTableRegisters(session, webapp_table_id) {
|
|
29
|
+
export async function getWebAppTableRegisters(session, webapp_table_id, limit) {
|
|
30
30
|
return handlePossibleAxiosErrors(async () => {
|
|
31
31
|
const headers = await getGraphQLAPIHeaders(session);
|
|
32
32
|
const response = await httpGraphQLAPI.post("", {
|
|
33
|
-
query: getWebAppRowsByWebAppTableIdStringQuery(Number(webapp_table_id)),
|
|
33
|
+
query: getWebAppRowsByWebAppTableIdStringQuery(Number(webapp_table_id), limit),
|
|
34
34
|
}, { headers });
|
|
35
35
|
if (response.data.errors) {
|
|
36
36
|
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./zauru/httpCMS.js";
|
|
|
8
8
|
export * from "./zauru/httpGraphQL.js";
|
|
9
9
|
export * from "./zauru/httpOauth.js";
|
|
10
10
|
export * from "./zauru/httpZauru.js";
|
|
11
|
+
export * from "./zauru/4pinos-solicitud-eliminacion-po.js";
|
|
11
12
|
export * from "./zauru/zauru-agencies.js";
|
|
12
13
|
export * from "./zauru/zauru-automatic-numbers.js";
|
|
13
14
|
export * from "./zauru/zauru-bookings.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { AxiosUtilsResponse, SolicitudEliminacionPO, WebAppRowGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
|
|
3
|
+
export declare function get4pinosSolicitudEliminacionPO(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<SolicitudEliminacionPO>[]>>;
|
|
4
|
+
export declare function delete4pinosSolicitudEliminacionPO(headers: any, session: Session, id: number): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
5
|
+
export declare function create4pinosSolicitudEliminacionPO(headers: any, session: Session, body: SolicitudEliminacionPO): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
6
|
+
export declare function update4pinosSolicitudEliminacionPO(headers: any, session: Session, id: number, body: SolicitudEliminacionPO): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
@@ -12,7 +12,7 @@ export declare function getWebAppRow<T>(session: Session, id: number): Promise<A
|
|
|
12
12
|
* @param webapp_table_id web app table id
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
export declare function getWebAppTableRegisters<T>(session: Session, webapp_table_id: string): Promise<AxiosUtilsResponse<WebAppRowGraphQL<T>[]>>;
|
|
15
|
+
export declare function getWebAppTableRegisters<T>(session: Session, webapp_table_id: string, limit?: number): Promise<AxiosUtilsResponse<WebAppRowGraphQL<T>[]>>;
|
|
16
16
|
/**
|
|
17
17
|
* deleteWebAppTableRegister Function for delete a web app table register
|
|
18
18
|
* @param headers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.220",
|
|
4
4
|
"description": "Servicios de consulta a Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@remix-run/node": "^2.8.1",
|
|
27
27
|
"@upstash/redis": "^1.34.5",
|
|
28
|
-
"@zauru-sdk/common": "^2.0.
|
|
29
|
-
"@zauru-sdk/config": "^2.0.
|
|
30
|
-
"@zauru-sdk/graphql": "^2.0.
|
|
31
|
-
"@zauru-sdk/types": "^2.0.
|
|
28
|
+
"@zauru-sdk/common": "^2.0.220",
|
|
29
|
+
"@zauru-sdk/config": "^2.0.220",
|
|
30
|
+
"@zauru-sdk/graphql": "^2.0.220",
|
|
31
|
+
"@zauru-sdk/types": "^2.0.220",
|
|
32
32
|
"axios": "^1.6.7",
|
|
33
33
|
"chalk": "5.3.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c8ca154d7c11e35c916f2e7f7bfc27f5ba2c14f1"
|
|
36
36
|
}
|