@spotsdev/sdk 1.4.0 → 1.5.2

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.
Files changed (67) hide show
  1. package/dist/index.cjs +2166 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +1656 -0
  4. package/dist/index.d.ts +1655 -36
  5. package/dist/index.js +2021 -64
  6. package/dist/index.js.map +1 -0
  7. package/package.json +22 -6
  8. package/src/api/entities.ts +171 -170
  9. package/src/api/mutations/products.ts +18 -2
  10. package/src/api/queries/index.ts +4 -0
  11. package/src/api/queries/payments.ts +67 -0
  12. package/dist/api/client.d.ts +0 -12
  13. package/dist/api/client.js +0 -72
  14. package/dist/api/entities.d.ts +0 -305
  15. package/dist/api/entities.js +0 -13
  16. package/dist/api/mutations/clubs.d.ts +0 -47
  17. package/dist/api/mutations/clubs.js +0 -97
  18. package/dist/api/mutations/conversations.d.ts +0 -45
  19. package/dist/api/mutations/conversations.js +0 -114
  20. package/dist/api/mutations/index.d.ts +0 -14
  21. package/dist/api/mutations/index.js +0 -40
  22. package/dist/api/mutations/notifications.d.ts +0 -38
  23. package/dist/api/mutations/notifications.js +0 -64
  24. package/dist/api/mutations/orders.d.ts +0 -73
  25. package/dist/api/mutations/orders.js +0 -114
  26. package/dist/api/mutations/posts.d.ts +0 -123
  27. package/dist/api/mutations/posts.js +0 -242
  28. package/dist/api/mutations/products.d.ts +0 -81
  29. package/dist/api/mutations/products.js +0 -98
  30. package/dist/api/mutations/redemptions.d.ts +0 -33
  31. package/dist/api/mutations/redemptions.js +0 -63
  32. package/dist/api/mutations/spots.d.ts +0 -93
  33. package/dist/api/mutations/spots.js +0 -167
  34. package/dist/api/mutations/users.d.ts +0 -73
  35. package/dist/api/mutations/users.js +0 -175
  36. package/dist/api/queries/auth.d.ts +0 -37
  37. package/dist/api/queries/auth.js +0 -61
  38. package/dist/api/queries/clubs.d.ts +0 -52
  39. package/dist/api/queries/clubs.js +0 -116
  40. package/dist/api/queries/conversations.d.ts +0 -52
  41. package/dist/api/queries/conversations.js +0 -83
  42. package/dist/api/queries/index.d.ts +0 -28
  43. package/dist/api/queries/index.js +0 -69
  44. package/dist/api/queries/misc.d.ts +0 -30
  45. package/dist/api/queries/misc.js +0 -91
  46. package/dist/api/queries/notifications.d.ts +0 -34
  47. package/dist/api/queries/notifications.js +0 -62
  48. package/dist/api/queries/orders.d.ts +0 -45
  49. package/dist/api/queries/orders.js +0 -93
  50. package/dist/api/queries/posts.d.ts +0 -92
  51. package/dist/api/queries/posts.js +0 -233
  52. package/dist/api/queries/products.d.ts +0 -48
  53. package/dist/api/queries/products.js +0 -87
  54. package/dist/api/queries/spots.d.ts +0 -93
  55. package/dist/api/queries/spots.js +0 -250
  56. package/dist/api/queries/templates.d.ts +0 -39
  57. package/dist/api/queries/templates.js +0 -81
  58. package/dist/api/queries/users.d.ts +0 -104
  59. package/dist/api/queries/users.js +0 -235
  60. package/dist/api/queries/wallet.d.ts +0 -109
  61. package/dist/api/queries/wallet.js +0 -136
  62. package/dist/api/services/index.d.ts +0 -2
  63. package/dist/api/services/index.js +0 -8
  64. package/dist/api/services/marketplace.d.ts +0 -129
  65. package/dist/api/services/marketplace.js +0 -168
  66. package/dist/api/types.d.ts +0 -57
  67. package/dist/api/types.js +0 -33
