@comapeo/core-react 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/commonjs/contexts/ClientApi.d.ts +14 -0
  2. package/dist/commonjs/contexts/ClientApi.js +16 -0
  3. package/dist/commonjs/hooks/client.d.ts +80 -0
  4. package/dist/commonjs/hooks/client.js +91 -0
  5. package/dist/{hooks → commonjs/hooks}/documents.d.ts +60 -5
  6. package/dist/commonjs/hooks/documents.js +192 -0
  7. package/dist/commonjs/hooks/invites.d.ts +51 -0
  8. package/dist/commonjs/hooks/invites.js +50 -0
  9. package/dist/commonjs/hooks/maps.js +37 -0
  10. package/dist/commonjs/hooks/projects.d.ts +334 -0
  11. package/dist/commonjs/hooks/projects.js +320 -0
  12. package/dist/commonjs/index.d.ts +12 -0
  13. package/dist/commonjs/index.js +69 -0
  14. package/dist/commonjs/lib/react-query/client.d.ts +61 -0
  15. package/dist/commonjs/lib/react-query/client.js +68 -0
  16. package/dist/{lib → commonjs/lib}/react-query/documents.d.ts +789 -706
  17. package/dist/commonjs/lib/react-query/documents.js +149 -0
  18. package/dist/commonjs/lib/react-query/invites.d.ts +71 -0
  19. package/dist/commonjs/lib/react-query/invites.js +85 -0
  20. package/dist/commonjs/lib/react-query/maps.d.ts +24 -0
  21. package/dist/commonjs/lib/react-query/maps.js +27 -0
  22. package/dist/commonjs/lib/react-query/projects.d.ts +332 -0
  23. package/dist/commonjs/lib/react-query/projects.js +235 -0
  24. package/dist/{lib → commonjs/lib}/react-query/shared.d.ts +5 -1
  25. package/dist/commonjs/lib/react-query/shared.js +23 -0
  26. package/dist/commonjs/package.json +3 -0
  27. package/dist/{contexts → esm/contexts}/ClientApi.d.ts +3 -3
  28. package/dist/{hooks → esm/hooks}/client.d.ts +23 -2
  29. package/dist/{hooks → esm/hooks}/client.js +21 -3
  30. package/dist/esm/hooks/documents.d.ts +167 -0
  31. package/dist/{hooks → esm/hooks}/documents.js +54 -3
  32. package/dist/esm/hooks/invites.d.ts +51 -0
  33. package/dist/esm/hooks/invites.js +44 -0
  34. package/dist/esm/hooks/maps.d.ts +33 -0
  35. package/dist/{hooks → esm/hooks}/maps.js +2 -2
  36. package/dist/{hooks → esm/hooks}/projects.d.ts +89 -6
  37. package/dist/{hooks → esm/hooks}/projects.js +59 -3
  38. package/dist/esm/index.d.ts +12 -0
  39. package/dist/esm/index.js +12 -0
  40. package/dist/esm/lib/react-query/client.d.ts +61 -0
  41. package/dist/esm/lib/react-query/client.js +59 -0
  42. package/dist/esm/lib/react-query/documents.d.ts +1584 -0
  43. package/dist/{lib → esm/lib}/react-query/documents.js +56 -2
  44. package/dist/esm/lib/react-query/invites.d.ts +71 -0
  45. package/dist/esm/lib/react-query/invites.js +76 -0
  46. package/dist/esm/lib/react-query/maps.d.ts +24 -0
  47. package/dist/{lib → esm/lib}/react-query/maps.js +6 -2
  48. package/dist/esm/lib/react-query/projects.d.ts +332 -0
  49. package/dist/{lib → esm/lib}/react-query/projects.js +84 -2
  50. package/dist/esm/lib/react-query/shared.d.ts +9 -0
  51. package/dist/{lib → esm/lib}/react-query/shared.js +7 -1
  52. package/dist/esm/package.json +3 -0
  53. package/docs/API.md +157 -258
  54. package/package.json +51 -37
  55. package/dist/index.d.ts +0 -11
  56. package/dist/index.js +0 -11
  57. package/dist/lib/react-query/client.d.ts +0 -30
  58. package/dist/lib/react-query/client.js +0 -29
  59. package/dist/lib/react-query/invites.d.ts +0 -12
  60. package/dist/lib/react-query/invites.js +0 -17
  61. package/dist/lib/react-query/maps.d.ts +0 -15
  62. package/dist/lib/react-query/projects.d.ts +0 -196
  63. /package/dist/{hooks → commonjs/hooks}/maps.d.ts +0 -0
  64. /package/dist/{contexts → esm/contexts}/ClientApi.js +0 -0
@@ -1,5 +1,5 @@
1
- import { queryOptions } from '@tanstack/react-query';
2
- import { baseQueryOptions, ROOT_QUERY_KEY } from './shared';
1
+ import { queryOptions, } from '@tanstack/react-query';
2
+ import { baseMutationOptions, baseQueryOptions, ROOT_QUERY_KEY, } from './shared.js';
3
3
  export function getProjectsQueryKey() {
4
4
  return [ROOT_QUERY_KEY, 'projects'];
5
5
  }
