@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.js CHANGED
@@ -2477,17 +2477,17 @@ Object.defineProperty(dist, "__esModule", { value: true });
2477
2477
  var _default = dist.default = (function () {
2478
2478
  });
2479
2479
 
2480
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
2481
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
2482
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
2480
+ var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
2481
+ var __hasOwnProp$e = Object.prototype.hasOwnProperty;
2482
+ var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
2483
2483
  var __objRest$8 = (source, exclude) => {
2484
2484
  var target = {};
2485
2485
  for (var prop in source)
2486
- if (__hasOwnProp$c.call(source, prop) && exclude.indexOf(prop) < 0)
2486
+ if (__hasOwnProp$e.call(source, prop) && exclude.indexOf(prop) < 0)
2487
2487
  target[prop] = source[prop];
2488
- if (source != null && __getOwnPropSymbols$c)
2489
- for (var prop of __getOwnPropSymbols$c(source)) {
2490
- if (exclude.indexOf(prop) < 0 && __propIsEnum$c.call(source, prop))
2488
+ if (source != null && __getOwnPropSymbols$e)
2489
+ for (var prop of __getOwnPropSymbols$e(source)) {
2490
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$e.call(source, prop))
2491
2491
  target[prop] = source[prop];
2492
2492
  }
2493
2493
  return target;
@@ -5231,7 +5231,7 @@ var ipaddr = {
5231
5231
  }).call(commonjsGlobal);
5232
5232
  } (ipaddr));
5233
5233
 
