@shipengine/alchemy 0.4.22 → 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 +152 -98
  2. package/index.mjs +152 -99
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -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)) {
@@ -5263,8 +5263,8 @@ const getEndUserIpAddress = () => __async$q(void 0, null, function* () {
5263
5263
  });
5264
5264
 
5265
5265
  var __defProp$5 = Object.defineProperty;
5266
- var __defProps$2 = Object.defineProperties;
5267
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
5266
+ var __defProps$3 = Object.defineProperties;
5267
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
5268
5268
  var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
5269
5269
  var __hasOwnProp$a = Object.prototype.hasOwnProperty;
5270
5270
  var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
@@ -5280,7 +5280,7 @@ var __spreadValues$5 = (a, b) => {
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)
@@ -5293,7 +5293,7 @@ var __objRest$6 = (source, exclude) => {
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$5({}, connection), {
5330
+ return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$3(__spreadValues$5({}, connection), {
5331
5331
  endUserIpAddress
5332
5332
  }));
5333
5333
  });
@@ -7561,7 +7561,7 @@ var __spreadValues$4 = (a, b) => {
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,7 +7590,7 @@ 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")]);
@@ -7598,7 +7598,7 @@ class FundingSourcesAPI {
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,7 +7607,7 @@ 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")]);
@@ -7715,23 +7715,7 @@ class SalesOrdersAPI {
7715
7715
  }
7716
7716
  }
7717
7717
 
7718
- var __defProp$3 = Object.defineProperty;
7719
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
7720
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
7721
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
7722
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7723
- var __spreadValues$3 = (a, b) => {
7724
- for (var prop in b || (b = {}))
7725
- if (__hasOwnProp$8.call(b, prop))
7726
- __defNormalProp$3(a, prop, b[prop]);
7727
- if (__getOwnPropSymbols$8)
7728
- for (var prop of __getOwnPropSymbols$8(b)) {
7729
- if (__propIsEnum$8.call(b, prop))
7730
- __defNormalProp$3(a, prop, b[prop]);
7731
- }
7732
- return a;
7733
- };
7734
- var __async$n = (__this, __arguments, generator) => {
7718
+ var __async$o = (__this, __arguments, generator) => {
7735
7719
  return new Promise((resolve, reject) => {
7736
7720
  var fulfilled = (value) => {
7737
7721
  try {
@@ -7760,11 +7744,9 @@ class ShipmentsAPI {
7760
7744
  createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
7761
7745
  );
7762
7746
  };
7763
- this.create = (shipment) => __async$n(this, null, function* () {
7747
+ this.create = (...shipments) => __async$o(this, null, function* () {
7764
7748
  return this.client.post("/v1/shipments", {
7765
- shipments: [
7766
- __spreadValues$3({}, shipment)
7767
- ]
7749
+ shipments
7768
7750
  });
7769
7751
  });
7770
7752
  this.client = client;
@@ -7790,26 +7772,26 @@ class WarehousesAPI {
7790
7772
  }
7791
7773
  }
7792
7774
 
7793
- var __defProp$2 = Object.defineProperty;
7794
- var __defProps$1 = Object.defineProperties;
7795
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7796
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
7797
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
7798
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
7799
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7800
- 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) => {
7801
7783
  for (var prop in b || (b = {}))
7802
- if (__hasOwnProp$7.call(b, prop))
7803
- __defNormalProp$2(a, prop, b[prop]);
7804
- if (__getOwnPropSymbols$7)
7805
- for (var prop of __getOwnPropSymbols$7(b)) {
7806
- if (__propIsEnum$7.call(b, prop))
7807
- __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]);
7808
7790
  }
7809
7791
  return a;
7810
7792
  };
7811
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7812
- 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) => {
7813
7795
  return new Promise((resolve, reject) => {
7814
7796
  var fulfilled = (value) => {
7815
7797
  try {
@@ -7831,7 +7813,7 @@ var __async$m = (__this, __arguments, generator) => {
7831
7813
  };
7832
7814
  const logger$1 = E({
7833
7815
  name: "shipengine-api",
7834
- serializers: __spreadProps$1(__spreadValues$2({}, k), {
7816
+ serializers: __spreadProps$2(__spreadValues$3({}, k), {
7835
7817
  req: (req) => ({
7836
7818
  headers: req.headers,
7837
7819
  method: req.method,
@@ -7856,7 +7838,7 @@ class ShipEngineAPI {
7856
7838
  constructor(token, { baseURL, headers, getToken }) {
7857
7839
  const client = axios.create({
7858
7840
  baseURL,
7859
- headers: __spreadProps$1(__spreadValues$2({}, headers), {
7841
+ headers: __spreadProps$2(__spreadValues$3({}, headers), {
7860
7842
  Authorization: `Bearer ${token}`,
7861
7843
  "Content-Type": "application/json"
7862
7844
  }),
@@ -7885,7 +7867,7 @@ class ShipEngineAPI {
7885
7867
  );
7886
7868
  return res;
7887
7869
  },
7888
- (err) => __async$m(this, null, function* () {
7870
+ (err) => __async$n(this, null, function* () {
7889
7871
  var _a, _b, _c, _d, _e, _f, _g;
7890
7872
  logger$1.error(
7891
7873
  { err, req: err.config, res: err.response },
@@ -8022,25 +8004,25 @@ const delay = (ms) => new Promise((resolve) => {
8022
8004
 
8023
8005
  const onError = (errors) => errors.forEach(console.log);
8024
8006
 
8025
- var __defProp$1 = Object.defineProperty;
8026
- var __defProps = Object.defineProperties;
8027
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8028
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8029
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8030
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8031
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8032
- 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) => {
8033
8015
  for (var prop in b || (b = {}))
8034
- if (__hasOwnProp$6.call(b, prop))
8035
- __defNormalProp$1(a, prop, b[prop]);
8036
- if (__getOwnPropSymbols$6)
8037
- for (var prop of __getOwnPropSymbols$6(b)) {
8038
- if (__propIsEnum$6.call(b, prop))
8039
- __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]);
8040
8022
  }
8041
8023
  return a;
8042
8024
  };
8043
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8025
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
8044
8026
  const streams = [];
8045
8027
  if (process.env.NODE_ENV === "production") {
8046
8028
  streams.push({
@@ -8049,7 +8031,7 @@ if (process.env.NODE_ENV === "production") {
8049
8031
  }
8050
8032
  const logger = E({
8051
8033
  name: "shipengine",
8052
- serializers: __spreadProps(__spreadValues$1({}, k), {
8034
+ serializers: __spreadProps$1(__spreadValues$2({}, k), {
8053
8035
  req: (req) => ({
8054
8036
  headers: req.headers,
8055
8037
  method: req.method,
@@ -8074,7 +8056,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
8074
8056
  throw error;
8075
8057
  });
8076
8058
 
8077
- var __async$l = (__this, __arguments, generator) => {
8059
+ var __async$m = (__this, __arguments, generator) => {
8078
8060
  return new Promise((resolve, reject) => {
8079
8061
  var fulfilled = (value) => {
8080
8062
  try {
@@ -8097,7 +8079,7 @@ var __async$l = (__this, __arguments, generator) => {
8097
8079
  const useAddFunds = (carrierId) => {
8098
8080
  const { client } = useShipEngine();
8099
8081
  return reactQuery.useMutation({
8100
- mutationFn: (funds) => __async$l(void 0, null, function* () {
8082
+ mutationFn: (funds) => __async$m(void 0, null, function* () {
8101
8083
  const result = yield client.carriers.addFunds(carrierId, funds);
8102
8084
  return result.data;
8103
8085
  }),
@@ -8106,7 +8088,7 @@ const useAddFunds = (carrierId) => {
8106
8088
  });
8107
8089
  };
8108
8090
 
8109
- var __async$k = (__this, __arguments, generator) => {
8091
+ var __async$l = (__this, __arguments, generator) => {
8110
8092
  return new Promise((resolve, reject) => {
8111
8093
  var fulfilled = (value) => {
8112
8094
  try {
@@ -8129,7 +8111,7 @@ var __async$k = (__this, __arguments, generator) => {
8129
8111
  const useCalculateRates = () => {
8130
8112
  const { client } = useShipEngine();
8131
8113
  return reactQuery.useMutation({
8132
- mutationFn: (_0) => __async$k(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8114
+ mutationFn: (_0) => __async$l(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8133
8115
  const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
8134
8116
  return result.data;
8135
8117
  }),
@@ -8138,7 +8120,7 @@ const useCalculateRates = () => {
8138
8120
  });
8139
8121
  };
8140
8122
 
8141
- var __async$j = (__this, __arguments, generator) => {
8123
+ var __async$k = (__this, __arguments, generator) => {
8142
8124
  return new Promise((resolve, reject) => {
8143
8125
  var fulfilled = (value) => {
8144
8126
  try {
@@ -8161,7 +8143,7 @@ var __async$j = (__this, __arguments, generator) => {
8161
8143
  const useConnectCarrier = () => {
8162
8144
  const { client } = useShipEngine();
8163
8145
  return reactQuery.useMutation({
8164
- mutationFn: (params) => __async$j(void 0, null, function* () {
8146
+ mutationFn: (params) => __async$k(void 0, null, function* () {
8165
8147
  const result = yield client.carriers.connect(params);
8166
8148
  return result.data;
8167
8149
  }),
@@ -8170,7 +8152,7 @@ const useConnectCarrier = () => {
8170
8152
  });
8171
8153
  };
8172
8154
 
8173
- var __async$i = (__this, __arguments, generator) => {
8155
+ var __async$j = (__this, __arguments, generator) => {
8174
8156
  return new Promise((resolve, reject) => {
8175
8157
  var fulfilled = (value) => {
8176
8158
  try {
@@ -8193,7 +8175,7 @@ var __async$i = (__this, __arguments, generator) => {
8193
8175
  const useCreateFundingSource = () => {
8194
8176
  const { client } = useShipEngine();
8195
8177
  return reactQuery.useMutation({
8196
- mutationFn: (fundingSource) => __async$i(void 0, null, function* () {
8178
+ mutationFn: (fundingSource) => __async$j(void 0, null, function* () {
8197
8179
  const result = yield client.fundingSources.create(fundingSource);
8198
8180
  return result.data;
8199
8181
  }),
@@ -8202,22 +8184,22 @@ const useCreateFundingSource = () => {
8202
8184
  });
8203
8185
  };
8204
8186
 
8205
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8206
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8207
- 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;
8208
8190
  var __objRest$5 = (source, exclude) => {
8209
8191
  var target = {};
8210
8192
  for (var prop in source)
8211
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8193
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8212
8194
  target[prop] = source[prop];
8213
- if (source != null && __getOwnPropSymbols$5)
8214
- for (var prop of __getOwnPropSymbols$5(source)) {
8215
- 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))
8216
8198
  target[prop] = source[prop];
8217
8199
  }
8218
8200
  return target;
8219
8201
  };
8220
- var __async$h = (__this, __arguments, generator) => {
8202
+ var __async$i = (__this, __arguments, generator) => {
8221
8203
  return new Promise((resolve, reject) => {
8222
8204
  var fulfilled = (value) => {
8223
8205
  try {
@@ -8240,7 +8222,7 @@ var __async$h = (__this, __arguments, generator) => {
8240
8222
  const useCreateLabel = () => {
8241
8223
  const { client } = useShipEngine();
8242
8224
  return reactQuery.useMutation({
8243
- mutationFn: (_a) => __async$h(void 0, null, function* () {
8225
+ mutationFn: (_a) => __async$i(void 0, null, function* () {
8244
8226
  var _b = _a, { rateId } = _b, options = __objRest$5(_b, ["rateId"]);
8245
8227
  const result = yield client.labels.createByRateId(rateId, options);
8246
8228
  return result.data;
@@ -8250,22 +8232,22 @@ const useCreateLabel = () => {
8250
8232
  });
8251
8233
  };
8252
8234
 
8253
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8254
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8255
- 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;
8256
8238
  var __objRest$4 = (source, exclude) => {
8257
8239
  var target = {};
8258
8240
  for (var prop in source)
8259
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
8241
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8260
8242
  target[prop] = source[prop];
8261
- if (source != null && __getOwnPropSymbols$4)
8262
- for (var prop of __getOwnPropSymbols$4(source)) {
8263
- 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))
8264
8246
  target[prop] = source[prop];
8265
8247
  }
8266
8248
  return target;
8267
8249
  };
8268
- var __async$g = (__this, __arguments, generator) => {
8250
+ var __async$h = (__this, __arguments, generator) => {
8269
8251
  return new Promise((resolve, reject) => {
8270
8252
  var fulfilled = (value) => {
8271
8253
  try {
@@ -8288,7 +8270,7 @@ var __async$g = (__this, __arguments, generator) => {
8288
8270
  const useCreateSalesOrderShipment = () => {
8289
8271
  const { client } = useShipEngine();
8290
8272
  return reactQuery.useMutation({
8291
- mutationFn: (_a) => __async$g(void 0, null, function* () {
8273
+ mutationFn: (_a) => __async$h(void 0, null, function* () {
8292
8274
  var _b = _a, { salesOrderId } = _b, shipment = __objRest$4(_b, ["salesOrderId"]);
8293
8275
  const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
8294
8276
  return result.data;
@@ -8298,6 +8280,75 @@ const useCreateSalesOrderShipment = () => {
8298
8280
  });
8299
8281
  };
8300
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
+
8301
8352
  var __async$f = (__this, __arguments, generator) => {
8302
8353
  return new Promise((resolve, reject) => {
8303
8354
  var fulfilled = (value) => {
@@ -8480,10 +8531,10 @@ const useGetShipment = (shipmentId) => {
8480
8531
  enabled: shipmentId !== void 0,
8481
8532
  onError,
8482
8533
  queryFn: () => {
8483
- if (shipmentId) {
8484
- return client.salesOrderShipments.get(shipmentId);
8534
+ if (!shipmentId) {
8535
+ return Promise.reject(new Error("shipmentId is required"));
8485
8536
  }
8486
- return Promise.reject(new Error("shipmentId is required"));
8537
+ return client.salesOrderShipments.get(shipmentId);
8487
8538
  },
8488
8539
  queryKey: ["useGetShipment", shipmentId],
8489
8540
  select: (result) => result.data
@@ -8581,9 +8632,11 @@ const useListSalesOrders = (params = {}) => {
8581
8632
  });
8582
8633
  };
8583
8634
 
8584
- const useListWarehouses = () => {
8635
+ const useListWarehouses = (options) => {
8636
+ var _a;
8585
8637
  const { client } = useShipEngine();
8586
8638
  return reactQuery.useQuery({
8639
+ enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
8587
8640
  onError,
8588
8641
  queryFn: () => client.warehouses.list(),
8589
8642
  queryKey: ["useListWarehouses"],
@@ -9847,6 +9900,7 @@ exports.useConnectCarrier = useConnectCarrier;
9847
9900
  exports.useCreateFundingSource = useCreateFundingSource;
9848
9901
  exports.useCreateLabel = useCreateLabel;
9849
9902
  exports.useCreateSalesOrderShipment = useCreateSalesOrderShipment;
9903
+ exports.useCreateShipment = useCreateShipment;
9850
9904
  exports.useCreateWarehouse = useCreateWarehouse;
9851
9905
  exports.useDeleteWarehouse = useDeleteWarehouse;
9852
9906
  exports.useGetAccountSettings = useGetAccountSettings;
package/index.mjs CHANGED
@@ -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)) {
@@ -5241,8 +5241,8 @@ const getEndUserIpAddress = () => __async$q(void 0, null, function* () {
5241
5241
  });
5242
5242
 
5243
5243
  var __defProp$5 = Object.defineProperty;
5244
- var __defProps$2 = Object.defineProperties;
5245
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
5244
+ var __defProps$3 = Object.defineProperties;
5245
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
5246
5246
  var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
5247
5247
  var __hasOwnProp$a = Object.prototype.hasOwnProperty;
5248
5248
  var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
@@ -5258,7 +5258,7 @@ var __spreadValues$5 = (a, b) => {
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)
@@ -5271,7 +5271,7 @@ var __objRest$6 = (source, exclude) => {
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$5({}, connection), {
5308
+ return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$3(__spreadValues$5({}, connection), {
5309
5309
  endUserIpAddress
5310
5310
  }));
5311
5311
  });
@@ -7539,7 +7539,7 @@ var __spreadValues$4 = (a, b) => {
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,7 +7568,7 @@ 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")]);
@@ -7576,7 +7576,7 @@ class FundingSourcesAPI {
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,7 +7585,7 @@ 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")]);
@@ -7693,23 +7693,7 @@ class SalesOrdersAPI {
7693
7693
  }
7694
7694
  }
7695
7695
 
7696
- var __defProp$3 = Object.defineProperty;
7697
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
7698
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
7699
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
7700
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7701
- var __spreadValues$3 = (a, b) => {
7702
- for (var prop in b || (b = {}))
7703
- if (__hasOwnProp$8.call(b, prop))
7704
- __defNormalProp$3(a, prop, b[prop]);
7705
- if (__getOwnPropSymbols$8)
7706
- for (var prop of __getOwnPropSymbols$8(b)) {
7707
- if (__propIsEnum$8.call(b, prop))
7708
- __defNormalProp$3(a, prop, b[prop]);
7709
- }
7710
- return a;
7711
- };
7712
- var __async$n = (__this, __arguments, generator) => {
7696
+ var __async$o = (__this, __arguments, generator) => {
7713
7697
  return new Promise((resolve, reject) => {
7714
7698
  var fulfilled = (value) => {
7715
7699
  try {
@@ -7738,11 +7722,9 @@ class ShipmentsAPI {
7738
7722
  createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
7739
7723
  );
7740
7724
  };
7741
- this.create = (shipment) => __async$n(this, null, function* () {
7725
+ this.create = (...shipments) => __async$o(this, null, function* () {
7742
7726
  return this.client.post("/v1/shipments", {
7743
- shipments: [
7744
- __spreadValues$3({}, shipment)
7745
- ]
7727
+ shipments
7746
7728
  });
7747
7729
  });
7748
7730
  this.client = client;
@@ -7768,26 +7750,26 @@ class WarehousesAPI {
7768
7750
  }
7769
7751
  }
7770
7752
 
7771
- var __defProp$2 = Object.defineProperty;
7772
- var __defProps$1 = Object.defineProperties;
7773
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
7774
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
7775
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
7776
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
7777
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7778
- 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) => {
7779
7761
  for (var prop in b || (b = {}))
7780
- if (__hasOwnProp$7.call(b, prop))
7781
- __defNormalProp$2(a, prop, b[prop]);
7782
- if (__getOwnPropSymbols$7)
7783
- for (var prop of __getOwnPropSymbols$7(b)) {
7784
- if (__propIsEnum$7.call(b, prop))
7785
- __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]);
7786
7768
  }
7787
7769
  return a;
7788
7770
  };
7789
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
7790
- 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) => {
7791
7773
  return new Promise((resolve, reject) => {
7792
7774
  var fulfilled = (value) => {
7793
7775
  try {
@@ -7809,7 +7791,7 @@ var __async$m = (__this, __arguments, generator) => {
7809
7791
  };
7810
7792
  const logger$1 = E({
7811
7793
  name: "shipengine-api",
7812
- serializers: __spreadProps$1(__spreadValues$2({}, k), {
7794
+ serializers: __spreadProps$2(__spreadValues$3({}, k), {
7813
7795
  req: (req) => ({
7814
7796
  headers: req.headers,
7815
7797
  method: req.method,
@@ -7834,7 +7816,7 @@ class ShipEngineAPI {
7834
7816
  constructor(token, { baseURL, headers, getToken }) {
7835
7817
  const client = axios.create({
7836
7818
  baseURL,
7837
- headers: __spreadProps$1(__spreadValues$2({}, headers), {
7819
+ headers: __spreadProps$2(__spreadValues$3({}, headers), {
7838
7820
  Authorization: `Bearer ${token}`,
7839
7821
  "Content-Type": "application/json"
7840
7822
  }),
@@ -7863,7 +7845,7 @@ class ShipEngineAPI {
7863
7845
  );
7864
7846
  return res;
7865
7847
  },
7866
- (err) => __async$m(this, null, function* () {
7848
+ (err) => __async$n(this, null, function* () {
7867
7849
  var _a, _b, _c, _d, _e, _f, _g;
7868
7850
  logger$1.error(
7869
7851
  { err, req: err.config, res: err.response },
@@ -8000,25 +7982,25 @@ const delay = (ms) => new Promise((resolve) => {
8000
7982
 
8001
7983
  const onError = (errors) => errors.forEach(console.log);
8002
7984
 
8003
- var __defProp$1 = Object.defineProperty;
8004
- var __defProps = Object.defineProperties;
8005
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8006
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8007
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8008
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8009
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8010
- 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) => {
8011
7993
  for (var prop in b || (b = {}))
8012
- if (__hasOwnProp$6.call(b, prop))
8013
- __defNormalProp$1(a, prop, b[prop]);
8014
- if (__getOwnPropSymbols$6)
8015
- for (var prop of __getOwnPropSymbols$6(b)) {
8016
- if (__propIsEnum$6.call(b, prop))
8017
- __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]);
8018
8000
  }
8019
8001
  return a;
8020
8002
  };
8021
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
8003
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
8022
8004
  const streams = [];
8023
8005
  if (process.env.NODE_ENV === "production") {
8024
8006
  streams.push({
@@ -8027,7 +8009,7 @@ if (process.env.NODE_ENV === "production") {
8027
8009
  }
8028
8010
  const logger = E({
8029
8011
  name: "shipengine",
8030
- serializers: __spreadProps(__spreadValues$1({}, k), {
8012
+ serializers: __spreadProps$1(__spreadValues$2({}, k), {
8031
8013
  req: (req) => ({
8032
8014
  headers: req.headers,
8033
8015
  method: req.method,
@@ -8052,7 +8034,7 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
8052
8034
  throw error;
8053
8035
  });
8054
8036
 
8055
- var __async$l = (__this, __arguments, generator) => {
8037
+ var __async$m = (__this, __arguments, generator) => {
8056
8038
  return new Promise((resolve, reject) => {
8057
8039
  var fulfilled = (value) => {
8058
8040
  try {
@@ -8075,7 +8057,7 @@ var __async$l = (__this, __arguments, generator) => {
8075
8057
  const useAddFunds = (carrierId) => {
8076
8058
  const { client } = useShipEngine();
8077
8059
  return useMutation({
8078
- mutationFn: (funds) => __async$l(void 0, null, function* () {
8060
+ mutationFn: (funds) => __async$m(void 0, null, function* () {
8079
8061
  const result = yield client.carriers.addFunds(carrierId, funds);
8080
8062
  return result.data;
8081
8063
  }),
@@ -8084,7 +8066,7 @@ const useAddFunds = (carrierId) => {
8084
8066
  });
8085
8067
  };
8086
8068
 
8087
- var __async$k = (__this, __arguments, generator) => {
8069
+ var __async$l = (__this, __arguments, generator) => {
8088
8070
  return new Promise((resolve, reject) => {
8089
8071
  var fulfilled = (value) => {
8090
8072
  try {
@@ -8107,7 +8089,7 @@ var __async$k = (__this, __arguments, generator) => {
8107
8089
  const useCalculateRates = () => {
8108
8090
  const { client } = useShipEngine();
8109
8091
  return useMutation({
8110
- mutationFn: (_0) => __async$k(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8092
+ mutationFn: (_0) => __async$l(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8111
8093
  const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
8112
8094
  return result.data;
8113
8095
  }),
@@ -8116,7 +8098,7 @@ const useCalculateRates = () => {
8116
8098
  });
8117
8099
  };
8118
8100
 
8119
- var __async$j = (__this, __arguments, generator) => {
8101
+ var __async$k = (__this, __arguments, generator) => {
8120
8102
  return new Promise((resolve, reject) => {
8121
8103
  var fulfilled = (value) => {
8122
8104
  try {
@@ -8139,7 +8121,7 @@ var __async$j = (__this, __arguments, generator) => {
8139
8121
  const useConnectCarrier = () => {
8140
8122
  const { client } = useShipEngine();
8141
8123
  return useMutation({
8142
- mutationFn: (params) => __async$j(void 0, null, function* () {
8124
+ mutationFn: (params) => __async$k(void 0, null, function* () {
8143
8125
  const result = yield client.carriers.connect(params);
8144
8126
  return result.data;
8145
8127
  }),
@@ -8148,7 +8130,7 @@ const useConnectCarrier = () => {
8148
8130
  });
8149
8131
  };
8150
8132
 
8151
- var __async$i = (__this, __arguments, generator) => {
8133
+ var __async$j = (__this, __arguments, generator) => {
8152
8134
  return new Promise((resolve, reject) => {
8153
8135
  var fulfilled = (value) => {
8154
8136
  try {
@@ -8171,7 +8153,7 @@ var __async$i = (__this, __arguments, generator) => {
8171
8153
  const useCreateFundingSource = () => {
8172
8154
  const { client } = useShipEngine();
8173
8155
  return useMutation({
8174
- mutationFn: (fundingSource) => __async$i(void 0, null, function* () {
8156
+ mutationFn: (fundingSource) => __async$j(void 0, null, function* () {
8175
8157
  const result = yield client.fundingSources.create(fundingSource);
8176
8158
  return result.data;
8177
8159
  }),
@@ -8180,22 +8162,22 @@ const useCreateFundingSource = () => {
8180
8162
  });
8181
8163
  };
8182
8164
 
8183
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8184
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8185
- 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;
8186
8168
  var __objRest$5 = (source, exclude) => {
8187
8169
  var target = {};
8188
8170
  for (var prop in source)
8189
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8171
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8190
8172
  target[prop] = source[prop];
8191
- if (source != null && __getOwnPropSymbols$5)
8192
- for (var prop of __getOwnPropSymbols$5(source)) {
8193
- 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))
8194
8176
  target[prop] = source[prop];
8195
8177
  }
8196
8178
  return target;
8197
8179
  };
8198
- var __async$h = (__this, __arguments, generator) => {
8180
+ var __async$i = (__this, __arguments, generator) => {
8199
8181
  return new Promise((resolve, reject) => {
8200
8182
  var fulfilled = (value) => {
8201
8183
  try {
@@ -8218,7 +8200,7 @@ var __async$h = (__this, __arguments, generator) => {
8218
8200
  const useCreateLabel = () => {
8219
8201
  const { client } = useShipEngine();
8220
8202
  return useMutation({
8221
- mutationFn: (_a) => __async$h(void 0, null, function* () {
8203
+ mutationFn: (_a) => __async$i(void 0, null, function* () {
8222
8204
  var _b = _a, { rateId } = _b, options = __objRest$5(_b, ["rateId"]);
8223
8205
  const result = yield client.labels.createByRateId(rateId, options);
8224
8206
  return result.data;
@@ -8228,22 +8210,22 @@ const useCreateLabel = () => {
8228
8210
  });
8229
8211
  };
8230
8212
 
8231
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
8232
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
8233
- 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;
8234
8216
  var __objRest$4 = (source, exclude) => {
8235
8217
  var target = {};
8236
8218
  for (var prop in source)
8237
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
8219
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8238
8220
  target[prop] = source[prop];
8239
- if (source != null && __getOwnPropSymbols$4)
8240
- for (var prop of __getOwnPropSymbols$4(source)) {
8241
- 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))
8242
8224
  target[prop] = source[prop];
8243
8225
  }
8244
8226
  return target;
8245
8227
  };
8246
- var __async$g = (__this, __arguments, generator) => {
8228
+ var __async$h = (__this, __arguments, generator) => {
8247
8229
  return new Promise((resolve, reject) => {
8248
8230
  var fulfilled = (value) => {
8249
8231
  try {
@@ -8266,7 +8248,7 @@ var __async$g = (__this, __arguments, generator) => {
8266
8248
  const useCreateSalesOrderShipment = () => {
8267
8249
  const { client } = useShipEngine();
8268
8250
  return useMutation({
8269
- mutationFn: (_a) => __async$g(void 0, null, function* () {
8251
+ mutationFn: (_a) => __async$h(void 0, null, function* () {
8270
8252
  var _b = _a, { salesOrderId } = _b, shipment = __objRest$4(_b, ["salesOrderId"]);
8271
8253
  const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
8272
8254
  return result.data;
@@ -8276,6 +8258,75 @@ const useCreateSalesOrderShipment = () => {
8276
8258
  });
8277
8259
  };
8278
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
+
8279
8330
  var __async$f = (__this, __arguments, generator) => {
8280
8331
  return new Promise((resolve, reject) => {
8281
8332
  var fulfilled = (value) => {
@@ -8458,10 +8509,10 @@ const useGetShipment = (shipmentId) => {
8458
8509
  enabled: shipmentId !== void 0,
8459
8510
  onError,
8460
8511
  queryFn: () => {
8461
- if (shipmentId) {
8462
- return client.salesOrderShipments.get(shipmentId);
8512
+ if (!shipmentId) {
8513
+ return Promise.reject(new Error("shipmentId is required"));
8463
8514
  }
8464
- return Promise.reject(new Error("shipmentId is required"));
8515
+ return client.salesOrderShipments.get(shipmentId);
8465
8516
  },
8466
8517
  queryKey: ["useGetShipment", shipmentId],
8467
8518
  select: (result) => result.data
@@ -8559,9 +8610,11 @@ const useListSalesOrders = (params = {}) => {
8559
8610
  });
8560
8611
  };
8561
8612
 
8562
- const useListWarehouses = () => {
8613
+ const useListWarehouses = (options) => {
8614
+ var _a;
8563
8615
  const { client } = useShipEngine();
8564
8616
  return useQuery({
8617
+ enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
8565
8618
  onError,
8566
8619
  queryFn: () => client.warehouses.list(),
8567
8620
  queryKey: ["useListWarehouses"],
@@ -9781,4 +9834,4 @@ const alchemy = {
9781
9834
  createElement
9782
9835
  };
9783
9836
 
9784
- 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.22",
3
+ "version": "0.4.24",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {