@zauru-sdk/utils 6.7.0 → 6.9.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.
|
@@ -26,7 +26,7 @@ export const getBitacorasPOMassive = (headers, session) => {
|
|
|
26
26
|
const { bitacora_ediciones_masivas_web_app_table_id } = await getVariablesByName(headers, session, [
|
|
27
27
|
"bitacora_ediciones_masivas_web_app_table_id",
|
|
28
28
|
]);
|
|
29
|
-
const response = await getWebAppTableRegisters(session, bitacora_ediciones_masivas_web_app_table_id, 1000);
|
|
29
|
+
const response = await getWebAppTableRegisters(session, bitacora_ediciones_masivas_web_app_table_id, { limit: 1000 });
|
|
30
30
|
if (response.error || !response.data) {
|
|
31
31
|
throw new Error(response.userMsg);
|
|
32
32
|
}
|
|
@@ -9,7 +9,7 @@ import { createWebAppTableRegister, getVariablesByName, getWebAppTableRegisters,
|
|
|
9
9
|
export const getDischargeHistories = (headers, session) => {
|
|
10
10
|
return handlePossibleAxiosErrors(async () => {
|
|
11
11
|
const { discharge_history_web_app_table_id } = await getVariablesByName(headers, session, ["discharge_history_web_app_table_id"]);
|
|
12
|
-
const response = await getWebAppTableRegisters(session, discharge_history_web_app_table_id, 1000);
|
|
12
|
+
const response = await getWebAppTableRegisters(session, discharge_history_web_app_table_id, { limit: 1000 });
|
|
13
13
|
if (response.error) {
|
|
14
14
|
throw new Error(`Ocurrió un error al consultar el historial de discharges: ${response.userMsg}`);
|
|
15
15
|
}
|
|
@@ -1,15 +1,55 @@
|
|
|
1
1
|
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
2
|
import { associateWebAppTableRegister, createWebAppTableRegister, deleteWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
|
|
3
|
+
const PROGRAMACIONES_FILTERED_DEFAULT_LIMIT = 1000;
|
|
4
|
+
const JSONB_ID_FILTER_KEYS = new Set(["payee_id", "item_id"]);
|
|
5
|
+
const expandJsonbIdFilterValue = (value) => {
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
10
|
+
return [value, String(value)];
|
|
11
|
+
}
|
|
12
|
+
if (typeof value === "string" && value !== "" && Number.isFinite(Number(value))) {
|
|
13
|
+
return [Number(value), value];
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
const expandProgramacionFilters = (filters) => {
|
|
18
|
+
if (!filters) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const expanded = {};
|
|
22
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
expanded[key] = JSONB_ID_FILTER_KEYS.has(key)
|
|
27
|
+
? expandJsonbIdFilterValue(value)
|
|
28
|
+
: value;
|
|
29
|
+
}
|
|
30
|
+
return Object.keys(expanded).length > 0 ? expanded : undefined;
|
|
31
|
+
};
|
|
3
32
|
/**
|
|
4
33
|
* Get programaciones from the web app table.
|
|
5
34
|
* @param headers Request headers.
|
|
6
35
|
* @param session Session object.
|
|
36
|
+
* @param options Optional JSON `data` filters and row limit. With filters, defaults to the last 1000 rows.
|
|
7
37
|
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<Programacion>[]>>.
|
|
8
38
|
*/
|
|
9
|
-
export const getProgramaciones = (headers, session) => {
|
|
39
|
+
export const getProgramaciones = (headers, session, options) => {
|
|
10
40
|
return handlePossibleAxiosErrors(async () => {
|
|
11
41
|
const { programaciones_webapp_table_id } = await getVariablesByName(headers, session, ["programaciones_webapp_table_id"]);
|
|
12
|
-
const
|
|
42
|
+
const dataFilters = expandProgramacionFilters(options?.filters);
|
|
43
|
+
const hasFilters = Boolean(dataFilters);
|
|
44
|
+
const queryOptions = hasFilters
|
|
45
|
+
? {
|
|
46
|
+
data: dataFilters,
|
|
47
|
+
limit: options?.limit ?? PROGRAMACIONES_FILTERED_DEFAULT_LIMIT,
|
|
48
|
+
}
|
|
49
|
+
: options?.limit != null
|
|
50
|
+
? { limit: options.limit }
|
|
51
|
+
: undefined;
|
|
52
|
+
const response = await getWebAppTableRegisters(session, programaciones_webapp_table_id, queryOptions);
|
|
13
53
|
if (response.error) {
|
|
14
54
|
throw new Error(`Ocurrió un error al consultar las programaciones: ${response.userMsg}`);
|
|
15
55
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { Session } from "@remix-run/node";
|
|
2
|
+
import type { WebAppRowDataFilterValue } from "@zauru-sdk/graphql";
|
|
2
3
|
import { AxiosUtilsResponse, Programacion, WebAppRowAssociateResponse, WebAppRowGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
|
|
4
|
+
export type GetProgramacionesOptions = {
|
|
5
|
+
filters?: Record<string, WebAppRowDataFilterValue>;
|
|
6
|
+
limit?: number;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
9
|
* Get programaciones from the web app table.
|
|
5
10
|
* @param headers Request headers.
|
|
6
11
|
* @param session Session object.
|
|
12
|
+
* @param options Optional JSON `data` filters and row limit. With filters, defaults to the last 1000 rows.
|
|
7
13
|
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<Programacion>[]>>.
|
|
8
14
|
*/
|
|
9
|
-
export declare const getProgramaciones: (headers: any, session: Session) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<Programacion>[]>>;
|
|
15
|
+
export declare const getProgramaciones: (headers: any, session: Session, options?: GetProgramacionesOptions) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<Programacion>[]>>;
|
|
10
16
|
/**
|
|
11
17
|
* Create a programacion in the web app table.
|
|
12
18
|
* @param headers Request headers.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.0",
|
|
4
4
|
"description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@remix-run/node": "^2.8.1",
|
|
28
28
|
"@zauru-sdk/common": "^6.4.0",
|
|
29
29
|
"@zauru-sdk/config": "^6.0.0",
|
|
30
|
-
"@zauru-sdk/graphql": "^6.
|
|
31
|
-
"@zauru-sdk/services": "^6.
|
|
30
|
+
"@zauru-sdk/graphql": "^6.7.0",
|
|
31
|
+
"@zauru-sdk/services": "^6.9.0",
|
|
32
32
|
"@zauru-sdk/types": "^6.14.0",
|
|
33
33
|
"moment": "^2.30.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "add1b36bf68bad8debe05c25fd826d68acce2810"
|
|
36
36
|
}
|