@comapeo/core-react 0.1.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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/contexts/ClientApi.d.ts +14 -0
- package/dist/contexts/ClientApi.js +12 -0
- package/dist/hooks/client.d.ts +59 -0
- package/dist/hooks/client.js +66 -0
- package/dist/hooks/documents.d.ts +475 -0
- package/dist/hooks/documents.js +124 -0
- package/dist/hooks/maps.d.ts +34 -0
- package/dist/hooks/maps.js +35 -0
- package/dist/hooks/projects.d.ts +261 -0
- package/dist/hooks/projects.js +257 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/lib/react-query/client.d.ts +30 -0
- package/dist/lib/react-query/client.js +29 -0
- package/dist/lib/react-query/documents.d.ts +1492 -0
- package/dist/lib/react-query/documents.js +62 -0
- package/dist/lib/react-query/invites.d.ts +12 -0
- package/dist/lib/react-query/invites.js +17 -0
- package/dist/lib/react-query/maps.d.ts +15 -0
- package/dist/lib/react-query/maps.js +18 -0
- package/dist/lib/react-query/projects.d.ts +188 -0
- package/dist/lib/react-query/projects.js +120 -0
- package/dist/lib/react-query/shared.d.ts +5 -0
- package/dist/lib/react-query/shared.js +12 -0
- package/docs/API.md +783 -0
- package/package.json +80 -0
package/docs/API.md
ADDED
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
## Functions
|
|
2
|
+
|
|
3
|
+
- [ClientApiProvider](#clientapiprovider)
|
|
4
|
+
- [baseQueryOptions](#basequeryoptions)
|
|
5
|
+
- [getClientQueryKey](#getclientquerykey)
|
|
6
|
+
- [getDeviceInfoQueryKey](#getdeviceinfoquerykey)
|
|
7
|
+
- [getIsArchiveDeviceQueryKey](#getisarchivedevicequerykey)
|
|
8
|
+
- [deviceInfoQueryOptions](#deviceinfoqueryoptions)
|
|
9
|
+
- [isArchiveDeviceQueryOptions](#isarchivedevicequeryoptions)
|
|
10
|
+
- [useClientApi](#useclientapi)
|
|
11
|
+
- [useOwnDeviceInfo](#useowndeviceinfo)
|
|
12
|
+
- [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)
|
|
38
|
+
- [useProjectSettings](#useprojectsettings)
|
|
39
|
+
- [useSingleProject](#usesingleproject)
|
|
40
|
+
- [useManyProjects](#usemanyprojects)
|
|
41
|
+
- [useSingleMember](#usesinglemember)
|
|
42
|
+
- [useManyMembers](#usemanymembers)
|
|
43
|
+
- [useIconUrl](#useiconurl)
|
|
44
|
+
- [useAttachmentUrl](#useattachmenturl)
|
|
45
|
+
- [useDocumentCreatedBy](#usedocumentcreatedby)
|
|
46
|
+
- [useSingleDocByDocId](#usesingledocbydocid)
|
|
47
|
+
- [useSingleDocByVersionId](#usesingledocbyversionid)
|
|
48
|
+
- [useManyDocs](#usemanydocs)
|
|
49
|
+
- [getMapsQueryKey](#getmapsquerykey)
|
|
50
|
+
- [getStyleJsonUrlQueryKey](#getstylejsonurlquerykey)
|
|
51
|
+
- [mapStyleJsonUrlQueryOptions](#mapstylejsonurlqueryoptions)
|
|
52
|
+
- [useMapStyleUrl](#usemapstyleurl)
|
|
53
|
+
- [getInvitesQueryKey](#getinvitesquerykey)
|
|
54
|
+
- [getPendingInvitesQueryKey](#getpendinginvitesquerykey)
|
|
55
|
+
- [pendingInvitesQueryOptions](#pendinginvitesqueryoptions)
|
|
56
|
+
|
|
57
|
+
### ClientApiProvider
|
|
58
|
+
|
|
59
|
+
Create a context provider that holds a CoMapeo API client instance.
|
|
60
|
+
|
|
61
|
+
| Function | Type |
|
|
62
|
+
| ---------- | ---------- |
|
|
63
|
+
| `ClientApiProvider` | `({ children, clientApi, }: { children: ReactNode; clientApi: MapeoClientApi; }) => FunctionComponentElement<ProviderProps<MapeoClientApi or null>>` |
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
|
|
67
|
+
* `opts.children`: React children node
|
|
68
|
+
* `opts.clientApi`: Client API instance
|
|
69
|
+
|
|
70
|
+
|
|
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_remote_archive"]` |
|
|
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
|
+
### useClientApi
|
|
108
|
+
|
|
109
|
+
Access a client API instance. If a ClientApiContext provider is not
|
|
110
|
+
set up, it will throw an error.
|
|
111
|
+
|
|
112
|
+
| Function | Type |
|
|
113
|
+
| ---------- | ---------- |
|
|
114
|
+
| `useClientApi` | `() => MapeoClientApi` |
|
|
115
|
+
|
|
116
|
+
Examples:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
function ClientExample() {
|
|
120
|
+
return (
|
|
121
|
+
// Creation of clientApi omitted for brevity
|
|
122
|
+
<ClientApiContext.Provider clientApi={clientApi}>
|
|
123
|
+
<ComponentThatUsesClient />
|
|
124
|
+
</ClientApiContext.Provider>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function ComponentThatUsesClient() {
|
|
129
|
+
const clientApi = useClientApi()
|
|
130
|
+
|
|
131
|
+
// Rest omitted for brevity.
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### useOwnDeviceInfo
|
|
137
|
+
|
|
138
|
+
Retrieve info about the current device.
|
|
139
|
+
|
|
140
|
+
| Function | Type |
|
|
141
|
+
| ---------- | ---------- |
|
|
142
|
+
| `useOwnDeviceInfo` | `() => { data: { deviceId: string; deviceType: "device_type_unspecified" or "mobile" or "tablet" or "desktop" or "selfHostedServer" or "UNRECOGNIZED"; } and Partial<DeviceInfoParam>; error: Error or null; isRefetching: boolean; }` |
|
|
143
|
+
|
|
144
|
+
Examples:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
function DeviceInfoExample() {
|
|
148
|
+
const { data } = useDeviceInfo()
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
### useIsArchiveDevice
|
|
154
|
+
|
|
155
|
+
Retrieve whether the current device is an archive device or not.
|
|
156
|
+
|
|
157
|
+
| Function | Type |
|
|
158
|
+
| ---------- | ---------- |
|
|
159
|
+
| `useIsArchiveDevice` | `() => { data: boolean; error: Error or null; isRefetching: boolean; }` |
|
|
160
|
+
|
|
161
|
+
Examples:
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
function IsArchiveDeviceExample() {
|
|
165
|
+
const { data } = useIsArchiveDevice()
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
|
|
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, opts, }: { projectId: string; docType: D; opts?: Parameters<ClientApi<MapeoProject>[D]["getMany"]>[0] or undefined; }) => readonly [...]` |
|
|
181
|
+
|
|
182
|
+
### getDocumentByDocIdQueryKey
|
|
183
|
+
|
|
184
|
+
| Function | Type |
|
|
185
|
+
| ---------- | ---------- |
|
|
186
|
+
| `getDocumentByDocIdQueryKey` | `<D extends DocumentType>({ projectId, docType, docId, opts, }: { projectId: string; docType: D; docId: Parameters<ClientApi<MapeoProject>[D]["getByDocId"]>[0]; opts?: Parameters<ClientApi<MapeoProject>[D]["getByDocId"]>[1] or undefined; }) => readonly [...]` |
|
|
187
|
+
|
|
188
|
+
### getDocumentByVersionIdQueryKey
|
|
189
|
+
|
|
190
|
+
| Function | Type |
|
|
191
|
+
| ---------- | ---------- |
|
|
192
|
+
| `getDocumentByVersionIdQueryKey` | `<D extends DocumentType>({ projectId, docType, versionId, opts, }: { projectId: string; docType: D; versionId: Parameters<ClientApi<MapeoProject>[D]["getByVersionId"]>[0]; opts?: Parameters<ClientApi<...>[D]["getByVersionId"]>[1] or undefined; }) => readonly [...]` |
|
|
193
|
+
|
|
194
|
+
### documentsQueryOptions
|
|
195
|
+
|
|
196
|
+
| Function | Type |
|
|
197
|
+
| ---------- | ---------- |
|
|
198
|
+
| `documentsQueryOptions` | `<D extends DocumentType>({ projectApi, projectId, docType, opts, }: { projectApi: ClientApi<MapeoProject>; projectId: string; docType: D; opts?: Parameters<ClientApi<MapeoProject>[D]["getMany"]>[0] or undefined; }) => OmitKeyof<...> and ... 1 more ... and { ...; }` |
|
|
199
|
+
|
|
200
|
+
### documentByDocumentIdQueryOptions
|
|
201
|
+
|
|
202
|
+
| Function | Type |
|
|
203
|
+
| ---------- | ---------- |
|
|
204
|
+
| `documentByDocumentIdQueryOptions` | `<D extends DocumentType>({ projectApi, projectId, docType, docId, opts, }: { projectApi: ClientApi<MapeoProject>; projectId: string; docType: D; docId: Parameters<ClientApi<MapeoProject>[D]["getByDocId"]>[0]; opts?: Omit<...> or undefined; }) => OmitKeyof<...> and ... 1 more ... and { ...; }` |
|
|
205
|
+
|
|
206
|
+
### documentByVersionIdQueryOptions
|
|
207
|
+
|
|
208
|
+
| Function | Type |
|
|
209
|
+
| ---------- | ---------- |
|
|
210
|
+
| `documentByVersionIdQueryOptions` | `<D extends DocumentType>({ projectApi, projectId, docType, versionId, opts, }: { projectApi: ClientApi<MapeoProject>; projectId: string; docType: D; versionId: Parameters<ClientApi<MapeoProject>[D]["getByVersionId"]>[0]; opts?: Parameters<...>[1] or undefined; }) => OmitKeyof<...> and ... 1 more ... and { ...; }` |
|
|
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, opts, }: { projectId: string; iconId: string; opts: BitmapOpts or SvgOpts; }) => readonly ["@comapeo/core-react", "projects", string, "icons", string, BitmapOpts or SvgOpts]` |
|
|
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 { ...; }` |
|
|
301
|
+
|
|
302
|
+
### iconUrlQueryOptions
|
|
303
|
+
|
|
304
|
+
| Function | Type |
|
|
305
|
+
| ---------- | ---------- |
|
|
306
|
+
| `iconUrlQueryOptions` | `({ projectApi, projectId, iconId, opts, }: { projectApi: ClientApi<MapeoProject>; projectId: string; iconId: string; opts: BitmapOpts or SvgOpts; }) => OmitKeyof<UseQueryOptions<string, Error, string, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
|
|
307
|
+
|
|
308
|
+
### documentCreatedByQueryOptions
|
|
309
|
+
|
|
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 { ...; }` |
|
|
313
|
+
|
|
314
|
+
### attachmentUrlQueryOptions
|
|
315
|
+
|
|
316
|
+
| Function | Type |
|
|
317
|
+
| ---------- | ---------- |
|
|
318
|
+
| `attachmentUrlQueryOptions` | `({ projectApi, projectId, blobId, }: { projectApi: ClientApi<MapeoProject>; projectId: string; blobId: BlobId; }) => OmitKeyof<UseQueryOptions<string, Error, string, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
|
|
319
|
+
|
|
320
|
+
### useProjectSettings
|
|
321
|
+
|
|
322
|
+
Retrieve the project settings for a project.
|
|
323
|
+
|
|
324
|
+
| Function | Type |
|
|
325
|
+
| ---------- | ---------- |
|
|
326
|
+
| `useProjectSettings` | `({ projectId }: { projectId: string; }) => { data: EditableProjectSettings; error: Error or null; isRefetching: boolean; }` |
|
|
327
|
+
|
|
328
|
+
Parameters:
|
|
329
|
+
|
|
330
|
+
* `opts.projectId`: Project public ID
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
Examples:
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
function BasicExample() {
|
|
337
|
+
const { data } = useProjectSettings({ projectId: '...' })
|
|
338
|
+
|
|
339
|
+
console.log(data.name)
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
### useSingleProject
|
|
345
|
+
|
|
346
|
+
Retrieve a project API instance for a project.
|
|
347
|
+
|
|
348
|
+
This is mostly used internally by the other hooks and should only be used if certain project APIs are not exposed via the hooks.
|
|
349
|
+
|
|
350
|
+
| Function | Type |
|
|
351
|
+
| ---------- | ---------- |
|
|
352
|
+
| `useSingleProject` | `({ projectId }: { projectId: string; }) => { data: ClientApi<MapeoProject>; error: Error or null; isRefetching: boolean; }` |
|
|
353
|
+
|
|
354
|
+
Parameters:
|
|
355
|
+
|
|
356
|
+
* `opts.projectId`: Project public ID
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
Examples:
|
|
360
|
+
|
|
361
|
+
```tsx
|
|
362
|
+
function BasicExample() {
|
|
363
|
+
const { data } = useSingleProject({ projectId: '...' })
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
### useManyProjects
|
|
369
|
+
|
|
370
|
+
Retrieve project information for each project that exists.
|
|
371
|
+
|
|
372
|
+
| Function | Type |
|
|
373
|
+
| ---------- | ---------- |
|
|
374
|
+
| `useManyProjects` | `() => { data: (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 { ...; })[]; error: Error or null; isRefetching: boolean; }` |
|
|
375
|
+
|
|
376
|
+
Examples:
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
function BasicExample() {
|
|
380
|
+
const { data } = useManyProjects()
|
|
381
|
+
|
|
382
|
+
console.log(data.map(project => project.name))
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
### useSingleMember
|
|
388
|
+
|
|
389
|
+
Retrieve a single member of a project.
|
|
390
|
+
|
|
391
|
+
| Function | Type |
|
|
392
|
+
| ---------- | ---------- |
|
|
393
|
+
| `useSingleMember` | `({ projectId, deviceId, }: { projectId: string; deviceId: string; }) => { data: MemberInfo; error: Error or null; isRefetching: boolean; }` |
|
|
394
|
+
|
|
395
|
+
Parameters:
|
|
396
|
+
|
|
397
|
+
* `opts.projectId`: Project public ID
|
|
398
|
+
* `opts.projectId`: Device ID of interest
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
Examples:
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
function BasicExample() {
|
|
405
|
+
const { data } = useSingleMember({ projectId: '...', deviceId: '...' })
|
|
406
|
+
|
|
407
|
+
console.log(data.role)
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
### useManyMembers
|
|
413
|
+
|
|
414
|
+
Retrieve all members of a project.
|
|
415
|
+
|
|
416
|
+
| Function | Type |
|
|
417
|
+
| ---------- | ---------- |
|
|
418
|
+
| `useManyMembers` | `({ projectId }: { projectId: string; }) => { data: MemberInfo[]; error: Error or null; isRefetching: boolean; }` |
|
|
419
|
+
|
|
420
|
+
Parameters:
|
|
421
|
+
|
|
422
|
+
* `opts.projectId`: Project public ID
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
Examples:
|
|
426
|
+
|
|
427
|
+
```tsx
|
|
428
|
+
function BasicExample() {
|
|
429
|
+
const { data } = useManyMembers({ projectId: '...' })
|
|
430
|
+
|
|
431
|
+
console.log(data.role)
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
### useIconUrl
|
|
437
|
+
|
|
438
|
+
Retrieve a URL that points to icon resources served by the embedded HTTP server.
|
|
439
|
+
|
|
440
|
+
_TODO: Explain bitmap opts vs svg opts_
|
|
441
|
+
|
|
442
|
+
| Function | Type |
|
|
443
|
+
| ---------- | ---------- |
|
|
444
|
+
| `useIconUrl` | `({ projectId, iconId, opts, }: { projectId: string; iconId: string; opts: BitmapOpts or SvgOpts; }) => { data: string; error: Error or null; isRefetching: boolean; }` |
|
|
445
|
+
|
|
446
|
+
Parameters:
|
|
447
|
+
|
|
448
|
+
* `opts.projectId`: Project public ID
|
|
449
|
+
* `opts.iconId`: Icon ID of interest
|
|
450
|
+
* `opts.opts`: Parameters related to the mime type of the icon of interest
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
Examples:
|
|
454
|
+
|
|
455
|
+
```tsx
|
|
456
|
+
function PngExample() {
|
|
457
|
+
const { data } = useIconUrl({
|
|
458
|
+
projectId: '...',
|
|
459
|
+
iconId: '...',
|
|
460
|
+
opts: {
|
|
461
|
+
mimeType: 'image/png',
|
|
462
|
+
pixelDensity: 1,
|
|
463
|
+
size: 'medium'
|
|
464
|
+
}
|
|
465
|
+
})
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
```tsx
|
|
470
|
+
function SvgExample() {
|
|
471
|
+
const { data } = useIconUrl({
|
|
472
|
+
projectId: '...',
|
|
473
|
+
iconId: '...',
|
|
474
|
+
opts: {
|
|
475
|
+
mimeType: 'image/svg',
|
|
476
|
+
size: 'medium'
|
|
477
|
+
}
|
|
478
|
+
})
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
### useAttachmentUrl
|
|
484
|
+
|
|
485
|
+
Retrieve a URL that points to a desired blob resource.
|
|
486
|
+
|
|
487
|
+
_TODO: Explain BlobId in more depth_
|
|
488
|
+
|
|
489
|
+
| Function | Type |
|
|
490
|
+
| ---------- | ---------- |
|
|
491
|
+
| `useAttachmentUrl` | `({ projectId, blobId, }: { projectId: string; blobId: BlobId; }) => { data: string; error: Error or null; isRefetching: boolean; }` |
|
|
492
|
+
|
|
493
|
+
Parameters:
|
|
494
|
+
|
|
495
|
+
* `opts.projectId`: Project public Id
|
|
496
|
+
* `opts.blobId`: Blob ID of the desired resource
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
Examples:
|
|
500
|
+
|
|
501
|
+
```tsx
|
|
502
|
+
function PhotoExample() {
|
|
503
|
+
const { data } = useAttachmentUrl({
|
|
504
|
+
projectId: '...',
|
|
505
|
+
blobId: {
|
|
506
|
+
type: 'photo',
|
|
507
|
+
variant: 'thumbnail',
|
|
508
|
+
name: '...',
|
|
509
|
+
driveId: '...',
|
|
510
|
+
}
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
```tsx
|
|
516
|
+
function AudioExample() {
|
|
517
|
+
const { data } = useAttachmentUrl({
|
|
518
|
+
projectId: '...',
|
|
519
|
+
blobId: {
|
|
520
|
+
type: 'audio',
|
|
521
|
+
variant: 'original',
|
|
522
|
+
name: '...',
|
|
523
|
+
driveId: '...',
|
|
524
|
+
}
|
|
525
|
+
})
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
```tsx
|
|
530
|
+
function VideoExample() {
|
|
531
|
+
const { data } = useAttachmentUrl({
|
|
532
|
+
projectId: '...',
|
|
533
|
+
blobId: {
|
|
534
|
+
type: 'video',
|
|
535
|
+
variant: 'original',
|
|
536
|
+
name: '...',
|
|
537
|
+
driveId: '...',
|
|
538
|
+
}
|
|
539
|
+
})
|
|
540
|
+
}
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
### useDocumentCreatedBy
|
|
545
|
+
|
|
546
|
+
Retrieve the device ID that created a document.
|
|
547
|
+
|
|
548
|
+
| Function | Type |
|
|
549
|
+
| ---------- | ---------- |
|
|
550
|
+
| `useDocumentCreatedBy` | `({ projectId, originalVersionId, }: { projectId: string; originalVersionId: string; }) => { data: string; error: Error or null; isRefetching: boolean; }` |
|
|
551
|
+
|
|
552
|
+
Parameters:
|
|
553
|
+
|
|
554
|
+
* `opts.projectId`: Project public ID
|
|
555
|
+
* `opts.originalVersionId`: Version ID of document
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
Examples:
|
|
559
|
+
|
|
560
|
+
```tsx
|
|
561
|
+
function BasicExample() {
|
|
562
|
+
const { data } = useDocumentCreatedBy({
|
|
563
|
+
projectId: '...',
|
|
564
|
+
originalVersionId: '...',
|
|
565
|
+
})
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
### useSingleDocByDocId
|
|
571
|
+
|
|
572
|
+
Retrieve a single document from the database based on the document's document ID.
|
|
573
|
+
|
|
574
|
+
Triggers the closest error boundary if the document cannot be found
|
|
575
|
+
|
|
576
|
+
| Function | Type |
|
|
577
|
+
| ---------- | ---------- |
|
|
578
|
+
| `useSingleDocByDocId` | `<D extends DocumentType>({ projectId, docType, docId, opts, }: { projectId: string; docType: D; docId: string; opts?: Omit<{ mustBeFound?: boolean or undefined; lang?: string or undefined; } or undefined, "mustBeFound"> or undefined; }) => { ...; }` |
|
|
579
|
+
|
|
580
|
+
Parameters:
|
|
581
|
+
|
|
582
|
+
* `opts.projectId`: Project public ID
|
|
583
|
+
* `opts.docType`: Document type of interest
|
|
584
|
+
* `opts.docId`: Document ID
|
|
585
|
+
* `opts.opts.lang`: Language to translate the document into
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
Examples:
|
|
589
|
+
|
|
590
|
+
```tsx
|
|
591
|
+
function SingleDocumentByDocIdExample() {
|
|
592
|
+
const { data } = useSingleDocByDocId({
|
|
593
|
+
projectId: '...',
|
|
594
|
+
docType: 'observation',
|
|
595
|
+
docId: '...',
|
|
596
|
+
})
|
|
597
|
+
|
|
598
|
+
console.log(data.schemaName) // logs 'observation'
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
### useSingleDocByVersionId
|
|
604
|
+
|
|
605
|
+
Retrieve a single document from the database based on the document's version ID.
|
|
606
|
+
|
|
607
|
+
Triggers the closest error boundary if the document cannot be found.
|
|
608
|
+
|
|
609
|
+
| Function | Type |
|
|
610
|
+
| ---------- | ---------- |
|
|
611
|
+
| `useSingleDocByVersionId` | `<D extends DocumentType>({ projectId, docType, versionId, opts, }: { projectId: string; docType: D; versionId: string; opts?: { lang?: string or undefined; } or undefined; }) => { data: { schemaName: "track"; locations: Position[]; ... 8 more ...; deleted: boolean; } or { ...; } or { ...; } or { ...; } or { ...; }; error:...` |
|
|
612
|
+
|
|
613
|
+
Parameters:
|
|
614
|
+
|
|
615
|
+
* `opts.projectId`: Project public ID
|
|
616
|
+
* `opts.docType`: Document type of interest
|
|
617
|
+
* `opts.versionId`: Document's version ID
|
|
618
|
+
* `opts.opts.lang`: Language to translate the document into
|
|
619
|
+
|
|
620
|
+
*
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
Examples:
|
|
624
|
+
|
|
625
|
+
```tsx
|
|
626
|
+
function SingleDocumentByVersionIdExample() {
|
|
627
|
+
const { data } = useSingleDocByVersionId({
|
|
628
|
+
projectId: '...',
|
|
629
|
+
docType: 'observation',
|
|
630
|
+
docId: '...',
|
|
631
|
+
})
|
|
632
|
+
|
|
633
|
+
console.log(data.schemaName) // logs 'observation'
|
|
634
|
+
}
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
### useManyDocs
|
|
639
|
+
|
|
640
|
+
Retrieve all documents of a specific `docType`.
|
|
641
|
+
|
|
642
|
+
| Function | Type |
|
|
643
|
+
| ---------- | ---------- |
|
|
644
|
+
| `useManyDocs` | `<D extends DocumentType>({ projectId, docType, opts, }: { projectId: string; docType: D; opts?: { includeDeleted?: boolean or undefined; lang?: string or undefined; } or undefined; }) => { data: ({ schemaName: "track"; locations: Position[]; ... 8 more ...; deleted: boolean; } and { ...; })[] or ({ ...; } and { ...; })[] or ...` |
|
|
645
|
+
|
|
646
|
+
Parameters:
|
|
647
|
+
|
|
648
|
+
* `opts.projectId`: Project public ID
|
|
649
|
+
* `opts.docType`: Document type of interest
|
|
650
|
+
* `opts.opts.includeDeleted`: Include documents that have been marked as deleted
|
|
651
|
+
* `opts.opts.lang`: Language to translate the documents into
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
Examples:
|
|
655
|
+
|
|
656
|
+
```tsx
|
|
657
|
+
function BasicExample() {
|
|
658
|
+
const { data } = useManyDocs({
|
|
659
|
+
projectId: '...',
|
|
660
|
+
docType: 'observations',
|
|
661
|
+
})
|
|
662
|
+
}
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
```tsx
|
|
666
|
+
function useAllObservations(opts) {
|
|
667
|
+
return useManyDocs({
|
|
668
|
+
...opts,
|
|
669
|
+
docType: 'observations',
|
|
670
|
+
})
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function useAllPresets(opts) {
|
|
674
|
+
return useManyDocs({
|
|
675
|
+
...opts,
|
|
676
|
+
docType: 'presets',
|
|
677
|
+
})
|
|
678
|
+
}
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
### getMapsQueryKey
|
|
683
|
+
|
|
684
|
+
| Function | Type |
|
|
685
|
+
| ---------- | ---------- |
|
|
686
|
+
| `getMapsQueryKey` | `() => readonly ["@comapeo/core-react", "maps"]` |
|
|
687
|
+
|
|
688
|
+
### getStyleJsonUrlQueryKey
|
|
689
|
+
|
|
690
|
+
| Function | Type |
|
|
691
|
+
| ---------- | ---------- |
|
|
692
|
+
| `getStyleJsonUrlQueryKey` | `({ refreshToken, }: { refreshToken?: string or undefined; }) => readonly ["@comapeo/core-react", "maps", "stylejson_url", { readonly refreshToken: string or undefined; }]` |
|
|
693
|
+
|
|
694
|
+
### mapStyleJsonUrlQueryOptions
|
|
695
|
+
|
|
696
|
+
| Function | Type |
|
|
697
|
+
| ---------- | ---------- |
|
|
698
|
+
| `mapStyleJsonUrlQueryOptions` | `({ clientApi, refreshToken, }: { clientApi: MapeoClientApi; refreshToken?: string or undefined; }) => OmitKeyof<UseQueryOptions<string, Error, string, QueryKey>, "queryFn"> and { ...; } and { ...; }` |
|
|
699
|
+
|
|
700
|
+
### useMapStyleUrl
|
|
701
|
+
|
|
702
|
+
Get a URL that points to a StyleJSON resource served by the embedded HTTP server.
|
|
703
|
+
|
|
704
|
+
If `opts.refreshToken` is specified, it will be appended to the returned URL as a search param. This is useful for forcing cache busting
|
|
705
|
+
due to hidden internal details by consuming components (e.g. map component from MapLibre).
|
|
706
|
+
|
|
707
|
+
| Function | Type |
|
|
708
|
+
| ---------- | ---------- |
|
|
709
|
+
| `useMapStyleUrl` | `({ refreshToken, }?: { refreshToken?: string or undefined; }) => { data: string; error: Error or null; isRefetching: boolean; }` |
|
|
710
|
+
|
|
711
|
+
Parameters:
|
|
712
|
+
|
|
713
|
+
* `opts.refreshToken`: String to append to the returned value as a search param
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
Examples:
|
|
717
|
+
|
|
718
|
+
```tsx
|
|
719
|
+
function ExampleWithoutRefreshToken() {
|
|
720
|
+
const { data, isRefetching } = useMapStyleUrl()
|
|
721
|
+
|
|
722
|
+
console.log(data) // logs something like 'http://localhost:...'
|
|
723
|
+
}
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
```tsx
|
|
727
|
+
function ExampleWithRefreshToken() {
|
|
728
|
+
const [refreshToken] = useState('foo')
|
|
729
|
+
const { data } = useMapStyleUrl({ refreshToken })
|
|
730
|
+
|
|
731
|
+
console.log(data) // logs something like 'http://localhost:...?refresh_token=foo'
|
|
732
|
+
}
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
### getInvitesQueryKey
|
|
737
|
+
|
|
738
|
+
| Function | Type |
|
|
739
|
+
| ---------- | ---------- |
|
|
740
|
+
| `getInvitesQueryKey` | `() => readonly ["@comapeo/core-react", "invites"]` |
|
|
741
|
+
|
|
742
|
+
### getPendingInvitesQueryKey
|
|
743
|
+
|
|
744
|
+
| Function | Type |
|
|
745
|
+
| ---------- | ---------- |
|
|
746
|
+
| `getPendingInvitesQueryKey` | `() => readonly ["@comapeo/core-react", "invites", { readonly status: "pending"; }]` |
|
|
747
|
+
|
|
748
|
+
### pendingInvitesQueryOptions
|
|
749
|
+
|
|
750
|
+
| Function | Type |
|
|
751
|
+
| ---------- | ---------- |
|
|
752
|
+
| `pendingInvitesQueryOptions` | `({ clientApi, }: { clientApi: MapeoClientApi; }) => OmitKeyof<UseQueryOptions<MapBuffers<InviteInternal>[], Error, MapBuffers<InviteInternal>[], QueryKey>, "queryFn"> and { ...; } and { ...; }` |
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
## Constants
|
|
756
|
+
|
|
757
|
+
- [ClientApiContext](#clientapicontext)
|
|
758
|
+
- [ROOT_QUERY_KEY](#root_query_key)
|
|
759
|
+
|
|
760
|
+
### ClientApiContext
|
|
761
|
+
|
|
762
|
+
| Constant | Type |
|
|
763
|
+
| ---------- | ---------- |
|
|
764
|
+
| `ClientApiContext` | `Context<MapeoClientApi or null>` |
|
|
765
|
+
|
|
766
|
+
### ROOT_QUERY_KEY
|
|
767
|
+
|
|
768
|
+
| Constant | Type |
|
|
769
|
+
| ---------- | ---------- |
|
|
770
|
+
| `ROOT_QUERY_KEY` | `"@comapeo/core-react"` |
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
## Types
|
|
775
|
+
|
|
776
|
+
- [DocumentType](#documenttype)
|
|
777
|
+
|
|
778
|
+
### DocumentType
|
|
779
|
+
|
|
780
|
+
| Type | Type |
|
|
781
|
+
| ---------- | ---------- |
|
|
782
|
+
| `DocumentType` | `Extract< MapeoDoc['schemaName'], 'field' or 'observation' or 'preset' or 'track' or 'remoteDetectionAlert' >` |
|
|
783
|
+
|