@horpynka/api-sdk 1.0.10 → 1.0.12

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.js CHANGED
@@ -267,6 +267,208 @@ var AuthApi = class extends BaseAPI {
267
267
  return AuthApiFp(this.configuration).signUp(signUpUserDTO, options).then((request) => request(this.axios, this.basePath));
268
268
  }
269
269
  };
270
+ var CategoriesApiAxiosParamCreator = function(configuration) {
271
+ return {
272
+ /**
273
+ *
274
+ * @param {*} [options] Override http request option.
275
+ * @throws {RequiredError}
276
+ */
277
+ findAll: async (options = {}) => {
278
+ const localVarPath = `/categories`;
279
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
280
+ let baseOptions;
281
+ if (configuration) {
282
+ baseOptions = configuration.baseOptions;
283
+ }
284
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
285
+ const localVarHeaderParameter = {};
286
+ const localVarQueryParameter = {};
287
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
288
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
289
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
290
+ return {
291
+ url: toPathString(localVarUrlObj),
292
+ options: localVarRequestOptions
293
+ };
294
+ },
295
+ /**
296
+ *
297
+ * @param {number} id
298
+ * @param {*} [options] Override http request option.
299
+ * @throws {RequiredError}
300
+ */
301
+ findOne: async (id, options = {}) => {
302
+ assertParamExists("findOne", "id", id);
303
+ const localVarPath = `/categories/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(id)));
304
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
305
+ let baseOptions;
306
+ if (configuration) {
307
+ baseOptions = configuration.baseOptions;
308
+ }
309
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
310
+ const localVarHeaderParameter = {};
311
+ const localVarQueryParameter = {};
312
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
313
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
314
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
315
+ return {
316
+ url: toPathString(localVarUrlObj),
317
+ options: localVarRequestOptions
318
+ };
319
+ }
320
+ };
321
+ };
322
+ var CategoriesApiFp = function(configuration) {
323
+ const localVarAxiosParamCreator = CategoriesApiAxiosParamCreator(configuration);
324
+ return {
325
+ /**
326
+ *
327
+ * @param {*} [options] Override http request option.
328
+ * @throws {RequiredError}
329
+ */
330
+ async findAll(options) {
331
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
332
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
333
+ const localVarOperationServerBasePath = operationServerMap["CategoriesApi.findAll"]?.[localVarOperationServerIndex]?.url;
334
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
335
+ },
336
+ /**
337
+ *
338
+ * @param {number} id
339
+ * @param {*} [options] Override http request option.
340
+ * @throws {RequiredError}
341
+ */
342
+ async findOne(id, options) {
343
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findOne(id, options);
344
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
345
+ const localVarOperationServerBasePath = operationServerMap["CategoriesApi.findOne"]?.[localVarOperationServerIndex]?.url;
346
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
347
+ }
348
+ };
349
+ };
350
+ var CategoriesApi = class extends BaseAPI {
351
+ /**
352
+ *
353
+ * @param {*} [options] Override http request option.
354
+ * @throws {RequiredError}
355
+ * @memberof CategoriesApi
356
+ */
357
+ findAll(options) {
358
+ return CategoriesApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
359
+ }
360
+ /**
361
+ *
362
+ * @param {number} id
363
+ * @param {*} [options] Override http request option.
364
+ * @throws {RequiredError}
365
+ * @memberof CategoriesApi
366
+ */
367
+ findOne(id, options) {
368
+ return CategoriesApiFp(this.configuration).findOne(id, options).then((request) => request(this.axios, this.basePath));
369
+ }
370
+ };
371
+ var DishesApiAxiosParamCreator = function(configuration) {
372
+ return {
373
+ /**
374
+ *
375
+ * @param {*} [options] Override http request option.
376
+ * @throws {RequiredError}
377
+ */
378
+ findAll: async (options = {}) => {
379
+ const localVarPath = `/dishes`;
380
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
381
+ let baseOptions;
382
+ if (configuration) {
383
+ baseOptions = configuration.baseOptions;
384
+ }
385
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
386
+ const localVarHeaderParameter = {};
387
+ const localVarQueryParameter = {};
388
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
389
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
390
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
391
+ return {
392
+ url: toPathString(localVarUrlObj),
393
+ options: localVarRequestOptions
394
+ };
395
+ },
396
+ /**
397
+ *
398
+ * @param {number} id
399
+ * @param {*} [options] Override http request option.
400
+ * @throws {RequiredError}
401
+ */
402
+ findOne: async (id, options = {}) => {
403
+ assertParamExists("findOne", "id", id);
404
+ const localVarPath = `/dishes/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(id)));
405
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
406
+ let baseOptions;
407
+ if (configuration) {
408
+ baseOptions = configuration.baseOptions;
409
+ }
410
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
411
+ const localVarHeaderParameter = {};
412
+ const localVarQueryParameter = {};
413
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
414
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
415
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
416
+ return {
417
+ url: toPathString(localVarUrlObj),
418
+ options: localVarRequestOptions
419
+ };
420
+ }
421
+ };
422
+ };
423
+ var DishesApiFp = function(configuration) {
424
+ const localVarAxiosParamCreator = DishesApiAxiosParamCreator(configuration);
425
+ return {
426
+ /**
427
+ *
428
+ * @param {*} [options] Override http request option.
429
+ * @throws {RequiredError}
430
+ */
431
+ async findAll(options) {
432
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
433
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
434
+ const localVarOperationServerBasePath = operationServerMap["DishesApi.findAll"]?.[localVarOperationServerIndex]?.url;
435
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
436
+ },
437
+ /**
438
+ *
439
+ * @param {number} id
440
+ * @param {*} [options] Override http request option.
441
+ * @throws {RequiredError}
442
+ */
443
+ async findOne(id, options) {
444
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findOne(id, options);
445
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
446
+ const localVarOperationServerBasePath = operationServerMap["DishesApi.findOne"]?.[localVarOperationServerIndex]?.url;
447
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
448
+ }
449
+ };
450
+ };
451
+ var DishesApi = class extends BaseAPI {
452
+ /**
453
+ *
454
+ * @param {*} [options] Override http request option.
455
+ * @throws {RequiredError}
456
+ * @memberof DishesApi
457
+ */
458
+ findAll(options) {
459
+ return DishesApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
460
+ }
461
+ /**
462
+ *
463
+ * @param {number} id
464
+ * @param {*} [options] Override http request option.
465
+ * @throws {RequiredError}
466
+ * @memberof DishesApi
467
+ */
468
+ findOne(id, options) {
469
+ return DishesApiFp(this.configuration).findOne(id, options).then((request) => request(this.axios, this.basePath));
470
+ }
471
+ };
270
472
  var OrdersApiAxiosParamCreator = function(configuration) {
271
473
  return {
272
474
  /**
@@ -535,6 +737,107 @@ var OrdersApi = class extends BaseAPI {
535
737
  return OrdersApiFp(this.configuration).update(id, updateOrderDto, options).then((request) => request(this.axios, this.basePath));
536
738
  }
537
739
  };
740
+ var ProductsApiAxiosParamCreator = function(configuration) {
741
+ return {
742
+ /**
743
+ *
744
+ * @param {*} [options] Override http request option.
745
+ * @throws {RequiredError}
746
+ */
747
+ findAll: async (options = {}) => {
748
+ const localVarPath = `/products`;
749
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
750
+ let baseOptions;
751
+ if (configuration) {
752
+ baseOptions = configuration.baseOptions;
753
+ }
754
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
755
+ const localVarHeaderParameter = {};
756
+ const localVarQueryParameter = {};
757
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
758
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
759
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
760
+ return {
761
+ url: toPathString(localVarUrlObj),
762
+ options: localVarRequestOptions
763
+ };
764
+ },
765
+ /**
766
+ *
767
+ * @param {number} id
768
+ * @param {*} [options] Override http request option.
769
+ * @throws {RequiredError}
770
+ */
771
+ findOne: async (id, options = {}) => {
772
+ assertParamExists("findOne", "id", id);
773
+ const localVarPath = `/products/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(id)));
774
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
775
+ let baseOptions;
776
+ if (configuration) {
777
+ baseOptions = configuration.baseOptions;
778
+ }
779
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
780
+ const localVarHeaderParameter = {};
781
+ const localVarQueryParameter = {};
782
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
783
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
784
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
785
+ return {
786
+ url: toPathString(localVarUrlObj),
787
+ options: localVarRequestOptions
788
+ };
789
+ }
790
+ };
791
+ };
792
+ var ProductsApiFp = function(configuration) {
793
+ const localVarAxiosParamCreator = ProductsApiAxiosParamCreator(configuration);
794
+ return {
795
+ /**
796
+ *
797
+ * @param {*} [options] Override http request option.
798
+ * @throws {RequiredError}
799
+ */
800
+ async findAll(options) {
801
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
802
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
803
+ const localVarOperationServerBasePath = operationServerMap["ProductsApi.findAll"]?.[localVarOperationServerIndex]?.url;
804
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
805
+ },
806
+ /**
807
+ *
808
+ * @param {number} id
809
+ * @param {*} [options] Override http request option.
810
+ * @throws {RequiredError}
811
+ */
812
+ async findOne(id, options) {
813
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findOne(id, options);
814
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
815
+ const localVarOperationServerBasePath = operationServerMap["ProductsApi.findOne"]?.[localVarOperationServerIndex]?.url;
816
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
817
+ }
818
+ };
819
+ };
820
+ var ProductsApi = class extends BaseAPI {
821
+ /**
822
+ *
823
+ * @param {*} [options] Override http request option.
824
+ * @throws {RequiredError}
825
+ * @memberof ProductsApi
826
+ */
827
+ findAll(options) {
828
+ return ProductsApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
829
+ }
830
+ /**
831
+ *
832
+ * @param {number} id
833
+ * @param {*} [options] Override http request option.
834
+ * @throws {RequiredError}
835
+ * @memberof ProductsApi
836
+ */
837
+ findOne(id, options) {
838
+ return ProductsApiFp(this.configuration).findOne(id, options).then((request) => request(this.axios, this.basePath));
839
+ }
840
+ };
538
841
 
539
842
  // src/api/generated/configuration.ts
540
843
  var Configuration = class {
@@ -625,8 +928,11 @@ var Configuration = class {
625
928
  }
626
929
  };
627
930
  var tanstackClient;
628
- var ordersApi;
629
931
  var authApi;
932
+ var categoriesApi;
933
+ var dishesApi;
934
+ var ordersApi;
935
+ var productsApi;
630
936
  function initApiClient(config) {
631
937
  const apiClient = globalAxios2.create({
632
938
  baseURL: config.baseURL,
@@ -636,16 +942,89 @@ function initApiClient(config) {
636
942
  basePath: config.baseURL
637
943
  });
638
944
  tanstackClient = new QueryClient();
639
- ordersApi = new OrdersApi(configuration, void 0, apiClient);
640
945
  authApi = new AuthApi(configuration, void 0, apiClient);
946
+ categoriesApi = new CategoriesApi(configuration, void 0, apiClient);
947
+ dishesApi = new DishesApi(configuration, void 0, apiClient);
948
+ ordersApi = new OrdersApi(configuration, void 0, apiClient);
949
+ productsApi = new ProductsApi(configuration, void 0, apiClient);
641
950
  return apiClient;
642
951
  }
952
+ var useAuthApi = () => {
953
+ const queryClient = useQueryClient();
954
+ const mutateRefresh = useMutation({
955
+ mutationFn: ({ onSettledCallback } = {}) => authApi.refresh(),
956
+ onSettled: (_data, _error, variables) => {
957
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
958
+ variables?.onSettledCallback && variables.onSettledCallback();
959
+ }
960
+ });
961
+ const mutateSignIn = useMutation({
962
+ mutationFn: ({ params: { signInUserDTO } }) => authApi.signIn(signInUserDTO),
963
+ onSettled: (_data, _error, { onSettledCallback }) => {
964
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
965
+ onSettledCallback && onSettledCallback();
966
+ }
967
+ });
968
+ const mutateSignUp = useMutation({
969
+ mutationFn: ({ params: { signUpUserDTO } }) => authApi.signUp(signUpUserDTO),
970
+ onSettled: (_data, _error, { onSettledCallback }) => {
971
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
972
+ onSettledCallback && onSettledCallback();
973
+ }
974
+ });
975
+ return {
976
+ mutateRefresh,
977
+ mutateSignIn,
978
+ mutateSignUp
979
+ };
980
+ };
981
+ var getCategoriesQuery = () => queryOptions({
982
+ queryKey: ["categories"],
983
+ queryFn: () => categoriesApi.findAll().then((res) => res.data)
984
+ });
985
+ var useCategoriesApi = () => {
986
+ return {
987
+ getCategoriesQuery
988
+ };
989
+ };
990
+ var getDishesQuery = () => queryOptions({
991
+ queryKey: ["dishes"],
992
+ queryFn: () => dishesApi.findAll().then((res) => res.data)
993
+ });
994
+ var getDishQuery = (id) => queryOptions({
995
+ queryKey: ["dishes", id],
996
+ queryFn: () => dishesApi.findOne(id).then((res) => res.data)
997
+ });
998
+ var useDishesApi = () => {
999
+ return {
1000
+ getDishesQuery,
1001
+ getDishQuery
1002
+ };
1003
+ };
643
1004
  var getOrdersQuery = (params) => queryOptions({
644
1005
  queryKey: ["orders", params],
645
1006
  queryFn: () => ordersApi.findAll(params?.page, params?.limit, params?.status).then((res) => res.data)
646
1007
  });
1008
+ var getOrderQuery = (id) => queryOptions({
1009
+ queryKey: ["orders", id],
1010
+ queryFn: () => ordersApi.findOne(id).then((res) => res.data)
1011
+ });
647
1012
  var useOrdersApi = () => {
648
1013
  const queryClient = useQueryClient();
1014
+ const mutateCreateOrder = useMutation({
1015
+ mutationFn: ({ params: { createOrderDto } }) => ordersApi.create(createOrderDto),
1016
+ onSettled: (_data, _error, { onSettledCallback }) => {
1017
+ queryClient.invalidateQueries({ queryKey: ["orders"] });
1018
+ onSettledCallback && onSettledCallback();
1019
+ }
1020
+ });
1021
+ const mutateUpdateOrder = useMutation({
1022
+ mutationFn: ({ params: { id, updateOrderDto } }) => ordersApi.update(id, updateOrderDto),
1023
+ onSettled: (_data, _error, { onSettledCallback }) => {
1024
+ queryClient.invalidateQueries({ queryKey: ["orders"] });
1025
+ onSettledCallback && onSettledCallback();
1026
+ }
1027
+ });
649
1028
  const mutateDeleteReceipt = useMutation({
650
1029
  mutationFn: ({ params: { id } }) => ordersApi.removeActiveReceipt(id),
651
1030
  onSettled: (_data, _error, { onSettledCallback }) => {
@@ -654,11 +1033,23 @@ var useOrdersApi = () => {
654
1033
  }
655
1034
  });
656
1035
  return {
657
- mutateDeleteReceipt,
658
- getOrdersQuery
1036
+ getOrdersQuery,
1037
+ getOrderQuery,
1038
+ mutateCreateOrder,
1039
+ mutateUpdateOrder,
1040
+ mutateDeleteReceipt
1041
+ };
1042
+ };
1043
+ var getProductsQuery = () => queryOptions({
1044
+ queryKey: ["products"],
1045
+ queryFn: () => productsApi.findAll().then((res) => res.data)
1046
+ });
1047
+ var useProductsApi = () => {
1048
+ return {
1049
+ getProductsQuery
659
1050
  };
660
1051
  };
661
1052
 
662
- export { authApi, initApiClient, ordersApi, tanstackClient, useOrdersApi };
1053
+ export { authApi, categoriesApi, dishesApi, initApiClient, ordersApi, productsApi, tanstackClient, useAuthApi, useCategoriesApi, useDishesApi, useOrdersApi, useProductsApi };
663
1054
  //# sourceMappingURL=index.js.map
664
1055
  //# sourceMappingURL=index.js.map