@chift/chift-nodejs 1.0.11 → 1.0.14

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.
@@ -1,37 +1,27 @@
1
1
  import { operations, components } from '../types/public-api/schema';
2
- import { RequestData } from '../types/api';
2
+ import { AutoPaginatedParams, RequestData } from '../types/api';
3
3
 
4
- type getPaymentsParams = Omit<
5
- operations['pos_get_payments']['parameters']['query'],
6
- 'page' | 'size'
7
- >;
4
+ type GetPaymentsParams = AutoPaginatedParams<operations['pos_get_payments']['parameters']['query']>;
8
5
 
9
- type getPaymentMethodsParams = Omit<
10
- operations['pos_get_payments_methods']['parameters']['query'],
11
- 'page' | 'size'
6
+ type GetPaymentMethodsParams = AutoPaginatedParams<
7
+ operations['pos_get_payments_methods']['parameters']['query']
12
8
  >;
13
9
 
14
- type getProductCategoriesParams = Omit<
15
- operations['pos_get_product_categories']['parameters']['query'],
16
- 'page' | 'size'
10
+ type GetProductCategoriesParams = AutoPaginatedParams<
11
+ operations['pos_get_product_categories']['parameters']['query']
17
12
  >;
18
13
 
19
- type getProductsParams = Omit<
20
- operations['pos_get_products']['parameters']['query'],
21
- 'page' | 'size'
22
- >;
14
+ type GetProductsParams = AutoPaginatedParams<operations['pos_get_products']['parameters']['query']>;
23
15
 
24
- type getCustomersParams = Omit<
25
- operations['pos_get_customers']['parameters']['query'],
26
- 'page' | 'size'
16
+ type GetCustomersParams = AutoPaginatedParams<
17
+ operations['pos_get_customers']['parameters']['query']
27
18
  >;
28
19
 
29
- type getAccountingCategoriesParams = Omit<
30
- operations['pos_get_accounting_categories']['parameters']['query'],
31
- 'page' | 'size'
20
+ type GetAccountingCategoriesParams = AutoPaginatedParams<
21
+ operations['pos_get_accounting_categories']['parameters']['query']
32
22
  >;
33
23
 
34
- type getOrdersParams = Omit<operations['pos_get_orders']['parameters']['query'], 'page' | 'size'>;
24
+ type GetOrdersParams = AutoPaginatedParams<operations['pos_get_orders']['parameters']['query']>;
35
25
 
36
26
  const posFactory = {
37
27
  getLocations(): RequestData<components['schemas']['POSLocationItem'][]> {
@@ -40,7 +30,7 @@ const posFactory = {
40
30
  url: '/consumers/{consumer_id}/pos/locations',
41
31
  };
42
32
  },
43
- getOrders(params: getOrdersParams): RequestData<components['schemas']['OrderItem'][]> {
33
+ getOrders(params: GetOrdersParams): RequestData<components['schemas']['OrderItem'][]> {
44
34
  return {
45
35
  params,
46
36
  method: 'get',
@@ -48,7 +38,7 @@ const posFactory = {
48
38
  };
49
39
  },
50
40
  getCustomers(
51
- params: getCustomersParams
41
+ params?: GetCustomersParams
52
42
  ): RequestData<components['schemas']['POSCustomerItem'][]> {
53
43
  return {
54
44
  params,
@@ -78,7 +68,7 @@ const posFactory = {
78
68
  };
79
69
  },
80
70
  getPaymentMethods(
81
- params: getPaymentMethodsParams
71
+ params?: GetPaymentMethodsParams
82
72
  ): RequestData<components['schemas']['PaymentMethods'][]> {
83
73
  return {
84
74
  params,
@@ -87,7 +77,7 @@ const posFactory = {
87
77
  };
88
78
  },
89
79
  getProductCategories(
90
- params: getProductCategoriesParams
80
+ params?: GetProductCategoriesParams
91
81
  ): RequestData<components['schemas']['CategoryItem'][]> {
92
82
  return {
93
83
  params,
@@ -95,7 +85,9 @@ const posFactory = {
95
85
  url: `/consumers/{consumer_id}/pos/product-categories`,
96
86
  };
97
87
  },
98
- getProducts(params: getProductsParams): RequestData<components['schemas']['POSProductItem'][]> {
88
+ getProducts(
89
+ params?: GetProductsParams
90
+ ): RequestData<components['schemas']['POSProductItem'][]> {
99
91
  return {
100
92
  params,
101
93
  method: 'get',
@@ -113,7 +105,7 @@ const posFactory = {
113
105
  },
114
106
  getClosure(
115
107
  date: string,
116
- params: operations['pos_get_closure']['parameters']['query']
108
+ params?: operations['pos_get_closure']['parameters']['query']
117
109
  ): RequestData<components['schemas']['ClosureItem']> {
118
110
  return {
119
111
  params,
@@ -121,7 +113,7 @@ const posFactory = {
121
113
  url: `/consumers/{consumer_id}/pos/closures/${date}`,
122
114
  };
123
115
  },
124
- getPayments(params: getPaymentsParams): RequestData<components['schemas']['PaymentItem'][]> {
116
+ getPayments(params: GetPaymentsParams): RequestData<components['schemas']['PaymentItem'][]> {
125
117
  return {
126
118
  params,
127
119
  method: 'get',
@@ -139,7 +131,7 @@ const posFactory = {
139
131
  };
140
132
  },
141
133
  getAccountingCategories(
142
- params: getAccountingCategoriesParams
134
+ params?: GetAccountingCategoriesParams
143
135
  ): RequestData<components['schemas']['AccountingCategoryItem'][]> {
144
136
  return {
145
137
  params,
package/src/types/api.ts CHANGED
@@ -33,3 +33,5 @@ export type ApiFor<TFactory extends RequestFactory> = {
33
33
  ? (...args: TArgs) => Promise<TResponse>
34
34
  : never;
35
35
  };
36
+
37
+ export type AutoPaginatedParams<T> = Omit<Exclude<T, undefined>, 'page' | 'size'>;