@zauru-sdk/utils 1.0.17 → 1.0.20

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/zauru/bitacora-edicion-masiva.utils.d.ts +3 -3
  3. package/dist/zauru/bitacora-edicion-masiva.utils.js +6 -6
  4. package/dist/zauru/consolidated-history.utils.d.ts +3 -3
  5. package/dist/zauru/consolidated-history.utils.js +6 -6
  6. package/dist/zauru/costos-items.utils.d.ts +9 -9
  7. package/dist/zauru/costos-items.utils.js +17 -17
  8. package/dist/zauru/discharges-histsory.utils.d.ts +3 -3
  9. package/dist/zauru/discharges-histsory.utils.js +6 -6
  10. package/dist/zauru/items.utils.d.ts +4 -10
  11. package/dist/zauru/items.utils.js +7 -42
  12. package/dist/zauru/motivos-rechazo.utils.d.ts +2 -2
  13. package/dist/zauru/motivos-rechazo.utils.js +4 -4
  14. package/dist/zauru/payees.utils.d.ts +5 -5
  15. package/dist/zauru/payees.utils.js +10 -10
  16. package/dist/zauru/specialItem.utils.d.ts +4 -4
  17. package/dist/zauru/specialItem.utils.js +9 -9
  18. package/dist/zauru/templates.utils.d.ts +6 -6
  19. package/dist/zauru/templates.utils.js +12 -12
  20. package/dist/zauru/tiposMuestra.utils.d.ts +4 -4
  21. package/dist/zauru/tiposMuestra.utils.js +8 -8
  22. package/dist/zauru/webapp-tables.utils.d.ts +2 -9
  23. package/dist/zauru/webapp-tables.utils.js +2 -37
  24. package/package.json +3 -3
  25. package/src/zauru/bitacora-edicion-masiva.utils.ts +9 -9
  26. package/src/zauru/consolidated-history.utils.ts +9 -9
  27. package/src/zauru/costos-items.utils.ts +31 -25
  28. package/src/zauru/discharges-histsory.utils.ts +9 -9
  29. package/src/zauru/items.utils.ts +9 -57
  30. package/src/zauru/motivos-rechazo.utils.ts +6 -6
  31. package/src/zauru/payees.utils.ts +15 -15
  32. package/src/zauru/specialItem.utils.ts +25 -15
  33. package/src/zauru/templates.utils.ts +18 -18
  34. package/src/zauru/tiposMuestra.utils.ts +12 -12
  35. package/src/zauru/webapp-tables.utils.ts +3 -61
@@ -1,8 +1,18 @@
1
1
  import type { Session } from "@remix-run/node";
2
2
  import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
- import { createWebAppTableRegister, deleteWebAppTableRegister, getVariablesByName, getWebAppTableRegisters, updateWebAppTableRegister } from "@zauru-sdk/services";
4
- import { AxiosUtilsResponse, SpecialItem, WebAppRowGraphQL, WebAppTableUpdateResponse } from "@zauru-sdk/types";
5
-
3
+ import {
4
+ createWebAppTableRegister,
5
+ deleteWebAppTableRegister,
6
+ getVariablesByName,
7
+ getWebAppTableRegisters,
8
+ updateWebAppTableRegister,
9
+ } from "@zauru-sdk/services";
10
+ import {
11
+ AxiosUtilsResponse,
12
+ SpecialItem,
13
+ WebAppRowGraphQL,
14
+ WebAppTableUpdateResponse,
15
+ } from "@zauru-sdk/types";
6
16
 
7
17
  /**
8
18
  * Get specialItems from the web app table.
@@ -10,10 +20,10 @@ import { AxiosUtilsResponse, SpecialItem, WebAppRowGraphQL, WebAppTableUpdateRes
10
20
  * @param session Session object.
11
21
  * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<SpecialItem>[]>>.
12
22
  */
