@sfxcode/nuxt-ui-mongocamp 1.5.8 → 2.1.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.
Files changed (104) hide show
  1. package/README.md +5 -5
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  4. package/dist/runtime/components/MongocampAggregationBuilder.vue +5 -2
  5. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  6. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +1 -0
  7. package/dist/runtime/components/MongocampAggregationStagePreview.vue +4 -2
  8. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
  9. package/dist/runtime/components/MongocampBucketFiles.vue +4 -6
  10. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +1 -0
  11. package/dist/runtime/components/MongocampCollectionCharts.vue +4 -2
  12. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +1 -0
  13. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +1 -0
  14. package/dist/runtime/components/MongocampCollectionCopy.vue +5 -3
  15. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +1 -0
  16. package/dist/runtime/components/MongocampCollectionData.vue +63 -36
  17. package/dist/runtime/components/MongocampCollectionInfos.vue +16 -1
  18. package/dist/runtime/components/MongocampDocumentView.vue +6 -1
  19. package/dist/runtime/components/MongocampExportAll.d.vue.ts +1 -0
  20. package/dist/runtime/components/MongocampExportAll.vue +12 -0
  21. package/dist/runtime/components/MongocampExportAll.vue.d.ts +1 -0
  22. package/dist/runtime/components/MongocampImport.vue +3 -0
  23. package/dist/runtime/components/MongocampIndexes.vue +7 -3
  24. package/dist/runtime/components/MongocampQueryBar.vue +15 -0
  25. package/dist/runtime/components/MongocampServerInfo.vue +1 -14
  26. package/dist/runtime/components/MongocampServerStatus.vue +7 -2
  27. package/dist/runtime/components/MongocampSettings.d.vue.ts +0 -3
  28. package/dist/runtime/components/MongocampSettings.vue +2 -48
  29. package/dist/runtime/components/MongocampSettings.vue.d.ts +0 -3
  30. package/dist/runtime/components/MongocampVersion.d.vue.ts +1 -1
  31. package/dist/runtime/components/MongocampVersion.vue +14 -7
  32. package/dist/runtime/components/MongocampVersion.vue.d.ts +1 -1
  33. package/dist/runtime/composables/useMongocampAdmin.js +6 -5
  34. package/dist/runtime/composables/useMongocampAggregation.d.ts +11 -3
  35. package/dist/runtime/composables/useMongocampAggregation.js +19 -10
  36. package/dist/runtime/composables/useMongocampBucket.d.ts +4 -0
  37. package/dist/runtime/composables/useMongocampBucket.js +7 -6
  38. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +6 -4
  39. package/dist/runtime/composables/useMongocampBulkByFilter.js +11 -6
  40. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +3 -1
  41. package/dist/runtime/composables/useMongocampCollectionCopy.js +4 -2
  42. package/dist/runtime/composables/useMongocampCollectionStats.js +2 -4
  43. package/dist/runtime/composables/useMongocampError.d.ts +1 -1
  44. package/dist/runtime/composables/useMongocampError.js +4 -1
  45. package/dist/runtime/composables/useMongocampExportAll.d.ts +17 -7
  46. package/dist/runtime/composables/useMongocampExportAll.js +19 -20
  47. package/dist/runtime/composables/useMongocampFetchAll.d.ts +11 -5
  48. package/dist/runtime/composables/useMongocampFetchAll.js +8 -8
  49. package/dist/runtime/composables/useMongocampJobs.js +3 -2
  50. package/dist/runtime/composables/useMongocampQuery.d.ts +26 -36
  51. package/dist/runtime/composables/useMongocampQuery.js +42 -49
  52. package/dist/runtime/composables/useMongocampSchema.js +2 -0
  53. package/dist/runtime/composables/useMongocampSystem.d.ts +3 -9
  54. package/dist/runtime/composables/useMongocampSystem.js +1 -9
  55. package/dist/runtime/locales/de.json +13 -12
  56. package/dist/runtime/locales/en.json +13 -12
  57. package/dist/runtime/publicUtils.d.ts +1 -0
  58. package/dist/runtime/publicUtils.js +1 -0
  59. package/dist/runtime/server/handlers/mongocampProxy.d.ts +1 -1
  60. package/dist/runtime/server/handlers/mongocampProxy.js +12 -12
  61. package/dist/runtime/utils/aggregationErrors.d.ts +0 -4
  62. package/dist/runtime/utils/aggregationErrors.js +0 -7
  63. package/dist/runtime/utils/aggregationPipeline.d.ts +2 -1
  64. package/dist/runtime/utils/aggregationPipeline.js +2 -3
  65. package/dist/runtime/utils/caseInsensitive.d.ts +10 -0
  66. package/dist/runtime/utils/caseInsensitive.js +8 -0
  67. package/dist/runtime/utils/collectionStats.d.ts +4 -1
  68. package/dist/runtime/utils/collectionStats.js +2 -2
  69. package/dist/runtime/utils/configRows.d.ts +3 -3
  70. package/dist/runtime/utils/cursorPaging.d.ts +16 -0
  71. package/dist/runtime/utils/cursorPaging.js +17 -0
  72. package/dist/runtime/utils/documentCompare.js +2 -3
  73. package/dist/runtime/utils/documentPaths.d.ts +5 -5
  74. package/dist/runtime/utils/documentPaths.js +9 -2
  75. package/dist/runtime/utils/documentTree.js +3 -0
  76. package/dist/runtime/utils/exportTrailer.d.ts +10 -0
  77. package/dist/runtime/utils/exportTrailer.js +28 -0
  78. package/dist/runtime/utils/fileFilter.d.ts +7 -0
  79. package/dist/runtime/utils/fileFilter.js +11 -0
  80. package/dist/runtime/utils/filterBuilder.d.ts +1 -1
  81. package/dist/runtime/utils/filterBuilder.js +12 -12
  82. package/dist/runtime/utils/filterSuggestions.js +1 -1
  83. package/dist/runtime/utils/indexForm.d.ts +7 -0
  84. package/dist/runtime/utils/indexForm.js +9 -0
  85. package/dist/runtime/utils/pagedFetch.d.ts +13 -0
  86. package/dist/runtime/utils/pagedFetch.js +44 -0
  87. package/dist/runtime/utils/queryState.d.ts +5 -0
  88. package/dist/runtime/utils/queryState.js +3 -2
  89. package/dist/runtime/utils/relaxedValues.d.ts +17 -0
  90. package/dist/runtime/utils/relaxedValues.js +51 -0
  91. package/dist/runtime/utils/requestLimits.d.ts +1 -1
  92. package/dist/runtime/utils/requestLimits.js +1 -1
  93. package/dist/runtime/utils/savedQueries.d.ts +2 -0
  94. package/dist/runtime/utils/savedQueries.js +1 -0
  95. package/dist/runtime/utils/schemaAnalysis.d.ts +4 -4
  96. package/dist/runtime/utils/schemaAnalysis.js +2 -2
  97. package/dist/runtime/utils/sensitiveFields.d.ts +20 -0
  98. package/dist/runtime/utils/sensitiveFields.js +63 -0
  99. package/dist/runtime/utils/serverError.d.ts +7 -0
  100. package/dist/runtime/utils/serverError.js +11 -0
  101. package/dist/runtime/utils/serverStatus.d.ts +2 -2
  102. package/package.json +12 -6
  103. package/dist/runtime/utils/luceneExpression.d.ts +0 -15
  104. package/dist/runtime/utils/luceneExpression.js +0 -74
@@ -200,7 +200,8 @@
200
200
  "chartsPick": "Wählen Sie ein Feld, um seine Verteilung zu sehen",
201
201
  "presenceSummary": "Diagramm Feldhäufigkeit",
202
202
  "presenceLabel": "Anteil der Dokumente mit dem Feld (%)",
203
- "presenceDescription": "Die {count} Felder, die in den wenigsten Dokumenten vorkommen"
203
+ "presenceDescription": "Die {count} Felder, die in den wenigsten Dokumenten vorkommen",
204
+ "loadFailedTitle": "{name} konnte nicht geladen werden"
204
205
  },
205
206
  "collectionData": {
206
207
  "filterPlaceholder": "Zeilen filtern...",
@@ -255,8 +256,8 @@
255
256
  "chartField": "Feld",
256
257
  "chartScopeAll": "Alle {count} Dokumente der Sammlung. | Alle {count} Dokumente der Sammlung.",
257
258
  "chartScopeFiltered": "Das {count} Dokument, das zum aktuellen Filter passt. | Die {count} Dokumente, die zum aktuellen Filter passen.",
258
- "chartTooLong": "Der aktuelle Filter ist zu lang für eine Diagrammanfrage. Bitte zuerst einschränken.",
259
- "aggregateTooltip": "Die passenden Dokumente aggregieren"
259
+ "aggregateTooltip": "Die passenden Dokumente aggregieren",
260
+ "sensitiveFieldsNote": "Passwörter und API-Keys sind ausgeblendet, und die Collection ist hier schreibgeschützt – Benutzer werden auf der Benutzerseite verwaltet."
260
261
  },
261
262
  "bucketFiles": {
262
263
  "filterPlaceholder": "Nach Dateiname filtern...",
@@ -346,11 +347,6 @@
346
347
  "clusterHeading": "Cluster",
347
348
  "clusterCoordinator": "Koordinator",
348
349
  "clusterSiteMaster": "Site-Master",
349
- "pluginsHeading": "Plugins",
350
- "routesPlugins": "Routen-Plugins",
351
- "filePlugins": "Datei-Plugins",
352
- "ignoredPlugins": "Ignorierte Plugins",
353
- "noPlugins": "Keine",
354
350
  "searchPlaceholder": "Einstellungen durchsuchen...",
355
351
  "maskedNote": "Geheime Werte (Passwörter, Schlüssel, Zugangsdaten, Hosts) werden nie angezeigt.",
356
352
  "maskedHint": "Verborgen: dieser Wert ist geheim",
@@ -399,7 +395,6 @@
399
395
  "importMaxBytes": "Größter Import",
400
396
  "grantDeniedStatus": "Status bei fehlender Berechtigung",
401
397
  "deniedStages": "Abgelehnte Aggregations-Operatoren",
402
- "olderServer": "Dieser Server hat keine Capabilities-Route (älter als 1.9.0).",
403
398
  "partFailed": "{part} konnte nicht geladen werden.",
404
399
  "partStats": "Die Datenbanklast",
405
400
  "partCapabilities": "Die Fähigkeiten",
@@ -443,6 +438,7 @@
443
438
  "network": "Der Server ist nicht erreichbar oder deine Sitzung ist abgelaufen. Erneut versuchen oder neu anmelden.",
444
439
  "unauthorized": "Deine Sitzung ist abgelaufen. Bitte melde dich erneut an.",
445
440
  "forbidden": "Dafür fehlt dir die Berechtigung.",
441
+ "notFound": "Es existiert nicht (mehr). Vielleicht wurde es gelöscht oder umbenannt.",
446
442
  "notAllowed": "Der Server erlaubt diese Anfrage nicht.",
447
443
  "notAllowedOperator": "Der Server erlaubt den Operator {operator} nicht.",
448
444
  "serverMessage": "Meldung des Servers: {message}",
@@ -615,15 +611,16 @@
615
611
  "importFile": "Datei importieren",
616
612
  "ndjsonImporting": "Der Server liest die Datei …",
617
613
  "ndjsonFailed": "{failed} von {read} Zeilen konnten nicht importiert werden",
614
+ "ndjsonAborted": "Nichts wurde importiert – der Server hat nichts aus der Datei behalten. Ursache beheben und die ganze Datei erneut senden.",
618
615
  "ndjsonLine": "Zeile {line}: {reason}",
619
616
  "ndjsonMoreErrors": "Nur die ersten fehlgeschlagenen Zeilen werden genannt."
620
617
  },
