washday-sdk 0.0.178 → 0.0.180

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.
@@ -11,17 +11,22 @@ import { generateQueryParamsStr } from "../../utils/apiUtils";
11
11
  import axiosInstance from "../axiosInstance";
12
12
  const GET_SET_CUSTOMERS_APP = 'api/v2/washdayapp/customers';
13
13
  const GET_SET_CUSTOMERS = 'api/customer';
14
- export const getList = function (params) {
14
+ export const getList = function (params, options) {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
16
  try {
17
17
  const config = {
18
- headers: { Authorization: `Bearer ${this.apiToken}` }
18
+ headers: { Authorization: `Bearer ${this.apiToken}` },
19
+ signal: (options === null || options === void 0 ? void 0 : options.signal) || params.signal || undefined
19
20
  };
20
21
  const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
21
22
  return yield axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
22
23
  }
23
24
  catch (error) {
24
- console.error('Error fetching getStoreStaff:', error);
25
+ if (error instanceof Error && (error.name === 'AbortError' || error.name === 'CanceledError')) {
26
+ console.log('Request was cancelled');
27
+ throw new Error('Request cancelled');
28
+ }
29
+ console.error('Error fetching customers:', error);
25
30
  throw error;
26
31
  }
27
32
  });
@@ -13,11 +13,12 @@ const GET_SET_ORDER = 'api/v2/order';
13
13
  const GET_SET_ORDER_CFDI = 'api/v2/orders';
14
14
  const GET_HEADER_SUMMARY = 'api/orderHeaderSummary';
15
15
  const GET_SET_ORDER_CUSTOMERS_APP = 'api/v2/washdayapp/orders';
16
- export const getList = function (params) {
16
+ export const getList = function (params, options) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  try {
19
19
  const config = {
20
- headers: { Authorization: `Bearer ${this.apiToken}` }
20
+ headers: { Authorization: `Bearer ${this.apiToken}` },
21
+ signal: (options === null || options === void 0 ? void 0 : options.signal) || params.signal || undefined
21
22
  };
22
23
  const queryParams = generateQueryParamsStr([
23
24
  'store',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.178",
3
+ "version": "0.0.180",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,3 +1,4 @@
1
+ import { GenericAbortSignal } from "axios";
1
2
  import { WashdayClientInstance } from "../../interfaces/Api";
2
3
  import { ICustomer } from "../../interfaces/Customer";
3
4
  import { IOrderInfo } from "../../interfaces/Order";
@@ -15,15 +16,21 @@ export const getList = async function (this: WashdayClientInstance, params: {
15
16
  toDate?: string
16
17
  limit: string
17
18
  pageNum: string
18
- }): Promise<any> {
19
+ signal?: GenericAbortSignal
20
+ }, options?: { signal?: GenericAbortSignal }): Promise<any> {
19
21
  try {
20
22
  const config = {
21
- headers: { Authorization: `Bearer ${this.apiToken}` }
23
+ headers: { Authorization: `Bearer ${this.apiToken}` },
24
+ signal: options?.signal || params.signal || undefined
22
25
  };
23
26
  const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum'], params);
24
27
  return await axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
25
28
  } catch (error) {
26
- console.error('Error fetching getStoreStaff:', error);
29
+ if (error instanceof Error && (error.name === 'AbortError' || error.name === 'CanceledError')) {
30
+ console.log('Request was cancelled');
31
+ throw new Error('Request cancelled');
32
+ }
33
+ console.error('Error fetching customers:', error);
27
34
  throw error;
28
35
  }
29
36
  };
@@ -1,3 +1,4 @@
1
+ import { GenericAbortSignal } from "axios";
1
2
  import { WashdayClientInstance } from "../../interfaces/Api";
2
3
  import { IOrder } from "../../interfaces/Order";
3
4
  import { generateQueryParamsStr } from "../../utils/apiUtils";
@@ -28,11 +29,12 @@ export const getList = async function (this: WashdayClientInstance, params: {
28
29
  pickupToDate: string | undefined,
29
30
  deliveryFromDate: string | undefined,
30
31
  deliveryToDate: string | undefined,
31
-
32
- }): Promise<any> {
32
+ signal?: GenericAbortSignal
33
+ }, options?: { signal?: GenericAbortSignal }): Promise<any> {
33
34
  try {
34
35
  const config = {
35
- headers: { Authorization: `Bearer ${this.apiToken}` }
36
+ headers: { Authorization: `Bearer ${this.apiToken}` },
37
+ signal: options?.signal || params.signal || undefined
36
38
  };
37
39
  const queryParams = generateQueryParamsStr([
38
40
  'store',