@growsober/sdk 1.0.0 → 1.0.1
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/api/mutations/admin.d.ts +1 -20
- package/dist/api/mutations/admin.js +1 -1
- package/dist/api/mutations/event-chat.d.ts +84 -7
- package/dist/api/mutations/event-chat.js +1 -1
- package/dist/api/mutations/matching.d.ts +2 -19
- package/dist/api/mutations/matching.js +6 -6
- package/dist/api/mutations/support.d.ts +5 -5
- package/dist/api/mutations/support.js +1 -1
- package/dist/api/queries/ambassadors.d.ts +71 -5
- package/dist/api/queries/ambassadors.js +1 -1
- package/dist/api/queries/event-chat.d.ts +30 -4
- package/dist/api/queries/grow90.d.ts +46 -4
- package/dist/api/queries/hubs.d.ts +2 -2
- package/dist/api/queries/hubs.js +1 -1
- package/dist/api/queries/map.d.ts +3 -3
- package/dist/api/queries/map.js +1 -1
- package/dist/api/queries/support.d.ts +88 -8
- package/dist/api/queries/support.js +1 -1
- package/dist/api/types.d.ts +63 -393
- package/dist/api/types.js +4 -4
- package/package.json +1 -1
- package/src/api/mutations/admin.ts +1 -20
- package/src/api/mutations/event-chat.ts +7 -7
- package/src/api/mutations/matching.ts +12 -32
- package/src/api/mutations/support.ts +11 -11
- package/src/api/queries/ambassadors.ts +6 -3
- package/src/api/queries/hubs.ts +3 -3
- package/src/api/queries/map.ts +10 -10
- package/src/api/queries/support.ts +8 -8
- package/src/api/types.ts +96 -448
|
@@ -6,33 +6,13 @@ import {
|
|
|
6
6
|
} from '@tanstack/react-query';
|
|
7
7
|
import { getApiClient } from '../client';
|
|
8
8
|
import { matchingKeys, MatchResponse, BuddyResponse } from '../queries/matching';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
message?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface UpdateMatchRequest {
|
|
20
|
-
status: 'ACCEPTED' | 'DECLINED' | 'BLOCKED';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface CreateBuddyRequest {
|
|
24
|
-
buddyId: string;
|
|
25
|
-
message?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface UpdateBuddyRequest {
|
|
29
|
-
status: 'ACCEPTED' | 'DECLINED' | 'ENDED';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface LogBuddyActivityRequest {
|
|
33
|
-
type: 'CHECK_IN' | 'MESSAGE' | 'SUPPORT';
|
|
34
|
-
note?: string;
|
|
35
|
-
}
|
|
9
|
+
import type {
|
|
10
|
+
CreateMatchRequest,
|
|
11
|
+
UpdateMatchRequest,
|
|
12
|
+
CreateBuddyRequest,
|
|
13
|
+
UpdateBuddyRequest,
|
|
14
|
+
LogBuddyActivityRequest,
|
|
15
|
+
} from '../types';
|
|
36
16
|
|
|
37
17
|
// ============================================================================
|
|
38
18
|
// MUTATION HOOKS
|
|
@@ -118,9 +98,9 @@ export function useAcceptMatch(
|
|
|
118
98
|
return {
|
|
119
99
|
...updateMatch,
|
|
120
100
|
mutate: (matchId: string, mutateOptions?: any) =>
|
|
121
|
-
updateMatch.mutate({ matchId, data: {
|
|
101
|
+
updateMatch.mutate({ matchId, data: { action: 'ACCEPT' } }, mutateOptions),
|
|
122
102
|
mutateAsync: (matchId: string) =>
|
|
123
|
-
updateMatch.mutateAsync({ matchId, data: {
|
|
103
|
+
updateMatch.mutateAsync({ matchId, data: { action: 'ACCEPT' } }),
|
|
124
104
|
} as UseMutationResult<MatchResponse, Error, string>;
|
|
125
105
|
}
|
|
126
106
|
|
|
@@ -141,9 +121,9 @@ export function useDeclineMatch(
|
|
|
141
121
|
return {
|
|
142
122
|
...updateMatch,
|
|
143
123
|
mutate: (matchId: string, mutateOptions?: any) =>
|
|
144
|
-
updateMatch.mutate({ matchId, data: {
|
|
124
|
+
updateMatch.mutate({ matchId, data: { action: 'DECLINE' } }, mutateOptions),
|
|
145
125
|
mutateAsync: (matchId: string) =>
|
|
146
|
-
updateMatch.mutateAsync({ matchId, data: {
|
|
126
|
+
updateMatch.mutateAsync({ matchId, data: { action: 'DECLINE' } }),
|
|
147
127
|
} as UseMutationResult<MatchResponse, Error, string>;
|
|
148
128
|
}
|
|
149
129
|
|
|
@@ -214,7 +194,7 @@ export function useRequestBuddy(
|
|
|
214
194
|
* @example
|
|
215
195
|
* ```tsx
|
|
216
196
|
* const updateBuddy = useUpdateBuddy();
|
|
217
|
-
* await updateBuddy.mutateAsync({ buddyId: 'buddy-123', data: {
|
|
197
|
+
* await updateBuddy.mutateAsync({ buddyId: 'buddy-123', data: { action: 'ACCEPT' } });
|
|
218
198
|
* ```
|
|
219
199
|
*/
|
|
220
200
|
export function useUpdateBuddy(
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
} from '@tanstack/react-query';
|
|
7
7
|
import { getApiClient } from '../client';
|
|
8
8
|
import type {
|
|
9
|
-
|
|
9
|
+
CheckInResponse,
|
|
10
10
|
CreateCheckInRequest,
|
|
11
11
|
UpdateCheckInRequest,
|
|
12
12
|
MoodLogResponse,
|
|
13
|
-
|
|
13
|
+
LogMoodRequest,
|
|
14
14
|
WinResponse,
|
|
15
15
|
CreateWinRequest,
|
|
16
16
|
HabitResponse,
|
|
@@ -44,14 +44,14 @@ import { supportKeys } from '../queries/support';
|
|
|
44
44
|
*/
|
|
45
45
|
export function useCreateCheckIn(
|
|
46
46
|
options?: Omit<
|
|
47
|
-
UseMutationOptions<
|
|
47
|
+
UseMutationOptions<CheckInResponse, Error, CreateCheckInRequest>,
|
|
48
48
|
'mutationFn'
|
|
49
49
|
>
|
|
50
|
-
): UseMutationResult<
|
|
50
|
+
): UseMutationResult<CheckInResponse, Error, CreateCheckInRequest> {
|
|
51
51
|
const queryClient = useQueryClient();
|
|
52
52
|
|
|
53
53
|
return useMutation({
|
|
54
|
-
mutationFn: async (data: CreateCheckInRequest): Promise<
|
|
54
|
+
mutationFn: async (data: CreateCheckInRequest): Promise<CheckInResponse> => {
|
|
55
55
|
const client = getApiClient();
|
|
56
56
|
const response = await client.post('/api/v1/support/check-ins', data);
|
|
57
57
|
return response.data;
|
|
@@ -88,14 +88,14 @@ export function useCreateCheckIn(
|
|
|
88
88
|
*/
|
|
89
89
|
export function useUpdateCheckIn(
|
|
90
90
|
options?: Omit<
|
|
91
|
-
UseMutationOptions<
|
|
91
|
+
UseMutationOptions<CheckInResponse, Error, { id: string; data: UpdateCheckInRequest }>,
|
|
92
92
|
'mutationFn'
|
|
93
93
|
>
|
|
94
|
-
): UseMutationResult<
|
|
94
|
+
): UseMutationResult<CheckInResponse, Error, { id: string; data: UpdateCheckInRequest }> {
|
|
95
95
|
const queryClient = useQueryClient();
|
|
96
96
|
|
|
97
97
|
return useMutation({
|
|
98
|
-
mutationFn: async ({ id, data }: { id: string; data: UpdateCheckInRequest }): Promise<
|
|
98
|
+
mutationFn: async ({ id, data }: { id: string; data: UpdateCheckInRequest }): Promise<CheckInResponse> => {
|
|
99
99
|
const client = getApiClient();
|
|
100
100
|
const response = await client.put(`/api/v1/support/check-ins/${id}`, data);
|
|
101
101
|
return response.data;
|
|
@@ -128,14 +128,14 @@ export function useUpdateCheckIn(
|
|
|
128
128
|
*/
|
|
129
129
|
export function useCreateMoodLog(
|
|
130
130
|
options?: Omit<
|
|
131
|
-
UseMutationOptions<MoodLogResponse, Error,
|
|
131
|
+
UseMutationOptions<MoodLogResponse, Error, LogMoodRequest>,
|
|
132
132
|
'mutationFn'
|
|
133
133
|
>
|
|
134
|
-
): UseMutationResult<MoodLogResponse, Error,
|
|
134
|
+
): UseMutationResult<MoodLogResponse, Error, LogMoodRequest> {
|
|
135
135
|
const queryClient = useQueryClient();
|
|
136
136
|
|
|
137
137
|
return useMutation({
|
|
138
|
-
mutationFn: async (data:
|
|
138
|
+
mutationFn: async (data: LogMoodRequest): Promise<MoodLogResponse> => {
|
|
139
139
|
const client = getApiClient();
|
|
140
140
|
const response = await client.post('/api/v1/support/mood', data);
|
|
141
141
|
return response.data;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
2
2
|
import { getApiClient } from '../client';
|
|
3
|
-
import type { AmbassadorResponse
|
|
3
|
+
import type { AmbassadorResponse } from '../types';
|
|
4
4
|
|
|
5
5
|
// ============================================================================
|
|
6
6
|
// QUERY KEYS
|
|
@@ -21,6 +21,9 @@ export const ambassadorKeys = {
|
|
|
21
21
|
// TYPES
|
|
22
22
|
// ============================================================================
|
|
23
23
|
|
|
24
|
+
// Extract status type from AmbassadorResponse
|
|
25
|
+
type AmbassadorStatus = AmbassadorResponse['status'];
|
|
26
|
+
|
|
24
27
|
export interface AmbassadorListFilters {
|
|
25
28
|
page?: number;
|
|
26
29
|
limit?: number;
|
|
@@ -108,11 +111,11 @@ export function useMyAmbassador(
|
|
|
108
111
|
*/
|
|
109
112
|
export function useAmbassadorLeaderboard(
|
|
110
113
|
filters?: LeaderboardFilters,
|
|
111
|
-
options?: Omit<UseQueryOptions<
|
|
114
|
+
options?: Omit<UseQueryOptions<AmbassadorResponse[]>, 'queryKey' | 'queryFn'>
|
|
112
115
|
) {
|
|
113
116
|
return useQuery({
|
|
114
117
|
queryKey: ambassadorKeys.leaderboard(filters),
|
|
115
|
-
queryFn: async (): Promise<
|
|
118
|
+
queryFn: async (): Promise<AmbassadorResponse[]> => {
|
|
116
119
|
const client = getApiClient();
|
|
117
120
|
const response = await client.get('/api/v1/ambassadors/leaderboard', { params: filters });
|
|
118
121
|
return response.data;
|
package/src/api/queries/hubs.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
2
2
|
import { getApiClient } from '../client';
|
|
3
|
-
import type { HubResponse,
|
|
3
|
+
import type { HubResponse, ChatMemberResponse } from '../types';
|
|
4
4
|
|
|
5
5
|
// ============================================================================
|
|
6
6
|
// QUERY KEYS
|
|
@@ -49,10 +49,10 @@ export interface PaginatedHubsResponse {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// ChatMemberResponse is imported from '../types'
|
|
53
53
|
|
|
54
54
|
export interface PaginatedMembersResponse {
|
|
55
|
-
data:
|
|
55
|
+
data: ChatMemberResponse[];
|
|
56
56
|
meta: {
|
|
57
57
|
total: number;
|
|
58
58
|
page: number;
|
package/src/api/queries/map.ts
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
import { useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
12
12
|
import { getApiClient } from '../client';
|
|
13
13
|
import type {
|
|
14
|
-
|
|
14
|
+
MapMemberResponse,
|
|
15
15
|
MapEventResponse,
|
|
16
16
|
MapHubResponse,
|
|
17
|
-
|
|
17
|
+
BusinessResponse,
|
|
18
18
|
} from '../types';
|
|
19
19
|
|
|
20
20
|
// ============================================================================
|
|
@@ -115,13 +115,13 @@ export interface MapBusinessesParams {
|
|
|
115
115
|
*/
|
|
116
116
|
export function useMapMembers(
|
|
117
117
|
params: MapMembersParams,
|
|
118
|
-
options?: Omit<UseQueryOptions<
|
|
119
|
-
): UseQueryResult<
|
|
118
|
+
options?: Omit<UseQueryOptions<MapMemberResponse[]>, 'queryKey' | 'queryFn'>
|
|
119
|
+
): UseQueryResult<MapMemberResponse[]> {
|
|
120
120
|
return useQuery({
|
|
121
121
|
queryKey: mapKeys.members(params),
|
|
122
|
-
queryFn: async (): Promise<
|
|
122
|
+
queryFn: async (): Promise<MapMemberResponse[]> => {
|
|
123
123
|
const client = getApiClient();
|
|
124
|
-
const response = await client.get<
|
|
124
|
+
const response = await client.get<MapMemberResponse[]>('/api/v1/map/members', {
|
|
125
125
|
params: {
|
|
126
126
|
lat: params.lat,
|
|
127
127
|
lng: params.lng,
|
|
@@ -308,13 +308,13 @@ export function useMapHubs(
|
|
|
308
308
|
*/
|
|
309
309
|
export function useMapBusinesses(
|
|
310
310
|
params: MapBusinessesParams,
|
|
311
|
-
options?: Omit<UseQueryOptions<
|
|
312
|
-
): UseQueryResult<
|
|
311
|
+
options?: Omit<UseQueryOptions<BusinessResponse[]>, 'queryKey' | 'queryFn'>
|
|
312
|
+
): UseQueryResult<BusinessResponse[]> {
|
|
313
313
|
return useQuery({
|
|
314
314
|
queryKey: mapKeys.businesses(params),
|
|
315
|
-
queryFn: async (): Promise<
|
|
315
|
+
queryFn: async (): Promise<BusinessResponse[]> => {
|
|
316
316
|
const client = getApiClient();
|
|
317
|
-
const response = await client.get<
|
|
317
|
+
const response = await client.get<BusinessResponse[]>('/api/v1/map/businesses', {
|
|
318
318
|
params: {
|
|
319
319
|
lat: params.lat,
|
|
320
320
|
lng: params.lng,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
2
2
|
import { getApiClient } from '../client';
|
|
3
3
|
import type {
|
|
4
|
-
|
|
4
|
+
CheckInResponse,
|
|
5
|
+
CheckInStreakResponse,
|
|
5
6
|
MoodLogResponse,
|
|
6
7
|
WinResponse,
|
|
7
8
|
HabitResponse,
|
|
8
9
|
ReflectionResponse,
|
|
9
|
-
UserStreakResponse,
|
|
10
10
|
} from '../types';
|
|
11
11
|
|
|
12
12
|
// ============================================================================
|
|
@@ -50,11 +50,11 @@ export interface WinsByCategory {
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
export function useCheckIns(
|
|
53
|
-
options?: Omit<UseQueryOptions<
|
|
53
|
+
options?: Omit<UseQueryOptions<CheckInResponse[]>, 'queryKey' | 'queryFn'>
|
|
54
54
|
) {
|
|
55
55
|
return useQuery({
|
|
56
56
|
queryKey: supportKeys.checkIns(),
|
|
57
|
-
queryFn: async (): Promise<
|
|
57
|
+
queryFn: async (): Promise<CheckInResponse[]> => {
|
|
58
58
|
const client = getApiClient();
|
|
59
59
|
const response = await client.get('/api/v1/support/check-ins');
|
|
60
60
|
// API wraps responses in { data: [...], meta: {...} }
|
|
@@ -75,11 +75,11 @@ export function useCheckIns(
|
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
77
|
export function useTodayCheckIn(
|
|
78
|
-
options?: Omit<UseQueryOptions<
|
|
78
|
+
options?: Omit<UseQueryOptions<CheckInResponse | null>, 'queryKey' | 'queryFn'>
|
|
79
79
|
) {
|
|
80
80
|
return useQuery({
|
|
81
81
|
queryKey: supportKeys.checkInToday(),
|
|
82
|
-
queryFn: async (): Promise<
|
|
82
|
+
queryFn: async (): Promise<CheckInResponse | null> => {
|
|
83
83
|
const client = getApiClient();
|
|
84
84
|
const response = await client.get('/api/v1/support/check-ins/today');
|
|
85
85
|
// API wraps responses in { data: {...}, meta: {...} }
|
|
@@ -100,11 +100,11 @@ export function useTodayCheckIn(
|
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
102
|
export function useCheckInStreak(
|
|
103
|
-
options?: Omit<UseQueryOptions<
|
|
103
|
+
options?: Omit<UseQueryOptions<CheckInStreakResponse>, 'queryKey' | 'queryFn'>
|
|
104
104
|
) {
|
|
105
105
|
return useQuery({
|
|
106
106
|
queryKey: supportKeys.checkInStreak(),
|
|
107
|
-
queryFn: async (): Promise<
|
|
107
|
+
queryFn: async (): Promise<CheckInStreakResponse> => {
|
|
108
108
|
const client = getApiClient();
|
|
109
109
|
const response = await client.get('/api/v1/support/check-ins/streak');
|
|
110
110
|
// API wraps responses in { data: {...}, meta: {...} }
|