5234
- var __async$t = (__this, __arguments, generator) => {
5234
+ var __async$u = (__this, __arguments, generator) => {
5235
5235
  return new Promise((resolve, reject) => {
5236
5236
  var fulfilled = (value) => {
5237
5237
  try {
@@ -5251,7 +5251,7 @@ var __async$t = (__this, __arguments, generator) => {
5251
5251
  step((generator = generator.apply(__this, __arguments)).next());
5252
5252
  });
5253
5253
  };
5254
- const getEndUserIpAddress = () => __async$t(void 0, null, function* () {
5254
+ const getEndUserIpAddress = () => __async$u(void 0, null, function* () {
5255
5255
  try {
5256
5256
  const response = yield axios.get("https://api.ipify.org/?format=json");
5257
5257
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -5263,38 +5263,38 @@ const getEndUserIpAddress = () => __async$t(void 0, null, function* () {
5263
5263
  }
5264
5264
  });
5265
5265
 
5266
- var __defProp$5 = Object.defineProperty;
5267
- var __defProps$3 = Object.defineProperties;
5268
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
5269
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
5270
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
5271
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
5272
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5273
- var __spreadValues$5 = (a, b) => {
5266
+ var __defProp$7 = Object.defineProperty;
5267
+ var __defProps$5 = Object.defineProperties;
5268
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
5269
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
5270
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
5271
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
5272
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5273
+ var __spreadValues$7 = (a, b) => {
5274
5274
  for (var prop in b || (b = {}))
5275
- if (__hasOwnProp$b.call(b, prop))
5276
- __defNormalProp$5(a, prop, b[prop]);
5277
- if (__getOwnPropSymbols$b)
5278
- for (var prop of __getOwnPropSymbols$b(b)) {
5279
- if (__propIsEnum$b.call(b, prop))
5280
- __defNormalProp$5(a, prop, b[prop]);
5275
+ if (__hasOwnProp$d.call(b, prop))
5276
+ __defNormalProp$7(a, prop, b[prop]);
5277
+ if (__getOwnPropSymbols$d)
5278
+ for (var prop of __getOwnPropSymbols$d(b)) {
5279
+ if (__propIsEnum$d.call(b, prop))
5280
+ __defNormalProp$7(a, prop, b[prop]);
5281
5281
  }
5282
5282
  return a;
5283
5283
  };
5284
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
5284
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
5285
5285
  var __objRest$7 = (source, exclude) => {
5286
5286
  var target = {};
5287
5287
  for (var prop in source)
5288
- if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
5288
+ if (__hasOwnProp$d.call(source, prop) && exclude.indexOf(prop) < 0)
5289
5289
  target[prop] = source[prop];
5290
- if (source != null && __getOwnPropSymbols$b)
5291
- for (var prop of __getOwnPropSymbols$b(source)) {
5292
- if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
5290
+ if (source != null && __getOwnPropSymbols$d)
5291
+ for (var prop of __getOwnPropSymbols$d(source)) {
5292
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$d.call(source, prop))
5293
5293
  target[prop] = source[prop];
5294
5294
  }
5295
5295
  return target;
5296
5296
  };
5297
- var __async$s = (__this, __arguments, generator) => {
5297
+ var __async$t = (__this, __arguments, generator) => {
5298
5298
  return new Promise((resolve, reject) => {
5299
5299
  var fulfilled = (value) => {
5300
5300
  try {
@@ -5323,12 +5323,12 @@ class CarriersAPI {
5323
5323
  this.get = (carrierId) => {
5324
5324
  return this.client.get(`/v1/carriers/${carrierId}`);
5325
5325
  };
5326
- this.connect = (_a) => __async$s(this, null, function* () {
5326
+ this.connect = (_a) => __async$t(this, null, function* () {
5327
5327
  var _b = _a, { carrierCode } = _b, connection = __objRest$7(_b, ["carrierCode"]);
5328
5328
  const endUserIpAddress = yield getEndUserIpAddress();
5329
5329
  if (!endUserIpAddress)
5330
5330
  return Promise.reject([new CodedError("Unable to get IP address")]);
5331
- return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$3(__spreadValues$5({}, connection), {
5331
+ return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$5(__spreadValues$7({}, connection), {
5332
5332
  endUserIpAddress
5333
5333
  }));
5334
5334
  });
@@ -7560,23 +7560,23 @@ class CustomPackagesAPI {
7560
7560
  }
7561
7561
  }
7562
7562
 
7563
- var __defProp$4 = Object.defineProperty;
7564
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
7565
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
7566
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
7567
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7568
- var __spreadValues$4 = (a, b) => {
7563
+ var __defProp$6 = Object.defineProperty;
7564
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
7565
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
7566
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
7567
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7568
+ var __spreadValues$6 = (a, b) => {
7569
7569
  for (var prop in b || (b = {}))
7570
- if (__hasOwnProp$a.call(b, prop))
7571
- __defNormalProp$4(a, prop, b[prop]);
7572
- if (__getOwnPropSymbols$a)
7573
- for (var prop of __getOwnPropSymbols$a(b)) {
7574
- if (__propIsEnum$a.call(b, prop))
7575
- __defNormalProp$4(a, prop, b[prop]);
7570
+ if (__hasOwnProp$c.call(b, prop))
7571
+ __defNormalProp$6(a, prop, b[prop]);
7572
+ if (__getOwnPropSymbols$c)
7573
+ for (var prop of __getOwnPropSymbols$c(b)) {
7574
+ if (__propIsEnum$c.call(b, prop))
7575
+ __defNormalProp$6(a, prop, b[prop]);
7576
7576
  }
7577
7577
  return a;
7578
7578
  };
7579
- var __async$r = (__this, __arguments, generator) => {
7579
+ var __async$s = (__this, __arguments, generator) => {
7580
7580
  return new Promise((resolve, reject) => {
7581
7581
  var fulfilled = (value) => {
7582
7582
  try {
@@ -7605,15 +7605,15 @@ class FundingSourcesAPI {
7605
7605
  this.get = (fundingSourceId) => {
7606
7606
  return this.client.get(`/v1/funding_sources/${fundingSourceId}`);
7607
7607
  };
7608
- this.create = (createFundingSource) => __async$r(this, null, function* () {
7608
+ this.create = (createFundingSource) => __async$s(this, null, function* () {
7609
7609
  const endUserIpAddress = yield getEndUserIpAddress();
7610
7610
  if (!endUserIpAddress)
7611
7611
  return Promise.reject([new CodedError("Unable to get IP address")]);
7612
- return yield this.client.post("/v1/funding_sources", __spreadValues$4({
7612
+ return yield this.client.post("/v1/funding_sources", __spreadValues$6({
7613
7613
  endUserIpAddress
7614
7614
  }, createFundingSource));
7615
7615
  });
7616
- this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$r(this, null, function* () {
7616
+ this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$s(this, null, function* () {
7617
7617
  const endUserIpAddress = yield getEndUserIpAddress();
7618
7618
  if (!endUserIpAddress)
7619
7619
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7626,14 +7626,20 @@ class FundingSourcesAPI {
7626
7626
  }
7627
7627
  );
7628
7628
  });
7629
- this.registerCarrier = (carrier) => __async$r(this, null, function* () {
7629
+ this.registerCarrier = (carrier) => __async$s(this, null, function* () {
7630
7630
  const endUserIpAddress = yield getEndUserIpAddress();
7631
7631
  if (!endUserIpAddress)
7632
7632
  return Promise.reject([new CodedError("Unable to get IP address")]);
7633
- return yield this.client.post("/v1/registration/funding_source", __spreadValues$4({
7633
+ return yield this.client.post("/v1/registration/funding_source", __spreadValues$6({
7634
7634
  endUserIpAddress
7635
7635
  }, carrier));
7636
7636
  });
7637
+ this.addFunds = (amount, fundingSourceId) => __async$s(this, null, function* () {
7638
+ return yield this.client.put(
7639
+ `/v1/funding_sources/${fundingSourceId}/add_funds`,
7640
+ amount
7641
+ );
7642
+ });
7637
7643
  this.client = client;
7638
7644
  }
7639
7645
  }
@@ -7765,7 +7771,7 @@ class SalesOrdersAPI {
7765
7771
  }
7766
7772
  }
7767
7773
 
7768
- var __async$q = (__this, __arguments, generator) => {
7774
+ var __async$r = (__this, __arguments, generator) => {
7769
7775
  return new Promise((resolve, reject) => {
7770
7776
  var fulfilled = (value) => {
7771
7777
  try {
@@ -7797,7 +7803,7 @@ class ShipmentsAPI {
7797
7803
  this.list = (options) => {
7798
7804
  return this.client.get("/v1/shipments", { params: options });
7799
7805
  };
7800
- this.create = (...shipments) => __async$q(this, null, function* () {
7806
+ this.create = (...shipments) => __async$r(this, null, function* () {
7801
7807
  return this.client.post("/v1/shipments", {
7802
7808
  shipments
7803
7809
  });
@@ -7825,26 +7831,26 @@ class WarehousesAPI {
7825
7831
  }
7826
7832
  }
7827
7833
 
7828
- var __defProp$3 = Object.defineProperty;
7829
- var __defProps$2 = Object.defineProperties;
7830
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
7831
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
7832
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
7833
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
7834
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7835
- var __spreadValues$3 = (a, b) => {
7834
+ var __defProp$5 = Object.defineProperty;
7835
+ var __defProps$4 = Object.defineProperties;
7836
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
7837
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
7838
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
7839
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
7840
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7841
+ var __spreadValues$5 = (a, b) => {
7836
7842
  for (var prop in b || (b = {}))
7837
- if (__hasOwnProp$9.call(b, prop))
7838
- __defNormalProp$3(a, prop, b[prop]);
7839
- if (__getOwnPropSymbols$9)
7840
- for (var prop of __getOwnPropSymbols$9(b)) {
7841
- if (__propIsEnum$9.call(b, prop))
7842
- __defNormalProp$3(a, prop, b[prop]);
7843
+ if (__hasOwnProp$b.call(b, prop))
7844
+ __defNormalProp$5(a, prop, b[prop]);
7845
+ if (__getOwnPropSymbols$b)
7846
+ for (var prop of __getOwnPropSymbols$b(b)) {
7847
+ if (__propIsEnum$b.call(b, prop))
7848
+ __defNormalProp$5(a, prop, b[prop]);
7843
7849
  }
7844
7850
  return a;
7845
7851
  };
7846
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
7847
- var __async$p = (__this, __arguments, generator) => {
7852
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
7853
+ var __async$q = (__this, __arguments, generator) => {
7848
7854
  return new Promise((resolve, reject) => {
7849
7855
  var fulfilled = (value) => {
7850
7856
  try {
@@ -7866,7 +7872,7 @@ var __async$p = (__this, __arguments, generator) => {
7866
7872
  };
7867
7873
  const logger$1 = E({
7868
7874
  name: "shipengine-api",
7869
- serializers: __spreadProps$2(__spreadValues$3({}, k), {
7875
+ serializers: __spreadProps$4(__spreadValues$5({}, k), {
7870
7876
  req: (req) => ({
7871
7877
  headers: req.headers,
7872
7878
  method: req.method,
@@ -7891,7 +7897,7 @@ class ShipEngineAPI {
7891
7897
  constructor(token, { baseURL, headers, getToken }) {
7892
7898
  const client = axios.create({
7893
7899
  baseURL,
7894
- headers: __spreadProps$2(__spreadValues$3({}, headers), {
7900
+ headers: __spreadProps$4(__spreadValues$5({}, headers), {
7895
7901
  Authorization: `Bearer ${token}`,
7896
7902
  "Content-Type": "application/json"
7897
7903
  }),
@@ -7925,7 +7931,7 @@ class ShipEngineAPI {
7925
7931
  );
7926
7932
  return res;
7927
7933
  },
7928
- (err) => __async$p(this, null, function* () {
7934
+ (err) => __async$q(this, null, function* () {
7929
7935
  var _a, _b, _c, _d, _e, _f, _g;
7930
7936
  logger$1.error(
7931
7937
  { err, req: err.config, res: err.response },
@@ -8065,25 +8071,25 @@ const delay = (ms) => new Promise((resolve) => {
8065
8071
 
8066
8072
  const onError = (errors) => errors.forEach(console.log);
8067
8073
 
8068
- var __defProp$2 = Object.defineProperty;
8069
- var __defProps$1 = Object.defineProperties;
8070
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
8071
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
8072
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
8073
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
8074
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8075
- var __spreadValues$2 = (a, b) => {
8074
+ var __defProp$4 = Object.defineProperty;
8075
+ var __defProps$3 = Object.defineProperties;
8076
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
8077
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
8078
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
8079
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
8080
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8081
+ var __spreadValues$4 = (a, b) => {
8076
8082
  for (var prop in b || (b = {}))
8077
- if (__hasOwnProp$8.call(b, prop))
8078
- __defNormalProp$2(a, prop, b[prop]);
8079
- if (__getOwnPropSymbols$8)
8080
- for (var prop of __getOwnPropSymbols$8(b)) {
8081
- if (__propIsEnum$8.call(b, prop))
8082
- __defNormalProp$2(a, prop, b[prop]);
8083
+ if (__hasOwnProp$a.call(b, prop))
8084
+ __defNormalProp$4(a, prop, b[prop]);
8085
+ if (__getOwnPropSymbols$a)
8086
+ for (var prop of __getOwnPropSymbols$a(b)) {
8087
+ if (__propIsEnum$a.call(b, prop))
8088
+ __defNormalProp$4(a, prop, b[prop]);
8083
8089
  }
8084
8090
  return a;
8085
8091
  };
8086
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
8092
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
8087
8093
  const streams = [];
8088
8094
  if (process.env.NODE_ENV === "production") {
8089
8095
  streams.push({
@@ -8092,7 +8098,7 @@ if (process.env.NODE_ENV === "production") {
8092
8098
  }
8093
8099
  const logger = E({
8094
8100
  name: "shipengine",
8095
- serializers: __spreadProps$1(__spreadValues$2({}, k), {
8101
+ serializers: __spreadProps$3(__spreadValues$4({}, k), {
8096
8102
  req: (req) => ({
8097
8103
  headers: req.headers,
8098
8104
  method: req.method,
@@ -8117,7 +8123,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
8117
8123
  throw error;
8118
8124
  });
8119
8125
 
8120
- var __async$o = (__this, __arguments, generator) => {
8126
+ var __async$p = (__this, __arguments, generator) => {
8121
8127
  return new Promise((resolve, reject) => {
8122
8128
  var fulfilled = (value) => {
8123
8129
  try {
@@ -8140,7 +8146,7 @@ var __async$o = (__this, __arguments, generator) => {
8140
8146
  const useAddFunds = (carrierId) => {
8141
8147
  const { client } = useShipEngine();
8142
8148
  return reactQuery.useMutation({
8143
- mutationFn: (funds) => __async$o(void 0, null, function* () {
8149
+ mutationFn: (funds) => __async$p(void 0, null, function* () {
8144
8150
  const result = yield client.carriers.addFunds(carrierId, funds);
8145
8151
  return result.data;
8146
8152
  }),
@@ -8149,7 +8155,7 @@ const useAddFunds = (carrierId) => {
8149
8155
  });
8150
8156
  };
8151
8157
 
8152
- var __async$n = (__this, __arguments, generator) => {
8158
+ var __async$o = (__this, __arguments, generator) => {
8153
8159
  return new Promise((resolve, reject) => {
8154
8160
  var fulfilled = (value) => {
8155
8161
  try {
@@ -8172,7 +8178,7 @@ var __async$n = (__this, __arguments, generator) => {
8172
8178
  const useCalculateRates = () => {
8173
8179
  const { client } = useShipEngine();
8174
8180
  return reactQuery.useMutation({
8175
- mutationFn: (_0) => __async$n(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8181
+ mutationFn: (_0) => __async$o(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8176
8182
  const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
8177
8183
  return result.data;
8178
8184
  }),
@@ -8181,7 +8187,7 @@ const useCalculateRates = () => {
8181
8187
  });
8182
8188
  };
8183
8189
 
8184
- var __async$m = (__this, __arguments, generator) => {
8190
+ var __async$n = (__this, __arguments, generator) => {
8185
8191
  return new Promise((resolve, reject) => {
8186
8192
  var fulfilled = (value) => {
8187
8193
  try {
@@ -8204,7 +8210,7 @@ var __async$m = (__this, __arguments, generator) => {
8204
8210
  const useConnectCarrier = () => {
8205
8211
  const { client } = useShipEngine();
8206
8212
  return reactQuery.useMutation({
8207
- mutationFn: (params) => __async$m(void 0, null, function* () {
8213
+ mutationFn: (params) => __async$n(void 0, null, function* () {
8208
8214
  const result = yield client.carriers.connect(params);
8209
8215
  return result.data;
8210
8216
  }),
@@ -8213,7 +8219,7 @@ const useConnectCarrier = () => {
8213
8219
  });
8214
8220
  };
8215
8221
 
8216
- var __async$l = (__this, __arguments, generator) => {
8222
+ var __async$m = (__this, __arguments, generator) => {
8217
8223
  return new Promise((resolve, reject) => {
8218
8224
  var fulfilled = (value) => {
8219
8225
  try {
@@ -8236,7 +8242,7 @@ var __async$l = (__this, __arguments, generator) => {
8236
8242
  const useCreateFundingSource = () => {
8237
8243
  const { client } = useShipEngine();
8238
8244
  return reactQuery.useMutation({
8239
- mutationFn: (fundingSource) => __async$l(void 0, null, function* () {
8245
+ mutationFn: (fundingSource) => __async$m(void 0, null, function* () {
8240
8246
  const result = yield client.fundingSources.create(fundingSource);
8241
8247
  return result.data;
8242
8248
  }),
@@ -8245,22 +8251,22 @@ const useCreateFundingSource = () => {
8245
8251
  });
8246
8252
  };
8247
8253
 
8248
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8249
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8250
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8254
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
8255
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
8256
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
8251
8257
  var __objRest$6 = (source, exclude) => {
8252
8258
  var target = {};
8253
8259
  for (var prop in source)
8254
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
8260
+ if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
8255
8261
  target[prop] = source[prop];
8256
- if (source != null && __getOwnPropSymbols$7)
8257
- for (var prop of __getOwnPropSymbols$7(source)) {
8258
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
8262
+ if (source != null && __getOwnPropSymbols$9)
8263
+ for (var prop of __getOwnPropSymbols$9(source)) {
8264
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
8259
8265
  target[prop] = source[prop];
8260
8266
  }
8261
8267
  return target;
8262
8268
  };
8263
- var __async$k = (__this, __arguments, generator) => {
8269
+ var __async$l = (__this, __arguments, generator) => {
8264
8270
  return new Promise((resolve, reject) => {
8265
8271
  var fulfilled = (value) => {
8266
8272
  try {
@@ -8283,7 +8289,7 @@ var __async$k = (__this, __arguments, generator) => {
8283
8289
  const useCreateLabel = () => {
8284
8290
  const { client } = useShipEngine();
8285
8291
  return reactQuery.useMutation({
8286
- mutationFn: (_a) => __async$k(void 0, null, function* () {
8292
+ mutationFn: (_a) => __async$l(void 0, null, function* () {
8287
8293
  var _b = _a, { rateId } = _b, options = __objRest$6(_b, ["rateId"]);
8288
8294
  const result = yield client.labels.createByRateId(rateId, options);
8289
8295
  return result.data;
@@ -8293,7 +8299,7 @@ const useCreateLabel = () => {
8293
8299
  });
8294
8300
  };
8295
8301
 
8296
- var __async$j = (__this, __arguments, generator) => {
8302
+ var __async$k = (__this, __arguments, generator) => {
8297
8303
  return new Promise((resolve, reject) => {
8298
8304
  var fulfilled = (value) => {
8299
8305
  try {
@@ -8316,7 +8322,7 @@ var __async$j = (__this, __arguments, generator) => {
8316
8322
  const useCreateRateCard = () => {
8317
8323
  const { client } = useShipEngine();
8318
8324
  return reactQuery.useMutation({
8319
- mutationFn: (rateCard) => __async$j(void 0, null, function* () {
8325
+ mutationFn: (rateCard) => __async$k(void 0, null, function* () {
8320
8326
  const result = yield client.rateCards.create(rateCard);
8321
8327
  return result.data;
8322
8328
  }),
@@ -8325,22 +8331,22 @@ const useCreateRateCard = () => {
8325
8331
  });
8326
8332
  };
8327
8333
 
8328
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8329
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8330
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8334
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
8335
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
8336
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
8331
8337
  var __objRest$5 = (source, exclude) => {
8332
8338
  var target = {};
8333
8339
  for (var prop in source)
8334
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8340
+ if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
8335
8341
  target[prop] = source[prop];
8336
- if (source != null && __getOwnPropSymbols$6)
8337
- for (var prop of __getOwnPropSymbols$6(source)) {
8338
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
8342
+ if (source != null && __getOwnPropSymbols$8)
8343
+ for (var prop of __getOwnPropSymbols$8(source)) {
8344
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
8339
8345
  target[prop] = source[prop];
8340
8346
  }
8341
8347
  return target;
8342
8348
  };
8343
- var __async$i = (__this, __arguments, generator) => {
8349
+ var __async$j = (__this, __arguments, generator) => {
8344
8350
  return new Promise((resolve, reject) => {
8345
8351
  var fulfilled = (value) => {
8346
8352
  try {
@@ -8363,7 +8369,7 @@ var __async$i = (__this, __arguments, generator) => {
8363
8369
  const useCreateSalesOrderShipment = () => {
8364
8370
  const { client } = useShipEngine();
8365
8371
  return reactQuery.useMutation({
8366
- mutationFn: (_a) => __async$i(void 0, null, function* () {
8372
+ mutationFn: (_a) => __async$j(void 0, null, function* () {
8367
8373
  var _b = _a, { salesOrderId } = _b, shipment = __objRest$5(_b, ["salesOrderId"]);
8368
8374
  const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
8369
8375
  return result.data;
@@ -8373,26 +8379,26 @@ const useCreateSalesOrderShipment = () => {
8373
8379
  });
8374
8380
  };
8375
8381
 
8376
- var __defProp$1 = Object.defineProperty;
8377
- var __defProps = Object.defineProperties;
8378
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8379
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8380
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8381
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8382
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8383
- var __spreadValues$1 = (a, b) => {
8382
+ var __defProp$3 = Object.defineProperty;
8383
+ var __defProps$2 = Object.defineProperties;
8384
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
8385
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8386
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8387
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8388
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8389
+ var __spreadValues$3 = (a, b) => {
8384
8390
  for (var prop in b || (b = {}))
8385
- if (__hasOwnProp$5.call(b, prop))
8386
- __defNormalProp$1(a, prop, b[prop]);
8387
- if (__getOwnPropSymbols$5)
8388
- for (var prop of __getOwnPropSymbols$5(b)) {
8389
- if (__propIsEnum$5.call(b, prop))
8390
- __defNormalProp$1(a, prop, b[prop]);
8391
+ if (__hasOwnProp$7.call(b, prop))
8392
+ __defNormalProp$3(a, prop, b[prop]);
8393
+ if (__getOwnPropSymbols$7)
8394
+ for (var prop of __getOwnPropSymbols$7(b)) {
8395
+ if (__propIsEnum$7.call(b, prop))
8396
+ __defNormalProp$3(a, prop, b[prop]);
8391
8397
  }
8392
8398
  return a;
8393
8399
  };
8394
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8395
- var __async$h = (__this, __arguments, generator) => {
8400
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
8401
+ var __async$i = (__this, __arguments, generator) => {
8396
8402
  return new Promise((resolve, reject) => {
8397
8403
  var fulfilled = (value) => {
8398
8404
  try {
@@ -8415,7 +8421,7 @@ var __async$h = (__this, __arguments, generator) => {
8415
8421
  const useCreateShipment = () => {
8416
8422
  const { client } = useShipEngine();
8417
8423
  return reactQuery.useMutation({
8418
- mutationFn: (shipment) => __async$h(void 0, null, function* () {
8424
+ mutationFn: (shipment) => __async$i(void 0, null, function* () {
8419
8425
  var _a;
8420
8426
  if (shipment.warehouseId === void 0) {
8421
8427
  throw new CodedError("errorMessages.noWarehouses", {
@@ -8433,7 +8439,7 @@ const useCreateShipment = () => {
8433
8439
  postalCode: "",
8434
8440
  stateProvince: ""
8435
8441
  };
8436
- return (yield client.shipments.create(__spreadProps(__spreadValues$1({}, shipment), {
8442
+ return (yield client.shipments.create(__spreadProps$2(__spreadValues$3({}, shipment), {
8437
8443
  shipTo
8438
8444
  }))).data;
8439
8445
  }),
@@ -8442,7 +8448,7 @@ const useCreateShipment = () => {
8442
8448
  });
8443
8449
  };
8444
8450
 
8445
- var __async$g = (__this, __arguments, generator) => {
8451
+ var __async$h = (__this, __arguments, generator) => {
8446
8452
  return new Promise((resolve, reject) => {
8447
8453
  var fulfilled = (value) => {
8448
8454
  try {
@@ -8465,7 +8471,7 @@ var __async$g = (__this, __arguments, generator) => {
8465
8471
  const useCreateWarehouse = () => {
8466
8472
  const { client } = useShipEngine();
8467
8473
  return reactQuery.useMutation({
8468
- mutationFn: (data) => __async$g(void 0, null, function* () {
8474
+ mutationFn: (data) => __async$h(void 0, null, function* () {
8469
8475
  const result = yield client.warehouses.create(data);
8470
8476
  return result.data;
8471
8477
  }),
@@ -8474,7 +8480,7 @@ const useCreateWarehouse = () => {
8474
8480
  });
8475
8481
  };
8476
8482
 
8477
- var __async$f = (__this, __arguments, generator) => {
8483
+ var __async$g = (__this, __arguments, generator) => {
8478
8484
  return new Promise((resolve, reject) => {
8479
8485
  var fulfilled = (value) => {
8480
8486
  try {
@@ -8497,7 +8503,7 @@ var __async$f = (__this, __arguments, generator) => {
8497
8503
  const useDeleteWarehouse = () => {
8498
8504
  const { client } = useShipEngine();
8499
8505
  return reactQuery.useMutation({
8500
- mutationFn: (_0) => __async$f(void 0, [_0], function* ({ warehouseId }) {
8506
+ mutationFn: (_0) => __async$g(void 0, [_0], function* ({ warehouseId }) {
8501
8507
  const result = yield client.warehouses.delete(warehouseId);
8502
8508
  return result.data;
8503
8509
  }),
@@ -8518,6 +8524,38 @@ const useDownloadRateCard = (rateCardId) => {
8518
8524
  });
8519
8525
  };
8520
8526
 
8527
+ var __async$f = (__this, __arguments, generator) => {
8528
+ return new Promise((resolve, reject) => {
8529
+ var fulfilled = (value) => {
8530
+ try {
8531
+ step(generator.next(value));
8532
+ } catch (e) {
8533
+ reject(e);
8534
+ }
8535
+ };
8536
+ var rejected = (value) => {
8537
+ try {
8538
+ step(generator.throw(value));
8539
+ } catch (e) {
8540
+ reject(e);
8541
+ }
8542
+ };
8543
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
8544
+ step((generator = generator.apply(__this, __arguments)).next());
8545
+ });
8546
+ };
8547
+ const useFundingSourcesAddFunds = (fundingSourceId) => {
8548
+ const { client } = useShipEngine();
8549
+ return reactQuery.useMutation({
8550
+ mutationFn: (funds) => __async$f(void 0, null, function* () {
8551
+ const result = yield client.fundingSources.addFunds(funds, fundingSourceId);
8552
+ return result.data;
8553
+ }),
8554
+ mutationKey: ["useFundingSourcesAddFunds"],
8555
+ onError
8556
+ });
8557
+ };
8558
+
8521
8559
  const useGetAccountSettings = () => {
8522
8560
  const { client } = useShipEngine();
8523
8561
  return reactQuery.useQuery({
@@ -8560,6 +8598,40 @@ const useGetCarrierById = (carrierId) => {
8560
8598
  });
8561
8599
  };
8562
8600
 
8601
+ const useGetCountriesByCarrier = (carrierId) => {
8602
+ const { client } = useShipEngine();
8603
+ return reactQuery.useQuery({
8604
+ enabled: !!carrierId,
8605
+ onError,
8606
+ queryFn: () => {
8607
+ if (carrierId)
8608
+ return client.carriers.getCountries(carrierId);
8609
+ return Promise.reject(new Error("carrierId is require"));
8610
+ },
8611
+ queryKey: ["useGetCountriesByCarrier", carrierId],
8612
+ select: (result) => result.data.countries,
8613
+ // Fresh for 5 minutes
8614
+ staleTime: 5 * 60 * 1e3
8615
+ });
8616
+ };
8617
+
8618
+ const useGetCurrenciesByCarrier = (carrierId) => {
8619
+ const { client } = useShipEngine();
8620
+ return reactQuery.useQuery({
8621
+ enabled: !!carrierId,
8622
+ onError,
8623
+ queryFn: () => {
8624
+ if (carrierId)
8625
+ return client.carriers.getCurrencies(carrierId);
8626
+ return Promise.reject(new Error("carrierId is require"));
8627
+ },
8628
+ queryKey: ["useGetCurrenciesByCarrier", carrierId],
8629
+ select: (result) => result.data.currencies,
8630
+ // Fresh for 5 minutes
8631
+ staleTime: 5 * 60 * 1e3
8632
+ });
8633
+ };
8634
+
8563
8635
  const useGetFundingSourceById = (fundingSourceId) => {
8564
8636
  const { client } = useShipEngine();
8565
8637
  return reactQuery.useQuery({
@@ -8600,6 +8672,19 @@ const useGetLabel = (labelId) => {
8600
8672
  });
8601
8673
  };
8602
8674
 
8675
+ const useGetRateCardById = (rateCardId) => {
8676
+ const { client } = useShipEngine();
8677
+ return reactQuery.useQuery({
8678
+ enabled: !!rateCardId,
8679
+ onError,
8680
+ queryFn: () => {
8681
+ return client.rateCards.get(rateCardId);
8682
+ },
8683
+ queryKey: ["useGetRateCardById", rateCardId],
8684
+ select: (result) => result.data
8685
+ });
8686
+ };
8687
+
8603
8688
  const useGetRatePackageFormatsByCarrier = (carrierId) => {
8604
8689
  const { client } = useShipEngine();
8605
8690
  return reactQuery.useQuery({
@@ -8617,32 +8702,32 @@ const useGetRatePackageFormatsByCarrier = (carrierId) => {
8617
8702
  });
8618
8703
  };
8619
8704
 
8620
- const useGetSalesOrder = (salesOrderId) => {
8705
+ const useGetSalesOrderShipment = (shipmentId) => {
8621
8706
  const { client } = useShipEngine();
8622
8707
  return reactQuery.useQuery({
8623
- enabled: salesOrderId !== void 0,
8708
+ enabled: shipmentId !== void 0,
8624
8709
  onError,
8625
8710
  queryFn: () => {
8626
- if (salesOrderId)
8627
- return client.salesOrders.get(salesOrderId);
8628
- return Promise.reject(new Error("salesOrderId is required"));
8711
+ if (shipmentId)
8712
+ return client.salesOrderShipments.get(shipmentId);
8713
+ return Promise.reject(new Error("shipmentId is required"));
8629
8714
  },
8630
- queryKey: ["useGetSalesOrder", salesOrderId],
8715
+ queryKey: ["useGetSalesOrderShipment", shipmentId],
8631
8716
  select: (result) => result.data
8632
8717
  });
8633
8718
  };
8634
8719
 
8635
- const useGetSalesOrderShipment = (shipmentId) => {
8720
+ const useGetSalesOrder = (salesOrderId) => {
8636
8721
  const { client } = useShipEngine();
8637
8722
  return reactQuery.useQuery({
8638
- enabled: shipmentId !== void 0,
8723
+ enabled: salesOrderId !== void 0,
8639
8724
  onError,
8640
8725
  queryFn: () => {
8641
- if (shipmentId)
8642
- return client.salesOrderShipments.get(shipmentId);
8643
- return Promise.reject(new Error("shipmentId is required"));
8726
+ if (salesOrderId)
8727
+ return client.salesOrders.get(salesOrderId);
8728
+ return Promise.reject(new Error("salesOrderId is required"));
8644
8729
  },
8645
- queryKey: ["useGetSalesOrderShipment", shipmentId],
8730
+ queryKey: ["useGetSalesOrder", salesOrderId],
8646
8731
  select: (result) => result.data
8647
8732
  });
8648
8733
  };
@@ -8664,31 +8749,34 @@ const useGetServicesByCarrier = (carrierId) => {
8664
8749
  });
8665
8750
  };
8666
8751
 
8667
- const useGetShipment = (shipmentId) => {
8752
+ const useGetShipmentRates = (shipmentId, createdAtStart) => {
8668
8753
  const { client } = useShipEngine();
8669
8754
  return reactQuery.useQuery({
8670
8755
  enabled: shipmentId !== void 0,
8671
8756
  onError,
8672
8757
  queryFn: () => {
8673
- if (!shipmentId) {
8674
- return Promise.reject(new Error("shipmentId is required"));
8758
+ if (shipmentId) {
8759
+ return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
8675
8760
  }
8676
- return client.salesOrderShipments.get(shipmentId);
8761
+ return Promise.reject(new Error("shipmentId is required"));
8677
8762
  },
8678
- queryKey: ["useGetShipment", shipmentId],
8763
+ queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
8679
8764
  select: (result) => result.data
8680
8765
  });
8681
8766
  };
8682
8767
 
8683
- const useGetRateCardById = (rateCardId) => {
8768
+ const useGetShipment = (shipmentId) => {
8684
8769
  const { client } = useShipEngine();
8685
8770
  return reactQuery.useQuery({
8686
- enabled: !!rateCardId,
8771
+ enabled: shipmentId !== void 0,
8687
8772
  onError,
8688
8773
  queryFn: () => {
8689
- return client.rateCards.get(rateCardId);
8774
+ if (!shipmentId) {
8775
+ return Promise.reject(new Error("shipmentId is required"));
8776
+ }
8777
+ return client.salesOrderShipments.get(shipmentId);
8690
8778
  },
8691
- queryKey: ["useGetRateCardById", rateCardId],
8779
+ queryKey: ["useGetShipment", shipmentId],
8692
8780
  select: (result) => result.data
8693
8781
  });
8694
8782
  };
@@ -8711,40 +8799,6 @@ const useGetWalletHistory = ({
8711
8799
  });
8712
8800
  };
8713
8801
 
8714
- const useGetCountriesByCarrier = (carrierId) => {
8715
- const { client } = useShipEngine();
8716
- return reactQuery.useQuery({
8717
- enabled: !!carrierId,
8718
- onError,
8719
- queryFn: () => {
8720
- if (carrierId)
8721
- return client.carriers.getCountries(carrierId);
8722
- return Promise.reject(new Error("carrierId is require"));
8723
- },
8724
- queryKey: ["useGetCountriesByCarrier", carrierId],
8725
- select: (result) => result.data.countries,
8726
- // Fresh for 5 minutes
8727
- staleTime: 5 * 60 * 1e3
8728
- });
8729
- };
8730
-
8731
- const useGetCurrenciesByCarrier = (carrierId) => {
8732
- const { client } = useShipEngine();
8733
- return reactQuery.useQuery({
8734
- enabled: !!carrierId,
8735
- onError,
8736
- queryFn: () => {
8737
- if (carrierId)
8738
- return client.carriers.getCurrencies(carrierId);
8739
- return Promise.reject(new Error("carrierId is require"));
8740
- },
8741
- queryKey: ["useGetCurrenciesByCarrier", carrierId],
8742
- select: (result) => result.data.currencies,
8743
- // Fresh for 5 minutes
8744
- staleTime: 5 * 60 * 1e3
8745
- });
8746
- };
8747
-
8748
8802
  const useListCarriers = () => {
8749
8803
  const { client } = useShipEngine();
8750
8804
  return reactQuery.useQuery({
@@ -8831,17 +8885,17 @@ const useListSalesOrders = (params = {}) => {
8831
8885
  });
8832
8886
  };
8833
8887
 
8834
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8835
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8836
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
8888
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8889
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8890
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8837
8891
  var __objRest$4 = (source, exclude) => {
8838
8892
  var target = {};
8839
8893
  for (var prop in source)
8840
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
8894
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8841
8895
  target[prop] = source[prop];
8842
- if (source != null && __getOwnPropSymbols$4)
8843
- for (var prop of __getOwnPropSymbols$4(source)) {
8844
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
8896
+ if (source != null && __getOwnPropSymbols$6)
8897
+ for (var prop of __getOwnPropSymbols$6(source)) {
8898
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
8845
8899
  target[prop] = source[prop];
8846
8900
  }
8847
8901
  return target;
@@ -8870,17 +8924,17 @@ const useListWarehouses = (options) => {
8870
8924
  });
8871
8925
  };
8872
8926
 
8873
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
8874
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
8875
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
8927
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8928
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8929
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8876
8930
  var __objRest$3 = (source, exclude) => {
8877
8931
  var target = {};
8878
8932
  for (var prop in source)
8879
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
8933
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8880
8934
  target[prop] = source[prop];
8881
- if (source != null && __getOwnPropSymbols$3)
8882
- for (var prop of __getOwnPropSymbols$3(source)) {
8883
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
8935
+ if (source != null && __getOwnPropSymbols$5)
8936
+ for (var prop of __getOwnPropSymbols$5(source)) {
8937
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
8884
8938
  target[prop] = source[prop];
8885
8939
  }
8886
8940
  return target;
@@ -9032,22 +9086,6 @@ const useRegisterCarrier = () => {
9032
9086
  });
9033
9087
  };
9034
9088
 
9035
- const useGetShipmentRates = (shipmentId, createdAtStart) => {
9036
- const { client } = useShipEngine();
9037
- return reactQuery.useQuery({
9038
- enabled: shipmentId !== void 0,
9039
- onError,
9040
- queryFn: () => {
9041
- if (shipmentId) {
9042
- return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
9043
- }
9044
- return Promise.reject(new Error("shipmentId is required"));
9045
- },
9046
- queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
9047
- select: (result) => result.data
9048
- });
9049
- };
9050
-
9051
9089
  var __async$a = (__this, __arguments, generator) => {
9052
9090
  return new Promise((resolve, reject) => {
9053
9091
  var fulfilled = (value) => {
@@ -9188,17 +9226,17 @@ const useUpdateRateCard = () => {
9188
9226
  });
9189
9227
  };
9190
9228
 
9191
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
9192
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
9193
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
9229
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
9230
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
9231
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
9194
9232
  var __objRest$2 = (source, exclude) => {
9195
9233
  var target = {};
9196
9234
  for (var prop in source)
9197
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
9235
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
9198
9236
  target[prop] = source[prop];
9199
- if (source != null && __getOwnPropSymbols$2)
9200
- for (var prop of __getOwnPropSymbols$2(source)) {
9201
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
9237
+ if (source != null && __getOwnPropSymbols$4)
9238
+ for (var prop of __getOwnPropSymbols$4(source)) {
9239
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
9202
9240
  target[prop] = source[prop];
9203
9241
  }
9204
9242
  return target;
@@ -9236,17 +9274,17 @@ const useUpdateSalesOrderShipment = () => {
9236
9274
  });
9237
9275
  };
9238
9276
 
9239
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
9240
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
9241
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
9277
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
9278
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
9279
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
9242
9280
  var __objRest$1 = (source, exclude) => {
9243
9281
  var target = {};
9244
9282
  for (var prop in source)
9245
- if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
9283
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
9246
9284
  target[prop] = source[prop];
9247
- if (source != null && __getOwnPropSymbols$1)
9248
- for (var prop of __getOwnPropSymbols$1(source)) {
9249
- if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
9285
+ if (source != null && __getOwnPropSymbols$3)
9286
+ for (var prop of __getOwnPropSymbols$3(source)) {
9287
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
9250
9288
  target[prop] = source[prop];
9251
9289
  }
9252
9290
  return target;
@@ -9430,81 +9468,83 @@ const useLoadIcons = ({ brandName, cdnURL = "/" }) => {
9430
9468
  }
9431
9469
  }))();
9432
9470
  }, [brandName, cdnURL]);
9433
- return (iconName) => __async$1(void 0, null, function* () {
9434
- if (iconIndex) {
9435
- const iconBrand = (iconIndex[iconName.toLowerCase()] || []).includes(brandName) ? brandName : brands.BrandName.FALLBACK;
9436
- const result = yield axios.get(`/brand/${iconBrand}/icons/${iconName.toLowerCase()}.svg`, {
9437
- baseURL: cdnURL,
9438
- responseType: "text"
9439
- });
9440
- return result.data;
9441
- }
9442
- return void 0;
9443
- });
9444
- };
9445
-
9446
- var __async = (__this, __arguments, generator) => {
9447
- return new Promise((resolve, reject) => {
9448
- var fulfilled = (value) => {
9449
- try {
9450
- step(generator.next(value));
9451
- } catch (e) {
9452
- reject(e);
9453
- }
9454
- };
9455
- var rejected = (value) => {
9456
- try {
9457
- step(generator.throw(value));
9458
- } catch (e) {
9459
- reject(e);
9471
+ return React.useCallback(
9472
+ (iconName) => __async$1(void 0, null, function* () {
9473
+ if (iconIndex) {
9474
+ const iconBrand = (iconIndex[iconName.toLowerCase()] || []).includes(brandName) ? brandName : brands.BrandName.FALLBACK;
9475
+ const result = yield axios.get(
9476
+ `/brand/${iconBrand}/icons/${iconName.toLowerCase()}.svg`,
9477
+ {
9478
+ baseURL: cdnURL,
9479
+ responseType: "text"
9480
+ }
9481
+ );
9482
+ return result.data;
9460
9483
  }
9461
- };
9462
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
9463
- step((generator = generator.apply(__this, __arguments)).next());
9464
- });
9484
+ return "";
9485
+ }),
9486
+ [brandName, cdnURL, iconIndex]
9487
+ );
9465
9488
  };
9489
+
9466
9490
  const useLoadTheme = ({ cdnURL = "/", brandName }) => {
9467
9491
  const [theme, setTheme] = React.useState();
9468
9492
  React.useEffect(() => {
9469
- (() => __async(void 0, null, function* () {
9470
- try {
9471
- const result = yield axios.get(`/brand/${brandName}/theme.json`, { baseURL: cdnURL });
9472
- const theme2 = new gigerTheme.Theme(result.data);
9473
- setTheme(theme2);
9474
- } catch (error) {
9475
- logger.error({ error }, `Error loading theme for brand ${brandName}`);
9476
- }
9477
- }))();
9493
+ axios.get(`/brand/${brandName}/theme.json`, { baseURL: cdnURL }).then(({ data }) => setTheme(new gigerTheme.Theme(data))).catch((error) => logger.error({ error }, `Error loading theme for brand ${brandName}`));
9478
9494
  }, [brandName, cdnURL]);
9479
9495
  return theme;
9480
9496
  };
9481
9497
 
9498
+ var __defProp$2 = Object.defineProperty;
9499
+ var __defProps$1 = Object.defineProperties;
9500
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
9501
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
9502
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
9503
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
9504
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9505
+ var __spreadValues$2 = (a, b) => {
9506
+ for (var prop in b || (b = {}))
9507
+ if (__hasOwnProp$2.call(b, prop))
9508
+ __defNormalProp$2(a, prop, b[prop]);
9509
+ if (__getOwnPropSymbols$2)
9510
+ for (var prop of __getOwnPropSymbols$2(b)) {
9511
+ if (__propIsEnum$2.call(b, prop))
9512
+ __defNormalProp$2(a, prop, b[prop]);
9513
+ }
9514
+ return a;
9515
+ };
9516
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
9482
9517
  const AlchemyContext = React.createContext(void 0);
9483
- const Alchemy = ({
9518
+ const renderAlchemyProviders = ({
9519
+ baseURL,
9520
+ children,
9521
+ getToken,
9522
+ theme,
9523
+ scope,
9524
+ fontStyles,
9525
+ iconCache,
9526
+ resolveIcon
9527
+ }) => /* @__PURE__ */ jsxs(react.ThemeProvider, { theme, children: [
9528
+ /* @__PURE__ */ jsx(react.Global, { styles: [giger.getEmotionResetStyles(scope), fontStyles] }),
9529
+ /* @__PURE__ */ jsx(giger.GigerConfigProvider, { iconCache, resolveIcon, children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children }) })
9530
+ ] });
9531
+ const AlchemyProvider = ({
9484
9532
  baseURL = "https://api.shipengine.com",
9485
9533
  brandName = brands.BrandName.FALLBACK,
9486
9534
  cdnURL = "/",
9487
9535
  children,
9488
9536
  getToken,
9489
- onError,
9537
+ onError = _default,
9490
9538
  scope = "lmnt"
9491
9539
  }) => {
9492
9540
  const theme = useLoadTheme({ brandName, cdnURL });
9493
9541
  const fontStyles = useLoadFonts({ cdnURL, scope, theme });
9494
9542
  const resolveIcon = useLoadIcons({ brandName, cdnURL });
9543
+ const iconCache = React.useMemo(giger.createIconCache, []);
9495
9544
  if (!theme)
9496
9545
  return null;
9497
- onError = onError != null ? onError : _default;
9498
- return /* @__PURE__ */ jsx(
9499
- AlchemyContext.Provider,
9500
- {
9501
- value: { baseURL, brandName, cdnURL, getToken, onError, scope, theme },
9502
- children: /* @__PURE__ */ jsxs(react.ThemeProvider, { theme, children: [
9503
- /* @__PURE__ */ jsx(react.Global, { styles: [giger.getEmotionResetStyles(scope), fontStyles] }),
9504
- /* @__PURE__ */ jsx(giger.GigerConfigProvider, { resolveIcon, children: /* @__PURE__ */ jsx(ShipEngine, { baseURL, getToken, children }) })
9505
- ] })
9506
- }
9507
- );
9546
+ const contextValue = { baseURL, brandName, cdnURL, getToken, onError, scope, theme };
9547
+ return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: renderAlchemyProviders(__spreadProps$1(__spreadValues$2({}, contextValue), { children, fontStyles, iconCache, resolveIcon })) });
9508
9548
  };
9509
9549
  const useAlchemy = () => {
9510
9550
  const context = React.useContext(AlchemyContext);
@@ -9514,6 +9554,69 @@ const useAlchemy = () => {
9514
9554
  return context;
9515
9555
  };
9516
9556
 
9557
+ var __defProp$1 = Object.defineProperty;
9558
+ var __defProps = Object.defineProperties;
9559
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9560
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
9561
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
9562
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
9563
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9564
+ var __spreadValues$1 = (a, b) => {
9565
+ for (var prop in b || (b = {}))
9566
+ if (__hasOwnProp$1.call(b, prop))
9567
+ __defNormalProp$1(a, prop, b[prop]);
9568
+ if (__getOwnPropSymbols$1)
9569
+ for (var prop of __getOwnPropSymbols$1(b)) {
9570
+ if (__propIsEnum$1.call(b, prop))
9571
+ __defNormalProp$1(a, prop, b[prop]);
9572
+ }
9573
+ return a;
9574
+ };
9575
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
9576
+ var __async = (__this, __arguments, generator) => {
9577
+ return new Promise((resolve, reject) => {
9578
+ var fulfilled = (value) => {
9579
+ try {
9580
+ step(generator.next(value));
9581
+ } catch (e) {
9582
+ reject(e);
9583
+ }
9584
+ };
9585
+ var rejected = (value) => {
9586
+ try {
9587
+ step(generator.throw(value));
9588
+ } catch (e) {
9589
+ reject(e);
9590
+ }
9591
+ };
9592
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
9593
+ step((generator = generator.apply(__this, __arguments)).next());
9594
+ });
9595
+ };
9596
+ const AlchemyTestProvider = ({ baseURL, children }) => {
9597
+ const scope = "lmnt";
9598
+ const theme = React.useMemo(() => new gigerTheme.Theme(), []);
9599
+ const fontStyles = react.css({ [`.${scope}`]: { fontFamily: theme.defaultFontFamily } });
9600
+ const getToken = React.useCallback(() => "none", []);
9601
+ const iconCache = React.useMemo(giger.createIconCache, []);
9602
+ const resolveIcon = React.useCallback(
9603
+ (iconName) => __async(void 0, null, function* () {
9604
+ return `<svg data-svg-id="${iconName}">mock icon-${iconName}</svg>`;
9605
+ }),
9606
+ []
9607
+ );
9608
+ const contextValue = {
9609
+ baseURL,
9610
+ brandName: brands.BrandName.FALLBACK,
9611
+ cdnURL: "mockCdnUrl",
9612
+ getToken,
9613
+ onError: _default,
9614
+ scope,
9615
+ theme
9616
+ };
9617
+ return /* @__PURE__ */ jsx(AlchemyContext.Provider, { value: contextValue, children: renderAlchemyProviders(__spreadProps(__spreadValues$1({}, contextValue), { children, fontStyles, iconCache, resolveIcon })) });
9618
+ };
9619
+
9517
9620
  var classnamesExports = {};
9518
9621
  var classnames = {
9519
9622
  get exports(){ return classnamesExports; },
@@ -10116,8 +10219,9 @@ const alchemy = {
10116
10219
 
10117
10220
  exports.AccountSettingsAPI = AccountSettingsAPI;
10118
10221
  exports.AddressesAPI = AddressesAPI;
10119
- exports.Alchemy = Alchemy;
10120
10222
  exports.AlchemyContext = AlchemyContext;
10223
+ exports.AlchemyProvider = AlchemyProvider;
10224
+ exports.AlchemyTestProvider = AlchemyTestProvider;
10121
10225
  exports.CarriersAPI = CarriersAPI;
10122
10226
  exports.CodedError = CodedError;
10123
10227
  exports.ConfirmationType = ConfirmationType;
@@ -10152,6 +10256,7 @@ exports.isCodedErrors = isCodedErrors;
10152
10256
  exports.logger = logger;
10153
10257
  exports.memoizedCreateCache = memoizedCreateCache;
10154
10258
  exports.onError = onError;
10259
+ exports.renderAlchemyProviders = renderAlchemyProviders;
10155
10260
  exports.retryUntil = retryUntil;
10156
10261
  exports.useAddFunds = useAddFunds;
10157
10262
  exports.useAlchemy = useAlchemy;
@@ -10165,6 +10270,7 @@ exports.useCreateShipment = useCreateShipment;
10165
10270
  exports.useCreateWarehouse = useCreateWarehouse;
10166
10271
  exports.useDeleteWarehouse = useDeleteWarehouse;
10167
10272
  exports.useDownloadRateCard = useDownloadRateCard;
10273
+ exports.useFundingSourcesAddFunds = useFundingSourcesAddFunds;
10168
10274
  exports.useGetAccountSettings = useGetAccountSettings;
10169
10275
  exports.useGetAutoFundingConfiguration = useGetAutoFundingConfiguration;
10170
10276
  exports.useGetCarrierById = useGetCarrierById;