@comapeo/core-react 3.1.0 → 3.2.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 +19 -2
- package/dist/commonjs/hooks/client.js +8 -4
- package/dist/commonjs/hooks/documents.d.ts +34 -3
- package/dist/commonjs/hooks/documents.js +12 -6
- package/dist/commonjs/hooks/invites.d.ts +39 -4
- package/dist/commonjs/hooks/invites.js +16 -8
- package/dist/commonjs/hooks/projects.d.ts +82 -8
- package/dist/commonjs/hooks/projects.js +32 -16
- package/dist/esm/hooks/client.d.ts +19 -2
- package/dist/esm/hooks/client.js +8 -4
- package/dist/esm/hooks/documents.d.ts +34 -3
- package/dist/esm/hooks/documents.js +12 -6
- package/dist/esm/hooks/invites.d.ts +39 -4
- package/dist/esm/hooks/invites.js +16 -8
- package/dist/esm/hooks/projects.d.ts +82 -8
- package/dist/esm/hooks/projects.js +32 -16
- package/docs/API.md +17 -17
- package/package.json +1 -1
|
@@ -61,20 +61,37 @@ 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", { with: { "resolution-mode": "import" } }).DeviceInfo["deviceType"];
|
|
67
68
|
}, unknown>;
|
|
68
69
|
reset: () => void;
|
|
69
|
-
status: "
|
|
70
|
+
status: "error";
|
|
71
|
+
} | {
|
|
72
|
+
error: null;
|
|
73
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
74
|
+
name: string;
|
|
75
|
+
deviceType: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).DeviceInfo["deviceType"];
|
|
76
|
+
}, unknown>;
|
|
77
|
+
reset: () => void;
|
|
78
|
+
status: "pending" | "success" | "idle";
|
|
70
79
|
};
|
|
71
80
|
/**
|
|
72
81
|
* Set or unset the current device as an archive device.
|
|
73
82
|
*/
|
|
74
83
|
export declare function useSetIsArchiveDevice(): {
|
|
84
|
+
error: Error;
|
|
85
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
86
|
+
isArchiveDevice: boolean;
|
|
87
|
+
}, unknown>;
|
|
88
|
+
reset: () => void;
|
|
89
|
+
status: "error";
|
|
90
|
+
} | {
|
|
91
|
+
error: null;
|
|
75
92
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
76
93
|
isArchiveDevice: boolean;
|
|
77
94
|
}, unknown>;
|
|
78
95
|
reset: () => void;
|
|
79
|
-
status: "pending" | "
|
|
96
|
+
status: "pending" | "success" | "idle";
|
|
80
97
|
};
|
|
@@ -77,8 +77,10 @@ function useIsArchiveDevice() {
|
|
|
77
77
|
function useSetOwnDeviceInfo() {
|
|
78
78
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
79
79
|
const clientApi = useClientApi();
|
|
80
|
-
const {
|
|
81
|
-
return
|
|
80
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, client_js_1.setOwnDeviceInfoMutationOptions)({ clientApi, queryClient }));
|
|
81
|
+
return status === 'error'
|
|
82
|
+
? { error, mutate, reset, status }
|
|
83
|
+
: { error: null, mutate, reset, status };
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
84
86
|
* Set or unset the current device as an archive device.
|
|
@@ -86,6 +88,8 @@ function useSetOwnDeviceInfo() {
|
|
|
86
88
|
function useSetIsArchiveDevice() {
|
|
87
89
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
88
90
|
const clientApi = useClientApi();
|
|
89
|
-
const { mutate, status, reset } = (0, react_query_1.useMutation)((0, client_js_1.setIsArchiveDeviceMutationOptions)({ clientApi, queryClient }));
|
|
90
|
-
return
|
|
91
|
+
const { error, mutate, status, reset } = (0, react_query_1.useMutation)((0, client_js_1.setIsArchiveDeviceMutationOptions)({ clientApi, queryClient }));
|
|
92
|
+
return status === 'error'
|
|
93
|
+
? { error, mutate, reset, status }
|
|
94
|
+
: { error: null, mutate, reset, status };
|
|
91
95
|
}
|
|
@@ -119,13 +119,23 @@ 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>;
|
|
127
128
|
reset: () => void;
|
|
128
|
-
status: "
|
|
129
|
+
status: "error";
|
|
130
|
+
} | {
|
|
131
|
+
error: null;
|
|
132
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
133
|
+
forks: Array<string>;
|
|
134
|
+
}, Error, {
|
|
135
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
136
|
+
}, unknown>;
|
|
137
|
+
reset: () => void;
|
|
138
|
+
status: "pending" | "success" | "idle";
|
|
129
139
|
};
|
|
130
140
|
/**
|
|
131
141
|
* Update a document within a project.
|
|
@@ -137,6 +147,7 @@ export declare function useUpdateDocument<D extends WriteableDocumentType>({ doc
|
|
|
137
147
|
docType: D;
|
|
138
148
|
projectId: string;
|
|
139
149
|
}): {
|
|
150
|
+
error: Error;
|
|
140
151
|
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
141
152
|
forks: Array<string>;
|
|
142
153
|
}, Error, {
|
|
@@ -144,7 +155,17 @@ export declare function useUpdateDocument<D extends WriteableDocumentType>({ doc
|
|
|
144
155
|
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
145
156
|
}, unknown>;
|
|
146
157
|
reset: () => void;
|
|
147
|
-
status: "
|
|
158
|
+
status: "error";
|
|
159
|
+
} | {
|
|
160
|
+
error: null;
|
|
161
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
162
|
+
forks: Array<string>;
|
|
163
|
+
}, Error, {
|
|
164
|
+
versionId: string;
|
|
165
|
+
value: Omit<import("../lib/types.js").WriteableValue<D>, "schemaName">;
|
|
166
|
+
}, unknown>;
|
|
167
|
+
reset: () => void;
|
|
168
|
+
status: "pending" | "success" | "idle";
|
|
148
169
|
};
|
|
149
170
|
/**
|
|
150
171
|
* Delete a document within a project.
|
|
@@ -156,12 +177,22 @@ export declare function useDeleteDocument<D extends WriteableDocumentType>({ doc
|
|
|
156
177
|
docType: D;
|
|
157
178
|
projectId: string;
|
|
158
179
|
}): {
|
|
180
|
+
error: Error;
|
|
181
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
182
|
+
forks: Array<string>;
|
|
183
|
+
}, Error, {
|
|
184
|
+
docId: string;
|
|
185
|
+
}, unknown>;
|
|
186
|
+
reset: () => void;
|
|
187
|
+
status: "error";
|
|
188
|
+
} | {
|
|
189
|
+
error: null;
|
|
159
190
|
mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/types.js").WriteableDocument<D> & {
|
|
160
191
|
forks: Array<string>;
|
|
161
192
|
}, Error, {
|
|
162
193
|
docId: string;
|
|
163
194
|
}, unknown>;
|
|
164
195
|
reset: () => void;
|
|
165
|
-
status: "pending" | "
|
|
196
|
+
status: "pending" | "success" | "idle";
|
|
166
197
|
};
|
|
167
198
|
export {};
|
|
@@ -148,13 +148,15 @@ function useManyDocs({ projectId, docType, includeDeleted, lang, }) {
|
|
|
148
148
|
function useCreateDocument({ docType, projectId, }) {
|
|
149
149
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
150
150
|
const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
|
|
151
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.createDocumentMutationOptions)({
|
|
151
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.createDocumentMutationOptions)({
|
|
152
152
|
docType,
|
|
153
153
|
projectApi,
|
|
154
154
|
projectId,
|
|
155
155
|
queryClient,
|
|
156
156
|
}));
|
|
157
|
-
return
|
|
157
|
+
return status === 'error'
|
|
158
|
+
? { error, mutate, reset, status }
|
|
159
|
+
: { error: null, mutate, reset, status };
|
|
158
160
|
}
|
|
159
161
|
/**
|
|
160
162
|
* Update a document within a project.
|
|
@@ -165,13 +167,15 @@ function useCreateDocument({ docType, projectId, }) {
|
|
|
165
167
|
function useUpdateDocument({ docType, projectId, }) {
|
|
166
168
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
167
169
|
const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
|
|
168
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.updateDocumentMutationOptions)({
|
|
170
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.updateDocumentMutationOptions)({
|
|
169
171
|
docType,
|
|
170
172
|
projectApi,
|
|
171
173
|
projectId,
|
|
172
174
|
queryClient,
|
|
173
175
|
}));
|
|
174
|
-
return
|
|
176
|
+
return status === 'error'
|
|
177
|
+
? { error, mutate, reset, status }
|
|
178
|
+
: { error: null, mutate, reset, status };
|
|
175
179
|
}
|
|
176
180
|
/**
|
|
177
181
|
* Delete a document within a project.
|
|
@@ -182,11 +186,13 @@ function useUpdateDocument({ docType, projectId, }) {
|
|
|
182
186
|
function useDeleteDocument({ docType, projectId, }) {
|
|
183
187
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
184
188
|
const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
|
|
185
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.deleteDocumentMutationOptions)({
|
|
189
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.deleteDocumentMutationOptions)({
|
|
186
190
|
docType,
|
|
187
191
|
projectApi,
|
|
188
192
|
projectId,
|
|
189
193
|
queryClient,
|
|
190
194
|
}));
|
|
191
|
-
return
|
|
195
|
+
return status === 'error'
|
|
196
|
+
? { error, mutate, reset, status }
|
|
197
|
+
: { error: null, mutate, reset, status };
|
|
192
198
|
}
|
|
@@ -2,21 +2,37 @@
|
|
|
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>;
|
|
8
9
|
reset: () => void;
|
|
9
|
-
status: "
|
|
10
|
+
status: "error";
|
|
11
|
+
} | {
|
|
12
|
+
error: null;
|
|
13
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
14
|
+
inviteId: string;
|
|
15
|
+
}, unknown>;
|
|
16
|
+
reset: () => void;
|
|
17
|
+
status: "pending" | "success" | "idle";
|
|
10
18
|
};
|
|
11
19
|
/**
|
|
12
20
|
* Reject an invite that has been received.
|
|
13
21
|
*/
|
|
14
22
|
export declare function useRejectInvite(): {
|
|
23
|
+
error: Error;
|
|
24
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
25
|
+
inviteId: string;
|
|
26
|
+
}, unknown>;
|
|
27
|
+
reset: () => void;
|
|
28
|
+
status: "error";
|
|
29
|
+
} | {
|
|
30
|
+
error: null;
|
|
15
31
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
16
32
|
inviteId: string;
|
|
17
33
|
}, unknown>;
|
|
18
34
|
reset: () => void;
|
|
19
|
-
status: "pending" | "
|
|
35
|
+
status: "pending" | "success" | "idle";
|
|
20
36
|
};
|
|
21
37
|
/**
|
|
22
38
|
* Send an invite for a project.
|
|
@@ -26,6 +42,7 @@ export declare function useRejectInvite(): {
|
|
|
26
42
|
export declare function useSendInvite({ projectId }: {
|
|
27
43
|
projectId: string;
|
|
28
44
|
}): {
|
|
45
|
+
error: Error;
|
|
29
46
|
mutate: import("@tanstack/react-query").UseMutateFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
30
47
|
deviceId: string;
|
|
31
48
|
roleDescription?: string;
|
|
@@ -33,7 +50,17 @@ export declare function useSendInvite({ projectId }: {
|
|
|
33
50
|
roleName?: string;
|
|
34
51
|
}, unknown>;
|
|
35
52
|
reset: () => void;
|
|
36
|
-
status: "
|
|
53
|
+
status: "error";
|
|
54
|
+
} | {
|
|
55
|
+
error: null;
|
|
56
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
|
|
57
|
+
deviceId: string;
|
|
58
|
+
roleDescription?: string;
|
|
59
|
+
roleId: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).RoleIdForNewInvite;
|
|
60
|
+
roleName?: string;
|
|
61
|
+
}, unknown>;
|
|
62
|
+
reset: () => void;
|
|
63
|
+
status: "pending" | "success" | "idle";
|
|
37
64
|
};
|
|
38
65
|
/**
|
|
39
66
|
* Request a cancellation of an invite sent to another device.
|
|
@@ -43,9 +70,17 @@ export declare function useSendInvite({ projectId }: {
|
|
|
43
70
|
export declare function useRequestCancelInvite({ projectId }: {
|
|
44
71
|
projectId: string;
|
|
45
72
|
}): {
|
|
73
|
+
error: Error;
|
|
74
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
75
|
+
deviceId: string;
|
|
76
|
+
}, unknown>;
|
|
77
|
+
reset: () => void;
|
|
78
|
+
status: "error";
|
|
79
|
+
} | {
|
|
80
|
+
error: null;
|
|
46
81
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
47
82
|
deviceId: string;
|
|
48
83
|
}, unknown>;
|
|
49
84
|
reset: () => void;
|
|
50
|
-
status: "pending" | "
|
|
85
|
+
status: "pending" | "success" | "idle";
|
|
51
86
|
};
|
|
@@ -14,8 +14,10 @@ const projects_js_1 = require("./projects.js");
|
|
|
14
14
|
function useAcceptInvite() {
|
|
15
15
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
16
16
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
17
|
-
const {
|
|
18
|
-
return
|
|
17
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, invites_js_1.acceptInviteMutationOptions)({ clientApi, queryClient }));
|
|
18
|
+
return status === 'error'
|
|
19
|
+
? { error, mutate, reset, status }
|
|
20
|
+
: { error: null, mutate, reset, status };
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Reject an invite that has been received.
|
|
@@ -23,8 +25,10 @@ function useAcceptInvite() {
|
|
|
23
25
|
function useRejectInvite() {
|
|
24
26
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
25
27
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
26
|
-
const {
|
|
27
|
-
return
|
|
28
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, invites_js_1.rejectInviteMutationOptions)({ clientApi, queryClient }));
|
|
29
|
+
return status === 'error'
|
|
30
|
+
? { error, mutate, reset, status }
|
|
31
|
+
: { error: null, mutate, reset, status };
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
30
34
|
* Send an invite for a project.
|
|
@@ -34,8 +38,10 @@ function useRejectInvite() {
|
|
|
34
38
|
function useSendInvite({ projectId }) {
|
|
35
39
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
36
40
|
const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
|
|
37
|
-
const {
|
|
38
|
-
return
|
|
41
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, invites_js_1.sendInviteMutationOptions)({ projectApi, projectId, queryClient }));
|
|
42
|
+
return status === 'error'
|
|
43
|
+
? { error, mutate, reset, status }
|
|
44
|
+
: { error: null, mutate, reset, status };
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
41
47
|
* Request a cancellation of an invite sent to another device.
|
|
@@ -45,6 +51,8 @@ function useSendInvite({ projectId }) {
|
|
|
45
51
|
function useRequestCancelInvite({ projectId }) {
|
|
46
52
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
47
53
|
const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
|
|
48
|
-
const {
|
|
49
|
-
return
|
|
54
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, invites_js_1.requestCancelInviteMutationOptions)({ projectApi, queryClient }));
|
|
55
|
+
return status === 'error'
|
|
56
|
+
? { error, mutate, reset, status }
|
|
57
|
+
: { error: null, mutate, reset, status };
|
|
50
58
|
}
|
|
@@ -275,33 +275,59 @@ export declare function useOwnRoleInProject({ projectId }: {
|
|
|
275
275
|
export declare function useAddServerPeer({ projectId }: {
|
|
276
276
|
projectId: string;
|
|
277
277
|
}): {
|
|
278
|
+
error: Error;
|
|
278
279
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
279
280
|
baseUrl: string;
|
|
280
281
|
dangerouslyAllowInsecureConnections?: boolean;
|
|
281
282
|
}, unknown>;
|
|
282
283
|
reset: () => void;
|
|
283
|
-
status: "
|
|
284
|
+
status: "error";
|
|
285
|
+
} | {
|
|
286
|
+
error: null;
|
|
287
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
288
|
+
baseUrl: string;
|
|
289
|
+
dangerouslyAllowInsecureConnections?: boolean;
|
|
290
|
+
}, unknown>;
|
|
291
|
+
reset: () => void;
|
|
292
|
+
status: "pending" | "success" | "idle";
|
|
284
293
|
};
|
|
285
294
|
/**
|
|
286
295
|
* Create a new project.
|
|
287
296
|
*/
|
|
288
297
|
export declare function useCreateProject(): {
|
|
298
|
+
error: Error;
|
|
289
299
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
290
300
|
name?: string;
|
|
291
301
|
configPath?: string;
|
|
292
302
|
} | undefined, unknown>;
|
|
293
303
|
reset: () => void;
|
|
294
|
-
status: "
|
|
304
|
+
status: "error";
|
|
305
|
+
} | {
|
|
306
|
+
error: null;
|
|
307
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
308
|
+
name?: string;
|
|
309
|
+
configPath?: string;
|
|
310
|
+
} | undefined, unknown>;
|
|
311
|
+
reset: () => void;
|
|
312
|
+
status: "pending" | "success" | "idle";
|
|
295
313
|
};
|
|
296
314
|
/**
|
|
297
315
|
* Leave an existing project.
|
|
298
316
|
*/
|
|
299
317
|
export declare function useLeaveProject(): {
|
|
318
|
+
error: Error;
|
|
300
319
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
301
320
|
projectId: string;
|
|
302
321
|
}, unknown>;
|
|
303
322
|
reset: () => void;
|
|
304
|
-
status: "
|
|
323
|
+
status: "error";
|
|
324
|
+
} | {
|
|
325
|
+
error: null;
|
|
326
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
327
|
+
projectId: string;
|
|
328
|
+
}, unknown>;
|
|
329
|
+
reset: () => void;
|
|
330
|
+
status: "pending" | "success" | "idle";
|
|
305
331
|
};
|
|
306
332
|
/**
|
|
307
333
|
* Update the configuration of a project using an external file.
|
|
@@ -311,11 +337,19 @@ export declare function useLeaveProject(): {
|
|
|
311
337
|
export declare function useImportProjectConfig({ projectId }: {
|
|
312
338
|
projectId: string;
|
|
313
339
|
}): {
|
|
340
|
+
error: Error;
|
|
341
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<Error[], Error, {
|
|
342
|
+
configPath: string;
|
|
343
|
+
}, unknown>;
|
|
344
|
+
reset: () => void;
|
|
345
|
+
status: "error";
|
|
346
|
+
} | {
|
|
347
|
+
error: null;
|
|
314
348
|
mutate: import("@tanstack/react-query").UseMutateFunction<Error[], Error, {
|
|
315
349
|
configPath: string;
|
|
316
350
|
}, unknown>;
|
|
317
351
|
reset: () => void;
|
|
318
|
-
status: "pending" | "
|
|
352
|
+
status: "pending" | "success" | "idle";
|
|
319
353
|
};
|
|
320
354
|
/**
|
|
321
355
|
* Update the settings of a project.
|
|
@@ -325,13 +359,23 @@ export declare function useImportProjectConfig({ projectId }: {
|
|
|
325
359
|
export declare function useUpdateProjectSettings({ projectId }: {
|
|
326
360
|
projectId: string;
|
|
327
361
|
}): {
|
|
362
|
+
error: Error;
|
|
363
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, Error, {
|
|
364
|
+
name?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["name"];
|
|
365
|
+
configMetadata?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["configMetadata"];
|
|
366
|
+
defaultPresets?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["defaultPresets"];
|
|
367
|
+
}, unknown>;
|
|
368
|
+
reset: () => void;
|
|
369
|
+
status: "error";
|
|
370
|
+
} | {
|
|
371
|
+
error: null;
|
|
328
372
|
mutate: import("@tanstack/react-query").UseMutateFunction<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, Error, {
|
|
329
373
|
name?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["name"];
|
|
330
374
|
configMetadata?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["configMetadata"];
|
|
331
375
|
defaultPresets?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["defaultPresets"];
|
|
332
376
|
}, unknown>;
|
|
333
377
|
reset: () => void;
|
|
334
|
-
status: "pending" | "
|
|
378
|
+
status: "pending" | "success" | "idle";
|
|
335
379
|
};
|
|
336
380
|
/**
|
|
337
381
|
* Create a blob for a project.
|
|
@@ -341,6 +385,7 @@ export declare function useUpdateProjectSettings({ projectId }: {
|
|
|
341
385
|
export declare function useCreateBlob({ projectId }: {
|
|
342
386
|
projectId: string;
|
|
343
387
|
}): {
|
|
388
|
+
error: Error;
|
|
344
389
|
mutate: import("@tanstack/react-query").UseMutateFunction<{
|
|
345
390
|
driveId: string;
|
|
346
391
|
name: string;
|
|
@@ -353,7 +398,22 @@ export declare function useCreateBlob({ projectId }: {
|
|
|
353
398
|
metadata: import("@comapeo/core/dist/blob-api.js", { with: { "resolution-mode": "import" } }).Metadata;
|
|
354
399
|
}, unknown>;
|
|
355
400
|
reset: () => void;
|
|
356
|
-
status: "
|
|
401
|
+
status: "error";
|
|
402
|
+
} | {
|
|
403
|
+
error: null;
|
|
404
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<{
|
|
405
|
+
driveId: string;
|
|
406
|
+
name: string;
|
|
407
|
+
type: "photo" | "video" | "audio";
|
|
408
|
+
hash: string;
|
|
409
|
+
}, Error, {
|
|
410
|
+
original: string;
|
|
411
|
+
preview?: string;
|
|
412
|
+
thumbnail?: string;
|
|
413
|
+
metadata: import("@comapeo/core/dist/blob-api.js", { with: { "resolution-mode": "import" } }).Metadata;
|
|
414
|
+
}, unknown>;
|
|
415
|
+
reset: () => void;
|
|
416
|
+
status: "pending" | "success" | "idle";
|
|
357
417
|
};
|
|
358
418
|
/**
|
|
359
419
|
* Hook to subscribe to the current sync state.
|
|
@@ -391,16 +451,30 @@ export declare function useDataSyncProgress({ projectId, }: {
|
|
|
391
451
|
export declare function useStartSync({ projectId }: {
|
|
392
452
|
projectId: string;
|
|
393
453
|
}): {
|
|
454
|
+
error: Error;
|
|
455
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
456
|
+
autostopDataSyncAfter: number | null;
|
|
457
|
+
} | undefined, unknown>;
|
|
458
|
+
reset: () => void;
|
|
459
|
+
status: "error";
|
|
460
|
+
} | {
|
|
461
|
+
error: null;
|
|
394
462
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
395
463
|
autostopDataSyncAfter: number | null;
|
|
396
464
|
} | undefined, unknown>;
|
|
397
465
|
reset: () => void;
|
|
398
|
-
status: "pending" | "
|
|
466
|
+
status: "pending" | "success" | "idle";
|
|
399
467
|
};
|
|
400
468
|
export declare function useStopSync({ projectId }: {
|
|
401
469
|
projectId: string;
|
|
402
470
|
}): {
|
|
471
|
+
error: Error;
|
|
472
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, void, unknown>;
|
|
473
|
+
reset: () => void;
|
|
474
|
+
status: "error";
|
|
475
|
+
} | {
|
|
476
|
+
error: null;
|
|
403
477
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, void, unknown>;
|
|
404
478
|
reset: () => void;
|
|
405
|
-
status: "pending" | "
|
|
479
|
+
status: "pending" | "success" | "idle";
|
|
406
480
|
};
|
|
@@ -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, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.addServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
|
|
296
|
+
return status === 'error'
|
|
297
|
+
? { error, mutate, reset, status }
|
|
298
|
+
: { error: null, mutate, 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 {
|
|
305
|
-
return
|
|
306
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createProjectMutationOptions)({ clientApi, queryClient }));
|
|
307
|
+
return status === 'error'
|
|
308
|
+
? { error, mutate, reset, status }
|
|
309
|
+
: { error: null, mutate, 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 {
|
|
314
|
-
return
|
|
317
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.leaveProjectMutationOptions)({ clientApi, queryClient }));
|
|
318
|
+
return status === 'error'
|
|
319
|
+
? { error, mutate, reset, status }
|
|
320
|
+
: { error: null, mutate, 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 {
|
|
325
|
-
return
|
|
330
|
+
const { error, mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.importProjectConfigMutationOptions)({ queryClient, projectApi, projectId }));
|
|
331
|
+
return status === 'error'
|
|
332
|
+
? { error, mutate, reset, status }
|
|
333
|
+
: { error: null, mutate, 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, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.updateProjectSettingsMutationOptions)({ projectApi, queryClient }));
|
|
344
|
+
return status === 'error'
|
|
345
|
+
? { error, mutate, reset, status }
|
|
346
|
+
: { error: null, mutate, 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, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createBlobMutationOptions)({ projectApi }));
|
|
356
|
+
return status === 'error'
|
|
357
|
+
? { error, mutate, reset, status }
|
|
358
|
+
: { error: null, mutate, 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 { mutate, reset, status, error } = (0, react_query_1.useMutation)((0, projects_js_1.startSyncMutationOptions)({ projectApi }));
|
|
409
|
+
return status === 'error'
|
|
410
|
+
? { error, mutate, reset, status }
|
|
411
|
+
: { error: null, mutate, 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, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.stopSyncMutationOptions)({ projectApi }));
|
|
416
|
+
return status === 'error'
|
|
417
|
+
? { error, mutate, reset, status }
|
|
418
|
+
: { error: null, mutate, reset, status };
|
|
403
419
|
}
|
|
@@ -61,20 +61,37 @@ 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>;
|
|
68
69
|
reset: () => void;
|
|
69
|
-
status: "
|
|
70
|
+
status: "error";
|
|
71
|
+
} | {
|
|
72
|
+
error: null;
|
|
73
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
74
|
+
name: string;
|
|
75
|
+
deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
|
|
76
|
+
}, unknown>;
|
|
77
|
+
reset: () => void;
|
|
78
|
+
status: "pending" | "success" | "idle";
|
|
70
79
|
};
|
|
71
80
|
/**
|
|
72
81
|
* Set or unset the current device as an archive device.
|
|
73
82
|
*/
|
|
74
83
|
export declare function useSetIsArchiveDevice(): {
|
|
84
|
+
error: Error;
|
|
85
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
86
|
+
isArchiveDevice: boolean;
|
|
87
|
+
}, unknown>;
|
|
88
|
+
reset: () => void;
|
|
89
|
+
status: "error";
|
|
90
|
+
} | {
|
|
91
|
+
error: null;
|
|
75
92
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
76
93
|
isArchiveDevice: boolean;
|
|
77
94
|
}, unknown>;
|
|
78
95
|
reset: () => void;
|
|
79
|
-
status: "pending" | "
|
|
96
|
+
status: "pending" | "success" | "idle";
|
|
80
97
|
};
|
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 {
|
|
74
|
-
return
|
|
73
|
+
const { error, mutate, reset, status } = useMutation(setOwnDeviceInfoMutationOptions({ clientApi, queryClient }));
|
|
74
|
+
return status === 'error'
|
|
75
|
+
? { error, mutate, reset, status }
|
|
76
|
+
: { error: null, mutate, 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, status, reset } = useMutation(setIsArchiveDeviceMutationOptions({ clientApi, queryClient }));
|
|
85
|
+
return status === 'error'
|
|
86
|
+
? { error, mutate, reset, status }
|
|
87
|
+
: { error: null, mutate, reset, status };
|
|
84
88
|
}
|