@arbidocs/react 0.5.130 → 0.5.131
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/contacts.js +11 -0
- package/dist/contacts.js.map +2 -2
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -15
- package/dist/index.js +2 -0
- package/dist/index.js.map +2 -2
- package/package.json +3 -3
package/dist/contacts.js
CHANGED
|
@@ -11,6 +11,16 @@ function useContacts(options) {
|
|
|
11
11
|
staleTime: 3e4
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
+
function useReferralSummary(currentUserExtId) {
|
|
15
|
+
const arbi = useArbi();
|
|
16
|
+
return useQuery({
|
|
17
|
+
queryKey: [...arbiQueryKeys.contacts(), "referrals", currentUserExtId],
|
|
18
|
+
queryFn: () => arbi.contacts.referrals(),
|
|
19
|
+
enabled: arbi.isLoggedIn,
|
|
20
|
+
retry: false,
|
|
21
|
+
staleTime: 3e4
|
|
22
|
+
});
|
|
23
|
+
}
|
|
14
24
|
function useInvalidateContacts() {
|
|
15
25
|
const qc = useQueryClient();
|
|
16
26
|
return () => qc.invalidateQueries({ queryKey: arbiQueryKeys.contacts() });
|
|
@@ -94,6 +104,7 @@ export {
|
|
|
94
104
|
useImportContacts,
|
|
95
105
|
useInviteContacts,
|
|
96
106
|
useLinkContact,
|
|
107
|
+
useReferralSummary,
|
|
97
108
|
useSearchContacts,
|
|
98
109
|
useUpdateContact
|
|
99
110
|
};
|
package/dist/contacts.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/contacts.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Contacts: one address book \u2014 people on ARBI, invitations still out, and plain cards.\n *\n * Shares `arbiQueryKeys.contacts()` with the messenger's people, so a change made here refreshes\n * the conversation rail on its own. The parts that turn an email list into a request and the backend\n * outcome into a sentence live in `@arbidocs/blocks/collaboration` (`AddContactsForm`).\n */\n\nimport { useEffect, useState } from 'react'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { contacts as contactsOps } from '@arbidocs/sdk/browser'\nimport { useArbi } from './useArbi'\nimport { arbiQueryKeys } from './hooks'\n\n/** Every contact: registered, invited and plain cards. */\nexport function useContacts(options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.contacts(),\n queryFn: () => arbi.contacts.list(),\n enabled: (options?.enabled ?? true) && arbi.isLoggedIn,\n staleTime: 30_000,\n })\n}\n\nfunction useInvalidateContacts() {\n const qc = useQueryClient()\n return () => qc.invalidateQueries({ queryKey: arbiQueryKeys.contacts() })\n}\n\n/**\n * Invite (or link) people by email. An address not yet on ARBI gets an invitation. Resolves with one\n * row per address (`outcome`, `status`); map it with `toAddContactsRows` from `@arbidocs/blocks/collaboration`.\n */\nexport function useInviteContacts() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (emails: string[]) => arbi.contacts.invite(emails),\n onSuccess: () => invalidate(),\n })\n}\n\n/** Create a card, optionally linking `email` and inviting it (`invite: true`). */\nexport function useCreateContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (body: contactsOps.ContactCreate) => arbi.contacts.create(body),\n onSuccess: () => invalidate(),\n })\n}\n\n/** Replace a contact's card details. */\nexport function useUpdateContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: ({ id, card }: { id: string; card: contactsOps.ContactCardWrite }) =>\n arbi.contacts.update(id, card),\n onSuccess: () => invalidate(),\n })\n}\n\n/**\n * Invite a contact to ARBI by `email`: a card-only contact is linked in place (its row and card kept);\n * without an id a new card is created and invited. Rejects with `DuplicateContactError` when `email`\n * already belongs to another contact. The list refreshes either way.\n */\nexport function useLinkContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: ({\n contact,\n email,\n card,\n }: {\n contact: Pick<contactsOps.Contact, 'external_id'>\n email: string\n card: contactsOps.ContactCardWrite\n }) =>\n contact.external_id\n ? arbi.contacts.link(contact.external_id, email, card)\n : arbi.contacts.create({ email, card, invite: true }),\n onSettled: () => invalidate(),\n })\n}\n\n/** Import one .vcf file (Pro: 403 `pro_required` otherwise); the list refreshes after each file. */\nexport function useImportContacts() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (file: Blob) => arbi.contacts.import(file),\n onSettled: () => invalidate(),\n })\n}\n\n/** Delete a contact, or withdraw its invitation, by contact id. */\nexport function useDeleteContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (contactId: string) => arbi.contacts.delete(contactId),\n onSuccess: () => invalidate(),\n })\n}\n\n/**\n * People matching `q` (your contacts and the registered people you share a workspace with), for a\n * picker: debounced, nothing fetched for an empty query, the previous matches kept while typing.\n */\nexport function useSearchContacts(q: string, { debounceMs = 200 }: { debounceMs?: number } = {}) {\n const arbi = useArbi()\n const term = useDebounced(q.trim(), debounceMs)\n return useQuery({\n queryKey: [...arbiQueryKeys.contacts(), 'search', term] as const,\n queryFn: () => arbi.contacts.search(term),\n enabled: term.length > 0 && arbi.isLoggedIn,\n staleTime: 60_000,\n placeholderData: (previous) => previous,\n retry: false,\n })\n}\n\nfunction useDebounced<T>(value: T, ms: number): T {\n const [debounced, setDebounced] = useState(value)\n useEffect(() => {\n const t = setTimeout(() => setDebounced(value), ms)\n return () => clearTimeout(t)\n }, [value, ms])\n return debounced\n}\n"],
|
|
5
|
-
"mappings": "AAQA,SAAS,WAAW,gBAAgB;AACpC,SAAS,aAAa,UAAU,sBAAsB;AAEtD,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAGvB,SAAS,YAAY,SAAiC;AAC3D,QAAM,OAAO,QAAQ;AACrB,SAAO,SAAS;AAAA,IACd,UAAU,cAAc,SAAS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AAClC,QAAM,OAAO,QAAQ;AACrB,QAAM,aAAa,sBAAsB;AACzC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SAAe,KAAK,SAAS,OAAO,IAAI;AAAA,IACrD,WAAW,MAAM,WAAW;AAAA,EAC9B,CAAC;AACH;AAGO,SAAS,mBAAmB;AACjC,QAAM,OAAO,QAAQ;AACrB,QAAM,aAAa,sBAAsB;AACzC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,cAAsB,KAAK,SAAS,OAAO,SAAS;AAAA,IACjE,WAAW,MAAM,WAAW;AAAA,EAC9B,CAAC;AACH;AAMO,SAAS,kBAAkB,GAAW,EAAE,aAAa,IAAI,IAA6B,CAAC,GAAG;AAC/F,QAAM,OAAO,QAAQ;AACrB,QAAM,OAAO,aAAa,EAAE,KAAK,GAAG,UAAU;AAC9C,SAAO,SAAS;AAAA,IACd,UAAU,CAAC,GAAG,cAAc,SAAS,GAAG,UAAU,IAAI;AAAA,IACtD,SAAS,MAAM,KAAK,SAAS,OAAO,IAAI;AAAA,IACxC,SAAS,KAAK,SAAS,KAAK,KAAK;AAAA,IACjC,WAAW;AAAA,IACX,iBAAiB,CAAC,aAAa;AAAA,IAC/B,OAAO;AAAA,EACT,CAAC;AACH;AAEA,SAAS,aAAgB,OAAU,IAAe;AAChD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,YAAU,MAAM;AACd,UAAM,IAAI,WAAW,MAAM,aAAa,KAAK,GAAG,EAAE;AAClD,WAAO,MAAM,aAAa,CAAC;AAAA,EAC7B,GAAG,CAAC,OAAO,EAAE,CAAC;AACd,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["/**\n * Contacts: one address book \u2014 people on ARBI, invitations still out, and plain cards.\n *\n * Shares `arbiQueryKeys.contacts()` with the messenger's people, so a change made here refreshes\n * the conversation rail on its own. The parts that turn an email list into a request and the backend\n * outcome into a sentence live in `@arbidocs/blocks/collaboration` (`AddContactsForm`).\n */\n\nimport { useEffect, useState } from 'react'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { contacts as contactsOps } from '@arbidocs/sdk/browser'\nimport { useArbi } from './useArbi'\nimport { arbiQueryKeys } from './hooks'\n\n/** Every contact: registered, invited and plain cards. */\nexport function useContacts(options?: { enabled?: boolean }) {\n const arbi = useArbi()\n return useQuery({\n queryKey: arbiQueryKeys.contacts(),\n queryFn: () => arbi.contacts.list(),\n enabled: (options?.enabled ?? true) && arbi.isLoggedIn,\n staleTime: 30_000,\n })\n}\n\n/** Referral progress for the signed-in owner's contact invitations. */\nexport function useReferralSummary(currentUserExtId: string) {\n const arbi = useArbi()\n return useQuery({\n queryKey: [...arbiQueryKeys.contacts(), 'referrals', currentUserExtId],\n queryFn: () => arbi.contacts.referrals(),\n enabled: arbi.isLoggedIn,\n retry: false,\n staleTime: 30_000,\n })\n}\n\nfunction useInvalidateContacts() {\n const qc = useQueryClient()\n return () => qc.invalidateQueries({ queryKey: arbiQueryKeys.contacts() })\n}\n\n/**\n * Invite (or link) people by email. An address not yet on ARBI gets an invitation. Resolves with one\n * row per address (`outcome`, `status`); map it with `toAddContactsRows` from `@arbidocs/blocks/collaboration`.\n */\nexport function useInviteContacts() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (emails: string[]) => arbi.contacts.invite(emails),\n onSuccess: () => invalidate(),\n })\n}\n\n/** Create a card, optionally linking `email` and inviting it (`invite: true`). */\nexport function useCreateContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (body: contactsOps.ContactCreate) => arbi.contacts.create(body),\n onSuccess: () => invalidate(),\n })\n}\n\n/** Replace a contact's card details. */\nexport function useUpdateContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: ({ id, card }: { id: string; card: contactsOps.ContactCardWrite }) =>\n arbi.contacts.update(id, card),\n onSuccess: () => invalidate(),\n })\n}\n\n/**\n * Invite a contact to ARBI by `email`: a card-only contact is linked in place (its row and card kept);\n * without an id a new card is created and invited. Rejects with `DuplicateContactError` when `email`\n * already belongs to another contact. The list refreshes either way.\n */\nexport function useLinkContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: ({\n contact,\n email,\n card,\n }: {\n contact: Pick<contactsOps.Contact, 'external_id'>\n email: string\n card: contactsOps.ContactCardWrite\n }) =>\n contact.external_id\n ? arbi.contacts.link(contact.external_id, email, card)\n : arbi.contacts.create({ email, card, invite: true }),\n onSettled: () => invalidate(),\n })\n}\n\n/** Import one .vcf file (Pro: 403 `pro_required` otherwise); the list refreshes after each file. */\nexport function useImportContacts() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (file: Blob) => arbi.contacts.import(file),\n onSettled: () => invalidate(),\n })\n}\n\n/** Delete a contact, or withdraw its invitation, by contact id. */\nexport function useDeleteContact() {\n const arbi = useArbi()\n const invalidate = useInvalidateContacts()\n return useMutation({\n mutationFn: (contactId: string) => arbi.contacts.delete(contactId),\n onSuccess: () => invalidate(),\n })\n}\n\n/**\n * People matching `q` (your contacts and the registered people you share a workspace with), for a\n * picker: debounced, nothing fetched for an empty query, the previous matches kept while typing.\n */\nexport function useSearchContacts(q: string, { debounceMs = 200 }: { debounceMs?: number } = {}) {\n const arbi = useArbi()\n const term = useDebounced(q.trim(), debounceMs)\n return useQuery({\n queryKey: [...arbiQueryKeys.contacts(), 'search', term] as const,\n queryFn: () => arbi.contacts.search(term),\n enabled: term.length > 0 && arbi.isLoggedIn,\n staleTime: 60_000,\n placeholderData: (previous) => previous,\n retry: false,\n })\n}\n\nfunction useDebounced<T>(value: T, ms: number): T {\n const [debounced, setDebounced] = useState(value)\n useEffect(() => {\n const t = setTimeout(() => setDebounced(value), ms)\n return () => clearTimeout(t)\n }, [value, ms])\n return debounced\n}\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,WAAW,gBAAgB;AACpC,SAA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AM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,YAAU,MAAM;AACd,UAAM,IAAI,WAAW,MAAM,aAAa,KAAK,GAAG,EAAE;AAClD,WAAO,MAAM,aAAa,CAAC;AAAA,EAC7B,GAAG,CAAC,OAAO,EAAE,CAAC;AACd,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -12115,6 +12115,16 @@ function useContacts(options) {
|
|
|
12115
12115
|
staleTime: 3e4
|
|
12116
12116
|
});
|
|
12117
12117
|
}
|
|
12118
|
+
function useReferralSummary(currentUserExtId) {
|
|
12119
|
+
const arbi = chunkFE6ZSNZE_cjs.useArbi();
|
|
12120
|
+
return reactQuery.useQuery({
|
|
12121
|
+
queryKey: [...chunkFE6ZSNZE_cjs.arbiQueryKeys.contacts(), "referrals", currentUserExtId],
|
|
12122
|
+
queryFn: () => arbi.contacts.referrals(),
|
|
12123
|
+
enabled: arbi.isLoggedIn,
|
|
12124
|
+
retry: false,
|
|
12125
|
+
staleTime: 3e4
|
|
12126
|
+
});
|
|
12127
|
+
}
|
|
12118
12128
|
function useInvalidateContacts() {
|
|
12119
12129
|
const qc = reactQuery.useQueryClient();
|
|
12120
12130
|
return () => qc.invalidateQueries({ queryKey: chunkFE6ZSNZE_cjs.arbiQueryKeys.contacts() });
|
|
@@ -20395,6 +20405,7 @@ exports.usePublishCalendar = usePublishCalendar;
|
|
|
20395
20405
|
exports.useRateSupportTicket = useRateSupportTicket;
|
|
20396
20406
|
exports.useReadMailMessage = useReadMailMessage;
|
|
20397
20407
|
exports.useReconnect = useReconnect;
|
|
20408
|
+
exports.useReferralSummary = useReferralSummary;
|
|
20398
20409
|
exports.useRefreshCalendar = useRefreshCalendar;
|
|
20399
20410
|
exports.useRefreshConnectorsOnRunEnd = useRefreshConnectorsOnRunEnd;
|
|
20400
20411
|
exports.useRefreshProject = useRefreshProject;
|