@comapeo/core-react 7.0.0 → 7.2.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/documents.d.ts +3 -3
- package/dist/commonjs/hooks/projects.d.ts +81 -1
- package/dist/commonjs/hooks/projects.js +84 -0
- package/dist/commonjs/index.d.ts +1 -1
- package/dist/commonjs/index.js +4 -1
- package/dist/commonjs/lib/react-query/documents.d.ts +12 -12
- package/dist/commonjs/lib/react-query/projects.d.ts +24 -3
- package/dist/commonjs/lib/react-query/projects.js +18 -0
- package/dist/esm/hooks/documents.d.ts +3 -3
- package/dist/esm/hooks/projects.d.ts +81 -1
- package/dist/esm/hooks/projects.js +84 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/react-query/documents.d.ts +12 -12
- package/dist/esm/lib/react-query/projects.d.ts +24 -3
- package/dist/esm/lib/react-query/projects.js +17 -0
- package/package.json +4 -4
|
@@ -31,7 +31,7 @@ export declare function useSingleDocByDocId<D extends WriteableDocumentType>({ p
|
|
|
31
31
|
}): {
|
|
32
32
|
data: Extract<({
|
|
33
33
|
schemaName: "track";
|
|
34
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
34
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
35
35
|
observationRefs: {
|
|
36
36
|
docId: string;
|
|
37
37
|
versionId: string;
|
|
@@ -178,7 +178,7 @@ export declare function useSingleDocByVersionId<D extends WriteableDocumentType>
|
|
|
178
178
|
}): {
|
|
179
179
|
data: Extract<({
|
|
180
180
|
schemaName: "track";
|
|
181
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
181
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
182
182
|
observationRefs: {
|
|
183
183
|
docId: string;
|
|
184
184
|
versionId: string;
|
|
@@ -336,7 +336,7 @@ export declare function useManyDocs<D extends WriteableDocumentType>({ projectId
|
|
|
336
336
|
}): {
|
|
337
337
|
data: Extract<({
|
|
338
338
|
schemaName: "track";
|
|
339
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
339
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
340
340
|
observationRefs: {
|
|
341
341
|
docId: string;
|
|
342
342
|
versionId: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BlobApi, IconApi } from '@comapeo/core' with { 'resolution-mode': 'import' };
|
|
2
|
+
import type { RoleChangeEvent } from '@comapeo/core/dist/mapeo-project.js' with { 'resolution-mode': 'import' };
|
|
2
3
|
import type { MapeoProjectApi } from '@comapeo/ipc' with { 'resolution-mode': 'import' };
|
|
3
4
|
import { type SyncState } from '../lib/sync.js';
|
|
4
5
|
/**
|
|
@@ -250,7 +251,9 @@ export declare function useDocumentCreatedBy({ projectId, originalVersionId, }:
|
|
|
250
251
|
export declare function useOwnRoleInProject({ projectId }: {
|
|
251
252
|
projectId: string;
|
|
252
253
|
}): {
|
|
253
|
-
data: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role
|
|
254
|
+
data: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
255
|
+
reason: string | undefined;
|
|
256
|
+
};
|
|
254
257
|
error: Error | null;
|
|
255
258
|
isRefetching: boolean;
|
|
256
259
|
};
|
|
@@ -478,6 +481,83 @@ export declare function useChangeMemberRole({ projectId }: {
|
|
|
478
481
|
reset: () => void;
|
|
479
482
|
status: "pending" | "success" | "idle";
|
|
480
483
|
};
|
|
484
|
+
/**
|
|
485
|
+
* Remove a member from a project, providing an optional reason for removal.
|
|
486
|
+
*
|
|
487
|
+
* Do NOT use this for removing your own device from a project. Use `useLeaveProject` instead.
|
|
488
|
+
*
|
|
489
|
+
* @param opts.projectId Project public ID
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```tsx
|
|
493
|
+
* function BasicExample() {
|
|
494
|
+
* const { mutate } = useRemoveMember({ projectId: '...' })
|
|
495
|
+
* mutate({
|
|
496
|
+
* deviceId: '...',
|
|
497
|
+
* // Optional
|
|
498
|
+
* reason: '...',
|
|
499
|
+
* })
|
|
500
|
+
* }
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
export declare function useRemoveMember({ projectId }: {
|
|
504
|
+
projectId: string;
|
|
505
|
+
}): {
|
|
506
|
+
error: Error;
|
|
507
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
508
|
+
deviceId: string;
|
|
509
|
+
reason?: string;
|
|
510
|
+
}, unknown>;
|
|
511
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
512
|
+
deviceId: string;
|
|
513
|
+
reason?: string;
|
|
514
|
+
}, unknown>;
|
|
515
|
+
reset: () => void;
|
|
516
|
+
status: "error";
|
|
517
|
+
} | {
|
|
518
|
+
error: null;
|
|
519
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
520
|
+
deviceId: string;
|
|
521
|
+
reason?: string;
|
|
522
|
+
}, unknown>;
|
|
523
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
524
|
+
deviceId: string;
|
|
525
|
+
reason?: string;
|
|
526
|
+
}, unknown>;
|
|
527
|
+
reset: () => void;
|
|
528
|
+
status: "pending" | "success" | "idle";
|
|
529
|
+
};
|
|
530
|
+
/**
|
|
531
|
+
* Set up listener for changes to your own role in a project.
|
|
532
|
+
* It is necessary to use this if you want the project role-related read hooks to update
|
|
533
|
+
* based on role change events that are received in the background.
|
|
534
|
+
*
|
|
535
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```tsx
|
|
539
|
+
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
540
|
+
* useProjectOwnRoleChangeListener({ projectId })
|
|
541
|
+
* }
|
|
542
|
+
* ```
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```tsx
|
|
546
|
+
* function ComponentWithListener({ projectId }: { projectId: string }) {
|
|
547
|
+
* useProjectOwnRoleChangeListener({
|
|
548
|
+
* projectId,
|
|
549
|
+
* listener: (event) => {
|
|
550
|
+
* // Handle role change, e.g., navigate to default project
|
|
551
|
+
* console.log('New role:', event.role)
|
|
552
|
+
* }
|
|
553
|
+
* })
|
|
554
|
+
* }
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
557
|
+
export declare function useProjectOwnRoleChangeListener({ projectId, listener, }: {
|
|
558
|
+
projectId: string;
|
|
559
|
+
listener?: (event: RoleChangeEvent) => void;
|
|
560
|
+
}): void;
|
|
481
561
|
/**
|
|
482
562
|
* Create a blob for a project.
|
|
483
563
|
*
|
|
@@ -17,6 +17,8 @@ exports.useImportProjectCategories = useImportProjectCategories;
|
|
|
17
17
|
exports.useImportProjectConfig = useImportProjectConfig;
|
|
18
18
|
exports.useUpdateProjectSettings = useUpdateProjectSettings;
|
|
19
19
|
exports.useChangeMemberRole = useChangeMemberRole;
|
|
20
|
+
exports.useRemoveMember = useRemoveMember;
|
|
21
|
+
exports.useProjectOwnRoleChangeListener = useProjectOwnRoleChangeListener;
|
|
20
22
|
exports.useCreateBlob = useCreateBlob;
|
|
21
23
|
exports.useSyncState = useSyncState;
|
|
22
24
|
exports.useDataSyncProgress = useDataSyncProgress;
|
|
@@ -412,6 +414,88 @@ function useChangeMemberRole({ projectId }) {
|
|
|
412
414
|
? { error, mutate, mutateAsync, reset, status }
|
|
413
415
|
: { error: null, mutate, mutateAsync, reset, status };
|
|
414
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Remove a member from a project, providing an optional reason for removal.
|
|
419
|
+
*
|
|
420
|
+
* Do NOT use this for removing your own device from a project. Use `useLeaveProject` instead.
|
|
421
|
+
*
|
|
422
|
+
* @param opts.projectId Project public ID
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```tsx
|
|
426
|
+
* function BasicExample() {
|
|
427
|
+
* const { mutate } = useRemoveMember({ projectId: '...' })
|
|
428
|
+
* mutate({
|
|
429
|
+
* deviceId: '...',
|
|
430
|
+
* // Optional
|
|
431
|
+
* reason: '...',
|
|
432
|
+
* })
|
|
433
|
+
* }
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
function useRemoveMember({ projectId }) {
|
|
437
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
438
|
+
const { data: projectApi } = useSingleProject({ projectId });
|
|
439
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.removeProjectMemberMutationOptions)({ projectId, projectApi, queryClient }));
|
|
440
|
+
return status === 'error'
|
|
441
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
442
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Set up listener for changes to your own role in a project.
|
|
446
|
+
* It is necessary to use this if you want the project role-related read hooks to update
|
|
447
|
+
* based on role change events that are received in the background.
|
|
448
|
+
*
|
|
449
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* ```tsx
|
|
453
|
+
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
454
|
+
* useProjectOwnRoleChangeListener({ projectId })
|
|
455
|
+
* }
|
|
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
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
function useProjectOwnRoleChangeListener({ projectId, listener, }) {
|
|
472
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
473
|
+
const { data: projectApi } = useSingleProject({ projectId });
|
|
474
|
+
(0, react_1.useEffect)(() => {
|
|
475
|
+
function invalidateCache() {
|
|
476
|
+
queryClient.invalidateQueries({
|
|
477
|
+
queryKey: (0, projects_js_1.getMembersQueryKey)({ projectId }),
|
|
478
|
+
});
|
|
479
|
+
queryClient.invalidateQueries({
|
|
480
|
+
queryKey: (0, projects_js_1.getProjectRoleQueryKey)({ projectId }),
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
projectApi.addListener('own-role-change', invalidateCache);
|
|
484
|
+
return () => {
|
|
485
|
+
projectApi.removeListener('own-role-change', invalidateCache);
|
|
486
|
+
};
|
|
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]);
|
|
498
|
+
}
|
|
415
499
|
/**
|
|
416
500
|
* Create a blob for a project.
|
|
417
501
|
*
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevi
|
|
|
3
3
|
export { useCreateDocument, useDeleteDocument, useManyDocs, usePresetsSelection, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
4
4
|
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSetUpInvitesListeners, useSingleInvite, } from './hooks/invites.js';
|
|
5
5
|
export { useMapStyleUrl } from './hooks/maps.js';
|
|
6
|
-
export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, useChangeMemberRole, useExportGeoJSON, useExportZipFile, } from './hooks/projects.js';
|
|
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';
|
|
8
8
|
export { type WriteableDocument, type WriteableDocumentType, type WriteableValue, } from './lib/types.js';
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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.useSetUpInvitesListeners = 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 = exports.ClientApiContext = void 0;
|
|
4
|
+
exports.useExportZipFile = void 0;
|
|
4
5
|
var ClientApi_js_1 = require("./contexts/ClientApi.js");
|
|
5
6
|
Object.defineProperty(exports, "ClientApiContext", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiContext; } });
|
|
6
7
|
Object.defineProperty(exports, "ClientApiProvider", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiProvider; } });
|
|
@@ -44,8 +45,10 @@ Object.defineProperty(exports, "useLeaveProject", { enumerable: true, get: funct
|
|
|
44
45
|
Object.defineProperty(exports, "useManyMembers", { enumerable: true, get: function () { return projects_js_1.useManyMembers; } });
|
|
45
46
|
Object.defineProperty(exports, "useManyProjects", { enumerable: true, get: function () { return projects_js_1.useManyProjects; } });
|
|
46
47
|
Object.defineProperty(exports, "useOwnRoleInProject", { enumerable: true, get: function () { return projects_js_1.useOwnRoleInProject; } });
|
|
48
|
+
Object.defineProperty(exports, "useProjectOwnRoleChangeListener", { enumerable: true, get: function () { return projects_js_1.useProjectOwnRoleChangeListener; } });
|
|
47
49
|
Object.defineProperty(exports, "useProjectSettings", { enumerable: true, get: function () { return projects_js_1.useProjectSettings; } });
|
|
48
50
|
Object.defineProperty(exports, "useRemoveServerPeer", { enumerable: true, get: function () { return projects_js_1.useRemoveServerPeer; } });
|
|
51
|
+
Object.defineProperty(exports, "useRemoveMember", { enumerable: true, get: function () { return projects_js_1.useRemoveMember; } });
|
|
49
52
|
Object.defineProperty(exports, "useSetAutostopDataSyncTimeout", { enumerable: true, get: function () { return projects_js_1.useSetAutostopDataSyncTimeout; } });
|
|
50
53
|
Object.defineProperty(exports, "useSingleMember", { enumerable: true, get: function () { return projects_js_1.useSingleMember; } });
|
|
51
54
|
Object.defineProperty(exports, "useSingleProject", { enumerable: true, get: function () { return projects_js_1.useSingleProject; } });
|
|
@@ -39,7 +39,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
39
39
|
lang?: string;
|
|
40
40
|
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
41
41
|
schemaName: "track";
|
|
42
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
42
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
43
43
|
observationRefs: {
|
|
44
44
|
docId: string;
|
|
45
45
|
versionId: string;
|
|
@@ -151,7 +151,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
151
151
|
deleted: boolean;
|
|
152
152
|
} & DerivedDocFields)[], Error, ({
|
|
153
153
|
schemaName: "track";
|
|
154
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
154
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
155
155
|
observationRefs: {
|
|
156
156
|
docId: string;
|
|
157
157
|
versionId: string;
|
|
@@ -267,7 +267,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
267
267
|
}]>, "queryFn"> & {
|
|
268
268
|
queryFn?: import("@tanstack/react-query").QueryFunction<({
|
|
269
269
|
schemaName: "track";
|
|
270
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
270
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
271
271
|
observationRefs: {
|
|
272
272
|
docId: string;
|
|
273
273
|
versionId: string;
|
|
@@ -388,7 +388,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
388
388
|
}] & {
|
|
389
389
|
[dataTagSymbol]: ({
|
|
390
390
|
schemaName: "track";
|
|
391
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
391
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
392
392
|
observationRefs: {
|
|
393
393
|
docId: string;
|
|
394
394
|
versionId: string;
|
|
@@ -510,7 +510,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
510
510
|
lang?: string;
|
|
511
511
|
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
512
512
|
schemaName: "track";
|
|
513
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
513
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
514
514
|
observationRefs: {
|
|
515
515
|
docId: string;
|
|
516
516
|
versionId: string;
|
|
@@ -622,7 +622,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
622
622
|
deleted: boolean;
|
|
623
623
|
} & DerivedDocFields), Error, ({
|
|
624
624
|
schemaName: "track";
|
|
625
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
625
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
626
626
|
observationRefs: {
|
|
627
627
|
docId: string;
|
|
628
628
|
versionId: string;
|
|
@@ -737,7 +737,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
737
737
|
}]>, "queryFn"> & {
|
|
738
738
|
queryFn?: import("@tanstack/react-query").QueryFunction<({
|
|
739
739
|
schemaName: "track";
|
|
740
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
740
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
741
741
|
observationRefs: {
|
|
742
742
|
docId: string;
|
|
743
743
|
versionId: string;
|
|
@@ -856,7 +856,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
856
856
|
}] & {
|
|
857
857
|
[dataTagSymbol]: ({
|
|
858
858
|
schemaName: "track";
|
|
859
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
859
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
860
860
|
observationRefs: {
|
|
861
861
|
docId: string;
|
|
862
862
|
versionId: string;
|
|
@@ -978,7 +978,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
978
978
|
lang?: string;
|
|
979
979
|
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
980
980
|
schemaName: "track";
|
|
981
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
981
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
982
982
|
observationRefs: {
|
|
983
983
|
docId: string;
|
|
984
984
|
versionId: string;
|
|
@@ -1090,7 +1090,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
1090
1090
|
deleted: boolean;
|
|
1091
1091
|
} & DerivedDocFields), Error, ({
|
|
1092
1092
|
schemaName: "track";
|
|
1093
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
1093
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
1094
1094
|
observationRefs: {
|
|
1095
1095
|
docId: string;
|
|
1096
1096
|
versionId: string;
|
|
@@ -1205,7 +1205,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
1205
1205
|
}]>, "queryFn"> & {
|
|
1206
1206
|
queryFn?: import("@tanstack/react-query").QueryFunction<({
|
|
1207
1207
|
schemaName: "track";
|
|
1208
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
1208
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
1209
1209
|
observationRefs: {
|
|
1210
1210
|
docId: string;
|
|
1211
1211
|
versionId: string;
|
|
@@ -1324,7 +1324,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
1324
1324
|
}] & {
|
|
1325
1325
|
[dataTagSymbol]: ({
|
|
1326
1326
|
schemaName: "track";
|
|
1327
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
1327
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
1328
1328
|
observationRefs: {
|
|
1329
1329
|
docId: string;
|
|
1330
1330
|
versionId: string;
|
|
@@ -79,11 +79,19 @@ export declare function projectMemberByIdQueryOptions({ projectApi, projectId, d
|
|
|
79
79
|
export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
|
|
80
80
|
projectApi: MapeoProjectApi;
|
|
81
81
|
projectId: string;
|
|
82
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role
|
|
83
|
-
|
|
82
|
+
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
83
|
+
reason: string | undefined;
|
|
84
|
+
}, Error, import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
85
|
+
reason: string | undefined;
|
|
86
|
+
}, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
|
|
87
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
88
|
+
reason: string | undefined;
|
|
89
|
+
}, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
|
|
84
90
|
} & {
|
|
85
91
|
queryKey: readonly ["@comapeo/core-react", "projects", string, "role"] & {
|
|
86
|
-
[dataTagSymbol]: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role
|
|
92
|
+
[dataTagSymbol]: import("@comapeo/core/dist/roles.js", { with: { "resolution-mode": "import" } }).Role & {
|
|
93
|
+
reason: string | undefined;
|
|
94
|
+
};
|
|
87
95
|
[dataTagErrorSymbol]: Error;
|
|
88
96
|
};
|
|
89
97
|
};
|
|
@@ -204,6 +212,19 @@ export declare function changeMemberRoleMutationOptions({ projectApi, projectId,
|
|
|
204
212
|
networkMode: "always";
|
|
205
213
|
retry: false;
|
|
206
214
|
};
|
|
215
|
+
export declare function removeProjectMemberMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
216
|
+
projectApi: MapeoProjectApi;
|
|
217
|
+
projectId: string;
|
|
218
|
+
queryClient: QueryClient;
|
|
219
|
+
}): {
|
|
220
|
+
mutationFn: ({ deviceId, reason }: {
|
|
221
|
+
deviceId: string;
|
|
222
|
+
reason?: string;
|
|
223
|
+
}) => Promise<void>;
|
|
224
|
+
onSuccess: () => void;
|
|
225
|
+
networkMode: "always";
|
|
226
|
+
retry: false;
|
|
227
|
+
};
|
|
207
228
|
export declare function createBlobMutationOptions({ projectApi, }: {
|
|
208
229
|
projectApi: MapeoProjectApi;
|
|
209
230
|
}): {
|
|
@@ -24,6 +24,7 @@ exports.importProjectCategoriesMutationOptions = importProjectCategoriesMutation
|
|
|
24
24
|
exports.importProjectConfigMutationOptions = importProjectConfigMutationOptions;
|
|
25
25
|
exports.updateProjectSettingsMutationOptions = updateProjectSettingsMutationOptions;
|
|
26
26
|
exports.changeMemberRoleMutationOptions = changeMemberRoleMutationOptions;
|
|
27
|
+
exports.removeProjectMemberMutationOptions = removeProjectMemberMutationOptions;
|
|
27
28
|
exports.createBlobMutationOptions = createBlobMutationOptions;
|
|
28
29
|
exports.startSyncMutationOptions = startSyncMutationOptions;
|
|
29
30
|
exports.stopSyncMutationOptions = stopSyncMutationOptions;
|
|
@@ -278,6 +279,23 @@ function changeMemberRoleMutationOptions({ projectApi, projectId, queryClient, }
|
|
|
278
279
|
},
|
|
279
280
|
};
|
|
280
281
|
}
|
|
282
|
+
function removeProjectMemberMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
283
|
+
return {
|
|
284
|
+
...(0, shared_js_1.baseMutationOptions)(),
|
|
285
|
+
mutationFn: async ({ deviceId, reason }) => {
|
|
286
|
+
// Have to avoid passing `undefined` explicitly
|
|
287
|
+
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
288
|
+
return reason
|
|
289
|
+
? projectApi.$member.remove(deviceId, { reason })
|
|
290
|
+
: projectApi.$member.remove(deviceId);
|
|
291
|
+
},
|
|
292
|
+
onSuccess: () => {
|
|
293
|
+
queryClient.invalidateQueries({
|
|
294
|
+
queryKey: getMembersQueryKey({ projectId }),
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
}
|
|
281
299
|
function createBlobMutationOptions({ projectApi, }) {
|
|
282
300
|
return {
|
|
283
301
|
...(0, shared_js_1.baseMutationOptions)(),
|
|
@@ -31,7 +31,7 @@ export declare function useSingleDocByDocId<D extends WriteableDocumentType>({ p
|
|
|
31
31
|
}): {
|
|
32
32
|
data: Extract<({
|
|
33
33
|
schemaName: "track";
|
|
34
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
34
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
35
35
|
observationRefs: {
|
|
36
36
|
docId: string;
|
|
37
37
|
versionId: string;
|
|
@@ -178,7 +178,7 @@ export declare function useSingleDocByVersionId<D extends WriteableDocumentType>
|
|
|
178
178
|
}): {
|
|
179
179
|
data: Extract<({
|
|
180
180
|
schemaName: "track";
|
|
181
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
181
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
182
182
|
observationRefs: {
|
|
183
183
|
docId: string;
|
|
184
184
|
versionId: string;
|
|
@@ -336,7 +336,7 @@ export declare function useManyDocs<D extends WriteableDocumentType>({ projectId
|
|
|
336
336
|
}): {
|
|
337
337
|
data: Extract<({
|
|
338
338
|
schemaName: "track";
|
|
339
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
339
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
340
340
|
observationRefs: {
|
|
341
341
|
docId: string;
|
|
342
342
|
versionId: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BlobApi, IconApi } from '@comapeo/core' with { 'resolution-mode': 'import' };
|
|
2
|
+
import type { RoleChangeEvent } from '@comapeo/core/dist/mapeo-project.js' with { 'resolution-mode': 'import' };
|
|
2
3
|
import type { MapeoProjectApi } from '@comapeo/ipc' with { 'resolution-mode': 'import' };
|
|
3
4
|
import { type SyncState } from '../lib/sync.js';
|
|
4
5
|
/**
|
|
@@ -250,7 +251,9 @@ export declare function useDocumentCreatedBy({ projectId, originalVersionId, }:
|
|
|
250
251
|
export declare function useOwnRoleInProject({ projectId }: {
|
|
251
252
|
projectId: string;
|
|
252
253
|
}): {
|
|
253
|
-
data: import("@comapeo/core/dist/roles.js").Role
|
|
254
|
+
data: import("@comapeo/core/dist/roles.js").Role & {
|
|
255
|
+
reason: string | undefined;
|
|
256
|
+
};
|
|
254
257
|
error: Error | null;
|
|
255
258
|
isRefetching: boolean;
|
|
256
259
|
};
|
|
@@ -478,6 +481,83 @@ export declare function useChangeMemberRole({ projectId }: {
|
|
|
478
481
|
reset: () => void;
|
|
479
482
|
status: "pending" | "success" | "idle";
|
|
480
483
|
};
|
|
484
|
+
/**
|
|
485
|
+
* Remove a member from a project, providing an optional reason for removal.
|
|
486
|
+
*
|
|
487
|
+
* Do NOT use this for removing your own device from a project. Use `useLeaveProject` instead.
|
|
488
|
+
*
|
|
489
|
+
* @param opts.projectId Project public ID
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```tsx
|
|
493
|
+
* function BasicExample() {
|
|
494
|
+
* const { mutate } = useRemoveMember({ projectId: '...' })
|
|
495
|
+
* mutate({
|
|
496
|
+
* deviceId: '...',
|
|
497
|
+
* // Optional
|
|
498
|
+
* reason: '...',
|
|
499
|
+
* })
|
|
500
|
+
* }
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
export declare function useRemoveMember({ projectId }: {
|
|
504
|
+
projectId: string;
|
|
505
|
+
}): {
|
|
506
|
+
error: Error;
|
|
507
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
508
|
+
deviceId: string;
|
|
509
|
+
reason?: string;
|
|
510
|
+
}, unknown>;
|
|
511
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
512
|
+
deviceId: string;
|
|
513
|
+
reason?: string;
|
|
514
|
+
}, unknown>;
|
|
515
|
+
reset: () => void;
|
|
516
|
+
status: "error";
|
|
517
|
+
} | {
|
|
518
|
+
error: null;
|
|
519
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
520
|
+
deviceId: string;
|
|
521
|
+
reason?: string;
|
|
522
|
+
}, unknown>;
|
|
523
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
524
|
+
deviceId: string;
|
|
525
|
+
reason?: string;
|
|
526
|
+
}, unknown>;
|
|
527
|
+
reset: () => void;
|
|
528
|
+
status: "pending" | "success" | "idle";
|
|
529
|
+
};
|
|
530
|
+
/**
|
|
531
|
+
* Set up listener for changes to your own role in a project.
|
|
532
|
+
* It is necessary to use this if you want the project role-related read hooks to update
|
|
533
|
+
* based on role change events that are received in the background.
|
|
534
|
+
*
|
|
535
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```tsx
|
|
539
|
+
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
540
|
+
* useProjectOwnRoleChangeListener({ projectId })
|
|
541
|
+
* }
|
|
542
|
+
* ```
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```tsx
|
|
546
|
+
* function ComponentWithListener({ projectId }: { projectId: string }) {
|
|
547
|
+
* useProjectOwnRoleChangeListener({
|
|
548
|
+
* projectId,
|
|
549
|
+
* listener: (event) => {
|
|
550
|
+
* // Handle role change, e.g., navigate to default project
|
|
551
|
+
* console.log('New role:', event.role)
|
|
552
|
+
* }
|
|
553
|
+
* })
|
|
554
|
+
* }
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
557
|
+
export declare function useProjectOwnRoleChangeListener({ projectId, listener, }: {
|
|
558
|
+
projectId: string;
|
|
559
|
+
listener?: (event: RoleChangeEvent) => void;
|
|
560
|
+
}): void;
|
|
481
561
|
/**
|
|
482
562
|
* Create a blob for a project.
|
|
483
563
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQueryClient, useSuspenseQuery, } from '@tanstack/react-query';
|
|
2
|
-
import { useSyncExternalStore } from 'react';
|
|
3
|
-
import { addServerPeerMutationOptions, changeMemberRoleMutationOptions, connectSyncServersMutationOptions, createBlobMutationOptions, createProjectMutationOptions, disconnectSyncServersMutationOptions, documentCreatedByQueryOptions, exportGeoJSONMutationOptions, exportZipFileMutationOptions, importProjectCategoriesMutationOptions, importProjectConfigMutationOptions, leaveProjectMutationOptions, mediaServerOriginQueryOptions, projectByIdQueryOptions, projectMemberByIdQueryOptions, projectMembersQueryOptions, projectOwnRoleQueryOptions, projectSettingsQueryOptions, projectsQueryOptions, removeServerPeerMutationOptions, setAutostopDataSyncTimeoutMutationOptions, startSyncMutationOptions, stopSyncMutationOptions, updateProjectSettingsMutationOptions, } from '../lib/react-query/projects.js';
|
|
2
|
+
import { useEffect, useSyncExternalStore } from 'react';
|
|
3
|
+
import { addServerPeerMutationOptions, changeMemberRoleMutationOptions, connectSyncServersMutationOptions, createBlobMutationOptions, createProjectMutationOptions, disconnectSyncServersMutationOptions, documentCreatedByQueryOptions, exportGeoJSONMutationOptions, exportZipFileMutationOptions, getMembersQueryKey, getProjectRoleQueryKey, importProjectCategoriesMutationOptions, importProjectConfigMutationOptions, leaveProjectMutationOptions, mediaServerOriginQueryOptions, projectByIdQueryOptions, projectMemberByIdQueryOptions, projectMembersQueryOptions, projectOwnRoleQueryOptions, projectSettingsQueryOptions, projectsQueryOptions, removeProjectMemberMutationOptions, removeServerPeerMutationOptions, setAutostopDataSyncTimeoutMutationOptions, startSyncMutationOptions, stopSyncMutationOptions, updateProjectSettingsMutationOptions, } from '../lib/react-query/projects.js';
|
|
4
4
|
import { SyncStore } from '../lib/sync.js';
|
|
5
5
|
import { getBlobUrl, getIconUrl } from '../lib/urls.js';
|
|
6
6
|
import { useClientApi } from './client.js';
|
|
@@ -383,6 +383,88 @@ export function useChangeMemberRole({ projectId }) {
|
|
|
383
383
|
? { error, mutate, mutateAsync, reset, status }
|
|
384
384
|
: { error: null, mutate, mutateAsync, reset, status };
|
|
385
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Remove a member from a project, providing an optional reason for removal.
|
|
388
|
+
*
|
|
389
|
+
* Do NOT use this for removing your own device from a project. Use `useLeaveProject` instead.
|
|
390
|
+
*
|
|
391
|
+
* @param opts.projectId Project public ID
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```tsx
|
|
395
|
+
* function BasicExample() {
|
|
396
|
+
* const { mutate } = useRemoveMember({ projectId: '...' })
|
|
397
|
+
* mutate({
|
|
398
|
+
* deviceId: '...',
|
|
399
|
+
* // Optional
|
|
400
|
+
* reason: '...',
|
|
401
|
+
* })
|
|
402
|
+
* }
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
export function useRemoveMember({ projectId }) {
|
|
406
|
+
const queryClient = useQueryClient();
|
|
407
|
+
const { data: projectApi } = useSingleProject({ projectId });
|
|
408
|
+
const { error, mutate, mutateAsync, reset, status } = useMutation(removeProjectMemberMutationOptions({ projectId, projectApi, queryClient }));
|
|
409
|
+
return status === 'error'
|
|
410
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
411
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Set up listener for changes to your own role in a project.
|
|
415
|
+
* It is necessary to use this if you want the project role-related read hooks to update
|
|
416
|
+
* based on role change events that are received in the background.
|
|
417
|
+
*
|
|
418
|
+
* @param opts.listener Optional listener to invoke when role changes
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```tsx
|
|
422
|
+
* function SomeComponent({ projectId }: { projectId: string }) {
|
|
423
|
+
* useProjectOwnRoleChangeListener({ projectId })
|
|
424
|
+
* }
|
|
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
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
export function useProjectOwnRoleChangeListener({ projectId, listener, }) {
|
|
441
|
+
const queryClient = useQueryClient();
|
|
442
|
+
const { data: projectApi } = useSingleProject({ projectId });
|
|
443
|
+
useEffect(() => {
|
|
444
|
+
function invalidateCache() {
|
|
445
|
+
queryClient.invalidateQueries({
|
|
446
|
+
queryKey: getMembersQueryKey({ projectId }),
|
|
447
|
+
});
|
|
448
|
+
queryClient.invalidateQueries({
|
|
449
|
+
queryKey: getProjectRoleQueryKey({ projectId }),
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
projectApi.addListener('own-role-change', invalidateCache);
|
|
453
|
+
return () => {
|
|
454
|
+
projectApi.removeListener('own-role-change', invalidateCache);
|
|
455
|
+
};
|
|
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]);
|
|
467
|
+
}
|
|
386
468
|
/**
|
|
387
469
|
* Create a blob for a project.
|
|
388
470
|
*
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevi
|
|
|
3
3
|
export { useCreateDocument, useDeleteDocument, useManyDocs, usePresetsSelection, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
4
4
|
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSetUpInvitesListeners, useSingleInvite, } from './hooks/invites.js';
|
|
5
5
|
export { useMapStyleUrl } from './hooks/maps.js';
|
|
6
|
-
export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, useChangeMemberRole, useExportGeoJSON, useExportZipFile, } from './hooks/projects.js';
|
|
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';
|
|
8
8
|
export { type WriteableDocument, type WriteableDocumentType, type WriteableValue, } from './lib/types.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevi
|
|
|
3
3
|
export { useCreateDocument, useDeleteDocument, useManyDocs, usePresetsSelection, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
4
4
|
export { useAcceptInvite, useManyInvites, useRejectInvite, useRequestCancelInvite, useSendInvite, useSetUpInvitesListeners, useSingleInvite, } from './hooks/invites.js';
|
|
5
5
|
export { useMapStyleUrl } from './hooks/maps.js';
|
|
6
|
-
export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectCategories, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, useChangeMemberRole, useExportGeoJSON, useExportZipFile, } from './hooks/projects.js';
|
|
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';
|
|
@@ -39,7 +39,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
39
39
|
lang?: string;
|
|
40
40
|
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
41
41
|
schemaName: "track";
|
|
42
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
42
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
43
43
|
observationRefs: {
|
|
44
44
|
docId: string;
|
|
45
45
|
versionId: string;
|
|
@@ -151,7 +151,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
151
151
|
deleted: boolean;
|
|
152
152
|
} & DerivedDocFields)[], Error, ({
|
|
153
153
|
schemaName: "track";
|
|
154
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
154
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
155
155
|
observationRefs: {
|
|
156
156
|
docId: string;
|
|
157
157
|
versionId: string;
|
|
@@ -267,7 +267,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
267
267
|
}]>, "queryFn"> & {
|
|
268
268
|
queryFn?: import("@tanstack/react-query").QueryFunction<({
|
|
269
269
|
schemaName: "track";
|
|
270
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
270
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
271
271
|
observationRefs: {
|
|
272
272
|
docId: string;
|
|
273
273
|
versionId: string;
|
|
@@ -388,7 +388,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
|
|
|
388
388
|
}] & {
|
|
389
389
|
[dataTagSymbol]: ({
|
|
390
390
|
schemaName: "track";
|
|
391
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
391
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
392
392
|
observationRefs: {
|
|
393
393
|
docId: string;
|
|
394
394
|
versionId: string;
|
|
@@ -510,7 +510,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
510
510
|
lang?: string;
|
|
511
511
|
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
512
512
|
schemaName: "track";
|
|
513
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
513
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
514
514
|
observationRefs: {
|
|
515
515
|
docId: string;
|
|
516
516
|
versionId: string;
|
|
@@ -622,7 +622,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
622
622
|
deleted: boolean;
|
|
623
623
|
} & DerivedDocFields), Error, ({
|
|
624
624
|
schemaName: "track";
|
|
625
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
625
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
626
626
|
observationRefs: {
|
|
627
627
|
docId: string;
|
|
628
628
|
versionId: string;
|
|
@@ -737,7 +737,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
737
737
|
}]>, "queryFn"> & {
|
|
738
738
|
queryFn?: import("@tanstack/react-query").QueryFunction<({
|
|
739
739
|
schemaName: "track";
|
|
740
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
740
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
741
741
|
observationRefs: {
|
|
742
742
|
docId: string;
|
|
743
743
|
versionId: string;
|
|
@@ -856,7 +856,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
|
|
|
856
856
|
}] & {
|
|
857
857
|
[dataTagSymbol]: ({
|
|
858
858
|
schemaName: "track";
|
|
859
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
859
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
860
860
|
observationRefs: {
|
|
861
861
|
docId: string;
|
|
862
862
|
versionId: string;
|
|
@@ -978,7 +978,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
978
978
|
lang?: string;
|
|
979
979
|
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<({
|
|
980
980
|
schemaName: "track";
|
|
981
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
981
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
982
982
|
observationRefs: {
|
|
983
983
|
docId: string;
|
|
984
984
|
versionId: string;
|
|
@@ -1090,7 +1090,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
1090
1090
|
deleted: boolean;
|
|
1091
1091
|
} & DerivedDocFields), Error, ({
|
|
1092
1092
|
schemaName: "track";
|
|
1093
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
1093
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
1094
1094
|
observationRefs: {
|
|
1095
1095
|
docId: string;
|
|
1096
1096
|
versionId: string;
|
|
@@ -1205,7 +1205,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
1205
1205
|
}]>, "queryFn"> & {
|
|
1206
1206
|
queryFn?: import("@tanstack/react-query").QueryFunction<({
|
|
1207
1207
|
schemaName: "track";
|
|
1208
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
1208
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
1209
1209
|
observationRefs: {
|
|
1210
1210
|
docId: string;
|
|
1211
1211
|
versionId: string;
|
|
@@ -1324,7 +1324,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
|
|
|
1324
1324
|
}] & {
|
|
1325
1325
|
[dataTagSymbol]: ({
|
|
1326
1326
|
schemaName: "track";
|
|
1327
|
-
locations: import("@comapeo/schema/dist/schema/track.js").Position[];
|
|
1327
|
+
locations: [import("@comapeo/schema/dist/schema/track.js").Position, import("@comapeo/schema/dist/schema/track.js").Position, ...import("@comapeo/schema/dist/schema/track.js").Position[]];
|
|
1328
1328
|
observationRefs: {
|
|
1329
1329
|
docId: string;
|
|
1330
1330
|
versionId: string;
|
|
@@ -79,11 +79,19 @@ export declare function projectMemberByIdQueryOptions({ projectApi, projectId, d
|
|
|
79
79
|
export declare function projectOwnRoleQueryOptions({ projectApi, projectId, }: {
|
|
80
80
|
projectApi: MapeoProjectApi;
|
|
81
81
|
projectId: string;
|
|
82
|
-
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js").Role
|
|
83
|
-
|
|
82
|
+
}): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@comapeo/core/dist/roles.js").Role & {
|
|
83
|
+
reason: string | undefined;
|
|
84
|
+
}, Error, import("@comapeo/core/dist/roles.js").Role & {
|
|
85
|
+
reason: string | undefined;
|
|
86
|
+
}, readonly ["@comapeo/core-react", "projects", string, "role"]>, "queryFn"> & {
|
|
87
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("@comapeo/core/dist/roles.js").Role & {
|
|
88
|
+
reason: string | undefined;
|
|
89
|
+
}, readonly ["@comapeo/core-react", "projects", string, "role"], never> | undefined;
|
|
84
90
|
} & {
|
|
85
91
|
queryKey: readonly ["@comapeo/core-react", "projects", string, "role"] & {
|
|
86
|
-
[dataTagSymbol]: import("@comapeo/core/dist/roles.js").Role
|
|
92
|
+
[dataTagSymbol]: import("@comapeo/core/dist/roles.js").Role & {
|
|
93
|
+
reason: string | undefined;
|
|
94
|
+
};
|
|
87
95
|
[dataTagErrorSymbol]: Error;
|
|
88
96
|
};
|
|
89
97
|
};
|
|
@@ -204,6 +212,19 @@ export declare function changeMemberRoleMutationOptions({ projectApi, projectId,
|
|
|
204
212
|
networkMode: "always";
|
|
205
213
|
retry: false;
|
|
206
214
|
};
|
|
215
|
+
export declare function removeProjectMemberMutationOptions({ projectApi, projectId, queryClient, }: {
|
|
216
|
+
projectApi: MapeoProjectApi;
|
|
217
|
+
projectId: string;
|
|
218
|
+
queryClient: QueryClient;
|
|
219
|
+
}): {
|
|
220
|
+
mutationFn: ({ deviceId, reason }: {
|
|
221
|
+
deviceId: string;
|
|
222
|
+
reason?: string;
|
|
223
|
+
}) => Promise<void>;
|
|
224
|
+
onSuccess: () => void;
|
|
225
|
+
networkMode: "always";
|
|
226
|
+
retry: false;
|
|
227
|
+
};
|
|
207
228
|
export declare function createBlobMutationOptions({ projectApi, }: {
|
|
208
229
|
projectApi: MapeoProjectApi;
|
|
209
230
|
}): {
|
|
@@ -244,6 +244,23 @@ export function changeMemberRoleMutationOptions({ projectApi, projectId, queryCl
|
|
|
244
244
|
},
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
|
+
export function removeProjectMemberMutationOptions({ projectApi, projectId, queryClient, }) {
|
|
248
|
+
return {
|
|
249
|
+
...baseMutationOptions(),
|
|
250
|
+
mutationFn: async ({ deviceId, reason }) => {
|
|
251
|
+
// Have to avoid passing `undefined` explicitly
|
|
252
|
+
// See https://github.com/digidem/rpc-reflector/issues/21
|
|
253
|
+
return reason
|
|
254
|
+
? projectApi.$member.remove(deviceId, { reason })
|
|
255
|
+
: projectApi.$member.remove(deviceId);
|
|
256
|
+
},
|
|
257
|
+
onSuccess: () => {
|
|
258
|
+
queryClient.invalidateQueries({
|
|
259
|
+
queryKey: getMembersQueryKey({ projectId }),
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
}
|
|
247
264
|
export function createBlobMutationOptions({ projectApi, }) {
|
|
248
265
|
return {
|
|
249
266
|
...baseMutationOptions(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comapeo/core-react",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "React wrapper for working with @comapeo/core",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
"types": "tsc"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@comapeo/core": "^5.
|
|
60
|
+
"@comapeo/core": "^5.1.1",
|
|
61
61
|
"@comapeo/ipc": "^6.0.0",
|
|
62
62
|
"@comapeo/schema": "*",
|
|
63
63
|
"@tanstack/react-query": "^5",
|
|
64
64
|
"react": "^18 || ^19"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@comapeo/core": "5.
|
|
67
|
+
"@comapeo/core": "5.1.1",
|
|
68
68
|
"@comapeo/ipc": "6.0.0",
|
|
69
|
-
"@comapeo/schema": "2.
|
|
69
|
+
"@comapeo/schema": "2.2.0",
|
|
70
70
|
"@eslint/compat": "1.3.2",
|
|
71
71
|
"@eslint/js": "9.35.0",
|
|
72
72
|
"@ianvs/prettier-plugin-sort-imports": "4.7.0",
|