@spotsdev/sdk 1.3.3 → 1.5.0

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