@comapeo/core-react 9.0.2 → 10.0.1
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/README.md +1 -1
- package/dist/commonjs/contexts/ClientApi.d.ts +1 -3
- package/dist/commonjs/contexts/ClientApi.js +2 -2
- package/dist/commonjs/hooks/client.d.ts +74 -33
- package/dist/commonjs/hooks/client.js +40 -11
- package/dist/commonjs/hooks/documents.d.ts +42 -429
- package/dist/commonjs/hooks/documents.js +100 -51
- package/dist/commonjs/hooks/invites.d.ts +153 -55
- package/dist/commonjs/hooks/invites.js +69 -20
- package/dist/commonjs/hooks/maps.d.ts +96 -225
- package/dist/commonjs/hooks/maps.js +104 -37
- package/dist/commonjs/hooks/projects.d.ts +666 -223
- package/dist/commonjs/hooks/projects.js +264 -131
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/lib/map-shares-stores.d.ts +1 -1
- package/dist/commonjs/lib/map-shares-stores.js +2 -2
- package/dist/commonjs/lib/presets.d.ts +1 -3
- package/dist/commonjs/lib/react-query.d.ts +103 -0
- package/dist/commonjs/lib/react-query.js +187 -0
- package/dist/commonjs/lib/sync.d.ts +2 -5
- package/dist/commonjs/lib/sync.js +0 -1
- package/dist/commonjs/lib/types.d.ts +4 -6
- package/dist/esm/contexts/ClientApi.d.ts +1 -3
- package/dist/esm/contexts/ClientApi.js +1 -1
- package/dist/esm/hooks/client.d.ts +74 -33
- package/dist/esm/hooks/client.js +40 -11
- package/dist/esm/hooks/documents.d.ts +42 -429
- package/dist/esm/hooks/documents.js +100 -51
- package/dist/esm/hooks/invites.d.ts +153 -55
- package/dist/esm/hooks/invites.js +69 -20
- package/dist/esm/hooks/maps.d.ts +96 -225
- package/dist/esm/hooks/maps.js +105 -38
- package/dist/esm/hooks/projects.d.ts +666 -223
- package/dist/esm/hooks/projects.js +262 -129
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/lib/map-shares-stores.d.ts +1 -1
- package/dist/esm/lib/map-shares-stores.js +1 -1
- package/dist/esm/lib/presets.d.ts +1 -3
- package/dist/esm/lib/react-query.d.ts +103 -0
- package/dist/esm/lib/react-query.js +162 -0
- package/dist/esm/lib/sync.d.ts +2 -5
- package/dist/esm/lib/sync.js +1 -1
- package/dist/esm/lib/types.d.ts +4 -6
- package/docs/API.md +137 -81
- package/package.json +39 -35
- package/dist/commonjs/lib/react-query/client.d.ts +0 -65
- package/dist/commonjs/lib/react-query/client.js +0 -68
- package/dist/commonjs/lib/react-query/documents.d.ts +0 -1484
- package/dist/commonjs/lib/react-query/documents.js +0 -149
- package/dist/commonjs/lib/react-query/invites.d.ts +0 -88
- package/dist/commonjs/lib/react-query/invites.js +0 -95
- package/dist/commonjs/lib/react-query/maps.d.ts +0 -104
- package/dist/commonjs/lib/react-query/maps.js +0 -129
- package/dist/commonjs/lib/react-query/mutation-result.d.ts +0 -8
- package/dist/commonjs/lib/react-query/mutation-result.js +0 -22
- package/dist/commonjs/lib/react-query/projects.d.ts +0 -316
- package/dist/commonjs/lib/react-query/projects.js +0 -359
- package/dist/commonjs/lib/react-query/shared.d.ts +0 -9
- package/dist/commonjs/lib/react-query/shared.js +0 -23
- package/dist/esm/lib/react-query/client.d.ts +0 -65
- package/dist/esm/lib/react-query/client.js +0 -59
- package/dist/esm/lib/react-query/documents.d.ts +0 -1484
- package/dist/esm/lib/react-query/documents.js +0 -137
- package/dist/esm/lib/react-query/invites.d.ts +0 -88
- package/dist/esm/lib/react-query/invites.js +0 -85
- package/dist/esm/lib/react-query/maps.d.ts +0 -104
- package/dist/esm/lib/react-query/maps.js +0 -119
- package/dist/esm/lib/react-query/mutation-result.d.ts +0 -8
- package/dist/esm/lib/react-query/mutation-result.js +0 -19
- package/dist/esm/lib/react-query/projects.d.ts +0 -316
- package/dist/esm/lib/react-query/projects.js +0 -324
- package/dist/esm/lib/react-query/shared.d.ts +0 -9
- package/dist/esm/lib/react-query/shared.js +0 -18
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import type { BlobApi, MemberApi } from '@comapeo/core' with { 'resolution-mode': 'import' };
|
|
2
|
-
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with {
|
|
3
|
-
'resolution-mode': 'import'
|
|
4
|
-
};
|
|
5
|
-
import { type QueryClient, type UnusedSkipTokenOptions } from '@tanstack/react-query';
|
|
6
|
-
export declare function getProjectsQueryKey(): readonly ["@comapeo/core-react", "projects"];
|
|
7
|
-
export declare function getProjectByIdQueryKey({ projectId }: {
|
|
8
|
-
projectId: string;
|
|
9
|
-
}): readonly ["@comapeo/core-react", "projects", string];
|
|
10
|
-
export declare function getProjectSettingsQueryKey({ projectId, }: {
|
|
11
|
-
projectId: string;
|
|
12
|
-
}): readonly ["@comapeo/core-react", "projects", string, "project_settings"];
|
|
13
|
-
export declare function getProjectRoleQueryKey({ projectId }: {
|
|
14
|
-
projectId: string;
|
|
15
|
-
}): readonly ["@comapeo/core-react", "projects", string, "role"];
|
|
16
|
-
export declare function getMembersQueryKey({ projectId }: {
|
|
17
|
-
projectId: string;
|
|
18
|
-
}): readonly ["@comapeo/core-react", "projects", string, "members"];
|
|
19
|
-
export declare function getMemberByIdQueryKey({ projectId, deviceId, }: {
|
|
20
|
-
projectId: string;
|
|
21
|
-
deviceId: string;
|
|
22
|
-
}): readonly ["@comapeo/core-react", "projects", string, "members", string];
|
|
23
|
-
export declare function getDocumentCreatedByQueryKey({ projectId, originalVersionId, }: {
|
|
24
|
-
projectId: string;
|
|
25
|
-
originalVersionId: string;
|
|
26
|
-
}): readonly ["@comapeo/core-react", "projects", string, "document_created_by", string];
|
|
27
|
-
/**
|
|
28
|
-
* We call this within a project hook, because that's the only place the API is
|
|
29
|
-
* exposed right now, but it is the same for all projects, so no need for
|
|
30
|
-
* scoping the query key to the project
|
|
31
|
-
*/
|
|
32
|
-
export declare function getMediaServerOriginQueryKey(): readonly ["@comapeo/core-react", "media_server_origin"];
|
|
33
|
-
export declare function projectsQueryOptions({ clientApi, }: {
|
|
34
|
-
clientApi: MapeoClientApi;
|
|
35
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/mapeo-manager.js", { with: { "resolution-mode": "import" } }).ListedProject[], Error, import("@comapeo/core/dist/mapeo-manager.js", { with: { "resolution-mode": "import" } }).ListedProject[], readonly ["@comapeo/core-react", "projects"]>, "queryFn"> & {
|
|
36
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/mapeo-manager.js", { with: { "resolution-mode": "import" } }).ListedProject[], readonly ["@comapeo/core-react", "projects"], never> | undefined;
|
|
37
|
-
} & {
|
|
38
|
-
queryKey: readonly ["@comapeo/core-react", "projects"] & {
|
|
39
|
-
[dataTagSymbol]: import("@comapeo/core/dist/mapeo-manager.js", { with: { "resolution-mode": "import" } }).ListedProject[];
|
|
40
|
-
[dataTagErrorSymbol]: Error;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export declare function projectByIdQueryOptions({ clientApi, projectId, }: {
|
|
44
|
-
clientApi: MapeoClientApi;
|
|
45
|
-
projectId: string;
|
|
46
|
-
}): UnusedSkipTokenOptions<MapeoProjectApi, Error, MapeoProjectApi, ReturnType<typeof getProjectByIdQueryKey>>;
|
|
47
|
-
export declare function projectSettingsQueryOptions({ projectApi, projectId, }: {
|
|
48
|
-
projectApi: MapeoProjectApi;
|
|
49
|
-
projectId: string;
|
|
50
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, Error, import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, readonly ["@comapeo/core-react", "projects", string, "project_settings"]>, "queryFn"> & {
|
|
51
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings, readonly ["@comapeo/core-react", "projects", string, "project_settings"], never> | undefined;
|
|
52
|
-
} & {
|
|
53
|
-
queryKey: readonly ["@comapeo/core-react", "projects", string, "project_settings"] & {
|
|
54
|
-
[dataTagSymbol]: import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings;
|
|
55
|
-
[dataTagErrorSymbol]: Error;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export declare function projectMembersQueryOptions({ projectApi, projectId, }: {
|
|
59
|
-
projectApi: MapeoProjectApi;
|
|
60
|
-
projectId: string;
|
|
61
|
-
}): 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"> & {
|
|
62
|
-
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;
|
|
63
|
-
} & {
|
|
64
|
-
queryKey: readonly ["@comapeo/core-react", "projects", string, "members"] & {
|
|
65
|
-
[dataTagSymbol]: import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo[];
|
|
66
|
-
[dataTagErrorSymbol]: Error;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
export declare function projectMemberByIdQueryOptions({ projectApi, projectId, deviceId, }: {
|
|
70
|
-
projectApi: MapeoProjectApi;
|
|
71
|
-
projectId: string;
|
|
72
|
-
deviceId: string;
|
|
73
|
-
}): 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"> & {
|
|
74
|
-
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;
|
|
75
|
-
} & {
|
|
76
|
-
queryKey: readonly ["@comapeo/core-react", "projects", string, "members", string] & {
|
|
77
|
-
[dataTagSymbol]: import("@comapeo/core/dist/member-api.js", { with: { "resolution-mode": "import" } }).MemberInfo;
|
|
78
|
-
[dataTagErrorSymbol]: Error;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
|
|
82
|
-
projectApi: MapeoProjectApi;
|
|
83
|
-
projectId: string;
|
|
84
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
85
|
-
reason: string | undefined;
|
|
86
|
-
}, Error, import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
87
|
-
reason: string | undefined;
|
|
88
|
-
}, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
|
|
89
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
90
|
-
reason: string | undefined;
|
|
91
|
-
}, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
|
|
92
|
-
} & {
|
|
93
|
-
queryKey: readonly ["@comapeo/core-react", "projects", string, "role"] & {
|
|
94
|
-
[dataTagSymbol]: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
95
|
-
reason: string | undefined;
|
|
96
|
-
};
|
|
97
|
-
[dataTagErrorSymbol]: Error;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
export declare function documentCreatedByQueryOptions({ projectApi, projectId, originalVersionId, }: {
|
|
101
|
-
projectApi: MapeoProjectApi;
|
|
102
|
-
projectId: string;
|
|
103
|
-
originalVersionId: string;
|
|
104
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, readonly ["@comapeo/core-react", "projects", string, "document_created_by", string]>, "queryFn"> & {
|
|
105
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<string, readonly ["@comapeo/core-react", "projects", string, "document_created_by", string], never> | undefined;
|
|
106
|
-
} & {
|
|
107
|
-
queryKey: readonly ["@comapeo/core-react", "projects", string, "document_created_by", string] & {
|
|
108
|
-
[dataTagSymbol]: string;
|
|
109
|
-
[dataTagErrorSymbol]: Error;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
export declare function mediaServerOriginQueryOptions({ projectApi, }: {
|
|
113
|
-
projectApi: MapeoProjectApi;
|
|
114
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, readonly ["@comapeo/core-react", "media_server_origin"]>, "queryFn"> & {
|
|
115
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<string, readonly ["@comapeo/core-react", "media_server_origin"], never> | undefined;
|
|
116
|
-
} & {
|
|
117
|
-
queryKey: readonly ["@comapeo/core-react", "media_server_origin"] & {
|
|
118
|
-
[dataTagSymbol]: string;
|
|
119
|
-
[dataTagErrorSymbol]: Error;
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
export declare function addServerPeerMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
123
|
-
projectApi: MapeoProjectApi;
|
|
124
|
-
projectId: string;
|
|
125
|
-
queryClient: QueryClient;
|
|
126
|
-
}): {
|
|
127
|
-
mutationFn: ({ baseUrl, dangerouslyAllowInsecureConnections }: {
|
|
128
|
-
baseUrl: string;
|
|
129
|
-
dangerouslyAllowInsecureConnections?: boolean;
|
|
130
|
-
}) => Promise<void>;
|
|
131
|
-
onSuccess: () => void;
|
|
132
|
-
networkMode: "always";
|
|
133
|
-
retry: false;
|
|
134
|
-
};
|
|
135
|
-
export declare function removeServerPeerMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
136
|
-
projectApi: MapeoProjectApi;
|
|
137
|
-
projectId: string;
|
|
138
|
-
queryClient: QueryClient;
|
|
139
|
-
}): {
|
|
140
|
-
mutationFn: ({ serverDeviceId, dangerouslyAllowInsecureConnections, }: {
|
|
141
|
-
serverDeviceId: string;
|
|
142
|
-
dangerouslyAllowInsecureConnections?: boolean;
|
|
143
|
-
}) => Promise<void>;
|
|
144
|
-
onSuccess: () => void;
|
|
145
|
-
networkMode: "always";
|
|
146
|
-
retry: false;
|
|
147
|
-
};
|
|
148
|
-
export declare function createProjectMutationOptions({ clientApi, queryClient, }: {
|
|
149
|
-
clientApi: MapeoClientApi;
|
|
150
|
-
queryClient: QueryClient;
|
|
151
|
-
}): {
|
|
152
|
-
mutationFn: (opts: {
|
|
153
|
-
name?: string;
|
|
154
|
-
configPath?: string;
|
|
155
|
-
projectColor?: string;
|
|
156
|
-
projectDescription?: string;
|
|
157
|
-
} | undefined) => Promise<string>;
|
|
158
|
-
onSuccess: () => void;
|
|
159
|
-
networkMode: "always";
|
|
160
|
-
retry: false;
|
|
161
|
-
};
|
|
162
|
-
export declare function leaveProjectMutationOptions({ clientApi, queryClient, }: {
|
|
163
|
-
clientApi: MapeoClientApi;
|
|
164
|
-
queryClient: QueryClient;
|
|
165
|
-
}): {
|
|
166
|
-
mutationFn: ({ projectId }: {
|
|
167
|
-
projectId: string;
|
|
168
|
-
}) => Promise<void>;
|
|
169
|
-
onSuccess: () => void;
|
|
170
|
-
networkMode: "always";
|
|
171
|
-
retry: false;
|
|
172
|
-
};
|
|
173
|
-
export declare function importProjectCategoriesMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
174
|
-
projectApi: MapeoProjectApi;
|
|
175
|
-
projectId: string;
|
|
176
|
-
queryClient: QueryClient;
|
|
177
|
-
}): {
|
|
178
|
-
mutationFn: ({ filePath }: {
|
|
179
|
-
filePath: string;
|
|
180
|
-
}) => Promise<void>;
|
|
181
|
-
onSuccess: () => void;
|
|
182
|
-
networkMode: "always";
|
|
183
|
-
retry: false;
|
|
184
|
-
};
|
|
185
|
-
export declare function importProjectConfigMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
186
|
-
projectApi: MapeoProjectApi;
|
|
187
|
-
projectId: string;
|
|
188
|
-
queryClient: QueryClient;
|
|
189
|
-
}): {
|
|
190
|
-
mutationFn: ({ configPath }: {
|
|
191
|
-
configPath: string;
|
|
192
|
-
}) => Promise<Error[]>;
|
|
193
|
-
onSuccess: () => void;
|
|
194
|
-
networkMode: "always";
|
|
195
|
-
retry: false;
|
|
196
|
-
};
|
|
197
|
-
export declare function updateProjectSettingsMutationOptions({ projectApi, queryClient, }: {
|
|
198
|
-
projectApi: MapeoProjectApi;
|
|
199
|
-
queryClient: QueryClient;
|
|
200
|
-
}): {
|
|
201
|
-
mutationFn: (value: Partial<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings>) => Promise<import("@comapeo/core/dist/mapeo-project.js", { with: { "resolution-mode": "import" } }).EditableProjectSettings>;
|
|
202
|
-
onSuccess: () => void;
|
|
203
|
-
networkMode: "always";
|
|
204
|
-
retry: false;
|
|
205
|
-
};
|
|
206
|
-
export declare function changeMemberRoleMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
207
|
-
projectApi: MapeoProjectApi;
|
|
208
|
-
projectId: string;
|
|
209
|
-
queryClient: QueryClient;
|
|
210
|
-
}): {
|
|
211
|
-
mutationFn: ({ deviceId, roleId }: {
|
|
212
|
-
deviceId: string;
|
|
213
|
-
roleId: MemberApi.RoleIdAssignableToOthers;
|
|
214
|
-
}) => Promise<void>;
|
|
215
|
-
onSuccess: () => void;
|
|
216
|
-
networkMode: "always";
|
|
217
|
-
retry: false;
|
|
218
|
-
};
|
|
219
|
-
export declare function removeProjectMemberMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
220
|
-
projectApi: MapeoProjectApi;
|
|
221
|
-
projectId: string;
|
|
222
|
-
queryClient: QueryClient;
|
|
223
|
-
}): {
|
|
224
|
-
mutationFn: ({ deviceId, reason }: {
|
|
225
|
-
deviceId: string;
|
|
226
|
-
reason?: string;
|
|
227
|
-
}) => Promise<void>;
|
|
228
|
-
onSuccess: () => void;
|
|
229
|
-
networkMode: "always";
|
|
230
|
-
retry: false;
|
|
231
|
-
};
|
|
232
|
-
export declare function createBlobMutationOptions({ projectApi, }: {
|
|
233
|
-
projectApi: MapeoProjectApi;
|
|
234
|
-
}): {
|
|
235
|
-
mutationFn: ({ original, preview, thumbnail, metadata }: {
|
|
236
|
-
original: string;
|
|
237
|
-
preview?: string;
|
|
238
|
-
thumbnail?: string;
|
|
239
|
-
metadata: BlobApi.Metadata;
|
|
240
|
-
}) => Promise<{
|
|
241
|
-
driveId: string;
|
|
242
|
-
name: string;
|
|
243
|
-
type: "photo" | "video" | "audio";
|
|
244
|
-
hash: string;
|
|
245
|
-
}>;
|
|
246
|
-
networkMode: "always";
|
|
247
|
-
retry: false;
|
|
248
|
-
};
|
|
249
|
-
export declare function startSyncMutationOptions({ projectApi, }: {
|
|
250
|
-
projectApi: MapeoProjectApi;
|
|
251
|
-
}): {
|
|
252
|
-
mutationFn: (opts: {
|
|
253
|
-
autostopDataSyncAfter: number | null;
|
|
254
|
-
} | undefined) => Promise<void>;
|
|
255
|
-
networkMode: "always";
|
|
256
|
-
retry: false;
|
|
257
|
-
};
|
|
258
|
-
export declare function stopSyncMutationOptions({ projectApi, }: {
|
|
259
|
-
projectApi: MapeoProjectApi;
|
|
260
|
-
}): {
|
|
261
|
-
mutationFn: () => Promise<void>;
|
|
262
|
-
networkMode: "always";
|
|
263
|
-
retry: false;
|
|
264
|
-
};
|
|
265
|
-
export declare function connectSyncServersMutationOptions({ projectApi, }: {
|
|
266
|
-
projectApi: MapeoProjectApi;
|
|
267
|
-
}): {
|
|
268
|
-
mutationFn: () => Promise<void>;
|
|
269
|
-
networkMode: "always";
|
|
270
|
-
retry: false;
|
|
271
|
-
};
|
|
272
|
-
export declare function disconnectSyncServersMutationOptions({ projectApi, }: {
|
|
273
|
-
projectApi: MapeoProjectApi;
|
|
274
|
-
}): {
|
|
275
|
-
mutationFn: () => Promise<void>;
|
|
276
|
-
networkMode: "always";
|
|
277
|
-
retry: false;
|
|
278
|
-
};
|
|
279
|
-
export declare function setAutostopDataSyncTimeoutMutationOptions({ projectApi, }: {
|
|
280
|
-
projectApi: MapeoProjectApi;
|
|
281
|
-
}): {
|
|
282
|
-
mutationFn: ({ after }: {
|
|
283
|
-
after: number | null;
|
|
284
|
-
}) => Promise<void>;
|
|
285
|
-
networkMode: "always";
|
|
286
|
-
retry: false;
|
|
287
|
-
};
|
|
288
|
-
export declare function exportGeoJSONMutationOptions({ projectApi, }: {
|
|
289
|
-
projectApi: MapeoProjectApi;
|
|
290
|
-
}): {
|
|
291
|
-
mutationFn: (opts: {
|
|
292
|
-
path: string;
|
|
293
|
-
exportOptions: {
|
|
294
|
-
observations?: boolean;
|
|
295
|
-
tracks?: boolean;
|
|
296
|
-
lang?: string;
|
|
297
|
-
};
|
|
298
|
-
}) => Promise<string>;
|
|
299
|
-
networkMode: "always";
|
|
300
|
-
retry: false;
|
|
301
|
-
};
|
|
302
|
-
export declare function exportZipFileMutationOptions({ projectApi, }: {
|
|
303
|
-
projectApi: MapeoProjectApi;
|
|
304
|
-
}): {
|
|
305
|
-
mutationFn: (opts: {
|
|
306
|
-
path: string;
|
|
307
|
-
exportOptions: {
|
|
308
|
-
observations?: boolean;
|
|
309
|
-
tracks?: boolean;
|
|
310
|
-
lang?: string;
|
|
311
|
-
attachments?: boolean;
|
|
312
|
-
};
|
|
313
|
-
}) => Promise<string>;
|
|
314
|
-
networkMode: "always";
|
|
315
|
-
retry: false;
|
|
316
|
-
};
|
|
@@ -1,359 +0,0 @@
|
|
|
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.getDocumentCreatedByQueryKey = getDocumentCreatedByQueryKey;
|
|
10
|
-
exports.getMediaServerOriginQueryKey = getMediaServerOriginQueryKey;
|
|
11
|
-
exports.projectsQueryOptions = projectsQueryOptions;
|
|
12
|
-
exports.projectByIdQueryOptions = projectByIdQueryOptions;
|
|
13
|
-
exports.projectSettingsQueryOptions = projectSettingsQueryOptions;
|
|
14
|
-
exports.projectMembersQueryOptions = projectMembersQueryOptions;
|
|
15
|
-
exports.projectMemberByIdQueryOptions = projectMemberByIdQueryOptions;
|
|
16
|
-
exports.projectOwnRoleQueryOptions = projectOwnRoleQueryOptions;
|
|
17
|
-
exports.documentCreatedByQueryOptions = documentCreatedByQueryOptions;
|
|
18
|
-
exports.mediaServerOriginQueryOptions = mediaServerOriginQueryOptions;
|
|
19
|
-
exports.addServerPeerMutationOptions = addServerPeerMutationOptions;
|
|
20
|
-
exports.removeServerPeerMutationOptions = removeServerPeerMutationOptions;
|
|
21
|
-
exports.createProjectMutationOptions = createProjectMutationOptions;
|
|
22
|
-
exports.leaveProjectMutationOptions = leaveProjectMutationOptions;
|
|
23
|
-
exports.importProjectCategoriesMutationOptions = importProjectCategoriesMutationOptions;
|
|
24
|
-
exports.importProjectConfigMutationOptions = importProjectConfigMutationOptions;
|
|
25
|
-
exports.updateProjectSettingsMutationOptions = updateProjectSettingsMutationOptions;
|
|
26
|
-
exports.changeMemberRoleMutationOptions = changeMemberRoleMutationOptions;
|
|
27
|
-
exports.removeProjectMemberMutationOptions = removeProjectMemberMutationOptions;
|
|
28
|
-
exports.createBlobMutationOptions = createBlobMutationOptions;
|
|
29
|
-
exports.startSyncMutationOptions = startSyncMutationOptions;
|
|
30
|
-
exports.stopSyncMutationOptions = stopSyncMutationOptions;
|
|
31
|
-
exports.connectSyncServersMutationOptions = connectSyncServersMutationOptions;
|
|
32
|
-
exports.disconnectSyncServersMutationOptions = disconnectSyncServersMutationOptions;
|
|
33
|
-
exports.setAutostopDataSyncTimeoutMutationOptions = setAutostopDataSyncTimeoutMutationOptions;
|
|
34
|
-
exports.exportGeoJSONMutationOptions = exportGeoJSONMutationOptions;
|
|
35
|
-
exports.exportZipFileMutationOptions = exportZipFileMutationOptions;
|
|
36
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
37
|
-
const shared_js_1 = require("./shared.js");
|
|
38
|
-
function getProjectsQueryKey() {
|
|
39
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'projects'];
|
|
40
|
-
}
|
|
41
|
-
function getProjectByIdQueryKey({ projectId }) {
|
|
42
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId];
|
|
43
|
-
}
|
|
44
|
-
function getProjectSettingsQueryKey({ projectId, }) {
|
|
45
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'project_settings'];
|
|
46
|
-
}
|
|
47
|
-
function getProjectRoleQueryKey({ projectId }) {
|
|
48
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'role'];
|
|
49
|
-
}
|
|
50
|
-
function getMembersQueryKey({ projectId }) {
|
|
51
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'members'];
|
|
52
|
-
}
|
|
53
|
-
function getMemberByIdQueryKey({ projectId, deviceId, }) {
|
|
54
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'projects', projectId, 'members', deviceId];
|
|
55
|
-
}
|
|
56
|
-
function getDocumentCreatedByQueryKey({ projectId, originalVersionId, }) {
|
|
57
|
-
return [
|
|
58
|
-
shared_js_1.ROOT_QUERY_KEY,
|
|
59
|
-
'projects',
|
|
60
|
-
projectId,
|
|
61
|
-
'document_created_by',
|
|
62
|
-
originalVersionId,
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* We call this within a project hook, because that's the only place the API is
|
|
67
|
-
* exposed right now, but it is the same for all projects, so no need for
|
|
68
|
-
* scoping the query key to the project
|
|
69
|
-
*/
|
|
70
|
-
function getMediaServerOriginQueryKey() {
|
|
71
|
-
return [shared_js_1.ROOT_QUERY_KEY, 'media_server_origin'];
|
|
72
|
-
}
|
|
73
|
-
function projectsQueryOptions({ clientApi, }) {
|
|
74
|
-
return (0, react_query_1.queryOptions)({
|
|
75
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
76
|
-
queryKey: getProjectsQueryKey(),
|
|
77
|
-
queryFn: async () => {
|
|
78
|
-
return clientApi.listProjects();
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
function projectByIdQueryOptions({ clientApi, projectId, }) {
|
|
83
|
-
return (0, react_query_1.queryOptions)({
|
|
84
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
85
|
-
queryKey: getProjectByIdQueryKey({ projectId }),
|
|
86
|
-
queryFn: async () => {
|
|
87
|
-
return clientApi.getProject(projectId);
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function projectSettingsQueryOptions({ projectApi, projectId, }) {
|
|
92
|
-
return (0, react_query_1.queryOptions)({
|
|
93
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
94
|
-
queryKey: getProjectSettingsQueryKey({ projectId }),
|
|
95
|
-
queryFn: async () => {
|
|
96
|
-
return projectApi.$getProjectSettings();
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function projectMembersQueryOptions({ projectApi, projectId, }) {
|
|
101
|
-
return (0, react_query_1.queryOptions)({
|
|
102
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
103
|
-
queryKey: getMembersQueryKey({ projectId }),
|
|
104
|
-
queryFn: async () => {
|
|
105
|
-
return projectApi.$member.getMany();
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function projectMemberByIdQueryOptions({ projectApi, projectId, deviceId, }) {
|
|
110
|
-
return (0, react_query_1.queryOptions)({
|
|
111
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
112
|
-
queryKey: getMemberByIdQueryKey({ projectId, deviceId }),
|
|
113
|
-
queryFn: async () => {
|
|
114
|
-
return projectApi.$member.getById(deviceId);
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function projectOwnRoleQueryOptions({ projectApi, projectId, }) {
|
|
119
|
-
return (0, react_query_1.queryOptions)({
|
|
120
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
121
|
-
queryKey: getProjectRoleQueryKey({ projectId }),
|
|
122
|
-
queryFn: async () => {
|
|
123
|
-
return projectApi.$getOwnRole();
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function documentCreatedByQueryOptions({ projectApi, projectId, originalVersionId, }) {
|
|
128
|
-
return (0, react_query_1.queryOptions)({
|
|
129
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
130
|
-
queryKey: getDocumentCreatedByQueryKey({
|
|
131
|
-
projectId,
|
|
132
|
-
originalVersionId,
|
|
133
|
-
}),
|
|
134
|
-
queryFn: async () => {
|
|
135
|
-
return projectApi.$originalVersionIdToDeviceId(originalVersionId);
|
|
136
|
-
},
|
|
137
|
-
staleTime: 'static',
|
|
138
|
-
gcTime: Infinity,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
// Used as a placeholder so that we can read the server port from the $blobs.getUrl() method
|
|
142
|
-
const FAKE_BLOB_ID = {
|
|
143
|
-
type: 'photo',
|
|
144
|
-
variant: 'original',
|
|
145
|
-
name: 'name',
|
|
146
|
-
driveId: 'drive-id',
|
|
147
|
-
};
|
|
148
|
-
function mediaServerOriginQueryOptions({ projectApi, }) {
|
|
149
|
-
return (0, react_query_1.queryOptions)({
|
|
150
|
-
...(0, shared_js_1.baseQueryOptions)(),
|
|
151
|
-
// HACK: The server doesn't yet expose a method to get its origin, so we use
|
|
152
|
-
// the existing $blobs.getUrl() to get the origin with a fake BlobId. The origin
|
|
153
|
-
// is the same regardless of the blobId, so it's not necessary to include it
|
|
154
|
-
// as a dep for the query key.
|
|
155
|
-
queryKey: getMediaServerOriginQueryKey(),
|
|
156
|
-
queryFn: async () => {
|
|
157
|
-
const url = await projectApi.$blobs.getUrl(FAKE_BLOB_ID);
|
|
158
|
-
return new URL(url).origin;
|
|
159
|
-
},
|
|
160
|
-
staleTime: 'static',
|
|
161
|
-
gcTime: Infinity,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
function addServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
165
|
-
return {
|
|
166
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
167
|
-
mutationFn: async ({ baseUrl, dangerouslyAllowInsecureConnections }) => {
|
|
168
|
-
return projectApi.$member.addServerPeer(baseUrl, {
|
|
169
|
-
dangerouslyAllowInsecureConnections,
|
|
170
|
-
});
|
|
171
|
-
},
|
|
172
|
-
onSuccess: () => {
|
|
173
|
-
queryClient.invalidateQueries({
|
|
174
|
-
queryKey: getMembersQueryKey({ projectId }),
|
|
175
|
-
});
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function removeServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
180
|
-
return {
|
|
181
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
182
|
-
mutationFn: async ({ serverDeviceId, dangerouslyAllowInsecureConnections, }) => {
|
|
183
|
-
return projectApi.$member.removeServerPeer(serverDeviceId, {
|
|
184
|
-
dangerouslyAllowInsecureConnections,
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
onSuccess: () => {
|
|
188
|
-
queryClient.invalidateQueries({
|
|
189
|
-
queryKey: getMembersQueryKey({ projectId }),
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
function createProjectMutationOptions({ clientApi, queryClient, }) {
|
|
195
|
-
return {
|
|
196
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
197
|
-
mutationFn: async (opts) => {
|
|
198
|
-
// Have to avoid passing `undefined` explicitly
|
|
199
|
-
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
200
|
-
return opts ? clientApi.createProject(opts) : clientApi.createProject();
|
|
201
|
-
},
|
|
202
|
-
onSuccess: () => {
|
|
203
|
-
queryClient.invalidateQueries({
|
|
204
|
-
queryKey: getProjectsQueryKey(),
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
function leaveProjectMutationOptions({ clientApi, queryClient, }) {
|
|
210
|
-
return {
|
|
211
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
212
|
-
mutationFn: async ({ projectId }) => {
|
|
213
|
-
return clientApi.leaveProject(projectId);
|
|
214
|
-
},
|
|
215
|
-
onSuccess: () => {
|
|
216
|
-
queryClient.invalidateQueries({
|
|
217
|
-
queryKey: getProjectsQueryKey(),
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
function importProjectCategoriesMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
223
|
-
return {
|
|
224
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
225
|
-
mutationFn: ({ filePath }) => {
|
|
226
|
-
return projectApi.$importCategories({ filePath });
|
|
227
|
-
},
|
|
228
|
-
onSuccess: () => {
|
|
229
|
-
queryClient.invalidateQueries({
|
|
230
|
-
queryKey: getProjectByIdQueryKey({ projectId }),
|
|
231
|
-
});
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function importProjectConfigMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
236
|
-
return {
|
|
237
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
238
|
-
mutationFn: ({ configPath }) => {
|
|
239
|
-
return projectApi.importConfig({ configPath });
|
|
240
|
-
},
|
|
241
|
-
onSuccess: () => {
|
|
242
|
-
queryClient.invalidateQueries({
|
|
243
|
-
queryKey: getProjectByIdQueryKey({ projectId }),
|
|
244
|
-
});
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
function updateProjectSettingsMutationOptions({ projectApi, queryClient, }) {
|
|
249
|
-
return {
|
|
250
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
251
|
-
mutationFn: async (value) => {
|
|
252
|
-
return projectApi.$setProjectSettings(value);
|
|
253
|
-
},
|
|
254
|
-
onSuccess: () => {
|
|
255
|
-
queryClient.invalidateQueries({
|
|
256
|
-
queryKey: getProjectsQueryKey(),
|
|
257
|
-
});
|
|
258
|
-
},
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
function changeMemberRoleMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
262
|
-
return {
|
|
263
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
264
|
-
mutationFn: async ({ deviceId, roleId }) => {
|
|
265
|
-
return projectApi.$member.assignRole(deviceId, roleId);
|
|
266
|
-
},
|
|
267
|
-
onSuccess: () => {
|
|
268
|
-
queryClient.invalidateQueries({
|
|
269
|
-
queryKey: getMembersQueryKey({ projectId }),
|
|
270
|
-
});
|
|
271
|
-
queryClient.invalidateQueries({
|
|
272
|
-
queryKey: getProjectRoleQueryKey({ projectId }),
|
|
273
|
-
});
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
function removeProjectMemberMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
278
|
-
return {
|
|
279
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
280
|
-
mutationFn: async ({ deviceId, reason }) => {
|
|
281
|
-
// Have to avoid passing `undefined` explicitly
|
|
282
|
-
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
283
|
-
return reason
|
|
284
|
-
? projectApi.$member.remove(deviceId, { reason })
|
|
285
|
-
: projectApi.$member.remove(deviceId);
|
|
286
|
-
},
|
|
287
|
-
onSuccess: () => {
|
|
288
|
-
queryClient.invalidateQueries({
|
|
289
|
-
queryKey: getMembersQueryKey({ projectId }),
|
|
290
|
-
});
|
|
291
|
-
},
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
function createBlobMutationOptions({ projectApi, }) {
|
|
295
|
-
return {
|
|
296
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
297
|
-
mutationFn: async ({ original, preview, thumbnail, metadata }) => {
|
|
298
|
-
return projectApi.$blobs.create({ original, preview, thumbnail }, metadata);
|
|
299
|
-
},
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
function startSyncMutationOptions({ projectApi, }) {
|
|
303
|
-
return {
|
|
304
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
305
|
-
mutationFn: async (opts) => {
|
|
306
|
-
// Have to avoid passing `undefined` explicitly
|
|
307
|
-
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
308
|
-
return opts ? projectApi.$sync.start(opts) : projectApi.$sync.start();
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
function stopSyncMutationOptions({ projectApi, }) {
|
|
313
|
-
return {
|
|
314
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
315
|
-
mutationFn: async () => {
|
|
316
|
-
return projectApi.$sync.stop();
|
|
317
|
-
},
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
function connectSyncServersMutationOptions({ projectApi, }) {
|
|
321
|
-
return {
|
|
322
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
323
|
-
mutationFn: async () => {
|
|
324
|
-
return projectApi.$sync.connectServers();
|
|
325
|
-
},
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
function disconnectSyncServersMutationOptions({ projectApi, }) {
|
|
329
|
-
return {
|
|
330
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
331
|
-
mutationFn: async () => {
|
|
332
|
-
return projectApi.$sync.disconnectServers();
|
|
333
|
-
},
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
function setAutostopDataSyncTimeoutMutationOptions({ projectApi, }) {
|
|
337
|
-
return {
|
|
338
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
339
|
-
mutationFn: async ({ after }) => {
|
|
340
|
-
return projectApi.$sync.setAutostopDataSyncTimeout(after);
|
|
341
|
-
},
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
function exportGeoJSONMutationOptions({ projectApi, }) {
|
|
345
|
-
return {
|
|
346
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
347
|
-
mutationFn: async (opts) => {
|
|
348
|
-
return projectApi.exportGeoJSONFile(opts.path, opts.exportOptions);
|
|
349
|
-
},
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
function exportZipFileMutationOptions({ projectApi, }) {
|
|
353
|
-
return {
|
|
354
|
-
...(0, shared_js_1.baseMutationOptions)(),
|
|
355
|
-
mutationFn: async (opts) => {
|
|
356
|
-
return projectApi.exportZipFile(opts.path, opts.exportOptions);
|
|
357
|
-
},
|
|
358
|
-
};
|
|
359
|
-
}
|