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