@comapeo/core-react 6.3.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/hooks/documents.d.ts +143 -108
- package/dist/commonjs/hooks/documents.js +50 -0
- package/dist/commonjs/hooks/projects.d.ts +29 -0
- package/dist/commonjs/hooks/projects.js +19 -0
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.js +3 -1
- package/dist/commonjs/lib/presets.d.ts +2 -0
- package/dist/commonjs/lib/presets.js +25 -0
- package/dist/commonjs/lib/react-query/documents.d.ts +439 -439
- package/dist/commonjs/lib/react-query/projects.d.ts +12 -0
- package/dist/commonjs/lib/react-query/projects.js +14 -0
- package/dist/esm/hooks/documents.d.ts +143 -108
- package/dist/esm/hooks/documents.js +50 -1
- package/dist/esm/hooks/projects.d.ts +29 -0
- package/dist/esm/hooks/projects.js +19 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/presets.d.ts +2 -0
- package/dist/esm/lib/presets.js +22 -0
- package/dist/esm/lib/react-query/documents.d.ts +439 -439
- package/dist/esm/lib/react-query/projects.d.ts +12 -0
- package/dist/esm/lib/react-query/projects.js +13 -0
- package/package.json +7 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Preset } from '@comapeo/schema' with { 'resolution-mode': 'import' };
|
|
1
2
|
import type { WriteableDocumentType } from '../lib/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Retrieve a single document from the database based on the document's document ID.
|
|
@@ -50,28 +51,14 @@ export declare function useSingleDocByDocId<D extends WriteableDocumentType>({ p
|
|
|
50
51
|
links: string[];
|
|
51
52
|
deleted: boolean;
|
|
52
53
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
53
|
-
schemaName: "
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
schemaName: "remoteDetectionAlert";
|
|
55
|
+
detectionDateStart: string;
|
|
56
|
+
detectionDateEnd: string;
|
|
57
|
+
sourceId: string;
|
|
58
|
+
metadata: {
|
|
58
59
|
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
59
60
|
};
|
|
60
|
-
|
|
61
|
-
manualLocation?: boolean;
|
|
62
|
-
position?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
63
|
-
lastSavedPosition?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
64
|
-
positionProvider?: {
|
|
65
|
-
gpsAvailable?: boolean;
|
|
66
|
-
passiveAvailable?: boolean;
|
|
67
|
-
locationServicesEnabled: boolean;
|
|
68
|
-
networkAvailable?: boolean;
|
|
69
|
-
};
|
|
70
|
-
} | undefined;
|
|
71
|
-
presetRef?: {
|
|
72
|
-
docId: string;
|
|
73
|
-
versionId: string;
|
|
74
|
-
} | undefined;
|
|
61
|
+
geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert.js").Geometry;
|
|
75
62
|
docId: string;
|
|
76
63
|
versionId: string;
|
|
77
64
|
originalVersionId: string;
|
|
@@ -103,6 +90,36 @@ export declare function useSingleDocByDocId<D extends WriteableDocumentType>({ p
|
|
|
103
90
|
updatedAt: string;
|
|
104
91
|
links: string[];
|
|
105
92
|
deleted: boolean;
|
|
93
|
+
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
94
|
+
schemaName: "observation";
|
|
95
|
+
lat?: number | undefined;
|
|
96
|
+
lon?: number | undefined;
|
|
97
|
+
attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
|
|
98
|
+
tags: {
|
|
99
|
+
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
100
|
+
};
|
|
101
|
+
metadata?: {
|
|
102
|
+
manualLocation?: boolean;
|
|
103
|
+
position?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
104
|
+
lastSavedPosition?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
105
|
+
positionProvider?: {
|
|
106
|
+
gpsAvailable?: boolean;
|
|
107
|
+
passiveAvailable?: boolean;
|
|
108
|
+
locationServicesEnabled: boolean;
|
|
109
|
+
networkAvailable?: boolean;
|
|
110
|
+
};
|
|
111
|
+
} | undefined;
|
|
112
|
+
presetRef?: {
|
|
113
|
+
docId: string;
|
|
114
|
+
versionId: string;
|
|
115
|
+
} | undefined;
|
|
116
|
+
docId: string;
|
|
117
|
+
versionId: string;
|
|
118
|
+
originalVersionId: string;
|
|
119
|
+
createdAt: string;
|
|
120
|
+
updatedAt: string;
|
|
121
|
+
links: string[];
|
|
122
|
+
deleted: boolean;
|
|
106
123
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
107
124
|
schemaName: "field";
|
|
108
125
|
tagKey: string;
|
|
@@ -124,22 +141,6 @@ export declare function useSingleDocByDocId<D extends WriteableDocumentType>({ p
|
|
|
124
141
|
updatedAt: string;
|
|
125
142
|
links: string[];
|
|
126
143
|
deleted: boolean;
|
|
127
|
-
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
128
|
-
schemaName: "remoteDetectionAlert";
|
|
129
|
-
detectionDateStart: string;
|
|
130
|
-
detectionDateEnd: string;
|
|
131
|
-
sourceId: string;
|
|
132
|
-
metadata: {
|
|
133
|
-
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
134
|
-
};
|
|
135
|
-
geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert.js").Geometry;
|
|
136
|
-
docId: string;
|
|
137
|
-
versionId: string;
|
|
138
|
-
originalVersionId: string;
|
|
139
|
-
createdAt: string;
|
|
140
|
-
updatedAt: string;
|
|
141
|
-
links: string[];
|
|
142
|
-
deleted: boolean;
|
|
143
144
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields), {
|
|
144
145
|
schemaName: D;
|
|
145
146
|
}>;
|
|
@@ -197,28 +198,14 @@ export declare function useSingleDocByVersionId<D extends WriteableDocumentType>
|
|
|
197
198
|
links: string[];
|
|
198
199
|
deleted: boolean;
|
|
199
200
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
200
|
-
schemaName: "
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
schemaName: "remoteDetectionAlert";
|
|
202
|
+
detectionDateStart: string;
|
|
203
|
+
detectionDateEnd: string;
|
|
204
|
+
sourceId: string;
|
|
205
|
+
metadata: {
|
|
205
206
|
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
206
207
|
};
|
|
207
|
-
|
|
208
|
-
manualLocation?: boolean;
|
|
209
|
-
position?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
210
|
-
lastSavedPosition?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
211
|
-
positionProvider?: {
|
|
212
|
-
gpsAvailable?: boolean;
|
|
213
|
-
passiveAvailable?: boolean;
|
|
214
|
-
locationServicesEnabled: boolean;
|
|
215
|
-
networkAvailable?: boolean;
|
|
216
|
-
};
|
|
217
|
-
} | undefined;
|
|
218
|
-
presetRef?: {
|
|
219
|
-
docId: string;
|
|
220
|
-
versionId: string;
|
|
221
|
-
} | undefined;
|
|
208
|
+
geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert.js").Geometry;
|
|
222
209
|
docId: string;
|
|
223
210
|
versionId: string;
|
|
224
211
|
originalVersionId: string;
|
|
@@ -250,6 +237,36 @@ export declare function useSingleDocByVersionId<D extends WriteableDocumentType>
|
|
|
250
237
|
updatedAt: string;
|
|
251
238
|
links: string[];
|
|
252
239
|
deleted: boolean;
|
|
240
|
+
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
241
|
+
schemaName: "observation";
|
|
242
|
+
lat?: number | undefined;
|
|
243
|
+
lon?: number | undefined;
|
|
244
|
+
attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
|
|
245
|
+
tags: {
|
|
246
|
+
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
247
|
+
};
|
|
248
|
+
metadata?: {
|
|
249
|
+
manualLocation?: boolean;
|
|
250
|
+
position?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
251
|
+
lastSavedPosition?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
252
|
+
positionProvider?: {
|
|
253
|
+
gpsAvailable?: boolean;
|
|
254
|
+
passiveAvailable?: boolean;
|
|
255
|
+
locationServicesEnabled: boolean;
|
|
256
|
+
networkAvailable?: boolean;
|
|
257
|
+
};
|
|
258
|
+
} | undefined;
|
|
259
|
+
presetRef?: {
|
|
260
|
+
docId: string;
|
|
261
|
+
versionId: string;
|
|
262
|
+
} | undefined;
|
|
263
|
+
docId: string;
|
|
264
|
+
versionId: string;
|
|
265
|
+
originalVersionId: string;
|
|
266
|
+
createdAt: string;
|
|
267
|
+
updatedAt: string;
|
|
268
|
+
links: string[];
|
|
269
|
+
deleted: boolean;
|
|
253
270
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
254
271
|
schemaName: "field";
|
|
255
272
|
tagKey: string;
|
|
@@ -271,22 +288,6 @@ export declare function useSingleDocByVersionId<D extends WriteableDocumentType>
|
|
|
271
288
|
updatedAt: string;
|
|
272
289
|
links: string[];
|
|
273
290
|
deleted: boolean;
|
|
274
|
-
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields) | ({
|
|
275
|
-
schemaName: "remoteDetectionAlert";
|
|
276
|
-
detectionDateStart: string;
|
|
277
|
-
detectionDateEnd: string;
|
|
278
|
-
sourceId: string;
|
|
279
|
-
metadata: {
|
|
280
|
-
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
281
|
-
};
|
|
282
|
-
geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert.js").Geometry;
|
|
283
|
-
docId: string;
|
|
284
|
-
versionId: string;
|
|
285
|
-
originalVersionId: string;
|
|
286
|
-
createdAt: string;
|
|
287
|
-
updatedAt: string;
|
|
288
|
-
links: string[];
|
|
289
|
-
deleted: boolean;
|
|
290
291
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields), {
|
|
291
292
|
schemaName: D;
|
|
292
293
|
}>;
|
|
@@ -355,28 +356,14 @@ export declare function useManyDocs<D extends WriteableDocumentType>({ projectId
|
|
|
355
356
|
links: string[];
|
|
356
357
|
deleted: boolean;
|
|
357
358
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields)[] | ({
|
|
358
|
-
schemaName: "
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
359
|
+
schemaName: "remoteDetectionAlert";
|
|
360
|
+
detectionDateStart: string;
|
|
361
|
+
detectionDateEnd: string;
|
|
362
|
+
sourceId: string;
|
|
363
|
+
metadata: {
|
|
363
364
|
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
364
365
|
};
|
|
365
|
-
|
|
366
|
-
manualLocation?: boolean;
|
|
367
|
-
position?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
368
|
-
lastSavedPosition?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
369
|
-
positionProvider?: {
|
|
370
|
-
gpsAvailable?: boolean;
|
|
371
|
-
passiveAvailable?: boolean;
|
|
372
|
-
locationServicesEnabled: boolean;
|
|
373
|
-
networkAvailable?: boolean;
|
|
374
|
-
};
|
|
375
|
-
} | undefined;
|
|
376
|
-
presetRef?: {
|
|
377
|
-
docId: string;
|
|
378
|
-
versionId: string;
|
|
379
|
-
} | undefined;
|
|
366
|
+
geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert.js").Geometry;
|
|
380
367
|
docId: string;
|
|
381
368
|
versionId: string;
|
|
382
369
|
originalVersionId: string;
|
|
@@ -408,6 +395,36 @@ export declare function useManyDocs<D extends WriteableDocumentType>({ projectId
|
|
|
408
395
|
updatedAt: string;
|
|
409
396
|
links: string[];
|
|
410
397
|
deleted: boolean;
|
|
398
|
+
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields)[] | ({
|
|
399
|
+
schemaName: "observation";
|
|
400
|
+
lat?: number | undefined;
|
|
401
|
+
lon?: number | undefined;
|
|
402
|
+
attachments: import("@comapeo/schema/dist/schema/observation.js").Attachment[];
|
|
403
|
+
tags: {
|
|
404
|
+
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
405
|
+
};
|
|
406
|
+
metadata?: {
|
|
407
|
+
manualLocation?: boolean;
|
|
408
|
+
position?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
409
|
+
lastSavedPosition?: import("@comapeo/schema/dist/schema/observation.js").Position;
|
|
410
|
+
positionProvider?: {
|
|
411
|
+
gpsAvailable?: boolean;
|
|
412
|
+
passiveAvailable?: boolean;
|
|
413
|
+
locationServicesEnabled: boolean;
|
|
414
|
+
networkAvailable?: boolean;
|
|
415
|
+
};
|
|
416
|
+
} | undefined;
|
|
417
|
+
presetRef?: {
|
|
418
|
+
docId: string;
|
|
419
|
+
versionId: string;
|
|
420
|
+
} | undefined;
|
|
421
|
+
docId: string;
|
|
422
|
+
versionId: string;
|
|
423
|
+
originalVersionId: string;
|
|
424
|
+
createdAt: string;
|
|
425
|
+
updatedAt: string;
|
|
426
|
+
links: string[];
|
|
427
|
+
deleted: boolean;
|
|
411
428
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields)[] | ({
|
|
412
429
|
schemaName: "field";
|
|
413
430
|
tagKey: string;
|
|
@@ -429,22 +446,6 @@ export declare function useManyDocs<D extends WriteableDocumentType>({ projectId
|
|
|
429
446
|
updatedAt: string;
|
|
430
447
|
links: string[];
|
|
431
448
|
deleted: boolean;
|
|
432
|
-
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields)[] | ({
|
|
433
|
-
schemaName: "remoteDetectionAlert";
|
|
434
|
-
detectionDateStart: string;
|
|
435
|
-
detectionDateEnd: string;
|
|
436
|
-
sourceId: string;
|
|
437
|
-
metadata: {
|
|
438
|
-
[k: string]: boolean | number | string | null | (boolean | number | string | null)[];
|
|
439
|
-
};
|
|
440
|
-
geometry: import("@comapeo/schema/dist/schema/remoteDetectionAlert.js").Geometry;
|
|
441
|
-
docId: string;
|
|
442
|
-
versionId: string;
|
|
443
|
-
originalVersionId: string;
|
|
444
|
-
createdAt: string;
|
|
445
|
-
updatedAt: string;
|
|
446
|
-
links: string[];
|
|
447
|
-
deleted: boolean;
|
|
448
449
|
} & import("@comapeo/core/dist/datatype/index.js", { with: { "resolution-mode": "import" } }).DerivedDocFields)[], Array<{
|
|
449
450
|
schemaName: D;
|
|
450
451
|
}>>;
|
|
@@ -545,3 +546,37 @@ export declare function useDeleteDocument<D extends WriteableDocumentType>({ doc
|
|
|
545
546
|
reset: () => void;
|
|
546
547
|
status: "pending" | "success" | "idle";
|
|
547
548
|
};
|
|
549
|
+
/**
|
|
550
|
+
* Retrieve presets for category selection, ordered by project settings.
|
|
551
|
+
*
|
|
552
|
+
* Returns presets in the order defined by `projectSettings.defaultPresets` for the
|
|
553
|
+
* specified data type. Falls back to alphabetical order (by preset name) if no defaults are configured.
|
|
554
|
+
*
|
|
555
|
+
* @param opts.projectId Project public ID
|
|
556
|
+
* @param opts.dataType Type of data being created ('observation' or 'track')
|
|
557
|
+
* @param opts.lang Language to translate presets into
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* ```tsx
|
|
561
|
+
* function ObservationCategoryChooser() {
|
|
562
|
+
* const presets = usePresetsSelection({
|
|
563
|
+
* projectId: '...',
|
|
564
|
+
* dataType: 'observation',
|
|
565
|
+
* })
|
|
566
|
+
* }
|
|
567
|
+
* ```
|
|
568
|
+
*
|
|
569
|
+
* ```tsx
|
|
570
|
+
* function TrackCategoryChooser() {
|
|
571
|
+
* const presets = usePresetsSelection({
|
|
572
|
+
* projectId: '...',
|
|
573
|
+
* dataType: 'track',
|
|
574
|
+
* })
|
|
575
|
+
* }
|
|
576
|
+
* ```
|
|
577
|
+
*/
|
|
578
|
+
export declare function usePresetsSelection({ projectId, dataType, lang, }: {
|
|
579
|
+
projectId: string;
|
|
580
|
+
dataType: 'observation' | 'track';
|
|
581
|
+
lang?: string;
|
|
582
|
+
}): Array<Preset>;
|
|
@@ -6,7 +6,10 @@ exports.useManyDocs = useManyDocs;
|
|
|
6
6
|
exports.useCreateDocument = useCreateDocument;
|
|
7
7
|
exports.useUpdateDocument = useUpdateDocument;
|
|
8
8
|
exports.useDeleteDocument = useDeleteDocument;
|
|
9
|
+
exports.usePresetsSelection = usePresetsSelection;
|
|
9
10
|
const react_query_1 = require("@tanstack/react-query");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const presets_js_1 = require("../lib/presets.js");
|
|
10
13
|
const documents_js_1 = require("../lib/react-query/documents.js");
|
|
11
14
|
const projects_js_1 = require("./projects.js");
|
|
12
15
|
/**
|
|
@@ -191,3 +194,50 @@ function useDeleteDocument({ docType, projectId, }) {
|
|
|
191
194
|
? { error, mutate, mutateAsync, reset, status }
|
|
192
195
|
: { error: null, mutate, mutateAsync, reset, status };
|
|
193
196
|
}
|
|
197
|
+
const dataTypeToGeometry = {
|
|
198
|
+
observation: 'point',
|
|
199
|
+
track: 'line',
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Retrieve presets for category selection, ordered by project settings.
|
|
203
|
+
*
|
|
204
|
+
* Returns presets in the order defined by `projectSettings.defaultPresets` for the
|
|
205
|
+
* specified data type. Falls back to alphabetical order (by preset name) if no defaults are configured.
|
|
206
|
+
*
|
|
207
|
+
* @param opts.projectId Project public ID
|
|
208
|
+
* @param opts.dataType Type of data being created ('observation' or 'track')
|
|
209
|
+
* @param opts.lang Language to translate presets into
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* function ObservationCategoryChooser() {
|
|
214
|
+
* const presets = usePresetsSelection({
|
|
215
|
+
* projectId: '...',
|
|
216
|
+
* dataType: 'observation',
|
|
217
|
+
* })
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* ```tsx
|
|
222
|
+
* function TrackCategoryChooser() {
|
|
223
|
+
* const presets = usePresetsSelection({
|
|
224
|
+
* projectId: '...',
|
|
225
|
+
* dataType: 'track',
|
|
226
|
+
* })
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
function usePresetsSelection({ projectId, dataType, lang, }) {
|
|
231
|
+
const { data: projectSettings } = (0, projects_js_1.useProjectSettings)({ projectId });
|
|
232
|
+
const { data: presets } = useManyDocs({
|
|
233
|
+
projectId,
|
|
234
|
+
docType: 'preset',
|
|
235
|
+
lang,
|
|
236
|
+
});
|
|
237
|
+
const presetsSelection = (0, react_1.useMemo)(() => {
|
|
238
|
+
const geometry = dataTypeToGeometry[dataType];
|
|
239
|
+
const defaults = projectSettings.defaultPresets?.[geometry];
|
|
240
|
+
return (0, presets_js_1.getPresetsSelection)(presets, defaults);
|
|
241
|
+
}, [presets, projectSettings.defaultPresets, dataType]);
|
|
242
|
+
return presetsSelection;
|
|
243
|
+
}
|
|
@@ -360,9 +360,38 @@ export declare function useLeaveProject(): {
|
|
|
360
360
|
reset: () => void;
|
|
361
361
|
status: "pending" | "success" | "idle";
|
|
362
362
|
};
|
|
363
|
+
/**
|
|
364
|
+
* Update the categories of a project using an external file.
|
|
365
|
+
*
|
|
366
|
+
* @param opts.projectId Public ID of the project to apply changes to.
|
|
367
|
+
*/
|
|
368
|
+
export declare function useImportProjectCategories({ projectId, }: {
|
|
369
|
+
projectId: string;
|
|
370
|
+
}): {
|
|
371
|
+
error: Error;
|
|
372
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
373
|
+
filePath: string;
|
|
374
|
+
}, unknown>;
|
|
375
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
376
|
+
filePath: string;
|
|
377
|
+
}, unknown>;
|
|
378
|
+
reset: () => void;
|
|
379
|
+
status: "error";
|
|
380
|
+
} | {
|
|
381
|
+
error: null;
|
|
382
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<void, Error, {
|
|
383
|
+
filePath: string;
|
|
384
|
+
}, unknown>;
|
|
385
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<void, Error, {
|
|
386
|
+
filePath: string;
|
|
387
|
+
}, unknown>;
|
|
388
|
+
reset: () => void;
|
|
389
|
+
status: "pending" | "success" | "idle";
|
|
390
|
+
};
|
|
363
391
|
/**
|
|
364
392
|
* Update the configuration of a project using an external file.
|
|
365
393
|
*
|
|
394
|
+
* @deprecated Use `useImportProjectCategories` instead.
|
|
366
395
|
* @param opts.projectId Public ID of the project to apply changes to.
|
|
367
396
|
*/
|
|
368
397
|
export declare function useImportProjectConfig({ projectId }: {
|
|
@@ -13,6 +13,7 @@ exports.useAddServerPeer = useAddServerPeer;
|
|
|
13
13
|
exports.useRemoveServerPeer = useRemoveServerPeer;
|
|
14
14
|
exports.useCreateProject = useCreateProject;
|
|
15
15
|
exports.useLeaveProject = useLeaveProject;
|
|
16
|
+
exports.useImportProjectCategories = useImportProjectCategories;
|
|
16
17
|
exports.useImportProjectConfig = useImportProjectConfig;
|
|
17
18
|
exports.useUpdateProjectSettings = useUpdateProjectSettings;
|
|
18
19
|
exports.useChangeMemberRole = useChangeMemberRole;
|
|
@@ -345,9 +346,27 @@ function useLeaveProject() {
|
|
|
345
346
|
? { error, mutate, mutateAsync, reset, status }
|
|
346
347
|
: { error: null, mutate, mutateAsync, reset, status };
|
|
347
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Update the categories of a project using an external file.
|
|
351
|
+
*
|
|
352
|
+
* @param opts.projectId Public ID of the project to apply changes to.
|
|
353
|
+
*/
|
|
354
|
+
function useImportProjectCategories({ projectId, }) {
|
|
355
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
356
|
+
const { data: projectApi } = useSingleProject({ projectId });
|
|
357
|
+
const { error, mutate, mutateAsync, reset, status } = (0, react_query_1.useMutation)((0, projects_js_1.importProjectCategoriesMutationOptions)({
|
|
358
|
+
queryClient,
|
|
359
|
+
projectApi,
|
|
360
|
+
projectId,
|
|
361
|
+
}));
|
|
362
|
+
return status === 'error'
|
|
363
|
+
? { error, mutate, mutateAsync, reset, status }
|
|
364
|
+
: { error: null, mutate, mutateAsync, reset, status };
|
|
365
|
+
}
|
|
348
366
|
/**
|
|
349
367
|
* Update the configuration of a project using an external file.
|
|
350
368
|
*
|
|
369
|
+
* @deprecated Use `useImportProjectCategories` instead.
|
|
351
370
|
* @param opts.projectId Public ID of the project to apply changes to.
|
|
352
371
|
*/
|
|
353
372
|
function useImportProjectConfig({ projectId }) {
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ClientApiContext, ClientApiProvider } from './contexts/ClientApi.js';
|
|
2
2
|
export { useClientApi, useIsArchiveDevice, useOwnDeviceInfo, useSetIsArchiveDevice, useSetOwnDeviceInfo, } from './hooks/client.js';
|
|
3
|
-
export { useCreateDocument, useDeleteDocument, useManyDocs, useSingleDocByDocId, useSingleDocByVersionId, useUpdateDocument, } from './hooks/documents.js';
|
|
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, 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, useProjectSettings, useRemoveServerPeer, 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,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useExportZipFile = exports.useExportGeoJSON = exports.useChangeMemberRole = 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.useChangeMemberRole = 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.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
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; } });
|
|
@@ -14,6 +14,7 @@ var documents_js_1 = require("./hooks/documents.js");
|
|
|
14
14
|
Object.defineProperty(exports, "useCreateDocument", { enumerable: true, get: function () { return documents_js_1.useCreateDocument; } });
|
|
15
15
|
Object.defineProperty(exports, "useDeleteDocument", { enumerable: true, get: function () { return documents_js_1.useDeleteDocument; } });
|
|
16
16
|
Object.defineProperty(exports, "useManyDocs", { enumerable: true, get: function () { return documents_js_1.useManyDocs; } });
|
|
17
|
+
Object.defineProperty(exports, "usePresetsSelection", { enumerable: true, get: function () { return documents_js_1.usePresetsSelection; } });
|
|
17
18
|
Object.defineProperty(exports, "useSingleDocByDocId", { enumerable: true, get: function () { return documents_js_1.useSingleDocByDocId; } });
|
|
18
19
|
Object.defineProperty(exports, "useSingleDocByVersionId", { enumerable: true, get: function () { return documents_js_1.useSingleDocByVersionId; } });
|
|
19
20
|
Object.defineProperty(exports, "useUpdateDocument", { enumerable: true, get: function () { return documents_js_1.useUpdateDocument; } });
|
|
@@ -37,6 +38,7 @@ Object.defineProperty(exports, "useDataSyncProgress", { enumerable: true, get: f
|
|
|
37
38
|
Object.defineProperty(exports, "useDisconnectSyncServers", { enumerable: true, get: function () { return projects_js_1.useDisconnectSyncServers; } });
|
|
38
39
|
Object.defineProperty(exports, "useDocumentCreatedBy", { enumerable: true, get: function () { return projects_js_1.useDocumentCreatedBy; } });
|
|
39
40
|
Object.defineProperty(exports, "useIconUrl", { enumerable: true, get: function () { return projects_js_1.useIconUrl; } });
|
|
41
|
+
Object.defineProperty(exports, "useImportProjectCategories", { enumerable: true, get: function () { return projects_js_1.useImportProjectCategories; } });
|
|
40
42
|
Object.defineProperty(exports, "useImportProjectConfig", { enumerable: true, get: function () { return projects_js_1.useImportProjectConfig; } });
|
|
41
43
|
Object.defineProperty(exports, "useLeaveProject", { enumerable: true, get: function () { return projects_js_1.useLeaveProject; } });
|
|
42
44
|
Object.defineProperty(exports, "useManyMembers", { enumerable: true, get: function () { return projects_js_1.useManyMembers; } });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPresetsSelection = getPresetsSelection;
|
|
4
|
+
/**
|
|
5
|
+
* Internal helper to sort presets alphabetically by name (case-insensitive).
|
|
6
|
+
*/
|
|
7
|
+
function sortByName(presets) {
|
|
8
|
+
return [...presets].sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
|
9
|
+
}
|
|
10
|
+
function getPresetsSelection(presets, orderedPresetIds = []) {
|
|
11
|
+
if (orderedPresetIds.length === 0) {
|
|
12
|
+
return sortByName(presets);
|
|
13
|
+
}
|
|
14
|
+
const presetsSelection = [];
|
|
15
|
+
for (const presetId of orderedPresetIds) {
|
|
16
|
+
const preset = presets.find((p) => p.docId === presetId);
|
|
17
|
+
if (preset) {
|
|
18
|
+
presetsSelection.push(preset);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (presetsSelection.length === 0) {
|
|
22
|
+
return sortByName(presets);
|
|
23
|
+
}
|
|
24
|
+
return presetsSelection;
|
|
25
|
+
}
|