@zauru-sdk/utils 1.0.7 → 1.0.9
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/CHANGELOG.md +16 -0
- package/dist/index.d.ts +23 -2
- package/dist/index.js +23 -2
- package/dist/zauru/automatic-number.utils.d.ts +9 -0
- package/dist/zauru/automatic-number.utils.js +24 -0
- package/dist/zauru/bitacora-edicion-masiva.utils.d.ts +23 -0
- package/dist/zauru/bitacora-edicion-masiva.utils.js +50 -0
- package/dist/zauru/bundles.utils.d.ts +39 -0
- package/dist/zauru/bundles.utils.js +160 -0
- package/dist/zauru/cases.utils.d.ts +9 -0
- package/dist/zauru/cases.utils.js +17 -0
- package/dist/zauru/consolidated-history.utils.d.ts +24 -0
- package/dist/zauru/consolidated-history.utils.js +52 -0
- package/dist/zauru/costos-items.utils.d.ts +87 -0
- package/dist/zauru/costos-items.utils.js +601 -0
- package/dist/zauru/deliveries.utils.d.ts +17 -0
- package/dist/zauru/deliveries.utils.js +46 -0
- package/dist/zauru/discharges-histsory.utils.d.ts +24 -0
- package/dist/zauru/discharges-histsory.utils.js +46 -0
- package/dist/zauru/employees.utils.d.ts +16 -0
- package/dist/zauru/employees.utils.js +39 -0
- package/dist/zauru/form.utils.d.ts +34 -0
- package/dist/zauru/form.utils.js +152 -0
- package/dist/zauru/invoices.utils.d.ts +22 -0
- package/dist/zauru/invoices.utils.js +79 -0
- package/dist/zauru/items.utils.d.ts +52 -0
- package/dist/zauru/items.utils.js +152 -0
- package/dist/zauru/lotes.utils.d.ts +31 -0
- package/dist/zauru/lotes.utils.js +307 -0
- package/dist/zauru/motivos-rechazo.utils.d.ts +10 -0
- package/dist/zauru/motivos-rechazo.utils.js +18 -0
- package/dist/zauru/payees.utils.d.ts +42 -0
- package/dist/zauru/payees.utils.js +128 -0
- package/dist/zauru/profiles.utils.d.ts +15 -0
- package/dist/zauru/profiles.utils.js +37 -0
- package/dist/zauru/providers.utils.d.ts +13 -0
- package/dist/zauru/providers.utils.js +36 -0
- package/dist/zauru/purchase-orders.utils.d.ts +114 -0
- package/dist/zauru/purchase-orders.utils.js +376 -0
- package/dist/zauru/shipments.utils.d.ts +21 -0
- package/dist/zauru/shipments.utils.js +90 -0
- package/dist/zauru/specialItem.utils.d.ts +34 -0
- package/dist/zauru/specialItem.utils.js +62 -0
- package/dist/zauru/templates.utils.d.ts +49 -0
- package/dist/zauru/templates.utils.js +93 -0
- package/dist/zauru/tiposMuestra.utils.d.ts +34 -0
- package/dist/zauru/tiposMuestra.utils.js +62 -0
- package/dist/zauru/webapp-tables.utils.d.ts +16 -0
- package/dist/zauru/webapp-tables.utils.js +51 -0
- package/package.json +6 -6
- package/src/index.ts +23 -0
- package/src/zauru/bitacora-edicion-masiva.utils.ts +99 -0
- package/src/zauru/bundles.utils.ts +251 -0
- package/src/zauru/cases.utils.ts +31 -0
- package/src/zauru/consolidated-history.utils.ts +102 -0
- package/src/zauru/costos-items.utils.ts +865 -0
- package/src/zauru/deliveries.utils.ts +77 -0
- package/src/zauru/discharges-histsory.utils.ts +105 -0
- package/src/zauru/employees.utils.ts +59 -0
- package/src/zauru/form.utils.ts +243 -0
- package/src/zauru/invoices.utils.ts +114 -0
- package/src/zauru/items.utils.ts +269 -0
- package/src/zauru/lotes.utils.ts +411 -0
- package/src/zauru/motivos-rechazo.utils.ts +47 -0
- package/src/zauru/payees.utils.ts +213 -0
- package/src/zauru/profiles.utils.ts +44 -0
- package/src/zauru/providers.utils.ts +67 -0
- package/src/zauru/purchase-orders.utils.ts +594 -0
- package/src/zauru/shipments.utils.ts +139 -0
- package/src/zauru/specialItem.utils.ts +126 -0
- package/src/zauru/templates.utils.ts +199 -0
- package/src/zauru/tiposMuestra.utils.ts +136 -0
- package/src/zauru/webapp-tables.utils.ts +94 -0
- /package/src/{automatic-number.utils.ts → zauru/automatic-number.utils.ts} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import { createWebAppTableRegister, deleteWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister } from "@zauru-sdk/services";
|
|
3
|
+
/**
|
|
4
|
+
* Get specialItems from the web app table.
|
|
5
|
+
* @param headers Request headers.
|
|
6
|
+
* @param session Session object.
|
|
7
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<SpecialItem>[]>>.
|
|
8
|
+
*/
|
|
9
|
+
export async function getSpecialItems(headers, session) {
|
|
10
|
+
return handlePossibleAxiosErrors(async () => {
|
|
11
|
+
const { special_product_web_app_table_id } = await getVariablesByName(headers, session, ["special_product_web_app_table_id"]);
|
|
12
|
+
const response = await getWebAppTableRegisters(session, special_product_web_app_table_id);
|
|
13
|
+
if (response.error) {
|
|
14
|
+
throw new Error(`Ocurrió un error al consultar los items especiales: ${response.userMsg}`);
|
|
15
|
+
}
|
|
16
|
+
const specialItems = response.data ?? [];
|
|
17
|
+
return specialItems;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a specialItem in the web app table.
|
|
22
|
+
* @param headers Request headers.
|
|
23
|
+
* @param session Session object.
|
|
24
|
+
* @param body SpecialItem data to be created.
|
|
25
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
26
|
+
*/
|
|
27
|
+
export async function createSpecialItem(headers, session, body) {
|
|
28
|
+
return handlePossibleAxiosErrors(async () => {
|
|
29
|
+
const { special_product_web_app_table_id } = await getVariablesByName(headers, session, ["special_product_web_app_table_id"]);
|
|
30
|
+
const response = await createWebAppTableRegister(headers, special_product_web_app_table_id, body);
|
|
31
|
+
return response;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Delete a specialItem from the web app table.
|
|
36
|
+
* @param headers Request headers.
|
|
37
|
+
* @param session Session object.
|
|
38
|
+
* @param id ID of the specialItem to be deleted.
|
|
39
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
40
|
+
*/
|
|
41
|
+
export async function deleteSpecialItem(headers, session, id) {
|
|
42
|
+
return handlePossibleAxiosErrors(async () => {
|
|
43
|
+
const { special_product_web_app_table_id } = await getVariablesByName(headers, session, ["special_product_web_app_table_id"]);
|
|
44
|
+
const response = await deleteWebAppTableRegister(headers, special_product_web_app_table_id, Number(id));
|
|
45
|
+
return response;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Update a specialItem in the web app table.
|
|
50
|
+
* @param headers Request headers.
|
|
51
|
+
* @param session Session object.
|
|
52
|
+
* @param id ID of the specialItem to be updated.
|
|
53
|
+
* @param body Updated specialItem data.
|
|
54
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
55
|
+
*/
|
|
56
|
+
export async function updateSpecialItem(headers, session, id, body) {
|
|
57
|
+
return handlePossibleAxiosErrors(async () => {
|
|
58
|
+
const { special_product_web_app_table_id } = await getVariablesByName(headers, session, ["special_product_web_app_table_id"]);
|
|
59
|
+
const response = await updateWebAppTableRegister(headers, special_product_web_app_table_id, Number(id), body);
|
|
60
|
+
return response;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { AxiosUtilsResponse, WebAppRowGraphQL, Template, WebAppTableUpdateResponse, HistoryTemplate } from "@zauru-sdk/types";
|
|
3
|
+
/**
|
|
4
|
+
* Get templates from the web app table.
|
|
5
|
+
* @param headers Request headers.
|
|
6
|
+
* @param session Session object.
|
|
7
|
+
* @returns A Promise of AxiosUtilsResponse<TemplateWebAppTable[]>.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTemplates(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<Template>[]>>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a template in the web app table.
|
|
12
|
+
* @param headers Request headers.
|
|
13
|
+
* @param session Session object.
|
|
14
|
+
* @param body Template data to be created.
|
|
15
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTemplate(headers: any, session: Session, body: Template): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete a template from the web app table.
|
|
20
|
+
* @param headers Request headers.
|
|
21
|
+
* @param session Session object.
|
|
22
|
+
* @param id ID of the template to be deleted.
|
|
23
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
24
|
+
*/
|
|
25
|
+
export declare function deleteTemplate(headers: any, session: Session, id: string): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
26
|
+
/**
|
|
27
|
+
* Update a template in the web app table.
|
|
28
|
+
* @param headers Request headers.
|
|
29
|
+
* @param session Session object.
|
|
30
|
+
* @param id ID of the template to be updated.
|
|
31
|
+
* @param body Updated template data.
|
|
32
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
33
|
+
*/
|
|
34
|
+
export declare function updateTemplate(headers: any, session: Session, id: string, body: Partial<Template>): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a template history entry in the web app table.
|
|
37
|
+
* @param headers Request headers.
|
|
38
|
+
* @param session Session object.
|
|
39
|
+
* @param body Template history data to be created.
|
|
40
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createTemplateHistory(headers: any, session: Session, body: Partial<HistoryTemplate>): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
43
|
+
/**
|
|
44
|
+
* Get template history entries from the web app table.
|
|
45
|
+
* @param headers Request headers.
|
|
46
|
+
* @param session Session object.
|
|
47
|
+
* @returns A Promise of AxiosUtilsResponse<TemplateHistoryWebAppTable[]>.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getTemplatesHistory(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<HistoryTemplate>[]>>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import { createWebAppTableRegister, deleteWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
|
|
3
|
+
/**
|
|
4
|
+
* Get templates from the web app table.
|
|
5
|
+
* @param headers Request headers.
|
|
6
|
+
* @param session Session object.
|
|
7
|
+
* @returns A Promise of AxiosUtilsResponse<TemplateWebAppTable[]>.
|
|
8
|
+
*/
|
|
9
|
+
export async function getTemplates(headers, session) {
|
|
10
|
+
return handlePossibleAxiosErrors(async () => {
|
|
11
|
+
const { templates_web_app_table_id } = await getVariablesByName(headers, session, ["templates_web_app_table_id"]);
|
|
12
|
+
const response = await getWebAppTableRegisters(session, templates_web_app_table_id);
|
|
13
|
+
if (response.error) {
|
|
14
|
+
throw new Error(`Ocurrió un error al intentar obtener los templates: ${response.userMsg}`);
|
|
15
|
+
}
|
|
16
|
+
const templateRegisters = response.data ?? [];
|
|
17
|
+
return templateRegisters;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a template in the web app table.
|
|
22
|
+
* @param headers Request headers.
|
|
23
|
+
* @param session Session object.
|
|
24
|
+
* @param body Template data to be created.
|
|
25
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
26
|
+
*/
|
|
27
|
+
export async function createTemplate(headers, session, body) {
|
|
28
|
+
return handlePossibleAxiosErrors(async () => {
|
|
29
|
+
const { templates_web_app_table_id } = await getVariablesByName(headers, session, ["templates_web_app_table_id"]);
|
|
30
|
+
const response = await createWebAppTableRegister(headers, templates_web_app_table_id, body);
|
|
31
|
+
return response;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Delete a template from the web app table.
|
|
36
|
+
* @param headers Request headers.
|
|
37
|
+
* @param session Session object.
|
|
38
|
+
* @param id ID of the template to be deleted.
|
|
39
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
40
|
+
*/
|
|
41
|
+
export async function deleteTemplate(headers, session, id) {
|
|
42
|
+
return handlePossibleAxiosErrors(async () => {
|
|
43
|
+
const { templates_web_app_table_id } = await getVariablesByName(headers, session, ["templates_web_app_table_id"]);
|
|
44
|
+
const response = await deleteWebAppTableRegister(headers, templates_web_app_table_id, Number(id));
|
|
45
|
+
return response;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Update a template in the web app table.
|
|
50
|
+
* @param headers Request headers.
|
|
51
|
+
* @param session Session object.
|
|
52
|
+
* @param id ID of the template to be updated.
|
|
53
|
+
* @param body Updated template data.
|
|
54
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
55
|
+
*/
|
|
56
|
+
export async function updateTemplate(headers, session, id, body) {
|
|
57
|
+
return handlePossibleAxiosErrors(async () => {
|
|
58
|
+
const { templates_web_app_table_id } = await getVariablesByName(headers, session, ["templates_web_app_table_id"]);
|
|
59
|
+
const response = await updateWebAppTableRegister(headers, templates_web_app_table_id, Number(id), body);
|
|
60
|
+
return response;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a template history entry in the web app table.
|
|
65
|
+
* @param headers Request headers.
|
|
66
|
+
* @param session Session object.
|
|
67
|
+
* @param body Template history data to be created.
|
|
68
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
69
|
+
*/
|
|
70
|
+
export async function createTemplateHistory(headers, session, body) {
|
|
71
|
+
return handlePossibleAxiosErrors(async () => {
|
|
72
|
+
const { history_templates_web_app_table_id } = await getVariablesByName(headers, session, ["history_templates_web_app_table_id"]);
|
|
73
|
+
const response = await createWebAppTableRegister(headers, history_templates_web_app_table_id, body);
|
|
74
|
+
return response;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get template history entries from the web app table.
|
|
79
|
+
* @param headers Request headers.
|
|
80
|
+
* @param session Session object.
|
|
81
|
+
* @returns A Promise of AxiosUtilsResponse<TemplateHistoryWebAppTable[]>.
|
|
82
|
+
*/
|
|
83
|
+
export async function getTemplatesHistory(headers, session) {
|
|
84
|
+
return handlePossibleAxiosErrors(async () => {
|
|
85
|
+
const { history_templates_web_app_table_id } = await getVariablesByName(headers, session, ["history_templates_web_app_table_id"]);
|
|
86
|
+
const response = await getWebAppTableRegisters(session, history_templates_web_app_table_id);
|
|
87
|
+
if (response.error) {
|
|
88
|
+
throw new Error(`Ocurrió un error al intentar obtener los history templates: ${response.userMsg}`);
|
|
89
|
+
}
|
|
90
|
+
const templateRegisters = response.data ?? [];
|
|
91
|
+
return templateRegisters;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { WebAppRowGraphQL, TipoMuestra, AxiosUtilsResponse, WebAppTableUpdateResponse } from "@zauru-sdk/types";
|
|
3
|
+
/**
|
|
4
|
+
* Get tipoMuestras from the web app table.
|
|
5
|
+
* @param headers Request headers.
|
|
6
|
+
* @param session Session object.
|
|
7
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<TipoMuestra>[]>>.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTipoMuestras(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<TipoMuestra>[]>>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a tipoMuestra in the web app table.
|
|
12
|
+
* @param headers Request headers.
|
|
13
|
+
* @param session Session object.
|
|
14
|
+
* @param body TipoMuestra data to be created.
|
|
15
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTipoMuestra(headers: any, session: Session, body: TipoMuestra): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
18
|
+
/**
|
|
19
|
+
* Delete a tipoMuestra from the web app table.
|
|
20
|
+
* @param headers Request headers.
|
|
21
|
+
* @param session Session object.
|
|
22
|
+
* @param id ID of the tipoMuestra to be deleted.
|
|
23
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
24
|
+
*/
|
|
25
|
+
export declare function deleteTipoMuestra(headers: any, session: Session, id: string): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
26
|
+
/**
|
|
27
|
+
* Update a tipoMuestra in the web app table.
|
|
28
|
+
* @param headers Request headers.
|
|
29
|
+
* @param session Session object.
|
|
30
|
+
* @param id ID of the tipoMuestra to be updated.
|
|
31
|
+
* @param body Updated tipoMuestra data.
|
|
32
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
33
|
+
*/
|
|
34
|
+
export declare function updateTipoMuestra(headers: any, session: Session, id: string, body: Partial<TipoMuestra>): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import { createWebAppTableRegister, deleteWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister, } from "@zauru-sdk/services";
|
|
3
|
+
/**
|
|
4
|
+
* Get tipoMuestras from the web app table.
|
|
5
|
+
* @param headers Request headers.
|
|
6
|
+
* @param session Session object.
|
|
7
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<TipoMuestra>[]>>.
|
|
8
|
+
*/
|
|
9
|
+
export async function getTipoMuestras(headers, session) {
|
|
10
|
+
return handlePossibleAxiosErrors(async () => {
|
|
11
|
+
const { tipo_muestra_web_app_table_id } = await getVariablesByName(headers, session, ["tipo_muestra_web_app_table_id"]);
|
|
12
|
+
const response = await getWebAppTableRegisters(session, tipo_muestra_web_app_table_id);
|
|
13
|
+
if (response.error) {
|
|
14
|
+
throw new Error(`Ocurrió un error al consultar los tipos de muestra: ${response.userMsg}`);
|
|
15
|
+
}
|
|
16
|
+
const tipoMuestras = response.data ?? [];
|
|
17
|
+
return tipoMuestras;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a tipoMuestra in the web app table.
|
|
22
|
+
* @param headers Request headers.
|
|
23
|
+
* @param session Session object.
|
|
24
|
+
* @param body TipoMuestra data to be created.
|
|
25
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
26
|
+
*/
|
|
27
|
+
export async function createTipoMuestra(headers, session, body) {
|
|
28
|
+
return handlePossibleAxiosErrors(async () => {
|
|
29
|
+
const { tipo_muestra_web_app_table_id } = await getVariablesByName(headers, session, ["tipo_muestra_web_app_table_id"]);
|
|
30
|
+
const response = await createWebAppTableRegister(headers, tipo_muestra_web_app_table_id, body);
|
|
31
|
+
return response;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Delete a tipoMuestra from the web app table.
|
|
36
|
+
* @param headers Request headers.
|
|
37
|
+
* @param session Session object.
|
|
38
|
+
* @param id ID of the tipoMuestra to be deleted.
|
|
39
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
40
|
+
*/
|
|
41
|
+
export async function deleteTipoMuestra(headers, session, id) {
|
|
42
|
+
return handlePossibleAxiosErrors(async () => {
|
|
43
|
+
const { tipo_muestra_web_app_table_id } = await getVariablesByName(headers, session, ["tipo_muestra_web_app_table_id"]);
|
|
44
|
+
const response = await deleteWebAppTableRegister(headers, tipo_muestra_web_app_table_id, Number(id));
|
|
45
|
+
return response;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Update a tipoMuestra in the web app table.
|
|
50
|
+
* @param headers Request headers.
|
|
51
|
+
* @param session Session object.
|
|
52
|
+
* @param id ID of the tipoMuestra to be updated.
|
|
53
|
+
* @param body Updated tipoMuestra data.
|
|
54
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
|
|
55
|
+
*/
|
|
56
|
+
export async function updateTipoMuestra(headers, session, id, body) {
|
|
57
|
+
return handlePossibleAxiosErrors(async () => {
|
|
58
|
+
const { tipo_muestra_web_app_table_id } = await getVariablesByName(headers, session, ["tipo_muestra_web_app_table_id"]);
|
|
59
|
+
const response = await updateWebAppTableRegister(headers, tipo_muestra_web_app_table_id, Number(id), body);
|
|
60
|
+
return response;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { AxiosUtilsResponse, RejectionWebAppTableObject, WebAppRowGraphQL, ReceptionType } from "@zauru-sdk/types";
|
|
3
|
+
/**
|
|
4
|
+
* getWebappTable
|
|
5
|
+
* @param headers
|
|
6
|
+
* @param session
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const getRejectionWebAppTable: (headers: any, session: Session) => Promise<AxiosUtilsResponse<RejectionWebAppTableObject>>;
|
|
10
|
+
/**
|
|
11
|
+
* Get template history entries from the web app table.
|
|
12
|
+
* @param headers Request headers.
|
|
13
|
+
* @param session Session object.
|
|
14
|
+
* @returns A Promise of AxiosUtilsResponse<ReceptionType[]>.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getReceptionTypes(headers: any, session: Session): Promise<AxiosUtilsResponse<WebAppRowGraphQL<ReceptionType>[]>>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
2
|
+
import { getVariablesByName, getWebAppTableRegisters, } from "@zauru-sdk/services";
|
|
3
|
+
import httpZauru from "@zauru-sdk/services/dist/zauru/httpZauru.server.js";
|
|
4
|
+
/**
|
|
5
|
+
* getWebappTable
|
|
6
|
+
* @param headers
|
|
7
|
+
* @param session
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export const getRejectionWebAppTable = async (headers, session) => {
|
|
11
|
+
return handlePossibleAxiosErrors(async () => {
|
|
12
|
+
const { recepciones_rejections_webapp_table_id, recepciones_rejection_types_webapp_table_id, } = await getVariablesByName(headers, session, [
|
|
13
|
+
"recepciones_rejections_webapp_table_id",
|
|
14
|
+
"recepciones_rejection_types_webapp_table_id",
|
|
15
|
+
]);
|
|
16
|
+
const webappTableResponse = await httpZauru.get(`/apps/webapp_tables/${recepciones_rejections_webapp_table_id}.json`, { headers });
|
|
17
|
+
const webappTableRejectionsResponse = await httpZauru.get(`/apps/webapp_tables/${recepciones_rejection_types_webapp_table_id}/webapp_rows.json`, { headers });
|
|
18
|
+
const rejections_select = [];
|
|
19
|
+
const rejections_complete = webappTableRejectionsResponse.data;
|
|
20
|
+
const keyName = Object.keys(rejections_complete[0].data)[0]; //get the first value
|
|
21
|
+
const rejections_list = [];
|
|
22
|
+
rejections_complete.forEach((val) => {
|
|
23
|
+
rejections_list.push(val.data[keyName]);
|
|
24
|
+
});
|
|
25
|
+
rejections_complete.forEach((rc) => {
|
|
26
|
+
rejections_select.push({
|
|
27
|
+
value: rc.data[keyName],
|
|
28
|
+
label: rc.data[keyName],
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
webapp_table: webappTableResponse.data.structure,
|
|
33
|
+
rejection_list: rejections_list,
|
|
34
|
+
rejection_select: rejections_select,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get template history entries from the web app table.
|
|
40
|
+
* @param headers Request headers.
|
|
41
|
+
* @param session Session object.
|
|
42
|
+
* @returns A Promise of AxiosUtilsResponse<ReceptionType[]>.
|
|
43
|
+
*/
|
|
44
|
+
export async function getReceptionTypes(headers, session) {
|
|
45
|
+
return handlePossibleAxiosErrors(async () => {
|
|
46
|
+
const { recepciones_receptions_type_table_id } = await getVariablesByName(headers, session, ["recepciones_receptions_type_table_id"]);
|
|
47
|
+
const response = await getWebAppTableRegisters(session, recepciones_receptions_type_table_id);
|
|
48
|
+
const receptionTypes = response?.data ?? [];
|
|
49
|
+
return receptionTypes;
|
|
50
|
+
});
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Utilidades, parseo de request y demás para desarrollo de webapps de Zauru",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@remix-run/node": "^2.8.1",
|
|
22
|
-
"@zauru-sdk/common": "^1.0.
|
|
22
|
+
"@zauru-sdk/common": "^1.0.8",
|
|
23
23
|
"@zauru-sdk/config": "^1.0.4",
|
|
24
|
-
"@zauru-sdk/graphql": "^1.0.
|
|
25
|
-
"@zauru-sdk/services": "^1.0.
|
|
26
|
-
"@zauru-sdk/types": "^1.0.
|
|
24
|
+
"@zauru-sdk/graphql": "^1.0.9",
|
|
25
|
+
"@zauru-sdk/services": "^1.0.9",
|
|
26
|
+
"@zauru-sdk/types": "^1.0.8"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=18.0.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "d5b8e3d9b606d6e275135e4624a27f44d9da7caf"
|
|
32
32
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from "./zauru/automatic-number.utils.js";
|
|
2
|
+
export * from "./zauru/bitacora-edicion-masiva.utils.js";
|
|
3
|
+
export * from "./zauru/bundles.utils.js";
|
|
4
|
+
export * from "./zauru/cases.utils.js";
|
|
5
|
+
export * from "./zauru/consolidated-history.utils.js";
|
|
6
|
+
export * from "./zauru/costos-items.utils.js";
|
|
7
|
+
export * from "./zauru/deliveries.utils.js";
|
|
8
|
+
export * from "./zauru/discharges-histsory.utils.js";
|
|
9
|
+
export * from "./zauru/employees.utils.js";
|
|
10
|
+
export * from "./zauru/form.utils.js";
|
|
11
|
+
export * from "./zauru/invoices.utils.js";
|
|
12
|
+
export * from "./zauru/items.utils.js";
|
|
13
|
+
export * from "./zauru/lotes.utils.js";
|
|
14
|
+
export * from "./zauru/motivos-rechazo.utils.js";
|
|
15
|
+
export * from "./zauru/payees.utils.js";
|
|
16
|
+
export * from "./zauru/profiles.utils.js";
|
|
17
|
+
export * from "./zauru/providers.utils.js";
|
|
18
|
+
export * from "./zauru/purchase-orders.utils.js";
|
|
19
|
+
export * from "./zauru/shipments.utils.js";
|
|
20
|
+
export * from "./zauru/specialItem.utils.js";
|
|
21
|
+
export * from "./zauru/templates.utils.js";
|
|
22
|
+
export * from "./zauru/tiposMuestra.utils.js";
|
|
23
|
+
export * from "./zauru/webapp-tables.utils.js";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Session } from "@remix-run/node";
|
|
2
|
+
import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
3
|
+
import {
|
|
4
|
+
createWebAppTableRegister,
|
|
5
|
+
getVariablesByName,
|
|
6
|
+
getWebAppTableRegisters,
|
|
7
|
+
updateWebAppTableRegister,
|
|
8
|
+
} from "@zauru-sdk/services";
|
|
9
|
+
import {
|
|
10
|
+
AxiosUtilsResponse,
|
|
11
|
+
WebAppTableUpdateResponse,
|
|
12
|
+
BitacoraPOMassive,
|
|
13
|
+
WebAppRowGraphQL,
|
|
14
|
+
} from "@zauru-sdk/types";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get saveBitacoraPOMassive from the web app table.
|
|
18
|
+
* @param headers Request headers.
|
|
19
|
+
* @param session Session object.
|
|
20
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
|
|
21
|
+
*/
|
|
22
|
+
export async function saveBitacoraPOMassive(
|
|
23
|
+
headers: any,
|
|
24
|
+
session: Session,
|
|
25
|
+
body: BitacoraPOMassive
|
|
26
|
+
): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
|
|
27
|
+
return handlePossibleAxiosErrors(async () => {
|
|
28
|
+
const { bitacora_ediciones_masivas_web_app_table_id } =
|
|
29
|
+
await getVariablesByName(headers, session, [
|
|
30
|
+
"bitacora_ediciones_masivas_web_app_table_id",
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const response = await createWebAppTableRegister<BitacoraPOMassive>(
|
|
34
|
+
headers,
|
|
35
|
+
bitacora_ediciones_masivas_web_app_table_id,
|
|
36
|
+
{ ...body, modificadoPor: session.get("name") }
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return response;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get getBitacorasPOMassive from the web app table.
|
|
45
|
+
* @param headers Request headers.
|
|
46
|
+
* @param session Session object.
|
|
47
|
+
* @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>.
|
|
48
|
+
*/
|
|
49
|
+
export async function getBitacorasPOMassive(
|
|
50
|
+
headers: any,
|
|
51
|
+
session: Session
|
|
52
|
+
): Promise<AxiosUtilsResponse<WebAppRowGraphQL<BitacoraPOMassive>[]>> {
|
|
53
|
+
return handlePossibleAxiosErrors(async () => {
|
|
54
|
+
const { bitacora_ediciones_masivas_web_app_table_id } =
|
|
55
|
+
await getVariablesByName(headers, session, [
|
|
56
|
+
"bitacora_ediciones_masivas_web_app_table_id",
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
const response = await getWebAppTableRegisters<BitacoraPOMassive>(
|
|
60
|
+
session,
|
|
61
|
+
bitacora_ediciones_masivas_web_app_table_id
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (response.error || !response.data) {
|
|
65
|
+
throw new Error(response.userMsg);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return response.data;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Put updateBitacorasPOMassive from the web app table.
|
|
74
|
+
* @param headers Request headers.
|
|
75
|
+
* @param session Session object.
|
|
76
|
+
* @returns A Promise of AxiosUtilsResponse<BitacorasPOMassiveWebAppTable[]>.
|
|
77
|
+
*/
|
|
78
|
+
export async function updateBitacorasPOMassive(
|
|
79
|
+
headers: any,
|
|
80
|
+
session: Session,
|
|
81
|
+
body: BitacoraPOMassive,
|
|
82
|
+
id_registro: string | number
|
|
83
|
+
): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
|
|
84
|
+
return handlePossibleAxiosErrors(async () => {
|
|
85
|
+
const { bitacora_ediciones_masivas_web_app_table_id } =
|
|
86
|
+
await getVariablesByName(headers, session, [
|
|
87
|
+
"bitacora_ediciones_masivas_web_app_table_id",
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
const response = await updateWebAppTableRegister<BitacoraPOMassive>(
|
|
91
|
+
headers,
|
|
92
|
+
bitacora_ediciones_masivas_web_app_table_id,
|
|
93
|
+
id_registro,
|
|
94
|
+
{ ...body, modificadoPor: session.get("name") }
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return response;
|
|
98
|
+
});
|
|
99
|
+
}
|