typedapi-client-helpers 0.1.5 → 0.1.7
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 +314 -676
- package/dist/api/generated/Import.d.ts +22 -0
- package/dist/api/generated/Import.d.ts.map +1 -0
- package/dist/api/generated/Import.js +48 -0
- package/dist/api/generated/Import.js.map +1 -0
- package/dist/api/generated/ImportRoute.d.ts +30 -0
- package/dist/api/generated/ImportRoute.d.ts.map +1 -0
- package/dist/api/generated/ImportRoute.js +13 -0
- package/dist/api/generated/ImportRoute.js.map +1 -0
- package/dist/api/generated/Order.d.ts +38 -0
- package/dist/api/generated/Order.d.ts.map +1 -0
- package/dist/api/generated/Order.js +75 -0
- package/dist/api/generated/Order.js.map +1 -0
- package/dist/api/generated/OrderRoute.d.ts +83 -0
- package/dist/api/generated/OrderRoute.d.ts.map +1 -0
- package/dist/api/generated/OrderRoute.js +13 -0
- package/dist/api/generated/OrderRoute.js.map +1 -0
- package/dist/api/generated/Product.d.ts +62 -0
- package/dist/api/generated/Product.d.ts.map +1 -0
- package/dist/api/generated/Product.js +114 -0
- package/dist/api/generated/Product.js.map +1 -0
- package/dist/api/generated/ProductRoute.d.ts +140 -0
- package/dist/api/generated/ProductRoute.d.ts.map +1 -0
- package/dist/api/generated/ProductRoute.js +13 -0
- package/dist/api/generated/ProductRoute.js.map +1 -0
- package/dist/api/generated/Report.d.ts +14 -0
- package/dist/api/generated/Report.d.ts.map +1 -0
- package/dist/api/generated/Report.js +32 -0
- package/dist/api/generated/Report.js.map +1 -0
- package/dist/api/generated/ReportRoute.d.ts +23 -0
- package/dist/api/generated/ReportRoute.d.ts.map +1 -0
- package/dist/api/generated/ReportRoute.js +13 -0
- package/dist/api/generated/ReportRoute.js.map +1 -0
- package/dist/api/generated/Supplier.d.ts +46 -0
- package/dist/api/generated/Supplier.d.ts.map +1 -0
- package/dist/api/generated/Supplier.js +87 -0
- package/dist/api/generated/Supplier.js.map +1 -0
- package/dist/api/generated/SupplierRoute.d.ts +101 -0
- package/dist/api/generated/SupplierRoute.d.ts.map +1 -0
- package/dist/api/generated/SupplierRoute.js +13 -0
- package/dist/api/generated/SupplierRoute.js.map +1 -0
- package/dist/api/generated/data-contracts.d.ts +277 -0
- package/dist/api/generated/data-contracts.d.ts.map +1 -0
- package/dist/api/generated/data-contracts.js +26 -0
- package/dist/api/generated/data-contracts.js.map +1 -0
- package/dist/api/generated/http-client.d.ts +61 -0
- package/dist/api/generated/http-client.d.ts.map +1 -0
- package/dist/api/generated/http-client.js +171 -0
- package/dist/api/generated/http-client.js.map +1 -0
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/methods/Import.api.d.ts +6 -0
- package/dist/api/methods/Import.api.d.ts.map +1 -0
- package/dist/api/methods/Import.api.js +27 -0
- package/dist/api/methods/Import.api.js.map +1 -0
- package/dist/api/methods/Order.api.d.ts +29 -0
- package/dist/api/methods/Order.api.d.ts.map +1 -0
- package/dist/api/methods/Order.api.js +52 -0
- package/dist/api/methods/Order.api.js.map +1 -0
- package/dist/api/methods/Product.api.d.ts +39 -0
- package/dist/api/methods/Product.api.d.ts.map +1 -0
- package/dist/api/methods/Product.api.js +69 -0
- package/dist/api/methods/Product.api.js.map +1 -0
- package/dist/api/methods/Report.api.d.ts +6 -0
- package/dist/api/methods/Report.api.d.ts.map +1 -0
- package/dist/api/methods/Report.api.js +19 -0
- package/dist/api/methods/Report.api.js.map +1 -0
- package/dist/api/methods/Supplier.api.d.ts +35 -0
- package/dist/api/methods/Supplier.api.d.ts.map +1 -0
- package/dist/api/methods/Supplier.api.js +63 -0
- package/dist/api/methods/Supplier.api.js.map +1 -0
- package/dist/index.cjs +47 -551
- package/dist/index.d.cts +108 -18
- package/dist/index.d.ts +108 -18
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -551
- package/dist/index.js.map +1 -0
- package/dist/interfaces/ApiResult.d.ts +17 -0
- package/dist/interfaces/ApiResult.d.ts.map +1 -0
- package/dist/interfaces/ApiResult.js +2 -0
- package/dist/interfaces/ApiResult.js.map +1 -0
- package/dist/interfaces/Filter.d.ts +31 -0
- package/dist/interfaces/Filter.d.ts.map +1 -0
- package/dist/interfaces/Filter.js +2 -0
- package/dist/interfaces/Filter.js.map +1 -0
- package/dist/interfaces/SortType.d.ts +7 -0
- package/dist/interfaces/SortType.d.ts.map +1 -0
- package/dist/interfaces/SortType.js +2 -0
- package/dist/interfaces/SortType.js.map +1 -0
- package/dist/types/ApiCallOptions.d.ts +9 -0
- package/dist/types/ApiCallOptions.d.ts.map +1 -0
- package/dist/types/ApiCallOptions.js +2 -0
- package/dist/types/ApiCallOptions.js.map +1 -0
- package/dist/types/ApiMethodTypes.d.ts +24 -0
- package/dist/types/ApiMethodTypes.d.ts.map +1 -0
- package/dist/types/ApiMethodTypes.js +2 -0
- package/dist/types/ApiMethodTypes.js.map +1 -0
- package/dist/types/HttpResponse.d.ts +16 -0
- package/dist/types/HttpResponse.d.ts.map +1 -0
- package/dist/types/HttpResponse.js +2 -0
- package/dist/types/HttpResponse.js.map +1 -0
- package/dist/utils/SortTypeFromSortDirection.d.ts +22 -0
- package/dist/utils/SortTypeFromSortDirection.d.ts.map +1 -0
- package/dist/utils/SortTypeFromSortDirection.js +45 -0
- package/dist/utils/SortTypeFromSortDirection.js.map +1 -0
- package/dist/utils/buildQuery.d.ts +11 -0
- package/dist/utils/buildQuery.d.ts.map +1 -0
- package/dist/utils/buildQuery.js +94 -0
- package/dist/utils/buildQuery.js.map +1 -0
- package/dist/utils/extractArgsCallbacksAndParams.d.ts +22 -0
- package/dist/utils/extractArgsCallbacksAndParams.d.ts.map +1 -0
- package/dist/utils/extractArgsCallbacksAndParams.js +44 -0
- package/dist/utils/extractArgsCallbacksAndParams.js.map +1 -0
- package/dist/utils/extractArgsToastsAndParams.d.ts +18 -0
- package/dist/utils/extractArgsToastsAndParams.d.ts.map +1 -0
- package/dist/utils/extractArgsToastsAndParams.js +40 -0
- package/dist/utils/extractArgsToastsAndParams.js.map +1 -0
- package/dist/utils/handleApiResponse.d.ts +9 -0
- package/dist/utils/handleApiResponse.d.ts.map +1 -0
- package/dist/utils/handleApiResponse.js +49 -0
- package/dist/utils/handleApiResponse.js.map +1 -0
- package/dist/utils/toFormData.d.ts +8 -0
- package/dist/utils/toFormData.d.ts.map +1 -0
- package/dist/utils/toFormData.js +68 -0
- package/dist/utils/toFormData.js.map +1 -0
- package/package.json +11 -3
- package/scripts/generate-api-minimal.mjs +263 -25
package/dist/index.js
CHANGED
|
@@ -73,7 +73,7 @@ function isCallback(value) {
|
|
|
73
73
|
function isRequestParams(value) {
|
|
74
74
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function extractArgsToastsAndParams(argsWithCallbacks) {
|
|
77
77
|
const values = [...argsWithCallbacks];
|
|
78
78
|
let onSuccess;
|
|
79
79
|
let onError;
|
|
@@ -101,6 +101,41 @@ function extractArgsCallbacksAndParams(argsWithCallbacks) {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
// src/utils/extractArgsCallbacksAndParams.ts
|
|
105
|
+
function isCallback2(value) {
|
|
106
|
+
return typeof value === "function";
|
|
107
|
+
}
|
|
108
|
+
function isRequestParams2(value) {
|
|
109
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
110
|
+
}
|
|
111
|
+
function extractArgsCallbacksAndParams(argsWithCallbacks) {
|
|
112
|
+
const values = [...argsWithCallbacks];
|
|
113
|
+
let onSuccess;
|
|
114
|
+
let onError;
|
|
115
|
+
let params;
|
|
116
|
+
let lastArgument = values[values.length - 1];
|
|
117
|
+
if (isRequestParams2(lastArgument)) {
|
|
118
|
+
params = lastArgument;
|
|
119
|
+
values.pop();
|
|
120
|
+
}
|
|
121
|
+
lastArgument = values[values.length - 1];
|
|
122
|
+
if (isCallback2(lastArgument)) {
|
|
123
|
+
onError = lastArgument;
|
|
124
|
+
values.pop();
|
|
125
|
+
}
|
|
126
|
+
lastArgument = values[values.length - 1];
|
|
127
|
+
if (isCallback2(lastArgument)) {
|
|
128
|
+
onSuccess = lastArgument;
|
|
129
|
+
values.pop();
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
args: values,
|
|
133
|
+
onSuccess,
|
|
134
|
+
onError,
|
|
135
|
+
params
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
104
139
|
// src/utils/handleApiResponse.ts
|
|
105
140
|
async function readResponseBody(response) {
|
|
106
141
|
if (response.status === 204) {
|
|
@@ -122,29 +157,32 @@ async function handleApiResponse(call, options) {
|
|
|
122
157
|
response = await call();
|
|
123
158
|
const data = await readResponseBody(response);
|
|
124
159
|
if (response.ok) {
|
|
125
|
-
|
|
126
|
-
return {
|
|
160
|
+
const result2 = {
|
|
127
161
|
ok: true,
|
|
128
162
|
status: response.status,
|
|
129
163
|
response: data
|
|
130
164
|
};
|
|
165
|
+
await options?.onSuccess?.(result2);
|
|
166
|
+
return result2;
|
|
131
167
|
}
|
|
132
168
|
const errorData = data;
|
|
133
|
-
|
|
134
|
-
return {
|
|
169
|
+
const result = {
|
|
135
170
|
ok: false,
|
|
136
171
|
status: response.status,
|
|
137
172
|
response: data,
|
|
138
173
|
error: errorData
|
|
139
174
|
};
|
|
175
|
+
await options?.onError?.(result);
|
|
176
|
+
return result;
|
|
140
177
|
} catch (error) {
|
|
141
|
-
|
|
142
|
-
return {
|
|
178
|
+
const result = {
|
|
143
179
|
ok: false,
|
|
144
180
|
status: error instanceof Response ? error.status : response?.status ?? 0,
|
|
145
181
|
response: void 0,
|
|
146
182
|
error
|
|
147
183
|
};
|
|
184
|
+
await options?.onError?.(result);
|
|
185
|
+
return result;
|
|
148
186
|
}
|
|
149
187
|
}
|
|
150
188
|
|
|
@@ -179,514 +217,6 @@ function getSortDirectionFromSortType(sortType) {
|
|
|
179
217
|
}
|
|
180
218
|
}
|
|
181
219
|
|
|
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
|
-
|
|
690
220
|
// src/utils/toFormData.ts
|
|
691
221
|
function toFormData(payload) {
|
|
692
222
|
const formData = new FormData();
|
|
@@ -719,45 +249,10 @@ function appendFormDataValue(formData, key, value) {
|
|
|
719
249
|
}
|
|
720
250
|
formData.append(key, JSON.stringify(value));
|
|
721
251
|
}
|
|
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
|
-
);
|
|
758
252
|
export {
|
|
759
253
|
buildQuery,
|
|
760
254
|
extractArgsCallbacksAndParams,
|
|
255
|
+
extractArgsToastsAndParams,
|
|
761
256
|
getSortDirectionFromSortType,
|
|
762
257
|
getSortTypeFromSortDirection,
|
|
763
258
|
handleApiResponse,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oCAAoC,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard result wrapper for API calls.
|
|
3
|
+
*
|
|
4
|
+
* When `ok` is true, the request succeeded and `response` contains the expected data.
|
|
5
|
+
* When `ok` is false, the request failed and `error` contains the thrown or returned error value.
|
|
6
|
+
*/
|
|
7
|
+
export type ApiResult<T> = {
|
|
8
|
+
ok: true;
|
|
9
|
+
status: number;
|
|
10
|
+
response: T;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
status: number;
|
|
14
|
+
response?: T;
|
|
15
|
+
error: unknown;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=ApiResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiResult.d.ts","sourceRoot":"","sources":["../../src/interfaces/ApiResult.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,CAAC;CACb,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiResult.js","sourceRoot":"","sources":["../../src/interfaces/ApiResult.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported filter input types used by typed filter forms.
|
|
3
|
+
*
|
|
4
|
+
* These values decide which UI input should be rendered for a filter.
|
|
5
|
+
*/
|
|
6
|
+
export type FilterType = "number" | "date" | "string" | "timespan" | "boolean" | "boolean-button" | "OptionValue";
|
|
7
|
+
/**
|
|
8
|
+
* Selectable option value used by option-based filters.
|
|
9
|
+
*
|
|
10
|
+
* `name` is shown in the UI and `value` is sent as the actual filter value.
|
|
11
|
+
*/
|
|
12
|
+
export interface OptionValue {
|
|
13
|
+
name: string;
|
|
14
|
+
value: number | string | Date;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for one filter field in a typed filter form.
|
|
18
|
+
*
|
|
19
|
+
* `filterName` maps the form value to a query property.
|
|
20
|
+
* `filterNameMax` can be used for range filters such as dates or numbers.
|
|
21
|
+
*/
|
|
22
|
+
export interface FilterFormValues<TQuery> {
|
|
23
|
+
name: string;
|
|
24
|
+
filterName: keyof TQuery;
|
|
25
|
+
filterNameMax?: keyof TQuery;
|
|
26
|
+
type: FilterType;
|
|
27
|
+
value: number | string | Date | boolean | null | OptionValue[] | string[];
|
|
28
|
+
maxValue?: number | string | Date | null;
|
|
29
|
+
isAList: boolean;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Filter.d.ts.map
|