@zauru-sdk/services 6.6.4 → 6.7.1
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.
|
@@ -2,7 +2,7 @@ import { arrayToObject, handlePossibleAxiosErrors } from "@zauru-sdk/common";
|
|
|
2
2
|
import { httpZauru } from "./httpZauru.js";
|
|
3
3
|
import { getGraphQLAPIHeaders } from "../common.js";
|
|
4
4
|
import { httpGraphQLAPI } from "./httpGraphQL.js";
|
|
5
|
-
import { getShipmentsStringQuery } from "@zauru-sdk/graphql";
|
|
5
|
+
import { getBookingByPurchaseOrderAndReferenceStringQuery, getShipmentsStringQuery, } from "@zauru-sdk/graphql";
|
|
6
6
|
/**
|
|
7
7
|
* insertBookings
|
|
8
8
|
* @param headers
|
|
@@ -80,3 +80,21 @@ export const getBooking = async (headers, booking_id) => {
|
|
|
80
80
|
return response.data;
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* getBookingByPurchaseOrderAndReference
|
|
85
|
+
* Returns the first non-voided, non-returned shipment linked to the PO
|
|
86
|
+
* with the given reference, or null when none exists.
|
|
87
|
+
*/
|
|
88
|
+
export const getBookingByPurchaseOrderAndReference = async (session, purchaseOrderId, reference) => {
|
|
89
|
+
return handlePossibleAxiosErrors(async () => {
|
|
90
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
91
|
+
const response = await httpGraphQLAPI.post("", {
|
|
92
|
+
query: getBookingByPurchaseOrderAndReferenceStringQuery(purchaseOrderId, reference),
|
|
93
|
+
}, { headers });
|
|
94
|
+
if (response.data.errors) {
|
|
95
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
96
|
+
}
|
|
97
|
+
return (response.data?.data?.purchase_orders?.[0]?.shipment_purchase_orders?.[0]
|
|
98
|
+
?.shipment ?? null);
|
|
99
|
+
});
|
|
100
|
+
};
|
|
@@ -26,3 +26,9 @@ export declare const getBookings: (session: Session, wheres?: string[]) => Promi
|
|
|
26
26
|
* @returns
|
|
27
27
|
*/
|
|
28
28
|
export declare const getBooking: (headers: any, booking_id: string) => Promise<AxiosUtilsResponse<ShipmentGraphQL>>;
|
|
29
|
+
/**
|
|
30
|
+
* getBookingByPurchaseOrderAndReference
|
|
31
|
+
* Returns the first non-voided, non-returned shipment linked to the PO
|
|
32
|
+
* with the given reference, or null when none exists.
|
|
33
|
+
*/
|
|
34
|
+
export declare const getBookingByPurchaseOrderAndReference: (session: Session, purchaseOrderId: number | string, reference: string) => Promise<AxiosUtilsResponse<ShipmentGraphQL | null>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.1",
|
|
4
4
|
"description": "Servicios de consulta a Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@remix-run/node": "^2.8.1",
|
|
28
28
|
"@upstash/redis": "^1.34.5",
|
|
29
|
-
"@zauru-sdk/common": "^6.3.
|
|
29
|
+
"@zauru-sdk/common": "^6.3.3",
|
|
30
30
|
"@zauru-sdk/config": "^6.0.0",
|
|
31
|
-
"@zauru-sdk/graphql": "^6.
|
|
32
|
-
"@zauru-sdk/types": "^6.
|
|
31
|
+
"@zauru-sdk/graphql": "^6.5.0",
|
|
32
|
+
"@zauru-sdk/types": "^6.11.0",
|
|
33
33
|
"axios": "^1.6.7",
|
|
34
34
|
"chalk": "5.3.0",
|
|
35
35
|
"moment": "^2.30.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "3b01e2440af4265aa61b77aba1e7dd33abb2e4fa"
|
|
38
38
|
}
|