@comapeo/core-react 4.2.1 → 4.3.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.
@@ -634,3 +634,103 @@ export declare function useSetAutostopDataSyncTimeout({ projectId, }: {
634
634
  reset: () => void;
635
635
  status: "pending" | "success" | "idle";
636
636
  };
637
+ /**
638
+ * Creates a GeoJson file with all the observations and/or tracks in the project.
639
+ *
640
+ * @param opts.projectId Public ID of the project to apply changes to.
641
+ */
642
+ export declare function useExportGeoJSON({ projectId }: {
643
+ projectId: string;
644
+ }): {
645
+ error: Error;
646
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
647
+ path: string;
648
+ exportOptions: {
649
+ observations?: boolean;
650
+ tracks?: boolean;
651
+ lang?: string;
652
+ };
653
+ }, unknown>;
654
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
655
+ path: string;
656
+ exportOptions: {
657
+ observations?: boolean;
658
+ tracks?: boolean;
659
+ lang?: string;
660
+ };
661
+ }, unknown>;
662
+ reset: () => void;
663
+ status: "error";
664
+ } | {
665
+ error: null;
666
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
667
+ path: string;
668
+ exportOptions: {
669
+ observations?: boolean;
670
+ tracks?: boolean;
671
+ lang?: string;
672
+ };
673
+ }, unknown>;
674
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
675
+ path: string;
676
+ exportOptions: {
677
+ observations?: boolean;
678
+ tracks?: boolean;
679
+ lang?: string;
680
+ };
681
+ }, unknown>;
682
+ reset: () => void;
683
+ status: "pending" | "success" | "idle";
684
+ };
685
+ /**
686
+ * Creates a zip file containing a GeoJson file with all the observations and/or tracks in the project and all associated attachments (photos and audio).
687
+ *
688
+ * @param opts.projectId Public ID of the project to apply changes to.
689
+ */
690
+ export declare function useExportZipFile({ projectId }: {
691
+ projectId: string;
692
+ }): {
693
+ error: Error;
694
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
695
+ path: string;
696
+ exportOptions: {
697
+ observations?: boolean;
698
+ tracks?: boolean;
699
+ lang?: string;
700
+ attachments?: boolean;
701
+ };
702
+ }, unknown>;
703
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
704
+ path: string;
705
+ exportOptions: {
706
+ observations?: boolean;
707
+ tracks?: boolean;
708
+ lang?: string;
709
+ attachments?: boolean;
710
+ };
711
+ }, unknown>;
712
+ reset: () => void;
713
+ status: "error";
714
+ } | {
715
+ error: null;
716
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
717
+ path: string;
718
+ exportOptions: {
719
+ observations?: boolean;
720
+ tracks?: boolean;
721
+ lang?: string;
722
+ attachments?: boolean;
723
+ };
724
+ }, unknown>;
725
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
726
+ path: string;
727
+ exportOptions: {
728
+ observations?: boolean;
729
+ tracks?: boolean;
730
+ lang?: string;
731
+ attachments?: boolean;
732
+ };
733
+ }, unknown>;
734
+ reset: () => void;
735
+ status: "pending" | "success" | "idle";
736
+ };
@@ -23,6 +23,8 @@ exports.useStopSync = useStopSync;
23
23
  exports.useConnectSyncServers = useConnectSyncServers;
24
24
  exports.useDisconnectSyncServers = useDisconnectSyncServers;
25
25
  exports.useSetAutostopDataSyncTimeout = useSetAutostopDataSyncTimeout;
26
+ exports.useExportGeoJSON = useExportGeoJSON;
27
+ exports.useExportZipFile = useExportZipFile;
26
28
  const react_query_1 = require("@tanstack/react-query");
27
29
  const react_1 = require("react");
28
30
  const projects_js_1 = require("../lib/react-query/projects.js");
@@ -450,3 +452,27 @@ function useSetAutostopDataSyncTimeout({ projectId, }) {
450
452
  ? { error, mutate, mutateAsync, reset, status }
451
453
  : { error: null, mutate, mutateAsync, reset, status };
452
454
  }
