@comapeo/core-react 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/commonjs/contexts/ClientApi.d.ts +14 -0
  2. package/dist/commonjs/contexts/ClientApi.js +16 -0
  3. package/dist/commonjs/hooks/client.d.ts +80 -0
  4. package/dist/commonjs/hooks/client.js +91 -0
  5. package/dist/{hooks → commonjs/hooks}/documents.d.ts +60 -5
  6. package/dist/commonjs/hooks/documents.js +192 -0
  7. package/dist/commonjs/hooks/invites.d.ts +51 -0
  8. package/dist/commonjs/hooks/invites.js +50 -0
  9. package/dist/commonjs/hooks/maps.js +37 -0
  10. package/dist/commonjs/hooks/projects.d.ts +334 -0
  11. package/dist/commonjs/hooks/projects.js +320 -0
  12. package/dist/commonjs/index.d.ts +12 -0
  13. package/dist/commonjs/index.js +69 -0
  14. package/dist/commonjs/lib/react-query/client.d.ts +61 -0
  15. package/dist/commonjs/lib/react-query/client.js +68 -0
  16. package/dist/{lib → commonjs/lib}/react-query/documents.d.ts +789 -706
  17. package/dist/commonjs/lib/react-query/documents.js +149 -0
  18. package/dist/commonjs/lib/react-query/invites.d.ts +71 -0
  19. package/dist/commonjs/lib/react-query/invites.js +85 -0
  20. package/dist/commonjs/lib/react-query/maps.d.ts +24 -0
  21. package/dist/commonjs/lib/react-query/maps.js +27 -0
  22. package/dist/commonjs/lib/react-query/projects.d.ts +332 -0
  23. package/dist/commonjs/lib/react-query/projects.js +235 -0
  24. package/dist/{lib → commonjs/lib}/react-query/shared.d.ts +5 -1
  25. package/dist/commonjs/lib/react-query/shared.js +23 -0
  26. package/dist/commonjs/package.json +3 -0
  27. package/dist/{contexts → esm/contexts}/ClientApi.d.ts +3 -3
  28. package/dist/{hooks → esm/hooks}/client.d.ts +23 -2
  29. package/dist/{hooks → esm/hooks}/client.js +21 -3
  30. package/dist/esm/hooks/documents.d.ts +167 -0
  31. package/dist/{hooks → esm/hooks}/documents.js +54 -3
  32. package/dist/esm/hooks/invites.d.ts +51 -0
  33. package/dist/esm/hooks/invites.js +44 -0
  34. package/dist/esm/hooks/maps.d.ts +33 -0
  35. package/dist/{hooks → esm/hooks}/maps.js +2 -2
  36. package/dist/{hooks → esm/hooks}/projects.d.ts +89 -6
  37. package/dist/{hooks → esm/hooks}/projects.js +59 -3
  38. package/dist/esm/index.d.ts +12 -0
  39. package/dist/esm/index.js +12 -0
  40. package/dist/esm/lib/react-query/client.d.ts +61 -0
  41. package/dist/esm/lib/react-query/client.js +59 -0
  42. package/dist/esm/lib/react-query/documents.d.ts +1584 -0
  43. package/dist/{lib → esm/lib}/react-query/documents.js +56 -2
  44. package/dist/esm/lib/react-query/invites.d.ts +71 -0
  45. package/dist/esm/lib/react-query/invites.js +76 -0
  46. package/dist/esm/lib/react-query/maps.d.ts +24 -0
  47. package/dist/{lib → esm/lib}/react-query/maps.js +6 -2
  48. package/dist/esm/lib/react-query/projects.d.ts +332 -0
  49. package/dist/{lib → esm/lib}/react-query/projects.js +84 -2
  50. package/dist/esm/lib/react-query/shared.d.ts +9 -0
  51. package/dist/{lib → esm/lib}/react-query/shared.js +7 -1
  52. package/dist/esm/package.json +3 -0
  53. package/docs/API.md +157 -258
  54. package/package.json +51 -37
  55. package/dist/index.d.ts +0 -11
  56. package/dist/index.js +0 -11
  57. package/dist/lib/react-query/client.d.ts +0 -30
  58. package/dist/lib/react-query/client.js +0 -29
  59. package/dist/lib/react-query/invites.d.ts +0 -12
  60. package/dist/lib/react-query/invites.js +0 -17
  61. package/dist/lib/react-query/maps.d.ts +0 -15
  62. package/dist/lib/react-query/projects.d.ts +0 -196
  63. /package/dist/{hooks → commonjs/hooks}/maps.d.ts +0 -0
  64. /package/dist/{contexts → esm/contexts}/ClientApi.js +0 -0
