@zauru-sdk/utils 6.25.0 → 6.26.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.
package/dist/esm/index.js
CHANGED
|
@@ -31,3 +31,4 @@ export * from "./zauru/webapp-tables.utils.js";
|
|
|
31
31
|
export * from "./zauru/4pinos-po-discount-history.utils.js";
|
|
32
32
|
export * from "./zauru/programaciones.utils.js";
|
|
33
33
|
export * from "./zauru/providerRestrictions.utils.js";
|
|
34
|
+
export * from "./zauru/providerReceptionMatrix.utils.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors, normalizeProviderRestrictionValues, normalizeRestrictionValue, PROVIDER_RECEPTION_EXCEPTIONS_TABLE_VAR, PROVIDER_RECEPTION_MATRIX_TABLE_VAR, } from "@zauru-sdk/common";
|
|
2
|
+
import { createWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
|
|
3
|
+
export const FOUR_PINOS_NON_SELECTABLE_RECEPTION_ITEM_IDS = [
|
|
4
|
+
782312, 782638,
|
|
5
|
+
];
|
|
6
|
+
export const filter4PinosSelectableReceptionItems = (items) => {
|
|
7
|
+
const excluded = new Set(FOUR_PINOS_NON_SELECTABLE_RECEPTION_ITEM_IDS);
|
|
8
|
+
return items.filter((item) => !excluded.has(Number(item.id)));
|
|
9
|
+
};
|
|
10
|
+
const getTableId = async (headers, session, varName) => {
|
|
11
|
+
const variables = await getVariablesByName(headers, session, [varName]);
|
|
12
|
+
return variables[varName];
|
|
13
|
+
};
|
|
14
|
+
const getRows = async (input) => handlePossibleAxiosErrors(async () => {
|
|
15
|
+
const tableId = await getTableId(input.headers, input.session, input.varName);
|
|
16
|
+
const data = {};
|
|
17
|
+
if (input.filters?.payeeId != null) {
|
|
18
|
+
data.payee_id = Number(input.filters.payeeId);
|
|
19
|
+
}
|
|
20
|
+
if (input.filters?.receptionTypeCode != null) {
|
|
21
|
+
data.reception_type_code = normalizeRestrictionValue(input.filters.receptionTypeCode);
|
|
22
|
+
}
|
|
23
|
+
const response = await getWebAppTableRegisters(input.session, tableId, {
|
|
24
|
+
...(Object.keys(data).length ? { data } : {}),
|
|
25
|
+
});
|
|
26
|
+
if (response.error) {
|
|
27
|
+
throw new Error(`Ocurrió un error al consultar ${input.label}: ${response.userMsg}`);
|
|
28
|
+
}
|
|
29
|
+
return response.data ?? [];
|
|
30
|
+
});
|
|
31
|
+
const createRow = async (input) => handlePossibleAxiosErrors(async () => {
|
|
32
|
+
const tableId = await getTableId(input.headers, input.session, input.varName);
|
|
33
|
+
return createWebAppTableRegister(input.headers, tableId, input.body);
|
|
34
|
+
});
|
|
35
|
+
const updateRow = async (input) => handlePossibleAxiosErrors(async () => {
|
|
36
|
+
const tableId = await getTableId(input.headers, input.session, input.varName);
|
|
37
|
+
return updateWebAppTableRegister(input.headers, tableId, input.id, input.body);
|
|
38
|
+
});
|
|
39
|
+
export const getProviderReceptionBlockRules = (headers, session, filters) => getRows({
|
|
40
|
+
headers,
|
|
41
|
+
session,
|
|
42
|
+
varName: PROVIDER_RECEPTION_MATRIX_TABLE_VAR,
|
|
43
|
+
label: "la matriz de restricciones de recepción",
|
|
44
|
+
filters,
|
|
45
|
+
});
|
|
46
|
+
export const createProviderReceptionBlockRule = (headers, session, body) => createRow({
|
|
47
|
+
headers,
|
|
48
|
+
session,
|
|
49
|
+
varName: PROVIDER_RECEPTION_MATRIX_TABLE_VAR,
|
|
50
|
+
body: {
|
|
51
|
+
...body,
|
|
52
|
+
blocked_item_ids: normalizeProviderRestrictionValues(body.blocked_item_ids),
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
export const updateProviderReceptionBlockRule = (headers, session, id, body) => updateRow({
|
|
56
|
+
headers,
|
|
57
|
+
session,
|
|
58
|
+
varName: PROVIDER_RECEPTION_MATRIX_TABLE_VAR,
|
|
59
|
+
id,
|
|
60
|
+
body,
|
|
61
|
+
});
|
|
62
|
+
export const getProviderReceptionExceptions = (headers, session, filters) => getRows({
|
|
63
|
+
headers,
|
|
64
|
+
session,
|
|
65
|
+
varName: PROVIDER_RECEPTION_EXCEPTIONS_TABLE_VAR,
|
|
66
|
+
label: "las excepciones temporales de recepción",
|
|
67
|
+
filters,
|
|
68
|
+
});
|
|
69
|
+
export const createProviderReceptionException = (headers, session, body) => createRow({
|
|
70
|
+
headers,
|
|
71
|
+
session,
|
|
72
|
+
varName: PROVIDER_RECEPTION_EXCEPTIONS_TABLE_VAR,
|
|
73
|
+
body: {
|
|
74
|
+
...body,
|
|
75
|
+
item_ids: normalizeProviderRestrictionValues(body.item_ids),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
export const updateProviderReceptionException = (headers, session, id, body) => updateRow({
|
|
79
|
+
headers,
|
|
80
|
+
session,
|
|
81
|
+
varName: PROVIDER_RECEPTION_EXCEPTIONS_TABLE_VAR,
|
|
82
|
+
id,
|
|
83
|
+
body,
|
|
84
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -31,3 +31,4 @@ export * from "./zauru/webapp-tables.utils.js";
|
|
|
31
31
|
export * from "./zauru/4pinos-po-discount-history.utils.js";
|
|
32
32
|
export * from "./zauru/programaciones.utils.js";
|
|
33
33
|
export * from "./zauru/providerRestrictions.utils.js";
|
|
34
|
+
export * from "./zauru/providerReceptionMatrix.utils.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import type { AxiosUtilsResponse, ProviderReceptionBlockRule, ProviderReceptionException, WebAppRowGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
|
|
3
|
+
export declare const FOUR_PINOS_NON_SELECTABLE_RECEPTION_ITEM_IDS: readonly [782312, 782638];
|
|
4
|
+
export declare const filter4PinosSelectableReceptionItems: <T extends {
|
|
5
|
+
id: number;
|
|
6
|
+
}>(items: T[]) => T[];
|
|
7
|
+
export declare const getProviderReceptionBlockRules: (headers: any, session: Session, filters?: {
|
|
8
|
+
payeeId?: number;
|
|
9
|
+
receptionTypeCode?: string;
|
|
10
|
+
}) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<ProviderReceptionBlockRule>[]>>;
|
|
11
|
+
export declare const createProviderReceptionBlockRule: (headers: any, session: Session, body: ProviderReceptionBlockRule) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
12
|
+
export declare const updateProviderReceptionBlockRule: (headers: any, session: Session, id: number, body: Partial<ProviderReceptionBlockRule>) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
13
|
+
export declare const getProviderReceptionExceptions: (headers: any, session: Session, filters?: {
|
|
14
|
+
payeeId?: number;
|
|
15
|
+
receptionTypeCode?: string;
|
|
16
|
+
}) => Promise<AxiosUtilsResponse<WebAppRowGraphQL<ProviderReceptionException>[]>>;
|
|
17
|
+
export declare const createProviderReceptionException: (headers: any, session: Session, body: ProviderReceptionException) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
18
|
+
export declare const updateProviderReceptionException: (headers: any, session: Session, id: number, body: Partial<ProviderReceptionException>) => Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.26.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",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@aws-sdk/client-cloudwatch-logs": "^3.1123.0",
|
|
73
73
|
"@remix-run/node": "^2.8.1",
|
|
74
|
-
"@zauru-sdk/common": "^6.
|
|
74
|
+
"@zauru-sdk/common": "^6.12.0",
|
|
75
75
|
"@zauru-sdk/config": "^6.0.0",
|
|
76
76
|
"@zauru-sdk/graphql": "^6.9.0",
|
|
77
|
-
"@zauru-sdk/services": "^6.15.
|
|
78
|
-
"@zauru-sdk/types": "^6.
|
|
77
|
+
"@zauru-sdk/services": "^6.15.1",
|
|
78
|
+
"@zauru-sdk/types": "^6.28.0",
|
|
79
79
|
"moment": "^2.30.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "2fda4a18e3f62d22c38fbb91052869db9ebc16f4"
|
|
82
82
|
}
|