@arascreative/erp-client 0.0.0-stage → 1.0.0

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.
@@ -0,0 +1,757 @@
1
+ /**
2
+ * Generated by orval v7.21.0 🍺
3
+ * Do not edit manually.
4
+ * ArasERP V1 API
5
+ * Enterprise Resource Planning Backend API
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import { useMutation, useQuery } from '@tanstack/react-query';
9
+ ;
10
+ export const getGetAntiforgeryTokenUrl = () => {
11
+ return `/identity/antiforgery`;
12
+ };
13
+ export const getAntiforgeryToken = async (options) => {
14
+ const res = await fetch(getGetAntiforgeryTokenUrl(), {
15
+ ...options,
16
+ method: 'GET'
17
+ });
18
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
19
+ const data = body ? JSON.parse(body) : {};
20
+ return { data, status: res.status, headers: res.headers };
21
+ };
22
+ export const getGetAntiforgeryTokenQueryKey = () => {
23
+ return [
24
+ `/identity/antiforgery`
25
+ ];
26
+ };
27
+ export const getGetAntiforgeryTokenQueryOptions = (options) => {
28
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
29
+ const queryKey = queryOptions?.queryKey ?? getGetAntiforgeryTokenQueryKey();
30
+ const queryFn = ({ signal }) => getAntiforgeryToken({ signal, ...fetchOptions });
31
+ return { queryKey, queryFn, ...queryOptions };
32
+ };
33
+ /**
34
+ * @summary Get an antiforgery token
35
+ */
36
+ export function useGetAntiforgeryToken(options, queryClient) {
37
+ const queryOptions = getGetAntiforgeryTokenQueryOptions(options);
38
+ const query = useQuery(queryOptions, queryClient);
39
+ query.queryKey = queryOptions.queryKey;
40
+ return query;
41
+ }
42
+ export const getLoginUrl = () => {
43
+ return `/identity/login`;
44
+ };
45
+ export const login = async (loginBody, options) => {
46
+ const res = await fetch(getLoginUrl(), {
47
+ ...options,
48
+ method: 'POST',
49
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
50
+ body: JSON.stringify(loginBody)
51
+ });
52
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
53
+ const data = body ? JSON.parse(body) : {};
54
+ return { data, status: res.status, headers: res.headers };
55
+ };
56
+ export const getLoginMutationOptions = (options) => {
57
+ const mutationKey = ['login'];
58
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
59
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
60
+ options
61
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
62
+ : { mutation: { mutationKey, }, fetch: undefined };
63
+ const mutationFn = (props) => {
64
+ const { data } = props ?? {};
65
+ return login(data, fetchOptions);
66
+ };
67
+ return { mutationFn, ...mutationOptions };
68
+ };
69
+ /**
70
+ * @summary Sign in with email and password
71
+ */
72
+ export const useLogin = (options, queryClient) => {
73
+ const mutationOptions = getLoginMutationOptions(options);
74
+ return useMutation(mutationOptions, queryClient);
75
+ };
76
+ export const getGetCurrentUserUrl = () => {
77
+ return `/identity/me`;
78
+ };
79
+ export const getCurrentUser = async (options) => {
80
+ const res = await fetch(getGetCurrentUserUrl(), {
81
+ ...options,
82
+ method: 'GET'
83
+ });
84
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
85
+ const data = body ? JSON.parse(body) : {};
86
+ return { data, status: res.status, headers: res.headers };
87
+ };
88
+ export const getGetCurrentUserQueryKey = () => {
89
+ return [
90
+ `/identity/me`
91
+ ];
92
+ };
93
+ export const getGetCurrentUserQueryOptions = (options) => {
94
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
95
+ const queryKey = queryOptions?.queryKey ?? getGetCurrentUserQueryKey();
96
+ const queryFn = ({ signal }) => getCurrentUser({ signal, ...fetchOptions });
97
+ return { queryKey, queryFn, ...queryOptions };
98
+ };
99
+ /**
100
+ * @summary Get the current signed-in user
101
+ */
102
+ export function useGetCurrentUser(options, queryClient) {
103
+ const queryOptions = getGetCurrentUserQueryOptions(options);
104
+ const query = useQuery(queryOptions, queryClient);
105
+ query.queryKey = queryOptions.queryKey;
106
+ return query;
107
+ }
108
+ export const getLogoutUrl = () => {
109
+ return `/identity/logout`;
110
+ };
111
+ export const logout = async (options) => {
112
+ const res = await fetch(getLogoutUrl(), {
113
+ ...options,
114
+ method: 'POST'
115
+ });
116
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
117
+ const data = body ? JSON.parse(body) : {};
118
+ return { data, status: res.status, headers: res.headers };
119
+ };
120
+ export const getLogoutMutationOptions = (options) => {
121
+ const mutationKey = ['logout'];
122
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
123
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
124
+ options
125
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
126
+ : { mutation: { mutationKey, }, fetch: undefined };
127
+ const mutationFn = () => {
128
+ return logout(fetchOptions);
129
+ };
130
+ return { mutationFn, ...mutationOptions };
131
+ };
132
+ /**
133
+ * @summary Revoke the current session and clear its cookie
134
+ */
135
+ export const useLogout = (options, queryClient) => {
136
+ const mutationOptions = getLogoutMutationOptions(options);
137
+ return useMutation(mutationOptions, queryClient);
138
+ };
139
+ export const getCreateOwnerUrl = () => {
140
+ return `/identity/owner`;
141
+ };
142
+ export const createOwner = async (createOwnerBody, options) => {
143
+ const res = await fetch(getCreateOwnerUrl(), {
144
+ ...options,
145
+ method: 'POST',
146
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
147
+ body: JSON.stringify(createOwnerBody)
148
+ });
149
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
150
+ const data = body ? JSON.parse(body) : {};
151
+ return { data, status: res.status, headers: res.headers };
152
+ };
153
+ export const getCreateOwnerMutationOptions = (options) => {
154
+ const mutationKey = ['createOwner'];
155
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
156
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
157
+ options
158
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
159
+ : { mutation: { mutationKey, }, fetch: undefined };
160
+ const mutationFn = (props) => {
161
+ const { data } = props ?? {};
162
+ return createOwner(data, fetchOptions);
163
+ };
164
+ return { mutationFn, ...mutationOptions };
165
+ };
166
+ /**
167
+ * @summary Create the owner account
168
+ */
169
+ export const useCreateOwner = (options, queryClient) => {
170
+ const mutationOptions = getCreateOwnerMutationOptions(options);
171
+ return useMutation(mutationOptions, queryClient);
172
+ };
173
+ export const getSearchAddressesUrl = (params) => {
174
+ const normalizedParams = new URLSearchParams();
175
+ Object.entries(params || {}).forEach(([key, value]) => {
176
+ if (value !== undefined) {
177
+ normalizedParams.append(key, value === null ? 'null' : value.toString());
178
+ }
179
+ });
180
+ const stringifiedParams = normalizedParams.toString();
181
+ return stringifiedParams.length > 0 ? `/addresses/search?${stringifiedParams}` : `/addresses/search`;
182
+ };
183
+ export const searchAddresses = async (params, options) => {
184
+ const res = await fetch(getSearchAddressesUrl(params), {
185
+ ...options,
186
+ method: 'GET'
187
+ });
188
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
189
+ const data = body ? JSON.parse(body) : {};
190
+ return { data, status: res.status, headers: res.headers };
191
+ };
192
+ export const getSearchAddressesQueryKey = (params) => {
193
+ return [
194
+ `/addresses/search`, ...(params ? [params] : [])
195
+ ];
196
+ };
197
+ export const getSearchAddressesQueryOptions = (params, options) => {
198
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
199
+ const queryKey = queryOptions?.queryKey ?? getSearchAddressesQueryKey(params);
200
+ const queryFn = ({ signal }) => searchAddresses(params, { signal, ...fetchOptions });
201
+ return { queryKey, queryFn, ...queryOptions };
202
+ };
203
+ /**
204
+ * @summary Search addresses by keyword
205
+ */
206
+ export function useSearchAddresses(params, options, queryClient) {
207
+ const queryOptions = getSearchAddressesQueryOptions(params, options);
208
+ const query = useQuery(queryOptions, queryClient);
209
+ query.queryKey = queryOptions.queryKey;
210
+ return query;
211
+ }
212
+ export const getToggleWarehouseStatusUrl = (id) => {
213
+ return `/warehouses/${id}/toggle-status`;
214
+ };
215
+ export const toggleWarehouseStatus = async (id, options) => {
216
+ const res = await fetch(getToggleWarehouseStatusUrl(id), {
217
+ ...options,
218
+ method: 'PATCH'
219
+ });
220
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
221
+ const data = body ? JSON.parse(body) : {};
222
+ return { data, status: res.status, headers: res.headers };
223
+ };
224
+ export const getToggleWarehouseStatusMutationOptions = (options) => {
225
+ const mutationKey = ['toggleWarehouseStatus'];
226
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
227
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
228
+ options
229
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
230
+ : { mutation: { mutationKey, }, fetch: undefined };
231
+ const mutationFn = (props) => {
232
+ const { id } = props ?? {};
233
+ return toggleWarehouseStatus(id, fetchOptions);
234
+ };
235
+ return { mutationFn, ...mutationOptions };
236
+ };
237
+ /**
238
+ * @summary Toggle warehouse active status
239
+ */
240
+ export const useToggleWarehouseStatus = (options, queryClient) => {
241
+ const mutationOptions = getToggleWarehouseStatusMutationOptions(options);
242
+ return useMutation(mutationOptions, queryClient);
243
+ };
244
+ export const getChangeStockItemStatusUrl = (id) => {
245
+ return `/stock-items/${id}/status`;
246
+ };
247
+ export const changeStockItemStatus = async (id, changeStockItemStatusBody, options) => {
248
+ const res = await fetch(getChangeStockItemStatusUrl(id), {
249
+ ...options,
250
+ method: 'PATCH',
251
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
252
+ body: JSON.stringify(changeStockItemStatusBody)
253
+ });
254
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
255
+ const data = body ? JSON.parse(body) : {};
256
+ return { data, status: res.status, headers: res.headers };
257
+ };
258
+ export const getChangeStockItemStatusMutationOptions = (options) => {
259
+ const mutationKey = ['changeStockItemStatus'];
260
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
261
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
262
+ options
263
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
264
+ : { mutation: { mutationKey, }, fetch: undefined };
265
+ const mutationFn = (props) => {
266
+ const { id, data } = props ?? {};
267
+ return changeStockItemStatus(id, data, fetchOptions);
268
+ };
269
+ return { mutationFn, ...mutationOptions };
270
+ };
271
+ /**
272
+ * @summary Change stock item active status
273
+ */
274
+ export const useChangeStockItemStatus = (options, queryClient) => {
275
+ const mutationOptions = getChangeStockItemStatusMutationOptions(options);
276
+ return useMutation(mutationOptions, queryClient);
277
+ };
278
+ export const getGetWarehouseByIdUrl = (id) => {
279
+ return `/warehouses/${id}`;
280
+ };
281
+ export const getWarehouseById = async (id, options) => {
282
+ const res = await fetch(getGetWarehouseByIdUrl(id), {
283
+ ...options,
284
+ method: 'GET'
285
+ });
286
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
287
+ const data = body ? JSON.parse(body) : {};
288
+ return { data, status: res.status, headers: res.headers };
289
+ };
290
+ export const getGetWarehouseByIdQueryKey = (id) => {
291
+ return [
292
+ `/warehouses/${id}`
293
+ ];
294
+ };
295
+ export const getGetWarehouseByIdQueryOptions = (id, options) => {
296
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
297
+ const queryKey = queryOptions?.queryKey ?? getGetWarehouseByIdQueryKey(id);
298
+ const queryFn = ({ signal }) => getWarehouseById(id, { signal, ...fetchOptions });
299
+ return { queryKey, queryFn, enabled: !!(id), ...queryOptions };
300
+ };
301
+ /**
302
+ * @summary Get warehouse by ID
303
+ */
304
+ export function useGetWarehouseById(id, options, queryClient) {
305
+ const queryOptions = getGetWarehouseByIdQueryOptions(id, options);
306
+ const query = useQuery(queryOptions, queryClient);
307
+ query.queryKey = queryOptions.queryKey;
308
+ return query;
309
+ }
310
+ export const getUpdateWarehouseUrl = (id) => {
311
+ return `/warehouses/${id}`;
312
+ };
313
+ export const updateWarehouse = async (id, updateWarehouseBody, options) => {
314
+ const res = await fetch(getUpdateWarehouseUrl(id), {
315
+ ...options,
316
+ method: 'PUT',
317
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
318
+ body: JSON.stringify(updateWarehouseBody)
319
+ });
320
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
321
+ const data = body ? JSON.parse(body) : {};
322
+ return { data, status: res.status, headers: res.headers };
323
+ };
324
+ export const getUpdateWarehouseMutationOptions = (options) => {
325
+ const mutationKey = ['updateWarehouse'];
326
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
327
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
328
+ options
329
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
330
+ : { mutation: { mutationKey, }, fetch: undefined };
331
+ const mutationFn = (props) => {
332
+ const { id, data } = props ?? {};
333
+ return updateWarehouse(id, data, fetchOptions);
334
+ };
335
+ return { mutationFn, ...mutationOptions };
336
+ };
337
+ /**
338
+ * @summary Update warehouse
339
+ */
340
+ export const useUpdateWarehouse = (options, queryClient) => {
341
+ const mutationOptions = getUpdateWarehouseMutationOptions(options);
342
+ return useMutation(mutationOptions, queryClient);
343
+ };
344
+ export const getDeleteWarehouseUrl = (id) => {
345
+ return `/warehouses/${id}`;
346
+ };
347
+ export const deleteWarehouse = async (id, options) => {
348
+ const res = await fetch(getDeleteWarehouseUrl(id), {
349
+ ...options,
350
+ method: 'DELETE'
351
+ });
352
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
353
+ const data = body ? JSON.parse(body) : {};
354
+ return { data, status: res.status, headers: res.headers };
355
+ };
356
+ export const getDeleteWarehouseMutationOptions = (options) => {
357
+ const mutationKey = ['deleteWarehouse'];
358
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
359
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
360
+ options
361
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
362
+ : { mutation: { mutationKey, }, fetch: undefined };
363
+ const mutationFn = (props) => {
364
+ const { id } = props ?? {};
365
+ return deleteWarehouse(id, fetchOptions);
366
+ };
367
+ return { mutationFn, ...mutationOptions };
368
+ };
369
+ /**
370
+ * @summary Delete warehouse
371
+ */
372
+ export const useDeleteWarehouse = (options, queryClient) => {
373
+ const mutationOptions = getDeleteWarehouseMutationOptions(options);
374
+ return useMutation(mutationOptions, queryClient);
375
+ };
376
+ export const getUpdateStockItemUrl = (id) => {
377
+ return `/stock-items/${id}`;
378
+ };
379
+ export const updateStockItem = async (id, updateStockItemBody, options) => {
380
+ const res = await fetch(getUpdateStockItemUrl(id), {
381
+ ...options,
382
+ method: 'PUT',
383
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
384
+ body: JSON.stringify(updateStockItemBody)
385
+ });
386
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
387
+ const data = body ? JSON.parse(body) : {};
388
+ return { data, status: res.status, headers: res.headers };
389
+ };
390
+ export const getUpdateStockItemMutationOptions = (options) => {
391
+ const mutationKey = ['updateStockItem'];
392
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
393
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
394
+ options
395
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
396
+ : { mutation: { mutationKey, }, fetch: undefined };
397
+ const mutationFn = (props) => {
398
+ const { id, data } = props ?? {};
399
+ return updateStockItem(id, data, fetchOptions);
400
+ };
401
+ return { mutationFn, ...mutationOptions };
402
+ };
403
+ /**
404
+ * @summary Update stock item
405
+ */
406
+ export const useUpdateStockItem = (options, queryClient) => {
407
+ const mutationOptions = getUpdateStockItemMutationOptions(options);
408
+ return useMutation(mutationOptions, queryClient);
409
+ };
410
+ export const getDeleteStockItemUrl = (id) => {
411
+ return `/stock-items/${id}`;
412
+ };
413
+ export const deleteStockItem = async (id, options) => {
414
+ const res = await fetch(getDeleteStockItemUrl(id), {
415
+ ...options,
416
+ method: 'DELETE'
417
+ });
418
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
419
+ const data = body ? JSON.parse(body) : {};
420
+ return { data, status: res.status, headers: res.headers };
421
+ };
422
+ export const getDeleteStockItemMutationOptions = (options) => {
423
+ const mutationKey = ['deleteStockItem'];
424
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
425
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
426
+ options
427
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
428
+ : { mutation: { mutationKey, }, fetch: undefined };
429
+ const mutationFn = (props) => {
430
+ const { id } = props ?? {};
431
+ return deleteStockItem(id, fetchOptions);
432
+ };
433
+ return { mutationFn, ...mutationOptions };
434
+ };
435
+ /**
436
+ * @summary Delete stock item
437
+ */
438
+ export const useDeleteStockItem = (options, queryClient) => {
439
+ const mutationOptions = getDeleteStockItemMutationOptions(options);
440
+ return useMutation(mutationOptions, queryClient);
441
+ };
442
+ export const getGetHealthUrl = () => {
443
+ return `/health`;
444
+ };
445
+ export const getHealth = async (options) => {
446
+ const res = await fetch(getGetHealthUrl(), {
447
+ ...options,
448
+ method: 'GET'
449
+ });
450
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
451
+ const data = body ? JSON.parse(body) : {};
452
+ return { data, status: res.status, headers: res.headers };
453
+ };
454
+ export const getGetHealthQueryKey = () => {
455
+ return [
456
+ `/health`
457
+ ];
458
+ };
459
+ export const getGetHealthQueryOptions = (options) => {
460
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
461
+ const queryKey = queryOptions?.queryKey ?? getGetHealthQueryKey();
462
+ const queryFn = ({ signal }) => getHealth({ signal, ...fetchOptions });
463
+ return { queryKey, queryFn, ...queryOptions };
464
+ };
465
+ /**
466
+ * @summary Health check
467
+ */
468
+ export function useGetHealth(options, queryClient) {
469
+ const queryOptions = getGetHealthQueryOptions(options);
470
+ const query = useQuery(queryOptions, queryClient);
471
+ query.queryKey = queryOptions.queryKey;
472
+ return query;
473
+ }
474
+ ;
475
+ export const getGetCustomersUrl = () => {
476
+ return `/customers`;
477
+ };
478
+ export const getCustomers = async (options) => {
479
+ const res = await fetch(getGetCustomersUrl(), {
480
+ ...options,
481
+ method: 'GET'
482
+ });
483
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
484
+ const data = body ? JSON.parse(body) : {};
485
+ return { data, status: res.status, headers: res.headers };
486
+ };
487
+ export const getGetCustomersQueryKey = () => {
488
+ return [
489
+ `/customers`
490
+ ];
491
+ };
492
+ export const getGetCustomersQueryOptions = (options) => {
493
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
494
+ const queryKey = queryOptions?.queryKey ?? getGetCustomersQueryKey();
495
+ const queryFn = ({ signal }) => getCustomers({ signal, ...fetchOptions });
496
+ return { queryKey, queryFn, ...queryOptions };
497
+ };
498
+ export function useGetCustomers(options, queryClient) {
499
+ const queryOptions = getGetCustomersQueryOptions(options);
500
+ const query = useQuery(queryOptions, queryClient);
501
+ query.queryKey = queryOptions.queryKey;
502
+ return query;
503
+ }
504
+ export const getCreateWarehouseUrl = () => {
505
+ return `/warehouses`;
506
+ };
507
+ export const createWarehouse = async (createWarehouseBody, options) => {
508
+ const res = await fetch(getCreateWarehouseUrl(), {
509
+ ...options,
510
+ method: 'POST',
511
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
512
+ body: JSON.stringify(createWarehouseBody)
513
+ });
514
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
515
+ const data = body ? JSON.parse(body) : {};
516
+ return { data, status: res.status, headers: res.headers };
517
+ };
518
+ export const getCreateWarehouseMutationOptions = (options) => {
519
+ const mutationKey = ['createWarehouse'];
520
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
521
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
522
+ options
523
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
524
+ : { mutation: { mutationKey, }, fetch: undefined };
525
+ const mutationFn = (props) => {
526
+ const { data } = props ?? {};
527
+ return createWarehouse(data, fetchOptions);
528
+ };
529
+ return { mutationFn, ...mutationOptions };
530
+ };
531
+ /**
532
+ * @summary Create a new warehouse
533
+ */
534
+ export const useCreateWarehouse = (options, queryClient) => {
535
+ const mutationOptions = getCreateWarehouseMutationOptions(options);
536
+ return useMutation(mutationOptions, queryClient);
537
+ };
538
+ ;
539
+ export const getListWarehousesUrl = (params) => {
540
+ const normalizedParams = new URLSearchParams();
541
+ Object.entries(params || {}).forEach(([key, value]) => {
542
+ if (value !== undefined) {
543
+ normalizedParams.append(key, value === null ? 'null' : value.toString());
544
+ }
545
+ });
546
+ const stringifiedParams = normalizedParams.toString();
547
+ return stringifiedParams.length > 0 ? `/warehouses?${stringifiedParams}` : `/warehouses`;
548
+ };
549
+ export const listWarehouses = async (params, options) => {
550
+ const res = await fetch(getListWarehousesUrl(params), {
551
+ ...options,
552
+ method: 'GET'
553
+ });
554
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
555
+ const data = body ? JSON.parse(body) : {};
556
+ return { data, status: res.status, headers: res.headers };
557
+ };
558
+ export const getListWarehousesQueryKey = (params) => {
559
+ return [
560
+ `/warehouses`, ...(params ? [params] : [])
561
+ ];
562
+ };
563
+ export const getListWarehousesQueryOptions = (params, options) => {
564
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
565
+ const queryKey = queryOptions?.queryKey ?? getListWarehousesQueryKey(params);
566
+ const queryFn = ({ signal }) => listWarehouses(params, { signal, ...fetchOptions });
567
+ return { queryKey, queryFn, ...queryOptions };
568
+ };
569
+ /**
570
+ * @summary List all warehouses
571
+ */
572
+ export function useListWarehouses(params, options, queryClient) {
573
+ const queryOptions = getListWarehousesQueryOptions(params, options);
574
+ const query = useQuery(queryOptions, queryClient);
575
+ query.queryKey = queryOptions.queryKey;
576
+ return query;
577
+ }
578
+ ;
579
+ export const getListStockMovementsUrl = (params) => {
580
+ const normalizedParams = new URLSearchParams();
581
+ Object.entries(params || {}).forEach(([key, value]) => {
582
+ if (value !== undefined) {
583
+ normalizedParams.append(key, value === null ? 'null' : value.toString());
584
+ }
585
+ });
586
+ const stringifiedParams = normalizedParams.toString();
587
+ return stringifiedParams.length > 0 ? `/stock-movements?${stringifiedParams}` : `/stock-movements`;
588
+ };
589
+ export const listStockMovements = async (params, options) => {
590
+ const res = await fetch(getListStockMovementsUrl(params), {
591
+ ...options,
592
+ method: 'GET'
593
+ });
594
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
595
+ const data = body ? JSON.parse(body) : {};
596
+ return { data, status: res.status, headers: res.headers };
597
+ };
598
+ export const getListStockMovementsQueryKey = (params) => {
599
+ return [
600
+ `/stock-movements`, ...(params ? [params] : [])
601
+ ];
602
+ };
603
+ export const getListStockMovementsQueryOptions = (params, options) => {
604
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
605
+ const queryKey = queryOptions?.queryKey ?? getListStockMovementsQueryKey(params);
606
+ const queryFn = ({ signal }) => listStockMovements(params, { signal, ...fetchOptions });
607
+ return { queryKey, queryFn, ...queryOptions };
608
+ };
609
+ /**
610
+ * @summary List stock movements
611
+ */
612
+ export function useListStockMovements(params, options, queryClient) {
613
+ const queryOptions = getListStockMovementsQueryOptions(params, options);
614
+ const query = useQuery(queryOptions, queryClient);
615
+ query.queryKey = queryOptions.queryKey;
616
+ return query;
617
+ }
618
+ export const getCreateStockItemUrl = () => {
619
+ return `/stock-items`;
620
+ };
621
+ export const createStockItem = async (createStockItemBody, options) => {
622
+ const res = await fetch(getCreateStockItemUrl(), {
623
+ ...options,
624
+ method: 'POST',
625
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
626
+ body: JSON.stringify(createStockItemBody)
627
+ });
628
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
629
+ const data = body ? JSON.parse(body) : {};
630
+ return { data, status: res.status, headers: res.headers };
631
+ };
632
+ export const getCreateStockItemMutationOptions = (options) => {
633
+ const mutationKey = ['createStockItem'];
634
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
635
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
636
+ options
637
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
638
+ : { mutation: { mutationKey, }, fetch: undefined };
639
+ const mutationFn = (props) => {
640
+ const { data } = props ?? {};
641
+ return createStockItem(data, fetchOptions);
642
+ };
643
+ return { mutationFn, ...mutationOptions };
644
+ };
645
+ /**
646
+ * @summary Create a new stock item
647
+ */
648
+ export const useCreateStockItem = (options, queryClient) => {
649
+ const mutationOptions = getCreateStockItemMutationOptions(options);
650
+ return useMutation(mutationOptions, queryClient);
651
+ };
652
+ ;
653
+ export const getListStockItemsUrl = (params) => {
654
+ const normalizedParams = new URLSearchParams();
655
+ Object.entries(params || {}).forEach(([key, value]) => {
656
+ if (value !== undefined) {
657
+ normalizedParams.append(key, value === null ? 'null' : value.toString());
658
+ }
659
+ });
660
+ const stringifiedParams = normalizedParams.toString();
661
+ return stringifiedParams.length > 0 ? `/stock-items?${stringifiedParams}` : `/stock-items`;
662
+ };
663
+ export const listStockItems = async (params, options) => {
664
+ const res = await fetch(getListStockItemsUrl(params), {
665
+ ...options,
666
+ method: 'GET'
667
+ });
668
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
669
+ const data = body ? JSON.parse(body) : {};
670
+ return { data, status: res.status, headers: res.headers };
671
+ };
672
+ export const getListStockItemsQueryKey = (params) => {
673
+ return [
674
+ `/stock-items`, ...(params ? [params] : [])
675
+ ];
676
+ };
677
+ export const getListStockItemsQueryOptions = (params, options) => {
678
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
679
+ const queryKey = queryOptions?.queryKey ?? getListStockItemsQueryKey(params);
680
+ const queryFn = ({ signal }) => listStockItems(params, { signal, ...fetchOptions });
681
+ return { queryKey, queryFn, ...queryOptions };
682
+ };
683
+ /**
684
+ * @summary List stock items
685
+ */
686
+ export function useListStockItems(params, options, queryClient) {
687
+ const queryOptions = getListStockItemsQueryOptions(params, options);
688
+ const query = useQuery(queryOptions, queryClient);
689
+ query.queryKey = queryOptions.queryKey;
690
+ return query;
691
+ }
692
+ export const getCreateBatchUrl = () => {
693
+ return `/batches`;
694
+ };
695
+ export const createBatch = async (createBatchBody, options) => {
696
+ const res = await fetch(getCreateBatchUrl(), {
697
+ ...options,
698
+ method: 'POST',
699
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
700
+ body: JSON.stringify(createBatchBody)
701
+ });
702
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
703
+ const data = body ? JSON.parse(body) : {};
704
+ return { data, status: res.status, headers: res.headers };
705
+ };
706
+ export const getCreateBatchMutationOptions = (options) => {
707
+ const mutationKey = ['createBatch'];
708
+ const { mutation: mutationOptions, fetch: fetchOptions } = options ?
709
+ options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
710
+ options
711
+ : { ...options, mutation: { ...options.mutation, mutationKey } }
712
+ : { mutation: { mutationKey, }, fetch: undefined };
713
+ const mutationFn = (props) => {
714
+ const { data } = props ?? {};
715
+ return createBatch(data, fetchOptions);
716
+ };
717
+ return { mutationFn, ...mutationOptions };
718
+ };
719
+ /**
720
+ * @summary Create a new stock batch
721
+ */
722
+ export const useCreateBatch = (options, queryClient) => {
723
+ const mutationOptions = getCreateBatchMutationOptions(options);
724
+ return useMutation(mutationOptions, queryClient);
725
+ };
726
+ export const getGetUrl = () => {
727
+ return `/`;
728
+ };
729
+ export const get = async (options) => {
730
+ const res = await fetch(getGetUrl(), {
731
+ ...options,
732
+ method: 'GET'
733
+ });
734
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
735
+ const data = body ? JSON.parse(body) : {};
736
+ return { data, status: res.status, headers: res.headers };
737
+ };
738
+ export const getGetQueryKey = () => {
739
+ return [
740
+ `/`
741
+ ];
742
+ };
743
+ export const getGetQueryOptions = (options) => {
744
+ const { query: queryOptions, fetch: fetchOptions } = options ?? {};
745
+ const queryKey = queryOptions?.queryKey ?? getGetQueryKey();
746
+ const queryFn = ({ signal }) => get({ signal, ...fetchOptions });
747
+ return { queryKey, queryFn, ...queryOptions };
748
+ };
749
+ /**
750
+ * @summary API welcome message
751
+ */
752
+ export function useGet(options, queryClient) {
753
+ const queryOptions = getGetQueryOptions(options);
754
+ const query = useQuery(queryOptions, queryClient);
755
+ query.queryKey = queryOptions.queryKey;
756
+ return query;
757
+ }