@zauru-sdk/services 1.0.116 → 1.0.119

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 (42) hide show
  1. package/dist/esm/zauru/httpZauru.js +3 -3
  2. package/dist/sessions/sessions.d.ts +1 -1
  3. package/package.json +7 -8
  4. package/dist/cjs/common.js +0 -277
  5. package/dist/cjs/graphql/index.js +0 -31
  6. package/dist/cjs/index.js +0 -54
  7. package/dist/cjs/sessions/sessions.js +0 -18
  8. package/dist/cjs/sessions/upstash.js +0 -59
  9. package/dist/cjs/zauru/httpGraphQL.js +0 -42
  10. package/dist/cjs/zauru/httpOauth.js +0 -42
  11. package/dist/cjs/zauru/httpZauru.js +0 -42
  12. package/dist/cjs/zauru/zauru-agencies.js +0 -27
  13. package/dist/cjs/zauru/zauru-automatic-numbers.js +0 -28
  14. package/dist/cjs/zauru/zauru-bookings.js +0 -90
  15. package/dist/cjs/zauru/zauru-bundles.js +0 -101
  16. package/dist/cjs/zauru/zauru-cases.js +0 -27
  17. package/dist/cjs/zauru/zauru-consolidated.js +0 -77
  18. package/dist/cjs/zauru/zauru-currencies.js +0 -27
  19. package/dist/cjs/zauru/zauru-deliveries.js +0 -53
  20. package/dist/cjs/zauru/zauru-discharges.js +0 -55
  21. package/dist/cjs/zauru/zauru-employees.js +0 -27
  22. package/dist/cjs/zauru/zauru-forms.js +0 -381
  23. package/dist/cjs/zauru/zauru-invoices.js +0 -134
  24. package/dist/cjs/zauru/zauru-items.js +0 -282
  25. package/dist/cjs/zauru/zauru-lote-record.js +0 -33
  26. package/dist/cjs/zauru/zauru-lotes.js +0 -307
  27. package/dist/cjs/zauru/zauru-motivos-rechazo.js +0 -57
  28. package/dist/cjs/zauru/zauru-payees.js +0 -259
  29. package/dist/cjs/zauru/zauru-payment-method.js +0 -34
  30. package/dist/cjs/zauru/zauru-payment-terms.js +0 -76
  31. package/dist/cjs/zauru/zauru-payments.js +0 -34
  32. package/dist/cjs/zauru/zauru-price-lists.js +0 -49
  33. package/dist/cjs/zauru/zauru-print-templates.js +0 -27
  34. package/dist/cjs/zauru/zauru-profiles.js +0 -80
  35. package/dist/cjs/zauru/zauru-purchase-orders.js +0 -423
  36. package/dist/cjs/zauru/zauru-receptions.js +0 -80
  37. package/dist/cjs/zauru/zauru-shipments.js +0 -59
  38. package/dist/cjs/zauru/zauru-suggested-prices.js +0 -94
  39. package/dist/cjs/zauru/zauru-tags.js +0 -20
  40. package/dist/cjs/zauru/zauru-templates.js +0 -22
  41. package/dist/cjs/zauru/zauru-variables.js +0 -64
  42. package/dist/cjs/zauru/zauru-web-app-tables.js +0 -164
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateAutomaticNumber = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
9
- /**
10
- * updateAutomaticNumber
11
- * @param headers
12
- * @param body
13
- * @returns
14
- */
15
- const updateAutomaticNumber = async (headers, body) => {
16
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
17
- const sendBody = {
18
- document_automatic_number: {
19
- ...body,
20
- },
21
- };
22
- const response = await httpZauru_js_1.default.put(`/settings/templates/document_automatic_numbers/${body.id}.json`, sendBody, {
23
- headers,
24
- });
25
- return response.data;
26
- });
27
- };
28
- exports.updateAutomaticNumber = updateAutomaticNumber;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getBooking = exports.getBookings = exports.getDeliveryByBooking = exports.insertBookings = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
9
- const common_js_1 = require("../common.js");
10
- const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
11
- const graphql_1 = require("@zauru-sdk/graphql");
12
- /**
13
- * insertBookings
14
- * @param headers
15
- * @param body
16
- * @returns
17
- */
18
- const insertBookings = async (headers, body, temp_purchase_order_id) => {
19
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
20
- const sendBody = {
21
- shipment: {
22
- ...body,
23
- movements_attributes: (0, common_1.arrayToObject)(body.movements),
24
- },
25
- };
26
- delete sendBody.shipment.movements;
27
- if (temp_purchase_order_id) {
28
- sendBody[`temp_purchase_order_id`] = `${temp_purchase_order_id}`;
29
- }
30
- const response = await httpZauru_js_1.default.post(`/inventories/bookings.json`, sendBody, {
31
- headers,
32
- });
33
- return response.data;
34
- });
35
- };
36
- exports.insertBookings = insertBookings;
37
- /**
38
- * getDeliveryByBooking
39
- * @param headers
40
- * @param shipment_id
41
- * @returns
42
- */
43
- const getDeliveryByBooking = async (headers, shipment_id) => {
44
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
45
- if (!shipment_id) {
46
- throw new Error("No hay un shipment_id, en getDeliveryByBooking");
47
- }
48
- const response = await httpZauru_js_1.default.get(`/inventories/bookings/${shipment_id}/deliver.json`, {
49
- headers,
50
- data: {
51
- id: shipment_id,
52
- },
53
- });
54
- return response.data;
55
- });
56
- };
57
- exports.getDeliveryByBooking = getDeliveryByBooking;
58
- /**
59
- * getBookings
60
- * @param headers
61
- * @returns
62
- */
63
- const getBookings = async (session, wheres = []) => {
64
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
65
- const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
66
- const response = await httpGraphQL_js_1.default.post("", {
67
- query: (0, graphql_1.getShipmentsStringQuery)([...wheres, "delivered: {_eq: false}"]),
68
- }, { headers });
69
- if (response.data.errors) {
70
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
71
- }
72
- const registers = response?.data?.data?.shipments;
73
- return registers;
74
- });
75
- };
76
- exports.getBookings = getBookings;
77
- /**
78
- * getBookings
79
- * @param headers
80
- * @returns
81
- */
82
- const getBooking = async (headers, booking_id) => {
83
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
84
- const response = await httpZauru_js_1.default.get(`/inventories/bookings/${booking_id}.json`, {
85
- headers,
86
- });
87
- return response.data;
88
- });
89
- };
90
- exports.getBooking = getBooking;
@@ -1,101 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.deleteBundle = exports.updateBundle = exports.createBundle = exports.getBundleByName = exports.getBundlesByItemCategoryId = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const common_js_1 = require("../common.js");
9
- const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
10
- const graphql_1 = require("@zauru-sdk/graphql");
11
- const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
12
- /**
13
- * getBundlesByItemCategoryId
14
- */
15
- async function getBundlesByItemCategoryId(session, id) {
16
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
17
- const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
18
- const response = await httpGraphQL_js_1.default.post("", {
19
- query: (0, graphql_1.getBundlesByItemCategoryIdStringQuery)(Number(id)),
20
- }, { headers });
21
- if (response.data.errors) {
22
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
23
- }
24
- const registers = response?.data?.data?.bundles;
25
- return registers;
26
- });
27
- }
28
- exports.getBundlesByItemCategoryId = getBundlesByItemCategoryId;
29
- /**
30
- * getBundleByName
31
- */
32
- async function getBundleByName(session, name) {
33
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
34
- const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
35
- const response = await httpGraphQL_js_1.default.post("", {
36
- query: graphql_1.getBundleByNameStringQuery,
37
- variables: {
38
- name,
39
- },
40
- }, { headers });
41
- if (response.data.errors) {
42
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
43
- }
44
- if (!response?.data?.data?.bundles[0]) {
45
- throw new Error(`No se encontró ningún bundle con el nombre: ${name} asociado`);
46
- }
47
- const register = response?.data?.data?.bundles[0];
48
- return register;
49
- });
50
- }
51
- exports.getBundleByName = getBundleByName;
52
- /**
53
- * createBundle
54
- * @param headers
55
- * @param body
56
- */
57
- async function createBundle(headers, body) {
58
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
59
- const sendBody = {
60
- ...body,
61
- bundle_details_attributes: (0, common_1.arrayToObject)(body.bundle_details, {
62
- withOutId: true,
63
- }),
64
- };
65
- delete sendBody.bundle_details;
66
- const response = await httpZauru_js_1.default.post(`/inventories/bundles.json`, sendBody, { headers });
67
- return response.data;
68
- });
69
- }
70
- exports.createBundle = createBundle;
71
- /**
72
- * updateBundle
73
- * @param headers
74
- * @param body
75
- */
76
- async function updateBundle(headers, body) {
77
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
78
- const sendBody = {
79
- ...body,
80
- bundle_details_attributes: (0, common_1.arrayToObject)(body.bundle_details),
81
- };
82
- delete sendBody.bundle_details;
83
- const response = await httpZauru_js_1.default.patch(`/inventories/bundles/${body.id}.json`, sendBody, { headers });
84
- return response.data;
85
- });
86
- }
87
- exports.updateBundle = updateBundle;
88
- /**
89
- * deleteBundle
90
- * @param headers
91
- * @param body
92
- */
93
- async function deleteBundle(headers, id) {
94
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
95
- await httpZauru_js_1.default.delete(`/inventories/bundles/${id}?destroy=true`, {
96
- headers,
97
- });
98
- return true;
99
- });
100
- }
101
- exports.deleteBundle = deleteBundle;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCasesByResponsibleId = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const common_js_1 = require("../common.js");
9
- const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
10
- const graphql_1 = require("@zauru-sdk/graphql");
11
- /**
12
- * getCasesByResponsibleId
13
- */
14
- async function getCasesByResponsibleId(session, responsible_id, wheres = []) {
15
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
16
- const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
17
- const response = await httpGraphQL_js_1.default.post("", {
18
- query: (0, graphql_1.getCasesByResponsibleIdStringQuery)(Number(responsible_id), wheres),
19
- }, { headers });
20
- if (response.data.errors) {
21
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
22
- }
23
- const registers = response?.data?.data?.cases;
24
- return registers;
25
- });
26
- }
27
- exports.getCasesByResponsibleId = getCasesByResponsibleId;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getConsolidatesBetweenDates = exports.getConsolidatedPDFResult = exports.generateConsolidatePDF = exports.createConsolidated = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
9
- const common_js_1 = require("../common.js");
10
- const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
11
- const graphql_1 = require("@zauru-sdk/graphql");
12
- /**
13
- *
14
- * @param headers
15
- * @returns
16
- */
17
- const createConsolidated = async (headers, body) => {
18
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
19
- const response = await httpZauru_js_1.default.post(`/purchases/consolidates/create_for_special_invoice.json`, body, {
20
- headers,
21
- });
22
- return response.data;
23
- });
24
- };
25
- exports.createConsolidated = createConsolidated;
26
- /**
27
- * generateConsolidatePDF
28
- * @param headers
29
- * @param body
30
- */
31
- const generateConsolidatePDF = async (headers, session, body) => {
32
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
33
- const { consolidated_template_id } = await (0, common_js_1.getVariablesByName)(headers, session, ["consolidated_template_id"]);
34
- body.print_template = consolidated_template_id;
35
- const response = await httpZauru_js_1.default.post("/purchases/consolidates/gen_print_all.json", body, { headers });
36
- return response.data;
37
- });
38
- };
39
- exports.generateConsolidatePDF = generateConsolidatePDF;
40
- /**
41
- * getConsolidatedPDFResult
42
- * @param headers
43
- * @param zid
44
- * @returns
45
- */
46
- const getConsolidatedPDFResult = async (headers, zid) => {
47
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
48
- const response = await httpZauru_js_1.default.get("purchases/consolidates/check_print_all", {
49
- headers,
50
- params: { zid },
51
- });
52
- return response.data;
53
- });
54
- };
55
- exports.getConsolidatedPDFResult = getConsolidatedPDFResult;
56
- /**
57
- *
58
- * @param session
59
- * @param dates
60
- * @returns
61
- */
62
- const getConsolidatesBetweenDates = async (session, dates) => {
63
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
64
- const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
65
- const response = await httpGraphQL_js_1.default.post("", {
66
- query: (0, graphql_1.getConsolidatesBetweenDatesStringQuery)((0, common_1.formatDateToUTC)(dates.startDate), (0, common_1.formatDateToUTC)(dates.endDate)),
67
- }, { headers });
68
- if (response.data.errors) {
69
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
70
- }
71
- if (!response?.data?.data.consolidates) {
72
- return [];
73
- }
74
- return response.data?.data.consolidates;
75
- });
76
- };
77
- exports.getConsolidatesBetweenDates = getConsolidatesBetweenDates;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCurrencies = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const common_js_1 = require("../common.js");
9
- const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
10
- const graphql_1 = require("@zauru-sdk/graphql");
11
- /**
12
- * getCurrencies
13
- */
14
- async function getCurrencies(session) {
15
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
16
- const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
17
- const response = await httpGraphQL_js_1.default.post("", {
18
- query: graphql_1.getCurrenciesStringQuery,
19
- }, { headers });
20
- if (response.data.errors) {
21
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
22
- }
23
- const registers = response?.data?.data?.currencies;
24
- return registers;
25
- });
26
- }
27
- exports.getCurrencies = getCurrencies;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.deleteDelivery = exports.getDeliveriesDataTables = exports.getDelivery = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
9
- /**
10
- * getDelivery
11
- * @param headers
12
- * @param body
13
- * @returns
14
- */
15
- async function getDelivery(headers, idDelivery) {
16
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
17
- const response = await httpZauru_js_1.default.get(`/inventories/deliveries/${idDelivery}.json`, {
18
- headers,
19
- });
20
- return response.data;
21
- });
22
- }
23
- exports.getDelivery = getDelivery;
24
- /**
25
- * GET DELIVERIES DATA TABLES
26
- * @param headers
27
- * @param body
28
- * @returns
29
- */
30
- async function getDeliveriesDataTables(headers, body) {
31
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
32
- const response = await httpZauru_js_1.default.post(`/inventories/deliveries/datatables.json`, body, {
33
- headers,
34
- });
35
- return response.data;
36
- });
37
- }
38
- exports.getDeliveriesDataTables = getDeliveriesDataTables;
39
- /**
40
- * deleteDelivery
41
- * @param headers
42
- * @param id
43
- * @returns
44
- */
45
- async function deleteDelivery(headers, id) {
46
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
47
- await httpZauru_js_1.default.delete(`/inventories/deliveries/${id}.json?destroy=true`, {
48
- headers,
49
- });
50
- return true;
51
- });
52
- }
53
- exports.deleteDelivery = deleteDelivery;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDischargePDFResult = exports.generateDischargePDF = exports.createDischarge = void 0;
7
- const common_js_1 = require("../common.js");
8
- const common_1 = require("@zauru-sdk/common");
9
- const httpZauru_js_1 = __importDefault(require("./httpZauru.js"));
10
- /**
11
- *
12
- * @param headers
13
- * @returns
14
- */
15
- const createDischarge = async (session, headers, body) => {
16
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
17
- const { id_check_discharge_method } = await (0, common_js_1.getVariablesByName)(headers, session, ["id_check_discharge_method"]);
18
- body.discharge.discharge_method_id = id_check_discharge_method;
19
- const response = await httpZauru_js_1.default.post(`/purchases/discharges.json`, body, {
20
- headers,
21
- });
22
- return response.data;
23
- });
24
- };
25
- exports.createDischarge = createDischarge;
26
- /**
27
- * generateDischargePDF
28
- * @param headers
29
- * @param body
30
- */
31
- const generateDischargePDF = async (headers, session, body) => {
32
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
33
- const { consolidated_template_id } = await (0, common_js_1.getVariablesByName)(headers, session, ["consolidated_template_id"]);
34
- body.print_template = consolidated_template_id;
35
- const response = await httpZauru_js_1.default.post("/purchases/consolidates/gen_print_all.json", body, { headers });
36
- return response.data;
37
- });
38
- };
39
- exports.generateDischargePDF = generateDischargePDF;
40
- /**
41
- * getDischargePDFResult
42
- * @param headers
43
- * @param zid
44
- * @returns
45
- */
46
- const getDischargePDFResult = async (headers, zid) => {
47
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
48
- const response = await httpZauru_js_1.default.get("purchases/consolidates/check_print_all", {
49
- headers,
50
- params: { zid },
51
- });
52
- return response.data;
53
- });
54
- };
55
- exports.getDischargePDFResult = getDischargePDFResult;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getEmployeesByAgencyId = void 0;
7
- const common_1 = require("@zauru-sdk/common");
8
- const common_js_1 = require("../common.js");
9
- const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
10
- const graphql_1 = require("@zauru-sdk/graphql");
11
- /**
12
- * getEmployeesByAgencyId
13
- */
14
- async function getEmployeesByAgencyId(session, id) {
15
- return (0, common_1.handlePossibleAxiosErrors)(async () => {
16
- const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
17
- const response = await httpGraphQL_js_1.default.post("", {
18
- query: (0, graphql_1.getEmployeesByAgencyIdStringQuery)(Number(id)),
19
- }, { headers });
20
- if (response.data.errors) {
21
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
22
- }
23
- const registers = response?.data?.data?.employees;
24
- return registers;
25
- });
26
- }
27
- exports.getEmployeesByAgencyId = getEmployeesByAgencyId;