@comapeo/core-react 0.1.1 → 1.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [0.1.2](https://github.com/digidem/comapeo-core-react/compare/v0.1.1...v0.1.2) (2024-12-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * fix return value of getIsArchiveDeviceQueryKey() ([8742fc2](https://github.com/digidem/comapeo-core-react/commit/8742fc24379564f64f9ec25c4c2e9179083d659d))
11
+
5
12
  ## [0.1.1](https://github.com/digidem/comapeo-core-react/compare/v0.1.0...v0.1.1) (2024-12-12)
6
13
 
7
14
 
package/README.md CHANGED
@@ -4,10 +4,10 @@ React wrapper for working with [`@comapeo/core`](https://github.com/digidem/coma
4
4
 
5
5
  ## Installation
6
6
 
7
- `@comapeo/schema`, `@comapeo/core`, and `@comapeo/ipc` are peer deps and must be installed alongside this package. You may want to pin these to specific versions depending on your needs.
7
+ `react`, `@tanstack/react-query`, `@comapeo/schema`, `@comapeo/core`, and `@comapeo/ipc` are peer deps and must be installed alongside this package. You may want to pin these to specific versions depending on your needs.
8
8
 
9
9
  ```sh
10
- npm install @comapeo/core-react @comapeo/schema @comapeo/core @comapeo/ipc
10
+ npm install react @tanstack/react-query@5 @comapeo/core-react @comapeo/schema @comapeo/core @comapeo/ipc
11
11
  ```
12
12
 
13
13
  ## API Documentation
@@ -4,7 +4,7 @@ export declare const ClientApiContext: import("react").Context<import("@comapeo/
4
4
  /**
5
5
  * Create a context provider that holds a CoMapeo API client instance.
6
6
  *
7
- * @param {Object} opts
7
+ * @param opts
8
8
  * @param {ReactNode} opts.children React children node
9
9
  * @param {MapeoClientApi} opts.clientApi Client API instance
10
10
  */
@@ -3,7 +3,7 @@ export const ClientApiContext = createContext(null);
3
3
  /**
4
4
  * Create a context provider that holds a CoMapeo API client instance.
5
5
  *
6
- * @param {Object} opts
6
+ * @param opts
7
7
  * @param {ReactNode} opts.children React children node
8
8
  * @param {MapeoClientApi} opts.clientApi Client API instance
9
9
  */
@@ -2,7 +2,7 @@
2
2
  * Access a client API instance. If a ClientApiContext provider is not
3
3
  * set up, it will throw an error.
4
4
  *
5
- * @returns {import('@comapeo/ipc').MapeoClientApi} Client API instance
5
+ * @returns Client API instance
6
6
  *
7
7
  * @example
8
8
  * ```tsx
@@ -6,7 +6,7 @@ import { deviceInfoQueryOptions, isArchiveDeviceQueryOptions, } from '../lib/rea
6
6
  * Access a client API instance. If a ClientApiContext provider is not
7
7
  * set up, it will throw an error.
8
8
  *
9
- * @returns {import('@comapeo/ipc').MapeoClientApi} Client API instance
9
+ * @returns Client API instance
10
10
  *
11
11
  * @example
12
12
  * ```tsx
@@ -1,15 +1,19 @@
1
- import { documentByDocumentIdQueryOptions, documentByVersionIdQueryOptions, documentsQueryOptions, type DocumentType } from '../lib/react-query/documents';
1
+ import type { MapeoDoc } from '@comapeo/schema';
2
+ import { type DocumentType } from '../lib/react-query/documents';
3
+ type ReadHookResult<D> = {
4
+ data: D;
5
+ error: Error | null;
6
+ isRefetching: boolean;
7
+ };
2
8
  /**
3
9
  * Retrieve a single document from the database based on the document's document ID.
4
10
  *
5
11
  * Triggers the closest error boundary if the document cannot be found
6
12
  *
7
- * @param {Object} opts
8
- * @param {string} opts.projectId Project public ID
9
- * @param {DocumentType} opts.docType Document type of interest
10
- * @param {string} opts.docId Document ID
11
- * @param {Object} [opts.opts]
12
- * @param {string} [opts.opts.lang] Language to translate the document into
13
+ * @param opts.projectId Project public ID
14
+ * @param opts.docType Document type of interest
15
+ * @param opts.docId Document ID
16
+ * @param opts.lang Language to translate the document into
13
17
  *
14
18
  * @example
15
19
  * ```tsx
@@ -24,150 +28,23 @@ import { documentByDocumentIdQueryOptions, documentByVersionIdQueryOptions, docu
24
28
  * }
25
29
  * ```
26
30
  */
27
- export declare function useSingleDocByDocId<D extends DocumentType>({ projectId, docType, docId, opts, }: {
31
+ export declare function useSingleDocByDocId<D extends DocumentType>({ projectId, docType, docId, lang, }: {
28
32
  projectId: string;
29
33
  docType: D;
30
34
  docId: string;
31
- opts?: Parameters<typeof documentByDocumentIdQueryOptions>[0]['opts'];
32
- }): {
33
- data: ({
34
- schemaName: "track";
35
- locations: import("@comapeo/schema/dist/schema/track").Position[];
36
- observationRefs: {
37
- docId: string;
38
- versionId: string;
39
- }[];
40
- tags: {
41
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
42
- };
43
- docId: string;
44
- versionId: string;
45
- originalVersionId: string;
46
- createdAt: string;
47
- updatedAt: string;
48
- links: string[];
49
- deleted: boolean;
50
- } & {
51
- forks: string[];
52
- }) | ({
53
- schemaName: "remoteDetectionAlert";
54
- detectionDateStart: string;
55
- detectionDateEnd: string;
56
- sourceId: string;
57
- metadata: {
58
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
59
- };
60
- geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert").Geometry;
61
- docId: string;
62
- versionId: string;
63
- originalVersionId: string;
64
- createdAt: string;
65
- updatedAt: string;
66
- links: string[];
67
- deleted: boolean;
68
- } & {
69
- forks: string[];
70
- }) | ({
71
- schemaName: "preset";
72
- name: string;
73
- geometry: ("point" | "vertex" | "line" | "area" | "relation")[];
74
- tags: import("@comapeo/schema/dist/schema/preset").Tags;
75
- addTags: import("@comapeo/schema/dist/schema/preset").Tags1;
76
- removeTags: import("@comapeo/schema/dist/schema/preset").Tags2;
77
- fieldRefs: {
78
- docId: string;
79
- versionId: string;
80
- }[];
81
- iconRef?: {
82
- docId: string;
83
- versionId: string;
84
- } | undefined;
85
- terms: string[];
86
- color?: string | undefined;
87
- docId: string;
88
- versionId: string;
89
- originalVersionId: string;
90
- createdAt: string;
91
- updatedAt: string;
92
- links: string[];
93
- deleted: boolean;
94
- } & {
95
- forks: string[];
96
- }) | ({
97
- schemaName: "observation";
98
- lat?: number | undefined;
99
- lon?: number | undefined;
100
- attachments: {
101
- driveDiscoveryId: string;
102
- name: string;
103
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
104
- hash: string;
105
- }[];
106
- tags: {
107
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
108
- };
109
- metadata?: {
110
- manualLocation?: boolean;
111
- position?: import("@comapeo/schema/dist/schema/observation").Position;
112
- lastSavedPosition?: import("@comapeo/schema/dist/schema/observation").Position;
113
- positionProvider?: {
114
- gpsAvailable?: boolean;
115
- passiveAvailable?: boolean;
116
- locationServicesEnabled: boolean;
117
- networkAvailable?: boolean;
118
- };
119
- } | undefined;
120
- presetRef?: {
121
- docId: string;
122
- versionId: string;
123
- } | undefined;
124
- docId: string;
125
- versionId: string;
126
- originalVersionId: string;
127
- createdAt: string;
128
- updatedAt: string;
129
- links: string[];
130
- deleted: boolean;
131
- } & {
132
- forks: string[];
133
- }) | ({
134
- schemaName: "field";
135
- tagKey: string;
136
- type: "type_unspecified" | "text" | "number" | "selectOne" | "selectMultiple" | "UNRECOGNIZED";
137
- label: string;
138
- appearance?: ("appearance_unspecified" | "singleline" | "multiline" | "UNRECOGNIZED") | undefined;
139
- snakeCase?: boolean | undefined;
140
- options?: {
141
- label: string;
142
- value: string | boolean | number | null;
143
- }[] | undefined;
144
- universal?: boolean | undefined;
145
- placeholder?: string | undefined;
146
- helperText?: string | undefined;
147
- docId: string;
148
- versionId: string;
149
- originalVersionId: string;
150
- createdAt: string;
151
- updatedAt: string;
152
- links: string[];
153
- deleted: boolean;
154
- } & {
155
- forks: string[];
156
- });
157
- error: Error | null;
158
- isRefetching: boolean;
159
- };
35
+ lang?: string;
36
+ }): ReadHookResult<Extract<MapeoDoc, {
37
+ schemaName: D;
38
+ }>>;
160
39
  /**
161
40
  * Retrieve a single document from the database based on the document's version ID.
162
41
  *
163
42
  * Triggers the closest error boundary if the document cannot be found.
164
43
  *
165
- * @param {Object} opts
166
- * @param {string} opts.projectId Project public ID
167
- * @param {DocumentType} opts.docType Document type of interest
168
- * @param {string} opts.versionId Document's version ID
169
- * @param {Object} [opts.opts]
170
- * @param {string} [opts.opts.lang] Language to translate the document into
44
+ * @param opts.projectId Project public ID
45
+ * @param opts.docType Document type of interest
46
+ * @param opts.versionId Document's version ID
47
+ * @param opts.lang Language to translate the document into
171
48
  *
172
49
  * * @example
173
50
  * ```tsx
@@ -182,138 +59,21 @@ export declare function useSingleDocByDocId<D extends DocumentType>({ projectId,
182
59
  * }
183
60
  * ```
184
61
  */
185
- export declare function useSingleDocByVersionId<D extends DocumentType>({ projectId, docType, versionId, opts, }: {
62
+ export declare function useSingleDocByVersionId<D extends DocumentType>({ projectId, docType, versionId, lang, }: {
186
63
  projectId: string;
187
64
  docType: D;
188
65
  versionId: string;
189
- opts?: Parameters<typeof documentByVersionIdQueryOptions>[0]['opts'];
190
- }): {
191
- data: {
192
- schemaName: "track";
193
- locations: import("@comapeo/schema/dist/schema/track").Position[];
194
- observationRefs: {
195
- docId: string;
196
- versionId: string;
197
- }[];
198
- tags: {
199
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
200
- };
201
- docId: string;
202
- versionId: string;
203
- originalVersionId: string;
204
- createdAt: string;
205
- updatedAt: string;
206
- links: string[];
207
- deleted: boolean;
208
- } | {
209
- schemaName: "remoteDetectionAlert";
210
- detectionDateStart: string;
211
- detectionDateEnd: string;
212
- sourceId: string;
213
- metadata: {
214
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
215
- };
216
- geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert").Geometry;
217
- docId: string;
218
- versionId: string;
219
- originalVersionId: string;
220
- createdAt: string;
221
- updatedAt: string;
222
- links: string[];
223
- deleted: boolean;
224
- } | {
225
- schemaName: "preset";
226
- name: string;
227
- geometry: ("point" | "vertex" | "line" | "area" | "relation")[];
228
- tags: import("@comapeo/schema/dist/schema/preset").Tags;
229
- addTags: import("@comapeo/schema/dist/schema/preset").Tags1;
230
- removeTags: import("@comapeo/schema/dist/schema/preset").Tags2;
231
- fieldRefs: {
232
- docId: string;
233
- versionId: string;
234
- }[];
235
- iconRef?: {
236
- docId: string;
237
- versionId: string;
238
- } | undefined;
239
- terms: string[];
240
- color?: string | undefined;
241
- docId: string;
242
- versionId: string;
243
- originalVersionId: string;
244
- createdAt: string;
245
- updatedAt: string;
246
- links: string[];
247
- deleted: boolean;
248
- } | {
249
- schemaName: "observation";
250
- lat?: number | undefined;
251
- lon?: number | undefined;
252
- attachments: {
253
- driveDiscoveryId: string;
254
- name: string;
255
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
256
- hash: string;
257
- }[];
258
- tags: {
259
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
260
- };
261
- metadata?: {
262
- manualLocation?: boolean;
263
- position?: import("@comapeo/schema/dist/schema/observation").Position;
264
- lastSavedPosition?: import("@comapeo/schema/dist/schema/observation").Position;
265
- positionProvider?: {
266
- gpsAvailable?: boolean;
267
- passiveAvailable?: boolean;
268
- locationServicesEnabled: boolean;
269
- networkAvailable?: boolean;
270
- };
271
- } | undefined;
272
- presetRef?: {
273
- docId: string;
274
- versionId: string;
275
- } | undefined;
276
- docId: string;
277
- versionId: string;
278
- originalVersionId: string;
279
- createdAt: string;
280
- updatedAt: string;
281
- links: string[];
282
- deleted: boolean;
283
- } | {
284
- schemaName: "field";
285
- tagKey: string;
286
- type: "type_unspecified" | "text" | "number" | "selectOne" | "selectMultiple" | "UNRECOGNIZED";
287
- label: string;
288
- appearance?: ("appearance_unspecified" | "singleline" | "multiline" | "UNRECOGNIZED") | undefined;
289
- snakeCase?: boolean | undefined;
290
- options?: {
291
- label: string;
292
- value: string | boolean | number | null;
293
- }[] | undefined;
294
- universal?: boolean | undefined;
295
- placeholder?: string | undefined;
296
- helperText?: string | undefined;
297
- docId: string;
298
- versionId: string;
299
- originalVersionId: string;
300
- createdAt: string;
301
- updatedAt: string;
302
- links: string[];
303
- deleted: boolean;
304
- };
305
- error: Error | null;
306
- isRefetching: boolean;
307
- };
66
+ lang?: string;
67
+ }): ReadHookResult<Extract<MapeoDoc, {
68
+ schemaName: D;
69
+ }>>;
308
70
  /**
309
71
  * Retrieve all documents of a specific `docType`.
310
72
  *
311
- * @param {Object} opts
312
- * @param {string} opts.projectId Project public ID
313
- * @param {DocumentType} opts.docType Document type of interest
314
- * @param {Object} [opts.opts]
315
- * @param {boolean} [opts.opts.includeDeleted] Include documents that have been marked as deleted
316
- * @param {string} [opts.opts.lang] Language to translate the documents into
73
+ * @param opts.projectId Project public ID
74
+ * @param opts.docType Document type of interest
75
+ * @param opts.includeDeleted Include documents that have been marked as deleted
76
+ * @param opts.lang Language to translate the documents into
317
77
  *
318
78
  * @example
319
79
  * ```tsx
@@ -341,135 +101,12 @@ export declare function useSingleDocByVersionId<D extends DocumentType>({ projec
341
101
  * }
342
102
  * ```
343
103
  */
344
- export declare function useManyDocs<D extends DocumentType>({ projectId, docType, opts, }: {
104
+ export declare function useManyDocs<D extends DocumentType>({ projectId, docType, includeDeleted, lang, }: {
345
105
  projectId: string;
346
106
  docType: D;
347
- opts?: Parameters<typeof documentsQueryOptions>[0]['opts'];
348
- }): {
349
- data: ({
350
- schemaName: "track";
351
- locations: import("@comapeo/schema/dist/schema/track").Position[];
352
- observationRefs: {
353
- docId: string;
354
- versionId: string;
355
- }[];
356
- tags: {
357
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
358
- };
359
- docId: string;
360
- versionId: string;
361
- originalVersionId: string;
362
- createdAt: string;
363
- updatedAt: string;
364
- links: string[];
365
- deleted: boolean;
366
- } & {
367
- forks: string[];
368
- })[] | ({
369
- schemaName: "remoteDetectionAlert";
370
- detectionDateStart: string;
371
- detectionDateEnd: string;
372
- sourceId: string;
373
- metadata: {
374
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
375
- };
376
- geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert").Geometry;
377
- docId: string;
378
- versionId: string;
379
- originalVersionId: string;
380
- createdAt: string;
381
- updatedAt: string;
382
- links: string[];
383
- deleted: boolean;
384
- } & {
385
- forks: string[];
386
- })[] | ({
387
- schemaName: "preset";
388
- name: string;
389
- geometry: ("point" | "vertex" | "line" | "area" | "relation")[];
390
- tags: import("@comapeo/schema/dist/schema/preset").Tags;
391
- addTags: import("@comapeo/schema/dist/schema/preset").Tags1;
392
- removeTags: import("@comapeo/schema/dist/schema/preset").Tags2;
393
- fieldRefs: {
394
- docId: string;
395
- versionId: string;
396
- }[];
397
- iconRef?: {
398
- docId: string;
399
- versionId: string;
400
- } | undefined;
401
- terms: string[];
402
- color?: string | undefined;
403
- docId: string;
404
- versionId: string;
405
- originalVersionId: string;
406
- createdAt: string;
407
- updatedAt: string;
408
- links: string[];
409
- deleted: boolean;
410
- } & {
411
- forks: string[];
412
- })[] | ({
413
- schemaName: "observation";
414
- lat?: number | undefined;
415
- lon?: number | undefined;
416
- attachments: {
417
- driveDiscoveryId: string;
418
- name: string;
419
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
420
- hash: string;
421
- }[];
422
- tags: {
423
- [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
424
- };
425
- metadata?: {
426
- manualLocation?: boolean;
427
- position?: import("@comapeo/schema/dist/schema/observation").Position;
428
- lastSavedPosition?: import("@comapeo/schema/dist/schema/observation").Position;
429
- positionProvider?: {
430
- gpsAvailable?: boolean;
431
- passiveAvailable?: boolean;
432
- locationServicesEnabled: boolean;
433
- networkAvailable?: boolean;
434
- };
435
- } | undefined;
436
- presetRef?: {
437
- docId: string;
438
- versionId: string;
439
- } | undefined;
440
- docId: string;
441
- versionId: string;
442
- originalVersionId: string;
443
- createdAt: string;
444
- updatedAt: string;
445
- links: string[];
446
- deleted: boolean;
447
- } & {
448
- forks: string[];
449
- })[] | ({
450
- schemaName: "field";
451
- tagKey: string;
452
- type: "type_unspecified" | "text" | "number" | "selectOne" | "selectMultiple" | "UNRECOGNIZED";
453
- label: string;
454
- appearance?: ("appearance_unspecified" | "singleline" | "multiline" | "UNRECOGNIZED") | undefined;
455
- snakeCase?: boolean | undefined;
456
- options?: {
457
- label: string;
458
- value: string | boolean | number | null;
459
- }[] | undefined;
460
- universal?: boolean | undefined;
461
- placeholder?: string | undefined;
462
- helperText?: string | undefined;
463
- docId: string;
464
- versionId: string;
465
- originalVersionId: string;
466
- createdAt: string;
467
- updatedAt: string;
468
- links: string[];
469
- deleted: boolean;
470
- } & {
471
- forks: string[];
472
- })[];
473
- error: Error | null;
474
- isRefetching: boolean;
475
- };
107
+ includeDeleted?: boolean;
108
+ lang?: string;
109
+ }): ReadHookResult<Extract<MapeoDoc, {
110
+ schemaName: D;
111
+ }>>;
112
+ export {};
@@ -1,18 +1,15 @@
1
1
  import { useSuspenseQuery } from '@tanstack/react-query';
2
2
  import { documentByDocumentIdQueryOptions, documentByVersionIdQueryOptions, documentsQueryOptions, } from '../lib/react-query/documents';
3
3
  import { useSingleProject } from './projects';
4
- // TODO: Return type is not narrowed properly by `docType`
5
4
  /**
6
5
  * Retrieve a single document from the database based on the document's document ID.
7
6
  *
8
7
  * Triggers the closest error boundary if the document cannot be found
9
8
  *
10
- * @param {Object} opts
11
- * @param {string} opts.projectId Project public ID
12
- * @param {DocumentType} opts.docType Document type of interest
13
- * @param {string} opts.docId Document ID
14
- * @param {Object} [opts.opts]
15
- * @param {string} [opts.opts.lang] Language to translate the document into
9
+ * @param opts.projectId Project public ID
10
+ * @param opts.docType Document type of interest
11
+ * @param opts.docId Document ID
12
+ * @param opts.lang Language to translate the document into
16
13
  *
17
14
  * @example
18
15
  * ```tsx
@@ -27,29 +24,33 @@ import { useSingleProject } from './projects';
27
24
  * }
28
25
  * ```
29
26
  */
30
- export function useSingleDocByDocId({ projectId, docType, docId, opts, }) {
27
+ export function useSingleDocByDocId({ projectId, docType, docId, lang, }) {
31
28
  const { data: projectApi } = useSingleProject({ projectId });
32
29
  const { data, error, isRefetching } = useSuspenseQuery(documentByDocumentIdQueryOptions({
33
30
  projectApi,
34
31
  projectId,
35
32
  docType,
36
33
  docId,
37
- opts,
34
+ lang,
38
35
  }));
39
- return { data, error, isRefetching };
36
+ return {
37
+ // @ts-expect-error - TS does not handle dependent types, so this will not
38
+ // be narrowed properly within the function body. See for example
39
+ // https://github.com/microsoft/TypeScript/issues/33014#event-15134418011
40
+ data,
41
+ error,
42
+ isRefetching,
43
+ };
40
44
  }
41
- // TODO: Return type is not narrowed properly by `docType`
42
45
  /**
43
46
  * Retrieve a single document from the database based on the document's version ID.
44
47
  *
45
48
  * Triggers the closest error boundary if the document cannot be found.
46
49
  *
47
- * @param {Object} opts
48
- * @param {string} opts.projectId Project public ID
49
- * @param {DocumentType} opts.docType Document type of interest
50
- * @param {string} opts.versionId Document's version ID
51
- * @param {Object} [opts.opts]
52
- * @param {string} [opts.opts.lang] Language to translate the document into
50
+ * @param opts.projectId Project public ID
51
+ * @param opts.docType Document type of interest
52
+ * @param opts.versionId Document's version ID
53
+ * @param opts.lang Language to translate the document into
53
54
  *
54
55
  * * @example
55
56
  * ```tsx
@@ -64,27 +65,29 @@ export function useSingleDocByDocId({ projectId, docType, docId, opts, }) {
64
65
  * }
65
66
  * ```
66
67
  */
67
- export function useSingleDocByVersionId({ projectId, docType, versionId, opts, }) {
68
+ export function useSingleDocByVersionId({ projectId, docType, versionId, lang, }) {
68
69
  const { data: projectApi } = useSingleProject({ projectId });
69
70
  const { data, error, isRefetching } = useSuspenseQuery(documentByVersionIdQueryOptions({
70
71
  projectApi,
71
72
  projectId,
72
73
  docType,
73
74
  versionId,
74
- opts,
75
+ lang,
75
76
  }));
76
- return { data, error, isRefetching };
77
+ return {
78
+ // @ts-expect-error - TS does not handle dependent types, see above
79
+ data,
80
+ error,
81
+ isRefetching,
82
+ };
77
83
  }
78
- // TODO: Return type is not narrowed properly by `docType`
79
84
  /**
80
85
  * Retrieve all documents of a specific `docType`.
81
86
  *
82
- * @param {Object} opts
83
- * @param {string} opts.projectId Project public ID
84
- * @param {DocumentType} opts.docType Document type of interest
85
- * @param {Object} [opts.opts]
86
- * @param {boolean} [opts.opts.includeDeleted] Include documents that have been marked as deleted
87
- * @param {string} [opts.opts.lang] Language to translate the documents into
87
+ * @param opts.projectId Project public ID
88
+ * @param opts.docType Document type of interest
89
+ * @param opts.includeDeleted Include documents that have been marked as deleted
90
+ * @param opts.lang Language to translate the documents into
88
91
  *
89
92
  * @example
90
93
  * ```tsx
@@ -112,13 +115,19 @@ export function useSingleDocByVersionId({ projectId, docType, versionId, opts, }
112
115
  * }
113
116
  * ```
114
117
  */
115
- export function useManyDocs({ projectId, docType, opts, }) {
118
+ export function useManyDocs({ projectId, docType, includeDeleted, lang, }) {
116
119
  const { data: projectApi } = useSingleProject({ projectId });
117
120
  const { data, error, isRefetching } = useSuspenseQuery(documentsQueryOptions({
118
121
  projectApi,
119
122
  projectId,
120
123
  docType,
121
- opts,
124
+ includeDeleted,
125
+ lang,
122
126
  }));
123
- return { data, error, isRefetching };
127
+ return {
128
+ // @ts-expect-error - TS does not handle dependent types, see above
129
+ data,
130
+ error,
131
+ isRefetching,
132
+ };
124
133
  }
@@ -4,8 +4,7 @@
4
4
  * If `opts.refreshToken` is specified, it will be appended to the returned URL as a search param. This is useful for forcing cache busting
5
5
  * due to hidden internal details by consuming components (e.g. map component from MapLibre).
6
6
  *
7
- * @param {Object} opts
8
- * @param {string} opts.refreshToken String to append to the returned value as a search param
7
+ * @param opts.refreshToken String to append to the returned value as a search param
9
8
  *
10
9
  * @example
11
10
  * ```tsx