typedapi-client-helpers 0.1.3 → 0.1.5

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.
package/dist/index.cjs CHANGED
@@ -20,67 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- TypedApiToastProvider: () => TypedApiToastProvider,
24
23
  buildQuery: () => buildQuery,
25
- extractArgsToastsAndParams: () => extractArgsToastsAndParams,
24
+ extractArgsCallbacksAndParams: () => extractArgsCallbacksAndParams,
26
25
  getSortDirectionFromSortType: () => getSortDirectionFromSortType,
27
26
  getSortTypeFromSortDirection: () => getSortTypeFromSortDirection,
28
27
  handleApiResponse: () => handleApiResponse,
29
- resetUnauthorizedHandling: () => resetUnauthorizedHandling,
30
28
  sortTypes: () => sortTypes,
31
- toFormData: () => toFormData,
32
- toast: () => toast
29
+ toFormData: () => toFormData
33
30
  });
34
31
  module.exports = __toCommonJS(index_exports);
35
32
 
36
- // src/toast/toast.tsx
37
- var import_react_toastify = require("react-toastify");
38
- var import_jsx_runtime = require("react/jsx-runtime");
39
- function ToastContent({ title, message }) {
40
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
41
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: title }),
42
- message && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: message })
43
- ] });
44
- }
45
- var toast = {
46
- success(message, title = "Success!") {
47
- import_react_toastify.toast.success(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContent, { title, message }));
48
- },
49
- error(message, title = "Error!") {
50
- import_react_toastify.toast.error(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContent, { title, message }));
51
- },
52
- warning(message, title = "Warning!") {
53
- import_react_toastify.toast.warning(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContent, { title, message }));
54
- },
55
- info(message, title = "Info") {
56
- import_react_toastify.toast.info(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContent, { title, message }));
57
- },
58
- async errorResponse(error) {
59
- let message = "Something went wrong.";
60
- try {
61
- if (error instanceof Response) {
62
- const text = await error.text();
63
- message = text || message;
64
- } else if (error instanceof Error) {
65
- message = error.message;
66
- } else if (typeof error === "string") {
67
- message = error;
68
- } else if (error && typeof error === "object") {
69
- message = JSON.stringify(error);
70
- }
71
- } catch {
72
- }
73
- import_react_toastify.toast.error(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToastContent, { title: "Error!", message }));
74
- }
75
- };
76
-
77
- // src/toast/ToastProvider.tsx
78
- var import_react_toastify2 = require("react-toastify");
79
- var import_jsx_runtime2 = require("react/jsx-runtime");
80
- function TypedApiToastProvider() {
81
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_toastify2.ToastContainer, { position: "bottom-right" });
82
- }
83
-
84
33
  // src/utils/buildQuery.ts
