@sfxcode/nuxt-ui-mongocamp 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +6 -0
  4. package/dist/runtime/components/MongocampAggregationBuilder.vue +390 -0
  5. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +6 -0
  6. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +11 -1
  7. package/dist/runtime/components/MongocampBulkDelete.vue +1 -0
  8. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +11 -1
  9. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +29 -0
  10. package/dist/runtime/components/MongocampBulkEdit.vue +138 -0
  11. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +29 -0
  12. package/dist/runtime/components/MongocampCollectionData.vue +100 -1
  13. package/dist/runtime/components/MongocampCollectionInfos.vue +162 -0
  14. package/dist/runtime/components/MongocampFilterBuilder.d.vue.ts +1 -0
  15. package/dist/runtime/components/MongocampFilterBuilder.vue +33 -2
  16. package/dist/runtime/components/MongocampFilterBuilder.vue.d.ts +1 -0
  17. package/dist/runtime/components/MongocampImport.d.vue.ts +10 -0
  18. package/dist/runtime/components/MongocampImport.vue +479 -0
  19. package/dist/runtime/components/MongocampImport.vue.d.ts +10 -0
  20. package/dist/runtime/components/MongocampRoleGrants.vue +25 -0
  21. package/dist/runtime/components/MongocampRoles.vue +74 -0
  22. package/dist/runtime/composables/useMongocampAggregation.d.ts +28 -0
  23. package/dist/runtime/composables/useMongocampAggregation.js +99 -0
  24. package/dist/runtime/composables/useMongocampBulkDelete.d.ts +1 -1
  25. package/dist/runtime/composables/useMongocampImport.d.ts +14 -0
  26. package/dist/runtime/composables/useMongocampImport.js +25 -0
  27. package/dist/runtime/locales/de.json +147 -2
  28. package/dist/runtime/locales/en.json +147 -2
  29. package/dist/runtime/utils/aggregationErrors.d.ts +10 -0
  30. package/dist/runtime/utils/aggregationErrors.js +17 -0
  31. package/dist/runtime/utils/aggregationPipeline.d.ts +42 -0
  32. package/dist/runtime/utils/aggregationPipeline.js +118 -0
  33. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  34. package/dist/runtime/utils/aggregationResult.js +17 -0
  35. package/dist/runtime/utils/analyzeSamples.d.ts +27 -0
  36. package/dist/runtime/utils/analyzeSamples.js +92 -0
  37. package/dist/runtime/utils/batchInsert.d.ts +22 -0
  38. package/dist/runtime/utils/batchInsert.js +24 -0
  39. package/dist/runtime/utils/bulkDelete.d.ts +6 -1
  40. package/dist/runtime/utils/bulkDelete.js +28 -4
  41. package/dist/runtime/utils/bulkEdit.d.ts +27 -0
  42. package/dist/runtime/utils/bulkEdit.js +45 -0
  43. package/dist/runtime/utils/filterSuggestions.d.ts +8 -0
  44. package/dist/runtime/utils/filterSuggestions.js +15 -0
  45. package/dist/runtime/utils/importPipeline.d.ts +21 -0
  46. package/dist/runtime/utils/importPipeline.js +52 -0
  47. package/dist/runtime/utils/importRows.d.ts +36 -0
  48. package/dist/runtime/utils/importRows.js +228 -0
  49. package/dist/runtime/utils/objectId.d.ts +1 -0
  50. package/dist/runtime/utils/objectId.js +4 -0
  51. package/package.json +2 -2
@@ -0,0 +1,99 @@
1
+ import { useMongocampClientApi, useI18n } from "#imports";
2
+ import { useMongocampError } from "./useMongocampError.js";
3
+ import { findForbidden } from "../utils/aggregationPipeline.js";
4
+ import { ForbiddenPipelineError, parseServerError } from "../utils/aggregationErrors.js";
5
+ const AGGREGATE_TIMEOUT_MS = 3e4;
6
+ const REQUEST_TIMEOUT_MS = 15e3;
7
+ const DEFAULT_SAMPLE_SIZE = 500;
8
+ const MAX_SAMPLE_SIZE = 1e3;
9
+ const DEFAULT_DISTINCT_LIMIT = 100;
10
+ function withTimeout(ms) {
11
+ return { signal: AbortSignal.timeout(ms) };
12
+ }
13
+ function isPlainObject(value) {
14
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15
+ }
16
+ function headerNumber(headers, name) {
17
+ const parsed = Number.parseInt(headers?.get(name) ?? "", 10);
18
+ return Number.isNaN(parsed) ? void 0 : parsed;
19
+ }
20
+ async function responseMessage(error) {
21
+ const response = error?.response;
22
+ if (!response) return void 0;
23
+ try {
24
+ const body = await response.clone().json();
25
+ return typeof body?.msg === "string" ? body.msg : void 0;
26
+ } catch {
27
+ return void 0;
28
+ }
29
+ }
30
+ async function isEmptyResultError(error) {
31
+ const status = error?.response?.status;
32
+ if (status !== 500) return false;
33
+ const message = await responseMessage(error);
34
+ return message !== void 0 && parseServerError(message).kind === "empty-result";
35
+ }
36
+ export function useMongocampAggregation() {
37
+ const { collectionApi } = useMongocampClientApi();
38
+ const { describeError } = useMongocampError();
39
+ const { t } = useI18n();
40
+ async function runAggregation(collectionName, pipeline, paging = {}) {
41
+ const findings = findForbidden(pipeline);
42
+ if (findings.length > 0) throw new ForbiddenPipelineError(findings);
43
+ const page = paging.page ?? 1;
44
+ let response;
45
+ try {
46
+ response = await collectionApi.aggregateRaw({
47
+ collectionName,
48
+ // the generated type says string values; the server takes any JSON. allowDiskUse is required.
49
+ mongoAggregateRequest: { pipeline, allowDiskUse: false },
50
+ rowsPerPage: paging.rowsPerPage,
51
+ page
52
+ }, withTimeout(AGGREGATE_TIMEOUT_MS));
53
+ } catch (error) {
54
+ if (await isEmptyResultError(error)) return { rows: [], total: 0, pages: 0, page };
55
+ throw error;
56
+ }
57
+ const value = await response.value();
58
+ const rows = Array.isArray(value) ? value.filter(isPlainObject) : [];
59
+ const headers = response.raw?.headers;
60
+ return {
61
+ rows,
62
+ total: headerNumber(headers, "x-pagination-count-rows") ?? rows.length,
63
+ pages: headerNumber(headers, "x-pagination-count-pages") ?? 1,
64
+ page: headerNumber(headers, "x-pagination-current-page") ?? page
65
+ };
66
+ }
67
+ async function listDistinct(collectionName, field, limit = DEFAULT_DISTINCT_LIMIT) {
68
+ const response = await collectionApi.distinctRaw({ collectionName, field, rowsPerPage: limit, page: 1 }, withTimeout(REQUEST_TIMEOUT_MS));
69
+ const value = await response.value();
70
+ const values = (Array.isArray(value) ? value : []).filter((v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean");
71
+ const total = headerNumber(response.raw?.headers, "x-pagination-count-rows") ?? values.length;
72
+ return { values, total, truncated: total > values.length };
73
+ }
74
+ async function sampleDocuments(collectionName, size = DEFAULT_SAMPLE_SIZE) {
75
+ const clamped = Math.min(Math.max(Math.floor(size) || DEFAULT_SAMPLE_SIZE, 1), MAX_SAMPLE_SIZE);
76
+ return runAggregation(collectionName, [{ stage: "$sample", value: { size: clamped } }], { page: 1, rowsPerPage: clamped });
77
+ }
78
+ async function describeAggregationError(error) {
79
+ if (error instanceof ForbiddenPipelineError) {
80
+ return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.forbidden", { operator: error.findings[0]?.operator ?? "" }) };
81
+ }
82
+ const response = error?.response;
83
+ const status = response?.status;
84
+ if (status === 405) return { kind: "retryable", message: t("nuxtUiMongocamp.aggregation.errors.retryable") };
85
+ if (response && status !== void 0 && status >= 400 && status !== 401 && status !== 403) {
86
+ try {
87
+ const body = await response.clone().json();
88
+ if (typeof body?.msg === "string" && body.msg) {
89
+ const info = parseServerError(body.msg);
90
+ if (info.kind !== "empty-result" && info.message) return { kind: info.kind, message: info.message };
91
+ }
92
+ } catch {
93
+ }
94
+ }
95
+ const described = describeError(error);
96
+ return { kind: described.kind === "forbidden" ? "forbidden-access" : described.kind, message: described.message };
97
+ }
98
+ return { runAggregation, listDistinct, sampleDocuments, describeAggregationError };
99
+ }
@@ -1,5 +1,5 @@
1
1
  import { runBulkDelete } from '../utils/bulkDelete.js';
2
- export type { BulkDeleteResult } from '../utils/bulkDelete.js';
2
+ export type { BulkDeleteResult, BulkRemoveMany } from '../utils/bulkDelete.js';
3
3
  export declare function useMongocampBulkDelete(): {
4
4
  runBulkDelete: typeof runBulkDelete;
5
5
  };
@@ -0,0 +1,14 @@
1
+ import type { BatchInsertResult } from '../utils/batchInsert.js';
2
+ export type { BatchInsertResult } from '../utils/batchInsert.js';
3
+ export interface ImportRowsOptions {
4
+ batchSize?: number;
5
+ signal?: AbortSignal;
6
+ onProgress?: (progress: {
7
+ done: number;
8
+ total: number;
9
+ }) => void;
10
+ stampMetadata?: boolean;
11
+ }
12
+ export declare function useMongocampImport(): {
13
+ importRows: (collectionName: string, rows: Record<string, unknown>[], options?: ImportRowsOptions) => Promise<BatchInsertResult>;
14
+ };
@@ -0,0 +1,25 @@
1
+ import { useMongocampClientApi } from "#imports";
2
+ import useMongocampDocument from "./useMongocampDocument.js";
3
+ import { runBatchInsert } from "../utils/batchInsert.js";
4
+ const BATCH_TIMEOUT_MS = 6e4;
5
+ function isRejectedBeforeWrite(error) {
6
+ const status = error?.response?.status;
7
+ return status === 400;
8
+ }
9
+ export function useMongocampImport() {
10
+ const { documentApi } = useMongocampClientApi();
11
+ const { ensureMetaData } = useMongocampDocument();
12
+ async function importRows(collectionName, rows, options = {}) {
13
+ const prepared = options.stampMetadata ? rows.map((row) => ensureMetaData({ ...row })) : rows;
14
+ return runBatchInsert(
15
+ prepared,
16
+ (batch) => {
17
+ const timeout = AbortSignal.timeout(BATCH_TIMEOUT_MS);
18
+ const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
19
+ return documentApi.insertMany({ collectionName, requestBody: batch }, { signal });
20
+ },
21
+ { batchSize: options.batchSize, signal: options.signal, onProgress: options.onProgress, isAtomicFailure: isRejectedBeforeWrite }
22
+ );
23
+ }
24
+ return { importRows };
25
+ }
@@ -61,6 +61,11 @@
61
61
  "manageGrantsTooltip": "Berechtigungen verwalten",
62
62
  "editRoleTooltip": "Rolle bearbeiten",
63
63
  "deleteRoleTooltip": "Rolle löschen",
64
+ "cloneRoleTooltip": "Rolle klonen",
65
+ "cloneRoleTitle": "Rolle klonen: {roleName}",
66
+ "cloneRole": "Rolle klonen",
67
+ "cloneRoleHint": "Die neue Rolle erhält eine Kopie des Admin-Flags und aller {count} Berechtigungen.",
68
+ "errorClone": "Rolle konnte nicht geklont werden",
64
69
  "errorAddRole": "Rolle konnte nicht hinzugefügt werden",
65
70
  "errorEditRole": "Rolle konnte nicht aktualisiert werden",
66
71
  "errorDelete": "Rolle konnte nicht gelöscht werden"
@@ -68,6 +73,8 @@
68
73
  "roleGrants": {
69
74
  "heading": "Berechtigungen: {roleName}",
70
75
  "addGrant": "Berechtigung hinzufügen",
76
+ "addAllRead": "Alle nur lesend hinzufügen",
77
+ "addAllReadTooltip": "Lesezugriff auf alle Collections ohne Berechtigung geben, außer auf die mc_-Collections von MongoCamp",
71
78
  "editGrantTitle": "Berechtigung bearbeiten: {name}",
72
79
  "collection": "Collection",
73
80
  "read": "Lesen",
@@ -130,7 +137,19 @@
130
137
  "confirmDeleteIndex": "Möchten Sie den Index \"{indexName}\" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",
131
138
  "errorCreateIndex": "Fehler beim Erstellen des Index",
132
139
  "errorDeleteIndex": "Fehler beim Löschen des Index",
133
- "typeStandard": "Standard"
140
+ "typeStandard": "Standard",
141
+ "statsTitle": "Feldstatistik",
142
+ "statsAnalyze": "Felder analysieren",
143
+ "statsSampleSize": "Stichprobengröße",
144
+ "statsSampled": "{sampled} von {total} Dokumenten geprüft",
145
+ "statsHint": "Zählt, wie oft jedes Feld vorkommt und welche Werte es enthält, anhand einer zufälligen Stichprobe von Dokumenten.",
146
+ "statsNote": "Aus einer zufälligen Stichprobe berechnet, nicht aus der gesamten Collection.",
147
+ "statsTruncated": "Es werden nur die ersten {count} Felder angezeigt.",
148
+ "statsColumnPresent": "Vorhanden",
149
+ "statsPresentTitle": "In {present} von {sampled} geprüften Dokumenten",
150
+ "statsColumnValues": "Häufige Werte",
151
+ "statsEmpty": "Keine Dokumente zum Analysieren",
152
+ "statsFailed": "Die Feldstatistik konnte nicht geladen werden"
134
153
  },
135
154
  "collectionData": {
136
155
  "filterPlaceholder": "Zeilen filtern...",
@@ -312,7 +331,21 @@
312
331
  "selectAll": "Alle Zeilen dieser Seite auswählen",
313
332
  "selectRow": "Zeile auswählen",
314
333
  "partialFailure": "{failed} von {total} konnten nicht gelöscht werden: {reason}",
315
- "cannotSelectSelf": "Du kannst dein eigenes Konto nicht löschen"
334
+ "cannotSelectSelf": "Du kannst dein eigenes Konto nicht löschen",
335
+ "editSelected": "Auswahl bearbeiten",
336
+ "editTitle": "{count} ausgewähltes Dokument bearbeiten | {count} ausgewählte Dokumente bearbeiten",
337
+ "editDescription": "Setzt ein Feld in allen ausgewählten Dokumenten auf denselben Wert.",
338
+ "editField": "Feld",
339
+ "editType": "Werttyp",
340
+ "editValue": "Wert",
341
+ "editTrue": "true",
342
+ "editFalse": "false",
343
+ "editValueRequired": "Wert eingeben",
344
+ "editSummary": "Setzt \"{field}\" in {count} Dokument. | Setzt \"{field}\" in {count} Dokumenten.",
345
+ "confirmEdit": "{count} aktualisieren",
346
+ "editPartialFailure": "{failed} von {total} konnten nicht aktualisiert werden: {reason}",
347
+ "editShortfall": "nur {matched} von {expected} ausgewählten Dokumenten wurden gefunden",
348
+ "editUnaddressable": "diese Dokument-ID kann nicht gesammelt aktualisiert werden"
316
349
  },
317
350
  "filterBuilder": {
318
351
  "matchLabel": "Treffer bei",
@@ -350,6 +383,118 @@
350
383
  "isEmpty": "existiert nicht",
351
384
  "isNotEmpty": "existiert"
352
385
  }
386
+ },
387
+ "import": {
388
+ "trigger": "Dokumente importieren",
389
+ "title": "Dokumente importieren",
390
+ "chooseFile": "JSON- oder CSV-Datei auswählen",
391
+ "hint": "Ein JSON-Array von Objekten oder eine CSV-Datei mit Kopfzeile. Bis zu {maxRows} Zeilen und {maxMb} MB.",
392
+ "chooseButton": "Datei auswählen",
393
+ "readError": "Die Datei konnte nicht gelesen werden",
394
+ "format": "Format",
395
+ "formatJson": "JSON",
396
+ "formatCsv": "CSV",
397
+ "delimiter": "Trennzeichen",
398
+ "delimiterComma": "Komma (,)",
399
+ "delimiterSemicolon": "Semikolon (;)",
400
+ "delimiterTab": "Tabulator",
401
+ "columnTypes": "Spaltentypen",
402
+ "typeString": "Text",
403
+ "typeNumber": "Zahl",
404
+ "typeBoolean": "Boolean",
405
+ "typeDate": "Datum",
406
+ "typeJson": "JSON",
407
+ "emptyAsText": "Leere Textzellen als leere Zeichenkette behalten",
408
+ "stampMetadata": "Erstellt-/Geändert-Informationen hinzufügen",
409
+ "summary": "{ready} von {total} Zeilen bereit zum Import",
410
+ "problems": "1 Zeile hat ein Problem und wird übersprungen | {count} Zeilen haben Probleme und werden übersprungen",
411
+ "truncated": "Es werden nur die ersten {maxRows} Zeilen importiert.",
412
+ "previewTitle": "Vorschau (erste {count} Zeilen)",
413
+ "moreErrors": "…und {count} weitere",
414
+ "errorRow": "Zeile {row}",
415
+ "errorRowColumn": "Zeile {row}, Spalte {column}",
416
+ "back": "Andere Datei wählen",
417
+ "close": "Schließen",
418
+ "importButton": "{count} Zeile importieren | {count} Zeilen importieren",
419
+ "importing": "Importiere… {done} von {total}",
420
+ "stop": "Stopp",
421
+ "result": "{count} Zeile importiert | {count} Zeilen importiert",
422
+ "failedBatch": "Zeilen {from}–{to} konnten nicht importiert werden: {reason}",
423
+ "maybePartial": "Ein Teil dieser Zeilen wurde möglicherweise schon hinzugefügt — ein erneuter Versuch kann Duplikate erzeugen.",
424
+ "retryFailed": "Fehlgeschlagene Zeilen erneut versuchen",
425
+ "aborted": "Import gestoppt. {count} Zeilen wurden nicht gesendet.",
426
+ "error": {
427
+ "file-too-large": "Die Datei ist zu groß",
428
+ "invalid-json": "Die Datei ist kein gültiges JSON",
429
+ "not-array": "Ein JSON-Array von Objekten wurde erwartet",
430
+ "not-object": "Dieser Eintrag ist kein Objekt",
431
+ "invalid-delimiter": "Ungültiges Trennzeichen",
432
+ "invalid-csv": "Die CSV-Datei konnte nicht gelesen werden (nicht geschlossenes Anführungszeichen oder leere Datei)",
433
+ "invalid-header": "Die Kopfzeile enthält einen leeren oder doppelten Spaltennamen",
434
+ "field-count": "Diese Zeile hat mehr Felder als die Kopfzeile",
435
+ "too-many-rows": "Zu viele Zeilen — die überzähligen werden ignoriert",
436
+ "empty-row": "Diese Zeile hat keine Felder",
437
+ "forbidden-key": "Feldnamen dürfen nicht mit $ beginnen oder __proto__ heißen",
438
+ "too-deep": "Diese Zeile ist zu tief verschachtelt",
439
+ "invalid-number": "Keine gültige Zahl",
440
+ "unsafe-integer": "Ganzzahl zu groß, um exakt gespeichert zu werden — als Text importieren",
441
+ "invalid-id": "_id muss eine 24-stellige Hex-Zeichenkette sein",
442
+ "invalid-boolean": "Erwartet true/false, yes/no oder 1/0",
443
+ "invalid-date": "Kein gültiges ISO-Datum",
444
+ "invalid-json-value": "Kein gültiges JSON"
445
+ }
446
+ },
447
+ "aggregation": {
448
+ "errors": {
449
+ "forbidden": "Diese Pipeline verwendet {operator}, was hier nicht erlaubt ist.",
450
+ "retryable": "Die Anfrage wurde auf dem Weg zum Server blockiert. Bitte erneut versuchen."
451
+ },
452
+ "modeVisual": "Stufen",
453
+ "modeJson": "JSON",
454
+ "addStage": "Stufe hinzufügen",
455
+ "newStageType": "Stufentyp",
456
+ "stageTitle": "Stufe {n}",
457
+ "stageValue": "JSON der Stufe {type}",
458
+ "moveUp": "Stufe nach oben",
459
+ "moveDown": "Stufe nach unten",
460
+ "removeStage": "Stufe entfernen",
461
+ "jsonLabel": "Pipeline (JSON-Array)",
462
+ "run": "Ausführen",
463
+ "resultsCount": "{count} Ergebnis | {count} Ergebnisse",
464
+ "pageSize": "Zeilen pro Seite",
465
+ "exportTooltip": "Diese Seite exportieren",
466
+ "exportJson": "Seite als JSON exportieren",
467
+ "exportCsv": "Seite als CSV exportieren",
468
+ "noResults": "Die Pipeline hat keine Ergebnisse geliefert",
469
+ "precisionNote": "Die Ergebnisse sind reines JSON: Datumswerte erscheinen als ISO-Text, ganze Zahlen über 2^53 können gerundet sein.",
470
+ "runFailedTitle": "Die Pipeline konnte nicht ausgeführt werden",
471
+ "fixStages": "Bitte zuerst die unten markierten Stufen korrigieren.",
472
+ "fixStagesFirst": "Bitte zuerst die fehlerhaften Stufen korrigieren, bevor zu JSON gewechselt wird.",
473
+ "cannotShowVisually": "Diese Pipeline verwendet Stufen, für die der Stufen-Editor kein Formular hat. Bitte in der JSON-Ansicht bleiben.",
474
+ "stageTypes": {
475
+ "$match": "$match — Dokumente filtern",
476
+ "$group": "$group — gruppieren und aggregieren",
477
+ "$sort": "$sort — sortieren",
478
+ "$project": "$project — Felder wählen oder berechnen",
479
+ "$limit": "$limit — die ersten N behalten"
480
+ },
481
+ "stageErrors": {
482
+ "invalid-json": "Kein gültiges JSON",
483
+ "not-object": "Diese Stufe braucht ein JSON-Objekt",
484
+ "invalid-limit": "Das Limit muss eine ganze Zahl ab 1 sein",
485
+ "invalid-sort": "Sortierrichtungen müssen 1 oder -1 sein",
486
+ "group-needs-id": "$group braucht eine _id (null gruppiert alles)",
487
+ "forbidden": "{operator} ist nicht erlaubt"
488
+ },
489
+ "pipelineErrors": {
490
+ "too-large": "Die Pipeline ist zu groß",
491
+ "invalid-json": "Die Pipeline ist kein gültiges JSON",
492
+ "not-array": "Die Pipeline muss ein JSON-Array von Stufen sein",
493
+ "too-many-stages": "Eine Pipeline darf höchstens 50 Stufen haben",
494
+ "stage-shape": "Stufe {n} muss ein Objekt mit genau einem Schlüssel sein, der mit $ beginnt, zum Beispiel \"$match\"",
495
+ "forbidden-operator": "{operator} ist nicht erlaubt (Stufe {n})",
496
+ "too-deep": "Stufe {n} ist zu tief verschachtelt"
497
+ }
353
498
  }
354
499
  }
