@zauru-sdk/utils 6.18.1 → 6.19.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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
2
|
import { createWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
|
|
3
|
+
const BITACORA_DEFAULT_LIMIT = 1000;
|
|
3
4
|
/**
|
|
4
5
|
* Get saveBitacoraPOMassive from the web app table.
|
|
5
6
|
* @param headers Request headers.
|
|
6
7
|
* @param session Session object.
|
|
7
|
-
* @returns A Promise of AxiosUtilsResponse<
|
|
8
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
8
9
|
*/
|
|
9
10
|
export const saveBitacoraPOMassive = (headers, session, body) => {
|
|
10
11
|
return handlePossibleAxiosErrors(async () => {
|
|
@@ -19,14 +20,19 @@ export const saveBitacoraPOMassive = (headers, session, body) => {
|
|
|
19
20
|
* Get getBitacorasPOMassive from the web app table.
|
|
20
21
|
* @param headers Request headers.
|
|
21
22
|
* @param session Session object.
|
|
23
|
+
* @param options Optional JSON `data` filters, `createdAt` range and row limit. Defaults to the last 1000 rows.
|
|
22
24
|
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
|
|
23
25
|
*/
|
|
24
|
-
export const getBitacorasPOMassive = (headers, session) => {
|
|
26
|
+
export const getBitacorasPOMassive = (headers, session, options) => {
|
|
25
27
|
return handlePossibleAxiosErrors(async () => {
|
|
26
28
|
const { bitacora_ediciones_masivas_web_app_table_id } = await getVariablesByName(headers, session, [
|
|
27
29
|
"bitacora_ediciones_masivas_web_app_table_id",
|
|
28
30
|
]);
|
|
29
|
-
const response = await getWebAppTableRegisters(session, bitacora_ediciones_masivas_web_app_table_id, {
|
|
31
|
+
const response = await getWebAppTableRegisters(session, bitacora_ediciones_masivas_web_app_table_id, {
|
|
32
|
+
limit: options?.limit ?? BITACORA_DEFAULT_LIMIT,
|
|
33
|
+
...(options?.data ? { data: options.data } : {}),
|
|
34
|
+
...(options?.createdAt ? { createdAt: options.createdAt } : {}),
|
|
35
|
+
});
|
|
30
36
|
if (response.error || !response.data) {
|
|
31
37
|
throw new Error(response.userMsg);
|
|
32
38
|
}
|
|
@@ -1,34 +1,6 @@
|
|
|
1
1
|
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
2
|
import { associateWebAppTableRegister, createWebAppTableRegister, deleteWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
|
|
3
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
|
-
};
|
|
32
4
|
/**
|
|
33
5
|
* Get programaciones from the web app table.
|
|
34
6
|
* @param headers Request headers.
|
|
@@ -39,8 +11,8 @@ const expandProgramacionFilters = (filters) => {
|
|
|
39
11
|
export const getProgramaciones = (headers, session, options) => {
|
|
40
12
|
return handlePossibleAxiosErrors(async () => {
|
|
41
13
|
const { programaciones_webapp_table_id } = await getVariablesByName(headers, session, ["programaciones_webapp_table_id"]);
|
|
42
|
-
const dataFilters =
|
|
43
|
-
const hasFilters = Boolean(dataFilters);
|
|
14
|
+
const dataFilters = options?.filters;
|
|
15
|
+
const hasFilters = Boolean(dataFilters && Object.keys(dataFilters).length > 0);
|
|
44
16
|
const queryOptions = hasFilters
|
|
45
17
|
? {
|
|
46
18
|
data: dataFilters,
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { Session } from "@remix-run/node";
|
|
2
|
+
import type { GetWebAppRowsByTableIdOptions } from "@zauru-sdk/graphql";
|
|
2
3
|
import { AxiosUtilsResponse, WebAppTableUpdateResponse, BitacoraPOMassive, WebAppRowGraphQL } from "@zauru-sdk/types";
|
|
3
4
|
/**
|
|
4
5
|
* Get saveBitacoraPOMassive from the web app table.
|
|
5
6
|
* @param headers Request headers.
|
|
6
7
|
* @param session Session object.
|
|
7
|
-
* @returns A Promise of AxiosUtilsResponse<
|
|
8
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
8
9
|
*/
|
|
9
10
|
export declare const saveBitacoraPOMassive: (headers: any, session: Session, body: BitacoraPOMassive) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
10
11
|
/**
|
|
11
12
|
* Get getBitacorasPOMassive from the web app table.
|
|
12
13
|
* @param headers Request headers.
|
|
13
14
|
* @param session Session object.
|
|
15
|
+
* @param options Optional JSON `data` filters, `createdAt` range and row limit. Defaults to the last 1000 rows.
|
|
14
16
|
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
|
|
15
17
|
*/
|
|
16
|
-
export declare const getBitacorasPOMassive: (headers: any, session: Session) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>>;
|
|
18
|
+
export declare const getBitacorasPOMassive: (headers: any, session: Session, options?: GetWebAppRowsByTableIdOptions) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>>;
|
|
17
19
|
/**
|
|
18
20
|
* Put updateBitacorasPOMassive from the web app table.
|
|
19
21
|
* @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.19.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",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"@remix-run/node": "^2.8.1",
|
|
74
74
|
"@zauru-sdk/common": "^6.8.1",
|
|
75
75
|
"@zauru-sdk/config": "^6.0.0",
|
|
76
|
-
"@zauru-sdk/graphql": "^6.
|
|
77
|
-
"@zauru-sdk/services": "^6.11.
|
|
76
|
+
"@zauru-sdk/graphql": "^6.8.0",
|
|
77
|
+
"@zauru-sdk/services": "^6.11.4",
|
|
78
78
|
"@zauru-sdk/types": "^6.19.0",
|
|
79
79
|
"moment": "^2.30.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "a5b35540efd2b3395e05ea0182c97d78f059c3c4"
|
|
82
82
|
}
|