@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.
Files changed (46) hide show
  1. package/dist/commonjs/hooks/client.d.ts +21 -0
  2. package/dist/commonjs/hooks/client.js +20 -0
  3. package/dist/commonjs/hooks/documents.d.ts +59 -4
  4. package/dist/commonjs/hooks/documents.js +54 -0
  5. package/dist/commonjs/hooks/invites.d.ts +51 -0
  6. package/dist/commonjs/hooks/invites.js +50 -0
  7. package/dist/commonjs/hooks/projects.d.ts +83 -0
  8. package/dist/commonjs/hooks/projects.js +62 -0
  9. package/dist/commonjs/index.d.ts +10 -9
  10. package/dist/commonjs/index.js +21 -21
  11. package/dist/commonjs/lib/react-query/client.d.ts +40 -9
  12. package/dist/commonjs/lib/react-query/client.js +32 -0
  13. package/dist/commonjs/lib/react-query/documents.d.ts +733 -650
  14. package/dist/commonjs/lib/react-query/documents.js +57 -0
  15. package/dist/commonjs/lib/react-query/invites.d.ts +63 -4
  16. package/dist/commonjs/lib/react-query/invites.js +63 -0
  17. package/dist/commonjs/lib/react-query/maps.d.ts +12 -3
  18. package/dist/commonjs/lib/react-query/maps.js +5 -1
  19. package/dist/commonjs/lib/react-query/projects.d.ts +183 -47
  20. package/dist/commonjs/lib/react-query/projects.js +88 -0
  21. package/dist/commonjs/lib/react-query/shared.d.ts +5 -1
  22. package/dist/commonjs/lib/react-query/shared.js +8 -1
  23. package/dist/esm/hooks/client.d.ts +21 -0
  24. package/dist/esm/hooks/client.js +20 -2
  25. package/dist/esm/hooks/documents.d.ts +59 -4
  26. package/dist/esm/hooks/documents.js +53 -2
  27. package/dist/esm/hooks/invites.d.ts +51 -0
  28. package/dist/esm/hooks/invites.js +44 -0
  29. package/dist/esm/hooks/projects.d.ts +83 -0
  30. package/dist/esm/hooks/projects.js +58 -2
  31. package/dist/esm/index.d.ts +10 -9
  32. package/dist/esm/index.js +10 -9
  33. package/dist/esm/lib/react-query/client.d.ts +40 -9
  34. package/dist/esm/lib/react-query/client.js +32 -2
  35. package/dist/esm/lib/react-query/documents.d.ts +733 -650
  36. package/dist/esm/lib/react-query/documents.js +56 -2
  37. package/dist/esm/lib/react-query/invites.d.ts +63 -4
  38. package/dist/esm/lib/react-query/invites.js +61 -2
  39. package/dist/esm/lib/react-query/maps.d.ts +12 -3
  40. package/dist/esm/lib/react-query/maps.js +5 -1
  41. package/dist/esm/lib/react-query/projects.d.ts +183 -47
  42. package/dist/esm/lib/react-query/projects.js +84 -2
  43. package/dist/esm/lib/react-query/shared.d.ts +5 -1
  44. package/dist/esm/lib/react-query/shared.js +7 -1
  45. package/docs/API.md +157 -258
  46. package/package.json +27 -28
@@ -1,4 +1,6 @@
1
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';
2
4
  export declare function getClientQueryKey(): readonly ["@comapeo/core-react", "client"];
3
5
  export declare function getDeviceInfoQueryKey(): readonly ["@comapeo/core-react", "client", "device_info"];
4
6
  export declare function getIsArchiveDeviceQueryKey(): readonly ["@comapeo/core-react", "client", "is_archive_device"];
