@growsober/sdk 1.0.20 → 1.0.22

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.
@@ -20,6 +20,8 @@ import type {
20
20
  CreateReflectionRequest,
21
21
  CravingLogResponse,
22
22
  LogCravingRequest,
23
+ JournalEntryResponse,
24
+ CreateJournalEntryRequest,
23
25
  } from '../types';
24
26
  import { supportKeys } from '../queries/support';
25
27
 
@@ -432,3 +434,38 @@ export function useLogCraving(
432
434
  ...options,
433
435
  });
434
436
  }
437
+
438
+ /**
439
+ * Create a journal entry
440
+ *
441
+ * @example
442
+ * ```tsx
443
+ * const { mutate, isPending } = useCreateJournalEntry();
444
+ *
445
+ * mutate({
446
+ * content: 'Today I felt grateful...',
447
+ * title: 'Gratitude',
448
+ * mood: 4
449
+ * });
450
+ * ```
451
+ */
452
+ export function useCreateJournalEntry(
453
+ options?: Omit<
454
+ UseMutationOptions<JournalEntryResponse, Error, CreateJournalEntryRequest>,
455
+ 'mutationFn'
456
+ >
457
+ ): UseMutationResult<JournalEntryResponse, Error, CreateJournalEntryRequest> {
458
+ const queryClient = useQueryClient();
459
+
460
+ return useMutation({
461
+ mutationFn: async (data: CreateJournalEntryRequest): Promise<JournalEntryResponse> => {
462
+ const client = getApiClient();
463
+ const response = await client.post('/api/v1/support/journal', data);
464
+ return response.data;
465
+ },
466
+ onSuccess: (newEntry, variables, context) => {
467
+ queryClient.invalidateQueries({ queryKey: supportKeys.journalEntries() });
468
+ },
469
+ ...options,
470
+ });
471
+ }
@@ -86,7 +86,7 @@ export function useBusinesses(
86
86
  const response = await client.get('/api/v1/businesses', {
87
87
  params: filters,
88
88
  });
89
- return response.data;
89
+ return response.data?.data || response.data;
90
90
  },
91
91
  ...options,
92
92
  });
@@ -91,7 +91,7 @@ export function useCreators(
91
91
  const response = await client.get('/api/v1/creators', {
92
92
  params: filters,
93
93
  });
94
- return response.data;
94
+ return response.data?.data || response.data;
95
95
  },
96
96
  ...options,
97
97
  });
@@ -30,8 +30,8 @@ export function useEventChat(eventId: string | undefined) {
30
30
  queryFn: async () => {
31
31
  if (!eventId) throw new Error('Event ID is required');
32
32
  const client = getApiClient();
33
- const response = await client.get<EventChatResponse>(`/api/v1/events/${eventId}/chat`);
34
- return response.data;
33
+ const response = await client.get(`/api/v1/events/${eventId}/chat`);
34
+ return (response.data?.data || response.data) as EventChatResponse;
35
35
  },
36
36
  enabled: !!eventId,
37
37
  });
@@ -46,8 +46,8 @@ export function useEventChatMembers(eventId: string | undefined) {
46
46
  queryFn: async () => {
47
47
  if (!eventId) throw new Error('Event ID is required');
48
48
  const client = getApiClient();
49
- const response = await client.get<ChatMemberResponse[]>(`/api/v1/events/${eventId}/chat/members`);
50
- return response.data;
49
+ const response = await client.get(`/api/v1/events/${eventId}/chat/members`);
50
+ return (response.data?.data || response.data) as ChatMemberResponse[];
51
51
  },
52
52
  enabled: !!eventId,
53
53
  });
