@comapeo/core-react 1.1.0 → 2.0.1

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.
Files changed (46) hide show
  1. package/dist/commonjs/hooks/client.d.ts +21 -0
  2. package/dist/commonjs/hooks/client.js +20 -0
  3. package/dist/commonjs/hooks/documents.d.ts +61 -6
  4. package/dist/commonjs/hooks/documents.js +54 -0
  5. package/dist/commonjs/hooks/invites.d.ts +51 -0
  6. package/dist/commonjs/hooks/invites.js +50 -0
  7. package/dist/commonjs/hooks/projects.d.ts +83 -0
  8. package/dist/commonjs/hooks/projects.js +62 -0
  9. package/dist/commonjs/index.d.ts +10 -9
  10. package/dist/commonjs/index.js +21 -21
  11. package/dist/commonjs/lib/react-query/client.d.ts +40 -9
  12. package/dist/commonjs/lib/react-query/client.js +32 -0
  13. package/dist/commonjs/lib/react-query/documents.d.ts +733 -650
  14. package/dist/commonjs/lib/react-query/documents.js +57 -0
  15. package/dist/commonjs/lib/react-query/invites.d.ts +63 -4
  16. package/dist/commonjs/lib/react-query/invites.js +63 -0
  17. package/dist/commonjs/lib/react-query/maps.d.ts +12 -3
  18. package/dist/commonjs/lib/react-query/maps.js +5 -1
  19. package/dist/commonjs/lib/react-query/projects.d.ts +183 -47
  20. package/dist/commonjs/lib/react-query/projects.js +88 -0
  21. package/dist/commonjs/lib/react-query/shared.d.ts +5 -1
  22. package/dist/commonjs/lib/react-query/shared.js +8 -1
  23. package/dist/esm/hooks/client.d.ts +21 -0
  24. package/dist/esm/hooks/client.js +20 -2
  25. package/dist/esm/hooks/documents.d.ts +61 -6
  26. package/dist/esm/hooks/documents.js +53 -2
  27. package/dist/esm/hooks/invites.d.ts +51 -0
  28. package/dist/esm/hooks/invites.js +44 -0
  29. package/dist/esm/hooks/projects.d.ts +83 -0
  30. package/dist/esm/hooks/projects.js +58 -2
  31. package/dist/esm/index.d.ts +10 -9
  32. package/dist/esm/index.js +10 -9
  33. package/dist/esm/lib/react-query/client.d.ts +40 -9
  34. package/dist/esm/lib/react-query/client.js +32 -2
  35. package/dist/esm/lib/react-query/documents.d.ts +733 -650
  36. package/dist/esm/lib/react-query/documents.js +56 -2
  37. package/dist/esm/lib/react-query/invites.d.ts +63 -4
  38. package/dist/esm/lib/react-query/invites.js +61 -2
  39. package/dist/esm/lib/react-query/maps.d.ts +12 -3
  40. package/dist/esm/lib/react-query/maps.js +5 -1
  41. package/dist/esm/lib/react-query/projects.d.ts +183 -47
  42. package/dist/esm/lib/react-query/projects.js +84 -2
  43. package/dist/esm/lib/react-query/shared.d.ts +5 -1
  44. package/dist/esm/lib/react-query/shared.js +7 -1
  45. package/docs/API.md +157 -258
  46. package/package.json +31 -28
@@ -57,3 +57,24 @@ export declare function useIsArchiveDevice(): {
57
57
  error: Error | null;
58
58
  isRefetching: boolean;
59
59
  };
60
+ /**
61
+ * Update the device info for the current device.
62
+ */
63
+ export declare function useSetOwnDeviceInfo(): {
64
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
65
+ name: string;
66
+ deviceType: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).DeviceInfo["deviceType"];
67
+ }, unknown>;
68
+ reset: () => void;
69
+ status: "pending" | "error" | "success" | "idle";
70
+ };
71
+ /**
72
+ * Set or unset the current device as an archive device.
73
+ */
74
+ export declare function useSetIsArchiveDevice(): {
75
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
76
+ isArchiveDevice: boolean;
77
+ }, unknown>;
78
+ reset: () => void;
79
+ status: "pending" | "error" | "success" | "idle";
80
+ };
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useClientApi = useClientApi;
4
4
  exports.useOwnDeviceInfo = useOwnDeviceInfo;
5
5
  exports.useIsArchiveDevice = useIsArchiveDevice;
6
+ exports.useSetOwnDeviceInfo = useSetOwnDeviceInfo;
7
+ exports.useSetIsArchiveDevice = useSetIsArchiveDevice;
6
8
  const react_query_1 = require("@tanstack/react-query");
7
9
  const react_1 = require("react");
8
10
  const ClientApi_js_1 = require("../contexts/ClientApi.js");
@@ -69,3 +71,21 @@ function useIsArchiveDevice() {
69
71
  const { data, error, isRefetching } = (0, react_query_1.useSuspenseQuery)((0, client_js_1.isArchiveDeviceQueryOptions)({ clientApi }));
70
72
  return { data, error, isRefetching };
71
73
  }
