@workhive/api 1.3.4 → 1.4.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.
- package/dist/client.d.ts +141 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +228 -12
- package/dist/context.d.ts +103 -3
- package/dist/context.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +24 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +20 -1
- package/dist/hooks/use-billing-status.d.ts +7 -0
- package/dist/hooks/use-billing-status.d.ts.map +1 -0
- package/dist/hooks/use-billing-status.js +17 -0
- package/dist/hooks/use-card.d.ts +2 -0
- package/dist/hooks/use-card.d.ts.map +1 -0
- package/dist/hooks/use-card.js +12 -0
- package/dist/hooks/use-cards.d.ts +5 -0
- package/dist/hooks/use-cards.d.ts.map +1 -0
- package/dist/hooks/use-cards.js +12 -0
- package/dist/hooks/use-create-card.d.ts +10 -0
- package/dist/hooks/use-create-card.d.ts.map +1 -0
- package/dist/hooks/use-create-card.js +13 -0
- package/dist/hooks/use-delete-card.d.ts +15 -0
- package/dist/hooks/use-delete-card.d.ts.map +1 -0
- package/dist/hooks/use-delete-card.js +38 -0
- package/dist/hooks/use-email-drafts.d.ts +32 -0
- package/dist/hooks/use-email-drafts.d.ts.map +1 -0
- package/dist/hooks/use-email-drafts.js +98 -0
- package/dist/hooks/use-gmail-connection-members.d.ts +2 -0
- package/dist/hooks/use-gmail-connection-members.d.ts.map +1 -0
- package/dist/hooks/use-gmail-connection-members.js +13 -0
- package/dist/hooks/use-gmail-connections.d.ts +5 -0
- package/dist/hooks/use-gmail-connections.d.ts.map +1 -0
- package/dist/hooks/use-gmail-connections.js +21 -0
- package/dist/hooks/use-gmail-messages.d.ts +2 -0
- package/dist/hooks/use-gmail-messages.d.ts.map +1 -0
- package/dist/hooks/use-gmail-messages.js +13 -0
- package/dist/hooks/use-gmail-signature.d.ts +2 -0
- package/dist/hooks/use-gmail-signature.d.ts.map +1 -0
- package/dist/hooks/use-gmail-signature.js +12 -0
- package/dist/hooks/use-gmail-thread-search-infinite.d.ts +2 -0
- package/dist/hooks/use-gmail-thread-search-infinite.d.ts.map +1 -0
- package/dist/hooks/use-gmail-thread-search-infinite.js +21 -0
- package/dist/hooks/use-gmail-thread-search.d.ts +2 -0
- package/dist/hooks/use-gmail-thread-search.d.ts.map +1 -0
- package/dist/hooks/use-gmail-thread-search.js +12 -0
- package/dist/hooks/use-gmail-threads-infinite.d.ts +5 -0
- package/dist/hooks/use-gmail-threads-infinite.d.ts.map +1 -0
- package/dist/hooks/use-gmail-threads-infinite.js +24 -0
- package/dist/hooks/use-gmail-threads.d.ts +7 -0
- package/dist/hooks/use-gmail-threads.d.ts.map +1 -0
- package/dist/hooks/use-gmail-threads.js +23 -0
- package/dist/hooks/use-inbox-badge-count.d.ts +6 -0
- package/dist/hooks/use-inbox-badge-count.d.ts.map +1 -0
- package/dist/hooks/use-inbox-badge-count.js +17 -0
- package/dist/hooks/use-inbox-thread-search.d.ts +2 -0
- package/dist/hooks/use-inbox-thread-search.d.ts.map +1 -0
- package/dist/hooks/use-inbox-thread-search.js +12 -0
- package/dist/hooks/use-inbox-threads-infinite.d.ts.map +1 -1
- package/dist/hooks/use-inbox-threads-infinite.js +1 -0
- package/dist/hooks/use-link-gmail-thread-contact.d.ts +7 -0
- package/dist/hooks/use-link-gmail-thread-contact.d.ts.map +1 -0
- package/dist/hooks/use-link-gmail-thread-contact.js +15 -0
- package/dist/hooks/use-manage-gmail-connection-members.d.ts +13 -0
- package/dist/hooks/use-manage-gmail-connection-members.d.ts.map +1 -0
- package/dist/hooks/use-manage-gmail-connection-members.js +25 -0
- package/dist/hooks/use-mark-inbox-thread-read.d.ts +3 -1
- package/dist/hooks/use-mark-inbox-thread-read.d.ts.map +1 -1
- package/dist/hooks/use-mark-inbox-thread-read.js +36 -14
- package/dist/hooks/use-mark-inbox-thread-unread.d.ts +3 -1
- package/dist/hooks/use-mark-inbox-thread-unread.d.ts.map +1 -1
- package/dist/hooks/use-mark-inbox-thread-unread.js +37 -14
- package/dist/hooks/use-me.d.ts.map +1 -1
- package/dist/hooks/use-me.js +2 -1
- package/dist/hooks/use-message-snippets.d.ts +1 -1
- package/dist/hooks/use-message-snippets.d.ts.map +1 -1
- package/dist/hooks/use-message-snippets.js +4 -3
- package/dist/hooks/use-missed-unseen-count.d.ts +8 -0
- package/dist/hooks/use-missed-unseen-count.d.ts.map +1 -0
- package/dist/hooks/use-missed-unseen-count.js +19 -0
- package/dist/hooks/use-patch-card.d.ts +15 -0
- package/dist/hooks/use-patch-card.d.ts.map +1 -0
- package/dist/hooks/use-patch-card.js +48 -0
- package/dist/hooks/use-phone-number.d.ts.map +1 -1
- package/dist/hooks/use-phone-number.js +2 -1
- package/dist/hooks/use-phone-numbers.d.ts.map +1 -1
- package/dist/hooks/use-phone-numbers.js +2 -1
- package/dist/hooks/use-send-gmail-message.d.ts +6 -0
- package/dist/hooks/use-send-gmail-message.d.ts.map +1 -0
- package/dist/hooks/use-send-gmail-message.js +21 -0
- package/dist/hooks/use-send-inbox-message.d.ts.map +1 -1
- package/dist/hooks/use-send-inbox-message.js +16 -13
- package/dist/hooks/use-tasks.d.ts +4 -0
- package/dist/hooks/use-tasks.d.ts.map +1 -1
- package/dist/hooks/use-tasks.js +14 -2
- package/dist/hooks/use-update-inbox-thread-status.d.ts +3 -1
- package/dist/hooks/use-update-inbox-thread-status.d.ts.map +1 -1
- package/dist/hooks/use-update-inbox-thread-status.js +36 -14
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/query-keys.d.ts +58 -0
- package/dist/query-keys.d.ts.map +1 -1
- package/dist/query-keys.js +50 -0
- package/dist/types.d.ts +370 -14
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
export function useGmailMessages(connectionId, threadId) {
|
|
5
|
+
const client = useApiClient();
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: gmailKeys.messages(threadId ?? ''),
|
|
8
|
+
queryFn: () => client.getGmailThreadMessages(connectionId, threadId),
|
|
9
|
+
enabled: Boolean(connectionId) && Boolean(threadId),
|
|
10
|
+
staleTime: 30000,
|
|
11
|
+
refetchOnWindowFocus: true,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gmail-signature.d.ts","sourceRoot":"","sources":["../../src/hooks/use-gmail-signature.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,8FAQjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
export function useGmailSignature(connectionId) {
|
|
5
|
+
const client = useApiClient();
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: gmailKeys.signature(connectionId),
|
|
8
|
+
queryFn: () => client.getGmailSignature(connectionId),
|
|
9
|
+
enabled: !!connectionId,
|
|
10
|
+
staleTime: 5 * 60000,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function useGmailThreadSearchInfinite(connectionId: string | undefined, query: string): import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/query-core").InfiniteData<import("..").GmailThreadSearchResponse, unknown>, Error>;
|
|
2
|
+
//# sourceMappingURL=use-gmail-thread-search-infinite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gmail-thread-search-infinite.d.ts","sourceRoot":"","sources":["../../src/hooks/use-gmail-thread-search-infinite.ts"],"names":[],"mappings":"AAMA,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,KAAK,EAAE,MAAM,+JAoBd"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
const SEARCH_PAGE_SIZE = 20;
|
|
5
|
+
export function useGmailThreadSearchInfinite(connectionId, query) {
|
|
6
|
+
const client = useApiClient();
|
|
7
|
+
return useInfiniteQuery({
|
|
8
|
+
queryKey: gmailKeys.searchInfinite(connectionId ?? '', query),
|
|
9
|
+
queryFn: ({ pageParam }) => client.searchGmailThreads(connectionId, {
|
|
10
|
+
q: query,
|
|
11
|
+
limit: SEARCH_PAGE_SIZE,
|
|
12
|
+
cursor: pageParam ?? undefined,
|
|
13
|
+
}),
|
|
14
|
+
getNextPageParam: (lastPage) => lastPage.has_more && lastPage.next_cursor
|
|
15
|
+
? lastPage.next_cursor
|
|
16
|
+
: undefined,
|
|
17
|
+
initialPageParam: null,
|
|
18
|
+
enabled: Boolean(connectionId) && query.length >= 2,
|
|
19
|
+
staleTime: 30000,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gmail-thread-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-gmail-thread-search.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,KAAK,EAAE,MAAM,iGASd"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
export function useGmailThreadSearch(connectionId, query) {
|
|
5
|
+
const client = useApiClient();
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: gmailKeys.threadSearch(connectionId ?? '', query),
|
|
8
|
+
queryFn: () => client.searchGmailThreads(connectionId, { q: query }),
|
|
9
|
+
enabled: Boolean(connectionId) && query.length >= 2,
|
|
10
|
+
staleTime: 30000,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function useGmailThreadsInfinite(connectionId: string | undefined, params?: {
|
|
2
|
+
status?: 'active' | 'archived';
|
|
3
|
+
unreadOnly?: boolean;
|
|
4
|
+
}): import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/query-core").InfiniteData<import("..").InboxThreadsResponse, unknown>, Error>;
|
|
5
|
+
//# sourceMappingURL=use-gmail-threads-infinite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gmail-threads-infinite.d.ts","sourceRoot":"","sources":["../../src/hooks/use-gmail-threads-infinite.ts"],"names":[],"mappings":"AAMA,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,0JAsBlE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
const PAGE_SIZE = 30;
|
|
5
|
+
export function useGmailThreadsInfinite(connectionId, params) {
|
|
6
|
+
const client = useApiClient();
|
|
7
|
+
const status = params?.status;
|
|
8
|
+
const unreadOnly = params?.unreadOnly === true;
|
|
9
|
+
return useInfiniteQuery({
|
|
10
|
+
queryKey: gmailKeys.threadsInfinite(connectionId ?? '', { status, unreadOnly }),
|
|
11
|
+
queryFn: ({ pageParam }) => client.getGmailThreads(connectionId, {
|
|
12
|
+
status,
|
|
13
|
+
limit: PAGE_SIZE,
|
|
14
|
+
cursor: pageParam ?? undefined,
|
|
15
|
+
unread_only: unreadOnly || undefined,
|
|
16
|
+
}),
|
|
17
|
+
getNextPageParam: (lastPage) => lastPage.has_more && lastPage.next_cursor
|
|
18
|
+
? lastPage.next_cursor
|
|
19
|
+
: undefined,
|
|
20
|
+
initialPageParam: null,
|
|
21
|
+
enabled: Boolean(connectionId),
|
|
22
|
+
staleTime: 60000,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function useGmailThreads(connectionId: string | undefined, params?: {
|
|
2
|
+
status?: 'active' | 'archived';
|
|
3
|
+
unreadOnly?: boolean;
|
|
4
|
+
page?: number;
|
|
5
|
+
pageSize?: number;
|
|
6
|
+
}): import("@tanstack/react-query").UseQueryResult<import("..").GmailThreadsPageResponse, Error>;
|
|
7
|
+
//# sourceMappingURL=use-gmail-threads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-gmail-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-gmail-threads.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,gGAqBpG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useQuery, keepPreviousData } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
const DEFAULT_PAGE_SIZE = 50;
|
|
5
|
+
export function useGmailThreads(connectionId, params) {
|
|
6
|
+
const client = useApiClient();
|
|
7
|
+
const status = params?.status;
|
|
8
|
+
const unreadOnly = params?.unreadOnly === true;
|
|
9
|
+
const page = params?.page ?? 1;
|
|
10
|
+
const pageSize = params?.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: gmailKeys.threads(connectionId ?? '', { status, unreadOnly, page }),
|
|
13
|
+
queryFn: () => client.getGmailThreads(connectionId, {
|
|
14
|
+
status,
|
|
15
|
+
page,
|
|
16
|
+
page_size: pageSize,
|
|
17
|
+
unread_only: unreadOnly || undefined,
|
|
18
|
+
}),
|
|
19
|
+
enabled: Boolean(connectionId),
|
|
20
|
+
staleTime: 30000,
|
|
21
|
+
placeholderData: keepPreviousData,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aggregate badge count across all assigned phone numbers.
|
|
3
|
+
* Polls every 60s so the sidebar stays reasonably fresh.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useInboxBadgeCount(): import("@tanstack/react-query").UseQueryResult<import("..").InboxBadgeCountResponse, Error>;
|
|
6
|
+
//# sourceMappingURL=use-inbox-badge-count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-inbox-badge-count.d.ts","sourceRoot":"","sources":["../../src/hooks/use-inbox-badge-count.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,kBAAkB,gGAQjC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { inboxKeys } from '../query-keys';
|
|
4
|
+
const BADGE_REFETCH_MS = 60000;
|
|
5
|
+
/**
|
|
6
|
+
* Aggregate badge count across all assigned phone numbers.
|
|
7
|
+
* Polls every 60s so the sidebar stays reasonably fresh.
|
|
8
|
+
*/
|
|
9
|
+
export function useInboxBadgeCount() {
|
|
10
|
+
const client = useApiClient();
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: inboxKeys.badgeCount(),
|
|
13
|
+
queryFn: () => client.getInboxBadgeCount(),
|
|
14
|
+
refetchInterval: BADGE_REFETCH_MS,
|
|
15
|
+
staleTime: BADGE_REFETCH_MS / 2,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-inbox-thread-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-inbox-thread-search.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,KAAK,EAAE,MAAM,iGASd"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { inboxKeys } from '../query-keys';
|
|
4
|
+
export function useInboxThreadSearch(phoneNumberId, query) {
|
|
5
|
+
const client = useApiClient();
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: inboxKeys.threadSearch(phoneNumberId ?? '', query),
|
|
8
|
+
queryFn: () => client.searchInboxThreads(phoneNumberId, { q: query }),
|
|
9
|
+
enabled: Boolean(phoneNumberId) && query.length >= 2,
|
|
10
|
+
staleTime: 30000,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-inbox-threads-infinite.d.ts","sourceRoot":"","sources":["../../src/hooks/use-inbox-threads-infinite.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC9B,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,MAAM,CAAC,EAAE,6BAA6B,
|
|
1
|
+
{"version":3,"file":"use-inbox-threads-infinite.d.ts","sourceRoot":"","sources":["../../src/hooks/use-inbox-threads-infinite.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC9B,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,MAAM,CAAC,EAAE,6BAA6B,0JAmBvC"}
|
|
@@ -12,6 +12,7 @@ export function useInboxThreadsInfinite(phoneNumberId, params) {
|
|
|
12
12
|
status: params?.status,
|
|
13
13
|
limit: PAGE_SIZE,
|
|
14
14
|
cursor: pageParam ?? undefined,
|
|
15
|
+
unread_only: unreadOnly || undefined,
|
|
15
16
|
}),
|
|
16
17
|
getNextPageParam: (lastPage) => lastPage.has_more && lastPage.next_cursor ? lastPage.next_cursor : undefined,
|
|
17
18
|
initialPageParam: null,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LinkGmailThreadContactPayload } from '../types';
|
|
2
|
+
export declare function useLinkGmailThreadContact(): import("@tanstack/react-query").UseMutationResult<import("..").LinkGmailThreadContactResponse, Error, {
|
|
3
|
+
connectionId: string;
|
|
4
|
+
threadId: string;
|
|
5
|
+
body: LinkGmailThreadContactPayload;
|
|
6
|
+
}, unknown>;
|
|
7
|
+
//# sourceMappingURL=use-link-gmail-thread-contact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-link-gmail-thread-contact.d.ts","sourceRoot":"","sources":["../../src/hooks/use-link-gmail-thread-contact.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAE7D,wBAAgB,yBAAyB;kBAUrB,MAAM;cACV,MAAM;UACV,6BAA6B;YAQxC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
export function useLinkGmailThreadContact() {
|
|
5
|
+
const client = useApiClient();
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutationFn: ({ connectionId, threadId, body, }) => client.linkGmailThreadContact(connectionId, threadId, body),
|
|
9
|
+
onSuccess: () => {
|
|
10
|
+
queryClient.invalidateQueries({
|
|
11
|
+
queryKey: gmailKeys.threadsInfinitePrefix,
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function useAddGmailConnectionMember(): import("@tanstack/react-query").UseMutationResult<{
|
|
2
|
+
member: import("..").GmailConnectionMember;
|
|
3
|
+
}, Error, {
|
|
4
|
+
connectionId: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
}, unknown>;
|
|
7
|
+
export declare function useRemoveGmailConnectionMember(): import("@tanstack/react-query").UseMutationResult<{
|
|
8
|
+
success: boolean;
|
|
9
|
+
}, Error, {
|
|
10
|
+
connectionId: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
}, unknown>;
|
|
13
|
+
//# sourceMappingURL=use-manage-gmail-connection-members.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-manage-gmail-connection-members.d.ts","sourceRoot":"","sources":["../../src/hooks/use-manage-gmail-connection-members.ts"],"names":[],"mappings":"AAIA,wBAAgB,2BAA2B;;;kBAKgB,MAAM;YAAU,MAAM;YAOhF;AAED,wBAAgB,8BAA8B;;;kBAKa,MAAM;YAAU,MAAM;YAOhF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { gmailKeys } from '../query-keys';
|
|
4
|
+
export function useAddGmailConnectionMember() {
|
|
5
|
+
const client = useApiClient();
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation({
|
|
8
|
+
mutationFn: ({ connectionId, userId }) => client.addGmailConnectionMember(connectionId, userId),
|
|
9
|
+
onSuccess: (_data, variables) => {
|
|
10
|
+
queryClient.invalidateQueries({ queryKey: gmailKeys.members(variables.connectionId) });
|
|
11
|
+
queryClient.invalidateQueries({ queryKey: gmailKeys.connections() });
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function useRemoveGmailConnectionMember() {
|
|
16
|
+
const client = useApiClient();
|
|
17
|
+
const queryClient = useQueryClient();
|
|
18
|
+
return useMutation({
|
|
19
|
+
mutationFn: ({ connectionId, userId }) => client.removeGmailConnectionMember(connectionId, userId),
|
|
20
|
+
onSuccess: (_data, variables) => {
|
|
21
|
+
queryClient.invalidateQueries({ queryKey: gmailKeys.members(variables.connectionId) });
|
|
22
|
+
queryClient.invalidateQueries({ queryKey: gmailKeys.connections() });
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { type InfiniteData } from '@tanstack/react-query';
|
|
1
2
|
import type { InboxThreadsResponse } from '../types';
|
|
2
3
|
export declare function useMarkInboxThreadRead(): import("@tanstack/react-query").UseMutationResult<{
|
|
3
4
|
ok: true;
|
|
4
5
|
}, Error, string, {
|
|
5
|
-
|
|
6
|
+
previousSms: [readonly unknown[], InfiniteData<InboxThreadsResponse, unknown> | undefined][];
|
|
7
|
+
previousGmail: [readonly unknown[], InfiniteData<InboxThreadsResponse, unknown> | undefined][];
|
|
6
8
|
}>;
|
|
7
9
|
//# sourceMappingURL=use-mark-inbox-thread-read.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mark-inbox-thread-read.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mark-inbox-thread-read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-mark-inbox-thread-read.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mark-inbox-thread-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA+B,MAAM,uBAAuB,CAAA;AAGtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AA0BpD,wBAAgB,sBAAsB;;;;;GA4CrC"}
|
|
@@ -1,35 +1,57 @@
|
|
|
1
1
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { useApiClient } from '../context';
|
|
3
|
-
|
|
3
|
+
import { inboxKeys, gmailKeys } from '../query-keys';
|
|
4
|
+
/** Optimistically set unread_count on a thread across a query cache prefix. */
|
|
5
|
+
function setUnreadOnThread(queryClient, queryKeyPrefix, threadId, unreadCount) {
|
|
6
|
+
queryClient.setQueriesData({ queryKey: queryKeyPrefix, exact: false }, (data) => {
|
|
7
|
+
if (!data?.pages)
|
|
8
|
+
return data;
|
|
9
|
+
return {
|
|
10
|
+
...data,
|
|
11
|
+
pages: data.pages.map((page) => ({
|
|
12
|
+
...page,
|
|
13
|
+
threads: page.threads.map((t) => t.id === threadId ? { ...t, unread_count: unreadCount } : t),
|
|
14
|
+
})),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
}
|
|
4
18
|
export function useMarkInboxThreadRead() {
|
|
5
19
|
const client = useApiClient();
|
|
6
20
|
const queryClient = useQueryClient();
|
|
7
21
|
return useMutation({
|
|
8
22
|
mutationFn: (threadId) => client.markInboxThreadRead(threadId),
|
|
9
23
|
onMutate: async (threadId) => {
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
await queryClient.cancelQueries({ queryKey: inboxKeys.threadsInfinitePrefix });
|
|
25
|
+
await queryClient.cancelQueries({ queryKey: gmailKeys.threadsInfinitePrefix });
|
|
26
|
+
const previousSms = queryClient.getQueriesData({
|
|
27
|
+
queryKey: inboxKeys.threadsInfinitePrefix,
|
|
12
28
|
exact: false,
|
|
13
29
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
threads: data.threads.map((t) => t.id === threadId ? { ...t, unread_count: 0 } : t),
|
|
19
|
-
};
|
|
30
|
+
const previousGmail = queryClient.getQueriesData({
|
|
31
|
+
queryKey: gmailKeys.threadsInfinitePrefix,
|
|
32
|
+
exact: false,
|
|
20
33
|
});
|
|
21
|
-
|
|
34
|
+
setUnreadOnThread(queryClient, inboxKeys.threadsInfinitePrefix, threadId, 0);
|
|
35
|
+
setUnreadOnThread(queryClient, gmailKeys.threadsInfinitePrefix, threadId, 0);
|
|
36
|
+
return { previousSms, previousGmail };
|
|
22
37
|
},
|
|
23
38
|
onError: (_err, _variables, context) => {
|
|
24
|
-
if (context?.
|
|
25
|
-
context.
|
|
39
|
+
if (context?.previousSms) {
|
|
40
|
+
context.previousSms.forEach(([queryKey, data]) => {
|
|
41
|
+
queryClient.setQueryData(queryKey, data);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (context?.previousGmail) {
|
|
45
|
+
context.previousGmail.forEach(([queryKey, data]) => {
|
|
26
46
|
queryClient.setQueryData(queryKey, data);
|
|
27
47
|
});
|
|
28
48
|
}
|
|
29
49
|
},
|
|
30
50
|
onSettled: () => {
|
|
31
|
-
queryClient.invalidateQueries({ queryKey:
|
|
32
|
-
queryClient.invalidateQueries({ queryKey:
|
|
51
|
+
queryClient.invalidateQueries({ queryKey: inboxKeys.threadsInfinitePrefix });
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: inboxKeys.threads() });
|
|
53
|
+
queryClient.invalidateQueries({ queryKey: inboxKeys.badgeCount() });
|
|
54
|
+
queryClient.invalidateQueries({ queryKey: gmailKeys.threadsInfinitePrefix });
|
|
33
55
|
},
|
|
34
56
|
});
|
|
35
57
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { type InfiniteData } from '@tanstack/react-query';
|
|
1
2
|
import type { InboxThreadsResponse } from '../types';
|
|
2
3
|
export declare function useMarkInboxThreadUnread(): import("@tanstack/react-query").UseMutationResult<{
|
|
3
4
|
ok: true;
|
|
4
5
|
}, Error, string, {
|
|
5
|
-
|
|
6
|
+
previousSms: [readonly unknown[], InfiniteData<InboxThreadsResponse, unknown> | undefined][];
|
|
7
|
+
previousGmail: [readonly unknown[], InfiniteData<InboxThreadsResponse, unknown> | undefined][];
|
|
6
8
|
}>;
|
|
7
9
|
//# sourceMappingURL=use-mark-inbox-thread-unread.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mark-inbox-thread-unread.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mark-inbox-thread-unread.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-mark-inbox-thread-unread.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mark-inbox-thread-unread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA+B,MAAM,uBAAuB,CAAA;AAItF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AA0BpD,wBAAgB,wBAAwB;;;;;GA4CvC"}
|
|
@@ -1,35 +1,58 @@
|
|
|
1
1
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { useApiClient } from '../context';
|
|
3
|
-
|
|
3
|
+
import { inboxKeys } from '../query-keys';
|
|
4
|
+
import { gmailKeys } from '../query-keys';
|
|
5
|
+
/** Optimistically set unread_count on a thread across both SMS and Gmail query caches. */
|
|
6
|
+
function setUnreadOnThread(queryClient, queryKeyPrefix, threadId, unreadCount) {
|
|
7
|
+
queryClient.setQueriesData({ queryKey: queryKeyPrefix, exact: false }, (data) => {
|
|
8
|
+
if (!data?.pages)
|
|
9
|
+
return data;
|
|
10
|
+
return {
|
|
11
|
+
...data,
|
|
12
|
+
pages: data.pages.map((page) => ({
|
|
13
|
+
...page,
|
|
14
|
+
threads: page.threads.map((t) => t.id === threadId ? { ...t, unread_count: unreadCount } : t),
|
|
15
|
+
})),
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
4
19
|
export function useMarkInboxThreadUnread() {
|
|
5
20
|
const client = useApiClient();
|
|
6
21
|
const queryClient = useQueryClient();
|
|
7
22
|
return useMutation({
|
|
8
23
|
mutationFn: (threadId) => client.markInboxThreadUnread(threadId),
|
|
9
24
|
onMutate: async (threadId) => {
|
|
10
|
-
|
|
11
|
-
|
|
25
|
+
await queryClient.cancelQueries({ queryKey: inboxKeys.threadsInfinitePrefix });
|
|
26
|
+
await queryClient.cancelQueries({ queryKey: gmailKeys.threadsInfinitePrefix });
|
|
27
|
+
const previousSms = queryClient.getQueriesData({
|
|
28
|
+
queryKey: inboxKeys.threadsInfinitePrefix,
|
|
12
29
|
exact: false,
|
|
13
30
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
threads: data.threads.map((t) => t.id === threadId ? { ...t, unread_count: (t.unread_count ?? 0) || 1 } : t),
|
|
19
|
-
};
|
|
31
|
+
const previousGmail = queryClient.getQueriesData({
|
|
32
|
+
queryKey: gmailKeys.threadsInfinitePrefix,
|
|
33
|
+
exact: false,
|
|
20
34
|
});
|
|
21
|
-
|
|
35
|
+
setUnreadOnThread(queryClient, inboxKeys.threadsInfinitePrefix, threadId, 1);
|
|
36
|
+
setUnreadOnThread(queryClient, gmailKeys.threadsInfinitePrefix, threadId, 1);
|
|
37
|
+
return { previousSms, previousGmail };
|
|
22
38
|
},
|
|
23
39
|
onError: (_err, _variables, context) => {
|
|
24
|
-
if (context?.
|
|
25
|
-
context.
|
|
40
|
+
if (context?.previousSms) {
|
|
41
|
+
context.previousSms.forEach(([queryKey, data]) => {
|
|
42
|
+
queryClient.setQueryData(queryKey, data);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (context?.previousGmail) {
|
|
46
|
+
context.previousGmail.forEach(([queryKey, data]) => {
|
|
26
47
|
queryClient.setQueryData(queryKey, data);
|
|
27
48
|
});
|
|
28
49
|
}
|
|
29
50
|
},
|
|
30
51
|
onSettled: () => {
|
|
31
|
-
queryClient.invalidateQueries({ queryKey:
|
|
32
|
-
queryClient.invalidateQueries({ queryKey:
|
|
52
|
+
queryClient.invalidateQueries({ queryKey: inboxKeys.threadsInfinitePrefix });
|
|
53
|
+
queryClient.invalidateQueries({ queryKey: inboxKeys.threads() });
|
|
54
|
+
queryClient.invalidateQueries({ queryKey: inboxKeys.badgeCount() });
|
|
55
|
+
queryClient.invalidateQueries({ queryKey: gmailKeys.threadsInfinitePrefix });
|
|
33
56
|
},
|
|
34
57
|
});
|
|
35
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-me.d.ts","sourceRoot":"","sources":["../../src/hooks/use-me.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-me.d.ts","sourceRoot":"","sources":["../../src/hooks/use-me.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,KAAK,mFAMpB"}
|
package/dist/hooks/use-me.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { useApiClient } from '../context';
|
|
3
|
+
import { meKeys } from '../query-keys';
|
|
3
4
|
/**
|
|
4
5
|
* Current user (GET /api/me).
|
|
5
6
|
* Use for banner avatar, profile, and org context.
|
|
@@ -7,7 +8,7 @@ import { useApiClient } from '../context';
|
|
|
7
8
|
export function useMe() {
|
|
8
9
|
const client = useApiClient();
|
|
9
10
|
return useQuery({
|
|
10
|
-
queryKey:
|
|
11
|
+
queryKey: meKeys.all,
|
|
11
12
|
queryFn: () => client.getMe(),
|
|
12
13
|
});
|
|
13
14
|
}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Message snippets for the current org (GET /api/settings/messaging/snippets).
|
|
3
3
|
* Use in Settings Snippets section and Inbox snippet picker.
|
|
4
4
|
*/
|
|
5
|
-
export declare function useMessageSnippets(): import("@tanstack/react-query").UseQueryResult<import("..").MessageSnippetsResponse, Error>;
|
|
5
|
+
export declare function useMessageSnippets(channel?: 'sms' | 'email'): import("@tanstack/react-query").UseQueryResult<import("..").MessageSnippetsResponse, Error>;
|
|
6
6
|
//# sourceMappingURL=use-message-snippets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-message-snippets.d.ts","sourceRoot":"","sources":["../../src/hooks/use-message-snippets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-message-snippets.d.ts","sourceRoot":"","sources":["../../src/hooks/use-message-snippets.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,+FAM3D"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { useApiClient } from '../context';
|
|
3
|
+
import { snippetKeys } from '../query-keys';
|
|
3
4
|
/**
|
|
4
5
|
* Message snippets for the current org (GET /api/settings/messaging/snippets).
|
|
5
6
|
* Use in Settings Snippets section and Inbox snippet picker.
|
|
6
7
|
*/
|
|
7
|
-
export function useMessageSnippets() {
|
|
8
|
+
export function useMessageSnippets(channel) {
|
|
8
9
|
const client = useApiClient();
|
|
9
10
|
return useQuery({
|
|
10
|
-
queryKey:
|
|
11
|
-
queryFn: () => client.getMessageSnippets(),
|
|
11
|
+
queryKey: snippetKeys.list(channel),
|
|
12
|
+
queryFn: () => client.getMessageSnippets(channel),
|
|
12
13
|
});
|
|
13
14
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-phone-number unseen missed call count.
|
|
3
|
+
* Used for the Calls tab badge inside the inbox page.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useMissedUnseenCount(phoneNumberId: string | undefined, options?: {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}): import("@tanstack/react-query").UseQueryResult<import("..").MissedUnseenCountResponse, Error>;
|
|
8
|
+
//# sourceMappingURL=use-missed-unseen-count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-missed-unseen-count.d.ts","sourceRoot":"","sources":["../../src/hooks/use-missed-unseen-count.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,iGAWhC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useApiClient } from '../context';
|
|
3
|
+
import { inboxKeys } from '../query-keys';
|
|
4
|
+
const MISSED_REFETCH_MS = 30000;
|
|
5
|
+
/**
|
|
6
|
+
* Per-phone-number unseen missed call count.
|
|
7
|
+
* Used for the Calls tab badge inside the inbox page.
|
|
8
|
+
*/
|
|
9
|
+
export function useMissedUnseenCount(phoneNumberId, options) {
|
|
10
|
+
const client = useApiClient();
|
|
11
|
+
const enabled = options?.enabled !== false && Boolean(phoneNumberId);
|
|
12
|
+
return useQuery({
|
|
13
|
+
queryKey: inboxKeys.missedUnseenCount(phoneNumberId ?? ''),
|
|
14
|
+
queryFn: () => client.getMissedUnseenCount(phoneNumberId),
|
|
15
|
+
enabled,
|
|
16
|
+
refetchInterval: enabled ? MISSED_REFETCH_MS : false,
|
|
17
|
+
staleTime: MISSED_REFETCH_MS / 2,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PipelineCard, PipelineCardsResponse } from '../types';
|
|
2
|
+
export interface PatchCardVariables {
|
|
3
|
+
pipelineId: string;
|
|
4
|
+
cardId: string;
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
/** Richer shape applied to the cache optimistically. Falls back to `data` when omitted. */
|
|
7
|
+
optimisticData?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare function usePatchCard(): import("@tanstack/react-query").UseMutationResult<{
|
|
10
|
+
card: PipelineCard;
|
|
11
|
+
}, Error, PatchCardVariables, {
|
|
12
|
+
previousCard: PipelineCard | undefined;
|
|
13
|
+
previousLists: [readonly unknown[], PipelineCardsResponse | undefined][];
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=use-patch-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-patch-card.d.ts","sourceRoot":"","sources":["../../src/hooks/use-patch-card.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEnE,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,2FAA2F;IAC3F,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC;AAED,wBAAgB,YAAY;;;;;GA+D3B"}
|