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