@zauru-sdk/services 1.0.49 → 1.0.52

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 (108) hide show
  1. package/dist/cjs/common.js +235 -0
  2. package/dist/cjs/index.js +50 -0
  3. package/dist/cjs/sessions/sessions.js +18 -0
  4. package/dist/cjs/sessions/upstash.js +59 -0
  5. package/dist/cjs/zauru/httpGraphQL.js +42 -0
  6. package/dist/cjs/zauru/httpOauth.js +42 -0
  7. package/dist/cjs/zauru/httpZauru.js +42 -0
  8. package/dist/cjs/zauru/zauru-agencies.js +27 -0
  9. package/dist/cjs/zauru/zauru-automatic-numbers.js +28 -0
  10. package/dist/cjs/zauru/zauru-bookings.js +90 -0
  11. package/dist/cjs/zauru/zauru-bundles.js +104 -0
  12. package/dist/cjs/zauru/zauru-cases.js +30 -0
  13. package/dist/cjs/zauru/zauru-consolidated.js +81 -0
  14. package/dist/cjs/zauru/zauru-currencies.js +27 -0
  15. package/dist/cjs/zauru/zauru-deliveries.js +53 -0
  16. package/dist/cjs/zauru/zauru-discharges.js +55 -0
  17. package/dist/cjs/zauru/zauru-employees.js +30 -0
  18. package/dist/cjs/zauru/zauru-forms.js +363 -0
  19. package/dist/cjs/zauru/zauru-invoices.js +104 -0
  20. package/dist/cjs/zauru/zauru-items.js +293 -0
  21. package/dist/cjs/zauru/zauru-lote-record.js +33 -0
  22. package/dist/cjs/zauru/zauru-lotes.js +312 -0
  23. package/dist/cjs/zauru/zauru-motivos-rechazo.js +57 -0
  24. package/dist/cjs/zauru/zauru-payees.js +247 -0
  25. package/dist/cjs/zauru/zauru-payment-terms.js +75 -0
  26. package/dist/cjs/zauru/zauru-price-lists.js +49 -0
  27. package/dist/cjs/zauru/zauru-profiles.js +80 -0
  28. package/dist/cjs/zauru/zauru-purchase-orders.js +438 -0
  29. package/dist/cjs/zauru/zauru-receptions.js +104 -0
  30. package/dist/cjs/zauru/zauru-shipments.js +62 -0
  31. package/dist/cjs/zauru/zauru-suggested-prices.js +94 -0
  32. package/dist/cjs/zauru/zauru-tags.js +20 -0
  33. package/dist/cjs/zauru/zauru-templates.js +22 -0
  34. package/dist/cjs/zauru/zauru-variables.js +56 -0
  35. package/dist/cjs/zauru/zauru-web-app-tables.js +167 -0
  36. package/package.json +12 -9
  37. package/CHANGELOG.md +0 -232
  38. package/src/common.ts +0 -343
  39. package/src/index.ts +0 -37
  40. package/src/sessions/sessions.ts +0 -17
  41. package/src/sessions/upstash.ts +0 -55
  42. package/src/zauru/httpGraphQL.ts +0 -55
  43. package/src/zauru/httpOauth.ts +0 -55
  44. package/src/zauru/httpZauru.ts +0 -56
  45. package/src/zauru/zauru-agencies.ts +0 -32
  46. package/src/zauru/zauru-automatic-numbers.ts +0 -35
  47. package/src/zauru/zauru-bookings.ts +0 -134
  48. package/src/zauru/zauru-bundles.ts +0 -157
  49. package/src/zauru/zauru-cases.ts +0 -44
  50. package/src/zauru/zauru-consolidated.ts +0 -129
  51. package/src/zauru/zauru-currencies.ts +0 -39
  52. package/src/zauru/zauru-deliveries.ts +0 -70
  53. package/src/zauru/zauru-discharges.ts +0 -90
  54. package/src/zauru/zauru-employees.ts +0 -43
  55. package/src/zauru/zauru-forms.ts +0 -618
  56. package/src/zauru/zauru-invoices.ts +0 -142
  57. package/src/zauru/zauru-items.ts +0 -481
  58. package/src/zauru/zauru-lote-record.ts +0 -77
  59. package/src/zauru/zauru-lotes.ts +0 -484
  60. package/src/zauru/zauru-motivos-rechazo.ts +0 -121
  61. package/src/zauru/zauru-payees.ts +0 -402
  62. package/src/zauru/zauru-payment-terms.ts +0 -126
  63. package/src/zauru/zauru-price-lists.ts +0 -68
  64. package/src/zauru/zauru-profiles.ts +0 -106
  65. package/src/zauru/zauru-purchase-orders.ts +0 -701
  66. package/src/zauru/zauru-receptions.ts +0 -148
  67. package/src/zauru/zauru-shipments.ts +0 -88
  68. package/src/zauru/zauru-suggested-prices.ts +0 -137
  69. package/src/zauru/zauru-tags.ts +0 -22
  70. package/src/zauru/zauru-templates.ts +0 -24
  71. package/src/zauru/zauru-variables.ts +0 -67
  72. package/src/zauru/zauru-web-app-tables.ts +0 -256
  73. package/tsconfig.json +0 -24
  74. /package/dist/{common.js → esm/common.js} +0 -0
  75. /package/dist/{index.js → esm/index.js} +0 -0
  76. /package/dist/{sessions → esm/sessions}/sessions.js +0 -0
  77. /package/dist/{sessions → esm/sessions}/upstash.js +0 -0
  78. /package/dist/{zauru → esm/zauru}/httpGraphQL.js +0 -0
  79. /package/dist/{zauru → esm/zauru}/httpOauth.js +0 -0
  80. /package/dist/{zauru → esm/zauru}/httpZauru.js +0 -0
  81. /package/dist/{zauru → esm/zauru}/zauru-agencies.js +0 -0
  82. /package/dist/{zauru → esm/zauru}/zauru-automatic-numbers.js +0 -0
  83. /package/dist/{zauru → esm/zauru}/zauru-bookings.js +0 -0
  84. /package/dist/{zauru → esm/zauru}/zauru-bundles.js +0 -0
  85. /package/dist/{zauru → esm/zauru}/zauru-cases.js +0 -0
  86. /package/dist/{zauru → esm/zauru}/zauru-consolidated.js +0 -0
  87. /package/dist/{zauru → esm/zauru}/zauru-currencies.js +0 -0
  88. /package/dist/{zauru → esm/zauru}/zauru-deliveries.js +0 -0
  89. /package/dist/{zauru → esm/zauru}/zauru-discharges.js +0 -0
  90. /package/dist/{zauru → esm/zauru}/zauru-employees.js +0 -0
  91. /package/dist/{zauru → esm/zauru}/zauru-forms.js +0 -0
  92. /package/dist/{zauru → esm/zauru}/zauru-invoices.js +0 -0
  93. /package/dist/{zauru → esm/zauru}/zauru-items.js +0 -0
  94. /package/dist/{zauru → esm/zauru}/zauru-lote-record.js +0 -0
  95. /package/dist/{zauru → esm/zauru}/zauru-lotes.js +0 -0
  96. /package/dist/{zauru → esm/zauru}/zauru-motivos-rechazo.js +0 -0
  97. /package/dist/{zauru → esm/zauru}/zauru-payees.js +0 -0
  98. /package/dist/{zauru → esm/zauru}/zauru-payment-terms.js +0 -0
  99. /package/dist/{zauru → esm/zauru}/zauru-price-lists.js +0 -0
  100. /package/dist/{zauru → esm/zauru}/zauru-profiles.js +0 -0
  101. /package/dist/{zauru → esm/zauru}/zauru-purchase-orders.js +0 -0
  102. /package/dist/{zauru → esm/zauru}/zauru-receptions.js +0 -0
  103. /package/dist/{zauru → esm/zauru}/zauru-shipments.js +0 -0
  104. /package/dist/{zauru → esm/zauru}/zauru-suggested-prices.js +0 -0
  105. /package/dist/{zauru → esm/zauru}/zauru-tags.js +0 -0
  106. /package/dist/{zauru → esm/zauru}/zauru-templates.js +0 -0
  107. /package/dist/{zauru → esm/zauru}/zauru-variables.js +0 -0
  108. /package/dist/{zauru → esm/zauru}/zauru-web-app-tables.js +0 -0
