@shipengine/alchemy 0.4.23 → 0.4.24

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.
Files changed (3) hide show
  1. package/index.js +182 -112
  2. package/index.mjs +182 -113
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -2476,17 +2476,17 @@ Object.defineProperty(dist, "__esModule", { value: true });
2476
2476
  var _default = dist.default = (function () {
2477
2477
  });
2478
2478
 
2479
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
2480
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
2481
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
2479
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
2480
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
2481
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
2482
2482
  var __objRest$7 = (source, exclude) => {
2483
2483
  var target = {};
2484
2484
  for (var prop in source)
2485
- if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
2485
+ if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
2486
2486
  target[prop] = source[prop];
2487
- if (source != null && __getOwnPropSymbols$a)
2488
- for (var prop of __getOwnPropSymbols$a(source)) {
2489
- if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
2487
+ if (source != null && __getOwnPropSymbols$b)
2488
+ for (var prop of __getOwnPropSymbols$b(source)) {
2489
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
2490
2490
  target[prop] = source[prop];
2491
2491
  }
2492
2492
  return target;
@@ -5230,7 +5230,7 @@ var ipaddr = {
5230
5230
  }).call(commonjsGlobal);
5231
5231
  } (ipaddr));
5232
5232
 
5233
- var __async$q = (__this, __arguments, generator) => {
5233
+ var __async$r = (__this, __arguments, generator) => {
5234
5234
  return new Promise((resolve, reject) => {
5235
5235
  var fulfilled = (value) => {
5236
5236
  try {
@@ -5250,7 +5250,7 @@ var __async$q = (__this, __arguments, generator) => {
5250
5250
  step((generator = generator.apply(__this, __arguments)).next());
5251
5251
  });
5252
5252
  };
5253
- const getEndUserIpAddress = () => __async$q(void 0, null, function* () {
5253
+ const getEndUserIpAddress = () => __async$r(void 0, null, function* () {
5254
5254
  try {
5255
5255
  const response = yield axios.get("https://api.ipify.org/?format=json");
5256
5256
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -5262,38 +5262,38 @@ const getEndUserIpAddress = () => __async$q(void 0, null, function* () {
5262
5262
  }
5263
5263
  });
5264
5264
 
5265
- var __defProp$4 = Object.defineProperty;
5266
- var __defProps$2 = Object.defineProperties;
5267
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
5268
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
5269
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
5270
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
5271
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5272
- var __spreadValues$4 = (a, b) => {
5265
+ var __defProp$5 = Object.defineProperty;
5266
+ var __defProps$3 = Object.defineProperties;
5267
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
5268
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
5269
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
5270
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
5271
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5272
+ var __spreadValues$5 = (a, b) => {
5273
5273
  for (var prop in b || (b = {}))
5274
- if (__hasOwnProp$9.call(b, prop))
5275
- __defNormalProp$4(a, prop, b[prop]);
5276
- if (__getOwnPropSymbols$9)
5277
- for (var prop of __getOwnPropSymbols$9(b)) {
5278
- if (__propIsEnum$9.call(b, prop))
5279
- __defNormalProp$4(a, prop, b[prop]);
5274
+ if (__hasOwnProp$a.call(b, prop))
5275
+ __defNormalProp$5(a, prop, b[prop]);
5276
+ if (__getOwnPropSymbols$a)
5277
+ for (var prop of __getOwnPropSymbols$a(b)) {
5278
+ if (__propIsEnum$a.call(b, prop))
5279
+ __defNormalProp$5(a, prop, b[prop]);
5280
5280
  }
5281
5281
  return a;
5282
5282
  };
5283
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
5283
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
5284
5284
  var __objRest$6 = (source, exclude) => {
5285
5285
  var target = {};
5286
5286
  for (var prop in source)
5287
- if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
5287
+ if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
5288
5288
  target[prop] = source[prop];
5289
- if (source != null && __getOwnPropSymbols$9)
5290
- for (var prop of __getOwnPropSymbols$9(source)) {
5291
- if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
5289
+ if (source != null && __getOwnPropSymbols$a)
5290
+ for (var prop of __getOwnPropSymbols$a(source)) {
5291
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
5292
5292
  target[prop] = source[prop];
5293
5293
  }
5294
5294
  return target;
5295
5295
  };
5296
- var __async$p = (__this, __arguments, generator) => {
5296
+ var __async$q = (__this, __arguments, generator) => {
5297
5297
  return new Promise((resolve, reject) => {
5298
5298
  var fulfilled = (value) => {
5299
5299
  try {
@@ -5322,12 +5322,12 @@ class CarriersAPI {
5322
5322
  this.get = (carrierId) => {
5323
5323
  return this.client.get(`/v1/carriers/${carrierId}`);
5324
5324
  };
5325
- this.connect = (_a) => __async$p(this, null, function* () {
5325
+ this.connect = (_a) => __async$q(this, null, function* () {
5326
5326
  var _b = _a, { carrierCode } = _b, connection = __objRest$6(_b, ["carrierCode"]);
5327
5327
  const endUserIpAddress = yield getEndUserIpAddress();
5328
5328
  if (!endUserIpAddress)
5329
5329
  return Promise.reject([new CodedError("Unable to get IP address")]);
5330
- return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$2(__spreadValues$4({}, connection), {
5330
+ return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$3(__spreadValues$5({}, connection), {
5331
5331
  endUserIpAddress
5332
5332
  }));
5333
5333
  });
@@ -7545,23 +7545,23 @@ class CustomPackagesAPI {
7545
7545
  }
7546
7546
  }
7547
7547
 
7548
- var __defProp$3 = Object.defineProperty;
7549
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
7550
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
7551
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
7552
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7553
- var __spreadValues$3 = (a, b) => {
7548
+ var __defProp$4 = Object.defineProperty;
7549
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
7550
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
7551
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
7552
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7553
+ var __spreadValues$4 = (a, b) => {
7554
7554
  for (var prop in b || (b = {}))
7555
- if (__hasOwnProp$8.call(b, prop))
7556
- __defNormalProp$3(a, prop, b[prop]);
7557
- if (__getOwnPropSymbols$8)
7558
- for (var prop of __getOwnPropSymbols$8(b)) {
7559
- if (__propIsEnum$8.call(b, prop))
7560
- __defNormalProp$3(a, prop, b[prop]);
7555
+ if (__hasOwnProp$9.call(b, prop))
7556
+ __defNormalProp$4(a, prop, b[prop]);
7557
+ if (__getOwnPropSymbols$9)
7558
+ for (var prop of __getOwnPropSymbols$9(b)) {
7559
+ if (__propIsEnum$9.call(b, prop))
7560
+ __defNormalProp$4(a, prop, b[prop]);
7561
7561
  }
7562
7562
  return a;
7563
7563
  };
7564
- var __async$o = (__this, __arguments, generator) => {
7564
+ var __async$p = (__this, __arguments, generator) => {
7565
7565
  return new Promise((resolve, reject) => {
7566
7566
  var fulfilled = (value) => {
7567
7567
  try {
@@ -7590,15 +7590,15 @@ class FundingSourcesAPI {
7590
7590
  this.get = (fundingSourceId) => {
7591
7591
  return this.client.get(`/v1/funding_sources/${fundingSourceId}`);
7592
7592
  };
7593
- this.create = (fundingSource) => __async$o(this, null, function* () {
7593
+ this.create = (fundingSource) => __async$p(this, null, function* () {
7594
7594
  const endUserIpAddress = yield getEndUserIpAddress();
7595
7595
  if (!endUserIpAddress)
7596
7596
  return Promise.reject([new CodedError("Unable to get IP address")]);
7597
- return yield this.client.post("/v1/funding_sources", __spreadValues$3({
7597
+ return yield this.client.post("/v1/funding_sources", __spreadValues$4({
7598
7598
  endUserIpAddress
7599
7599
  }, fundingSource));
7600
7600
  });
7601
- this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$o(this, null, function* () {
7601
+ this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$p(this, null, function* () {
7602
7602
  const endUserIpAddress = yield getEndUserIpAddress();
7603
7603
  if (!endUserIpAddress)
7604
7604
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7607,11 +7607,11 @@ class FundingSourcesAPI {
7607
7607
  { billingInfo, endUserIpAddress, paymentMethod: { creditCardInfo } }
7608
7608
  );
7609
7609
  });
7610
- this.registerCarrier = (carrier) => __async$o(this, null, function* () {
7610
+ this.registerCarrier = (carrier) => __async$p(this, null, function* () {
7611
7611
  const endUserIpAddress = yield getEndUserIpAddress();
7612
7612
  if (!endUserIpAddress)
7613
7613
  return Promise.reject([new CodedError("Unable to get IP address")]);
7614
- return yield this.client.post("/v1/registration/funding_source", __spreadValues$3({
7614
+ return yield this.client.post("/v1/registration/funding_source", __spreadValues$4({
7615
7615
  endUserIpAddress
7616
7616
  }, carrier));
7617
7617
  });
@@ -7715,7 +7715,7 @@ class SalesOrdersAPI {
7715
7715
  }
7716
7716
  }
7717
7717
 
7718
- var __async$n = (__this, __arguments, generator) => {
7718
+ var __async$o = (__this, __arguments, generator) => {
7719
7719
  return new Promise((resolve, reject) => {
7720
7720
  var fulfilled = (value) => {
7721
7721
  try {
@@ -7744,7 +7744,7 @@ class ShipmentsAPI {
7744
7744
  createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
7745
7745
  );
7746
7746
  };
7747
- this.create = (...shipments) => __async$n(this, null, function* () {
7747
+ this.create = (...shipments) => __async$o(this, null, function* () {
7748
7748
  return this.client.post("/v1/shipments", {
7749
7749
  shipments
7750
7750
  });
@@ -7772,26 +7772,26 @@ class WarehousesAPI {
7772
7772
  }
7773
7773
  }
7774
7774
 
7775
- var __defProp$2 = Object.defineProperty;
7776
- var __defProps$1 = Object.defineProperties;
7777
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7778
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
7779
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
7780
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
7781
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7782
- var __spreadValues$2 = (a, b) => {
7775
+ var __defProp$3 = Object.defineProperty;
7776
+ var __defProps$2 = Object.defineProperties;
7777
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
7778
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
7779
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
7780
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
7781
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7782
+ var __spreadValues$3 = (a, b) => {
7783
7783
  for (var prop in b || (b = {}))
7784
- if (__hasOwnProp$7.call(b, prop))
7785
- __defNormalProp$2(a, prop, b[prop]);
7786
- if (__getOwnPropSymbols$7)
7787
- for (var prop of __getOwnPropSymbols$7(b)) {
7788
- if (__propIsEnum$7.call(b, prop))
7789
- __defNormalProp$2(a, prop, b[prop]);
7784
+ if (__hasOwnProp$8.call(b, prop))
7785
+ __defNormalProp$3(a, prop, b[prop]);
7786
+ if (__getOwnPropSymbols$8)
7787
+ for (var prop of __getOwnPropSymbols$8(b)) {
7788
+ if (__propIsEnum$8.call(b, prop))
7789
+ __defNormalProp$3(a, prop, b[prop]);
7790
7790
  }
7791
7791
  return a;
7792
7792
  };
7793
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7794
- var __async$m = (__this, __arguments, generator) => {
7793
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
7794
+ var __async$n = (__this, __arguments, generator) => {
7795
7795
  return new Promise((resolve, reject) => {
7796
7796
  var fulfilled = (value) => {
7797
7797
  try {
@@ -7813,7 +7813,7 @@ var __async$m = (__this, __arguments, generator) => {
7813
7813
  };
7814
7814
  const logger$1 = E({
7815
7815
  name: "shipengine-api",
7816
- serializers: __spreadProps$1(__spreadValues$2({}, k), {
7816
+ serializers: __spreadProps$2(__spreadValues$3({}, k), {
7817
7817
  req: (req) => ({
7818
7818
  headers: req.headers,
7819
7819
  method: req.method,
@@ -7838,7 +7838,7 @@ class ShipEngineAPI {
7838
7838
  constructor(token, { baseURL, headers, getToken }) {
7839
7839
  const client = axios.create({
7840
7840
  baseURL,
7841
- headers: __spreadProps$1(__spreadValues$2({}, headers), {
7841
+ headers: __spreadProps$2(__spreadValues$3({}, headers), {
7842
7842
  Authorization: `Bearer ${token}`,
7843
7843
  "Content-Type": "application/json"
7844
7844
  }),
@@ -7867,7 +7867,7 @@ class ShipEngineAPI {
7867
7867
  );
7868
7868
  return res;
7869
7869
  },
7870
- (err) => __async$m(this, null, function* () {
7870
+ (err) => __async$n(this, null, function* () {
7871
7871
  var _a, _b, _c, _d, _e, _f, _g;
7872
7872
  logger$1.error(
7873
7873
  { err, req: err.config, res: err.response },
@@ -8004,25 +8004,25 @@ const delay = (ms) => new Promise((resolve) => {
8004
8004
 
8005
8005
  const onError = (errors) => errors.forEach(console.log);
8006
8006
 
8007
- var __defProp$1 = Object.defineProperty;
8008
- var __defProps = Object.defineProperties;
8009
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8010
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8011
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8012
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8013
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8014
- var __spreadValues$1 = (a, b) => {
8007
+ var __defProp$2 = Object.defineProperty;
8008
+ var __defProps$1 = Object.defineProperties;
8009
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
8010
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8011
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8012
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8013
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8014
+ var __spreadValues$2 = (a, b) => {
8015
8015
  for (var prop in b || (b = {}))
8016
- if (__hasOwnProp$6.call(b, prop))
8017
- __defNormalProp$1(a, prop, b[prop]);
8018
- if (__getOwnPropSymbols$6)
8019
- for (var prop of __getOwnPropSymbols$6(b)) {
8020
- if (__propIsEnum$6.call(b, prop))
8021
- __defNormalProp$1(a, prop, b[prop]);
8016
+ if (__hasOwnProp$7.call(b, prop))
8017
+ __defNormalProp$2(a, prop, b[prop]);
8018
+ if (__getOwnPropSymbols$7)
8019
+ for (var prop of __getOwnPropSymbols$7(b)) {
8020
+ if (__propIsEnum$7.call(b, prop))
8021
+ __defNormalProp$2(a, prop, b[prop]);
8022
8022
  }
8023
8023
  return a;
8024
8024
  };
8025
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8025
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
8026
8026
  const streams = [];
8027
8027
  if (process.env.NODE_ENV === "production") {
8028
8028
  streams.push({
@@ -8031,7 +8031,7 @@ if (process.env.NODE_ENV === "production") {
8031
8031
  }
8032
8032
  const logger = E({
8033
8033
  name: "shipengine",
8034
- serializers: __spreadProps(__spreadValues$1({}, k), {
8034
+ serializers: __spreadProps$1(__spreadValues$2({}, k), {
8035
8035
  req: (req) => ({
8036
8036
  headers: req.headers,
8037
8037
  method: req.method,
@@ -8056,7 +8056,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
8056
8056
  throw error;
8057
8057
  });
8058
8058
 
8059
- var __async$l = (__this, __arguments, generator) => {
8059
+ var __async$m = (__this, __arguments, generator) => {
8060
8060
  return new Promise((resolve, reject) => {
8061
8061
  var fulfilled = (value) => {
8062
8062
  try {
@@ -8079,7 +8079,7 @@ var __async$l = (__this, __arguments, generator) => {
8079
8079
  const useAddFunds = (carrierId) => {
8080
8080
  const { client } = useShipEngine();
8081
8081
  return reactQuery.useMutation({
8082
- mutationFn: (funds) => __async$l(void 0, null, function* () {
8082
+ mutationFn: (funds) => __async$m(void 0, null, function* () {
8083
8083
  const result = yield client.carriers.addFunds(carrierId, funds);
8084
8084
  return result.data;
8085
8085
  }),
@@ -8088,7 +8088,7 @@ const useAddFunds = (carrierId) => {
8088
8088
  });
8089
8089
  };
8090
8090
 
8091
- var __async$k = (__this, __arguments, generator) => {
8091
+ var __async$l = (__this, __arguments, generator) => {
8092
8092
  return new Promise((resolve, reject) => {
8093
8093
  var fulfilled = (value) => {
8094
8094
  try {
@@ -8111,7 +8111,7 @@ var __async$k = (__this, __arguments, generator) => {
8111
8111
  const useCalculateRates = () => {
8112
8112
  const { client } = useShipEngine();
8113
8113
  return reactQuery.useMutation({
8114
- mutationFn: (_0) => __async$k(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8114
+ mutationFn: (_0) => __async$l(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8115
8115
  const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
8116
8116
  return result.data;
8117
8117
  }),
@@ -8120,7 +8120,7 @@ const useCalculateRates = () => {
8120
8120
  });
8121
8121
  };
8122
8122
 
8123
- var __async$j = (__this, __arguments, generator) => {
8123
+ var __async$k = (__this, __arguments, generator) => {
8124
8124
  return new Promise((resolve, reject) => {
8125
8125
  var fulfilled = (value) => {
8126
8126
  try {
@@ -8143,7 +8143,7 @@ var __async$j = (__this, __arguments, generator) => {
8143
8143
  const useConnectCarrier = () => {
8144
8144
  const { client } = useShipEngine();
8145
8145
  return reactQuery.useMutation({
8146
- mutationFn: (params) => __async$j(void 0, null, function* () {
8146
+ mutationFn: (params) => __async$k(void 0, null, function* () {
8147
8147
  const result = yield client.carriers.connect(params);
8148
8148
  return result.data;
8149
8149
  }),
@@ -8152,7 +8152,7 @@ const useConnectCarrier = () => {
8152
8152
  });
8153
8153
  };
8154
8154
 
8155
- var __async$i = (__this, __arguments, generator) => {
8155
+ var __async$j = (__this, __arguments, generator) => {
8156
8156
  return new Promise((resolve, reject) => {
8157
8157
  var fulfilled = (value) => {
8158
8158
  try {
@@ -8175,7 +8175,7 @@ var __async$i = (__this, __arguments, generator) => {
8175
8175
  const useCreateFundingSource = () => {
8176
8176
  const { client } = useShipEngine();
8177
8177
  return reactQuery.useMutation({
8178
- mutationFn: (fundingSource) => __async$i(void 0, null, function* () {
8178
+ mutationFn: (fundingSource) => __async$j(void 0, null, function* () {
8179
8179
  const result = yield client.fundingSources.create(fundingSource);
8180
8180
  return result.data;
8181
8181
  }),
@@ -8184,22 +8184,22 @@ const useCreateFundingSource = () => {
8184
8184
  });
8185
8185
  };
8186
8186
 
8187
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8188
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8189
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8187
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8188
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8189
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8190
8190
  var __objRest$5 = (source, exclude) => {
8191
8191
  var target = {};
8192
8192
  for (var prop in source)
8193
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8193
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8194
8194
  target[prop] = source[prop];
8195
- if (source != null && __getOwnPropSymbols$5)
8196
- for (var prop of __getOwnPropSymbols$5(source)) {
8197
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
8195
+ if (source != null && __getOwnPropSymbols$6)
8196
+ for (var prop of __getOwnPropSymbols$6(source)) {
8197
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
8198
8198
  target[prop] = source[prop];
8199
8199
  }
8200
8200
  return target;
8201
8201
  };
8202
- var __async$h = (__this, __arguments, generator) => {
8202
+ var __async$i = (__this, __arguments, generator) => {
8203
8203
  return new Promise((resolve, reject) => {
8204
8204
  var fulfilled = (value) => {
8205
8205
  try {
@@ -8222,7 +8222,7 @@ var __async$h = (__this, __arguments, generator) => {
8222
8222
  const useCreateLabel = () => {
8223
8223
  const { client } = useShipEngine();
8224
8224
  return reactQuery.useMutation({
8225
- mutationFn: (_a) => __async$h(void 0, null, function* () {
8225
+ mutationFn: (_a) => __async$i(void 0, null, function* () {
8226
8226
  var _b = _a, { rateId } = _b, options = __objRest$5(_b, ["rateId"]);
8227
8227
  const result = yield client.labels.createByRateId(rateId, options);
8228
8228
  return result.data;
@@ -8232,22 +8232,22 @@ const useCreateLabel = () => {
8232
8232
  });
8233
8233
  };
8234
8234
 
8235
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8236
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8237
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
8235
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8236
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8237
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8238
8238
  var __objRest$4 = (source, exclude) => {
8239
8239
  var target = {};
8240
8240
  for (var prop in source)
8241
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
8241
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8242
8242
  target[prop] = source[prop];
8243
- if (source != null && __getOwnPropSymbols$4)
8244
- for (var prop of __getOwnPropSymbols$4(source)) {
8245
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
8243
+ if (source != null && __getOwnPropSymbols$5)
8244
+ for (var prop of __getOwnPropSymbols$5(source)) {
8245
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
8246
8246
  target[prop] = source[prop];
8247
8247
  }
8248
8248
  return target;
8249
8249
  };
8250
- var __async$g = (__this, __arguments, generator) => {
8250
+ var __async$h = (__this, __arguments, generator) => {
8251
8251
  return new Promise((resolve, reject) => {
8252
8252
  var fulfilled = (value) => {
8253
8253
  try {
@@ -8270,7 +8270,7 @@ var __async$g = (__this, __arguments, generator) => {
8270
8270
  const useCreateSalesOrderShipment = () => {
8271
8271
  const { client } = useShipEngine();
8272
8272
  return reactQuery.useMutation({
8273
- mutationFn: (_a) => __async$g(void 0, null, function* () {
8273
+ mutationFn: (_a) => __async$h(void 0, null, function* () {
8274
8274
  var _b = _a, { salesOrderId } = _b, shipment = __objRest$4(_b, ["salesOrderId"]);
8275
8275
  const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
8276
8276
  return result.data;
@@ -8280,6 +8280,75 @@ const useCreateSalesOrderShipment = () => {
8280
8280
  });
8281
8281
  };
8282
8282
 
8283
+ var __defProp$1 = Object.defineProperty;
8284
+ var __defProps = Object.defineProperties;
8285
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8286
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8287
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8288
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
8289
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8290
+ var __spreadValues$1 = (a, b) => {
8291
+ for (var prop in b || (b = {}))
8292
+ if (__hasOwnProp$4.call(b, prop))
8293
+ __defNormalProp$1(a, prop, b[prop]);
8294
+ if (__getOwnPropSymbols$4)
8295
+ for (var prop of __getOwnPropSymbols$4(b)) {
8296
+ if (__propIsEnum$4.call(b, prop))
8297
+ __defNormalProp$1(a, prop, b[prop]);
8298
+ }
8299
+ return a;
8300
+ };
8301
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8302
+ var __async$g = (__this, __arguments, generator) => {
8303
+ return new Promise((resolve, reject) => {
8304
+ var fulfilled = (value) => {
8305
+ try {
8306
+ step(generator.next(value));
8307
+ } catch (e) {
8308
+ reject(e);
8309
+ }
8310
+ };
8311
+ var rejected = (value) => {
8312
+ try {
8313
+ step(generator.throw(value));
8314
+ } catch (e) {
8315
+ reject(e);
8316
+ }
8317
+ };
8318
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
8319
+ step((generator = generator.apply(__this, __arguments)).next());
8320
+ });
8321
+ };
8322
+ const useCreateShipment = () => {
8323
+ const { client } = useShipEngine();
8324
+ return reactQuery.useMutation({
8325
+ mutationFn: (shipment) => __async$g(void 0, null, function* () {
8326
+ var _a;
8327
+ if (shipment.warehouseId === void 0) {
8328
+ throw new CodedError("errorMessages.noWarehouses", {
8329
+ errorCode: "unknown",
8330
+ errorSource: "client",
8331
+ errorType: "business_rules"
8332
+ });
8333
+ }
8334
+ const shipTo = (_a = shipment.shipTo) != null ? _a : {
8335
+ addressLine1: "",
8336
+ cityLocality: "",
8337
+ countryCode: "",
8338
+ name: "",
8339
+ phone: "",
8340
+ postalCode: "",
8341
+ stateProvince: ""
8342
+ };
8343
+ return (yield client.shipments.create(__spreadProps(__spreadValues$1({}, shipment), {
8344
+ shipTo
8345
+ }))).data;
8346
+ }),
8347
+ mutationKey: ["useCreateShipment"],
8348
+ onError
8349
+ });
8350
+ };
8351
+
8283
8352
  var __async$f = (__this, __arguments, generator) => {
8284
8353
  return new Promise((resolve, reject) => {
8285
8354
  var fulfilled = (value) => {
@@ -9831,6 +9900,7 @@ exports.useConnectCarrier = useConnectCarrier;
9831
9900
  exports.useCreateFundingSource = useCreateFundingSource;
9832
9901
  exports.useCreateLabel = useCreateLabel;
9833
9902
  exports.useCreateSalesOrderShipment = useCreateSalesOrderShipment;
9903
+ exports.useCreateShipment = useCreateShipment;
9834
9904
  exports.useCreateWarehouse = useCreateWarehouse;
9835
9905
  exports.useDeleteWarehouse = useDeleteWarehouse;
9836
9906
  exports.useGetAccountSettings = useGetAccountSettings;
package/index.mjs CHANGED
@@ -2454,17 +2454,17 @@ Object.defineProperty(dist, "__esModule", { value: true });
2454
2454
  var _default = dist.default = (function () {
2455
2455
  });
2456
2456
 
2457
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
2458
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
2459
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
2457
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
2458
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
2459
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
2460
2460
  var __objRest$7 = (source, exclude) => {
2461
2461
  var target = {};
2462
2462
  for (var prop in source)
2463
- if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
2463
+ if (__hasOwnProp$b.call(source, prop) && exclude.indexOf(prop) < 0)
2464
2464
  target[prop] = source[prop];
2465
- if (source != null && __getOwnPropSymbols$a)
2466
- for (var prop of __getOwnPropSymbols$a(source)) {
2467
- if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
2465
+ if (source != null && __getOwnPropSymbols$b)
2466
+ for (var prop of __getOwnPropSymbols$b(source)) {
2467
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$b.call(source, prop))
2468
2468
  target[prop] = source[prop];
2469
2469
  }
2470
2470
  return target;
@@ -5208,7 +5208,7 @@ var ipaddr = {
5208
5208
  }).call(commonjsGlobal);
5209
5209
  } (ipaddr));
5210
5210
 
5211
- var __async$q = (__this, __arguments, generator) => {
5211
+ var __async$r = (__this, __arguments, generator) => {
5212
5212
  return new Promise((resolve, reject) => {
5213
5213
  var fulfilled = (value) => {
5214
5214
  try {
@@ -5228,7 +5228,7 @@ var __async$q = (__this, __arguments, generator) => {
5228
5228
  step((generator = generator.apply(__this, __arguments)).next());
5229
5229
  });
5230
5230
  };
5231
- const getEndUserIpAddress = () => __async$q(void 0, null, function* () {
5231
+ const getEndUserIpAddress = () => __async$r(void 0, null, function* () {
5232
5232
  try {
5233
5233
  const response = yield axios.get("https://api.ipify.org/?format=json");
5234
5234
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -5240,38 +5240,38 @@ const getEndUserIpAddress = () => __async$q(void 0, null, function* () {
5240
5240
  }
5241
5241
  });
5242
5242
 
5243
- var __defProp$4 = Object.defineProperty;
5244
- var __defProps$2 = Object.defineProperties;
5245
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
5246
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
5247
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
5248
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
5249
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5250
- var __spreadValues$4 = (a, b) => {
5243
+ var __defProp$5 = Object.defineProperty;
5244
+ var __defProps$3 = Object.defineProperties;
5245
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
5246
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
5247
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
5248
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
5249
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5250
+ var __spreadValues$5 = (a, b) => {
5251
5251
  for (var prop in b || (b = {}))
5252
- if (__hasOwnProp$9.call(b, prop))
5253
- __defNormalProp$4(a, prop, b[prop]);
5254
- if (__getOwnPropSymbols$9)
5255
- for (var prop of __getOwnPropSymbols$9(b)) {
5256
- if (__propIsEnum$9.call(b, prop))
5257
- __defNormalProp$4(a, prop, b[prop]);
5252
+ if (__hasOwnProp$a.call(b, prop))
5253
+ __defNormalProp$5(a, prop, b[prop]);
5254
+ if (__getOwnPropSymbols$a)
5255
+ for (var prop of __getOwnPropSymbols$a(b)) {
5256
+ if (__propIsEnum$a.call(b, prop))
5257
+ __defNormalProp$5(a, prop, b[prop]);
5258
5258
  }
5259
5259
  return a;
5260
5260
  };
5261
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
5261
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
5262
5262
  var __objRest$6 = (source, exclude) => {
5263
5263
  var target = {};
5264
5264
  for (var prop in source)
5265
- if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
5265
+ if (__hasOwnProp$a.call(source, prop) && exclude.indexOf(prop) < 0)
5266
5266
  target[prop] = source[prop];
5267
- if (source != null && __getOwnPropSymbols$9)
5268
- for (var prop of __getOwnPropSymbols$9(source)) {
5269
- if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
5267
+ if (source != null && __getOwnPropSymbols$a)
5268
+ for (var prop of __getOwnPropSymbols$a(source)) {
5269
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$a.call(source, prop))
5270
5270
  target[prop] = source[prop];
5271
5271
  }
5272
5272
  return target;
5273
5273
  };
5274
- var __async$p = (__this, __arguments, generator) => {
5274
+ var __async$q = (__this, __arguments, generator) => {
5275
5275
  return new Promise((resolve, reject) => {
5276
5276
  var fulfilled = (value) => {
5277
5277
  try {
@@ -5300,12 +5300,12 @@ class CarriersAPI {
5300
5300
  this.get = (carrierId) => {
5301
5301
  return this.client.get(`/v1/carriers/${carrierId}`);
5302
5302
  };
5303
- this.connect = (_a) => __async$p(this, null, function* () {
5303
+ this.connect = (_a) => __async$q(this, null, function* () {
5304
5304
  var _b = _a, { carrierCode } = _b, connection = __objRest$6(_b, ["carrierCode"]);
5305
5305
  const endUserIpAddress = yield getEndUserIpAddress();
5306
5306
  if (!endUserIpAddress)
5307
5307
  return Promise.reject([new CodedError("Unable to get IP address")]);
5308
- return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$2(__spreadValues$4({}, connection), {
5308
+ return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$3(__spreadValues$5({}, connection), {
5309
5309
  endUserIpAddress
5310
5310
  }));
5311
5311
  });
@@ -7523,23 +7523,23 @@ class CustomPackagesAPI {
7523
7523
  }
7524
7524
  }
7525
7525
 
7526
- var __defProp$3 = Object.defineProperty;
7527
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
7528
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
7529
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
7530
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7531
- var __spreadValues$3 = (a, b) => {
7526
+ var __defProp$4 = Object.defineProperty;
7527
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
7528
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
7529
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
7530
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7531
+ var __spreadValues$4 = (a, b) => {
7532
7532
  for (var prop in b || (b = {}))
7533
- if (__hasOwnProp$8.call(b, prop))
7534
- __defNormalProp$3(a, prop, b[prop]);
7535
- if (__getOwnPropSymbols$8)
7536
- for (var prop of __getOwnPropSymbols$8(b)) {
7537
- if (__propIsEnum$8.call(b, prop))
7538
- __defNormalProp$3(a, prop, b[prop]);
7533
+ if (__hasOwnProp$9.call(b, prop))
7534
+ __defNormalProp$4(a, prop, b[prop]);
7535
+ if (__getOwnPropSymbols$9)
7536
+ for (var prop of __getOwnPropSymbols$9(b)) {
7537
+ if (__propIsEnum$9.call(b, prop))
7538
+ __defNormalProp$4(a, prop, b[prop]);
7539
7539
  }
7540
7540
  return a;
7541
7541
  };
7542
- var __async$o = (__this, __arguments, generator) => {
7542
+ var __async$p = (__this, __arguments, generator) => {
7543
7543
  return new Promise((resolve, reject) => {
7544
7544
  var fulfilled = (value) => {
7545
7545
  try {
@@ -7568,15 +7568,15 @@ class FundingSourcesAPI {
7568
7568
  this.get = (fundingSourceId) => {
7569
7569
  return this.client.get(`/v1/funding_sources/${fundingSourceId}`);
7570
7570
  };
7571
- this.create = (fundingSource) => __async$o(this, null, function* () {
7571
+ this.create = (fundingSource) => __async$p(this, null, function* () {
7572
7572
  const endUserIpAddress = yield getEndUserIpAddress();
7573
7573
  if (!endUserIpAddress)
7574
7574
  return Promise.reject([new CodedError("Unable to get IP address")]);
7575
- return yield this.client.post("/v1/funding_sources", __spreadValues$3({
7575
+ return yield this.client.post("/v1/funding_sources", __spreadValues$4({
7576
7576
  endUserIpAddress
7577
7577
  }, fundingSource));
7578
7578
  });
7579
- this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$o(this, null, function* () {
7579
+ this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$p(this, null, function* () {
7580
7580
  const endUserIpAddress = yield getEndUserIpAddress();
7581
7581
  if (!endUserIpAddress)
7582
7582
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7585,11 +7585,11 @@ class FundingSourcesAPI {
7585
7585
  { billingInfo, endUserIpAddress, paymentMethod: { creditCardInfo } }
7586
7586
  );
7587
7587
  });
7588
- this.registerCarrier = (carrier) => __async$o(this, null, function* () {
7588
+ this.registerCarrier = (carrier) => __async$p(this, null, function* () {
7589
7589
  const endUserIpAddress = yield getEndUserIpAddress();
7590
7590
  if (!endUserIpAddress)
7591
7591
  return Promise.reject([new CodedError("Unable to get IP address")]);
7592
- return yield this.client.post("/v1/registration/funding_source", __spreadValues$3({
7592
+ return yield this.client.post("/v1/registration/funding_source", __spreadValues$4({
7593
7593
  endUserIpAddress
7594
7594
  }, carrier));
7595
7595
  });
@@ -7693,7 +7693,7 @@ class SalesOrdersAPI {
7693
7693
  }
7694
7694
  }
7695
7695
 
7696
- var __async$n = (__this, __arguments, generator) => {
7696
+ var __async$o = (__this, __arguments, generator) => {
7697
7697
  return new Promise((resolve, reject) => {
7698
7698
  var fulfilled = (value) => {
7699
7699
  try {
@@ -7722,7 +7722,7 @@ class ShipmentsAPI {
7722
7722
  createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
7723
7723
  );
7724
7724
  };
7725
- this.create = (...shipments) => __async$n(this, null, function* () {
7725
+ this.create = (...shipments) => __async$o(this, null, function* () {
7726
7726
  return this.client.post("/v1/shipments", {
7727
7727
  shipments
7728
7728
  });
@@ -7750,26 +7750,26 @@ class WarehousesAPI {
7750
7750
  }
7751
7751
  }
7752
7752
 
7753
- var __defProp$2 = Object.defineProperty;
7754
- var __defProps$1 = Object.defineProperties;
7755
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7756
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
7757
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
7758
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
7759
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7760
- var __spreadValues$2 = (a, b) => {
7753
+ var __defProp$3 = Object.defineProperty;
7754
+ var __defProps$2 = Object.defineProperties;
7755
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
7756
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
7757
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
7758
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
7759
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7760
+ var __spreadValues$3 = (a, b) => {
7761
7761
  for (var prop in b || (b = {}))
7762
- if (__hasOwnProp$7.call(b, prop))
7763
- __defNormalProp$2(a, prop, b[prop]);
7764
- if (__getOwnPropSymbols$7)
7765
- for (var prop of __getOwnPropSymbols$7(b)) {
7766
- if (__propIsEnum$7.call(b, prop))
7767
- __defNormalProp$2(a, prop, b[prop]);
7762
+ if (__hasOwnProp$8.call(b, prop))
7763
+ __defNormalProp$3(a, prop, b[prop]);
7764
+ if (__getOwnPropSymbols$8)
7765
+ for (var prop of __getOwnPropSymbols$8(b)) {
7766
+ if (__propIsEnum$8.call(b, prop))
7767
+ __defNormalProp$3(a, prop, b[prop]);
7768
7768
  }
7769
7769
  return a;
7770
7770
  };
7771
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7772
- var __async$m = (__this, __arguments, generator) => {
7771
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
7772
+ var __async$n = (__this, __arguments, generator) => {
7773
7773
  return new Promise((resolve, reject) => {
7774
7774
  var fulfilled = (value) => {
7775
7775
  try {
@@ -7791,7 +7791,7 @@ var __async$m = (__this, __arguments, generator) => {
7791
7791
  };
7792
7792
  const logger$1 = E({
7793
7793
  name: "shipengine-api",
7794
- serializers: __spreadProps$1(__spreadValues$2({}, k), {
7794
+ serializers: __spreadProps$2(__spreadValues$3({}, k), {
7795
7795
  req: (req) => ({
7796
7796
  headers: req.headers,
7797
7797
  method: req.method,
@@ -7816,7 +7816,7 @@ class ShipEngineAPI {
7816
7816
  constructor(token, { baseURL, headers, getToken }) {
7817
7817
  const client = axios.create({
7818
7818
  baseURL,
7819
- headers: __spreadProps$1(__spreadValues$2({}, headers), {
7819
+ headers: __spreadProps$2(__spreadValues$3({}, headers), {
7820
7820
  Authorization: `Bearer ${token}`,
7821
7821
  "Content-Type": "application/json"
7822
7822
  }),
@@ -7845,7 +7845,7 @@ class ShipEngineAPI {
7845
7845
  );
7846
7846
  return res;
7847
7847
  },
7848
- (err) => __async$m(this, null, function* () {
7848
+ (err) => __async$n(this, null, function* () {
7849
7849
  var _a, _b, _c, _d, _e, _f, _g;
7850
7850
  logger$1.error(
7851
7851
  { err, req: err.config, res: err.response },
@@ -7982,25 +7982,25 @@ const delay = (ms) => new Promise((resolve) => {
7982
7982
 
7983
7983
  const onError = (errors) => errors.forEach(console.log);
7984
7984
 
7985
- var __defProp$1 = Object.defineProperty;
7986
- var __defProps = Object.defineProperties;
7987
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7988
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
7989
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
7990
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
7991
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7992
- var __spreadValues$1 = (a, b) => {
7985
+ var __defProp$2 = Object.defineProperty;
7986
+ var __defProps$1 = Object.defineProperties;
7987
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7988
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
7989
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
7990
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
7991
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7992
+ var __spreadValues$2 = (a, b) => {
7993
7993
  for (var prop in b || (b = {}))
7994
- if (__hasOwnProp$6.call(b, prop))
7995
- __defNormalProp$1(a, prop, b[prop]);
7996
- if (__getOwnPropSymbols$6)
7997
- for (var prop of __getOwnPropSymbols$6(b)) {
7998
- if (__propIsEnum$6.call(b, prop))
7999
- __defNormalProp$1(a, prop, b[prop]);
7994
+ if (__hasOwnProp$7.call(b, prop))
7995
+ __defNormalProp$2(a, prop, b[prop]);
7996
+ if (__getOwnPropSymbols$7)
7997
+ for (var prop of __getOwnPropSymbols$7(b)) {
7998
+ if (__propIsEnum$7.call(b, prop))
7999
+ __defNormalProp$2(a, prop, b[prop]);
8000
8000
  }
8001
8001
  return a;
8002
8002
  };
8003
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8003
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
8004
8004
  const streams = [];
8005
8005
  if (process.env.NODE_ENV === "production") {
8006
8006
  streams.push({
@@ -8009,7 +8009,7 @@ if (process.env.NODE_ENV === "production") {
8009
8009
  }
8010
8010
  const logger = E({
8011
8011
  name: "shipengine",
8012
- serializers: __spreadProps(__spreadValues$1({}, k), {
8012
+ serializers: __spreadProps$1(__spreadValues$2({}, k), {
8013
8013
  req: (req) => ({
8014
8014
  headers: req.headers,
8015
8015
  method: req.method,
@@ -8034,7 +8034,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
8034
8034
  throw error;
8035
8035
  });
8036
8036
 
8037
- var __async$l = (__this, __arguments, generator) => {
8037
+ var __async$m = (__this, __arguments, generator) => {
8038
8038
  return new Promise((resolve, reject) => {
8039
8039
  var fulfilled = (value) => {
8040
8040
  try {
@@ -8057,7 +8057,7 @@ var __async$l = (__this, __arguments, generator) => {
8057
8057
  const useAddFunds = (carrierId) => {
8058
8058
  const { client } = useShipEngine();
8059
8059
  return useMutation({
8060
- mutationFn: (funds) => __async$l(void 0, null, function* () {
8060
+ mutationFn: (funds) => __async$m(void 0, null, function* () {
8061
8061
  const result = yield client.carriers.addFunds(carrierId, funds);
8062
8062
  return result.data;
8063
8063
  }),
@@ -8066,7 +8066,7 @@ const useAddFunds = (carrierId) => {
8066
8066
  });
8067
8067
  };
8068
8068
 
8069
- var __async$k = (__this, __arguments, generator) => {
8069
+ var __async$l = (__this, __arguments, generator) => {
8070
8070
  return new Promise((resolve, reject) => {
8071
8071
  var fulfilled = (value) => {
8072
8072
  try {
@@ -8089,7 +8089,7 @@ var __async$k = (__this, __arguments, generator) => {
8089
8089
  const useCalculateRates = () => {
8090
8090
  const { client } = useShipEngine();
8091
8091
  return useMutation({
8092
- mutationFn: (_0) => __async$k(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8092
+ mutationFn: (_0) => __async$l(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8093
8093
  const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
8094
8094
  return result.data;
8095
8095
  }),
@@ -8098,7 +8098,7 @@ const useCalculateRates = () => {
8098
8098
  });
8099
8099
  };
8100
8100
 
8101
- var __async$j = (__this, __arguments, generator) => {
8101
+ var __async$k = (__this, __arguments, generator) => {
8102
8102
  return new Promise((resolve, reject) => {
8103
8103
  var fulfilled = (value) => {
8104
8104
  try {
@@ -8121,7 +8121,7 @@ var __async$j = (__this, __arguments, generator) => {
8121
8121
  const useConnectCarrier = () => {
8122
8122
  const { client } = useShipEngine();
8123
8123
  return useMutation({
8124
- mutationFn: (params) => __async$j(void 0, null, function* () {
8124
+ mutationFn: (params) => __async$k(void 0, null, function* () {
8125
8125
  const result = yield client.carriers.connect(params);
8126
8126
  return result.data;
8127
8127
  }),
@@ -8130,7 +8130,7 @@ const useConnectCarrier = () => {
8130
8130
  });
8131
8131
  };
8132
8132
 
8133
- var __async$i = (__this, __arguments, generator) => {
8133
+ var __async$j = (__this, __arguments, generator) => {
8134
8134
  return new Promise((resolve, reject) => {
8135
8135
  var fulfilled = (value) => {
8136
8136
  try {
@@ -8153,7 +8153,7 @@ var __async$i = (__this, __arguments, generator) => {
8153
8153
  const useCreateFundingSource = () => {
8154
8154
  const { client } = useShipEngine();
8155
8155
  return useMutation({
8156
- mutationFn: (fundingSource) => __async$i(void 0, null, function* () {
8156
+ mutationFn: (fundingSource) => __async$j(void 0, null, function* () {
8157
8157
  const result = yield client.fundingSources.create(fundingSource);
8158
8158
  return result.data;
8159
8159
  }),
@@ -8162,22 +8162,22 @@ const useCreateFundingSource = () => {
8162
8162
  });
8163
8163
  };
8164
8164
 
8165
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8166
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8167
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8165
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8166
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8167
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8168
8168
  var __objRest$5 = (source, exclude) => {
8169
8169
  var target = {};
8170
8170
  for (var prop in source)
8171
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8171
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8172
8172
  target[prop] = source[prop];
8173
- if (source != null && __getOwnPropSymbols$5)
8174
- for (var prop of __getOwnPropSymbols$5(source)) {
8175
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
8173
+ if (source != null && __getOwnPropSymbols$6)
8174
+ for (var prop of __getOwnPropSymbols$6(source)) {
8175
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
8176
8176
  target[prop] = source[prop];
8177
8177
  }
8178
8178
  return target;
8179
8179
  };
8180
- var __async$h = (__this, __arguments, generator) => {
8180
+ var __async$i = (__this, __arguments, generator) => {
8181
8181
  return new Promise((resolve, reject) => {
8182
8182
  var fulfilled = (value) => {
8183
8183
  try {
@@ -8200,7 +8200,7 @@ var __async$h = (__this, __arguments, generator) => {
8200
8200
  const useCreateLabel = () => {
8201
8201
  const { client } = useShipEngine();
8202
8202
  return useMutation({
8203
- mutationFn: (_a) => __async$h(void 0, null, function* () {
8203
+ mutationFn: (_a) => __async$i(void 0, null, function* () {
8204
8204
  var _b = _a, { rateId } = _b, options = __objRest$5(_b, ["rateId"]);
8205
8205
  const result = yield client.labels.createByRateId(rateId, options);
8206
8206
  return result.data;
@@ -8210,22 +8210,22 @@ const useCreateLabel = () => {
8210
8210
  });
8211
8211
  };
8212
8212
 
8213
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8214
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8215
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
8213
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8214
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8215
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8216
8216
  var __objRest$4 = (source, exclude) => {
8217
8217
  var target = {};
8218
8218
  for (var prop in source)
8219
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
8219
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8220
8220
  target[prop] = source[prop];
8221
- if (source != null && __getOwnPropSymbols$4)
8222
- for (var prop of __getOwnPropSymbols$4(source)) {
8223
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
8221
+ if (source != null && __getOwnPropSymbols$5)
8222
+ for (var prop of __getOwnPropSymbols$5(source)) {
8223
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
8224
8224
  target[prop] = source[prop];
8225
8225
  }
8226
8226
  return target;
8227
8227
  };
8228
- var __async$g = (__this, __arguments, generator) => {
8228
+ var __async$h = (__this, __arguments, generator) => {
8229
8229
  return new Promise((resolve, reject) => {
8230
8230
  var fulfilled = (value) => {
8231
8231
  try {
@@ -8248,7 +8248,7 @@ var __async$g = (__this, __arguments, generator) => {
8248
8248
  const useCreateSalesOrderShipment = () => {
8249
8249
  const { client } = useShipEngine();
8250
8250
  return useMutation({
8251
- mutationFn: (_a) => __async$g(void 0, null, function* () {
8251
+ mutationFn: (_a) => __async$h(void 0, null, function* () {
8252
8252
  var _b = _a, { salesOrderId } = _b, shipment = __objRest$4(_b, ["salesOrderId"]);
8253
8253
  const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
8254
8254
  return result.data;
@@ -8258,6 +8258,75 @@ const useCreateSalesOrderShipment = () => {
8258
8258
  });
8259
8259
  };
8260
8260
 
8261
+ var __defProp$1 = Object.defineProperty;
8262
+ var __defProps = Object.defineProperties;
8263
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8264
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8265
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8266
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
8267
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8268
+ var __spreadValues$1 = (a, b) => {
8269
+ for (var prop in b || (b = {}))
8270
+ if (__hasOwnProp$4.call(b, prop))
8271
+ __defNormalProp$1(a, prop, b[prop]);
8272
+ if (__getOwnPropSymbols$4)
8273
+ for (var prop of __getOwnPropSymbols$4(b)) {
8274
+ if (__propIsEnum$4.call(b, prop))
8275
+ __defNormalProp$1(a, prop, b[prop]);
8276
+ }
8277
+ return a;
8278
+ };
8279
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8280
+ var __async$g = (__this, __arguments, generator) => {
8281
+ return new Promise((resolve, reject) => {
8282
+ var fulfilled = (value) => {
8283
+ try {
8284
+ step(generator.next(value));
8285
+ } catch (e) {
8286
+ reject(e);
8287
+ }
8288
+ };
8289
+ var rejected = (value) => {
8290
+ try {
8291
+ step(generator.throw(value));
8292
+ } catch (e) {
8293
+ reject(e);
8294
+ }
8295
+ };
8296
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
8297
+ step((generator = generator.apply(__this, __arguments)).next());
8298
+ });
8299
+ };
8300
+ const useCreateShipment = () => {
8301
+ const { client } = useShipEngine();
8302
+ return useMutation({
8303
+ mutationFn: (shipment) => __async$g(void 0, null, function* () {
8304
+ var _a;
8305
+ if (shipment.warehouseId === void 0) {
8306
+ throw new CodedError("errorMessages.noWarehouses", {
8307
+ errorCode: "unknown",
8308
+ errorSource: "client",
8309
+ errorType: "business_rules"
8310
+ });
8311
+ }
8312
+ const shipTo = (_a = shipment.shipTo) != null ? _a : {
8313
+ addressLine1: "",
8314
+ cityLocality: "",
8315
+ countryCode: "",
8316
+ name: "",
8317
+ phone: "",
8318
+ postalCode: "",
8319
+ stateProvince: ""
8320
+ };
8321
+ return (yield client.shipments.create(__spreadProps(__spreadValues$1({}, shipment), {
8322
+ shipTo
8323
+ }))).data;
8324
+ }),
8325
+ mutationKey: ["useCreateShipment"],
8326
+ onError
8327
+ });
8328
+ };
8329
+
8261
8330
  var __async$f = (__this, __arguments, generator) => {
8262
8331
  return new Promise((resolve, reject) => {
8263
8332
  var fulfilled = (value) => {
@@ -9765,4 +9834,4 @@ const alchemy = {
9765
9834
  createElement
9766
9835
  };
9767
9836
 
9768
- export { AccountSettingsAPI, AddressesAPI, Alchemy, AlchemyContext, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateSalesOrderShipment, useCreateWarehouse, useDeleteWarehouse, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetSalesOrder, useGetSalesOrderShipment, useGetShipment, useGetShipmentRates, useGetWalletHistory, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListSalesOrderShipments, useListSalesOrders, useListWarehouses, useLoadFonts, useLoadIcons, useLoadTheme, useNotifySalesOrderShipped, useParseAddress, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateSalesOrderShipment, useUpdateWarehouse, useValidateAddresses, useVoidLabel };
9837
+ export { AccountSettingsAPI, AddressesAPI, Alchemy, AlchemyContext, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteWarehouse, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetSalesOrder, useGetSalesOrderShipment, useGetShipment, useGetShipmentRates, useGetWalletHistory, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListSalesOrderShipments, useListSalesOrders, useListWarehouses, useLoadFonts, useLoadIcons, useLoadTheme, useNotifySalesOrderShipped, useParseAddress, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateSalesOrderShipment, useUpdateWarehouse, useValidateAddresses, useVoidLabel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/alchemy",
3
- "version": "0.4.23",
3
+ "version": "0.4.24",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {