@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
@@ -1,6 +1,7 @@
1
1
  type __VLS_Props = {
2
2
  collection: string;
3
3
  filter?: string;
4
+ matchCase?: boolean;
4
5
  sort?: string[];
5
6
  projection?: string[];
6
7
  total?: number;
@@ -503,11 +503,14 @@ const limitsText = computed(() => ({ maxRows: DEFAULT_IMPORT_LIMITS.maxRows, max
503
503
  class="flex flex-col gap-3"
504
504
  data-test="ndjson-result"
505
505
  >
506
+ <!-- server 2.0 imports all or nothing: an aborted import removes what earlier batches stored -->
506
507
  <UAlert
507
508
  v-if="serverError"
508
509
  color="error"
509
510
  :variant="ui.alert.variant"
510
511
  icon="i-lucide-circle-alert"
512
+ data-test="ndjson-aborted"
513
+ :title="t('nuxtUiMongocamp.import.ndjsonAborted')"
511
514
  :description="serverError"
512
515
  />
513
516
  <template v-else-if="serverResult">
@@ -8,6 +8,7 @@ import {
8
8
  buildIndexRequest,
9
9
  canDropIndex,
10
10
  classifyIndexError,
11
+ collationLocale,
11
12
  describeKey,
12
13
  formatBytes,
13
14
  indexKeys,
@@ -15,6 +16,7 @@ import {
15
16
  isTextIndex,
16
17
  isUnusedIndex,
17
18
  MAX_INDEX_FIELDS,
19
+ partialFilterText,
18
20
  validateIndexForm
19
21
  } from "../utils/indexForm";
20
22
  import { shortenLabel } from "../utils/chartData";
@@ -74,7 +76,9 @@ const rows = computed(
74
76
  sparse: idx.sparse,
75
77
  hidden: idx.hidden,
76
78
  partial: idx.partialFilterExpression != null,
79
+ partialFilter: partialFilterText(idx.partialFilterExpression),
77
80
  collation: idx.collation != null,
81
+ collationLocale: collationLocale(idx.collation),
78
82
  language: idx.defaultLanguage ?? void 0,
79
83
  expireAfterSeconds: isExpiringIndex(idx) ? idx.expireAfterSeconds : void 0,
80
84
  size: storage.value?.indexSizes[idx.name],
@@ -107,11 +111,11 @@ const columns = computed(() => [
107
111
  if (row.original.text) flags.push({ label: "text", color: "info" });
108
112
  if (row.original.expireAfterSeconds !== void 0) flags.push({ label: `expire ${row.original.expireAfterSeconds}s`, color: "secondary" });
109
113
  if (row.original.sparse) flags.push({ label: "sparse", color: "secondary" });
110
- if (row.original.partial) flags.push({ label: "partial", color: "secondary" });
114
+ if (row.original.partial) flags.push({ label: "partial", color: "secondary", title: row.original.partialFilter });
111
115
  if (row.original.hidden) flags.push({ label: "hidden", color: "warning" });
112
- if (row.original.collation) flags.push({ label: "collation", color: "secondary" });
116
+ if (row.original.collation) flags.push({ label: row.original.collationLocale ? `collation ${row.original.collationLocale}` : "collation", color: "secondary" });
113
117
  if (row.original.text && row.original.language) flags.push({ label: row.original.language, color: "info" });
114
- const badges = flags.map((flag) => h(UBadge, { label: flag.label, color: flag.color, variant: ui.value.badge.variant, size: "sm" }));
118
+ const badges = flags.map((flag) => h(UBadge, { label: flag.label, color: flag.color, variant: ui.value.badge.variant, size: "sm", title: flag.title, ...flag.title ? { "data-partial-filter": flag.title } : {} }));
115
119
  if (badges.length === 0) badges.push(h(UBadge, { label: t("nuxtUiMongocamp.collectionInfos.typeStandard"), color: "neutral", variant: ui.value.badge.variant, size: "sm" }));
116
120
  return h("div", { class: "flex flex-wrap gap-1" }, badges);
117
121
  }
@@ -44,6 +44,9 @@ function commit(next, options = {}) {
44
44
  emit("apply", next);
45
45
  if (options.remember !== false && !isEmptyQuery(next)) record(toSavedQuery(next));
46
46
  }
47
+ function toggleMatchCase() {
48
+ commit({ ...model.value, matchCase: !model.value.matchCase }, { remember: false });
49
+ }
47
50
  function onBuilderApply(lucene) {
48
51
  commit({ ...model.value, filterGroup: cloneGroup(draft.value), lucene });
49
52
  }
@@ -134,6 +137,18 @@ function saveCurrent() {
134
137
  />
135
138
  </UChip>
136
139
 
140
+ <UButton
141
+ icon="i-lucide-case-sensitive"
142
+ color="neutral"
143
+ :variant="model.matchCase ? 'subtle' : 'ghost'"
144
+ :size="ui.controlSize"
145
+ :aria-pressed="model.matchCase"
146
+ :aria-label="t('nuxtUiMongocamp.queryBar.matchCase')"
147
+ :title="t('nuxtUiMongocamp.queryBar.matchCaseHint')"
148
+ data-test="match-case"
149
+ @click="toggleMatchCase"
150
+ />
151
+
137
152
  <UPopover>
138
153
  <UChip
139
154
  :text="model.sort.length"
@@ -23,10 +23,6 @@ const stats = ref(null);
23
23
  const capabilities = ref(null);
24
24
  const loading = ref(false);
25
25
  const failed = ref({ info: false, stats: false, capabilities: false });
26
- const olderServer = ref(false);
27
- function statusOf(error) {
28
- return error?.response?.status;
29
- }
30
26
  async function load() {
31
27
  const [info, loadedStats, loadedCapabilities] = await Promise.allSettled([
32
28
  getServerInfo(),
@@ -36,12 +32,10 @@ async function load() {
36
32
  mongoDbVersion.value = info.status === "fulfilled" ? info.value.mongoDbVersion || null : mongoDbVersion.value;
37
33
  stats.value = loadedStats.status === "fulfilled" ? loadedStats.value : stats.value;
38
34
  capabilities.value = loadedCapabilities.status === "fulfilled" ? loadedCapabilities.value : capabilities.value;
39
- const missing = loadedCapabilities.status === "rejected" && [404, 405].includes(statusOf(loadedCapabilities.reason) ?? 0);
40
- olderServer.value = missing;
41
35
  failed.value = {
42
36
  info: info.status === "rejected",
43
37
  stats: loadedStats.status === "rejected",
44
- capabilities: loadedCapabilities.status === "rejected" && !missing
38
+ capabilities: loadedCapabilities.status === "rejected"
45
39
  };
46
40
  if ([info, loadedStats, loadedCapabilities].every((r) => r.status === "rejected")) throw info.reason;
47
41
  }
@@ -270,13 +264,6 @@ defineExpose({ refresh });
270
264
  </div>
271
265
  </UCard>
272
266
 
273
- <UAlert
274
- v-if="olderServer && !hideCapabilities"
275
- color="neutral"
276
- :variant="ui.alert.variant"
277
- data-testid="older-server"
278
- :description="t('nuxtUiMongocamp.serverInfo.olderServer')"
279
- />
280
267
  <UCard v-if="!hideCapabilities && capabilities">
281
268
  <template #header>
282
269
  <span class="font-semibold">{{ t("nuxtUiMongocamp.serverInfo.capabilitiesHeading") }}</span>
@@ -12,7 +12,7 @@ const props = defineProps({
12
12
  const { t } = useI18n();
13
13
  const paths = useMongocampPaths();
14
14
  const { $mongocampVersion } = useNuxtApp();
15
- const { getStats, getServerInfo } = useMongocampSystem();
15
+ const { getStats, getServerInfo, getCapabilities } = useMongocampSystem();
16
16
  const { canSeeAdmin } = useMongocampRoles();
17
17
  const { blocked } = useMongocampAdminGate();
18
18
  const state = useMongocampStorage();
@@ -24,9 +24,14 @@ const uptimeSeconds = ref();
24
24
  const outcome = ref({ info: "skipped", stats: "skipped" });
25
25
  const canAskInfo = computed(() => isProxyMode || !!state.value?.profile);
26
26
  const canAskStats = computed(() => canAskInfo.value && !blocked.value);
27
+ async function databaseInfo() {
28
+ if (!blocked.value) return getServerInfo();
29
+ const major = (await getCapabilities()).mongoDbMajor;
30
+ return { mongoDbVersion: major ? String(major) : void 0 };
31
+ }
27
32
  async function refresh() {
28
33
  const [info, stats] = await Promise.allSettled([
29
- canAskInfo.value ? getServerInfo() : Promise.reject(new Error("skipped")),
34
+ canAskInfo.value ? databaseInfo() : Promise.reject(new Error("skipped")),
30
35
  canAskStats.value ? getStats() : Promise.reject(new Error("skipped"))
31
36
  ]);
32
37
  mongoDbVersion.value = info.status === "fulfilled" ? info.value.mongoDbVersion || void 0 : void 0;
@@ -3,8 +3,6 @@ type __VLS_Props = {
3
3
  hideHeading?: boolean;
4
4
  /** Hide the refresh button. */
5
5
  hideRefresh?: boolean;
6
- /** Hide the plugins card (the plugins request is skipped too). */
7
- hidePlugins?: boolean;
8
6
  /** Hide the cluster card (the cluster request is skipped too). */
9
7
  hideCluster?: boolean;
10
8
  /** Hide the whole configuration section — search, note and table (the configuration request is skipped too). */
@@ -28,7 +26,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
28
26
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
29
27
  hideRefresh: boolean;
30
28
  hideHeading: boolean;
31
- hidePlugins: boolean;
32
29
  hideCluster: boolean;
33
30
  hideConfigurations: boolean;
34
31
  hideSearch: boolean;
@@ -7,7 +7,6 @@ const PAGE_SIZE = 10;
7
7
  const props = defineProps({
8
8
  hideHeading: { type: Boolean, required: false, default: false },
9
9
  hideRefresh: { type: Boolean, required: false, default: false },
10
- hidePlugins: { type: Boolean, required: false, default: false },
11
10
  hideCluster: { type: Boolean, required: false, default: false },
12
11
  hideConfigurations: { type: Boolean, required: false, default: false },
13
12
  hideSearch: { type: Boolean, required: false, default: false },
@@ -16,10 +15,9 @@ const props = defineProps({
16
15
  });
17
16
  const { t } = useI18n();
18
17
  const ui = useMongocampUi();
19
- const { getSettings, listConfigurations, getCluster } = useMongocampSystem();
18
+ const { listConfigurations, getCluster } = useMongocampSystem();
20
19
  const { isAdmin } = useMongocampRoles();
21
20
  const configurations = ref([]);
22
- const plugins = ref(null);
23
21
  const cluster = ref(null);
24
22
  const loading = ref(false);
25
23
  const loadError = ref(null);
@@ -31,18 +29,15 @@ async function fetchSettings() {
31
29
  loading.value = true;
32
30
  loadError.value = null;
33
31
  try {
34
- const [loadedPlugins, rows, loadedCluster] = await Promise.all([
35
- props.hidePlugins ? Promise.resolve(null) : getSettings(),
32
+ const [rows, loadedCluster] = await Promise.all([
36
33
  props.hideConfigurations ? Promise.resolve([]) : listConfigurations(),
37
34
  // optional context: a failing cluster endpoint must not take the settings page down
38
35
  props.hideCluster ? Promise.resolve(null) : getCluster().catch(() => null)
39
36
  ]);
40
- plugins.value = loadedPlugins;
41
37
  cluster.value = loadedCluster;
42
38
  configurations.value = rows;
43
39
  } catch (e) {
44
40
  loadError.value = e;
45
- plugins.value = null;
46
41
  cluster.value = null;
47
42
  configurations.value = [];
48
43
  } finally {
@@ -82,11 +77,6 @@ const columns = computed(() => [
82
77
  cell: ({ row }) => row.original.needsRestart ? h(UBadge, { label: t("nuxtUiMongocamp.settings.restartNeeded"), color: "warning", variant: ui.value.badge.variant }) : h("span", { class: "text-dimmed" }, "\u2014")
83
78
  }
84
79
  ]);
85
- const pluginGroups = computed(() => [
86
- { key: "routes", label: t("nuxtUiMongocamp.settings.routesPlugins"), items: plugins.value?.routesPlugins ?? [] },
87
- { key: "file", label: t("nuxtUiMongocamp.settings.filePlugins"), items: plugins.value?.filePlugins ?? [] },
88
- { key: "ignored", label: t("nuxtUiMongocamp.settings.ignoredPlugins"), items: plugins.value?.ignoredPlugins ?? [] }
89
- ]);
90
80
  fetchSettings();
91
81
  defineExpose({ refresh: fetchSettings });
92
82
  </script>
@@ -136,42 +126,6 @@ defineExpose({ refresh: fetchSettings });
136
126
  @retry="fetchSettings"
137
127
  />
138
128
 
139
- <UCard v-if="plugins && !hidePlugins">
140
- <template #header>
141
- <span class="font-semibold">{{ t("nuxtUiMongocamp.settings.pluginsHeading") }}</span>
142
- </template>
143
- <div class="grid gap-4 sm:grid-cols-3">
144
- <section
145
- v-for="group in pluginGroups"
146
- :key="group.key"
147
- class="flex flex-col gap-1"
148
- >
149
- <h3 class="text-sm font-semibold">
150
- {{ group.label }}
151
- </h3>
152
- <div
153
- v-if="group.items.length"
154
- class="flex flex-wrap gap-1"
155
- >
156
- <UBadge
157
- v-for="item in group.items"
158
- :key="item"
159
- :label="item"
160
- color="neutral"
161
- :variant="ui.badge.variant"
162
- size="sm"
163
- />
164
- </div>
165
- <p
166
- v-else
167
- class="text-sm text-dimmed"
168
- >
169
- {{ t("nuxtUiMongocamp.settings.noPlugins") }}
170
- </p>
171
- </section>
172
- </div>
173
- </UCard>
174
-
175
129
  <UCard v-if="cluster && !hideCluster">
176
130
  <template #header>
177
131
  <span class="font-semibold">{{ t("nuxtUiMongocamp.settings.clusterHeading") }}</span>
@@ -3,8 +3,6 @@ type __VLS_Props = {
3
3
  hideHeading?: boolean;
4
4
  /** Hide the refresh button. */
5
5
  hideRefresh?: boolean;
6
- /** Hide the plugins card (the plugins request is skipped too). */
7
- hidePlugins?: boolean;
8
6
  /** Hide the cluster card (the cluster request is skipped too). */
9
7
  hideCluster?: boolean;
10
8
  /** Hide the whole configuration section — search, note and table (the configuration request is skipped too). */
@@ -28,7 +26,6 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
28
26
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
29
27
  hideRefresh: boolean;
30
28
  hideHeading: boolean;
31
- hidePlugins: boolean;
32
29
  hideCluster: boolean;
33
30
  hideConfigurations: boolean;
34
31
  hideSearch: boolean;
@@ -1,5 +1,5 @@
1
1
  type __VLS_Props = {
2
- /** Hide the MongoDB version badge (it is also hidden while the server cannot tell, e.g. before login or below server 1.9.0). */
2
+ /** Hide the MongoDB version badge (it is also hidden while the server cannot tell, e.g. before login). */
3
3
  hideDatabase?: boolean;
4
4
  };
5
5
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
@@ -9,22 +9,29 @@ const props = defineProps({
9
9
  const { t } = useI18n();
10
10
  const ui = useMongocampUi();
11
11
  const { $mongocampVersion } = useNuxtApp();
12
- const { getServerInfo } = useMongocampSystem();
12
+ const { getServerInfo, getCapabilities } = useMongocampSystem();
13
13
  const state = useMongocampStorage();
14
14
  const isProxyMode = useMongocampProxyMode();
15
15
  const version = computed(() => $mongocampVersion.value);
16
16
  const mongoDbVersion = ref(null);
17
17
  const canAsk = computed(() => !props.hideDatabase && (isProxyMode || !!state.value?.profile));
18
- watch(canAsk, async (ask) => {
19
- if (!ask) {
20
- mongoDbVersion.value = null;
21
- return;
18
+ async function loadDatabaseVersion() {
19
+ if (isProxyMode || state.value?.profile?.isAdmin === true) {
20
+ try {
21
+ const full = (await getServerInfo()).mongoDbVersion;
22
+ if (full) return full;
23
+ } catch {
24
+ }
22
25
  }
23
26
  try {
24
- mongoDbVersion.value = (await getServerInfo()).mongoDbVersion || null;
27
+ const major = (await getCapabilities()).mongoDbMajor;
28
+ return major ? String(major) : null;
25
29
  } catch {
26
- mongoDbVersion.value = null;
30
+ return null;
27
31
  }
32
+ }
33
+ watch(canAsk, async (ask) => {
34
+ mongoDbVersion.value = ask ? await loadDatabaseVersion() : null;
28
35
  }, { immediate: true });
29
36
  </script>
30
37
 
@@ -1,5 +1,5 @@
1
1
  type __VLS_Props = {
2
- /** Hide the MongoDB version badge (it is also hidden while the server cannot tell, e.g. before login or below server 1.9.0). */
2
+ /** Hide the MongoDB version badge (it is also hidden while the server cannot tell, e.g. before login). */
3
3
  hideDatabase?: boolean;
4
4
  };
5
5
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
@@ -1,5 +1,6 @@
1
1
  import { useMongocampClientApi } from "#imports";
2
2
  import { analysisSampleSize, analysisTimeoutMs } from "../utils/schemaAnalysis.js";
3
+ import { ignoringNotFound } from "../utils/serverError.js";
3
4
  const REQUEST_TIMEOUT_MS = 15e3;
4
5
  function withTimeout() {
5
6
  return { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) };
@@ -20,7 +21,7 @@ export default () => {
20
21
  });
21
22
  }
22
23
  async function deleteUser(userId) {
23
- return adminApi.deleteUser({ userId });
24
+ return await ignoringNotFound(() => adminApi.deleteUser({ userId })) ?? { value: true };
24
25
  }
25
26
  async function updateUserRoles(userId, roles) {
26
27
  return adminApi.updateRolesForUser({ userId, requestBody: roles });
@@ -47,20 +48,20 @@ export default () => {
47
48
  return adminApi.updateRole({ roleName, updateRoleRequest: { isAdmin, collectionGrants } });
48
49
  }
49
50
  async function deleteRole(roleName) {
50
- return adminApi.deleteRole({ roleName });
51
+ return await ignoringNotFound(() => adminApi.deleteRole({ roleName })) ?? { value: true };
51
52
  }
52
53
  async function clearCollection(collectionName) {
53
- return collectionApi.clearCollection({ collectionName }, withTimeout());
54
+ return await ignoringNotFound(() => collectionApi.clearCollection({ collectionName }, withTimeout())) ?? { value: true };
54
55
  }
55
56
  async function deleteCollection(collectionName) {
56
- return collectionApi.deleteCollection({ collectionName }, withTimeout());
57
+ return await ignoringNotFound(() => collectionApi.deleteCollection({ collectionName }, withTimeout())) ?? { value: true };
57
58
  }
58
59
  async function getJsonSchema(collectionName) {
59
60
  return collectionApi.getJsonSchema({ collectionName }, withTimeout());
60
61
  }
61
62
  async function getSchemaAnalysis(collectionName, documents, depth = 3) {
62
63
  const sampleSize = analysisSampleSize(documents);
63
- return collectionApi.getSchemaAnalysis({ collectionName, sampleSize, deepth: depth }, { signal: AbortSignal.timeout(analysisTimeoutMs(sampleSize)) });
64
+ return collectionApi.getSchemaAnalysis({ collectionName, sampleSize, depth }, { signal: AbortSignal.timeout(analysisTimeoutMs(sampleSize)) });
64
65
  }
65
66
  async function getUser(userId) {
66
67
  return adminApi.getUser({ userId }, withTimeout());
@@ -8,15 +8,23 @@ export interface AggregationOptions {
8
8
  /**
9
9
  * Lets the pipeline use `$collStats` / `$indexStats` (storage and index-usage numbers) — and nothing else from the
10
10
  * deny-list. Their results carry the database server's address, so `host` and `ns` are removed from every row.
11
- * For the module's own stats calls; the aggregation builder never sets it.
11
+ * The aggregation builder never sets it.
12
+ * @deprecated A stock MongoCamp 2.0 server refuses both stages (`AGGREGATION_STAGES_DENIED`); index usage comes from
13
+ * `useMongocampCollectionStats().getIndexUsage` (`GET …/index/stats`), storage numbers from `getStorage`.
12
14
  */
13
15
  allowStatsStages?: boolean;
14
16
  /**
15
17
  * A Lucene filter (the syntax of the document list) applied by the server as the first `$match` (server 1.7.0), so an
16
- * aggregation can follow what a table shows. It travels in the URL: one over ~1 800 encoded characters is refused up front
17
- * with a `FilterTooLongError` instead of becoming an opaque network failure.
18
+ * aggregation can follow what a table shows. It travels in the request body (server 2.2), so its length has no limit.
18
19
  */
19
20
  filter?: string;
21
+ /** Match the wildcards of `filter` without regard to case (server 2.0 matches them case-sensitively otherwise). */
22
+ filterCaseInsensitive?: boolean;
23
+ /**
24
+ * Skip the count (`count=none`, server 2.0) when only the rows are needed: the server does less work, and `total` is then
25
+ * the number of rows returned, `pages` 1.
26
+ */
27
+ skipCount?: boolean;
20
28
  /** Aborting rejects the call (an `AbortError`); the 30 s timeout still applies. */
21
29
  signal?: AbortSignal;
22
30
  }
@@ -1,9 +1,9 @@
1
1
  import { useMongocampClientApi, useI18n } from "#imports";
2
2
  import { useMongocampError } from "./useMongocampError.js";
3
3
  import { findForbidden, STATS_OPERATORS } from "../utils/aggregationPipeline.js";
4
- import { FilterTooLongError, ForbiddenPipelineError } from "../utils/aggregationErrors.js";
4
+ import { ForbiddenPipelineError } from "../utils/aggregationErrors.js";
5
+ import { sensitiveFieldReferences, sensitiveFieldsOf, sensitiveFieldsOfPipeline, withoutFieldsDeep } from "../utils/sensitiveFields.js";
5
6
  import { fieldPathsOf } from "../utils/fieldDetails.js";
6
- import { isFilterTooLong, MAX_ENCODED_FILTER_LENGTH } from "../utils/requestLimits.js";
7
7
  import { stripServerFields } from "../utils/aggregationResult.js";
8
8
  import { readJsonKeepingLongs } from "../utils/bigIntJson.js";
9
9
  import { headerNumber } from "../utils/paginationHeaders.js";
@@ -31,18 +31,25 @@ export function useMongocampAggregation() {
31
31
  async function runAggregation(collectionName, pipeline, paging = {}, options = {}) {
32
32
  const findings = findForbidden(pipeline, options.allowStatsStages ? STATS_OPERATORS : []);
33
33
  if (findings.length > 0) throw new ForbiddenPipelineError(findings);
34
- if (isFilterTooLong(options.filter)) throw new FilterTooLongError(MAX_ENCODED_FILTER_LENGTH);
34
+ const hiddenFields = sensitiveFieldsOfPipeline(collectionName, pipeline);
35
+ const hiddenUses = sensitiveFieldReferences(pipeline, hiddenFields);
36
+ if (hiddenUses.length > 0) {
37
+ throw new ForbiddenPipelineError(hiddenUses.map((use) => ({ stageIndex: use.stageIndex, operator: use.reference, path: use.reference, sensitive: true })));
38
+ }
35
39
  const page = paging.page ?? 1;
36
40
  const response = await collectionApi.aggregateRaw({
37
41
  collectionName,
38
42
  // the generated type says string values; the server takes any JSON. allowDiskUse is required.
39
- mongoAggregateRequest: { pipeline, allowDiskUse: false },
43
+ // the filter goes in the body (server 2.2) — no URL limit; in both places the server answers 400 (code 4004)
44
+ mongoAggregateRequest: { pipeline, allowDiskUse: false, filter: options.filter?.trim() ? options.filter : void 0 },
40
45
  rowsPerPage: paging.rowsPerPage,
41
46
  page,
42
- filter: options.filter?.trim() ? options.filter : void 0
47
+ filterCaseInsensitive: options.filter?.trim() ? options.filterCaseInsensitive : void 0,
48
+ count: options.skipCount ? "none" : void 0,
49
+ extendedJson: "relaxed"
43
50
  }, requestInit(AGGREGATE_TIMEOUT_MS, options.signal));
44
51
  const value = await readJsonKeepingLongs(response);
45
- const unwrapped = Array.isArray(value) ? value.filter(isPlainObject).map((row) => unwrapExtendedJson(row)) : [];
52
+ const unwrapped = (Array.isArray(value) ? value.filter(isPlainObject).map((row) => unwrapExtendedJson(row)) : []).map((row) => withoutFieldsDeep(row, hiddenFields));
46
53
  const rows = options.allowStatsStages ? stripServerFields(unwrapped) : unwrapped;
47
54
  const headers = response.raw?.headers;
48
55
  return {
@@ -59,6 +66,7 @@ export function useMongocampAggregation() {
59
66
  return fieldPathsOf(await listFieldDetails(collectionName));
60
67
  }
61
68
  async function listDistinct(collectionName, field, limit = DEFAULT_DISTINCT_LIMIT) {
69
+ if (sensitiveFieldsOf(collectionName).includes(field)) return { values: [], total: 0, truncated: false };
62
70
  const response = await collectionApi.distinctRaw({ collectionName, field, rowsPerPage: limit, page: 1 }, withTimeout(REQUEST_TIMEOUT_MS));
63
71
  const value = unwrapExtendedJson(await readJsonKeepingLongs(response));
64
72
  const values = (Array.isArray(value) ? value : []).filter((v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean");
@@ -67,12 +75,13 @@ export function useMongocampAggregation() {
67
75
  }
68
76
  async function sampleDocuments(collectionName, size = DEFAULT_SAMPLE_SIZE) {
69
77
  const clamped = Math.min(Math.max(Math.floor(size) || DEFAULT_SAMPLE_SIZE, 1), MAX_SAMPLE_SIZE);
70
- return runAggregation(collectionName, [{ stage: "$sample", value: { size: clamped } }], { page: 1, rowsPerPage: clamped });
78
+ return runAggregation(collectionName, [{ stage: "$sample", value: { size: clamped } }], { page: 1, rowsPerPage: clamped }, { skipCount: true });
71
79
  }
72
80
  async function describeAggregationError(error) {
73
- if (error instanceof FilterTooLongError) return { kind: "other", message: t("nuxtUiMongocamp.aggregation.errors.filterTooLong", { max: error.max }) };
74
81
  if (error instanceof ForbiddenPipelineError) {
75
- return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.forbidden", { operator: error.findings[0]?.operator ?? "" }) };
82
+ const first = error.findings[0];
83
+ if (first?.sensitive) return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.sensitiveField", { field: first.operator }) };
84
+ return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.forbidden", { operator: first?.operator ?? "" }) };
76
85
  }
77
86
  const server = await readServerError(error);
78
87
  if (server.code === OPERATOR_NOT_ALLOWED_CODE) {
@@ -86,7 +95,7 @@ export function useMongocampAggregation() {
86
95
  return { kind: server.kind ?? "other", message: server.message };
87
96
  }
88
97
  const described = describeError(error);
89
- const kind = described.kind === "forbidden" ? "forbidden-access" : described.kind === "notAllowed" || described.kind === "invalid" ? "other" : described.kind;
98
+ const kind = described.kind === "forbidden" ? "forbidden-access" : described.kind === "notAllowed" || described.kind === "invalid" || described.kind === "notFound" ? "other" : described.kind;
90
99
  return { kind, message: described.message };
91
100
  }
92
101
  return { runAggregation, listDistinct, listFieldNames, listFieldDetails, sampleDocuments, describeAggregationError };
@@ -1,5 +1,9 @@
1
1
  import type { BucketInformation, FileInformation } from '@sfxcode/nuxt-mongocamp-server';
2
2
  export interface ListFilesOptions {
3
+ /**
4
+ * A MongoDB query as JSON text (`{"filename":{"$regex":"png","$options":"i"}}`, see `filenameFilter`) — **not Lucene**: the
5
+ * file list ignores a Lucene string and returns every file.
6
+ */
3
7
  filter?: string;
4
8
  sort?: string;
5
9
  projection?: string;
@@ -2,6 +2,7 @@ import { ref } from "vue";
2
2
  import { useI18n, useMongocampClientApi, useToast } from "#imports";
3
3
  import { BUCKET_COLLECTION_SUFFIX } from "../utils/collectionProtection.js";
4
4
  import { isFilterTooLong, MAX_ENCODED_FILTER_LENGTH } from "../utils/requestLimits.js";
5
+ import { ignoringNotFound } from "../utils/serverError.js";
5
6
  function unwrapId(value) {
6
7
  if (typeof value === "string") return value;
7
8
  if (typeof value === "object" && value !== null && "$oid" in value) {
@@ -110,9 +111,9 @@ export function useMongocampBucket() {
110
111
  async function deleteFile(bucketName, fileId) {
111
112
  fileActionInFlight.value.add(fileId);
112
113
  try {
113
- const result = await fileApi.deleteFile({ bucketName, fileId });
114
+ const result = await ignoringNotFound(() => fileApi.deleteFile({ bucketName, fileId }));
114
115
  toast.add({ title: t("nuxtUiMongocamp.bucket.deletedTitle"), description: t("nuxtUiMongocamp.bucket.deletedDescription"), color: "success" });
115
- return result.wasAcknowledged;
116
+ return result ? result.wasAcknowledged : true;
116
117
  } catch (e) {
117
118
  toast.add({ title: t("nuxtUiMongocamp.bucket.deleteFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.deleteFailedFallback"), color: "error" });
118
119
  return false;
@@ -146,9 +147,9 @@ export function useMongocampBucket() {
146
147
  async function clearBucket(bucketName) {
147
148
  bucketActionInFlight.value.add(bucketName);
148
149
  try {
149
- const result = await bucketApi.clearBucket({ bucketName });
150
+ const result = await ignoringNotFound(() => bucketApi.clearBucket({ bucketName }));
150
151
  toast.add({ title: t("nuxtUiMongocamp.bucket.bucketClearedTitle"), description: t("nuxtUiMongocamp.bucket.bucketClearedDescription", { bucketName }), color: "success" });
151
- return result.value;
152
+ return result ? result.value : true;
152
153
  } catch (e) {
153
154
  toast.add({ title: t("nuxtUiMongocamp.bucket.clearFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.clearFailedFallback", { bucketName }), color: "error" });
154
155
  return false;
@@ -159,9 +160,9 @@ export function useMongocampBucket() {
159
160
  async function deleteBucket(bucketName) {
160
161
  bucketActionInFlight.value.add(bucketName);
161
162
  try {
162
- const result = await bucketApi.deleteBucket({ bucketName });
163
+ const result = await ignoringNotFound(() => bucketApi.deleteBucket({ bucketName }));
163
164
  toast.add({ title: t("nuxtUiMongocamp.bucket.bucketDeletedTitle"), description: t("nuxtUiMongocamp.bucket.bucketDeletedDescription", { bucketName }), color: "success" });
164
- return result.value;
165
+ return result ? result.value : true;
165
166
  } catch (e) {
166
167
  toast.add({ title: t("nuxtUiMongocamp.bucket.deleteFailedTitle"), description: e instanceof Error ? e.message : t("nuxtUiMongocamp.bucket.deleteFailedBucketFallback", { bucketName }), color: "error" });
167
168
  return false;
@@ -1,3 +1,4 @@
1
+ import type { FilterCallOptions } from '../utils/caseInsensitive.js';
1
2
  export interface BulkUpdateByFilterResult {
2
3
  matched: number;
3
4
  modified: number;
@@ -6,10 +7,11 @@ export interface BulkUpdateByFilterResult {
6
7
  * Count, delete and update by the **Lucene filter** of the list — one request each (server 1.7.0): no ids are collected,
7
8
  * so there is no cap, no id snapshot and nothing to chunk. An empty filter would touch the whole collection, which the
8
9
  * server only does with `matchAll=true`; it is sent exactly when the filter is empty, so the caller's own confirmation
9
- * (the typed collection name) is what guards that case. A filter the server cannot parse is answered 400 (nothing changes).
10
+ * (the typed collection name) is what guards that case. The last argument is an `AbortSignal` or
11
+ * `{ signal, filterCaseInsensitive }` (server 2.0: wildcards match case-sensitively unless that flag is set). A filter the server cannot parse is answered 400 (nothing changes).
10
12
  */
11
13
  export declare function useMongocampBulkByFilter(): {
12
- countDocuments: (collectionName: string, filter?: string, signal?: AbortSignal) => Promise<number>;
13
- deleteByFilter: (collectionName: string, filter?: string, signal?: AbortSignal) => Promise<number>;
14
- updateByFilter: (collectionName: string, filter: string | undefined, document: Record<string, unknown>, signal?: AbortSignal) => Promise<BulkUpdateByFilterResult>;
14
+ countDocuments: (collectionName: string, filter?: string, options?: AbortSignal | FilterCallOptions) => Promise<number>;
15
+ deleteByFilter: (collectionName: string, filter?: string, options?: AbortSignal | FilterCallOptions) => Promise<number>;
16
+ updateByFilter: (collectionName: string, filter: string | undefined, document: Record<string, unknown>, options?: AbortSignal | FilterCallOptions) => Promise<BulkUpdateByFilterResult>;
15
17
  };
@@ -1,20 +1,24 @@
1
1
  import { useMongocampClientApi } from "#imports";
2
+ import { filterCallOptions } from "../utils/caseInsensitive.js";
2
3
  export function useMongocampBulkByFilter() {
3
4
  const { documentApi } = useMongocampClientApi();
4
5
  const clean = (filter) => filter && filter.trim() !== "" ? filter : void 0;
5
- async function countDocuments(collectionName, filter, signal) {
6
- const response = await documentApi.countDocuments({ collectionName, filter: clean(filter) }, signal ? { signal } : void 0);
6
+ async function countDocuments(collectionName, filter, options) {
7
+ const { signal, filterCaseInsensitive } = filterCallOptions(options);
8
+ const response = await documentApi.countDocumentsByBody({ collectionName, countRequest: { filter: clean(filter) }, filterCaseInsensitive }, signal ? { signal } : void 0);
7
9
  return response.count;
8
10
  }
9
- async function deleteByFilter(collectionName, filter, signal) {
11
+ async function deleteByFilter(collectionName, filter, options) {
12
+ const { signal, filterCaseInsensitive } = filterCallOptions(options);
10
13
  const lucene = clean(filter);
11
14
  const response = await documentApi.deleteMany(
12
- { collectionName, requestBody: {}, filter: lucene, matchAll: lucene === void 0 ? true : void 0 },
15
+ { collectionName, requestBody: {}, filter: lucene, matchAll: lucene === void 0 ? true : void 0, filterCaseInsensitive },
13
16
  signal ? { signal } : void 0
14
17
  );
15
18
  return response.deletedCount;
16
19
  }
17
- async function updateByFilter(collectionName, filter, document, signal) {
20
+ async function updateByFilter(collectionName, filter, document, options) {
21
+ const { signal, filterCaseInsensitive } = filterCallOptions(options);
18
22
  const lucene = clean(filter);
19
23
  const response = await documentApi.updateMany(
20
24
  {
@@ -22,7 +26,8 @@ export function useMongocampBulkByFilter() {
22
26
  // the generated type says string values only; the server takes any JSON value
23
27
  updateRequest: { filter: {}, document },
24
28
  filter: lucene,
25
- matchAll: lucene === void 0 ? true : void 0
29
+ matchAll: lucene === void 0 ? true : void 0,
30
+ filterCaseInsensitive
26
31
  },
27
32
  signal ? { signal } : void 0
28
33
  );
@@ -3,6 +3,8 @@ export interface CopyOptions {
3
3
  target: string;
4
4
  /** Lucene filter: copy only the documents that match. */
5
5
  filter?: string;
6
+ /** Match the wildcards of `filter` without regard to case (server 2.0 matches them case-sensitively otherwise). */
7
+ filterCaseInsensitive?: boolean;
6
8
  /** Create the same indexes on the new collection (the server reproduces them from the real index specifications). */
7
9
  withIndexes?: boolean;
8
10
  signal?: AbortSignal;
@@ -41,5 +43,5 @@ export declare function useMongocampCollectionCopy(): {
41
43
  backupCollection: (options: BackupOptions) => Promise<CopyResult>;
42
44
  renameCollection: (source: string, target: string, signal?: AbortSignal) => Promise<RenameResult>;
43
45
  listCollectionNames: () => Promise<string[]>;
44
- countDocuments: (collectionName: string, filter?: string, signal?: AbortSignal) => Promise<number>;
46
+ countDocuments: (collectionName: string, filter?: string, options?: AbortSignal | import("../utils/caseInsensitive.js").FilterCallOptions) => Promise<number>;
45
47
  };
@@ -11,11 +11,13 @@ export function useMongocampCollectionCopy() {
11
11
  return await collectionApi.listCollections();
12
12
  }
13
13
  async function copyCollection(options) {
14
- const { source, target, filter, withIndexes, signal } = options;
14
+ const { source, target, filter, filterCaseInsensitive, withIndexes, signal } = options;
15
+ const lucene = filter?.trim() ? filter : void 0;
15
16
  try {
16
17
  const response = await collectionApi.copyCollection({
17
18
  collectionName: source,
18
- copyRequest: { target, filter: filter?.trim() ? filter : void 0, withIndexes: withIndexes ?? false }
19
+ copyRequest: { target, filter: lucene, withIndexes: withIndexes ?? false },
20
+ filterCaseInsensitive: lucene ? filterCaseInsensitive : void 0
19
21
  }, signal ? { signal } : void 0);
20
22
  return { target: response.name, count: response.count, indexes: response.indexes };
21
23
  } catch (error) {