@comapeo/core-react 3.1.0 → 3.3.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 +33 -2
- package/dist/commonjs/hooks/client.js +8 -4
- package/dist/commonjs/hooks/documents.d.ts +66 -3
- package/dist/commonjs/hooks/documents.js +12 -6
- package/dist/commonjs/hooks/invites.d.ts +69 -4
- package/dist/commonjs/hooks/invites.js +16 -8
- package/dist/commonjs/hooks/projects.d.ts +150 -8
- package/dist/commonjs/hooks/projects.js +32 -16
- package/dist/esm/hooks/client.d.ts +33 -2
- package/dist/esm/hooks/client.js +8 -4
- package/dist/esm/hooks/documents.d.ts +66 -3
- package/dist/esm/hooks/documents.js +12 -6
- package/dist/esm/hooks/invites.d.ts +69 -4
- package/dist/esm/hooks/invites.js +16 -8
- package/dist/esm/hooks/projects.d.ts +150 -8
- package/dist/esm/hooks/projects.js +32 -16
- package/docs/API.md +17 -17
- package/package.json +2 -1
|
@@ -292,8 +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 { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.addServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
|
|
296
|
-
return
|
|
295
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.addServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
|
|
296
|
+
return status === 'error'
|
|
297
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
298
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
297
299
|
}
|
|
298
300
|
/**
|
|
299
301
|
* Create a new project.
|
|
@@ -301,8 +303,10 @@ function useAddServerPeer({ projectId }) {
|
|
|
301
303
|
function useCreateProject() {
|
|
302
304
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
303
305
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
304
|
-
const { mutate,
|
|
305
|
-
return
|
|
306
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createProjectMutationOptions)({ clientApi, queryClient }));
|
|
307
|
+
return status === 'error'
|
|
308
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
309
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
306
310
|
}
|
|
307
311
|
/**
|
|
308
312
|
* Leave an existing project.
|
|
@@ -310,8 +314,10 @@ function useCreateProject() {
|
|
|
310
314
|
function useLeaveProject() {
|
|
311
315
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
312
316
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
313
|
-
const { mutate,
|
|
314
|
-
return
|
|
317
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.leaveProjectMutationOptions)({ clientApi, queryClient }));
|
|
318
|
+
return status === 'error'
|
|
319
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
320
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
315
321
|
}
|
|
316
322
|
/**
|
|
317
323
|
* Update the configuration of a project using an external file.
|
|
@@ -321,8 +327,10 @@ function useLeaveProject() {
|
|
|
321
327
|
function useImportProjectConfig({ projectId }) {
|
|
322
328
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
323
329
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
324
|
-
const { mutate,
|
|
325
|
-
return
|
|
330
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.importProjectConfigMutationOptions)({ queryClient, projectApi, projectId }));
|
|
331
|
+
return status === 'error'
|
|
332
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
333
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
326
334
|
}
|
|
327
335
|
/**
|
|
328
336
|
* Update the settings of a project.
|
|
@@ -332,8 +340,10 @@ function useImportProjectConfig({ projectId }) {
|
|
|
332
340
|
function useUpdateProjectSettings({ projectId }) {
|
|
333
341
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
334
342
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
335
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.updateProjectSettingsMutationOptions)({ projectApi, queryClient }));
|
|
336
|
-
return
|
|
343
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.updateProjectSettingsMutationOptions)({ projectApi, queryClient }));
|
|
344
|
+
return status === 'error'
|
|
345
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
346
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
337
347
|
}
|
|
338
348
|
/**
|
|
339
349
|
* Create a blob for a project.
|
|
@@ -342,8 +352,10 @@ function useUpdateProjectSettings({ projectId }) {
|
|
|
342
352
|
*/
|
|
343
353
|
function useCreateBlob({ projectId }) {
|
|
344
354
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
345
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createBlobMutationOptions)({ projectApi }));
|
|
346
|
-
return
|
|
355
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createBlobMutationOptions)({ projectApi }));
|
|
356
|
+
return status === 'error'
|
|
357
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
358
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
347
359
|
}
|
|
348
360
|
const PROJECT_SYNC_STORE_MAP = new WeakMap();
|
|
349
361
|
function useSyncStore({ projectId }) {
|
|
@@ -393,11 +405,15 @@ function useDataSyncProgress({ projectId, }) {
|
|
|
393
405
|
}
|
|
394
406
|
function useStartSync({ projectId }) {
|
|
395
407
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
396
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.startSyncMutationOptions)({ projectApi }));
|
|
397
|
-
return
|
|
408
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.startSyncMutationOptions)({ projectApi }));
|
|
409
|
+
return status === 'error'
|
|
410
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
411
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
398
412
|
}
|
|
399
413
|
function useStopSync({ projectId }) {
|
|
400
414
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
401
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.stopSyncMutationOptions)({ projectApi }));
|
|
402
|
-
return
|
|
415
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.stopSyncMutationOptions)({ projectApi }));
|
|
416
|
+
return status === 'error'
|
|
417
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
418
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
403
419
|
}
|
|
@@ -61,20 +61,51 @@ export declare function useIsArchiveDevice(): {
|
|
|
61
61
|
* Update the device info for the current device.
|
|
62
62
|
*/
|
|
63
63
|
export declare function useSetOwnDeviceInfo(): {
|
|
64
|
+
error: Error;
|
|
64
65
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
65
66
|
name: string;
|
|
66
67
|
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
67
68
|
}, unknown>;
|
|
69
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
70
|
+
name: string;
|
|
71
|
+
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
72
|
+
}, unknown>;
|
|
68
73
|
reset: () => void;
|
|
69
|
-
status: "
|
|
74
|
+
status: "error";
|
|
75
|
+
} | {
|
|
76
|
+
error: null;
|
|
77
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
78
|
+
name: string;
|
|
79
|
+
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
80
|
+
}, unknown>;
|
|
81
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
82
|
+
name: string;
|
|
83
|
+
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
84
|
+
}, unknown>;
|
|
85
|
+
reset: () => void;
|
|
86
|
+
status: "pending" | "success" | "idle";
|
|
70
87
|
};
|
|
71
88
|
/**
|
|
72
89
|
* Set or unset the current device as an archive device.
|
|
73
90
|
*/
|
|
74
91
|
export declare function useSetIsArchiveDevice(): {
|
|
92
|
+
error: Error;
|
|
75
93
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
76
94
|
isArchiveDevice: boolean;
|
|
77
95
|
}, unknown>;
|
|
96
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
97
|
+
isArchiveDevice: boolean;
|
|
98
|
+
}, unknown>;
|
|
99
|
+
reset: () => void;
|
|
100
|
+
status: "error";
|
|
101
|
+
} | {
|
|
102
|
+
error: null;
|
|
103
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
104
|
+
isArchiveDevice: boolean;
|
|
105
|
+
}, unknown>;
|
|
106
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
107
|
+
isArchiveDevice: boolean;
|
|
108
|
+
}, unknown>;
|
|
78
109
|
reset: () => void;
|
|
79
|
-
status: "pending" | "
|
|
110
|
+
status: "pending" | "success" | "idle";
|
|
80
111
|
};
|
package/dist/esm/hooks/client.js
CHANGED
|
@@ -70,8 +70,10 @@ export function useIsArchiveDevice() {
|
|
|
70
70
|
export function useSetOwnDeviceInfo() {
|
|
71
71
|
const queryClient = useQueryClient();
|
|
72
72
|
const clientApi = useClientApi();
|
|
73
|
-
const { mutate,
|
|
74
|
-
return
|
|
73
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(setOwnDeviceInfoMutationOptions({ clientApi, queryClient }));
|
|
74
|
+
return status === 'error'
|
|
75
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
76
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
79
|
* Set or unset the current device as an archive device.
|
|
@@ -79,6 +81,8 @@ export function useSetOwnDeviceInfo() {
|
|
|
79
81
|
export function useSetIsArchiveDevice() {
|
|
80
82
|
const queryClient = useQueryClient();
|
|
81
83
|
const clientApi = useClientApi();
|
|
82
|
-
const { mutate, status, reset } = useMutation(setIsArchiveDeviceMutationOptions({ clientApi, queryClient }));
|
|
83
|
-
return
|
|
84
|
+
const { error, mutate, mutateAsync, status, reset } = useMutation(setIsArchiveDeviceMutationOptions({ clientApi, queryClient }));
|
|
85
|
+
return status === 'error'
|
|
86
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
87
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
84
88
|
}
|
|
@@ -119,13 +119,33 @@ export declare function useCreateDocument<D extends WriteableDocumentType>({ doc
|
|
|
119
119
|
docType: D;
|
|
120
120
|
projectId: string;
|
|
121
121
|
}): {
|
|
122
|
+
error: Error;
|
|
122
123
|
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
123
124
|
forks: Array<string>;
|
|
124
125
|
}, Error, {
|
|
125
126
|
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
126
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>;
|
|
127
133
|
reset: () => void;
|
|
128
|
-
status: "
|
|
134
|
+
status: "error";
|
|
135
|
+
} | {
|
|
136
|
+
error: null;
|
|
137
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
138
|
+
forks: Array<string>;
|
|
139
|
+
}, Error, {
|
|
140
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
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>;
|
|
147
|
+
reset: () => void;
|
|
148
|
+
status: "pending" | "success" | "idle";
|
|
129
149
|
};
|
|
130
150
|
/**
|
|
131
151
|
* Update a document within a project.
|
|
@@ -137,14 +157,37 @@ export declare function useUpdateDocument<D extends WriteableDocumentType>({ doc
|
|
|
137
157
|
docType: D;
|
|
138
158
|
projectId: string;
|
|
139
159
|
}): {
|
|
160
|
+
error: Error;
|
|
140
161
|
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
141
162
|
forks: Array<string>;
|
|
142
163
|
}, Error, {
|
|
143
164
|
versionId: string;
|
|
144
165
|
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
145
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>;
|
|
146
173
|
reset: () => void;
|
|
147
|
-
status: "
|
|
174
|
+
status: "error";
|
|
175
|
+
} | {
|
|
176
|
+
error: null;
|
|
177
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
178
|
+
forks: Array<string>;
|
|
179
|
+
}, Error, {
|
|
180
|
+
versionId: string;
|
|
181
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
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>;
|
|
189
|
+
reset: () => void;
|
|
190
|
+
status: "pending" | "success" | "idle";
|
|
148
191
|
};
|
|
149
192
|
/**
|
|
150
193
|
* Delete a document within a project.
|
|
@@ -156,12 +199,32 @@ export declare function useDeleteDocument<D extends WriteableDocumentType>({ doc
|
|
|
156
199
|
docType: D;
|
|
157
200
|
projectId: string;
|
|
158
201
|
}): {
|
|
202
|
+
error: Error;
|
|
203
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
204
|
+
forks: Array<string>;
|
|
205
|
+
}, Error, {
|
|
206
|
+
docId: string;
|
|
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>;
|
|
213
|
+
reset: () => void;
|
|
214
|
+
status: "error";
|
|
215
|
+
} | {
|
|
216
|
+
error: null;
|
|
159
217
|
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
160
218
|
forks: Array<string>;
|
|
161
219
|
}, Error, {
|
|
162
220
|
docId: string;
|
|
163
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>;
|
|
164
227
|
reset: () => void;
|
|
165
|
-
status: "pending" | "
|
|
228
|
+
status: "pending" | "success" | "idle";
|
|
166
229
|
};
|
|
167
230
|
export {};
|
|
@@ -140,13 +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 { 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
|
-
return
|
|
149
|
+
return status === 'error'
|
|
150
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
151
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
150
152
|
}
|
|
151
153
|
/**
|
|
152
154
|
* Update a document within a project.
|
|
@@ -157,13 +159,15 @@ export function useCreateDocument({ docType, projectId, }) {
|
|
|
157
159
|
export function useUpdateDocument({ docType, projectId, }) {
|
|
158
160
|
const queryClient = useQueryClient();
|
|
159
161
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
160
|
-
const { mutate, reset, status } = useMutation(updateDocumentMutationOptions({
|
|
162
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(updateDocumentMutationOptions({
|
|
161
163
|
docType,
|
|
162
164
|
projectApi,
|
|
163
165
|
projectId,
|
|
164
166
|
queryClient,
|
|
165
167
|
}));
|
|
166
|
-
return
|
|
168
|
+
return status === 'error'
|
|
169
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
170
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
167
171
|
}
|
|
168
172
|
/**
|
|
169
173
|
* Delete a document within a project.
|
|
@@ -174,11 +178,13 @@ export function useUpdateDocument({ docType, projectId, }) {
|
|
|
174
178
|
export function useDeleteDocument({ docType, projectId, }) {
|
|
175
179
|
const queryClient = useQueryClient();
|
|
176
180
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
177
|
-
const { mutate, reset, status } = useMutation(deleteDocumentMutationOptions({
|
|
181
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(deleteDocumentMutationOptions({
|
|
178
182
|
docType,
|
|
179
183
|
projectApi,
|
|
180
184
|
projectId,
|
|
181
185
|
queryClient,
|
|
182
186
|
}));
|
|
183
|
-
return
|
|
187
|
+
return status === 'error'
|
|
188
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
189
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
184
190
|
}
|
|
@@ -2,21 +2,49 @@
|
|
|
2
2
|
* Accept an invite that has been received.
|
|
3
3
|
*/
|
|
4
4
|
export declare function useAcceptInvite(): {
|
|
5
|
+
error: Error;
|
|
5
6
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
6
7
|
inviteId: string;
|
|
7
8
|
}, unknown>;
|
|
9
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
10
|
+
inviteId: string;
|
|
11
|
+
}, unknown>;
|
|
8
12
|
reset: () => void;
|
|
9
|
-
status: "
|
|
13
|
+
status: "error";
|
|
14
|
+
} | {
|
|
15
|
+
error: null;
|
|
16
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
17
|
+
inviteId: string;
|
|
18
|
+
}, unknown>;
|
|
19
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
20
|
+
inviteId: string;
|
|
21
|
+
}, unknown>;
|
|
22
|
+
reset: () => void;
|
|
23
|
+
status: "pending" | "success" | "idle";
|
|
10
24
|
};
|
|
11
25
|
/**
|
|
12
26
|
* Reject an invite that has been received.
|
|
13
27
|
*/
|
|
14
28
|
export declare function useRejectInvite(): {
|
|
29
|
+
error: Error;
|
|
15
30
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
16
31
|
inviteId: string;
|
|
17
32
|
}, unknown>;
|
|
33
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
34
|
+
inviteId: string;
|
|
35
|
+
}, unknown>;
|
|
18
36
|
reset: () => void;
|
|
19
|
-
status: "
|
|
37
|
+
status: "error";
|
|
38
|
+
} | {
|
|
39
|
+
error: null;
|
|
40
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
41
|
+
inviteId: string;
|
|
42
|
+
}, unknown>;
|
|
43
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
44
|
+
inviteId: string;
|
|
45
|
+
}, unknown>;
|
|
46
|
+
reset: () => void;
|
|
47
|
+
status: "pending" | "success" | "idle";
|
|
20
48
|
};
|
|
21
49
|
/**
|
|
22
50
|
* Send an invite for a project.
|
|
@@ -26,14 +54,37 @@ export declare function useRejectInvite(): {
|
|
|
26
54
|
export declare function useSendInvite({ projectId }: {
|
|
27
55
|
projectId: string;
|
|
28
56
|
}): {
|
|
57
|
+
error: Error;
|
|
29
58
|
mutate: import("@tanstack/react-query").UseMutateFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
30
59
|
deviceId: string;
|
|
31
60
|
roleDescription?: string;
|
|
32
61
|
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
33
62
|
roleName?: string;
|
|
34
63
|
}, unknown>;
|
|
64
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
65
|
+
deviceId: string;
|
|
66
|
+
roleDescription?: string;
|
|
67
|
+
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
68
|
+
roleName?: string;
|
|
69
|
+
}, unknown>;
|
|
35
70
|
reset: () => void;
|
|
36
|
-
status: "
|
|
71
|
+
status: "error";
|
|
72
|
+
} | {
|
|
73
|
+
error: null;
|
|
74
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
75
|
+
deviceId: string;
|
|
76
|
+
roleDescription?: string;
|
|
77
|
+
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
78
|
+
roleName?: string;
|
|
79
|
+
}, unknown>;
|
|
80
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
81
|
+
deviceId: string;
|
|
82
|
+
roleDescription?: string;
|
|
83
|
+
roleId: import("@comapeo/core/dist/roles.js").RoleIdForNewInvite;
|
|
84
|
+
roleName?: string;
|
|
85
|
+
}, unknown>;
|
|
86
|
+
reset: () => void;
|
|
87
|
+
status: "pending" | "success" | "idle";
|
|
37
88
|
};
|
|
38
89
|
/**
|
|
39
90
|
* Request a cancellation of an invite sent to another device.
|
|
@@ -43,9 +94,23 @@ export declare function useSendInvite({ projectId }: {
|
|
|
43
94
|
export declare function useRequestCancelInvite({ projectId }: {
|
|
44
95
|
projectId: string;
|
|
45
96
|
}): {
|
|
97
|
+
error: Error;
|
|
98
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
99
|
+
deviceId: string;
|
|
100
|
+
}, unknown>;
|
|
101
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
102
|
+
deviceId: string;
|
|
103
|
+
}, unknown>;
|
|
104
|
+
reset: () => void;
|
|
105
|
+
status: "error";
|
|
106
|
+
} | {
|
|
107
|
+
error: null;
|
|
46
108
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
47
109
|
deviceId: string;
|
|
48
110
|
}, unknown>;
|
|
111
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
112
|
+
deviceId: string;
|
|
113
|
+
}, unknown>;
|
|
49
114
|
reset: () => void;
|
|
50
|
-
status: "pending" | "
|
|
115
|
+
status: "pending" | "success" | "idle";
|
|
51
116
|
};
|
|
@@ -8,8 +8,10 @@ import { useSingleProject } from './projects.js';
|
|
|
8
8
|
export function useAcceptInvite() {
|
|
9
9
|
const queryClient = useQueryClient();
|
|
10
10
|
const clientApi = useClientApi();
|
|
11
|
-
const { mutate,
|
|
12
|
-
return
|
|
11
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(acceptInviteMutationOptions({ clientApi, queryClient }));
|
|
12
|
+
return status === 'error'
|
|
13
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
14
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Reject an invite that has been received.
|
|
@@ -17,8 +19,10 @@ export function useAcceptInvite() {
|
|
|
17
19
|
export function useRejectInvite() {
|
|
18
20
|
const queryClient = useQueryClient();
|
|
19
21
|
const clientApi = useClientApi();
|
|
20
|
-
const { mutate,
|
|
21
|
-
return
|
|
22
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(rejectInviteMutationOptions({ clientApi, queryClient }));
|
|
23
|
+
return status === 'error'
|
|
24
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
25
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* Send an invite for a project.
|
|
@@ -28,8 +32,10 @@ export function useRejectInvite() {
|
|
|
28
32
|
export function useSendInvite({ projectId }) {
|
|
29
33
|
const queryClient = useQueryClient();
|
|
30
34
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
31
|
-
const { mutate,
|
|
32
|
-
return
|
|
35
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(sendInviteMutationOptions({ projectApi, projectId, queryClient }));
|
|
36
|
+
return status === 'error'
|
|
37
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
38
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* Request a cancellation of an invite sent to another device.
|
|
@@ -39,6 +45,8 @@ export function useSendInvite({ projectId }) {
|
|
|
39
45
|
export function useRequestCancelInvite({ projectId }) {
|
|
40
46
|
const queryClient = useQueryClient();
|
|
41
47
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
42
|
-
const { mutate,
|
|
43
|
-
return
|
|
48
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(requestCancelInviteMutationOptions({ projectApi, queryClient }));
|
|
49
|
+
return status === 'error'
|
|
50
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
51
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
44
52
|
}
|