@comapeo/core-react 1.1.0 → 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.
- package/dist/commonjs/hooks/client.d.ts +21 -0
- package/dist/commonjs/hooks/client.js +20 -0
- package/dist/commonjs/hooks/documents.d.ts +59 -4
- package/dist/commonjs/hooks/documents.js +54 -0
- package/dist/commonjs/hooks/invites.d.ts +51 -0
- package/dist/commonjs/hooks/invites.js +50 -0
- package/dist/commonjs/hooks/projects.d.ts +83 -0
- package/dist/commonjs/hooks/projects.js +62 -0
- package/dist/commonjs/index.d.ts +10 -9
- package/dist/commonjs/index.js +21 -21
- package/dist/commonjs/lib/react-query/client.d.ts +40 -9
- package/dist/commonjs/lib/react-query/client.js +32 -0
- package/dist/commonjs/lib/react-query/documents.d.ts +733 -650
- package/dist/commonjs/lib/react-query/documents.js +57 -0
- package/dist/commonjs/lib/react-query/invites.d.ts +63 -4
- package/dist/commonjs/lib/react-query/invites.js +63 -0
- package/dist/commonjs/lib/react-query/maps.d.ts +12 -3
- package/dist/commonjs/lib/react-query/maps.js +5 -1
- package/dist/commonjs/lib/react-query/projects.d.ts +183 -47
- package/dist/commonjs/lib/react-query/projects.js +88 -0
- package/dist/commonjs/lib/react-query/shared.d.ts +5 -1
- package/dist/commonjs/lib/react-query/shared.js +8 -1
- package/dist/esm/hooks/client.d.ts +21 -0
- package/dist/esm/hooks/client.js +20 -2
- package/dist/esm/hooks/documents.d.ts +59 -4
- package/dist/esm/hooks/documents.js +53 -2
- package/dist/esm/hooks/invites.d.ts +51 -0
- package/dist/esm/hooks/invites.js +44 -0
- package/dist/esm/hooks/projects.d.ts +83 -0
- package/dist/esm/hooks/projects.js +58 -2
- package/dist/esm/index.d.ts +10 -9
- package/dist/esm/index.js +10 -9
- package/dist/esm/lib/react-query/client.d.ts +40 -9
- package/dist/esm/lib/react-query/client.js +32 -2
- package/dist/esm/lib/react-query/documents.d.ts +733 -650
- package/dist/esm/lib/react-query/documents.js +56 -2
- package/dist/esm/lib/react-query/invites.d.ts +63 -4
- package/dist/esm/lib/react-query/invites.js +61 -2
- package/dist/esm/lib/react-query/maps.d.ts +12 -3
- package/dist/esm/lib/react-query/maps.js +5 -1
- package/dist/esm/lib/react-query/projects.d.ts +183 -47
- package/dist/esm/lib/react-query/projects.js +84 -2
- package/dist/esm/lib/react-query/shared.d.ts +5 -1
- package/dist/esm/lib/react-query/shared.js +7 -1
- package/docs/API.md +157 -258
- package/package.json +27 -28
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
-
import { baseQueryOptions, ROOT_QUERY_KEY } from './shared.js';
|
|
1
|
+
import { queryOptions, } from '@tanstack/react-query';
|
|
2
|
+
import { baseMutationOptions, baseQueryOptions, ROOT_QUERY_KEY, } from './shared.js';
|
|
3
3
|
export function getDocumentsQueryKey({ projectId, docType, }) {
|
|
4
4
|
return [ROOT_QUERY_KEY, 'projects', projectId, docType];
|
|
5
5
|
}
|
|
@@ -81,3 +81,57 @@ export function documentByVersionIdQueryOptions({ projectApi, projectId, docType
|
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
+
export function createDocumentMutationOptions({ docType, projectApi, projectId, queryClient, }) {
|
|
85
|
+
return {
|
|
86
|
+
...baseMutationOptions(),
|
|
87
|
+
mutationFn: async ({ value, }) => {
|
|
88
|
+
// @ts-expect-error TS not handling this well
|
|
89
|
+
return projectApi[docType].create({
|
|
90
|
+
...value,
|
|
91
|
+
schemaName: docType,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
onSuccess: () => {
|
|
95
|
+
queryClient.invalidateQueries({
|
|
96
|
+
queryKey: getDocumentsQueryKey({
|
|
97
|
+
projectId,
|
|
98
|
+
docType,
|
|
99
|
+
}),
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function updateDocumentMutationOptions({ docType, projectApi, projectId, queryClient, }) {
|
|
105
|
+
return {
|
|
106
|
+
...baseMutationOptions(),
|
|
107
|
+
mutationFn: async ({ versionId, value, }) => {
|
|
108
|
+
// @ts-expect-error TS not handling this well
|
|
109
|
+
return projectApi[docType].update(versionId, value);
|
|
110
|
+
},
|
|
111
|
+
onSuccess: () => {
|
|
112
|
+
queryClient.invalidateQueries({
|
|
113
|
+
queryKey: getDocumentsQueryKey({
|
|
114
|
+
projectId,
|
|
115
|
+
docType,
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export function deleteDocumentMutationOptions({ docType, projectApi, projectId, queryClient, }) {
|
|
122
|
+
return {
|
|
123
|
+
...baseMutationOptions(),
|
|
124
|
+
mutationFn: async ({ docId, }) => {
|
|
125
|
+
// @ts-expect-error TS not handling this well
|
|
126
|
+
return projectApi[docType].delete(docId);
|
|
127
|
+
},
|
|
128
|
+
onSuccess: () => {
|
|
129
|
+
queryClient.invalidateQueries({
|
|
130
|
+
queryKey: getDocumentsQueryKey({
|
|
131
|
+
projectId,
|
|
132
|
+
docType,
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -1,12 +1,71 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RoleIdForNewInvite } from '@comapeo/core/dist/roles.js' with { 'resolution-mode': 'import' };
|
|
2
|
+
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with { 'resolution-mode': 'import' };
|
|
3
|
+
import { type QueryClient } from '@tanstack/react-query';
|
|
2
4
|
export declare function getInvitesQueryKey(): readonly ["@comapeo/core-react", "invites"];
|
|
3
5
|
export declare function getPendingInvitesQueryKey(): readonly ["@comapeo/core-react", "invites", {
|
|
4
6
|
readonly status: "pending";
|
|
5
7
|
}];
|
|
6
8
|
export declare function pendingInvitesQueryOptions({ clientApi, }: {
|
|
7
9
|
clientApi: MapeoClientApi;
|
|
8
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[], Error, import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[],
|
|
9
|
-
|
|
10
|
+
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[], Error, import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[], readonly ["@comapeo/core-react", "invites", {
|
|
11
|
+
readonly status: "pending";
|
|
12
|
+
}]>, "queryFn"> & {
|
|
13
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[], readonly ["@comapeo/core-react", "invites", {
|
|
14
|
+
readonly status: "pending";
|
|
15
|
+
}], never> | undefined;
|
|
10
16
|
} & {
|
|
11
|
-
queryKey:
|
|
17
|
+
queryKey: readonly ["@comapeo/core-react", "invites", {
|
|
18
|
+
readonly status: "pending";
|
|
19
|
+
}] & {
|
|
20
|
+
[dataTagSymbol]: import("@comapeo/core/dist/types.js").MapBuffers<import("@comapeo/core/dist/invite-api.js").InviteInternal>[];
|
|
21
|
+
[dataTagErrorSymbol]: Error;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function acceptInviteMutationOptions({ clientApi, queryClient, }: {
|
|
25
|
+
clientApi: MapeoClientApi;
|
|
26
|
+
queryClient: QueryClient;
|
|
27
|
+
}): {
|
|
28
|
+
mutationFn: ({ inviteId }: {
|
|
29
|
+
inviteId: string;
|
|
30
|
+
}) => Promise<string>;
|
|
31
|
+
onSuccess: () => void;
|
|
32
|
+
networkMode: "always";
|
|
33
|
+
retry: false;
|
|
34
|
+
};
|
|
35
|
+
export declare function rejectInviteMutationOptions({ clientApi, queryClient, }: {
|
|
36
|
+
clientApi: MapeoClientApi;
|
|
37
|
+
queryClient: QueryClient;
|
|
38
|
+
}): {
|
|
39
|
+
mutationFn: ({ inviteId }: {
|
|
40
|
+
inviteId: string;
|
|
41
|
+
}) => Promise<void>;
|
|
42
|
+
onSuccess: () => void;
|
|
43
|
+
networkMode: "always";
|
|
44
|
+
retry: false;
|
|
45
|
+
};
|
|
46
|
+
export declare function sendInviteMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
47
|
+
projectApi: MapeoProjectApi;
|
|
48
|
+
projectId: string;
|
|
49
|
+
queryClient: QueryClient;
|
|
50
|
+
}): {
|
|
51
|
+
mutationFn: ({ deviceId, ...role }: {
|
|
52
|
+
deviceId: string;
|
|
53
|
+
roleDescription?: string;
|
|
54
|
+
roleId: RoleIdForNewInvite;
|
|
55
|
+
roleName?: string;
|
|
56
|
+
}) => Promise<"ACCEPT" | "REJECT" | "ALREADY">;
|
|
57
|
+
onSuccess: () => void;
|
|
58
|
+
networkMode: "always";
|
|
59
|
+
retry: false;
|
|
60
|
+
};
|
|
61
|
+
export declare function requestCancelInviteMutationOptions({ projectApi, queryClient, }: {
|
|
62
|
+
projectApi: MapeoProjectApi;
|
|
63
|
+
queryClient: QueryClient;
|
|
64
|
+
}): {
|
|
65
|
+
mutationFn: ({ deviceId }: {
|
|
66
|
+
deviceId: string;
|
|
67
|
+
}) => Promise<void>;
|
|
68
|
+
onSuccess: () => void;
|
|
69
|
+
networkMode: "always";
|
|
70
|
+
retry: false;
|
|
12
71
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
1
|
+
import { queryOptions, } from '@tanstack/react-query';
|
|
2
|
+
import { getMembersQueryKey, getProjectsQueryKey } from './projects.js';
|
|
3
|
+
import { baseMutationOptions, baseQueryOptions, ROOT_QUERY_KEY, } from './shared.js';
|
|
3
4
|
export function getInvitesQueryKey() {
|
|
4
5
|
return [ROOT_QUERY_KEY, 'invites'];
|
|
5
6
|
}
|
|
@@ -15,3 +16,61 @@ export function pendingInvitesQueryOptions({ clientApi, }) {
|
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
}
|
|
19
|
+
export function acceptInviteMutationOptions({ clientApi, queryClient, }) {
|
|
20
|
+
return {
|
|
21
|
+
...baseMutationOptions(),
|
|
22
|
+
mutationFn: async ({ inviteId }) => {
|
|
23
|
+
return clientApi.invite.accept({ inviteId });
|
|
24
|
+
},
|
|
25
|
+
onSuccess: () => {
|
|
26
|
+
queryClient.invalidateQueries({
|
|
27
|
+
queryKey: getInvitesQueryKey(),
|
|
28
|
+
});
|
|
29
|
+
queryClient.invalidateQueries({
|
|
30
|
+
queryKey: getProjectsQueryKey(),
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function rejectInviteMutationOptions({ clientApi, queryClient, }) {
|
|
36
|
+
return {
|
|
37
|
+
...baseMutationOptions(),
|
|
38
|
+
mutationFn: async ({ inviteId }) => {
|
|
39
|
+
return clientApi.invite.reject({ inviteId });
|
|
40
|
+
},
|
|
41
|
+
onSuccess: () => {
|
|
42
|
+
queryClient.invalidateQueries({
|
|
43
|
+
queryKey: getInvitesQueryKey(),
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function sendInviteMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
49
|
+
return {
|
|
50
|
+
...baseMutationOptions(),
|
|
51
|
+
mutationFn: async ({ deviceId, ...role }) => {
|
|
52
|
+
return projectApi.$member.invite(deviceId, role);
|
|
53
|
+
},
|
|
54
|
+
onSuccess: () => {
|
|
55
|
+
queryClient.invalidateQueries({
|
|
56
|
+
queryKey: getInvitesQueryKey(),
|
|
57
|
+
});
|
|
58
|
+
queryClient.invalidateQueries({
|
|
59
|
+
queryKey: getMembersQueryKey({ projectId }),
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function requestCancelInviteMutationOptions({ projectApi, queryClient, }) {
|
|
65
|
+
return {
|
|
66
|
+
...baseMutationOptions(),
|
|
67
|
+
mutationFn: async ({ deviceId }) => {
|
|
68
|
+
return projectApi.$member.requestCancelInvite(deviceId);
|
|
69
|
+
},
|
|
70
|
+
onSuccess: () => {
|
|
71
|
+
queryClient.invalidateQueries({
|
|
72
|
+
queryKey: getInvitesQueryKey(),
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -8,8 +8,17 @@ export declare function getStyleJsonUrlQueryKey({ refreshToken, }: {
|
|
|
8
8
|
export declare function mapStyleJsonUrlQueryOptions({ clientApi, refreshToken, }: {
|
|
9
9
|
clientApi: MapeoClientApi;
|
|
10
10
|
refreshToken?: string;
|
|
11
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string,
|
|
12
|
-
|
|
11
|
+
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string, readonly ["@comapeo/core-react", "maps", "stylejson_url", {
|
|
12
|
+
readonly refreshToken: string | undefined;
|
|
13
|
+
}]>, "queryFn"> & {
|
|
14
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<string, readonly ["@comapeo/core-react", "maps", "stylejson_url", {
|
|
15
|
+
readonly refreshToken: string | undefined;
|
|
16
|
+
}], never> | undefined;
|
|
13
17
|
} & {
|
|
14
|
-
queryKey:
|
|
18
|
+
queryKey: readonly ["@comapeo/core-react", "maps", "stylejson_url", {
|
|
19
|
+
readonly refreshToken: string | undefined;
|
|
20
|
+
}] & {
|
|
21
|
+
[dataTagSymbol]: string;
|
|
22
|
+
[dataTagErrorSymbol]: Error;
|
|
23
|
+
};
|
|
15
24
|
};
|
|
@@ -12,7 +12,11 @@ export function mapStyleJsonUrlQueryOptions({ clientApi, refreshToken, }) {
|
|
|
12
12
|
queryKey: getStyleJsonUrlQueryKey({ refreshToken }),
|
|
13
13
|
queryFn: async () => {
|
|
14
14
|
const result = await clientApi.getMapStyleJsonUrl();
|
|
15
|
-
|
|
15
|
+
if (!refreshToken)
|
|
16
|
+
return result;
|
|
17
|
+
const u = new URL(result);
|
|
18
|
+
u.searchParams.set('refresh_token', refreshToken);
|
|
19
|
+
return u.href;
|
|
16
20
|
},
|
|
17
21
|
});
|
|
18
22
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from '@comapeo/core/dist/blob-api.js' with { 'resolution-mode': 'import' };
|
|
1
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' };
|
|
2
4
|
import type { BlobId } from '@comapeo/core/dist/types.js' with { 'resolution-mode': 'import' };
|
|
3
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';
|
|
4
8
|
export declare function getProjectsQueryKey(): readonly ["@comapeo/core-react", "projects"];
|
|
5
9
|
export declare function getProjectByIdQueryKey({ projectId }: {
|
|
6
10
|
projectId: string;
|
|
@@ -81,7 +85,7 @@ export declare function projectsQueryOptions({ clientApi, }: {
|
|
|
81
85
|
projectId: string;
|
|
82
86
|
createdAt?: string | undefined;
|
|
83
87
|
updatedAt?: string | undefined;
|
|
84
|
-
})[],
|
|
88
|
+
})[], readonly ["@comapeo/core-react", "projects"]>, "queryFn"> & {
|
|
85
89
|
queryFn?: import("@tanstack/react-query").QueryFunction<(Pick<{
|
|
86
90
|
schemaName: "projectSettings";
|
|
87
91
|
name?: string | undefined;
|
|
@@ -102,95 +106,227 @@ export declare function projectsQueryOptions({ clientApi, }: {
|
|
|
102
106
|
projectId: string;
|
|
103
107
|
createdAt?: string | undefined;
|
|
104
108
|
updatedAt?: string | undefined;
|
|
105
|
-
})[],
|
|
109
|
+
})[], readonly ["@comapeo/core-react", "projects"], never> | undefined;
|
|
106
110
|
} & {
|
|
107
|
-
queryKey:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
+
};
|
|
128
135
|
};
|
|
129
136
|
export declare function projectByIdQueryOptions({ clientApi, projectId, }: {
|
|
130
137
|
clientApi: MapeoClientApi;
|
|
131
138
|
projectId: string;
|
|
132
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js").MapeoProject>, Error, import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js").MapeoProject>,
|
|
133
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js").MapeoProject>,
|
|
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").MapeoProject>, Error, import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js").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").MapeoProject>, readonly ["@comapeo/core-react", "projects", string], never> | undefined;
|
|
134
141
|
} & {
|
|
135
|
-
queryKey:
|
|
142
|
+
queryKey: readonly ["@comapeo/core-react", "projects", string] & {
|
|
143
|
+
[dataTagSymbol]: import("rpc-reflector/lib/types.js").ClientApi<import("@comapeo/core/dist/mapeo-project.js").MapeoProject>;
|
|
144
|
+
[dataTagErrorSymbol]: Error;
|
|
145
|
+
};
|
|
136
146
|
};
|
|
137
147
|
export declare function projectSettingsQueryOptions({ projectApi, projectId, }: {
|
|
138
148
|
projectApi: MapeoProjectApi;
|
|
139
149
|
projectId: string;
|
|
140
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<
|
|
141
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<
|
|
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;
|
|
142
152
|
} & {
|
|
143
|
-
queryKey:
|
|
153
|
+
queryKey: readonly ["@comapeo/core-react", "projects", string, "project_settings"] & {
|
|
154
|
+
[dataTagSymbol]: EditableProjectSettings;
|
|
155
|
+
[dataTagErrorSymbol]: Error;
|
|
156
|
+
};
|
|
144
157
|
};
|
|
145
158
|
export declare function projectMembersQueryOptions({ projectApi, projectId, }: {
|
|
146
159
|
projectApi: MapeoProjectApi;
|
|
147
160
|
projectId: string;
|
|
148
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/member-api.js").MemberInfo[], Error, import("@comapeo/core/dist/member-api.js").MemberInfo[],
|
|
149
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/member-api.js").MemberInfo[],
|
|
161
|
+
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/member-api.js").MemberInfo[], Error, import("@comapeo/core/dist/member-api.js").MemberInfo[], readonly ["@comapeo/core-react", "projects", string, "members"]>, "queryFn"> & {
|
|
162
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/member-api.js").MemberInfo[], readonly ["@comapeo/core-react", "projects", string, "members"], never> | undefined;
|
|
150
163
|
} & {
|
|
151
|
-
queryKey:
|
|
164
|
+
queryKey: readonly ["@comapeo/core-react", "projects", string, "members"] & {
|
|
165
|
+
[dataTagSymbol]: import("@comapeo/core/dist/member-api.js").MemberInfo[];
|
|
166
|
+
[dataTagErrorSymbol]: Error;
|
|
167
|
+
};
|
|
152
168
|
};
|
|
153
169
|
export declare function projectMemberByIdQueryOptions({ projectApi, projectId, deviceId, }: {
|
|
154
170
|
projectApi: MapeoProjectApi;
|
|
155
171
|
projectId: string;
|
|
156
172
|
deviceId: string;
|
|
157
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/member-api.js").MemberInfo, Error, import("@comapeo/core/dist/member-api.js").MemberInfo,
|
|
158
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/member-api.js").MemberInfo,
|
|
173
|
+
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/member-api.js").MemberInfo, Error, import("@comapeo/core/dist/member-api.js").MemberInfo, readonly ["@comapeo/core-react", "projects", string, "members", string]>, "queryFn"> & {
|
|
174
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/member-api.js").MemberInfo, readonly ["@comapeo/core-react", "projects", string, "members", string], never> | undefined;
|
|
159
175
|
} & {
|
|
160
|
-
queryKey:
|
|
176
|
+
queryKey: readonly ["@comapeo/core-react", "projects", string, "members", string] & {
|
|
177
|
+
[dataTagSymbol]: import("@comapeo/core/dist/member-api.js").MemberInfo;
|
|
178
|
+
[dataTagErrorSymbol]: Error;
|
|
179
|
+
};
|
|
161
180
|
};
|
|
162
181
|
export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
|
|
163
182
|
projectApi: MapeoProjectApi;
|
|
164
183
|
projectId: string;
|
|
165
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, Error, import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">,
|
|
166
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">,
|
|
184
|
+
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, Error, import("@comapeo/core/dist/roles.js").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").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
|
|
167
186
|
} & {
|
|
168
|
-
queryKey:
|
|
187
|
+
queryKey: readonly ["@comapeo/core-react", "projects", string, "role"] & {
|
|
188
|
+
[dataTagSymbol]: import("@comapeo/core/dist/roles.js").Role<"a12a6702b93bd7ff" | "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9" | "8ced989b1904606b" | "08e4251e36f6e7ed">;
|
|
189
|
+
[dataTagErrorSymbol]: Error;
|
|
190
|
+
};
|
|
169
191
|
};
|
|
170
192
|
export declare function iconUrlQueryOptions({ projectApi, projectId, iconId, ...mimeBasedOpts }: {
|
|
171
193
|
projectApi: MapeoProjectApi;
|
|
172
194
|
projectId: string;
|
|
173
195
|
iconId: Parameters<MapeoProjectApi['$icons']['getIconUrl']>[0];
|
|
174
|
-
} & (BitmapOpts | SvgOpts)): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string,
|
|
175
|
-
|
|
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").IconVariant["mimeType"], "image/png">;
|
|
198
|
+
pixelDensity: Extract<import("@comapeo/core/dist/icon-api.js").IconVariant, {
|
|
199
|
+
mimeType: "image/png";
|
|
200
|
+
}>["pixelDensity"];
|
|
201
|
+
size: import("@comapeo/core/dist/icon-api.js").ValidSizes;
|
|
202
|
+
} | {
|
|
203
|
+
mimeType: Extract<import("@comapeo/core/dist/icon-api.js").IconVariant["mimeType"], "image/svg+xml">;
|
|
204
|
+
size: import("@comapeo/core/dist/icon-api.js").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").IconVariant["mimeType"], "image/png">;
|
|
208
|
+
pixelDensity: Extract<import("@comapeo/core/dist/icon-api.js").IconVariant, {
|
|
209
|
+
mimeType: "image/png";
|
|
210
|
+
}>["pixelDensity"];
|
|
211
|
+
size: import("@comapeo/core/dist/icon-api.js").ValidSizes;
|
|
212
|
+
} | {
|
|
213
|
+
mimeType: Extract<import("@comapeo/core/dist/icon-api.js").IconVariant["mimeType"], "image/svg+xml">;
|
|
214
|
+
size: import("@comapeo/core/dist/icon-api.js").ValidSizes;
|
|
215
|
+
}], never> | undefined;
|
|
176
216
|
} & {
|
|
177
|
-
queryKey:
|
|
217
|
+
queryKey: readonly ["@comapeo/core-react", "projects", string, "icons", string, {
|
|
218
|
+
mimeType: Extract<import("@comapeo/core/dist/icon-api.js").IconVariant["mimeType"], "image/png">;
|
|
219
|
+
pixelDensity: Extract<import("@comapeo/core/dist/icon-api.js").IconVariant, {
|
|
220
|
+
mimeType: "image/png";
|
|
221
|
+
}>["pixelDensity"];
|
|
222
|
+
size: import("@comapeo/core/dist/icon-api.js").ValidSizes;
|
|
223
|
+
} | {
|
|
224
|
+
mimeType: Extract<import("@comapeo/core/dist/icon-api.js").IconVariant["mimeType"], "image/svg+xml">;
|
|
225
|
+
size: import("@comapeo/core/dist/icon-api.js").ValidSizes;
|
|
226
|
+
}] & {
|
|
227
|
+
[dataTagSymbol]: string;
|
|
228
|
+
[dataTagErrorSymbol]: Error;
|
|
229
|
+
};
|
|
178
230
|
};
|
|
179
231
|
export declare function documentCreatedByQueryOptions({ projectApi, projectId, originalVersionId, }: {
|
|
180
232
|
projectApi: MapeoProjectApi;
|
|
181
233
|
projectId: string;
|
|
182
234
|
originalVersionId: string;
|
|
183
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string,
|
|
184
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<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;
|
|
185
237
|
} & {
|
|
186
|
-
queryKey:
|
|
238
|
+
queryKey: readonly ["@comapeo/core-react", "projects", string, "document_created_by", string] & {
|
|
239
|
+
[dataTagSymbol]: string;
|
|
240
|
+
[dataTagErrorSymbol]: Error;
|
|
241
|
+
};
|
|
187
242
|
};
|
|
188
243
|
export declare function attachmentUrlQueryOptions({ projectApi, projectId, blobId, }: {
|
|
189
244
|
projectApi: MapeoProjectApi;
|
|
190
245
|
projectId: string;
|
|
191
246
|
blobId: BlobId;
|
|
192
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<string, Error, string,
|
|
193
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<string,
|
|
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;
|
|
194
249
|
} & {
|
|
195
|
-
queryKey:
|
|
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;
|
|
196
332
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
-
import { baseQueryOptions, ROOT_QUERY_KEY } from './shared.js';
|
|
1
|
+
import { queryOptions, } from '@tanstack/react-query';
|
|
2
|
+
import { baseMutationOptions, baseQueryOptions, ROOT_QUERY_KEY, } from './shared.js';
|
|
3
3
|
export function getProjectsQueryKey() {
|
|
4
4
|
return [ROOT_QUERY_KEY, 'projects'];
|
|
5
5
|
}
|
|
@@ -125,3 +125,85 @@ export function attachmentUrlQueryOptions({ projectApi, projectId, blobId, }) {
|
|
|
125
125
|
},
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
+
export function addServerPeerMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
129
|
+
return {
|
|
130
|
+
...baseMutationOptions(),
|
|
131
|
+
mutationFn: async ({ baseUrl, dangerouslyAllowInsecureConnections }) => {
|
|
132
|
+
return projectApi.$member.addServerPeer(baseUrl, {
|
|
133
|
+
dangerouslyAllowInsecureConnections,
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
onSuccess: () => {
|
|
137
|
+
queryClient.invalidateQueries({
|
|
138
|
+
queryKey: getMembersQueryKey({ projectId }),
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function createProjectMutationOptions({ clientApi, queryClient, }) {
|
|
144
|
+
return {
|
|
145
|
+
...baseMutationOptions(),
|
|
146
|
+
mutationFn: async (opts) => {
|
|
147
|
+
// Have to avoid passing `undefined` explicitly
|
|
148
|
+
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
149
|
+
return opts
|
|
150
|
+
? clientApi.createProject({
|
|
151
|
+
configPath: opts.configPath,
|
|
152
|
+
name: opts.name,
|
|
153
|
+
})
|
|
154
|
+
: clientApi.createProject();
|
|
155
|
+
},
|
|
156
|
+
onSuccess: () => {
|
|
157
|
+
queryClient.invalidateQueries({
|
|
158
|
+
queryKey: getProjectsQueryKey(),
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export function leaveProjectMutationOptions({ clientApi, queryClient, }) {
|
|
164
|
+
return {
|
|
165
|
+
...baseMutationOptions(),
|
|
166
|
+
mutationFn: async ({ projectId }) => {
|
|
167
|
+
return clientApi.leaveProject(projectId);
|
|
168
|
+
},
|
|
169
|
+
onSuccess: () => {
|
|
170
|
+
queryClient.invalidateQueries({
|
|
171
|
+
queryKey: getProjectsQueryKey(),
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export function importProjectConfigMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
177
|
+
return {
|
|
178
|
+
...baseMutationOptions(),
|
|
179
|
+
mutationFn: ({ configPath }) => {
|
|
180
|
+
return projectApi.importConfig({ configPath });
|
|
181
|
+
},
|
|
182
|
+
onSuccess: () => {
|
|
183
|
+
queryClient.invalidateQueries({
|
|
184
|
+
queryKey: getProjectByIdQueryKey({ projectId }),
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export function updateProjectSettingsMutationOptions({ projectApi, queryClient, }) {
|
|
190
|
+
return {
|
|
191
|
+
...baseMutationOptions(),
|
|
192
|
+
mutationFn: async (value) => {
|
|
193
|
+
return projectApi.$setProjectSettings(value);
|
|
194
|
+
},
|
|
195
|
+
onSuccess: () => {
|
|
196
|
+
queryClient.invalidateQueries({
|
|
197
|
+
queryKey: getProjectsQueryKey(),
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export function createBlobMutationOptions({ projectApi, }) {
|
|
203
|
+
return {
|
|
204
|
+
...baseMutationOptions(),
|
|
205
|
+
mutationFn: async ({ original, preview, thumbnail, metadata }) => {
|
|
206
|
+
return projectApi.$blobs.create({ original, preview, thumbnail }, metadata);
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|