455
+ /**
456
+ * Creates a GeoJson file with all the observations and/or tracks in the project.
457
+ *
458
+ * @param opts.projectId Public ID of the project to apply changes to.
459
+ */
460
+ function useExportGeoJSON({ projectId }) {
461
+ const { data: projectApi } = useSingleProject({ projectId });
462
+ const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.exportGeoJSONMutationOptions)({ projectApi }));
463
+ return status === 'error'
464
+ ? { error, mutate, mutateAsync, reset, status }
465
+ : { error: null, mutate, mutateAsync, reset, status };
466
+ }
467
+ /**
468
+ * Creates a zip file containing a GeoJson file with all the observations and/or tracks in the project and all associated attachments (photos and audio).
469
+ *
470
+ * @param opts.projectId Public ID of the project to apply changes to.
471
+ */
472
+ function useExportZipFile({ projectId }) {
473
+ const { data: projectApi } = useSingleProject({ projectId });
474
+ const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.exportZipFileMutationOptions)({ projectApi }));
475
+ return status === 'error'
476
+ ? { error, mutate, mutateAsync, reset, status }
477
+ : { error: null, mutate, mutateAsync, reset, status };
478
+ }
@@ -3,6 +3,6 @@ export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevi
3
3
  export { useCreateDocument, useDeleteDocument, useManyDocs, 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, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
6
+ export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, 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';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useUpdateProjectSettings = exports.useSyncState = exports.useStopSync = exports.useStartSync = exports.useSingleProject = exports.useSingleMember = exports.useSetAutostopDataSyncTimeout = exports.useRemoveServerPeer = exports.useProjectSettings = exports.useOwnRoleInProject = exports.useManyProjects = exports.useManyMembers = exports.useLeaveProject = exports.useImportProjectConfig = 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.useManyDocs = exports.useDeleteDocument = exports.useCreateDocument = exports.useSetOwnDeviceInfo = exports.useSetIsArchiveDevice = exports.useOwnDeviceInfo = exports.useIsArchiveDevice = exports.useClientApi = exports.ClientApiProvider = exports.ClientApiContext = void 0;
3
+ exports.useExportZipFile = exports.useExportGeoJSON = exports.useUpdateProjectSettings = exports.useSyncState = exports.useStopSync = exports.useStartSync = exports.useSingleProject = exports.useSingleMember = exports.useSetAutostopDataSyncTimeout = exports.useRemoveServerPeer = exports.useProjectSettings = exports.useOwnRoleInProject = exports.useManyProjects = exports.useManyMembers = exports.useLeaveProject = exports.useImportProjectConfig = 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.useManyDocs = exports.useDeleteDocument = exports.useCreateDocument = exports.useSetOwnDeviceInfo = exports.useSetIsArchiveDevice = exports.useOwnDeviceInfo = exports.useIsArchiveDevice = exports.useClientApi = exports.ClientApiProvider = exports.ClientApiContext = void 0;
4
4
  var ClientApi_js_1 = require("./contexts/ClientApi.js");
5
5
  Object.defineProperty(exports, "ClientApiContext", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiContext; } });
6
6
  Object.defineProperty(exports, "ClientApiProvider", { enumerable: true, get: function () { return ClientApi_js_1.ClientApiProvider; } });
