@comapeo/core-react 3.3.0 → 4.1.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.
@@ -37,7 +37,7 @@ export declare function useClientApi(): import("@comapeo/ipc/dist/client.js", {
37
37
  export declare function useOwnDeviceInfo(): {
38
38
  data: {
39
39
  deviceId: string;
40
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
40
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
41
41
  } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>;
42
42
  error: Error | null;
43
43
  isRefetching: boolean;
@@ -1,3 +1,53 @@
1
+ /**
2
+ * Set up listeners for received and updated invites.
3
+ * It is necessary to use this if you want the invites-related read hooks to update
4
+ * based on invites that are received or changed in the background.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * function App() {
9
+ * // Use this somewhere near the root of the application
10
+ * useSetUpInvitesListeners()
11
+ *
12
+ * return <RestOfApp />
13
+ * }
14
+ * ```
15
+ */
16
+ export declare function useSetUpInvitesListeners(): void;
17
+ /**
18
+ * Get all invites that the device has received.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * function Example() {
23
+ * const { data } = useManyInvites()
24
+ * }
25
+ * ```
26
+ */
27
+ export declare function useManyInvites(): {
28
+ data: import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite[];
29
+ error: Error | null;
30
+ isRefetching: boolean;
31
+ };
32
+ /**
33
+ * Get a single invite based on its ID.
34
+ *
35
+ * @param opts.inviteId ID of invite
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * function Example() {
40
+ * const { data } = useSingleInvite({ inviteId: '...' })
41
+ * }
42
+ * ```
43
+ */
44
+ export declare function useSingleInvite({ inviteId }: {
45
+ inviteId: string;
46
+ }): {
47
+ data: import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite;
48
+ error: Error | null;
49
+ isRefetching: boolean;
50
+ };
1
51
  /**
2
52
  * Accept an invite that has been received.
3
53
  */
@@ -1,13 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSetUpInvitesListeners = useSetUpInvitesListeners;
4
+ exports.useManyInvites = useManyInvites;
5
+ exports.useSingleInvite = useSingleInvite;
3
6
  exports.useAcceptInvite = useAcceptInvite;
4
7
  exports.useRejectInvite = useRejectInvite;
5
8
  exports.useSendInvite = useSendInvite;
6
9
  exports.useRequestCancelInvite = useRequestCancelInvite;
7
10
  const react_query_1 = require("@tanstack/react-query");
11
+ const react_1 = require("react");
8
12
  const invites_js_1 = require("../lib/react-query/invites.js");
9
13
  const client_js_1 = require("./client.js");
10
14
  const projects_js_1 = require("./projects.js");
15
+ /**
16
+ * Set up listeners for received and updated invites.
17
+ * It is necessary to use this if you want the invites-related read hooks to update
18
+ * based on invites that are received or changed in the background.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * function App() {
23
+ * // Use this somewhere near the root of the application
24
+ * useSetUpInvitesListeners()
25
+ *
26
+ * return <RestOfApp />
27
+ * }
28
+ * ```
29
+ */
30
+ function useSetUpInvitesListeners() {
31
+ const queryClient = (0, react_query_1.useQueryClient)();
32
+ const clientApi = (0, client_js_1.useClientApi)();
33
+ (0, react_1.useEffect)(() => {
34
+ function invalidateCache() {
35
+ queryClient.invalidateQueries({ queryKey: (0, invites_js_1.getInvitesQueryKey)() });
36
+ }
37
+ clientApi.invite.addListener('invite-received', invalidateCache);
38
+ clientApi.invite.addListener('invite-updated', invalidateCache);
39
+ return () => {
40
+ clientApi.invite.removeListener('invite-received', invalidateCache);
41
+ clientApi.invite.removeListener('invite-updated', invalidateCache);
42
+ };
43
+ }, [clientApi, queryClient]);
44
+ }
45
+ /**
46
+ * Get all invites that the device has received.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * function Example() {
51
+ * const { data } = useManyInvites()
52
+ * }
53
+ * ```
54
+ */
55
+ function useManyInvites() {
56
+ const clientApi = (0, client_js_1.useClientApi)();
57
+ const { data, error, isRefetching } = (0, react_query_1.useSuspenseQuery)((0, invites_js_1.getInvitesQueryOptions)({ clientApi }));
58
+ return { data, error, isRefetching };
59
+ }
60
+ /**
61
+ * Get a single invite based on its ID.
62
+ *
63
+ * @param opts.inviteId ID of invite
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * function Example() {
68
+ * const { data } = useSingleInvite({ inviteId: '...' })
69
+ * }
70
+ * ```
71
+ */
72
+ function useSingleInvite({ inviteId }) {
73
+ const clientApi = (0, client_js_1.useClientApi)();
74
+ const { data, error, isRefetching } = (0, react_query_1.useSuspenseQuery)((0, invites_js_1.getInviteByIdQueryOptions)({ clientApi, inviteId }));
75
+ return { data, error, isRefetching };
76
+ }
11
77
  /**
12
78
  * Accept an invite that has been received.
13
79
  */
@@ -268,7 +268,7 @@ export declare function useDocumentCreatedBy({ projectId, originalVersionId, }:
268
268
  export declare function useOwnRoleInProject({ projectId }: {
269
269
  projectId: string;
270
270
  }): {
271
- data: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">;
271
+ data: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">;
272
272
  error: Error | null;
273
273
  isRefetching: boolean;
274
274
  };
@@ -299,6 +299,33 @@ export declare function useAddServerPeer({ projectId }: {
299
299
  reset: () => void;
300
300
  status: "pending" | "success" | "idle";
301
301
  };
302
+ export declare function useRemoveServerPeer({ projectId }: {
303
+ projectId: string;
304
+ }): {
305
+ error: Error;
306
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
307
+ serverDeviceId: string;
308
+ dangerouslyAllowInsecureConnections?: boolean;
309
+ }, unknown>;
310
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
311
+ serverDeviceId: string;
312
+ dangerouslyAllowInsecureConnections?: boolean;
313
+ }, unknown>;
314
+ reset: () => void;
315
+ status: "error";
316
+ } | {
317
+ error: null;
318
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
319
+ serverDeviceId: string;
320
+ dangerouslyAllowInsecureConnections?: boolean;
321
+ }, unknown>;
322
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
323
+ serverDeviceId: string;
324
+ dangerouslyAllowInsecureConnections?: boolean;
325
+ }, unknown>;
326
+ reset: () => void;
327
+ status: "pending" | "success" | "idle";
328
+ };
302
329
  /**
303
330
  * Create a new project.
304
331
  */
@@ -10,6 +10,7 @@ exports.useAttachmentUrl = useAttachmentUrl;
10
10
  exports.useDocumentCreatedBy = useDocumentCreatedBy;
11
11
  exports.useOwnRoleInProject = useOwnRoleInProject;
12
12
  exports.useAddServerPeer = useAddServerPeer;
13
+ exports.useRemoveServerPeer = useRemoveServerPeer;
13
14
  exports.useCreateProject = useCreateProject;
14
15
  exports.useLeaveProject = useLeaveProject;
15
16
  exports.useImportProjectConfig = useImportProjectConfig;
@@ -297,6 +298,14 @@ function useAddServerPeer({ projectId }) {
297
298
  ? { error, mutate, mutateAsync, reset, status }
298
299
  : { error: null, mutate, mutateAsync, reset, status };
299
300
  }
301
+ function useRemoveServerPeer({ projectId }) {
302
+ const queryClient = (0, react_query_1.useQueryClient)();
303
+ const { data: projectApi } = useSingleProject({ projectId });
304
+ const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.removeServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
305
+ return status === 'error'
306
+ ? { error, mutate, mutateAsync, reset, status }
307
+ : { error: null, mutate, mutateAsync, reset, status };
308
+ }
300
309
  /**
301
310
  * Create a new project.
302
311
  */
@@ -1,8 +1,8 @@
1
1
  export { ClientApiContext, ClientApiProvider } from './contexts/ClientApi.js';
2
2
  export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
3
3
  export { useCreateDocument, useDeleteDocument, useManyDocs, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
4
- export { useAcceptInvite, useRejectInvite, useRequestCancelInvite, useSendInvite, } from './hooks/invites.js';
4
+ export { useAcceptInvite, useSetUpInvitesListeners, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSingleInvite, } from './hooks/invites.js';
5
5
  export { useMapStyleUrl } from './hooks/maps.js';
6
- export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDataSyncProgress, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
6
+ export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDataSyncProgress, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
7
7
  export { type SyncState } from './lib/sync.js';
8
8
  export { type WriteableDocument, type WriteableDocumentType, type WriteableValue, } from './lib/types.js';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUpdateProjectSettings = exports.useSyncState = exports.useStopSync = exports.useStartSync = exports.useSingleProject = exports.useSingleMember = exports.useProjectSettings = exports.useOwnRoleInProject = exports.useManyProjects = exports.useManyMembers = exports.useLeaveProject = exports.useImportProjectConfig = exports.useIconUrl = exports.useDocumentCreatedBy = exports.useDataSyncProgress = exports.useCreateProject = exports.useCreateBlob = exports.useAttachmentUrl = exports.useAddServerPeer = exports.useMapStyleUrl = exports.useSendInvite = exports.useRequestCancelInvite = exports.useRejectInvite = exports.useAcceptInvite = exports.useUpdateDocument = exports.useSingleDocByVersionId = exports.useSingleDocByDocId = exports.useManyDocs = exports.useDeleteDocument = exports.useCreateDocument = exports.useSetOwnDeviceInfo = exports.useSetIsArchiveDevice = exports.useOwnDeviceInfo = exports.useIsArchiveDevice = exports.useClientApi = exports.ClientApiProvider = exports.ClientApiContext = void 0;
3
+ exports.useUpdateProjectSettings = exports.useSyncState = exports.useStopSync = exports.useStartSync = exports.useSingleProject = exports.useSingleMember = exports.useRemoveServerPeer = exports.useProjectSettings = exports.useOwnRoleInProject = exports.useManyProjects = exports.useManyMembers = exports.useLeaveProject = exports.useImportProjectConfig = exports.useIconUrl = exports.useDocumentCreatedBy = exports.useDataSyncProgress = exports.useCreateProject = exports.useCreateBlob = exports.useAttachmentUrl = exports.useAddServerPeer = exports.useMapStyleUrl = exports.useSingleInvite = exports.useSendInvite = exports.useRequestCancelInvite = exports.useRejectInvite = exports.useManyInvites = exports.useSetUpInvitesListeners = exports.useAcceptInvite = exports.useUpdateDocument = exports.useSingleDocByVersionId = exports.useSingleDocByDocId = exports.useManyDocs = exports.useDeleteDocument = exports.useCreateDocument = exports.useSetOwnDeviceInfo = exports.useSetIsArchiveDevice = exports.useOwnDeviceInfo = exports.useIsArchiveDevice = exports.useClientApi = exports.ClientApiProvider = exports.ClientApiContext = void 0;
4
4
  var ClientApi_js_1 = require("./contexts/ClientApi.js");
5
5
  Object.defineProperty(exports, "ClientApiContext", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiContext; } });