621
618
  "aggregation": {
622
619
  "errors": {
623
620
  "forbidden": "Diese Pipeline verwendet {operator}, was hier nicht erlaubt ist.",
621
+ "sensitiveField": "Diese Pipeline liest {field}, ein ausgeblendetes Feld der MongoCamp-Benutzer (Passwort-Hash oder API-Key).",
624
622
  "retryable": "Die Anfrage wurde auf dem Weg zum Server blockiert. Bitte erneut versuchen.",
625
- "unavailable": "Der Server hat diese Anfrage nicht beantwortet. Versuche es erneut.",
626
- "filterTooLong": "Der Filter ist zu lang für ein Diagramm (höchstens {max} Zeichen). Bitte zuerst einschränken."
623
+ "unavailable": "Der Server hat diese Anfrage nicht beantwortet. Versuche es erneut."
627
624
  },
628
625
  "modeVisual": "Stufen",
629
626
  "modeJson": "JSON",
@@ -774,7 +771,9 @@
774
771
  "wordFilter": "Filter",
775
772
  "wordSort": "Sortierung",
776
773
  "wordFields": "Felder",
777
- "customFilter": "Filtertext: {query}"
774
+ "customFilter": "Filtertext: {query}",
775
+ "matchCase": "Groß-/Kleinschreibung beachten",
776
+ "matchCaseHint": "Aus: Suche und Platzhalter im Filter ignorieren Groß- und Kleinschreibung. An: sie müssen genau passen, was bei großen Collections schneller ist."
778
777
  },
779
778
  "indexes": {
780
779
  "columnUsage": "Nutzung",
@@ -876,6 +875,8 @@
876
875
  "scopeFiltered": "Die Dokumente von {collection}, die zum aktuellen Filter passen",
877
876
  "count": "{count} Dokument | {count} Dokumente",
878
877
  "formatLabel": "Format",
878
+ "exactTypes": "Genaue Zahlentypen behalten",
879
+ "exactTypesHint": "Größere Datei; ein erneuter Import behält ganze Zahlen genau als Int32 bzw. Int64. Ohne diese Option ist die Datei leichter lesbar und ein erneuter Import speichert ganze Zahlen als Int64.",
879
880
  "formatJson": "JSON (ein Array)",
880
881
  "formatNdjson": "NDJSON (ein Dokument pro Zeile)",
881
882
  "formatCsv": "CSV",
@@ -200,7 +200,8 @@
200
200
  "chartsPick": "Choose a field to see its distribution",
201
201
  "presenceSummary": "Field presence chart",
202
202
  "presenceLabel": "Share of documents that have the field (%)",
203
- "presenceDescription": "The {count} fields found in the fewest documents"
203
+ "presenceDescription": "The {count} fields found in the fewest documents",
204
+ "loadFailedTitle": "Could not load {name}"
204
205
  },
205
206
  "collectionData": {
206
207
  "filterPlaceholder": "Filter rows...",
@@ -255,8 +256,8 @@
255
256
  "chartField": "Field",
256
257
  "chartScopeAll": "All {count} document of the collection. | All {count} documents of the collection.",
257
258
  "chartScopeFiltered": "The {count} document that match the current filter. | The {count} documents that match the current filter.",
258
- "chartTooLong": "The current filter is too long to send with a chart request. Narrow it first.",
259
- "aggregateTooltip": "Aggregate the matching documents"
259
+ "aggregateTooltip": "Aggregate the matching documents",
260
+ "sensitiveFieldsNote": "Passwords and API keys are hidden, and the collection is read-only here — manage users on the users page."
260
261
  },
261
262
  "bucketFiles": {
262
263
  "filterPlaceholder": "Filter by filename...",
@@ -346,11 +347,6 @@
346
347
  "clusterHeading": "Cluster",
347
348
  "clusterCoordinator": "coordinator",
348
349
  "clusterSiteMaster": "site master",
349
- "pluginsHeading": "Plugins",
350
- "routesPlugins": "Route plugins",
351
- "filePlugins": "File plugins",
352
- "ignoredPlugins": "Ignored plugins",
353
- "noPlugins": "None",
354
350
  "searchPlaceholder": "Search settings...",
355
351
  "maskedNote": "Secret values (passwords, keys, credentials, hosts) are never shown.",
356
352
  "maskedHint": "Hidden: this value is a secret",
@@ -399,7 +395,6 @@
399
395
  "importMaxBytes": "Largest import",
400
396
  "grantDeniedStatus": "Status for a missing grant",
401
397
  "deniedStages": "Refused aggregation operators",
402
- "olderServer": "This server has no capabilities route (older than 1.9.0).",
403
398
  "partFailed": "{part} could not be loaded.",
404
399
  "partStats": "The database load",
405
400
  "partCapabilities": "The capabilities",
@@ -443,6 +438,7 @@
443
438
  "network": "The server could not be reached, or your session has expired. Try again, or log in again.",
444
439
  "unauthorized": "Your session has expired. Please log in again.",
445
440
  "forbidden": "You do not have permission to do this.",
441
+ "notFound": "It does not exist (any more). It may have been deleted or renamed.",
446
442
  "notAllowed": "The server does not allow this request.",
447
443
  "notAllowedOperator": "The server does not allow the operator {operator}.",
448
444
  "serverMessage": "Server message: {message}",
@@ -615,15 +611,16 @@
615
611
  "importFile": "Import file",
616
612
  "ndjsonImporting": "The server is reading the file…",
617
613
  "ndjsonFailed": "{failed} of {read} lines could not be imported",
614
+ "ndjsonAborted": "Nothing was imported — the server kept none of the file. Fix the cause and send the whole file again.",
618
615
  "ndjsonLine": "Line {line}: {reason}",
619
616
  "ndjsonMoreErrors": "Only the first failed lines are named."
620
617
  },