355
500
  }
@@ -61,6 +61,11 @@
61
61
  "manageGrantsTooltip": "Manage grants",
62
62
  "editRoleTooltip": "Edit role",
63
63
  "deleteRoleTooltip": "Delete role",
64
+ "cloneRoleTooltip": "Clone role",
65
+ "cloneRoleTitle": "Clone Role: {roleName}",
66
+ "cloneRole": "Clone Role",
67
+ "cloneRoleHint": "The new role gets a copy of the admin flag and all {count} grants.",
68
+ "errorClone": "Failed to clone role",
64
69
  "errorAddRole": "Failed to add role",
65
70
  "errorEditRole": "Failed to update role",
66
71
  "errorDelete": "Failed to delete role"
@@ -68,6 +73,8 @@
68
73
  "roleGrants": {
69
74
  "heading": "Grants: {roleName}",
70
75
  "addGrant": "Add Grant",
76
+ "addAllRead": "Add all read-only",
77
+ "addAllReadTooltip": "Grant read access to every collection without a grant, except MongoCamp's own mc_ collections",
71
78
  "editGrantTitle": "Edit Grant: {name}",
72
79
  "collection": "Collection",
73
80
  "read": "Read",
@@ -130,7 +137,19 @@
130
137
  "confirmDeleteIndex": "Are you sure you want to delete the index \"{indexName}\"? This action cannot be undone.",
131
138
  "errorCreateIndex": "Error creating index",
132
139
  "errorDeleteIndex": "Error deleting index",
133
- "typeStandard": "standard"
140
+ "typeStandard": "standard",
141
+ "statsTitle": "Field statistics",
142
+ "statsAnalyze": "Analyze fields",
143
+ "statsSampleSize": "Sample size",
144
+ "statsSampled": "{sampled} of {total} documents sampled",
145
+ "statsHint": "Counts how often each field occurs and which values it holds, from a random sample of documents.",
146
+ "statsNote": "Computed from a random sample, not from the whole collection.",
147
+ "statsTruncated": "Only the first {count} fields are shown.",
148
+ "statsColumnPresent": "Present",
149
+ "statsPresentTitle": "In {present} of {sampled} sampled documents",
150
+ "statsColumnValues": "Common values",
151
+ "statsEmpty": "No documents to analyze",
152
+ "statsFailed": "The field statistics could not be loaded"
134
153
  },
135
154
  "collectionData": {
136
155
  "filterPlaceholder": "Filter rows...",
@@ -312,7 +331,21 @@
312
331
  "selectAll": "Select all rows on this page",
313
332
  "selectRow": "Select row",
314
333
  "partialFailure": "{failed} of {total} could not be deleted: {reason}",
315
- "cannotSelectSelf": "You cannot delete your own account"
334
+ "cannotSelectSelf": "You cannot delete your own account",
335
+ "editSelected": "Edit selected",
336
+ "editTitle": "Edit {count} selected document | Edit {count} selected documents",
337
+ "editDescription": "Set one field to the same value on every selected document.",
338
+ "editField": "Field",
339
+ "editType": "Value type",
340
+ "editValue": "Value",
341
+ "editTrue": "true",
342
+ "editFalse": "false",
343
+ "editValueRequired": "Enter a value",
344
+ "editSummary": "Sets \"{field}\" on {count} document. | Sets \"{field}\" on {count} documents.",
345
+ "confirmEdit": "Update {count}",
346
+ "editPartialFailure": "{failed} of {total} could not be updated: {reason}",
347
+ "editShortfall": "only {matched} of {expected} selected documents were found",
348
+ "editUnaddressable": "this document id cannot be updated in bulk"
316
349
  },
