@shipengine/alchemy 1.0.4 → 2.0.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/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
- import { createContext, forwardRef, useContext, createElement as createElement$1, Fragment, useState, useEffect, useMemo } from 'react';
2
+ import { createContext, forwardRef, useContext, createElement as createElement$1, Fragment, useState, useEffect, useCallback, useMemo } from 'react';
3
3
  import { jsx as jsx$1, jsxs as jsxs$1 } from 'react/jsx-runtime';
4
4
  import { css, Global, ThemeProvider, CacheProvider } from '@emotion/react';
5
5
  import { BrandName } from '@packlink/brands';
6
- import { getEmotionResetStyles, GigerConfigProvider } from '@packlink/giger';
6
+ import { getEmotionResetStyles, createIconCache, GigerConfigProvider } from '@packlink/giger';
7
7
  import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient } from 'react-query';
8
8
  import { Theme } from '@packlink/giger-theme';
9
9
  import { I18nextProvider } from 'react-i18next';
@@ -2455,17 +2455,17 @@ Object.defineProperty(dist, "__esModule", { value: true });
2455
2455
  var _default = dist.default = (function () {
2456
2456
  });
2457
2457
 
2458
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
2459
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
2460
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
2458
+ var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
2459
+ var __hasOwnProp$e = Object.prototype.hasOwnProperty;
2460
+ var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
2461
2461
  var __objRest$8 = (source, exclude) => {
2462
2462
  var target = {};
2463
2463
  for (var prop in source)
2464
- if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
2464
+ if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
2465
2465
  target[prop] = source[prop];
2466
- if (source != null && __getOwnPropSymbols$c)
2467
- for (var prop of __getOwnPropSymbols$c(source)) {
2468
- if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
2466
+ if (source != null && __getOwnPropSymbols$e)
2467
+ for (var prop of __getOwnPropSymbols$e(source)) {
2468
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$e.call(source, prop))
2469
2469
  target[prop] = source[prop];
2470
2470
  }
2471
2471
  return target;
@@ -5209,7 +5209,7 @@ var ipaddr = {
5209
5209
  }).call(commonjsGlobal);
5210
5210
  } (ipaddr));
5211
5211
 