@@ -51,3 +51,5 @@ Object.defineProperty(exports, "useStartSync", { enumerable: true, get: function
51
51
  Object.defineProperty(exports, "useStopSync", { enumerable: true, get: function () { return projects_js_1.useStopSync; } });
52
52
  Object.defineProperty(exports, "useSyncState", { enumerable: true, get: function () { return projects_js_1.useSyncState; } });
53
53
  Object.defineProperty(exports, "useUpdateProjectSettings", { enumerable: true, get: function () { return projects_js_1.useUpdateProjectSettings; } });
54
+ Object.defineProperty(exports, "useExportGeoJSON", { enumerable: true, get: function () { return projects_js_1.useExportGeoJSON; } });
55
+ Object.defineProperty(exports, "useExportZipFile", { enumerable: true, get: function () { return projects_js_1.useExportZipFile; } });
@@ -59,12 +59,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
59
59
  schemaName: "observation";
60
60
  lat?: number | undefined;
61
61
  lon?: number | undefined;
62
- attachments: {
63
- driveDiscoveryId: string;
64
- name: string;
65
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
66
- hash: string;
67
- }[];
62
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
68
63
  tags: {
69
64
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
70
65
  };
@@ -182,12 +177,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
182
177
  schemaName: "observation";
183
178
  lat?: number | undefined;
184
179
  lon?: number | undefined;
185
- attachments: {
186
- driveDiscoveryId: string;
187
- name: string;
188
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
189
- hash: string;
190
- }[];
180
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
191
181
  tags: {
192
182
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
193
183
  };
@@ -309,12 +299,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
309
299
  schemaName: "observation";
310
300
  lat?: number | undefined;
311
301
  lon?: number | undefined;
312
- attachments: {
313
- driveDiscoveryId: string;
314
- name: string;
315
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
316
- hash: string;
317
- }[];
302
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
318
303
  tags: {
319
304
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
320
305
  };
@@ -441,12 +426,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
441
426
  schemaName: "observation";
442
427
  lat?: number | undefined;
443
428
  lon?: number | undefined;
444
- attachments: {
445
- driveDiscoveryId: string;
446
- name: string;
447
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
448
- hash: string;
449
- }[];
429
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
450
430
  tags: {
451
431
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
452
432
  };
@@ -574,12 +554,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
574
554
  schemaName: "observation";
575
555
  lat?: number | undefined;
576
556
  lon?: number | undefined;
577
- attachments: {
578
- driveDiscoveryId: string;
579
- name: string;
580
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
581
- hash: string;
582
- }[];
557
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
583
558
  tags: {
584
559
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
585
560
  };
@@ -697,12 +672,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
697
672
  schemaName: "observation";
698
673
  lat?: number | undefined;
699
674
  lon?: number | undefined;
700
- attachments: {
701
- driveDiscoveryId: string;
702
- name: string;
703
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
704
- hash: string;
705
- }[];
675
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
706
676
  tags: {
707
677
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
708
678
  };
@@ -823,12 +793,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
823
793
  schemaName: "observation";
824
794
  lat?: number | undefined;
825
795
  lon?: number | undefined;
826
- attachments: {
827
- driveDiscoveryId: string;
828
- name: string;
829
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
830
- hash: string;
831
- }[];
796
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
832
797
  tags: {
833
798
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
834
799
  };
@@ -953,12 +918,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
953
918
  schemaName: "observation";
954
919
  lat?: number | undefined;
955
920
  lon?: number | undefined;
956
- attachments: {
957
- driveDiscoveryId: string;
958
- name: string;
959
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
960
- hash: string;
961
- }[];
921
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
962
922
  tags: {
963
923
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
964
924
  };
@@ -1084,12 +1044,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1084
1044
  schemaName: "observation";
1085
1045
  lat?: number | undefined;
1086
1046
  lon?: number | undefined;
1087
- attachments: {
1088
- driveDiscoveryId: string;
1089
- name: string;
1090
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1091
- hash: string;
1092
- }[];
1047
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1093
1048
  tags: {
1094
1049
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1095
1050
  };
@@ -1197,12 +1152,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1197
1152
  schemaName: "observation";
1198
1153
  lat?: number | undefined;
1199
1154
  lon?: number | undefined;
1200
- attachments: {
1201
- driveDiscoveryId: string;
1202
- name: string;
1203
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1204
- hash: string;
1205
- }[];
1155
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1206
1156
  tags: {
1207
1157
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1208
1158
  };
@@ -1313,12 +1263,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1313
1263
  schemaName: "observation";
1314
1264
  lat?: number | undefined;
1315
1265
  lon?: number | undefined;
1316
- attachments: {
1317
- driveDiscoveryId: string;
1318
- name: string;
1319
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1320
- hash: string;
1321
- }[];
1266
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1322
1267
  tags: {
1323
1268
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1324
1269
  };
@@ -1433,12 +1378,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1433
1378
  schemaName: "observation";
1434
1379
  lat?: number | undefined;
1435
1380
  lon?: number | undefined;
1436
- attachments: {
1437
- driveDiscoveryId: string;
1438
- name: string;
1439
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1440
- hash: string;
1441
- }[];
1381
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1442
1382
  tags: {
1443
1383
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1444
1384
  };
@@ -384,3 +384,32 @@ export declare function setAutostopDataSyncTimeoutMutationOptions({ projectApi,
384
384
  networkMode: "always";
385
385
  retry: false;
386
386
  };
387
+ export declare function exportGeoJSONMutationOptions({ projectApi, }: {
388
+ projectApi: MapeoProjectApi;
389
+ }): {
390
+ mutationFn: (opts: {
391
+ path: string;
392
+ exportOptions: {
393
+ observations?: boolean;
394
+ tracks?: boolean;
395
+ lang?: string;
396
+ };
397
+ }) => Promise<string>;
398
+ networkMode: "always";
399
+ retry: false;
400
+ };
401
+ export declare function exportZipFileMutationOptions({ projectApi, }: {
402
+ projectApi: MapeoProjectApi;
403
+ }): {
404
+ mutationFn: (opts: {
405
+ path: string;
406
+ exportOptions: {
407
+ observations?: boolean;
408
+ tracks?: boolean;
409
+ lang?: string;
410
+ attachments?: boolean;
411
+ };
412
+ }) => Promise<string>;
413
+ networkMode: "always";
414
+ retry: false;
415
+ };
@@ -30,6 +30,8 @@ exports.stopSyncMutationOptions = stopSyncMutationOptions;
30
30
  exports.connectSyncServersMutationOptions = connectSyncServersMutationOptions;
31
31
  exports.disconnectSyncServersMutationOptions = disconnectSyncServersMutationOptions;
32
32
  exports.setAutostopDataSyncTimeoutMutationOptions = setAutostopDataSyncTimeoutMutationOptions;
33
+ exports.exportGeoJSONMutationOptions = exportGeoJSONMutationOptions;
34
+ exports.exportZipFileMutationOptions = exportZipFileMutationOptions;
33
35
  const react_query_1 = require("@tanstack/react-query");
34
36
  const shared_js_1 = require("./shared.js");
35
37
  function getProjectsQueryKey() {
@@ -296,3 +298,19 @@ function setAutostopDataSyncTimeoutMutationOptions({ projectApi, }) {
296
298
  },
297
299
  };
298
300
  }
301
+ function exportGeoJSONMutationOptions({ projectApi, }) {
302
+ return {
303
+ ...(0, shared_js_1.baseMutationOptions)(),
304
+ mutationFn: async (opts) => {
305
+ return projectApi.exportGeoJSONFile(opts.path, opts.exportOptions);
306
+ },
307
+ };
308
+ }
309
+ function exportZipFileMutationOptions({ projectApi, }) {
310
+ return {
311
+ ...(0, shared_js_1.baseMutationOptions)(),
312
+ mutationFn: async (opts) => {
313
+ return projectApi.exportZipFile(opts.path, opts.exportOptions);
314
+ },
315
+ };
316
+ }
@@ -634,3 +634,103 @@ export declare function useSetAutostopDataSyncTimeout({ projectId, }: {
634
634
  reset: () => void;
635
635
  status: "pending" | "success" | "idle";
636
636
  };
637
+ /**
638
+ * Creates a GeoJson file with all the observations and/or tracks in the project.
639
+ *
640
+ * @param opts.projectId Public ID of the project to apply changes to.
641
+ */
642
+ export declare function useExportGeoJSON({ projectId }: {
643
+ projectId: string;
644
+ }): {
645
+ error: Error;
646
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
647
+ path: string;
648
+ exportOptions: {
649
+ observations?: boolean;
650
+ tracks?: boolean;
651
+ lang?: string;
652
+ };
653
+ }, unknown>;
654
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
655
+ path: string;
656
+ exportOptions: {
657
+ observations?: boolean;
658
+ tracks?: boolean;
659
+ lang?: string;
660
+ };
661
+ }, unknown>;
662
+ reset: () => void;
663
+ status: "error";
664
+ } | {
665
+ error: null;
666
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
667
+ path: string;
668
+ exportOptions: {
669
+ observations?: boolean;
670
+ tracks?: boolean;
671
+ lang?: string;
672
+ };
673
+ }, unknown>;
674
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
675
+ path: string;
676
+ exportOptions: {
677
+ observations?: boolean;
678
+ tracks?: boolean;
679
+ lang?: string;
680
+ };
681
+ }, unknown>;
682
+ reset: () => void;
683
+ status: "pending" | "success" | "idle";
684
+ };
685
+ /**
686
+ * Creates a zip file containing a GeoJson file with all the observations and/or tracks in the project and all associated attachments (photos and audio).
687
+ *
688
+ * @param opts.projectId Public ID of the project to apply changes to.
689
+ */
690
+ export declare function useExportZipFile({ projectId }: {
691
+ projectId: string;
692
+ }): {
693
+ error: Error;
694
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
695
+ path: string;
696
+ exportOptions: {
697
+ observations?: boolean;
698
+ tracks?: boolean;
699
+ lang?: string;
700
+ attachments?: boolean;
701
+ };
702
+ }, unknown>;
703
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
704
+ path: string;
705
+ exportOptions: {
706
+ observations?: boolean;
707
+ tracks?: boolean;
708
+ lang?: string;
709
+ attachments?: boolean;
710
+ };
711
+ }, unknown>;
712
+ reset: () => void;
713
+ status: "error";
714
+ } | {
715
+ error: null;
716
+ mutate: import("@tanstack/react-query").UseMutateFunction<string, Error, {
717
+ path: string;
718
+ exportOptions: {
719
+ observations?: boolean;
720
+ tracks?: boolean;
721
+ lang?: string;
722
+ attachments?: boolean;
723
+ };
724
+ }, unknown>;
725
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<string, Error, {
726
+ path: string;
727
+ exportOptions: {
728
+ observations?: boolean;
729
+ tracks?: boolean;
730
+ lang?: string;
731
+ attachments?: boolean;
732
+ };
733
+ }, unknown>;
734
+ reset: () => void;
735
+ status: "pending" | "success" | "idle";
736
+ };
@@ -1,6 +1,6 @@
1
1
  import { useMutation, useQueryClient, useSuspenseQuery, } from '@tanstack/react-query';
