@comapeo/core-react 3.0.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 +104 -8
- package/dist/commonjs/hooks/projects.js +53 -16
- package/dist/commonjs/index.d.ts +1 -1
- package/dist/commonjs/index.js +2 -1
- 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 +104 -8
- package/dist/esm/hooks/projects.js +53 -17
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/docs/API.md +43 -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
|
}
|
|
@@ -250,36 +250,84 @@ export declare function useDocumentCreatedBy({ projectId, originalVersionId, }:
|
|
|
250
250
|
error: Error | null;
|
|
251
251
|
isRefetching: boolean;
|
|
252
252
|
};
|
|
253
|
+
/**
|
|
254
|
+
* Get the role for the current device in a specified project.
|
|
255
|
+
* This is a more convenient alternative to using the `useOwnDeviceInfo` and `useManyMembers` hooks.
|
|
256
|
+
*
|
|
257
|
+
* @param opts.projectId Project public ID
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```tsx
|
|
261
|
+
* function BasicExample() {
|
|
262
|
+
* const { data } = useOwnRoleInProject({
|
|
263
|
+
* projectId: '...',
|
|
264
|
+
* })
|
|
265
|
+
* }
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
export declare function useOwnRoleInProject({ projectId }: {
|
|
269
|
+
projectId: string;
|
|
270
|
+
}): {
|
|
271
|
+
data: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">;
|
|
272
|
+
error: Error | null;
|
|
273
|
+
isRefetching: boolean;
|
|
274
|
+
};
|
|
253
275
|
export declare function useAddServerPeer({ projectId }: {
|
|
254
276
|
projectId: string;
|
|
255
277
|
}): {
|
|
278
|
+
error: Error;
|
|
279
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
280
|
+
baseUrl: string;
|
|
281
|
+
dangerouslyAllowInsecureConnections?: boolean;
|
|
282
|
+
}, unknown>;
|
|
283
|
+
reset: () => void;
|
|
284
|
+
status: "error";
|
|
285
|
+
} | {
|
|
286
|
+
error: null;
|
|
256
287
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
257
288
|
baseUrl: string;
|
|
258
289
|
dangerouslyAllowInsecureConnections?: boolean;
|
|
259
290
|
}, unknown>;
|
|
260
291
|
reset: () => void;
|
|
261
|
-
status: "pending" | "
|
|
292
|
+
status: "pending" | "success" | "idle";
|
|
262
293
|
};
|
|
263
294
|
/**
|
|
264
295
|
* Create a new project.
|
|
265
296
|
*/
|
|
266
297
|
export declare function useCreateProject(): {
|
|
298
|
+
error: Error;
|
|
267
299
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
268
300
|
name?: string;
|
|
269
301
|
configPath?: string;
|
|
270
302
|
} | undefined, unknown>;
|
|
271
303
|
reset: () => void;
|
|
272
|
-
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";
|
|
273
313
|
};
|
|
274
314
|
/**
|
|
275
315
|
* Leave an existing project.
|
|
276
316
|
*/
|
|
277
317
|
export declare function useLeaveProject(): {
|
|
318
|
+
error: Error;
|
|
278
319
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
279
320
|
projectId: string;
|
|
280
321
|
}, unknown>;
|
|
281
322
|
reset: () => void;
|
|
282
|
-
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";
|
|
283
331
|
};
|
|
284
332
|
/**
|
|
285
333
|
* Update the configuration of a project using an external file.
|
|
@@ -289,11 +337,19 @@ export declare function useLeaveProject(): {
|
|
|
289
337
|
export declare function useImportProjectConfig({ projectId }: {
|
|
290
338
|
projectId: string;
|
|
291
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;
|
|
292
348
|
mutate: import("@tanstack/react-query").UseMutateFunction<Error[], Error, {
|
|
293
349
|
configPath: string;
|
|
294
350
|
}, unknown>;
|
|
295
351
|
reset: () => void;
|
|
296
|
-
status: "pending" | "
|
|
352
|
+
status: "pending" | "success" | "idle";
|
|
297
353
|
};
|
|
298
354
|
/**
|
|
299
355
|
* Update the settings of a project.
|
|
@@ -303,13 +359,23 @@ export declare function useImportProjectConfig({ projectId }: {
|
|
|
303
359
|
export declare function useUpdateProjectSettings({ projectId }: {
|
|
304
360
|
projectId: string;
|
|
305
361
|
}): {
|
|
362
|
+
error: Error;
|
|
306
363
|
mutate: import("@tanstack/react-query").UseMutateFunction<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, Error, {
|
|
307
364
|
name?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["name"];
|
|
308
365
|
configMetadata?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["configMetadata"];
|
|
309
366
|
defaultPresets?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["defaultPresets"];
|
|
310
367
|
}, unknown>;
|
|
311
368
|
reset: () => void;
|
|
312
|
-
status: "
|
|
369
|
+
status: "error";
|
|
370
|
+
} | {
|
|
371
|
+
error: null;
|
|
372
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, Error, {
|
|
373
|
+
name?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["name"];
|
|
374
|
+
configMetadata?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["configMetadata"];
|
|
375
|
+
defaultPresets?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["defaultPresets"];
|
|
376
|
+
}, unknown>;
|
|
377
|
+
reset: () => void;
|
|
378
|
+
status: "pending" | "success" | "idle";
|
|
313
379
|
};
|
|
314
380
|
/**
|
|
315
381
|
* Create a blob for a project.
|
|
@@ -319,6 +385,7 @@ export declare function useUpdateProjectSettings({ projectId }: {
|
|
|
319
385
|
export declare function useCreateBlob({ projectId }: {
|
|
320
386
|
projectId: string;
|
|
321
387
|
}): {
|
|
388
|
+
error: Error;
|
|
322
389
|
mutate: import("@tanstack/react-query").UseMutateFunction<{
|
|
323
390
|
driveId: string;
|
|
324
391
|
name: string;
|
|
@@ -331,7 +398,22 @@ export declare function useCreateBlob({ projectId }: {
|
|
|
331
398
|
metadata: import("@comapeo/core/dist/blob-api.js", { with: { "resolution-mode": "import" } }).Metadata;
|
|
332
399
|
}, unknown>;
|
|
333
400
|
reset: () => void;
|
|
334
|
-
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";
|
|
335
417
|
};
|
|
336
418
|
/**
|
|
337
419
|
* Hook to subscribe to the current sync state.
|
|
@@ -369,16 +451,30 @@ export declare function useDataSyncProgress({ projectId, }: {
|
|
|
369
451
|
export declare function useStartSync({ projectId }: {
|
|
370
452
|
projectId: string;
|
|
371
453
|
}): {
|
|
454
|
+
error: Error;
|
|
372
455
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
373
456
|
autostopDataSyncAfter: number | null;
|
|
374
457
|
} | undefined, unknown>;
|
|
375
458
|
reset: () => void;
|
|
376
|
-
status: "
|
|
459
|
+
status: "error";
|
|
460
|
+
} | {
|
|
461
|
+
error: null;
|
|
462
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
463
|
+
autostopDataSyncAfter: number | null;
|
|
464
|
+
} | undefined, unknown>;
|
|
465
|
+
reset: () => void;
|
|
466
|
+
status: "pending" | "success" | "idle";
|
|
377
467
|
};
|
|
378
468
|
export declare function useStopSync({ projectId }: {
|
|
379
469
|
projectId: string;
|
|
380
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;
|
|
381
477
|
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, void, unknown>;
|
|
382
478
|
reset: () => void;
|
|
383
|
-
status: "pending" | "
|
|
479
|
+
status: "pending" | "success" | "idle";
|
|
384
480
|
};
|
|
@@ -8,6 +8,7 @@ exports.useManyMembers = useManyMembers;
|
|
|
8
8
|
exports.useIconUrl = useIconUrl;
|
|
9
9
|
exports.useAttachmentUrl = useAttachmentUrl;
|
|
10
10
|
exports.useDocumentCreatedBy = useDocumentCreatedBy;
|
|
11
|
+
exports.useOwnRoleInProject = useOwnRoleInProject;
|
|
11
12
|
exports.useAddServerPeer = useAddServerPeer;
|
|
12
13
|
exports.useCreateProject = useCreateProject;
|
|
13
14
|
exports.useLeaveProject = useLeaveProject;
|
|
@@ -268,11 +269,33 @@ function useDocumentCreatedBy({ projectId, originalVersionId, }) {
|
|
|
268
269
|
const { data, error, isRefetching } = (0, react_query_1.useSuspenseQuery)((0, projects_js_1.documentCreatedByQueryOptions)({ projectApi, projectId, originalVersionId }));
|
|
269
270
|
return { data, error, isRefetching };
|
|
270
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Get the role for the current device in a specified project.
|
|
274
|
+
* This is a more convenient alternative to using the `useOwnDeviceInfo` and `useManyMembers` hooks.
|
|
275
|
+
*
|
|
276
|
+
* @param opts.projectId Project public ID
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```tsx
|
|
280
|
+
* function BasicExample() {
|
|
281
|
+
* const { data } = useOwnRoleInProject({
|
|
282
|
+
* projectId: '...',
|
|
283
|
+
* })
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
function useOwnRoleInProject({ projectId }) {
|
|
288
|
+
const { data: projectApi } = useSingleProject({ projectId });
|
|
289
|
+
const { data, error, isRefetching } = (0, react_query_1.useSuspenseQuery)((0, projects_js_1.projectOwnRoleQueryOptions)({ projectApi, projectId }));
|
|
290
|
+
return { data, error, isRefetching };
|
|
291
|
+
}
|
|
271
292
|
function useAddServerPeer({ projectId }) {
|
|
272
293
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
273
294
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
274
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.addServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
|
|
275
|
-
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 };
|
|
276
299
|
}
|
|
277
300
|
/**
|
|
278
301
|
* Create a new project.
|
|
@@ -280,8 +303,10 @@ function useAddServerPeer({ projectId }) {
|
|
|
280
303
|
function useCreateProject() {
|
|
281
304
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
282
305
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
283
|
-
const {
|
|
284
|
-
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 };
|
|
285
310
|
}
|
|
286
311
|
/**
|
|
287
312
|
* Leave an existing project.
|
|
@@ -289,8 +314,10 @@ function useCreateProject() {
|
|
|
289
314
|
function useLeaveProject() {
|
|
290
315
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
291
316
|
const clientApi = (0, client_js_1.useClientApi)();
|
|
292
|
-
const {
|
|
293
|
-
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 };
|
|
294
321
|
}
|
|
295
322
|
/**
|
|
296
323
|
* Update the configuration of a project using an external file.
|
|
@@ -300,8 +327,10 @@ function useLeaveProject() {
|
|
|
300
327
|
function useImportProjectConfig({ projectId }) {
|
|
301
328
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
302
329
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
303
|
-
const {
|
|
304
|
-
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 };
|
|
305
334
|
}
|
|
306
335
|
/**
|
|
307
336
|
* Update the settings of a project.
|
|
@@ -311,8 +340,10 @@ function useImportProjectConfig({ projectId }) {
|
|
|
311
340
|
function useUpdateProjectSettings({ projectId }) {
|
|
312
341
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
313
342
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
314
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.updateProjectSettingsMutationOptions)({ projectApi, queryClient }));
|
|
315
|
-
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 };
|
|
316
347
|
}
|
|
317
348
|
/**
|
|
318
349
|
* Create a blob for a project.
|
|
@@ -321,8 +352,10 @@ function useUpdateProjectSettings({ projectId }) {
|
|
|
321
352
|
*/
|
|
322
353
|
function useCreateBlob({ projectId }) {
|
|
323
354
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
324
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createBlobMutationOptions)({ projectApi }));
|
|
325
|
-
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 };
|
|
326
359
|
}
|
|
327
360
|
const PROJECT_SYNC_STORE_MAP = new WeakMap();
|
|
328
361
|
function useSyncStore({ projectId }) {
|
|
@@ -372,11 +405,15 @@ function useDataSyncProgress({ projectId, }) {
|
|
|
372
405
|
}
|
|
373
406
|
function useStartSync({ projectId }) {
|
|
374
407
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
375
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.startSyncMutationOptions)({ projectApi }));
|
|
376
|
-
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 };
|
|
377
412
|
}
|
|
378
413
|
function useStopSync({ projectId }) {
|
|
379
414
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
380
|
-
const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.stopSyncMutationOptions)({ projectApi }));
|
|
381
|
-
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 };
|
|
382
419
|
}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevi
|
|
|
3
3
|
export { useCreateDocument, useDeleteDocument, useManyDocs, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
4
4
|
export { useAcceptInvite, useRejectInvite, useRequestCancelInvite, useSendInvite, } from './hooks/invites.js';
|
|
5
5
|
export { useMapStyleUrl } from './hooks/maps.js';
|
|
6
|
-
export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDataSyncProgress, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useProjectSettings, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
|
|
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';
|
|
8
8
|
export { type WriteableDocument, type WriteableDocumentType, type WriteableValue, } from './lib/types.js';
|