5212
- var __async$t = (__this, __arguments, generator) => {
5212
+ var __async$u = (__this, __arguments, generator) => {
5213
5213
  return new Promise((resolve, reject) => {
5214
5214
  var fulfilled = (value) => {
5215
5215
  try {
@@ -5229,7 +5229,7 @@ var __async$t = (__this, __arguments, generator) => {
5229
5229
  step((generator = generator.apply(__this, __arguments)).next());
5230
5230
  });
5231
5231
  };
5232
- const getEndUserIpAddress = () => __async$t(void 0, null, function* () {
5232
+ const getEndUserIpAddress = () => __async$u(void 0, null, function* () {
5233
5233
  try {
5234
5234
  const response = yield axios.get("https://api.ipify.org/?format=json");
5235
5235
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -5241,38 +5241,38 @@ const getEndUserIpAddress = () => __async$t(void 0, null, function* () {
5241
5241
  }
5242
5242
  });
5243
5243
 
5244
- var __defProp$5 = Object.defineProperty;
5245
- var __defProps$3 = Object.defineProperties;
5246
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
5247
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
5248
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
5249
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
5250
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5251
- var __spreadValues$5 = (a, b) => {
5244
+ var __defProp$7 = Object.defineProperty;
5245
+ var __defProps$5 = Object.defineProperties;
5246
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
5247
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
5248
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
5249
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
5250
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5251
+ var __spreadValues$7 = (a, b) => {
5252
5252
  for (var prop in b || (b = {}))
5253
- if (__hasOwnProp$b.call(b, prop))
5254
- __defNormalProp$5(a, prop, b[prop]);
5255
- if (__getOwnPropSymbols$b)
5256
- for (var prop of __getOwnPropSymbols$b(b)) {
5257
- if (__propIsEnum$b.call(b, prop))
5258
- __defNormalProp$5(a, prop, b[prop]);
5253
+ if (__hasOwnProp$d.call(b, prop))
5254
+ __defNormalProp$7(a, prop, b[prop]);
5255
+ if (__getOwnPropSymbols$d)
5256
+ for (var prop of __getOwnPropSymbols$d(b)) {
5257
+ if (__propIsEnum$d.call(b, prop))
5258
+ __defNormalProp$7(a, prop, b[prop]);
5259
5259
  }
5260
5260
  return a;
5261
5261
  };
5262
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
5262
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
5263
5263
  var __objRest$7 = (source, exclude) => {
5264
5264
  var target = {};
5265
5265
  for (var prop in source)
5266
- if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
5266
+ if (__hasOwnProp$d.call(source, prop) && exclude.indexOf(prop) < 0)
5267
5267
  target[prop] = source[prop];
5268
- if (source != null && __getOwnPropSymbols$b)
5269
- for (var prop of __getOwnPropSymbols$b(source)) {
5270
- if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
5268
+ if (source != null && __getOwnPropSymbols$d)
5269
+ for (var prop of __getOwnPropSymbols$d(source)) {
5270
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$d.call(source, prop))
5271
5271
  target[prop] = source[prop];
5272
5272
  }
5273
5273
  return target;
5274
5274
  };
5275
- var __async$s = (__this, __arguments, generator) => {
5275
+ var __async$t = (__this, __arguments, generator) => {
5276
5276
  return new Promise((resolve, reject) => {
5277
5277
  var fulfilled = (value) => {
5278
5278
  try {
@@ -5301,12 +5301,12 @@ class CarriersAPI {
5301
5301
  this.get = (carrierId) => {
5302
5302
  return this.client.get(`/v1/carriers/${carrierId}`);
5303
5303
  };
5304
- this.connect = (_a) => __async$s(this, null, function* () {
5304
+ this.connect = (_a) => __async$t(this, null, function* () {
5305
5305
  var _b = _a, { carrierCode } = _b, connection = __objRest$7(_b, ["carrierCode"]);
5306
5306
  const endUserIpAddress = yield getEndUserIpAddress();
5307
5307
  if (!endUserIpAddress)
5308
5308
  return Promise.reject([new CodedError("Unable to get IP address")]);
5309
- return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$3(__spreadValues$5({}, connection), {
5309
+ return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$5(__spreadValues$7({}, connection), {
5310
5310
  endUserIpAddress
5311
5311
  }));
5312
5312
  });
@@ -7538,23 +7538,23 @@ class CustomPackagesAPI {
7538
7538
  }
7539
7539
  }
7540
7540
 
7541
- var __defProp$4 = Object.defineProperty;
7542
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
7543
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
7544
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
7545
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7546
- var __spreadValues$4 = (a, b) => {
7541
+ var __defProp$6 = Object.defineProperty;
7542
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
7543
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
7544
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
7545
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7546
+ var __spreadValues$6 = (a, b) => {
7547
7547
  for (var prop in b || (b = {}))
7548
- if (__hasOwnProp$a.call(b, prop))
7549
- __defNormalProp$4(a, prop, b[prop]);
7550
- if (__getOwnPropSymbols$a)
7551
- for (var prop of __getOwnPropSymbols$a(b)) {
7552
- if (__propIsEnum$a.call(b, prop))
7553
- __defNormalProp$4(a, prop, b[prop]);
7548
+ if (__hasOwnProp$c.call(b, prop))
7549
+ __defNormalProp$6(a, prop, b[prop]);
7550
+ if (__getOwnPropSymbols$c)
7551
+ for (var prop of __getOwnPropSymbols$c(b)) {
7552
+ if (__propIsEnum$c.call(b, prop))
7553
+ __defNormalProp$6(a, prop, b[prop]);
7554
7554
  }
7555
7555
  return a;
7556
7556
  };
7557
- var __async$r = (__this, __arguments, generator) => {
7557
+ var __async$s = (__this, __arguments, generator) => {
7558
7558
  return new Promise((resolve, reject) => {
7559
7559
  var fulfilled = (value) => {
7560
7560
  try {
@@ -7583,15 +7583,15 @@ class FundingSourcesAPI {
7583
7583
  this.get = (fundingSourceId) => {
7584
7584
  return this.client.get(`/v1/funding_sources/${fundingSourceId}`);
7585
7585
  };
7586
- this.create = (createFundingSource) => __async$r(this, null, function* () {
7586
+ this.create = (createFundingSource) => __async$s(this, null, function* () {
7587
7587
  const endUserIpAddress = yield getEndUserIpAddress();
7588
7588
  if (!endUserIpAddress)
7589
7589
  return Promise.reject([new CodedError("Unable to get IP address")]);
7590
- return yield this.client.post("/v1/funding_sources", __spreadValues$4({
7590
+ return yield this.client.post("/v1/funding_sources", __spreadValues$6({
7591
7591
  endUserIpAddress
7592
7592
  }, createFundingSource));
7593
7593
  });
7594
- this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$r(this, null, function* () {
7594
+ this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$s(this, null, function* () {
7595
7595
  const endUserIpAddress = yield getEndUserIpAddress();
7596
7596
  if (!endUserIpAddress)
7597
7597
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7604,14 +7604,20 @@ class FundingSourcesAPI {
7604
7604
  }
7605
7605
  );
7606
7606
  });
7607
- this.registerCarrier = (carrier) => __async$r(this, null, function* () {
7607
+ this.registerCarrier = (carrier) => __async$s(this, null, function* () {
7608
7608
  const endUserIpAddress = yield getEndUserIpAddress();
7609
7609
  if (!endUserIpAddress)
7610
7610
  return Promise.reject([new CodedError("Unable to get IP address")]);
7611
- return yield this.client.post("/v1/registration/funding_source", __spreadValues$4({
7611
+ return yield this.client.post("/v1/registration/funding_source", __spreadValues$6({
7612
7612
  endUserIpAddress
7613
7613
  }, carrier));
7614
7614
  });
7615
+ this.addFunds = (amount, fundingSourceId) => __async$s(this, null, function* () {
7616
+ return yield this.client.put(
7617
+ `/v1/funding_sources/${fundingSourceId}/add_funds`,
7618
+ amount
7619
+ );
7620
+ });
7615
7621
  this.client = client;
7616
7622
  }
7617
7623
  }
@@ -7743,7 +7749,7 @@ class SalesOrdersAPI {
7743
7749
  }
7744
7750
  }
7745
7751
 
7746
- var __async$q = (__this, __arguments, generator) => {
7752
+ var __async$r = (__this, __arguments, generator) => {
7747
7753
  return new Promise((resolve, reject) => {
7748
7754
  var fulfilled = (value) => {
7749
7755
  try {
@@ -7775,7 +7781,7 @@ class ShipmentsAPI {
7775
7781
  this.list = (options) => {
7776
7782
  return this.client.get("/v1/shipments", { params: options });
7777
7783
  };
7778
- this.create = (...shipments) => __async$q(this, null, function* () {
7784
+ this.create = (...shipments) => __async$r(this, null, function* () {
7779
7785
  return this.client.post("/v1/shipments", {
7780
7786
  shipments
7781
7787
  });
@@ -7803,26 +7809,26 @@ class WarehousesAPI {
7803
7809
  }
7804
7810
  }
7805
7811
 
7806
- var __defProp$3 = Object.defineProperty;
7807
- var __defProps$2 = Object.defineProperties;
7808
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
7809
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
7810
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
7811
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
7812
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7813
- var __spreadValues$3 = (a, b) => {
7812
+ var __defProp$5 = Object.defineProperty;
7813
+ var __defProps$4 = Object.defineProperties;
7814
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
7815
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
7816
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
7817
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
7818
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7819
+ var __spreadValues$5 = (a, b) => {
7814
7820
  for (var prop in b || (b = {}))
7815
- if (__hasOwnProp$9.call(b, prop))
7816
- __defNormalProp$3(a, prop, b[prop]);
7817
- if (__getOwnPropSymbols$9)
7818
- for (var prop of __getOwnPropSymbols$9(b)) {
7819
- if (__propIsEnum$9.call(b, prop))
7820
- __defNormalProp$3(a, prop, b[prop]);
7821
+ if (__hasOwnProp$b.call(b, prop))
7822
+ __defNormalProp$5(a, prop, b[prop]);
7823
+ if (__getOwnPropSymbols$b)
7824
+ for (var prop of __getOwnPropSymbols$b(b)) {
7825
+ if (__propIsEnum$b.call(b, prop))
7826
+ __defNormalProp$5(a, prop, b[prop]);
7821
7827
  }
7822
7828
  return a;
7823
7829
  };
7824
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
7825
- var __async$p = (__this, __arguments, generator) => {
7830
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
7831
+ var __async$q = (__this, __arguments, generator) => {
7826
7832
  return new Promise((resolve, reject) => {
7827
7833
  var fulfilled = (value) => {
7828
7834
  try {
@@ -7844,7 +7850,7 @@ var __async$p = (__this, __arguments, generator) => {
7844
7850
  };
7845
7851
  const logger$1 = E({
7846
7852
  name: "shipengine-api",
7847
- serializers: __spreadProps$2(__spreadValues$3({}, k), {
7853
+ serializers: __spreadProps$4(__spreadValues$5({}, k), {
7848
7854
  req: (req) => ({
7849
7855
  headers: req.headers,
7850
7856
  method: req.method,
@@ -7869,7 +7875,7 @@ class ShipEngineAPI {
7869
7875
  constructor(token, { baseURL, headers, getToken }) {
7870
7876
  const client = axios.create({
7871
7877
  baseURL,
7872
- headers: __spreadProps$2(__spreadValues$3({}, headers), {
7878
+ headers: __spreadProps$4(__spreadValues$5({}, headers), {
7873
7879
  Authorization: `Bearer ${token}`,
7874
7880
  "Content-Type": "application/json"
7875
7881
  }),
@@ -7903,7 +7909,7 @@ class ShipEngineAPI {
7903
7909
  );
7904
7910
  return res;
7905
7911
  },
7906
- (err) => __async$p(this, null, function* () {
7912
+ (err) => __async$q(this, null, function* () {
7907
7913
  var _a, _b, _c, _d, _e, _f, _g;
7908
7914
  logger$1.error(
7909
7915
  { err, req: err.config, res: err.response },
@@ -8043,25 +8049,25 @@ const delay = (ms) => new Promise((resolve) => {
8043
8049
 
8044
8050
  const onError = (errors) => errors.forEach(console.log);
8045
8051
 
8046
- var __defProp$2 = Object.defineProperty;
8047
- var __defProps$1 = Object.defineProperties;
8048
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
8049
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
8050
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
8051
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
8052
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8053
- var __spreadValues$2 = (a, b) => {
8052
+ var __defProp$4 = Object.defineProperty;
8053
+ var __defProps$3 = Object.defineProperties;
8054
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
8055
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
8056
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
8057
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
8058
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8059
+ var __spreadValues$4 = (a, b) => {
8054
8060
  for (var prop in b || (b = {}))
8055
- if (__hasOwnProp$8.call(b, prop))
8056
- __defNormalProp$2(a, prop, b[prop]);
8057
- if (__getOwnPropSymbols$8)
8058
- for (var prop of __getOwnPropSymbols$8(b)) {
8059
- if (__propIsEnum$8.call(b, prop))
8060
- __defNormalProp$2(a, prop, b[prop]);
8061
+ if (__hasOwnProp$a.call(b, prop))
8062
+ __defNormalProp$4(a, prop, b[prop]);
8063
+ if (__getOwnPropSymbols$a)
8064
+ for (var prop of __getOwnPropSymbols$a(b)) {
8065
+ if (__propIsEnum$a.call(b, prop))
8066
+ __defNormalProp$4(a, prop, b[prop]);
8061
8067
  }
8062
8068
  return a;
8063
8069
  };
8064
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
8070
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
8065
8071
  const streams = [];
8066
8072
  if (process.env.NODE_ENV === "production") {
8067
8073
  streams.push({
@@ -8070,7 +8076,7 @@ if (process.env.NODE_ENV === "production") {
8070
8076
  }
8071
8077
  const logger = E({
8072
8078
  name: "shipengine",
8073
- serializers: __spreadProps$1(__spreadValues$2({}, k), {
8079
+ serializers: __spreadProps$3(__spreadValues$4({}, k), {
8074
8080
  req: (req) => ({
8075
8081
  headers: req.headers,
8076
8082
  method: req.method,
@@ -8095,7 +8101,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
8095
8101
  throw error;
8096
8102
  });
8097
8103
 
8098
- var __async$o = (__this, __arguments, generator) => {
8104
+ var __async$p = (__this, __arguments, generator) => {
8099
8105
  return new Promise((resolve, reject) => {
8100
8106
  var fulfilled = (value) => {
8101
8107
  try {
@@ -8118,7 +8124,7 @@ var __async$o = (__this, __arguments, generator) => {
8118
8124
  const useAddFunds = (carrierId) => {
8119
8125
  const { client } = useShipEngine();
8120
8126
  return useMutation({
8121
- mutationFn: (funds) => __async$o(void 0, null, function* () {
8127
+ mutationFn: (funds) => __async$p(void 0, null, function* () {
8122
8128
  const result = yield client.carriers.addFunds(carrierId, funds);
8123
8129
  return result.data;
8124
8130
  }),
@@ -8127,7 +8133,7 @@ const useAddFunds = (carrierId) => {
8127
8133
  });
8128
8134
  };
8129
8135
 
8130
- var __async$n = (__this, __arguments, generator) => {
8136
+ var __async$o = (__this, __arguments, generator) => {
8131
8137
  return new Promise((resolve, reject) => {
8132
8138
  var fulfilled = (value) => {
8133
8139
  try {
@@ -8150,7 +8156,7 @@ var __async$n = (__this, __arguments, generator) => {
8150
8156
  const useCalculateRates = () => {
8151
8157
  const { client } = useShipEngine();
8152
8158
  return useMutation({
8153
- mutationFn: (_0) => __async$n(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8159
+ mutationFn: (_0) => __async$o(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8154
8160
  const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
8155
8161
  return result.data;
8156
8162
  }),
@@ -8159,7 +8165,7 @@ const useCalculateRates = () => {
8159
8165
  });
8160
8166
  };
8161
8167
 
8162
- var __async$m = (__this, __arguments, generator) => {
8168
+ var __async$n = (__this, __arguments, generator) => {
8163
8169
  return new Promise((resolve, reject) => {
8164
8170
  var fulfilled = (value) => {
8165
8171
  try {
@@ -8182,7 +8188,7 @@ var __async$m = (__this, __arguments, generator) => {
8182
8188
  const useConnectCarrier = () => {
8183
8189
  const { client } = useShipEngine();
8184
8190
  return useMutation({
8185
- mutationFn: (params) => __async$m(void 0, null, function* () {
8191
+ mutationFn: (params) => __async$n(void 0, null, function* () {
8186
8192
  const result = yield client.carriers.connect(params);
8187
8193
  return result.data;
8188
8194
  }),
@@ -8191,7 +8197,7 @@ const useConnectCarrier = () => {
8191
8197
  });
8192
8198
  };
8193
8199
 
8194
- var __async$l = (__this, __arguments, generator) => {
8200
+ var __async$m = (__this, __arguments, generator) => {
8195
8201
  return new Promise((resolve, reject) => {
8196
8202
  var fulfilled = (value) => {
8197
8203
  try {
@@ -8214,7 +8220,7 @@ var __async$l = (__this, __arguments, generator) => {
8214
8220
  const useCreateFundingSource = () => {
8215
8221
  const { client } = useShipEngine();
8216
8222
  return useMutation({
8217
- mutationFn: (fundingSource) => __async$l(void 0, null, function* () {
8223
+ mutationFn: (fundingSource) => __async$m(void 0, null, function* () {
8218
8224
  const result = yield client.fundingSources.create(fundingSource);
8219
8225
  return result.data;
8220
8226
  }),
@@ -8223,22 +8229,22 @@ const useCreateFundingSource = () => {
8223
8229
  });
8224
8230
  };
8225
8231
 
8226
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8227
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8228
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8232
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
8233
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
8234
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
8229
8235
  var __objRest$6 = (source, exclude) => {
8230
8236
  var target = {};
8231
8237
  for (var prop in source)
8232
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
8238
+ if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
8233
8239
  target[prop] = source[prop];
8234
- if (source != null && __getOwnPropSymbols$7)
8235
- for (var prop of __getOwnPropSymbols$7(source)) {
8236
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
8240
+ if (source != null && __getOwnPropSymbols$9)
8241
+ for (var prop of __getOwnPropSymbols$9(source)) {
8242
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
8237
8243
  target[prop] = source[prop];
8238
8244
  }
8239
8245
  return target;
8240
8246
  };
8241
- var __async$k = (__this, __arguments, generator) => {
8247
+ var __async$l = (__this, __arguments, generator) => {
8242
8248
  return new Promise((resolve, reject) => {
8243
8249
  var fulfilled = (value) => {
8244
8250
  try {
@@ -8261,7 +8267,7 @@ var __async$k = (__this, __arguments, generator) => {
8261
8267
  const useCreateLabel = () => {
8262
8268
  const { client } = useShipEngine();
8263
8269
  return useMutation({
8264
- mutationFn: (_a) => __async$k(void 0, null, function* () {
8270
+ mutationFn: (_a) => __async$l(void 0, null, function* () {
8265
8271
  var _b = _a, { rateId } = _b, options = __objRest$6(_b, ["rateId"]);
8266
8272
  const result = yield client.labels.createByRateId(rateId, options);
8267
8273
  return result.data;
@@ -8271,7 +8277,7 @@ const useCreateLabel = () => {
8271
8277
  });
8272
8278
  };
8273
8279
 
8274
- var __async$j = (__this, __arguments, generator) => {
8280
+ var __async$k = (__this, __arguments, generator) => {
8275
8281
  return new Promise((resolve, reject) => {
8276
8282
  var fulfilled = (value) => {
8277
8283
  try {
@@ -8294,7 +8300,7 @@ var __async$j = (__this, __arguments, generator) => {
8294
8300
  const useCreateRateCard = () => {
8295
8301
  const { client } = useShipEngine();
8296
8302
  return useMutation({
8297
- mutationFn: (rateCard) => __async$j(void 0, null, function* () {
8303
+ mutationFn: (rateCard) => __async$k(void 0, null, function* () {
8298
8304
  const result = yield client.rateCards.create(rateCard);
8299
8305
  return result.data;
8300
8306
  }),
@@ -8303,22 +8309,22 @@ const useCreateRateCard = () => {
8303
8309
  });
8304
8310
  };
8305
8311
 
8306
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8307
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8308
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8312
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
8313
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
8314
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
8309
8315
  var __objRest$5 = (source, exclude) => {
8310
8316
  var target = {};
8311
8317
  for (var prop in source)
8312
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8318
+ if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
8313
8319
  target[prop] = source[prop];
8314
- if (source != null && __getOwnPropSymbols$6)
8315
- for (var prop of __getOwnPropSymbols$6(source)) {
8316
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
8320
+ if (source != null && __getOwnPropSymbols$8)
8321
+ for (var prop of __getOwnPropSymbols$8(source)) {
8322
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
8317
8323
  target[prop] = source[prop];
8318
8324
  }
8319
8325
  return target;
8320
8326
  };
8321
- var __async$i = (__this, __arguments, generator) => {
8327
+ var __async$j = (__this, __arguments, generator) => {
8322
8328
  return new Promise((resolve, reject) => {
8323
8329
  var fulfilled = (value) => {
8324
8330
  try {
@@ -8341,7 +8347,7 @@ var __async$i = (__this, __arguments, generator) => {
8341
8347
  const useCreateSalesOrderShipment = () => {
8342
8348
  const { client } = useShipEngine();
8343
8349
  return useMutation({
8344
- mutationFn: (_a) => __async$i(void 0, null, function* () {
8350
+ mutationFn: (_a) => __async$j(void 0, null, function* () {
8345
8351
  var _b = _a, { salesOrderId } = _b, shipment = __objRest$5(_b, ["salesOrderId"]);
8346
8352
  const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
8347
8353
  return result.data;
@@ -8351,26 +8357,26 @@ const useCreateSalesOrderShipment = () => {
8351
8357
  });
8352
8358
  };
8353
8359
 
8354
- var __defProp$1 = Object.defineProperty;
8355
- var __defProps = Object.defineProperties;
8356
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8357
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8358
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8359
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8360
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8361
- var __spreadValues$1 = (a, b) => {
8360
+ var __defProp$3 = Object.defineProperty;
8361
+ var __defProps$2 = Object.defineProperties;
8362
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
8363
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8364
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8365
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8366
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8367
+ var __spreadValues$3 = (a, b) => {
8362
8368
  for (var prop in b || (b = {}))
8363
- if (__hasOwnProp$5.call(b, prop))
8364
- __defNormalProp$1(a, prop, b[prop]);
8365
- if (__getOwnPropSymbols$5)
8366
- for (var prop of __getOwnPropSymbols$5(b)) {
8367
- if (__propIsEnum$5.call(b, prop))
8368
- __defNormalProp$1(a, prop, b[prop]);
8369
+ if (__hasOwnProp$7.call(b, prop))
8370
+ __defNormalProp$3(a, prop, b[prop]);
8371
+ if (__getOwnPropSymbols$7)
8372
+ for (var prop of __getOwnPropSymbols$7(b)) {
8373
+ if (__propIsEnum$7.call(b, prop))
8374
+ __defNormalProp$3(a, prop, b[prop]);
8369
8375
  }
8370
8376
  return a;
8371
8377
  };
8372
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8373
- var __async$h = (__this, __arguments, generator) => {
8378
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
8379
+ var __async$i = (__this, __arguments, generator) => {
8374
8380
  return new Promise((resolve, reject) => {
8375
8381
  var fulfilled = (value) => {
8376
8382
  try {
@@ -8393,7 +8399,7 @@ var __async$h = (__this, __arguments, generator) => {
8393
8399
  const useCreateShipment = () => {
8394
8400
  const { client } = useShipEngine();
8395
8401
  return useMutation({
8396
- mutationFn: (shipment) => __async$h(void 0, null, function* () {
8402
+ mutationFn: (shipment) => __async$i(void 0, null, function* () {
8397
8403
  var _a;
8398
8404
  if (shipment.warehouseId === void 0) {
8399
8405
  throw new CodedError("errorMessages.noWarehouses", {
@@ -8411,7 +8417,7 @@ const useCreateShipment = () => {
8411
8417
  postalCode: "",
8412
8418
  stateProvince: ""
8413
8419
  };
8414
- return (yield client.shipments.create(__spreadProps(__spreadValues$1({}, shipment), {
8420
+ return (yield client.shipments.create(__spreadProps$2(__spreadValues$3({}, shipment), {
8415
8421
  shipTo
8416
8422
  }))).data;
8417
8423
  }),
@@ -8420,7 +8426,7 @@ const useCreateShipment = () => {
8420
8426
  });
8421
8427
  };
8422
8428
 
8423
- var __async$g = (__this, __arguments, generator) => {
8429
+ var __async$h = (__this, __arguments, generator) => {
8424
8430
  return new Promise((resolve, reject) => {
8425
8431
  var fulfilled = (value) => {
8426
8432
  try {
@@ -8443,7 +8449,7 @@ var __async$g = (__this, __arguments, generator) => {
8443
8449
  const useCreateWarehouse = () => {
8444
8450
  const { client } = useShipEngine();
8445
8451
  return useMutation({
8446
- mutationFn: (data) => __async$g(void 0, null, function* () {
8452
+ mutationFn: (data) => __async$h(void 0, null, function* () {
8447
8453
  const result = yield client.warehouses.create(data);
8448
8454
  return result.data;
8449
8455
  }),
@@ -8452,7 +8458,7 @@ const useCreateWarehouse = () => {
8452
8458
  });
8453
8459
  };
8454
8460
 
8455
- var __async$f = (__this, __arguments, generator) => {
8461
+ var __async$g = (__this, __arguments, generator) => {
8456
8462
  return new Promise((resolve, reject) => {
8457
8463
  var fulfilled = (value) => {
8458
8464
  try {
@@ -8475,7 +8481,7 @@ var __async$f = (__this, __arguments, generator) => {
8475
8481
  const useDeleteWarehouse = () => {
8476
8482
  const { client } = useShipEngine();
8477
8483
  return useMutation({
8478
- mutationFn: (_0) => __async$f(void 0, [_0], function* ({ warehouseId }) {
8484
+ mutationFn: (_0) => __async$g(void 0, [_0], function* ({ warehouseId }) {
8479
8485
  const result = yield client.warehouses.delete(warehouseId);
8480
8486
  return result.data;
8481
8487
  }),
@@ -8496,6 +8502,38 @@ const useDownloadRateCard = (rateCardId) => {
8496
8502
  });
8497
8503
  };
8498
8504
 
8505
+ var __async$f = (__this, __arguments, generator) => {
8506
+ return new Promise((resolve, reject) => {
8507
+ var fulfilled = (value) => {
8508
+ try {
8509
+ step(generator.next(value));
8510
+ } catch (e) {
8511
+ reject(e);
8512
+ }
8513
+ };
8514
+ var rejected = (value) => {
8515
+ try {
8516
+ step(generator.throw(value));
8517
+ } catch (e) {
8518
+ reject(e);
8519
+ }
8520
+ };
8521
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
8522
+ step((generator = generator.apply(__this, __arguments)).next());
8523
+ });
8524
+ };
8525
+ const useFundingSourcesAddFunds = (fundingSourceId) => {
8526
+ const { client } = useShipEngine();
8527
+ return useMutation({
8528
+ mutationFn: (funds) => __async$f(void 0, null, function* () {
8529
+ const result = yield client.fundingSources.addFunds(funds, fundingSourceId);
8530
+ return result.data;
8531
+ }),
8532
+ mutationKey: ["useFundingSourcesAddFunds"],
8533
+ onError
8534
+ });
8535
+ };
8536
+
8499
8537
  const useGetAccountSettings = () => {
8500
8538
  const { client } = useShipEngine();
8501
8539
  return useQuery({
@@ -8538,6 +8576,40 @@ const useGetCarrierById = (carrierId) => {
8538
8576
  });
8539
8577
  };
8540
8578
 
8579
+ const useGetCountriesByCarrier = (carrierId) => {
8580
+ const { client } = useShipEngine();
8581
+ return useQuery({
8582
+ enabled: !!carrierId,
8583
+ onError,
8584
+ queryFn: () => {
8585
+ if (carrierId)
8586
+ return client.carriers.getCountries(carrierId);
8587
+ return Promise.reject(new Error("carrierId is require"));
8588
+ },
8589
+ queryKey: ["useGetCountriesByCarrier", carrierId],
8590
+ select: (result) => result.data.countries,
8591
+ // Fresh for 5 minutes
8592
+ staleTime: 5 * 60 * 1e3
8593
+ });
8594
+ };
8595
+
8596
+ const useGetCurrenciesByCarrier = (carrierId) => {
8597
+ const { client } = useShipEngine();
8598
+ return useQuery({
8599
+ enabled: !!carrierId,
8600
+ onError,
8601
+ queryFn: () => {
8602
+ if (carrierId)
8603
+ return client.carriers.getCurrencies(carrierId);
8604
+ return Promise.reject(new Error("carrierId is require"));
8605
+ },
8606
+ queryKey: ["useGetCurrenciesByCarrier", carrierId],
8607
+ select: (result) => result.data.currencies,
8608
+ // Fresh for 5 minutes
8609
+ staleTime: 5 * 60 * 1e3
8610
+ });
8611
+ };
8612
+
8541
8613
  const useGetFundingSourceById = (fundingSourceId) => {
8542
8614
  const { client } = useShipEngine();
8543
8615
  return useQuery({
@@ -8578,6 +8650,19 @@ const useGetLabel = (labelId) => {
8578
8650
  });
8579
8651
  };
8580
8652
 
8653
+ const useGetRateCardById = (rateCardId) => {
8654
+ const { client } = useShipEngine();
8655
+ return useQuery({
8656
+ enabled: !!rateCardId,
8657
+ onError,
8658
+ queryFn: () => {
8659
+ return client.rateCards.get(rateCardId);
8660
+ },
8661
+ queryKey: ["useGetRateCardById", rateCardId],
8662
+ select: (result) => result.data
8663
+ });
8664
+ };
8665
+
8581
8666
  const useGetRatePackageFormatsByCarrier = (carrierId) => {
8582
8667
  const { client } = useShipEngine();
8583
8668
  return useQuery({
@@ -8595,32 +8680,32 @@ const useGetRatePackageFormatsByCarrier = (carrierId) => {
8595
8680
  });
8596
8681
  };
8597
8682
 
8598
- const useGetSalesOrder = (salesOrderId) => {
8683
+ const useGetSalesOrderShipment = (shipmentId) => {
8599
8684
  const { client } = useShipEngine();
8600
8685
  return useQuery({
8601
- enabled: salesOrderId !== void 0,
8686
+ enabled: shipmentId !== void 0,
8602
8687
  onError,
8603
8688
  queryFn: () => {
8604
- if (salesOrderId)
8605
- return client.salesOrders.get(salesOrderId);
8606
- return Promise.reject(new Error("salesOrderId is required"));
8689
+ if (shipmentId)
8690
+ return client.salesOrderShipments.get(shipmentId);
8691
+ return Promise.reject(new Error("shipmentId is required"));
8607
8692
  },
8608
- queryKey: ["useGetSalesOrder", salesOrderId],
8693
+ queryKey: ["useGetSalesOrderShipment", shipmentId],
8609
8694
  select: (result) => result.data
8610
8695
  });
8611
8696
  };
8612
8697
 
8613
- const useGetSalesOrderShipment = (shipmentId) => {
8698
+ const useGetSalesOrder = (salesOrderId) => {
8614
8699
  const { client } = useShipEngine();
8615
8700
  return useQuery({
8616
- enabled: shipmentId !== void 0,
8701
+ enabled: salesOrderId !== void 0,
8617
8702
  onError,
8618
8703
  queryFn: () => {
8619
- if (shipmentId)
8620
- return client.salesOrderShipments.get(shipmentId);
8621
- return Promise.reject(new Error("shipmentId is required"));
8704
+ if (salesOrderId)
8705
+ return client.salesOrders.get(salesOrderId);
8706
+ return Promise.reject(new Error("salesOrderId is required"));
8622
8707
  },
8623
- queryKey: ["useGetSalesOrderShipment", shipmentId],
8708
+ queryKey: ["useGetSalesOrder", salesOrderId],
8624
8709
  select: (result) => result.data
8625
8710
  });
8626
8711
  };
@@ -8642,31 +8727,34 @@ const useGetServicesByCarrier = (carrierId) => {
8642
8727
  });
8643
8728
  };
8644
8729
 
8645
- const useGetShipment = (shipmentId) => {
8730
+ const useGetShipmentRates = (shipmentId, createdAtStart) => {
8646
8731
  const { client } = useShipEngine();
8647
8732
  return useQuery({
8648
8733
  enabled: shipmentId !== void 0,
8649
8734
  onError,
8650
8735
  queryFn: () => {
8651
- if (!shipmentId) {
8652
- return Promise.reject(new Error("shipmentId is required"));
8736
+ if (shipmentId) {
8737
+ return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
8653
8738
  }
8654
- return client.salesOrderShipments.get(shipmentId);
8739
+ return Promise.reject(new Error("shipmentId is required"));
8655
8740
  },
8656
- queryKey: ["useGetShipment", shipmentId],
8741
+ queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
8657
8742
  select: (result) => result.data
8658
8743
  });
8659
8744
  };
8660
8745
 
8661
- const useGetRateCardById = (rateCardId) => {
8746
+ const useGetShipment = (shipmentId) => {
8662
8747
  const { client } = useShipEngine();
8663
8748
  return useQuery({
8664
- enabled: !!rateCardId,
8749
+ enabled: shipmentId !== void 0,
8665
8750
  onError,
8666
8751
  queryFn: () => {
8667
- return client.rateCards.get(rateCardId);
8752
+ if (!shipmentId) {
8753
+ return Promise.reject(new Error("shipmentId is required"));
8754
+ }
8755
+ return client.salesOrderShipments.get(shipmentId);
8668
8756
  },
8669
- queryKey: ["useGetRateCardById", rateCardId],
8757
+ queryKey: ["useGetShipment", shipmentId],
8670
8758
  select: (result) => result.data
8671
8759
  });
8672
8760
  };
@@ -8689,40 +8777,6 @@ const useGetWalletHistory = ({
8689
8777
  });
8690
8778
  };
8691
8779
 
8692
- const useGetCountriesByCarrier = (carrierId) => {
8693
- const { client } = useShipEngine();
8694
- return useQuery({
8695
- enabled: !!carrierId,
8696
- onError,
8697
- queryFn: () => {
8698
- if (carrierId)
8699
- return client.carriers.getCountries(carrierId);
8700
- return Promise.reject(new Error("carrierId is require"));
8701
- },
8702
- queryKey: ["useGetCountriesByCarrier", carrierId],
8703
- select: (result) => result.data.countries,
8704
- // Fresh for 5 minutes
8705
- staleTime: 5 * 60 * 1e3
8706
- });
8707
- };
8708
-
8709
- const useGetCurrenciesByCarrier = (carrierId) => {
8710
- const { client } = useShipEngine();
8711
- return useQuery({
8712
- enabled: !!carrierId,
8713
- onError,
8714
- queryFn: () => {
8715
- if (carrierId)
8716
- return client.carriers.getCurrencies(carrierId);
8717
- return Promise.reject(new Error("carrierId is require"));
8718
- },
8719
- queryKey: ["useGetCurrenciesByCarrier", carrierId],
8720
- select: (result) => result.data.currencies,
8721
- // Fresh for 5 minutes
8722
- staleTime: 5 * 60 * 1e3
8723
- });
8724
- };
8725
-
8726
8780
  const useListCarriers = () => {
8727
8781
  const { client } = useShipEngine();
8728
8782
  return useQuery({
@@ -8809,17 +8863,17 @@ const useListSalesOrders = (params = {}) => {
8809
8863
  });
8810
8864
  };
8811
8865
 
8812
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8813
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8814
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
8866
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8867
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8868
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8815
8869
  var __objRest$4 = (source, exclude) => {
8816
8870
  var target = {};
8817
8871
  for (var prop in source)
8818
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
8872
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8819
8873
  target[prop] = source[prop];
8820
- if (source != null && __getOwnPropSymbols$4)
8821
- for (var prop of __getOwnPropSymbols$4(source)) {
8822
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
8874
+ if (source != null && __getOwnPropSymbols$6)
8875
+ for (var prop of __getOwnPropSymbols$6(source)) {
8876
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
8823
8877
  target[prop] = source[prop];
8824
8878
  }
8825
8879
  return target;
@@ -8848,17 +8902,17 @@ const useListWarehouses = (options) => {
8848
8902
  });
8849
8903
  };
8850
8904
 
8851
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
8852
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
8853
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
8905
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8906
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8907
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8854
8908
  var __objRest$3 = (source, exclude) => {
8855
8909
  var target = {};
8856
8910
  for (var prop in source)
8857
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
8911
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8858
8912
  target[prop] = source[prop];
8859
- if (source != null && __getOwnPropSymbols$3)
8860
- for (var prop of __getOwnPropSymbols$3(source)) {
8861
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
8913
+ if (source != null && __getOwnPropSymbols$5)
8914
+ for (var prop of __getOwnPropSymbols$5(source)) {
8915
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
8862
8916
  target[prop] = source[prop];
8863
8917
  }
8864
8918
  return target;
@@ -9010,22 +9064,6 @@ const useRegisterCarrier = () => {
9010
9064
  });
9011
9065
  };
9012
9066
 
9013
- const useGetShipmentRates = (shipmentId, createdAtStart) => {
9014
- const { client } = useShipEngine();
9015
- return useQuery({
9016
- enabled: shipmentId !== void 0,
9017
- onError,
9018
- queryFn: () => {
9019
- if (shipmentId) {
9020
- return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
9021
- }
9022
- return Promise.reject(new Error("shipmentId is required"));
9023
- },
9024
- queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
9025
- select: (result) => result.data
9026
- });
9027
- };
9028
-
9029
9067
  var __async$a = (__this, __arguments, generator) => {
9030
9068
  return new Promise((resolve, reject) => {
9031
9069
  var fulfilled = (value) => {
@@ -9166,17 +9204,17 @@ const useUpdateRateCard = () => {
9166
9204
  });
9167
9205
  };
9168
9206
 
9169
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
9170
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
9171
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
9207
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
9208
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
9209
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
9172
9210
  var __objRest$2 = (source, exclude) => {
9173
9211
  var target = {};
9174
9212
  for (var prop in source)
9175
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
9213
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
9176
9214
  target[prop] = source[prop];
9177
- if (source != null && __getOwnPropSymbols$2)
9178
- for (var prop of __getOwnPropSymbols$2(source)) {
9179
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
9215
+ if (source != null && __getOwnPropSymbols$4)
9216
+ for (var prop of __getOwnPropSymbols$4(source)) {
9217
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
9180
9218
  target[prop] = source[prop];
9181
9219
  }
9182
9220
  return target;
@@ -9214,17 +9252,17 @@ const useUpdateSalesOrderShipment = () => {
9214
9252
  });
9215
9253
  };
9216
9254
 
9217
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
9218
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
9219
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
9255
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
9256
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
9257
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
9220
9258
  var __objRest$1 = (source, exclude) => {
9221
9259
  var target = {};
9222
9260
  for (var prop in source)
9223
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
9261
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
9224
9262
  target[prop] = source[prop];
9225
- if (source != null && __getOwnPropSymbols$1)
9226
- for (var prop of __getOwnPropSymbols$1(source)) {
9227
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
9263
+ if (source != null && __getOwnPropSymbols$3)
9264
+ for (var prop of __getOwnPropSymbols$3(source)) {
9265
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
9228
9266
  target[prop] = source[prop];
9229
9267
  }
9230
9268
  return target;
@@ -9408,81 +9446,83 @@ const useLoadIcons = ({ brandName, cdnURL = "/" }) => {
9408
9446
  }
9409
9447
  }))();
9410
9448
  }, [brandName, cdnURL]);
9411
- return (iconName) => __async$1(void 0, null, function* () {
9412
- if (iconIndex) {
9413
- const iconBrand = (iconIndex[iconName.toLowerCase()] || []).includes(brandName) ? brandName : BrandName.FALLBACK;
9414
- const result = yield axios.get(`/brand/${iconBrand}/icons/${iconName.toLowerCase()}.svg`, {
9415
- baseURL: cdnURL,
9416
- responseType: "text"
9417
- });
9418
- return result.data;
9419
- }
9420
- return void 0;
9421
- });
9422
- };
9423
-
9424
- var __async = (__this, __arguments, generator) => {
9425
- return new Promise((resolve, reject) => {
9426
- var fulfilled = (value) => {
9427
- try {
9428
- step(generator.next(value));
9429
- } catch (e) {
9430
- reject(e);
9431
- }
9432
- };
9433
- var rejected = (value) => {
9434
- try {
9435
- step(generator.throw(value));
9436
- } catch (e) {
9437
- reject(e);
9449
+ return useCallback(
9450
+ (iconName) => __async$1(void 0, null, function* () {
9451
+ if (iconIndex) {
9452
+ const iconBrand = (iconIndex[iconName.toLowerCase()] || []).includes(brandName) ? brandName : BrandName.FALLBACK;
9453
+ const result = yield axios.get(
9454
+ `/brand/${iconBrand}/icons/${iconName.toLowerCase()}.svg`,
9455
+ {
9456
+ baseURL: cdnURL,
9457
+ responseType: "text"
9458
+ }
9459
+ );
9460
+ return result.data;
9438
9461
  }
9439
- };
9440
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
9441
- step((generator = generator.apply(__this, __arguments)).next());
9442
- });
9462
+ return "";
9463
+ }),
9464
+ [brandName, cdnURL, iconIndex]
9465
+ );
9443
9466
  };
9467
+
9444
9468
  const useLoadTheme = ({ cdnURL = "/", brandName }) => {
9445
9469
  const [theme, setTheme] = useState();
9446
9470
  useEffect(() => {
9447
- (() => __async(void 0, null, function* () {
9448
- try {
9449
- const result = yield axios.get(`/brand/${brandName}/theme.json`, { baseURL: cdnURL });
9450
- const theme2 = new Theme(result.data);
9451
- setTheme(theme2);
9452
- } catch (error) {
9453
- logger.error({ error }, `Error loading theme for brand ${brandName}`);
9454
- }
9455
- }))();
9471
+ axios.get(`/brand/${brandName}/theme.json`, { baseURL: cdnURL }).then(({ data }) => setTheme(new Theme(data))).catch((error) => logger.error({ error }, `Error loading theme for brand ${brandName}`));
9456
9472
  }, [brandName, cdnURL]);
9457
9473
  return theme;
9458
9474
  };
9459
9475
 
9476
+ var __defProp$2 = Object.defineProperty;
9477
+ var __defProps$1 = Object.defineProperties;
9478
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
9479
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
9480
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
9481
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
9482
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9483
+ var __spreadValues$2 = (a, b) => {
9484
+ for (var prop in b || (b = {}))
9485
+ if (__hasOwnProp$2.call(b, prop))
9486
+ __defNormalProp$2(a, prop, b[prop]);
9487
+ if (__getOwnPropSymbols$2)
9488
+ for (var prop of __getOwnPropSymbols$2(b)) {
9489
+ if (__propIsEnum$2.call(b, prop))
9490
+ __defNormalProp$2(a, prop, b[prop]);
9491
+ }
9492
+ return a;
9493
+ };
9494
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
9460
9495
  const AlchemyContext = createContext(void 0);
9461
- const Alchemy = ({
9496
+ const renderAlchemyProviders = ({
9497
+ baseURL,
9498
+ children,
9499
+ getToken,
9500
+ theme,
9501
+ scope,
9502
+ fontStyles,
9503
+ iconCache,
9504
+ resolveIcon
9505
+ }) => /* @__PURE__ */ jsxs(ThemeProvider, { theme, children: [
9506
+ /* @__PURE__ */ jsx(Global, { styles: [getEmotionResetStyles(scope), fontStyles] }),
9507
+ /* @__PURE__ */ jsx(GigerConfigProvider, { iconCache, resolveIcon, children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children }) })
9508
+ ] });
9509
+ const AlchemyProvider = ({
9462
9510
  baseURL = "https://api.shipengine.com",
9463
9511
  brandName = BrandName.FALLBACK,
9464
9512
  cdnURL = "/",
9465
9513
  children,
9466
9514
  getToken,
9467
- onError,
9515
+ onError = _default,
9468
9516
  scope = "lmnt"
9469
9517
  }) => {
9470
9518
  const theme = useLoadTheme({ brandName, cdnURL });
9471
9519
  const fontStyles = useLoadFonts({ cdnURL, scope, theme });
9472
9520
  const resolveIcon = useLoadIcons({ brandName, cdnURL });
9521
+ const iconCache = useMemo(createIconCache, []);
9473
9522
  if (!theme)
9474
9523
  return null;
9475
- onError = onError != null ? onError : _default;
9476
- return /* @__PURE__ */ jsx(
9477
- AlchemyContext.Provider,
9478
- {
9479
- value: { baseURL, brandName, cdnURL, getToken, onError, scope, theme },
9480
- children: /* @__PURE__ */ jsxs(ThemeProvider, { theme, children: [
9481
- /* @__PURE__ */ jsx(Global, { styles: [getEmotionResetStyles(scope), fontStyles] }),
9482
- /* @__PURE__ */ jsx(GigerConfigProvider, { resolveIcon, children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children }) })
9483
- ] })
9484
- }
9485
- );
9524
+ const contextValue = { baseURL, brandName, cdnURL, getToken, onError, scope, theme };
9525
+ return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: renderAlchemyProviders(__spreadProps$1(__spreadValues$2({}, contextValue), { children, fontStyles, iconCache, resolveIcon })) });
9486
9526
  };
9487
9527
  const useAlchemy = () => {
9488
9528
  const context = useContext(AlchemyContext);
@@ -9492,6 +9532,69 @@ const useAlchemy = () => {
9492
9532
  return context;
9493
9533
  };
9494
9534
 
9535
+ var __defProp$1 = Object.defineProperty;
9536
+ var __defProps = Object.defineProperties;
9537
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9538
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
9539
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
9540
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
9541
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9542
+ var __spreadValues$1 = (a, b) => {
9543
+ for (var prop in b || (b = {}))
9544
+ if (__hasOwnProp$1.call(b, prop))
9545
+ __defNormalProp$1(a, prop, b[prop]);
9546
+ if (__getOwnPropSymbols$1)
9547
+ for (var prop of __getOwnPropSymbols$1(b)) {
9548
+ if (__propIsEnum$1.call(b, prop))
9549
+ __defNormalProp$1(a, prop, b[prop]);
9550
+ }
9551
+ return a;
9552
+ };
9553
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9554
+ var __async = (__this, __arguments, generator) => {
9555
+ return new Promise((resolve, reject) => {
9556
+ var fulfilled = (value) => {
9557
+ try {
9558
+ step(generator.next(value));
9559
+ } catch (e) {
9560
+ reject(e);
9561
+ }
9562
+ };
9563
+ var rejected = (value) => {
9564
+ try {
9565
+ step(generator.throw(value));
9566
+ } catch (e) {
9567
+ reject(e);
9568
+ }
9569
+ };
9570
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
9571
+ step((generator = generator.apply(__this, __arguments)).next());
9572
+ });
9573
+ };
9574
+ const AlchemyTestProvider = ({ baseURL, children }) => {
9575
+ const scope = "lmnt";
9576
+ const theme = useMemo(() => new Theme(), []);
9577
+ const fontStyles = css({ [`.${scope}`]: { fontFamily: theme.defaultFontFamily } });
9578
+ const getToken = useCallback(() => "none", []);
9579
+ const iconCache = useMemo(createIconCache, []);
9580
+ const resolveIcon = useCallback(
9581
+ (iconName) => __async(void 0, null, function* () {
9582
+ return `<svg data-svg-id="${iconName}">mock icon-${iconName}</svg>`;
9583
+ }),
9584
+ []
9585
+ );
9586
+ const contextValue = {
9587
+ baseURL,
9588
+ brandName: BrandName.FALLBACK,
9589
+ cdnURL: "mockCdnUrl",
9590
+ getToken,
9591
+ onError: _default,
9592
+ scope,
9593
+ theme
9594
+ };
9595
+ return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: renderAlchemyProviders(__spreadProps(__spreadValues$1({}, contextValue), { children, fontStyles, iconCache, resolveIcon })) });
9596
+ };
9597
+
9495
9598
  var classnamesExports = {};
9496
9599
  var classnames = {
9497
9600
  get exports(){ return classnamesExports; },
@@ -10092,4 +10195,4 @@ const alchemy = {
10092
10195
  createElement
10093
10196
  };
10094
10197
 
10095
- export { AccountSettingsAPI, AddressesAPI, Alchemy, AlchemyContext, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateRateCard, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteWarehouse, useDownloadRateCard, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetCountriesByCarrier, useGetCurrenciesByCarrier, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetRateCardById, useGetRatePackageFormatsByCarrier, useGetSalesOrder, useGetSalesOrderShipment, useGetServicesByCarrier, useGetShipment, useGetShipmentRates, useGetWalletHistory, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListShipments, useListWarehouses, useLoadFonts, useLoadIcons, useLoadTheme, useNotifySalesOrderShipped, useParseAddress, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateRateCard, useUpdateSalesOrderShipment, useUpdateWarehouse, useValidateAddresses, useVoidLabel };
10198
+ export { AccountSettingsAPI, AddressesAPI, AlchemyContext, AlchemyProvider, AlchemyTestProvider, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, renderAlchemyProviders, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateRateCard, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteWarehouse, useDownloadRateCard, useFundingSourcesAddFunds, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetCountriesByCarrier, useGetCurrenciesByCarrier, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetRateCardById, useGetRatePackageFormatsByCarrier, useGetSalesOrder, useGetSalesOrderShipment, useGetServicesByCarrier, useGetShipment, useGetShipmentRates, useGetWalletHistory, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListShipments, useListWarehouses, useLoadFonts, useLoadIcons, useLoadTheme, useNotifySalesOrderShipped, useParseAddress, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateRateCard, useUpdateSalesOrderShipment, useUpdateWarehouse, useValidateAddresses, useVoidLabel };