2
2
  import { useSyncExternalStore } from 'react';
3
- import { addServerPeerMutationOptions, attachmentUrlQueryOptions, connectSyncServersMutationOptions, createBlobMutationOptions, createProjectMutationOptions, disconnectSyncServersMutationOptions, documentCreatedByQueryOptions, iconUrlQueryOptions, importProjectConfigMutationOptions, leaveProjectMutationOptions, projectByIdQueryOptions, projectMemberByIdQueryOptions, projectMembersQueryOptions, projectOwnRoleQueryOptions, projectSettingsQueryOptions, projectsQueryOptions, removeServerPeerMutationOptions, setAutostopDataSyncTimeoutMutationOptions, startSyncMutationOptions, stopSyncMutationOptions, updateProjectSettingsMutationOptions, } from '../lib/react-query/projects.js';
3
+ import { addServerPeerMutationOptions, attachmentUrlQueryOptions, connectSyncServersMutationOptions, createBlobMutationOptions, createProjectMutationOptions, disconnectSyncServersMutationOptions, documentCreatedByQueryOptions, exportGeoJSONMutationOptions, exportZipFileMutationOptions, iconUrlQueryOptions, importProjectConfigMutationOptions, leaveProjectMutationOptions, projectByIdQueryOptions, projectMemberByIdQueryOptions, projectMembersQueryOptions, projectOwnRoleQueryOptions, projectSettingsQueryOptions, projectsQueryOptions, removeServerPeerMutationOptions, setAutostopDataSyncTimeoutMutationOptions, startSyncMutationOptions, stopSyncMutationOptions, updateProjectSettingsMutationOptions, } from '../lib/react-query/projects.js';
4
4
  import { SyncStore } from '../lib/sync.js';
