@sfxcode/nuxt-ui-mongocamp 1.5.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +5 -5
  2. package/dist/module.d.mts +17 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +4 -0
  5. package/dist/runtime/components/MongocampAccount.vue +12 -14
  6. package/dist/runtime/components/MongocampAggregationBuilder.d.vue.ts +1 -0
  7. package/dist/runtime/components/MongocampAggregationBuilder.vue +32 -45
  8. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +1 -0
  9. package/dist/runtime/components/MongocampAggregationChart.vue +7 -5
  10. package/dist/runtime/components/MongocampAggregationStagePreview.d.vue.ts +1 -0
  11. package/dist/runtime/components/MongocampAggregationStagePreview.vue +5 -3
  12. package/dist/runtime/components/MongocampAggregationStagePreview.vue.d.ts +1 -0
  13. package/dist/runtime/components/MongocampBucketFiles.vue +29 -40
  14. package/dist/runtime/components/MongocampBulkDelete.vue +8 -9
  15. package/dist/runtime/components/MongocampBulkEdit.vue +5 -4
  16. package/dist/runtime/components/MongocampChart.vue +1 -1
  17. package/dist/runtime/components/MongocampCollectionCharts.d.vue.ts +1 -0
  18. package/dist/runtime/components/MongocampCollectionCharts.vue +10 -7
  19. package/dist/runtime/components/MongocampCollectionCharts.vue.d.ts +1 -0
  20. package/dist/runtime/components/MongocampCollectionCopy.d.vue.ts +1 -0
  21. package/dist/runtime/components/MongocampCollectionCopy.vue +11 -9
  22. package/dist/runtime/components/MongocampCollectionCopy.vue.d.ts +1 -0
  23. package/dist/runtime/components/MongocampCollectionData.vue +97 -87
  24. package/dist/runtime/components/MongocampCollectionInfos.vue +34 -24
  25. package/dist/runtime/components/MongocampCollectionRename.vue +5 -4
  26. package/dist/runtime/components/MongocampCollections.vue +24 -33
  27. package/dist/runtime/components/MongocampCommandPalette.vue +3 -1
  28. package/dist/runtime/components/MongocampConfirmByName.vue +5 -4
  29. package/dist/runtime/components/MongocampDashboard.vue +5 -3
  30. package/dist/runtime/components/MongocampDatabases.vue +14 -8
  31. package/dist/runtime/components/MongocampDocumentCompare.vue +6 -4
  32. package/dist/runtime/components/MongocampDocumentView.vue +12 -9
  33. package/dist/runtime/components/MongocampEmptyState.vue +4 -1
  34. package/dist/runtime/components/MongocampErrorAlert.vue +8 -7
  35. package/dist/runtime/components/MongocampExportAll.d.vue.ts +1 -0
  36. package/dist/runtime/components/MongocampExportAll.vue +19 -7
  37. package/dist/runtime/components/MongocampExportAll.vue.d.ts +1 -0
  38. package/dist/runtime/components/MongocampFilePreview.vue +7 -6
  39. package/dist/runtime/components/MongocampFilterBuilder.vue +12 -16
  40. package/dist/runtime/components/MongocampGrantList.vue +6 -2
  41. package/dist/runtime/components/MongocampImport.vue +32 -28
  42. package/dist/runtime/components/MongocampIndexes.vue +21 -19
  43. package/dist/runtime/components/MongocampJobs.vue +20 -20
  44. package/dist/runtime/components/MongocampLogin.vue +2 -1
  45. package/dist/runtime/components/MongocampPermissionMatrix.vue +14 -11
  46. package/dist/runtime/components/MongocampQueryBar.vue +33 -32
  47. package/dist/runtime/components/MongocampRoleGrants.vue +21 -17
  48. package/dist/runtime/components/MongocampRoles.vue +28 -32
  49. package/dist/runtime/components/MongocampServerInfo.vue +17 -25
  50. package/dist/runtime/components/MongocampServerOverview.vue +16 -12
  51. package/dist/runtime/components/MongocampServerStatus.vue +9 -3
  52. package/dist/runtime/components/MongocampSettings.vue +15 -11
  53. package/dist/runtime/components/MongocampUserAccess.vue +11 -6
  54. package/dist/runtime/components/MongocampUsers.vue +32 -35
  55. package/dist/runtime/components/MongocampVersion.d.vue.ts +1 -1
  56. package/dist/runtime/components/MongocampVersion.vue +20 -11
  57. package/dist/runtime/components/MongocampVersion.vue.d.ts +1 -1
  58. package/dist/runtime/composables/useMongocampAdmin.js +6 -5
  59. package/dist/runtime/composables/useMongocampAggregation.d.ts +10 -1
  60. package/dist/runtime/composables/useMongocampAggregation.js +17 -5
  61. package/dist/runtime/composables/useMongocampBucket.d.ts +4 -0
  62. package/dist/runtime/composables/useMongocampBucket.js +7 -6
  63. package/dist/runtime/composables/useMongocampBulkByFilter.d.ts +6 -4
  64. package/dist/runtime/composables/useMongocampBulkByFilter.js +11 -6
  65. package/dist/runtime/composables/useMongocampCollectionCopy.d.ts +3 -1
  66. package/dist/runtime/composables/useMongocampCollectionCopy.js +4 -2
  67. package/dist/runtime/composables/useMongocampCollectionStats.js +2 -4
  68. package/dist/runtime/composables/useMongocampError.d.ts +1 -1
  69. package/dist/runtime/composables/useMongocampError.js +4 -1
  70. package/dist/runtime/composables/useMongocampExportAll.d.ts +10 -1
  71. package/dist/runtime/composables/useMongocampExportAll.js +4 -1
  72. package/dist/runtime/composables/useMongocampFetchAll.d.ts +11 -5
  73. package/dist/runtime/composables/useMongocampFetchAll.js +8 -8
  74. package/dist/runtime/composables/useMongocampJobs.js +3 -2
  75. package/dist/runtime/composables/useMongocampQuery.d.ts +26 -36
  76. package/dist/runtime/composables/useMongocampQuery.js +45 -48
  77. package/dist/runtime/composables/useMongocampSchema.js +2 -0
  78. package/dist/runtime/composables/useMongocampUi.d.ts +8 -0
  79. package/dist/runtime/composables/useMongocampUi.js +7 -0
  80. package/dist/runtime/locales/de.json +12 -4
  81. package/dist/runtime/locales/en.json +12 -4
  82. package/dist/runtime/plugin.js +8 -0
  83. package/dist/runtime/publicUtils.d.ts +1 -0
  84. package/dist/runtime/publicUtils.js +1 -0
  85. package/dist/runtime/server/handlers/mongocampProxy.d.ts +1 -1
  86. package/dist/runtime/server/handlers/mongocampProxy.js +12 -12
  87. package/dist/runtime/utils/aggregationPipeline.d.ts +2 -1
  88. package/dist/runtime/utils/aggregationPipeline.js +2 -3
  89. package/dist/runtime/utils/caseInsensitive.d.ts +10 -0
  90. package/dist/runtime/utils/caseInsensitive.js +8 -0
  91. package/dist/runtime/utils/collectionStats.d.ts +4 -1
  92. package/dist/runtime/utils/collectionStats.js +2 -2
  93. package/dist/runtime/utils/compactSession.d.ts +13 -0
  94. package/dist/runtime/utils/compactSession.js +12 -0
  95. package/dist/runtime/utils/configRows.d.ts +3 -3
  96. package/dist/runtime/utils/cursorPaging.d.ts +16 -0
  97. package/dist/runtime/utils/cursorPaging.js +17 -0
  98. package/dist/runtime/utils/documentCompare.js +2 -3
  99. package/dist/runtime/utils/documentPaths.d.ts +5 -5
  100. package/dist/runtime/utils/documentPaths.js +9 -2
  101. package/dist/runtime/utils/documentTree.js +3 -0
  102. package/dist/runtime/utils/fileFilter.d.ts +7 -0
  103. package/dist/runtime/utils/fileFilter.js +11 -0
  104. package/dist/runtime/utils/filterBuilder.d.ts +1 -1
  105. package/dist/runtime/utils/filterBuilder.js +5 -11
  106. package/dist/runtime/utils/filterSuggestions.js +1 -1
  107. package/dist/runtime/utils/indexForm.d.ts +7 -0
  108. package/dist/runtime/utils/indexForm.js +9 -0
  109. package/dist/runtime/utils/pagedFetch.d.ts +13 -0
  110. package/dist/runtime/utils/pagedFetch.js +44 -0
  111. package/dist/runtime/utils/queryState.d.ts +5 -0
  112. package/dist/runtime/utils/queryState.js +3 -2
  113. package/dist/runtime/utils/relaxedValues.d.ts +17 -0
  114. package/dist/runtime/utils/relaxedValues.js +51 -0
  115. package/dist/runtime/utils/requestLimits.d.ts +1 -1
  116. package/dist/runtime/utils/requestLimits.js +1 -1
  117. package/dist/runtime/utils/savedQueries.d.ts +2 -0
  118. package/dist/runtime/utils/savedQueries.js +1 -0
  119. package/dist/runtime/utils/schemaAnalysis.d.ts +4 -4
  120. package/dist/runtime/utils/schemaAnalysis.js +2 -2
  121. package/dist/runtime/utils/sensitiveFields.d.ts +20 -0
  122. package/dist/runtime/utils/sensitiveFields.js +63 -0
  123. package/dist/runtime/utils/serverError.d.ts +7 -0
  124. package/dist/runtime/utils/serverError.js +11 -0
  125. package/dist/runtime/utils/serverStatus.d.ts +2 -2
  126. package/dist/runtime/utils/uiTheme.d.ts +65 -0
  127. package/dist/runtime/utils/uiTheme.js +47 -0
  128. package/package.json +22 -16
  129. package/dist/runtime/utils/luceneExpression.d.ts +0 -15
  130. package/dist/runtime/utils/luceneExpression.js +0 -74
