@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
|
@@ -1,17 +1,80 @@
|
|
|
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
|
*/
|
|
8
71
|
export function useAcceptInvite() {
|
|
9
72
|
const queryClient = useQueryClient();
|
|
10
73
|
const clientApi = useClientApi();
|
|
11
|
-
const { error, mutate, reset, status } = useMutation(acceptInviteMutationOptions({ clientApi, queryClient }));
|
|
74
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(acceptInviteMutationOptions({ clientApi, queryClient }));
|
|
12
75
|
return status === 'error'
|
|
13
|
-
? { error, mutate, reset, status }
|
|
14
|
-
: { error: null, mutate, reset, status };
|
|
76
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
77
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
15
78
|
}
|
|
16
79
|
/**
|
|
17
80
|
* Reject an invite that has been received.
|
|
@@ -19,10 +82,10 @@ export function useAcceptInvite() {
|
|
|
19
82
|
export function useRejectInvite() {
|
|
20
83
|
const queryClient = useQueryClient();
|
|
21
84
|
const clientApi = useClientApi();
|
|
22
|
-
const { error, mutate, reset, status } = useMutation(rejectInviteMutationOptions({ clientApi, queryClient }));
|
|
85
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(rejectInviteMutationOptions({ clientApi, queryClient }));
|
|
23
86
|
return status === 'error'
|
|
24
|
-
? { error, mutate, reset, status }
|
|
25
|
-
: { error: null, mutate, reset, status };
|
|
87
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
88
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
26
89
|
}
|
|
27
90
|
/**
|
|
28
91
|
* Send an invite for a project.
|
|
@@ -32,10 +95,10 @@ export function useRejectInvite() {
|
|
|
32
95
|
export function useSendInvite({ projectId }) {
|
|
33
96
|
const queryClient = useQueryClient();
|
|
34
97
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
35
|
-
const { error, mutate, reset, status } = useMutation(sendInviteMutationOptions({ projectApi, projectId, queryClient }));
|
|
98
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(sendInviteMutationOptions({ projectApi, projectId, queryClient }));
|
|
36
99
|
return status === 'error'
|
|
37
|
-
? { error, mutate, reset, status }
|
|
38
|
-
: { error: null, mutate, reset, status };
|
|
100
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
101
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
39
102
|
}
|
|
40
103
|
/**
|
|
41
104
|
* Request a cancellation of an invite sent to another device.
|
|
@@ -45,8 +108,8 @@ export function useSendInvite({ projectId }) {
|
|
|
45
108
|
export function useRequestCancelInvite({ projectId }) {
|
|
46
109
|
const queryClient = useQueryClient();
|
|
47
110
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
48
|
-
const { error, mutate, reset, status } = useMutation(requestCancelInviteMutationOptions({ projectApi, queryClient }));
|
|
111
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(requestCancelInviteMutationOptions({ projectApi, queryClient }));
|
|
49
112
|
return status === 'error'
|
|
50
|
-
? { error, mutate, reset, status }
|
|
51
|
-
: { error: null, mutate, reset, status };
|
|
113
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
114
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
52
115
|
}
|
|
@@ -280,6 +280,10 @@ export declare function useAddServerPeer({ projectId }: {
|
|
|
280
280
|
baseUrl: string;
|
|
281
281
|
dangerouslyAllowInsecureConnections?: boolean;
|
|
282
282
|
}, unknown>;
|
|
283
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
284
|
+
baseUrl: string;
|
|
285
|
+
dangerouslyAllowInsecureConnections?: boolean;
|
|
286
|
+
}, unknown>;
|
|
283
287
|
reset: () => void;
|
|
284
288
|
status: "error";
|
|
285
289
|
} | {
|
|
@@ -288,6 +292,10 @@ export declare function useAddServerPeer({ projectId }: {
|
|
|
288
292
|
baseUrl: string;
|
|
289
293
|
dangerouslyAllowInsecureConnections?: boolean;
|
|
290
294
|
}, unknown>;
|
|
295
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
296
|
+
baseUrl: string;
|
|
297
|
+
dangerouslyAllowInsecureConnections?: boolean;
|
|
298
|
+
}, unknown>;
|
|
291
299
|
reset: () => void;
|
|
292
300
|
status: "pending" | "success" | "idle";
|
|
293
301
|
};
|
|
@@ -300,6 +308,10 @@ export declare function useCreateProject(): {
|
|
|
300
308
|
name?: string;
|
|
301
309
|
configPath?: string;
|
|
302
310
|
} | undefined, unknown>;
|
|
311
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
312
|
+
name?: string;
|
|
313
|
+
configPath?: string;
|
|
314
|
+
} | undefined, unknown>;
|
|
303
315
|
reset: () => void;
|
|
304
316
|
status: "error";
|
|
305
317
|
} | {
|
|
@@ -308,6 +320,10 @@ export declare function useCreateProject(): {
|
|
|
308
320
|
name?: string;
|
|
309
321
|
configPath?: string;
|
|
310
322
|
} | undefined, unknown>;
|
|
323
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
324
|
+
name?: string;
|
|
325
|
+
configPath?: string;
|
|
326
|
+
} | undefined, unknown>;
|
|
311
327
|
reset: () => void;
|
|
312
328
|
status: "pending" | "success" | "idle";
|
|
313
329
|
};
|
|
@@ -319,6 +335,9 @@ export declare function useLeaveProject(): {
|
|
|
319
335
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
320
336
|
projectId: string;
|
|
321
337
|
}, unknown>;
|
|
338
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
339
|
+
projectId: string;
|
|
340
|
+
}, unknown>;
|
|
322
341
|
reset: () => void;
|
|
323
342
|
status: "error";
|
|
324
343
|
} | {
|
|
@@ -326,6 +345,9 @@ export declare function useLeaveProject(): {
|
|
|
326
345
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
327
346
|
projectId: string;
|
|
328
347
|
}, unknown>;
|
|
348
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
349
|
+
projectId: string;
|
|
350
|
+
}, unknown>;
|
|
329
351
|
reset: () => void;
|
|
330
352
|
status: "pending" | "success" | "idle";
|
|
331
353
|
};
|
|
@@ -341,6 +363,9 @@ export declare function useImportProjectConfig({ projectId }: {
|
|
|
341
363
|
mutate: import("@tanstack/react-query").UseMutateFunction<Error[], Error, {
|
|
342
364
|
configPath: string;
|
|
343
365
|
}, unknown>;
|
|
366
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Error[], Error, {
|
|
367
|
+
configPath: string;
|
|
368
|
+
}, unknown>;
|
|
344
369
|
reset: () => void;
|
|
345
370
|
status: "error";
|
|
346
371
|
} | {
|
|
@@ -348,6 +373,9 @@ export declare function useImportProjectConfig({ projectId }: {
|
|
|
348
373
|
mutate: import("@tanstack/react-query").UseMutateFunction<Error[], Error, {
|
|
349
374
|
configPath: string;
|
|
350
375
|
}, unknown>;
|
|
376
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<Error[], Error, {
|
|
377
|
+
configPath: string;
|
|
378
|
+
}, unknown>;
|
|
351
379
|
reset: () => void;
|
|
352
380
|
status: "pending" | "success" | "idle";
|
|
353
381
|
};
|
|
@@ -365,6 +393,11 @@ export declare function useUpdateProjectSettings({ projectId }: {
|
|
|
365
393
|
configMetadata?: import("@comapeo/schema").ProjectSettings["configMetadata"];
|
|
366
394
|
defaultPresets?: import("@comapeo/schema").ProjectSettings["defaultPresets"];
|
|
367
395
|
}, unknown>;
|
|
396
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@comapeo/core/dist/mapeo-project.js").EditableProjectSettings, Error, {
|
|
397
|
+
name?: import("@comapeo/schema").ProjectSettings["name"];
|
|
398
|
+
configMetadata?: import("@comapeo/schema").ProjectSettings["configMetadata"];
|
|
399
|
+
defaultPresets?: import("@comapeo/schema").ProjectSettings["defaultPresets"];
|
|
400
|
+
}, unknown>;
|
|
368
401
|
reset: () => void;
|
|
369
402
|
status: "error";
|
|
370
403
|
} | {
|
|
@@ -374,6 +407,11 @@ export declare function useUpdateProjectSettings({ projectId }: {
|
|
|
374
407
|
configMetadata?: import("@comapeo/schema").ProjectSettings["configMetadata"];
|
|
375
408
|
defaultPresets?: import("@comapeo/schema").ProjectSettings["defaultPresets"];
|
|
376
409
|
}, unknown>;
|
|
410
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@comapeo/core/dist/mapeo-project.js").EditableProjectSettings, Error, {
|
|
411
|
+
name?: import("@comapeo/schema").ProjectSettings["name"];
|
|
412
|
+
configMetadata?: import("@comapeo/schema").ProjectSettings["configMetadata"];
|
|
413
|
+
defaultPresets?: import("@comapeo/schema").ProjectSettings["defaultPresets"];
|
|
414
|
+
}, unknown>;
|
|
377
415
|
reset: () => void;
|
|
378
416
|
status: "pending" | "success" | "idle";
|
|
379
417
|
};
|
|
@@ -397,6 +435,17 @@ export declare function useCreateBlob({ projectId }: {
|
|
|
397
435
|
thumbnail?: string;
|
|
398
436
|
metadata: import("@comapeo/core/dist/blob-api.js").Metadata;
|
|
399
437
|
}, unknown>;
|
|
438
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
439
|
+
driveId: string;
|
|
440
|
+
name: string;
|
|
441
|
+
type: "photo" | "video" | "audio";
|
|
442
|
+
hash: string;
|
|
443
|
+
}, Error, {
|
|
444
|
+
original: string;
|
|
445
|
+
preview?: string;
|
|
446
|
+
thumbnail?: string;
|
|
447
|
+
metadata: import("@comapeo/core/dist/blob-api.js").Metadata;
|
|
448
|
+
}, unknown>;
|
|
400
449
|
reset: () => void;
|
|
401
450
|
status: "error";
|
|
402
451
|
} | {
|
|
@@ -412,6 +461,17 @@ export declare function useCreateBlob({ projectId }: {
|
|
|
412
461
|
thumbnail?: string;
|
|
413
462
|
metadata: import("@comapeo/core/dist/blob-api.js").Metadata;
|
|
414
463
|
}, unknown>;
|
|
464
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
465
|
+
driveId: string;
|
|
466
|
+
name: string;
|
|
467
|
+
type: "photo" | "video" | "audio";
|
|
468
|
+
hash: string;
|
|
469
|
+
}, Error, {
|
|
470
|
+
original: string;
|
|
471
|
+
preview?: string;
|
|
472
|
+
thumbnail?: string;
|
|
473
|
+
metadata: import("@comapeo/core/dist/blob-api.js").Metadata;
|
|
474
|
+
}, unknown>;
|
|
415
475
|
reset: () => void;
|
|
416
476
|
status: "pending" | "success" | "idle";
|
|
417
477
|
};
|
|
@@ -455,6 +515,9 @@ export declare function useStartSync({ projectId }: {
|
|
|
455
515
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
456
516
|
autostopDataSyncAfter: number | null;
|
|
457
517
|
} | undefined, unknown>;
|
|
518
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
519
|
+
autostopDataSyncAfter: number | null;
|
|
520
|
+
} | undefined, unknown>;
|
|
458
521
|
reset: () => void;
|
|
459
522
|
status: "error";
|
|
460
523
|
} | {
|
|
@@ -462,6 +525,9 @@ export declare function useStartSync({ projectId }: {
|
|
|
462
525
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
463
526
|
autostopDataSyncAfter: number | null;
|
|
464
527
|
} | undefined, unknown>;
|
|
528
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
529
|
+
autostopDataSyncAfter: number | null;
|
|
530
|
+
} | undefined, unknown>;
|
|
465
531
|
reset: () => void;
|
|
466
532
|
status: "pending" | "success" | "idle";
|
|
467
533
|
};
|
|
@@ -470,11 +536,13 @@ export declare function useStopSync({ projectId }: {
|
|
|
470
536
|
}): {
|
|
471
537
|
error: Error;
|
|
472
538
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, void, unknown>;
|
|
539
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, void, unknown>;
|
|
473
540
|
reset: () => void;
|
|
474
541
|
status: "error";
|
|
475
542
|
} | {
|
|
476
543
|
error: null;
|
|
477
544
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, void, unknown>;
|
|
545
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, void, unknown>;
|
|
478
546
|
reset: () => void;
|
|
479
547
|
status: "pending" | "success" | "idle";
|
|
480
548
|
};
|
|
@@ -271,10 +271,10 @@ export function useOwnRoleInProject({ projectId }) {
|
|
|
271
271
|
export function useAddServerPeer({ projectId }) {
|
|
272
272
|
const queryClient = useQueryClient();
|
|
273
273
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
274
|
-
const { error, mutate, reset, status } = useMutation(addServerPeerMutationOptions({ projectApi, projectId, queryClient }));
|
|
274
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(addServerPeerMutationOptions({ projectApi, projectId, queryClient }));
|
|
275
275
|
return status === 'error'
|
|
276
|
-
? { error, mutate, reset, status }
|
|
277
|
-
: { error: null, mutate, reset, status };
|
|
276
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
277
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
278
278
|
}
|
|
279
279
|
/**
|
|
280
280
|
* Create a new project.
|
|
@@ -282,10 +282,10 @@ export function useAddServerPeer({ projectId }) {
|
|
|
282
282
|
export function useCreateProject() {
|
|
283
283
|
const queryClient = useQueryClient();
|
|
284
284
|
const clientApi = useClientApi();
|
|
285
|
-
const { error, mutate, reset, status } = useMutation(createProjectMutationOptions({ clientApi, queryClient }));
|
|
285
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(createProjectMutationOptions({ clientApi, queryClient }));
|
|
286
286
|
return status === 'error'
|
|
287
|
-
? { error, mutate, reset, status }
|
|
288
|
-
: { error: null, mutate, reset, status };
|
|
287
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
288
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
291
291
|
* Leave an existing project.
|
|
@@ -293,10 +293,10 @@ export function useCreateProject() {
|
|
|
293
293
|
export function useLeaveProject() {
|
|
294
294
|
const queryClient = useQueryClient();
|
|
295
295
|
const clientApi = useClientApi();
|
|
296
|
-
const { error, mutate, reset, status } = useMutation(leaveProjectMutationOptions({ clientApi, queryClient }));
|
|
296
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(leaveProjectMutationOptions({ clientApi, queryClient }));
|
|
297
297
|
return status === 'error'
|
|
298
|
-
? { error, mutate, reset, status }
|
|
299
|
-
: { error: null, mutate, reset, status };
|
|
298
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
299
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
300
300
|
}
|
|
301
301
|
/**
|
|
302
302
|
* Update the configuration of a project using an external file.
|
|
@@ -306,10 +306,10 @@ export function useLeaveProject() {
|
|
|
306
306
|
export function useImportProjectConfig({ projectId }) {
|
|
307
307
|
const queryClient = useQueryClient();
|
|
308
308
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
309
|
-
const { error, mutate, reset, status } = useMutation(importProjectConfigMutationOptions({ queryClient, projectApi, projectId }));
|
|
309
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(importProjectConfigMutationOptions({ queryClient, projectApi, projectId }));
|
|
310
310
|
return status === 'error'
|
|
311
|
-
? { error, mutate, reset, status }
|
|
312
|
-
: { error: null, mutate, reset, status };
|
|
311
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
312
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
313
313
|
}
|
|
314
314
|
/**
|
|
315
315
|
* Update the settings of a project.
|
|
@@ -319,10 +319,10 @@ export function useImportProjectConfig({ projectId }) {
|
|
|
319
319
|
export function useUpdateProjectSettings({ projectId }) {
|
|
320
320
|
const queryClient = useQueryClient();
|
|
321
321
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
322
|
-
const { error, mutate, reset, status } = useMutation(updateProjectSettingsMutationOptions({ projectApi, queryClient }));
|
|
322
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(updateProjectSettingsMutationOptions({ projectApi, queryClient }));
|
|
323
323
|
return status === 'error'
|
|
324
|
-
? { error, mutate, reset, status }
|
|
325
|
-
: { error: null, mutate, reset, status };
|
|
324
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
325
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
326
326
|
}
|
|
327
327
|
/**
|
|
328
328
|
* Create a blob for a project.
|
|
@@ -331,10 +331,10 @@ export function useUpdateProjectSettings({ projectId }) {
|
|
|
331
331
|
*/
|
|
332
332
|
export function useCreateBlob({ projectId }) {
|
|
333
333
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
334
|
-
const { error, mutate, reset, status } = useMutation(createBlobMutationOptions({ projectApi }));
|
|
334
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(createBlobMutationOptions({ projectApi }));
|
|
335
335
|
return status === 'error'
|
|
336
|
-
? { error, mutate, reset, status }
|
|
337
|
-
: { error: null, mutate, reset, status };
|
|
336
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
337
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
338
338
|
}
|
|
339
339
|
const PROJECT_SYNC_STORE_MAP = new WeakMap();
|
|
340
340
|
function useSyncStore({ projectId }) {
|
|
@@ -384,15 +384,15 @@ export function useDataSyncProgress({ projectId, }) {
|
|
|
384
384
|
}
|
|
385
385
|
export function useStartSync({ projectId }) {
|
|
386
386
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
387
|
-
const { mutate, reset, status
|
|
387
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(startSyncMutationOptions({ projectApi }));
|
|
388
388
|
return status === 'error'
|
|
389
|
-
? { error, mutate, reset, status }
|
|
390
|
-
: { error: null, mutate, reset, status };
|
|
389
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
390
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
391
391
|
}
|
|
392
392
|
export function useStopSync({ projectId }) {
|
|
393
393
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
394
|
-
const { error, mutate, reset, status } = useMutation(stopSyncMutationOptions({ projectApi }));
|
|
394
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(stopSyncMutationOptions({ projectApi }));
|
|
395
395
|
return status === 'error'
|
|
396
|
-
? { error, mutate, reset, status }
|
|
397
|
-
: { error: null, mutate, reset, status };
|
|
396
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
397
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
398
398
|
}
|
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
|
}
|