@shipengine/alchemy 2.2.2 → 2.2.3

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 +648 -609
  2. package/index.mjs +649 -611
  3. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { jsx as jsx$1, jsxs as jsxs$1 } from 'react/jsx-runtime';
4
4
  import { css, Global, ThemeProvider, CacheProvider } from '@emotion/react';
5
5
  import { BrandName } from '@packlink/brands';
6
6
  import { getEmotionResetStyles, createIconCache, GigerConfigProvider } from '@packlink/giger';
7
- import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient } from 'react-query';
7
+ import { QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient } from 'react-query';
8
8
  import { Theme } from '@packlink/giger-theme';
9
9
  import { I18nextProvider } from 'react-i18next';
10
10
  import i18n from 'i18next';
@@ -5216,7 +5216,7 @@ var ipaddr = {
5216
5216
  }).call(commonjsGlobal);
5217
5217
  } (ipaddr));
5218
5218
 
5219
- var __async$w = (__this, __arguments, generator) => {
5219
+ var __async$x = (__this, __arguments, generator) => {
5220
5220
  return new Promise((resolve, reject) => {
5221
5221
  var fulfilled = (value) => {
5222
5222
  try {
@@ -5236,7 +5236,7 @@ var __async$w = (__this, __arguments, generator) => {
5236
5236
  step((generator = generator.apply(__this, __arguments)).next());
5237
5237
  });
5238
5238
  };
5239
- const getEndUserIpAddress = () => __async$w(void 0, null, function* () {
5239
+ const getEndUserIpAddress = () => __async$x(void 0, null, function* () {
5240
5240
  try {
5241
5241
  const response = yield axios.get("https://api.ipify.org/?format=json");
5242
5242
  if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
@@ -5279,7 +5279,7 @@ var __objRest$7 = (source, exclude) => {
5279
5279
  }
5280
5280
  return target;
5281
5281
  };
5282
- var __async$v = (__this, __arguments, generator) => {
5282
+ var __async$w = (__this, __arguments, generator) => {
5283
5283
  return new Promise((resolve, reject) => {
5284
5284
  var fulfilled = (value) => {
5285
5285
  try {
@@ -5308,7 +5308,7 @@ class CarriersAPI {
5308
5308
  this.get = (carrierId) => {
5309
5309
  return this.client.get(`/v1/carriers/${carrierId}`);
5310
5310
  };
5311
- this.connect = (_a) => __async$v(this, null, function* () {
5311
+ this.connect = (_a) => __async$w(this, null, function* () {
5312
5312
  var _b = _a, { carrierCode } = _b, connection = __objRest$7(_b, ["carrierCode"]);
5313
5313
  const endUserIpAddress = yield getEndUserIpAddress();
5314
5314
  if (!endUserIpAddress)
@@ -7561,7 +7561,7 @@ var __spreadValues$6 = (a, b) => {
7561
7561
  }
7562
7562
  return a;
7563
7563
  };
7564
- var __async$u = (__this, __arguments, generator) => {
7564
+ var __async$v = (__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 = (createFundingSource) => __async$u(this, null, function* () {
7593
+ this.create = (createFundingSource) => __async$v(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
  }, createFundingSource));
7600
7600
  });
7601
- this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$u(this, null, function* () {
7601
+ this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$v(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")]);
@@ -7611,7 +7611,7 @@ class FundingSourcesAPI {
7611
7611
  }
7612
7612
  );
7613
7613
  });
7614
- this.registerCarrier = (carrier) => __async$u(this, null, function* () {
7614
+ this.registerCarrier = (carrier) => __async$v(this, null, function* () {
7615
7615
  const endUserIpAddress = yield getEndUserIpAddress();
7616
7616
  if (!endUserIpAddress)
7617
7617
  return Promise.reject([new CodedError("Unable to get IP address")]);
@@ -7619,7 +7619,7 @@ class FundingSourcesAPI {
7619
7619
  endUserIpAddress
7620
7620
  }, carrier));
7621
7621
  });
7622
- this.addFunds = (amount, fundingSourceId) => __async$u(this, null, function* () {
7622
+ this.addFunds = (amount, fundingSourceId) => __async$v(this, null, function* () {
7623
7623
  return yield this.client.put(
7624
7624
  `/v1/funding_sources/${fundingSourceId}/add_funds`,
7625
7625
  amount
@@ -7711,6 +7711,12 @@ class RateCardsAPI {
7711
7711
  this.publish = (rateCardId) => {
7712
7712
  return this.client.post(`/v1/rate_cards/${rateCardId}/publish`);
7713
7713
  };
7714
+ /**
7715
+ * @description https://auctane.atlassian.net/wiki/spaces/TE/pages/3837431603/Inc+1+3.+Rate+Card+Details#Delete-Rate-Card
7716
+ */
7717
+ this.delete = (rateCardId) => {
7718
+ return this.client.delete(`/v1/rate_cards/${rateCardId}`);
7719
+ };
7714
7720
  this.client = client;
7715
7721
  }
7716
7722
  }
@@ -7768,7 +7774,7 @@ class SalesOrdersAPI {
7768
7774
  }
7769
7775
  }
7770
7776
 
7771
- var __async$t = (__this, __arguments, generator) => {
7777
+ var __async$u = (__this, __arguments, generator) => {
7772
7778
  return new Promise((resolve, reject) => {
7773
7779
  var fulfilled = (value) => {
7774
7780
  try {
@@ -7800,7 +7806,7 @@ class ShipmentsAPI {
7800
7806
  this.list = (options) => {
7801
7807
  return this.client.get("/v1/shipments", { params: options });
7802
7808
  };
7803
- this.create = (...shipments) => __async$t(this, null, function* () {
7809
+ this.create = (...shipments) => __async$u(this, null, function* () {
7804
7810
  return this.client.post("/v1/shipments", {
7805
7811
  shipments
7806
7812
  });
@@ -7847,7 +7853,7 @@ var __spreadValues$5 = (a, b) => {
7847
7853
  return a;
7848
7854
  };
7849
7855
  var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
7850
- var __async$s = (__this, __arguments, generator) => {
7856
+ var __async$t = (__this, __arguments, generator) => {
7851
7857
  return new Promise((resolve, reject) => {
7852
7858
  var fulfilled = (value) => {
7853
7859
  try {
@@ -7941,7 +7947,7 @@ class ShipEngineAPI {
7941
7947
  );
7942
7948
  return res;
7943
7949
  },
7944
- (err) => __async$s(this, null, function* () {
7950
+ (err) => __async$t(this, null, function* () {
7945
7951
  var _a, _b, _c, _d, _e, _f, _g;
7946
7952
  logger$1.error(
7947
7953
  { err, req: err.config, res: err.response },
@@ -8133,7 +8139,17 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
8133
8139
  throw error;
8134
8140
  });
8135
8141
 
8136
- var __async$r = (__this, __arguments, generator) => {
8142
+ const useGetAccountSettings = () => {
8143
+ const { client } = useShipEngine();
8144
+ return useQuery({
8145
+ onError,
8146
+ queryFn: () => client.accountSettings.get(),
8147
+ queryKey: ["getAccountSettings"],
8148
+ select: (result) => result.data
8149
+ });
8150
+ };
8151
+
8152
+ var __async$s = (__this, __arguments, generator) => {
8137
8153
  return new Promise((resolve, reject) => {
8138
8154
  var fulfilled = (value) => {
8139
8155
  try {
@@ -8153,19 +8169,19 @@ var __async$r = (__this, __arguments, generator) => {
8153
8169
  step((generator = generator.apply(__this, __arguments)).next());
8154
8170
  });
8155
8171
  };
8156
- const useAddFunds = (carrierId) => {
8172
+ const useUpdateAccountSettings = () => {
8157
8173
  const { client } = useShipEngine();
8158
8174
  return useMutation({
8159
- mutationFn: (funds) => __async$r(void 0, null, function* () {
8160
- const result = yield client.carriers.addFunds(carrierId, funds);
8175
+ mutationFn: (settings) => __async$s(void 0, null, function* () {
8176
+ const result = yield client.accountSettings.update(settings);
8161
8177
  return result.data;
8162
8178
  }),
8163
- mutationKey: ["useAddFunds"],
8179
+ mutationKey: ["useUpdateAccountSettings"],
8164
8180
  onError
8165
8181
  });
8166
8182
  };
8167
8183
 
8168
- var __async$q = (__this, __arguments, generator) => {
8184
+ var __async$r = (__this, __arguments, generator) => {
8169
8185
  return new Promise((resolve, reject) => {
8170
8186
  var fulfilled = (value) => {
8171
8187
  try {
@@ -8185,19 +8201,19 @@ var __async$q = (__this, __arguments, generator) => {
8185
8201
  step((generator = generator.apply(__this, __arguments)).next());
8186
8202
  });
8187
8203
  };
8188
- const useCalculateRates = () => {
8204
+ const useParseAddress = () => {
8189
8205
  const { client } = useShipEngine();
8190
8206
  return useMutation({
8191
- mutationFn: (_0) => __async$q(void 0, [_0], function* ({ rateOptions, shipmentId }) {
8192
- const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
8207
+ mutationFn: (_0) => __async$r(void 0, [_0], function* ({ address, text }) {
8208
+ const result = yield client.addresses.parse(text, address);
8193
8209
  return result.data;
8194
8210
  }),
8195
- mutationKey: ["useCalculateRates"],
8211
+ mutationKey: ["useParseAddress"],
8196
8212
  onError
8197
8213
  });
8198
8214
  };
8199
8215
 
8200
- var __async$p = (__this, __arguments, generator) => {
8216
+ var __async$q = (__this, __arguments, generator) => {
8201
8217
  return new Promise((resolve, reject) => {
8202
8218
  var fulfilled = (value) => {
8203
8219
  try {
@@ -8217,19 +8233,19 @@ var __async$p = (__this, __arguments, generator) => {
8217
8233
  step((generator = generator.apply(__this, __arguments)).next());
8218
8234
  });
8219
8235
  };
8220
- const useConnectCarrier = () => {
8236
+ const useValidateAddresses = () => {
8221
8237
  const { client } = useShipEngine();
8222
8238
  return useMutation({
8223
- mutationFn: (params) => __async$p(void 0, null, function* () {
8224
- const result = yield client.carriers.connect(params);
8239
+ mutationFn: (addresses) => __async$q(void 0, null, function* () {
8240
+ const result = yield client.addresses.validate(addresses);
8225
8241
  return result.data;
8226
8242
  }),
8227
- mutationKey: ["useConnectCarrier"],
8243
+ mutationKey: ["useValidateAddresses"],
8228
8244
  onError
8229
8245
  });
8230
8246
  };
8231
8247
 
8232
- var __async$o = (__this, __arguments, generator) => {
8248
+ var __async$p = (__this, __arguments, generator) => {
8233
8249
  return new Promise((resolve, reject) => {
8234
8250
  var fulfilled = (value) => {
8235
8251
  try {
@@ -8249,34 +8265,19 @@ var __async$o = (__this, __arguments, generator) => {
8249
8265
  step((generator = generator.apply(__this, __arguments)).next());
8250
8266
  });
8251
8267
  };
8252
- const useCreateFundingSource = () => {
8268
+ const useAddFunds = (carrierId) => {
8253
8269
  const { client } = useShipEngine();
8254
8270
  return useMutation({
8255
- mutationFn: (fundingSource) => __async$o(void 0, null, function* () {
8256
- const result = yield client.fundingSources.create(fundingSource);
8271
+ mutationFn: (funds) => __async$p(void 0, null, function* () {
8272
+ const result = yield client.carriers.addFunds(carrierId, funds);
8257
8273
  return result.data;
8258
8274
  }),
8259
- mutationKey: ["useCreateFundingSource"],
8275
+ mutationKey: ["useAddFunds"],
8260
8276
  onError
8261
8277
  });
8262
8278
  };
8263
8279
 
8264
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
8265
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
8266
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
8267
- var __objRest$6 = (source, exclude) => {
8268
- var target = {};
8269
- for (var prop in source)
8270
- if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
8271
- target[prop] = source[prop];
8272
- if (source != null && __getOwnPropSymbols$9)
8273
- for (var prop of __getOwnPropSymbols$9(source)) {
8274
- if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
8275
- target[prop] = source[prop];
8276
- }
8277
- return target;
8278
- };
8279
- var __async$n = (__this, __arguments, generator) => {
8280
+ var __async$o = (__this, __arguments, generator) => {
8280
8281
  return new Promise((resolve, reject) => {
8281
8282
  var fulfilled = (value) => {
8282
8283
  try {
@@ -8296,20 +8297,147 @@ var __async$n = (__this, __arguments, generator) => {
8296
8297
  step((generator = generator.apply(__this, __arguments)).next());
8297
8298
  });
8298
8299
  };
8299
- const useCreateLabel = () => {
8300
+ const useConnectCarrier = () => {
8300
8301
  const { client } = useShipEngine();
8301
8302
  return useMutation({
8302
- mutationFn: (_a) => __async$n(void 0, null, function* () {
8303
- var _b = _a, { rateId } = _b, options = __objRest$6(_b, ["rateId"]);
8304
- const result = yield client.labels.createByRateId(rateId, options);
8303
+ mutationFn: (params) => __async$o(void 0, null, function* () {
8304
+ const result = yield client.carriers.connect(params);
8305
8305
  return result.data;
8306
8306
  }),
8307
- mutationKey: ["useCreateLabel"],
8307
+ mutationKey: ["useConnectCarrier"],
8308
8308
  onError
8309
8309
  });
8310
8310
  };
8311
8311
 
8312
- var __async$m = (__this, __arguments, generator) => {
8312
+ const useGetAutoFundingConfiguration = (carrierId) => {
8313
+ const { client } = useShipEngine();
8314
+ return useQuery({
8315
+ enabled: carrierId !== void 0,
8316
+ onError,
8317
+ queryFn: () => {
8318
+ if (carrierId)
8319
+ return client.carriers.getAutoFunding(carrierId);
8320
+ return Promise.reject(new Error("carrierId is required."));
8321
+ },
8322
+ queryKey: ["useGetAutoFundingConfiguration", carrierId],
8323
+ select: (result) => result.data
8324
+ });
8325
+ };
8326
+
8327
+ const useGetCarrierById = (carrierId) => {
8328
+ const { client } = useShipEngine();
8329
+ return useQuery({
8330
+ enabled: !!carrierId,
8331
+ onError,
8332
+ queryFn: () => {
8333
+ if (carrierId)
8334
+ return client.carriers.get(carrierId);
8335
+ return Promise.reject(new Error("carrierId is require"));
8336
+ },
8337
+ queryKey: ["useGetCarrierById", carrierId],
8338
+ select: (result) => result.data,
8339
+ // Fresh for 5 minutes
8340
+ staleTime: 5 * 60 * 1e3
8341
+ });
8342
+ };
8343
+
8344
+ const useGetCountriesByCarrier = (carrierId) => {
8345
+ const { client } = useShipEngine();
8346
+ return useQuery({
8347
+ enabled: !!carrierId,
8348
+ onError,
8349
+ queryFn: () => {
8350
+ if (carrierId)
8351
+ return client.carriers.getCountries(carrierId);
8352
+ return Promise.reject(new Error("carrierId is require"));
8353
+ },
8354
+ queryKey: ["useGetCountriesByCarrier", carrierId],
8355
+ select: (result) => result.data.countries,
8356
+ // Fresh for 5 minutes
8357
+ staleTime: 5 * 60 * 1e3
8358
+ });
8359
+ };
8360
+
8361
+ const useGetCurrenciesByCarrier = (carrierId) => {
8362
+ const { client } = useShipEngine();
8363
+ return useQuery({
8364
+ enabled: !!carrierId,
8365
+ onError,
8366
+ queryFn: () => {
8367
+ if (carrierId)
8368
+ return client.carriers.getCurrencies(carrierId);
8369
+ return Promise.reject(new Error("carrierId is require"));
8370
+ },
8371
+ queryKey: ["useGetCurrenciesByCarrier", carrierId],
8372
+ select: (result) => result.data.currencies,
8373
+ // Fresh for 5 minutes
8374
+ staleTime: 5 * 60 * 1e3
8375
+ });
8376
+ };
8377
+
8378
+ const useGetPackageRatingGroupByCarrier = (carrierId) => {
8379
+ const { client } = useShipEngine();
8380
+ return useQuery({
8381
+ enabled: !!carrierId,
8382
+ onError,
8383
+ queryFn: () => {
8384
+ if (carrierId)
8385
+ return client.carriers.getPackageRatingGroup(carrierId);
8386
+ return Promise.reject(new Error("carrierId is required"));
8387
+ },
8388
+ queryKey: ["useGetRatePackageFormatsByCarrier", carrierId],
8389
+ select: (result) => result.data.packageRatingGroup,
8390
+ // Fresh for 5 minutes
8391
+ staleTime: 5 * 60 * 1e3
8392
+ });
8393
+ };
8394
+
8395
+ const useGetServicesByCarrier = (carrierId) => {
8396
+ const { client } = useShipEngine();
8397
+ return useQuery({
8398
+ enabled: !!carrierId,
8399
+ onError,
8400
+ queryFn: () => {
8401
+ if (carrierId)
8402
+ return client.carriers.getServices(carrierId);
8403
+ return Promise.reject(new Error("carrierId is required"));
8404
+ },
8405
+ queryKey: ["useGetServicesByCarrier", carrierId],
8406
+ select: (result) => result.data.services,
8407
+ // Fresh for 5 minutes
8408
+ staleTime: 5 * 60 * 1e3
8409
+ });
8410
+ };
8411
+
8412
+ const useGetWalletHistory = ({
8413
+ enabled,
8414
+ page,
8415
+ range
8416
+ }) => {
8417
+ const { client } = useShipEngine();
8418
+ const [startDate, endDate] = range;
8419
+ return useQuery({
8420
+ enabled,
8421
+ keepPreviousData: true,
8422
+ // See https://react-query-v3.tanstack.com/guides/paginated-queries#better-paginated-queries-with-keeppreviousdata
8423
+ onError,
8424
+ queryFn: () => client.carriers.getWalletHistory(startDate, endDate, page),
8425
+ queryKey: ["useGetWalletHistory", startDate, endDate, page],
8426
+ select: (result) => result.data
8427
+ });
8428
+ };
8429
+
8430
+ const useListCarriers = () => {
8431
+ const { client } = useShipEngine();
8432
+ return useQuery({
8433
+ onError,
8434
+ queryFn: () => client.carriers.list(),
8435
+ queryKey: ["useListCarriers"],
8436
+ select: (result) => result.data.carriers
8437
+ });
8438
+ };
8439
+
8440
+ var __async$n = (__this, __arguments, generator) => {
8313
8441
  return new Promise((resolve, reject) => {
8314
8442
  var fulfilled = (value) => {
8315
8443
  try {
@@ -8329,34 +8457,33 @@ var __async$m = (__this, __arguments, generator) => {
8329
8457
  step((generator = generator.apply(__this, __arguments)).next());
8330
8458
  });
8331
8459
  };
8332
- const useCreateRateCard = () => {
8460
+ const useUpdateAutoFunding = (carrierId) => {
8333
8461
  const { client } = useShipEngine();
8462
+ const queryClient = useQueryClient();
8334
8463
  return useMutation({
8335
- mutationFn: (rateCard) => __async$m(void 0, null, function* () {
8336
- const result = yield client.rateCards.create(rateCard);
8464
+ mutationFn: (options) => __async$n(void 0, null, function* () {
8465
+ const result = yield client.carriers.updateAutoFunding(carrierId, options);
8337
8466
  return result.data;
8338
8467
  }),
8339
- mutationKey: ["useCreateRateCard"],
8340
- onError
8468
+ mutationKey: ["useUpdateAutoFunding"],
8469
+ onError,
8470
+ onSuccess: (_) => {
8471
+ queryClient.invalidateQueries(["useGetAutoFunding", carrierId], { exact: true });
8472
+ }
8341
8473
  });
8342
8474
  };
8343
8475
 
8344
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
8345
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
8346
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
8347
- var __objRest$5 = (source, exclude) => {
8348
- var target = {};
8349
- for (var prop in source)
8350
- if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
8351
- target[prop] = source[prop];
8352
- if (source != null && __getOwnPropSymbols$8)
8353
- for (var prop of __getOwnPropSymbols$8(source)) {
8354
- if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
8355
- target[prop] = source[prop];
8356
- }
8357
- return target;
8476
+ const useListCustomPackageTypes = () => {
8477
+ const { client } = useShipEngine();
8478
+ return useQuery({
8479
+ onError,
8480
+ queryFn: () => client.customPackages.list(),
8481
+ queryKey: ["useListCustomPackageTypes"],
8482
+ select: (result) => result.data.packages
8483
+ });
8358
8484
  };
8359
- var __async$l = (__this, __arguments, generator) => {
8485
+
8486
+ var __async$m = (__this, __arguments, generator) => {
8360
8487
  return new Promise((resolve, reject) => {
8361
8488
  var fulfilled = (value) => {
8362
8489
  try {
@@ -8376,39 +8503,19 @@ var __async$l = (__this, __arguments, generator) => {
8376
8503
  step((generator = generator.apply(__this, __arguments)).next());
8377
8504
  });
8378
8505
  };
8379
- const useCreateSalesOrderShipment = () => {
8506
+ const useCreateFundingSource = () => {
8380
8507
  const { client } = useShipEngine();
8381
8508
  return useMutation({
8382
- mutationFn: (_a) => __async$l(void 0, null, function* () {
8383
- var _b = _a, { salesOrderId } = _b, shipment = __objRest$5(_b, ["salesOrderId"]);
8384
- const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
8509
+ mutationFn: (fundingSource) => __async$m(void 0, null, function* () {
8510
+ const result = yield client.fundingSources.create(fundingSource);
8385
8511
  return result.data;
8386
8512
  }),
8387
- mutationKey: ["useCreateSalesOrderShipment"],
8513
+ mutationKey: ["useCreateFundingSource"],
8388
8514
  onError
8389
8515
  });
8390
8516
  };
8391
8517
 
8392
- var __defProp$3 = Object.defineProperty;
8393
- var __defProps$2 = Object.defineProperties;
8394
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
8395
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
8396
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
8397
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
8398
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8399
- var __spreadValues$3 = (a, b) => {
8400
- for (var prop in b || (b = {}))
8401
- if (__hasOwnProp$7.call(b, prop))
8402
- __defNormalProp$3(a, prop, b[prop]);
8403
- if (__getOwnPropSymbols$7)
8404
- for (var prop of __getOwnPropSymbols$7(b)) {
8405
- if (__propIsEnum$7.call(b, prop))
8406
- __defNormalProp$3(a, prop, b[prop]);
8407
- }
8408
- return a;
8409
- };
8410
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
8411
- var __async$k = (__this, __arguments, generator) => {
8518
+ var __async$l = (__this, __arguments, generator) => {
8412
8519
  return new Promise((resolve, reject) => {
8413
8520
  var fulfilled = (value) => {
8414
8521
  try {
@@ -8428,69 +8535,39 @@ var __async$k = (__this, __arguments, generator) => {
8428
8535
  step((generator = generator.apply(__this, __arguments)).next());
8429
8536
  });
8430
8537
  };
8431
- const useCreateShipment = () => {
8538
+ const useFundingSourcesAddFunds = (fundingSourceId) => {
8432
8539
  const { client } = useShipEngine();
8433
8540
  return useMutation({
8434
- mutationFn: (shipment) => __async$k(void 0, null, function* () {
8435
- var _a;
8436
- if (shipment.warehouseId === void 0) {
8437
- throw new CodedError("errorMessages.noWarehouses", {
8438
- errorCode: "unknown",
8439
- errorSource: "client",
8440
- errorType: "business_rules"
8441
- });
8442
- }
8443
- const shipTo = (_a = shipment.shipTo) != null ? _a : {
8444
- addressLine1: "",
8445
- cityLocality: "",
8446
- countryCode: "",
8447
- name: "",
8448
- phone: "",
8449
- postalCode: "",
8450
- stateProvince: ""
8451
- };
8452
- return (yield client.shipments.create(__spreadProps$2(__spreadValues$3({}, shipment), {
8453
- shipTo
8454
- }))).data;
8541
+ mutationFn: (funds) => __async$l(void 0, null, function* () {
8542
+ const result = yield client.fundingSources.addFunds(funds, fundingSourceId);
8543
+ return result.data;
8455
8544
  }),
8456
- mutationKey: ["useCreateShipment"],
8545
+ mutationKey: ["useFundingSourcesAddFunds"],
8457
8546
  onError
8458
8547
  });
8459
8548
  };
8460
8549
 
8461
- var __async$j = (__this, __arguments, generator) => {
8462
- return new Promise((resolve, reject) => {
8463
- var fulfilled = (value) => {
8464
- try {
8465
- step(generator.next(value));
8466
- } catch (e) {
8467
- reject(e);
8468
- }
8469
- };
8470
- var rejected = (value) => {
8471
- try {
8472
- step(generator.throw(value));
8473
- } catch (e) {
8474
- reject(e);
8475
- }
8476
- };
8477
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
8478
- step((generator = generator.apply(__this, __arguments)).next());
8550
+ const useGetFundingSourceById = (fundingSourceId) => {
8551
+ const { client } = useShipEngine();
8552
+ return useQuery({
8553
+ onError,
8554
+ queryFn: () => client.fundingSources.get(fundingSourceId),
8555
+ queryKey: ["getFundingSourceById"],
8556
+ select: (result) => result.data
8479
8557
  });
8480
8558
  };
8481
- const useCreateWarehouse = () => {
8559
+
8560
+ const useListFundingSources = () => {
8482
8561
  const { client } = useShipEngine();
8483
- return useMutation({
8484
- mutationFn: (data) => __async$j(void 0, null, function* () {
8485
- const result = yield client.warehouses.create(data);
8486
- return result.data;
8487
- }),
8488
- mutationKey: ["useCreateWarehouse"],
8489
- onError
8562
+ return useQuery({
8563
+ onError,
8564
+ queryFn: () => client.fundingSources.list(),
8565
+ queryKey: ["useListFundingSources"],
8566
+ select: (result) => result.data.fundingSources
8490
8567
  });
8491
8568
  };
8492
8569
 
8493
- var __async$i = (__this, __arguments, generator) => {
8570
+ var __async$k = (__this, __arguments, generator) => {
8494
8571
  return new Promise((resolve, reject) => {
8495
8572
  var fulfilled = (value) => {
8496
8573
  try {
@@ -8510,31 +8587,19 @@ var __async$i = (__this, __arguments, generator) => {
8510
8587
  step((generator = generator.apply(__this, __arguments)).next());
8511
8588
  });
8512
8589
  };
8513
- const useDeleteWarehouse = () => {
8590
+ const useRegisterCarrier = () => {
8514
8591
  const { client } = useShipEngine();
8515
8592
  return useMutation({
8516
- mutationFn: (_0) => __async$i(void 0, [_0], function* ({ warehouseId }) {
8517
- const result = yield client.warehouses.delete(warehouseId);
8593
+ mutationFn: (carrier) => __async$k(void 0, null, function* () {
8594
+ const result = yield client.fundingSources.registerCarrier(carrier);
8518
8595
  return result.data;
8519
8596
  }),
8520
- mutationKey: ["useDeleteWarehouse"],
8597
+ mutationKey: ["useRegisterCarrier"],
8521
8598
  onError
8522
8599
  });
8523
8600
  };
8524
8601
 
8525
- const useDownloadRateCard = (rateCardId) => {
8526
- const { client } = useShipEngine();
8527
- return useQuery({
8528
- enabled: !!rateCardId.length,
8529
- onError,
8530
- queryFn: () => {
8531
- return client.rateCards.download(rateCardId);
8532
- },
8533
- queryKey: ["useDownloadRateCard", rateCardId]
8534
- });
8535
- };
8536
-
8537
- var __async$h = (__this, __arguments, generator) => {
8602
+ var __async$j = (__this, __arguments, generator) => {
8538
8603
  return new Promise((resolve, reject) => {
8539
8604
  var fulfilled = (value) => {
8540
8605
  try {
@@ -8554,104 +8619,26 @@ var __async$h = (__this, __arguments, generator) => {
8554
8619
  step((generator = generator.apply(__this, __arguments)).next());
8555
8620
  });
8556
8621
  };
8557
- const useFundingSourcesAddFunds = (fundingSourceId) => {
8622
+ const useUpdateFundingSource = () => {
8558
8623
  const { client } = useShipEngine();
8559
8624
  return useMutation({
8560
- mutationFn: (funds) => __async$h(void 0, null, function* () {
8561
- const result = yield client.fundingSources.addFunds(funds, fundingSourceId);
8625
+ mutationFn: (_0) => __async$j(void 0, [_0], function* ({
8626
+ billingInfo,
8627
+ creditCardInfo,
8628
+ fundingSourceId
8629
+ }) {
8630
+ const result = yield client.fundingSources.update(
8631
+ billingInfo,
8632
+ creditCardInfo,
8633
+ fundingSourceId
8634
+ );
8562
8635
  return result.data;
8563
8636
  }),
8564
- mutationKey: ["useFundingSourcesAddFunds"],
8637
+ mutationKey: ["useUpdateFundingSource"],
8565
8638
  onError
8566
8639
  });
8567
8640
  };
8568
8641
 
8569
- const useGetAccountSettings = () => {
8570
- const { client } = useShipEngine();
8571
- return useQuery({
8572
- onError,
8573
- queryFn: () => client.accountSettings.get(),
8574
- queryKey: ["getAccountSettings"],
8575
- select: (result) => result.data
8576
- });
8577
- };
8578
-
8579
- const useGetAutoFundingConfiguration = (carrierId) => {
8580
- const { client } = useShipEngine();
8581
- return useQuery({
8582
- enabled: carrierId !== void 0,
8583
- onError,
8584
- queryFn: () => {
8585
- if (carrierId)
8586
- return client.carriers.getAutoFunding(carrierId);
8587
- return Promise.reject(new Error("carrierId is required."));
8588
- },
8589
- queryKey: ["useGetAutoFundingConfiguration", carrierId],
8590
- select: (result) => result.data
8591
- });
8592
- };
8593
-
8594
- const useGetCarrierById = (carrierId) => {
8595
- const { client } = useShipEngine();
8596
- return useQuery({
8597
- enabled: !!carrierId,
8598
- onError,
8599
- queryFn: () => {
8600
- if (carrierId)
8601
- return client.carriers.get(carrierId);
8602
- return Promise.reject(new Error("carrierId is require"));
8603
- },
8604
- queryKey: ["useGetCarrierById", carrierId],
8605
- select: (result) => result.data,
8606
- // Fresh for 5 minutes
8607
- staleTime: 5 * 60 * 1e3
8608
- });
8609
- };
8610
-
8611
- const useGetCountriesByCarrier = (carrierId) => {
8612
- const { client } = useShipEngine();
8613
- return useQuery({
8614
- enabled: !!carrierId,
8615
- onError,
8616
- queryFn: () => {
8617
- if (carrierId)
8618
- return client.carriers.getCountries(carrierId);
8619
- return Promise.reject(new Error("carrierId is require"));
8620
- },
8621
- queryKey: ["useGetCountriesByCarrier", carrierId],
8622
- select: (result) => result.data.countries,
8623
- // Fresh for 5 minutes
8624
- staleTime: 5 * 60 * 1e3
8625
- });
8626
- };
8627
-
8628
- const useGetCurrenciesByCarrier = (carrierId) => {
8629
- const { client } = useShipEngine();
8630
- return useQuery({
8631
- enabled: !!carrierId,
8632
- onError,
8633
- queryFn: () => {
8634
- if (carrierId)
8635
- return client.carriers.getCurrencies(carrierId);
8636
- return Promise.reject(new Error("carrierId is require"));
8637
- },
8638
- queryKey: ["useGetCurrenciesByCarrier", carrierId],
8639
- select: (result) => result.data.currencies,
8640
- // Fresh for 5 minutes
8641
- staleTime: 5 * 60 * 1e3
8642
- });
8643
- };
8644
-
8645
- const useGetFundingSourceById = (fundingSourceId) => {
8646
- const { client } = useShipEngine();
8647
- return useQuery({
8648
- onError,
8649
- queryFn: () => client.fundingSources.get(fundingSourceId),
8650
- queryKey: ["getFundingSourceById"],
8651
- select: (result) => result.data
8652
- });
8653
- };
8654
-
8655
8642
  const useGetInsuranceAccount = (insuranceProvider) => {
8656
8643
  const { client } = useShipEngine();
8657
8644
  return useQuery({
@@ -8667,288 +8654,122 @@ const useGetInsuranceAccount = (insuranceProvider) => {
8667
8654
  });
8668
8655
  };
8669
8656
 
8670
- const useGetLabel = (labelId) => {
8671
- const { client } = useShipEngine();
8672
- return useQuery({
8673
- enabled: labelId !== void 0,
8674
- onError,
8675
- queryFn: () => {
8676
- if (labelId)
8677
- return client.labels.get(labelId);
8678
- return Promise.reject(new Error("labelId is require"));
8679
- },
8680
- queryKey: ["useGetLabel", labelId],
8681
- select: (result) => result.data
8682
- });
8683
- };
8684
-
8685
- const useGetRateCardById = (rateCardId) => {
8686
- const { client } = useShipEngine();
8687
- return useQuery({
8688
- enabled: !!rateCardId,
8689
- onError,
8690
- queryFn: () => {
8691
- return client.rateCards.get(rateCardId);
8692
- },
8693
- queryKey: ["useGetRateCardById", rateCardId],
8694
- select: (result) => result.data
8695
- });
8696
- };
8697
-
8698
- const useGetPackageRatingGroupByCarrier = (carrierId) => {
8699
- const { client } = useShipEngine();
8700
- return useQuery({
8701
- enabled: !!carrierId,
8702
- onError,
8703
- queryFn: () => {
8704
- if (carrierId)
8705
- return client.carriers.getPackageRatingGroup(carrierId);
8706
- return Promise.reject(new Error("carrierId is required"));
8707
- },
8708
- queryKey: ["useGetRatePackageFormatsByCarrier", carrierId],
8709
- select: (result) => result.data.packageRatingGroup,
8710
- // Fresh for 5 minutes
8711
- staleTime: 5 * 60 * 1e3
8712
- });
8713
- };
8714
-
8715
- const useGetSalesOrderShipment = (shipmentId) => {
8716
- const { client } = useShipEngine();
8717
- return useQuery({
8718
- enabled: shipmentId !== void 0,
8719
- onError,
8720
- queryFn: () => {
8721
- if (shipmentId)
8722
- return client.salesOrderShipments.get(shipmentId);
8723
- return Promise.reject(new Error("shipmentId is required"));
8724
- },
8725
- queryKey: ["useGetSalesOrderShipment", shipmentId],
8726
- select: (result) => result.data
8727
- });
8728
- };
8729
-
8730
- const useGetSalesOrder = (salesOrderId) => {
8731
- const { client } = useShipEngine();
8732
- return useQuery({
8733
- enabled: salesOrderId !== void 0,
8734
- onError,
8735
- queryFn: () => {
8736
- if (salesOrderId)
8737
- return client.salesOrders.get(salesOrderId);
8738
- return Promise.reject(new Error("salesOrderId is required"));
8739
- },
8740
- queryKey: ["useGetSalesOrder", salesOrderId],
8741
- select: (result) => result.data
8742
- });
8743
- };
8744
-
8745
- const useGetServicesByCarrier = (carrierId) => {
8746
- const { client } = useShipEngine();
8747
- return useQuery({
8748
- enabled: !!carrierId,
8749
- onError,
8750
- queryFn: () => {
8751
- if (carrierId)
8752
- return client.carriers.getServices(carrierId);
8753
- return Promise.reject(new Error("carrierId is required"));
8754
- },
8755
- queryKey: ["useGetServicesByCarrier", carrierId],
8756
- select: (result) => result.data.services,
8757
- // Fresh for 5 minutes
8758
- staleTime: 5 * 60 * 1e3
8759
- });
8760
- };
8761
-
8762
- const useGetShipmentRates = (shipmentId, createdAtStart) => {
8763
- const { client } = useShipEngine();
8764
- return useQuery({
8765
- enabled: shipmentId !== void 0,
8766
- onError,
8767
- queryFn: () => {
8768
- if (shipmentId) {
8769
- return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
8770
- }
8771
- return Promise.reject(new Error("shipmentId is required"));
8772
- },
8773
- queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
8774
- select: (result) => result.data
8775
- });
8776
- };
8777
-
8778
- const useGetShipment = (shipmentId) => {
8779
- const { client } = useShipEngine();
8780
- return useQuery({
8781
- enabled: shipmentId !== void 0,
8782
- onError,
8783
- queryFn: () => {
8784
- if (!shipmentId) {
8785
- return Promise.reject(new Error("shipmentId is required"));
8786
- }
8787
- return client.salesOrderShipments.get(shipmentId);
8788
- },
8789
- queryKey: ["useGetShipment", shipmentId],
8790
- select: (result) => result.data
8791
- });
8792
- };
8793
-
8794
- const useGetWalletHistory = ({
8795
- enabled,
8796
- page,
8797
- range
8798
- }) => {
8799
- const { client } = useShipEngine();
8800
- const [startDate, endDate] = range;
8801
- return useQuery({
8802
- enabled,
8803
- keepPreviousData: true,
8804
- // See https://react-query-v3.tanstack.com/guides/paginated-queries#better-paginated-queries-with-keeppreviousdata
8805
- onError,
8806
- queryFn: () => client.carriers.getWalletHistory(startDate, endDate, page),
8807
- queryKey: ["useGetWalletHistory", startDate, endDate, page],
8808
- select: (result) => result.data
8809
- });
8810
- };
8811
-
8812
- const useListCarriers = () => {
8813
- const { client } = useShipEngine();
8814
- return useQuery({
8815
- onError,
8816
- queryFn: () => client.carriers.list(),
8817
- queryKey: ["useListCarriers"],
8818
- select: (result) => result.data.carriers
8819
- });
8820
- };
8821
-
8822
- const useListCustomPackageTypes = () => {
8823
- const { client } = useShipEngine();
8824
- return useQuery({
8825
- onError,
8826
- queryFn: () => client.customPackages.list(),
8827
- queryKey: ["useListCustomPackageTypes"],
8828
- select: (result) => result.data.packages
8829
- });
8830
- };
8831
-
8832
- const useListFundingSources = () => {
8833
- const { client } = useShipEngine();
8834
- return useQuery({
8835
- onError,
8836
- queryFn: () => client.fundingSources.list(),
8837
- queryKey: ["useListFundingSources"],
8838
- select: (result) => result.data.fundingSources
8839
- });
8840
- };
8841
-
8842
- const useListLabels = (params) => {
8843
- const { client } = useShipEngine();
8844
- return useQuery({
8845
- enabled: params && Object.values(params).some((v) => v !== void 0),
8846
- onError,
8847
- queryFn: () => client.labels.list(params),
8848
- queryKey: ["useListLabels", params],
8849
- select: (result) => result.data.labels
8657
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
8658
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
8659
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
8660
+ var __objRest$6 = (source, exclude) => {
8661
+ var target = {};
8662
+ for (var prop in source)
8663
+ if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
8664
+ target[prop] = source[prop];
8665
+ if (source != null && __getOwnPropSymbols$9)
8666
+ for (var prop of __getOwnPropSymbols$9(source)) {
8667
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
8668
+ target[prop] = source[prop];
8669
+ }
8670
+ return target;
8671
+ };
8672
+ var __async$i = (__this, __arguments, generator) => {
8673
+ return new Promise((resolve, reject) => {
8674
+ var fulfilled = (value) => {
8675
+ try {
8676
+ step(generator.next(value));
8677
+ } catch (e) {
8678
+ reject(e);
8679
+ }
8680
+ };
8681
+ var rejected = (value) => {
8682
+ try {
8683
+ step(generator.throw(value));
8684
+ } catch (e) {
8685
+ reject(e);
8686
+ }
8687
+ };
8688
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
8689
+ step((generator = generator.apply(__this, __arguments)).next());
8850
8690
  });
8851
8691
  };
8852
-
8853
- const useListOrderSources = () => {
8692
+ const useCreateLabel = () => {
8854
8693
  const { client } = useShipEngine();
8855
- return useQuery({
8856
- onError,
8857
- queryFn: () => client.orderSources.list(),
8858
- queryKey: ["useListOrderSources"],
8859
- select: (result) => result.data.orderSources
8694
+ return useMutation({
8695
+ mutationFn: (_a) => __async$i(void 0, null, function* () {
8696
+ var _b = _a, { rateId } = _b, options = __objRest$6(_b, ["rateId"]);
8697
+ const result = yield client.labels.createByRateId(rateId, options);
8698
+ return result.data;
8699
+ }),
8700
+ mutationKey: ["useCreateLabel"],
8701
+ onError
8860
8702
  });
8861
8703
  };
8862
8704
 
8863
- const useListRateCards = (carrierIds) => {
8705
+ const useGetLabel = (labelId) => {
8864
8706
  const { client } = useShipEngine();
8865
8707
  return useQuery({
8866
- enabled: !!carrierIds.length,
8708
+ enabled: labelId !== void 0,
8867
8709
  onError,
8868
8710
  queryFn: () => {
8869
- return client.rateCards.list(carrierIds);
8711
+ if (labelId)
8712
+ return client.labels.get(labelId);
8713
+ return Promise.reject(new Error("labelId is require"));
8870
8714
  },
8871
- queryKey: ["useListRateCards", carrierIds],
8872
- select: (result) => result.data.rateCards
8715
+ queryKey: ["useGetLabel", labelId],
8716
+ select: (result) => result.data
8873
8717
  });
8874
8718
  };
8875
8719
 
8876
- const useListSalesOrderShipments = (params) => {
8720
+ const useListLabels = (params) => {
8877
8721
  const { client } = useShipEngine();
8878
8722
  return useQuery({
8879
8723
  enabled: params && Object.values(params).some((v) => v !== void 0),
8880
8724
  onError,
8881
- queryFn: () => client.salesOrderShipments.list(params),
8882
- queryKey: ["useListSalesOrderShipments", params],
8883
- select: (result) => result.data.shipments
8725
+ queryFn: () => client.labels.list(params),
8726
+ queryKey: ["useListLabels", params],
8727
+ select: (result) => result.data.labels
8884
8728
  });
8885
8729
  };
8886
8730
 
8887
- const useListSalesOrders = (params = {}) => {
8888
- const { client } = useShipEngine();
8889
- return useQuery({
8890
- enabled: params && Object.values(params).some((v) => v !== void 0),
8891
- onError,
8892
- queryFn: () => client.salesOrders.list(params),
8893
- queryKey: ["useListSalesOrders", params],
8894
- select: (result) => result.data.salesOrders
8731
+ var __async$h = (__this, __arguments, generator) => {
8732
+ return new Promise((resolve, reject) => {
8733
+ var fulfilled = (value) => {
8734
+ try {
8735
+ step(generator.next(value));
8736
+ } catch (e) {
8737
+ reject(e);
8738
+ }
8739
+ };
8740
+ var rejected = (value) => {
8741
+ try {
8742
+ step(generator.throw(value));
8743
+ } catch (e) {
8744
+ reject(e);
8745
+ }
8746
+ };
8747
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
8748
+ step((generator = generator.apply(__this, __arguments)).next());
8895
8749
  });
8896
8750
  };
8897
-
8898
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
8899
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
8900
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
8901
- var __objRest$4 = (source, exclude) => {
8902
- var target = {};
8903
- for (var prop in source)
8904
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
8905
- target[prop] = source[prop];
8906
- if (source != null && __getOwnPropSymbols$6)
8907
- for (var prop of __getOwnPropSymbols$6(source)) {
8908
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
8909
- target[prop] = source[prop];
8910
- }
8911
- return target;
8912
- };
8913
- const useListShipments = (_params) => {
8914
- const _a = _params || {}, { enabled = true } = _a, params = __objRest$4(_a, ["enabled"]);
8751
+ const useVoidLabel = () => {
8915
8752
  const { client } = useShipEngine();
8916
- return useQuery({
8917
- enabled,
8918
- onError,
8919
- queryFn: () => client.shipments.list(params),
8920
- queryKey: ["useListShipments", params],
8921
- select: (result) => result.data
8753
+ return useMutation({
8754
+ mutationFn: (labelId) => __async$h(void 0, null, function* () {
8755
+ const result = yield client.labels.void(labelId);
8756
+ return result.data;
8757
+ }),
8758
+ mutationKey: ["useVoidLabel"],
8759
+ onError
8922
8760
  });
8923
8761
  };
8924
8762
 
8925
- const useListWarehouses = (options) => {
8926
- var _a;
8763
+ const useListOrderSources = () => {
8927
8764
  const { client } = useShipEngine();
8928
8765
  return useQuery({
8929
- enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
8930
8766
  onError,
8931
- queryFn: () => client.warehouses.list(),
8932
- queryKey: ["useListWarehouses"],
8933
- select: (result) => result.data.warehouses
8767
+ queryFn: () => client.orderSources.list(),
8768
+ queryKey: ["useListOrderSources"],
8769
+ select: (result) => result.data.orderSources
8934
8770
  });
8935
8771
  };
8936
8772
 
8937
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
8938
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
8939
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
8940
- var __objRest$3 = (source, exclude) => {
8941
- var target = {};
8942
- for (var prop in source)
8943
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
8944
- target[prop] = source[prop];
8945
- if (source != null && __getOwnPropSymbols$5)
8946
- for (var prop of __getOwnPropSymbols$5(source)) {
8947
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
8948
- target[prop] = source[prop];
8949
- }
8950
- return target;
8951
- };
8952
8773
  var __async$g = (__this, __arguments, generator) => {
8953
8774
  return new Promise((resolve, reject) => {
8954
8775
  var fulfilled = (value) => {
@@ -8969,15 +8790,32 @@ var __async$g = (__this, __arguments, generator) => {
8969
8790
  step((generator = generator.apply(__this, __arguments)).next());
8970
8791
  });
8971
8792
  };
8972
- const useNotifySalesOrderShipped = () => {
8793
+ const useRefreshOrderSourceAsync = () => {
8973
8794
  const { client } = useShipEngine();
8974
8795
  return useMutation({
8975
- mutationFn: (_a) => __async$g(void 0, null, function* () {
8976
- var _b = _a, { salesOrderId } = _b, tracking = __objRest$3(_b, ["salesOrderId"]);
8977
- const result = yield client.salesOrders.notifyShipped(salesOrderId, tracking);
8796
+ mutationFn: (orderSourceId) => __async$g(void 0, null, function* () {
8797
+ const result = yield client.orderSources.refresh(orderSourceId);
8978
8798
  return result.data;
8979
8799
  }),
8980
- mutationKey: ["useNotifySalesOrder"],
8800
+ mutationKey: ["useRefreshOrderSourceAsync"]
8801
+ });
8802
+ };
8803
+ const useRefreshOrderSource = () => {
8804
+ const { client } = useShipEngine();
8805
+ const { mutateAsync: refreshOrderSourceAsync } = useRefreshOrderSourceAsync();
8806
+ return useMutation({
8807
+ mutationFn: (orderSourceId) => __async$g(void 0, null, function* () {
8808
+ yield refreshOrderSourceAsync(orderSourceId);
8809
+ const waitResult = yield retryUntil(() => __async$g(void 0, null, function* () {
8810
+ const { data: checkResult } = yield client.orderSources.get(orderSourceId);
8811
+ if (["preparing_update", "updating"].includes(checkResult.refreshInfo.status)) {
8812
+ throw new CodedError("Order source is still refreshing");
8813
+ }
8814
+ return checkResult;
8815
+ }), 20);
8816
+ return waitResult;
8817
+ }),
8818
+ mutationKey: ["useRefreshOrderSource"],
8981
8819
  onError
8982
8820
  });
8983
8821
  };
@@ -9002,18 +8840,56 @@ var __async$f = (__this, __arguments, generator) => {
9002
8840
  step((generator = generator.apply(__this, __arguments)).next());
9003
8841
  });
9004
8842
  };
9005
- const useParseAddress = () => {
8843
+ const useCreateRateCard = () => {
9006
8844
  const { client } = useShipEngine();
9007
8845
  return useMutation({
9008
- mutationFn: (_0) => __async$f(void 0, [_0], function* ({ address, text }) {
9009
- const result = yield client.addresses.parse(text, address);
8846
+ mutationFn: (rateCard) => __async$f(void 0, null, function* () {
8847
+ const result = yield client.rateCards.create(rateCard);
9010
8848
  return result.data;
9011
8849
  }),
9012
- mutationKey: ["useParseAddress"],
8850
+ mutationKey: ["useCreateRateCard"],
9013
8851
  onError
9014
8852
  });
9015
8853
  };
9016
8854
 
8855
+ const useDownloadRateCard = (rateCardId) => {
8856
+ const { client } = useShipEngine();
8857
+ return useQuery({
8858
+ enabled: !!rateCardId.length,
8859
+ onError,
8860
+ queryFn: () => {
8861
+ return client.rateCards.download(rateCardId);
8862
+ },
8863
+ queryKey: ["useDownloadRateCard", rateCardId]
8864
+ });
8865
+ };
8866
+
8867
+ const useGetRateCardById = (rateCardId) => {
8868
+ const { client } = useShipEngine();
8869
+ return useQuery({
8870
+ enabled: !!rateCardId,
8871
+ onError,
8872
+ queryFn: () => {
8873
+ return client.rateCards.get(rateCardId);
8874
+ },
8875
+ queryKey: ["useGetRateCardById", rateCardId],
8876
+ select: (result) => result.data
8877
+ });
8878
+ };
8879
+
8880
+ const useListRateCards = (carrierIds) => {
8881
+ const { client } = useShipEngine();
8882
+ return useQuery({
8883
+ enabled: !!carrierIds.length,
8884
+ onError,
8885
+ queryFn: () => {
8886
+ return client.rateCards.list(carrierIds);
8887
+ },
8888
+ queryKey: ["useListRateCards", carrierIds],
8889
+ select: (result) => result.data.rateCards
8890
+ });
8891
+ };
8892
+
9017
8893
  var __async$e = (__this, __arguments, generator) => {
9018
8894
  return new Promise((resolve, reject) => {
9019
8895
  var fulfilled = (value) => {
@@ -9065,32 +8941,14 @@ var __async$d = (__this, __arguments, generator) => {
9065
8941
  step((generator = generator.apply(__this, __arguments)).next());
9066
8942
  });
9067
8943
  };
9068
- const useRefreshOrderSourceAsync = () => {
8944
+ const useUpdateRateCard = () => {
9069
8945
  const { client } = useShipEngine();
9070
8946
  return useMutation({
9071
- mutationFn: (orderSourceId) => __async$d(void 0, null, function* () {
9072
- const result = yield client.orderSources.refresh(orderSourceId);
8947
+ mutationFn: (rateCard) => __async$d(void 0, null, function* () {
8948
+ const result = yield client.rateCards.update(rateCard);
9073
8949
  return result.data;
9074
8950
  }),
9075
- mutationKey: ["useRefreshOrderSourceAsync"]
9076
- });
9077
- };
9078
- const useRefreshOrderSource = () => {
9079
- const { client } = useShipEngine();
9080
- const { mutateAsync: refreshOrderSourceAsync } = useRefreshOrderSourceAsync();
9081
- return useMutation({
9082
- mutationFn: (orderSourceId) => __async$d(void 0, null, function* () {
9083
- yield refreshOrderSourceAsync(orderSourceId);
9084
- const waitResult = yield retryUntil(() => __async$d(void 0, null, function* () {
9085
- const { data: checkResult } = yield client.orderSources.get(orderSourceId);
9086
- if (["preparing_update", "updating"].includes(checkResult.refreshInfo.status)) {
9087
- throw new CodedError("Order source is still refreshing");
9088
- }
9089
- return checkResult;
9090
- }), 20);
9091
- return waitResult;
9092
- }),
9093
- mutationKey: ["useRefreshOrderSource"],
8951
+ mutationKey: ["useUpdateRateCard"],
9094
8952
  onError
9095
8953
  });
9096
8954
  };
@@ -9115,14 +8973,14 @@ var __async$c = (__this, __arguments, generator) => {
9115
8973
  step((generator = generator.apply(__this, __arguments)).next());
9116
8974
  });
9117
8975
  };
9118
- const useRegisterCarrier = () => {
8976
+ const useUploadRateCard = () => {
9119
8977
  const { client } = useShipEngine();
9120
8978
  return useMutation({
9121
- mutationFn: (carrier) => __async$c(void 0, null, function* () {
9122
- const result = yield client.fundingSources.registerCarrier(carrier);
8979
+ mutationFn: (_0) => __async$c(void 0, [_0], function* ({ rateCardId, file }) {
8980
+ const result = yield client.rateCards.upload(rateCardId, file);
9123
8981
  return result.data;
9124
8982
  }),
9125
- mutationKey: ["useRegisterCarrier"],
8983
+ mutationKey: ["useUploadRateCard"],
9126
8984
  onError
9127
8985
  });
9128
8986
  };
@@ -9147,14 +9005,14 @@ var __async$b = (__this, __arguments, generator) => {
9147
9005
  step((generator = generator.apply(__this, __arguments)).next());
9148
9006
  });
9149
9007
  };
9150
- const useUpdateAccountSettings = () => {
9008
+ const useDeleteRateCard = () => {
9151
9009
  const { client } = useShipEngine();
9152
9010
  return useMutation({
9153
- mutationFn: (settings) => __async$b(void 0, null, function* () {
9154
- const result = yield client.accountSettings.update(settings);
9011
+ mutationFn: (rateCardId) => __async$b(void 0, null, function* () {
9012
+ const result = yield client.rateCards.delete(rateCardId);
9155
9013
  return result.data;
9156
9014
  }),
9157
- mutationKey: ["useUpdateAccountSettings"],
9015
+ mutationKey: ["useDeleteRateCard"],
9158
9016
  onError
9159
9017
  });
9160
9018
  };
@@ -9179,22 +9037,59 @@ var __async$a = (__this, __arguments, generator) => {
9179
9037
  step((generator = generator.apply(__this, __arguments)).next());
9180
9038
  });
9181
9039
  };
9182
- const useUpdateAutoFunding = (carrierId) => {
9040
+ const useCalculateRates = () => {
9183
9041
  const { client } = useShipEngine();
9184
- const queryClient = useQueryClient();
9185
9042
  return useMutation({
9186
- mutationFn: (options) => __async$a(void 0, null, function* () {
9187
- const result = yield client.carriers.updateAutoFunding(carrierId, options);
9043
+ mutationFn: (_0) => __async$a(void 0, [_0], function* ({ rateOptions, shipmentId }) {
9044
+ const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
9188
9045
  return result.data;
9189
9046
  }),
9190
- mutationKey: ["useUpdateAutoFunding"],
9047
+ mutationKey: ["useCalculateRates"],
9048
+ onError
9049
+ });
9050
+ };
9051
+
9052
+ const useGetSalesOrder = (salesOrderId) => {
9053
+ const { client } = useShipEngine();
9054
+ return useQuery({
9055
+ enabled: salesOrderId !== void 0,
9056
+ onError,
9057
+ queryFn: () => {
9058
+ if (salesOrderId)
9059
+ return client.salesOrders.get(salesOrderId);
9060
+ return Promise.reject(new Error("salesOrderId is required"));
9061
+ },
9062
+ queryKey: ["useGetSalesOrder", salesOrderId],
9063
+ select: (result) => result.data
9064
+ });
9065
+ };
9066
+
9067
+ const useListSalesOrders = (params = {}) => {
9068
+ const { client } = useShipEngine();
9069
+ return useQuery({
9070
+ enabled: params && Object.values(params).some((v) => v !== void 0),
9191
9071
  onError,
9192
- onSuccess: (_) => {
9193
- queryClient.invalidateQueries(["useGetAutoFunding", carrierId], { exact: true });
9194
- }
9072
+ queryFn: () => client.salesOrders.list(params),
9073
+ queryKey: ["useListSalesOrders", params],
9074
+ select: (result) => result.data.salesOrders
9195
9075
  });
9196
9076
  };
9197
9077
 
9078
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
9079
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
9080
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
9081
+ var __objRest$5 = (source, exclude) => {
9082
+ var target = {};
9083
+ for (var prop in source)
9084
+ if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
9085
+ target[prop] = source[prop];
9086
+ if (source != null && __getOwnPropSymbols$8)
9087
+ for (var prop of __getOwnPropSymbols$8(source)) {
9088
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
9089
+ target[prop] = source[prop];
9090
+ }
9091
+ return target;
9092
+ };
9198
9093
  var __async$9 = (__this, __arguments, generator) => {
9199
9094
  return new Promise((resolve, reject) => {
9200
9095
  var fulfilled = (value) => {
@@ -9215,26 +9110,34 @@ var __async$9 = (__this, __arguments, generator) => {
9215
9110
  step((generator = generator.apply(__this, __arguments)).next());
9216
9111
  });
9217
9112
  };
9218
- const useUpdateFundingSource = () => {
9113
+ const useNotifySalesOrderShipped = () => {
9219
9114
  const { client } = useShipEngine();
9220
9115
  return useMutation({
9221
- mutationFn: (_0) => __async$9(void 0, [_0], function* ({
9222
- billingInfo,
9223
- creditCardInfo,
9224
- fundingSourceId
9225
- }) {
9226
- const result = yield client.fundingSources.update(
9227
- billingInfo,
9228
- creditCardInfo,
9229
- fundingSourceId
9230
- );
9116
+ mutationFn: (_a) => __async$9(void 0, null, function* () {
9117
+ var _b = _a, { salesOrderId } = _b, tracking = __objRest$5(_b, ["salesOrderId"]);
9118
+ const result = yield client.salesOrders.notifyShipped(salesOrderId, tracking);
9231
9119
  return result.data;
9232
9120
  }),
9233
- mutationKey: ["useUpdateFundingSource"],
9121
+ mutationKey: ["useNotifySalesOrder"],
9234
9122
  onError
9235
9123
  });
9236
9124
  };
9237
9125
 
9126
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
9127
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
9128
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
9129
+ var __objRest$4 = (source, exclude) => {
9130
+ var target = {};
9131
+ for (var prop in source)
9132
+ if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
9133
+ target[prop] = source[prop];
9134
+ if (source != null && __getOwnPropSymbols$7)
9135
+ for (var prop of __getOwnPropSymbols$7(source)) {
9136
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
9137
+ target[prop] = source[prop];
9138
+ }
9139
+ return target;
9140
+ };
9238
9141
  var __async$8 = (__this, __arguments, generator) => {
9239
9142
  return new Promise((resolve, reject) => {
9240
9143
  var fulfilled = (value) => {
@@ -9255,29 +9158,56 @@ var __async$8 = (__this, __arguments, generator) => {
9255
9158
  step((generator = generator.apply(__this, __arguments)).next());
9256
9159
  });
9257
9160
  };
9258
- const useUpdateRateCard = () => {
9161
+ const useCreateSalesOrderShipment = () => {
9259
9162
  const { client } = useShipEngine();
9260
9163
  return useMutation({
9261
- mutationFn: (rateCard) => __async$8(void 0, null, function* () {
9262
- const result = yield client.rateCards.update(rateCard);
9164
+ mutationFn: (_a) => __async$8(void 0, null, function* () {
9165
+ var _b = _a, { salesOrderId } = _b, shipment = __objRest$4(_b, ["salesOrderId"]);
9166
+ const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
9263
9167
  return result.data;
9264
9168
  }),
9265
- mutationKey: ["useUpdateRateCard"],
9169
+ mutationKey: ["useCreateSalesOrderShipment"],
9266
9170
  onError
9267
9171
  });
9268
9172
  };
9269
9173
 
9270
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
9271
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
9272
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
9273
- var __objRest$2 = (source, exclude) => {
9174
+ const useGetSalesOrderShipment = (shipmentId) => {
9175
+ const { client } = useShipEngine();
9176
+ return useQuery({
9177
+ enabled: shipmentId !== void 0,
9178
+ onError,
9179
+ queryFn: () => {
9180
+ if (shipmentId)
9181
+ return client.salesOrderShipments.get(shipmentId);
9182
+ return Promise.reject(new Error("shipmentId is required"));
9183
+ },
9184
+ queryKey: ["useGetSalesOrderShipment", shipmentId],
9185
+ select: (result) => result.data
9186
+ });
9187
+ };
9188
+
9189
+ const useListSalesOrderShipments = (params) => {
9190
+ const { client } = useShipEngine();
9191
+ return useQuery({
9192
+ enabled: params && Object.values(params).some((v) => v !== void 0),
9193
+ onError,
9194
+ queryFn: () => client.salesOrderShipments.list(params),
9195
+ queryKey: ["useListSalesOrderShipments", params],
9196
+ select: (result) => result.data.shipments
9197
+ });
9198
+ };
9199
+
9200
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
9201
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
9202
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
9203
+ var __objRest$3 = (source, exclude) => {
9274
9204
  var target = {};
9275
9205
  for (var prop in source)
9276
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
9206
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
9277
9207
  target[prop] = source[prop];
9278
- if (source != null && __getOwnPropSymbols$4)
9279
- for (var prop of __getOwnPropSymbols$4(source)) {
9280
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
9208
+ if (source != null && __getOwnPropSymbols$6)
9209
+ for (var prop of __getOwnPropSymbols$6(source)) {
9210
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
9281
9211
  target[prop] = source[prop];
9282
9212
  }
9283
9213
  return target;
@@ -9306,7 +9236,7 @@ const useUpdateSalesOrderShipment = () => {
9306
9236
  const { client } = useShipEngine();
9307
9237
  return useMutation({
9308
9238
  mutationFn: (_a) => __async$7(void 0, null, function* () {
9309
- var _b = _a, { shipmentId } = _b, shipment = __objRest$2(_b, ["shipmentId"]);
9239
+ var _b = _a, { shipmentId } = _b, shipment = __objRest$3(_b, ["shipmentId"]);
9310
9240
  const result = yield client.salesOrderShipments.update(shipmentId, shipment);
9311
9241
  return result.data;
9312
9242
  }),
@@ -9315,21 +9245,25 @@ const useUpdateSalesOrderShipment = () => {
9315
9245
  });
9316
9246
  };
9317
9247
 
9318
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
9319
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
9320
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
9321
- var __objRest$1 = (source, exclude) => {
9322
- var target = {};
9323
- for (var prop in source)
9324
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
9325
- target[prop] = source[prop];
9326
- if (source != null && __getOwnPropSymbols$3)
9327
- for (var prop of __getOwnPropSymbols$3(source)) {
9328
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
9329
- target[prop] = source[prop];
9248
+ var __defProp$3 = Object.defineProperty;
9249
+ var __defProps$2 = Object.defineProperties;
9250
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
9251
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
9252
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
9253
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
9254
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9255
+ var __spreadValues$3 = (a, b) => {
9256
+ for (var prop in b || (b = {}))
9257
+ if (__hasOwnProp$5.call(b, prop))
9258
+ __defNormalProp$3(a, prop, b[prop]);
9259
+ if (__getOwnPropSymbols$5)
9260
+ for (var prop of __getOwnPropSymbols$5(b)) {
9261
+ if (__propIsEnum$5.call(b, prop))
9262
+ __defNormalProp$3(a, prop, b[prop]);
9330
9263
  }
9331
- return target;
9264
+ return a;
9332
9265
  };
9266
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
9333
9267
  var __async$6 = (__this, __arguments, generator) => {
9334
9268
  return new Promise((resolve, reject) => {
9335
9269
  var fulfilled = (value) => {
@@ -9350,19 +9284,95 @@ var __async$6 = (__this, __arguments, generator) => {
9350
9284
  step((generator = generator.apply(__this, __arguments)).next());
9351
9285
  });
9352
9286
  };
9353
- const useUpdateWarehouse = () => {
9287
+ const useCreateShipment = () => {
9354
9288
  const { client } = useShipEngine();
9355
9289
  return useMutation({
9356
- mutationFn: (_a) => __async$6(void 0, null, function* () {
9357
- var _b = _a, { warehouseId } = _b, warehouse = __objRest$1(_b, ["warehouseId"]);
9358
- const result = yield client.warehouses.update(warehouseId, warehouse);
9359
- return result.data;
9290
+ mutationFn: (shipment) => __async$6(void 0, null, function* () {
9291
+ var _a;
9292
+ if (shipment.warehouseId === void 0) {
9293
+ throw new CodedError("errorMessages.noWarehouses", {
9294
+ errorCode: "unknown",
9295
+ errorSource: "client",
9296
+ errorType: "business_rules"
9297
+ });
9298
+ }
9299
+ const shipTo = (_a = shipment.shipTo) != null ? _a : {
9300
+ addressLine1: "",
9301
+ cityLocality: "",
9302
+ countryCode: "",
9303
+ name: "",
9304
+ phone: "",
9305
+ postalCode: "",
9306
+ stateProvince: ""
9307
+ };
9308
+ return (yield client.shipments.create(__spreadProps$2(__spreadValues$3({}, shipment), {
9309
+ shipTo
9310
+ }))).data;
9360
9311
  }),
9361
- mutationKey: ["useUpdateWarehouse"],
9312
+ mutationKey: ["useCreateShipment"],
9362
9313
  onError
9363
9314
  });
9364
9315
  };
9365
9316
 
9317
+ const useGetShipmentRates = (shipmentId, createdAtStart) => {
9318
+ const { client } = useShipEngine();
9319
+ return useQuery({
9320
+ enabled: shipmentId !== void 0,
9321
+ onError,
9322
+ queryFn: () => {
9323
+ if (shipmentId) {
9324
+ return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
9325
+ }
9326
+ return Promise.reject(new Error("shipmentId is required"));
9327
+ },
9328
+ queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
9329
+ select: (result) => result.data
9330
+ });
9331
+ };
9332
+
9333
+ const useGetShipment = (shipmentId) => {
9334
+ const { client } = useShipEngine();
9335
+ return useQuery({
9336
+ enabled: shipmentId !== void 0,
9337
+ onError,
9338
+ queryFn: () => {
9339
+ if (!shipmentId) {
9340
+ return Promise.reject(new Error("shipmentId is required"));
9341
+ }
9342
+ return client.salesOrderShipments.get(shipmentId);
9343
+ },
9344
+ queryKey: ["useGetShipment", shipmentId],
9345
+ select: (result) => result.data
9346
+ });
9347
+ };
9348
+
9349
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
9350
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
9351
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
9352
+ var __objRest$2 = (source, exclude) => {
9353
+ var target = {};
9354
+ for (var prop in source)
9355
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
9356
+ target[prop] = source[prop];
9357
+ if (source != null && __getOwnPropSymbols$4)
9358
+ for (var prop of __getOwnPropSymbols$4(source)) {
9359
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
9360
+ target[prop] = source[prop];
9361
+ }
9362
+ return target;
9363
+ };
9364
+ const useListShipments = (_params) => {
9365
+ const _a = _params || {}, { enabled = true } = _a, params = __objRest$2(_a, ["enabled"]);
9366
+ const { client } = useShipEngine();
9367
+ return useQuery({
9368
+ enabled,
9369
+ onError,
9370
+ queryFn: () => client.shipments.list(params),
9371
+ queryKey: ["useListShipments", params],
9372
+ select: (result) => result.data
9373
+ });
9374
+ };
9375
+
9366
9376
  var __async$5 = (__this, __arguments, generator) => {
9367
9377
  return new Promise((resolve, reject) => {
9368
9378
  var fulfilled = (value) => {
@@ -9383,14 +9393,14 @@ var __async$5 = (__this, __arguments, generator) => {
9383
9393
  step((generator = generator.apply(__this, __arguments)).next());
9384
9394
  });
9385
9395
  };
9386
- const useUploadRateCard = () => {
9396
+ const useCreateWarehouse = () => {
9387
9397
  const { client } = useShipEngine();
9388
9398
  return useMutation({
9389
- mutationFn: (_0) => __async$5(void 0, [_0], function* ({ rateCardId, file }) {
9390
- const result = yield client.rateCards.upload(rateCardId, file);
9399
+ mutationFn: (data) => __async$5(void 0, null, function* () {
9400
+ const result = yield client.warehouses.create(data);
9391
9401
  return result.data;
9392
9402
  }),
9393
- mutationKey: ["useUploadRateCard"],
9403
+ mutationKey: ["useCreateWarehouse"],
9394
9404
  onError
9395
9405
  });
9396
9406
  };
@@ -9415,18 +9425,45 @@ var __async$4 = (__this, __arguments, generator) => {
9415
9425
  step((generator = generator.apply(__this, __arguments)).next());
9416
9426
  });
9417
9427
  };
9418
- const useValidateAddresses = () => {
9428
+ const useDeleteWarehouse = () => {
9419
9429
  const { client } = useShipEngine();
9420
9430
  return useMutation({
9421
- mutationFn: (addresses) => __async$4(void 0, null, function* () {
9422
- const result = yield client.addresses.validate(addresses);
9431
+ mutationFn: (_0) => __async$4(void 0, [_0], function* ({ warehouseId }) {
9432
+ const result = yield client.warehouses.delete(warehouseId);
9423
9433
  return result.data;
9424
9434
  }),
9425
- mutationKey: ["useValidateAddresses"],
9435
+ mutationKey: ["useDeleteWarehouse"],
9426
9436
  onError
9427
9437
  });
9428
9438
  };
9429
9439
 
9440
+ const useListWarehouses = (options) => {
9441
+ var _a;
9442
+ const { client } = useShipEngine();
9443
+ return useQuery({
9444
+ enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
9445
+ onError,
9446
+ queryFn: () => client.warehouses.list(),
9447
+ queryKey: ["useListWarehouses"],
9448
+ select: (result) => result.data.warehouses
9449
+ });
9450
+ };
9451
+
9452
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
9453
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
9454
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
9455
+ var __objRest$1 = (source, exclude) => {
9456
+ var target = {};
9457
+ for (var prop in source)
9458
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
9459
+ target[prop] = source[prop];
9460
+ if (source != null && __getOwnPropSymbols$3)
9461
+ for (var prop of __getOwnPropSymbols$3(source)) {
9462
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
9463
+ target[prop] = source[prop];
9464
+ }
9465
+ return target;
9466
+ };
9430
9467
  var __async$3 = (__this, __arguments, generator) => {
9431
9468
  return new Promise((resolve, reject) => {
9432
9469
  var fulfilled = (value) => {
@@ -9447,14 +9484,15 @@ var __async$3 = (__this, __arguments, generator) => {
9447
9484
  step((generator = generator.apply(__this, __arguments)).next());
9448
9485
  });
9449
9486
  };
9450
- const useVoidLabel = () => {
9487
+ const useUpdateWarehouse = () => {
9451
9488
  const { client } = useShipEngine();
9452
9489
  return useMutation({
9453
- mutationFn: (labelId) => __async$3(void 0, null, function* () {
9454
- const result = yield client.labels.void(labelId);
9490
+ mutationFn: (_a) => __async$3(void 0, null, function* () {
9491
+ var _b = _a, { warehouseId } = _b, warehouse = __objRest$1(_b, ["warehouseId"]);
9492
+ const result = yield client.warehouses.update(warehouseId, warehouse);
9455
9493
  return result.data;
9456
9494
  }),
9457
- mutationKey: ["useVoidLabel"],
9495
+ mutationKey: ["useUpdateWarehouse"],
9458
9496
  onError
9459
9497
  });
9460
9498
  };
@@ -10309,4 +10347,4 @@ const alchemy = {
10309
10347
  createElement
10310
10348
  };
10311
10349
 
10312
- export { AccountSettingsAPI, AddressesAPI, AlchemyContext, AlchemyProvider, AlchemyTestProvider, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ElementContainerProvider, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, renderAlchemyProviders, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateRateCard, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteWarehouse, useDownloadRateCard, useElementContainer, useFundingSourcesAddFunds, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetCountriesByCarrier, useGetCurrenciesByCarrier, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetPackageRatingGroupByCarrier, useGetRateCardById, useGetSalesOrder, useGetSalesOrderShipment, useGetServicesByCarrier, useGetShipment, useGetShipmentRates, useGetWalletHistory, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListShipments, useListWarehouses, useLoadFonts, useLoadIcons, useLoadTheme, useNotifySalesOrderShipped, useParseAddress, usePublishRateCard, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateRateCard, useUpdateSalesOrderShipment, useUpdateWarehouse, useUploadRateCard, useValidateAddresses, useVoidLabel };
10350
+ export { AccountSettingsAPI, AddressesAPI, AlchemyContext, AlchemyProvider, AlchemyTestProvider, CarriersAPI, CodedError, ConfirmationType, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, Element, ElementContainerProvider, ErrorBoundary, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngine, ShipEngineAPI, ShipEngineContext, ShipmentsAPI, WarehousesAPI, alchemy, alchemy as default, delay, getEndUserIpAddress, isCodedError, isCodedErrors, logger, memoizedCreateCache, onError, renderAlchemyProviders, retryUntil, useAddFunds, useAlchemy, useCalculateRates, useConnectCarrier, useCreateFundingSource, useCreateLabel, useCreateRateCard, useCreateSalesOrderShipment, useCreateShipment, useCreateWarehouse, useDeleteRateCard, useDeleteWarehouse, useDownloadRateCard, useElementContainer, useFundingSourcesAddFunds, useGetAccountSettings, useGetAutoFundingConfiguration, useGetCarrierById, useGetCountriesByCarrier, useGetCurrenciesByCarrier, useGetFundingSourceById, useGetInsuranceAccount, useGetLabel, useGetPackageRatingGroupByCarrier, useGetRateCardById, useGetSalesOrder, useGetSalesOrderShipment, useGetServicesByCarrier, useGetShipment, useGetShipmentRates, useGetWalletHistory, useI18n, useListCarriers, useListCustomPackageTypes, useListFundingSources, useListLabels, useListOrderSources, useListRateCards, useListSalesOrderShipments, useListSalesOrders, useListShipments, useListWarehouses, useLoadFonts, useLoadIcons, useLoadTheme, useNotifySalesOrderShipped, useParseAddress, usePublishRateCard, useRefreshOrderSource, useRefreshOrderSourceAsync, useRegisterCarrier, useShipEngine, useUpdateAccountSettings, useUpdateAutoFunding, useUpdateFundingSource, useUpdateRateCard, useUpdateSalesOrderShipment, useUpdateWarehouse, useUploadRateCard, useValidateAddresses, useVoidLabel };