@horpynka/api-sdk 1.0.9 → 1.0.11

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
@@ -80,6 +80,29 @@ var createRequestFunction = function(axiosArgs, globalAxios3, BASE_PATH2, config
80
80
  // src/api/generated/api.ts
81
81
  var AuthApiAxiosParamCreator = function(configuration) {
82
82
  return {
83
+ /**
84
+ *
85
+ * @param {*} [options] Override http request option.
86
+ * @throws {RequiredError}
87
+ */
88
+ getSession: async (options = {}) => {
89
+ const localVarPath = `/auth/get-session`;
90
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
91
+ let baseOptions;
92
+ if (configuration) {
93
+ baseOptions = configuration.baseOptions;
94
+ }
95
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
96
+ const localVarHeaderParameter = {};
97
+ const localVarQueryParameter = {};
98
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
99
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
100
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
101
+ return {
102
+ url: toPathString(localVarUrlObj),
103
+ options: localVarRequestOptions
104
+ };
105
+ },
83
106
  /**
84
107
  *
85
108
  * @param {*} [options] Override http request option.
@@ -162,6 +185,17 @@ var AuthApiAxiosParamCreator = function(configuration) {
162
185
  var AuthApiFp = function(configuration) {
163
186
  const localVarAxiosParamCreator = AuthApiAxiosParamCreator(configuration);
164
187
  return {
188
+ /**
189
+ *
190
+ * @param {*} [options] Override http request option.
191
+ * @throws {RequiredError}
192
+ */
193
+ async getSession(options) {
194
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getSession(options);
195
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
196
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.getSession"]?.[localVarOperationServerIndex]?.url;
197
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
198
+ },
165
199
  /**
166
200
  *
167
201
  * @param {*} [options] Override http request option.
@@ -200,6 +234,15 @@ var AuthApiFp = function(configuration) {
200
234
  };
201
235
  };
202
236
  var AuthApi = class extends BaseAPI {
237
+ /**
238
+ *
239
+ * @param {*} [options] Override http request option.
240
+ * @throws {RequiredError}
241
+ * @memberof AuthApi
242
+ */
243
+ getSession(options) {
244
+ return AuthApiFp(this.configuration).getSession(options).then((request) => request(this.axios, this.basePath));
245
+ }
203
246
  /**
204
247
  *
205
248
  * @param {*} [options] Override http request option.
@@ -230,6 +273,161 @@ var AuthApi = class extends BaseAPI {
230
273
  return AuthApiFp(this.configuration).signUp(signUpUserDTO, options).then((request) => request(this.axios, this.basePath));
231
274
  }
232
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
+ var CategoriesApiFp = function(configuration) {
304
+ const localVarAxiosParamCreator = CategoriesApiAxiosParamCreator(configuration);
305
+ return {
306
+ /**
307
+ *
308
+ * @param {*} [options] Override http request option.
309
+ * @throws {RequiredError}
310
+ */
311
+ async findAll(options) {
312
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
313
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
314
+ const localVarOperationServerBasePath = operationServerMap["CategoriesApi.findAll"]?.[localVarOperationServerIndex]?.url;
315
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
316
+ }
317
+ };
318
+ };
319
+ var CategoriesApi = class extends BaseAPI {
320
+ /**
321
+ *
322
+ * @param {*} [options] Override http request option.
323
+ * @throws {RequiredError}
324
+ * @memberof CategoriesApi
325
+ */
326
+ findAll(options) {
327
+ return CategoriesApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
328
+ }
329
+ };
330
+ var DishesApiAxiosParamCreator = function(configuration) {
331
+ return {
332
+ /**
333
+ *
334
+ * @param {*} [options] Override http request option.
335
+ * @throws {RequiredError}
336
+ */
337
+ findAll: async (options = {}) => {
338
+ const localVarPath = `/dishes`;
339
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
340
+ let baseOptions;
341
+ if (configuration) {
342
+ baseOptions = configuration.baseOptions;
343
+ }
344
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
345
+ const localVarHeaderParameter = {};
346
+ const localVarQueryParameter = {};
347
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
348
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
349
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
350
+ return {
351
+ url: toPathString(localVarUrlObj),
352
+ options: localVarRequestOptions
353
+ };
354
+ },
355
+ /**
356
+ *
357
+ * @param {number} id
358
+ * @param {*} [options] Override http request option.
359
+ * @throws {RequiredError}
360
+ */
361
+ findOne: async (id, options = {}) => {
362
+ assertParamExists("findOne", "id", id);
363
+ const localVarPath = `/dishes/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(id)));
364
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
365
+ let baseOptions;
366
+ if (configuration) {
367
+ baseOptions = configuration.baseOptions;
368
+ }
369
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
370
+ const localVarHeaderParameter = {};
371
+ const localVarQueryParameter = {};
372
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
373
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
374
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
375
+ return {
376
+ url: toPathString(localVarUrlObj),
377
+ options: localVarRequestOptions
378
+ };
379
+ }
380
+ };
381
+ };
382
+ var DishesApiFp = function(configuration) {
383
+ const localVarAxiosParamCreator = DishesApiAxiosParamCreator(configuration);
384
+ return {
385
+ /**
386
+ *
387
+ * @param {*} [options] Override http request option.
388
+ * @throws {RequiredError}
389
+ */
390
+ async findAll(options) {
391
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
392
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
393
+ const localVarOperationServerBasePath = operationServerMap["DishesApi.findAll"]?.[localVarOperationServerIndex]?.url;
394
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
395
+ },
396
+ /**
397
+ *
398
+ * @param {number} id
399
+ * @param {*} [options] Override http request option.
400
+ * @throws {RequiredError}
401
+ */
402
+ async findOne(id, options) {
403
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findOne(id, options);
404
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
405
+ const localVarOperationServerBasePath = operationServerMap["DishesApi.findOne"]?.[localVarOperationServerIndex]?.url;
406
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
407
+ }
408
+ };
409
+ };
410
+ var DishesApi = class extends BaseAPI {
411
+ /**
412
+ *
413
+ * @param {*} [options] Override http request option.
414
+ * @throws {RequiredError}
415
+ * @memberof DishesApi
416
+ */
417
+ findAll(options) {
418
+ return DishesApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
419
+ }
420
+ /**
421
+ *
422
+ * @param {number} id
423
+ * @param {*} [options] Override http request option.
424
+ * @throws {RequiredError}
425
+ * @memberof DishesApi
426
+ */
427
+ findOne(id, options) {
428
+ return DishesApiFp(this.configuration).findOne(id, options).then((request) => request(this.axios, this.basePath));
429
+ }
430
+ };
233
431
  var OrdersApiAxiosParamCreator = function(configuration) {
234
432
  return {
235
433
  /**
@@ -498,6 +696,60 @@ var OrdersApi = class extends BaseAPI {
498
696
  return OrdersApiFp(this.configuration).update(id, updateOrderDto, options).then((request) => request(this.axios, this.basePath));
499
697
  }
500
698
  };
699
+ var ProductsApiAxiosParamCreator = function(configuration) {
700
+ return {
701
+ /**
702
+ *
703
+ * @param {*} [options] Override http request option.
704
+ * @throws {RequiredError}
705
+ */
706
+ findAll: async (options = {}) => {
707
+ const localVarPath = `/products`;
708
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
709
+ let baseOptions;
710
+ if (configuration) {
711
+ baseOptions = configuration.baseOptions;
712
+ }
713
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
714
+ const localVarHeaderParameter = {};
715
+ const localVarQueryParameter = {};
716
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
717
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
718
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
719
+ return {
720
+ url: toPathString(localVarUrlObj),
721
+ options: localVarRequestOptions
722
+ };
723
+ }
724
+ };
725
+ };
726
+ var ProductsApiFp = function(configuration) {
727
+ const localVarAxiosParamCreator = ProductsApiAxiosParamCreator(configuration);
728
+ return {
729
+ /**
730
+ *
731
+ * @param {*} [options] Override http request option.
732
+ * @throws {RequiredError}
733
+ */
734
+ async findAll(options) {
735
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
736
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
737
+ const localVarOperationServerBasePath = operationServerMap["ProductsApi.findAll"]?.[localVarOperationServerIndex]?.url;
738
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2__default.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
739
+ }
740
+ };
741
+ };
742
+ var ProductsApi = class extends BaseAPI {
743
+ /**
744
+ *
745
+ * @param {*} [options] Override http request option.
746
+ * @throws {RequiredError}
747
+ * @memberof ProductsApi
748
+ */
749
+ findAll(options) {
750
+ return ProductsApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
751
+ }
752
+ };
501
753
 
502
754
  // src/api/generated/configuration.ts
503
755
  var Configuration = class {
@@ -588,8 +840,11 @@ var Configuration = class {
588
840
  }
589
841
  };
590
842
  exports.tanstackClient = void 0;
591
- exports.ordersApi = void 0;
592
843
  exports.authApi = void 0;
844
+ exports.categoriesApi = void 0;
845
+ exports.dishesApi = void 0;
846
+ exports.ordersApi = void 0;
847
+ exports.productsApi = void 0;
593
848
  function initApiClient(config) {
594
849
  const apiClient = globalAxios2__default.default.create({
595
850
  baseURL: config.baseURL,
@@ -599,16 +854,89 @@ function initApiClient(config) {
599
854
  basePath: config.baseURL
600
855
  });
601
856
  exports.tanstackClient = new reactQuery.QueryClient();
602
- exports.ordersApi = new OrdersApi(configuration, void 0, apiClient);
603
857
  exports.authApi = new AuthApi(configuration, void 0, apiClient);
858
+ exports.categoriesApi = new CategoriesApi(configuration, void 0, apiClient);
859
+ exports.dishesApi = new DishesApi(configuration, void 0, apiClient);
860
+ exports.ordersApi = new OrdersApi(configuration, void 0, apiClient);
861
+ exports.productsApi = new ProductsApi(configuration, void 0, apiClient);
604
862
  return apiClient;
605
863
  }
864
+ var useAuthApi = () => {
865
+ const queryClient = reactQuery.useQueryClient();
866
+ const mutateRefresh = reactQuery.useMutation({
867
+ mutationFn: ({ onSettledCallback } = {}) => exports.authApi.refresh(),
868
+ onSettled: (_data, _error, variables) => {
869
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
870
+ variables?.onSettledCallback && variables.onSettledCallback();
871
+ }
872
+ });
873
+ const mutateSignIn = reactQuery.useMutation({
874
+ mutationFn: ({ params: { signInUserDTO } }) => exports.authApi.signIn(signInUserDTO),
875
+ onSettled: (_data, _error, { onSettledCallback }) => {
876
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
877
+ onSettledCallback && onSettledCallback();
878
+ }
879
+ });
880
+ const mutateSignUp = reactQuery.useMutation({
881
+ mutationFn: ({ params: { signUpUserDTO } }) => exports.authApi.signUp(signUpUserDTO),
882
+ onSettled: (_data, _error, { onSettledCallback }) => {
883
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
884
+ onSettledCallback && onSettledCallback();
885
+ }
886
+ });
887
+ return {
888
+ mutateRefresh,
889
+ mutateSignIn,
890
+ mutateSignUp
891
+ };
892
+ };
893
+ var getCategoriesQuery = () => reactQuery.queryOptions({
894
+ queryKey: ["categories"],
895
+ queryFn: () => exports.categoriesApi.findAll().then((res) => res.data)
896
+ });
897
+ var useCategoriesApi = () => {
898
+ return {
899
+ getCategoriesQuery
900
+ };
901
+ };
902
+ var getDishesQuery = () => reactQuery.queryOptions({
903
+ queryKey: ["dishes"],
904
+ queryFn: () => exports.dishesApi.findAll().then((res) => res.data)
905
+ });
906
+ var getDishQuery = (id) => reactQuery.queryOptions({
907
+ queryKey: ["dishes", id],
908
+ queryFn: () => exports.dishesApi.findOne(id).then((res) => res.data)
909
+ });
910
+ var useDishesApi = () => {
911
+ return {
912
+ getDishesQuery,
913
+ getDishQuery
914
+ };
915
+ };
606
916
  var getOrdersQuery = (params) => reactQuery.queryOptions({
607
917
  queryKey: ["orders", params],
608
918
  queryFn: () => exports.ordersApi.findAll(params?.page, params?.limit, params?.status).then((res) => res.data)
609
919
  });
920
+ var getOrderQuery = (id) => reactQuery.queryOptions({
921
+ queryKey: ["orders", id],
922
+ queryFn: () => exports.ordersApi.findOne(id).then((res) => res.data)
923
+ });
610
924
  var useOrdersApi = () => {
611
925
  const queryClient = reactQuery.useQueryClient();
926
+ const mutateCreateOrder = reactQuery.useMutation({
927
+ mutationFn: ({ params: { createOrderDto } }) => exports.ordersApi.create(createOrderDto),
928
+ onSettled: (_data, _error, { onSettledCallback }) => {
929
+ queryClient.invalidateQueries({ queryKey: ["orders"] });
930
+ onSettledCallback && onSettledCallback();
931
+ }
932
+ });
933
+ const mutateUpdateOrder = reactQuery.useMutation({
934
+ mutationFn: ({ params: { id, updateOrderDto } }) => exports.ordersApi.update(id, updateOrderDto),
935
+ onSettled: (_data, _error, { onSettledCallback }) => {
936
+ queryClient.invalidateQueries({ queryKey: ["orders"] });
937
+ onSettledCallback && onSettledCallback();
938
+ }
939
+ });
612
940
  const mutateDeleteReceipt = reactQuery.useMutation({
613
941
  mutationFn: ({ params: { id } }) => exports.ordersApi.removeActiveReceipt(id),
614
942
  onSettled: (_data, _error, { onSettledCallback }) => {
@@ -617,12 +945,28 @@ var useOrdersApi = () => {
617
945
  }
618
946
  });
619
947
  return {
620
- mutateDeleteReceipt,
621
- getOrdersQuery
948
+ getOrdersQuery,
949
+ getOrderQuery,
950
+ mutateCreateOrder,
951
+ mutateUpdateOrder,
952
+ mutateDeleteReceipt
953
+ };
954
+ };
955
+ var getProductsQuery = () => reactQuery.queryOptions({
956
+ queryKey: ["products"],
957
+ queryFn: () => exports.productsApi.findAll().then((res) => res.data)
958
+ });
959
+ var useProductsApi = () => {
960
+ return {
961
+ getProductsQuery
622
962
  };
623
963
  };
624
964
 
625
965
  exports.initApiClient = initApiClient;
966
+ exports.useAuthApi = useAuthApi;
967
+ exports.useCategoriesApi = useCategoriesApi;
968
+ exports.useDishesApi = useDishesApi;
626
969
  exports.useOrdersApi = useOrdersApi;
970
+ exports.useProductsApi = useProductsApi;
627
971
  //# sourceMappingURL=index.cjs.map
628
972
  //# sourceMappingURL=index.cjs.map