@@ -6,12 +6,14 @@ import { runBulkDelete } from "../utils/bulkDelete";
6
6
  import { createSelectColumn } from "../utils/createSelectColumn";
7
7
  import { createListPagination } from "../utils/listPagination";
8
8
  import { useMongocampAdminGate } from "../composables/useMongocampAdminGate";
9
+ import { useMongocampUi } from "../composables/useMongocampUi";
9
10
  defineProps({
10
11
  hideHeading: { type: Boolean, required: false },
11
12
  hideRefresh: { type: Boolean, required: false }
12
13
  });
13
14
  const emit = defineEmits(["changed"]);
14
15
  const { t } = useI18n();
16
+ const ui = useMongocampUi();
15
17
  const { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles, regenerateUserApiKey } = useMongocampAdmin();
16
18
  const toast = useToast();
17
19
  const users = ref([]);
@@ -256,8 +258,7 @@ function withTooltip(text, node) {
256
258
  function sortHeader(column, label) {
257
259
  const isSorted = column.getIsSorted();
258
260
  return h(UButton, {
259
- color: "neutral",
260
- variant: "ghost",
261
+ ...ui.value.sortHeader,
261
262
  label,
262
263
  icon: isSorted === "asc" ? "i-lucide-arrow-up-narrow-wide" : isSorted === "desc" ? "i-lucide-arrow-down-wide-narrow" : "i-lucide-arrow-up-down",
263
264
  class: "-mx-2.5",
@@ -267,9 +268,8 @@ function sortHeader(column, label) {
267
268
  function deleteButton(userId) {
268
269
  const button = (disabled) => h(UButton, {
269
270
  "icon": "i-lucide-trash-2",
271
+ ...ui.value.iconButton,
270
272
  "color": "error",
271
- "variant": "ghost",
272
- "size": "sm",
273
273
  "aria-label": t("nuxtUiMongocamp.users.deleteUserTooltip"),
274
274
  disabled,
275
275
  "onClick": () => confirmDelete(userId)
@@ -295,7 +295,7 @@ const columns = computed(() => [
295
295
  cell: ({ row }) => h(UBadge, {
296
296
  label: row.original.isAdmin ? t("nuxtUiMongocamp.users.roleAdmin") : t("nuxtUiMongocamp.users.roleUser"),
297
297
  color: row.original.isAdmin ? "primary" : "neutral",
298
- variant: "subtle"
298
+ variant: ui.value.badge.variant
299
299
  })
300
300
  },
301
301
  {
@@ -308,35 +308,30 @@ const columns = computed(() => [
308
308
  return h(
309
309
  "div",
310
310
  { class: "flex flex-wrap gap-1" },
311
- roles.map((role) => h(UBadge, { label: role, color: "primary", variant: "subtle" }))
311
+ roles.map((role) => h(UBadge, { label: role, color: "primary", variant: ui.value.badge.variant }))
312
312
  );
313
313
  }
314
314
  },
315
315
  {
316
316
  id: "actions",
317
317
  header: "",
318
- cell: ({ row }) => h("div", { class: "flex gap-1 justify-end" }, [
318
+ cell: ({ row }) => h("div", { "class": "flex gap-1 justify-end", "data-mongocamp-part": "row-actions" }, [
319
319
  withTooltip(t("nuxtUiMongocamp.users.detailsTooltip"), h(UButton, {
320
320
  "icon": "i-lucide-info",
321
- "color": "neutral",
322
- "variant": "ghost",
323
- "size": "sm",
321
+ ...ui.value.iconButton,
324
322
  "aria-label": t("nuxtUiMongocamp.users.detailsTooltip"),
325
323
  "onClick": () => openDetail(row.original)
326
324
  })),
327
325
  withTooltip(t("nuxtUiMongocamp.users.editUserTooltip"), h(UButton, {
328
326
  "icon": "i-lucide-pencil",
329
- "color": "neutral",
330
- "variant": "ghost",
331
- "size": "sm",
327
+ ...ui.value.iconButton,
332
328
  "aria-label": t("nuxtUiMongocamp.users.editUserTooltip"),
333
329
  "onClick": () => openEdit(row.original)
334
330
  })),
335
331
  isSelf(row.original.user) ? null : withTooltip(t("nuxtUiMongocamp.users.regenerateKeyTooltip"), h(UButton, {
336
332
  "icon": "i-lucide-key-round",
333
+ ...ui.value.iconButton,
337
334
  "color": "warning",
338
- "variant": "ghost",
339
- "size": "sm",
340
335
  "aria-label": t("nuxtUiMongocamp.users.regenerateKeyTooltip"),
341
336
  "onClick": () => confirmRegenerateKey(row.original.user)
342
337
  })),
@@ -354,27 +349,32 @@ defineExpose({ refresh: fetchUsers });
354
349
  <template>
355
350
  <MongocampEmptyState
356
351
  v-if="blocked"
352
+ class="mongocamp-users"
357
353
  icon="i-lucide-shield-alert"
358
354
  :title="message"
359
355
  data-test="admin-only"
360
356
  />
361
357
  <div
362
358
  v-else
363
- class="flex flex-col gap-4"
359
+ class="mongocamp-users flex flex-col gap-4"
364
360
  >
365
361
  <div class="flex items-center justify-between gap-4">
366
362
  <h2
367
363
  v-if="!hideHeading"
364
+ data-mongocamp-part="heading"
368
365
  class="text-xl font-semibold"
369
366
  >
370
367
  {{ t("nuxtUiMongocamp.users.heading") }}
371
368
  </h2>
372
- <div class="flex flex-1 items-center gap-2">
369
+ <div
370
+ data-mongocamp-part="toolbar"
371
+ class="flex flex-1 items-center gap-2"
372
+ >
373
373
  <UInput
374
374
  v-model="filterText"
375
375
  icon="i-lucide-search"
376
376
  :placeholder="t('nuxtUiMongocamp.users.searchPlaceholder')"
377
- size="sm"
377
+ :size="ui.controlSize"
378
378
  class="flex-1 max-w-xs"
379
379
  @input="onFilterInput"
380
380
  />
@@ -384,8 +384,7 @@ defineExpose({ refresh: fetchUsers });
384
384
  >
385
385
  <UButton
386
386
  icon="i-lucide-refresh-cw"
387
- color="neutral"
388
- variant="ghost"
387
+ v-bind="ui.toolbarButton"
389
388
  :loading="loading"
390
389
  :aria-label="t('nuxtUiMongocamp.common.refresh')"
391
390
  @click="fetchUsers"
@@ -418,6 +417,7 @@ defineExpose({ refresh: fetchUsers });
418
417
  v-model:sorting="sorting"
419
418
  v-model:row-selection="rowSelection"
420
419
  v-model:pagination="pagination"
420
+ data-mongocamp-part="table"
421
421
  :pagination-options="paginationOptions"
422
422
  :get-row-id="(row) => row.user"
423
423
  :row-selection-options="{ enableRowSelection: canSelectUser }"
@@ -488,7 +488,7 @@ defineExpose({ refresh: fetchUsers });
488
488
  <UModal
489
489
  v-model:open="isDeleteModalOpen"
490
490
  :title="t('nuxtUiMongocamp.users.deleteUserTitle')"
491
- :ui="{ footer: 'justify-end' }"
491
+ :ui="{ footer: ui.modal.footer }"
492
492
  >
493
493
  <template #body>
494
494
  <p>{{ t("nuxtUiMongocamp.users.confirmDelete", { userId: userToDelete }) }}</p>
@@ -496,7 +496,7 @@ defineExpose({ refresh: fetchUsers });
496
496
  v-if="deleteError"
497
497
  class="mt-3"
498
498
  color="error"
499
- variant="subtle"
499
+ :variant="ui.alert.variant"
500
500
  icon="i-lucide-circle-alert"
501
501
  :description="deleteError"
502
502
  />
@@ -504,14 +504,13 @@ defineExpose({ refresh: fetchUsers });
504
504
  <template #footer>
505
505
  <UButton
506
506
  :label="t('nuxtUiMongocamp.common.cancel')"
507
- color="neutral"
508
- variant="ghost"
507
+ v-bind="ui.dialogCancel"
509
508
  :disabled="deleting"
510
509
  @click="isDeleteModalOpen = false"
511
510
  />
512
511
  <UButton
513
512
  :label="t('nuxtUiMongocamp.common.delete')"
514
- color="error"
513
+ v-bind="ui.dangerAction"
515
514
  :loading="deleting"
516
515
  @click="handleDeleteUser"
517
516
  />
@@ -522,7 +521,7 @@ defineExpose({ refresh: fetchUsers });
522
521
  v-model:open="isKeyModalOpen"
523
522
  :title="t('nuxtUiMongocamp.users.regenerateKeyTitle', { userId: keyUser })"
524
523
  :dismissible="!keyBusy"
525
- :ui="{ footer: 'justify-end' }"
524
+ :ui="{ footer: ui.modal.footer }"
526
525
  >
527
526
  <template #body>
528
527
  <div
@@ -542,8 +541,7 @@ defineExpose({ refresh: fetchUsers });
542
541
  <UButton
543
542
  icon="i-lucide-copy"
544
543
  :label="t('nuxtUiMongocamp.common.copy')"
545
- color="neutral"
546
- variant="subtle"
544
+ v-bind="ui.secondaryAction"
547
545
  @click="copyNewApiKey"
548
546
  />
549
547
  </div>
@@ -554,7 +552,7 @@ defineExpose({ refresh: fetchUsers });
554
552
  v-if="keyError"
555
553
  class="mt-3"
556
554
  color="error"
557
- variant="subtle"
555
+ :variant="ui.alert.variant"
558
556
  icon="i-lucide-circle-alert"
559
557
  :description="keyError"
560
558
  />
@@ -570,14 +568,13 @@ defineExpose({ refresh: fetchUsers });
570
568
  <template v-else>
571
569
  <UButton
572
570
  :label="t('nuxtUiMongocamp.common.cancel')"
573
- color="neutral"
574
- variant="ghost"
571
+ v-bind="ui.dialogCancel"
575
572
  :disabled="keyBusy"
576
573
  @click="isKeyModalOpen = false"
577
574
  />
578
575
  <UButton
579
576
  :label="t('nuxtUiMongocamp.account.regenerate')"
580
- color="error"
577
+ v-bind="ui.dangerAction"
581
578
  icon="i-lucide-key-round"
582
579
  :loading="keyBusy"
583
580
  @click="handleRegenerateKey"
@@ -589,7 +586,7 @@ defineExpose({ refresh: fetchUsers });
589
586
  <USlideover
590
587
  v-model:open="isDetailOpen"
591
588
  :title="t('nuxtUiMongocamp.users.detailsTitle', { userId: detail?.user ?? '' })"
592
- :ui="{ content: 'sm:max-w-xl' }"
589
+ :ui="{ content: ui.modal.md }"
593
590
  >
594
591
  <template #body>
595
592
  <div
@@ -600,7 +597,7 @@ defineExpose({ refresh: fetchUsers });
600
597
  <UBadge
601
598
  :label="detail.isAdmin ? t('nuxtUiMongocamp.users.roleAdmin') : t('nuxtUiMongocamp.users.roleUser')"
602
599
  :color="detail.isAdmin ? 'primary' : 'neutral'"
603
- variant="subtle"
600
+ :variant="ui.badge.variant"
604
601
  />
605
602
  </div>
606
603
  <section class="flex flex-col gap-2">
@@ -616,7 +613,7 @@ defineExpose({ refresh: fetchUsers });
616
613
  :key="role"
617
614
  :label="role"
618
615
  color="primary"
619
- variant="subtle"
616
+ :variant="ui.badge.variant"
620
617
  />
621
618
  </div>
622
619
  <p
@@ -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<{}>, {
@@ -2,36 +2,45 @@
2
2
  import { computed, ref, watch } from "vue";
3
3
  import { useI18n, useMongocampProxyMode, useMongocampStorage, useMongocampSystem } from "#imports";
4
4
  import { useNuxtApp } from "#app";
5
+ import { useMongocampUi } from "../composables/useMongocampUi";
5
6
  const props = defineProps({
6
7
  hideDatabase: { type: Boolean, required: false, default: false }
7
8
  });
8
9
  const { t } = useI18n();
10
+ const ui = useMongocampUi();
9
11
  const { $mongocampVersion } = useNuxtApp();
10
- const { getServerInfo } = useMongocampSystem();
12
+ const { getServerInfo, getCapabilities } = useMongocampSystem();
11
13
  const state = useMongocampStorage();
12
14
  const isProxyMode = useMongocampProxyMode();
13
15
  const version = computed(() => $mongocampVersion.value);
14
16
  const mongoDbVersion = ref(null);
15
17
  const canAsk = computed(() => !props.hideDatabase && (isProxyMode || !!state.value?.profile));
16
- watch(canAsk, async (ask) => {
17
- if (!ask) {
18
- mongoDbVersion.value = null;
19
- 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
+ }
20
25
  }
21
26
  try {
22
- mongoDbVersion.value = (await getServerInfo()).mongoDbVersion || null;
27
+ const major = (await getCapabilities()).mongoDbMajor;
28
+ return major ? String(major) : null;
23
29
  } catch {
24
- mongoDbVersion.value = null;
30
+ return null;
25
31
  }
32
+ }
33
+ watch(canAsk, async (ask) => {
34
+ mongoDbVersion.value = ask ? await loadDatabaseVersion() : null;
26
35
  }, { immediate: true });
27
36
  </script>
28
37
 
29
38
  <template>
30
- <span class="inline-flex items-center gap-1.5">
39
+ <span class="mongocamp-version inline-flex items-center gap-1.5">
31
40
  <UBadge
32
41
  v-if="version"
33
42
  color="primary"
34
- variant="subtle"
43
+ :variant="ui.badge.variant"
35
44
  icon="i-lucide-database"
36
45
  >
37
46
  {{ version.name }} v{{ version.version }}
@@ -39,7 +48,7 @@ watch(canAsk, async (ask) => {
39
48
  <UBadge
40
49
  v-else
41
50
  color="neutral"
42
- variant="subtle"
51
+ :variant="ui.badge.variant"
43
52
  icon="i-lucide-database-zap"
44
53
  >
45
54
  {{ t("nuxtUiMongocamp.version.unavailable") }}
@@ -47,7 +56,7 @@ watch(canAsk, async (ask) => {
47
56
  <UBadge
48
57
  v-if="mongoDbVersion"
49
58
  color="neutral"
50
- variant="subtle"
59
+ :variant="ui.badge.variant"
51
60
  icon="i-simple-icons-mongodb"
52
61
  data-testid="mongodb-version"
53
62
  >
@@ -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,7 +8,9 @@ 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
  /**
@@ -17,6 +19,13 @@ export interface AggregationOptions {
17
19
  * with a `FilterTooLongError` instead of becoming an opaque network failure.
18
20
  */
19
21
  filter?: string;
22
+ /** Match the wildcards of `filter` without regard to case (server 2.0 matches them case-sensitively otherwise). */
23
+ filterCaseInsensitive?: boolean;
24
+ /**
25
+ * Skip the count (`count=none`, server 2.0) when only the rows are needed: the server does less work, and `total` is then
26
+ * the number of rows returned, `pages` 1.
27
+ */
28
+ skipCount?: boolean;
20
29
  /** Aborting rejects the call (an `AbortError`); the 30 s timeout still applies. */
21
30
  signal?: AbortSignal;
22
31
  }
@@ -2,6 +2,7 @@ import { useMongocampClientApi, useI18n } from "#imports";
2
2
  import { useMongocampError } from "./useMongocampError.js";
3
3
  import { findForbidden, STATS_OPERATORS } from "../utils/aggregationPipeline.js";
4
4
  import { FilterTooLongError, ForbiddenPipelineError } from "../utils/aggregationErrors.js";
5
+ import { sensitiveFieldReferences, sensitiveFieldsOf, sensitiveFieldsOfPipeline, withoutFieldsDeep } from "../utils/sensitiveFields.js";
5
6
  import { fieldPathsOf } from "../utils/fieldDetails.js";
6
7
  import { isFilterTooLong, MAX_ENCODED_FILTER_LENGTH } from "../utils/requestLimits.js";
7
8
  import { stripServerFields } from "../utils/aggregationResult.js";
@@ -31,6 +32,11 @@ export function useMongocampAggregation() {
31
32
  async function runAggregation(collectionName, pipeline, paging = {}, options = {}) {
32
33
  const findings = findForbidden(pipeline, options.allowStatsStages ? STATS_OPERATORS : []);
33
34
  if (findings.length > 0) throw new ForbiddenPipelineError(findings);
35
+ const hiddenFields = sensitiveFieldsOfPipeline(collectionName, pipeline);
36
+ const hiddenUses = sensitiveFieldReferences(pipeline, hiddenFields);
37
+ if (hiddenUses.length > 0) {
38
+ throw new ForbiddenPipelineError(hiddenUses.map((use) => ({ stageIndex: use.stageIndex, operator: use.reference, path: use.reference, sensitive: true })));
39
+ }
34
40
  if (isFilterTooLong(options.filter)) throw new FilterTooLongError(MAX_ENCODED_FILTER_LENGTH);
35
41
  const page = paging.page ?? 1;
36
42
  const response = await collectionApi.aggregateRaw({
@@ -39,10 +45,13 @@ export function useMongocampAggregation() {
39
45
  mongoAggregateRequest: { pipeline, allowDiskUse: false },
40
46
  rowsPerPage: paging.rowsPerPage,
41
47
  page,
42
- filter: options.filter?.trim() ? options.filter : void 0
48
+ filter: options.filter?.trim() ? options.filter : void 0,
49
+ filterCaseInsensitive: options.filter?.trim() ? options.filterCaseInsensitive : void 0,
50
+ count: options.skipCount ? "none" : void 0,
51
+ extendedJson: "relaxed"
43
52
  }, requestInit(AGGREGATE_TIMEOUT_MS, options.signal));
44
53
  const value = await readJsonKeepingLongs(response);
45
- const unwrapped = Array.isArray(value) ? value.filter(isPlainObject).map((row) => unwrapExtendedJson(row)) : [];
54
+ const unwrapped = (Array.isArray(value) ? value.filter(isPlainObject).map((row) => unwrapExtendedJson(row)) : []).map((row) => withoutFieldsDeep(row, hiddenFields));
46
55
  const rows = options.allowStatsStages ? stripServerFields(unwrapped) : unwrapped;
47
56
  const headers = response.raw?.headers;
48
57
  return {
@@ -59,6 +68,7 @@ export function useMongocampAggregation() {
59
68
  return fieldPathsOf(await listFieldDetails(collectionName));
60
69
  }
61
70
  async function listDistinct(collectionName, field, limit = DEFAULT_DISTINCT_LIMIT) {
71
+ if (sensitiveFieldsOf(collectionName).includes(field)) return { values: [], total: 0, truncated: false };
62
72
  const response = await collectionApi.distinctRaw({ collectionName, field, rowsPerPage: limit, page: 1 }, withTimeout(REQUEST_TIMEOUT_MS));
63
73
  const value = unwrapExtendedJson(await readJsonKeepingLongs(response));
64
74
  const values = (Array.isArray(value) ? value : []).filter((v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean");
@@ -67,12 +77,14 @@ export function useMongocampAggregation() {
67
77
  }
68
78
  async function sampleDocuments(collectionName, size = DEFAULT_SAMPLE_SIZE) {
69
79
  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 });
80
+ return runAggregation(collectionName, [{ stage: "$sample", value: { size: clamped } }], { page: 1, rowsPerPage: clamped }, { skipCount: true });
71
81
  }
72
82
  async function describeAggregationError(error) {
73
83
  if (error instanceof FilterTooLongError) return { kind: "other", message: t("nuxtUiMongocamp.aggregation.errors.filterTooLong", { max: error.max }) };
74
84
  if (error instanceof ForbiddenPipelineError) {
75
- return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.forbidden", { operator: error.findings[0]?.operator ?? "" }) };
85
+ const first = error.findings[0];
86
+ if (first?.sensitive) return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.sensitiveField", { field: first.operator }) };
87
+ return { kind: "forbidden", message: t("nuxtUiMongocamp.aggregation.errors.forbidden", { operator: first?.operator ?? "" }) };
76
88
  }
77
89
  const server = await readServerError(error);
78
90
  if (server.code === OPERATOR_NOT_ALLOWED_CODE) {
@@ -86,7 +98,7 @@ export function useMongocampAggregation() {
86
98
  return { kind: server.kind ?? "other", message: server.message };
87
99
  }
88
100
  const described = describeError(error);
89
- const kind = described.kind === "forbidden" ? "forbidden-access" : described.kind === "notAllowed" || described.kind === "invalid" ? "other" : described.kind;
101
+ const kind = described.kind === "forbidden" ? "forbidden-access" : described.kind === "notAllowed" || described.kind === "invalid" || described.kind === "notFound" ? "other" : described.kind;
90
102
  return { kind, message: described.message };
91
103
  }
92
104
  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.countDocuments({ collectionName, 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) {
@@ -1,16 +1,14 @@
1
1
  import { useMongocampClientApi } from "#imports";
2
2
  import { mapIndexUsage, mapStorage } from "../utils/collectionStats.js";
3
- import { useMongocampAggregation } from "./useMongocampAggregation.js";
4
3
  const REQUEST_TIMEOUT_MS = 15e3;
5
4
  export function useMongocampCollectionStats() {
6
- const { collectionApi } = useMongocampClientApi();
7
- const { runAggregation } = useMongocampAggregation();
5
+ const { collectionApi, indexApi } = useMongocampClientApi();
8
6
  async function getStorage(collection) {
9
7
  const status = await collectionApi.getCollectionInformation({ collectionName: collection }, { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
10
8
  return mapStorage(status);
11
9
  }
12
10
  async function getIndexUsage(collection) {
13
- const { rows } = await runAggregation(collection, [{ stage: "$indexStats", value: {} }], { rowsPerPage: 1e3 }, { allowStatsStages: true });
11
+ const rows = await indexApi.indexStats({ collectionName: collection }, { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
14
12
  return mapIndexUsage(rows);
15
13
  }
16
14
  return { getStorage, getIndexUsage };
@@ -1,4 +1,4 @@
1
- export type MongocampErrorKind = 'network' | 'unauthorized' | 'forbidden' | 'notAllowed' | 'invalid' | 'other';
1
+ export type MongocampErrorKind = 'network' | 'unauthorized' | 'forbidden' | 'notAllowed' | 'invalid' | 'notFound' | 'other';
2
2
  export interface DescribedError {
3
3
  kind: MongocampErrorKind;
4
4
  message: string;