@@ -0,0 +1,332 @@
1
+ import type { Metadata } from '@comapeo/core/dist/blob-api.js' with { 'resolution-mode': 'import' };
2
+ import type { BitmapOpts, SvgOpts } from '@comapeo/core/dist/icon-api.js' with { 'resolution-mode': 'import' };
3
+ import type { EditableProjectSettings } from '@comapeo/core/dist/mapeo-project.js' with { 'resolution-mode': 'import' };
4
+ import type { BlobId } from '@comapeo/core/dist/types.js' with { 'resolution-mode': 'import' };
5
+ import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with { 'resolution-mode': 'import' };
6
+ import type { ProjectSettings } from '@comapeo/schema' with { 'resolution-mode': 'import' };
7
+ import { type QueryClient } from '@tanstack/react-query';
8
+ export declare function getProjectsQueryKey(): readonly ["@comapeo/core-react", "projects"];
9
+ export declare function getProjectByIdQueryKey({ projectId }: {
10
+ projectId: string;
11
+ }): readonly ["@comapeo/core-react", "projects", string];
12
+ export declare function getProjectSettingsQueryKey({ projectId, }: {
13
+ projectId: string;
14
+ }): readonly ["@comapeo/core-react", "projects", string, "project_settings"];
15
+ export declare function getProjectRoleQueryKey({ projectId }: {
16
+ projectId: string;
17
+ }): readonly ["@comapeo/core-react", "projects", string, "role"];
18
+ export declare function getMembersQueryKey({ projectId }: {
19
+ projectId: string;
20
+ }): readonly ["@comapeo/core-react", "projects", string, "members"];
21
+ export declare function getMemberByIdQueryKey({ projectId, deviceId, }: {
22
+ projectId: string;
23
+ deviceId: string;
24
+ }): readonly ["@comapeo/core-react", "projects", string, "members", string];
25
+ export declare function getIconUrlQueryKey({ projectId, iconId, ...mimeBasedOpts }: {
26
+ projectId: string;
27
+ iconId: string;
28
+ } & (BitmapOpts | SvgOpts)): readonly ["@comapeo/core-react", "projects", string, "icons", string, {
29
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/png">;
30
+ pixelDensity: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant, {
31
+ mimeType: "image/png";
32
+ }>["pixelDensity"];
33
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
34
+ } | {
35
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/svg+xml">;
36
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
37
+ }];
38
+ export declare function getDocumentCreatedByQueryKey({ projectId, originalVersionId, }: {
39
+ projectId: string;
40
+ originalVersionId: string;
41
+ }): readonly ["@comapeo/core-react", "projects", string, "document_created_by", string];
42
+ export declare function getAttachmentUrlQueryKey({ projectId, blobId, }: {
43
+ projectId: string;
44
+ blobId: BlobId;
45
+ }): readonly ["@comapeo/core-react", "projects", string, "attachments", BlobId];
46
+ export declare function projectsQueryOptions({ clientApi, }: {
47
+ clientApi: MapeoClientApi;
48
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<(Pick<{
49
+ schemaName: "projectSettings";
50
+ name?: string | undefined;
51
+ defaultPresets?: {
52
+ point: string[];
53
+ area: string[];
54
+ vertex: string[];
55
+ line: string[];
56
+ relation: string[];
57
+ } | undefined;
58
+ configMetadata?: {
59
+ name: string;
60
+ buildDate: string;
61
+ importDate: string;
62
+ fileVersion: string;
63
+ } | undefined;
64
+ }, "name"> & {
65
+ projectId: string;
66
+ createdAt?: string | undefined;
67
+ updatedAt?: string | undefined;
68
+ })[], Error, (Pick<{
69
+ schemaName: "projectSettings";
70
+ name?: string | undefined;
71
+ defaultPresets?: {
72
+ point: string[];
73
+ area: string[];
74
+ vertex: string[];
75
+ line: string[];
76
+ relation: string[];
77
+ } | undefined;
78
+ configMetadata?: {
79
+ name: string;
80
+ buildDate: string;
81
+ importDate: string;
82
+ fileVersion: string;
83
+ } | undefined;
84
+ }, "name"> & {
85
+ projectId: string;
86
+ createdAt?: string | undefined;
87
+ updatedAt?: string | undefined;
88
+ })[], readonly ["@comapeo/core-react", "projects"]>, "queryFn"> & {
89
+ queryFn?: import("@tanstack/react-query").QueryFunction<(Pick<{
90
+ schemaName: "projectSettings";
91
+ name?: string | undefined;
92
+ defaultPresets?: {
93
+ point: string[];
94
+ area: string[];
95
+ vertex: string[];
96
+ line: string[];
97
+ relation: string[];
98
+ } | undefined;
99
+ configMetadata?: {
100
+ name: string;
101
+ buildDate: string;
102
+ importDate: string;
103
+ fileVersion: string;
104
+ } | undefined;
105
+ }, "name"> & {
106
+ projectId: string;
107
+ createdAt?: string | undefined;
108
+ updatedAt?: string | undefined;
109
+ })[], readonly ["@comapeo/core-react", "projects"], never> | undefined;
110
+ } & {
111
+ queryKey: readonly ["@comapeo/core-react", "projects"] & {
112
+ [dataTagSymbol]: (Pick<{
113
+ schemaName: "projectSettings";
114
+ name?: string | undefined;
115
+ defaultPresets?: {
116
+ point: string[];
117
+ area: string[];
118
+ vertex: string[];
119
+ line: string[];
120
+ relation: string[];
121
+ } | undefined;
122
+ configMetadata?: {
123
+ name: string;
124
+ buildDate: string;
125
+ importDate: string;
126
+ fileVersion: string;
127
+ } | undefined;
128
+ }, "name"> & {
129
+ projectId: string;
130
+ createdAt?: string | undefined;
131
+ updatedAt?: string | undefined;
132
+ })[];
133
+ [dataTagErrorSymbol]: Error;
134
+ };
135
+ };
136
+ export declare function projectByIdQueryOptions({ clientApi, projectId, }: {
137
+ clientApi: MapeoClientApi;
138
+ projectId: string;
139
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).MapeoProject>, Error, import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).MapeoProject>, readonly ["@comapeo/core-react", "projects", string]>, "queryFn"> & {
140
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).MapeoProject>, readonly ["@comapeo/core-react", "projects", string], never> | undefined;
141
+ } & {
142
+ queryKey: readonly ["@comapeo/core-react", "projects", string] & {
143
+ [dataTagSymbol]: import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).MapeoProject>;
144
+ [dataTagErrorSymbol]: Error;
145
+ };
146
+ };
147
+ export declare function projectSettingsQueryOptions({ projectApi, projectId, }: {
148
+ projectApi: MapeoProjectApi;
149
+ projectId: string;
150
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<EditableProjectSettings, Error, EditableProjectSettings, readonly ["@comapeo/core-react", "projects", string, "project_settings"]>, "queryFn"> & {
151
+ queryFn?: import("@tanstack/react-query").QueryFunction<EditableProjectSettings, readonly ["@comapeo/core-react", "projects", string, "project_settings"], never> | undefined;
152
+ } & {
153
+ queryKey: readonly ["@comapeo/core-react", "projects", string, "project_settings"] & {
154
+ [dataTagSymbol]: EditableProjectSettings;
155
+ [dataTagErrorSymbol]: Error;
156
+ };
157
+ };
158
+ export declare function projectMembersQueryOptions({ projectApi, projectId, }: {
159
+ projectApi: MapeoProjectApi;
160
+ projectId: string;
161
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo[], Error, import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo[], readonly ["@comapeo/core-react", "projects", string, "members"]>, "queryFn"> & {
162
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo[], readonly ["@comapeo/core-react", "projects", string, "members"], never> | undefined;
163
+ } & {
164
+ queryKey: readonly ["@comapeo/core-react", "projects", string, "members"] & {
165
+ [dataTagSymbol]: import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo[];
166
+ [dataTagErrorSymbol]: Error;
167
+ };
168
+ };
169
+ export declare function projectMemberByIdQueryOptions({ projectApi, projectId, deviceId, }: {
170
+ projectApi: MapeoProjectApi;
171
+ projectId: string;
172
+ deviceId: string;
173
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo, Error, import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo, readonly ["@comapeo/core-react", "projects", string, "members", string]>, "queryFn"> & {
174
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo, readonly ["@comapeo/core-react", "projects", string, "members", string], never> | undefined;
175
+ } & {
176
+ queryKey: readonly ["@comapeo/core-react", "projects", string, "members", string] & {
177
+ [dataTagSymbol]: import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo;
178
+ [dataTagErrorSymbol]: Error;
179
+ };
180
+ };
181
+ export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
182
+ projectApi: MapeoProjectApi;
183
+ projectId: string;
184
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, Error, import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
185
+ queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
186
+ } & {
187
+ queryKey: readonly ["@comapeo/core-react", "projects", string, "role"] & {
188
+ [dataTagSymbol]: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">;
189
+ [dataTagErrorSymbol]: Error;
190
+ };
191
+ };
192
+ export declare function iconUrlQueryOptions({ projectApi, projectId, iconId, ...mimeBasedOpts }: {
193
+ projectApi: MapeoProjectApi;
194
+ projectId: string;
195
+ iconId: Parameters<MapeoProjectApi['$icons']['getIconUrl']>[0];
196
+ } & (BitmapOpts | SvgOpts)): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, readonly ["@comapeo/core-react", "projects", string, "icons", string, {
197
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/png">;
198
+ pixelDensity: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant, {
199
+ mimeType: "image/png";
200
+ }>["pixelDensity"];
201
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
202
+ } | {
203
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/svg+xml">;
204
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
205
+ }]>, "queryFn"> & {
206
+ queryFn?: import("@tanstack/react-query").QueryFunction<string, readonly ["@comapeo/core-react", "projects", string, "icons", string, {
207
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/png">;
208
+ pixelDensity: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant, {
209
+ mimeType: "image/png";
210
+ }>["pixelDensity"];
211
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
212
+ } | {
213
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/svg+xml">;
214
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
215
+ }], never> | undefined;
216
+ } & {
217
+ queryKey: readonly ["@comapeo/core-react", "projects", string, "icons", string, {
218
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/png">;
219
+ pixelDensity: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant, {
220
+ mimeType: "image/png";
221
+ }>["pixelDensity"];
222
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
223
+ } | {
224
+ mimeType: Extract<import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).IconVariant["mimeType"], "image/svg+xml">;
225
+ size: import("@comapeo/core/dist/icon-api.js", { with: { "resolution-mode": "import" } }).ValidSizes;
226
+ }] & {
227
+ [dataTagSymbol]: string;
228
+ [dataTagErrorSymbol]: Error;
229
+ };
230
+ };
231
+ export declare function documentCreatedByQueryOptions({ projectApi, projectId, originalVersionId, }: {
232
+ projectApi: MapeoProjectApi;
233
+ projectId: string;
234
+ originalVersionId: string;
235
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, readonly ["@comapeo/core-react", "projects", string, "document_created_by", string]>, "queryFn"> & {
236
+ queryFn?: import("@tanstack/react-query").QueryFunction<string, readonly ["@comapeo/core-react", "projects", string, "document_created_by", string], never> | undefined;
237
+ } & {
238
+ queryKey: readonly ["@comapeo/core-react", "projects", string, "document_created_by", string] & {
239
+ [dataTagSymbol]: string;
240
+ [dataTagErrorSymbol]: Error;
241
+ };
242
+ };
243
+ export declare function attachmentUrlQueryOptions({ projectApi, projectId, blobId, }: {
244
+ projectApi: MapeoProjectApi;
245
+ projectId: string;
246
+ blobId: BlobId;
247
+ }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, readonly ["@comapeo/core-react", "projects", string, "attachments", BlobId]>, "queryFn"> & {
248
+ queryFn?: import("@tanstack/react-query").QueryFunction<string, readonly ["@comapeo/core-react", "projects", string, "attachments", BlobId], never> | undefined;
249
+ } & {
250
+ queryKey: readonly ["@comapeo/core-react", "projects", string, "attachments", BlobId] & {
251
+ [dataTagSymbol]: string;
252
+ [dataTagErrorSymbol]: Error;
253
+ };
254
+ };
255
+ export declare function addServerPeerMutationOptions({ projectApi, projectId, queryClient, }: {
256
+ projectApi: MapeoProjectApi;
257
+ projectId: string;
258
+ queryClient: QueryClient;
259
+ }): {
260
+ mutationFn: ({ baseUrl, dangerouslyAllowInsecureConnections }: {
261
+ baseUrl: string;
262
+ dangerouslyAllowInsecureConnections?: boolean;
263
+ }) => Promise<void>;
264
+ onSuccess: () => void;
265
+ networkMode: "always";
266
+ retry: false;
267
+ };
268
+ export declare function createProjectMutationOptions({ clientApi, queryClient, }: {
269
+ clientApi: MapeoClientApi;
270
+ queryClient: QueryClient;
271
+ }): {
272
+ mutationFn: (opts: {
273
+ name?: string;
274
+ configPath?: string;
275
+ } | undefined) => Promise<string>;
276
+ onSuccess: () => void;
277
+ networkMode: "always";
278
+ retry: false;
279
+ };
280
+ export declare function leaveProjectMutationOptions({ clientApi, queryClient, }: {
281
+ clientApi: MapeoClientApi;
282
+ queryClient: QueryClient;
283
+ }): {
284
+ mutationFn: ({ projectId }: {
285
+ projectId: string;
286
+ }) => Promise<void>;
287
+ onSuccess: () => void;
288
+ networkMode: "always";
289
+ retry: false;
290
+ };
291
+ export declare function importProjectConfigMutationOptions({ projectApi, projectId, queryClient, }: {
292
+ projectApi: MapeoProjectApi;
293
+ projectId: string;
294
+ queryClient: QueryClient;
295
+ }): {
296
+ mutationFn: ({ configPath }: {
297
+ configPath: string;
298
+ }) => Promise<Error[]>;
299
+ onSuccess: () => void;
300
+ networkMode: "always";
301
+ retry: false;
302
+ };
303
+ export declare function updateProjectSettingsMutationOptions({ projectApi, queryClient, }: {
304
+ projectApi: MapeoProjectApi;
305
+ queryClient: QueryClient;
306
+ }): {
307
+ mutationFn: (value: {
308
+ name?: ProjectSettings["name"];
309
+ configMetadata?: ProjectSettings["configMetadata"];
310
+ defaultPresets?: ProjectSettings["defaultPresets"];
311
+ }) => Promise<EditableProjectSettings>;
312
+ onSuccess: () => void;
313
+ networkMode: "always";
314
+ retry: false;
315
+ };
316
+ export declare function createBlobMutationOptions({ projectApi, }: {
317
+ projectApi: MapeoProjectApi;
318
+ }): {
319
+ mutationFn: ({ original, preview, thumbnail, metadata }: {
320
+ original: string;
321
+ preview?: string;
322
+ thumbnail?: string;
323
+ metadata: Metadata;
324
+ }) => Promise<{
325
+ driveId: string;
326
+ name: string;
327
+ type: "photo" | "video" | "audio";
328
+ hash: string;
329
+ }>;
330
+ networkMode: "always";
331
+ retry: false;
332
+ };
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProjectsQueryKey = getProjectsQueryKey;
4
+ exports.getProjectByIdQueryKey = getProjectByIdQueryKey;
5
+ exports.getProjectSettingsQueryKey = getProjectSettingsQueryKey;
6
+ exports.getProjectRoleQueryKey = getProjectRoleQueryKey;
7
+ exports.getMembersQueryKey = getMembersQueryKey;
8
+ exports.getMemberByIdQueryKey = getMemberByIdQueryKey;
9
+ exports.getIconUrlQueryKey = getIconUrlQueryKey;
10
+ exports.getDocumentCreatedByQueryKey = getDocumentCreatedByQueryKey;
11
+ exports.getAttachmentUrlQueryKey = getAttachmentUrlQueryKey;
12
+ exports.projectsQueryOptions = projectsQueryOptions;
13
+ exports.projectByIdQueryOptions = projectByIdQueryOptions;
14
+ exports.projectSettingsQueryOptions = projectSettingsQueryOptions;
15
+ exports.projectMembersQueryOptions = projectMembersQueryOptions;
16
+ exports.projectMemberByIdQueryOptions = projectMemberByIdQueryOptions;
17
+ exports.projectOwnRoleQueryOptions = projectOwnRoleQueryOptions;
18
+ exports.iconUrlQueryOptions = iconUrlQueryOptions;
19
+ exports.documentCreatedByQueryOptions = documentCreatedByQueryOptions;
20
+ exports.attachmentUrlQueryOptions = attachmentUrlQueryOptions;
21
+ exports.addServerPeerMutationOptions = addServerPeerMutationOptions;
22
+ exports.createProjectMutationOptions = createProjectMutationOptions;
23
+ exports.leaveProjectMutationOptions = leaveProjectMutationOptions;
24
+ exports.importProjectConfigMutationOptions = importProjectConfigMutationOptions;
25
+ exports.updateProjectSettingsMutationOptions = updateProjectSettingsMutationOptions;
26
+ exports.createBlobMutationOptions = createBlobMutationOptions;
27
+ const react_query_1 = require("@tanstack/react-query");
28
+ const shared_js_1 = require("./shared.js");
29
+ function getProjectsQueryKey() {
30
+ return [shared_js_1.ROOT_QUERY_KEY, 'projects'];
31
+ }
32
+ function getProjectByIdQueryKey({ projectId }) {
33
+ return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId];
34
+ }
35
+ function getProjectSettingsQueryKey({ projectId, }) {
36
+ return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'project_settings'];
37
+ }
38
+ function getProjectRoleQueryKey({ projectId }) {
39
+ return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'role'];
40
+ }
41
+ function getMembersQueryKey({ projectId }) {
42
+ return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'members'];
43
+ }
44
+ function getMemberByIdQueryKey({ projectId, deviceId, }) {
45
+ return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'members', deviceId];
46
+ }
47
+ function getIconUrlQueryKey({ projectId, iconId, ...mimeBasedOpts }) {
48
+ return [
49
+ shared_js_1.ROOT_QUERY_KEY,
50
+ 'projects',
51
+ projectId,
52
+ 'icons',
53
+ iconId,
54
+ mimeBasedOpts,
55
+ ];
56
+ }
57
+ function getDocumentCreatedByQueryKey({ projectId, originalVersionId, }) {
58
+ return [
59
+ shared_js_1.ROOT_QUERY_KEY,
60
+ 'projects',
61
+ projectId,
62
+ 'document_created_by',
63
+ originalVersionId,
64
+ ];
65
+ }
66
+ function getAttachmentUrlQueryKey({ projectId, blobId, }) {
67
+ return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'attachments', blobId];
68
+ }
69
+ function projectsQueryOptions({ clientApi, }) {
70
+ return (0, react_query_1.queryOptions)({
71
+ ...(0, shared_js_1.baseQueryOptions)(),
72
+ queryKey: getProjectsQueryKey(),
73
+ queryFn: async () => {
74
+ return clientApi.listProjects();
75
+ },
76
+ });
77
+ }
78
+ function projectByIdQueryOptions({ clientApi, projectId, }) {
79
+ return (0, react_query_1.queryOptions)({
80
+ ...(0, shared_js_1.baseQueryOptions)(),
81
+ queryKey: getProjectByIdQueryKey({ projectId }),
82
+ queryFn: async () => {
83
+ return clientApi.getProject(projectId);
84
+ },
85
+ });
86
+ }
87
+ function projectSettingsQueryOptions({ projectApi, projectId, }) {
88
+ return (0, react_query_1.queryOptions)({
89
+ ...(0, shared_js_1.baseQueryOptions)(),
90
+ queryKey: getProjectSettingsQueryKey({ projectId }),
91
+ queryFn: async () => {
92
+ return projectApi.$getProjectSettings();
93
+ },
94
+ });
95
+ }
96
+ function projectMembersQueryOptions({ projectApi, projectId, }) {
97
+ return (0, react_query_1.queryOptions)({
98
+ ...(0, shared_js_1.baseQueryOptions)(),
99
+ queryKey: getMembersQueryKey({ projectId }),
100
+ queryFn: async () => {
101
+ return projectApi.$member.getMany();
102
+ },
103
+ });
104
+ }
105
+ function projectMemberByIdQueryOptions({ projectApi, projectId, deviceId, }) {
106
+ return (0, react_query_1.queryOptions)({
107
+ ...(0, shared_js_1.baseQueryOptions)(),
108
+ queryKey: getMemberByIdQueryKey({ projectId, deviceId }),
109
+ queryFn: async () => {
110
+ return projectApi.$member.getById(deviceId);
111
+ },
112
+ });
113
+ }
114
+ function projectOwnRoleQueryOptions({ projectApi, projectId, }) {
115
+ return (0, react_query_1.queryOptions)({
116
+ ...(0, shared_js_1.baseQueryOptions)(),
117
+ queryKey: getProjectRoleQueryKey({ projectId }),
118
+ queryFn: async () => {
119
+ return projectApi.$getOwnRole();
120
+ },
121
+ });
122
+ }
123
+ function iconUrlQueryOptions({ projectApi, projectId, iconId, ...mimeBasedOpts }) {
124
+ return (0, react_query_1.queryOptions)({
125
+ ...(0, shared_js_1.baseQueryOptions)(),
126
+ queryKey: getIconUrlQueryKey({ ...mimeBasedOpts, projectId, iconId }),
127
+ queryFn: async () => {
128
+ return projectApi.$icons.getIconUrl(iconId, mimeBasedOpts);
129
+ },
130
+ });
131
+ }
132
+ function documentCreatedByQueryOptions({ projectApi, projectId, originalVersionId, }) {
133
+ return (0, react_query_1.queryOptions)({
134
+ ...(0, shared_js_1.baseQueryOptions)(),
135
+ queryKey: getDocumentCreatedByQueryKey({
136
+ projectId,
137
+ originalVersionId,
138
+ }),
139
+ queryFn: async () => {
140
+ return projectApi.$originalVersionIdToDeviceId(originalVersionId);
141
+ },
142
+ });
143
+ }
144
+ function attachmentUrlQueryOptions({ projectApi, projectId, blobId, }) {
145
+ return (0, react_query_1.queryOptions)({
146
+ ...(0, shared_js_1.baseQueryOptions)(),
147
+ queryKey: getAttachmentUrlQueryKey({ projectId, blobId }),
148
+ queryFn: async () => {
149
+ // TODO: Might need a refresh token? (similar to map style url)
150
+ return projectApi.$blobs.getUrl(blobId);
151
+ },
152
+ });
153
+ }
154
+ function addServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
155
+ return {
156
+ ...(0, shared_js_1.baseMutationOptions)(),
157
+ mutationFn: async ({ baseUrl, dangerouslyAllowInsecureConnections }) => {
158
+ return projectApi.$member.addServerPeer(baseUrl, {
159
+ dangerouslyAllowInsecureConnections,
160
+ });
161
+ },
162
+ onSuccess: () => {
163
+ queryClient.invalidateQueries({
164
+ queryKey: getMembersQueryKey({ projectId }),
165
+ });
166
+ },
167
+ };
168
+ }
169
+ function createProjectMutationOptions({ clientApi, queryClient, }) {
170
+ return {
171
+ ...(0, shared_js_1.baseMutationOptions)(),
172
+ mutationFn: async (opts) => {
173
+ // Have to avoid passing `undefined` explicitly
174
+ // See https://github.com/digidem/rpc-reflector/issues/21
175
+ return opts
176
+ ? clientApi.createProject({
177
+ configPath: opts.configPath,
178
+ name: opts.name,
179
+ })
180
+ : clientApi.createProject();
181
+ },
182
+ onSuccess: () => {
183
+ queryClient.invalidateQueries({
184
+ queryKey: getProjectsQueryKey(),
185
+ });
186
+ },
187
+ };
188
+ }
189
+ function leaveProjectMutationOptions({ clientApi, queryClient, }) {
190
+ return {
191
+ ...(0, shared_js_1.baseMutationOptions)(),
192
+ mutationFn: async ({ projectId }) => {
193
+ return clientApi.leaveProject(projectId);
194
+ },
195
+ onSuccess: () => {
196
+ queryClient.invalidateQueries({
197
+ queryKey: getProjectsQueryKey(),
198
+ });
199
+ },
200
+ };
201
+ }
202
+ function importProjectConfigMutationOptions({ projectApi, projectId, queryClient, }) {
203
+ return {
204
+ ...(0, shared_js_1.baseMutationOptions)(),
205
+ mutationFn: ({ configPath }) => {
206
+ return projectApi.importConfig({ configPath });
207
+ },
208
+ onSuccess: () => {
209
+ queryClient.invalidateQueries({
210
+ queryKey: getProjectByIdQueryKey({ projectId }),
211
+ });
212
+ },
213
+ };
214
+ }
215
+ function updateProjectSettingsMutationOptions({ projectApi, queryClient, }) {
216
+ return {
217
+ ...(0, shared_js_1.baseMutationOptions)(),
218
+ mutationFn: async (value) => {
219
+ return projectApi.$setProjectSettings(value);
220
+ },
221
+ onSuccess: () => {
222
+ queryClient.invalidateQueries({
223
+ queryKey: getProjectsQueryKey(),
224
+ });
225
+ },
226
+ };
227
+ }
228
+ function createBlobMutationOptions({ projectApi, }) {
229
+ return {
230
+ ...(0, shared_js_1.baseMutationOptions)(),
231
+ mutationFn: async ({ original, preview, thumbnail, metadata }) => {
232
+ return projectApi.$blobs.create({ original, preview, thumbnail }, metadata);
233
+ },
234
+ };
235
+ }
@@ -1,5 +1,9 @@
1
1
  export declare const ROOT_QUERY_KEY = "@comapeo/core-react";