13
- export async function getSpecialItems(
23
+ export const getSpecialItems = (
14
24
  headers: any,
15
25
  session: Session
16
- ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<SpecialItem>[]>> {
26
+ ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<SpecialItem>[]>> => {
17
27
  return handlePossibleAxiosErrors(async () => {
18
28
  const { special_product_web_app_table_id } = await getVariablesByName(
19
29
  headers,
@@ -36,7 +46,7 @@ export async function getSpecialItems(
36
46
 
37
47
  return specialItems;
38
48
  });
39
- }
49
+ };
40
50
 
41
51
  /**
42
52
  * Create a specialItem in the web app table.
@@ -45,11 +55,11 @@ export async function getSpecialItems(
45
55
  * @param body SpecialItem data to be created.
46
56
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
47
57
  */
48
- export async function createSpecialItem(
58
+ export const createSpecialItem = (
49
59
  headers: any,
50
60
  session: Session,
51
61
  body: SpecialItem
52
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
62
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
53
63
  return handlePossibleAxiosErrors(async () => {
54
64
  const { special_product_web_app_table_id } = await getVariablesByName(
55
65
  headers,
@@ -63,7 +73,7 @@ export async function createSpecialItem(
63
73
  );
64
74
  return response;
65
75
  });
66
- }
76
+ };
67
77
 
68
78
  /**
69
79
  * Delete a specialItem from the web app table.
@@ -72,11 +82,11 @@ export async function createSpecialItem(
72
82
  * @param id ID of the specialItem to be deleted.
73
83
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
74
84
  */
75
- export async function deleteSpecialItem(
85
+ export const deleteSpecialItem = (
76
86
  headers: any,
77
87
  session: Session,
78
88
  id: string
79
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
89
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
80
90
  return handlePossibleAxiosErrors(async () => {
81
91
  const { special_product_web_app_table_id } = await getVariablesByName(
82
92
  headers,
@@ -91,7 +101,7 @@ export async function deleteSpecialItem(
91
101
  );
92
102
  return response;
93
103
  });
94
- }
104
+ };
95
105
 
96
106
  /**
97
107
  * Update a specialItem in the web app table.
@@ -101,12 +111,12 @@ export async function deleteSpecialItem(
101
111
  * @param body Updated specialItem data.
102
112
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
103
113
  */
104
- export async function updateSpecialItem(
114
+ export const updateSpecialItem = (
105
115
  headers: any,
106
116
  session: Session,
107
117
  id: string,
108
118
  body: Partial<SpecialItem>
109
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
119
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
110
120
  return handlePossibleAxiosErrors(async () => {
111
121
  const { special_product_web_app_table_id } = await getVariablesByName(
112
122
  headers,
@@ -123,4 +133,4 @@ export async function updateSpecialItem(
123
133
 
124
134
  return response;
125
135
  });
126
- }
136
+ };
@@ -21,10 +21,10 @@ import {
21
21
  * @param session Session object.
22
22
  * @returns A Promise of AxiosUtilsResponse<TemplateWebAppTable[]>.
23
23
  */
24
- export async function getTemplates(
24
+ export const getTemplates = (
25
25
  headers: any,
26
26
  session: Session
27
- ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<Template>[]>> {
27
+ ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<Template>[]>> => {
28
28
  return handlePossibleAxiosErrors(async () => {
29
29
  const { templates_web_app_table_id } = await getVariablesByName(
30
30
  headers,
@@ -47,7 +47,7 @@ export async function getTemplates(
47
47
 
48
48
  return templateRegisters;
49
49
  });
50
- }
50
+ };
51
51
 
52
52
  /**
53
53
  * Create a template in the web app table.
@@ -56,11 +56,11 @@ export async function getTemplates(
56
56
  * @param body Template data to be created.
57
57
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
58
58
  */
59
- export async function createTemplate(
59
+ export const createTemplate = (
60
60
  headers: any,
61
61
  session: Session,
62
62
  body: Template
63
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
63
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
64
64
  return handlePossibleAxiosErrors(async () => {
65
65
  const { templates_web_app_table_id } = await getVariablesByName(
66
66
  headers,
@@ -74,7 +74,7 @@ export async function createTemplate(
74
74
  );
75
75
  return response;
76
76
  });
77
- }
77
+ };
78
78
 
79
79
  /**
80
80
  * Delete a template from the web app table.
@@ -83,11 +83,11 @@ export async function createTemplate(
83
83
  * @param id ID of the template to be deleted.
84
84
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
85
85
  */
86
- export async function deleteTemplate(
86
+ export const deleteTemplate = (
87
87
  headers: any,
88
88
  session: Session,
89
89
  id: string
90
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
90
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
91
91
  return handlePossibleAxiosErrors(async () => {
92
92
  const { templates_web_app_table_id } = await getVariablesByName(
93
93
  headers,
@@ -102,7 +102,7 @@ export async function deleteTemplate(
102
102
  );
103
103
  return response;
104
104
  });
105
- }
105
+ };
106
106
 
107
107
  /**
108
108
  * Update a template in the web app table.
@@ -112,12 +112,12 @@ export async function deleteTemplate(
112
112
  * @param body Updated template data.
113
113
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
114
114
  */
115
- export async function updateTemplate(
115
+ export const updateTemplate = (
116
116
  headers: any,
117
117
  session: Session,
118
118
  id: string,
119
119
  body: Partial<Template>
120
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
120
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
121
121
  return handlePossibleAxiosErrors(async () => {
122
122
  const { templates_web_app_table_id } = await getVariablesByName(
123
123
  headers,
@@ -134,7 +134,7 @@ export async function updateTemplate(
134
134
 
135
135
  return response;
136
136
  });
137
- }
137
+ };
138
138
 
139
139
  /**
140
140
  * Create a template history entry in the web app table.
@@ -143,11 +143,11 @@ export async function updateTemplate(
143
143
  * @param body Template history data to be created.
144
144
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
145
145
  */
146
- export async function createTemplateHistory(
146
+ export const createTemplateHistory = (
147
147
  headers: any,
148
148
  session: Session,
149
149
  body: Partial<HistoryTemplate>
150
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
150
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
151
151
  return handlePossibleAxiosErrors(async () => {
152
152
  const { history_templates_web_app_table_id } = await getVariablesByName(
153
153
  headers,
@@ -163,7 +163,7 @@ export async function createTemplateHistory(
163
163
 
164
164
  return response;
165
165
  });
166
- }
166
+ };
167
167
 
168
168
  /**
169
169
  * Get template history entries from the web app table.
@@ -171,10 +171,10 @@ export async function createTemplateHistory(
171
171
  * @param session Session object.
172
172
  * @returns A Promise of AxiosUtilsResponse<TemplateHistoryWebAppTable[]>.
173
173
  */
174
- export async function getTemplatesHistory(
174
+ export const getTemplatesHistory = (
175
175
  headers: any,
176
176
  session: Session
177
- ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<HistoryTemplate>[]>> {
177
+ ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<HistoryTemplate>[]>> => {
178
178
  return handlePossibleAxiosErrors(async () => {
179
179
  const { history_templates_web_app_table_id } = await getVariablesByName(
180
180
  headers,
@@ -196,4 +196,4 @@ export async function getTemplatesHistory(
196
196
 
197
197
  return templateRegisters;
198
198
  });
199
- }
199
+ };
@@ -20,10 +20,10 @@ import {
20
20
  * @param session Session object.
21
21
  * @returns A Promise of AxiosUtilsResponse<WebAppRowGraphQL<TipoMuestra>[]>>.
22
22
  */
23
- export async function getTipoMuestras(
23
+ export const getTipoMuestras = (
24
24
  headers: any,
25
25
  session: Session
26
- ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<TipoMuestra>[]>> {
26
+ ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<TipoMuestra>[]>> => {
27
27
  return handlePossibleAxiosErrors(async () => {
28
28
  const { tipo_muestra_web_app_table_id } = await getVariablesByName(
29
29
  headers,
@@ -46,7 +46,7 @@ export async function getTipoMuestras(
46
46
 
47
47
  return tipoMuestras;
48
48
  });
49
- }
49
+ };
50
50
 
51
51
  /**
52
52
  * Create a tipoMuestra in the web app table.
@@ -55,11 +55,11 @@ export async function getTipoMuestras(
55
55
  * @param body TipoMuestra data to be created.
56
56
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
57
57
  */
58
- export async function createTipoMuestra(
58
+ export const createTipoMuestra = (
59
59
  headers: any,
60
60
  session: Session,
61
61
  body: TipoMuestra
62
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
62
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
63
63
  return handlePossibleAxiosErrors(async () => {
64
64
  const { tipo_muestra_web_app_table_id } = await getVariablesByName(
65
65
  headers,
@@ -73,7 +73,7 @@ export async function createTipoMuestra(
73
73
  );
74
74
  return response;
75
75
  });
76
- }
76
+ };
77
77
 
78
78
  /**
79
79
  * Delete a tipoMuestra from the web app table.
@@ -82,11 +82,11 @@ export async function createTipoMuestra(
82
82
  * @param id ID of the tipoMuestra to be deleted.
83
83
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
84
84
  */
85
- export async function deleteTipoMuestra(
85
+ export const deleteTipoMuestra = (
86
86
  headers: any,
87
87
  session: Session,
88
88
  id: string
89
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
89
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
90
90
  return handlePossibleAxiosErrors(async () => {
91
91
  const { tipo_muestra_web_app_table_id } = await getVariablesByName(
92
92
  headers,
@@ -101,7 +101,7 @@ export async function deleteTipoMuestra(
101
101
  );
102
102
  return response;
103
103
  });
104
- }
104
+ };
105
105
 
106
106
  /**
107
107
  * Update a tipoMuestra in the web app table.
@@ -111,12 +111,12 @@ export async function deleteTipoMuestra(
111
111
  * @param body Updated tipoMuestra data.
112
112
  * @returns A Promise of AxiosUtilsResponse<WebAppTableUpdateResponse>.
113
113
  */
114
- export async function updateTipoMuestra(
114
+ export const updateTipoMuestra = (
115
115
  headers: any,
116
116
  session: Session,
117
117
  id: string,
118
118
  body: Partial<TipoMuestra>
119
- ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> {
119
+ ): Promise<AxiosUtilsResponse<WebAppTableUpdateResponse>> => {
120
120
  return handlePossibleAxiosErrors(async () => {
121
121
  const { tipo_muestra_web_app_table_id } = await getVariablesByName(
122
122
  headers,
@@ -133,4 +133,4 @@ export async function updateTipoMuestra(
133
133
 
134
134
  return response;
135
135
  });
136
- }
136
+ };
@@ -4,80 +4,22 @@ import {
4
4
  getVariablesByName,
5
5
  getWebAppTableRegisters,
6
6
  } from "@zauru-sdk/services";
7
- import httpZauru from "@zauru-sdk/services/dist/zauru/httpZauru.server.js";
8
7
  import {
9
8
  AxiosUtilsResponse,
10
- MotivoRechazo,
11
- RejectionWebAppTableObject,
12
9
  WebAppRowGraphQL,
13
10
  ReceptionType,
14
- WebAppTableGraphQL,
15
11
  } from "@zauru-sdk/types";
16
12
 
17
- /**
18
- * getWebappTable
19
- * @param headers
20
- * @param session
21
- * @returns
22
- */
23
- export const getRejectionWebAppTable = async (
24
- headers: any,
25
- session: Session
26
- ): Promise<AxiosUtilsResponse<RejectionWebAppTableObject>> => {
27
- return handlePossibleAxiosErrors(async () => {
28
- const {
29
- recepciones_rejections_webapp_table_id,
30
- recepciones_rejection_types_webapp_table_id,
31
- } = await getVariablesByName(headers, session, [
32
- "recepciones_rejections_webapp_table_id",
33
- "recepciones_rejection_types_webapp_table_id",
34
- ]);
35
-
36
- const webappTableResponse = await httpZauru.get<WebAppTableGraphQL>(
37
- `/apps/webapp_tables/${recepciones_rejections_webapp_table_id}.json`,
38
- { headers }
39
- );
40
-
41
- const webappTableRejectionsResponse = await httpZauru.get<
42
- WebAppRowGraphQL<MotivoRechazo>[]
43
- >(
44
- `/apps/webapp_tables/${recepciones_rejection_types_webapp_table_id}/webapp_rows.json`,
45
- { headers }
46
- );
47
-
48
- const rejections_select: { value: string; label: string }[] = [];
49
- const rejections_complete = webappTableRejectionsResponse.data;
50
- const keyName: string = Object.keys(rejections_complete[0].data)[0]; //get the first value
51
- const rejections_list: string[] = [];
52
- rejections_complete.forEach((val: any) => {
53
- rejections_list.push(val.data[keyName]);
54
- });
55
-
56
- rejections_complete.forEach((rc: any) => {
57
- rejections_select.push({
58
- value: rc.data[keyName],
59
- label: rc.data[keyName],
60
- });
61
- });
62
-
63
- return {
64
- webapp_table: webappTableResponse.data.structure,
65
- rejection_list: rejections_list,
66
- rejection_select: rejections_select,
67
- } as RejectionWebAppTableObject;
68
- });
69
- };
70
-
71
13
  /**
72
14
  * Get template history entries from the web app table.
73
15
  * @param headers Request headers.
74
16
  * @param session Session object.
75
17
  * @returns A Promise of AxiosUtilsResponse<ReceptionType[]>.
76
18
  */
77
- export async function getReceptionTypes(
19
+ export const getReceptionTypes = (
78
20
  headers: any,
79
21
  session: Session
80
- ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<ReceptionType>[]>> {
22
+ ): Promise<AxiosUtilsResponse<WebAppRowGraphQL<ReceptionType>[]>> => {
81
23
  return handlePossibleAxiosErrors(async () => {
82
24
  const { recepciones_receptions_type_table_id } = await getVariablesByName(
83
25
  headers,
@@ -91,4 +33,4 @@ export async function getReceptionTypes(
91
33
  const receptionTypes = response?.data ?? [];
92
34
  return receptionTypes;
93
35
  });
94
- }
36
+ };