@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,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
-
'resolution-mode': 'import'
|
|
3
|
-
};
|
|
4
|
-
import type { DeviceInfo } from '@comapeo/schema' with {
|
|
5
|
-
'resolution-mode': 'import'
|
|
6
|
-
};
|
|
7
|
-
import { type QueryClient } from '@tanstack/react-query';
|
|
8
|
-
export declare function getClientQueryKey(): readonly ["@comapeo/core-react", "client"];
|
|
9
|
-
export declare function getDeviceInfoQueryKey(): readonly ["@comapeo/core-react", "client", "device_info"];
|
|
10
|
-
export declare function getIsArchiveDeviceQueryKey(): readonly ["@comapeo/core-react", "client", "is_archive_device"];
|
|
11
|
-
export declare function deviceInfoQueryOptions({ clientApi, }: {
|
|
12
|
-
clientApi: MapeoClientApi;
|
|
13
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
14
|
-
deviceId: string;
|
|
15
|
-
deviceType: import("@comapeo/core/dist/schema/client.js").DeviceInfoParam["deviceType"];
|
|
16
|
-
} & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>, Error, {
|
|
17
|
-
deviceId: string;
|
|
18
|
-
deviceType: import("@comapeo/core/dist/schema/client.js").DeviceInfoParam["deviceType"];
|
|
19
|
-
} & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"]>, "queryFn"> & {
|
|
20
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
21
|
-
deviceId: string;
|
|
22
|
-
deviceType: import("@comapeo/core/dist/schema/client.js").DeviceInfoParam["deviceType"];
|
|
23
|
-
} & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"], never> | undefined;
|
|
24
|
-
} & {
|
|
25
|
-
queryKey: readonly ["@comapeo/core-react", "client", "device_info"] & {
|
|
26
|
-
[dataTagSymbol]: {
|
|
27
|
-
deviceId: string;
|
|
28
|
-
deviceType: import("@comapeo/core/dist/schema/client.js").DeviceInfoParam["deviceType"];
|
|
29
|
-
} & Partial<import("@comapeo/core/dist/schema/client.js").DeviceInfoParam>;
|
|
30
|
-
[dataTagErrorSymbol]: Error;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export declare function isArchiveDeviceQueryOptions({ clientApi, }: {
|
|
34
|
-
clientApi: MapeoClientApi;
|
|
35
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<boolean, Error, boolean, readonly ["@comapeo/core-react", "client", "is_archive_device"]>, "queryFn"> & {
|
|
36
|
-
queryFn?: import("@tanstack/react-query").QueryFunction<boolean, readonly ["@comapeo/core-react", "client", "is_archive_device"], never> | undefined;
|
|
37
|
-
} & {
|
|
38
|
-
queryKey: readonly ["@comapeo/core-react", "client", "is_archive_device"] & {
|
|
39
|
-
[dataTagSymbol]: boolean;
|
|
40
|
-
[dataTagErrorSymbol]: Error;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export declare function setOwnDeviceInfoMutationOptions({ clientApi, queryClient, }: {
|
|
44
|
-
clientApi: MapeoClientApi;
|
|
45
|
-
queryClient: QueryClient;
|
|
46
|
-
}): {
|
|
47
|
-
mutationFn: ({ name, deviceType }: {
|
|
48
|
-
name: string;
|
|
49
|
-
deviceType: DeviceInfo["deviceType"];
|
|
50
|
-
}) => Promise<void>;
|
|
51
|
-
onSuccess: () => void;
|
|
52
|
-
networkMode: "always";
|
|
53
|
-
retry: false;
|
|
54
|
-
};
|
|
55
|
-
export declare function setIsArchiveDeviceMutationOptions({ clientApi, queryClient, }: {
|
|
56
|
-
clientApi: MapeoClientApi;
|
|
57
|
-
queryClient: QueryClient;
|
|
58
|
-
}): {
|
|
59
|
-
mutationFn: ({ isArchiveDevice }: {
|
|
60
|
-
isArchiveDevice: boolean;
|
|
61
|
-
}) => Promise<void>;
|
|
62
|
-
onSuccess: () => void;
|
|
63
|
-
networkMode: "always";
|
|
64
|
-
retry: false;
|
|
65
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { queryOptions, } from '@tanstack/react-query';
|
|
2
|
-
import { getProjectsQueryKey } from './projects.js';
|
|
3
|
-
import { baseMutationOptions, baseQueryOptions, ROOT_QUERY_KEY, } from './shared.js';
|
|
4
|
-
export function getClientQueryKey() {
|
|
5
|
-
return [ROOT_QUERY_KEY, 'client'];
|
|
6
|
-
}
|
|
7
|
-
export function getDeviceInfoQueryKey() {
|
|
8
|
-
return [ROOT_QUERY_KEY, 'client', 'device_info'];
|
|
9
|
-
}
|
|
10
|
-
export function getIsArchiveDeviceQueryKey() {
|
|
11
|
-
return [ROOT_QUERY_KEY, 'client', 'is_archive_device'];
|
|
12
|
-
}
|
|
13
|
-
export function deviceInfoQueryOptions({ clientApi, }) {
|
|
14
|
-
return queryOptions({
|
|
15
|
-
...baseQueryOptions(),
|
|
16
|
-
queryKey: getDeviceInfoQueryKey(),
|
|
17
|
-
queryFn: async () => {
|
|
18
|
-
return clientApi.getDeviceInfo();
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
export function isArchiveDeviceQueryOptions({ clientApi, }) {
|
|
23
|
-
return queryOptions({
|
|
24
|
-
...baseQueryOptions(),
|
|
25
|
-
queryKey: getIsArchiveDeviceQueryKey(),
|
|
26
|
-
queryFn: async () => {
|
|
27
|
-
return clientApi.getIsArchiveDevice();
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
export function setOwnDeviceInfoMutationOptions({ clientApi, queryClient, }) {
|
|
32
|
-
return {
|
|
33
|
-
...baseMutationOptions(),
|
|
34
|
-
mutationFn: async ({ name, deviceType }) => {
|
|
35
|
-
return clientApi.setDeviceInfo({ name, deviceType });
|
|
36
|
-
},
|
|
37
|
-
onSuccess: () => {
|
|
38
|
-
queryClient.invalidateQueries({
|
|
39
|
-
queryKey: getDeviceInfoQueryKey(),
|
|
40
|
-
});
|
|
41
|
-
queryClient.invalidateQueries({
|
|
42
|
-
queryKey: getProjectsQueryKey(),
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export function setIsArchiveDeviceMutationOptions({ clientApi, queryClient, }) {
|
|
48
|
-
return {
|
|
49
|
-
...baseMutationOptions(),
|
|
50
|
-
mutationFn: async ({ isArchiveDevice }) => {
|
|
51
|
-
return clientApi.setIsArchiveDevice(isArchiveDevice);
|
|
52
|
-
},
|
|
53
|
-
onSuccess: () => {
|
|
54
|
-
queryClient.invalidateQueries({
|
|
55
|
-
queryKey: getIsArchiveDeviceQueryKey(),
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|