@comapeo/core-react 3.2.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 +15 -1
- package/dist/commonjs/hooks/client.js +6 -6
- package/dist/commonjs/hooks/documents.d.ts +32 -0
- package/dist/commonjs/hooks/documents.js +9 -9
- package/dist/commonjs/hooks/invites.d.ts +80 -0
- package/dist/commonjs/hooks/invites.js +78 -12
- package/dist/commonjs/hooks/projects.d.ts +68 -0
- package/dist/commonjs/hooks/projects.js +24 -24
- 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 +15 -1
- package/dist/esm/hooks/client.js +6 -6
- package/dist/esm/hooks/documents.d.ts +32 -0
- package/dist/esm/hooks/documents.js +9 -9
- package/dist/esm/hooks/invites.d.ts +80 -0
- package/dist/esm/hooks/invites.js +77 -14
- package/dist/esm/hooks/projects.d.ts +68 -0
- package/dist/esm/hooks/projects.js +24 -24
- 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 +6 -5
|
@@ -292,10 +292,10 @@ function useOwnRoleInProject({ projectId }) {
|
|
|
292
292
|
function useAddServerPeer({ projectId }) {
|
|
293
293
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
294
294
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
295
|
-
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.addServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
|
|
295
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.addServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
|
|
296
296
|
return status === 'error'
|
|
297
|
-
? { error, mutate, reset, status }
|
|
298
|
-
: { error: null, mutate, reset, status };
|
|
297
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
298
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
301
|
* Create a new project.
|
|
@@ -303,10 +303,10 @@ function useAddServerPeer({ projectId }) {
|
|
|
303
303
|
function useCreateProject() {
|
|
304
304
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
305
305
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
306
|
-
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createProjectMutationOptions)({ clientApi, queryClient }));
|
|
306
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createProjectMutationOptions)({ clientApi, queryClient }));
|
|
307
307
|
return status === 'error'
|
|
308
|
-
? { error, mutate, reset, status }
|
|
309
|
-
: { error: null, mutate, reset, status };
|
|
308
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
309
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* Leave an existing project.
|
|
@@ -314,10 +314,10 @@ function useCreateProject() {
|
|
|
314
314
|
function useLeaveProject() {
|
|
315
315
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
316
316
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
317
|
-
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.leaveProjectMutationOptions)({ clientApi, queryClient }));
|
|
317
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.leaveProjectMutationOptions)({ clientApi, queryClient }));
|
|
318
318
|
return status === 'error'
|
|
319
|
-
? { error, mutate, reset, status }
|
|
320
|
-
: { error: null, mutate, reset, status };
|
|
319
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
320
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
323
323
|
* Update the configuration of a project using an external file.
|
|
@@ -327,10 +327,10 @@ function useLeaveProject() {
|
|
|
327
327
|
function useImportProjectConfig({ projectId }) {
|
|
328
328
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
329
329
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
330
|
-
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.importProjectConfigMutationOptions)({ queryClient, projectApi, projectId }));
|
|
330
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.importProjectConfigMutationOptions)({ queryClient, projectApi, projectId }));
|
|
331
331
|
return status === 'error'
|
|
332
|
-
? { error, mutate, reset, status }
|
|
333
|
-
: { error: null, mutate, reset, status };
|
|
332
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
333
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
334
334
|
}
|
|
335
335
|
/**
|
|
336
336
|
* Update the settings of a project.
|
|
@@ -340,10 +340,10 @@ function useImportProjectConfig({ projectId }) {
|
|
|
340
340
|
function useUpdateProjectSettings({ projectId }) {
|
|
341
341
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
342
342
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
343
|
-
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.updateProjectSettingsMutationOptions)({ projectApi, queryClient }));
|
|
343
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.updateProjectSettingsMutationOptions)({ projectApi, queryClient }));
|
|
344
344
|
return status === 'error'
|
|
345
|
-
? { error, mutate, reset, status }
|
|
346
|
-
: { error: null, mutate, reset, status };
|
|
345
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
346
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
349
349
|
* Create a blob for a project.
|
|
@@ -352,10 +352,10 @@ function useUpdateProjectSettings({ projectId }) {
|
|
|
352
352
|
*/
|
|
353
353
|
function useCreateBlob({ projectId }) {
|
|
354
354
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
355
|
-
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createBlobMutationOptions)({ projectApi }));
|
|
355
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createBlobMutationOptions)({ projectApi }));
|
|
356
356
|
return status === 'error'
|
|
357
|
-
? { error, mutate, reset, status }
|
|
358
|
-
: { error: null, mutate, reset, status };
|
|
357
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
358
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
359
359
|
}
|
|
360
360
|
const PROJECT_SYNC_STORE_MAP = new WeakMap();
|
|
361
361
|
function useSyncStore({ projectId }) {
|
|
@@ -405,15 +405,15 @@ function useDataSyncProgress({ projectId, }) {
|
|
|
405
405
|
}
|
|
406
406
|
function useStartSync({ projectId }) {
|
|
407
407
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
408
|
-
const { mutate, reset, status
|
|
408
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.startSyncMutationOptions)({ projectApi }));
|
|
409
409
|
return status === 'error'
|
|
410
|
-
? { error, mutate, reset, status }
|
|
411
|
-
: { error: null, mutate, reset, status };
|
|
410
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
411
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
412
412
|
}
|
|
413
413
|
function useStopSync({ projectId }) {
|
|
414
414
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
415
|
-
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.stopSyncMutationOptions)({ projectApi }));
|
|
415
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.stopSyncMutationOptions)({ projectApi }));
|
|
416
416
|
return status === 'error'
|
|
417
|
-
? { error, mutate, reset, status }
|
|
418
|
-
: { error: null, mutate, reset, status };
|
|
417
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
418
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
419
419
|
}
|
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;
|
|
@@ -66,6 +66,10 @@ export declare function useSetOwnDeviceInfo(): {
|
|
|
66
66
|
name: string;
|
|
67
67
|
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
68
68
|
}, unknown>;
|
|
69
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
70
|
+
name: string;
|
|
71
|
+
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
72
|
+
}, unknown>;
|
|
69
73
|
reset: () => void;
|
|
70
74
|
status: "error";
|
|
71
75
|
} | {
|
|
@@ -74,6 +78,10 @@ export declare function useSetOwnDeviceInfo(): {
|
|
|
74
78
|
name: string;
|
|
75
79
|
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
76
80
|
}, unknown>;
|
|
81
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
82
|
+
name: string;
|
|
83
|
+
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
84
|
+
}, unknown>;
|
|
77
85
|
reset: () => void;
|
|
78
86
|
status: "pending" | "success" | "idle";
|
|
79
87
|
};
|
|
@@ -85,6 +93,9 @@ export declare function useSetIsArchiveDevice(): {
|
|
|
85
93
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
86
94
|
isArchiveDevice: boolean;
|
|
87
95
|
}, unknown>;
|
|
96
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
97
|
+
isArchiveDevice: boolean;
|
|
98
|
+
}, unknown>;
|
|
88
99
|
reset: () => void;
|
|
89
100
|
status: "error";
|
|
90
101
|
} | {
|
|
@@ -92,6 +103,9 @@ export declare function useSetIsArchiveDevice(): {
|
|
|
92
103
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
93
104
|
isArchiveDevice: boolean;
|
|
94
105
|
}, unknown>;
|
|
106
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
107
|
+
isArchiveDevice: boolean;
|
|
108
|
+
}, unknown>;
|
|
95
109
|
reset: () => void;
|
|
96
110
|
status: "pending" | "success" | "idle";
|
|
97
111
|
};
|
package/dist/esm/hooks/client.js
CHANGED
|
@@ -70,10 +70,10 @@ export function useIsArchiveDevice() {
|
|
|
70
70
|
export function useSetOwnDeviceInfo() {
|
|
71
71
|
const queryClient = useQueryClient();
|
|
72
72
|
const clientApi = useClientApi();
|
|
73
|
-
const { error, mutate, reset, status } = useMutation(setOwnDeviceInfoMutationOptions({ clientApi, queryClient }));
|
|
73
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(setOwnDeviceInfoMutationOptions({ clientApi, queryClient }));
|
|
74
74
|
return status === 'error'
|
|
75
|
-
? { error, mutate, reset, status }
|
|
76
|
-
: { error: null, mutate, reset, status };
|
|
75
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
76
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Set or unset the current device as an archive device.
|
|
@@ -81,8 +81,8 @@ export function useSetOwnDeviceInfo() {
|
|
|
81
81
|
export function useSetIsArchiveDevice() {
|
|
82
82
|
const queryClient = useQueryClient();
|
|
83
83
|
const clientApi = useClientApi();
|
|
84
|
-
const { error, mutate, status, reset } = useMutation(setIsArchiveDeviceMutationOptions({ clientApi, queryClient }));
|
|
84
|
+
const { error, mutate, mutateAsync, status, reset } = useMutation(setIsArchiveDeviceMutationOptions({ clientApi, queryClient }));
|
|
85
85
|
return status === 'error'
|
|
86
|
-
? { error, mutate, reset, status }
|
|
87
|
-
: { error: null, mutate, reset, status };
|
|
86
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
87
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
88
88
|
}
|
|
@@ -125,6 +125,11 @@ export declare function useCreateDocument<D extends WriteableDocumentType>({ doc
|
|
|
125
125
|
}, Error, {
|
|
126
126
|
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
127
127
|
}, unknown>;
|
|
128
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
129
|
+
forks: Array<string>;
|
|
130
|
+
}, Error, {
|
|
131
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
132
|
+
}, unknown>;
|
|
128
133
|
reset: () => void;
|
|
129
134
|
status: "error";
|
|
130
135
|
} | {
|
|
@@ -134,6 +139,11 @@ export declare function useCreateDocument<D extends WriteableDocumentType>({ doc
|
|
|
134
139
|
}, Error, {
|
|
135
140
|
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
136
141
|
}, unknown>;
|
|
142
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
143
|
+
forks: Array<string>;
|
|
144
|
+
}, Error, {
|
|
145
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
146
|
+
}, unknown>;
|
|
137
147
|
reset: () => void;
|
|
138
148
|
status: "pending" | "success" | "idle";
|
|
139
149
|
};
|
|
@@ -154,6 +164,12 @@ export declare function useUpdateDocument<D extends WriteableDocumentType>({ doc
|
|
|
154
164
|
versionId: string;
|
|
155
165
|
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
156
166
|
}, unknown>;
|
|
167
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
168
|
+
forks: Array<string>;
|
|
169
|
+
}, Error, {
|
|
170
|
+
versionId: string;
|
|
171
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
172
|
+
}, unknown>;
|
|
157
173
|
reset: () => void;
|
|
158
174
|
status: "error";
|
|
159
175
|
} | {
|
|
@@ -164,6 +180,12 @@ export declare function useUpdateDocument<D extends WriteableDocumentType>({ doc
|
|
|
164
180
|
versionId: string;
|
|
165
181
|
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
166
182
|
}, unknown>;
|
|
183
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
184
|
+
forks: Array<string>;
|
|
185
|
+
}, Error, {
|
|
186
|
+
versionId: string;
|
|
187
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
188
|
+
}, unknown>;
|
|
167
189
|
reset: () => void;
|
|
168
190
|
status: "pending" | "success" | "idle";
|
|
169
191
|
};
|
|
@@ -183,6 +205,11 @@ export declare function useDeleteDocument<D extends WriteableDocumentType>({ doc
|
|
|
183
205
|
}, Error, {
|
|
184
206
|
docId: string;
|
|
185
207
|
}, unknown>;
|
|
208
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
209
|
+
forks: Array<string>;
|
|
210
|
+
}, Error, {
|
|
211
|
+
docId: string;
|
|
212
|
+
}, unknown>;
|
|
186
213
|
reset: () => void;
|
|
187
214
|
status: "error";
|
|
188
215
|
} | {
|
|
@@ -192,6 +219,11 @@ export declare function useDeleteDocument<D extends WriteableDocumentType>({ doc
|
|
|
192
219
|
}, Error, {
|
|
193
220
|
docId: string;
|
|
194
221
|
}, unknown>;
|
|
222
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
223
|
+
forks: Array<string>;
|
|
224
|
+
}, Error, {
|
|
225
|
+
docId: string;
|
|
226
|
+
}, unknown>;
|
|
195
227
|
reset: () => void;
|
|
196
228
|
status: "pending" | "success" | "idle";
|
|
197
229
|
};
|
|
@@ -140,15 +140,15 @@ export function useManyDocs({ projectId, docType, includeDeleted, lang, }) {
|
|
|
140
140
|
export function useCreateDocument({ docType, projectId, }) {
|
|
141
141
|
const queryClient = useQueryClient();
|
|
142
142
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
143
|
-
const { error, mutate, reset, status } = useMutation(createDocumentMutationOptions({
|
|
143
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(createDocumentMutationOptions({
|
|
144
144
|
docType,
|
|
145
145
|
projectApi,
|
|
146
146
|
projectId,
|
|
147
147
|
queryClient,
|
|
148
148
|
}));
|
|
149
149
|
return status === 'error'
|
|
150
|
-
? { error, mutate, reset, status }
|
|
151
|
-
: { error: null, mutate, reset, status };
|
|
150
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
151
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Update a document within a project.
|
|
@@ -159,15 +159,15 @@ export function useCreateDocument({ docType, projectId, }) {
|
|
|
159
159
|
export function useUpdateDocument({ docType, projectId, }) {
|
|
160
160
|
const queryClient = useQueryClient();
|
|
161
161
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
162
|
-
const { error, mutate, reset, status } = useMutation(updateDocumentMutationOptions({
|
|
162
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(updateDocumentMutationOptions({
|
|
163
163
|
docType,
|
|
164
164
|
projectApi,
|
|
165
165
|
projectId,
|
|
166
166
|
queryClient,
|
|
167
167
|
}));
|
|
168
168
|
return status === 'error'
|
|
169
|
-
? { error, mutate, reset, status }
|
|
170
|
-
: { error: null, mutate, reset, status };
|
|
169
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
170
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* Delete a document within a project.
|
|
@@ -178,13 +178,13 @@ export function useUpdateDocument({ docType, projectId, }) {
|
|
|
178
178
|
export function useDeleteDocument({ docType, projectId, }) {
|
|
179
179
|
const queryClient = useQueryClient();
|
|
180
180
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
181
|
-
const { error, mutate, reset, status } = useMutation(deleteDocumentMutationOptions({
|
|
181
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(deleteDocumentMutationOptions({
|
|
182
182
|
docType,
|
|
183
183
|
projectApi,
|
|
184
184
|
projectId,
|
|
185
185
|
queryClient,
|
|
186
186
|
}));
|
|
187
187
|
return status === 'error'
|
|
188
|
-
? { error, mutate, reset, status }
|
|
189
|
-
: { error: null, mutate, reset, status };
|
|
188
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
189
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
190
190
|
}
|
|
@@ -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
|
*/
|
|
@@ -6,6 +56,9 @@ export declare function useAcceptInvite(): {
|
|
|
6
56
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
7
57
|
inviteId: string;
|
|
8
58
|
}, unknown>;
|
|
59
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
60
|
+
inviteId: string;
|
|
61
|
+
}, unknown>;
|
|
9
62
|
reset: () => void;
|
|
10
63
|
status: "error";
|
|
11
64
|
} | {
|
|
@@ -13,6 +66,9 @@ export declare function useAcceptInvite(): {
|
|
|
13
66
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
14
67
|
inviteId: string;
|
|
15
68
|
}, unknown>;
|
|
69
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
70
|
+
inviteId: string;
|
|
71
|
+
}, unknown>;
|
|
16
72
|
reset: () => void;
|
|
17
73
|
status: "pending" | "success" | "idle";
|
|
18
74
|
};
|
|
@@ -24,6 +80,9 @@ export declare function useRejectInvite(): {
|
|
|
24
80
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
25
81
|
inviteId: string;
|
|
26
82
|
}, unknown>;
|
|
83
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
84
|
+
inviteId: string;
|
|
85
|
+
}, unknown>;
|
|
27
86
|
reset: () => void;
|
|
28
87
|
status: "error";
|
|
29
88
|
} | {
|
|
@@ -31,6 +90,9 @@ export declare function useRejectInvite(): {
|
|
|
31
90
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
32
91
|
inviteId: string;
|
|
33
92
|
}, unknown>;
|
|
93
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
94
|
+
inviteId: string;
|
|
95
|
+
}, unknown>;
|
|
34
96
|
reset: () => void;
|
|
35
97
|
status: "pending" | "success" | "idle";
|
|
36
98
|
};
|
|
@@ -49,6 +111,12 @@ export declare function useSendInvite({ projectId }: {
|
|
|
49
111
|
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
50
112
|
roleName?: string;
|
|
51
113
|
}, unknown>;
|
|
114
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
115
|
+
deviceId: string;
|
|
116
|
+
roleDescription?: string;
|
|
117
|
+
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
118
|
+
roleName?: string;
|
|
119
|
+
}, unknown>;
|
|
52
120
|
reset: () => void;
|
|
53
121
|
status: "error";
|
|
54
122
|
} | {
|
|
@@ -59,6 +127,12 @@ export declare function useSendInvite({ projectId }: {
|
|
|
59
127
|
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
60
128
|
roleName?: string;
|
|
61
129
|
}, unknown>;
|
|
130
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
131
|
+
deviceId: string;
|
|
132
|
+
roleDescription?: string;
|
|
133
|
+
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
134
|
+
roleName?: string;
|
|
135
|
+
}, unknown>;
|
|
62
136
|
reset: () => void;
|
|
63
137
|
status: "pending" | "success" | "idle";
|
|
64
138
|
};
|
|
@@ -74,6 +148,9 @@ export declare function useRequestCancelInvite({ projectId }: {
|
|
|
74
148
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
75
149
|
deviceId: string;
|
|
76
150
|
}, unknown>;
|
|
151
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
152
|
+
deviceId: string;
|
|
153
|
+
}, unknown>;
|
|
77
154
|
reset: () => void;
|
|
78
155
|
status: "error";
|
|
79
156
|
} | {
|
|
@@ -81,6 +158,9 @@ export declare function useRequestCancelInvite({ projectId }: {
|
|
|
81
158
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
82
159
|
deviceId: string;
|
|
83
160
|
}, unknown>;
|
|
161
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
162
|
+
deviceId: string;
|
|
163
|
+
}, unknown>;
|
|
84
164
|
reset: () => void;
|
|
85
165
|
status: "pending" | "success" | "idle";
|
|
86
166
|
};
|