@@ -66,10 +66,10 @@ export function useEventChatMessages(eventId: string | undefined, limit = 50) {
66
66
  if (pageParam) {
67
67
  params.append('cursor', pageParam);
68
68
  }
69
- const response = await client.get<PaginatedMessagesResponse>(
69
+ const response = await client.get(
70
70
  `/api/v1/events/${eventId}/chat/messages?${params.toString()}`
71
71
  );
72
- return response.data;
72
+ return (response.data?.data || response.data) as PaginatedMessagesResponse;
73
73
  },
74
74
  initialPageParam: undefined as string | undefined,
75
75
  getNextPageParam: (lastPage) => lastPage.nextCursor,
@@ -162,7 +162,7 @@ export function useUpcomingEvents(
162
162
  const response = await client.get('/api/v1/events/upcoming', {
163
163
  params: { limit },
164
164
  });
165
- return response.data;
165
+ return response.data?.data || response.data;
166
166
  },
167
167
  ...options,
168
168
  });
@@ -54,7 +54,7 @@ export function useStripeConnectStatus(options?: { enabled?: boolean }) {
54
54
  return useQuery({
55
55
  queryKey: stripeConnectKeys.status(),
56
56
  queryFn: async () => {
57
- const response = await getApiClient().get<StripeAccountStatus>('/creators/me/stripe-connect/status');
57
+ const response = await getApiClient().get<StripeAccountStatus>('/api/v1/creators/me/stripe-connect/status');
58
58
  return response.data;
59
59
  },
60
60
  enabled: options?.enabled ?? true,
@@ -65,7 +65,7 @@ export function useCreatorEarnings(options?: { enabled?: boolean }) {
65
65
  return useQuery({
66
66
  queryKey: stripeConnectKeys.earnings(),
67
67
  queryFn: async () => {
68
- const response = await getApiClient().get<EarningsResponse>('/creators/me/stripe-connect/earnings');
68
+ const response = await getApiClient().get<EarningsResponse>('/api/v1/creators/me/stripe-connect/earnings');
69
69
  return response.data;
70
70
  },
71
71
  enabled: options?.enabled ?? true,
@@ -9,6 +9,7 @@ import type {
9
9
  ReflectionResponse,
10
10
  CravingLogResponse,
11
11
  CravingStatsResponse,
12
+ JournalEntryResponse,
12
13
  } from '../types';
13
14
 
14
15
  // ============================================================================
@@ -27,6 +28,7 @@ export const supportKeys = {
27
28
  winsByCategory: () => [...supportKeys.wins(), 'by-category'] as const,
28
29
  habits: () => [...supportKeys.all, 'habits'] as const,
29
30
  reflections: () => [...supportKeys.all, 'reflections'] as const,
31
+ journalEntries: () => [...supportKeys.all, 'journal'] as const,
30
32
  };
31
33
 
32
34
  // ============================================================================
@@ -287,3 +289,25 @@ export function useCravingStats(
287
289
  ...options,
288
290
  });
289
291
  }
292
+
293
+ /**
294
+ * Get journal entries for the current user
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * const { data, isLoading } = useJournalEntries();
299
+ * ```
300
+ */
301
+ export function useJournalEntries(
302
+ options?: Omit<UseQueryOptions<JournalEntryResponse[]>, 'queryKey' | 'queryFn'>
303
+ ) {
304
+ return useQuery({
305
+ queryKey: supportKeys.journalEntries(),
306
+ queryFn: async (): Promise<JournalEntryResponse[]> => {
307
+ const client = getApiClient();
308
+ const response = await client.get('/api/v1/support/journal');
309
+ return response.data;
310
+ },
311
+ ...options,
312
+ });
313
+ }
package/src/api/types.ts CHANGED
@@ -329,6 +329,11 @@ export type CravingLogResponse = components['schemas']['CravingLogResponseDto'];
329
329
  export type LogCravingRequest = components['schemas']['LogCravingDto'];
330
330
  export type CravingStatsResponse = components['schemas']['CravingStatsDto'];
331
331
 
332
+ // Journal
333
+ export type JournalEntryResponse = components['schemas']['JournalEntryResponseDto'];
334
+ export type CreateJournalEntryRequest = components['schemas']['CreateJournalEntryDto'];
335
+ export type UpdateJournalEntryRequest = components['schemas']['UpdateJournalEntryDto'];
336
+
332
337
  // ============================================================================
333
338
  // MAP TYPES
334
339
  // ============================================================================