@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.js CHANGED
@@ -74,6 +74,29 @@ var createRequestFunction = function(axiosArgs, globalAxios3, BASE_PATH2, config
74
74
  // src/api/generated/api.ts
75
75
  var AuthApiAxiosParamCreator = function(configuration) {
76
76
  return {
77
+ /**
78
+ *
79
+ * @param {*} [options] Override http request option.
80
+ * @throws {RequiredError}
81
+ */
82
+ getSession: async (options = {}) => {
83
+ const localVarPath = `/auth/get-session`;
84
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
85
+ let baseOptions;
86
+ if (configuration) {
87
+ baseOptions = configuration.baseOptions;
88
+ }
89
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
90
+ const localVarHeaderParameter = {};
91
+ const localVarQueryParameter = {};
92
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
93
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
94
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
95
+ return {
96
+ url: toPathString(localVarUrlObj),
97
+ options: localVarRequestOptions
98
+ };
99
+ },
77
100
  /**
78
101
  *
79
102
  * @param {*} [options] Override http request option.
@@ -156,6 +179,17 @@ var AuthApiAxiosParamCreator = function(configuration) {
156
179
  var AuthApiFp = function(configuration) {
157
180
  const localVarAxiosParamCreator = AuthApiAxiosParamCreator(configuration);
158
181
  return {
182
+ /**
183
+ *
184
+ * @param {*} [options] Override http request option.
185
+ * @throws {RequiredError}
186
+ */
187
+ async getSession(options) {
188
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getSession(options);
189
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
190
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.getSession"]?.[localVarOperationServerIndex]?.url;
191
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
192
+ },
159
193
  /**
160
194
  *
161
195
  * @param {*} [options] Override http request option.
@@ -194,6 +228,15 @@ var AuthApiFp = function(configuration) {
194
228
  };
195
229
  };
196
230
  var AuthApi = class extends BaseAPI {
231
+ /**
232
+ *
233
+ * @param {*} [options] Override http request option.
234
+ * @throws {RequiredError}
235
+ * @memberof AuthApi
236
+ */
237
+ getSession(options) {
238
+ return AuthApiFp(this.configuration).getSession(options).then((request) => request(this.axios, this.basePath));
239
+ }
197
240
  /**
198
241
  *
199
242
  * @param {*} [options] Override http request option.
@@ -224,6 +267,161 @@ var AuthApi = class extends BaseAPI {
224
267
  return AuthApiFp(this.configuration).signUp(signUpUserDTO, options).then((request) => request(this.axios, this.basePath));
225
268
  }
226
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
+ var CategoriesApiFp = function(configuration) {
298
+ const localVarAxiosParamCreator = CategoriesApiAxiosParamCreator(configuration);
299
+ return {
300
+ /**
301
+ *
302
+ * @param {*} [options] Override http request option.
303
+ * @throws {RequiredError}
304
+ */
305
+ async findAll(options) {
306
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
307
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
308
+ const localVarOperationServerBasePath = operationServerMap["CategoriesApi.findAll"]?.[localVarOperationServerIndex]?.url;
309
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
310
+ }
311
+ };
312
+ };
313
+ var CategoriesApi = class extends BaseAPI {
314
+ /**
315
+ *
316
+ * @param {*} [options] Override http request option.
317
+ * @throws {RequiredError}
318
+ * @memberof CategoriesApi
319
+ */
320
+ findAll(options) {
321
+ return CategoriesApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
322
+ }
323
+ };
324
+ var DishesApiAxiosParamCreator = function(configuration) {
325
+ return {
326
+ /**
327
+ *
328
+ * @param {*} [options] Override http request option.
329
+ * @throws {RequiredError}
330
+ */
331
+ findAll: async (options = {}) => {
332
+ const localVarPath = `/dishes`;
333
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
334
+ let baseOptions;
335
+ if (configuration) {
336
+ baseOptions = configuration.baseOptions;
337
+ }
338
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
339
+ const localVarHeaderParameter = {};
340
+ const localVarQueryParameter = {};
341
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
342
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
343
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
344
+ return {
345
+ url: toPathString(localVarUrlObj),
346
+ options: localVarRequestOptions
347
+ };
348
+ },
349
+ /**
350
+ *
351
+ * @param {number} id
352
+ * @param {*} [options] Override http request option.
353
+ * @throws {RequiredError}
354
+ */
355
+ findOne: async (id, options = {}) => {
356
+ assertParamExists("findOne", "id", id);
357
+ const localVarPath = `/dishes/{id}`.replace(`{${"id"}}`, encodeURIComponent(String(id)));
358
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
359
+ let baseOptions;
360
+ if (configuration) {
361
+ baseOptions = configuration.baseOptions;
362
+ }
363
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
364
+ const localVarHeaderParameter = {};
365
+ const localVarQueryParameter = {};
366
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
367
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
368
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
369
+ return {
370
+ url: toPathString(localVarUrlObj),
371
+ options: localVarRequestOptions
372
+ };
373
+ }
374
+ };
375
+ };
376
+ var DishesApiFp = function(configuration) {
377
+ const localVarAxiosParamCreator = DishesApiAxiosParamCreator(configuration);
378
+ return {
379
+ /**
380
+ *
381
+ * @param {*} [options] Override http request option.
382
+ * @throws {RequiredError}
383
+ */
384
+ async findAll(options) {
385
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
386
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
387
+ const localVarOperationServerBasePath = operationServerMap["DishesApi.findAll"]?.[localVarOperationServerIndex]?.url;
388
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
389
+ },
390
+ /**
391
+ *
392
+ * @param {number} id
393
+ * @param {*} [options] Override http request option.
394
+ * @throws {RequiredError}
395
+ */
396
+ async findOne(id, options) {
397
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findOne(id, options);
398
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
399
+ const localVarOperationServerBasePath = operationServerMap["DishesApi.findOne"]?.[localVarOperationServerIndex]?.url;
400
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
401
+ }
402
+ };
403
+ };
404
+ var DishesApi = class extends BaseAPI {
405
+ /**
406
+ *
407
+ * @param {*} [options] Override http request option.
408
+ * @throws {RequiredError}
409
+ * @memberof DishesApi
410
+ */
411
+ findAll(options) {
412
+ return DishesApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
413
+ }
414
+ /**
415
+ *
416
+ * @param {number} id
417
+ * @param {*} [options] Override http request option.
418
+ * @throws {RequiredError}
419
+ * @memberof DishesApi
420
+ */
421
+ findOne(id, options) {
422
+ return DishesApiFp(this.configuration).findOne(id, options).then((request) => request(this.axios, this.basePath));
423
+ }
424
+ };
227
425
  var OrdersApiAxiosParamCreator = function(configuration) {
228
426
  return {
229
427
  /**
@@ -492,6 +690,60 @@ var OrdersApi = class extends BaseAPI {
492
690
  return OrdersApiFp(this.configuration).update(id, updateOrderDto, options).then((request) => request(this.axios, this.basePath));
493
691
  }
494
692
  };
693
+ var ProductsApiAxiosParamCreator = function(configuration) {
694
+ return {
695
+ /**
696
+ *
697
+ * @param {*} [options] Override http request option.
698
+ * @throws {RequiredError}
699
+ */
700
+ findAll: async (options = {}) => {
701
+ const localVarPath = `/products`;
702
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
703
+ let baseOptions;
704
+ if (configuration) {
705
+ baseOptions = configuration.baseOptions;
706
+ }
707
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
708
+ const localVarHeaderParameter = {};
709
+ const localVarQueryParameter = {};
710
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
711
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
712
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
713
+ return {
714
+ url: toPathString(localVarUrlObj),
715
+ options: localVarRequestOptions
716
+ };
717
+ }
718
+ };
719
+ };
720
+ var ProductsApiFp = function(configuration) {
721
+ const localVarAxiosParamCreator = ProductsApiAxiosParamCreator(configuration);
722
+ return {
723
+ /**
724
+ *
725
+ * @param {*} [options] Override http request option.
726
+ * @throws {RequiredError}
727
+ */
728
+ async findAll(options) {
729
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findAll(options);
730
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
731
+ const localVarOperationServerBasePath = operationServerMap["ProductsApi.findAll"]?.[localVarOperationServerIndex]?.url;
732
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
733
+ }
734
+ };
735
+ };
736
+ var ProductsApi = class extends BaseAPI {
737
+ /**
738
+ *
739
+ * @param {*} [options] Override http request option.
740
+ * @throws {RequiredError}
741
+ * @memberof ProductsApi
742
+ */
743
+ findAll(options) {
744
+ return ProductsApiFp(this.configuration).findAll(options).then((request) => request(this.axios, this.basePath));
745
+ }
746
+ };
495
747
 
496
748
  // src/api/generated/configuration.ts
497
749
  var Configuration = class {
@@ -582,8 +834,11 @@ var Configuration = class {
582
834
  }
583
835
  };
584
836
  var tanstackClient;
585
- var ordersApi;
586
837
  var authApi;
838
+ var categoriesApi;
839
+ var dishesApi;
840
+ var ordersApi;
841
+ var productsApi;
587
842
  function initApiClient(config) {
588
843
  const apiClient = globalAxios2.create({
589
844
  baseURL: config.baseURL,
@@ -593,16 +848,89 @@ function initApiClient(config) {
593
848
  basePath: config.baseURL
594
849
  });
595
850
  tanstackClient = new QueryClient();
596
- ordersApi = new OrdersApi(configuration, void 0, apiClient);
597
851
  authApi = new AuthApi(configuration, void 0, apiClient);
852
+ categoriesApi = new CategoriesApi(configuration, void 0, apiClient);
853
+ dishesApi = new DishesApi(configuration, void 0, apiClient);
854
+ ordersApi = new OrdersApi(configuration, void 0, apiClient);
855
+ productsApi = new ProductsApi(configuration, void 0, apiClient);
598
856
  return apiClient;
599
857
  }
858
+ var useAuthApi = () => {
859
+ const queryClient = useQueryClient();
860
+ const mutateRefresh = useMutation({
861
+ mutationFn: ({ onSettledCallback } = {}) => authApi.refresh(),
862
+ onSettled: (_data, _error, variables) => {
863
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
864
+ variables?.onSettledCallback && variables.onSettledCallback();
865
+ }
866
+ });
867
+ const mutateSignIn = useMutation({
868
+ mutationFn: ({ params: { signInUserDTO } }) => authApi.signIn(signInUserDTO),
869
+ onSettled: (_data, _error, { onSettledCallback }) => {
870
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
871
+ onSettledCallback && onSettledCallback();
872
+ }
873
+ });
874
+ const mutateSignUp = useMutation({
875
+ mutationFn: ({ params: { signUpUserDTO } }) => authApi.signUp(signUpUserDTO),
876
+ onSettled: (_data, _error, { onSettledCallback }) => {
877
+ queryClient.invalidateQueries({ queryKey: ["auth"] });
878
+ onSettledCallback && onSettledCallback();
879
+ }
880
+ });
881
+ return {
882
+ mutateRefresh,
883
+ mutateSignIn,
884
+ mutateSignUp
885
+ };
886
+ };
887
+ var getCategoriesQuery = () => queryOptions({
888
+ queryKey: ["categories"],
889
+ queryFn: () => categoriesApi.findAll().then((res) => res.data)
890
+ });
891
+ var useCategoriesApi = () => {
892
+ return {
893
+ getCategoriesQuery
894
+ };
895
+ };
896
+ var getDishesQuery = () => queryOptions({
897
+ queryKey: ["dishes"],
898
+ queryFn: () => dishesApi.findAll().then((res) => res.data)
899
+ });
900
+ var getDishQuery = (id) => queryOptions({
901
+ queryKey: ["dishes", id],
902
+ queryFn: () => dishesApi.findOne(id).then((res) => res.data)
903
+ });
904
+ var useDishesApi = () => {
905
+ return {
906
+ getDishesQuery,
907
+ getDishQuery
908
+ };
909
+ };
600
910
  var getOrdersQuery = (params) => queryOptions({
601
911
  queryKey: ["orders", params],
602
912
  queryFn: () => ordersApi.findAll(params?.page, params?.limit, params?.status).then((res) => res.data)
603
913
  });
914
+ var getOrderQuery = (id) => queryOptions({
915
+ queryKey: ["orders", id],
916
+ queryFn: () => ordersApi.findOne(id).then((res) => res.data)
917
+ });
604
918
  var useOrdersApi = () => {
605
919
  const queryClient = useQueryClient();
920
+ const mutateCreateOrder = useMutation({
921
+ mutationFn: ({ params: { createOrderDto } }) => ordersApi.create(createOrderDto),
922
+ onSettled: (_data, _error, { onSettledCallback }) => {
923
+ queryClient.invalidateQueries({ queryKey: ["orders"] });
924
+ onSettledCallback && onSettledCallback();
925
+ }
926
+ });
927
+ const mutateUpdateOrder = useMutation({
928
+ mutationFn: ({ params: { id, updateOrderDto } }) => ordersApi.update(id, updateOrderDto),
929
+ onSettled: (_data, _error, { onSettledCallback }) => {
930
+ queryClient.invalidateQueries({ queryKey: ["orders"] });
931
+ onSettledCallback && onSettledCallback();
932
+ }
933
+ });
606
934
  const mutateDeleteReceipt = useMutation({
607
935
  mutationFn: ({ params: { id } }) => ordersApi.removeActiveReceipt(id),
608
936
  onSettled: (_data, _error, { onSettledCallback }) => {
@@ -611,11 +939,23 @@ var useOrdersApi = () => {
611
939
  }
612
940
  });
613
941
  return {
614
- mutateDeleteReceipt,
615
- getOrdersQuery
942
+ getOrdersQuery,
943
+ getOrderQuery,
944
+ mutateCreateOrder,
945
+ mutateUpdateOrder,
946
+ mutateDeleteReceipt
947
+ };
948
+ };
949
+ var getProductsQuery = () => queryOptions({
950
+ queryKey: ["products"],
951
+ queryFn: () => productsApi.findAll().then((res) => res.data)
952
+ });
953
+ var useProductsApi = () => {
954
+ return {
955
+ getProductsQuery
616
956
  };
617
957
  };
618
958
 
619
- export { authApi, initApiClient, ordersApi, tanstackClient, useOrdersApi };
959
+ export { authApi, categoriesApi, dishesApi, initApiClient, ordersApi, productsApi, tanstackClient, useAuthApi, useCategoriesApi, useDishesApi, useOrdersApi, useProductsApi };
620
960
  //# sourceMappingURL=index.js.map
621
961
  //# sourceMappingURL=index.js.map