@shipengine/react-api 0.8.2 → 0.9.0
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/hooks/index.d.ts +2 -0
- package/hooks/use-create-shipment.d.ts +13 -0
- package/hooks/use-list-rate-cards.d.ts +5 -0
- package/index.js +126 -42
- package/index.mjs +125 -43
- package/package.json +1 -1
package/hooks/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./use-connect-carrier";
|
|
|
4
4
|
export * from "./use-create-funding-source";
|
|
5
5
|
export * from "./use-create-label";
|
|
6
6
|
export * from "./use-create-sales-order-shipment";
|
|
7
|
+
export * from "./use-create-shipment";
|
|
7
8
|
export * from "./use-create-warehouse";
|
|
8
9
|
export * from "./use-delete-warehouse";
|
|
9
10
|
export * from "./use-get-account-settings";
|
|
@@ -21,6 +22,7 @@ export * from "./use-list-custom-package-types";
|
|
|
21
22
|
export * from "./use-list-funding-sources";
|
|
22
23
|
export * from "./use-list-labels";
|
|
23
24
|
export * from "./use-list-order-sources";
|
|
25
|
+
export * from "./use-list-rate-cards";
|
|
24
26
|
export * from "./use-list-sales-order-shipments";
|
|
25
27
|
export * from "./use-list-sales-orders";
|
|
26
28
|
export * from "./use-list-warehouses";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SE } from "@shipengine/js-api";
|
|
2
|
+
export type CreateShipmentData = {
|
|
3
|
+
warehouseId: string;
|
|
4
|
+
} & Partial<Omit<SE.Shipment, "items">>;
|
|
5
|
+
/**
|
|
6
|
+
* @category ShipEngine API Hooks
|
|
7
|
+
*
|
|
8
|
+
* @see [ShipEngine Developer Docs](https://shipengine.github.io/shipengine-openapi/#operation/create_shipments)
|
|
9
|
+
*/
|
|
10
|
+
export declare const useCreateShipment: () => import("react-query").UseMutationResult<{
|
|
11
|
+
has_errors: boolean;
|
|
12
|
+
shipments: SE.Shipment[];
|
|
13
|
+
}, SE.CodedError[], CreateShipmentData, unknown>;
|
package/index.js
CHANGED
|
@@ -62,25 +62,25 @@ const onError = (errors) => errors.forEach(console.log);
|
|
|
62
62
|
|
|
63
63
|
var o={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},l={};function a(e){return "string"==typeof e?o[e.toLowerCase()]:e}function c(e,r){return c=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},c(e,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return !1}}function f(e,r,t){return f=u()?Reflect.construct:function(e,r,t){var s=[null];s.push.apply(s,r);var i=new(Function.bind.apply(e,s));return t&&c(i,t.prototype),i},f.apply(null,arguments)}function h(e){if(null==e)return e;if(Array.isArray(e))return e.slice();if("object"==typeof e){var r={};return Object.keys(e).forEach(function(t){r[t]=e[t];}),r}return e}function v(e){return void 0===e?"undefined":null===e?"null":Array.isArray(e)?"[ "+e.map(function(e){return v(e)}).join(", ")+" ]":"object"==typeof e?JSON.stringify(e):"function"==typeof e?"[Function: "+e.name+"]":"boolean"==typeof e||"number"==typeof e?e:"'"+e.toString()+"'"}function p(e){if("string"!=typeof e){for(var r=new Array(arguments.length),t=0;t<arguments.length;t++)r[t]=v(arguments[t]);return r.join(" ")}for(var s=/%[sdj%]/g,i=1,n=arguments,o=n.length,l=String(e).replace(s,function(e){if("%%"===e)return "%";if(i>=o)return e;switch(e){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(e){return "[Circular]"}default:return e}}),a=n[i];i<o;a=n[++i])l+=null===a||"object"!=typeof a?" "+a:" "+v(a);return l}function m(e,r){var t=e.split("\n");t[0]&&t[0].indexOf("call-stack-error")>=0&&t.shift();var s=t[r],i=null;if(s){var n=/^\s*(at|.*@)\s*(.+)?$/.exec(s);i=Array.isArray(n)&&n[2]?n[2]:s;}return i}Object.keys(o).forEach(function(e){l[o[e]]=e;});var y={};function d(e,r){if(r){if(y[r])return;y[r]=!0;}console.error(e+"\n");}function g(e){return y[e]}function w(){var e=[];return function(r,t){return t&&"object"==typeof t?-1!==e.indexOf(t)?"[Circular]":(e.push(t),t):t}}var b=/*#__PURE__*/function(){function e(){}return e.prototype.write=function(e){e.level<30?console.log(e):e.level<40?console.info(e):e.level<50?console.warn(e):console.error(e),e.err&&e.err.stack&&console.error(e.err.stack),e.obj&&console.log(e.obj);},e}(),j=/*#__PURE__*/function(){function e(r,t,s){var i,n,o,l,a=this;if(!(this instanceof e))return new e(r,t);if(void 0!==t&&(i=r,r=t,!(i instanceof e)))throw new TypeError("invalid Logger creation: do not pass a second arg");if(!r)throw new TypeError("options (object) is required");if(i){if(r.name)throw new TypeError("invalid options.name: child cannot set logger name")}else if(!r.name)throw new TypeError("options.name (string) is required");if(r.stream&&r.streams)throw new TypeError('cannot mix "streams" and "stream" options');if(r.streams&&!Array.isArray(r.streams))throw new TypeError("invalid options.streams: must be an array");if(r.serializers&&("object"!=typeof r.serializers||Array.isArray(r.serializers)))throw new TypeError("invalid options.serializers: must be an object");if(i&&s){this._level=i._level,this.streams=i.streams,this.serializers=i.serializers,this.src=i.src,n=this.fields={};var c=Object.keys(i.fields);for(l=0;l<c.length;l++)n[o=c[l]]=i.fields[o];var u=Object.keys(r);for(l=0;l<u.length;l++)n[o=u[l]]=r[o];}else {if(i){for(this._level=i._level,this.streams=[],l=0;l<i.streams.length;l++){var f=h(i.streams[l]);this.streams.push(f);}this.serializers=h(i.serializers),this.src=i.src,this.fields=h(i.fields),r.level&&this.level(r.level);}else this._level=Number.POSITIVE_INFINITY,this.streams=[],this.serializers=null,this.src=!1,this.fields={};r.stream?this.addStream({type:"stream",stream:r.stream,level:r.level}):r.streams?r.streams.forEach(function(e){a.addStream(e,r.level);}):i&&r.level?this.level(r.level):i||this.addStream({type:"raw",stream:new b,level:r.level}),r.serializers&&this.addSerializers(r.serializers),r.src&&(this.src=!0),delete(n=h(r)).stream,delete n.level,delete n.streams,delete n.serializers,delete n.src,this.serializers&&this._applySerializers(n),Object.keys(n).forEach(function(e){a.fields[e]=n[e];});}}var r=e.prototype;return r.addStream=function(e,r){void 0===r&&(r=30),(e=h(e)).type="raw",e.level=a(e.level||r),e.level<this._level&&(this._level=e.level),this.streams.push(e),delete this.haveNonRawStreams;},r.addSerializers=function(e){var r=this;this.serializers||(this.serializers={}),Object.keys(e).forEach(function(t){var s=e[t];if("function"!=typeof s)throw new TypeError(p('invalid serializer for "%s" field: must be a function',t));r.serializers[t]=s;});},r.child=function(e,r){return new this.constructor(this,e||{},r)},r.level=function(e){if(void 0===e)return this._level;for(var r=a(e),t=this.streams.length,s=0;s<t;s++)this.streams[s].level=r;this._level=r;},r.levels=function(e,r){if(void 0===e)return this.streams.map(function(e){return e.level});var t;if("number"==typeof e){if(void 0===(t=this.streams[e]))throw new Error("invalid stream index: "+e)}else {for(var s=this.streams.length,i=0;i<s;i++){var n=this.streams[i];if(n.name===e){t=n;break}}if(!t)throw new Error(p('no stream with name "%s"',e))}if(void 0===r)return t.level;var o=a(r);t.level=o,o<this._level&&(this._level=o);},r._applySerializers=function(e,r){var t=this;Object.keys(this.serializers).forEach(function(s){if(!(void 0===e[s]||r&&r[s]))try{e[s]=t.serializers[s](e[s]);}catch(r){d(p('bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.\n%s',s,r.stack||r)),e[s]=p('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)',s);}});},r._emit=function(e,r){var t,s;if(void 0===this.haveNonRawStreams)for(this.haveNonRawStreams=!1,t=0;t<this.streams.length;t++)if(!this.streams[t].raw){this.haveNonRawStreams=!0;break}if(r||this.haveNonRawStreams)try{s=JSON.stringify(e,w())+"\n";}catch(r){var i=r.stack.split(/\n/g,2).join("\n");d('bunyan: ERROR: Exception in `JSON.stringify(rec)`. You can install the "safe-json-stringify" module to have Bunyan fallback to safer stringification. Record:\n'+function(e,r){return r||(r=" "),r+e.split(/\r?\n/g).join("\n"+r)}(p("%s\n%s",e,r.stack)),i),s=p("(Exception in JSON.stringify(rec): %j. See stderr for details.)\n",r.message);}if(r)return s;var n=e.level;for(t=0;t<this.streams.length;t++){var o=this.streams[t];o.level<=n&&o.stream.write(e);}return s},e}();function z(e){return function(){var r=this;function t(t){var n;t[0]instanceof Error?(s={err:r.serializers&&r.serializers.err?r.serializers.err(t[0]):k.err(t[0])},n={err:!0},i=1===t.length?[s.err.message]:Array.prototype.slice.call(t,1)):"object"!=typeof t[0]&&null!==t[0]||Array.isArray(t[0])?(s=null,i=Array.prototype.slice.call(t)):(s=t[0],i=1===t.length&&s.err&&s.err instanceof Error?[s.err.message]:Array.prototype.slice.call(t,1));var o=h(r.fields);o.level=e;var a=s?h(s):null;if(a&&(r.serializers&&r._applySerializers(a,n),Object.keys(a).forEach(function(e){o[e]=a[e];})),o.levelName=l[e],o.msg=i.length?p.apply(r,i):"",o.time||(o.time=new Date),r.src&&!o.src)try{throw new Error("call-stack-error")}catch(e){var c=e.stack?m(e.stack,2):"";c||g("src")||d("Unable to determine src line info","src"),o.src=c||"";}return o.v=1,o}var s=null,i=arguments,n=null;if(0===arguments.length)return this._level<=e;this._level>e||(n=t(i),this._emit(n));}}function S(e){var r=e.stack||e.toString();if(e.cause&&"function"==typeof e.cause){var t=e.cause();t&&(r+="\nCaused by: "+S(t));}return r}j.prototype.trace=z(10),j.prototype.debug=z(20),j.prototype.info=z(30),j.prototype.warn=z(40),j.prototype.error=z(50),j.prototype.fatal=z(60);var k={err:function(e){return e&&e.stack?{message:e.message,name:e.name,stack:S(e),code:e.code,signal:e.signal}:e}};function E(){return f(j,[].slice.call(arguments))}var A={levels:{trace:"color: DeepPink",debug:"color: GoldenRod",info:"color: DarkTurquoise",warn:"color: Purple",error:"color: Crimson",fatal:"color: Black"},def:"color: DimGray",msg:"color: SteelBlue",src:"color: DimGray; font-style: italic; font-size: 0.9em"},R=/*#__PURE__*/function(){function e(e){var r=void 0===e?{}:e,t=r.logByLevel,s=r.css,i=void 0===s?A:s;this.logByLevel=void 0!==t&&t,this.css=i;}return e.prototype.write=function(e){var r,t,s=this.css.def,i=this.css.msg,n=this.css.src,o=e.childName?e.name+"/"+e.childName:e.name,a=l[e.level],c=(Array(6-a.length).join(" ")+a).toUpperCase();this.logByLevel?(10===e.level?a="debug":60===e.level&&(a="error"),t="function"==typeof console[a]?console[a]:console.log):t=console.log,r=e.level<20?this.css.levels.trace:e.level<30?this.css.levels.debug:e.level<40?this.css.levels.info:e.level<50?this.css.levels.warn:e.level<60?this.css.levels.error:this.css.levels.fatal;var u=function(e,r){return Array(r+1-(e+"").length).join("0")+e},f=[];f.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s "+(e.src?"%c%s":"")),f.push(u(e.time.getHours(),2)),f.push(u(e.time.getMinutes(),2)),f.push(u(e.time.getSeconds(),2)),f.push(u(e.time.getMilliseconds(),4)),f.push(r),f.push(c),f.push(s),f.push(o),f.push(i),f.push(e.msg),e.src&&(f.push(n),f.push(e.src)),e.obj&&(f.push("\n"),f.push(e.obj)),e.err&&e.err.stack&&(f.push("\n"),f.push(e.err.stack)),t.apply(console,f);},e.getDefaultCss=function(){return A},e}();
|
|
64
64
|
|
|
65
|
-
var __defProp = Object.defineProperty;
|
|
66
|
-
var __defProps = Object.defineProperties;
|
|
67
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
68
|
-
var __getOwnPropSymbols$
|
|
69
|
-
var __hasOwnProp$
|
|
70
|
-
var __propIsEnum$
|
|
71
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
72
|
-
var __spreadValues = (a, b) => {
|
|
65
|
+
var __defProp$1 = Object.defineProperty;
|
|
66
|
+
var __defProps$1 = Object.defineProperties;
|
|
67
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
68
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
69
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
70
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
71
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
72
|
+
var __spreadValues$1 = (a, b) => {
|
|
73
73
|
for (var prop in b || (b = {}))
|
|
74
|
-
if (__hasOwnProp$
|
|
75
|
-
__defNormalProp(a, prop, b[prop]);
|
|
76
|
-
if (__getOwnPropSymbols$
|
|
77
|
-
for (var prop of __getOwnPropSymbols$
|
|
78
|
-
if (__propIsEnum$
|
|
79
|
-
__defNormalProp(a, prop, b[prop]);
|
|
74
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
75
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
76
|
+
if (__getOwnPropSymbols$6)
|
|
77
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
78
|
+
if (__propIsEnum$6.call(b, prop))
|
|
79
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
80
80
|
}
|
|
81
81
|
return a;
|
|
82
82
|
};
|
|
83
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
83
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
84
84
|
const streams = [];
|
|
85
85
|
if (process.env.NODE_ENV === "production") {
|
|
86
86
|
streams.push({
|
|
@@ -89,7 +89,7 @@ if (process.env.NODE_ENV === "production") {
|
|
|
89
89
|
}
|
|
90
90
|
const logger = E({
|
|
91
91
|
name: "shipengine",
|
|
92
|
-
serializers: __spreadProps(__spreadValues({}, k), {
|
|
92
|
+
serializers: __spreadProps$1(__spreadValues$1({}, k), {
|
|
93
93
|
req: (req) => ({
|
|
94
94
|
headers: req.headers,
|
|
95
95
|
method: req.method,
|
|
@@ -114,7 +114,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
|
|
|
114
114
|
throw error;
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
var __async$
|
|
117
|
+
var __async$j = (__this, __arguments, generator) => {
|
|
118
118
|
return new Promise((resolve, reject) => {
|
|
119
119
|
var fulfilled = (value) => {
|
|
120
120
|
try {
|
|
@@ -137,7 +137,7 @@ var __async$i = (__this, __arguments, generator) => {
|
|
|
137
137
|
const useAddFunds = (carrierId) => {
|
|
138
138
|
const { client } = useShipEngine();
|
|
139
139
|
return reactQuery.useMutation({
|
|
140
|
-
mutationFn: (funds) => __async$
|
|
140
|
+
mutationFn: (funds) => __async$j(void 0, null, function* () {
|
|
141
141
|
const result = yield client.carriers.addFunds(carrierId, funds);
|
|
142
142
|
return result.data;
|
|
143
143
|
}),
|
|
@@ -146,7 +146,7 @@ const useAddFunds = (carrierId) => {
|
|
|
146
146
|
});
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
var __async$
|
|
149
|
+
var __async$i = (__this, __arguments, generator) => {
|
|
150
150
|
return new Promise((resolve, reject) => {
|
|
151
151
|
var fulfilled = (value) => {
|
|
152
152
|
try {
|
|
@@ -169,7 +169,7 @@ var __async$h = (__this, __arguments, generator) => {
|
|
|
169
169
|
const useCalculateRates = () => {
|
|
170
170
|
const { client } = useShipEngine();
|
|
171
171
|
return reactQuery.useMutation({
|
|
172
|
-
mutationFn: (_0) => __async$
|
|
172
|
+
mutationFn: (_0) => __async$i(void 0, [_0], function* ({ rateOptions, shipmentId }) {
|
|
173
173
|
const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
|
|
174
174
|
return result.data;
|
|
175
175
|
}),
|
|
@@ -178,7 +178,7 @@ const useCalculateRates = () => {
|
|
|
178
178
|
});
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
var __async$
|
|
181
|
+
var __async$h = (__this, __arguments, generator) => {
|
|
182
182
|
return new Promise((resolve, reject) => {
|
|
183
183
|
var fulfilled = (value) => {
|
|
184
184
|
try {
|
|
@@ -201,7 +201,7 @@ var __async$g = (__this, __arguments, generator) => {
|
|
|
201
201
|
const useConnectCarrier = () => {
|
|
202
202
|
const { client } = useShipEngine();
|
|
203
203
|
return reactQuery.useMutation({
|
|
204
|
-
mutationFn: (params) => __async$
|
|
204
|
+
mutationFn: (params) => __async$h(void 0, null, function* () {
|
|
205
205
|
const result = yield client.carriers.connect(params);
|
|
206
206
|
return result.data;
|
|
207
207
|
}),
|
|
@@ -210,7 +210,7 @@ const useConnectCarrier = () => {
|
|
|
210
210
|
});
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
-
var __async$
|
|
213
|
+
var __async$g = (__this, __arguments, generator) => {
|
|
214
214
|
return new Promise((resolve, reject) => {
|
|
215
215
|
var fulfilled = (value) => {
|
|
216
216
|
try {
|
|
@@ -233,7 +233,7 @@ var __async$f = (__this, __arguments, generator) => {
|
|
|
233
233
|
const useCreateFundingSource = () => {
|
|
234
234
|
const { client } = useShipEngine();
|
|
235
235
|
return reactQuery.useMutation({
|
|
236
|
-
mutationFn: (fundingSource) => __async$
|
|
236
|
+
mutationFn: (fundingSource) => __async$g(void 0, null, function* () {
|
|
237
237
|
const result = yield client.fundingSources.create(fundingSource);
|
|
238
238
|
return result.data;
|
|
239
239
|
}),
|
|
@@ -242,22 +242,22 @@ const useCreateFundingSource = () => {
|
|
|
242
242
|
});
|
|
243
243
|
};
|
|
244
244
|
|
|
245
|
-
var __getOwnPropSymbols$
|
|
246
|
-
var __hasOwnProp$
|
|
247
|
-
var __propIsEnum$
|
|
245
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
246
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
247
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
248
248
|
var __objRest$4 = (source, exclude) => {
|
|
249
249
|
var target = {};
|
|
250
250
|
for (var prop in source)
|
|
251
|
-
if (__hasOwnProp$
|
|
251
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
252
252
|
target[prop] = source[prop];
|
|
253
|
-
if (source != null && __getOwnPropSymbols$
|
|
254
|
-
for (var prop of __getOwnPropSymbols$
|
|
255
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
253
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
254
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
255
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
256
256
|
target[prop] = source[prop];
|
|
257
257
|
}
|
|
258
258
|
return target;
|
|
259
259
|
};
|
|
260
|
-
var __async$
|
|
260
|
+
var __async$f = (__this, __arguments, generator) => {
|
|
261
261
|
return new Promise((resolve, reject) => {
|
|
262
262
|
var fulfilled = (value) => {
|
|
263
263
|
try {
|
|
@@ -280,7 +280,7 @@ var __async$e = (__this, __arguments, generator) => {
|
|
|
280
280
|
const useCreateLabel = () => {
|
|
281
281
|
const { client } = useShipEngine();
|
|
282
282
|
return reactQuery.useMutation({
|
|
283
|
-
mutationFn: (_a) => __async$
|
|
283
|
+
mutationFn: (_a) => __async$f(void 0, null, function* () {
|
|
284
284
|
var _b = _a, { rateId } = _b, options = __objRest$4(_b, ["rateId"]);
|
|
285
285
|
const result = yield client.labels.createByRateId(rateId, options);
|
|
286
286
|
return result.data;
|
|
@@ -290,22 +290,22 @@ const useCreateLabel = () => {
|
|
|
290
290
|
});
|
|
291
291
|
};
|
|
292
292
|
|
|
293
|
-
var __getOwnPropSymbols$
|
|
294
|
-
var __hasOwnProp$
|
|
295
|
-
var __propIsEnum$
|
|
293
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
294
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
295
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
296
296
|
var __objRest$3 = (source, exclude) => {
|
|
297
297
|
var target = {};
|
|
298
298
|
for (var prop in source)
|
|
299
|
-
if (__hasOwnProp$
|
|
299
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
300
300
|
target[prop] = source[prop];
|
|
301
|
-
if (source != null && __getOwnPropSymbols$
|
|
302
|
-
for (var prop of __getOwnPropSymbols$
|
|
303
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
301
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
302
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
303
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
304
304
|
target[prop] = source[prop];
|
|
305
305
|
}
|
|
306
306
|
return target;
|
|
307
307
|
};
|
|
308
|
-
var __async$
|
|
308
|
+
var __async$e = (__this, __arguments, generator) => {
|
|
309
309
|
return new Promise((resolve, reject) => {
|
|
310
310
|
var fulfilled = (value) => {
|
|
311
311
|
try {
|
|
@@ -328,7 +328,7 @@ var __async$d = (__this, __arguments, generator) => {
|
|
|
328
328
|
const useCreateSalesOrderShipment = () => {
|
|
329
329
|
const { client } = useShipEngine();
|
|
330
330
|
return reactQuery.useMutation({
|
|
331
|
-
mutationFn: (_a) => __async$
|
|
331
|
+
mutationFn: (_a) => __async$e(void 0, null, function* () {
|
|
332
332
|
var _b = _a, { salesOrderId } = _b, shipment = __objRest$3(_b, ["salesOrderId"]);
|
|
333
333
|
const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
|
|
334
334
|
return result.data;
|
|
@@ -338,6 +338,75 @@ const useCreateSalesOrderShipment = () => {
|
|
|
338
338
|
});
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
+
var __defProp = Object.defineProperty;
|
|
342
|
+
var __defProps = Object.defineProperties;
|
|
343
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
344
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
345
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
346
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
347
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
348
|
+
var __spreadValues = (a, b) => {
|
|
349
|
+
for (var prop in b || (b = {}))
|
|
350
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
351
|
+
__defNormalProp(a, prop, b[prop]);
|
|
352
|
+
if (__getOwnPropSymbols$3)
|
|
353
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
354
|
+
if (__propIsEnum$3.call(b, prop))
|
|
355
|
+
__defNormalProp(a, prop, b[prop]);
|
|
356
|
+
}
|
|
357
|
+
return a;
|
|
358
|
+
};
|
|
359
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
360
|
+
var __async$d = (__this, __arguments, generator) => {
|
|
361
|
+
return new Promise((resolve, reject) => {
|
|
362
|
+
var fulfilled = (value) => {
|
|
363
|
+
try {
|
|
364
|
+
step(generator.next(value));
|
|
365
|
+
} catch (e) {
|
|
366
|
+
reject(e);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
var rejected = (value) => {
|
|
370
|
+
try {
|
|
371
|
+
step(generator.throw(value));
|
|
372
|
+
} catch (e) {
|
|
373
|
+
reject(e);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
377
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
const useCreateShipment = () => {
|
|
381
|
+
const { client } = useShipEngine();
|
|
382
|
+
return reactQuery.useMutation({
|
|
383
|
+
mutationFn: (shipment) => __async$d(void 0, null, function* () {
|
|
384
|
+
var _a;
|
|
385
|
+
if (shipment.warehouseId === void 0) {
|
|
386
|
+
throw new jsApi.SE.CodedError("errorMessages.noWarehouses", {
|
|
387
|
+
errorCode: "unknown",
|
|
388
|
+
errorSource: "client",
|
|
389
|
+
errorType: "business_rules"
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
const shipTo = (_a = shipment.shipTo) != null ? _a : {
|
|
393
|
+
addressLine1: "",
|
|
394
|
+
cityLocality: "",
|
|
395
|
+
countryCode: "",
|
|
396
|
+
name: "",
|
|
397
|
+
phone: "",
|
|
398
|
+
postalCode: "",
|
|
399
|
+
stateProvince: ""
|
|
400
|
+
};
|
|
401
|
+
return (yield client.shipments.create(__spreadProps(__spreadValues({}, shipment), {
|
|
402
|
+
shipTo
|
|
403
|
+
}))).data;
|
|
404
|
+
}),
|
|
405
|
+
mutationKey: ["useCreateShipment"],
|
|
406
|
+
onError
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
|
|
341
410
|
var __async$c = (__this, __arguments, generator) => {
|
|
342
411
|
return new Promise((resolve, reject) => {
|
|
343
412
|
var fulfilled = (value) => {
|
|
@@ -599,6 +668,19 @@ const useListOrderSources = () => {
|
|
|
599
668
|
});
|
|
600
669
|
};
|
|
601
670
|
|
|
671
|
+
const useListRateCards = (carrierIds) => {
|
|
672
|
+
const { client } = useShipEngine();
|
|
673
|
+
return reactQuery.useQuery({
|
|
674
|
+
enabled: !!carrierIds.length,
|
|
675
|
+
onError,
|
|
676
|
+
queryFn: () => {
|
|
677
|
+
return client.rateCards.list(carrierIds);
|
|
678
|
+
},
|
|
679
|
+
queryKey: ["useListRateCards", carrierIds],
|
|
680
|
+
select: (result) => result.data.rateCards
|
|
681
|
+
});
|
|
682
|
+
};
|
|
683
|
+
|
|
602
684
|
const useListSalesOrderShipments = (params) => {
|
|
603
685
|
const { client } = useShipEngine();
|
|
604
686
|
return reactQuery.useQuery({
|
|
@@ -1091,6 +1173,7 @@ exports.useConnectCarrier = useConnectCarrier;
|
|
|
1091
1173
|
exports.useCreateFundingSource = useCreateFundingSource;
|
|
1092
1174
|
exports.useCreateLabel = useCreateLabel;
|
|
1093
1175
|
exports.useCreateSalesOrderShipment = useCreateSalesOrderShipment;
|
|
1176
|
+
exports.useCreateShipment = useCreateShipment;
|
|
1094
1177
|
exports.useCreateWarehouse = useCreateWarehouse;
|
|
1095
1178
|
exports.useDeleteWarehouse = useDeleteWarehouse;
|
|
1096
1179
|
exports.useGetAccountSettings = useGetAccountSettings;
|
|
@@ -1109,6 +1192,7 @@ exports.useListCustomPackageTypes = useListCustomPackageTypes;
|
|
|
1109
1192
|
exports.useListFundingSources = useListFundingSources;
|
|
1110
1193
|
exports.useListLabels = useListLabels;
|
|
1111
1194
|
exports.useListOrderSources = useListOrderSources;
|
|
1195
|
+
exports.useListRateCards = useListRateCards;
|
|
1112
1196
|
exports.useListSalesOrderShipments = useListSalesOrderShipments;
|
|
1113
1197
|
exports.useListSalesOrders = useListSalesOrders;
|
|
1114
1198
|
exports.useListWarehouses = useListWarehouses;
|
package/index.mjs
CHANGED
|
@@ -59,25 +59,25 @@ const onError = (errors) => errors.forEach(console.log);
|
|
|
59
59
|
|
|
60
60
|
var o={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},l={};function a(e){return "string"==typeof e?o[e.toLowerCase()]:e}function c(e,r){return c=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},c(e,r)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return !1}}function f(e,r,t){return f=u()?Reflect.construct:function(e,r,t){var s=[null];s.push.apply(s,r);var i=new(Function.bind.apply(e,s));return t&&c(i,t.prototype),i},f.apply(null,arguments)}function h(e){if(null==e)return e;if(Array.isArray(e))return e.slice();if("object"==typeof e){var r={};return Object.keys(e).forEach(function(t){r[t]=e[t];}),r}return e}function v(e){return void 0===e?"undefined":null===e?"null":Array.isArray(e)?"[ "+e.map(function(e){return v(e)}).join(", ")+" ]":"object"==typeof e?JSON.stringify(e):"function"==typeof e?"[Function: "+e.name+"]":"boolean"==typeof e||"number"==typeof e?e:"'"+e.toString()+"'"}function p(e){if("string"!=typeof e){for(var r=new Array(arguments.length),t=0;t<arguments.length;t++)r[t]=v(arguments[t]);return r.join(" ")}for(var s=/%[sdj%]/g,i=1,n=arguments,o=n.length,l=String(e).replace(s,function(e){if("%%"===e)return "%";if(i>=o)return e;switch(e){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch(e){return "[Circular]"}default:return e}}),a=n[i];i<o;a=n[++i])l+=null===a||"object"!=typeof a?" "+a:" "+v(a);return l}function m(e,r){var t=e.split("\n");t[0]&&t[0].indexOf("call-stack-error")>=0&&t.shift();var s=t[r],i=null;if(s){var n=/^\s*(at|.*@)\s*(.+)?$/.exec(s);i=Array.isArray(n)&&n[2]?n[2]:s;}return i}Object.keys(o).forEach(function(e){l[o[e]]=e;});var y={};function d(e,r){if(r){if(y[r])return;y[r]=!0;}console.error(e+"\n");}function g(e){return y[e]}function w(){var e=[];return function(r,t){return t&&"object"==typeof t?-1!==e.indexOf(t)?"[Circular]":(e.push(t),t):t}}var b=/*#__PURE__*/function(){function e(){}return e.prototype.write=function(e){e.level<30?console.log(e):e.level<40?console.info(e):e.level<50?console.warn(e):console.error(e),e.err&&e.err.stack&&console.error(e.err.stack),e.obj&&console.log(e.obj);},e}(),j=/*#__PURE__*/function(){function e(r,t,s){var i,n,o,l,a=this;if(!(this instanceof e))return new e(r,t);if(void 0!==t&&(i=r,r=t,!(i instanceof e)))throw new TypeError("invalid Logger creation: do not pass a second arg");if(!r)throw new TypeError("options (object) is required");if(i){if(r.name)throw new TypeError("invalid options.name: child cannot set logger name")}else if(!r.name)throw new TypeError("options.name (string) is required");if(r.stream&&r.streams)throw new TypeError('cannot mix "streams" and "stream" options');if(r.streams&&!Array.isArray(r.streams))throw new TypeError("invalid options.streams: must be an array");if(r.serializers&&("object"!=typeof r.serializers||Array.isArray(r.serializers)))throw new TypeError("invalid options.serializers: must be an object");if(i&&s){this._level=i._level,this.streams=i.streams,this.serializers=i.serializers,this.src=i.src,n=this.fields={};var c=Object.keys(i.fields);for(l=0;l<c.length;l++)n[o=c[l]]=i.fields[o];var u=Object.keys(r);for(l=0;l<u.length;l++)n[o=u[l]]=r[o];}else {if(i){for(this._level=i._level,this.streams=[],l=0;l<i.streams.length;l++){var f=h(i.streams[l]);this.streams.push(f);}this.serializers=h(i.serializers),this.src=i.src,this.fields=h(i.fields),r.level&&this.level(r.level);}else this._level=Number.POSITIVE_INFINITY,this.streams=[],this.serializers=null,this.src=!1,this.fields={};r.stream?this.addStream({type:"stream",stream:r.stream,level:r.level}):r.streams?r.streams.forEach(function(e){a.addStream(e,r.level);}):i&&r.level?this.level(r.level):i||this.addStream({type:"raw",stream:new b,level:r.level}),r.serializers&&this.addSerializers(r.serializers),r.src&&(this.src=!0),delete(n=h(r)).stream,delete n.level,delete n.streams,delete n.serializers,delete n.src,this.serializers&&this._applySerializers(n),Object.keys(n).forEach(function(e){a.fields[e]=n[e];});}}var r=e.prototype;return r.addStream=function(e,r){void 0===r&&(r=30),(e=h(e)).type="raw",e.level=a(e.level||r),e.level<this._level&&(this._level=e.level),this.streams.push(e),delete this.haveNonRawStreams;},r.addSerializers=function(e){var r=this;this.serializers||(this.serializers={}),Object.keys(e).forEach(function(t){var s=e[t];if("function"!=typeof s)throw new TypeError(p('invalid serializer for "%s" field: must be a function',t));r.serializers[t]=s;});},r.child=function(e,r){return new this.constructor(this,e||{},r)},r.level=function(e){if(void 0===e)return this._level;for(var r=a(e),t=this.streams.length,s=0;s<t;s++)this.streams[s].level=r;this._level=r;},r.levels=function(e,r){if(void 0===e)return this.streams.map(function(e){return e.level});var t;if("number"==typeof e){if(void 0===(t=this.streams[e]))throw new Error("invalid stream index: "+e)}else {for(var s=this.streams.length,i=0;i<s;i++){var n=this.streams[i];if(n.name===e){t=n;break}}if(!t)throw new Error(p('no stream with name "%s"',e))}if(void 0===r)return t.level;var o=a(r);t.level=o,o<this._level&&(this._level=o);},r._applySerializers=function(e,r){var t=this;Object.keys(this.serializers).forEach(function(s){if(!(void 0===e[s]||r&&r[s]))try{e[s]=t.serializers[s](e[s]);}catch(r){d(p('bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.\n%s',s,r.stack||r)),e[s]=p('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)',s);}});},r._emit=function(e,r){var t,s;if(void 0===this.haveNonRawStreams)for(this.haveNonRawStreams=!1,t=0;t<this.streams.length;t++)if(!this.streams[t].raw){this.haveNonRawStreams=!0;break}if(r||this.haveNonRawStreams)try{s=JSON.stringify(e,w())+"\n";}catch(r){var i=r.stack.split(/\n/g,2).join("\n");d('bunyan: ERROR: Exception in `JSON.stringify(rec)`. You can install the "safe-json-stringify" module to have Bunyan fallback to safer stringification. Record:\n'+function(e,r){return r||(r=" "),r+e.split(/\r?\n/g).join("\n"+r)}(p("%s\n%s",e,r.stack)),i),s=p("(Exception in JSON.stringify(rec): %j. See stderr for details.)\n",r.message);}if(r)return s;var n=e.level;for(t=0;t<this.streams.length;t++){var o=this.streams[t];o.level<=n&&o.stream.write(e);}return s},e}();function z(e){return function(){var r=this;function t(t){var n;t[0]instanceof Error?(s={err:r.serializers&&r.serializers.err?r.serializers.err(t[0]):k.err(t[0])},n={err:!0},i=1===t.length?[s.err.message]:Array.prototype.slice.call(t,1)):"object"!=typeof t[0]&&null!==t[0]||Array.isArray(t[0])?(s=null,i=Array.prototype.slice.call(t)):(s=t[0],i=1===t.length&&s.err&&s.err instanceof Error?[s.err.message]:Array.prototype.slice.call(t,1));var o=h(r.fields);o.level=e;var a=s?h(s):null;if(a&&(r.serializers&&r._applySerializers(a,n),Object.keys(a).forEach(function(e){o[e]=a[e];})),o.levelName=l[e],o.msg=i.length?p.apply(r,i):"",o.time||(o.time=new Date),r.src&&!o.src)try{throw new Error("call-stack-error")}catch(e){var c=e.stack?m(e.stack,2):"";c||g("src")||d("Unable to determine src line info","src"),o.src=c||"";}return o.v=1,o}var s=null,i=arguments,n=null;if(0===arguments.length)return this._level<=e;this._level>e||(n=t(i),this._emit(n));}}function S(e){var r=e.stack||e.toString();if(e.cause&&"function"==typeof e.cause){var t=e.cause();t&&(r+="\nCaused by: "+S(t));}return r}j.prototype.trace=z(10),j.prototype.debug=z(20),j.prototype.info=z(30),j.prototype.warn=z(40),j.prototype.error=z(50),j.prototype.fatal=z(60);var k={err:function(e){return e&&e.stack?{message:e.message,name:e.name,stack:S(e),code:e.code,signal:e.signal}:e}};function E(){return f(j,[].slice.call(arguments))}var A={levels:{trace:"color: DeepPink",debug:"color: GoldenRod",info:"color: DarkTurquoise",warn:"color: Purple",error:"color: Crimson",fatal:"color: Black"},def:"color: DimGray",msg:"color: SteelBlue",src:"color: DimGray; font-style: italic; font-size: 0.9em"},R=/*#__PURE__*/function(){function e(e){var r=void 0===e?{}:e,t=r.logByLevel,s=r.css,i=void 0===s?A:s;this.logByLevel=void 0!==t&&t,this.css=i;}return e.prototype.write=function(e){var r,t,s=this.css.def,i=this.css.msg,n=this.css.src,o=e.childName?e.name+"/"+e.childName:e.name,a=l[e.level],c=(Array(6-a.length).join(" ")+a).toUpperCase();this.logByLevel?(10===e.level?a="debug":60===e.level&&(a="error"),t="function"==typeof console[a]?console[a]:console.log):t=console.log,r=e.level<20?this.css.levels.trace:e.level<30?this.css.levels.debug:e.level<40?this.css.levels.info:e.level<50?this.css.levels.warn:e.level<60?this.css.levels.error:this.css.levels.fatal;var u=function(e,r){return Array(r+1-(e+"").length).join("0")+e},f=[];f.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s "+(e.src?"%c%s":"")),f.push(u(e.time.getHours(),2)),f.push(u(e.time.getMinutes(),2)),f.push(u(e.time.getSeconds(),2)),f.push(u(e.time.getMilliseconds(),4)),f.push(r),f.push(c),f.push(s),f.push(o),f.push(i),f.push(e.msg),e.src&&(f.push(n),f.push(e.src)),e.obj&&(f.push("\n"),f.push(e.obj)),e.err&&e.err.stack&&(f.push("\n"),f.push(e.err.stack)),t.apply(console,f);},e.getDefaultCss=function(){return A},e}();
|
|
61
61
|
|
|
62
|
-
var __defProp = Object.defineProperty;
|
|
63
|
-
var __defProps = Object.defineProperties;
|
|
64
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
65
|
-
var __getOwnPropSymbols$
|
|
66
|
-
var __hasOwnProp$
|
|
67
|
-
var __propIsEnum$
|
|
68
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
69
|
-
var __spreadValues = (a, b) => {
|
|
62
|
+
var __defProp$1 = Object.defineProperty;
|
|
63
|
+
var __defProps$1 = Object.defineProperties;
|
|
64
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
65
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
66
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
67
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
68
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
69
|
+
var __spreadValues$1 = (a, b) => {
|
|
70
70
|
for (var prop in b || (b = {}))
|
|
71
|
-
if (__hasOwnProp$
|
|
72
|
-
__defNormalProp(a, prop, b[prop]);
|
|
73
|
-
if (__getOwnPropSymbols$
|
|
74
|
-
for (var prop of __getOwnPropSymbols$
|
|
75
|
-
if (__propIsEnum$
|
|
76
|
-
__defNormalProp(a, prop, b[prop]);
|
|
71
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
72
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
73
|
+
if (__getOwnPropSymbols$6)
|
|
74
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
75
|
+
if (__propIsEnum$6.call(b, prop))
|
|
76
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
77
77
|
}
|
|
78
78
|
return a;
|
|
79
79
|
};
|
|
80
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
80
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
81
81
|
const streams = [];
|
|
82
82
|
if (process.env.NODE_ENV === "production") {
|
|
83
83
|
streams.push({
|
|
@@ -86,7 +86,7 @@ if (process.env.NODE_ENV === "production") {
|
|
|
86
86
|
}
|
|
87
87
|
const logger = E({
|
|
88
88
|
name: "shipengine",
|
|
89
|
-
serializers: __spreadProps(__spreadValues({}, k), {
|
|
89
|
+
serializers: __spreadProps$1(__spreadValues$1({}, k), {
|
|
90
90
|
req: (req) => ({
|
|
91
91
|
headers: req.headers,
|
|
92
92
|
method: req.method,
|
|
@@ -111,7 +111,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
|
|
|
111
111
|
throw error;
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
var __async$
|
|
114
|
+
var __async$j = (__this, __arguments, generator) => {
|
|
115
115
|
return new Promise((resolve, reject) => {
|
|
116
116
|
var fulfilled = (value) => {
|
|
117
117
|
try {
|
|
@@ -134,7 +134,7 @@ var __async$i = (__this, __arguments, generator) => {
|
|
|
134
134
|
const useAddFunds = (carrierId) => {
|
|
135
135
|
const { client } = useShipEngine();
|
|
136
136
|
return useMutation({
|
|
137
|
-
mutationFn: (funds) => __async$
|
|
137
|
+
mutationFn: (funds) => __async$j(void 0, null, function* () {
|
|
138
138
|
const result = yield client.carriers.addFunds(carrierId, funds);
|
|
139
139
|
return result.data;
|
|
140
140
|
}),
|
|
@@ -143,7 +143,7 @@ const useAddFunds = (carrierId) => {
|
|
|
143
143
|
});
|
|
144
144
|
};
|
|
145
145
|
|
|
146
|
-
var __async$
|
|
146
|
+
var __async$i = (__this, __arguments, generator) => {
|
|
147
147
|
return new Promise((resolve, reject) => {
|
|
148
148
|
var fulfilled = (value) => {
|
|
149
149
|
try {
|
|
@@ -166,7 +166,7 @@ var __async$h = (__this, __arguments, generator) => {
|
|
|
166
166
|
const useCalculateRates = () => {
|
|
167
167
|
const { client } = useShipEngine();
|
|
168
168
|
return useMutation({
|
|
169
|
-
mutationFn: (_0) => __async$
|
|
169
|
+
mutationFn: (_0) => __async$i(void 0, [_0], function* ({ rateOptions, shipmentId }) {
|
|
170
170
|
const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
|
|
171
171
|
return result.data;
|
|
172
172
|
}),
|
|
@@ -175,7 +175,7 @@ const useCalculateRates = () => {
|
|
|
175
175
|
});
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
var __async$
|
|
178
|
+
var __async$h = (__this, __arguments, generator) => {
|
|
179
179
|
return new Promise((resolve, reject) => {
|
|
180
180
|
var fulfilled = (value) => {
|
|
181
181
|
try {
|
|
@@ -198,7 +198,7 @@ var __async$g = (__this, __arguments, generator) => {
|
|
|
198
198
|
const useConnectCarrier = () => {
|
|
199
199
|
const { client } = useShipEngine();
|
|
200
200
|
return useMutation({
|
|
201
|
-
mutationFn: (params) => __async$
|
|
201
|
+
mutationFn: (params) => __async$h(void 0, null, function* () {
|
|
202
202
|
const result = yield client.carriers.connect(params);
|
|
203
203
|
return result.data;
|
|
204
204
|
}),
|
|
@@ -207,7 +207,7 @@ const useConnectCarrier = () => {
|
|
|
207
207
|
});
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
var __async$
|
|
210
|
+
var __async$g = (__this, __arguments, generator) => {
|
|
211
211
|
return new Promise((resolve, reject) => {
|
|
212
212
|
var fulfilled = (value) => {
|
|
213
213
|
try {
|
|
@@ -230,7 +230,7 @@ var __async$f = (__this, __arguments, generator) => {
|
|
|
230
230
|
const useCreateFundingSource = () => {
|
|
231
231
|
const { client } = useShipEngine();
|
|
232
232
|
return useMutation({
|
|
233
|
-
mutationFn: (fundingSource) => __async$
|
|
233
|
+
mutationFn: (fundingSource) => __async$g(void 0, null, function* () {
|
|
234
234
|
const result = yield client.fundingSources.create(fundingSource);
|
|
235
235
|
return result.data;
|
|
236
236
|
}),
|
|
@@ -239,22 +239,22 @@ const useCreateFundingSource = () => {
|
|
|
239
239
|
});
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
var __getOwnPropSymbols$
|
|
243
|
-
var __hasOwnProp$
|
|
244
|
-
var __propIsEnum$
|
|
242
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
243
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
244
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
245
245
|
var __objRest$4 = (source, exclude) => {
|
|
246
246
|
var target = {};
|
|
247
247
|
for (var prop in source)
|
|
248
|
-
if (__hasOwnProp$
|
|
248
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
249
249
|
target[prop] = source[prop];
|
|
250
|
-
if (source != null && __getOwnPropSymbols$
|
|
251
|
-
for (var prop of __getOwnPropSymbols$
|
|
252
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
250
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
251
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
252
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
253
253
|
target[prop] = source[prop];
|
|
254
254
|
}
|
|
255
255
|
return target;
|
|
256
256
|
};
|
|
257
|
-
var __async$
|
|
257
|
+
var __async$f = (__this, __arguments, generator) => {
|
|
258
258
|
return new Promise((resolve, reject) => {
|
|
259
259
|
var fulfilled = (value) => {
|
|
260
260
|
try {
|
|
@@ -277,7 +277,7 @@ var __async$e = (__this, __arguments, generator) => {
|
|
|
277
277
|
const useCreateLabel = () => {
|
|
278
278
|
const { client } = useShipEngine();
|
|
279
279
|
return useMutation({
|
|
280
|
-
mutationFn: (_a) => __async$
|
|
280
|
+
mutationFn: (_a) => __async$f(void 0, null, function* () {
|
|
281
281
|
var _b = _a, { rateId } = _b, options = __objRest$4(_b, ["rateId"]);
|
|
282
282
|
const result = yield client.labels.createByRateId(rateId, options);
|
|
283
283
|
return result.data;
|
|
@@ -287,22 +287,22 @@ const useCreateLabel = () => {
|
|
|
287
287
|
});
|
|
288
288
|
};
|
|
289
289
|
|
|
290
|
-
var __getOwnPropSymbols$
|
|
291
|
-
var __hasOwnProp$
|
|
292
|
-
var __propIsEnum$
|
|
290
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
291
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
292
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
293
293
|
var __objRest$3 = (source, exclude) => {
|
|
294
294
|
var target = {};
|
|
295
295
|
for (var prop in source)
|
|
296
|
-
if (__hasOwnProp$
|
|
296
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
297
297
|
target[prop] = source[prop];
|
|
298
|
-
if (source != null && __getOwnPropSymbols$
|
|
299
|
-
for (var prop of __getOwnPropSymbols$
|
|
300
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
298
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
299
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
300
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
301
301
|
target[prop] = source[prop];
|
|
302
302
|
}
|
|
303
303
|
return target;
|
|
304
304
|
};
|
|
305
|
-
var __async$
|
|
305
|
+
var __async$e = (__this, __arguments, generator) => {
|
|
306
306
|
return new Promise((resolve, reject) => {
|
|
307
307
|
var fulfilled = (value) => {
|
|
308
308
|
try {
|
|
@@ -325,7 +325,7 @@ var __async$d = (__this, __arguments, generator) => {
|
|
|
325
325
|
const useCreateSalesOrderShipment = () => {
|
|
326
326
|
const { client } = useShipEngine();
|
|
327
327
|
return useMutation({
|
|
328
|
-
mutationFn: (_a) => __async$
|
|
328
|
+
mutationFn: (_a) => __async$e(void 0, null, function* () {
|
|
329
329
|
var _b = _a, { salesOrderId } = _b, shipment = __objRest$3(_b, ["salesOrderId"]);
|
|
330
330
|
const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
|
|
331
331
|
return result.data;
|
|
@@ -335,6 +335,75 @@ const useCreateSalesOrderShipment = () => {
|
|
|
335
335
|
});
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
+
var __defProp = Object.defineProperty;
|
|
339
|
+
var __defProps = Object.defineProperties;
|
|
340
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
341
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
342
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
343
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
344
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
345
|
+
var __spreadValues = (a, b) => {
|
|
346
|
+
for (var prop in b || (b = {}))
|
|
347
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
348
|
+
__defNormalProp(a, prop, b[prop]);
|
|
349
|
+
if (__getOwnPropSymbols$3)
|
|
350
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
351
|
+
if (__propIsEnum$3.call(b, prop))
|
|
352
|
+
__defNormalProp(a, prop, b[prop]);
|
|
353
|
+
}
|
|
354
|
+
return a;
|
|
355
|
+
};
|
|
356
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
357
|
+
var __async$d = (__this, __arguments, generator) => {
|
|
358
|
+
return new Promise((resolve, reject) => {
|
|
359
|
+
var fulfilled = (value) => {
|
|
360
|
+
try {
|
|
361
|
+
step(generator.next(value));
|
|
362
|
+
} catch (e) {
|
|
363
|
+
reject(e);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
var rejected = (value) => {
|
|
367
|
+
try {
|
|
368
|
+
step(generator.throw(value));
|
|
369
|
+
} catch (e) {
|
|
370
|
+
reject(e);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
374
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
const useCreateShipment = () => {
|
|
378
|
+
const { client } = useShipEngine();
|
|
379
|
+
return useMutation({
|
|
380
|
+
mutationFn: (shipment) => __async$d(void 0, null, function* () {
|
|
381
|
+
var _a;
|
|
382
|
+
if (shipment.warehouseId === void 0) {
|
|
383
|
+
throw new SE.CodedError("errorMessages.noWarehouses", {
|
|
384
|
+
errorCode: "unknown",
|
|
385
|
+
errorSource: "client",
|
|
386
|
+
errorType: "business_rules"
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
const shipTo = (_a = shipment.shipTo) != null ? _a : {
|
|
390
|
+
addressLine1: "",
|
|
391
|
+
cityLocality: "",
|
|
392
|
+
countryCode: "",
|
|
393
|
+
name: "",
|
|
394
|
+
phone: "",
|
|
395
|
+
postalCode: "",
|
|
396
|
+
stateProvince: ""
|
|
397
|
+
};
|
|
398
|
+
return (yield client.shipments.create(__spreadProps(__spreadValues({}, shipment), {
|
|
399
|
+
shipTo
|
|
400
|
+
}))).data;
|
|
401
|
+
}),
|
|
402
|
+
mutationKey: ["useCreateShipment"],
|
|
403
|
+
onError
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
|
|
338
407
|
var __async$c = (__this, __arguments, generator) => {
|
|
339
408
|
return new Promise((resolve, reject) => {
|
|
340
409
|
var fulfilled = (value) => {
|
|
@@ -596,6 +665,19 @@ const useListOrderSources = () => {
|
|
|
596
665
|
});
|
|
597
666
|
};
|
|
598
667
|
|
|
668
|
+
const useListRateCards = (carrierIds) => {
|
|
669
|
+
const { client } = useShipEngine();
|
|
670
|
+
return useQuery({
|
|
671
|
+
enabled: !!carrierIds.length,
|
|
672
|
+
onError,
|
|
673
|
+
queryFn: () => {
|
|
674
|
+
return client.rateCards.list(carrierIds);
|
|
675
|
+
},
|
|
676
|
+
queryKey: ["useListRateCards", carrierIds],
|
|
677
|
+
select: (result) => result.data.rateCards
|
|
678
|
+
});
|
|
679
|
+
};
|
|
680
|
+
|
|
599
681
|
const useListSalesOrderShipments = (params) => {
|
|
600
682
|
const { client } = useShipEngine();
|
|
601
683
|
return useQuery({
|
|
@@ -1076,4 +1158,4 @@ const useVoidLabel = () => {
|
|
|
1076
1158
|
});
|
|
1077
1159
|
};
|
|
1078
1160
|
|
|
1079
|
-
export { ShipEngine, ShipEngineContext, delay, logger, onError, retryUntil, useAddFunds, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateSalesOrderShipment, useCreateWarehouse, useDeleteWarehouse, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetSalesOrder, useGetSalesOrderShipment, useGetShipment, useGetShipmentRates, useGetWalletHistory, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListSalesOrderShipments, useListSalesOrders, useListWarehouses, useNotifySalesOrderShipped, useParseAddress, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateSalesOrderShipment, useUpdateWarehouse, useValidateAddresses, useVoidLabel };
|
|
1161
|
+
export { ShipEngine, ShipEngineContext, delay, logger, onError, retryUntil, useAddFunds, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteWarehouse, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetSalesOrder, useGetSalesOrderShipment, useGetShipment, useGetShipmentRates, useGetWalletHistory, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListWarehouses, useNotifySalesOrderShipped, useParseAddress, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateSalesOrderShipment, useUpdateWarehouse, useValidateAddresses, useVoidLabel };
|