package/dist/index.js CHANGED
@@ -1,66 +1,2023 @@
1
- "use strict";
2
- /**
3
- * Spots SDK
4
- *
5
- * TypeScript SDK for the Spots API with TanStack Query hooks.
6
- *
7
- * @example
8
- * ```tsx
9
- * import { configureSDK, useCurrentUser, useSpots, useCreatePost } from '@spots/sdk';
10
- *
11
- * // Configure SDK with your API base URL and token management
12
- * configureSDK({
13
- * baseURL: 'https://spots-api-psi.vercel.app',
14
- * getAccessToken: () => localStorage.getItem('accessToken'),
15
- * refreshAccessToken: async () => {
16
- * // Your token refresh logic
17
- * return newAccessToken;
18
- * },
19
- * onUnauthorized: () => {
20
- * // Handle unauthorized access
21
- * window.location.href = '/login';
22
- * },
23
- * });
24
- *
25
- * // Use hooks in your components
26
- * function App() {
27
- * const { data: user } = useCurrentUser();
28
- * const { data: spots } = useSpots();
29
- * const { mutate: createPost } = useCreatePost();
30
- * // ...
31
- * }
32
- * ```
33
- */
34
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
35
- if (k2 === undefined) k2 = k;
36
- var desc = Object.getOwnPropertyDescriptor(m, k);
37
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
38
- desc = { enumerable: true, get: function() { return m[k]; } };
1
+ import axios from 'axios';
2
+ import * as types_star from '@spotsdev/types';
3
+ import { useMutation, useQuery, useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
22
+
23
+ // src/index.ts
24
+ var index_exports = {};
25
+ __export(index_exports, {
26
+ clubKeys: () => clubKeys,
27
+ configureSDK: () => configureSDK,
28
+ conversationKeys: () => conversationKeys,
29
+ getApiClient: () => getApiClient,
30
+ getConfig: () => getConfig,
31
+ miscKeys: () => miscKeys,
32
+ notificationKeys: () => notificationKeys,
33
+ orderKeys: () => orderKeys,
34
+ paymentKeys: () => paymentKeys,
35
+ postKeys: () => postKeys,
36
+ productKeys: () => productKeys,
37
+ spotKeys: () => spotKeys,
38
+ templateKeys: () => templateKeys,
39
+ useAdjustStock: () => useAdjustStock,
40
+ useBlockUser: () => useBlockUser,
41
+ useBlockedUsers: () => useBlockedUsers,
42
+ useCancelOrder: () => useCancelOrder,
43
+ useCities: () => useCities,
44
+ useClaimSpot: () => useClaimSpot,
45
+ useClub: () => useClub,
46
+ useClubBySlug: () => useClubBySlug,
47
+ useClubMembership: () => useClubMembership,
48
+ useClubsBySpot: () => useClubsBySpot,
49
+ useClubsByUser: () => useClubsByUser,
50
+ useCompleteOnboardingStep: () => useCompleteOnboardingStep,
51
+ useConversation: () => useConversation,
52
+ useConversationMessages: () => useConversationMessages,
53
+ useConversations: () => useConversations,
54
+ useCreateClub: () => useCreateClub,
55
+ useCreateCoinbaseCharge: () => useCreateCoinbaseCharge,
56
+ useCreateConversation: () => useCreateConversation,
57
+ useCreateDirectConversation: () => useCreateDirectConversation,
58
+ useCreateOrder: () => useCreateOrder,
59
+ useCreatePost: () => useCreatePost,
60
+ useCreateProduct: () => useCreateProduct,
61
+ useCreateReply: () => useCreateReply,
62
+ useCreateSpot: () => useCreateSpot,
63
+ useCreateStripeIntent: () => useCreateStripeIntent,
64
+ useCurrentUser: () => useCurrentUser,
65
+ useDeleteAccount: () => useDeleteAccount,
66
+ useDeletePost: () => useDeletePost,
67
+ useDeleteProduct: () => useDeleteProduct,
68
+ useDeleteReply: () => useDeleteReply,
69
+ useFavoriteSpot: () => useFavoriteSpot,
70
+ useFulfillPost: () => useFulfillPost,
71
+ useInfiniteSpots: () => useInfiniteSpots,
72
+ useJoinClub: () => useJoinClub,
73
+ useLeaveClub: () => useLeaveClub,
74
+ useLifeSituations: () => useLifeSituations,
75
+ useMarkConversationAsRead: () => useMarkConversationAsRead,
76
+ useMarkNotificationsRead: () => useMarkNotificationsRead,
77
+ useMyOrders: () => useMyOrders,
78
+ useNotifications: () => useNotifications,
79
+ useOrder: () => useOrder,
80
+ useOwnedSpots: () => useOwnedSpots,
81
+ usePaymentConfig: () => usePaymentConfig,
82
+ usePost: () => usePost,
83
+ usePostResponses: () => usePostResponses,
84
+ usePostStatus: () => usePostStatus,
85
+ usePostUpvotes: () => usePostUpvotes,
86
+ usePosts: () => usePosts,
87
+ usePostsFeed: () => usePostsFeed,
88
+ useProduct: () => useProduct,
89
+ useProductBySlug: () => useProductBySlug,
90
+ useRateSpot: () => useRateSpot,
91
+ useRedeem: () => useRedeem,
92
+ useRedemptionLookup: () => useRedemptionLookup,
93
+ useRefreshToken: () => useRefreshToken,
94
+ useRegisterDeviceToken: () => useRegisterDeviceToken,
95
+ useRemoveDeviceToken: () => useRemoveDeviceToken,
96
+ useReportPost: () => useReportPost,
97
+ useReportSpot: () => useReportSpot,
98
+ useRespondToPost: () => useRespondToPost,
99
+ useSendMessage: () => useSendMessage,
100
+ useSendOtp: () => useSendOtp,
101
+ useSendTypingIndicator: () => useSendTypingIndicator,
102
+ useSpot: () => useSpot,
103
+ useSpotByQR: () => useSpotByQR,
104
+ useSpotBySlug: () => useSpotBySlug,
105
+ useSpotFavoriteStatus: () => useSpotFavoriteStatus,
106
+ useSpotImages: () => useSpotImages,
107
+ useSpotOrders: () => useSpotOrders,
108
+ useSpotPosts: () => useSpotPosts,
109
+ useSpotProducts: () => useSpotProducts,
110
+ useSpotRedemptions: () => useSpotRedemptions,
111
+ useSpots: () => useSpots,
112
+ useSubscribeToSpot: () => useSubscribeToSpot,
113
+ useTemplate: () => useTemplate,
114
+ useTemplateBySlug: () => useTemplateBySlug,
115
+ useTemplates: () => useTemplates,
116
+ useUnblockUser: () => useUnblockUser,
117
+ useUnreadNotificationCount: () => useUnreadNotificationCount,
118
+ useUnsubscribeFromSpot: () => useUnsubscribeFromSpot,
119
+ useUpdateClub: () => useUpdateClub,
120
+ useUpdateInterests: () => useUpdateInterests,
121
+ useUpdateOrderStatus: () => useUpdateOrderStatus,
122
+ useUpdatePost: () => useUpdatePost,
123
+ useUpdatePostStatus: () => useUpdatePostStatus,
124
+ useUpdateProduct: () => useUpdateProduct,
125
+ useUpdateProfile: () => useUpdateProfile,
126
+ useUpdateResponse: () => useUpdateResponse,
127
+ useUpdateSpot: () => useUpdateSpot,
128
+ useUpdateVibes: () => useUpdateVibes,
129
+ useUploadAvatar: () => useUploadAvatar,
130
+ useUpvotePost: () => useUpvotePost,
131
+ useUserActivity: () => useUserActivity,
132
+ useUserClubs: () => useUserClubs,
133
+ useUserFavorites: () => useUserFavorites,
134
+ useUserPosts: () => useUserPosts,
135
+ useUserSpotsSummary: () => useUserSpotsSummary,
136
+ useUserStats: () => useUserStats,
137
+ useUserSubscriptions: () => useUserSubscriptions,
138
+ useVerifyOtp: () => useVerifyOtp,
139
+ useVibes: () => useVibes,
140
+ useVoidRedemption: () => useVoidRedemption,
141
+ useWallet: () => useWallet,
142
+ useWalletHistory: () => useWalletHistory,
143
+ userKeys: () => userKeys,
144
+ walletKeys: () => walletKeys
145
+ });
146
+ var config = null;
147
+ var apiClient = null;
148
+ function configureSDK(sdkConfig) {
149
+ config = sdkConfig;
150
+ apiClient = createApiClient(sdkConfig);
151
+ }
152
+ function getApiClient() {
153
+ if (!apiClient) {
154
+ throw new Error("SDK not configured. Call configureSDK() first.");
155
+ }
156
+ return apiClient;
157
+ }
158
+ function getConfig() {
159
+ if (!config) {
160
+ throw new Error("SDK not configured. Call configureSDK() first.");
161
+ }
162
+ return config;
163
+ }
164
+ function createApiClient(sdkConfig) {
165
+ const client = axios.create({
166
+ baseURL: sdkConfig.baseURL,
167
+ headers: {
168
+ "Content-Type": "application/json"
169
+ }
170
+ });
171
+ client.interceptors.request.use(
172
+ async (requestConfig) => {
173
+ const token = await sdkConfig.getAccessToken();
174
+ if (token) {
175
+ requestConfig.headers.Authorization = `Bearer ${token}`;
176
+ }
177
+ console.log(
178
+ `[SDK] ${requestConfig.method?.toUpperCase()} ${sdkConfig.baseURL}${requestConfig.url}`
179
+ );
180
+ return requestConfig;
181
+ },
182
+ (error) => Promise.reject(error)
183
+ );
184
+ client.interceptors.response.use(
185
+ (response) => response,
186
+ async (error) => {
187
+ console.log(
188
+ `[SDK] Error: ${error.response?.status} ${error.config?.url}`,
189
+ error.message
190
+ );
191
+ if (error.response?.status === 401) {
192
+ if (sdkConfig.refreshAccessToken) {
193
+ try {
194
+ const newToken = await sdkConfig.refreshAccessToken();
195
+ if (newToken && error.config) {
196
+ error.config.headers.Authorization = `Bearer ${newToken}`;
197
+ return client.request(error.config);
198
+ }
199
+ } catch {
200
+ sdkConfig.onUnauthorized?.();
201
+ }
202
+ } else {
203
+ sdkConfig.onUnauthorized?.();
204
+ }
205
+ }
206
+ return Promise.reject(error);
207
+ }
208
+ );
209
+ return client;
210
+ }
211
+
212
+ // src/api/types.ts
213
+ var types_exports = {};
214
+ __reExport(types_exports, types_star);
215
+
216
+ // src/index.ts
217
+ __reExport(index_exports, types_exports);
218
+ function useSendOtp(options) {
219
+ return useMutation({
220
+ mutationFn: async (data) => {
221
+ const client = getApiClient();
222
+ const response = await client.post(
223
+ "/auth/send-otp",
224
+ data
225
+ );
226
+ return response.data;
227
+ },
228
+ ...options
229
+ });
230
+ }
231
+ function useVerifyOtp(options) {
232
+ return useMutation({
233
+ mutationFn: async (data) => {
234
+ const client = getApiClient();
235
+ const response = await client.post("/auth/verify-otp", data);
236
+ return response.data;
237
+ },
238
+ ...options
239
+ });
240
+ }
241
+ function useRefreshToken(options) {
242
+ return useMutation({
243
+ mutationFn: async (data) => {
244
+ const client = getApiClient();
245
+ const response = await client.post(
246
+ "/auth/refresh",
247
+ data
248
+ );
249
+ return response.data;
250
+ },
251
+ ...options
252
+ });
253
+ }
254
+ function extractArrayData(data) {
255
+ if (Array.isArray(data)) {
256
+ return data;
257
+ }
258
+ if (data && typeof data === "object" && "data" in data) {
259
+ const nested = data.data;
260
+ if (Array.isArray(nested)) {
261
+ return nested;
262
+ }
263
+ }
264
+ return [];
265
+ }
266
+ var userKeys = {
267
+ all: ["users"],
268
+ me: () => [...userKeys.all, "me"],
269
+ stats: () => [...userKeys.me(), "stats"],
270
+ spotsSummary: () => [...userKeys.me(), "spots-summary"],
271
+ activity: (limit) => [...userKeys.me(), "activity", limit],
272
+ posts: (params) => [...userKeys.me(), "posts", params],
273
+ clubs: () => [...userKeys.me(), "clubs"],
274
+ subscriptions: () => [...userKeys.me(), "subscriptions"],
275
+ blocked: () => [...userKeys.me(), "blocked"],
276
+ ownedSpots: () => [...userKeys.me(), "owned-spots"],
277
+ favorites: () => [...userKeys.me(), "favorites"]
278
+ };
279
+ function useCurrentUser(options) {
280
+ return useQuery({
281
+ queryKey: userKeys.me(),
282
+ queryFn: async () => {
283
+ console.log("[SDK-USERS] Fetching /users/me...");
284
+ const client = getApiClient();
285
+ try {
286
+ const response = await client.get("/users/me");
287
+ console.log("[SDK-USERS] Success:", response.status);
288
+ return response.data.data;
289
+ } catch (error) {
290
+ const axiosError = error;
291
+ console.log(
292
+ "[SDK-USERS] Error:",
293
+ axiosError.response?.status,
294
+ "URL:",
295
+ axiosError.config?.baseURL,
296
+ axiosError.config?.url
297
+ );
298
+ throw error;
299
+ }
300
+ },
301
+ ...options
302
+ });
303
+ }
304
+ function useUserStats(options) {
305
+ return useQuery({
306
+ queryKey: userKeys.stats(),
307
+ queryFn: async () => {
308
+ const client = getApiClient();
309
+ const response = await client.get("/users/me/stats");
310
+ return response.data.data;
311
+ },
312
+ ...options
313
+ });
314
+ }
315
+ function useUserSpotsSummary(options) {
316
+ return useQuery({
317
+ queryKey: userKeys.spotsSummary(),
318
+ queryFn: async () => {
319
+ const client = getApiClient();
320
+ const response = await client.get(
321
+ "/users/me/spots-summary"
322
+ );
323
+ return response.data.data;
324
+ },
325
+ ...options
326
+ });
327
+ }
328
+ function useUserActivity(limit = 10, options) {
329
+ return useQuery({
330
+ queryKey: userKeys.activity(limit),
331
+ queryFn: async () => {
332
+ const client = getApiClient();
333
+ const response = await client.get(
334
+ `/users/me/activity?limit=${limit}`
335
+ );
336
+ return extractArrayData(response.data.data);
337
+ },
338
+ ...options
339
+ });
340
+ }
341
+ function useUserPosts(params, options) {
342
+ return useQuery({
343
+ queryKey: userKeys.posts(params),
344
+ queryFn: async () => {
345
+ const client = getApiClient();
346
+ const queryParams = new URLSearchParams();
347
+ if (params?.page) queryParams.set("page", String(params.page));
348
+ if (params?.limit) queryParams.set("limit", String(params.limit));
349
+ const response = await client.get(
350
+ `/user/me/posts?${queryParams}`
351
+ );
352
+ return extractArrayData(response.data.data);
353
+ },
354
+ ...options
355
+ });
356
+ }
357
+ function useUserClubs(options) {
358
+ return useQuery({
359
+ queryKey: userKeys.clubs(),
360
+ queryFn: async () => {
361
+ const client = getApiClient();
362
+ const response = await client.get("/user/me/clubs");
363
+ return extractArrayData(response.data.data);
364
+ },
365
+ ...options
366
+ });
367
+ }
368
+ function useUserSubscriptions(options) {
369
+ return useQuery({
370
+ queryKey: userKeys.subscriptions(),
371
+ queryFn: async () => {
372
+ const client = getApiClient();
373
+ const response = await client.get(
374
+ "/user/me/subscriptions"
375
+ );
376
+ return extractArrayData(response.data.data);
377
+ },
378
+ ...options
379
+ });
380
+ }
381
+ function useBlockedUsers(options) {
382
+ return useQuery({
383
+ queryKey: userKeys.blocked(),
384
+ queryFn: async () => {
385
+ const client = getApiClient();
386
+ const response = await client.get("/user/me/blocked");
387
+ return extractArrayData(response.data.data);
388
+ },
389
+ ...options
390
+ });
391
+ }
392
+ function useOwnedSpots(options) {
393
+ return useQuery({
394
+ queryKey: userKeys.ownedSpots(),
395
+ queryFn: async () => {
396
+ const client = getApiClient();
397
+ const response = await client.get(
398
+ "/users/me/owned-spots"
399
+ );
400
+ return extractArrayData(response.data.data);
401
+ },
402
+ ...options
403
+ });
404
+ }
405
+ function useUserFavorites(options) {
406
+ return useQuery({
407
+ queryKey: userKeys.favorites(),
408
+ queryFn: async () => {
409
+ const client = getApiClient();
410
+ const response = await client.get(
411
+ "/users/me/favorites"
412
+ );
413
+ return extractArrayData(response.data.data);
414
+ },
415
+ ...options
416
+ });
417
+ }
418
+ function extractArrayData2(data) {
419
+ if (Array.isArray(data)) {
420
+ return data;
421
+ }
422
+ if (data && typeof data === "object" && "data" in data) {
423
+ const nested = data.data;
424
+ if (Array.isArray(nested)) {
425
+ return nested;
426
+ }
427
+ }
428
+ return [];
429
+ }
430
+ function extractObjectData(data) {
431
+ if (data && typeof data === "object" && "data" in data && !Array.isArray(data)) {
432
+ const nested = data.data;
433
+ if (nested && typeof nested === "object" && "data" in nested && !Array.isArray(nested)) {
434
+ return nested.data;
435
+ }
436
+ return nested;
437
+ }
438
+ return data;
439
+ }
440
+ var spotKeys = {
441
+ all: ["spots"],
442
+ lists: () => [...spotKeys.all, "list"],
443
+ list: (filters) => [...spotKeys.lists(), filters],
444
+ details: () => [...spotKeys.all, "detail"],
445
+ detail: (id) => [...spotKeys.details(), id],
446
+ bySlug: (slug) => [...spotKeys.all, "slug", slug],
447
+ byQR: (qrCode) => [...spotKeys.all, "qr", qrCode],
448
+ images: (spotId) => [...spotKeys.detail(spotId), "images"]
449
+ };
450
+ function useSpots(params, options) {
451
+ return useQuery({
452
+ queryKey: spotKeys.list(params),
453
+ queryFn: async () => {
454
+ const client = getApiClient();
455
+ const queryParams = new URLSearchParams();
456
+ if (params?.limit) queryParams.set("limit", String(params.limit));
457
+ if (params?.city) queryParams.set("city", params.city);
458
+ if (params?.type) queryParams.set("type", params.type);
459
+ if (params?.lat) queryParams.set("lat", String(params.lat));
460
+ if (params?.lng) queryParams.set("lng", String(params.lng));
461
+ if (params?.radius) queryParams.set("radius", String(params.radius));
462
+ if (params?.search) queryParams.set("search", params.search);
463
+ if (params?.vibes) queryParams.set("vibeIds", params.vibes);
464
+ if (params?.cityId) queryParams.set("cityId", params.cityId);
465
+ if (params?.page) queryParams.set("page", String(params.page));
466
+ const response = await client.get(
467
+ `/spots?${queryParams}`
468
+ );
469
+ return extractArrayData2(response.data.data);
470
+ },
471
+ ...options
472
+ });
473
+ }
474
+ function useSpot(spotId, options) {
475
+ return useQuery({
476
+ queryKey: spotKeys.detail(spotId),
477
+ queryFn: async () => {
478
+ const client = getApiClient();
479
+ const response = await client.get(
480
+ `/spots/${spotId}`
481
+ );
482
+ return extractObjectData(response.data.data);
483
+ },
484
+ enabled: !!spotId,
485
+ ...options
486
+ });
487
+ }
488
+ function useSpotBySlug(slug, options) {
489
+ return useQuery({
490
+ queryKey: spotKeys.bySlug(slug),
491
+ queryFn: async () => {
492
+ const client = getApiClient();
493
+ const response = await client.get(
494
+ `/spots/slug/${slug}`
495
+ );
496
+ return extractObjectData(response.data.data);
497
+ },
498
+ enabled: !!slug,
499
+ ...options
500
+ });
501
+ }
502
+ function useSpotByQR(qrCode, options) {
503
+ return useQuery({
504
+ queryKey: spotKeys.byQR(qrCode),
505
+ queryFn: async () => {
506
+ const client = getApiClient();
507
+ const response = await client.get(
508
+ `/spots/qr/${qrCode}`
509
+ );
510
+ return extractObjectData(response.data.data);
511
+ },
512
+ enabled: !!qrCode,
513
+ ...options
514
+ });
515
+ }
516
+ function useSpotImages(spotId, options) {
517
+ return useQuery({
518
+ queryKey: spotKeys.images(spotId),
519
+ queryFn: async () => {
520
+ const client = getApiClient();
521
+ const response = await client.get(
522
+ `/spots/${spotId}/images`
523
+ );
524
+ return extractArrayData2(response.data.data);
525
+ },
526
+ enabled: !!spotId,
527
+ ...options
528
+ });
529
+ }
530
+ function useSpotFavoriteStatus(spotId, options) {
531
+ return useQuery({
532
+ queryKey: [...spotKeys.detail(spotId), "favorite"],
533
+ queryFn: async () => {
534
+ const client = getApiClient();
535
+ const response = await client.get(
536
+ `/spots/${spotId}/favorite`
537
+ );
538
+ return extractObjectData(response.data.data);
539
+ },
540
+ enabled: !!spotId,
541
+ ...options
542
+ });
543
+ }
544
+ function useInfiniteSpots(params, options) {
545
+ return useInfiniteQuery({
546
+ queryKey: [...spotKeys.lists(), "infinite", params],
547
+ queryFn: async ({ pageParam = 1 }) => {
548
+ const client = getApiClient();
549
+ const queryParams = new URLSearchParams();
550
+ queryParams.set("page", String(pageParam));
551
+ if (params?.limit) queryParams.set("limit", String(params.limit));
552
+ if (params?.city) queryParams.set("city", params.city);
553
+ if (params?.cityId) queryParams.set("cityId", params.cityId);
554
+ if (params?.type && params.type !== "All")
555
+ queryParams.set("type", params.type);
556
+ if (params?.search?.trim())
557
+ queryParams.set("search", params.search.trim());
558
+ if (params?.templateSlugs) {
559
+ params.templateSlugs.forEach(
560
+ (slug) => queryParams.append("templateSlugs", slug)
561
+ );
562
+ }
563
+ if (params?.vibeIds) {
564
+ params.vibeIds.forEach((id) => queryParams.append("vibeIds", id));
565
+ }
566
+ const response = await client.get(
567
+ `/spots?${queryParams}`
568
+ );
569
+ const data = response.data.data;
570
+ if (data && typeof data === "object" && "data" in data) {
571
+ return data;
572
+ }
573
+ const page = pageParam;
574
+ return {
575
+ data: extractArrayData2(data),
576
+ meta: {
577
+ total: 0,
578
+ page,
579
+ limit: params?.limit || 20,
580
+ totalPages: 1,
581
+ hasNextPage: false,
582
+ hasPreviousPage: page > 1
583
+ }
584
+ };
585
+ },
586
+ initialPageParam: 1,
587
+ getNextPageParam: (lastPage) => {
588
+ return lastPage.meta.hasNextPage ? lastPage.meta.page + 1 : void 0;
589
+ },
590
+ ...options
591
+ });
592
+ }
593
+ function extractArrayData3(data) {
594
+ if (Array.isArray(data)) {
595
+ return data;
596
+ }
597
+ if (data && typeof data === "object" && "data" in data) {
598
+ const nested = data.data;
599
+ if (Array.isArray(nested)) {
600
+ return nested;
601
+ }
602
+ }
603
+ return [];
604
+ }
605
+ function extractObjectData2(data) {
606
+ if (data && typeof data === "object" && "data" in data && !Array.isArray(data)) {
607
+ const nested = data.data;
608
+ if (nested && typeof nested === "object" && "data" in nested && !Array.isArray(nested)) {
609
+ return nested.data;
610
+ }
611
+ return nested;
612
+ }
613
+ return data;
614
+ }
615
+ var postKeys = {
616
+ all: ["posts"],
617
+ lists: () => [...postKeys.all, "list"],
618
+ list: (filters) => [...postKeys.lists(), filters],
619
+ bySpot: (spotId, filters) => [...postKeys.all, "spot", spotId, filters],
620
+ details: () => [...postKeys.all, "detail"],
621
+ detail: (id) => [...postKeys.details(), id],
622
+ responses: (postId) => [...postKeys.detail(postId), "responses"],
623
+ status: (postId) => [...postKeys.detail(postId), "status"],
624
+ upvotes: (postId, filters) => [...postKeys.detail(postId), "upvotes", filters]
625
+ };
626
+ function useSpotPosts(spotId, params, options) {
627
+ return useQuery({
628
+ queryKey: postKeys.bySpot(spotId, params),
629
+ queryFn: async () => {
630
+ const client = getApiClient();
631
+ const queryParams = new URLSearchParams();
632
+ if (params?.postType) queryParams.set("postType", params.postType);
633
+ if (params?.status) queryParams.set("status", params.status);
634
+ if (params?.page) queryParams.set("page", String(params.page));
635
+ if (params?.limit) queryParams.set("limit", String(params.limit));
636
+ const response = await client.get(
637
+ `/spots/${spotId}/posts?${queryParams}`
638
+ );
639
+ return extractArrayData3(response.data.data);
640
+ },
641
+ enabled: !!spotId,
642
+ ...options
643
+ });
644
+ }
645
+ function usePost(postId, options) {
646
+ return useQuery({
647
+ queryKey: postKeys.detail(postId),
648
+ queryFn: async () => {
649
+ const client = getApiClient();
650
+ const response = await client.get(
651
+ `/posts/${postId}`
652
+ );
653
+ return extractObjectData2(response.data.data);
654
+ },
655
+ enabled: !!postId,
656
+ ...options
657
+ });
658
+ }
659
+ function usePostResponses(postId, options) {
660
+ return useQuery({
661
+ queryKey: postKeys.responses(postId),
662
+ queryFn: async () => {
663
+ const client = getApiClient();
664
+ const response = await client.get(
665
+ `/posts/${postId}/responses`
666
+ );
667
+ return extractArrayData3(response.data.data);
668
+ },
669
+ enabled: !!postId,
670
+ ...options
671
+ });
672
+ }
673
+ function usePosts(params, options) {
674
+ return useQuery({
675
+ queryKey: postKeys.list(params),
676
+ queryFn: async () => {
677
+ const client = getApiClient();
678
+ const queryParams = new URLSearchParams();
679
+ if (params?.postType) queryParams.set("postType", params.postType);
680
+ if (params?.limit) queryParams.set("limit", String(params.limit));
681
+ const response = await client.get(
682
+ `/posts?${queryParams}`
683
+ );
684
+ return extractArrayData3(response.data.data);
685
+ },
686
+ ...options
687
+ });
688
+ }
689
+ function usePostStatus(postId, options) {
690
+ return useQuery({
691
+ queryKey: postKeys.status(postId),
692
+ queryFn: async () => {
693
+ const client = getApiClient();
694
+ const response = await client.get(
695
+ `/posts/${postId}/status`
696
+ );
697
+ return extractObjectData2(response.data.data);
698
+ },
699
+ enabled: !!postId,
700
+ ...options
701
+ });
702
+ }
703
+ function usePostUpvotes(postId, params, options) {
704
+ return useQuery({
705
+ queryKey: postKeys.upvotes(postId, params),
706
+ queryFn: async () => {
707
+ const client = getApiClient();
708
+ const queryParams = new URLSearchParams();
709
+ if (params?.limit) queryParams.set("limit", String(params.limit));
710
+ if (params?.offset) queryParams.set("offset", String(params.offset));
711
+ const queryString = queryParams.toString();
712
+ const response = await client.get(
713
+ `/posts/${postId}/upvotes${queryString ? `?${queryString}` : ""}`
714
+ );
715
+ return response.data.data;
716
+ },
717
+ enabled: !!postId,
718
+ ...options
719
+ });
720
+ }
721
+ function usePostsFeed(params, options) {
722
+ return useQuery({
723
+ queryKey: [...postKeys.lists(), "feed", params],
724
+ queryFn: async () => {
725
+ const client = getApiClient();
726
+ const queryParams = new URLSearchParams();
727
+ queryParams.set("lat", String(params.lat));
728
+ queryParams.set("lng", String(params.lng));
729
+ if (params.radius) queryParams.set("radius", String(params.radius));
730
+ if (params.postType) queryParams.set("postType", params.postType);
731
+ if (params.cursor) queryParams.set("cursor", params.cursor);
732
+ if (params.limit) queryParams.set("limit", String(params.limit));
733
+ const response = await client.get(`/posts/feed?${queryParams}`);
734
+ const data = response.data.data;
735
+ return {
736
+ posts: data.posts ?? extractArrayData3(data),
737
+ hasMore: data.hasMore ?? false,
738
+ nextCursor: data.nextCursor
739
+ };
740
+ },
741
+ enabled: params.lat !== 0 && params.lng !== 0,
742
+ ...options
743
+ });
744
+ }
745
+ var conversationKeys = {
746
+ all: ["conversations"],
747
+ lists: () => [...conversationKeys.all, "list"],
748
+ list: () => [...conversationKeys.lists()],
749
+ details: () => [...conversationKeys.all, "detail"],
750
+ detail: (id) => [...conversationKeys.details(), id],
751
+ messages: (conversationId, params) => [...conversationKeys.detail(conversationId), "messages", params]
752
+ };
753
+ function useConversations(options) {
754
+ return useQuery({
755
+ queryKey: conversationKeys.list(),
756
+ queryFn: async () => {
757
+ const client = getApiClient();
758
+ const response = await client.get("/conversations");
759
+ return response.data.data;
760
+ },
761
+ ...options
762
+ });
763
+ }
764
+ function useConversation(conversationId, options) {
765
+ return useQuery({
766
+ queryKey: conversationKeys.detail(conversationId),
767
+ queryFn: async () => {
768
+ const client = getApiClient();
769
+ const response = await client.get(
770
+ `/conversations/${conversationId}`
771
+ );
772
+ return response.data.data;
773
+ },
774
+ enabled: !!conversationId,
775
+ ...options
776
+ });
777
+ }
778
+ function useConversationMessages(conversationId, params, options) {
779
+ return useQuery({
780
+ queryKey: conversationKeys.messages(conversationId, params),
781
+ queryFn: async () => {
782
+ const client = getApiClient();
783
+ const queryParams = new URLSearchParams();
784
+ if (params?.limit) queryParams.set("limit", String(params.limit));
785
+ if (params?.before) queryParams.set("before", params.before);
786
+ const response = await client.get(`/conversations/${conversationId}/messages?${queryParams}`);
787
+ return response.data;
788
+ },
789
+ enabled: !!conversationId,
790
+ ...options
791
+ });
792
+ }
793
+ var clubKeys = {
794
+ all: ["clubs"],
795
+ bySpot: (spotId) => [...clubKeys.all, "spot", spotId],
796
+ details: () => [...clubKeys.all, "detail"],
797
+ detail: (id) => [...clubKeys.details(), id],
798
+ bySlug: (slug) => [...clubKeys.all, "slug", slug],
799
+ byUser: (userId) => [...clubKeys.all, "user", userId],
800
+ membership: (clubId, userId) => [...clubKeys.detail(clubId), "membership", userId]
801
+ };
802
+ function useClubsBySpot(spotId, options) {
803
+ return useQuery({
804
+ queryKey: clubKeys.bySpot(spotId),
805
+ queryFn: async () => {
806
+ const client = getApiClient();
807
+ const response = await client.get(
808
+ `/clubs/spot/${spotId}`
809
+ );
810
+ return response.data.data;
811
+ },
812
+ enabled: !!spotId,
813
+ ...options
814
+ });
815
+ }
816
+ function useClub(clubId, options) {
817
+ return useQuery({
818
+ queryKey: clubKeys.detail(clubId),
819
+ queryFn: async () => {
820
+ const client = getApiClient();
821
+ const response = await client.get(`/clubs/${clubId}`);
822
+ return response.data.data;
823
+ },
824
+ enabled: !!clubId,
825
+ ...options
826
+ });
827
+ }
828
+ function useClubBySlug(slug, options) {
829
+ return useQuery({
830
+ queryKey: clubKeys.bySlug(slug),
831
+ queryFn: async () => {
832
+ const client = getApiClient();
833
+ const response = await client.get(
834
+ `/clubs/slug/${slug}`
835
+ );
836
+ return response.data.data;
837
+ },
838
+ enabled: !!slug,
839
+ ...options
840
+ });
841
+ }
842
+ function useClubsByUser(userId, options) {
843
+ return useQuery({
844
+ queryKey: clubKeys.byUser(userId),
845
+ queryFn: async () => {
846
+ const client = getApiClient();
847
+ const response = await client.get(
848
+ `/clubs/user/${userId}`
849
+ );
850
+ return response.data.data;
851
+ },
852
+ enabled: !!userId,
853
+ ...options
854
+ });
855
+ }
856
+ function useClubMembership(clubId, userId, options) {
857
+ return useQuery({
858
+ queryKey: clubKeys.membership(clubId, userId),
859
+ queryFn: async () => {
860
+ const client = getApiClient();
861
+ const response = await client.get(`/clubs/${clubId}/membership/${userId}`);
862
+ return response.data.data;
863
+ },
864
+ enabled: !!clubId && !!userId,
865
+ ...options
866
+ });
867
+ }
868
+ var templateKeys = {
869
+ all: ["templates"],
870
+ lists: () => [...templateKeys.all, "list"],
871
+ list: (filters) => [...templateKeys.lists(), filters],
872
+ details: () => [...templateKeys.all, "detail"],
873
+ detail: (id) => [...templateKeys.details(), id],
874
+ bySlug: (slug) => [...templateKeys.all, "slug", slug]
875
+ };
876
+ function useTemplates(params, options) {
877
+ return useQuery({
878
+ queryKey: templateKeys.list(params),
879
+ queryFn: async () => {
880
+ const client = getApiClient();
881
+ const queryParams = new URLSearchParams();
882
+ if (params?.spotType) queryParams.set("spotType", params.spotType);
883
+ const response = await client.get(
884
+ `/templates?${queryParams}`
885
+ );
886
+ return response.data.data;
887
+ },
888
+ ...options
889
+ });
890
+ }
891
+ function useTemplate(templateId, options) {
892
+ return useQuery({
893
+ queryKey: templateKeys.detail(templateId),
894
+ queryFn: async () => {
895
+ const client = getApiClient();
896
+ const response = await client.get(
897
+ `/templates/${templateId}`
898
+ );
899
+ return response.data.data;
900
+ },
901
+ enabled: !!templateId,
902
+ ...options
903
+ });
904
+ }
905
+ function useTemplateBySlug(slug, options) {
906
+ return useQuery({
907
+ queryKey: templateKeys.bySlug(slug),
908
+ queryFn: async () => {
909
+ const client = getApiClient();
910
+ const response = await client.get(
911
+ `/templates/slug/${slug}`
912
+ );
913
+ return response.data.data;
914
+ },
915
+ enabled: !!slug,
916
+ ...options
917
+ });
918
+ }
919
+ var notificationKeys = {
920
+ all: ["notifications"],
921
+ lists: () => [...notificationKeys.all, "list"],
922
+ list: (params) => [...notificationKeys.lists(), params],
923
+ unreadCount: () => [...notificationKeys.all, "unreadCount"]
924
+ };
925
+ function useNotifications(params, options) {
926
+ return useQuery({
927
+ queryKey: notificationKeys.list(params),
928
+ queryFn: async () => {
929
+ const client = getApiClient();
930
+ const queryParams = new URLSearchParams();
931
+ if (params?.limit) queryParams.set("limit", String(params.limit));
932
+ if (params?.unreadOnly)
933
+ queryParams.set("unreadOnly", String(params.unreadOnly));
934
+ const response = await client.get(
935
+ `/notifications?${queryParams}`
936
+ );
937
+ return response.data.data;
938
+ },
939
+ ...options
940
+ });
941
+ }
942
+ function useUnreadNotificationCount(options) {
943
+ return useQuery({
944
+ queryKey: notificationKeys.unreadCount(),
945
+ queryFn: async () => {
946
+ const client = getApiClient();
947
+ const response = await client.get(
948
+ "/notifications/unread-count"
949
+ );
950
+ return response.data.data.count;
951
+ },
952
+ ...options
953
+ });
954
+ }
955
+ function extractArrayData4(data) {
956
+ if (Array.isArray(data)) {
957
+ return data;
958
+ }
959
+ if (data && typeof data === "object" && "data" in data) {
960
+ const nested = data.data;
961
+ if (Array.isArray(nested)) {
962
+ return nested;
963
+ }
964
+ }
965
+ return [];
966
+ }
967
+ var miscKeys = {
968
+ cities: () => ["cities"],
969
+ vibes: () => ["vibes"],
970
+ lifeSituations: () => ["life-situations"]
971
+ };
972
+ function useCities(options) {
973
+ return useQuery({
974
+ queryKey: miscKeys.cities(),
975
+ queryFn: async () => {
976
+ const client = getApiClient();
977
+ const response = await client.get("/cities");
978
+ return extractArrayData4(response.data.data);
979
+ },
980
+ staleTime: 1e3 * 60 * 60,
981
+ ...options
982
+ });
983
+ }
984
+ function useVibes(options) {
985
+ return useQuery({
986
+ queryKey: miscKeys.vibes(),
987
+ queryFn: async () => {
988
+ const client = getApiClient();
989
+ const response = await client.get("/vibes");
990
+ return extractArrayData4(response.data.data);
991
+ },
992
+ staleTime: 1e3 * 60 * 60,
993
+ ...options
994
+ });
995
+ }
996
+ function useLifeSituations(options) {
997
+ return useQuery({
998
+ queryKey: miscKeys.lifeSituations(),
999
+ queryFn: async () => {
1000
+ const client = getApiClient();
1001
+ const response = await client.get("/life-situations");
1002
+ return extractArrayData4(response.data.data);
1003
+ },
1004
+ staleTime: 1e3 * 60 * 60,
1005
+ ...options
1006
+ });
1007
+ }
1008
+ var productKeys = {
1009
+ all: ["products"],
1010
+ lists: () => [...productKeys.all, "list"],
1011
+ list: (filters) => [...productKeys.lists(), filters],
1012
+ details: () => [...productKeys.all, "detail"],
1013
+ detail: (id) => [...productKeys.details(), id],
1014
+ bySlug: (spotId, slug) => [...productKeys.all, "slug", spotId, slug],
1015
+ bySpot: (spotId) => [...productKeys.all, "spot", spotId]
1016
+ };
1017
+ function useSpotProducts(spotId, params, options) {
1018
+ return useQuery({
1019
+ queryKey: productKeys.bySpot(spotId),
1020
+ queryFn: async () => {
1021
+ const client = getApiClient();
1022
+ const queryParams = new URLSearchParams();
1023
+ if (params?.limit) queryParams.set("limit", String(params.limit));
1024
+ if (params?.page) queryParams.set("page", String(params.page));
1025
+ if (params?.type) queryParams.set("type", params.type);
1026
+ const response = await client.get(
1027
+ `/spots/${spotId}/products?${queryParams}`
1028
+ );
1029
+ return response.data.data;
1030
+ },
1031
+ enabled: !!spotId,
1032
+ ...options
1033
+ });
1034
+ }
1035
+ function useProduct(productId, options) {
1036
+ return useQuery({
1037
+ queryKey: productKeys.detail(productId),
1038
+ queryFn: async () => {
1039
+ const client = getApiClient();
1040
+ const response = await client.get(
1041
+ `/products/${productId}`
1042
+ );
1043
+ return response.data.data;
1044
+ },
1045
+ enabled: !!productId,
1046
+ ...options
1047
+ });
1048
+ }
1049
+ function useProductBySlug(spotId, slug, options) {
1050
+ return useQuery({
1051
+ queryKey: productKeys.bySlug(spotId, slug),
1052
+ queryFn: async () => {
1053
+ const client = getApiClient();
1054
+ const response = await client.get(
1055
+ `/spots/${spotId}/products/slug/${slug}`
1056
+ );
1057
+ return response.data.data;
1058
+ },
1059
+ enabled: !!spotId && !!slug,
1060
+ ...options
1061
+ });
1062
+ }
1063
+ var orderKeys = {
1064
+ all: ["orders"],
1065
+ lists: () => [...orderKeys.all, "list"],
1066
+ list: (filters) => [...orderKeys.lists(), filters],
1067
+ details: () => [...orderKeys.all, "detail"],
1068
+ detail: (id) => [...orderKeys.details(), id],
1069
+ myOrders: () => [...orderKeys.all, "my"],
1070
+ spotOrders: (spotId) => [...orderKeys.all, "spot", spotId]
1071
+ };
1072
+ function useMyOrders(params, options) {
1073
+ return useQuery({
1074
+ queryKey: orderKeys.list({ ...params, my: true }),
1075
+ queryFn: async () => {
1076
+ const client = getApiClient();
1077
+ const queryParams = new URLSearchParams();
1078
+ if (params?.status) queryParams.set("status", params.status);
1079
+ if (params?.limit) queryParams.set("limit", String(params.limit));
1080
+ if (params?.page) queryParams.set("page", String(params.page));
1081
+ const response = await client.get(`/users/me/orders?${queryParams}`);
1082
+ return response.data.data;
1083
+ },
1084
+ ...options
1085
+ });
1086
+ }
1087
+ function useOrder(orderId, options) {
1088
+ return useQuery({
1089
+ queryKey: orderKeys.detail(orderId),
1090
+ queryFn: async () => {
1091
+ const client = getApiClient();
1092
+ const response = await client.get(
1093
+ `/orders/${orderId}`
1094
+ );
1095
+ return response.data.data;
1096
+ },
1097
+ enabled: !!orderId,
1098
+ ...options
1099
+ });
1100
+ }
1101
+ function useSpotOrders(spotId, params, options) {
1102
+ return useQuery({
1103
+ queryKey: orderKeys.spotOrders(spotId),
1104
+ queryFn: async () => {
1105
+ const client = getApiClient();
1106
+ const queryParams = new URLSearchParams();
1107
+ if (params?.status) queryParams.set("status", params.status);
1108
+ if (params?.limit) queryParams.set("limit", String(params.limit));
1109
+ if (params?.page) queryParams.set("page", String(params.page));
1110
+ const response = await client.get(`/seller/spots/${spotId}/orders?${queryParams}`);
1111
+ return response.data.data;
1112
+ },
1113
+ enabled: !!spotId,
1114
+ ...options
1115
+ });
1116
+ }
1117
+ function extractArrayData5(data) {
1118
+ if (Array.isArray(data)) {
1119
+ return data;
1120
+ }
1121
+ if (data && typeof data === "object" && "data" in data) {
1122
+ const nested = data.data;
1123
+ if (Array.isArray(nested)) {
1124
+ return nested;
1125
+ }
1126
+ }
1127
+ return [];
1128
+ }
1129
+ function extractObjectData3(data) {
1130
+ if (data && typeof data === "object" && "data" in data && !Array.isArray(data)) {
1131
+ const nested = data.data;
1132
+ if (nested && typeof nested === "object" && "data" in nested && !Array.isArray(nested)) {
1133
+ return nested.data;
39
1134
  }
40
- Object.defineProperty(o, k2, desc);
41
- }) : (function(o, m, k, k2) {
42
- if (k2 === undefined) k2 = k;
43
- o[k2] = m[k];
44
- }));
45
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
46
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1135
+ return nested;
1136
+ }
1137
+ return data;
1138
+ }
1139
+ var walletKeys = {
1140
+ all: ["wallet"],
1141
+ active: () => [...walletKeys.all, "active"],
1142
+ history: (page) => [...walletKeys.all, "history", page],
1143
+ redemptions: () => ["redemptions"],
1144
+ lookup: (qrCode) => [...walletKeys.redemptions(), "lookup", qrCode],
1145
+ spotRedemptions: (spotId, page) => [...walletKeys.redemptions(), "spot", spotId, page]
47
1146
  };