6
6
  Object.defineProperty(exports, "ClientApiProvider", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiProvider; } });
@@ -19,9 +19,12 @@ Object.defineProperty(exports, "useSingleDocByVersionId", { enumerable: true, ge
19
19
  Object.defineProperty(exports, "useUpdateDocument", { enumerable: true, get: function () { return documents_js_1.useUpdateDocument; } });
20
20
  var invites_js_1 = require("./hooks/invites.js");
21
21
  Object.defineProperty(exports, "useAcceptInvite", { enumerable: true, get: function () { return invites_js_1.useAcceptInvite; } });
22
+ Object.defineProperty(exports, "useSetUpInvitesListeners", { enumerable: true, get: function () { return invites_js_1.useSetUpInvitesListeners; } });
23
+ Object.defineProperty(exports, "useManyInvites", { enumerable: true, get: function () { return invites_js_1.useManyInvites; } });
22
24
  Object.defineProperty(exports, "useRejectInvite", { enumerable: true, get: function () { return invites_js_1.useRejectInvite; } });
23
25
  Object.defineProperty(exports, "useRequestCancelInvite", { enumerable: true, get: function () { return invites_js_1.useRequestCancelInvite; } });
24
26
  Object.defineProperty(exports, "useSendInvite", { enumerable: true, get: function () { return invites_js_1.useSendInvite; } });
27
+ Object.defineProperty(exports, "useSingleInvite", { enumerable: true, get: function () { return invites_js_1.useSingleInvite; } });
25
28
  var maps_js_1 = require("./hooks/maps.js");
26
29
  Object.defineProperty(exports, "useMapStyleUrl", { enumerable: true, get: function () { return maps_js_1.useMapStyleUrl; } });
27
30
  var projects_js_1 = require("./hooks/projects.js");
@@ -38,6 +41,7 @@ Object.defineProperty(exports, "useManyMembers", { enumerable: true, get: functi
38
41
  Object.defineProperty(exports, "useManyProjects", { enumerable: true, get: function () { return projects_js_1.useManyProjects; } });
39
42
  Object.defineProperty(exports, "useOwnRoleInProject", { enumerable: true, get: function () { return projects_js_1.useOwnRoleInProject; } });
40
43
  Object.defineProperty(exports, "useProjectSettings", { enumerable: true, get: function () { return projects_js_1.useProjectSettings; } });
44
+ Object.defineProperty(exports, "useRemoveServerPeer", { enumerable: true, get: function () { return projects_js_1.useRemoveServerPeer; } });
41
45
  Object.defineProperty(exports, "useSingleMember", { enumerable: true, get: function () { return projects_js_1.useSingleMember; } });
42
46
  Object.defineProperty(exports, "useSingleProject", { enumerable: true, get: function () { return projects_js_1.useSingleProject; } });
43
47
  Object.defineProperty(exports, "useStartSync", { enumerable: true, get: function () { return projects_js_1.useStartSync; } });
@@ -8,20 +8,20 @@ export declare function deviceInfoQueryOptions({ clientApi, }: {
8
8
  clientApi: MapeoClientApi;
9
9
  }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
10
10
  deviceId: string;
11
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
11
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
12
12
  } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, Error, {
13
13
  deviceId: string;
14
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
14
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
15
15
  } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"]>, "queryFn"> & {
16
16
  queryFn?: import("@tanstack/react-query").QueryFunction<{
17
17
  deviceId: string;
18
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
18
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
19
19
  } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"], never> | undefined;
20
20
  } & {
21
21
  queryKey: readonly ["@comapeo/core-react", "client", "device_info"] & {
22
22
  [dataTagSymbol]: {
23
23
  deviceId: string;
24
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
24
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
25
25
  } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>;
26
26
  [dataTagErrorSymbol]: Error;
27
27
  };
@@ -2,22 +2,35 @@ import type { RoleIdForNewInvite } from '@comapeo/core/dist/roles.js' with { 're
2
2
  import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with { 'resolution-mode': 'import' };
3
3
  import { type QueryClient } from '@tanstack/react-query';
4
4
  export declare function getInvitesQueryKey(): readonly ["@comapeo/core-react", "invites"];
5
- export declare function getPendingInvitesQueryKey(): readonly ["@comapeo/core-react", "invites", {
6
- readonly status: "pending";
5
+ export declare function getInvitesByIdQueryKey({ inviteId }: {
6
+ inviteId: string;
7
+ }): readonly ["@comapeo/core-react", "invites", {
8
+ readonly inviteId: string;
7
9
  }];
8
- export declare function pendingInvitesQueryOptions({ clientApi, }: {
10
+ export declare function getInvitesQueryOptions({ clientApi, }: {
9
11
  clientApi: MapeoClientApi;
10
- }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/types.js", { with: { "resolution-mode": "import" } }).MapBuffers<import("@comapeo/core/dist/invite-api.js", { with: { "resolution-mode": "import" } }).InviteInternal>[], Error, import("@comapeo/core/dist/types.js", { with: { "resolution-mode": "import" } }).MapBuffers<import("@comapeo/core/dist/invite-api.js", { with: { "resolution-mode": "import" } }).InviteInternal>[], readonly ["@comapeo/core-react", "invites", {
11
- readonly status: "pending";
12
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite[], Error, import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite[], readonly ["@comapeo/core-react", "invites"]>, "queryFn"> & {
13
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite[], readonly ["@comapeo/core-react", "invites"], never> | undefined;
14
+ } & {
15
+ queryKey: readonly ["@comapeo/core-react", "invites"] & {
16
+ [dataTagSymbol]: import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite[];
17
+ [dataTagErrorSymbol]: Error;
18
+ };
19
+ };
20
+ export declare function getInviteByIdQueryOptions({ clientApi, inviteId, }: {
21
+ clientApi: MapeoClientApi;
22
+ inviteId: string;
23
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite, Error, import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite, readonly ["@comapeo/core-react", "invites", {
24
+ readonly inviteId: string;
12
25
  }]>, "queryFn"> & {
13
- queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/types.js", { with: { "resolution-mode": "import" } }).MapBuffers<import("@comapeo/core/dist/invite-api.js", { with: { "resolution-mode": "import" } }).InviteInternal>[], readonly ["@comapeo/core-react", "invites", {
14
- readonly status: "pending";
26
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite, readonly ["@comapeo/core-react", "invites", {
27
+ readonly inviteId: string;
15
28
  }], never> | undefined;
16
29
  } & {
17
30
  queryKey: readonly ["@comapeo/core-react", "invites", {
18
- readonly status: "pending";
31
+ readonly inviteId: string;
19
32
  }] & {
20
- [dataTagSymbol]: import("@comapeo/core/dist/types.js", { with: { "resolution-mode": "import" } }).MapBuffers<import("@comapeo/core/dist/invite-api.js", { with: { "resolution-mode": "import" } }).InviteInternal>[];
33
+ [dataTagSymbol]: import("@comapeo/core/dist/invite/invite-api.js", { with: { "resolution-mode": "import" } }).Invite;
21
34
  [dataTagErrorSymbol]: Error;
22
35
  };
23
36
  };
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvitesQueryKey = getInvitesQueryKey;
4
- exports.getPendingInvitesQueryKey = getPendingInvitesQueryKey;
5
- exports.pendingInvitesQueryOptions = pendingInvitesQueryOptions;
4
+ exports.getInvitesByIdQueryKey = getInvitesByIdQueryKey;
5
+ exports.getInvitesQueryOptions = getInvitesQueryOptions;
6
+ exports.getInviteByIdQueryOptions = getInviteByIdQueryOptions;
6
7
  exports.acceptInviteMutationOptions = acceptInviteMutationOptions;
7
8
  exports.rejectInviteMutationOptions = rejectInviteMutationOptions;
8
9
  exports.sendInviteMutationOptions = sendInviteMutationOptions;
@@ -13,15 +14,24 @@ const shared_js_1 = require("./shared.js");
13
14
  function getInvitesQueryKey() {
14
15
  return [shared_js_1.ROOT_QUERY_KEY, 'invites'];
15
16
  }
16
- function getPendingInvitesQueryKey() {
17
- return [shared_js_1.ROOT_QUERY_KEY, 'invites', { status: 'pending' }];
17
+ function getInvitesByIdQueryKey({ inviteId }) {
18
+ return [shared_js_1.ROOT_QUERY_KEY, 'invites', { inviteId }];
18
19
  }
19
- function pendingInvitesQueryOptions({ clientApi, }) {
20
+ function getInvitesQueryOptions({ clientApi, }) {
20
21
  return (0, react_query_1.queryOptions)({
21
22
  ...(0, shared_js_1.baseQueryOptions)(),
22
- queryKey: getPendingInvitesQueryKey(),
23
+ queryKey: getInvitesQueryKey(),
23
24
  queryFn: async () => {
24
- return clientApi.invite.getPending();
25
+ return clientApi.invite.getMany();
26
+ },
27
+ });
28
+ }
29
+ function getInviteByIdQueryOptions({ clientApi, inviteId, }) {
30
+ return (0, react_query_1.queryOptions)({
31
+ ...(0, shared_js_1.baseQueryOptions)(),
32
+ queryKey: getInvitesByIdQueryKey({ inviteId }),
33
+ queryFn: async () => {
34
+ return clientApi.invite.getById(inviteId);
25
35
  },
26
36
  });
27
37
  }
@@ -181,11 +181,11 @@ export declare function projectMemberByIdQueryOptions({ projectApi, projectId, d
181
181
  export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
182
182
  projectApi: MapeoProjectApi;
183
183
  projectId: string;
184
- }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, Error, import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
185
- queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
184
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">, Error, import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
185
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
186
186
  } & {
187
187
  queryKey: readonly ["@comapeo/core-react", "projects", string, "role"] & {
188
- [dataTagSymbol]: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">;
188
+ [dataTagSymbol]: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">;
189
189
  [dataTagErrorSymbol]: Error;
190
190
  };
191
191
  };
@@ -265,6 +265,19 @@ export declare function addServerPeerMutationOptions({ projectApi, projectId, qu
265
265
  networkMode: "always";
266
266
  retry: false;
267
267
  };
268
+ export declare function removeServerPeerMutationOptions({ projectApi, projectId, queryClient, }: {
269
+ projectApi: MapeoProjectApi;
270
+ projectId: string;
271
+ queryClient: QueryClient;
272
+ }): {
273
+ mutationFn: ({ serverDeviceId, dangerouslyAllowInsecureConnections, }: {
274
+ serverDeviceId: string;
275
+ dangerouslyAllowInsecureConnections?: boolean;
276
+ }) => Promise<void>;
277
+ onSuccess: () => void;
278
+ networkMode: "always";
279
+ retry: false;
280
+ };
268
281
  export declare function createProjectMutationOptions({ clientApi, queryClient, }: {
269
282
  clientApi: MapeoClientApi;
270
283
  queryClient: QueryClient;
@@ -19,6 +19,7 @@ exports.iconUrlQueryOptions = iconUrlQueryOptions;
19
19
  exports.documentCreatedByQueryOptions = documentCreatedByQueryOptions;
20
20
  exports.attachmentUrlQueryOptions = attachmentUrlQueryOptions;
21
21
  exports.addServerPeerMutationOptions = addServerPeerMutationOptions;
22
+ exports.removeServerPeerMutationOptions = removeServerPeerMutationOptions;
22
23
  exports.createProjectMutationOptions = createProjectMutationOptions;
23
24
  exports.leaveProjectMutationOptions = leaveProjectMutationOptions;
24
25
  exports.importProjectConfigMutationOptions = importProjectConfigMutationOptions;
@@ -168,6 +169,21 @@ function addServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
168
169
  },
169
170
  };
170
171
  }
172
+ function removeServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
173
+ return {
174
+ ...(0, shared_js_1.baseMutationOptions)(),
175
+ mutationFn: async ({ serverDeviceId, dangerouslyAllowInsecureConnections, }) => {
176
+ return projectApi.$member.removeServerPeer(serverDeviceId, {
177
+ dangerouslyAllowInsecureConnections,
178
+ });
179
+ },
180
+ onSuccess: () => {
181
+ queryClient.invalidateQueries({
182
+ queryKey: getMembersQueryKey({ projectId }),
183
+ });
184
+ },
185
+ };
186
+ }
171
187
  function createProjectMutationOptions({ clientApi, queryClient, }) {
172
188
  return {
173
189
  ...(0, shared_js_1.baseMutationOptions)(),
@@ -37,7 +37,7 @@ export declare function useClientApi(): import("@comapeo/ipc/dist/client.js").Ma
37
37
  export declare function useOwnDeviceInfo(): {
38
38
  data: {
39
39
  deviceId: string;
40
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
40
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
41
41
  } & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>;
42
42
  error: Error | null;
43
43
  isRefetching: boolean;
@@ -1,3 +1,53 @@
1
+ /**
2
+ * Set up listeners for received and updated invites.
3
+ * It is necessary to use this if you want the invites-related read hooks to update
4
+ * based on invites that are received or changed in the background.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * function App() {
9
+ * // Use this somewhere near the root of the application
10
+ * useSetUpInvitesListeners()
11
+ *
12
+ * return <RestOfApp />
13
+ * }
14
+ * ```
15
+ */
16
+ export declare function useSetUpInvitesListeners(): void;
17
+ /**
18
+ * Get all invites that the device has received.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * function Example() {
23
+ * const { data } = useManyInvites()
24
+ * }
25
+ * ```
26
+ */
27
+ export declare function useManyInvites(): {
28
+ data: import("@comapeo/core/dist/invite/invite-api.js").Invite[];
29
+ error: Error | null;
30
+ isRefetching: boolean;
31
+ };
32
+ /**
33
+ * Get a single invite based on its ID.
34
+ *
35
+ * @param opts.inviteId ID of invite
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * function Example() {
40
+ * const { data } = useSingleInvite({ inviteId: '...' })
41
+ * }
42
+ * ```
43
+ */
44
+ export declare function useSingleInvite({ inviteId }: {
45
+ inviteId: string;
46
+ }): {
47
+ data: import("@comapeo/core/dist/invite/invite-api.js").Invite;
48
+ error: Error | null;
49
+ isRefetching: boolean;
50
+ };
1
51
  /**
2
52
  * Accept an invite that has been received.
3
53
  */
@@ -1,7 +1,70 @@
1
- import { useMutation, useQueryClient } from '@tanstack/react-query';
2
- import { acceptInviteMutationOptions, rejectInviteMutationOptions, requestCancelInviteMutationOptions, sendInviteMutationOptions, } from '../lib/react-query/invites.js';
1
+ import { useMutation, useQueryClient, useSuspenseQuery, } from '@tanstack/react-query';
2
+ import { useEffect } from 'react';
3
+ import { acceptInviteMutationOptions, getInviteByIdQueryOptions, getInvitesQueryKey, getInvitesQueryOptions, rejectInviteMutationOptions, requestCancelInviteMutationOptions, sendInviteMutationOptions, } from '../lib/react-query/invites.js';
3
4
  import { useClientApi } from './client.js';
4
5
  import { useSingleProject } from './projects.js';
6
+ /**
7
+ * Set up listeners for received and updated invites.
8
+ * It is necessary to use this if you want the invites-related read hooks to update
9
+ * based on invites that are received or changed in the background.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * function App() {
14
+ * // Use this somewhere near the root of the application
15
+ * useSetUpInvitesListeners()
16
+ *
17
+ * return <RestOfApp />
18
+ * }
19
+ * ```
20
+ */
21
+ export function useSetUpInvitesListeners() {
22
+ const queryClient = useQueryClient();
23
+ const clientApi = useClientApi();
24
+ useEffect(() => {
25
+ function invalidateCache() {
26
+ queryClient.invalidateQueries({ queryKey: getInvitesQueryKey() });
27
+ }
28
+ clientApi.invite.addListener('invite-received', invalidateCache);
29
+ clientApi.invite.addListener('invite-updated', invalidateCache);
30
+ return () => {
31
+ clientApi.invite.removeListener('invite-received', invalidateCache);
32
+ clientApi.invite.removeListener('invite-updated', invalidateCache);
33
+ };
34
+ }, [clientApi, queryClient]);
35
+ }
36
+ /**
37
+ * Get all invites that the device has received.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * function Example() {
42
+ * const { data } = useManyInvites()
43
+ * }
44
+ * ```
45
+ */
46
+ export function useManyInvites() {
47
+ const clientApi = useClientApi();
48
+ const { data, error, isRefetching } = useSuspenseQuery(getInvitesQueryOptions({ clientApi }));
49
+ return { data, error, isRefetching };
50
+ }
51
+ /**
52
+ * Get a single invite based on its ID.
53
+ *
54
+ * @param opts.inviteId ID of invite
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * function Example() {
59
+ * const { data } = useSingleInvite({ inviteId: '...' })
60
+ * }
61
+ * ```
62
+ */
63
+ export function useSingleInvite({ inviteId }) {
64
+ const clientApi = useClientApi();
65
+ const { data, error, isRefetching } = useSuspenseQuery(getInviteByIdQueryOptions({ clientApi, inviteId }));
66
+ return { data, error, isRefetching };
67
+ }
5
68
  /**
6
69
  * Accept an invite that has been received.
7
70
  */
@@ -268,7 +268,7 @@ export declare function useDocumentCreatedBy({ projectId, originalVersionId, }:
268
268
  export declare function useOwnRoleInProject({ projectId }: {
269
269
  projectId: string;
270
270
  }): {
271
- data: import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">;
271
+ data: import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">;
272
272
  error: Error | null;
273
273
  isRefetching: boolean;
274
274
  };
@@ -299,6 +299,33 @@ export declare function useAddServerPeer({ projectId }: {
299
299
  reset: () => void;
300
300
  status: "pending" | "success" | "idle";
301
301
  };
302
+ export declare function useRemoveServerPeer({ projectId }: {
303
+ projectId: string;
304
+ }): {
305
+ error: Error;
306
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
307
+ serverDeviceId: string;
308
+ dangerouslyAllowInsecureConnections?: boolean;
309
+ }, unknown>;
310
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
311
+ serverDeviceId: string;
312
+ dangerouslyAllowInsecureConnections?: boolean;
313
+ }, unknown>;
314
+ reset: () => void;
315
+ status: "error";
316
+ } | {
317
+ error: null;
318
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
319
+ serverDeviceId: string;
320
+ dangerouslyAllowInsecureConnections?: boolean;
321
+ }, unknown>;
322
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
323
+ serverDeviceId: string;
324
+ dangerouslyAllowInsecureConnections?: boolean;
325
+ }, unknown>;
326
+ reset: () => void;
327
+ status: "pending" | "success" | "idle";
328
+ };
302
329
  /**
303
330
  * Create a new project.
304
331
  */
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQueryClient, useSuspenseQuery, } from '@tanstack/react-query';
2
2
  import { useSyncExternalStore } from 'react';
3
- import { addServerPeerMutationOptions, attachmentUrlQueryOptions, createBlobMutationOptions, createProjectMutationOptions, documentCreatedByQueryOptions, iconUrlQueryOptions, importProjectConfigMutationOptions, leaveProjectMutationOptions, projectByIdQueryOptions, projectMemberByIdQueryOptions, projectMembersQueryOptions, projectOwnRoleQueryOptions, projectSettingsQueryOptions, projectsQueryOptions, startSyncMutationOptions, stopSyncMutationOptions, updateProjectSettingsMutationOptions, } from '../lib/react-query/projects.js';
3
+ import { addServerPeerMutationOptions, attachmentUrlQueryOptions, createBlobMutationOptions, createProjectMutationOptions, documentCreatedByQueryOptions, iconUrlQueryOptions, importProjectConfigMutationOptions, leaveProjectMutationOptions, projectByIdQueryOptions, projectMemberByIdQueryOptions, projectMembersQueryOptions, projectOwnRoleQueryOptions, projectSettingsQueryOptions, projectsQueryOptions, removeServerPeerMutationOptions, startSyncMutationOptions, stopSyncMutationOptions, updateProjectSettingsMutationOptions, } from '../lib/react-query/projects.js';
4
4
  import { SyncStore } from '../lib/sync.js';
5
5
  import { useClientApi } from './client.js';
6
6
  /**
@@ -276,6 +276,14 @@ export function useAddServerPeer({ projectId }) {
276
276
  ? { error, mutate, mutateAsync, reset, status }
277
277
  : { error: null, mutate, mutateAsync, reset, status };
278
278
  }
279
+ export function useRemoveServerPeer({ projectId }) {
280
+ const queryClient = useQueryClient();
281
+ const { data: projectApi } = useSingleProject({ projectId });
282
+ const { error, mutate, mutateAsync, reset, status } = useMutation(removeServerPeerMutationOptions({ projectApi, projectId, queryClient }));
283
+ return status === 'error'
284
+ ? { error, mutate, mutateAsync, reset, status }
285
+ : { error: null, mutate, mutateAsync, reset, status };
286
+ }
279
287
  /**
280
288
  * Create a new project.
281
289
  */
@@ -1,8 +1,8 @@
1
1
  export { ClientApiContext, ClientApiProvider } from './contexts/ClientApi.js';
2
2
  export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
3
3
  export { useCreateDocument, useDeleteDocument, useManyDocs, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
4
- export { useAcceptInvite, useRejectInvite, useRequestCancelInvite, useSendInvite, } from './hooks/invites.js';
4
+ export { useAcceptInvite, useSetUpInvitesListeners, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSingleInvite, } from './hooks/invites.js';
5
5
  export { useMapStyleUrl } from './hooks/maps.js';
6
- export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDataSyncProgress, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
6
+ export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDataSyncProgress, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
7
7
  export { type SyncState } from './lib/sync.js';
8
8
  export { type WriteableDocument, type WriteableDocumentType, type WriteableValue, } from './lib/types.js';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ClientApiContext, ClientApiProvider } from './contexts/ClientApi.js';
2
2
  export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
3
3
  export { useCreateDocument, useDeleteDocument, useManyDocs, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
4
- export { useAcceptInvite, useRejectInvite, useRequestCancelInvite, useSendInvite, } from './hooks/invites.js';
4
+ export { useAcceptInvite, useSetUpInvitesListeners, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSingleInvite, } from './hooks/invites.js';
5
5
  export { useMapStyleUrl } from './hooks/maps.js';
6
- export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDataSyncProgress, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
6
+ export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDataSyncProgress, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
@@ -8,20 +8,20 @@ export declare function deviceInfoQueryOptions({ clientApi, }: {
8
8
  clientApi: MapeoClientApi;
9
9
  }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
10
10
  deviceId: string;
11
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
11
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
12
12
  } & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>, Error, {
13
13
  deviceId: string;
14
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
14
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
15
15
  } & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"]>, "queryFn"> & {
16
16
  queryFn?: import("@tanstack/react-query").QueryFunction<{
17
17
  deviceId: string;
18
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
18
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
19
19
  } & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"], never> | undefined;
20
20
  } & {
21
21
  queryKey: readonly ["@comapeo/core-react", "client", "device_info"] & {
22
22
  [dataTagSymbol]: {
23
23
  deviceId: string;
24
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
24
+ deviceType: "UNRECOGNIZED" | "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer";
25
25
  } & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>;
26
26
  [dataTagErrorSymbol]: Error;
27
27
  };
@@ -2,22 +2,35 @@ import type { RoleIdForNewInvite } from '@comapeo/core/dist/roles.js' with { 're
2
2
  import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with { 'resolution-mode': 'import' };
3
3
  import { type QueryClient } from '@tanstack/react-query';
4
4
  export declare function getInvitesQueryKey(): readonly ["@comapeo/core-react", "invites"];
5
- export declare function getPendingInvitesQueryKey(): readonly ["@comapeo/core-react", "invites", {
6
- readonly status: "pending";
5
+ export declare function getInvitesByIdQueryKey({ inviteId }: {
6
+ inviteId: string;
7
+ }): readonly ["@comapeo/core-react", "invites", {
8
+ readonly inviteId: string;
7
9
  }];
8
- export declare function pendingInvitesQueryOptions({ clientApi, }: {
10
+ export declare function getInvitesQueryOptions({ clientApi, }: {
9
11
  clientApi: MapeoClientApi;
10
- }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[], Error, import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[], readonly ["@comapeo/core-react", "invites", {
11
- readonly status: "pending";
12
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/invite/invite-api.js").Invite[], Error, import("@comapeo/core/dist/invite/invite-api.js").Invite[], readonly ["@comapeo/core-react", "invites"]>, "queryFn"> & {
13
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/invite/invite-api.js").Invite[], readonly ["@comapeo/core-react", "invites"], never> | undefined;
14
+ } & {
15
+ queryKey: readonly ["@comapeo/core-react", "invites"] & {
16
+ [dataTagSymbol]: import("@comapeo/core/dist/invite/invite-api.js").Invite[];
17
+ [dataTagErrorSymbol]: Error;
18
+ };
19
+ };
20
+ export declare function getInviteByIdQueryOptions({ clientApi, inviteId, }: {
21
+ clientApi: MapeoClientApi;
22
+ inviteId: string;
23
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/invite/invite-api.js").Invite, Error, import("@comapeo/core/dist/invite/invite-api.js").Invite, readonly ["@comapeo/core-react", "invites", {
24
+ readonly inviteId: string;
12
25
  }]>, "queryFn"> & {
13
- queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[], readonly ["@comapeo/core-react", "invites", {
14
- readonly status: "pending";
26
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/invite/invite-api.js").Invite, readonly ["@comapeo/core-react", "invites", {
27
+ readonly inviteId: string;
15
28
  }], never> | undefined;
16
29
  } & {
17
30
  queryKey: readonly ["@comapeo/core-react", "invites", {
18
- readonly status: "pending";
31
+ readonly inviteId: string;
19
32
  }] & {
20
- [dataTagSymbol]: import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[];
33
+ [dataTagSymbol]: import("@comapeo/core/dist/invite/invite-api.js").Invite;
21
34
  [dataTagErrorSymbol]: Error;
22
35
  };
23
36
  };
@@ -4,15 +4,24 @@ import { baseMutationOptions, baseQueryOptions, ROOT_QUERY_KEY, } from './shared
4
4
  export function getInvitesQueryKey() {
5
5
  return [ROOT_QUERY_KEY, 'invites'];
6
6
  }
7
- export function getPendingInvitesQueryKey() {
8
- return [ROOT_QUERY_KEY, 'invites', { status: 'pending' }];
7
+ export function getInvitesByIdQueryKey({ inviteId }) {
8
+ return [ROOT_QUERY_KEY, 'invites', { inviteId }];
9
9
  }
10
- export function pendingInvitesQueryOptions({ clientApi, }) {
10
+ export function getInvitesQueryOptions({ clientApi, }) {
11
11
  return queryOptions({
12
12
  ...baseQueryOptions(),
13
- queryKey: getPendingInvitesQueryKey(),
13
+ queryKey: getInvitesQueryKey(),
14
14
  queryFn: async () => {
15
- return clientApi.invite.getPending();
15
+ return clientApi.invite.getMany();
16
+ },
17
+ });
18
+ }
19
+ export function getInviteByIdQueryOptions({ clientApi, inviteId, }) {
20
+ return queryOptions({
21
+ ...baseQueryOptions(),
22
+ queryKey: getInvitesByIdQueryKey({ inviteId }),
23
+ queryFn: async () => {
24
+ return clientApi.invite.getById(inviteId);
16
25
  },
17
26
  });
18
27
  }
@@ -181,11 +181,11 @@ export declare function projectMemberByIdQueryOptions({ projectApi, projectId, d
181
181
  export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
182
182
  projectApi: MapeoProjectApi;
183
183
  projectId: string;
184
- }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, Error, import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
185
- queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
184
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">, Error, import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
185
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
186
186
  } & {
187
187
  queryKey: readonly ["@comapeo/core-react", "projects", string, "role"] & {
188
- [dataTagSymbol]: import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">;
188
+ [dataTagSymbol]: import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "a24eaca65ab5d5d0" | "08e4251e36f6e7ed">;
189
189
  [dataTagErrorSymbol]: Error;
190
190
  };
191
191
  };
@@ -265,6 +265,19 @@ export declare function addServerPeerMutationOptions({ projectApi, projectId, qu
265
265
  networkMode: "always";
266
266
  retry: false;
267
267
  };
268
+ export declare function removeServerPeerMutationOptions({ projectApi, projectId, queryClient, }: {
269
+ projectApi: MapeoProjectApi;
270
+ projectId: string;
271
+ queryClient: QueryClient;
272
+ }): {
273
+ mutationFn: ({ serverDeviceId, dangerouslyAllowInsecureConnections, }: {
274
+ serverDeviceId: string;
275
+ dangerouslyAllowInsecureConnections?: boolean;
276
+ }) => Promise<void>;
277
+ onSuccess: () => void;
278
+ networkMode: "always";
279
+ retry: false;
280
+ };
268
281
  export declare function createProjectMutationOptions({ clientApi, queryClient, }: {
269
282
  clientApi: MapeoClientApi;
270
283
  queryClient: QueryClient;
@@ -140,6 +140,21 @@ export function addServerPeerMutationOptions({ projectApi, projectId, queryClien
140
140
  },
141
141
  };
142
142
  }
143
+ export function removeServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
144
+ return {
145
+ ...baseMutationOptions(),
146
+ mutationFn: async ({ serverDeviceId, dangerouslyAllowInsecureConnections, }) => {
147
+ return projectApi.$member.removeServerPeer(serverDeviceId, {
148
+ dangerouslyAllowInsecureConnections,
149
+ });
150
+ },
151
+ onSuccess: () => {
152
+ queryClient.invalidateQueries({
153
+ queryKey: getMembersQueryKey({ projectId }),
154
+ });
155
+ },
156
+ };
157
+ }
143
158
  export function createProjectMutationOptions({ clientApi, queryClient, }) {
144
159
  return {
145
160
  ...baseMutationOptions(),
package/docs/API.md CHANGED
@@ -16,6 +16,7 @@
16
16
  - [useDocumentCreatedBy](#usedocumentcreatedby)
17
17
  - [useOwnRoleInProject](#useownroleinproject)
18
18
  - [useAddServerPeer](#useaddserverpeer)
19
+ - [useRemoveServerPeer](#useremoveserverpeer)
19
20
  - [useCreateProject](#usecreateproject)
20
21
  - [useLeaveProject](#useleaveproject)
21
22
  - [useImportProjectConfig](#useimportprojectconfig)
@@ -31,6 +32,9 @@
31
32
  - [useCreateDocument](#usecreatedocument)
32
33
  - [useUpdateDocument](#useupdatedocument)
33
34
  - [useDeleteDocument](#usedeletedocument)
35
+ - [useSetUpInvitesListeners](#usesetupinviteslisteners)
36
+ - [useManyInvites](#usemanyinvites)
37
+ - [useSingleInvite](#usesingleinvite)
34
38
  - [useAcceptInvite](#useacceptinvite)
35
39
  - [useRejectInvite](#userejectinvite)
36
40
  - [useSendInvite](#usesendinvite)
@@ -86,7 +90,7 @@ Retrieve info about the current device.
86
90
 
87
91
  | Function | Type |
88
92
  | ---------- | ---------- |
89
- | `useOwnDeviceInfo` | `() => { data: { deviceId: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer" or "UNRECOGNIZED"; } and Partial<DeviceInfoParam>; error: Error or null; isRefetching: boolean; }` |
93
+ | `useOwnDeviceInfo` | `() => { data: { deviceId: string; deviceType: "UNRECOGNIZED" or "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer"; } and Partial<DeviceInfoParam>; error: Error or null; isRefetching: boolean; }` |
90
94
 
91
95
  Examples:
92
96
 
@@ -120,7 +124,7 @@ Update the device info for the current device.
120
124
 
121
125
  | Function | Type |
122
126
  | ---------- | ---------- |
123
- | `useSetOwnDeviceInfo` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { name: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer" or "UNRECOGNIZED"; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
127
+ | `useSetOwnDeviceInfo` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { name: string; deviceType: "UNRECOGNIZED" or "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer"; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
124
128
 
125
129
  ### useSetIsArchiveDevice
126
130
 
@@ -128,7 +132,7 @@ Set or unset the current device as an archive device.
128
132
 
129
133
  | Function | Type |
130
134
  | ---------- | ---------- |
131
- | `useSetIsArchiveDevice` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; reset: () => void; status: "error"; } or { error: null; mutate: UseMutateFunction<...>; reset: () => void; status: "pending" or ... 1 more ... or "idle"; }` |
135
+ | `useSetIsArchiveDevice` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
132
136
 
133
137
  ### useProjectSettings
134
138
 
@@ -385,7 +389,7 @@ This is a more convenient alternative to using the `useOwnDeviceInfo` and `useMa
385
389
 
386
390
  | Function | Type |
387
391
  | ---------- | ---------- |
388
- | `useOwnRoleInProject` | `({ projectId }: { projectId: string; }) => { data: Role<"a12a6702b93bd7ff" or "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9" or "8ced989b1904606b" or "08e4251e36f6e7ed">; error: Error or null; isRefetching: boolean; }` |
392
+ | `useOwnRoleInProject` | `({ projectId }: { projectId: string; }) => { data: Role<"a12a6702b93bd7ff" or "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9" or "8ced989b1904606b" or "a24eaca65ab5d5d0" or "08e4251e36f6e7ed">; error: Error or null; isRefetching: boolean; }` |
389
393
 
390
394
  Parameters:
391
395
 
@@ -407,7 +411,13 @@ function BasicExample() {
407
411
 
408
412
  | Function | Type |
409
413
  | ---------- | ---------- |
410
- | `useAddServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { baseUrl: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
414
+ | `useAddServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { baseUrl: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
415
+
416
+ ### useRemoveServerPeer
417
+
418
+ | Function | Type |
419
+ | ---------- | ---------- |
420
+ | `useRemoveServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { serverDeviceId: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
411
421
 
412
422
  ### useCreateProject
413
423
 
@@ -415,7 +425,7 @@ Create a new project.
415
425
 
416
426
  | Function | Type |
417
427
  | ---------- | ---------- |
418
- | `useCreateProject` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { name?: string or undefined; configPath?: string or undefined; } or undefined, unknown>; reset: () => void; status: "error"; } or { ...; }` |
428
+ | `useCreateProject` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { name?: string or undefined; configPath?: string or undefined; } or undefined, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
419
429
 
420
430
  ### useLeaveProject
421
431
 
@@ -423,7 +433,7 @@ Leave an existing project.
423
433
 
424
434
  | Function | Type |
425
435
  | ---------- | ---------- |
426
- | `useLeaveProject` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { projectId: string; }, unknown>; reset: () => void; status: "error"; } or { error: null; mutate: UseMutateFunction<void, Error, { ...; }, unknown>; reset: () => void; status: "pending" or ... 1 more ... or "idle"; }` |
436
+ | `useLeaveProject` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { projectId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { projectId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
427
437
 
428
438
  ### useImportProjectConfig
429
439
 
@@ -431,7 +441,7 @@ Update the configuration of a project using an external file.
431
441
 
432
442
  | Function | Type |
433
443
  | ---------- | ---------- |
434
- | `useImportProjectConfig` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<Error[], Error, { configPath: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
444
+ | `useImportProjectConfig` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<Error[], Error, { configPath: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<Error[], Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
435
445
 
436
446
  Parameters:
437
447
 
@@ -444,7 +454,7 @@ Update the settings of a project.
444
454
 
445
455
  | Function | Type |
446
456
  | ---------- | ---------- |
447
- | `useUpdateProjectSettings` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<EditableProjectSettings, Error, { name?: string or undefined; configMetadata?: { ...; } or undefined; defaultPresets?: { ...; } or undefined; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
457
+ | `useUpdateProjectSettings` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<EditableProjectSettings, Error, { name?: string or undefined; configMetadata?: { ...; } or undefined; defaultPresets?: { ...; } or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } ...` |
448
458
 
449
459
  Parameters:
450
460
 
@@ -457,7 +467,7 @@ Create a blob for a project.
457
467
 
458
468
  | Function | Type |
459
469
  | ---------- | ---------- |
460
- | `useCreateBlob` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<{ driveId: string; name: string; type: "photo" or "audio" or "video"; hash: string; }, Error, { original: string; preview?: string or undefined; thumbnail?: string or undefined; metadata: Metadata; }, unknown>; reset: () => void; status...` |
470
+ | `useCreateBlob` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<{ driveId: string; name: string; type: "photo" or "audio" or "video"; hash: string; }, Error, { original: string; preview?: string or undefined; thumbnail?: string or undefined; metadata: Metadata; }, unknown>; mutateAsync: UseMutateAsy...` |
461
471
 
462
472
  Parameters:
463
473
 
@@ -508,13 +518,13 @@ Provides the progress of data sync for sync-enabled connected peers
508
518
 
509
519
  | Function | Type |
510
520
  | ---------- | ---------- |
511
- | `useStartSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { autostopDataSyncAfter: number or null; } or undefined, unknown>; reset: () => void; status: "error"; } or { ...; }` |
521
+ | `useStartSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { autostopDataSyncAfter: number or null; } or undefined, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
512
522
 
513
523
  ### useStopSync
514
524
 
515
525
  | Function | Type |
516
526
  | ---------- | ---------- |
517
- | `useStopSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, void, unknown>; reset: () => void; status: "error"; } or { error: null; mutate: UseMutateFunction<...>; reset: () => void; status: "pending" or ... 1 more ... or "idle"; }` |
527
+ | `useStopSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
518
528
 
519
529
  ### useSingleDocByDocId
520
530
 
@@ -524,7 +534,7 @@ Triggers the closest error boundary if the document cannot be found
524
534
 
525
535
  | Function | Type |
526
536
  | ---------- | ---------- |
527
- | `useSingleDocByDocId` | `<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "device_type_unspecified" or ... 4 more ... or "UNRECOGNIZED"; ... 7 more ...; deleted: b...` |
537
+ | `useSingleDocByDocId` | `<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "UNRECOGNIZED" or ... 4 more ... or "selfHostedServer"; ... 7 more ...; deleted: boolean;...` |
528
538
 
529
539
  Parameters:
530
540
 
@@ -557,7 +567,7 @@ Triggers the closest error boundary if the document cannot be found.
557
567
 
558
568
  | Function | Type |
559
569
  | ---------- | ---------- |
560
- | `useSingleDocByVersionId` | `<D extends WriteableDocumentType>({ projectId, docType, versionId, lang, }: { projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "device_type_unspecified" or ... 4 more ... or "UNRECOGNIZED"; ... 7 more ...; de...` |
570
+ | `useSingleDocByVersionId` | `<D extends WriteableDocumentType>({ projectId, docType, versionId, lang, }: { projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "UNRECOGNIZED" or ... 4 more ... or "selfHostedServer"; ... 7 more ...; deleted: ...` |
561
571
 
562
572
  Parameters:
563
573
 
@@ -590,7 +600,7 @@ Retrieve all documents of a specific `docType`.
590
600
 
591
601
  | Function | Type |
592
602
  | ---------- | ---------- |
593
- | `useManyDocs` | `<D extends WriteableDocumentType>({ projectId, docType, includeDeleted, lang, }: { projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => ReadHookResult<(Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "device_type_unspecified" or ... 4 more ... or "UNRECOGN...` |
603
+ | `useManyDocs` | `<D extends WriteableDocumentType>({ projectId, docType, includeDeleted, lang, }: { projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => ReadHookResult<(Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "UNRECOGNIZED" or ... 4 more ... or "selfHostedServer"; ...` |
594
604
 
595
605
  Parameters:
596
606
 
@@ -634,7 +644,7 @@ Create a document for a project.
634
644
 
635
645
  | Function | Type |
636
646
  | ---------- | ---------- |
637
- | `useCreateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
647
+ | `useCreateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
638
648
 
639
649
  Parameters:
640
650
 
@@ -648,7 +658,7 @@ Update a document within a project.
648
658
 
649
659
  | Function | Type |
650
660
  | ---------- | ---------- |
651
- | `useUpdateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
661
+ | `useUpdateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
652
662
 
653
663
  Parameters:
654
664
 
@@ -662,7 +672,7 @@ Delete a document within a project.
662
672
 
663
673
  | Function | Type |
664
674
  | ---------- | ---------- |
665
- | `useDeleteDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
675
+ | `useDeleteDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { error: Error; mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { ...; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
666
676
 
667
677
  Parameters:
668
678
 
@@ -670,13 +680,74 @@ Parameters:
670
680
  * `opts.projectId`: Public ID of project document belongs to.
671
681
 
672
682
 
683
+ ### useSetUpInvitesListeners
684
+
685
+ Set up listeners for received and updated invites.
686
+ It is necessary to use this if you want the invites-related read hooks to update
687
+ based on invites that are received or changed in the background.
688
+
689
+ | Function | Type |
690
+ | ---------- | ---------- |
691
+ | `useSetUpInvitesListeners` | `() => void` |
692
+
693
+ Examples:
694
+
695
+ ```tsx
696
+ function App() {
697
+ // Use this somewhere near the root of the application
698
+ useSetUpInvitesListeners()
699
+
700
+ return <RestOfApp />
701
+ }
702
+ ```
703
+
704
+
705
+ ### useManyInvites
706
+
707
+ Get all invites that the device has received.
708
+
709
+ | Function | Type |
710
+ | ---------- | ---------- |
711
+ | `useManyInvites` | `() => { data: Invite[]; error: Error or null; isRefetching: boolean; }` |
712
+
713
+ Examples:
714
+
715
+ ```ts
716
+ function Example() {
717
+ const { data } = useManyInvites()
718
+ }
719
+ ```
720
+
721
+
722
+ ### useSingleInvite
723
+
724
+ Get a single invite based on its ID.
725
+
726
+ | Function | Type |
727
+ | ---------- | ---------- |
728
+ | `useSingleInvite` | `({ inviteId }: { inviteId: string; }) => { data: Invite; error: Error or null; isRefetching: boolean; }` |
729
+
730
+ Parameters:
731
+
732
+ * `opts.inviteId`: ID of invite
733
+
734
+
735
+ Examples:
736
+
737
+ ```ts
738
+ function Example() {
739
+ const { data } = useSingleInvite({ inviteId: '...' })
740
+ }
741
+ ```
742
+
743
+
673
744
  ### useAcceptInvite
674
745
 
675
746
  Accept an invite that has been received.
676
747
 
677
748
  | Function | Type |
678
749
  | ---------- | ---------- |
679
- | `useAcceptInvite` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { error: null; mutate: UseMutateFunction<string, Error, { ...; }, unknown>; reset: () => void; status: "pending" or ... 1 more ... or "idle"; }` |
750
+ | `useAcceptInvite` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<string, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
680
751
 
681
752
  ### useRejectInvite
682
753
 
@@ -684,7 +755,7 @@ Reject an invite that has been received.
684
755
 
685
756
  | Function | Type |
686
757
  | ---------- | ---------- |
687
- | `useRejectInvite` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { error: null; mutate: UseMutateFunction<void, Error, { ...; }, unknown>; reset: () => void; status: "pending" or ... 1 more ... or "idle"; }` |
758
+ | `useRejectInvite` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
688
759
 
689
760
  ### useSendInvite
690
761
 
@@ -692,7 +763,7 @@ Send an invite for a project.
692
763
 
693
764
  | Function | Type |
694
765
  | ---------- | ---------- |
695
- | `useSendInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<"ACCEPT" or "REJECT" or "ALREADY", Error, { deviceId: string; roleDescription?: string or undefined; roleId: "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9"; roleName?: string or undefined; }, unknown>; reset: () => void; s...` |
766
+ | `useSendInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<"ACCEPT" or "REJECT" or "ALREADY", Error, { deviceId: string; roleDescription?: string or undefined; roleId: "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9"; roleName?: string or undefined; }, unknown>; mutateAsync: UseMuta...` |
696
767
 
697
768
  Parameters:
698
769
 
@@ -705,7 +776,7 @@ Request a cancellation of an invite sent to another device.
705
776
 
706
777
  | Function | Type |
707
778
  | ---------- | ---------- |
708
- | `useRequestCancelInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { deviceId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
779
+ | `useRequestCancelInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { deviceId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
709
780
 
710
781
  Parameters:
711
782
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comapeo/core-react",
3
- "version": "3.3.0",
3
+ "version": "4.1.0",
4
4
  "description": "React wrapper for working with @comapeo/core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,41 +57,44 @@
57
57
  "types": "tsc"
58
58
  },
59
59
  "peerDependencies": {
60
- "@comapeo/core": "*",
61
- "@comapeo/ipc": "*",
60
+ "@comapeo/core": "^3.1.0",
61
+ "@comapeo/ipc": "^3.0.0",
62
62
  "@comapeo/schema": "*",
63
63
  "@tanstack/react-query": "^5",
64
64
  "react": "^18 || ^19"
65
65
  },
66
66
  "devDependencies": {
67
- "@comapeo/core": "2.3.1",
68
- "@comapeo/ipc": "2.1.0",
69
- "@comapeo/schema": "1.4.1",
70
- "@eslint/compat": "1.2.7",
71
- "@eslint/js": "9.23.0",
67
+ "@comapeo/core": "3.1.1",
68
+ "@comapeo/ipc": "3.0.0",
69
+ "@comapeo/schema": "1.5.0",
70
+ "@eslint/compat": "1.2.9",
71
+ "@eslint/js": "9.26.0",
72
72
  "@ianvs/prettier-plugin-sort-imports": "4.4.1",
73
73
  "@mapeo/crypto": "1.0.0-alpha.10",
74
- "@tanstack/eslint-plugin-query": "5.68.0",
75
- "@tanstack/react-query": "5.69.0",
74
+ "@tanstack/eslint-plugin-query": "5.74.7",
75
+ "@tanstack/react-query": "5.75.2",
76
76
  "@testing-library/dom": "10.4.0",
77
- "@testing-library/react": "16.2.0",
78
- "@types/node": "22.13.13",
77
+ "@testing-library/react": "16.3.0",
78
+ "@types/node": "22.15.3",
79
79
  "@types/react": "19.0.12",
80
80
  "@types/react-dom": "19.0.4",
81
- "eslint": "9.23.0",
81
+ "@vitest/eslint-plugin": "1.1.44",
82
+ "eslint": "9.26.0",
82
83
  "eslint-plugin-react-hooks": "5.2.0",
84
+ "eslint-plugin-testing-library": "7.1.1",
83
85
  "fastify": "4.29.0",
84
86
  "globals": "16.0.0",
85
87
  "husky": "9.1.7",
86
- "lint-staged": "15.5.0",
88
+ "lint-staged": "15.5.1",
87
89
  "npm-run-all2": "7.0.2",
88
90
  "prettier": "3.5.3",
89
91
  "random-access-memory": "6.2.1",
90
92
  "react": "19.0.0",
93
+ "react-dom": "19.0.0",
91
94
  "tsdoc-markdown": "1.2.0",
92
95
  "tshy": "3.0.2",
93
- "typescript": "5.8.2",
94
- "typescript-eslint": "8.27.0",
95
- "vitest": "3.0.9"
96
+ "typescript": "5.8.3",
97
+ "typescript-eslint": "8.31.1",
98
+ "vitest": "3.1.3"
96
99
  }
97
100
  }