@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.
- package/dist/CLAUDE.md +1 -0
- package/dist/api/mutations/bookings.d.ts +16 -0
- package/dist/api/mutations/bookings.js +16 -2
- package/dist/api/mutations/event-chat.d.ts +1 -1
- package/dist/api/mutations/stripe-connect.js +4 -4
- package/dist/api/mutations/support.d.ts +16 -1
- package/dist/api/mutations/support.js +30 -1
- package/dist/api/queries/businesses.js +2 -2
- package/dist/api/queries/creators.js +2 -2
- package/dist/api/queries/event-chat.js +4 -4
- package/dist/api/queries/events.js +2 -2
- package/dist/api/queries/stripe-connect.js +3 -3
- package/dist/api/queries/support.d.ts +20 -1
- package/dist/api/queries/support.js +22 -1
- package/dist/api/types.d.ts +3 -0
- package/dist/api/types.js +1 -1
- package/package.json +1 -1
- package/src/api/mutations/bookings.ts +29 -1
- package/src/api/mutations/stripe-connect.ts +3 -3
- package/src/api/mutations/support.ts +37 -0
- package/src/api/queries/businesses.ts +1 -1
- package/src/api/queries/creators.ts +1 -1
- package/src/api/queries/event-chat.ts +6 -6
- package/src/api/queries/events.ts +1 -1
- package/src/api/queries/stripe-connect.ts +2 -2
- package/src/api/queries/support.ts +24 -0
- package/src/api/types.ts +5 -0
|
@@ -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
|
+
}
|
|
@@ -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
|
|
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
|
|
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
|
|
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,
|
|
@@ -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
|
// ============================================================================
|