48
- Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.getConfig = exports.getApiClient = exports.configureSDK = void 0;
50
- var client_1 = require("./api/client");
51
- Object.defineProperty(exports, "configureSDK", { enumerable: true, get: function () { return client_1.configureSDK; } });
52
- Object.defineProperty(exports, "getApiClient", { enumerable: true, get: function () { return client_1.getApiClient; } });
53
- Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return client_1.getConfig; } });
54
- // ============================================================================
55
- // TYPES
56
- // ============================================================================
57
- __exportStar(require("./api/types"), exports);
58
- // ============================================================================
59
- // QUERY HOOKS
60
- // ============================================================================
61
- __exportStar(require("./api/queries"), exports);
62
- // ============================================================================
63
- // MUTATION HOOKS
64
- // ============================================================================
65
- __exportStar(require("./api/mutations"), exports);
66
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBK0JHOzs7Ozs7Ozs7Ozs7Ozs7OztBQU9ILHVDQUFrRTtBQUExRCxzR0FBQSxZQUFZLE9BQUE7QUFBRSxzR0FBQSxZQUFZLE9BQUE7QUFBRSxtR0FBQSxTQUFTLE9BQUE7QUFFN0MsK0VBQStFO0FBQy9FLFFBQVE7QUFDUiwrRUFBK0U7QUFFL0UsOENBQTJCO0FBRTNCLCtFQUErRTtBQUMvRSxjQUFjO0FBQ2QsK0VBQStFO0FBRS9FLGdEQUE2QjtBQUU3QiwrRUFBK0U7QUFDL0UsaUJBQWlCO0FBQ2pCLCtFQUErRTtBQUUvRSxrREFBK0IiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIFNwb3RzIFNES1xuICpcbiAqIFR5cGVTY3JpcHQgU0RLIGZvciB0aGUgU3BvdHMgQVBJIHdpdGggVGFuU3RhY2sgUXVlcnkgaG9va3MuXG4gKlxuICogQGV4YW1wbGVcbiAqIGBgYHRzeFxuICogaW1wb3J0IHsgY29uZmlndXJlU0RLLCB1c2VDdXJyZW50VXNlciwgdXNlU3BvdHMsIHVzZUNyZWF0ZVBvc3QgfSBmcm9tICdAc3BvdHMvc2RrJztcbiAqXG4gKiAvLyBDb25maWd1cmUgU0RLIHdpdGggeW91ciBBUEkgYmFzZSBVUkwgYW5kIHRva2VuIG1hbmFnZW1lbnRcbiAqIGNvbmZpZ3VyZVNESyh7XG4gKiAgIGJhc2VVUkw6ICdodHRwczovL3Nwb3RzLWFwaS1wc2kudmVyY2VsLmFwcCcsXG4gKiAgIGdldEFjY2Vzc1Rva2VuOiAoKSA9PiBsb2NhbFN0b3JhZ2UuZ2V0SXRlbSgnYWNjZXNzVG9rZW4nKSxcbiAqICAgcmVmcmVzaEFjY2Vzc1Rva2VuOiBhc3luYyAoKSA9PiB7XG4gKiAgICAgLy8gWW91ciB0b2tlbiByZWZyZXNoIGxvZ2ljXG4gKiAgICAgcmV0dXJuIG5ld0FjY2Vzc1Rva2VuO1xuICogICB9LFxuICogICBvblVuYXV0aG9yaXplZDogKCkgPT4ge1xuICogICAgIC8vIEhhbmRsZSB1bmF1dGhvcml6ZWQgYWNjZXNzXG4gKiAgICAgd2luZG93LmxvY2F0aW9uLmhyZWYgPSAnL2xvZ2luJztcbiAqICAgfSxcbiAqIH0pO1xuICpcbiAqIC8vIFVzZSBob29rcyBpbiB5b3VyIGNvbXBvbmVudHNcbiAqIGZ1bmN0aW9uIEFwcCgpIHtcbiAqICAgY29uc3QgeyBkYXRhOiB1c2VyIH0gPSB1c2VDdXJyZW50VXNlcigpO1xuICogICBjb25zdCB7IGRhdGE6IHNwb3RzIH0gPSB1c2VTcG90cygpO1xuICogICBjb25zdCB7IG11dGF0ZTogY3JlYXRlUG9zdCB9ID0gdXNlQ3JlYXRlUG9zdCgpO1xuICogICAvLyAuLi5cbiAqIH1cbiAqIGBgYFxuICovXG5cbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbi8vIEFQSSBDTElFTlRcbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuZXhwb3J0IHR5cGUge1NES0NvbmZpZ30gZnJvbSAnLi9hcGkvY2xpZW50J1xuZXhwb3J0IHtjb25maWd1cmVTREssIGdldEFwaUNsaWVudCwgZ2V0Q29uZmlnfSBmcm9tICcuL2FwaS9jbGllbnQnXG5cbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbi8vIFRZUEVTXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG5cbmV4cG9ydCAqIGZyb20gJy4vYXBpL3R5cGVzJ1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBRVUVSWSBIT09LU1xuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgKiBmcm9tICcuL2FwaS9xdWVyaWVzJ1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBNVVRBVElPTiBIT09LU1xuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgKiBmcm9tICcuL2FwaS9tdXRhdGlvbnMnXG4iXX0=
1147
+ function useWallet(options) {
1148
+ return useQuery({
1149
+ queryKey: walletKeys.active(),
1150
+ queryFn: async () => {
1151
+ const client = getApiClient();
1152
+ const response = await client.get("/wallet");
1153
+ return extractArrayData5(response.data.data);
1154
+ },
1155
+ ...options
1156
+ });
1157
+ }
1158
+ function useWalletHistory(params, options) {
1159
+ return useQuery({
1160
+ queryKey: walletKeys.history(params?.page),
1161
+ queryFn: async () => {
1162
+ const client = getApiClient();
1163
+ const queryParams = new URLSearchParams();
1164
+ if (params?.page) queryParams.set("page", String(params.page));
1165
+ if (params?.limit) queryParams.set("limit", String(params.limit));
1166
+ const response = await client.get(
1167
+ `/wallet/history?${queryParams}`
1168
+ );
1169
+ return extractObjectData3(response.data.data);
1170
+ },
1171
+ ...options
1172
+ });
1173
+ }
1174
+ function useRedemptionLookup(qrCode, options) {
1175
+ return useQuery({
1176
+ queryKey: walletKeys.lookup(qrCode),
1177
+ queryFn: async () => {
1178
+ const client = getApiClient();
1179
+ const response = await client.get(
1180
+ `/redemptions/lookup/${qrCode}`
1181
+ );
1182
+ return extractObjectData3(response.data.data);
1183
+ },
1184
+ enabled: !!qrCode && qrCode.length > 0,
1185
+ ...options
1186
+ });
1187
+ }
1188
+ function useSpotRedemptions(spotId, params, options) {
1189
+ return useQuery({
1190
+ queryKey: walletKeys.spotRedemptions(spotId, params?.page),
1191
+ queryFn: async () => {
1192
+ const client = getApiClient();
1193
+ const queryParams = new URLSearchParams();
1194
+ if (params?.page) queryParams.set("page", String(params.page));
1195
+ if (params?.limit) queryParams.set("limit", String(params.limit));
1196
+ const response = await client.get(
1197
+ `/spots/${spotId}/redemptions?${queryParams}`
1198
+ );
1199
+ return extractObjectData3(response.data.data);
1200
+ },
1201
+ enabled: !!spotId,
1202
+ ...options
1203
+ });
1204
+ }
1205
+ var paymentKeys = {
1206
+ all: ["payments"],
1207
+ config: () => [...paymentKeys.all, "config"]
1208
+ };
1209
+ function usePaymentConfig(options) {
1210
+ return useQuery({
1211
+ queryKey: paymentKeys.config(),
1212
+ queryFn: async () => {
1213
+ const client = getApiClient();
1214
+ const response = await client.get(
1215
+ "/payments/config"
1216
+ );
1217
+ return response.data.data;
1218
+ },
1219
+ staleTime: 1e3 * 60 * 60,
1220
+ // 1 hour - config rarely changes
1221
+ ...options
1222
+ });
1223
+ }
1224
+ function useUpdateProfile(options) {
1225
+ const queryClient = useQueryClient();
1226
+ return useMutation({
1227
+ mutationFn: async (data) => {
1228
+ const client = getApiClient();
1229
+ const response = await client.put("/users/me", data);
1230
+ return response.data.data;
1231
+ },
1232
+ onSuccess: (data) => {
1233
+ queryClient.setQueryData(userKeys.me(), data);
1234
+ },
1235
+ ...options
1236
+ });
1237
+ }
1238
+ function useUploadAvatar(options) {
1239
+ const queryClient = useQueryClient();
1240
+ return useMutation({
1241
+ mutationFn: async (formData) => {
1242
+ const client = getApiClient();
1243
+ const response = await client.post(
1244
+ "/users/me/avatar",
1245
+ formData,
1246
+ {
1247
+ headers: { "Content-Type": "multipart/form-data" }
1248
+ }
1249
+ );
1250
+ return response.data.data;
1251
+ },
1252
+ onSuccess: () => {
1253
+ queryClient.invalidateQueries({ queryKey: userKeys.me() });
1254
+ },
1255
+ ...options
1256
+ });
1257
+ }
1258
+ function useDeleteAccount(options) {
1259
+ const queryClient = useQueryClient();
1260
+ return useMutation({
1261
+ mutationFn: async () => {
1262
+ const client = getApiClient();
1263
+ await client.delete("/users/me");
1264
+ },
1265
+ onSuccess: () => {
1266
+ queryClient.clear();
1267
+ },
1268
+ ...options
1269
+ });
1270
+ }
1271
+ function useUpdateVibes(options) {
1272
+ const queryClient = useQueryClient();
1273
+ return useMutation({
1274
+ mutationFn: async (data) => {
1275
+ const client = getApiClient();
1276
+ const response = await client.put(
1277
+ "/users/me/vibes",
1278
+ data
1279
+ );
1280
+ return response.data.data;
1281
+ },
1282
+ onSuccess: () => {
1283
+ queryClient.invalidateQueries({ queryKey: userKeys.me() });
1284
+ },
1285
+ ...options
1286
+ });
1287
+ }
1288
+ function useUpdateInterests(options) {
1289
+ const queryClient = useQueryClient();
1290
+ return useMutation({
1291
+ mutationFn: async (data) => {
1292
+ const client = getApiClient();
1293
+ const response = await client.put(
1294
+ "/user/me/interests",
1295
+ data
1296
+ );
1297
+ return response.data.data;
1298
+ },
1299
+ onSuccess: () => {
1300
+ queryClient.invalidateQueries({ queryKey: userKeys.me() });
1301
+ },
1302
+ ...options
1303
+ });
1304
+ }
1305
+ function useCompleteOnboardingStep(options) {
1306
+ const queryClient = useQueryClient();
1307
+ return useMutation({
1308
+ mutationFn: async (data) => {
1309
+ const client = getApiClient();
1310
+ const response = await client.post(
1311
+ "/user/me/onboarding-step",
1312
+ data
1313
+ );
1314
+ return response.data.data;
1315
+ },
1316
+ onSuccess: () => {
1317
+ queryClient.invalidateQueries({ queryKey: userKeys.me() });
1318
+ },
1319
+ ...options
1320
+ });
1321
+ }
1322
+ function useBlockUser(options) {
1323
+ const queryClient = useQueryClient();
1324
+ return useMutation({
1325
+ mutationFn: async (userId) => {
1326
+ const client = getApiClient();
1327
+ await client.post(`/users/${userId}/block`);
1328
+ },
1329
+ onSuccess: () => {
1330
+ queryClient.invalidateQueries({ queryKey: userKeys.blocked() });
1331
+ },
1332
+ ...options
1333
+ });
1334
+ }
1335
+ function useUnblockUser(options) {
1336
+ const queryClient = useQueryClient();
1337
+ return useMutation({
1338
+ mutationFn: async (userId) => {
1339
+ const client = getApiClient();
1340
+ await client.delete(`/users/${userId}/block`);
1341
+ },
1342
+ onSuccess: () => {
1343
+ queryClient.invalidateQueries({ queryKey: userKeys.blocked() });
1344
+ },
1345
+ ...options
1346
+ });
1347
+ }
1348
+ function useCreatePost(options) {
1349
+ const queryClient = useQueryClient();
1350
+ return useMutation({
1351
+ mutationFn: async ({ spotId, ...data }) => {
1352
+ const client = getApiClient();
1353
+ const response = await client.post(
1354
+ `/spots/${spotId}/posts`,
1355
+ data
1356
+ );
1357
+ return response.data.data;
1358
+ },
1359
+ onSuccess: (_, variables) => {
1360
+ queryClient.invalidateQueries({
1361
+ queryKey: postKeys.bySpot(variables.spotId)
1362
+ });
1363
+ },
1364
+ ...options
1365
+ });
1366
+ }
1367
+ function useUpdatePost(options) {
1368
+ const queryClient = useQueryClient();
1369
+ return useMutation({
1370
+ mutationFn: async ({ postId, title, content }) => {
1371
+ const client = getApiClient();
1372
+ const response = await client.put(
1373
+ `/posts/${postId}`,
1374
+ { title, description: content }
1375
+ );
1376
+ return response.data.data;
1377
+ },
1378
+ onSuccess: (data, variables) => {
1379
+ queryClient.setQueryData(postKeys.detail(variables.postId), data);
1380
+ },
1381
+ ...options
1382
+ });
1383
+ }
1384
+ function useDeletePost(options) {
1385
+ const queryClient = useQueryClient();
1386
+ return useMutation({
1387
+ mutationFn: async (postId) => {
1388
+ const client = getApiClient();
1389
+ await client.delete(`/posts/${postId}`);
1390
+ },
1391
+ onSuccess: (_, postId) => {
1392
+ queryClient.invalidateQueries({ queryKey: postKeys.detail(postId) });
1393
+ queryClient.invalidateQueries({ queryKey: postKeys.lists() });
1394
+ },
1395
+ ...options
1396
+ });
1397
+ }
1398
+ function useFulfillPost(options) {
1399
+ const queryClient = useQueryClient();
1400
+ return useMutation({
1401
+ mutationFn: async (postId) => {
1402
+ const client = getApiClient();
1403
+ const response = await client.put(
1404
+ `/posts/${postId}/fulfill`
1405
+ );
1406
+ return response.data.data;
1407
+ },
1408
+ onSuccess: (data, postId) => {
1409
+ queryClient.setQueryData(postKeys.detail(postId), data);
1410
+ },
1411
+ ...options
1412
+ });
1413
+ }
1414
+ function useUpvotePost(options) {
1415
+ const queryClient = useQueryClient();
1416
+ return useMutation({
1417
+ mutationFn: async (postId) => {
1418
+ const client = getApiClient();
1419
+ const response = await client.post(
1420
+ `/posts/${postId}/upvote`
1421
+ );
1422
+ return response.data.data;
1423
+ },
1424
+ onSuccess: (_, postId) => {
1425
+ queryClient.invalidateQueries({ queryKey: postKeys.detail(postId) });
1426
+ },
1427
+ ...options
1428
+ });
1429
+ }
1430
+ function useCreateReply(options) {
1431
+ const queryClient = useQueryClient();
1432
+ return useMutation({
1433
+ mutationFn: async ({ postId, ...data }) => {
1434
+ const client = getApiClient();
1435
+ const response = await client.post(
1436
+ `/posts/${postId}/reply`,
1437
+ data
1438
+ );
1439
+ return response.data.data;
1440
+ },
1441
+ onSuccess: (_, variables) => {
1442
+ queryClient.invalidateQueries({
1443
+ queryKey: postKeys.detail(variables.postId)
1444
+ });
1445
+ },
1446
+ ...options
1447
+ });
1448
+ }
1449
+ function useDeleteReply(options) {
1450
+ const queryClient = useQueryClient();
1451
+ return useMutation({
1452
+ mutationFn: async ({ replyId }) => {
1453
+ const client = getApiClient();
1454
+ await client.delete(`/replies/${replyId}`);
1455
+ },
1456
+ onSuccess: (_, variables) => {
1457
+ queryClient.invalidateQueries({
1458
+ queryKey: postKeys.detail(variables.postId)
1459
+ });
1460
+ },
1461
+ ...options
1462
+ });
1463
+ }
1464
+ function useRespondToPost(options) {
1465
+ const queryClient = useQueryClient();
1466
+ return useMutation({
1467
+ mutationFn: async ({ postId, ...data }) => {
1468
+ const client = getApiClient();
1469
+ const response = await client.post(
1470
+ `/posts/${postId}/respond`,
1471
+ data
1472
+ );
1473
+ return response.data.data;
1474
+ },
1475
+ onSuccess: (_, variables) => {
1476
+ queryClient.invalidateQueries({
1477
+ queryKey: postKeys.detail(variables.postId)
1478
+ });
1479
+ queryClient.invalidateQueries({
1480
+ queryKey: postKeys.responses(variables.postId)
1481
+ });
1482
+ },
1483
+ ...options
1484
+ });
1485
+ }
1486
+ function useUpdateResponse(options) {
1487
+ const queryClient = useQueryClient();
1488
+ return useMutation({
1489
+ mutationFn: async ({
1490
+ responseId,
1491
+ postId: _,
1492
+ ...data
1493
+ }) => {
1494
+ const client = getApiClient();
1495
+ const response = await client.put(
1496
+ `/responses/${responseId}`,
1497
+ data
1498
+ );
1499
+ return response.data.data;
1500
+ },
1501
+ onSuccess: (_, variables) => {
1502
+ queryClient.invalidateQueries({
1503
+ queryKey: postKeys.responses(variables.postId)
1504
+ });
1505
+ },
1506
+ ...options
1507
+ });
1508
+ }
1509
+ function useReportPost(options) {
1510
+ return useMutation({
1511
+ mutationFn: async ({ postId, ...data }) => {
1512
+ const client = getApiClient();
1513
+ await client.post(`/posts/${postId}/report`, data);
1514
+ },
1515
+ ...options
1516
+ });
1517
+ }
1518
+ function useUpdatePostStatus(options) {
1519
+ const queryClient = useQueryClient();
1520
+ return useMutation({
1521
+ mutationFn: async ({ postId, ...data }) => {
1522
+ const client = getApiClient();
1523
+ const response = await client.put(
1524
+ `/posts/${postId}/status`,
1525
+ data
1526
+ );
1527
+ return response.data.data;
1528
+ },
1529
+ onSuccess: (data, variables) => {
1530
+ queryClient.setQueryData(postKeys.status(variables.postId), data);
1531
+ },
1532
+ ...options
1533
+ });
1534
+ }
1535
+ function useCreateSpot(options) {
1536
+ const queryClient = useQueryClient();
1537
+ return useMutation({
1538
+ mutationFn: async (data) => {
1539
+ const client = getApiClient();
1540
+ const response = await client.post("/spots", data);
1541
+ return response.data.data;
1542
+ },
1543
+ onSuccess: () => {
1544
+ queryClient.invalidateQueries({ queryKey: spotKeys.lists() });
1545
+ },
1546
+ ...options
1547
+ });
1548
+ }
1549
+ function useUpdateSpot(options) {
1550
+ const queryClient = useQueryClient();
1551
+ return useMutation({
1552
+ mutationFn: async ({ spotId, ...data }) => {
1553
+ const client = getApiClient();
1554
+ const response = await client.put(
1555
+ `/spots/${spotId}`,
1556
+ data
1557
+ );
1558
+ return response.data.data;
1559
+ },
1560
+ onSuccess: (data, variables) => {
1561
+ queryClient.setQueryData(spotKeys.detail(variables.spotId), data);
1562
+ },
1563
+ ...options
1564
+ });
1565
+ }
1566
+ function useClaimSpot(options) {
1567
+ return useMutation({
1568
+ mutationFn: async ({ spotId, ...data }) => {
1569
+ const client = getApiClient();
1570
+ const response = await client.post(
1571
+ `/spots/${spotId}/claim`,
1572
+ data
1573
+ );
1574
+ return response.data.data;
1575
+ },
1576
+ ...options
1577
+ });
1578
+ }
1579
+ function useSubscribeToSpot(options) {
1580
+ const queryClient = useQueryClient();
1581
+ return useMutation({
1582
+ mutationFn: async (spotId) => {
1583
+ const client = getApiClient();
1584
+ await client.post(`/spots/${spotId}/subscribe`);
1585
+ },
1586
+ onSuccess: () => {
1587
+ queryClient.invalidateQueries({ queryKey: userKeys.subscriptions() });
1588
+ },
1589
+ ...options
1590
+ });
1591
+ }
1592
+ function useUnsubscribeFromSpot(options) {
1593
+ const queryClient = useQueryClient();
1594
+ return useMutation({
1595
+ mutationFn: async (spotId) => {
1596
+ const client = getApiClient();
1597
+ await client.delete(`/spots/${spotId}/subscribe`);
1598
+ },
1599
+ onSuccess: () => {
1600
+ queryClient.invalidateQueries({ queryKey: userKeys.subscriptions() });
1601
+ },
1602
+ ...options
1603
+ });
1604
+ }
1605
+ function useFavoriteSpot(options) {
1606
+ const queryClient = useQueryClient();
1607
+ return useMutation({
1608
+ mutationFn: async (spotId) => {
1609
+ const client = getApiClient();
1610
+ const response = await client.post(
1611
+ `/spots/${spotId}/favorite`
1612
+ );
1613
+ return response.data.data;
1614
+ },
1615
+ onSuccess: () => {
1616
+ queryClient.invalidateQueries({ queryKey: userKeys.favorites() });
1617
+ },
1618
+ ...options
1619
+ });
1620
+ }
1621
+ function useRateSpot(options) {
1622
+ const queryClient = useQueryClient();
1623
+ return useMutation({
1624
+ mutationFn: async ({
1625
+ spotId,
1626
+ rating
1627
+ }) => {
1628
+ const client = getApiClient();
1629
+ const response = await client.post(
1630
+ `/spots/${spotId}/rate`,
1631
+ { rating }
1632
+ );
1633
+ return response.data.data;
1634
+ },
1635
+ onSuccess: (_, variables) => {
1636
+ queryClient.invalidateQueries({
1637
+ queryKey: spotKeys.detail(variables.spotId)
1638
+ });
1639
+ },
1640
+ ...options
1641
+ });
1642
+ }
1643
+ function useReportSpot(options) {
1644
+ return useMutation({
1645
+ mutationFn: async ({
1646
+ spotId,
1647
+ reason,
1648
+ details
1649
+ }) => {
1650
+ const client = getApiClient();
1651
+ const response = await client.post(
1652
+ `/spots/${spotId}/report`,
1653
+ { reason, details }
1654
+ );
1655
+ return response.data.data;
1656
+ },
1657
+ ...options
1658
+ });
1659
+ }
1660
+ function useCreateConversation(options) {
1661
+ const queryClient = useQueryClient();
1662
+ return useMutation({
1663
+ mutationFn: async (data) => {
1664
+ const client = getApiClient();
1665
+ const response = await client.post(
1666
+ "/conversations",
1667
+ data
1668
+ );
1669
+ return response.data.data;
1670
+ },
1671
+ onSuccess: () => {
1672
+ queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
1673
+ },
1674
+ ...options
1675
+ });
1676
+ }
1677
+ function useCreateDirectConversation(options) {
1678
+ const queryClient = useQueryClient();
1679
+ return useMutation({
1680
+ mutationFn: async (data) => {
1681
+ const client = getApiClient();
1682
+ const response = await client.post(
1683
+ "/conversations/direct",
1684
+ data
1685
+ );
1686
+ return response.data.data;
1687
+ },
1688
+ onSuccess: () => {
1689
+ queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
1690
+ },
1691
+ ...options
1692
+ });
1693
+ }
1694
+ function useSendMessage(options) {
1695
+ const queryClient = useQueryClient();
1696
+ return useMutation({
1697
+ mutationFn: async ({ conversationId, ...data }) => {
1698
+ const client = getApiClient();
1699
+ const response = await client.post(
1700
+ `/conversations/${conversationId}/messages`,
1701
+ data
1702
+ );
1703
+ return response.data.data;
1704
+ },
1705
+ onSuccess: (_, variables) => {
1706
+ queryClient.invalidateQueries({
1707
+ queryKey: conversationKeys.messages(variables.conversationId)
1708
+ });
1709
+ queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
1710
+ },
1711
+ ...options
1712
+ });
1713
+ }
1714
+ function useMarkConversationAsRead(options) {
1715
+ const queryClient = useQueryClient();
1716
+ return useMutation({
1717
+ mutationFn: async (conversationId) => {
1718
+ const client = getApiClient();
1719
+ await client.put(`/conversations/${conversationId}/read`);
1720
+ },
1721
+ onSuccess: (_, conversationId) => {
1722
+ queryClient.invalidateQueries({
1723
+ queryKey: conversationKeys.detail(conversationId)
1724
+ });
1725
+ queryClient.invalidateQueries({ queryKey: conversationKeys.lists() });
1726
+ },
1727
+ ...options
1728
+ });
1729
+ }
1730
+ function useSendTypingIndicator(options) {
1731
+ return useMutation({
1732
+ mutationFn: async (conversationId) => {
1733
+ const client = getApiClient();
1734
+ await client.post(`/conversations/${conversationId}/typing`);
1735
+ },
1736
+ ...options
1737
+ });
1738
+ }
1739
+ function useCreateClub(options) {
1740
+ const queryClient = useQueryClient();
1741
+ return useMutation({
1742
+ mutationFn: async (data) => {
1743
+ const client = getApiClient();
1744
+ const response = await client.post("/clubs", data);
1745
+ return response.data.data;
1746
+ },
1747
+ onSuccess: (_, variables) => {
1748
+ queryClient.invalidateQueries({
1749
+ queryKey: clubKeys.bySpot(variables.spotId)
1750
+ });
1751
+ },
1752
+ ...options
1753
+ });
1754
+ }
1755
+ function useUpdateClub(options) {
1756
+ const queryClient = useQueryClient();
1757
+ return useMutation({
1758
+ mutationFn: async ({ clubId, ...data }) => {
1759
+ const client = getApiClient();
1760
+ const response = await client.put(
1761
+ `/clubs/${clubId}`,
1762
+ data
1763
+ );
1764
+ return response.data.data;
1765
+ },
1766
+ onSuccess: (data, variables) => {
1767
+ queryClient.setQueryData(clubKeys.detail(variables.clubId), data);
1768
+ },
1769
+ ...options
1770
+ });
1771
+ }
1772
+ function useJoinClub(options) {
1773
+ const queryClient = useQueryClient();
1774
+ return useMutation({
1775
+ mutationFn: async (clubId) => {
1776
+ const client = getApiClient();
1777
+ await client.post(`/clubs/${clubId}/join`);
1778
+ },
1779
+ onSuccess: (_, clubId) => {
1780
+ queryClient.invalidateQueries({ queryKey: clubKeys.detail(clubId) });
1781
+ queryClient.invalidateQueries({ queryKey: userKeys.clubs() });
1782
+ },
1783
+ ...options
1784
+ });
1785
+ }
1786
+ function useLeaveClub(options) {
1787
+ const queryClient = useQueryClient();
1788
+ return useMutation({
1789
+ mutationFn: async (clubId) => {
1790
+ const client = getApiClient();
1791
+ await client.post(`/clubs/${clubId}/leave`);
1792
+ },
1793
+ onSuccess: (_, clubId) => {
1794
+ queryClient.invalidateQueries({ queryKey: clubKeys.detail(clubId) });
1795
+ queryClient.invalidateQueries({ queryKey: userKeys.clubs() });
1796
+ },
1797
+ ...options
1798
+ });
1799
+ }
1800
+ function useMarkNotificationsRead(options) {
1801
+ const queryClient = useQueryClient();
1802
+ return useMutation({
1803
+ mutationFn: async (data) => {
1804
+ const client = getApiClient();
1805
+ await client.put("/notifications/read", data);
1806
+ },
1807
+ onSuccess: () => {
1808
+ queryClient.invalidateQueries({ queryKey: notificationKeys.lists() });
1809
+ queryClient.invalidateQueries({ queryKey: notificationKeys.unreadCount() });
1810
+ },
1811
+ ...options
1812
+ });
1813
+ }
1814
+ function useRegisterDeviceToken(options) {
1815
+ return useMutation({
1816
+ mutationFn: async (data) => {
1817
+ const client = getApiClient();
1818
+ await client.post("/device-tokens", data);
1819
+ },
1820
+ ...options
1821
+ });
1822
+ }
1823
+ function useRemoveDeviceToken(options) {
1824
+ return useMutation({
1825
+ mutationFn: async (data) => {
1826
+ const client = getApiClient();
1827
+ await client.delete("/device-tokens", { data });
1828
+ },
1829
+ ...options
1830
+ });
1831
+ }
1832
+ function generateSlug(name) {
1833
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 100);
1834
+ }
1835
+ function useCreateProduct(options) {
1836
+ const queryClient = useQueryClient();
1837
+ return useMutation({
1838
+ mutationFn: async (data) => {
1839
+ const client = getApiClient();
1840
+ const { spotId, slug, ...productData } = data;
1841
+ const productSlug = slug || generateSlug(productData.name);
1842
+ const response = await client.post(
1843
+ `/spots/${spotId}/products`,
1844
+ { ...productData, slug: productSlug }
1845
+ );
1846
+ return response.data.data;
1847
+ },
1848
+ onSuccess: (_, variables) => {
1849
+ queryClient.invalidateQueries({ queryKey: productKeys.bySpot(variables.spotId) });
1850
+ queryClient.invalidateQueries({ queryKey: productKeys.list({ my: true }) });
1851
+ },
1852
+ ...options
1853
+ });
1854
+ }
1855
+ function useUpdateProduct(options) {
1856
+ const queryClient = useQueryClient();
1857
+ return useMutation({
1858
+ mutationFn: async ({ productId, data }) => {
1859
+ const client = getApiClient();
1860
+ const response = await client.put(
1861
+ `/products/${productId}`,
1862
+ data
1863
+ );
1864
+ return response.data.data;
1865
+ },
1866
+ onSuccess: (data) => {
1867
+ queryClient.setQueryData(productKeys.detail(data.id), data);
1868
+ queryClient.invalidateQueries({ queryKey: productKeys.bySpot(data.spotId) });
1869
+ queryClient.invalidateQueries({ queryKey: productKeys.list({ my: true }) });
1870
+ },
1871
+ ...options
1872
+ });
1873
+ }
1874
+ function useDeleteProduct(options) {
1875
+ const queryClient = useQueryClient();
1876
+ return useMutation({
1877
+ mutationFn: async (productId) => {
1878
+ const client = getApiClient();
1879
+ await client.delete(`/products/${productId}`);
1880
+ },
1881
+ onSuccess: () => {
1882
+ queryClient.invalidateQueries({ queryKey: productKeys.all });
1883
+ },
1884
+ ...options
1885
+ });
1886
+ }
1887
+ function useAdjustStock(options) {
1888
+ const queryClient = useQueryClient();
1889
+ return useMutation({
1890
+ mutationFn: async ({ productId, quantity, reason, notes }) => {
1891
+ const client = getApiClient();
1892
+ const response = await client.post(
1893
+ `/products/${productId}/stock`,
1894
+ { quantity, reason, notes }
1895
+ );
1896
+ return response.data.data;
1897
+ },
1898
+ onSuccess: (data) => {
1899
+ queryClient.setQueryData(productKeys.detail(data.id), data);
1900
+ queryClient.invalidateQueries({ queryKey: productKeys.bySpot(data.spotId) });
1901
+ },
1902
+ ...options
1903
+ });
1904
+ }
1905
+ function useCreateOrder(options) {
1906
+ const queryClient = useQueryClient();
1907
+ return useMutation({
1908
+ mutationFn: async (data) => {
1909
+ const client = getApiClient();
1910
+ const response = await client.post(
1911
+ "/orders",
1912
+ data
1913
+ );
1914
+ return response.data.data;
1915
+ },
1916
+ onSuccess: (_, variables) => {
1917
+ queryClient.invalidateQueries({ queryKey: productKeys.bySpot(variables.spotId) });
1918
+ queryClient.invalidateQueries({ queryKey: orderKeys.list({ my: true }) });
1919
+ },
1920
+ ...options
1921
+ });
1922
+ }
1923
+ function useCreateStripeIntent(options) {
1924
+ return useMutation({
1925
+ mutationFn: async (orderId) => {
1926
+ const client = getApiClient();
1927
+ const response = await client.post(
1928
+ `/payments/stripe/intent/${orderId}`
1929
+ );
1930
+ return response.data.data;
1931
+ },
1932
+ ...options
1933
+ });
1934
+ }
1935
+ function useCreateCoinbaseCharge(options) {
1936
+ return useMutation({
1937
+ mutationFn: async (orderId) => {
1938
+ const client = getApiClient();
1939
+ const response = await client.post(
1940
+ `/payments/coinbase/charge/${orderId}`
1941
+ );
1942
+ return response.data.data;
1943
+ },
1944
+ ...options
1945
+ });
1946
+ }
1947
+ function useUpdateOrderStatus(options) {
1948
+ const queryClient = useQueryClient();
1949
+ return useMutation({
1950
+ mutationFn: async ({ orderId, status }) => {
1951
+ const client = getApiClient();
1952
+ const response = await client.put(
1953
+ `/orders/${orderId}/status`,
1954
+ { status }
1955
+ );
1956
+ return response.data.data;
1957
+ },
1958
+ onSuccess: (data) => {
1959
+ queryClient.setQueryData(orderKeys.detail(data.id), data);
1960
+ queryClient.invalidateQueries({ queryKey: orderKeys.spotOrders(data.spotId) });
1961
+ },
1962
+ ...options
1963
+ });
1964
+ }
1965
+ function useCancelOrder(options) {
1966
+ const queryClient = useQueryClient();
1967
+ return useMutation({
1968
+ mutationFn: async (orderId) => {
1969
+ const client = getApiClient();
1970
+ const response = await client.post(
1971
+ `/orders/${orderId}/cancel`
1972
+ );
1973
+ return response.data.data;
1974
+ },
1975
+ onSuccess: (data) => {
1976
+ queryClient.setQueryData(orderKeys.detail(data.id), data);
1977
+ queryClient.invalidateQueries({ queryKey: orderKeys.list({ my: true }) });
1978
+ queryClient.invalidateQueries({ queryKey: productKeys.bySpot(data.spotId) });
1979
+ },
1980
+ ...options
1981
+ });
1982
+ }
1983
+ function useRedeem() {
1984
+ const queryClient = useQueryClient();
1985
+ return useMutation({
1986
+ mutationFn: async (request) => {
1987
+ const client = getApiClient();
1988
+ const response = await client.post("/redemptions/redeem", request);
1989
+ return response.data.data;
1990
+ },
1991
+ onSuccess: (_data, variables) => {
1992
+ queryClient.invalidateQueries({
1993
+ queryKey: walletKeys.lookup(variables.qrCode)
1994
+ });
1995
+ if (variables.spotId) {
1996
+ queryClient.invalidateQueries({
1997
+ queryKey: walletKeys.spotRedemptions(variables.spotId)
1998
+ });
1999
+ }
2000
+ }
2001
+ });
2002
+ }
2003
+ function useVoidRedemption() {
2004
+ const queryClient = useQueryClient();
2005
+ return useMutation({
2006
+ mutationFn: async ({
2007
+ redemptionId,
2008
+ reason
2009
+ }) => {
2010
+ const client = getApiClient();
2011
+ const response = await client.put(`/redemptions/${redemptionId}/void`, { reason });
2012
+ return response.data.data;
2013
+ },
2014
+ onSuccess: () => {
2015
+ queryClient.invalidateQueries({ queryKey: walletKeys.all });
2016
+ queryClient.invalidateQueries({ queryKey: walletKeys.redemptions() });
2017
+ }
2018
+ });
2019
+ }
2020
+
2021
+ export { clubKeys, configureSDK, conversationKeys, getApiClient, getConfig, miscKeys, notificationKeys, orderKeys, paymentKeys, postKeys, productKeys, spotKeys, templateKeys, useAdjustStock, useBlockUser, useBlockedUsers, useCancelOrder, useCities, useClaimSpot, useClub, useClubBySlug, useClubMembership, useClubsBySpot, useClubsByUser, useCompleteOnboardingStep, useConversation, useConversationMessages, useConversations, useCreateClub, useCreateCoinbaseCharge, useCreateConversation, useCreateDirectConversation, useCreateOrder, useCreatePost, useCreateProduct, useCreateReply, useCreateSpot, useCreateStripeIntent, useCurrentUser, useDeleteAccount, useDeletePost, useDeleteProduct, useDeleteReply, useFavoriteSpot, useFulfillPost, useInfiniteSpots, useJoinClub, useLeaveClub, useLifeSituations, useMarkConversationAsRead, useMarkNotificationsRead, useMyOrders, useNotifications, useOrder, useOwnedSpots, usePaymentConfig, usePost, usePostResponses, usePostStatus, usePostUpvotes, usePosts, usePostsFeed, useProduct, useProductBySlug, useRateSpot, useRedeem, useRedemptionLookup, useRefreshToken, useRegisterDeviceToken, useRemoveDeviceToken, useReportPost, useReportSpot, useRespondToPost, useSendMessage, useSendOtp, useSendTypingIndicator, useSpot, useSpotByQR, useSpotBySlug, useSpotFavoriteStatus, useSpotImages, useSpotOrders, useSpotPosts, useSpotProducts, useSpotRedemptions, useSpots, useSubscribeToSpot, useTemplate, useTemplateBySlug, useTemplates, useUnblockUser, useUnreadNotificationCount, useUnsubscribeFromSpot, useUpdateClub, useUpdateInterests, useUpdateOrderStatus, useUpdatePost, useUpdatePostStatus, useUpdateProduct, useUpdateProfile, useUpdateResponse, useUpdateSpot, useUpdateVibes, useUploadAvatar, useUpvotePost, useUserActivity, useUserClubs, useUserFavorites, useUserPosts, useUserSpotsSummary, useUserStats, useUserSubscriptions, useVerifyOtp, useVibes, useVoidRedemption, useWallet, useWalletHistory, userKeys, walletKeys };
2022
+ //# sourceMappingURL=index.js.map
2023
+ //# sourceMappingURL=index.js.map