@@ -125,3 +125,85 @@ export function attachmentUrlQueryOptions({ projectApi, projectId, blobId, }) {
125
125
  },
126
126
  });
127
127
  }
128
+ export function addServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
129
+ return {
130
+ ...baseMutationOptions(),
131
+ mutationFn: async ({ baseUrl, dangerouslyAllowInsecureConnections }) => {
132
+ return projectApi.$member.addServerPeer(baseUrl, {
133
+ dangerouslyAllowInsecureConnections,
134
+ });
135
+ },
136
+ onSuccess: () => {
137
+ queryClient.invalidateQueries({
138
+ queryKey: getMembersQueryKey({ projectId }),
139
+ });
140
+ },
141
+ };
142
+ }
143
+ export function createProjectMutationOptions({ clientApi, queryClient, }) {
144
+ return {
145
+ ...baseMutationOptions(),
146
+ mutationFn: async (opts) => {
147
+ // Have to avoid passing `undefined` explicitly
148
+ // See https://github.com/digidem/rpc-reflector/issues/21
149
+ return opts
150
+ ? clientApi.createProject({
151
+ configPath: opts.configPath,
152
+ name: opts.name,
153
+ })
154
+ : clientApi.createProject();
155
+ },
156
+ onSuccess: () => {
157
+ queryClient.invalidateQueries({
158
+ queryKey: getProjectsQueryKey(),
159
+ });
160
+ },
161
+ };
162
+ }
163
+ export function leaveProjectMutationOptions({ clientApi, queryClient, }) {
164
+ return {
165
+ ...baseMutationOptions(),
166
+ mutationFn: async ({ projectId }) => {
167
+ return clientApi.leaveProject(projectId);
168
+ },
169
+ onSuccess: () => {
170
+ queryClient.invalidateQueries({
171
+ queryKey: getProjectsQueryKey(),
172
+ });
173
+ },
174
+ };
175
+ }
176
+ export function importProjectConfigMutationOptions({ projectApi, projectId, queryClient, }) {
177
+ return {
178
+ ...baseMutationOptions(),
179
+ mutationFn: ({ configPath }) => {
180
+ return projectApi.importConfig({ configPath });
181
+ },
182
+ onSuccess: () => {
183
+ queryClient.invalidateQueries({
184
+ queryKey: getProjectByIdQueryKey({ projectId }),
185
+ });
186
+ },
187
+ };
188
+ }
189
+ export function updateProjectSettingsMutationOptions({ projectApi, queryClient, }) {
190
+ return {
191
+ ...baseMutationOptions(),
192
+ mutationFn: async (value) => {
193
+ return projectApi.$setProjectSettings(value);
194
+ },
195
+ onSuccess: () => {
196
+ queryClient.invalidateQueries({
197
+ queryKey: getProjectsQueryKey(),
198
+ });
199
+ },
200
+ };
201
+ }
202
+ export function createBlobMutationOptions({ projectApi, }) {
203
+ return {
204
+ ...baseMutationOptions(),
205
+ mutationFn: async ({ original, preview, thumbnail, metadata }) => {
206
+ return projectApi.$blobs.create({ original, preview, thumbnail }, metadata);
207
+ },
208
+ };
209
+ }
@@ -0,0 +1,9 @@
1
+ export declare const ROOT_QUERY_KEY = "@comapeo/core-react";
2
+ export declare function baseQueryOptions(): {
3
+ networkMode: "always";
4
+ retry: false;
5
+ };
6
+ export declare function baseMutationOptions(): {
7
+ networkMode: "always";
8
+ retry: false;
9
+ };
@@ -7,6 +7,12 @@ export const ROOT_QUERY_KEY = '@comapeo/core-react';
7
7
  export function baseQueryOptions() {
8
8
  return {
9
9
  networkMode: 'always',
10
- retry: 0,
10
+ retry: false,
11
+ };
12
+ }
13
+ export function baseMutationOptions() {
14
+ return {
15
+ networkMode: 'always',
16
+ retry: false,
11
17
  };
12
18
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/docs/API.md CHANGED
@@ -1,40 +1,11 @@
1
1
  ## Functions
2
2
 
3
3
  - [ClientApiProvider](#clientapiprovider)
4
- - [baseQueryOptions](#basequeryoptions)
5
- - [getClientQueryKey](#getclientquerykey)
6
- - [getDeviceInfoQueryKey](#getdeviceinfoquerykey)
7
- - [getIsArchiveDeviceQueryKey](#getisarchivedevicequerykey)
8
- - [deviceInfoQueryOptions](#deviceinfoqueryoptions)
9
- - [isArchiveDeviceQueryOptions](#isarchivedevicequeryoptions)
10
4
  - [useClientApi](#useclientapi)
11
5
  - [useOwnDeviceInfo](#useowndeviceinfo)
12
6
  - [useIsArchiveDevice](#useisarchivedevice)
13
- - [getDocumentsQueryKey](#getdocumentsquerykey)
14
- - [getManyDocumentsQueryKey](#getmanydocumentsquerykey)
15
- - [getDocumentByDocIdQueryKey](#getdocumentbydocidquerykey)
16
- - [getDocumentByVersionIdQueryKey](#getdocumentbyversionidquerykey)
17
- - [documentsQueryOptions](#documentsqueryoptions)
18
- - [documentByDocumentIdQueryOptions](#documentbydocumentidqueryoptions)
19
- - [documentByVersionIdQueryOptions](#documentbyversionidqueryoptions)
20
- - [getProjectsQueryKey](#getprojectsquerykey)
21
- - [getProjectByIdQueryKey](#getprojectbyidquerykey)
22
- - [getProjectSettingsQueryKey](#getprojectsettingsquerykey)
23
- - [getProjectRoleQueryKey](#getprojectrolequerykey)
24
- - [getMembersQueryKey](#getmembersquerykey)
25
- - [getMemberByIdQueryKey](#getmemberbyidquerykey)
26
- - [getIconUrlQueryKey](#geticonurlquerykey)
27
- - [getDocumentCreatedByQueryKey](#getdocumentcreatedbyquerykey)
28
- - [getAttachmentUrlQueryKey](#getattachmenturlquerykey)
29
- - [projectsQueryOptions](#projectsqueryoptions)
30
- - [projectByIdQueryOptions](#projectbyidqueryoptions)
31
- - [projectSettingsQueryOptions](#projectsettingsqueryoptions)
32
- - [projectMembersQueryOptions](#projectmembersqueryoptions)
33
- - [projectMemberByIdQueryOptions](#projectmemberbyidqueryoptions)
34
- - [projectOwnRoleQueryOptions](#projectownrolequeryoptions)
35
- - [iconUrlQueryOptions](#iconurlqueryoptions)
36
- - [documentCreatedByQueryOptions](#documentcreatedbyqueryoptions)
37
- - [attachmentUrlQueryOptions](#attachmenturlqueryoptions)
7
+ - [useSetOwnDeviceInfo](#usesetowndeviceinfo)
8
+ - [useSetIsArchiveDevice](#usesetisarchivedevice)
38
9
  - [useProjectSettings](#useprojectsettings)
39
10
  - [useSingleProject](#usesingleproject)
40
11
  - [useManyProjects](#usemanyprojects)
@@ -43,16 +14,23 @@
43
14
  - [useIconUrl](#useiconurl)
44
15
  - [useAttachmentUrl](#useattachmenturl)
45
16
  - [useDocumentCreatedBy](#usedocumentcreatedby)
17
+ - [useAddServerPeer](#useaddserverpeer)
18
+ - [useCreateProject](#usecreateproject)
19
+ - [useLeaveProject](#useleaveproject)
20
+ - [useImportProjectConfig](#useimportprojectconfig)
21
+ - [useUpdateProjectSettings](#useupdateprojectsettings)
22
+ - [useCreateBlob](#usecreateblob)
46
23
  - [useSingleDocByDocId](#usesingledocbydocid)
47
24
  - [useSingleDocByVersionId](#usesingledocbyversionid)
48
25
  - [useManyDocs](#usemanydocs)
49
- - [getMapsQueryKey](#getmapsquerykey)
50
- - [getStyleJsonUrlQueryKey](#getstylejsonurlquerykey)
51
- - [mapStyleJsonUrlQueryOptions](#mapstylejsonurlqueryoptions)
26
+ - [useCreateDocument](#usecreatedocument)
27
+ - [useUpdateDocument](#useupdatedocument)
28
+ - [useDeleteDocument](#usedeletedocument)
29
+ - [useAcceptInvite](#useacceptinvite)
30
+ - [useRejectInvite](#userejectinvite)
31
+ - [useSendInvite](#usesendinvite)
32
+ - [useRequestCancelInvite](#userequestcancelinvite)
52
33
  - [useMapStyleUrl](#usemapstyleurl)
53
- - [getInvitesQueryKey](#getinvitesquerykey)
54
- - [getPendingInvitesQueryKey](#getpendinginvitesquerykey)
55
- - [pendingInvitesQueryOptions](#pendinginvitesqueryoptions)
56
34
 
57
35
  ### ClientApiProvider
58
36
 
@@ -68,42 +46,6 @@ Parameters:
68
46
  * `opts.clientApi`: Client API instance
69
47
 
70
48
 
71
- ### baseQueryOptions
72
-
73
- | Function | Type |
74
- | ---------- | ---------- |
75
- | `baseQueryOptions` | `() => { networkMode: "always"; retry: number; }` |
76
-
77
- ### getClientQueryKey
78
-
79
- | Function | Type |
80
- | ---------- | ---------- |
81
- | `getClientQueryKey` | `() => readonly ["@comapeo/core-react", "client"]` |
82
-
83
- ### getDeviceInfoQueryKey
84
-
85
- | Function | Type |
86
- | ---------- | ---------- |
87
- | `getDeviceInfoQueryKey` | `() => readonly ["@comapeo/core-react", "client", "device_info"]` |
88
-
89
- ### getIsArchiveDeviceQueryKey
90
-
91
- | Function | Type |
92
- | ---------- | ---------- |
93
- | `getIsArchiveDeviceQueryKey` | `() => readonly ["@comapeo/core-react", "client", "is_archive_device"]` |
94
-
95
- ### deviceInfoQueryOptions
96
-
97
- | Function | Type |
98
- | ---------- | ---------- |
99
- | `deviceInfoQueryOptions` | `({ clientApi, }: { clientApi: MapeoClientApi; }) => OmitKeyof<UseQueryOptions<{ deviceId: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer" or "UNRECOGNIZED"; } and Partial<...>, Error, { ...; } and Partial<...>, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
100
-
101
- ### isArchiveDeviceQueryOptions
102
-
103
- | Function | Type |
104
- | ---------- | ---------- |
105
- | `isArchiveDeviceQueryOptions` | `({ clientApi, }: { clientApi: MapeoClientApi; }) => OmitKeyof<UseQueryOptions<boolean, Error, boolean, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
106
-
107
49
  ### useClientApi
108
50
 
109
51
  Access a client API instance. If a ClientApiContext provider is not
@@ -167,155 +109,21 @@ function IsArchiveDeviceExample() {
167
109
  ```
168
110
 
169
111
 
170
- ### getDocumentsQueryKey
171
-
172
- | Function | Type |
173
- | ---------- | ---------- |
174
- | `getDocumentsQueryKey` | `<D extends DocumentType>({ projectId, docType, }: { projectId: string; docType: D; }) => readonly ["@comapeo/core-react", "projects", string, D]` |
175
-
176
- ### getManyDocumentsQueryKey
177
-
178
- | Function | Type |
179
- | ---------- | ---------- |
180
- | `getManyDocumentsQueryKey` | `<D extends DocumentType>({ projectId, docType, includeDeleted, lang, }: { projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => readonly ["@comapeo/core-react", "projects", string, D, { ...; }]` |
181
-
182
- ### getDocumentByDocIdQueryKey
183
-
184
- | Function | Type |
185
- | ---------- | ---------- |
186
- | `getDocumentByDocIdQueryKey` | `<D extends DocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => readonly ["@comapeo/core-react", "projects", string, D, string, { readonly lang: string or undefined; }]` |
187
-
188
- ### getDocumentByVersionIdQueryKey
189
-
190
- | Function | Type |
191
- | ---------- | ---------- |
192
- | `getDocumentByVersionIdQueryKey` | `<D extends DocumentType>({ projectId, docType, versionId, lang, }: { projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => readonly ["@comapeo/core-react", "projects", string, D, string, { readonly lang: string or undefined; }]` |
193
-
194
- ### documentsQueryOptions
195
-
196
- | Function | Type |
197
- | ---------- | ---------- |
198
- | `documentsQueryOptions` | `<D extends DocumentType>({ projectApi, projectId, docType, includeDeleted, lang, }: { projectApi: ClientApi<MapeoProject>; projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => OmitKeyof<...> and ... 1 more ... and { ...; }` |
199
-
200
- ### documentByDocumentIdQueryOptions
201
-
202
- | Function | Type |
203
- | ---------- | ---------- |
204
- | `documentByDocumentIdQueryOptions` | `<D extends DocumentType>({ projectApi, projectId, docType, docId, lang, }: { projectApi: ClientApi<MapeoProject>; projectId: string; docType: D; docId: string; lang?: string or undefined; }) => OmitKeyof<UseQueryOptions<({ schemaName: "track"; ... 9 more ...; deleted: boolean; } and { ...; }) or ({ ...; } and { ...; }) or ...` |
205
-
206
- ### documentByVersionIdQueryOptions
207
-
208
- | Function | Type |
209
- | ---------- | ---------- |
210
- | `documentByVersionIdQueryOptions` | `<D extends DocumentType>({ projectApi, projectId, docType, versionId, lang, }: { projectApi: ClientApi<MapeoProject>; projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => OmitKeyof<UseQueryOptions<{ schemaName: "track"; ... 9 more ...; deleted: boolean; } or { ...; } or { ...; } or { ...; ...` |
211
-
212
- ### getProjectsQueryKey
213
-
214
- | Function | Type |
215
- | ---------- | ---------- |
216
- | `getProjectsQueryKey` | `() => readonly ["@comapeo/core-react", "projects"]` |
217
-
218
- ### getProjectByIdQueryKey
219
-
220
- | Function | Type |
221
- | ---------- | ---------- |
222
- | `getProjectByIdQueryKey` | `({ projectId }: { projectId: string; }) => readonly ["@comapeo/core-react", "projects", string]` |
223
-
224
- ### getProjectSettingsQueryKey
225
-
226
- | Function | Type |
227
- | ---------- | ---------- |
228
- | `getProjectSettingsQueryKey` | `({ projectId, }: { projectId: string; }) => readonly ["@comapeo/core-react", "projects", string, "project_settings"]` |
229
-
230
- ### getProjectRoleQueryKey
231
-
232
- | Function | Type |
233
- | ---------- | ---------- |
234
- | `getProjectRoleQueryKey` | `({ projectId }: { projectId: string; }) => readonly ["@comapeo/core-react", "projects", string, "role"]` |
235
-
236
- ### getMembersQueryKey
237
-
238
- | Function | Type |
239
- | ---------- | ---------- |
240
- | `getMembersQueryKey` | `({ projectId }: { projectId: string; }) => readonly ["@comapeo/core-react", "projects", string, "members"]` |
241
-
242
- ### getMemberByIdQueryKey
243
-
244
- | Function | Type |
245
- | ---------- | ---------- |
246
- | `getMemberByIdQueryKey` | `({ projectId, deviceId, }: { projectId: string; deviceId: string; }) => readonly ["@comapeo/core-react", "projects", string, "members", string]` |
247
-
248
- ### getIconUrlQueryKey
249
-
250
- | Function | Type |
251
- | ---------- | ---------- |
252
- | `getIconUrlQueryKey` | `({ projectId, iconId, ...mimeBasedOpts }: { projectId: string; iconId: string; } and (BitmapOpts or SvgOpts)) => readonly ["@comapeo/core-react", "projects", string, "icons", string, { mimeType: "image/png"; pixelDensity: 2 or ... 1 more ... or 1; size: ValidSizes; } or { ...; }]` |
253
-
254
- ### getDocumentCreatedByQueryKey
255
-
256
- | Function | Type |
257
- | ---------- | ---------- |
258
- | `getDocumentCreatedByQueryKey` | `({ projectId, originalVersionId, }: { projectId: string; originalVersionId: string; }) => readonly ["@comapeo/core-react", "projects", string, "document_created_by", string]` |
259
-
260
- ### getAttachmentUrlQueryKey
261
-
262
- | Function | Type |
263
- | ---------- | ---------- |
264
- | `getAttachmentUrlQueryKey` | `({ projectId, blobId, }: { projectId: string; blobId: BlobId; }) => readonly ["@comapeo/core-react", "projects", string, "attachments", BlobId]` |
265
-
266
- ### projectsQueryOptions
267
-
268
- | Function | Type |
269
- | ---------- | ---------- |
270
- | `projectsQueryOptions` | `({ clientApi, }: { clientApi: MapeoClientApi; }) => OmitKeyof<UseQueryOptions<(Pick<{ schemaName: "projectSettings"; name?: string or undefined; defaultPresets?: { point: string[]; area: string[]; vertex: string[]; line: string[]; relation: string[]; } or undefined; configMetadata?: { ...; } or undefined; }, "name"> and ...` |
271
-
272
- ### projectByIdQueryOptions
273
-
274
- | Function | Type |
275
- | ---------- | ---------- |
276
- | `projectByIdQueryOptions` | `({ clientApi, projectId, }: { clientApi: MapeoClientApi; projectId: string; }) => OmitKeyof<UseQueryOptions<ClientApi<MapeoProject>, Error, ClientApi<MapeoProject>, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
277
-
278
- ### projectSettingsQueryOptions
279
-
280
- | Function | Type |
281
- | ---------- | ---------- |
282
- | `projectSettingsQueryOptions` | `({ projectApi, projectId, }: { projectApi: ClientApi<MapeoProject>; projectId: string; }) => OmitKeyof<UseQueryOptions<EditableProjectSettings, Error, EditableProjectSettings, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
283
-
284
- ### projectMembersQueryOptions
285
-
286
- | Function | Type |
287
- | ---------- | ---------- |
288
- | `projectMembersQueryOptions` | `({ projectApi, projectId, }: { projectApi: ClientApi<MapeoProject>; projectId: string; }) => OmitKeyof<UseQueryOptions<MemberInfo[], Error, MemberInfo[], QueryKey>, "queryFn"> and { ...; } and { ...; }` |
289
-
290
- ### projectMemberByIdQueryOptions
291
-
292
- | Function | Type |
293
- | ---------- | ---------- |
294
- | `projectMemberByIdQueryOptions` | `({ projectApi, projectId, deviceId, }: { projectApi: ClientApi<MapeoProject>; projectId: string; deviceId: string; }) => OmitKeyof<UseQueryOptions<MemberInfo, Error, MemberInfo, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
295
-
296
- ### projectOwnRoleQueryOptions
297
-
298
- | Function | Type |
299
- | ---------- | ---------- |
300
- | `projectOwnRoleQueryOptions` | `({ projectApi, projectId, }: { projectApi: ClientApi<MapeoProject>; projectId: string; }) => OmitKeyof<UseQueryOptions<Role<"a12a6702b93bd7ff" or "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9" or "8ced989b1904606b" or "08e4251e36f6e7ed">, Error, Role<...>, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
112
+ ### useSetOwnDeviceInfo
301
113
 
302
- ### iconUrlQueryOptions
114
+ Update the device info for the current device.
303
115
 
304
116
  | Function | Type |
305
117
  | ---------- | ---------- |
306
- | `iconUrlQueryOptions` | `({ projectApi, projectId, iconId, ...mimeBasedOpts }: { projectApi: ClientApi<MapeoProject>; projectId: string; iconId: string; } and (BitmapOpts or SvgOpts)) => OmitKeyof<UseQueryOptions<string, Error, string, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
307
-
308
- ### documentCreatedByQueryOptions
118
+ | `useSetOwnDeviceInfo` | `() => { mutate: UseMutateFunction<void, Error, { name: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer" or "UNRECOGNIZED"; }, unknown>; reset: () => void; status: "pending" or ... 2 more ... or "idle"; }` |
309
119
 
310
- | Function | Type |
311
- | ---------- | ---------- |
312
- | `documentCreatedByQueryOptions` | `({ projectApi, projectId, originalVersionId, }: { projectApi: ClientApi<MapeoProject>; projectId: string; originalVersionId: string; }) => OmitKeyof<UseQueryOptions<string, Error, string, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
120
+ ### useSetIsArchiveDevice
313
121
 
314
- ### attachmentUrlQueryOptions
122
+ Set or unset the current device as an archive device.
315
123
 
316
124
  | Function | Type |
317
125
  | ---------- | ---------- |
318
- | `attachmentUrlQueryOptions` | `({ projectApi, projectId, blobId, }: { projectApi: ClientApi<MapeoProject>; projectId: string; blobId: BlobId; }) => OmitKeyof<UseQueryOptions<string, Error, string, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
126
+ | `useSetIsArchiveDevice` | `() => { mutate: UseMutateFunction<void, Error, { isArchiveDevice: boolean; }, unknown>; reset: () => void; status: "pending" or "error" or "success" or "idle"; }` |
319
127
 
320
128
  ### useProjectSettings
321
129
 
@@ -565,6 +373,67 @@ function BasicExample() {
565
373
  ```
566
374
 
567
375
 
376
+ ### useAddServerPeer
377
+
378
+ | Function | Type |
379
+ | ---------- | ---------- |
380
+ | `useAddServerPeer` | `({ projectId }: { projectId: string; }) => { mutate: UseMutateFunction<void, Error, { baseUrl: string; dangerouslyAllowInsecureConnections?: boolean or undefined; }, unknown>; reset: () => void; status: "pending" or ... 2 more ... or "idle"; }` |
381
+
382
+ ### useCreateProject
383
+
384
+ Create a new project.
385
+
386
+ | Function | Type |
387
+ | ---------- | ---------- |
388
+ | `useCreateProject` | `() => { mutate: UseMutateFunction<string, Error, { name?: string or undefined; configPath?: string or undefined; } or undefined, unknown>; reset: () => void; status: "pending" or ... 2 more ... or "idle"; }` |
389
+
390
+ ### useLeaveProject
391
+
392
+ Leave an existing project.
393
+
394
+ | Function | Type |
395
+ | ---------- | ---------- |
396
+ | `useLeaveProject` | `() => { mutate: UseMutateFunction<void, Error, { projectId: string; }, unknown>; reset: () => void; status: "pending" or "error" or "success" or "idle"; }` |
397
+
398
+ ### useImportProjectConfig
399
+
400
+ Update the configuration of a project using an external file.
401
+
402
+ | Function | Type |
403
+ | ---------- | ---------- |
404
+ | `useImportProjectConfig` | `({ projectId }: { projectId: string; }) => { mutate: UseMutateFunction<Error[], Error, { configPath: string; }, unknown>; reset: () => void; status: "pending" or "error" or "success" or "idle"; }` |
405
+
406
+ Parameters:
407
+
408
+ * `opts.projectId`: Public ID of the project to apply changes to.
409
+
410
+
411
+ ### useUpdateProjectSettings
412
+
413
+ Update the settings of a project.
414
+
415
+ | Function | Type |
416
+ | ---------- | ---------- |
417
+ | `useUpdateProjectSettings` | `({ projectId }: { projectId: string; }) => { mutate: UseMutateFunction<EditableProjectSettings, Error, { name?: string or undefined; configMetadata?: { name: string; buildDate: string; importDate: string; fileVersion: string; } or undefined; defaultPresets?: { ...; } or undefined; }, unknown>; reset: () => void; status...` |
418
+
419
+ Parameters:
420
+
421
+ * `opts.projectId`: Public ID of the project to apply changes to.
422
+
423
+
424
+ ### useCreateBlob
425
+
426
+ Create a blob for a project.
427
+
428
+ | Function | Type |
429
+ | ---------- | ---------- |
430
+ | `useCreateBlob` | `({ projectId }: { projectId: string; }) => { mutate: UseMutateFunction<{ driveId: string; name: string; type: "audio" or "video" or "photo"; hash: string; }, Error, { original: string; preview?: string or undefined; thumbnail?: string or undefined; metadata: Metadata; }, unknown>; reset: () => void; status: "pending" or ...` |
431
+
432
+ Parameters:
433
+
434
+ * `opts.projectId`: Public project ID of project to apply to changes to.
435
+
436
+
568
437
  ### useSingleDocByDocId
569
438
 
570
439
  Retrieve a single document from the database based on the document's document ID.
@@ -573,7 +442,7 @@ Triggers the closest error boundary if the document cannot be found
573
442
 
574
443
  | Function | Type |
575
444
  | ---------- | ---------- |
576
- | `useSingleDocByDocId` | `<D extends DocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; docRefType: "track" or ... 7 more ... or "type_unspecified"; ... 10 more ......` |
445
+ | `useSingleDocByDocId` | `<D extends WriteableDocumentType>({ projectId, docType, docId, lang, }: { projectId: string; docType: D; docId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "device_type_unspecified" or ... 4 more ... or "UNRECOGNIZED"; ... 7 more ...; deleted: b...` |
577
446
 
578
447
  Parameters:
579
448
 
@@ -606,7 +475,7 @@ Triggers the closest error boundary if the document cannot be found.
606
475
 
607
476
  | Function | Type |
608
477
  | ---------- | ---------- |
609
- | `useSingleDocByVersionId` | `<D extends DocumentType>({ projectId, docType, versionId, lang, }: { projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; docRefType: "track" or ... 7 more ... or "type_unspecified"; ... 10 ...` |
478
+ | `useSingleDocByVersionId` | `<D extends WriteableDocumentType>({ projectId, docType, versionId, lang, }: { projectId: string; docType: D; versionId: string; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "device_type_unspecified" or ... 4 more ... or "UNRECOGNIZED"; ... 7 more ...; de...` |
610
479
 
611
480
  Parameters:
612
481
 
@@ -639,7 +508,7 @@ Retrieve all documents of a specific `docType`.
639
508
 
640
509
  | Function | Type |
641
510
  | ---------- | ---------- |
642
- | `useManyDocs` | `<D extends DocumentType>({ projectId, docType, includeDeleted, lang, }: { projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "translation"; docRef: { docId: string; versionId: string; }; ... 11 more ...; deleted: boolean; }, { .....` |
511
+ | `useManyDocs` | `<D extends WriteableDocumentType>({ projectId, docType, includeDeleted, lang, }: { projectId: string; docType: D; includeDeleted?: boolean or undefined; lang?: string or undefined; }) => ReadHookResult<Extract<{ schemaName: "deviceInfo"; name: string; deviceType: "device_type_unspecified" or ... 4 more ... or "UNRECOGNI...` |
643
512
 
644
513
  Parameters:
645
514
 
@@ -677,23 +546,89 @@ function useAllPresets(opts) {
677
546
  ```
678
547
 
679
548
 
680
- ### getMapsQueryKey
549
+ ### useCreateDocument
550
+
551
+ Create a document for a project.
552
+
553
+ | Function | Type |
554
+ | ---------- | ---------- |
555
+ | `useCreateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { value: Omit<WriteableValue<D>, "schemaName">; }, unknown>; reset: () => void; status: "pending" or ... 2 more ... or "idle"; }` |
556
+
557
+ Parameters:
558
+
559
+ * `opts.docType`: Document type to create.
560
+ * `opts.projectId`: Public ID of project to create document for.
561
+
562
+
563
+ ### useUpdateDocument
564
+
565
+ Update a document within a project.
681
566
 
682
567
  | Function | Type |
683
568
  | ---------- | ---------- |
684
- | `getMapsQueryKey` | `() => readonly ["@comapeo/core-react", "maps"]` |
569
+ | `useUpdateDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { versionId: string; value: Omit<...>; }, unknown>; reset: () => void; status: "pending" or ... 2 more ... or "idle"; }` |
685
570
 
686
- ### getStyleJsonUrlQueryKey
571
+ Parameters:
572
+
573
+ * `opts.docType`: Document type to update.
574
+ * `opts.projectId`: Public ID of project document belongs to.
575
+
576
+
577
+ ### useDeleteDocument
578
+
579
+ Delete a document within a project.
580
+
581
+ | Function | Type |
582
+ | ---------- | ---------- |
583
+ | `useDeleteDocument` | `<D extends WriteableDocumentType>({ docType, projectId, }: { docType: D; projectId: string; }) => { mutate: UseMutateFunction<WriteableDocument<D> and { forks: string[]; }, Error, { docId: string; }, unknown>; reset: () => void; status: "pending" or ... 2 more ... or "idle"; }` |
584
+
585
+ Parameters:
586
+
587
+ * `opts.docType`: Document type to delete.
588
+ * `opts.projectId`: Public ID of project document belongs to.
589
+
590
+
591
+ ### useAcceptInvite
592
+
593
+ Accept an invite that has been received.
687
594
 
688
595
  | Function | Type |
689
596
  | ---------- | ---------- |
690
- | `getStyleJsonUrlQueryKey` | `({ refreshToken, }: { refreshToken?: string or undefined; }) => readonly ["@comapeo/core-react", "maps", "stylejson_url", { readonly refreshToken: string or undefined; }]` |
597
+ | `useAcceptInvite` | `() => { mutate: UseMutateFunction<string, Error, { inviteId: string; }, unknown>; reset: () => void; status: "pending" or "error" or "success" or "idle"; }` |
691
598
 
692
- ### mapStyleJsonUrlQueryOptions
599
+ ### useRejectInvite
600
+
601
+ Reject an invite that has been received.
693
602
 
694
603
  | Function | Type |
695
604
  | ---------- | ---------- |
696
- | `mapStyleJsonUrlQueryOptions` | `({ clientApi, refreshToken, }: { clientApi: MapeoClientApi; refreshToken?: string or undefined; }) => OmitKeyof<UseQueryOptions<string, Error, string, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
605
+ | `useRejectInvite` | `() => { mutate: UseMutateFunction<void, Error, { inviteId: string; }, unknown>; reset: () => void; status: "pending" or "error" or "success" or "idle"; }` |
606
+
607
+ ### useSendInvite
608
+
609
+ Send an invite for a project.
610
+
611
+ | Function | Type |
612
+ | ---------- | ---------- |
613
+ | `useSendInvite` | `({ projectId }: { projectId: string; }) => { mutate: UseMutateFunction<"ACCEPT" or "REJECT" or "ALREADY", Error, { deviceId: string; roleDescription?: string or undefined; roleId: "f7c150f5a3a9a855" or "012fd2d431c0bf60" or "9e6d29263cba36c9"; roleName?: string or undefined; }, unknown>; reset: () => void; status: "pendin...` |
614
+
615
+ Parameters:
616
+
617
+ * `opts.projectId`: Public ID of project to send the invite on behalf of.
618
+
619
+
620
+ ### useRequestCancelInvite
621
+
622
+ Request a cancellation of an invite sent to another device.
623
+
624
+ | Function | Type |
625
+ | ---------- | ---------- |
626
+ | `useRequestCancelInvite` | `({ projectId }: { projectId: string; }) => { mutate: UseMutateFunction<void, Error, { deviceId: string; }, unknown>; reset: () => void; status: "pending" or "error" or "success" or "idle"; }` |
627
+
628
+ Parameters:
629
+
630
+ * `opts.projectId`: Public ID of project to request the invite cancellation for.
631
+
697
632
 
698
633
  ### useMapStyleUrl
699
634
 
@@ -731,29 +666,10 @@ function ExampleWithRefreshToken() {
731
666
  ```
732
667
 
733
668
 
734
- ### getInvitesQueryKey
735
-
736
- | Function | Type |
737
- | ---------- | ---------- |
738
- | `getInvitesQueryKey` | `() => readonly ["@comapeo/core-react", "invites"]` |
739
-
740
- ### getPendingInvitesQueryKey
741
-
742
- | Function | Type |
743
- | ---------- | ---------- |
744
- | `getPendingInvitesQueryKey` | `() => readonly ["@comapeo/core-react", "invites", { readonly status: "pending"; }]` |
745
-
746
- ### pendingInvitesQueryOptions
747
-
748
- | Function | Type |
749
- | ---------- | ---------- |
750
- | `pendingInvitesQueryOptions` | `({ clientApi, }: { clientApi: MapeoClientApi; }) => OmitKeyof<UseQueryOptions<MapBuffers<InviteInternal>[], Error, MapBuffers<InviteInternal>[], QueryKey>, "queryFn"> and { ...; } and { ...; }` |
751
-
752
669
 
753
670
  ## Constants
754
671
 
755
672
  - [ClientApiContext](#clientapicontext)
756
- - [ROOT_QUERY_KEY](#root_query_key)
757
673
 
758
674
  ### ClientApiContext
759
675
 
@@ -761,21 +677,4 @@ function ExampleWithRefreshToken() {
761
677
  | ---------- | ---------- |
762
678
  | `ClientApiContext` | `Context<MapeoClientApi or null>` |
763
679
 
764
- ### ROOT_QUERY_KEY
765
-
766
- | Constant | Type |
767
- | ---------- | ---------- |
768
- | `ROOT_QUERY_KEY` | `"@comapeo/core-react"` |
769
-
770
-
771
-
772
- ## Types
773
-
774
- - [DocumentType](#documenttype)
775
-
776
- ### DocumentType
777
-
778
- | Type | Type |
779
- | ---------- | ---------- |
780
- | `DocumentType` | `Extract< MapeoDoc['schemaName'], 'field' or 'observation' or 'preset' or 'track' or 'remoteDetectionAlert' >` |
781
680