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