2
2
  export declare function baseQueryOptions(): {
3
3
  networkMode: "always";
4
- retry: number;
4
+ retry: false;
5
+ };
6
+ export declare function baseMutationOptions(): {
7
+ networkMode: "always";
8
+ retry: false;
5
9
  };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ROOT_QUERY_KEY = void 0;
4
+ exports.baseQueryOptions = baseQueryOptions;
5
+ exports.baseMutationOptions = baseMutationOptions;
6
+ exports.ROOT_QUERY_KEY = '@comapeo/core-react';
7
+ // Since the API is running locally, queries should run regardless of network
8
+ // status, and should not be retried. In React Native the API consumer would
9
+ // have to manually set the network mode, but we still should keep these options
10
+ // to avoid surprises. Not using the queryClient `defaultOptions` because the API
11
+ // consumer might also use the same queryClient for network queries
12
+ function baseQueryOptions() {
13
+ return {
14
+ networkMode: 'always',
15
+ retry: false,
16
+ };
17
+ }
18
+ function baseMutationOptions() {
19
+ return {
20
+ networkMode: 'always',
21
+ retry: false,
22
+ };
23
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1,6 +1,6 @@
1
- import type { MapeoClientApi } from '@comapeo/ipc';
1
+ import type { MapeoClientApi } from '@comapeo/ipc' with { 'resolution-mode': 'import' };
2
2
  import { type ReactNode } from 'react';
3
- export declare const ClientApiContext: import("react").Context<import("@comapeo/ipc/dist/client").MapeoClientApi | null>;
3
+ export declare const ClientApiContext: import("react").Context<import("@comapeo/ipc/dist/client.js").MapeoClientApi | null>;
4
4
  /**
5
5
  * Create a context provider that holds a CoMapeo API client instance.
6
6
  *
@@ -11,4 +11,4 @@ export declare const ClientApiContext: import("react").Context<import("@comapeo/
11
11
  export declare function ClientApiProvider({ children, clientApi, }: {
12
12
  children: ReactNode;
13
13
  clientApi: MapeoClientApi;
14
- }): import("react").FunctionComponentElement<import("react").ProviderProps<import("@comapeo/ipc/dist/client").MapeoClientApi | null>>;
14
+ }): import("react").FunctionComponentElement<import("react").ProviderProps<import("@comapeo/ipc/dist/client.js").MapeoClientApi | null>>;
@@ -23,7 +23,7 @@
23
23
  * ```
24
24
  *
25
25
  */
26
- export declare function useClientApi(): import("@comapeo/ipc/dist/client").MapeoClientApi;
26
+ export declare function useClientApi(): import("@comapeo/ipc/dist/client.js").MapeoClientApi;
27
27
  /**
28
28
  * Retrieve info about the current device.
29
29
  *
@@ -38,7 +38,7 @@ export declare function useOwnDeviceInfo(): {
38
38
  data: {
39
39
  deviceId: string;
40
40
  deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
41
- } & Partial<import("@comapeo/core/dist/schema/client").DeviceInfoParam>;
41
+ } & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>;
42
42
  error: Error | null;
43
43
  isRefetching: boolean;
44
44
  };
@@ -57,3 +57,24 @@ export declare function useIsArchiveDevice(): {
57
57
  error: Error | null;
58
58
  isRefetching: boolean;
59
59
  };
60
+ /**
61
+ * Update the device info for the current device.
62
+ */
63
+ export declare function useSetOwnDeviceInfo(): {
64
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
65
+ name: string;
66
+ deviceType: import("@comapeo/schema").DeviceInfo["deviceType"];
67
+ }, unknown>;
68
+ reset: () => void;
69
+ status: "pending" | "error" | "success" | "idle";
70
+ };
71
+ /**
72
+ * Set or unset the current device as an archive device.
73
+ */
74
+ export declare function useSetIsArchiveDevice(): {
75
+ mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
76
+ isArchiveDevice: boolean;
77
+ }, unknown>;
78
+ reset: () => void;
79
+ status: "pending" | "error" | "success" | "idle";
80
+ };