317
350
  "filterBuilder": {
318
351
  "matchLabel": "Match",
@@ -350,6 +383,118 @@
350
383
  "isEmpty": "does not exist",
351
384
  "isNotEmpty": "exists"
352
385
  }
386
+ },
387
+ "import": {
388
+ "trigger": "Import documents",
389
+ "title": "Import documents",
390
+ "chooseFile": "Choose a JSON or CSV file",
391
+ "hint": "A JSON array of objects, or a CSV file with a header row. Up to {maxRows} rows and {maxMb} MB.",
392
+ "chooseButton": "Choose file",
393
+ "readError": "The file could not be read",
394
+ "format": "Format",
395
+ "formatJson": "JSON",
396
+ "formatCsv": "CSV",
397
+ "delimiter": "Delimiter",
398
+ "delimiterComma": "Comma (,)",
399
+ "delimiterSemicolon": "Semicolon (;)",
400
+ "delimiterTab": "Tab",
401
+ "columnTypes": "Column types",
402
+ "typeString": "Text",
403
+ "typeNumber": "Number",
404
+ "typeBoolean": "Boolean",
405
+ "typeDate": "Date",
406
+ "typeJson": "JSON",
407
+ "emptyAsText": "Keep empty text cells as empty strings",
408
+ "stampMetadata": "Add created/updated information",
409
+ "summary": "{ready} of {total} rows ready to import",
410
+ "problems": "1 row has a problem and will be skipped | {count} rows have problems and will be skipped",
411
+ "truncated": "Only the first {maxRows} rows are imported.",
412
+ "previewTitle": "Preview (first {count} rows)",
413
+ "moreErrors": "…and {count} more",
414
+ "errorRow": "Row {row}",
415
+ "errorRowColumn": "Row {row}, column {column}",
416
+ "back": "Choose another file",
417
+ "close": "Close",
418
+ "importButton": "Import {count} row | Import {count} rows",
419
+ "importing": "Importing… {done} of {total}",
420
+ "stop": "Stop",
421
+ "result": "{count} row imported | {count} rows imported",
422
+ "failedBatch": "Rows {from}–{to} could not be imported: {reason}",
423
+ "maybePartial": "Part of these rows may already have been added — retrying could create duplicates.",
424
+ "retryFailed": "Retry failed rows",
425
+ "aborted": "Import stopped. {count} rows were not sent.",
426
+ "error": {
427
+ "file-too-large": "The file is too large",
428
+ "invalid-json": "The file is not valid JSON",
429
+ "not-array": "Expected a JSON array of objects",
430
+ "not-object": "This entry is not an object",
431
+ "invalid-delimiter": "Invalid delimiter",
432
+ "invalid-csv": "The CSV file could not be read (unclosed quote or empty file)",
433
+ "invalid-header": "The header row has an empty or duplicate column name",
434
+ "field-count": "This row has more fields than the header",
435
+ "too-many-rows": "Too many rows — the extra rows are ignored",
436
+ "empty-row": "This row has no fields",
437
+ "forbidden-key": "Field names must not start with $ or be __proto__",
438
+ "too-deep": "This row is nested too deeply",
439
+ "invalid-number": "Not a valid number",
440
+ "unsafe-integer": "Integer too large to store exactly — import it as text",
441
+ "invalid-id": "_id must be a 24-character hex string",
442
+ "invalid-boolean": "Expected true/false, yes/no or 1/0",
443
+ "invalid-date": "Not a valid ISO date",
444
+ "invalid-json-value": "Not valid JSON"
445
+ }
446
+ },
447
+ "aggregation": {
448
+ "errors": {
449
+ "forbidden": "This pipeline uses {operator}, which is not allowed here.",
450
+ "retryable": "The request was blocked on its way to the server. Try again."
451
+ },
452
+ "modeVisual": "Stages",
453
+ "modeJson": "JSON",
454
+ "addStage": "Add stage",
455
+ "newStageType": "Stage type",
456
+ "stageTitle": "Stage {n}",
457
+ "stageValue": "JSON of the {type} stage",
458
+ "moveUp": "Move stage up",
459
+ "moveDown": "Move stage down",
460
+ "removeStage": "Remove stage",
461
+ "jsonLabel": "Pipeline (JSON array)",
462
+ "run": "Run",
463
+ "resultsCount": "{count} result | {count} results",
464
+ "pageSize": "Rows per page",
465
+ "exportTooltip": "Export this page",
466
+ "exportJson": "Export page as JSON",
467
+ "exportCsv": "Export page as CSV",
468
+ "noResults": "The pipeline returned no results",
469
+ "precisionNote": "Results are plain JSON: dates appear as ISO text and whole numbers beyond 2^53 may be rounded.",
470
+ "runFailedTitle": "The pipeline could not be run",
471
+ "fixStages": "Fix the stages marked below first.",
472
+ "fixStagesFirst": "Fix the stages with errors before switching to JSON.",
473
+ "cannotShowVisually": "This pipeline uses stages the stage editor has no form for. Stay in the JSON view.",
474
+ "stageTypes": {
475
+ "$match": "$match — filter documents",
476
+ "$group": "$group — group and aggregate",
477
+ "$sort": "$sort — order",
478
+ "$project": "$project — choose or compute fields",
479
+ "$limit": "$limit — keep the first N"
480
+ },
481
+ "stageErrors": {
482
+ "invalid-json": "Not valid JSON",
483
+ "not-object": "This stage needs a JSON object",
484
+ "invalid-limit": "The limit must be a whole number of 1 or more",
485
+ "invalid-sort": "Sort directions must be 1 or -1",
486
+ "group-needs-id": "$group needs an _id (use null to group everything)",
487
+ "forbidden": "{operator} is not allowed"
488
+ },
489
+ "pipelineErrors": {
490
+ "too-large": "The pipeline is too large",
491
+ "invalid-json": "The pipeline is not valid JSON",
492
+ "not-array": "The pipeline must be a JSON array of stages",
493
+ "too-many-stages": "A pipeline can have at most 50 stages",
494
+ "stage-shape": "Stage {n} must be an object with exactly one key that starts with $, for example \"$match\"",
495
+ "forbidden-operator": "{operator} is not allowed (stage {n})",
496
+ "too-deep": "Stage {n} is nested too deeply"
497
+ }
353
498
  }