85
34
  function buildQuery(filters, page = 1, pageSize = 100, sortBy = null, sortDirection) {
86
35
  let isPageSizeSet = pageSize > 0;
@@ -150,111 +99,81 @@ function convertType(type, value) {
150
99
  }
151
100
 
152
101
  // src/utils/extractArgsToastsAndParams.ts
153
- function isToastOptions(value) {
154
- return typeof value === "object" && value !== null && ("toastSuccess" in value || "toastError" in value);
102
+ function isCallback(value) {
103
+ return typeof value === "function";
155
104
  }
156
105
  function isRequestParams(value) {
157
- return typeof value === "object" && value !== null && !isToastOptions(value);
106
+ return typeof value === "object" && value !== null && !Array.isArray(value);
158
107
  }
159
- function extractArgsToastsAndParams(argsWithToast) {
160
- const args = [...argsWithToast];
161
- let toastOptions;
108
+ function extractArgsCallbacksAndParams(argsWithCallbacks) {
109
+ const values = [...argsWithCallbacks];
110
+ let onSuccess;
111
+ let onError;
162
112
  let params;
163
- const lastArg = args[args.length - 1];
164
- if (isRequestParams(lastArg)) {
165
- params = lastArg;
166
- args.pop();
113
+ let lastArgument = values[values.length - 1];
114
+ if (isRequestParams(lastArgument)) {
115
+ params = lastArgument;
116
+ values.pop();
117
+ }
118
+ lastArgument = values[values.length - 1];
119
+ if (isCallback(lastArgument)) {
120
+ onError = lastArgument;
121
+ values.pop();
167
122
  }
168
- const newLastArg = args[args.length - 1];
169
- if (isToastOptions(newLastArg)) {
170
- toastOptions = newLastArg;
171
- args.pop();
123
+ lastArgument = values[values.length - 1];
124
+ if (isCallback(lastArgument)) {
125
+ onSuccess = lastArgument;
126
+ values.pop();
172
127
  }
173
128
  return {
174
- args,
175
- toastOptions,
129
+ args: values,
130
+ onSuccess,
131
+ onError,
176
132
  params
177
133
  };
178
134
  }
179
135
 
180
136
  // src/utils/handleApiResponse.ts
181
- var isHandlingUnauthorized = false;
182
- function handleUnauthorized() {
183
- if (isHandlingUnauthorized) {
184
- return {
185
- ok: false,
186
- status: 401,
187
- response: void 0,
188
- error: new Error("Unauthorized")
189
- };
137
+ async function readResponseBody(response) {
138
+ if (response.status === 204) {
139
+ return void 0;
190
140
  }
191
- isHandlingUnauthorized = true;
192
- localStorage.removeItem("loggedInUser");
193
- sessionStorage.clear();
194
- toast.error("Your session has expired. Please log in again.", "Session Expired");
195
- if (window.location.pathname !== "/login") {
196
- window.dispatchEvent(new Event("unauthorized"));
141
+ const text = await response.text();
142
+ if (!text) {
143
+ return void 0;
197
144
  }
198
- return {
199
- ok: false,
200
- status: 401,
201
- response: void 0,
202
- error: new Error("Unauthorized")
203
- };
204
- }
205
- function resetUnauthorizedHandling() {
206
- isHandlingUnauthorized = false;
145
+ const contentType = response.headers.get("content-type");
146
+ if (contentType?.includes("application/json")) {
147
+ return JSON.parse(text);
148
+ }
149
+ return text;
207
150
  }
208
- async function handleApiResponse(call, toastOptions) {
151
+ async function handleApiResponse(call, options) {
209
152
  let response;
210
153
  try {
211
154
  response = await call();
212
- if (response.status === 401) {
213
- return handleUnauthorized();
214
- }
215
- let data;
216
- try {
217
- const textData = await response.text();
218
- data = textData ? JSON.parse(textData) : void 0;
219
- } catch {
220
- data = void 0;
221
- }
155
+ const data = await readResponseBody(response);
222
156
  if (response.ok) {
223
- if (toastOptions?.toastSuccess) {
224
- toast.success(
225
- toastOptions.toastSuccess.message,
226
- toastOptions.toastSuccess.title
227
- );
228
- }
157
+ await options?.onSuccess?.(data);
229
158
  return {
230
159
  ok: true,
231
160
  status: response.status,
232
161
  response: data
233
162
  };
234
163
  }
235
- if (toastOptions?.toastError) {
236
- toast.error(
237
- toastOptions.toastError.message,
238
- toastOptions.toastError.title
239
- );
240
- } else {
241
- await toast.errorResponse(response);
242
- }
164
+ const errorData = data;
165
+ await options?.onError?.(errorData);
243
166
  return {
244
167
  ok: false,
245
168
  status: response.status,
246
169
  response: data,
247
- error: null
170
+ error: errorData
248
171
  };
249
172
  } catch (error) {
250
- const status = error instanceof Response ? error.status : response?.status ?? 0;
251
- if (status === 401) {
252
- return handleUnauthorized();
253
- }
254
- await toast.errorResponse(error);
173
+ await options?.onError?.(error);
255
174
  return {
256
175
  ok: false,
257
- status,
176
+ status: error instanceof Response ? error.status : response?.status ?? 0,
258
177
  response: void 0,
259
178
  error
260
179
  };
@@ -292,6 +211,514 @@ function getSortDirectionFromSortType(sortType) {
292
211
  }
293
212
  }
294
213
 
214
+ // src/api/generated/http-client.ts
215
+ var HttpClient = class {
216
+ constructor(apiConfig = {}) {
217
+ this.baseUrl = "https://localhost:7000";
218
+ this.securityData = null;
219
+ this.abortControllers = /* @__PURE__ */ new Map();
220
+ this.customFetch = (...fetchParams) => fetch(...fetchParams);
221
+ this.baseApiParams = {
222
+ credentials: "same-origin",
223
+ headers: {},
224
+ redirect: "follow",
225
+ referrerPolicy: "no-referrer"
226
+ };
227
+ this.setSecurityData = (data) => {
228
+ this.securityData = data;
229
+ };
230
+ this.contentFormatters = {
231
+ ["application/json" /* Json */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
232
+ ["application/vnd.api+json" /* JsonApi */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
233
+ ["text/plain" /* Text */]: (input) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
234
+ ["multipart/form-data" /* FormData */]: (input) => {
235
+ if (input instanceof FormData) {
236
+ return input;
237
+ }
238
+ return Object.keys(input || {}).reduce((formData, key) => {
239
+ const property = input[key];
240
+ formData.append(
241
+ key,
242
+ property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`
243
+ );
244
+ return formData;
245
+ }, new FormData());
246
+ },
247
+ ["application/x-www-form-urlencoded" /* UrlEncoded */]: (input) => this.toQueryString(input)
248
+ };
249
+ this.createAbortSignal = (cancelToken) => {
250
+ if (this.abortControllers.has(cancelToken)) {
251
+ const abortController2 = this.abortControllers.get(cancelToken);
252
+ if (abortController2) {
253
+ return abortController2.signal;
254
+ }
255
+ return void 0;
256
+ }
257
+ const abortController = new AbortController();
258
+ this.abortControllers.set(cancelToken, abortController);
259
+ return abortController.signal;
260
+ };
261
+ this.abortRequest = (cancelToken) => {
262
+ const abortController = this.abortControllers.get(cancelToken);
263
+ if (abortController) {
264
+ abortController.abort();
265
+ this.abortControllers.delete(cancelToken);
266
+ }
267
+ };
268
+ this.request = async ({
269
+ body,
270
+ secure,
271
+ path,
272
+ type,
273
+ query,
274
+ format,
275
+ baseUrl,
276
+ cancelToken,
277
+ ...params
278
+ }) => {
279
+ const secureParams = (typeof secure === "boolean" ? secure : this.baseApiParams.secure) && this.securityWorker && await this.securityWorker(this.securityData) || {};
280
+ const requestParams = this.mergeRequestParams(params, secureParams);
281
+ const queryString = query && this.toQueryString(query);
282
+ const payloadFormatter = this.contentFormatters[type || "application/json" /* Json */];
283
+ const responseFormat = format || requestParams.format;
284
+ return this.customFetch(
285
+ `${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
286
+ {
287
+ ...requestParams,
288
+ headers: {
289
+ ...requestParams.headers || {},
290
+ ...type && type !== "multipart/form-data" /* FormData */ ? { "Content-Type": type } : {}
291
+ },
292
+ signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
293
+ body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
294
+ }
295
+ ).then(async (response) => {
296
+ const r = response;
297
+ r.data = null;
298
+ r.error = null;
299
+ const responseToParse = responseFormat ? response.clone() : response;
300
+ const data = !responseFormat ? r : await responseToParse[responseFormat]().then((data2) => {
301
+ if (r.ok) {
302
+ r.data = data2;
303
+ } else {
304
+ r.error = data2;
305
+ }
306
+ return r;
307
+ }).catch((e) => {
308
+ r.error = e;
309
+ return r;
310
+ });
311
+ if (cancelToken) {
312
+ this.abortControllers.delete(cancelToken);
313
+ }
314
+ if (!response.ok) throw data;
315
+ return data;
316
+ });
317
+ };
318
+ Object.assign(this, apiConfig);
319
+ }
320
+ encodeQueryParam(key, value) {
321
+ const encodedKey = encodeURIComponent(key);
322
+ return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
323
+ }
324
+ addQueryParam(query, key) {
325
+ return this.encodeQueryParam(key, query[key]);
326
+ }
327
+ addArrayQueryParam(query, key) {
328
+ const value = query[key];
329
+ return value.map((v) => this.encodeQueryParam(key, v)).join("&");
330
+ }
331
+ toQueryString(rawQuery) {
332
+ const query = rawQuery || {};
333
+ const keys = Object.keys(query).filter(
334
+ (key) => "undefined" !== typeof query[key]
335
+ );
336
+ return keys.map(
337
+ (key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)
338
+ ).join("&");
339
+ }
340
+ addQueryParams(rawQuery) {
341
+ const queryString = this.toQueryString(rawQuery);
342
+ return queryString ? `?${queryString}` : "";
343
+ }
344
+ mergeRequestParams(params1, params2) {
345
+ return {
346
+ ...this.baseApiParams,
347
+ ...params1,
348
+ ...params2 || {},
349
+ headers: {
350
+ ...this.baseApiParams.headers || {},
351
+ ...params1.headers || {},
352
+ ...params2 && params2.headers || {}
353
+ }
354
+ };
355
+ }
356
+ };
357
+
358
+ // src/api/generated/Import.ts
359
+ var Import = class extends HttpClient {
360
+ constructor() {
361
+ super(...arguments);
362
+ /**
363
+ * No description
364
+ *
365
+ * @tags Import
366
+ * @name UploadProductFile
367
+ * @request POST:/api/import/products
368
+ */
369
+ this.uploadProductFile = (data, params = {}) => this.request({
370
+ path: `/api/import/products`,
371
+ method: "POST",
372
+ body: data,
373
+ type: "multipart/form-data" /* FormData */,
374
+ format: "json",
375
+ ...params
376
+ });
377
+ /**
378
+ * No description
379
+ *
380
+ * @tags Import
381
+ * @name UploadSupplierFile
382
+ * @request POST:/api/import/suppliers
383
+ */
384
+ this.uploadSupplierFile = (data, params = {}) => this.request({
385
+ path: `/api/import/suppliers`,
386
+ method: "POST",
387
+ body: data,
388
+ type: "multipart/form-data" /* FormData */,
389
+ format: "json",
390
+ ...params
391
+ });
392
+ }
393
+ };
394
+
395
+ // src/api/methods/Import.api.ts
396
+ var importApi = new Import();
397
+
398
+ // src/api/generated/Order.ts
399
+ var Order = class extends HttpClient {
400
+ constructor() {
401
+ super(...arguments);
402
+ /**
403
+ * No description
404
+ *
405
+ * @tags Order
406
+ * @name GetOrders
407
+ * @request GET:/api/orders
408
+ */
409
+ this.getOrders = (query = {}, params = {}) => this.request({
410
+ path: `/api/orders`,
411
+ method: "GET",
412
+ query,
413
+ format: "json",
414
+ ...params
415
+ });
416
+ /**
417
+ * No description
418
+ *
419
+ * @tags Order
420
+ * @name CreateOrder
421
+ * @request POST:/api/orders
422
+ */
423
+ this.createOrder = (data, params = {}) => this.request({
424
+ path: `/api/orders`,
425
+ method: "POST",
426
+ body: data,
427
+ type: "application/json" /* Json */,
428
+ format: "json",
429
+ ...params
430
+ });
431
+ /**
432
+ * No description
433
+ *
434
+ * @tags Order
435
+ * @name GetOrderById
436
+ * @request GET:/api/orders/{id}
437
+ */
438
+ this.getOrderById = ({ id }, params = {}) => this.request({
439
+ path: `/api/orders/${id}`,
440
+ method: "GET",
441
+ format: "json",
442
+ ...params
443
+ });
444
+ /**
445
+ * No description
446
+ *
447
+ * @tags Order
448
+ * @name ApproveOrder
449
+ * @request PUT:/api/orders/{id}/approve
450
+ */
451
+ this.approveOrder = ({ id }, data, params = {}) => this.request({
452
+ path: `/api/orders/${id}/approve`,
453
+ method: "PUT",
454
+ body: data,
455
+ type: "application/json" /* Json */,
456
+ format: "json",
457
+ ...params
458
+ });
459
+ }
460
+ };
461
+
462
+ // src/api/methods/Order.api.ts
463
+ var orderApi = new Order();
464
+ async function getOrders(query, onSuccess, onError, params) {
465
+ return handleApiResponse(
466
+ () => orderApi.getOrders(query, params ?? {}),
467
+ { onSuccess, onError }
468
+ );
469
+ }
470
+
471
+ // src/api/generated/Product.ts
472
+ var Product = class extends HttpClient {
473
+ constructor() {
474
+ super(...arguments);
475
+ /**
476
+ * No description
477
+ *
478
+ * @tags Product
479
+ * @name GetProducts
480
+ * @request GET:/api/products
481
+ */
482
+ this.getProducts = (query = {}, params = {}) => this.request({
483
+ path: `/api/products`,
484
+ method: "GET",
485
+ query,
486
+ format: "json",
487
+ ...params
488
+ });
489
+ /**
490
+ * No description
491
+ *
492
+ * @tags Product
493
+ * @name CreateProduct
494
+ * @request POST:/api/products
495
+ */
496
+ this.createProduct = (data, params = {}) => this.request({
497
+ path: `/api/products`,
498
+ method: "POST",
499
+ body: data,
500
+ type: "application/json" /* Json */,
501
+ format: "json",
502
+ ...params
503
+ });
504
+ /**
505
+ * No description
506
+ *
507
+ * @tags Product
508
+ * @name GetProductById
509
+ * @request GET:/api/products/{id}
510
+ */
511
+ this.getProductById = ({ id }, params = {}) => this.request({
512
+ path: `/api/products/${id}`,
513
+ method: "GET",
514
+ format: "json",
515
+ ...params
516
+ });
517
+ /**
518
+ * No description
519
+ *
520
+ * @tags Product
521
+ * @name UpdateProduct
522
+ * @request PUT:/api/products/{id}
523
+ */
524
+ this.updateProduct = ({ id }, data, params = {}) => this.request({
525
+ path: `/api/products/${id}`,
526
+ method: "PUT",
527
+ body: data,
528
+ type: "application/json" /* Json */,
529
+ format: "json",
530
+ ...params
531
+ });
532
+ /**
533
+ * No description
534
+ *
535
+ * @tags Product
536
+ * @name DeleteProduct
537
+ * @request DELETE:/api/products/{id}
538
+ */
539
+ this.deleteProduct = ({ id }, params = {}) => this.request({
540
+ path: `/api/products/${id}`,
541
+ method: "DELETE",
542
+ ...params
543
+ });
544
+ /**
545
+ * No description
546
+ *
547
+ * @tags Product
548
+ * @name SearchProducts
549
+ * @request GET:/api/products/search
550
+ */
551
+ this.searchProducts = (query = {}, params = {}) => this.request({
552
+ path: `/api/products/search`,
553
+ method: "GET",
554
+ query,
555
+ format: "json",
556
+ ...params
557
+ });
558
+ /**
559
+ * No description
560
+ *
561
+ * @tags Product
562
+ * @name ExportProducts
563
+ * @request GET:/api/products/export
564
+ */
565
+ this.exportProducts = (query = {}, params = {}) => this.request({
566
+ path: `/api/products/export`,
567
+ method: "GET",
568
+ query,
569
+ ...params
570
+ });
571
+ }
572
+ };
573
+
574
+ // src/api/methods/Product.api.ts
575
+ var productApi = new Product();
576
+
577
+ // src/api/generated/Report.ts
578
+ var Report = class extends HttpClient {
579
+ constructor() {
580
+ super(...arguments);
581
+ /**
582
+ * No description
583
+ *
584
+ * @tags Report
585
+ * @name GetInventorySummary
586
+ * @request GET:/api/reports/summary
587
+ */
588
+ this.getInventorySummary = (query = {}, params = {}) => this.request({
589
+ path: `/api/reports/summary`,
590
+ method: "GET",
591
+ query,
592
+ format: "json",
593
+ ...params
594
+ });
595
+ }
596
+ };
597
+
598
+ // src/api/methods/Report.api.ts
599
+ var reportApi = new Report();
600
+
601
+ // src/api/generated/Supplier.ts
602
+ var Supplier = class extends HttpClient {
603
+ constructor() {
604
+ super(...arguments);
605
+ /**
606
+ * No description
607
+ *
608
+ * @tags Supplier
609
+ * @name GetSuppliers
610
+ * @request GET:/api/suppliers
611
+ */
612
+ this.getSuppliers = (query = {}, params = {}) => this.request({
613
+ path: `/api/suppliers`,
614
+ method: "GET",
615
+ query,
616
+ format: "json",
617
+ ...params
618
+ });
619
+ /**
620
+ * No description
621
+ *
622
+ * @tags Supplier
623
+ * @name CreateSupplier
624
+ * @request POST:/api/suppliers
625
+ */
626
+ this.createSupplier = (data, params = {}) => this.request({
627
+ path: `/api/suppliers`,
628
+ method: "POST",
629
+ body: data,
630
+ type: "application/json" /* Json */,
631
+ format: "json",
632
+ ...params
633
+ });
634
+ /**
635
+ * No description
636
+ *
637
+ * @tags Supplier
638
+ * @name GetSupplierById
639
+ * @request GET:/api/suppliers/{id}
640
+ */
641
+ this.getSupplierById = ({ id }, params = {}) => this.request({
642
+ path: `/api/suppliers/${id}`,
643
+ method: "GET",
644
+ format: "json",
645
+ ...params
646
+ });
647
+ /**
648
+ * No description
649
+ *
650
+ * @tags Supplier
651
+ * @name UpdateSupplier
652
+ * @request PUT:/api/suppliers/{id}
653
+ */
654
+ this.updateSupplier = ({ id }, data, params = {}) => this.request({
655
+ path: `/api/suppliers/${id}`,
656
+ method: "PUT",
657
+ body: data,
658
+ type: "application/json" /* Json */,
659
+ format: "json",
660
+ ...params
661
+ });
662
+ /**
663
+ * No description
664
+ *
665
+ * @tags Supplier
666
+ * @name DeleteSupplier
667
+ * @request DELETE:/api/suppliers/{id}
668
+ */
669
+ this.deleteSupplier = ({ id }, params = {}) => this.request({
670
+ path: `/api/suppliers/${id}`,
671
+ method: "DELETE",
672
+ ...params
673
+ });
674
+ }
675
+ };
676
+
677
+ // src/api/methods/Supplier.api.ts
678
+ var supplierApi = new Supplier();
679
+ async function createSupplier(...argsWithCallbacks) {
680
+ const {
681
+ args,
682
+ onSuccess,
683
+ onError,
684
+ params
685
+ } = extractArgsCallbacksAndParams(argsWithCallbacks);
686
+ const requestArgs = [
687
+ ...args,
688
+ params ?? {}
689
+ ];
690
+ return handleApiResponse(
691
+ () => supplierApi.createSupplier(
692
+ ...requestArgs
693
+ ),
694
+ {
695
+ onSuccess,
696
+ onError
697
+ }
698
+ );
699
+ }
700
+ async function getSupplierById(...argsWithCallbacks) {
701
+ const {
702
+ args,
703
+ onSuccess,
704
+ onError,
705
+ params
706
+ } = extractArgsCallbacksAndParams(argsWithCallbacks);
707
+ const requestArgs = [
708
+ ...args,
709
+ params ?? {}
710
+ ];
711
+ return handleApiResponse(
712
+ () => supplierApi.getSupplierById(
713
+ ...requestArgs
714
+ ),
715
+ {
716
+ onSuccess,
717
+ onError
718
+ }
719
+ );
720
+ }
721
+
295
722
  // src/utils/toFormData.ts
296
723
  function toFormData(payload) {
297
724
  const formData = new FormData();
@@ -324,16 +751,49 @@ function appendFormDataValue(formData, key, value) {
324
751
  }
325
752
  formData.append(key, JSON.stringify(value));
326
753
  }
754
+ var x = createSupplier(
755
+ { id: "", name: "Test Supplier", active: true, countryCode: "US", email: "test.supplier@example.com", rating: 4.5 },
756
+ () => {
757
+ console.info("Created");
758
+ },
759
+ (error) => {
760
+ console.error("Error", error);
761
+ }
762
+ );
763
+ var y = getOrders(
764
+ {},
765
+ (response) => {
766
+ console.info("Created", response);
767
+ },
768
+ (error) => {
769
+ console.error("Error", error);
770
+ }
771
+ );
772
+ var x2 = getSupplierById(
773
+ { id: "1" },
774
+ () => {
775
+ console.info("Created");
776
+ },
777
+ (error) => {
778
+ console.error("Error", error);
779
+ }
780
+ );
781
+ var y2 = getSupplierById(
782
+ { id: "1" },
783
+ (response) => {
784
+ console.info("Created", response);
785
+ },
786
+ (error) => {
787
+ console.error("Error", error);
788
+ }
789
+ );
327
790
  // Annotate the CommonJS export names for ESM import in node:
328
791
  0 && (module.exports = {
329
- TypedApiToastProvider,
330
792
  buildQuery,
331
- extractArgsToastsAndParams,
793
+ extractArgsCallbacksAndParams,
332
794
  getSortDirectionFromSortType,
333
795
  getSortTypeFromSortDirection,
334
796
  handleApiResponse,
335
- resetUnauthorizedHandling,
336
797
  sortTypes,
337
- toFormData,
338
- toast
798
+ toFormData
339
799
  });