5
5
  import { useClientApi } from './client.js';
6
6
  /**
@@ -425,3 +425,27 @@ export function useSetAutostopDataSyncTimeout({ projectId, }) {
425
425
  ? { error, mutate, mutateAsync, reset, status }
426
426
  : { error: null, mutate, mutateAsync, reset, status };
427
427
  }
428
+ /**
429
+ * Creates a GeoJson file with all the observations and/or tracks in the project.
430
+ *
431
+ * @param opts.projectId Public ID of the project to apply changes to.
432
+ */
433
+ export function useExportGeoJSON({ projectId }) {
434
+ const { data: projectApi } = useSingleProject({ projectId });
435
+ const { error, mutate, mutateAsync, reset, status } = useMutation(exportGeoJSONMutationOptions({ projectApi }));
436
+ return status === 'error'
437
+ ? { error, mutate, mutateAsync, reset, status }
438
+ : { error: null, mutate, mutateAsync, reset, status };
439
+ }
440
+ /**
441
+ * Creates a zip file containing a GeoJson file with all the observations and/or tracks in the project and all associated attachments (photos and audio).
442
+ *
443
+ * @param opts.projectId Public ID of the project to apply changes to.
444
+ */
445
+ export function useExportZipFile({ projectId }) {
446
+ const { data: projectApi } = useSingleProject({ projectId });
447
+ const { error, mutate, mutateAsync, reset, status } = useMutation(exportZipFileMutationOptions({ projectApi }));
448
+ return status === 'error'
449
+ ? { error, mutate, mutateAsync, reset, status }
450
+ : { error: null, mutate, mutateAsync, reset, status };
451
+ }
@@ -3,6 +3,6 @@ export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevi
3
3
  export { useCreateDocument, useDeleteDocument, useManyDocs, 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, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
6
+ export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, 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, 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, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, } from './hooks/projects.js';
6
+ export { useAddServerPeer, useAttachmentUrl, useConnectSyncServers, useCreateBlob, useCreateProject, useDataSyncProgress, useDisconnectSyncServers, useDocumentCreatedBy, useIconUrl, useImportProjectConfig, useLeaveProject, useManyMembers, useManyProjects, useOwnRoleInProject, useProjectSettings, useRemoveServerPeer, useSetAutostopDataSyncTimeout, useSingleMember, useSingleProject, useStartSync, useStopSync, useSyncState, useUpdateProjectSettings, useExportGeoJSON, useExportZipFile, } from './hooks/projects.js';
@@ -59,12 +59,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
59
59
  schemaName: "observation";