621
618
  "aggregation": {
622
619
  "errors": {
623
620
  "forbidden": "This pipeline uses {operator}, which is not allowed here.",
621
+ "sensitiveField": "This pipeline reads {field}, a hidden field of MongoCamp's users (password hash or API key).",
624
622
  "retryable": "The request was blocked on its way to the server. Try again.",
625
- "unavailable": "The server did not answer this request. Try again.",
626
- "filterTooLong": "The filter is too long to chart ({max} characters at most). Narrow it first."
623
+ "unavailable": "The server did not answer this request. Try again."
627
624
  },
628
625
  "modeVisual": "Stages",
629
626
  "modeJson": "JSON",
@@ -774,7 +771,9 @@
774
771
  "wordFilter": "Filter",
775
772
  "wordSort": "Sort",
776
773
  "wordFields": "Fields",
777
- "customFilter": "Filter text: {query}"
774
+ "customFilter": "Filter text: {query}",
775
+ "matchCase": "Match case",
776
+ "matchCaseHint": "Off: the search and filter wildcards ignore upper and lower case. On: they match the case exactly, which is faster on large collections."
778
777
  },
779
778
  "indexes": {
780
779
  "columnUsage": "Usage",
@@ -876,6 +875,8 @@
876
875
  "scopeFiltered": "The documents of {collection} that match the current filter",
877
876
  "count": "{count} document | {count} documents",
878
877
  "formatLabel": "Format",
878
+ "exactTypes": "Keep exact number types",
879
+ "exactTypesHint": "Larger file; a re-import keeps whole numbers as Int32 and Int64 exactly as stored. Without it the file is easier to read and a re-import stores whole numbers as Int64.",
879
880
  "formatJson": "JSON (one array)",
880
881
  "formatNdjson": "NDJSON (one document per line)",
881
882
  "formatCsv": "CSV",
@@ -3,3 +3,4 @@ export { connectionUsage, formatCount, formatUptime } from './utils/serverInfo.j
3
3
  export { groupCollectionNames } from './utils/collectionNames.js';
4
4
  export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from './utils/collectionProtection.js';
5
5
  export { isNetworkFailure } from './utils/connection.js';
6
+ export { idOf } from './utils/relaxedValues.js';
@@ -3,3 +3,4 @@ export { connectionUsage, formatCount, formatUptime } from "./utils/serverInfo.j
3
3
  export { groupCollectionNames } from "./utils/collectionNames.js";
4
4
  export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from "./utils/collectionProtection.js";
5
5
  export { isNetworkFailure } from "./utils/connection.js";
6
+ export { idOf } from "./utils/relaxedValues.js";
@@ -1,2 +1,2 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
1
+ declare const _default: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<import("h3").HTTPResponse>>;
2
2
  export default _default;
@@ -1,14 +1,16 @@
1
- import { createError, defineEventHandler, getRequestURL, proxyRequest } from "h3";
2
- import { useNitroApp, useRuntimeConfig } from "nitropack/runtime";
1
+ import { createError, defineHandler, getRequestURL, proxyRequest } from "h3";
2
+ import { useNitroApp } from "nitro/app";
3
+ import { useRuntimeConfig } from "nitro/runtime-config";
3
4
  import { consola } from "consola";
4
5
  let warnedMissingAuthorizeHook = false;
5
6
  function hasAuthorizeHookRegistered(hooks) {
7
+ if (!hooks) return false;
6
8
  const bag = hooks._hooks;
7
9
  if (!bag) return true;
8
10
  return (bag["mongocamp-proxy:authorize"]?.length ?? 0) > 0;
9
11
  }
10
- export default defineEventHandler(async (event) => {
11
- const config = useRuntimeConfig(event);
12
+ export default defineHandler(async (event) => {
13
+ const config = useRuntimeConfig();
12
14
  const options = config.public.nuxtUiMongocampOptions;
13
15
  if (!options?.useServerProxy) {
14
16
  throw createError({ statusCode: 404, statusMessage: "Not Found" });
@@ -20,7 +22,7 @@ export default defineEventHandler(async (event) => {
20
22
  "[nuxt-ui-mongocamp] `useServerProxy` is enabled but no `mongocamp-proxy:authorize` hook is registered. The proxy route is unguarded: any caller who can reach it gets the full power of the configured MongoCamp api key. Register a guard from your own `server/plugins/*.ts` \u2014 see docs/guide/server-proxy-auth.md."
21
23
  );
22
24
  }
23
- await nitroHooks.callHook("mongocamp-proxy:authorize", event);
25
+ await nitroHooks?.callHook("mongocamp-proxy:authorize", event);
24
26
  const serverProxyPath = (options.serverProxyPath ?? "/api/_mongocamp").replace(/\/+$/, "");
25
27
  const mongocampUrl = config.public.mongocamp?.url;
26
28
  const apiKey = config.mongocampApiKey ?? "";
@@ -34,12 +36,10 @@ export default defineEventHandler(async (event) => {
34
36
  const subPath = requestUrl.pathname.slice(serverProxyPath.length);
35
37
  const target = `${mongocampUrl}${subPath}${requestUrl.search}`;
36
38
  return proxyRequest(event, target, {
37
- headers: {
38
- "X-AUTH-APIKEY": apiKey,
39
- // Neutralize any Authorization header the caller sent — auth against MongoCamp in
40
- // proxy mode must only ever come from the server-side api key above, never from
41
- // whatever a caller (legitimate or not) put on their own request.
42
- "Authorization": ""
43
- }
39
+ // Drop any Authorization header (and the app's cookies) the caller sent — auth against
40
+ // MongoCamp in proxy mode must only ever come from the server-side api key below, never
41
+ // from whatever a caller (legitimate or not) put on their own request.
42
+ filterHeaders: ["authorization", "cookie"],
43
+ headers: { "X-AUTH-APIKEY": apiKey }
44
44
  });
45
45
  });
@@ -3,10 +3,6 @@ export declare class ForbiddenPipelineError extends Error {
3
3
  findings: ForbiddenUse[];
4
4
  constructor(findings: ForbiddenUse[]);
5
5
  }
6
- export declare class FilterTooLongError extends Error {
7
- max: number;
8
- constructor(max: number);
9
- }
10
6
  export interface ServerErrorInfo {
11
7
  kind: 'mongo' | 'other';
12
8
  message: string;
@@ -5,13 +5,6 @@ export class ForbiddenPipelineError extends Error {
5
5
  this.name = "ForbiddenPipelineError";
6
6
  }
7
7
  }
8
- export class FilterTooLongError extends Error {
9
- constructor(max) {
10
- super(`The filter is longer than ${max} characters`);
11
- this.max = max;
12
- this.name = "FilterTooLongError";
13
- }
14
- }
15
8
  const MONGO_COMMAND_FAILED = /^Command failed with error \d+ \([^)]*\): '([\s\S]*?)' on server \S+?\.\s+The full response is[\s\S]*$/;
16
9
  const SERVER_ADDRESS = / on server \S+?(?=\.(?:\s|$)|\s|$)/g;
17
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;
@@ -1,4 +1,4 @@
1
- export declare const FORBIDDEN_OPERATORS: readonly ["$out", "$merge", "$function", "$accumulator", "$where", "$lookup", "$unionWith", "$graphLookup", "$collStats", "$indexStats"];
1
+ export declare const FORBIDDEN_OPERATORS: readonly ["$out", "$merge", "$function", "$accumulator", "$where", "$currentOp", "$listSessions", "$collStats", "$indexStats"];
2
2
  export declare const STATS_OPERATORS: readonly ["$collStats", "$indexStats"];
3
3
  export declare const VISUAL_STAGE_TYPES: readonly ["$match", "$group", "$sort", "$project", "$limit", "$unwind", "$addFields", "$count", "$bucketAuto"];
4
4
  export type AggregationStageType = typeof VISUAL_STAGE_TYPES[number];
@@ -15,6 +15,7 @@ export interface ForbiddenUse {
15
15
  stageIndex: number;
16
16
  operator: string;
17
17
  path: string;
18
+ sensitive?: boolean;
18
19
  }
19
20
  export type PipelineErrorCode = 'too-large' | 'invalid-json' | 'not-array' | 'too-many-stages' | 'stage-shape' | 'forbidden-operator' | 'too-deep';
20
21
  export interface PipelineError {
@@ -4,9 +4,8 @@ export const FORBIDDEN_OPERATORS = [
4
4
  "$function",
5
5
  "$accumulator",
6
6
  "$where",
7
- "$lookup",
8
- "$unionWith",
9
- "$graphLookup",
7
+ "$currentOp",
8
+ "$listSessions",
10
9
  "$collStats",
11
10
  "$indexStats"
12
11
  ];
@@ -0,0 +1,10 @@
1
+ /** `true` when the server should match the wildcards of `filter` without regard to case; `undefined` = send nothing. */
2
+ export declare function caseInsensitiveFlag(filter: string | undefined, matchCase?: boolean): true | undefined;
3
+ /** The options a filtered request takes besides the filter itself. */
4
+ export interface FilterCallOptions {
5
+ signal?: AbortSignal;
6
+ /** Match the filter's wildcards without regard to case (see `caseInsensitiveFlag`). */
7
+ filterCaseInsensitive?: boolean;
8
+ }
9
+ /** Accepts the old positional `AbortSignal` as well as the options object. */
10
+ export declare function filterCallOptions(value: AbortSignal | FilterCallOptions | undefined): FilterCallOptions;
@@ -0,0 +1,8 @@
1
+ const UNESCAPED_WILDCARD = /(?:^|[^\\])[*?]/;
2
+ export function caseInsensitiveFlag(filter, matchCase = false) {
3
+ return !matchCase && filter !== void 0 && UNESCAPED_WILDCARD.test(filter) ? true : void 0;
4
+ }
5
+ export function filterCallOptions(value) {
6
+ if (value === void 0) return {};
7
+ return typeof AbortSignal !== "undefined" && value instanceof AbortSignal ? { signal: value } : value;
8
+ }
@@ -27,5 +27,8 @@ export interface IndexUsage {
27
27
  /** A non-negative finite number, else 0 (a missing or malformed number is not worth failing a card for). */
28
28
  export declare function toCount(value: unknown): number;
29
29
  export declare function mapStorage(status: Partial<CollectionStatus>): CollectionStorage;
30
- /** Rows of a `$indexStats` aggregation (already unwrapped, `host`/`ns` stripped) as typed usage; rows without a name are skipped. */
30
+ /**
31
+ * Index usage as typed rows: from `GET …/index/stats` (`{ name, key, ops, since }`, server 2.0) or from raw `$indexStats`
32
+ * rows (`accesses.ops` / `accesses.since`); rows without a name are skipped.
33
+ */
31
34
  export declare function mapIndexUsage(rows: Array<Record<string, unknown>>): IndexUsage[];
@@ -29,12 +29,12 @@ export function mapIndexUsage(rows) {
29
29
  for (const row of rows) {
30
30
  if (typeof row.name !== "string" || row.name === "") continue;
31
31
  const accesses = isRecord(row.accesses) ? row.accesses : {};
32
- const ops = toCount(accesses.ops);
32
+ const ops = toCount(row.ops ?? accesses.ops);
33
33
  out.push({
34
34
  name: row.name,
35
35
  key: isRecord(row.key) ? row.key : {},
36
36
  ops,
37
- since: isoOrNull(accesses.since),
37
+ since: isoOrNull(row.since ?? accesses.since),
38
38
  unused: ops === 0
39
39
  });
40
40
  }
@@ -11,8 +11,8 @@ export declare function isSecretConfigKey(key: string): boolean;
11
11
  export declare function buildConfigRows(configurations: unknown): ConfigRow[];
12
12
  export declare const GRANT_STATUS_KEY = "AUTH_GRANT_DENIED_STATUS";
13
13
  /**
14
- * Whether the server still answers a missing grant with `401` (its default; `403` is planned for the next major version): a
15
- * generated client clears the session on a 401, which this module works around by turning that 401 into a 403 itself. `false`
16
- * when the setting is `403`, absent (an older server) or unreadable.
14
+ * Whether the server answers a missing grant with `401` (the default of server 2.0, `AUTH_GRANT_DENIED_STATUS`): a generated
15
+ * client clears the session on a 401, which this module works around by turning that 401 into a 403 itself. `false` when the
16
+ * setting is `403`, absent or unreadable.
17
17
  */
18
18
  export declare function grantStatusHint(rows: readonly ConfigRow[]): boolean;
@@ -0,0 +1,16 @@
1
+ /** The sort the server uses for a cursor, also for page numbers: the given keys, then `_id` unless it is already there. */
2
+ export declare function stableSort(sort: readonly string[] | undefined): string[];
3
+ /** The cursors of the pages reached by stepping forward, for one list (`key`: filter, sort, fields, page size, …). */
4
+ export interface CursorMemory {
5
+ key: string;
6
+ /** page number → the `after` that loads it; page 1 is always `''`. */
7
+ cursors: Record<number, string>;
8
+ }
9
+ export declare function emptyCursorMemory(): CursorMemory;
10
+ /** The `after` that loads `page` of the list `key`, or `undefined` when only its page number can load it. */
11
+ export declare function cursorFor(memory: CursorMemory, key: string, page: number): string | undefined;
12
+ /**
13
+ * The memory after `page` of the list `key` was loaded and answered with `next` (absent on the last page). Another list
14
+ * starts afresh; a missing `next` forgets what lay beyond.
15
+ */
16
+ export declare function rememberNext(memory: CursorMemory, key: string, page: number, next: string | undefined): CursorMemory;
@@ -0,0 +1,17 @@
1
+ export function stableSort(sort) {
2
+ const keys = [...sort ?? []];
3
+ return keys.some((key) => key === "_id" || key === "-_id") ? keys : [...keys, "_id"];
4
+ }
5
+ export function emptyCursorMemory() {
6
+ return { key: "", cursors: {} };
7
+ }
8
+ export function cursorFor(memory, key, page) {
9
+ if (page === 1) return "";
10
+ return memory.key === key ? memory.cursors[page] : void 0;
11
+ }
12
+ export function rememberNext(memory, key, page, next) {
13
+ const kept = memory.key === key ? Object.entries(memory.cursors).filter(([p]) => Number(p) !== page + 1) : [];
14
+ const cursors = Object.fromEntries(kept);
15
+ if (next) cursors[page + 1] = next;
16
+ return { key, cursors };
17
+ }
@@ -6,13 +6,12 @@ export function plainValue(value) {
6
6
  if (typeof value === "bigint") return value.toString();
7
7
  return unwrapExtendedJson(value);
8
8
  }
9
- const WRAPPED_AS_TEXT = /* @__PURE__ */ new Set(["objectId", "date", "long", "decimal"]);
10
9
  const NUMERIC = /* @__PURE__ */ new Set(["number", "int", "long", "double", "decimal"]);
11
10
  const EXACT_NUMERIC = /* @__PURE__ */ new Set(["int", "long", "double", "decimal"]);
12
11
  function typesAgree(a, b) {
13
12
  if (a === b) return true;
14
13
  if (NUMERIC.has(a) && NUMERIC.has(b)) return !(EXACT_NUMERIC.has(a) && EXACT_NUMERIC.has(b));
15
- return a === "string" && WRAPPED_AS_TEXT.has(b) || b === "string" && WRAPPED_AS_TEXT.has(a);
14
+ return false;
16
15
  }
17
16
  function leafEqual(a, b) {
18
17
  if (a === b) return true;
@@ -44,7 +43,7 @@ export function compareDocuments(left, right, options = {}) {
44
43
  }
45
44
  const r = plainValue(other.value);
46
45
  const equal = leafEqual(l, r);
47
- const typeDiffers = !typesAgree(entry.type, other.type) && String(l) === String(r);
46
+ const typeDiffers = !typesAgree(entry.type, other.type) && (equal || String(l) === String(r));
48
47
  rows.push({
49
48
  path: entry.path,
50
49
  status: equal && !typeDiffers ? "same" : "changed",
@@ -1,4 +1,4 @@
1
- export type PathValueType = 'null' | 'string' | 'boolean' | 'number' | 'int' | 'long' | 'double' | 'decimal' | 'objectId' | 'date' | 'array' | 'object';
1
+ export type PathValueType = 'null' | 'string' | 'boolean' | 'number' | 'int' | 'long' | 'double' | 'decimal' | 'objectId' | 'date' | 'array' | 'object' | 'binary' | 'regex' | 'timestamp' | 'minKey' | 'maxKey';
2
2
  export interface FlatEntry {
3
3
  path: string;
4
4
  type: PathValueType;
@@ -16,10 +16,10 @@ export interface FlattenResult {
16
16
  truncated: boolean;
17
17
  }
18
18
  /**
19
- * What a value is, with extended-JSON wrappers recognised as their BSON type. Read a document with `extendedJson=canonical`
20
- * (server 1.8.1) to get the types: `_id` and nested ids are `{ $oid }`, dates `{ $date }`, numbers `{ $numberInt }` /
21
- * `{ $numberLong }` / `{ $numberDouble }` / `{ $numberDecimal }`, date-looking text `{ $string }`. A document read as plain
22
- * JSON has no wrappers (ids and dates are strings) and is typed as what JSON says — the module no longer guesses.
19
+ * What a value is, with extended-JSON wrappers recognised as their BSON type. The server's default (relaxed) read wraps ids
20
+ * `{ $oid }`, dates `{ $date }`, integers beyond 2^53 `{ $numberLong }`, decimals `{ $numberDecimal }`, date-looking text
21
+ * `{ $string }`, binary/regex/timestamp/min-max keys; other numbers are plain (`number`). A canonical read
22
+ * (`extendedJson=canonical`) also wraps every number, so int, long and double can be told apart.
23
23
  */
24
24
  export declare function typeOf(value: unknown): PathValueType;
25
25
  /** Splits a path at its unescaped dots; `''` is the empty path (no segments). */
@@ -11,8 +11,15 @@ const WRAPPER_TYPES = {
11
11
  $numberInt: "int",
12
12
  $numberDouble: "double",
13
13
  $numberDecimal: "decimal",
14
- // text that looks like a date, marked as text by the server in a typed read
15
- $string: "string"
14
+ // text that looks like a date, marked as text by the server
15
+ $string: "string",
16
+ // wrappers without a plain JavaScript value: one leaf each
17
+ $binary: "binary",
18
+ $uuid: "binary",
19
+ $regularExpression: "regex",
20
+ $timestamp: "timestamp",
21
+ $minKey: "minKey",
22
+ $maxKey: "maxKey"
16
23
  };
17
24
  function wrapperType(value) {
18
25
  const keys = Object.keys(value);
@@ -1,4 +1,5 @@
1
1
  import { joinPath, typeOf } from "./documentPaths.js";
2
+ import { leafWrapperText } from "./relaxedValues.js";
2
3
  export const DEFAULT_MAX_NODES = 5e3;
3
4
  export const MAX_TREE_DEPTH = 32;
4
5
  export const COLLAPSE_ABOVE_NODES = 200;
@@ -95,6 +96,8 @@ export function nodeDisplay(node) {
95
96
  return parsed && !Number.isNaN(parsed.getTime()) ? { text, title: parsed.toLocaleString() } : { text };
96
97
  }
97
98
  if (typeof value === "object" && value !== null) {
99
+ const leaf = leafWrapperText(value);
100
+ if (leaf !== void 0) return { text: leaf };
98
101
  const inner = Object.values(value)[0];
99
102
  return { text: typeof inner === "string" ? inner : JSON.stringify(inner) };
100
103
  }
@@ -0,0 +1,10 @@
1
+ export interface ExportTrailer {
2
+ /** Documents the server wrote — only for a complete file (an end marker). */
3
+ count?: number;
4
+ /** The last line was a marker (end or error); `cut` is then where the file without it ends. */
5
+ marker: boolean;
6
+ /** Byte offset of the marker line: `blob.slice(0, cut)` is the file without it. */
7
+ cut: number;
8
+ }
9
+ /** Reads the marker from the end of an NDJSON or CSV export; only the last bytes are read. */
10
+ export declare function readExportTrailer(blob: Blob, format: 'ndjson' | 'csv'): Promise<ExportTrailer>;
@@ -0,0 +1,28 @@
1
+ const TAIL_BYTES = 64 * 1024;
2
+ function parseMarker(line, format) {
3
+ if (format === "csv") {
4
+ const end = /^# end (\d+)$/.exec(line);
5
+ if (end) return { marker: true, count: Number(end[1]) };
6
+ return { marker: line.startsWith("# error") };
7
+ }
8
+ if (!line.startsWith('{"$')) return { marker: false };
9
+ try {
10
+ const parsed = JSON.parse(line);
11
+ if (parsed.$end === true && Number.isSafeInteger(parsed.count)) return { marker: true, count: parsed.count };
12
+ return { marker: typeof parsed.$error === "string" };
13
+ } catch {
14
+ return { marker: false };
15
+ }
16
+ }
17
+ export async function readExportTrailer(blob, format) {
18
+ const start = Math.max(0, blob.size - TAIL_BYTES);
19
+ const tail = new Uint8Array(await blob.slice(start).arrayBuffer());
20
+ let end = tail.length;
21
+ while (end > 0 && (tail[end - 1] === 10 || tail[end - 1] === 13)) end--;
22
+ if (end === 0) return { marker: false, cut: blob.size };
23
+ const lineStart = tail.lastIndexOf(10, end - 1) + 1;
24
+ if (lineStart === 0 && start > 0) return { marker: false, cut: blob.size };
25
+ const line = new TextDecoder().decode(tail.subarray(lineStart, end));
26
+ const { marker, count } = parseMarker(line, format);
27
+ return marker ? { marker, count, cut: start + lineStart } : { marker: false, cut: blob.size };
28
+ }
@@ -0,0 +1,7 @@
1
+ /** The text as a regular expression that matches it literally. */
2
+ export declare function escapeRegex(text: string): string;
3
+ /**
4
+ * The `filter` for files whose name contains `term` (case-insensitive unless `matchCase`), as the JSON text the list
5
+ * route takes: `{"filename":{"$regex":"…","$options":"i"}}`. `undefined` for a blank term = no filter.
6
+ */
7
+ export declare function filenameFilter(term: string, matchCase?: boolean): string | undefined;
@@ -0,0 +1,11 @@
1
+ const REGEX_SPECIAL = /[.*+?^${}()|[\]\\]/g;
2
+ export function escapeRegex(text) {
3
+ return text.replace(REGEX_SPECIAL, "\\$&");
4
+ }
5
+ export function filenameFilter(term, matchCase = false) {
6
+ const trimmed = term.trim();
7
+ if (trimmed === "") return void 0;
8
+ const condition = { $regex: escapeRegex(trimmed) };
9
+ if (!matchCase) condition.$options = "i";
10
+ return JSON.stringify({ filename: condition });
11
+ }
@@ -12,7 +12,7 @@ export interface FilterCondition {
12
12
  export interface FilterGroup {
13
13
  match: 'all' | 'any';
14
14
  conditions: FilterCondition[];
15
- /** Exclude what the combined conditions match (NOT). Written with De Morgan, see `useMongocampQuery().not`. */
15
+ /** Exclude what the combined conditions match (NOT): `-( … )`, see `useMongocampQuery().not`. */
16
16
  negate?: boolean;
17
17
  }
18
18
  export declare const FILTER_OPERATORS_BY_TYPE: Record<FilterFieldType, FilterOperator[]>;
@@ -2,14 +2,15 @@ import { useMongocampQuery } from "../composables/useMongocampQuery.js";
2
2
  import { escapeFieldName } from "./escapeFieldName.js";
3
3
  import { isIsoDateTimeString } from "./isoDate.js";
4
4
  import { isObjectIdHex } from "./objectId.js";
5
+ const OBJECT_ID_PART = /^[0-9a-f]{1,24}$/i;
5
6
  export const FILTER_OPERATORS_BY_TYPE = {
6
7
  "string": ["contains", "equals", "notEquals", "startsWith", "endsWith", "oneOf", "isEmpty", "isNotEmpty"],
7
8
  "number": ["equals", "notEquals", "gte", "lte", "between", "oneOf", "isEmpty", "isNotEmpty"],
8
9
  "date-time": ["gte", "lte", "between", "isEmpty", "isNotEmpty"],
9
- "boolean": ["isTrue", "isFalse"],
10
- "objectId": ["equals", "notEquals", "oneOf"],
11
- "array": [],
12
- "object": []
10
+ "boolean": ["isTrue", "isFalse", "isEmpty", "isNotEmpty"],
11
+ "objectId": ["equals", "notEquals", "oneOf", "startsWith", "endsWith", "contains"],
12
+ "array": ["isEmpty", "isNotEmpty"],
13
+ "object": ["isEmpty", "isNotEmpty"]
13
14
  };
14
15
  export function operatorsFor(type) {
15
16
  return Object.hasOwn(FILTER_OPERATORS_BY_TYPE, type) ? FILTER_OPERATORS_BY_TYPE[type] : FILTER_OPERATORS_BY_TYPE.string;
@@ -45,12 +46,6 @@ function parseRangeBound(type, raw) {
45
46
  if (type === "date-time") return isIsoDateTimeString(raw) ? raw : null;
46
47
  return null;
47
48
  }
48
- function existsType(type) {
49
- if (type === "string") return "text";
50
- if (type === "number") return "number";
51
- if (type === "date-time") return "date";
52
- return void 0;
53
- }
54
49
  function splitList(raw) {
55
50
  return raw.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
56
51
  }
@@ -62,6 +57,11 @@ export function buildCondition(condition, type) {
62
57
  const value = (condition.value ?? "").trim();
63
58
  const value2 = (condition.value2 ?? "").trim();
64
59
  if (type === "objectId") {
60
+ if (condition.operator === "startsWith" || condition.operator === "endsWith" || condition.operator === "contains") {
61
+ if (!OBJECT_ID_PART.test(value)) return "";
62
+ if (condition.operator === "startsWith") return h.startsWith(field, value);
63
+ return condition.operator === "endsWith" ? h.endsWith(field, value) : h.like(field, value);
64
+ }
65
65
  const ids = condition.operator === "oneOf" ? splitList(value) : [value];
66
66
  if (ids.length === 0 || !ids.every(isObjectIdHex)) return "";
67
67
  if (condition.operator === "oneOf") return h.byIds(ids);
@@ -69,9 +69,9 @@ export function buildCondition(condition, type) {
69
69
  }
70
70
  switch (condition.operator) {
71
71
  case "isEmpty":
72
- return h.notExists(field, existsType(type));
72
+ return h.notExists(field);
73
73
  case "isNotEmpty":
74
- return h.exists(field, existsType(type));
74
+ return h.exists(field);
75
75
  case "isTrue":
76
76
  return h.isTrue(field);
77
77
  case "isFalse":
@@ -1,5 +1,5 @@
1
1
  const SUGGESTION_OPERATORS = ["equals", "notEquals", "oneOf"];
2
- const UNFILTERABLE = /[:*?()\\]/;
2
+ const UNFILTERABLE = /\*/;
3
3
  export function isSuggestable(value, operator) {
4
4
  if (value.trim() === "" || UNFILTERABLE.test(value)) return false;
5
5
  return operator !== "oneOf" || !value.includes(",");