@zauru-sdk/utils 1.0.18 → 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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.20](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.19...v1.0.20) (2024-03-22)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/utils
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.0.18](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.17...v1.0.18) (2024-03-22)
7
15
 
8
16
  **Note:** Version bump only for package @zauru-sdk/utils
@@ -1,5 +1,5 @@
1
1
  import type { Session } from "@remix-run/node";
2
- import { AxiosUtilsResponse, ItemGraphQL, SearchItemParams, ItemDataTable, ItemCategoryGraphQL } from "@zauru-sdk/types";
2
+ import { AxiosUtilsResponse, ItemGraphQL, ItemCategoryGraphQL } from "@zauru-sdk/types";
3
3
  /**
4
4
  *
5
5
  * @param headers
@@ -21,12 +21,6 @@ export declare const getItemsByLabCategory: (headers: any, session: Session) =>
21
21
  * @returns
22
22
  */
23
23
  export declare const getItemServicesByLabCategory: (headers: any, session: Session) => Promise<AxiosUtilsResponse<ItemGraphQL[]>>;
24
- /**
25
- *
26
- * @param headers
27
- * @returns
28
- */
29
- export declare const getItemsDataTable: (headers: any, search: SearchItemParams) => Promise<AxiosUtilsResponse<ItemDataTable[]>>;
30
24
  /**
31
25
  * getLabItemCategories
32
26
  * @param session
@@ -1,6 +1,5 @@
1
- import { extractValueBetweenTags, handlePossibleAxiosErrors, } from "@zauru-sdk/common";
1
+ import { handlePossibleAxiosErrors, } from "@zauru-sdk/common";
2
2
  import { createItem, createItemCategory, getItemCategoriesBySuperCategoryId, getItemsByCategoryId, getItemsBySuperCategoryId, getVariablesByName, } from "@zauru-sdk/services";
3
- import httpZauru from "@zauru-sdk/services/dist/zauru/httpZauru.server.js";
4
3
  /**
5
4
  *
6
5
  * @param headers
@@ -52,40 +51,6 @@ export const getItemServicesByLabCategory = async (headers, session) => {
52
51
  return response?.data ?? [];
53
52
  });
54
53
  };
55
- /**
56
- *
57
- * @param headers
58
- * @returns
59
- */
60
- export const getItemsDataTable = async (headers, search) => {
61
- return handlePossibleAxiosErrors(async () => {
62
- const response = await httpZauru.post(`/settings/items/datatables.json`, search, { headers });
63
- const items = response.data?.data?.map((x) => formatHTMLItemList(x)) ?? [];
64
- return items;
65
- });
66
- };
67
- //============================ FORMATEADO DE ITEMS
68
- function extractIdFromURL(input) {
69
- const regex = /\/items\/(\d+)/;
70
- const match = input.match(regex);
71
- return match ? parseInt(match[1], 10) : -1;
72
- }
73
- function formatHTMLItemList(item) {
74
- return {
75
- zid: parseInt(extractValueBetweenTags(item.zid, "a"), 10),
76
- itemId: extractIdFromURL(item.cod),
77
- name: extractValueBetweenTags(item.name, "a"),
78
- stck: extractValueBetweenTags(item.stck, "i") || null,
79
- act: extractValueBetweenTags(item.act, "i") || null,
80
- sell: extractValueBetweenTags(item.sell, "i") || null,
81
- purch: extractValueBetweenTags(item.purch, "i") || null,
82
- vat: extractValueBetweenTags(item.vat, "i") || null,
83
- cat: item.cat,
84
- warr: item.warr,
85
- cat_note: item.cat_note,
86
- DT_RowId: parseInt(item.DT_RowId.replace("settings-item-", ""), 10),
87
- };
88
- }
89
54
  /**
90
55
  * getLabItemCategories
91
56
  * @param session
@@ -1,12 +1,5 @@
1
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>>;
2
+ import { AxiosUtilsResponse, WebAppRowGraphQL, ReceptionType } from "@zauru-sdk/types";
10
3
  /**
11
4
  * Get template history entries from the web app table.
12
5
  * @param headers Request headers.
@@ -1,40 +1,5 @@
1
1
  import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
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
3
  /**
39
4
  * Get template history entries from the web app table.
40
5
  * @param headers Request headers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/utils",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
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",
@@ -22,11 +22,11 @@
22
22
  "@zauru-sdk/common": "^1.0.13",
23
23
  "@zauru-sdk/config": "^1.0.4",
24
24
  "@zauru-sdk/graphql": "^1.0.9",
25
- "@zauru-sdk/services": "^1.0.18",
25
+ "@zauru-sdk/services": "^1.0.20",
26
26
  "@zauru-sdk/types": "^1.0.13"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=18.0.0"
30
30
  },
31
- "gitHead": "bcd403ed2996283a6eed13ce56cc24b2ee824369"
31
+ "gitHead": "84391740f5024f39c8795e006bdb676d6808ed56"
32
32
  }
@@ -11,7 +11,6 @@ import {
11
11
  getItemsBySuperCategoryId,
12
12
  getVariablesByName,
13
13
  } from "@zauru-sdk/services";
14
- import httpZauru from "@zauru-sdk/services/dist/zauru/httpZauru.server.js";
15
14
  import {
16
15
  AxiosUtilsResponse,
17
16
  ItemGraphQL,
@@ -119,53 +118,6 @@ export const getItemServicesByLabCategory = async (
119
118
  });
120
119
  };
121
120
 
122
- /**
123
- *
124
- * @param headers
125
- * @returns
126
- */
127
- export const getItemsDataTable = async (
128
- headers: any,
129
- search: SearchItemParams
130
- ): Promise<AxiosUtilsResponse<ItemDataTable[]>> => {
131
- return handlePossibleAxiosErrors(async () => {
132
- const response = await httpZauru.post<ResponseItemList>(
133
- `/settings/items/datatables.json`,
134
- search,
135
- { headers }
136
- );
137
-
138
- const items: ItemDataTable[] =
139
- response.data?.data?.map((x) => formatHTMLItemList(x)) ?? [];
140
-
141
- return items;
142
- });
143
- };
144
-
145
- //============================ FORMATEADO DE ITEMS
146
- function extractIdFromURL(input: string): number {
147
- const regex = /\/items\/(\d+)/;
148
- const match = input.match(regex);
149
- return match ? parseInt(match[1], 10) : -1;
150
- }
151
-
152
- function formatHTMLItemList(item: HTMLItemListSchema): ItemDataTable {
153
- return {
154
- zid: parseInt(extractValueBetweenTags(item.zid, "a"), 10),
155
- itemId: extractIdFromURL(item.cod),
156
- name: extractValueBetweenTags(item.name, "a"),
157
- stck: extractValueBetweenTags(item.stck, "i") || null,
158
- act: extractValueBetweenTags(item.act, "i") || null,
159
- sell: extractValueBetweenTags(item.sell, "i") || null,
160
- purch: extractValueBetweenTags(item.purch, "i") || null,
161
- vat: extractValueBetweenTags(item.vat, "i") || null,
162
- cat: item.cat,
163
- warr: item.warr,
164
- cat_note: item.cat_note,
165
- DT_RowId: parseInt(item.DT_RowId.replace("settings-item-", ""), 10),
166
- };
167
- }
168
-
169
121
  /**
170
122
  * getLabItemCategories
171
123
  * @param session
@@ -4,70 +4,12 @@ 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.
@@ -91,4 +33,4 @@ export const getReceptionTypes = (
91
33
  const receptionTypes = response?.data ?? [];
92
34
  return receptionTypes;
93
35
  });
94
- }
36
+ };