@comapeo/core-react 3.3.0 → 4.0.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/commonjs/hooks/client.d.ts +1 -1
- package/dist/commonjs/hooks/invites.d.ts +50 -0
- package/dist/commonjs/hooks/invites.js +66 -0
- package/dist/commonjs/index.d.ts +1 -1
- package/dist/commonjs/index.js +4 -1
- package/dist/commonjs/lib/react-query/client.d.ts +4 -4
- package/dist/commonjs/lib/react-query/invites.d.ts +22 -9
- package/dist/commonjs/lib/react-query/invites.js +17 -7
- package/dist/esm/hooks/client.d.ts +1 -1
- package/dist/esm/hooks/invites.d.ts +50 -0
- package/dist/esm/hooks/invites.js +65 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/react-query/client.d.ts +4 -4
- package/dist/esm/lib/react-query/invites.d.ts +22 -9
- package/dist/esm/lib/react-query/invites.js +14 -5
- package/docs/API.md +85 -21
- package/package.json +5 -5
|
@@ -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"
|
|
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
|
*/
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
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';
|
|
7
7
|
export { type SyncState } from './lib/sync.js';
|
package/dist/commonjs/index.js
CHANGED
|
@@ -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.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");
|
|
@@ -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"
|
|
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"
|
|
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"
|
|
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"
|
|
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
|
|
6
|
-
|
|
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
|
|
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/
|
|
11
|
-
|
|
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/
|
|
14
|
-
readonly
|
|
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
|
|
31
|
+
readonly inviteId: string;
|
|
19
32
|
}] & {
|
|
20
|
-
[dataTagSymbol]: import("@comapeo/core/dist/
|
|
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.
|
|
5
|
-
exports.
|
|
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
|
|
17
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'invites', {
|
|
17
|
+
function getInvitesByIdQueryKey({ inviteId }) {
|
|
18
|
+
return [shared_js_1.ROOT_QUERY_KEY, 'invites', { inviteId }];
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function getInvitesQueryOptions({ clientApi, }) {
|
|
20
21
|
return (0, react_query_1.queryOptions)({
|
|
21
22
|
...(0, shared_js_1.baseQueryOptions)(),
|
|
22
|
-
queryKey:
|
|
23
|
+
queryKey: getInvitesQueryKey(),
|
|
23
24
|
queryFn: async () => {
|
|
24
|
-
return clientApi.invite.
|
|
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
|
}
|
|
@@ -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"
|
|
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 {
|
|
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
|
*/
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
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';
|
|
7
7
|
export { type SyncState } from './lib/sync.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
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';
|
|
@@ -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"
|
|
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"
|
|
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"
|
|
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"
|
|
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
|
|
6
|
-
|
|
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
|
|
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/
|
|
11
|
-
readonly
|
|
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/
|
|
14
|
-
readonly
|
|
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
|
|
31
|
+
readonly inviteId: string;
|
|
19
32
|
}] & {
|
|
20
|
-
[dataTagSymbol]: import("@comapeo/core/dist/
|
|
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
|
|
8
|
-
return [ROOT_QUERY_KEY, 'invites', {
|
|
7
|
+
export function getInvitesByIdQueryKey({ inviteId }) {
|
|
8
|
+
return [ROOT_QUERY_KEY, 'invites', { inviteId }];
|
|
9
9
|
}
|
|
10
|
-
export function
|
|
10
|
+
export function getInvitesQueryOptions({ clientApi, }) {
|
|
11
11
|
return queryOptions({
|
|
12
12
|
...baseQueryOptions(),
|
|
13
|
-
queryKey:
|
|
13
|
+
queryKey: getInvitesQueryKey(),
|
|
14
14
|
queryFn: async () => {
|
|
15
|
-
return clientApi.invite.
|
|
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
|
}
|
package/docs/API.md
CHANGED
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
- [useCreateDocument](#usecreatedocument)
|
|
32
32
|
- [useUpdateDocument](#useupdatedocument)
|
|
33
33
|
- [useDeleteDocument](#usedeletedocument)
|
|
34
|
+
- [useSetUpInvitesListeners](#usesetupinviteslisteners)
|
|
35
|
+
- [useManyInvites](#usemanyinvites)
|
|
36
|
+
- [useSingleInvite](#usesingleinvite)
|
|
34
37
|
- [useAcceptInvite](#useacceptinvite)
|
|
35
38
|
- [useRejectInvite](#userejectinvite)
|
|
36
39
|
- [useSendInvite](#usesendinvite)
|
|
@@ -86,7 +89,7 @@ Retrieve info about the current device.
|
|
|
86
89
|
|
|
87
90
|
| Function | Type |
|
|
88
91
|
| ---------- | ---------- |
|
|
89
|
-
| `useOwnDeviceInfo` | `() => { data: { deviceId: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer"
|
|
92
|
+
| `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
93
|
|
|
91
94
|
Examples:
|
|
92
95
|
|
|
@@ -120,7 +123,7 @@ Update the device info for the current device.
|
|
|
120
123
|
|
|
121
124
|
| Function | Type |
|
|
122
125
|
| ---------- | ---------- |
|
|
123
|
-
| `useSetOwnDeviceInfo` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { name: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer"
|
|
126
|
+
| `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
127
|
|
|
125
128
|
### useSetIsArchiveDevice
|
|
126
129
|
|
|
@@ -128,7 +131,7 @@ Set or unset the current device as an archive device.
|
|
|
128
131
|
|
|
129
132
|
| Function | Type |
|
|
130
133
|
| ---------- | ---------- |
|
|
131
|
-
| `useSetIsArchiveDevice` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { isArchiveDevice: boolean; }, unknown>;
|
|
134
|
+
| `useSetIsArchiveDevice` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
132
135
|
|
|
133
136
|
### useProjectSettings
|
|
134
137
|
|
|
@@ -407,7 +410,7 @@ function BasicExample() {
|
|
|
407
410
|
|
|
408
411
|
| Function | Type |
|
|
409
412
|
| ---------- | ---------- |
|
|
410
|
-
| `useAddServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { baseUrl: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
413
|
+
| `useAddServerPeer` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { baseUrl: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error"; } or { ...; }` |
|
|
411
414
|
|
|
412
415
|
### useCreateProject
|
|
413
416
|
|
|
@@ -415,7 +418,7 @@ Create a new project.
|
|
|
415
418
|
|
|
416
419
|
| Function | Type |
|
|
417
420
|
| ---------- | ---------- |
|
|
418
|
-
| `useCreateProject` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { name?: string or undefined; configPath?: string or undefined; } or undefined, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
421
|
+
| `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
422
|
|
|
420
423
|
### useLeaveProject
|
|
421
424
|
|
|
@@ -423,7 +426,7 @@ Leave an existing project.
|
|
|
423
426
|
|
|
424
427
|
| Function | Type |
|
|
425
428
|
| ---------- | ---------- |
|
|
426
|
-
| `useLeaveProject` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { projectId: string; }, unknown>;
|
|
429
|
+
| `useLeaveProject` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { projectId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { projectId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
427
430
|
|
|
428
431
|
### useImportProjectConfig
|
|
429
432
|
|
|
@@ -431,7 +434,7 @@ Update the configuration of a project using an external file.
|
|
|
431
434
|
|
|
432
435
|
| Function | Type |
|
|
433
436
|
| ---------- | ---------- |
|
|
434
|
-
| `useImportProjectConfig` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<Error[], Error, { configPath: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
437
|
+
| `useImportProjectConfig` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<Error[], Error, { configPath: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<Error[], Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
435
438
|
|
|
436
439
|
Parameters:
|
|
437
440
|
|
|
@@ -444,7 +447,7 @@ Update the settings of a project.
|
|
|
444
447
|
|
|
445
448
|
| Function | Type |
|
|
446
449
|
| ---------- | ---------- |
|
|
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"; }
|
|
450
|
+
| `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
451
|
|
|
449
452
|
Parameters:
|
|
450
453
|
|
|
@@ -457,7 +460,7 @@ Create a blob for a project.
|
|
|
457
460
|
|
|
458
461
|
| Function | Type |
|
|
459
462
|
| ---------- | ---------- |
|
|
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>;
|
|
463
|
+
| `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
464
|
|
|
462
465
|
Parameters:
|
|
463
466
|
|
|
@@ -508,13 +511,13 @@ Provides the progress of data sync for sync-enabled connected peers
|
|
|
508
511
|
|
|
509
512
|
| Function | Type |
|
|
510
513
|
| ---------- | ---------- |
|
|
511
|
-
| `useStartSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { autostopDataSyncAfter: number or null; } or undefined, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
514
|
+
| `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
515
|
|
|
513
516
|
### useStopSync
|
|
514
517
|
|
|
515
518
|
| Function | Type |
|
|
516
519
|
| ---------- | ---------- |
|
|
517
|
-
| `useStopSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, void, unknown>;
|
|
520
|
+
| `useStopSync` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, void, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, void, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
518
521
|
|
|
519
522
|
### useSingleDocByDocId
|
|
520
523
|
|
|
@@ -524,7 +527,7 @@ Triggers the closest error boundary if the document cannot be found
|
|
|
524
527
|
|
|
525
528
|
| Function | Type |
|
|
526
529
|
| ---------- | ---------- |
|
|
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: "
|
|
530
|
+
| `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
531
|
|
|
529
532
|
Parameters:
|
|
530
533
|
|
|
@@ -557,7 +560,7 @@ Triggers the closest error boundary if the document cannot be found.
|
|
|
557
560
|
|
|
558
561
|
| Function | Type |
|
|
559
562
|
| ---------- | ---------- |
|
|
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: "
|
|
563
|
+
| `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
564
|
|
|
562
565
|
Parameters:
|
|
563
566
|
|
|
@@ -590,7 +593,7 @@ Retrieve all documents of a specific `docType`.
|
|
|
590
593
|
|
|
591
594
|
| Function | Type |
|
|
592
595
|
| ---------- | ---------- |
|
|
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: "
|
|
596
|
+
| `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
597
|
|
|
595
598
|
Parameters:
|
|
596
599
|
|
|
@@ -634,7 +637,7 @@ Create a document for a project.
|
|
|
634
637
|
|
|
635
638
|
| Function | Type |
|
|
636
639
|
| ---------- | ---------- |
|
|
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 { ...; }` |
|
|
640
|
+
| `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
641
|
|
|
639
642
|
Parameters:
|
|
640
643
|
|
|
@@ -648,7 +651,7 @@ Update a document within a project.
|
|
|
648
651
|
|
|
649
652
|
| Function | Type |
|
|
650
653
|
| ---------- | ---------- |
|
|
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 { ...; }` |
|
|
654
|
+
| `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
655
|
|
|
653
656
|
Parameters:
|
|
654
657
|
|
|
@@ -662,7 +665,7 @@ Delete a document within a project.
|
|
|
662
665
|
|
|
663
666
|
| Function | Type |
|
|
664
667
|
| ---------- | ---------- |
|
|
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 { ...; }` |
|
|
668
|
+
| `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
669
|
|
|
667
670
|
Parameters:
|
|
668
671
|
|
|
@@ -670,13 +673,74 @@ Parameters:
|
|
|
670
673
|
* `opts.projectId`: Public ID of project document belongs to.
|
|
671
674
|
|
|
672
675
|
|
|
676
|
+
### useSetUpInvitesListeners
|
|
677
|
+
|
|
678
|
+
Set up listeners for received and updated invites.
|
|
679
|
+
It is necessary to use this if you want the invites-related read hooks to update
|
|
680
|
+
based on invites that are received or changed in the background.
|
|
681
|
+
|
|
682
|
+
| Function | Type |
|
|
683
|
+
| ---------- | ---------- |
|
|
684
|
+
| `useSetUpInvitesListeners` | `() => void` |
|
|
685
|
+
|
|
686
|
+
Examples:
|
|
687
|
+
|
|
688
|
+
```tsx
|
|
689
|
+
function App() {
|
|
690
|
+
// Use this somewhere near the root of the application
|
|
691
|
+
useSetUpInvitesListeners()
|
|
692
|
+
|
|
693
|
+
return <RestOfApp />
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
### useManyInvites
|
|
699
|
+
|
|
700
|
+
Get all invites that the device has received.
|
|
701
|
+
|
|
702
|
+
| Function | Type |
|
|
703
|
+
| ---------- | ---------- |
|
|
704
|
+
| `useManyInvites` | `() => { data: Invite[]; error: Error or null; isRefetching: boolean; }` |
|
|
705
|
+
|
|
706
|
+
Examples:
|
|
707
|
+
|
|
708
|
+
```ts
|
|
709
|
+
function Example() {
|
|
710
|
+
const { data } = useManyInvites()
|
|
711
|
+
}
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
### useSingleInvite
|
|
716
|
+
|
|
717
|
+
Get a single invite based on its ID.
|
|
718
|
+
|
|
719
|
+
| Function | Type |
|
|
720
|
+
| ---------- | ---------- |
|
|
721
|
+
| `useSingleInvite` | `({ inviteId }: { inviteId: string; }) => { data: Invite; error: Error or null; isRefetching: boolean; }` |
|
|
722
|
+
|
|
723
|
+
Parameters:
|
|
724
|
+
|
|
725
|
+
* `opts.inviteId`: ID of invite
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
Examples:
|
|
729
|
+
|
|
730
|
+
```ts
|
|
731
|
+
function Example() {
|
|
732
|
+
const { data } = useSingleInvite({ inviteId: '...' })
|
|
733
|
+
}
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
|
|
673
737
|
### useAcceptInvite
|
|
674
738
|
|
|
675
739
|
Accept an invite that has been received.
|
|
676
740
|
|
|
677
741
|
| Function | Type |
|
|
678
742
|
| ---------- | ---------- |
|
|
679
|
-
| `useAcceptInvite` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { inviteId: string; }, unknown>;
|
|
743
|
+
| `useAcceptInvite` | `() => { error: Error; mutate: UseMutateFunction<string, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<string, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
680
744
|
|
|
681
745
|
### useRejectInvite
|
|
682
746
|
|
|
@@ -684,7 +748,7 @@ Reject an invite that has been received.
|
|
|
684
748
|
|
|
685
749
|
| Function | Type |
|
|
686
750
|
| ---------- | ---------- |
|
|
687
|
-
| `useRejectInvite` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { inviteId: string; }, unknown>;
|
|
751
|
+
| `useRejectInvite` | `() => { error: Error; mutate: UseMutateFunction<void, Error, { inviteId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { inviteId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
688
752
|
|
|
689
753
|
### useSendInvite
|
|
690
754
|
|
|
@@ -692,7 +756,7 @@ Send an invite for a project.
|
|
|
692
756
|
|
|
693
757
|
| Function | Type |
|
|
694
758
|
| ---------- | ---------- |
|
|
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>;
|
|
759
|
+
| `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
760
|
|
|
697
761
|
Parameters:
|
|
698
762
|
|
|
@@ -705,7 +769,7 @@ Request a cancellation of an invite sent to another device.
|
|
|
705
769
|
|
|
706
770
|
| Function | Type |
|
|
707
771
|
| ---------- | ---------- |
|
|
708
|
-
| `useRequestCancelInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { deviceId: string; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
772
|
+
| `useRequestCancelInvite` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { deviceId: string; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
|
|
709
773
|
|
|
710
774
|
Parameters:
|
|
711
775
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comapeo/core-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "React wrapper for working with @comapeo/core",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
"types": "tsc"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@comapeo/core": "
|
|
61
|
-
"@comapeo/ipc": "
|
|
60
|
+
"@comapeo/core": "^3.0.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": "
|
|
68
|
-
"@comapeo/ipc": "
|
|
67
|
+
"@comapeo/core": "3.0.0",
|
|
68
|
+
"@comapeo/ipc": "3.0.0",
|
|
69
69
|
"@comapeo/schema": "1.4.1",
|
|
70
70
|
"@eslint/compat": "1.2.7",
|
|
71
71
|
"@eslint/js": "9.23.0",
|