74
+ /**
75
+ * Update the device info for the current device.
76
+ */
77
+ function useSetOwnDeviceInfo() {
78
+ const queryClient = (0, react_query_1.useQueryClient)();
79
+ const clientApi = useClientApi();
80
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, client_js_1.setOwnDeviceInfoMutationOptions)({ clientApi, queryClient }));
81
+ return { mutate, reset, status };
82
+ }
83
+ /**
84
+ * Set or unset the current device as an archive device.
85
+ */
86
+ function useSetIsArchiveDevice() {
87
+ const queryClient = (0, react_query_1.useQueryClient)();
88
+ const clientApi = useClientApi();
89
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, client_js_1.setIsArchiveDeviceMutationOptions)({ clientApi, queryClient }));
90
+ return { mutate, reset, status };
91
+ }
@@ -1,5 +1,5 @@
1
1
  import type { MapeoDoc } from '@comapeo/schema' with { 'resolution-mode': 'import' };
2
- import { type DocumentType } from '../lib/react-query/documents.js';
2
+ import { type WriteableDocumentType } from '../lib/react-query/documents.js';
3
3
  type ReadHookResult<D> = {
4
4
  data: D;
5
5
  error: Error | null;
@@ -28,7 +28,7 @@ type ReadHookResult<D> = {
28
28
  * }
29
29
  * ```
30
30
  */
31
- export declare function useSingleDocByDocId<D extends DocumentType>({ projectId, docType, docId, lang, }: {
31
+ export declare function useSingleDocByDocId<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: {
32
32
  projectId: string;
33
33
  docType: D;
34
34
  docId: string;
@@ -59,7 +59,7 @@ export declare function useSingleDocByDocId<D extends DocumentType>({ projectId,
59
59
  * }
60
60
  * ```
61
61
  */
62
- export declare function useSingleDocByVersionId<D extends DocumentType>({ projectId, docType, versionId, lang, }: {
62
+ export declare function useSingleDocByVersionId<D extends WriteableDocumentType>({ projectId, docType, versionId, lang, }: {
63
63
  projectId: string;
64
64
  docType: D;
65
65
  versionId: string;
@@ -101,12 +101,67 @@ export declare function useSingleDocByVersionId<D extends DocumentType>({ projec
101
101
  * }
102
102
  * ```
103
103
  */
104
- export declare function useManyDocs<D extends DocumentType>({ projectId, docType, includeDeleted, lang, }: {
104
+ export declare function useManyDocs<D extends WriteableDocumentType>({ projectId, docType, includeDeleted, lang, }: {
105
105
  projectId: string;
106
106
  docType: D;
107
107
  includeDeleted?: boolean;
108
108
  lang?: string;
109
- }): ReadHookResult<Extract<MapeoDoc, {
109
+ }): ReadHookResult<Array<Extract<MapeoDoc, {
110
110
  schemaName: D;
111
- }>>;
111
+ }>>>;
112
+ /**
113
+ * Create a document for a project.
114
+ *
115
+ * @param opts.docType Document type to create.
116
+ * @param opts.projectId Public ID of project to create document for.
117
+ */
118
+ export declare function useCreateDocument<D extends WriteableDocumentType>({ docType, projectId, }: {
119
+ docType: D;
120
+ projectId: string;
121
+ }): {
122
+ mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/react-query/documents.js").WriteableDocument<D> & {
123
+ forks: Array<string>;
124
+ }, Error, {
125
+ value: Omit<import("../lib/react-query/documents.js").WriteableValue<D>, "schemaName">;
126
+ }, unknown>;
127
+ reset: () => void;
128
+ status: "pending" | "error" | "success" | "idle";
129
+ };
130
+ /**
131
+ * Update a document within a project.
132
+ *
133
+ * @param opts.docType Document type to update.
134
+ * @param opts.projectId Public ID of project document belongs to.
135
+ */
136
+ export declare function useUpdateDocument<D extends WriteableDocumentType>({ docType, projectId, }: {
137
+ docType: D;
138
+ projectId: string;
139
+ }): {
140
+ mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/react-query/documents.js").WriteableDocument<D> & {
141
+ forks: Array<string>;
142
+ }, Error, {
143
+ versionId: string;
144
+ value: Omit<import("../lib/react-query/documents.js").WriteableValue<D>, "schemaName">;
145
+ }, unknown>;
146
+ reset: () => void;
147
+ status: "pending" | "error" | "success" | "idle";
148
+ };
149
+ /**
150
+ * Delete a document within a project.
151
+ *
152
+ * @param opts.docType Document type to delete.
153
+ * @param opts.projectId Public ID of project document belongs to.
154
+ */
155
+ export declare function useDeleteDocument<D extends WriteableDocumentType>({ docType, projectId, }: {
156
+ docType: D;
157
+ projectId: string;
158
+ }): {
159
+ mutate: import("@tanstack/react-query").UseMutateFunction<import("../lib/react-query/documents.js").WriteableDocument<D> & {
160
+ forks: Array<string>;
161
+ }, Error, {
162
+ docId: string;
163
+ }, unknown>;
164
+ reset: () => void;
165
+ status: "pending" | "error" | "success" | "idle";
166
+ };
112
167
  export {};
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSingleDocByDocId = useSingleDocByDocId;
4
4
  exports.useSingleDocByVersionId = useSingleDocByVersionId;
5
5
  exports.useManyDocs = useManyDocs;
6
+ exports.useCreateDocument = useCreateDocument;
7
+ exports.useUpdateDocument = useUpdateDocument;
8
+ exports.useDeleteDocument = useDeleteDocument;
6
9
  const react_query_1 = require("@tanstack/react-query");
7
10
  const documents_js_1 = require("../lib/react-query/documents.js");
8
11
  const projects_js_1 = require("./projects.js");
@@ -136,3 +139,54 @@ function useManyDocs({ projectId, docType, includeDeleted, lang, }) {
136
139
  isRefetching,
137
140
  };
138
141
  }
142
+ /**
143
+ * Create a document for a project.
144
+ *
145
+ * @param opts.docType Document type to create.
146
+ * @param opts.projectId Public ID of project to create document for.
147
+ */
148
+ function useCreateDocument({ docType, projectId, }) {
149
+ const queryClient = (0, react_query_1.useQueryClient)();
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)({
152
+ docType,
153
+ projectApi,
154
+ projectId,
155
+ queryClient,
156
+ }));
157
+ return { mutate, reset, status };
158
+ }
159
+ /**
160
+ * Update a document within a project.
161
+ *
162
+ * @param opts.docType Document type to update.
163
+ * @param opts.projectId Public ID of project document belongs to.
164
+ */
165
+ function useUpdateDocument({ docType, projectId, }) {
166
+ const queryClient = (0, react_query_1.useQueryClient)();
167
+ const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
168
+ const { mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.updateDocumentMutationOptions)({
169
+ docType,
170
+ projectApi,
171
+ projectId,
172
+ queryClient,
173
+ }));
174
+ return { mutate, reset, status };
175
+ }
176
+ /**
177
+ * Delete a document within a project.
178
+ *
179
+ * @param opts.docType Document type to delete.
180
+ * @param opts.projectId Public ID of project document belongs to.
181
+ */
182
+ function useDeleteDocument({ docType, projectId, }) {
183
+ const queryClient = (0, react_query_1.useQueryClient)();
184
+ const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
185
+ const { mutate, reset, status } = (0, react_query_1.useMutation)((0, documents_js_1.deleteDocumentMutationOptions)({
186
+ docType,
187
+ projectApi,
188
+ projectId,
189
+ queryClient,
190
+ }));
191
+ return { mutate, reset, status };
192
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Accept an invite that has been received.
3
+ */
4
+ export declare function useAcceptInvite(): {
5
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
6
+ inviteId: string;
7
+ }, unknown>;
8
+ reset: () => void;
9
+ status: "pending" | "error" | "success" | "idle";
10
+ };
11
+ /**
12
+ * Reject an invite that has been received.
13
+ */
14
+ export declare function useRejectInvite(): {
15
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
16
+ inviteId: string;
17
+ }, unknown>;
18
+ reset: () => void;
19
+ status: "pending" | "error" | "success" | "idle";
20
+ };
21
+ /**
22
+ * Send an invite for a project.
23
+ *
24
+ * @param opts.projectId Public ID of project to send the invite on behalf of.
25
+ */
26
+ export declare function useSendInvite({ projectId }: {
27
+ projectId: string;
28
+ }): {
29
+ mutate: import("@tanstack/react-query").UseMutateFunction<"ACCEPT" | "REJECT" | "ALREADY", Error, {
30
+ deviceId: string;
31
+ roleDescription?: string;
32
+ roleId: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).RoleIdForNewInvite;
33
+ roleName?: string;
34
+ }, unknown>;
35
+ reset: () => void;
36
+ status: "pending" | "error" | "success" | "idle";
37
+ };
38
+ /**
39
+ * Request a cancellation of an invite sent to another device.
40
+ *
41
+ * @param opts.projectId Public ID of project to request the invite cancellation for.
42
+ */
43
+ export declare function useRequestCancelInvite({ projectId }: {
44
+ projectId: string;
45
+ }): {
46
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
47
+ deviceId: string;
48
+ }, unknown>;
49
+ reset: () => void;
50
+ status: "pending" | "error" | "success" | "idle";
51
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useAcceptInvite = useAcceptInvite;
4
+ exports.useRejectInvite = useRejectInvite;
5
+ exports.useSendInvite = useSendInvite;
6
+ exports.useRequestCancelInvite = useRequestCancelInvite;
7
+ const react_query_1 = require("@tanstack/react-query");
8
+ const invites_js_1 = require("../lib/react-query/invites.js");
9
+ const client_js_1 = require("./client.js");
10
+ const projects_js_1 = require("./projects.js");
11
+ /**
12
+ * Accept an invite that has been received.
13
+ */
14
+ function useAcceptInvite() {
15
+ const queryClient = (0, react_query_1.useQueryClient)();
16
+ const clientApi = (0, client_js_1.useClientApi)();
17
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, invites_js_1.acceptInviteMutationOptions)({ clientApi, queryClient }));
18
+ return { mutate, reset, status };
19
+ }
20
+ /**
21
+ * Reject an invite that has been received.
22
+ */
23
+ function useRejectInvite() {
24
+ const queryClient = (0, react_query_1.useQueryClient)();
25
+ const clientApi = (0, client_js_1.useClientApi)();
26
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, invites_js_1.rejectInviteMutationOptions)({ clientApi, queryClient }));
27
+ return { mutate, reset, status };
28
+ }
29
+ /**
30
+ * Send an invite for a project.
31
+ *
32
+ * @param opts.projectId Public ID of project to send the invite on behalf of.
33
+ */
34
+ function useSendInvite({ projectId }) {
35
+ const queryClient = (0, react_query_1.useQueryClient)();
36
+ const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
37
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, invites_js_1.sendInviteMutationOptions)({ projectApi, projectId, queryClient }));
38
+ return { mutate, reset, status };
39
+ }
40
+ /**
41
+ * Request a cancellation of an invite sent to another device.
42
+ *
43
+ * @param opts.projectId Public ID of project to request the invite cancellation for.
44
+ */
45
+ function useRequestCancelInvite({ projectId }) {
46
+ const queryClient = (0, react_query_1.useQueryClient)();
47
+ const { data: projectApi } = (0, projects_js_1.useSingleProject)({ projectId });
48
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, invites_js_1.requestCancelInviteMutationOptions)({ projectApi, queryClient }));
49
+ return { mutate, reset, status };
50
+ }
@@ -249,3 +249,86 @@ export declare function useDocumentCreatedBy({ projectId, originalVersionId, }:
249
249
  error: Error | null;
250
250
  isRefetching: boolean;
251
251
  };
252
+ export declare function useAddServerPeer({ projectId }: {
253
+ projectId: string;
254
+ }): {
255
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
256
+ baseUrl: string;
257
+ dangerouslyAllowInsecureConnections?: boolean;
258
+ }, unknown>;
259
+ reset: () => void;
260
+ status: "pending" | "error" | "success" | "idle";
261
+ };
262
+ /**
263
+ * Create a new project.
264
+ */
265
+ export declare function useCreateProject(): {
266
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
267
+ name?: string;
268
+ configPath?: string;
269
+ } | undefined, unknown>;
270
+ reset: () => void;
271
+ status: "pending" | "error" | "success" | "idle";
272
+ };
273
+ /**
274
+ * Leave an existing project.
275
+ */
276
+ export declare function useLeaveProject(): {
277
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
278
+ projectId: string;
279
+ }, unknown>;
280
+ reset: () => void;
281
+ status: "pending" | "error" | "success" | "idle";
282
+ };
283
+ /**
284
+ * Update the configuration of a project using an external file.
285
+ *
286
+ * @param opts.projectId Public ID of the project to apply changes to.
287
+ */
288
+ export declare function useImportProjectConfig({ projectId }: {
289
+ projectId: string;
290
+ }): {
291
+ mutate: import("@tanstack/react-query").UseMutateFunction<Error[], Error, {
292
+ configPath: string;
293
+ }, unknown>;
294
+ reset: () => void;
295
+ status: "pending" | "error" | "success" | "idle";
296
+ };
297
+ /**
298
+ * Update the settings of a project.
299
+ *
300
+ * @param opts.projectId Public ID of the project to apply changes to.
301
+ */
302
+ export declare function useUpdateProjectSettings({ projectId }: {
303
+ projectId: string;
304
+ }): {
305
+ mutate: import("@tanstack/react-query").UseMutateFunction<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, Error, {
306
+ name?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["name"];
307
+ configMetadata?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["configMetadata"];
308
+ defaultPresets?: import("@comapeo/schema", { with: { "resolution-mode": "import" } }).ProjectSettings["defaultPresets"];
309
+ }, unknown>;
310
+ reset: () => void;
311
+ status: "pending" | "error" | "success" | "idle";
312
+ };
313
+ /**
314
+ * Create a blob for a project.
315
+ *
316
+ * @param opts.projectId Public project ID of project to apply to changes to.
317
+ */
318
+ export declare function useCreateBlob({ projectId }: {
319
+ projectId: string;
320
+ }): {
321
+ mutate: import("@tanstack/react-query").UseMutateFunction<{
322
+ driveId: string;
323
+ name: string;
324
+ type: "photo" | "video" | "audio";
325
+ hash: string;
326
+ }, Error, {
327
+ original: string;
328
+ preview?: string;
329
+ thumbnail?: string;
330
+ metadata: import("@comapeo/core/dist/blob-api.js", { with: { "resolution-mode": "import" } }).Metadata;
331
+ }, unknown>;
332
+ reset: () => void;
333
+ status: "pending" | "error" | "success" | "idle";
334
+ };
@@ -8,6 +8,12 @@ exports.useManyMembers = useManyMembers;
8
8
  exports.useIconUrl = useIconUrl;
9
9
  exports.useAttachmentUrl = useAttachmentUrl;
10
10
  exports.useDocumentCreatedBy = useDocumentCreatedBy;
11
+ exports.useAddServerPeer = useAddServerPeer;
12
+ exports.useCreateProject = useCreateProject;
13
+ exports.useLeaveProject = useLeaveProject;
14
+ exports.useImportProjectConfig = useImportProjectConfig;
15
+ exports.useUpdateProjectSettings = useUpdateProjectSettings;
16
+ exports.useCreateBlob = useCreateBlob;
11
17
  const react_query_1 = require("@tanstack/react-query");
12
18
  const projects_js_1 = require("../lib/react-query/projects.js");
13
19
  const client_js_1 = require("./client.js");
@@ -256,3 +262,59 @@ function useDocumentCreatedBy({ projectId, originalVersionId, }) {
256
262
  const { data, error, isRefetching } = (0, react_query_1.useSuspenseQuery)((0, projects_js_1.documentCreatedByQueryOptions)({ projectApi, projectId, originalVersionId }));
257
263
  return { data, error, isRefetching };
258
264
  }
265
+ function useAddServerPeer({ projectId }) {
266
+ const queryClient = (0, react_query_1.useQueryClient)();
267
+ const { data: projectApi } = useSingleProject({ projectId });
268
+ const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.addServerPeerMutationOptions)({ projectApi, projectId, queryClient }));
269
+ return { mutate, reset, status };
270
+ }
271
+ /**
272
+ * Create a new project.
273
+ */
274
+ function useCreateProject() {
275
+ const queryClient = (0, react_query_1.useQueryClient)();
276
+ const clientApi = (0, client_js_1.useClientApi)();
277
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, projects_js_1.createProjectMutationOptions)({ clientApi, queryClient }));
278
+ return { mutate, reset, status };
279
+ }
280
+ /**
281
+ * Leave an existing project.
282
+ */
283
+ function useLeaveProject() {
284
+ const queryClient = (0, react_query_1.useQueryClient)();
285
+ const clientApi = (0, client_js_1.useClientApi)();
286
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, projects_js_1.leaveProjectMutationOptions)({ clientApi, queryClient }));
287
+ return { mutate, reset, status };
288
+ }
289
+ /**
290
+ * Update the configuration of a project using an external file.
291
+ *
292
+ * @param opts.projectId Public ID of the project to apply changes to.
293
+ */
294
+ function useImportProjectConfig({ projectId }) {
295
+ const queryClient = (0, react_query_1.useQueryClient)();
296
+ const { data: projectApi } = useSingleProject({ projectId });
297
+ const { mutate, status, reset } = (0, react_query_1.useMutation)((0, projects_js_1.importProjectConfigMutationOptions)({ queryClient, projectApi, projectId }));
298
+ return { mutate, reset, status };
299
+ }
300
+ /**
301
+ * Update the settings of a project.
302
+ *
303
+ * @param opts.projectId Public ID of the project to apply changes to.
304
+ */
305
+ function useUpdateProjectSettings({ projectId }) {
306
+ const queryClient = (0, react_query_1.useQueryClient)();
307
+ const { data: projectApi } = useSingleProject({ projectId });
308
+ const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.updateProjectSettingsMutationOptions)({ projectApi, queryClient }));
309
+ return { mutate, reset, status };
310
+ }
311
+ /**
312
+ * Create a blob for a project.
313
+ *
314
+ * @param opts.projectId Public project ID of project to apply to changes to.
315
+ */
316
+ function useCreateBlob({ projectId }) {
317
+ const { data: projectApi } = useSingleProject({ projectId });
318
+ const { mutate, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.createBlobMutationOptions)({ projectApi }));
319
+ return { mutate, reset, status };
320
+ }
@@ -1,11 +1,12 @@
1
1
  export { ClientApiContext, ClientApiProvider } from './contexts/ClientApi.js';
2
- export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, } from './hooks/client.js';
3
- export { useManyDocs, useSingleDocByDocId, useSingleDocByVersionId, } from './hooks/documents.js';
2
+ export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
3
+ export { useCreateDocument, useDeleteDocument, useManyDocs, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
4
+ export { useAcceptInvite, useRejectInvite, useRequestCancelInvite, useSendInvite, } from './hooks/invites.js';
4
5
  export { useMapStyleUrl } from './hooks/maps.js';
5
- export { useAttachmentUrl, useDocumentCreatedBy, useIconUrl, useManyMembers, useManyProjects, useProjectSettings, useSingleMember, useSingleProject, } from './hooks/projects.js';
6
- export { deviceInfoQueryOptions, getClientQueryKey, getDeviceInfoQueryKey, getIsArchiveDeviceQueryKey, isArchiveDeviceQueryOptions, } from './lib/react-query/client.js';
7
- export { documentByDocumentIdQueryOptions, documentByVersionIdQueryOptions, documentsQueryOptions, getDocumentByDocIdQueryKey, getDocumentByVersionIdQueryKey, getDocumentsQueryKey, getManyDocumentsQueryKey, type DocumentType, } from './lib/react-query/documents.js';
8
- export { getInvitesQueryKey, getPendingInvitesQueryKey, pendingInvitesQueryOptions, } from './lib/react-query/invites.js';
9
- export { getMapsQueryKey, getStyleJsonUrlQueryKey, mapStyleJsonUrlQueryOptions, } from './lib/react-query/maps.js';
10
- export { attachmentUrlQueryOptions, documentCreatedByQueryOptions, getAttachmentUrlQueryKey, getDocumentCreatedByQueryKey, getIconUrlQueryKey, getMemberByIdQueryKey, getMembersQueryKey, getProjectByIdQueryKey, getProjectRoleQueryKey, getProjectSettingsQueryKey, getProjectsQueryKey, iconUrlQueryOptions, projectByIdQueryOptions, projectMembersQueryOptions, projectOwnRoleQueryOptions, projectSettingsQueryOptions, projectsQueryOptions, } from './lib/react-query/projects.js';
11
- export { ROOT_QUERY_KEY, baseQueryOptions } from './lib/react-query/shared.js';
6
+ export { useAddServerPeer, useAttachmentUrl, useCreateBlob, useCreateProject, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useProjectSettings, useSingleMember, useSingleProject, useUpdateProjectSettings, } from './hooks/projects.js';
7
+ export { getClientQueryKey, getDeviceInfoQueryKey, getIsArchiveDeviceQueryKey, } from './lib/react-query/client.js';
8
+ export { getDocumentByDocIdQueryKey, getDocumentByVersionIdQueryKey, getDocumentsQueryKey, getManyDocumentsQueryKey, type WriteableDocument, type WriteableDocumentType, type WriteableValue, } from './lib/react-query/documents.js';
9
+ export { getInvitesQueryKey, getPendingInvitesQueryKey, } from './lib/react-query/invites.js';
10
+ export { getMapsQueryKey, getStyleJsonUrlQueryKey, } from './lib/react-query/maps.js';
11
+ export { getAttachmentUrlQueryKey, getDocumentCreatedByQueryKey, getIconUrlQueryKey, getMemberByIdQueryKey, getMembersQueryKey, getProjectByIdQueryKey, getProjectRoleQueryKey, getProjectSettingsQueryKey, getProjectsQueryKey, } from './lib/react-query/projects.js';
12
+ export { ROOT_QUERY_KEY } from './lib/react-query/shared.js';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projectOwnRoleQueryOptions = exports.projectMembersQueryOptions = exports.projectByIdQueryOptions = exports.iconUrlQueryOptions = exports.getProjectsQueryKey = exports.getProjectSettingsQueryKey = exports.getProjectRoleQueryKey = exports.getProjectByIdQueryKey = exports.getMembersQueryKey = exports.getMemberByIdQueryKey = exports.getIconUrlQueryKey = exports.getDocumentCreatedByQueryKey = exports.getAttachmentUrlQueryKey = exports.documentCreatedByQueryOptions = exports.attachmentUrlQueryOptions = exports.mapStyleJsonUrlQueryOptions = exports.getStyleJsonUrlQueryKey = exports.getMapsQueryKey = exports.pendingInvitesQueryOptions = exports.getPendingInvitesQueryKey = exports.getInvitesQueryKey = exports.getManyDocumentsQueryKey = exports.getDocumentsQueryKey = exports.getDocumentByVersionIdQueryKey = exports.getDocumentByDocIdQueryKey = exports.documentsQueryOptions = exports.documentByVersionIdQueryOptions = exports.documentByDocumentIdQueryOptions = exports.isArchiveDeviceQueryOptions = exports.getIsArchiveDeviceQueryKey = exports.getDeviceInfoQueryKey = exports.getClientQueryKey = exports.deviceInfoQueryOptions = exports.useSingleProject = exports.useSingleMember = exports.useProjectSettings = exports.useManyProjects = exports.useManyMembers = exports.useIconUrl = exports.useDocumentCreatedBy = exports.useAttachmentUrl = exports.useMapStyleUrl = exports.useSingleDocByVersionId = exports.useSingleDocByDocId = exports.useManyDocs = exports.useOwnDeviceInfo = exports.useIsArchiveDevice = exports.useClientApi = exports.ClientApiProvider = exports.ClientApiContext = void 0;
4
- exports.baseQueryOptions = exports.ROOT_QUERY_KEY = exports.projectsQueryOptions = exports.projectSettingsQueryOptions = void 0;
3
+ exports.getProjectRoleQueryKey = exports.getProjectByIdQueryKey = exports.getMembersQueryKey = exports.getMemberByIdQueryKey = exports.getIconUrlQueryKey = exports.getDocumentCreatedByQueryKey = exports.getAttachmentUrlQueryKey = exports.getStyleJsonUrlQueryKey = exports.getMapsQueryKey = exports.getPendingInvitesQueryKey = exports.getInvitesQueryKey = exports.getManyDocumentsQueryKey = exports.getDocumentsQueryKey = exports.getDocumentByVersionIdQueryKey = exports.getDocumentByDocIdQueryKey = exports.getIsArchiveDeviceQueryKey = exports.getDeviceInfoQueryKey = exports.getClientQueryKey = exports.useUpdateProjectSettings = exports.useSingleProject = exports.useSingleMember = exports.useProjectSettings = exports.useManyProjects = exports.useManyMembers = exports.useLeaveProject = exports.useImportProjectConfig = exports.useIconUrl = exports.useDocumentCreatedBy = exports.useCreateProject = exports.useCreateBlob = exports.useAttachmentUrl = exports.useAddServerPeer = exports.useMapStyleUrl = exports.useSendInvite = exports.useRequestCancelInvite = exports.useRejectInvite = exports.useAcceptInvite = exports.useUpdateDocument = exports.useSingleDocByVersionId = exports.useSingleDocByDocId = exports.useManyDocs = exports.useDeleteDocument = exports.useCreateDocument = exports.useSetOwnDeviceInfo = exports.useSetIsArchiveDevice = exports.useOwnDeviceInfo = exports.useIsArchiveDevice = exports.useClientApi = exports.ClientApiProvider = exports.ClientApiContext = void 0;
4
+ exports.ROOT_QUERY_KEY = exports.getProjectsQueryKey = exports.getProjectSettingsQueryKey = void 0;
5
5
  var ClientApi_js_1 = require("./contexts/ClientApi.js");
6
6
  Object.defineProperty(exports, "ClientApiContext", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiContext; } });
7
7
  Object.defineProperty(exports, "ClientApiProvider", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiProvider; } });
@@ -9,46 +9,53 @@ var client_js_1 = require("./hooks/client.js");
9
9
  Object.defineProperty(exports, "useClientApi", { enumerable: true, get: function () { return client_js_1.useClientApi; } });
10
10
  Object.defineProperty(exports, "useIsArchiveDevice", { enumerable: true, get: function () { return client_js_1.useIsArchiveDevice; } });
11
11
  Object.defineProperty(exports, "useOwnDeviceInfo", { enumerable: true, get: function () { return client_js_1.useOwnDeviceInfo; } });
12
+ Object.defineProperty(exports, "useSetIsArchiveDevice", { enumerable: true, get: function () { return client_js_1.useSetIsArchiveDevice; } });
13
+ Object.defineProperty(exports, "useSetOwnDeviceInfo", { enumerable: true, get: function () { return client_js_1.useSetOwnDeviceInfo; } });
12
14
  var documents_js_1 = require("./hooks/documents.js");
15
+ Object.defineProperty(exports, "useCreateDocument", { enumerable: true, get: function () { return documents_js_1.useCreateDocument; } });
16
+ Object.defineProperty(exports, "useDeleteDocument", { enumerable: true, get: function () { return documents_js_1.useDeleteDocument; } });
13
17
  Object.defineProperty(exports, "useManyDocs", { enumerable: true, get: function () { return documents_js_1.useManyDocs; } });
14
18
  Object.defineProperty(exports, "useSingleDocByDocId", { enumerable: true, get: function () { return documents_js_1.useSingleDocByDocId; } });
15
19
  Object.defineProperty(exports, "useSingleDocByVersionId", { enumerable: true, get: function () { return documents_js_1.useSingleDocByVersionId; } });
20
+ Object.defineProperty(exports, "useUpdateDocument", { enumerable: true, get: function () { return documents_js_1.useUpdateDocument; } });
21
+ var invites_js_1 = require("./hooks/invites.js");
22
+ Object.defineProperty(exports, "useAcceptInvite", { enumerable: true, get: function () { return invites_js_1.useAcceptInvite; } });
23
+ Object.defineProperty(exports, "useRejectInvite", { enumerable: true, get: function () { return invites_js_1.useRejectInvite; } });
24
+ Object.defineProperty(exports, "useRequestCancelInvite", { enumerable: true, get: function () { return invites_js_1.useRequestCancelInvite; } });
25
+ Object.defineProperty(exports, "useSendInvite", { enumerable: true, get: function () { return invites_js_1.useSendInvite; } });
16
26
  var maps_js_1 = require("./hooks/maps.js");
17
27
  Object.defineProperty(exports, "useMapStyleUrl", { enumerable: true, get: function () { return maps_js_1.useMapStyleUrl; } });
18
28
  var projects_js_1 = require("./hooks/projects.js");
29
+ Object.defineProperty(exports, "useAddServerPeer", { enumerable: true, get: function () { return projects_js_1.useAddServerPeer; } });
19
30
  Object.defineProperty(exports, "useAttachmentUrl", { enumerable: true, get: function () { return projects_js_1.useAttachmentUrl; } });
31
+ Object.defineProperty(exports, "useCreateBlob", { enumerable: true, get: function () { return projects_js_1.useCreateBlob; } });
32
+ Object.defineProperty(exports, "useCreateProject", { enumerable: true, get: function () { return projects_js_1.useCreateProject; } });
20
33
  Object.defineProperty(exports, "useDocumentCreatedBy", { enumerable: true, get: function () { return projects_js_1.useDocumentCreatedBy; } });
21
34
  Object.defineProperty(exports, "useIconUrl", { enumerable: true, get: function () { return projects_js_1.useIconUrl; } });
35
+ Object.defineProperty(exports, "useImportProjectConfig", { enumerable: true, get: function () { return projects_js_1.useImportProjectConfig; } });
36
+ Object.defineProperty(exports, "useLeaveProject", { enumerable: true, get: function () { return projects_js_1.useLeaveProject; } });
22
37
  Object.defineProperty(exports, "useManyMembers", { enumerable: true, get: function () { return projects_js_1.useManyMembers; } });
23
38
  Object.defineProperty(exports, "useManyProjects", { enumerable: true, get: function () { return projects_js_1.useManyProjects; } });
24
39
  Object.defineProperty(exports, "useProjectSettings", { enumerable: true, get: function () { return projects_js_1.useProjectSettings; } });
25
40
  Object.defineProperty(exports, "useSingleMember", { enumerable: true, get: function () { return projects_js_1.useSingleMember; } });
26
41
  Object.defineProperty(exports, "useSingleProject", { enumerable: true, get: function () { return projects_js_1.useSingleProject; } });
42
+ Object.defineProperty(exports, "useUpdateProjectSettings", { enumerable: true, get: function () { return projects_js_1.useUpdateProjectSettings; } });
27
43
  var client_js_2 = require("./lib/react-query/client.js");
28
- Object.defineProperty(exports, "deviceInfoQueryOptions", { enumerable: true, get: function () { return client_js_2.deviceInfoQueryOptions; } });
29
44
  Object.defineProperty(exports, "getClientQueryKey", { enumerable: true, get: function () { return client_js_2.getClientQueryKey; } });
30
45
  Object.defineProperty(exports, "getDeviceInfoQueryKey", { enumerable: true, get: function () { return client_js_2.getDeviceInfoQueryKey; } });
31
46
  Object.defineProperty(exports, "getIsArchiveDeviceQueryKey", { enumerable: true, get: function () { return client_js_2.getIsArchiveDeviceQueryKey; } });
32
- Object.defineProperty(exports, "isArchiveDeviceQueryOptions", { enumerable: true, get: function () { return client_js_2.isArchiveDeviceQueryOptions; } });
33
47
  var documents_js_2 = require("./lib/react-query/documents.js");
34
- Object.defineProperty(exports, "documentByDocumentIdQueryOptions", { enumerable: true, get: function () { return documents_js_2.documentByDocumentIdQueryOptions; } });
35
- Object.defineProperty(exports, "documentByVersionIdQueryOptions", { enumerable: true, get: function () { return documents_js_2.documentByVersionIdQueryOptions; } });
36
- Object.defineProperty(exports, "documentsQueryOptions", { enumerable: true, get: function () { return documents_js_2.documentsQueryOptions; } });
37
48
  Object.defineProperty(exports, "getDocumentByDocIdQueryKey", { enumerable: true, get: function () { return documents_js_2.getDocumentByDocIdQueryKey; } });
38
49
  Object.defineProperty(exports, "getDocumentByVersionIdQueryKey", { enumerable: true, get: function () { return documents_js_2.getDocumentByVersionIdQueryKey; } });
39
50
  Object.defineProperty(exports, "getDocumentsQueryKey", { enumerable: true, get: function () { return documents_js_2.getDocumentsQueryKey; } });
40
51
  Object.defineProperty(exports, "getManyDocumentsQueryKey", { enumerable: true, get: function () { return documents_js_2.getManyDocumentsQueryKey; } });
41
- var invites_js_1 = require("./lib/react-query/invites.js");
42
- Object.defineProperty(exports, "getInvitesQueryKey", { enumerable: true, get: function () { return invites_js_1.getInvitesQueryKey; } });
43
- Object.defineProperty(exports, "getPendingInvitesQueryKey", { enumerable: true, get: function () { return invites_js_1.getPendingInvitesQueryKey; } });
44
- Object.defineProperty(exports, "pendingInvitesQueryOptions", { enumerable: true, get: function () { return invites_js_1.pendingInvitesQueryOptions; } });
52
+ var invites_js_2 = require("./lib/react-query/invites.js");
53
+ Object.defineProperty(exports, "getInvitesQueryKey", { enumerable: true, get: function () { return invites_js_2.getInvitesQueryKey; } });
54
+ Object.defineProperty(exports, "getPendingInvitesQueryKey", { enumerable: true, get: function () { return invites_js_2.getPendingInvitesQueryKey; } });
45
55
  var maps_js_2 = require("./lib/react-query/maps.js");
46
56
  Object.defineProperty(exports, "getMapsQueryKey", { enumerable: true, get: function () { return maps_js_2.getMapsQueryKey; } });
47
57
  Object.defineProperty(exports, "getStyleJsonUrlQueryKey", { enumerable: true, get: function () { return maps_js_2.getStyleJsonUrlQueryKey; } });
48
- Object.defineProperty(exports, "mapStyleJsonUrlQueryOptions", { enumerable: true, get: function () { return maps_js_2.mapStyleJsonUrlQueryOptions; } });
49
58
  var projects_js_2 = require("./lib/react-query/projects.js");
50
- Object.defineProperty(exports, "attachmentUrlQueryOptions", { enumerable: true, get: function () { return projects_js_2.attachmentUrlQueryOptions; } });
51
- Object.defineProperty(exports, "documentCreatedByQueryOptions", { enumerable: true, get: function () { return projects_js_2.documentCreatedByQueryOptions; } });
52
59
  Object.defineProperty(exports, "getAttachmentUrlQueryKey", { enumerable: true, get: function () { return projects_js_2.getAttachmentUrlQueryKey; } });
53
60
  Object.defineProperty(exports, "getDocumentCreatedByQueryKey", { enumerable: true, get: function () { return projects_js_2.getDocumentCreatedByQueryKey; } });
54
61
  Object.defineProperty(exports, "getIconUrlQueryKey", { enumerable: true, get: function () { return projects_js_2.getIconUrlQueryKey; } });
@@ -58,12 +65,5 @@ Object.defineProperty(exports, "getProjectByIdQueryKey", { enumerable: true, get
58
65
  Object.defineProperty(exports, "getProjectRoleQueryKey", { enumerable: true, get: function () { return projects_js_2.getProjectRoleQueryKey; } });
59
66
  Object.defineProperty(exports, "getProjectSettingsQueryKey", { enumerable: true, get: function () { return projects_js_2.getProjectSettingsQueryKey; } });
60
67
  Object.defineProperty(exports, "getProjectsQueryKey", { enumerable: true, get: function () { return projects_js_2.getProjectsQueryKey; } });
61
- Object.defineProperty(exports, "iconUrlQueryOptions", { enumerable: true, get: function () { return projects_js_2.iconUrlQueryOptions; } });
62
- Object.defineProperty(exports, "projectByIdQueryOptions", { enumerable: true, get: function () { return projects_js_2.projectByIdQueryOptions; } });
63
- Object.defineProperty(exports, "projectMembersQueryOptions", { enumerable: true, get: function () { return projects_js_2.projectMembersQueryOptions; } });
64
- Object.defineProperty(exports, "projectOwnRoleQueryOptions", { enumerable: true, get: function () { return projects_js_2.projectOwnRoleQueryOptions; } });
65
- Object.defineProperty(exports, "projectSettingsQueryOptions", { enumerable: true, get: function () { return projects_js_2.projectSettingsQueryOptions; } });
66
- Object.defineProperty(exports, "projectsQueryOptions", { enumerable: true, get: function () { return projects_js_2.projectsQueryOptions; } });
67
68
  var shared_js_1 = require("./lib/react-query/shared.js");
68
69
  Object.defineProperty(exports, "ROOT_QUERY_KEY", { enumerable: true, get: function () { return shared_js_1.ROOT_QUERY_KEY; } });
69
- Object.defineProperty(exports, "baseQueryOptions", { enumerable: true, get: function () { return shared_js_1.baseQueryOptions; } });