@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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
## 0.1.0 (2024-12-12)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- initial implementation of many tanstack-query queries ([8a6aed7](https://github.com/digidem/comapeo-core-react/commit/8a6aed78f646c0f536551ac4a0423ff5d7780b33))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Digital Democracy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @comapeo/core-react
|
|
2
|
+
|
|
3
|
+
React wrapper for working with [`@comapeo/core`](https://github.com/digidem/comapeo-core)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @comapeo/core-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Documentation
|
|
12
|
+
|
|
13
|
+
Still a work in progress. Currently lives in [`docs/API.md`](./docs/API.md).
|
|
14
|
+
|
|
15
|
+
## Contributing
|
|
16
|
+
|
|
17
|
+
See contributing docs in [`docs/CONTRIBUTING.md`](./docs/CONTRIBUTING.md)
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MapeoClientApi } from '@comapeo/ipc';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
export declare const ClientApiContext: import("react").Context<import("@comapeo/ipc/dist/client").MapeoClientApi | null>;
|
|
4
|
+
/**
|
|
5
|
+
* Create a context provider that holds a CoMapeo API client instance.
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} opts
|
|
8
|
+
* @param {ReactNode} opts.children React children node
|
|
9
|
+
* @param {MapeoClientApi} opts.clientApi Client API instance
|
|
10
|
+
*/
|
|
11
|
+
export declare function ClientApiProvider({ children, clientApi, }: {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
clientApi: MapeoClientApi;
|
|
14
|
+
}): import("react").FunctionComponentElement<import("react").ProviderProps<import("@comapeo/ipc/dist/client").MapeoClientApi | null>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, createElement } from 'react';
|
|
2
|
+
export const ClientApiContext = createContext(null);
|
|
3
|
+
/**
|
|
4
|
+
* Create a context provider that holds a CoMapeo API client instance.
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} opts
|
|
7
|
+
* @param {ReactNode} opts.children React children node
|
|
8
|
+
* @param {MapeoClientApi} opts.clientApi Client API instance
|
|
9
|
+
*/
|
|
10
|
+
export function ClientApiProvider({ children, clientApi, }) {
|
|
11
|
+
return createElement(ClientApiContext.Provider, { value: clientApi }, children);
|
|
12
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access a client API instance. If a ClientApiContext provider is not
|
|
3
|
+
* set up, it will throw an error.
|
|
4
|
+
*
|
|
5
|
+
* @returns {import('@comapeo/ipc').MapeoClientApi} Client API instance
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* function ClientExample() {
|
|
10
|
+
* return (
|
|
11
|
+
* // Creation of clientApi omitted for brevity
|
|
12
|
+
* <ClientApiContext.Provider clientApi={clientApi}>
|
|
13
|
+
* <ComponentThatUsesClient />
|
|
14
|
+
* </ClientApiContext.Provider>
|
|
15
|
+
* )
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* function ComponentThatUsesClient() {
|
|
19
|
+
* const clientApi = useClientApi()
|
|
20
|
+
*
|
|
21
|
+
* // Rest omitted for brevity.
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare function useClientApi(): import("@comapeo/ipc/dist/client").MapeoClientApi;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieve info about the current device.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* function DeviceInfoExample() {
|
|
33
|
+
* const { data } = useDeviceInfo()
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function useOwnDeviceInfo(): {
|
|
38
|
+
data: {
|
|
39
|
+
deviceId: string;
|
|
40
|
+
deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
|
|
41
|
+
} & Partial<import("@comapeo/core/dist/schema/client").DeviceInfoParam>;
|
|
42
|
+
error: Error | null;
|
|
43
|
+
isRefetching: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve whether the current device is an archive device or not.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* function IsArchiveDeviceExample() {
|
|
51
|
+
* const { data } = useIsArchiveDevice()
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function useIsArchiveDevice(): {
|
|
56
|
+
data: boolean;
|
|
57
|
+
error: Error | null;
|
|
58
|
+
isRefetching: boolean;
|
|
59
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { ClientApiContext } from '../contexts/ClientApi';
|
|
4
|
+
import { deviceInfoQueryOptions, isArchiveDeviceQueryOptions, } from '../lib/react-query/client';
|
|
5
|
+
/**
|
|
6
|
+
* Access a client API instance. If a ClientApiContext provider is not
|
|
7
|
+
* set up, it will throw an error.
|
|
8
|
+
*
|
|
9
|
+
* @returns {import('@comapeo/ipc').MapeoClientApi} Client API instance
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function ClientExample() {
|
|
14
|
+
* return (
|
|
15
|
+
* // Creation of clientApi omitted for brevity
|
|
16
|
+
* <ClientApiContext.Provider clientApi={clientApi}>
|
|
17
|
+
* <ComponentThatUsesClient />
|
|
18
|
+
* </ClientApiContext.Provider>
|
|
19
|
+
* )
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* function ComponentThatUsesClient() {
|
|
23
|
+
* const clientApi = useClientApi()
|
|
24
|
+
*
|
|
25
|
+
* // Rest omitted for brevity.
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export function useClientApi() {
|
|
31
|
+
const clientApi = useContext(ClientApiContext);
|
|
32
|
+
if (!clientApi) {
|
|
33
|
+
throw new Error('No client API set. Make sure you set up the ClientApiContext provider properly');
|
|
34
|
+
}
|
|
35
|
+
return clientApi;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve info about the current device.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* function DeviceInfoExample() {
|
|
43
|
+
* const { data } = useDeviceInfo()
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function useOwnDeviceInfo() {
|
|
48
|
+
const clientApi = useClientApi();
|
|
49
|
+
const { data, error, isRefetching } = useSuspenseQuery(deviceInfoQueryOptions({ clientApi }));
|
|
50
|
+
return { data, error, isRefetching };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Retrieve whether the current device is an archive device or not.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* function IsArchiveDeviceExample() {
|
|
58
|
+
* const { data } = useIsArchiveDevice()
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function useIsArchiveDevice() {
|
|
63
|
+
const clientApi = useClientApi();
|
|
64
|
+
const { data, error, isRefetching } = useSuspenseQuery(isArchiveDeviceQueryOptions({ clientApi }));
|
|
65
|
+
return { data, error, isRefetching };
|
|
66
|
+
}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { documentByDocumentIdQueryOptions, documentByVersionIdQueryOptions, documentsQueryOptions, type DocumentType } from '../lib/react-query/documents';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve a single document from the database based on the document's document ID.
|
|
4
|
+
*
|
|
5
|
+
* Triggers the closest error boundary if the document cannot be found
|
|
6
|
+
*
|
|
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
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* function SingleDocumentByDocIdExample() {
|
|
17
|
+
* const { data } = useSingleDocByDocId({
|
|
18
|
+
* projectId: '...',
|
|
19
|
+
* docType: 'observation',
|
|
20
|
+
* docId: '...',
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* console.log(data.schemaName) // logs 'observation'
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useSingleDocByDocId<D extends DocumentType>({ projectId, docType, docId, opts, }: {
|
|
28
|
+
projectId: string;
|
|
29
|
+
docType: D;
|
|
30
|
+
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
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Retrieve a single document from the database based on the document's version ID.
|
|
162
|
+
*
|
|
163
|
+
* Triggers the closest error boundary if the document cannot be found.
|
|
164
|
+
*
|
|
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
|
|
171
|
+
*
|
|
172
|
+
* * @example
|
|
173
|
+
* ```tsx
|
|
174
|
+
* function SingleDocumentByVersionIdExample() {
|
|
175
|
+
* const { data } = useSingleDocByVersionId({
|
|
176
|
+
* projectId: '...',
|
|
177
|
+
* docType: 'observation',
|
|
178
|
+
* docId: '...',
|
|
179
|
+
* })
|
|
180
|
+
*
|
|
181
|
+
* console.log(data.schemaName) // logs 'observation'
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
export declare function useSingleDocByVersionId<D extends DocumentType>({ projectId, docType, versionId, opts, }: {
|
|
186
|
+
projectId: string;
|
|
187
|
+
docType: D;
|
|
188
|
+
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
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Retrieve all documents of a specific `docType`.
|
|
310
|
+
*
|
|
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
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```tsx
|
|
320
|
+
* function BasicExample() {
|
|
321
|
+
* const { data } = useManyDocs({
|
|
322
|
+
* projectId: '...',
|
|
323
|
+
* docType: 'observations',
|
|
324
|
+
* })
|
|
325
|
+
* }
|
|
326
|
+
* ```
|
|
327
|
+
*
|
|
328
|
+
* ```tsx
|
|
329
|
+
* function useAllObservations(opts) {
|
|
330
|
+
* return useManyDocs({
|
|
331
|
+
* ...opts,
|
|
332
|
+
* docType: 'observations',
|
|
333
|
+
* })
|
|
334
|
+
* }
|
|
335
|
+
*
|
|
336
|
+
* function useAllPresets(opts) {
|
|
337
|
+
* return useManyDocs({
|
|
338
|
+
* ...opts,
|
|
339
|
+
* docType: 'presets',
|
|
340
|
+
* })
|
|
341
|
+
* }
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
export declare function useManyDocs<D extends DocumentType>({ projectId, docType, opts, }: {
|
|
345
|
+
projectId: string;
|
|
346
|
+
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
|
+
};
|