@@ -1,148 +0,0 @@
1
- import type { Session } from "@remix-run/node";
2
- import {
3
- arrayToObject,
4
- getDatePickerCurrentDate,
5
- handlePossibleAxiosErrors,
6
- } from "@zauru-sdk/common";
7
- import {
8
- AxiosUtilsResponse,
9
- NewReceptionBody,
10
- PurchaseOrderGraphQL,
11
- } from "@zauru-sdk/types";
12
- import httpZauru from "./httpZauru.js";
13
-
14
- /**
15
- * createNewReception
16
- * @param headers
17
- * @param body
18
- * @param purchase_order_id
19
- * @returns
20
- */
21
- export async function createNewReception(
22
- headers: any,
23
- body: NewReceptionBody,
24
- purchase_order_id: number | string
25
- ) {
26
- return handlePossibleAxiosErrors(async () => {
27
- const response = await httpZauru<any>(
28
- `/purchases/purchase_orders/${purchase_order_id}/receptions.json`,
29
- { method: "POST", headers, data: body }
30
- );
31
-
32
- return response.data;
33
- });
34
- }
35
-
36
- /**
37
- * deleteReception
38
- * @param headers
39
- * @param id
40
- * @returns
41
- */
42
- export async function deleteReception(
43
- headers: any,
44
- receptionId: string | number,
45
- poId: string | number
46
- ): Promise<AxiosUtilsResponse<boolean>> {
47
- return handlePossibleAxiosErrors(async () => {
48
- await httpZauru.get(
49
- `/purchases/receptions/${receptionId}/rebound.json?purchase_order_id=${poId}`,
50
- {
51
- headers,
52
- }
53
- );
54
-
55
- return true;
56
- });
57
- }
58
-
59
- /**
60
- *
61
- * @param headers
62
- * @param poId
63
- * @returns
64
- */
65
- export async function createNewPurchaseOrderReception(
66
- headers: any,
67
- session: Session,
68
- body: Partial<PurchaseOrderGraphQL>
69
- ): Promise<AxiosUtilsResponse<boolean>> {
70
- return handlePossibleAxiosErrors(async () => {
71
- const sendBody = {
72
- reception: {
73
- memo: "LABORATORIO - Recibido parcialmente desde WebApp",
74
- purchase_order_id: body.id,
75
- needs_transit: false,
76
- agency_id: session.get("agency_id"),
77
- entity_id: session.get("selectedEntity"),
78
- received_at: getDatePickerCurrentDate(),
79
- invoice_number: "",
80
- reception_details_attributes: arrayToObject(
81
- body?.purchase_order_details?.map((x) => {
82
- return {
83
- item_id: x.item_id,
84
- purchase_order_detail_id: x.id,
85
- quantity: x.delivered_quantity,
86
- };
87
- })
88
- ),
89
- },
90
- purchase_order_id: body.id,
91
- };
92
-
93
- await httpZauru.post(
94
- `/purchases/purchase_orders/${body.id}/receptions.json`,
95
- sendBody,
96
- {
97
- headers,
98
- }
99
- );
100
-
101
- return true;
102
- });
103
- }
104
-
105
- /**
106
- *
107
- * @param headers
108
- * @param poId
109
- * @returns
110
- */
111
- export async function createNewLotPurchaseOrderReception(
112
- headers: any,
113
- session: Session,
114
- body: Partial<PurchaseOrderGraphQL> & { fechaVencimiento: string }
115
- ): Promise<AxiosUtilsResponse<boolean>> {
116
- return handlePossibleAxiosErrors(async () => {
117
- const sendBody = {
118
- memo: "LABORATORIO - Recibido parcialmente desde WebApp",
119
- purchase_order_id: body.id,
120
- needs_transit: false,
121
- received_at: getDatePickerCurrentDate(),
122
- invoice_number: "",
123
- agency_id: session.get("agency_id"),
124
- entity_id: session.get("selectedEntity"),
125
- reception_details_attributes: arrayToObject(
126
- body?.purchase_order_details?.map((x) => {
127
- return {
128
- item_id: x.item_id,
129
- purchase_order_detail_id: x.id,
130
- lot_delivered_quantity: [x.delivered_quantity],
131
- lot_name: [body.id_number],
132
- lot_expire: [body.fechaVencimiento],
133
- };
134
- })
135
- ),
136
- };
137
-
138
- await httpZauru.post(
139
- `/purchases/purchase_orders/${body.id}/receptions.json`,
140
- { reception: sendBody, purchase_order_id: body.id },
141
- {
142
- headers,
143
- }
144
- );
145
-
146
- return true;
147
- });
148
- }
@@ -1,88 +0,0 @@
1
- import type { Session } from "@remix-run/node";
2
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
- import { AxiosUtilsResponse, ShipmentGraphQL } from "@zauru-sdk/types";
4
- import { getGraphQLAPIHeaders } from "../common.js";
5
- import httpGraphQLAPI from "./httpGraphQL.js";
6
- import { getShipmentsByToAgencyLast100StringQuery } from "@zauru-sdk/graphql";
7
- import httpZauru from "./httpZauru.js";
8
-
9
- /**
10
- * getShipmentsByToAgencyLast100Id_booking
11
- */
12
- export async function getShipmentsByToAgencyLast100Id_booking(
13
- session: Session,
14
- agency_to_id: string | number
15
- ): Promise<AxiosUtilsResponse<ShipmentGraphQL[]>> {
16
- return handlePossibleAxiosErrors(async () => {
17
- const headers = await getGraphQLAPIHeaders(session);
18
-
19
- const response = await httpGraphQLAPI.post<{
20
- data: { shipments: ShipmentGraphQL[] };
21
- errors?: {
22
- message: string;
23
- extensions: { path: string; code: string };
24
- }[];
25
- }>(
26
- "",
27
- {
28
- query: getShipmentsByToAgencyLast100StringQuery,
29
- variables: {
30
- agency_to_id,
31
- },
32
- },
33
- { headers }
34
- );
35
-
36
- if (response.data.errors) {
37
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
38
- }
39
-
40
- const registers = response?.data?.data?.shipments;
41
-
42
- return registers;
43
- });
44
- }
45
-
46
- /**
47
- * receiveShipment_booking
48
- * @param headers
49
- * @param id
50
- * @returns
51
- */
52
- export async function receiveShipment_booking(
53
- headers: any,
54
- id: string | number
55
- ): Promise<AxiosUtilsResponse<boolean>> {
56
- return handlePossibleAxiosErrors(async () => {
57
- const response = await httpZauru.get<any>(
58
- `/inventories/bookings/${id}/deliver.json`,
59
- { headers }
60
- );
61
-
62
- if (!response.data) {
63
- throw new Error(
64
- "Sin respuesta de: /inventories/bookings/id/deliver.json"
65
- );
66
- }
67
-
68
- return true;
69
- });
70
- }
71
-
72
- /**
73
- * deleteShipment_booking
74
- * @param headers
75
- * @param id
76
- * @returns
77
- */
78
- export async function deleteShipment_booking(
79
- headers: any,
80
- id: string | number
81
- ): Promise<AxiosUtilsResponse<boolean>> {
82
- return handlePossibleAxiosErrors(async () => {
83
- await httpZauru.delete<any>(`/inventories/bookings/${id}.json`, {
84
- headers,
85
- });
86
- return true;
87
- });
88
- }
@@ -1,137 +0,0 @@
1
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
- import {
3
- AxiosUtilsResponse,
4
- ItemWithPrices,
5
- SuggestedPriceGraphQL,
6
- } from "@zauru-sdk/types";
7
- import httpZauru from "./httpZauru.js";
8
- import { Session } from "@remix-run/node";
9
- import { getGraphQLAPIHeaders } from "../common.js";
10
- import httpGraphQLAPI from "./httpGraphQL.js";
11
- import { getSuggestedPricesStringQuery } from "@zauru-sdk/graphql";
12
-
13
- /**
14
- *
15
- * @param headers
16
- * @returns
17
- */
18
- export const getSuggestedPricesExportJSON = async (
19
- headers: any
20
- ): Promise<AxiosUtilsResponse<ItemWithPrices[]>> => {
21
- return handlePossibleAxiosErrors(async () => {
22
- const response = await httpZauru.get<ItemWithPrices[]>(
23
- `/sales/suggested_prices/export.json`,
24
- {
25
- headers,
26
- }
27
- );
28
-
29
- return response.data;
30
- });
31
- };
32
-
33
- /**
34
- * getSuggestedPrices
35
- * @param session
36
- * @param id
37
- */
38
- export async function getSuggestedPrices(
39
- session: Session,
40
- config: {
41
- notNullPriceList?: boolean;
42
- withItems?: boolean;
43
- withItemCategories?: boolean;
44
- onlyCurrent?: boolean;
45
- }
46
- ): Promise<AxiosUtilsResponse<SuggestedPriceGraphQL[]>> {
47
- return handlePossibleAxiosErrors(async () => {
48
- const {
49
- notNullPriceList = false,
50
- withItems = false,
51
- withItemCategories = false,
52
- onlyCurrent = false,
53
- } = config;
54
- const headers = await getGraphQLAPIHeaders(session);
55
-
56
- const response = await httpGraphQLAPI.post<{
57
- data: { suggested_prices: SuggestedPriceGraphQL[] };
58
- errors?: {
59
- message: string;
60
- extensions: { path: string; code: string };
61
- }[];
62
- }>(
63
- "",
64
- {
65
- query: getSuggestedPricesStringQuery({
66
- notNullPriceList,
67
- withItems,
68
- withItemCategories,
69
- onlyCurrent,
70
- }),
71
- },
72
- { headers }
73
- );
74
-
75
- if (response.data.errors) {
76
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
77
- }
78
-
79
- return response?.data?.data?.suggested_prices ?? [];
80
- });
81
- }
82
-
83
- /**
84
- * createSuggestedPrice
85
- * @param headers
86
- * @param body
87
- */
88
- export async function createSuggestedPrice(
89
- headers: any,
90
- body: Partial<SuggestedPriceGraphQL>
91
- ): Promise<AxiosUtilsResponse<SuggestedPriceGraphQL>> {
92
- return handlePossibleAxiosErrors(async () => {
93
- const response = await httpZauru.post<SuggestedPriceGraphQL>(
94
- `/sales/suggested_prices.json`,
95
- { suggested_price: body },
96
- { headers }
97
- );
98
- return response.data;
99
- });
100
- }
101
-
102
- //No existe actualizar
103
- // /**
104
- // * updateSuggestedPrice
105
- // * @param headers
106
- // * @param body
107
- // */
108
- // export async function updateSuggestedPrice(
109
- // headers: any,
110
- // body: Partial<SuggestedPriceGraphQL>
111
- // ): Promise<AxiosUtilsResponse<SuggestedPriceGraphQL>> {
112
- // return handlePossibleAxiosErrors(async () => {
113
- // const response = await httpZauru.patch<SuggestedPriceGraphQL>(
114
- // `/sales/suggested_prices.json`,
115
- // { suggested_price: body },
116
- // { headers }
117
- // );
118
- // return response.data;
119
- // });
120
- // }
121
-
122
- /**
123
- * deleteSuggestedPrice
124
- * @param headers
125
- * @param body
126
- */
127
- export async function deleteSuggestedPrice(
128
- headers: any,
129
- id: string | number
130
- ): Promise<AxiosUtilsResponse<boolean>> {
131
- return handlePossibleAxiosErrors(async () => {
132
- await httpZauru.delete<any>(`/sales/suggested_prices/${id}?destroy=true`, {
133
- headers,
134
- });
135
- return true;
136
- });
137
- }
@@ -1,22 +0,0 @@
1
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
- import { AxiosUtilsResponse, TagGraphQL } from "@zauru-sdk/types";
3
- import httpZauru from "./httpZauru.js";
4
-
5
- /**
6
- * createTag
7
- * @param headers
8
- * @param body
9
- */
10
- export async function createTag(
11
- headers: any,
12
- body: Partial<TagGraphQL>
13
- ): Promise<AxiosUtilsResponse<TagGraphQL>> {
14
- return handlePossibleAxiosErrors(async () => {
15
- const response = await httpZauru.post<TagGraphQL>(
16
- `/settings/tags.json`,
17
- { tag: body },
18
- { headers }
19
- );
20
- return response.data;
21
- });
22
- }
@@ -1,24 +0,0 @@
1
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
- import { AxiosUtilsResponse } from "@zauru-sdk/types";
3
- import httpZauru from "./httpZauru.js";
4
-
5
- /**
6
- *
7
- * @param headers
8
- * @returns
9
- */
10
- export const getReceptionTemplate = async (
11
- headers: any,
12
- id: string | number
13
- ): Promise<AxiosUtilsResponse<string>> => {
14
- return handlePossibleAxiosErrors(async () => {
15
- const response = await httpZauru.get<string>(
16
- `/settings/templates/print_templates/${id}/preview_with_vars`,
17
- {
18
- headers,
19
- }
20
- );
21
-
22
- return response.data;
23
- });
24
- };
@@ -1,67 +0,0 @@
1
- import chalk from "chalk";
2
- import httpZauru from "./httpZauru.js";
3
- import { VariableGraphQL, AxiosUtilsResponse } from "@zauru-sdk/types";
4
-
5
- /**
6
- * getVariables Function for get all zauru variables
7
- * @param headers
8
- * @returns
9
- */
10
- export async function getVariables(
11
- headers: any
12
- ): Promise<AxiosUtilsResponse<VariableGraphQL[]>> {
13
- try {
14
- const response = await httpZauru<VariableGraphQL[]>(
15
- `/apps/webapp_vars.json`,
16
- {
17
- method: "GET",
18
- headers: headers,
19
- }
20
- );
21
-
22
- return { data: response.data, error: false } as AxiosUtilsResponse<
23
- VariableGraphQL[]
24
- >;
25
- } catch (error) {
26
- console.log(
27
- chalk.red(`OCURRIÓ UN ERROR AL CARGAR LAS VARIABLES: ${error}`)
28
- );
29
- return {
30
- msg: error,
31
- error: true,
32
- userMsg: "Ocurrió un error al intentar obtener las variables",
33
- } as AxiosUtilsResponse<VariableGraphQL[]>;
34
- }
35
- }
36
-
37
- /**
38
- *
39
- * @param headers
40
- * @param body
41
- * @returns
42
- */
43
- export async function createVariable(
44
- headers: any,
45
- body: Partial<VariableGraphQL>
46
- ) {
47
- try {
48
- const response = await httpZauru.post<VariableGraphQL>(
49
- `/apps/webapp_vars.json`,
50
- { variable: body },
51
- {
52
- headers,
53
- }
54
- );
55
-
56
- return {
57
- data: response.data,
58
- error: false,
59
- } as AxiosUtilsResponse<VariableGraphQL>;
60
- } catch (error) {
61
- return {
62
- msg: error,
63
- error: true,
64
- userMsg: `Ocurrió un error al intentar crear la variable ${body.name}`,
65
- } as AxiosUtilsResponse<VariableGraphQL>;
66
- }
67
- }