@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 +7 -0
- package/README.md +2 -2
- package/dist/contexts/ClientApi.d.ts +1 -1
- package/dist/contexts/ClientApi.js +1 -1
- package/dist/hooks/client.d.ts +1 -1
- package/dist/hooks/client.js +1 -1
- package/dist/hooks/documents.d.ts +36 -399
- package/dist/hooks/documents.js +39 -30
- package/dist/hooks/maps.d.ts +1 -2
- package/dist/hooks/maps.js +1 -2
- package/dist/hooks/projects.d.ts +22 -32
- package/dist/hooks/projects.js +21 -30
- package/dist/lib/react-query/client.d.ts +1 -1
- package/dist/lib/react-query/client.js +1 -1
- package/dist/lib/react-query/documents.d.ts +28 -19
- package/dist/lib/react-query/documents.js +36 -15
- package/dist/lib/react-query/projects.d.ts +16 -8
- package/dist/lib/react-query/projects.js +12 -5
- package/docs/API.md +25 -27
- package/package.json +5 -5
package/dist/hooks/maps.js
CHANGED
|
@@ -7,8 +7,7 @@ import { useClientApi } from './client';
|
|
|
7
7
|
* If `opts.refreshToken` is specified, it will be appended to the returned URL as a search param. This is useful for forcing cache busting
|
|
8
8
|
* due to hidden internal details by consuming components (e.g. map component from MapLibre).
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param {string} opts.refreshToken String to append to the returned value as a search param
|
|
10
|
+
* @param opts.refreshToken String to append to the returned value as a search param
|
|
12
11
|
*
|
|
13
12
|
* @example
|
|
14
13
|
* ```tsx
|
package/dist/hooks/projects.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import type { BitmapOpts, SvgOpts } from '@comapeo/core/dist/icon-api';
|
|
1
2
|
import type { BlobId } from '@comapeo/core/dist/types';
|
|
2
|
-
import { iconUrlQueryOptions } from '../lib/react-query/projects';
|
|
3
3
|
/**
|
|
4
4
|
* Retrieve the project settings for a project.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param {string} opts.projectId Project public ID
|
|
6
|
+
* @param opts.projectId Project public ID
|
|
8
7
|
*
|
|
9
8
|
* @example
|
|
10
9
|
* ```tsx
|
|
@@ -27,8 +26,7 @@ export declare function useProjectSettings({ projectId }: {
|
|
|
27
26
|
*
|
|
28
27
|
* This is mostly used internally by the other hooks and should only be used if certain project APIs are not exposed via the hooks.
|
|
29
28
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param {string} opts.projectId Project public ID
|
|
29
|
+
* @param opts.projectId Project public ID
|
|
32
30
|
*
|
|
33
31
|
* @example
|
|
34
32
|
* ```tsx
|
|
@@ -84,9 +82,8 @@ export declare function useManyProjects(): {
|
|
|
84
82
|
/**
|
|
85
83
|
* Retrieve a single member of a project.
|
|
86
84
|
*
|
|
87
|
-
* @param
|
|
88
|
-
* @param
|
|
89
|
-
* @param {deviceId} opts.projectId Device ID of interest
|
|
85
|
+
* @param opts.projectId Project public ID
|
|
86
|
+
* @param opts.projectId Device ID of interest
|
|
90
87
|
*
|
|
91
88
|
* @example
|
|
92
89
|
* ```tsx
|
|
@@ -108,8 +105,7 @@ export declare function useSingleMember({ projectId, deviceId, }: {
|
|
|
108
105
|
/**
|
|
109
106
|
* Retrieve all members of a project.
|
|
110
107
|
*
|
|
111
|
-
* @param
|
|
112
|
-
* @param {string} opts.projectId Project public ID
|
|
108
|
+
* @param opts.projectId Project public ID
|
|
113
109
|
*
|
|
114
110
|
* @example
|
|
115
111
|
* ```tsx
|
|
@@ -132,10 +128,11 @@ export declare function useManyMembers({ projectId }: {
|
|
|
132
128
|
*
|
|
133
129
|
* _TODO: Explain bitmap opts vs svg opts_
|
|
134
130
|
*
|
|
135
|
-
* @param
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
138
|
-
* @param
|
|
131
|
+
* @param opts.projectId Project public ID
|
|
132
|
+
* @param opts.iconId Icon ID of interest
|
|
133
|
+
* @param opts.mimeType MIME type of desired resource
|
|
134
|
+
* @param opts.pixelDensity Pixel density resource (only applicable when `mimeType` is `'image/png'`)
|
|
135
|
+
* @param opts.size Size of desired resource
|
|
139
136
|
*
|
|
140
137
|
* @example
|
|
141
138
|
* ```tsx
|
|
@@ -143,11 +140,9 @@ export declare function useManyMembers({ projectId }: {
|
|
|
143
140
|
* const { data } = useIconUrl({
|
|
144
141
|
* projectId: '...',
|
|
145
142
|
* iconId: '...',
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* size: 'medium'
|
|
150
|
-
* }
|
|
143
|
+
* mimeType: 'image/png',
|
|
144
|
+
* pixelDensity: 1,
|
|
145
|
+
* size: 'medium'
|
|
151
146
|
* })
|
|
152
147
|
* }
|
|
153
148
|
* ```
|
|
@@ -157,19 +152,16 @@ export declare function useManyMembers({ projectId }: {
|
|
|
157
152
|
* const { data } = useIconUrl({
|
|
158
153
|
* projectId: '...',
|
|
159
154
|
* iconId: '...',
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* size: 'medium'
|
|
163
|
-
* }
|
|
155
|
+
* mimeType: 'image/svg',
|
|
156
|
+
* size: 'medium'
|
|
164
157
|
* })
|
|
165
158
|
* }
|
|
166
159
|
* ```
|
|
167
160
|
*/
|
|
168
|
-
export declare function useIconUrl({ projectId, iconId,
|
|
161
|
+
export declare function useIconUrl({ projectId, iconId, ...mimeBasedOpts }: {
|
|
169
162
|
projectId: string;
|
|
170
163
|
iconId: string;
|
|
171
|
-
|
|
172
|
-
}): {
|
|
164
|
+
} & (BitmapOpts | SvgOpts)): {
|
|
173
165
|
data: string;
|
|
174
166
|
error: Error | null;
|
|
175
167
|
isRefetching: boolean;
|
|
@@ -179,9 +171,8 @@ export declare function useIconUrl({ projectId, iconId, opts, }: {
|
|
|
179
171
|
*
|
|
180
172
|
* _TODO: Explain BlobId in more depth_
|
|
181
173
|
*
|
|
182
|
-
* @param
|
|
183
|
-
* @param
|
|
184
|
-
* @param {BlobId} opts.blobId Blob ID of the desired resource
|
|
174
|
+
* @param opts.projectId Project public Id
|
|
175
|
+
* @param opts.blobId Blob ID of the desired resource
|
|
185
176
|
*
|
|
186
177
|
* @example
|
|
187
178
|
* ```tsx
|
|
@@ -237,9 +228,8 @@ export declare function useAttachmentUrl({ projectId, blobId, }: {
|
|
|
237
228
|
/**
|
|
238
229
|
* Retrieve the device ID that created a document.
|
|
239
230
|
*
|
|
240
|
-
* @param
|
|
241
|
-
* @param
|
|
242
|
-
* @param {string} opts.originalVersionId Version ID of document
|
|
231
|
+
* @param opts.projectId Project public ID
|
|
232
|
+
* @param opts.originalVersionId Version ID of document
|
|
243
233
|
*
|
|
244
234
|
* @example
|
|
245
235
|
* ```tsx
|
package/dist/hooks/projects.js
CHANGED
|
@@ -4,8 +4,7 @@ import { useClientApi } from './client';
|
|
|
4
4
|
/**
|
|
5
5
|
* Retrieve the project settings for a project.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param {string} opts.projectId Project public ID
|
|
7
|
+
* @param opts.projectId Project public ID
|
|
9
8
|
*
|
|
10
9
|
* @example
|
|
11
10
|
* ```tsx
|
|
@@ -33,8 +32,7 @@ export function useProjectSettings({ projectId }) {
|
|
|
33
32
|
*
|
|
34
33
|
* This is mostly used internally by the other hooks and should only be used if certain project APIs are not exposed via the hooks.
|
|
35
34
|
*
|
|
36
|
-
* @param
|
|
37
|
-
* @param {string} opts.projectId Project public ID
|
|
35
|
+
* @param opts.projectId Project public ID
|
|
38
36
|
*
|
|
39
37
|
* @example
|
|
40
38
|
* ```tsx
|
|
@@ -81,9 +79,8 @@ export function useManyProjects() {
|
|
|
81
79
|
/**
|
|
82
80
|
* Retrieve a single member of a project.
|
|
83
81
|
*
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
86
|
-
* @param {deviceId} opts.projectId Device ID of interest
|
|
82
|
+
* @param opts.projectId Project public ID
|
|
83
|
+
* @param opts.projectId Device ID of interest
|
|
87
84
|
*
|
|
88
85
|
* @example
|
|
89
86
|
* ```tsx
|
|
@@ -106,8 +103,7 @@ export function useSingleMember({ projectId, deviceId, }) {
|
|
|
106
103
|
/**
|
|
107
104
|
* Retrieve all members of a project.
|
|
108
105
|
*
|
|
109
|
-
* @param
|
|
110
|
-
* @param {string} opts.projectId Project public ID
|
|
106
|
+
* @param opts.projectId Project public ID
|
|
111
107
|
*
|
|
112
108
|
* @example
|
|
113
109
|
* ```tsx
|
|
@@ -128,10 +124,11 @@ export function useManyMembers({ projectId }) {
|
|
|
128
124
|
*
|
|
129
125
|
* _TODO: Explain bitmap opts vs svg opts_
|
|
130
126
|
*
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
127
|
+
* @param opts.projectId Project public ID
|
|
128
|
+
* @param opts.iconId Icon ID of interest
|
|
129
|
+
* @param opts.mimeType MIME type of desired resource
|
|
130
|
+
* @param opts.pixelDensity Pixel density resource (only applicable when `mimeType` is `'image/png'`)
|
|
131
|
+
* @param opts.size Size of desired resource
|
|
135
132
|
*
|
|
136
133
|
* @example
|
|
137
134
|
* ```tsx
|
|
@@ -139,11 +136,9 @@ export function useManyMembers({ projectId }) {
|
|
|
139
136
|
* const { data } = useIconUrl({
|
|
140
137
|
* projectId: '...',
|
|
141
138
|
* iconId: '...',
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* size: 'medium'
|
|
146
|
-
* }
|
|
139
|
+
* mimeType: 'image/png',
|
|
140
|
+
* pixelDensity: 1,
|
|
141
|
+
* size: 'medium'
|
|
147
142
|
* })
|
|
148
143
|
* }
|
|
149
144
|
* ```
|
|
@@ -153,21 +148,19 @@ export function useManyMembers({ projectId }) {
|
|
|
153
148
|
* const { data } = useIconUrl({
|
|
154
149
|
* projectId: '...',
|
|
155
150
|
* iconId: '...',
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* size: 'medium'
|
|
159
|
-
* }
|
|
151
|
+
* mimeType: 'image/svg',
|
|
152
|
+
* size: 'medium'
|
|
160
153
|
* })
|
|
161
154
|
* }
|
|
162
155
|
* ```
|
|
163
156
|
*/
|
|
164
|
-
export function useIconUrl({ projectId, iconId,
|
|
157
|
+
export function useIconUrl({ projectId, iconId, ...mimeBasedOpts }) {
|
|
165
158
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
166
159
|
const { data, error, isRefetching } = useSuspenseQuery(iconUrlQueryOptions({
|
|
160
|
+
...mimeBasedOpts,
|
|
167
161
|
projectApi,
|
|
168
162
|
projectId,
|
|
169
163
|
iconId,
|
|
170
|
-
opts,
|
|
171
164
|
}));
|
|
172
165
|
return { data, error, isRefetching };
|
|
173
166
|
}
|
|
@@ -176,9 +169,8 @@ export function useIconUrl({ projectId, iconId, opts, }) {
|
|
|
176
169
|
*
|
|
177
170
|
* _TODO: Explain BlobId in more depth_
|
|
178
171
|
*
|
|
179
|
-
* @param
|
|
180
|
-
* @param
|
|
181
|
-
* @param {BlobId} opts.blobId Blob ID of the desired resource
|
|
172
|
+
* @param opts.projectId Project public Id
|
|
173
|
+
* @param opts.blobId Blob ID of the desired resource
|
|
182
174
|
*
|
|
183
175
|
* @example
|
|
184
176
|
* ```tsx
|
|
@@ -236,9 +228,8 @@ export function useAttachmentUrl({ projectId, blobId, }) {
|
|
|
236
228
|
/**
|
|
237
229
|
* Retrieve the device ID that created a document.
|
|
238
230
|
*
|
|
239
|
-
* @param
|
|
240
|
-
* @param
|
|
241
|
-
* @param {string} opts.originalVersionId Version ID of document
|
|
231
|
+
* @param opts.projectId Project public ID
|
|
232
|
+
* @param opts.originalVersionId Version ID of document
|
|
242
233
|
*
|
|
243
234
|
* @example
|
|
244
235
|
* ```tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MapeoClientApi } from '@comapeo/ipc';
|
|
2
2
|
export declare function getClientQueryKey(): readonly ["@comapeo/core-react", "client"];
|
|
3
3
|
export declare function getDeviceInfoQueryKey(): readonly ["@comapeo/core-react", "client", "device_info"];
|
|
4
|
-
export declare function getIsArchiveDeviceQueryKey(): readonly ["@comapeo/core-react", "client", "
|
|
4
|
+
export declare function getIsArchiveDeviceQueryKey(): readonly ["@comapeo/core-react", "client", "is_archive_device"];
|
|
5
5
|
export declare function deviceInfoQueryOptions({ clientApi, }: {
|
|
6
6
|
clientApi: MapeoClientApi;
|
|
7
7
|
}): import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
@@ -7,7 +7,7 @@ export function getDeviceInfoQueryKey() {
|
|
|
7
7
|
return [ROOT_QUERY_KEY, 'client', 'device_info'];
|
|
8
8
|
}
|
|
9
9
|
export function getIsArchiveDeviceQueryKey() {
|
|
10
|
-
return [ROOT_QUERY_KEY, 'client', '
|
|
10
|
+
return [ROOT_QUERY_KEY, 'client', 'is_archive_device'];
|
|
11
11
|
}
|
|
12
12
|
export function deviceInfoQueryOptions({ clientApi, }) {
|
|
13
13
|
return queryOptions({
|
|
@@ -5,28 +5,37 @@ export declare function getDocumentsQueryKey<D extends DocumentType>({ projectId
|
|
|
5
5
|
projectId: string;
|
|
6
6
|
docType: D;
|
|
7
7
|
}): readonly ["@comapeo/core-react", "projects", string, D];
|
|
8
|
-
export declare function getManyDocumentsQueryKey<D extends DocumentType>({ projectId, docType,
|
|
8
|
+
export declare function getManyDocumentsQueryKey<D extends DocumentType>({ projectId, docType, includeDeleted, lang, }: {
|
|
9
9
|
projectId: string;
|
|
10
10
|
docType: D;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
includeDeleted?: boolean;
|
|
12
|
+
lang?: string;
|
|
13
|
+
}): readonly ["@comapeo/core-react", "projects", string, D, {
|
|
14
|
+
readonly includeDeleted: boolean | undefined;
|
|
15
|
+
readonly lang: string | undefined;
|
|
16
|
+
}];
|
|
17
|
+
export declare function getDocumentByDocIdQueryKey<D extends DocumentType>({ projectId, docType, docId, lang, }: {
|
|
14
18
|
projectId: string;
|
|
15
19
|
docType: D;
|
|
16
|
-
docId:
|
|
17
|
-
|
|
18
|
-
}): readonly ["@comapeo/core-react", "projects", string, D,
|
|
19
|
-
|
|
20
|
+
docId: string;
|
|
21
|
+
lang?: string;
|
|
22
|
+
}): readonly ["@comapeo/core-react", "projects", string, D, string, {
|
|
23
|
+
readonly lang: string | undefined;
|
|
24
|
+
}];
|
|
25
|
+
export declare function getDocumentByVersionIdQueryKey<D extends DocumentType>({ projectId, docType, versionId, lang, }: {
|
|
20
26
|
projectId: string;
|
|
21
27
|
docType: D;
|
|
22
|
-
versionId:
|
|
23
|
-
|
|
24
|
-
}): readonly ["@comapeo/core-react", "projects", string, D,
|
|
25
|
-
|
|
28
|
+
versionId: string;
|
|
29
|
+
lang?: string;
|
|
30
|
+
}): readonly ["@comapeo/core-react", "projects", string, D, string, {
|
|
31
|
+
readonly lang: string | undefined;
|
|
32
|
+
}];
|
|
33
|
+
export declare function documentsQueryOptions<D extends DocumentType>({ projectApi, projectId, docType, includeDeleted, lang, }: {
|
|
26
34
|
projectApi: MapeoProjectApi;
|
|
27
35
|
projectId: string;
|
|
28
36
|
docType: D;
|
|
29
|
-
|
|
37
|
+
includeDeleted?: boolean;
|
|
38
|
+
lang?: string;
|
|
30
39
|
}): import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
31
40
|
schemaName: "track";
|
|
32
41
|
locations: import("@comapeo/schema/dist/schema/track").Position[];
|
|
@@ -524,12 +533,12 @@ export declare function documentsQueryOptions<D extends DocumentType>({ projectA
|
|
|
524
533
|
forks: string[];
|
|
525
534
|
})[]>;
|
|
526
535
|
};
|
|
527
|
-
export declare function documentByDocumentIdQueryOptions<D extends DocumentType>({ projectApi, projectId, docType, docId,
|
|
536
|
+
export declare function documentByDocumentIdQueryOptions<D extends DocumentType>({ projectApi, projectId, docType, docId, lang, }: {
|
|
528
537
|
projectApi: MapeoProjectApi;
|
|
529
538
|
projectId: string;
|
|
530
539
|
docType: D;
|
|
531
|
-
docId:
|
|
532
|
-
|
|
540
|
+
docId: string;
|
|
541
|
+
lang?: string;
|
|
533
542
|
}): import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
534
543
|
schemaName: "track";
|
|
535
544
|
locations: import("@comapeo/schema/dist/schema/track").Position[];
|
|
@@ -1027,12 +1036,12 @@ export declare function documentByDocumentIdQueryOptions<D extends DocumentType>
|
|
|
1027
1036
|
forks: string[];
|
|
1028
1037
|
})>;
|
|
1029
1038
|
};
|
|
1030
|
-
export declare function documentByVersionIdQueryOptions<D extends DocumentType>({ projectApi, projectId, docType, versionId,
|
|
1039
|
+
export declare function documentByVersionIdQueryOptions<D extends DocumentType>({ projectApi, projectId, docType, versionId, lang, }: {
|
|
1031
1040
|
projectApi: MapeoProjectApi;
|
|
1032
1041
|
projectId: string;
|
|
1033
1042
|
docType: D;
|
|
1034
|
-
versionId:
|
|
1035
|
-
|
|
1043
|
+
versionId: string;
|
|
1044
|
+
lang?: string;
|
|
1036
1045
|
}): import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
1037
1046
|
schemaName: "track";
|
|
1038
1047
|
locations: import("@comapeo/schema/dist/schema/track").Position[];
|
|
@@ -3,60 +3,81 @@ import { baseQueryOptions, ROOT_QUERY_KEY } from './shared';
|
|
|
3
3
|
export function getDocumentsQueryKey({ projectId, docType, }) {
|
|
4
4
|
return [ROOT_QUERY_KEY, 'projects', projectId, docType];
|
|
5
5
|
}
|
|
6
|
-
export function getManyDocumentsQueryKey({ projectId, docType,
|
|
7
|
-
return [
|
|
6
|
+
export function getManyDocumentsQueryKey({ projectId, docType, includeDeleted, lang, }) {
|
|
7
|
+
return [
|
|
8
|
+
ROOT_QUERY_KEY,
|
|
9
|
+
'projects',
|
|
10
|
+
projectId,
|
|
11
|
+
docType,
|
|
12
|
+
{ includeDeleted, lang },
|
|
13
|
+
];
|
|
8
14
|
}
|
|
9
|
-
export function getDocumentByDocIdQueryKey({ projectId, docType, docId,
|
|
10
|
-
return [
|
|
15
|
+
export function getDocumentByDocIdQueryKey({ projectId, docType, docId, lang, }) {
|
|
16
|
+
return [
|
|
17
|
+
ROOT_QUERY_KEY,
|
|
18
|
+
'projects',
|
|
19
|
+
projectId,
|
|
20
|
+
docType,
|
|
21
|
+
docId,
|
|
22
|
+
{ lang },
|
|
23
|
+
];
|
|
11
24
|
}
|
|
12
|
-
export function getDocumentByVersionIdQueryKey({ projectId, docType, versionId,
|
|
25
|
+
export function getDocumentByVersionIdQueryKey({ projectId, docType, versionId, lang, }) {
|
|
13
26
|
return [
|
|
14
27
|
ROOT_QUERY_KEY,
|
|
15
28
|
'projects',
|
|
16
29
|
projectId,
|
|
17
30
|
docType,
|
|
18
31
|
versionId,
|
|
19
|
-
|
|
32
|
+
{ lang },
|
|
20
33
|
];
|
|
21
34
|
}
|
|
22
|
-
export function documentsQueryOptions({ projectApi, projectId, docType,
|
|
35
|
+
export function documentsQueryOptions({ projectApi, projectId, docType, includeDeleted, lang, }) {
|
|
23
36
|
return queryOptions({
|
|
24
37
|
...baseQueryOptions(),
|
|
25
|
-
queryKey: getManyDocumentsQueryKey({
|
|
38
|
+
queryKey: getManyDocumentsQueryKey({
|
|
39
|
+
projectId,
|
|
40
|
+
docType,
|
|
41
|
+
includeDeleted,
|
|
42
|
+
lang,
|
|
43
|
+
}),
|
|
26
44
|
queryFn: async () => {
|
|
27
|
-
return projectApi[docType].getMany(
|
|
45
|
+
return projectApi[docType].getMany({
|
|
46
|
+
includeDeleted,
|
|
47
|
+
lang,
|
|
48
|
+
});
|
|
28
49
|
},
|
|
29
50
|
});
|
|
30
51
|
}
|
|
31
|
-
export function documentByDocumentIdQueryOptions({ projectApi, projectId, docType, docId,
|
|
52
|
+
export function documentByDocumentIdQueryOptions({ projectApi, projectId, docType, docId, lang, }) {
|
|
32
53
|
return queryOptions({
|
|
33
54
|
...baseQueryOptions(),
|
|
34
55
|
queryKey: getDocumentByDocIdQueryKey({
|
|
35
56
|
projectId,
|
|
36
57
|
docType,
|
|
37
58
|
docId,
|
|
38
|
-
|
|
59
|
+
lang,
|
|
39
60
|
}),
|
|
40
61
|
queryFn: async () => {
|
|
41
62
|
return projectApi[docType].getByDocId(docId, {
|
|
42
|
-
|
|
63
|
+
lang,
|
|
43
64
|
// We want to make sure that this throws in the case that no match is found
|
|
44
65
|
mustBeFound: true,
|
|
45
66
|
});
|
|
46
67
|
},
|
|
47
68
|
});
|
|
48
69
|
}
|
|
49
|
-
export function documentByVersionIdQueryOptions({ projectApi, projectId, docType, versionId,
|
|
70
|
+
export function documentByVersionIdQueryOptions({ projectApi, projectId, docType, versionId, lang, }) {
|
|
50
71
|
return queryOptions({
|
|
51
72
|
...baseQueryOptions(),
|
|
52
73
|
queryKey: getDocumentByVersionIdQueryKey({
|
|
53
74
|
projectId,
|
|
54
75
|
docType,
|
|
55
76
|
versionId,
|
|
56
|
-
|
|
77
|
+
lang,
|
|
57
78
|
}),
|
|
58
79
|
queryFn: async () => {
|
|
59
|
-
return projectApi[docType].getByVersionId(versionId,
|
|
80
|
+
return projectApi[docType].getByVersionId(versionId, { lang });
|
|
60
81
|
},
|
|
61
82
|
});
|
|
62
83
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BitmapOpts, SvgOpts } from '@comapeo/core/dist/icon-api';
|
|
1
2
|
import type { BlobId } from '@comapeo/core/dist/types.js';
|
|
2
3
|
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc';
|
|
3
4
|
export declare function getProjectsQueryKey(): readonly ["@comapeo/core-react", "projects"];
|
|
@@ -17,11 +18,19 @@ export declare function getMemberByIdQueryKey({ projectId, deviceId, }: {
|
|
|
17
18
|
projectId: string;
|
|
18
19
|
deviceId: string;
|
|
19
20
|
}): readonly ["@comapeo/core-react", "projects", string, "members", string];
|
|
20
|
-
export declare function getIconUrlQueryKey({ projectId, iconId,
|
|
21
|
-
projectId: string;
|
|
22
|
-
iconId:
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
export declare function getIconUrlQueryKey({ projectId, iconId, ...mimeBasedOpts }: {
|
|
22
|
+
projectId: string;
|
|
23
|
+
iconId: string;
|
|
24
|
+
} & (BitmapOpts | SvgOpts)): readonly ["@comapeo/core-react", "projects", string, "icons", string, {
|
|
25
|
+
mimeType: Extract<import("@comapeo/core/dist/icon-api").IconVariant["mimeType"], "image/png">;
|
|
26
|
+
pixelDensity: Extract<import("@comapeo/core/dist/icon-api").IconVariant, {
|
|
27
|
+
mimeType: "image/png";
|
|
28
|
+
}>["pixelDensity"];
|
|
29
|
+
size: import("@comapeo/core/dist/icon-api").ValidSizes;
|
|
30
|
+
} | {
|
|
31
|
+
mimeType: Extract<import("@comapeo/core/dist/icon-api").IconVariant["mimeType"], "image/svg+xml">;
|
|
32
|
+
size: import("@comapeo/core/dist/icon-api").ValidSizes;
|
|
33
|
+
}];
|
|
25
34
|
export declare function getDocumentCreatedByQueryKey({ projectId, originalVersionId, }: {
|
|
26
35
|
projectId: string;
|
|
27
36
|
originalVersionId: string;
|
|
@@ -158,12 +167,11 @@ export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
|
|
|
158
167
|
} & {
|
|
159
168
|
queryKey: import("@tanstack/query-core").DataTag<import("@tanstack/query-core").QueryKey, import("@comapeo/core/dist/roles").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">>;
|
|
160
169
|
};
|
|
161
|
-
export declare function iconUrlQueryOptions({ projectApi, projectId, iconId,
|
|
170
|
+
export declare function iconUrlQueryOptions({ projectApi, projectId, iconId, ...mimeBasedOpts }: {
|
|
162
171
|
projectApi: MapeoProjectApi;
|
|
163
172
|
projectId: string;
|
|
164
173
|
iconId: Parameters<MapeoProjectApi['$icons']['getIconUrl']>[0];
|
|
165
|
-
|
|
166
|
-
}): import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, import("@tanstack/query-core").QueryKey>, "queryFn"> & {
|
|
174
|
+
} & (BitmapOpts | SvgOpts)): import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, import("@tanstack/query-core").QueryKey>, "queryFn"> & {
|
|
167
175
|
queryFn?: import("@tanstack/query-core").QueryFunction<string, import("@tanstack/query-core").QueryKey, never> | undefined;
|
|
168
176
|
} & {
|
|
169
177
|
queryKey: import("@tanstack/query-core").DataTag<import("@tanstack/query-core").QueryKey, string>;
|
|
@@ -18,8 +18,15 @@ export function getMembersQueryKey({ projectId }) {
|
|
|
18
18
|
export function getMemberByIdQueryKey({ projectId, deviceId, }) {
|
|
19
19
|
return [ROOT_QUERY_KEY, 'projects', projectId, 'members', deviceId];
|
|
20
20
|
}
|
|
21
|
-
export function getIconUrlQueryKey({ projectId, iconId,
|
|
22
|
-
return [
|
|
21
|
+
export function getIconUrlQueryKey({ projectId, iconId, ...mimeBasedOpts }) {
|
|
22
|
+
return [
|
|
23
|
+
ROOT_QUERY_KEY,
|
|
24
|
+
'projects',
|
|
25
|
+
projectId,
|
|
26
|
+
'icons',
|
|
27
|
+
iconId,
|
|
28
|
+
mimeBasedOpts,
|
|
29
|
+
];
|
|
23
30
|
}
|
|
24
31
|
export function getDocumentCreatedByQueryKey({ projectId, originalVersionId, }) {
|
|
25
32
|
return [
|
|
@@ -87,12 +94,12 @@ export function projectOwnRoleQueryOptions({ projectApi, projectId, }) {
|
|
|
87
94
|
},
|
|
88
95
|
});
|
|
89
96
|
}
|
|
90
|
-
export function iconUrlQueryOptions({ projectApi, projectId, iconId,
|
|
97
|
+
export function iconUrlQueryOptions({ projectApi, projectId, iconId, ...mimeBasedOpts }) {
|
|
91
98
|
return queryOptions({
|
|
92
99
|
...baseQueryOptions(),
|
|
93
|
-
queryKey: getIconUrlQueryKey({ projectId, iconId
|
|
100
|
+
queryKey: getIconUrlQueryKey({ ...mimeBasedOpts, projectId, iconId }),
|
|
94
101
|
queryFn: async () => {
|
|
95
|
-
return projectApi.$icons.getIconUrl(iconId,
|
|
102
|
+
return projectApi.$icons.getIconUrl(iconId, mimeBasedOpts);
|
|
96
103
|
},
|
|
97
104
|
});
|
|
98
105
|
}
|