60
60
  lat?: number | undefined;
61
61
  lon?: number | undefined;
62
- attachments: {
63
- driveDiscoveryId: string;
64
- name: string;
65
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
66
- hash: string;
67
- }[];
62
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
68
63
  tags: {
69
64
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
70
65
  };
@@ -182,12 +177,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
182
177
  schemaName: "observation";
183
178
  lat?: number | undefined;
184
179
  lon?: number | undefined;
185
- attachments: {
186
- driveDiscoveryId: string;
187
- name: string;
188
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
189
- hash: string;
190
- }[];
180
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
191
181
  tags: {
192
182
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
193
183
  };
@@ -309,12 +299,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
309
299
  schemaName: "observation";
310
300
  lat?: number | undefined;
311
301
  lon?: number | undefined;
312
- attachments: {
313
- driveDiscoveryId: string;
314
- name: string;
315
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
316
- hash: string;
317
- }[];
302
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
318
303
  tags: {
319
304
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
320
305
  };
@@ -441,12 +426,7 @@ export declare function documentsQueryOptions<D extends WriteableDocumentType>({
441
426
  schemaName: "observation";
442
427
  lat?: number | undefined;
443
428
  lon?: number | undefined;
444
- attachments: {
445
- driveDiscoveryId: string;
446
- name: string;
447
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
448
- hash: string;
449
- }[];
429
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
450
430
  tags: {
451
431
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
452
432
  };
@@ -574,12 +554,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
574
554
  schemaName: "observation";
575
555
  lat?: number | undefined;
576
556
  lon?: number | undefined;
577
- attachments: {
578
- driveDiscoveryId: string;
579
- name: string;
580
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
581
- hash: string;
582
- }[];
557
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
583
558
  tags: {
584
559
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
585
560
  };
@@ -697,12 +672,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
697
672
  schemaName: "observation";
698
673
  lat?: number | undefined;
699
674
  lon?: number | undefined;
700
- attachments: {
701
- driveDiscoveryId: string;
702
- name: string;
703
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
704
- hash: string;
705
- }[];
675
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
706
676
  tags: {
707
677
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
708
678
  };
@@ -823,12 +793,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
823
793
  schemaName: "observation";
824
794
  lat?: number | undefined;
825
795
  lon?: number | undefined;
826
- attachments: {
827
- driveDiscoveryId: string;
828
- name: string;
829
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
830
- hash: string;
831
- }[];
796
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
832
797
  tags: {
833
798
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
834
799
  };
@@ -953,12 +918,7 @@ export declare function documentByDocumentIdQueryOptions<D extends WriteableDocu
953
918
  schemaName: "observation";
954
919
  lat?: number | undefined;
955
920
  lon?: number | undefined;
956
- attachments: {
957
- driveDiscoveryId: string;
958
- name: string;
959
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
960
- hash: string;
961
- }[];
921
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
962
922
  tags: {
963
923
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
964
924
  };
@@ -1084,12 +1044,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1084
1044
  schemaName: "observation";
1085
1045
  lat?: number | undefined;
1086
1046
  lon?: number | undefined;
1087
- attachments: {
1088
- driveDiscoveryId: string;
1089
- name: string;
1090
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1091
- hash: string;
1092
- }[];
1047
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1093
1048
  tags: {
1094
1049
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1095
1050
  };
@@ -1197,12 +1152,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1197
1152
  schemaName: "observation";
1198
1153
  lat?: number | undefined;
1199
1154
  lon?: number | undefined;
1200
- attachments: {
1201
- driveDiscoveryId: string;
1202
- name: string;
1203
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1204
- hash: string;
1205
- }[];
1155
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1206
1156
  tags: {
1207
1157
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1208
1158
  };
@@ -1313,12 +1263,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1313
1263
  schemaName: "observation";
1314
1264
  lat?: number | undefined;
1315
1265
  lon?: number | undefined;
1316
- attachments: {
1317
- driveDiscoveryId: string;
1318
- name: string;
1319
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1320
- hash: string;
1321
- }[];
1266
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1322
1267
  tags: {
1323
1268
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1324
1269
  };
@@ -1433,12 +1378,7 @@ export declare function documentByVersionIdQueryOptions<D extends WriteableDocum
1433
1378
  schemaName: "observation";
1434
1379
  lat?: number | undefined;
1435
1380
  lon?: number | undefined;
1436
- attachments: {
1437
- driveDiscoveryId: string;
1438
- name: string;
1439
- type: "attachment_type_unspecified" | "photo" | "video" | "audio" | "UNRECOGNIZED";
1440
- hash: string;
1441
- }[];
1381
+ attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
1442
1382
  tags: {
1443
1383
  [k: string]: boolean | number | string | null | (boolean | number | string | null)[];
1444
1384
  };
@@ -384,3 +384,32 @@ export declare function setAutostopDataSyncTimeoutMutationOptions({ projectApi,
384
384
  networkMode: "always";
385
385
  retry: false;
386
386
  };
387
+ export declare function exportGeoJSONMutationOptions({ projectApi, }: {
388
+ projectApi: MapeoProjectApi;
389
+ }): {
390
+ mutationFn: (opts: {
391
+ path: string;
392
+ exportOptions: {
393
+ observations?: boolean;
394
+ tracks?: boolean;
395
+ lang?: string;
396
+ };
397
+ }) => Promise<string>;
398
+ networkMode: "always";
399
+ retry: false;
400
+ };
401
+ export declare function exportZipFileMutationOptions({ projectApi, }: {
402
+ projectApi: MapeoProjectApi;
403
+ }): {
404
+ mutationFn: (opts: {
405
+ path: string;
406
+ exportOptions: {
407
+ observations?: boolean;
408
+ tracks?: boolean;
409
+ lang?: string;
410
+ attachments?: boolean;
411
+ };
412
+ }) => Promise<string>;
413
+ networkMode: "always";
414
+ retry: false;
415
+ };
@@ -264,3 +264,19 @@ export function setAutostopDataSyncTimeoutMutationOptions({ projectApi, }) {
264
264
  },
265
265
  };
266
266
  }
267
+ export function exportGeoJSONMutationOptions({ projectApi, }) {
268
+ return {
269
+ ...baseMutationOptions(),
270
+ mutationFn: async (opts) => {
271
+ return projectApi.exportGeoJSONFile(opts.path, opts.exportOptions);
272
+ },
273
+ };
274
+ }
275
+ export function exportZipFileMutationOptions({ projectApi, }) {
276
+ return {
277
+ ...baseMutationOptions(),
278
+ mutationFn: async (opts) => {
279
+ return projectApi.exportZipFile(opts.path, opts.exportOptions);
280
+ },
281
+ };
282
+ }
package/docs/API.md CHANGED
@@ -29,6 +29,8 @@
29
29
  - [useConnectSyncServers](#useconnectsyncservers)
30
30
  - [useDisconnectSyncServers](#usedisconnectsyncservers)
31
31
  - [useSetAutostopDataSyncTimeout](#usesetautostopdatasynctimeout)
32
+ - [useExportGeoJSON](#useexportgeojson)
33
+ - [useExportZipFile](#useexportzipfile)
32
34
  - [useSingleDocByDocId](#usesingledocbydocid)
33
35
  - [useSingleDocByVersionId](#usesingledocbyversionid)
34
36
  - [useManyDocs](#usemanydocs)
@@ -547,6 +549,32 @@ Provides the progress of data sync for sync-enabled connected peers
547
549
  | ---------- | ---------- |
548
550
  | `useSetAutostopDataSyncTimeout` | `({ projectId, }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<void, Error, { after: number or null; }, unknown>; mutateAsync: UseMutateAsyncFunction<void, Error, { ...; }, unknown>; reset: () => void; status: "error"; } or { ...; }` |
549
551
 
552
+ ### useExportGeoJSON
553
+
554
+ Creates a GeoJson file with all the observations and/or tracks in the project.
555
+
556
+ | Function | Type |
557
+ | ---------- | ---------- |
558
+ | `useExportGeoJSON` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<string, Error, { path: string; exportOptions: { observations?: boolean or undefined; tracks?: boolean or undefined; lang?: string or undefined; }; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>; reset: () => void; status: "error...` |
559
+
560
+ Parameters:
561
+
562
+ * `opts.projectId`: Public ID of the project to apply changes to.
563
+
564
+
565
+ ### useExportZipFile
566
+
567
+ Creates a zip file containing a GeoJson file with all the observations and/or tracks in the project and all associated attachments (photos and audio).
568
+
569
+ | Function | Type |
570
+ | ---------- | ---------- |
571
+ | `useExportZipFile` | `({ projectId }: { projectId: string; }) => { error: Error; mutate: UseMutateFunction<string, Error, { path: string; exportOptions: { observations?: boolean or undefined; tracks?: boolean or undefined; lang?: string or undefined; attachments?: boolean or undefined; }; }, unknown>; mutateAsync: UseMutateAsyncFunction<...>...` |
572
+
573
+ Parameters:
574
+
575
+ * `opts.projectId`: Public ID of the project to apply changes to.
576
+
577
+
550
578
  ### useSingleDocByDocId
551
579
 
552
580
  Retrieve a single document from the database based on the document's document ID.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comapeo/core-react",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "React wrapper for working with @comapeo/core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,33 +57,33 @@
57
57
  "types": "tsc"
58
58
  },
59
59
  "peerDependencies": {
60
- "@comapeo/core": "^3.1.0",
60
+ "@comapeo/core": "^3.2.0",
61
61
  "@comapeo/ipc": "^3.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": "3.1.1",
67
+ "@comapeo/core": "3.2.0",
68
68
  "@comapeo/ipc": "3.0.0",
69
- "@comapeo/schema": "1.5.0",
69
+ "@comapeo/schema": "1.6.0",
70
70
  "@eslint/compat": "1.2.9",
71
- "@eslint/js": "9.26.0",
71
+ "@eslint/js": "9.27.0",
72
72
  "@ianvs/prettier-plugin-sort-imports": "4.4.1",
73
73
  "@mapeo/crypto": "1.0.0-alpha.10",
74
74
  "@tanstack/eslint-plugin-query": "5.74.7",
75
- "@tanstack/react-query": "5.75.2",
75
+ "@tanstack/react-query": "5.76.1",
76
76
  "@testing-library/dom": "10.4.0",
77
77
  "@testing-library/react": "16.3.0",
78
- "@types/node": "22.15.3",
78
+ "@types/node": "22.15.19",
79
79
  "@types/react": "19.0.12",
80
80
  "@types/react-dom": "19.0.4",
81
- "@vitest/eslint-plugin": "1.1.44",
82
- "eslint": "9.26.0",
81
+ "@vitest/eslint-plugin": "1.2.0",
82
+ "eslint": "9.27.0",
83
83
  "eslint-plugin-react-hooks": "5.2.0",
84
- "eslint-plugin-testing-library": "7.1.1",
85
- "fastify": "4.29.0",
86
- "globals": "16.0.0",
84
+ "eslint-plugin-testing-library": "7.2.1",
85
+ "fastify": "4.29.1",
86
+ "globals": "16.1.0",
87
87
  "husky": "9.1.7",
88
88
  "lint-staged": "15.5.1",
89
89
  "npm-run-all2": "7.0.2",
@@ -94,7 +94,7 @@
94
94
  "tsdoc-markdown": "1.2.0",
95
95
  "tshy": "3.0.2",
96
96
  "typescript": "5.8.3",
97
- "typescript-eslint": "8.31.1",
98
- "vitest": "3.1.3"
97
+ "typescript-eslint": "8.32.1",
98
+ "vitest": "3.1.4"
99
99
  }
100
100
  }