@shipengine/react-api 0.3.3 → 0.4.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 +1 -1
- package/hooks/use-get-wallet-history.d.ts +10 -0
- package/index.js +12 -12
- package/index.mjs +137 -151
- package/package.json +1 -1
- package/hooks/use-get-wallet-transaction-history.d.ts +0 -5
package/hooks/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export * from "./use-get-label";
|
|
|
13
13
|
export * from "./use-get-sales-order";
|
|
14
14
|
export * from "./use-get-sales-order-shipment";
|
|
15
15
|
export * from "./use-get-shipment";
|
|
16
|
-
export * from "./use-get-wallet-
|
|
16
|
+
export * from "./use-get-wallet-history";
|
|
17
17
|
export * from "./use-list-carriers";
|
|
18
18
|
export * from "./use-list-custom-package-types";
|
|
19
19
|
export * from "./use-list-labels";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category ShipEngine API Hooks
|
|
3
|
+
*
|
|
4
|
+
* @see https://react-query-v3.tanstack.com/guides/paginated-queries
|
|
5
|
+
*/
|
|
6
|
+
export declare const useGetWalletHistory: ({ enabled, page, range, }: {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
page: number;
|
|
9
|
+
range: [Date, Date];
|
|
10
|
+
}) => import("react-query").UseQueryResult<import("@shipengine/js-api").WalletTransactionHistory, import("@shipengine/js-api").CodedError[]>;
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react-query"),O=require("react/jsx-runtime"),
|
|
2
|
-
`);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(E).forEach(function(e){
|
|
3
|
-
`)}function
|
|
4
|
-
%s`,n,
|
|
5
|
-
`}catch(
|
|
6
|
-
`);L('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(f,
|
|
7
|
-
`+
|
|
8
|
-
%s`,t,
|
|
9
|
-
`,
|
|
10
|
-
Caused by: `+
|
|
11
|
-
`),
|
|
12
|
-
`),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react-query"),O=require("react/jsx-runtime"),z=require("react"),w=require("@shipengine/js-api"),K=z.createContext(void 0),x=({baseURL:e,children:r,headers:t,getToken:s})=>{const[i,n]=z.useState(()=>{const y=s();if(typeof y=="string")return new w.ShipEngineAPI(y,{baseURL:e,getToken:s,headers:t??{}});y.then(u=>n(new w.ShipEngineAPI(u,{baseURL:e,getToken:s,headers:t??{}})))}),a=new o.QueryClient;return i?O.jsx(K.Provider,{value:{client:i},children:O.jsx(o.QueryClientProvider,{client:a,children:r})}):O.jsx("div",{style:{alignItems:"center",display:"flex",height:"100%",justifyContent:"center",width:"100%"},children:"Loading..."})},c=()=>{const e=z.useContext(K);if(!e)throw new Error("useShipEngine must be called within a ShipEngineProvider");return e},G=e=>new Promise(r=>{setTimeout(()=>r(!0),e)}),l=e=>e.forEach(console.log);var E={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},k={};function A(e){return typeof e=="string"?E[e.toLowerCase()]:e}function j(e,r){return j=Object.setPrototypeOf||function(t,s){return t.__proto__=s,t},j(e,r)}function B(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function C(e,r,t){return C=B()?Reflect.construct:function(s,i,n){var a=[null];a.push.apply(a,i);var y=new(Function.bind.apply(s,a));return n&&j(y,n.prototype),y},C.apply(null,arguments)}function v(e){if(e==null)return e;if(Array.isArray(e))return e.slice();if(typeof e=="object"){var r={};return Object.keys(e).forEach(function(t){r[t]=e[t]}),r}return e}function F(e){return e===void 0?"undefined":e===null?"null":Array.isArray(e)?"[ "+e.map(function(r){return F(r)}).join(", ")+" ]":typeof e=="object"?JSON.stringify(e):typeof e=="function"?"[Function: "+e.name+"]":typeof e=="boolean"||typeof e=="number"?e:"'"+e.toString()+"'"}function m(e){if(typeof e!="string"){for(var r=new Array(arguments.length),t=0;t<arguments.length;t++)r[t]=F(arguments[t]);return r.join(" ")}for(var s=/%[sdj%]/g,i=1,n=arguments,a=n.length,y=String(e).replace(s,function(h){if(h==="%%")return"%";if(i>=a)return h;switch(h){case"%s":return String(n[i++]);case"%d":return Number(n[i++]);case"%j":try{return JSON.stringify(n[i++])}catch{return"[Circular]"}default:return h}}),u=n[i];i<a;u=n[++i])y+=u===null||typeof u!="object"?" "+u:" "+F(u);return y}function U(e,r){var t=e.split(`
|
|
2
|
+
`);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(E).forEach(function(e){k[E[e]]=e});var q={};function L(e,r){if(r){if(q[r])return;q[r]=!0}console.error(e+`
|
|
3
|
+
`)}function T(e){return q[e]}function W(){var e=[];return function(r,t){return t&&typeof t=="object"?e.indexOf(t)!==-1?"[Circular]":(e.push(t),t):t}}var D=function(){function e(){}return e.prototype.write=function(r){r.level<30?console.log(r):r.level<40?console.info(r):r.level<50?console.warn(r):console.error(r),r.err&&r.err.stack&&console.error(r.err.stack),r.obj&&console.log(r.obj)},e}(),p=function(){function e(t,s,i){var n,a,y,u,h=this;if(!(this instanceof e))return new e(t,s);if(s!==void 0&&(n=t,t=s,!(n instanceof e)))throw new TypeError("invalid Logger creation: do not pass a second arg");if(!t)throw new TypeError("options (object) is required");if(n){if(t.name)throw new TypeError("invalid options.name: child cannot set logger name")}else if(!t.name)throw new TypeError("options.name (string) is required");if(t.stream&&t.streams)throw new TypeError('cannot mix "streams" and "stream" options');if(t.streams&&!Array.isArray(t.streams))throw new TypeError("invalid options.streams: must be an array");if(t.serializers&&(typeof t.serializers!="object"||Array.isArray(t.serializers)))throw new TypeError("invalid options.serializers: must be an object");if(n&&i){this._level=n._level,this.streams=n.streams,this.serializers=n.serializers,this.src=n.src,a=this.fields={};var f=Object.keys(n.fields);for(u=0;u<f.length;u++)a[y=f[u]]=n.fields[y];var d=Object.keys(t);for(u=0;u<d.length;u++)a[y=d[u]]=t[y]}else{if(n){for(this._level=n._level,this.streams=[],u=0;u<n.streams.length;u++){var b=v(n.streams[u]);this.streams.push(b)}this.serializers=v(n.serializers),this.src=n.src,this.fields=v(n.fields),t.level&&this.level(t.level)}else this._level=Number.POSITIVE_INFINITY,this.streams=[],this.serializers=null,this.src=!1,this.fields={};t.stream?this.addStream({type:"stream",stream:t.stream,level:t.level}):t.streams?t.streams.forEach(function(g){h.addStream(g,t.level)}):n&&t.level?this.level(t.level):n||this.addStream({type:"raw",stream:new D,level:t.level}),t.serializers&&this.addSerializers(t.serializers),t.src&&(this.src=!0),delete(a=v(t)).stream,delete a.level,delete a.streams,delete a.serializers,delete a.src,this.serializers&&this._applySerializers(a),Object.keys(a).forEach(function(g){h.fields[g]=a[g]})}}var r=e.prototype;return r.addStream=function(t,s){s===void 0&&(s=30),(t=v(t)).type="raw",t.level=A(t.level||s),t.level<this._level&&(this._level=t.level),this.streams.push(t),delete this.haveNonRawStreams},r.addSerializers=function(t){var s=this;this.serializers||(this.serializers={}),Object.keys(t).forEach(function(i){var n=t[i];if(typeof n!="function")throw new TypeError(m('invalid serializer for "%s" field: must be a function',i));s.serializers[i]=n})},r.child=function(t,s){return new this.constructor(this,t||{},s)},r.level=function(t){if(t===void 0)return this._level;for(var s=A(t),i=this.streams.length,n=0;n<i;n++)this.streams[n].level=s;this._level=s},r.levels=function(t,s){if(t===void 0)return this.streams.map(function(h){return h.level});var i;if(typeof t=="number"){if((i=this.streams[t])===void 0)throw new Error("invalid stream index: "+t)}else{for(var n=this.streams.length,a=0;a<n;a++){var y=this.streams[a];if(y.name===t){i=y;break}}if(!i)throw new Error(m('no stream with name "%s"',t))}if(s===void 0)return i.level;var u=A(s);i.level=u,u<this._level&&(this._level=u)},r._applySerializers=function(t,s){var i=this;Object.keys(this.serializers).forEach(function(n){if(!(t[n]===void 0||s&&s[n]))try{t[n]=i.serializers[n](t[n])}catch(a){L(m(`bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.
|
|
4
|
+
%s`,n,a.stack||a)),t[n]=m('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)',n)}})},r._emit=function(t,s){var i,n;if(this.haveNonRawStreams===void 0){for(this.haveNonRawStreams=!1,i=0;i<this.streams.length;i++)if(!this.streams[i].raw){this.haveNonRawStreams=!0;break}}if(s||this.haveNonRawStreams)try{n=JSON.stringify(t,W())+`
|
|
5
|
+
`}catch(h){var a=h.stack.split(/\n/g,2).join(`
|
|
6
|
+
`);L('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(f,d){return d||(d=" "),d+f.split(/\r?\n/g).join(`
|
|
7
|
+
`+d)}(m(`%s
|
|
8
|
+
%s`,t,h.stack)),a),n=m(`(Exception in JSON.stringify(rec): %j. See stderr for details.)
|
|
9
|
+
`,h.message)}if(s)return n;var y=t.level;for(i=0;i<this.streams.length;i++){var u=this.streams[i];u.level<=y&&u.stream.write(t)}return n},e}();function S(e){return function(){var r=this;function t(a){var y;a[0]instanceof Error?(s={err:r.serializers&&r.serializers.err?r.serializers.err(a[0]):_.err(a[0])},y={err:!0},i=a.length===1?[s.err.message]:Array.prototype.slice.call(a,1)):typeof a[0]!="object"&&a[0]!==null||Array.isArray(a[0])?(s=null,i=Array.prototype.slice.call(a)):(s=a[0],i=a.length===1&&s.err&&s.err instanceof Error?[s.err.message]:Array.prototype.slice.call(a,1));var u=v(r.fields);u.level=e;var h=s?v(s):null;if(h&&(r.serializers&&r._applySerializers(h,y),Object.keys(h).forEach(function(d){u[d]=h[d]})),u.levelName=k[e],u.msg=i.length?m.apply(r,i):"",u.time||(u.time=new Date),r.src&&!u.src)try{throw new Error("call-stack-error")}catch(d){var f=d.stack?U(d.stack,2):"";f||T("src")||L("Unable to determine src line info","src"),u.src=f||""}return u.v=1,u}var s=null,i=arguments,n=null;if(arguments.length===0)return this._level<=e;this._level>e||(n=t(i),this._emit(n))}}function P(e){var r=e.stack||e.toString();if(e.cause&&typeof e.cause=="function"){var t=e.cause();t&&(r+=`
|
|
10
|
+
Caused by: `+P(t))}return r}p.prototype.trace=S(10),p.prototype.debug=S(20),p.prototype.info=S(30),p.prototype.warn=S(40),p.prototype.error=S(50),p.prototype.fatal=S(60);var _={err:function(e){return e&&e.stack?{message:e.message,name:e.name,stack:P(e),code:e.code,signal:e.signal}:e}};function V(){return C(p,[].slice.call(arguments))}var R={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"},H=function(){function e(r){var t=r===void 0?{}:r,s=t.logByLevel,i=t.css,n=i===void 0?R:i;this.logByLevel=s!==void 0&&s,this.css=n}return e.prototype.write=function(r){var t,s,i=this.css.def,n=this.css.msg,a=this.css.src,y=r.childName?r.name+"/"+r.childName:r.name,u=k[r.level],h=(Array(6-u.length).join(" ")+u).toUpperCase();this.logByLevel?(r.level===10?u="debug":r.level===60&&(u="error"),s=typeof console[u]=="function"?console[u]:console.log):s=console.log,t=r.level<20?this.css.levels.trace:r.level<30?this.css.levels.debug:r.level<40?this.css.levels.info:r.level<50?this.css.levels.warn:r.level<60?this.css.levels.error:this.css.levels.fatal;var f=function(b,g){return Array(g+1-(b+"").length).join("0")+b},d=[];d.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s "+(r.src?"%c%s":"")),d.push(f(r.time.getHours(),2)),d.push(f(r.time.getMinutes(),2)),d.push(f(r.time.getSeconds(),2)),d.push(f(r.time.getMilliseconds(),4)),d.push(t),d.push(h),d.push(i),d.push(y),d.push(n),d.push(r.msg),r.src&&(d.push(a),d.push(r.src)),r.obj&&(d.push(`
|
|
11
|
+
`),d.push(r.obj)),r.err&&r.err.stack&&(d.push(`
|
|
12
|
+
`),d.push(r.err.stack)),s.apply(console,d)},e.getDefaultCss=function(){return R},e}();const N=[];process.env.NODE_ENV==="production"&&N.push({stream:new H});const J=V({name:"shipengine",serializers:{..._,req:e=>({headers:e.headers,method:e.method,url:e.url}),res:e=>({data:e.data,headers:e.config.headers,method:e.config.method,statusCode:e.status,url:e.config.url})},streams:N}),M=(e,r=10,t=1e3)=>Promise.resolve().then(e).catch(function s(i){if(r-=1,r>0)return G(t).then(e).catch(s);throw i}),I=e=>{const{client:r}=c();return o.useMutation({mutationFn:async t=>(await r.carriers.addFunds(e,t)).data,mutationKey:["useAddFunds"],onError:l})},Y=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({rateOptions:r,shipmentId:t})=>(await e.rates.calculateByShipmentId(t,r)).data,mutationKey:["useCalculateRates"],onError:l})},$=()=>{const{client:e}=c();return o.useMutation({mutationFn:async r=>(await e.carriers.connect(r)).data,mutationKey:["useConnectCarrier"],onError:l})},X=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({rateId:r,...t})=>(await e.labels.createByRateId(r,t)).data,mutationKey:["useCreateLabel"],onError:l})},Z=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({salesOrderId:r,...t})=>(await e.salesOrderShipments.create(r,t)).data,mutationKey:["useCreateSalesOrderShipment"],onError:l})},ee=()=>{const{client:e}=c();return o.useMutation({mutationFn:async r=>(await e.warehouses.create(r)).data,mutationKey:["useCreateWarehouse"],onError:l})},te=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({warehouseId:r})=>(await e.warehouses.delete(r)).data,mutationKey:["useDeleteWarehouse"],onError:l})},re=()=>{const{client:e}=c();return o.useQuery({onError:l,queryFn:()=>e.accountSettings.get(),queryKey:["getAccountSettings"],select:r=>r.data})},se=e=>{const{client:r}=c();return o.useQuery({enabled:e!==void 0,onError:l,queryFn:()=>e?r.carriers.getAutoFunding(e):Promise.reject(new Error("carrierId is required.")),queryKey:["useGetAutoFundingConfiguration",e],select:t=>t.data})},ne=e=>{const{client:r}=c();return o.useQuery({enabled:!!e,onError:l,queryFn:()=>e?r.carriers.get(e):Promise.reject(new Error("carrierId is require")),queryKey:["useGetCarrierById",e],select:t=>t.data,staleTime:5*60*1e3})},ie=e=>{const{client:r}=c();return o.useQuery({enabled:e!==void 0,onError:l,queryFn:()=>e?r.insurance.get(e):Promise.reject(new Error("insuranceProvider is required")),queryKey:["useGetInsuranceAccount",e],select:t=>t.data})},ae=e=>{const{client:r}=c();return o.useQuery({enabled:e!==void 0,onError:l,queryFn:()=>e?r.labels.get(e):Promise.reject(new Error("labelId is require")),queryKey:["useGetLabel",e],select:t=>t.data})},ue=e=>{const{client:r}=c();return o.useQuery({enabled:e!==void 0,onError:l,queryFn:()=>e?r.salesOrders.get(e):Promise.reject(new Error("salesOrderId is required")),queryKey:["useGetSalesOrder",e],select:t=>t.data})},oe=e=>{const{client:r}=c();return o.useQuery({enabled:e!==void 0,onError:l,queryFn:()=>e?r.salesOrderShipments.get(e):Promise.reject(new Error("shipmentId is required")),queryKey:["useGetSalesOrderShipment",e],select:t=>t.data})},le=e=>{const{client:r}=c();return o.useQuery({enabled:e!==void 0,onError:l,queryFn:()=>e?r.salesOrderShipments.get(e):Promise.reject(new Error("shipmentId is required")),queryKey:["useGetShipment",e],select:t=>t.data})},ce=({enabled:e,page:r,range:t})=>{const{client:s}=c(),[i,n]=t;return o.useQuery({enabled:e,keepPreviousData:!0,onError:l,queryFn:()=>s.carriers.getWalletHistory(i,n,r),queryKey:["useGetWalletHistory",i,n,r],select:a=>a.data})},de=()=>{const{client:e}=c();return o.useQuery({onError:l,queryFn:()=>e.carriers.list(),queryKey:["useListCarriers"],select:r=>r.data.carriers})},ye=()=>{const{client:e}=c();return o.useQuery({onError:l,queryFn:()=>e.customPackages.list(),queryKey:["useListCustomPackageTypes"],select:r=>r.data.packages})},he=e=>{const{client:r}=c();return o.useQuery({enabled:e&&Object.values(e).some(t=>t!==void 0),onError:l,queryFn:()=>r.labels.list(e),queryKey:["useListLabels",e],select:t=>t.data.labels})},fe=()=>{const{client:e}=c();return o.useQuery({onError:l,queryFn:()=>e.orderSources.list(),queryKey:["useListOrderSources"],select:r=>r.data.orderSources})},me=e=>{const{client:r}=c();return o.useQuery({enabled:e&&Object.values(e).some(t=>t!==void 0),onError:l,queryFn:()=>r.salesOrderShipments.list(e),queryKey:["useListSalesOrderShipments",e],select:t=>t.data.shipments})},pe=(e={})=>{const{client:r}=c();return o.useQuery({enabled:e&&Object.values(e).some(t=>t!==void 0),onError:l,queryFn:()=>r.salesOrders.list(e),queryKey:["useListSalesOrders",e],select:t=>t.data.salesOrders})},ve=()=>{const{client:e}=c();return o.useQuery({onError:l,queryFn:()=>e.warehouses.list(),queryKey:["useListWarehouses"],select:r=>r.data.warehouses})},ge=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({salesOrderId:r,...t})=>(await e.salesOrders.notifyShipped(r,t)).data,mutationKey:["useNotifySalesOrder"],onError:l})},Se=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({address:r,text:t})=>(await e.addresses.parse(t,r)).data,mutationKey:["useParseAddress"],onError:l})},Q=()=>{const{client:e}=c();return o.useMutation({mutationFn:async r=>(await e.orderSources.refresh(r)).data,mutationKey:["useRefreshOrderSourceAsync"]})},we=()=>{const{client:e}=c(),{mutateAsync:r}=Q();return o.useMutation({mutationFn:async t=>(await r(t),await M(async()=>{const{data:i}=await e.orderSources.get(t);if(["preparing_update","updating"].includes(i.refreshInfo.status))throw new w.SE.CodedError("Order source is still refreshing");return i},20)),mutationKey:["useRefreshOrderSource"],onError:l})},be=()=>o.useMutation({mutationFn:async e=>(await Promise.resolve({data:{defaultLabelLayout:"4x6",dimension:"inch",weight:"ounce"},errors:[],isLoading:!1,isValidating:!1})).data,mutationKey:["useUpdateAccountSettings"],onError:l}),Oe=e=>{const{client:r}=c(),t=o.useQueryClient();return o.useMutation({mutationFn:async s=>(await r.carriers.updateAutoFunding(e,s)).data,mutationKey:["useUpdateAutoFunding"],onError:l,onSuccess:s=>{t.invalidateQueries(["useGetAutoFunding",e],{exact:!0})}})},Ae=()=>o.useMutation({mutationFn:async e=>(await Promise.resolve({data:{},errors:[],isLoading:!1,isValidating:!1})).data,mutationKey:["useUpdateBilling"],onError:l}),Ee=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({shipmentId:r,...t})=>(await e.salesOrderShipments.update(r,t)).data,mutationKey:["useUpdateSalesOrderShipment"],onError:l})},je=()=>{const{client:e}=c();return o.useMutation({mutationFn:async({warehouseId:r,...t})=>(await e.warehouses.update(r,t)).data,mutationKey:["useUpdateWarehouse"],onError:l})},Ce=()=>{const{client:e}=c();return o.useMutation({mutationFn:async r=>(await e.addresses.validate(r)).data,mutationKey:["useValidateAddresses"],onError:l})},Fe=()=>{const{client:e}=c();return o.useMutation({mutationFn:async r=>(await e.labels.void(r)).data,mutationKey:["useVoidLabel"],onError:l})};exports.ShipEngine=x;exports.ShipEngineContext=K;exports.delay=G;exports.logger=J;exports.onError=l;exports.retryUntil=M;exports.useAddFunds=I;exports.useCalculateRates=Y;exports.useConnectCarrier=$;exports.useCreateLabel=X;exports.useCreateSalesOrderShipment=Z;exports.useCreateWarehouse=ee;exports.useDeleteWarehouse=te;exports.useGetAccountSettings=re;exports.useGetAutoFundingConfiguration=se;exports.useGetCarrierById=ne;exports.useGetInsuranceAccount=ie;exports.useGetLabel=ae;exports.useGetSalesOrder=ue;exports.useGetSalesOrderShipment=oe;exports.useGetShipment=le;exports.useGetWalletHistory=ce;exports.useListCarriers=de;exports.useListCustomPackageTypes=ye;exports.useListLabels=he;exports.useListOrderSources=fe;exports.useListSalesOrderShipments=me;exports.useListSalesOrders=pe;exports.useListWarehouses=ve;exports.useNotifySalesOrderShipped=ge;exports.useParseAddress=Se;exports.useRefreshOrderSource=we;exports.useRefreshOrderSourceAsync=Q;exports.useShipEngine=c;exports.useUpdateAccountSettings=be;exports.useUpdateAutoFunding=Oe;exports.useUpdateBilling=Ae;exports.useUpdateSalesOrderShipment=Ee;exports.useUpdateWarehouse=je;exports.useValidateAddresses=Ce;exports.useVoidLabel=Fe;Object.keys(w).forEach(e=>{e!=="default"&&!exports.hasOwnProperty(e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>w[e]})});
|
package/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { QueryClient as
|
|
1
|
+
import { QueryClient as N, QueryClientProvider as x, useMutation as h, useQuery as y, useQueryClient as B } from "react-query";
|
|
2
2
|
import { jsx as O } from "react/jsx-runtime";
|
|
3
|
-
import { createContext as
|
|
3
|
+
import { createContext as T, useState as D, useContext as U } from "react";
|
|
4
4
|
import { ShipEngineAPI as K, SE as W } from "@shipengine/js-api";
|
|
5
5
|
export * from "@shipengine/js-api";
|
|
6
|
-
const R =
|
|
7
|
-
const [i, n] =
|
|
6
|
+
const R = T(void 0), ne = ({ baseURL: e, children: r, headers: t, getToken: s }) => {
|
|
7
|
+
const [i, n] = D(() => {
|
|
8
8
|
const d = s();
|
|
9
9
|
if (typeof d == "string")
|
|
10
10
|
return new K(d, {
|
|
@@ -13,16 +13,16 @@ const R = B(void 0), ne = ({ baseURL: e, children: r, headers: t, getToken: s })
|
|
|
13
13
|
headers: t ?? {}
|
|
14
14
|
});
|
|
15
15
|
d.then(
|
|
16
|
-
(
|
|
17
|
-
new K(
|
|
16
|
+
(o) => n(
|
|
17
|
+
new K(o, {
|
|
18
18
|
baseURL: e,
|
|
19
19
|
getToken: s,
|
|
20
20
|
headers: t ?? {}
|
|
21
21
|
})
|
|
22
22
|
)
|
|
23
23
|
);
|
|
24
|
-
}),
|
|
25
|
-
return i ? /* @__PURE__ */ O(R.Provider, { value: { client: i }, children: /* @__PURE__ */ O(x, { client:
|
|
24
|
+
}), a = new N();
|
|
25
|
+
return i ? /* @__PURE__ */ O(R.Provider, { value: { client: i }, children: /* @__PURE__ */ O(x, { client: a, children: r }) }) : /* @__PURE__ */ O(
|
|
26
26
|
"div",
|
|
27
27
|
{
|
|
28
28
|
style: {
|
|
@@ -36,13 +36,13 @@ const R = B(void 0), ne = ({ baseURL: e, children: r, headers: t, getToken: s })
|
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
38
|
}, c = () => {
|
|
39
|
-
const e =
|
|
39
|
+
const e = U(R);
|
|
40
40
|
if (!e)
|
|
41
41
|
throw new Error("useShipEngine must be called within a ShipEngineProvider");
|
|
42
42
|
return e;
|
|
43
43
|
}, V = (e) => new Promise((r) => {
|
|
44
44
|
setTimeout(() => r(!0), e);
|
|
45
|
-
}),
|
|
45
|
+
}), u = (e) => e.forEach(console.log);
|
|
46
46
|
var F = { trace: 10, debug: 20, info: 30, warn: 40, error: 50, fatal: 60 }, z = {};
|
|
47
47
|
function E(e) {
|
|
48
48
|
return typeof e == "string" ? F[e.toLowerCase()] : e;
|
|
@@ -52,7 +52,7 @@ function j(e, r) {
|
|
|
52
52
|
return t.__proto__ = s, t;
|
|
53
53
|
}, j(e, r);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function J() {
|
|
56
56
|
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
|
|
57
57
|
return !1;
|
|
58
58
|
if (typeof Proxy == "function")
|
|
@@ -64,13 +64,13 @@ function I() {
|
|
|
64
64
|
return !1;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
var d = new (Function.bind.apply(s,
|
|
67
|
+
function q(e, r, t) {
|
|
68
|
+
return q = J() ? Reflect.construct : function(s, i, n) {
|
|
69
|
+
var a = [null];
|
|
70
|
+
a.push.apply(a, i);
|
|
71
|
+
var d = new (Function.bind.apply(s, a))();
|
|
72
72
|
return n && j(d, n.prototype), d;
|
|
73
|
-
},
|
|
73
|
+
}, q.apply(null, arguments);
|
|
74
74
|
}
|
|
75
75
|
function g(e) {
|
|
76
76
|
if (e == null)
|
|
@@ -85,21 +85,21 @@ function g(e) {
|
|
|
85
85
|
}
|
|
86
86
|
return e;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function A(e) {
|
|
89
89
|
return e === void 0 ? "undefined" : e === null ? "null" : Array.isArray(e) ? "[ " + e.map(function(r) {
|
|
90
|
-
return
|
|
90
|
+
return A(r);
|
|
91
91
|
}).join(", ") + " ]" : typeof e == "object" ? JSON.stringify(e) : typeof e == "function" ? "[Function: " + e.name + "]" : typeof e == "boolean" || typeof e == "number" ? e : "'" + e.toString() + "'";
|
|
92
92
|
}
|
|
93
93
|
function p(e) {
|
|
94
94
|
if (typeof e != "string") {
|
|
95
95
|
for (var r = new Array(arguments.length), t = 0; t < arguments.length; t++)
|
|
96
|
-
r[t] =
|
|
96
|
+
r[t] = A(arguments[t]);
|
|
97
97
|
return r.join(" ");
|
|
98
98
|
}
|
|
99
|
-
for (var s = /%[sdj%]/g, i = 1, n = arguments,
|
|
99
|
+
for (var s = /%[sdj%]/g, i = 1, n = arguments, a = n.length, d = String(e).replace(s, function(f) {
|
|
100
100
|
if (f === "%%")
|
|
101
101
|
return "%";
|
|
102
|
-
if (i >=
|
|
102
|
+
if (i >= a)
|
|
103
103
|
return f;
|
|
104
104
|
switch (f) {
|
|
105
105
|
case "%s":
|
|
@@ -115,11 +115,11 @@ function p(e) {
|
|
|
115
115
|
default:
|
|
116
116
|
return f;
|
|
117
117
|
}
|
|
118
|
-
}),
|
|
119
|
-
d +=
|
|
118
|
+
}), o = n[i]; i < a; o = n[++i])
|
|
119
|
+
d += o === null || typeof o != "object" ? " " + o : " " + A(o);
|
|
120
120
|
return d;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function Q(e, r) {
|
|
123
123
|
var t = e.split(`
|
|
124
124
|
`);
|
|
125
125
|
t[0] && t[0].indexOf("call-stack-error") >= 0 && t.shift();
|
|
@@ -143,16 +143,16 @@ function k(e, r) {
|
|
|
143
143
|
console.error(e + `
|
|
144
144
|
`);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function H(e) {
|
|
147
147
|
return C[e];
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function M() {
|
|
150
150
|
var e = [];
|
|
151
151
|
return function(r, t) {
|
|
152
152
|
return t && typeof t == "object" ? e.indexOf(t) !== -1 ? "[Circular]" : (e.push(t), t) : t;
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
var
|
|
155
|
+
var Y = /* @__PURE__ */ function() {
|
|
156
156
|
function e() {
|
|
157
157
|
}
|
|
158
158
|
return e.prototype.write = function(r) {
|
|
@@ -160,7 +160,7 @@ var M = /* @__PURE__ */ function() {
|
|
|
160
160
|
}, e;
|
|
161
161
|
}(), v = /* @__PURE__ */ function() {
|
|
162
162
|
function e(t, s, i) {
|
|
163
|
-
var n,
|
|
163
|
+
var n, a, d, o, f = this;
|
|
164
164
|
if (!(this instanceof e))
|
|
165
165
|
return new e(t, s);
|
|
166
166
|
if (s !== void 0 && (n = t, t = s, !(n instanceof e)))
|
|
@@ -179,17 +179,17 @@ var M = /* @__PURE__ */ function() {
|
|
|
179
179
|
if (t.serializers && (typeof t.serializers != "object" || Array.isArray(t.serializers)))
|
|
180
180
|
throw new TypeError("invalid options.serializers: must be an object");
|
|
181
181
|
if (n && i) {
|
|
182
|
-
this._level = n._level, this.streams = n.streams, this.serializers = n.serializers, this.src = n.src,
|
|
182
|
+
this._level = n._level, this.streams = n.streams, this.serializers = n.serializers, this.src = n.src, a = this.fields = {};
|
|
183
183
|
var m = Object.keys(n.fields);
|
|
184
|
-
for (
|
|
185
|
-
|
|
186
|
-
var
|
|
187
|
-
for (
|
|
188
|
-
|
|
184
|
+
for (o = 0; o < m.length; o++)
|
|
185
|
+
a[d = m[o]] = n.fields[d];
|
|
186
|
+
var l = Object.keys(t);
|
|
187
|
+
for (o = 0; o < l.length; o++)
|
|
188
|
+
a[d = l[o]] = t[d];
|
|
189
189
|
} else {
|
|
190
190
|
if (n) {
|
|
191
|
-
for (this._level = n._level, this.streams = [],
|
|
192
|
-
var b = g(n.streams[
|
|
191
|
+
for (this._level = n._level, this.streams = [], o = 0; o < n.streams.length; o++) {
|
|
192
|
+
var b = g(n.streams[o]);
|
|
193
193
|
this.streams.push(b);
|
|
194
194
|
}
|
|
195
195
|
this.serializers = g(n.serializers), this.src = n.src, this.fields = g(n.fields), t.level && this.level(t.level);
|
|
@@ -197,8 +197,8 @@ var M = /* @__PURE__ */ function() {
|
|
|
197
197
|
this._level = Number.POSITIVE_INFINITY, this.streams = [], this.serializers = null, this.src = !1, this.fields = {};
|
|
198
198
|
t.stream ? this.addStream({ type: "stream", stream: t.stream, level: t.level }) : t.streams ? t.streams.forEach(function(w) {
|
|
199
199
|
f.addStream(w, t.level);
|
|
200
|
-
}) : n && t.level ? this.level(t.level) : n || this.addStream({ type: "raw", stream: new
|
|
201
|
-
f.fields[w] =
|
|
200
|
+
}) : n && t.level ? this.level(t.level) : n || this.addStream({ type: "raw", stream: new Y(), level: t.level }), t.serializers && this.addSerializers(t.serializers), t.src && (this.src = !0), delete (a = g(t)).stream, delete a.level, delete a.streams, delete a.serializers, delete a.src, this.serializers && this._applySerializers(a), Object.keys(a).forEach(function(w) {
|
|
201
|
+
f.fields[w] = a[w];
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -231,8 +231,8 @@ var M = /* @__PURE__ */ function() {
|
|
|
231
231
|
if ((i = this.streams[t]) === void 0)
|
|
232
232
|
throw new Error("invalid stream index: " + t);
|
|
233
233
|
} else {
|
|
234
|
-
for (var n = this.streams.length,
|
|
235
|
-
var d = this.streams[
|
|
234
|
+
for (var n = this.streams.length, a = 0; a < n; a++) {
|
|
235
|
+
var d = this.streams[a];
|
|
236
236
|
if (d.name === t) {
|
|
237
237
|
i = d;
|
|
238
238
|
break;
|
|
@@ -243,17 +243,17 @@ var M = /* @__PURE__ */ function() {
|
|
|
243
243
|
}
|
|
244
244
|
if (s === void 0)
|
|
245
245
|
return i.level;
|
|
246
|
-
var
|
|
247
|
-
i.level =
|
|
246
|
+
var o = E(s);
|
|
247
|
+
i.level = o, o < this._level && (this._level = o);
|
|
248
248
|
}, r._applySerializers = function(t, s) {
|
|
249
249
|
var i = this;
|
|
250
250
|
Object.keys(this.serializers).forEach(function(n) {
|
|
251
251
|
if (!(t[n] === void 0 || s && s[n]))
|
|
252
252
|
try {
|
|
253
253
|
t[n] = i.serializers[n](t[n]);
|
|
254
|
-
} catch (
|
|
254
|
+
} catch (a) {
|
|
255
255
|
k(p(`bunyan: ERROR: Exception thrown from the "%s" Bunyan serializer. This should never happen. This is a bugin that serializer function.
|
|
256
|
-
%s`, n,
|
|
256
|
+
%s`, n, a.stack || a)), t[n] = p('(Error in Bunyan log "%s" serializer broke field. See stderr for details.)', n);
|
|
257
257
|
}
|
|
258
258
|
});
|
|
259
259
|
}, r._emit = function(t, s) {
|
|
@@ -267,24 +267,24 @@ var M = /* @__PURE__ */ function() {
|
|
|
267
267
|
}
|
|
268
268
|
if (s || this.haveNonRawStreams)
|
|
269
269
|
try {
|
|
270
|
-
n = JSON.stringify(t,
|
|
270
|
+
n = JSON.stringify(t, M()) + `
|
|
271
271
|
`;
|
|
272
272
|
} catch (f) {
|
|
273
|
-
var
|
|
273
|
+
var a = f.stack.split(/\n/g, 2).join(`
|
|
274
274
|
`);
|
|
275
|
-
k('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(m,
|
|
276
|
-
return
|
|
277
|
-
` +
|
|
275
|
+
k('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(m, l) {
|
|
276
|
+
return l || (l = " "), l + m.split(/\r?\n/g).join(`
|
|
277
|
+
` + l);
|
|
278
278
|
}(p(`%s
|
|
279
|
-
%s`, t, f.stack)),
|
|
279
|
+
%s`, t, f.stack)), a), n = p(`(Exception in JSON.stringify(rec): %j. See stderr for details.)
|
|
280
280
|
`, f.message);
|
|
281
281
|
}
|
|
282
282
|
if (s)
|
|
283
283
|
return n;
|
|
284
284
|
var d = t.level;
|
|
285
285
|
for (i = 0; i < this.streams.length; i++) {
|
|
286
|
-
var
|
|
287
|
-
|
|
286
|
+
var o = this.streams[i];
|
|
287
|
+
o.level <= d && o.stream.write(t);
|
|
288
288
|
}
|
|
289
289
|
return n;
|
|
290
290
|
}, e;
|
|
@@ -292,22 +292,22 @@ var M = /* @__PURE__ */ function() {
|
|
|
292
292
|
function S(e) {
|
|
293
293
|
return function() {
|
|
294
294
|
var r = this;
|
|
295
|
-
function t(
|
|
295
|
+
function t(a) {
|
|
296
296
|
var d;
|
|
297
|
-
|
|
298
|
-
var
|
|
299
|
-
|
|
297
|
+
a[0] instanceof Error ? (s = { err: r.serializers && r.serializers.err ? r.serializers.err(a[0]) : P.err(a[0]) }, d = { err: !0 }, i = a.length === 1 ? [s.err.message] : Array.prototype.slice.call(a, 1)) : typeof a[0] != "object" && a[0] !== null || Array.isArray(a[0]) ? (s = null, i = Array.prototype.slice.call(a)) : (s = a[0], i = a.length === 1 && s.err && s.err instanceof Error ? [s.err.message] : Array.prototype.slice.call(a, 1));
|
|
298
|
+
var o = g(r.fields);
|
|
299
|
+
o.level = e;
|
|
300
300
|
var f = s ? g(s) : null;
|
|
301
|
-
if (f && (r.serializers && r._applySerializers(f, d), Object.keys(f).forEach(function(
|
|
302
|
-
|
|
303
|
-
})),
|
|
301
|
+
if (f && (r.serializers && r._applySerializers(f, d), Object.keys(f).forEach(function(l) {
|
|
302
|
+
o[l] = f[l];
|
|
303
|
+
})), o.levelName = z[e], o.msg = i.length ? p.apply(r, i) : "", o.time || (o.time = new Date()), r.src && !o.src)
|
|
304
304
|
try {
|
|
305
305
|
throw new Error("call-stack-error");
|
|
306
|
-
} catch (
|
|
307
|
-
var m =
|
|
308
|
-
m ||
|
|
306
|
+
} catch (l) {
|
|
307
|
+
var m = l.stack ? Q(l.stack, 2) : "";
|
|
308
|
+
m || H("src") || k("Unable to determine src line info", "src"), o.src = m || "";
|
|
309
309
|
}
|
|
310
|
-
return
|
|
310
|
+
return o.v = 1, o;
|
|
311
311
|
}
|
|
312
312
|
var s = null, i = arguments, n = null;
|
|
313
313
|
if (arguments.length === 0)
|
|
@@ -328,32 +328,32 @@ v.prototype.trace = S(10), v.prototype.debug = S(20), v.prototype.info = S(30),
|
|
|
328
328
|
var P = { err: function(e) {
|
|
329
329
|
return e && e.stack ? { message: e.message, name: e.name, stack: _(e), code: e.code, signal: e.signal } : e;
|
|
330
330
|
} };
|
|
331
|
-
function
|
|
332
|
-
return
|
|
331
|
+
function $() {
|
|
332
|
+
return q(v, [].slice.call(arguments));
|
|
333
333
|
}
|
|
334
|
-
var L = { 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" },
|
|
334
|
+
var L = { 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" }, I = /* @__PURE__ */ function() {
|
|
335
335
|
function e(r) {
|
|
336
336
|
var t = r === void 0 ? {} : r, s = t.logByLevel, i = t.css, n = i === void 0 ? L : i;
|
|
337
337
|
this.logByLevel = s !== void 0 && s, this.css = n;
|
|
338
338
|
}
|
|
339
339
|
return e.prototype.write = function(r) {
|
|
340
|
-
var t, s, i = this.css.def, n = this.css.msg,
|
|
341
|
-
this.logByLevel ? (r.level === 10 ?
|
|
340
|
+
var t, s, i = this.css.def, n = this.css.msg, a = this.css.src, d = r.childName ? r.name + "/" + r.childName : r.name, o = z[r.level], f = (Array(6 - o.length).join(" ") + o).toUpperCase();
|
|
341
|
+
this.logByLevel ? (r.level === 10 ? o = "debug" : r.level === 60 && (o = "error"), s = typeof console[o] == "function" ? console[o] : console.log) : s = console.log, t = r.level < 20 ? this.css.levels.trace : r.level < 30 ? this.css.levels.debug : r.level < 40 ? this.css.levels.info : r.level < 50 ? this.css.levels.warn : r.level < 60 ? this.css.levels.error : this.css.levels.fatal;
|
|
342
342
|
var m = function(b, w) {
|
|
343
343
|
return Array(w + 1 - (b + "").length).join("0") + b;
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
`),
|
|
347
|
-
`),
|
|
344
|
+
}, l = [];
|
|
345
|
+
l.push("[%s:%s:%s:%s] %c%s%c: %s: %c%s " + (r.src ? "%c%s" : "")), l.push(m(r.time.getHours(), 2)), l.push(m(r.time.getMinutes(), 2)), l.push(m(r.time.getSeconds(), 2)), l.push(m(r.time.getMilliseconds(), 4)), l.push(t), l.push(f), l.push(i), l.push(d), l.push(n), l.push(r.msg), r.src && (l.push(a), l.push(r.src)), r.obj && (l.push(`
|
|
346
|
+
`), l.push(r.obj)), r.err && r.err.stack && (l.push(`
|
|
347
|
+
`), l.push(r.err.stack)), s.apply(console, l);
|
|
348
348
|
}, e.getDefaultCss = function() {
|
|
349
349
|
return L;
|
|
350
350
|
}, e;
|
|
351
351
|
}();
|
|
352
|
-
const
|
|
353
|
-
process.env.NODE_ENV === "production" &&
|
|
354
|
-
stream: new
|
|
352
|
+
const G = [];
|
|
353
|
+
process.env.NODE_ENV === "production" && G.push({
|
|
354
|
+
stream: new I()
|
|
355
355
|
});
|
|
356
|
-
const ie =
|
|
356
|
+
const ie = $({
|
|
357
357
|
name: "shipengine",
|
|
358
358
|
serializers: {
|
|
359
359
|
...P,
|
|
@@ -370,7 +370,7 @@ const ie = Y({
|
|
|
370
370
|
url: e.config.url
|
|
371
371
|
})
|
|
372
372
|
},
|
|
373
|
-
streams:
|
|
373
|
+
streams: G
|
|
374
374
|
}), X = (e, r = 10, t = 1e3) => Promise.resolve().then(e).catch(function s(i) {
|
|
375
375
|
if (r -= 1, r > 0)
|
|
376
376
|
return V(t).then(e).catch(s);
|
|
@@ -380,54 +380,54 @@ const ie = Y({
|
|
|
380
380
|
return h({
|
|
381
381
|
mutationFn: async (t) => (await r.carriers.addFunds(e, t)).data,
|
|
382
382
|
mutationKey: ["useAddFunds"],
|
|
383
|
-
onError:
|
|
383
|
+
onError: u
|
|
384
384
|
});
|
|
385
385
|
}, oe = () => {
|
|
386
386
|
const { client: e } = c();
|
|
387
387
|
return h({
|
|
388
388
|
mutationFn: async ({ rateOptions: r, shipmentId: t }) => (await e.rates.calculateByShipmentId(t, r)).data,
|
|
389
389
|
mutationKey: ["useCalculateRates"],
|
|
390
|
-
onError:
|
|
390
|
+
onError: u
|
|
391
391
|
});
|
|
392
392
|
}, ue = () => {
|
|
393
393
|
const { client: e } = c();
|
|
394
394
|
return h({
|
|
395
395
|
mutationFn: async (r) => (await e.carriers.connect(r)).data,
|
|
396
396
|
mutationKey: ["useConnectCarrier"],
|
|
397
|
-
onError:
|
|
397
|
+
onError: u
|
|
398
398
|
});
|
|
399
399
|
}, le = () => {
|
|
400
400
|
const { client: e } = c();
|
|
401
401
|
return h({
|
|
402
402
|
mutationFn: async ({ rateId: r, ...t }) => (await e.labels.createByRateId(r, t)).data,
|
|
403
403
|
mutationKey: ["useCreateLabel"],
|
|
404
|
-
onError:
|
|
404
|
+
onError: u
|
|
405
405
|
});
|
|
406
406
|
}, ce = () => {
|
|
407
407
|
const { client: e } = c();
|
|
408
408
|
return h({
|
|
409
409
|
mutationFn: async ({ salesOrderId: r, ...t }) => (await e.salesOrderShipments.create(r, t)).data,
|
|
410
410
|
mutationKey: ["useCreateSalesOrderShipment"],
|
|
411
|
-
onError:
|
|
411
|
+
onError: u
|
|
412
412
|
});
|
|
413
413
|
}, de = () => {
|
|
414
414
|
const { client: e } = c();
|
|
415
415
|
return h({
|
|
416
416
|
mutationFn: async (r) => (await e.warehouses.create(r)).data,
|
|
417
417
|
mutationKey: ["useCreateWarehouse"],
|
|
418
|
-
onError:
|
|
418
|
+
onError: u
|
|
419
419
|
});
|
|
420
420
|
}, fe = () => {
|
|
421
421
|
const { client: e } = c();
|
|
422
422
|
return h({
|
|
423
423
|
mutationFn: async ({ warehouseId: r }) => (await e.warehouses.delete(r)).data,
|
|
424
424
|
mutationKey: ["useDeleteWarehouse"],
|
|
425
|
-
onError:
|
|
425
|
+
onError: u
|
|
426
426
|
});
|
|
427
427
|
}, he = () => {
|
|
428
428
|
const { client: e } = c();
|
|
429
429
|
return y({
|
|
430
|
-
onError:
|
|
430
|
+
onError: u,
|
|
431
431
|
queryFn: () => e.accountSettings.get(),
|
|
432
432
|
queryKey: ["getAccountSettings"],
|
|
433
433
|
select: (r) => r.data
|
|
@@ -436,7 +436,7 @@ const ie = Y({
|
|
|
436
436
|
const { client: r } = c();
|
|
437
437
|
return y({
|
|
438
438
|
enabled: e !== void 0,
|
|
439
|
-
onError:
|
|
439
|
+
onError: u,
|
|
440
440
|
queryFn: () => e ? r.carriers.getAutoFunding(e) : Promise.reject(new Error("carrierId is required.")),
|
|
441
441
|
queryKey: ["useGetAutoFundingConfiguration", e],
|
|
442
442
|
select: (t) => t.data
|
|
@@ -445,7 +445,7 @@ const ie = Y({
|
|
|
445
445
|
const { client: r } = c();
|
|
446
446
|
return y({
|
|
447
447
|
enabled: !!e,
|
|
448
|
-
onError:
|
|
448
|
+
onError: u,
|
|
449
449
|
queryFn: () => e ? r.carriers.get(e) : Promise.reject(new Error("carrierId is require")),
|
|
450
450
|
queryKey: ["useGetCarrierById", e],
|
|
451
451
|
select: (t) => t.data,
|
|
@@ -456,7 +456,7 @@ const ie = Y({
|
|
|
456
456
|
const { client: r } = c();
|
|
457
457
|
return y({
|
|
458
458
|
enabled: e !== void 0,
|
|
459
|
-
onError:
|
|
459
|
+
onError: u,
|
|
460
460
|
queryFn: () => e ? r.insurance.get(e) : Promise.reject(new Error("insuranceProvider is required")),
|
|
461
461
|
queryKey: ["useGetInsuranceAccount", e],
|
|
462
462
|
select: (t) => t.data
|
|
@@ -465,7 +465,7 @@ const ie = Y({
|
|
|
465
465
|
const { client: r } = c();
|
|
466
466
|
return y({
|
|
467
467
|
enabled: e !== void 0,
|
|
468
|
-
onError:
|
|
468
|
+
onError: u,
|
|
469
469
|
queryFn: () => e ? r.labels.get(e) : Promise.reject(new Error("labelId is require")),
|
|
470
470
|
queryKey: ["useGetLabel", e],
|
|
471
471
|
select: (t) => t.data
|
|
@@ -474,7 +474,7 @@ const ie = Y({
|
|
|
474
474
|
const { client: r } = c();
|
|
475
475
|
return y({
|
|
476
476
|
enabled: e !== void 0,
|
|
477
|
-
onError:
|
|
477
|
+
onError: u,
|
|
478
478
|
queryFn: () => e ? r.salesOrders.get(e) : Promise.reject(new Error("salesOrderId is required")),
|
|
479
479
|
queryKey: ["useGetSalesOrder", e],
|
|
480
480
|
select: (t) => t.data
|
|
@@ -483,7 +483,7 @@ const ie = Y({
|
|
|
483
483
|
const { client: r } = c();
|
|
484
484
|
return y({
|
|
485
485
|
enabled: e !== void 0,
|
|
486
|
-
onError:
|
|
486
|
+
onError: u,
|
|
487
487
|
queryFn: () => e ? r.salesOrderShipments.get(e) : Promise.reject(new Error("shipmentId is required")),
|
|
488
488
|
queryKey: ["useGetSalesOrderShipment", e],
|
|
489
489
|
select: (t) => t.data
|
|
@@ -492,44 +492,30 @@ const ie = Y({
|
|
|
492
492
|
const { client: r } = c();
|
|
493
493
|
return y({
|
|
494
494
|
enabled: e !== void 0,
|
|
495
|
-
onError:
|
|
495
|
+
onError: u,
|
|
496
496
|
queryFn: () => e ? r.salesOrderShipments.get(e) : Promise.reject(new Error("shipmentId is required")),
|
|
497
497
|
queryKey: ["useGetShipment", e],
|
|
498
498
|
select: (t) => t.data
|
|
499
499
|
});
|
|
500
|
-
}, be = (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
transactionType: "fund"
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
amount: 50.65,
|
|
520
|
-
balance: 10,
|
|
521
|
-
carrierId: "string",
|
|
522
|
-
carrierProvider: "string carrier name",
|
|
523
|
-
labelId: "string",
|
|
524
|
-
transactionDate: "",
|
|
525
|
-
transactionId: "string",
|
|
526
|
-
transactionType: "purchase"
|
|
527
|
-
}
|
|
528
|
-
]
|
|
529
|
-
}), Oe = () => {
|
|
500
|
+
}, be = ({
|
|
501
|
+
enabled: e,
|
|
502
|
+
page: r,
|
|
503
|
+
range: t
|
|
504
|
+
}) => {
|
|
505
|
+
const { client: s } = c(), [i, n] = t;
|
|
506
|
+
return y({
|
|
507
|
+
enabled: e,
|
|
508
|
+
keepPreviousData: !0,
|
|
509
|
+
// See https://react-query-v3.tanstack.com/guides/paginated-queries#better-paginated-queries-with-keeppreviousdata
|
|
510
|
+
onError: u,
|
|
511
|
+
queryFn: () => s.carriers.getWalletHistory(i, n, r),
|
|
512
|
+
queryKey: ["useGetWalletHistory", i, n, r],
|
|
513
|
+
select: (a) => a.data
|
|
514
|
+
});
|
|
515
|
+
}, Oe = () => {
|
|
530
516
|
const { client: e } = c();
|
|
531
517
|
return y({
|
|
532
|
-
onError:
|
|
518
|
+
onError: u,
|
|
533
519
|
queryFn: () => e.carriers.list(),
|
|
534
520
|
queryKey: ["useListCarriers"],
|
|
535
521
|
select: (r) => r.data.carriers
|
|
@@ -537,7 +523,7 @@ const ie = Y({
|
|
|
537
523
|
}, Ee = () => {
|
|
538
524
|
const { client: e } = c();
|
|
539
525
|
return y({
|
|
540
|
-
onError:
|
|
526
|
+
onError: u,
|
|
541
527
|
queryFn: () => e.customPackages.list(),
|
|
542
528
|
queryKey: ["useListCustomPackageTypes"],
|
|
543
529
|
select: (r) => r.data.packages
|
|
@@ -546,7 +532,7 @@ const ie = Y({
|
|
|
546
532
|
const { client: r } = c();
|
|
547
533
|
return y({
|
|
548
534
|
enabled: e && Object.values(e).some((t) => t !== void 0),
|
|
549
|
-
onError:
|
|
535
|
+
onError: u,
|
|
550
536
|
queryFn: () => r.labels.list(e),
|
|
551
537
|
queryKey: ["useListLabels", e],
|
|
552
538
|
select: (t) => t.data.labels
|
|
@@ -554,25 +540,25 @@ const ie = Y({
|
|
|
554
540
|
}, je = () => {
|
|
555
541
|
const { client: e } = c();
|
|
556
542
|
return y({
|
|
557
|
-
onError:
|
|
543
|
+
onError: u,
|
|
558
544
|
queryFn: () => e.orderSources.list(),
|
|
559
545
|
queryKey: ["useListOrderSources"],
|
|
560
546
|
select: (r) => r.data.orderSources
|
|
561
547
|
});
|
|
562
|
-
},
|
|
548
|
+
}, qe = (e) => {
|
|
563
549
|
const { client: r } = c();
|
|
564
550
|
return y({
|
|
565
551
|
enabled: e && Object.values(e).some((t) => t !== void 0),
|
|
566
|
-
onError:
|
|
552
|
+
onError: u,
|
|
567
553
|
queryFn: () => r.salesOrderShipments.list(e),
|
|
568
554
|
queryKey: ["useListSalesOrderShipments", e],
|
|
569
555
|
select: (t) => t.data.shipments
|
|
570
556
|
});
|
|
571
|
-
},
|
|
557
|
+
}, Ae = (e = {}) => {
|
|
572
558
|
const { client: r } = c();
|
|
573
559
|
return y({
|
|
574
560
|
enabled: e && Object.values(e).some((t) => t !== void 0),
|
|
575
|
-
onError:
|
|
561
|
+
onError: u,
|
|
576
562
|
queryFn: () => r.salesOrders.list(e),
|
|
577
563
|
queryKey: ["useListSalesOrders", e],
|
|
578
564
|
select: (t) => t.data.salesOrders
|
|
@@ -580,7 +566,7 @@ const ie = Y({
|
|
|
580
566
|
}, Ce = () => {
|
|
581
567
|
const { client: e } = c();
|
|
582
568
|
return y({
|
|
583
|
-
onError:
|
|
569
|
+
onError: u,
|
|
584
570
|
queryFn: () => e.warehouses.list(),
|
|
585
571
|
queryKey: ["useListWarehouses"],
|
|
586
572
|
select: (r) => r.data.warehouses
|
|
@@ -590,14 +576,14 @@ const ie = Y({
|
|
|
590
576
|
return h({
|
|
591
577
|
mutationFn: async ({ salesOrderId: r, ...t }) => (await e.salesOrders.notifyShipped(r, t)).data,
|
|
592
578
|
mutationKey: ["useNotifySalesOrder"],
|
|
593
|
-
onError:
|
|
579
|
+
onError: u
|
|
594
580
|
});
|
|
595
581
|
}, ze = () => {
|
|
596
582
|
const { client: e } = c();
|
|
597
583
|
return h({
|
|
598
584
|
mutationFn: async ({ address: r, text: t }) => (await e.addresses.parse(t, r)).data,
|
|
599
585
|
mutationKey: ["useParseAddress"],
|
|
600
|
-
onError:
|
|
586
|
+
onError: u
|
|
601
587
|
});
|
|
602
588
|
}, Z = () => {
|
|
603
589
|
const { client: e } = c();
|
|
@@ -615,7 +601,7 @@ const ie = Y({
|
|
|
615
601
|
return i;
|
|
616
602
|
}, 20)),
|
|
617
603
|
mutationKey: ["useRefreshOrderSource"],
|
|
618
|
-
onError:
|
|
604
|
+
onError: u
|
|
619
605
|
});
|
|
620
606
|
}, Le = () => h({
|
|
621
607
|
mutationFn: async (e) => (await Promise.resolve({
|
|
@@ -625,13 +611,13 @@ const ie = Y({
|
|
|
625
611
|
isValidating: !1
|
|
626
612
|
})).data,
|
|
627
613
|
mutationKey: ["useUpdateAccountSettings"],
|
|
628
|
-
onError:
|
|
614
|
+
onError: u
|
|
629
615
|
}), Re = (e) => {
|
|
630
|
-
const { client: r } = c(), t =
|
|
616
|
+
const { client: r } = c(), t = B();
|
|
631
617
|
return h({
|
|
632
618
|
mutationFn: async (s) => (await r.carriers.updateAutoFunding(e, s)).data,
|
|
633
619
|
mutationKey: ["useUpdateAutoFunding"],
|
|
634
|
-
onError:
|
|
620
|
+
onError: u,
|
|
635
621
|
onSuccess: (s) => {
|
|
636
622
|
t.invalidateQueries(["useGetAutoFunding", e], { exact: !0 });
|
|
637
623
|
}
|
|
@@ -644,34 +630,34 @@ const ie = Y({
|
|
|
644
630
|
isValidating: !1
|
|
645
631
|
})).data,
|
|
646
632
|
mutationKey: ["useUpdateBilling"],
|
|
647
|
-
onError:
|
|
633
|
+
onError: u
|
|
648
634
|
}), Pe = () => {
|
|
649
635
|
const { client: e } = c();
|
|
650
636
|
return h({
|
|
651
637
|
mutationFn: async ({ shipmentId: r, ...t }) => (await e.salesOrderShipments.update(r, t)).data,
|
|
652
638
|
mutationKey: ["useUpdateSalesOrderShipment"],
|
|
653
|
-
onError:
|
|
639
|
+
onError: u
|
|
654
640
|
});
|
|
655
|
-
},
|
|
641
|
+
}, Ge = () => {
|
|
656
642
|
const { client: e } = c();
|
|
657
643
|
return h({
|
|
658
644
|
mutationFn: async ({ warehouseId: r, ...t }) => (await e.warehouses.update(r, t)).data,
|
|
659
645
|
mutationKey: ["useUpdateWarehouse"],
|
|
660
|
-
onError:
|
|
646
|
+
onError: u
|
|
661
647
|
});
|
|
662
|
-
},
|
|
648
|
+
}, Ne = () => {
|
|
663
649
|
const { client: e } = c();
|
|
664
650
|
return h({
|
|
665
651
|
mutationFn: async (r) => (await e.addresses.validate(r)).data,
|
|
666
652
|
mutationKey: ["useValidateAddresses"],
|
|
667
|
-
onError:
|
|
653
|
+
onError: u
|
|
668
654
|
});
|
|
669
655
|
}, xe = () => {
|
|
670
656
|
const { client: e } = c();
|
|
671
657
|
return h({
|
|
672
658
|
mutationFn: async (r) => (await e.labels.void(r)).data,
|
|
673
659
|
mutationKey: ["useVoidLabel"],
|
|
674
|
-
onError:
|
|
660
|
+
onError: u
|
|
675
661
|
});
|
|
676
662
|
};
|
|
677
663
|
export {
|
|
@@ -679,7 +665,7 @@ export {
|
|
|
679
665
|
R as ShipEngineContext,
|
|
680
666
|
V as delay,
|
|
681
667
|
ie as logger,
|
|
682
|
-
|
|
668
|
+
u as onError,
|
|
683
669
|
X as retryUntil,
|
|
684
670
|
ae as useAddFunds,
|
|
685
671
|
oe as useCalculateRates,
|
|
@@ -696,13 +682,13 @@ export {
|
|
|
696
682
|
ge as useGetSalesOrder,
|
|
697
683
|
we as useGetSalesOrderShipment,
|
|
698
684
|
Se as useGetShipment,
|
|
699
|
-
be as
|
|
685
|
+
be as useGetWalletHistory,
|
|
700
686
|
Oe as useListCarriers,
|
|
701
687
|
Ee as useListCustomPackageTypes,
|
|
702
688
|
Fe as useListLabels,
|
|
703
689
|
je as useListOrderSources,
|
|
704
|
-
|
|
705
|
-
|
|
690
|
+
qe as useListSalesOrderShipments,
|
|
691
|
+
Ae as useListSalesOrders,
|
|
706
692
|
Ce as useListWarehouses,
|
|
707
693
|
ke as useNotifySalesOrderShipped,
|
|
708
694
|
ze as useParseAddress,
|
|
@@ -713,7 +699,7 @@ export {
|
|
|
713
699
|
Re as useUpdateAutoFunding,
|
|
714
700
|
_e as useUpdateBilling,
|
|
715
701
|
Pe as useUpdateSalesOrderShipment,
|
|
716
|
-
|
|
717
|
-
|
|
702
|
+
Ge as useUpdateWarehouse,
|
|
703
|
+
Ne as useValidateAddresses,
|
|
718
704
|
xe as useVoidLabel
|
|
719
705
|
};
|
package/package.json
CHANGED