354
499
  }
355
500
  }
@@ -0,0 +1,10 @@
1
+ import type { ForbiddenUse } from './aggregationPipeline.js';
2
+ export declare class ForbiddenPipelineError extends Error {
3
+ findings: ForbiddenUse[];
4
+ constructor(findings: ForbiddenUse[]);
5
+ }
6
+ export interface ServerErrorInfo {
7
+ kind: 'mongo' | 'empty-result' | 'other';
8
+ message: string;
9
+ }
10
+ export declare function parseServerError(msg: string): ServerErrorInfo;
@@ -0,0 +1,17 @@
1
+ export class ForbiddenPipelineError extends Error {
2
+ constructor(findings) {
3
+ super(`The pipeline uses ${findings[0]?.operator ?? "a forbidden operator"}`);
4
+ this.findings = findings;
5
+ this.name = "ForbiddenPipelineError";
6
+ }
7
+ }
8
+ const MONGO_COMMAND_FAILED = /^Command failed with error \d+ \([^)]*\): '([\s\S]*?)' on server \S+?\.\s+The full response is[\s\S]*$/;
9
+ const SERVER_ADDRESS = / on server \S+?(?=\.(?:\s|$)|\s|$)/g;
10
+ const BARE_ADDRESS = /\b(?:\d{1,3}\.){3}\d{1,3}(?::\d+)?\b|\b[a-z0-9-]+(?:\.[a-z0-9-]+)+:\d{2,5}\b/gi;
11
+ export function parseServerError(msg) {
12
+ const text = msg.trim();
13
+ const command = MONGO_COMMAND_FAILED.exec(text);
14
+ if (command) return { kind: "mongo", message: command[1].trim() };
15
+ if (/^Index 0 out of bounds for length 0$/.test(text)) return { kind: "empty-result", message: text };
16
+ return { kind: "other", message: text.replace(SERVER_ADDRESS, "").replace(BARE_ADDRESS, "").replace(/\s{2,}/g, " ").trim() };
17
+ }
@@ -0,0 +1,42 @@
1
+ export declare const FORBIDDEN_OPERATORS: readonly ["$out", "$merge", "$function", "$accumulator", "$where", "$lookup", "$unionWith", "$graphLookup"];
2
+ export declare const VISUAL_STAGE_TYPES: readonly ["$match", "$group", "$sort", "$project", "$limit"];
3
+ export type AggregationStageType = typeof VISUAL_STAGE_TYPES[number];
4
+ export interface AggregationStage {
5
+ id: string;
6
+ type: AggregationStageType;
7
+ value: unknown;
8
+ }
9
+ export interface RequestStage {
10
+ stage: string;
11
+ value: unknown;
12
+ }
13
+ export interface ForbiddenUse {
14
+ stageIndex: number;
15
+ operator: string;
16
+ path: string;
17
+ }
18
+ export type PipelineErrorCode = 'too-large' | 'invalid-json' | 'not-array' | 'too-many-stages' | 'stage-shape' | 'forbidden-operator' | 'too-deep';
19
+ export interface PipelineError {
20
+ code: PipelineErrorCode;
21
+ stageIndex?: number;
22
+ operator?: string;
23
+ path?: string;
24
+ }
25
+ export type ParsedPipeline = {
26
+ ok: true;
27
+ pipeline: RequestStage[];
28
+ } | {
29
+ ok: false;
30
+ error: PipelineError;
31
+ };
32
+ export type StageIssueCode = 'not-object' | 'invalid-limit' | 'invalid-sort' | 'group-needs-id';
33
+ export interface StageIssue {
34
+ stageIndex: number;
35
+ code: StageIssueCode;
36
+ }
37
+ export declare function findForbidden(pipeline: RequestStage[]): ForbiddenUse[];
38
+ export declare function buildPipeline(stages: AggregationStage[]): RequestStage[];
39
+ export declare function validateStages(stages: AggregationStage[]): StageIssue[];
40
+ export declare function parsePipeline(text: string): ParsedPipeline;
41
+ export declare function pipelineToText(pipeline: RequestStage[]): string;
42
+ export declare function toVisualStages(pipeline: RequestStage[], makeId?: (index: number) => string): AggregationStage[] | null;