@@ -10,21 +12,50 @@ export declare function deviceInfoQueryOptions({ clientApi, }: {
10
12
  } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, Error, {
11
13
  deviceId: string;
12
14
  deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
13
- } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, import("@tanstack/react-query").QueryKey>, "queryFn"> & {
15
+ } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"]>, "queryFn"> & {
14
16
  queryFn?: import("@tanstack/react-query").QueryFunction<{
15
17
  deviceId: string;
16
18
  deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
17
- } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, import("@tanstack/react-query").QueryKey, never> | undefined;
19
+ } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>, readonly ["@comapeo/core-react", "client", "device_info"], never> | undefined;
18
20
  } & {
19
- queryKey: import("@tanstack/react-query").DataTag<import("@tanstack/react-query").QueryKey, {
20
- deviceId: string;
21
- deviceType: "device_type_unspecified" | "mobile" | "tablet" | "desktop" | "selfHostedServer" | "UNRECOGNIZED";
22
- } & Partial<import("@comapeo/core/dist/schema/client.js", { with: { "resolution-mode": "import" } }).DeviceInfoParam>>;
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", { with: { "resolution-mode": "import" } }).DeviceInfoParam>;
26
+ [dataTagErrorSymbol]: Error;
27
+ };
23
28
  };
24
29
  export declare function isArchiveDeviceQueryOptions({ clientApi, }: {
25
30
  clientApi: MapeoClientApi;
26
- }): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<boolean, Error, boolean, import("@tanstack/react-query").QueryKey>, "queryFn"> & {
27
- queryFn?: import("@tanstack/react-query").QueryFunction<boolean, import("@tanstack/react-query").QueryKey, never> | undefined;
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;
28
33
  } & {
29
- queryKey: import("@tanstack/react-query").DataTag<import("@tanstack/react-query").QueryKey, boolean>;
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;
30
61
  };
@@ -5,7 +5,10 @@ exports.getDeviceInfoQueryKey = getDeviceInfoQueryKey;
5
5
  exports.getIsArchiveDeviceQueryKey = getIsArchiveDeviceQueryKey;
6
6
  exports.deviceInfoQueryOptions = deviceInfoQueryOptions;
7
7
  exports.isArchiveDeviceQueryOptions = isArchiveDeviceQueryOptions;
8
+ exports.setOwnDeviceInfoMutationOptions = setOwnDeviceInfoMutationOptions;
9
+ exports.setIsArchiveDeviceMutationOptions = setIsArchiveDeviceMutationOptions;
8
10
  const react_query_1 = require("@tanstack/react-query");
11
+ const projects_js_1 = require("./projects.js");
9
12
  const shared_js_1 = require("./shared.js");
10
13
  function getClientQueryKey() {
11
14
  return [shared_js_1.ROOT_QUERY_KEY, 'client'];
@@ -34,3 +37,32 @@ function isArchiveDeviceQueryOptions({ clientApi, }) {
34
37
  },
35
38
  });
36
39
  }
40
+ function setOwnDeviceInfoMutationOptions({ clientApi, queryClient, }) {
41
+ return {
42
+ ...(0, shared_js_1.baseMutationOptions)(),
43
+ mutationFn: async ({ name, deviceType }) => {
44
+ return clientApi.setDeviceInfo({ name, deviceType });
45
+ },
46
+ onSuccess: () => {
47
+ queryClient.invalidateQueries({
48
+ queryKey: getDeviceInfoQueryKey(),
49
+ });
50
+ queryClient.invalidateQueries({
51
+ queryKey: (0, projects_js_1.getProjectsQueryKey)(),
52
+ });
53
+ },
54
+ };
55
+ }
56
+ function setIsArchiveDeviceMutationOptions({ clientApi, queryClient, }) {
57
+ return {
58
+ ...(0, shared_js_1.baseMutationOptions)(),
59
+ mutationFn: async ({ isArchiveDevice }) => {
60
+ return clientApi.setIsArchiveDevice(isArchiveDevice);
61
+ },
62
+ onSuccess: () => {
63
+ queryClient.invalidateQueries({
64
+ queryKey: getIsArchiveDeviceQueryKey(),
65
+ });
66
+ },
67
+ };
68
+ }