@comapeo/core-react 7.1.0 → 8.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/contexts/ClientApi.d.ts +3 -1
- package/dist/commonjs/contexts/ClientApi.js +14 -0
- package/dist/commonjs/hooks/client.d.ts +3 -1
- package/dist/commonjs/hooks/documents.d.ts +3 -1
- package/dist/commonjs/hooks/invites.d.ts +0 -16
- package/dist/commonjs/hooks/invites.js +0 -32
- package/dist/commonjs/hooks/projects.d.ts +34 -3
- package/dist/commonjs/hooks/projects.js +26 -1
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.js +1 -4
- package/dist/commonjs/lib/presets.d.ts +3 -1
- package/dist/commonjs/lib/react-query/client.d.ts +6 -2
- package/dist/commonjs/lib/react-query/documents.d.ts +7 -3
- package/dist/commonjs/lib/react-query/invites.d.ts +6 -2
- package/dist/commonjs/lib/react-query/maps.d.ts +3 -1
- package/dist/commonjs/lib/react-query/projects.d.ts +5 -1
- package/dist/commonjs/lib/react-query/projects.js +1 -6
- package/dist/commonjs/lib/sync.d.ts +3 -1
- package/dist/commonjs/lib/types.d.ts +3 -1
- package/dist/esm/contexts/ClientApi.d.ts +3 -1
- package/dist/esm/contexts/ClientApi.js +15 -1
- package/dist/esm/hooks/client.d.ts +3 -1
- package/dist/esm/hooks/documents.d.ts +3 -1
- package/dist/esm/hooks/invites.d.ts +0 -16
- package/dist/esm/hooks/invites.js +1 -32
- package/dist/esm/hooks/projects.d.ts +34 -3
- package/dist/esm/hooks/projects.js +26 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/presets.d.ts +3 -1
- package/dist/esm/lib/react-query/client.d.ts +6 -2
- package/dist/esm/lib/react-query/documents.d.ts +7 -3
- package/dist/esm/lib/react-query/invites.d.ts +6 -2
- package/dist/esm/lib/react-query/maps.d.ts +3 -1
- package/dist/esm/lib/react-query/projects.d.ts +5 -1
- package/dist/esm/lib/react-query/projects.js +1 -6
- package/dist/esm/lib/sync.d.ts +3 -1
- package/dist/esm/lib/types.d.ts +3 -1
- package/package.json +28 -28
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
import { type Context, type JSX, type ReactNode } from 'react';
|
|
3
5
|
export declare const ClientApiContext: Context<MapeoClientApi | null>;
|
|
4
6
|
/**
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClientApiContext = void 0;
|
|
4
4
|
exports.ClientApiProvider = ClientApiProvider;
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
5
6
|
const react_1 = require("react");
|
|
7
|
+
const invites_js_1 = require("../lib/react-query/invites.js");
|
|
6
8
|
exports.ClientApiContext = (0, react_1.createContext)(null);
|
|
7
9
|
/**
|
|
8
10
|
* Create a context provider that holds a CoMapeo API client instance.
|
|
@@ -12,5 +14,17 @@ exports.ClientApiContext = (0, react_1.createContext)(null);
|
|
|
12
14
|
*
|
|
13
15
|
*/
|
|
14
16
|
function ClientApiProvider({ children, clientApi, }) {
|
|
17
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
function invalidateCache() {
|
|
20
|
+
queryClient.invalidateQueries({ queryKey: (0, invites_js_1.getInvitesQueryKey)() });
|
|
21
|
+
}
|
|
22
|
+
clientApi.invite.addListener('invite-received', invalidateCache);
|
|
23
|
+
clientApi.invite.addListener('invite-updated', invalidateCache);
|
|
24
|
+
return () => {
|
|
25
|
+
clientApi.invite.removeListener('invite-received', invalidateCache);
|
|
26
|
+
clientApi.invite.removeListener('invite-updated', invalidateCache);
|
|
27
|
+
};
|
|
28
|
+
}, [clientApi, queryClient]);
|
|
15
29
|
return (0, react_1.createElement)(exports.ClientApiContext.Provider, { value: clientApi }, children);
|
|
16
30
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
/**
|
|
3
5
|
* Access a client API instance. If a ClientApiContext provider is not
|
|
4
6
|
* set up, it will throw an error.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Preset } from '@comapeo/schema' with {
|
|
1
|
+
import type { Preset } from '@comapeo/schema' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
import type { WriteableDocumentType } from '../lib/types.js';
|
|
3
5
|
/**
|
|
4
6
|
* Retrieve a single document from the database based on the document's document ID.
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set up listeners for received and updated invites.
|
|
3
|
-
* It is necessary to use this if you want the invites-related read hooks to update
|
|
4
|
-
* based on invites that are received or changed in the background.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* function App() {
|
|
9
|
-
* // Use this somewhere near the root of the application
|
|
10
|
-
* useSetUpInvitesListeners()
|
|
11
|
-
*
|
|
12
|
-
* return <RestOfApp />
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function useSetUpInvitesListeners(): void;
|
|
17
1
|
/**
|
|
18
2
|
* Get all invites that the device has received.
|
|
19
3
|
*
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSetUpInvitesListeners = useSetUpInvitesListeners;
|
|
4
3
|
exports.useManyInvites = useManyInvites;
|
|
5
4
|
exports.useSingleInvite = useSingleInvite;
|
|
6
5
|
exports.useAcceptInvite = useAcceptInvite;
|
|
@@ -8,40 +7,9 @@ exports.useRejectInvite = useRejectInvite;
|
|
|
8
7
|
exports.useSendInvite = useSendInvite;
|
|
9
8
|
exports.useRequestCancelInvite = useRequestCancelInvite;
|
|
10
9
|
const react_query_1 = require("@tanstack/react-query");
|
|
11
|
-
const react_1 = require("react");
|
|
12
10
|
const invites_js_1 = require("../lib/react-query/invites.js");
|
|
13
11
|
const client_js_1 = require("./client.js");
|
|
14
12
|
const projects_js_1 = require("./projects.js");
|
|
15
|
-
/**
|
|
16
|
-
* Set up listeners for received and updated invites.
|
|
17
|
-
* It is necessary to use this if you want the invites-related read hooks to update
|
|
18
|
-
* based on invites that are received or changed in the background.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* function App() {
|
|
23
|
-
* // Use this somewhere near the root of the application
|
|
24
|
-
* useSetUpInvitesListeners()
|
|
25
|
-
*
|
|
26
|
-
* return <RestOfApp />
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
function useSetUpInvitesListeners() {
|
|
31
|
-
const queryClient = (0, react_query_1.useQueryClient)();
|
|
32
|
-
const clientApi = (0, client_js_1.useClientApi)();
|
|
33
|
-
(0, react_1.useEffect)(() => {
|
|
34
|
-
function invalidateCache() {
|
|
35
|
-
queryClient.invalidateQueries({ queryKey: (0, invites_js_1.getInvitesQueryKey)() });
|
|
36
|
-
}
|
|
37
|
-
clientApi.invite.addListener('invite-received', invalidateCache);
|
|
38
|
-
clientApi.invite.addListener('invite-updated', invalidateCache);
|
|
39
|
-
return () => {
|
|
40
|
-
clientApi.invite.removeListener('invite-received', invalidateCache);
|
|
41
|
-
clientApi.invite.removeListener('invite-updated', invalidateCache);
|
|
42
|
-
};
|
|
43
|
-
}, [clientApi, queryClient]);
|
|
44
|
-
}
|
|
45
13
|
/**
|
|
46
14
|
* Get all invites that the device has received.
|
|
47
15
|
*
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import type { BlobApi, IconApi } from '@comapeo/core' with {
|
|
2
|
-
|
|
1
|
+
import type { BlobApi, IconApi } from '@comapeo/core' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
4
|
+
import type { RoleChangeEvent } from '@comapeo/core/dist/mapeo-project.js' with {
|
|
5
|
+
'resolution-mode': 'import'
|
|
6
|
+
};
|
|
7
|
+
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
8
|
+
'resolution-mode': 'import'
|
|
9
|
+
};
|
|
3
10
|
import { type SyncState } from '../lib/sync.js';
|
|
4
11
|
/**
|
|
5
12
|
* Retrieve the project settings for a project.
|
|
@@ -318,10 +325,14 @@ export declare function useCreateProject(): {
|
|
|
318
325
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
319
326
|
name?: string;
|
|
320
327
|
configPath?: string;
|
|
328
|
+
projectColor?: string;
|
|
329
|
+
projectDescription?: string;
|
|
321
330
|
} | undefined, unknown>;
|
|
322
331
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
323
332
|
name?: string;
|
|
324
333
|
configPath?: string;
|
|
334
|
+
projectColor?: string;
|
|
335
|
+
projectDescription?: string;
|
|
325
336
|
} | undefined, unknown>;
|
|
326
337
|
reset: () => void;
|
|
327
338
|
status: "error";
|
|
@@ -330,10 +341,14 @@ export declare function useCreateProject(): {
|
|
|
330
341
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
331
342
|
name?: string;
|
|
332
343
|
configPath?: string;
|
|
344
|
+
projectColor?: string;
|
|
345
|
+
projectDescription?: string;
|
|
333
346
|
} | undefined, unknown>;
|
|
334
347
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
335
348
|
name?: string;
|
|
336
349
|
configPath?: string;
|
|
350
|
+
projectColor?: string;
|
|
351
|
+
projectDescription?: string;
|
|
337
352
|
} | undefined, unknown>;
|
|
338
353
|
reset: () => void;
|
|
339
354
|
status: "pending" | "success" | "idle";
|
|
@@ -531,15 +546,31 @@ export declare function useRemoveMember({ projectId }: {
|
|
|
531
546
|
* It is necessary to use this if you want the project role-related read hooks to update
|
|
532
547
|
* based on role change events that are received in the background.
|
|
533
548
|
*
|
|
549
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
550
|
+
*
|
|
534
551
|
* @example
|
|
535
552
|
* ```tsx
|
|
536
553
|
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
537
554
|
* useProjectOwnRoleChangeListener({ projectId })
|
|
538
555
|
* }
|
|
539
556
|
* ```
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```tsx
|
|
560
|
+
* function ComponentWithListener({ projectId }: { projectId: string }) {
|
|
561
|
+
* useProjectOwnRoleChangeListener({
|
|
562
|
+
* projectId,
|
|
563
|
+
* listener: (event) => {
|
|
564
|
+
* // Handle role change, e.g., navigate to default project
|
|
565
|
+
* console.log('New role:', event.role)
|
|
566
|
+
* }
|
|
567
|
+
* })
|
|
568
|
+
* }
|
|
569
|
+
* ```
|
|
540
570
|
*/
|
|
541
|
-
export declare function useProjectOwnRoleChangeListener({ projectId, }: {
|
|
571
|
+
export declare function useProjectOwnRoleChangeListener({ projectId, listener, }: {
|
|
542
572
|
projectId: string;
|
|
573
|
+
listener?: (event: RoleChangeEvent) => void;
|
|
543
574
|
}): void;
|
|
544
575
|
/**
|
|
545
576
|
* Create a blob for a project.
|
|
@@ -446,14 +446,29 @@ function useRemoveMember({ projectId }) {
|
|
|
446
446
|
* It is necessary to use this if you want the project role-related read hooks to update
|
|
447
447
|
* based on role change events that are received in the background.
|
|
448
448
|
*
|
|
449
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
450
|
+
*
|
|
449
451
|
* @example
|
|
450
452
|
* ```tsx
|
|
451
453
|
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
452
454
|
* useProjectOwnRoleChangeListener({ projectId })
|
|
453
455
|
* }
|
|
454
456
|
* ```
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```tsx
|
|
460
|
+
* function ComponentWithListener({ projectId }: { projectId: string }) {
|
|
461
|
+
* useProjectOwnRoleChangeListener({
|
|
462
|
+
* projectId,
|
|
463
|
+
* listener: (event) => {
|
|
464
|
+
* // Handle role change, e.g., navigate to default project
|
|
465
|
+
* console.log('New role:', event.role)
|
|
466
|
+
* }
|
|
467
|
+
* })
|
|
468
|
+
* }
|
|
469
|
+
* ```
|
|
455
470
|
*/
|
|
456
|
-
function useProjectOwnRoleChangeListener({ projectId, }) {
|
|
471
|
+
function useProjectOwnRoleChangeListener({ projectId, listener, }) {
|
|
457
472
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
458
473
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
459
474
|
(0, react_1.useEffect)(() => {
|
|
@@ -470,6 +485,16 @@ function useProjectOwnRoleChangeListener({ projectId, }) {
|
|
|
470
485
|
projectApi.removeListener('own-role-change', invalidateCache);
|
|
471
486
|
};
|
|
472
487
|
}, [projectApi, queryClient, projectId]);
|
|
488
|
+
(0, react_1.useEffect)(() => {
|
|
489
|
+
if (listener) {
|
|
490
|
+
projectApi.addListener('own-role-change', listener);
|
|
491
|
+
}
|
|
492
|
+
return () => {
|
|
493
|
+
if (listener) {
|
|
494
|
+
projectApi.removeListener('own-role-change', listener);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
}, [projectApi, listener]);
|
|
473
498
|
}
|
|
474
499
|
/**
|
|
475
500
|
* Create a blob for a project.
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ClientApiProvider } from './contexts/ClientApi.js';
|
|
2
2
|
export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
|
|
3
3
|
export { useCreateDocument, useDeleteDocument, useManyDocs, usePresetsSelection, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
4
|
-
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite,
|
|
4
|
+
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSingleInvite, } from './hooks/invites.js';
|
|
5
5
|
export { useMapStyleUrl } from './hooks/maps.js';
|
|
6
6
|
export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectOwnRoleChangeListener, useProjectSettings, useRemoveServerPeer, useRemoveMember, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, useChangeMemberRole, useExportGeoJSON, useExportZipFile, } from './hooks/projects.js';
|
|
7
7
|
export { type SyncState } from './lib/sync.js';
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useExportGeoJSON = exports.useChangeMemberRole = exports.useUpdateProjectSettings = exports.useSyncState = exports.useStopSync = exports.useStartSync = exports.useSingleProject = exports.useSingleMember = exports.useSetAutostopDataSyncTimeout = exports.useRemoveMember = exports.useRemoveServerPeer = exports.useProjectSettings = exports.useProjectOwnRoleChangeListener = exports.useOwnRoleInProject = exports.useManyProjects = exports.useManyMembers = exports.useLeaveProject = exports.useImportProjectConfig = exports.useImportProjectCategories = exports.useIconUrl = exports.useDocumentCreatedBy = exports.useDisconnectSyncServers = exports.useDataSyncProgress = exports.useCreateProject = exports.useCreateBlob = exports.useConnectSyncServers = exports.useAttachmentUrl = exports.useAddServerPeer = exports.useMapStyleUrl = exports.useSingleInvite = exports.
|
|
4
|
-
exports.useExportZipFile = void 0;
|
|
3
|
+
exports.useExportZipFile = exports.useExportGeoJSON = exports.useChangeMemberRole = exports.useUpdateProjectSettings = exports.useSyncState = exports.useStopSync = exports.useStartSync = exports.useSingleProject = exports.useSingleMember = exports.useSetAutostopDataSyncTimeout = exports.useRemoveMember = exports.useRemoveServerPeer = exports.useProjectSettings = exports.useProjectOwnRoleChangeListener = exports.useOwnRoleInProject = exports.useManyProjects = exports.useManyMembers = exports.useLeaveProject = exports.useImportProjectConfig = exports.useImportProjectCategories = exports.useIconUrl = exports.useDocumentCreatedBy = exports.useDisconnectSyncServers = exports.useDataSyncProgress = exports.useCreateProject = exports.useCreateBlob = exports.useConnectSyncServers = exports.useAttachmentUrl = exports.useAddServerPeer = exports.useMapStyleUrl = exports.useSingleInvite = exports.useSendInvite = exports.useRequestCancelInvite = exports.useRejectInvite = exports.useManyInvites = exports.useAcceptInvite = exports.useUpdateDocument = exports.useSingleDocByVersionId = exports.useSingleDocByDocId = exports.usePresetsSelection = exports.useManyDocs = exports.useDeleteDocument = exports.useCreateDocument = exports.useSetOwnDeviceInfo = exports.useSetIsArchiveDevice = exports.useOwnDeviceInfo = exports.useIsArchiveDevice = exports.useClientApi = exports.ClientApiProvider = void 0;
|
|
5
4
|
var ClientApi_js_1 = require("./contexts/ClientApi.js");
|
|
6
|
-
Object.defineProperty(exports, "ClientApiContext", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiContext; } });
|
|
7
5
|
Object.defineProperty(exports, "ClientApiProvider", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiProvider; } });
|
|
8
6
|
var client_js_1 = require("./hooks/client.js");
|
|
9
7
|
Object.defineProperty(exports, "useClientApi", { enumerable: true, get: function () { return client_js_1.useClientApi; } });
|
|
@@ -25,7 +23,6 @@ Object.defineProperty(exports, "useManyInvites", { enumerable: true, get: functi
|
|
|
25
23
|
Object.defineProperty(exports, "useRejectInvite", { enumerable: true, get: function () { return invites_js_1.useRejectInvite; } });
|
|
26
24
|
Object.defineProperty(exports, "useRequestCancelInvite", { enumerable: true, get: function () { return invites_js_1.useRequestCancelInvite; } });
|
|
27
25
|
Object.defineProperty(exports, "useSendInvite", { enumerable: true, get: function () { return invites_js_1.useSendInvite; } });
|
|
28
|
-
Object.defineProperty(exports, "useSetUpInvitesListeners", { enumerable: true, get: function () { return invites_js_1.useSetUpInvitesListeners; } });
|
|
29
26
|
Object.defineProperty(exports, "useSingleInvite", { enumerable: true, get: function () { return invites_js_1.useSingleInvite; } });
|
|
30
27
|
var maps_js_1 = require("./hooks/maps.js");
|
|
31
28
|
Object.defineProperty(exports, "useMapStyleUrl", { enumerable: true, get: function () { return maps_js_1.useMapStyleUrl; } });
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type { Preset } from '@comapeo/schema' with {
|
|
1
|
+
import type { Preset } from '@comapeo/schema' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export declare function getPresetsSelection(presets: Array<Preset>, orderedPresetIds?: Array<string>): Array<Preset>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
-
|
|
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
|
+
};
|
|
3
7
|
import { type QueryClient } from '@tanstack/react-query';
|
|
4
8
|
export declare function getClientQueryKey(): readonly ["@comapeo/core-react", "client"];
|
|
5
9
|
export declare function getDeviceInfoQueryKey(): readonly ["@comapeo/core-react", "client", "device_info"];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { DerivedDocFields } from '@comapeo/core/dist/datatype/index.js' with {
|
|
2
|
-
|
|
1
|
+
import type { DerivedDocFields } from '@comapeo/core/dist/datatype/index.js' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
4
|
+
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
5
|
+
'resolution-mode': 'import'
|
|
6
|
+
};
|
|
3
7
|
import { type QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { WriteableDocument, WriteableDocumentType, WriteableValue } from '../types.js';
|
|
8
|
+
import type { WriteableDocument, WriteableDocumentType, WriteableValue } from '../types.js';
|
|
5
9
|
export declare function getDocumentsQueryKey<D extends WriteableDocumentType>({ projectId, docType, }: {
|
|
6
10
|
projectId: string;
|
|
7
11
|
docType: D;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { MemberApi } from '@comapeo/core' with {
|
|
2
|
-
|
|
1
|
+
import type { MemberApi } from '@comapeo/core' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
4
|
+
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with {
|
|
5
|
+
'resolution-mode': 'import'
|
|
6
|
+
};
|
|
3
7
|
import { type QueryClient } from '@tanstack/react-query';
|
|
4
8
|
export declare function getInvitesQueryKey(): readonly ["@comapeo/core-react", "invites"];
|
|
5
9
|
export declare function getInvitesByIdQueryKey({ inviteId }: {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export declare function getMapsQueryKey(): readonly ["@comapeo/core-react", "maps"];
|
|
3
5
|
export declare function getStyleJsonUrlQueryKey({ refreshToken, }: {
|
|
4
6
|
refreshToken?: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BlobApi, MemberApi } from '@comapeo/core' with { 'resolution-mode': 'import' };
|
|
2
|
-
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with {
|
|
2
|
+
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with {
|
|
3
|
+
'resolution-mode': 'import'
|
|
4
|
+
};
|
|
3
5
|
import { type QueryClient, type UnusedSkipTokenOptions } from '@tanstack/react-query';
|
|
4
6
|
export declare function getProjectsQueryKey(): readonly ["@comapeo/core-react", "projects"];
|
|
5
7
|
export declare function getProjectByIdQueryKey({ projectId }: {
|
|
@@ -150,6 +152,8 @@ export declare function createProjectMutationOptions({ clientApi, queryClient, }
|
|
|
150
152
|
mutationFn: (opts: {
|
|
151
153
|
name?: string;
|
|
152
154
|
configPath?: string;
|
|
155
|
+
projectColor?: string;
|
|
156
|
+
projectDescription?: string;
|
|
153
157
|
} | undefined) => Promise<string>;
|
|
154
158
|
onSuccess: () => void;
|
|
155
159
|
networkMode: "always";
|
|
@@ -197,12 +197,7 @@ function createProjectMutationOptions({ clientApi, queryClient, }) {
|
|
|
197
197
|
mutationFn: async (opts) => {
|
|
198
198
|
// Have to avoid passing `undefined` explicitly
|
|
199
199
|
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
200
|
-
return opts
|
|
201
|
-
? clientApi.createProject({
|
|
202
|
-
configPath: opts.configPath,
|
|
203
|
-
name: opts.name,
|
|
204
|
-
})
|
|
205
|
-
: clientApi.createProject();
|
|
200
|
+
return opts ? clientApi.createProject(opts) : clientApi.createProject();
|
|
206
201
|
},
|
|
207
202
|
onSuccess: () => {
|
|
208
203
|
queryClient.invalidateQueries({
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export type SyncState = Awaited<ReturnType<MapeoProjectApi['$sync']['getState']>>;
|
|
3
5
|
export declare function getDataSyncCountForDevice(syncStateForDevice: SyncState['remoteDeviceSyncState'][string]): number;
|
|
4
6
|
export declare class SyncStore {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoDoc, MapeoValue } from '@comapeo/schema' with {
|
|
1
|
+
import type { MapeoDoc, MapeoValue } from '@comapeo/schema' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export type WriteableDocumentType = Extract<MapeoDoc['schemaName'], 'field' | 'observation' | 'preset' | 'track' | 'remoteDetectionAlert'>;
|
|
3
5
|
export type WriteableValue<D extends WriteableDocumentType> = Extract<MapeoValue, {
|
|
4
6
|
schemaName: D;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
import { type Context, type JSX, type ReactNode } from 'react';
|
|
3
5
|
export declare const ClientApiContext: Context<MapeoClientApi | null>;
|
|
4
6
|
/**
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { createContext, createElement, useEffect, } from 'react';
|
|
3
|
+
import { getInvitesQueryKey } from '../lib/react-query/invites.js';
|
|
2
4
|
export const ClientApiContext = createContext(null);
|
|
3
5
|
/**
|
|
4
6
|
* Create a context provider that holds a CoMapeo API client instance.
|
|
@@ -8,5 +10,17 @@ export const ClientApiContext = createContext(null);
|
|
|
8
10
|
*
|
|
9
11
|
*/
|
|
10
12
|
export function ClientApiProvider({ children, clientApi, }) {
|
|
13
|
+
const queryClient = useQueryClient();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
function invalidateCache() {
|
|
16
|
+
queryClient.invalidateQueries({ queryKey: getInvitesQueryKey() });
|
|
17
|
+
}
|
|
18
|
+
clientApi.invite.addListener('invite-received', invalidateCache);
|
|
19
|
+
clientApi.invite.addListener('invite-updated', invalidateCache);
|
|
20
|
+
return () => {
|
|
21
|
+
clientApi.invite.removeListener('invite-received', invalidateCache);
|
|
22
|
+
clientApi.invite.removeListener('invite-updated', invalidateCache);
|
|
23
|
+
};
|
|
24
|
+
}, [clientApi, queryClient]);
|
|
11
25
|
return createElement(ClientApiContext.Provider, { value: clientApi }, children);
|
|
12
26
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
/**
|
|
3
5
|
* Access a client API instance. If a ClientApiContext provider is not
|
|
4
6
|
* set up, it will throw an error.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Preset } from '@comapeo/schema' with {
|
|
1
|
+
import type { Preset } from '@comapeo/schema' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
import type { WriteableDocumentType } from '../lib/types.js';
|
|
3
5
|
/**
|
|
4
6
|
* Retrieve a single document from the database based on the document's document ID.
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set up listeners for received and updated invites.
|
|
3
|
-
* It is necessary to use this if you want the invites-related read hooks to update
|
|
4
|
-
* based on invites that are received or changed in the background.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* function App() {
|
|
9
|
-
* // Use this somewhere near the root of the application
|
|
10
|
-
* useSetUpInvitesListeners()
|
|
11
|
-
*
|
|
12
|
-
* return <RestOfApp />
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function useSetUpInvitesListeners(): void;
|
|
17
1
|
/**
|
|
18
2
|
* Get all invites that the device has received.
|
|
19
3
|
*
|
|
@@ -1,38 +1,7 @@
|
|
|
1
1
|
import { useMutation, useQueryClient, useSuspenseQuery, } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
3
|
-
import { acceptInviteMutationOptions, getInviteByIdQueryOptions, getInvitesQueryKey, getInvitesQueryOptions, rejectInviteMutationOptions, requestCancelInviteMutationOptions, sendInviteMutationOptions, } from '../lib/react-query/invites.js';
|
|
2
|
+
import { acceptInviteMutationOptions, getInviteByIdQueryOptions, getInvitesQueryOptions, rejectInviteMutationOptions, requestCancelInviteMutationOptions, sendInviteMutationOptions, } from '../lib/react-query/invites.js';
|
|
4
3
|
import { useClientApi } from './client.js';
|
|
5
4
|
import { useSingleProject } from './projects.js';
|
|
6
|
-
/**
|
|
7
|
-
* Set up listeners for received and updated invites.
|
|
8
|
-
* It is necessary to use this if you want the invites-related read hooks to update
|
|
9
|
-
* based on invites that are received or changed in the background.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* function App() {
|
|
14
|
-
* // Use this somewhere near the root of the application
|
|
15
|
-
* useSetUpInvitesListeners()
|
|
16
|
-
*
|
|
17
|
-
* return <RestOfApp />
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export function useSetUpInvitesListeners() {
|
|
22
|
-
const queryClient = useQueryClient();
|
|
23
|
-
const clientApi = useClientApi();
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
function invalidateCache() {
|
|
26
|
-
queryClient.invalidateQueries({ queryKey: getInvitesQueryKey() });
|
|
27
|
-
}
|
|
28
|
-
clientApi.invite.addListener('invite-received', invalidateCache);
|
|
29
|
-
clientApi.invite.addListener('invite-updated', invalidateCache);
|
|
30
|
-
return () => {
|
|
31
|
-
clientApi.invite.removeListener('invite-received', invalidateCache);
|
|
32
|
-
clientApi.invite.removeListener('invite-updated', invalidateCache);
|
|
33
|
-
};
|
|
34
|
-
}, [clientApi, queryClient]);
|
|
35
|
-
}
|
|
36
5
|
/**
|
|
37
6
|
* Get all invites that the device has received.
|
|
38
7
|
*
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import type { BlobApi, IconApi } from '@comapeo/core' with {
|
|
2
|
-
|
|
1
|
+
import type { BlobApi, IconApi } from '@comapeo/core' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
4
|
+
import type { RoleChangeEvent } from '@comapeo/core/dist/mapeo-project.js' with {
|
|
5
|
+
'resolution-mode': 'import'
|
|
6
|
+
};
|
|
7
|
+
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
8
|
+
'resolution-mode': 'import'
|
|
9
|
+
};
|
|
3
10
|
import { type SyncState } from '../lib/sync.js';
|
|
4
11
|
/**
|
|
5
12
|
* Retrieve the project settings for a project.
|
|
@@ -318,10 +325,14 @@ export declare function useCreateProject(): {
|
|
|
318
325
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
319
326
|
name?: string;
|
|
320
327
|
configPath?: string;
|
|
328
|
+
projectColor?: string;
|
|
329
|
+
projectDescription?: string;
|
|
321
330
|
} | undefined, unknown>;
|
|
322
331
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
323
332
|
name?: string;
|
|
324
333
|
configPath?: string;
|
|
334
|
+
projectColor?: string;
|
|
335
|
+
projectDescription?: string;
|
|
325
336
|
} | undefined, unknown>;
|
|
326
337
|
reset: () => void;
|
|
327
338
|
status: "error";
|
|
@@ -330,10 +341,14 @@ export declare function useCreateProject(): {
|
|
|
330
341
|
mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
|
|
331
342
|
name?: string;
|
|
332
343
|
configPath?: string;
|
|
344
|
+
projectColor?: string;
|
|
345
|
+
projectDescription?: string;
|
|
333
346
|
} | undefined, unknown>;
|
|
334
347
|
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
|
|
335
348
|
name?: string;
|
|
336
349
|
configPath?: string;
|
|
350
|
+
projectColor?: string;
|
|
351
|
+
projectDescription?: string;
|
|
337
352
|
} | undefined, unknown>;
|
|
338
353
|
reset: () => void;
|
|
339
354
|
status: "pending" | "success" | "idle";
|
|
@@ -531,15 +546,31 @@ export declare function useRemoveMember({ projectId }: {
|
|
|
531
546
|
* It is necessary to use this if you want the project role-related read hooks to update
|
|
532
547
|
* based on role change events that are received in the background.
|
|
533
548
|
*
|
|
549
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
550
|
+
*
|
|
534
551
|
* @example
|
|
535
552
|
* ```tsx
|
|
536
553
|
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
537
554
|
* useProjectOwnRoleChangeListener({ projectId })
|
|
538
555
|
* }
|
|
539
556
|
* ```
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```tsx
|
|
560
|
+
* function ComponentWithListener({ projectId }: { projectId: string }) {
|
|
561
|
+
* useProjectOwnRoleChangeListener({
|
|
562
|
+
* projectId,
|
|
563
|
+
* listener: (event) => {
|
|
564
|
+
* // Handle role change, e.g., navigate to default project
|
|
565
|
+
* console.log('New role:', event.role)
|
|
566
|
+
* }
|
|
567
|
+
* })
|
|
568
|
+
* }
|
|
569
|
+
* ```
|
|
540
570
|
*/
|
|
541
|
-
export declare function useProjectOwnRoleChangeListener({ projectId, }: {
|
|
571
|
+
export declare function useProjectOwnRoleChangeListener({ projectId, listener, }: {
|
|
542
572
|
projectId: string;
|
|
573
|
+
listener?: (event: RoleChangeEvent) => void;
|
|
543
574
|
}): void;
|
|
544
575
|
/**
|
|
545
576
|
* Create a blob for a project.
|
|
@@ -415,14 +415,29 @@ export function useRemoveMember({ projectId }) {
|
|
|
415
415
|
* It is necessary to use this if you want the project role-related read hooks to update
|
|
416
416
|
* based on role change events that are received in the background.
|
|
417
417
|
*
|
|
418
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
419
|
+
*
|
|
418
420
|
* @example
|
|
419
421
|
* ```tsx
|
|
420
422
|
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
421
423
|
* useProjectOwnRoleChangeListener({ projectId })
|
|
422
424
|
* }
|
|
423
425
|
* ```
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```tsx
|
|
429
|
+
* function ComponentWithListener({ projectId }: { projectId: string }) {
|
|
430
|
+
* useProjectOwnRoleChangeListener({
|
|
431
|
+
* projectId,
|
|
432
|
+
* listener: (event) => {
|
|
433
|
+
* // Handle role change, e.g., navigate to default project
|
|
434
|
+
* console.log('New role:', event.role)
|
|
435
|
+
* }
|
|
436
|
+
* })
|
|
437
|
+
* }
|
|
438
|
+
* ```
|
|
424
439
|
*/
|
|
425
|
-
export function useProjectOwnRoleChangeListener({ projectId, }) {
|
|
440
|
+
export function useProjectOwnRoleChangeListener({ projectId, listener, }) {
|
|
426
441
|
const queryClient = useQueryClient();
|
|
427
442
|
const { data: projectApi } = useSingleProject({ projectId });
|
|
428
443
|
useEffect(() => {
|
|
@@ -439,6 +454,16 @@ export function useProjectOwnRoleChangeListener({ projectId, }) {
|
|
|
439
454
|
projectApi.removeListener('own-role-change', invalidateCache);
|
|
440
455
|
};
|
|
441
456
|
}, [projectApi, queryClient, projectId]);
|
|
457
|
+
useEffect(() => {
|
|
458
|
+
if (listener) {
|
|
459
|
+
projectApi.addListener('own-role-change', listener);
|
|
460
|
+
}
|
|
461
|
+
return () => {
|
|
462
|
+
if (listener) {
|
|
463
|
+
projectApi.removeListener('own-role-change', listener);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}, [projectApi, listener]);
|
|
442
467
|
}
|
|
443
468
|
/**
|
|
444
469
|
* Create a blob for a project.
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ClientApiProvider } from './contexts/ClientApi.js';
|
|
2
2
|
export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
|
|
3
3
|
export { useCreateDocument, useDeleteDocument, useManyDocs, usePresetsSelection, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
4
|
-
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite,
|
|
4
|
+
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSingleInvite, } from './hooks/invites.js';
|
|
5
5
|
export { useMapStyleUrl } from './hooks/maps.js';
|
|
6
6
|
export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectOwnRoleChangeListener, useProjectSettings, useRemoveServerPeer, useRemoveMember, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, useChangeMemberRole, useExportGeoJSON, useExportZipFile, } from './hooks/projects.js';
|
|
7
7
|
export { type SyncState } from './lib/sync.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ClientApiProvider } from './contexts/ClientApi.js';
|
|
2
2
|
export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
|
|
3
3
|
export { useCreateDocument, useDeleteDocument, useManyDocs, usePresetsSelection, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
4
|
-
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite,
|
|
4
|
+
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSingleInvite, } from './hooks/invites.js';
|
|
5
5
|
export { useMapStyleUrl } from './hooks/maps.js';
|
|
6
6
|
export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectOwnRoleChangeListener, useProjectSettings, useRemoveServerPeer, useRemoveMember, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, useChangeMemberRole, useExportGeoJSON, useExportZipFile, } from './hooks/projects.js';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type { Preset } from '@comapeo/schema' with {
|
|
1
|
+
import type { Preset } from '@comapeo/schema' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export declare function getPresetsSelection(presets: Array<Preset>, orderedPresetIds?: Array<string>): Array<Preset>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
-
|
|
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
|
+
};
|
|
3
7
|
import { type QueryClient } from '@tanstack/react-query';
|
|
4
8
|
export declare function getClientQueryKey(): readonly ["@comapeo/core-react", "client"];
|
|
5
9
|
export declare function getDeviceInfoQueryKey(): readonly ["@comapeo/core-react", "client", "device_info"];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { DerivedDocFields } from '@comapeo/core/dist/datatype/index.js' with {
|
|
2
|
-
|
|
1
|
+
import type { DerivedDocFields } from '@comapeo/core/dist/datatype/index.js' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
4
|
+
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
5
|
+
'resolution-mode': 'import'
|
|
6
|
+
};
|
|
3
7
|
import { type QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { WriteableDocument, WriteableDocumentType, WriteableValue } from '../types.js';
|
|
8
|
+
import type { WriteableDocument, WriteableDocumentType, WriteableValue } from '../types.js';
|
|
5
9
|
export declare function getDocumentsQueryKey<D extends WriteableDocumentType>({ projectId, docType, }: {
|
|
6
10
|
projectId: string;
|
|
7
11
|
docType: D;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { MemberApi } from '@comapeo/core' with {
|
|
2
|
-
|
|
1
|
+
import type { MemberApi } from '@comapeo/core' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
4
|
+
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with {
|
|
5
|
+
'resolution-mode': 'import'
|
|
6
|
+
};
|
|
3
7
|
import { type QueryClient } from '@tanstack/react-query';
|
|
4
8
|
export declare function getInvitesQueryKey(): readonly ["@comapeo/core-react", "invites"];
|
|
5
9
|
export declare function getInvitesByIdQueryKey({ inviteId }: {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoClientApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export declare function getMapsQueryKey(): readonly ["@comapeo/core-react", "maps"];
|
|
3
5
|
export declare function getStyleJsonUrlQueryKey({ refreshToken, }: {
|
|
4
6
|
refreshToken?: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BlobApi, MemberApi } from '@comapeo/core' with { 'resolution-mode': 'import' };
|
|
2
|
-
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with {
|
|
2
|
+
import type { MapeoClientApi, MapeoProjectApi } from '@comapeo/ipc' with {
|
|
3
|
+
'resolution-mode': 'import'
|
|
4
|
+
};
|
|
3
5
|
import { type QueryClient, type UnusedSkipTokenOptions } from '@tanstack/react-query';
|
|
4
6
|
export declare function getProjectsQueryKey(): readonly ["@comapeo/core-react", "projects"];
|
|
5
7
|
export declare function getProjectByIdQueryKey({ projectId }: {
|
|
@@ -150,6 +152,8 @@ export declare function createProjectMutationOptions({ clientApi, queryClient, }
|
|
|
150
152
|
mutationFn: (opts: {
|
|
151
153
|
name?: string;
|
|
152
154
|
configPath?: string;
|
|
155
|
+
projectColor?: string;
|
|
156
|
+
projectDescription?: string;
|
|
153
157
|
} | undefined) => Promise<string>;
|
|
154
158
|
onSuccess: () => void;
|
|
155
159
|
networkMode: "always";
|
|
@@ -162,12 +162,7 @@ export function createProjectMutationOptions({ clientApi, queryClient, }) {
|
|
|
162
162
|
mutationFn: async (opts) => {
|
|
163
163
|
// Have to avoid passing `undefined` explicitly
|
|
164
164
|
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
165
|
-
return opts
|
|
166
|
-
? clientApi.createProject({
|
|
167
|
-
configPath: opts.configPath,
|
|
168
|
-
name: opts.name,
|
|
169
|
-
})
|
|
170
|
-
: clientApi.createProject();
|
|
165
|
+
return opts ? clientApi.createProject(opts) : clientApi.createProject();
|
|
171
166
|
},
|
|
172
167
|
onSuccess: () => {
|
|
173
168
|
queryClient.invalidateQueries({
|
package/dist/esm/lib/sync.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
1
|
+
import type { MapeoProjectApi } from '@comapeo/ipc' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export type SyncState = Awaited<ReturnType<MapeoProjectApi['$sync']['getState']>>;
|
|
3
5
|
export declare function getDataSyncCountForDevice(syncStateForDevice: SyncState['remoteDeviceSyncState'][string]): number;
|
|
4
6
|
export declare class SyncStore {
|
package/dist/esm/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { MapeoDoc, MapeoValue } from '@comapeo/schema' with {
|
|
1
|
+
import type { MapeoDoc, MapeoValue } from '@comapeo/schema' with {
|
|
2
|
+
'resolution-mode': 'import'
|
|
3
|
+
};
|
|
2
4
|
export type WriteableDocumentType = Extract<MapeoDoc['schemaName'], 'field' | 'observation' | 'preset' | 'track' | 'remoteDetectionAlert'>;
|
|
3
5
|
export type WriteableValue<D extends WriteableDocumentType> = Extract<MapeoValue, {
|
|
4
6
|
schemaName: D;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comapeo/core-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "React wrapper for working with @comapeo/core",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,47 +57,47 @@
|
|
|
57
57
|
"types": "tsc"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@comapeo/core": "^5.
|
|
61
|
-
"@comapeo/ipc": "^6.0.
|
|
60
|
+
"@comapeo/core": "^5.2.1",
|
|
61
|
+
"@comapeo/ipc": "^6.0.2",
|
|
62
62
|
"@comapeo/schema": "*",
|
|
63
63
|
"@tanstack/react-query": "^5",
|
|
64
64
|
"react": "^18 || ^19"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@comapeo/core": "5.
|
|
68
|
-
"@comapeo/ipc": "6.0.
|
|
67
|
+
"@comapeo/core": "5.2.1",
|
|
68
|
+
"@comapeo/ipc": "6.0.2",
|
|
69
69
|
"@comapeo/schema": "2.2.0",
|
|
70
|
-
"@eslint/compat": "
|
|
71
|
-
"@eslint/js": "9.
|
|
70
|
+
"@eslint/compat": "2.0.0",
|
|
71
|
+
"@eslint/js": "9.39.2",
|
|
72
72
|
"@ianvs/prettier-plugin-sort-imports": "4.7.0",
|
|
73
73
|
"@mapeo/crypto": "1.0.0-alpha.10",
|
|
74
74
|
"@mapeo/default-config": "6.0.0",
|
|
75
75
|
"@mapeo/mock-data": "5.0.0",
|
|
76
|
-
"@tanstack/eslint-plugin-query": "5.
|
|
77
|
-
"@tanstack/react-query": "5.
|
|
76
|
+
"@tanstack/eslint-plugin-query": "5.91.2",
|
|
77
|
+
"@tanstack/react-query": "5.90.12",
|
|
78
78
|
"@testing-library/dom": "10.4.1",
|
|
79
|
-
"@testing-library/react": "16.3.
|
|
80
|
-
"@types/node": "22.
|
|
81
|
-
"@types/react": "19.
|
|
82
|
-
"@types/react-dom": "19.
|
|
83
|
-
"@vitest/eslint-plugin": "1.
|
|
84
|
-
"eslint": "9.
|
|
85
|
-
"eslint-plugin-react-hooks": "
|
|
86
|
-
"eslint-plugin-testing-library": "7.
|
|
79
|
+
"@testing-library/react": "16.3.1",
|
|
80
|
+
"@types/node": "22.19.3",
|
|
81
|
+
"@types/react": "19.2.7",
|
|
82
|
+
"@types/react-dom": "19.2.3",
|
|
83
|
+
"@vitest/eslint-plugin": "1.5.2",
|
|
84
|
+
"eslint": "9.39.2",
|
|
85
|
+
"eslint-plugin-react-hooks": "7.0.1",
|
|
86
|
+
"eslint-plugin-testing-library": "7.14.0",
|
|
87
87
|
"fastify": "4.29.1",
|
|
88
|
-
"globals": "16.
|
|
89
|
-
"happy-dom": "
|
|
88
|
+
"globals": "16.5.0",
|
|
89
|
+
"happy-dom": "20.0.11",
|
|
90
90
|
"husky": "9.1.7",
|
|
91
|
-
"lint-staged": "
|
|
92
|
-
"npm-run-all2": "
|
|
93
|
-
"prettier": "3.
|
|
91
|
+
"lint-staged": "16.2.7",
|
|
92
|
+
"npm-run-all2": "8.0.4",
|
|
93
|
+
"prettier": "3.7.4",
|
|
94
94
|
"random-access-memory": "6.2.1",
|
|
95
|
-
"react": "19.
|
|
96
|
-
"react-dom": "19.
|
|
95
|
+
"react": "19.2.3",
|
|
96
|
+
"react-dom": "19.2.3",
|
|
97
97
|
"tsdoc-markdown": "1.4.1",
|
|
98
|
-
"tshy": "3.0
|
|
99
|
-
"typescript": "5.9.
|
|
100
|
-
"typescript-eslint": "8.
|
|
101
|
-
"vitest": "
|
|
98
|
+
"tshy": "3.1.0",
|
|
99
|
+
"typescript": "5.9.3",
|
|
100
|
+
"typescript-eslint": "8.49.0",
|
|
101
|
+
"vitest": "4.0.15"
|
|
102
102
|
}
|
|
103
103
|
}
|