@sfxcode/nuxt-ui-mongocamp 1.3.2 → 1.3.3

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.mts +12 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +18 -5
  5. package/dist/runtime/components/MongocampAggregationBuilder.vue +2 -2
  6. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -1
  7. package/dist/runtime/components/MongocampCollectionData.vue +67 -3
  8. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -1
  9. package/dist/runtime/components/MongocampCollectionInfos.vue +104 -8
  10. package/dist/runtime/components/MongocampCollections.d.vue.ts +8 -1
  11. package/dist/runtime/components/MongocampCollections.vue +84 -72
  12. package/dist/runtime/components/MongocampCollections.vue.d.ts +8 -1
  13. package/dist/runtime/components/MongocampConfirmByName.d.vue.ts +23 -0
  14. package/dist/runtime/components/MongocampConfirmByName.vue +92 -0
  15. package/dist/runtime/components/MongocampConfirmByName.vue.d.ts +23 -0
  16. package/dist/runtime/components/MongocampErrorAlert.vue +28 -5
  17. package/dist/runtime/components/MongocampGrantList.d.vue.ts +7 -0
  18. package/dist/runtime/components/MongocampGrantList.vue +38 -0
  19. package/dist/runtime/components/MongocampGrantList.vue.d.ts +7 -0
  20. package/dist/runtime/components/MongocampRoles.vue +45 -0
  21. package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
  22. package/dist/runtime/components/MongocampSettings.vue +179 -0
  23. package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
  24. package/dist/runtime/components/MongocampUsers.vue +183 -3
  25. package/dist/runtime/composables/useMongocampAdmin.d.ts +7 -1
  26. package/dist/runtime/composables/useMongocampAdmin.js +24 -1
  27. package/dist/runtime/composables/useMongocampAggregation.js +1 -0
  28. package/dist/runtime/composables/useMongocampBucket.js +1 -1
  29. package/dist/runtime/composables/useMongocampIndex.d.ts +1 -0
  30. package/dist/runtime/composables/useMongocampIndex.js +8 -1
  31. package/dist/runtime/composables/useMongocampRoles.d.ts +1 -0
  32. package/dist/runtime/composables/useMongocampRoles.js +3 -2
  33. package/dist/runtime/composables/useMongocampSession.d.ts +8 -0
  34. package/dist/runtime/composables/useMongocampSession.js +45 -0
  35. package/dist/runtime/composables/useMongocampSystem.d.ts +15 -3
  36. package/dist/runtime/composables/useMongocampSystem.js +19 -2
  37. package/dist/runtime/locales/de.json +61 -2
  38. package/dist/runtime/locales/en.json +61 -2
  39. package/dist/runtime/plugin.js +19 -0
  40. package/dist/runtime/utils/collectionProtection.d.ts +3 -0
  41. package/dist/runtime/utils/collectionProtection.js +7 -0
  42. package/dist/runtime/utils/configRows.d.ts +11 -0
  43. package/dist/runtime/utils/configRows.js +53 -0
  44. package/dist/runtime/utils/failureKind.d.ts +3 -0
  45. package/dist/runtime/utils/failureKind.js +11 -0
  46. package/dist/runtime/utils/jwtExpiry.d.ts +3 -0
  47. package/dist/runtime/utils/jwtExpiry.js +31 -0
  48. package/dist/runtime/utils/serverProbe.d.ts +10 -0
  49. package/dist/runtime/utils/serverProbe.js +25 -0
  50. package/dist/runtime/utils/sessionGuard.d.ts +10 -0
  51. package/dist/runtime/utils/sessionGuard.js +10 -0
  52. package/dist/runtime/utils/throttled.d.ts +6 -0
  53. package/dist/runtime/utils/throttled.js +16 -0
  54. package/package.json +1 -1
@@ -1,11 +1,12 @@
1
1
  <script setup>
2
- import { computed, h, reactive, ref, resolveComponent } from "vue";
3
- import { useI18n, useMongocampError, useMongocampStorage } from "#imports";
2
+ import { computed, h, reactive, ref, resolveComponent, watch } from "vue";
3
+ import { useI18n, useMongocampError, useMongocampStorage, useToast } from "#imports";
4
4
  import useMongocampAdmin from "../composables/useMongocampAdmin";
5
5
  import { runBulkDelete } from "../utils/bulkDelete";
6
6
  import { createSelectColumn } from "../utils/createSelectColumn";
7
7
  const { t } = useI18n();
8
- const { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles } = useMongocampAdmin();
8
+ const { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles, regenerateUserApiKey } = useMongocampAdmin();
9
+ const toast = useToast();
9
10
  const users = ref([]);
10
11
  const loading = ref(false);
11
12
  const filterText = ref("");
@@ -184,6 +185,51 @@ async function handleDeleteUser() {
184
185
  }
185
186
  }
186
187
  const UBadge = resolveComponent("UBadge");
188
+ const isKeyModalOpen = ref(false);
189
+ const keyUser = ref("");
190
+ const newApiKey = ref(null);
191
+ const keyBusy = ref(false);
192
+ const keyError = ref("");
193
+ function confirmRegenerateKey(userId) {
194
+ keyUser.value = userId;
195
+ newApiKey.value = null;
196
+ keyError.value = "";
197
+ isKeyModalOpen.value = true;
198
+ }
199
+ async function handleRegenerateKey() {
200
+ if (isSelf(keyUser.value) || keyBusy.value) return;
201
+ keyBusy.value = true;
202
+ keyError.value = "";
203
+ try {
204
+ newApiKey.value = await regenerateUserApiKey(keyUser.value);
205
+ await fetchUsers();
206
+ } catch (e) {
207
+ keyError.value = describeError(e).message;
208
+ } finally {
209
+ keyBusy.value = false;
210
+ }
211
+ }
212
+ async function copyNewApiKey() {
213
+ if (!newApiKey.value) return;
214
+ await navigator.clipboard.writeText(newApiKey.value);
215
+ toast.add({ title: t("nuxtUiMongocamp.account.copiedTitle"), description: t("nuxtUiMongocamp.account.copiedDescription"), color: "success" });
216
+ }
217
+ watch(isKeyModalOpen, (isOpen) => {
218
+ if (isOpen) return;
219
+ newApiKey.value = null;
220
+ keyError.value = "";
221
+ });
222
+ const isDetailOpen = ref(false);
223
+ const detail = ref(null);
224
+ function openDetail(user) {
225
+ detail.value = {
226
+ user: user.user,
227
+ isAdmin: user.isAdmin,
228
+ roles: [...user.roles ?? []],
229
+ grants: (user.grants ?? []).map((g) => ({ ...g }))
230
+ };
231
+ isDetailOpen.value = true;
232
+ }
187
233
  const UButton = resolveComponent("UButton");
188
234
  const UTooltip = resolveComponent("UTooltip");
189
235
  const UCheckbox = resolveComponent("UCheckbox");
@@ -253,6 +299,14 @@ const columns = computed(() => [
253
299
  id: "actions",
254
300
  header: "",
255
301
  cell: ({ row }) => h("div", { class: "flex gap-1 justify-end" }, [
302
+ withTooltip(t("nuxtUiMongocamp.users.detailsTooltip"), h(UButton, {
303
+ "icon": "i-lucide-info",
304
+ "color": "neutral",
305
+ "variant": "ghost",
306
+ "size": "sm",
307
+ "aria-label": t("nuxtUiMongocamp.users.detailsTooltip"),
308
+ "onClick": () => openDetail(row.original)
309
+ })),
256
310
  withTooltip(t("nuxtUiMongocamp.users.editUserTooltip"), h(UButton, {
257
311
  "icon": "i-lucide-pencil",
258
312
  "color": "neutral",
@@ -261,6 +315,14 @@ const columns = computed(() => [
261
315
  "aria-label": t("nuxtUiMongocamp.users.editUserTooltip"),
262
316
  "onClick": () => openEdit(row.original)
263
317
  })),
318
+ isSelf(row.original.user) ? null : withTooltip(t("nuxtUiMongocamp.users.regenerateKeyTooltip"), h(UButton, {
319
+ "icon": "i-lucide-key-round",
320
+ "color": "warning",
321
+ "variant": "ghost",
322
+ "size": "sm",
323
+ "aria-label": t("nuxtUiMongocamp.users.regenerateKeyTooltip"),
324
+ "onClick": () => confirmRegenerateKey(row.original.user)
325
+ })),
264
326
  deleteButton(row.original.user)
265
327
  ])
266
328
  }
@@ -407,5 +469,123 @@ fetchRoles();
407
469
  />
408
470
  </template>
409
471
  </UModal>
472
+
473
+ <UModal
474
+ v-model:open="isKeyModalOpen"
475
+ :title="t('nuxtUiMongocamp.users.regenerateKeyTitle', { userId: keyUser })"
476
+ :dismissible="!keyBusy"
477
+ :ui="{ footer: 'justify-end' }"
478
+ >
479
+ <template #body>
480
+ <div
481
+ v-if="newApiKey"
482
+ class="flex flex-col gap-2"
483
+ >
484
+ <p class="text-sm text-warning-500">
485
+ {{ t("nuxtUiMongocamp.account.apiKeyOnceWarning") }}
486
+ </p>
487
+ <div class="flex items-center gap-2">
488
+ <UInput
489
+ :model-value="newApiKey"
490
+ readonly
491
+ class="flex-1 font-mono text-xs"
492
+ :aria-label="t('nuxtUiMongocamp.users.newApiKeyLabel')"
493
+ />
494
+ <UButton
495
+ icon="i-lucide-copy"
496
+ :label="t('nuxtUiMongocamp.common.copy')"
497
+ color="neutral"
498
+ variant="subtle"
499
+ @click="copyNewApiKey"
500
+ />
501
+ </div>
502
+ </div>
503
+ <template v-else>
504
+ <p>{{ t("nuxtUiMongocamp.users.confirmRegenerateKey", { userId: keyUser }) }}</p>
505
+ <UAlert
506
+ v-if="keyError"
507
+ class="mt-3"
508
+ color="error"
509
+ variant="subtle"
510
+ icon="i-lucide-circle-alert"
511
+ :description="keyError"
512
+ />
513
+ </template>
514
+ </template>
515
+ <template #footer>
516
+ <template v-if="newApiKey">
517
+ <UButton
518
+ :label="t('nuxtUiMongocamp.common.dismiss')"
519
+ @click="isKeyModalOpen = false"
520
+ />
521
+ </template>
522
+ <template v-else>
523
+ <UButton
524
+ :label="t('nuxtUiMongocamp.common.cancel')"
525
+ color="neutral"
526
+ variant="ghost"
527
+ :disabled="keyBusy"
528
+ @click="isKeyModalOpen = false"
529
+ />
530
+ <UButton
531
+ :label="t('nuxtUiMongocamp.account.regenerate')"
532
+ color="error"
533
+ icon="i-lucide-key-round"
534
+ :loading="keyBusy"
535
+ @click="handleRegenerateKey"
536
+ />
537
+ </template>
538
+ </template>
539
+ </UModal>
540
+
541
+ <USlideover
542
+ v-model:open="isDetailOpen"
543
+ :title="t('nuxtUiMongocamp.users.detailsTitle', { userId: detail?.user ?? '' })"
544
+ :ui="{ content: 'sm:max-w-xl' }"
545
+ >
546
+ <template #body>
547
+ <div
548
+ v-if="detail"
549
+ class="flex flex-col gap-4"
550
+ >
551
+ <div class="flex items-center gap-2">
552
+ <UBadge
553
+ :label="detail.isAdmin ? t('nuxtUiMongocamp.users.roleAdmin') : t('nuxtUiMongocamp.users.roleUser')"
554
+ :color="detail.isAdmin ? 'error' : 'neutral'"
555
+ variant="subtle"
556
+ />
557
+ </div>
558
+ <section class="flex flex-col gap-2">
559
+ <h3 class="text-sm font-semibold">
560
+ {{ t("nuxtUiMongocamp.users.detailsRoles") }}
561
+ </h3>
562
+ <div
563
+ v-if="detail.roles.length"
564
+ class="flex flex-wrap gap-1"
565
+ >
566
+ <UBadge
567
+ v-for="role in detail.roles"
568
+ :key="role"
569
+ :label="role"
570
+ color="primary"
571
+ variant="subtle"
572
+ />
573
+ </div>
574
+ <p
575
+ v-else
576
+ class="text-sm text-dimmed"
577
+ >
578
+ {{ t("nuxtUiMongocamp.users.detailsNoRoles") }}
579
+ </p>
580
+ </section>
581
+ <section class="flex flex-col gap-2">
582
+ <h3 class="text-sm font-semibold">
583
+ {{ t("nuxtUiMongocamp.users.detailsGrants") }}
584
+ </h3>
585
+ <MongocampGrantList :grants="detail.grants" />
586
+ </section>
587
+ </div>
588
+ </template>
589
+ </USlideover>
410
590
  </div>
411
591
  </template>
@@ -1,4 +1,4 @@
1
- import type { Grant, Role, UserProfile } from '@sfxcode/nuxt-mongocamp-server';
1
+ import type { Grant, JsonSchema, Role, UserProfile } from '@sfxcode/nuxt-mongocamp-server';
2
2
  declare const _default: () => {
3
3
  listUsers: (filter?: string) => Promise<UserProfile[]>;
4
4
  addUser: (userId: string, password: string, apiKey?: string, roles?: string[]) => Promise<UserProfile>;
@@ -10,5 +10,11 @@ declare const _default: () => {
10
10
  updateRole: (roleName: string, isAdmin: boolean, collectionGrants?: Grant[]) => Promise<Role>;
11
11
  deleteRole: (roleName: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
12
12
  listCollections: () => Promise<string[]>;
13
+ clearCollection: (collectionName: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
14
+ deleteCollection: (collectionName: string) => Promise<import("@sfxcode/nuxt-mongocamp-server").JsonValueBoolean>;
15
+ getJsonSchema: (collectionName: string) => Promise<JsonSchema>;
16
+ getUser: (userId: string) => Promise<UserProfile>;
17
+ getRole: (roleName: string) => Promise<Role>;
18
+ regenerateUserApiKey: (userId: string) => Promise<string>;
13
19
  };
14
20
  export default _default;
@@ -1,4 +1,8 @@
1
1
  import { useMongocampClientApi } from "#imports";
2
+ const REQUEST_TIMEOUT_MS = 15e3;
3
+ function withTimeout() {
4
+ return { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) };
5
+ }
2
6
  export default () => {
3
7
  const { adminApi, collectionApi } = useMongocampClientApi();
4
8
  async function listUsers(filter = "") {
@@ -44,5 +48,24 @@ export default () => {
44
48
  async function deleteRole(roleName) {
45
49
  return adminApi.deleteRole({ roleName });
46
50
  }
47
- return { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles, addRole, updateRole, deleteRole, listCollections };
51
+ async function clearCollection(collectionName) {
52
+ return collectionApi.clearCollection({ collectionName }, withTimeout());
53
+ }
54
+ async function deleteCollection(collectionName) {
55
+ return collectionApi.deleteCollection({ collectionName }, withTimeout());
56
+ }
57
+ async function getJsonSchema(collectionName) {
58
+ return collectionApi.getJsonSchema({ collectionName }, withTimeout());
59
+ }
60
+ async function getUser(userId) {
61
+ return adminApi.getUser({ userId }, withTimeout());
62
+ }
63
+ async function getRole(roleName) {
64
+ return adminApi.getRole({ roleName }, withTimeout());
65
+ }
66
+ async function regenerateUserApiKey(userId) {
67
+ const result = await adminApi.gnerateNewApiKeyForUser({ userId }, withTimeout());
68
+ return result.value;
69
+ }
70
+ return { listUsers, addUser, deleteUser, updateUserRoles, updateUserPassword, listRoles, addRole, updateRole, deleteRole, listCollections, clearCollection, deleteCollection, getJsonSchema, getUser, getRole, regenerateUserApiKey };
48
71
  };
@@ -82,6 +82,7 @@ export function useMongocampAggregation() {
82
82
  const response = error?.response;
83
83
  const status = response?.status;
84
84
  if (status === 405) return { kind: "retryable", message: t("nuxtUiMongocamp.aggregation.errors.retryable") };
85
+ if (status === 503) return { kind: "retryable", message: t("nuxtUiMongocamp.aggregation.errors.unavailable") };
85
86
  if (response && status !== void 0 && status >= 400 && status !== 401 && status !== 403) {
86
87
  try {
87
88
  const body = await response.clone().json();
@@ -1,6 +1,6 @@
1
1
  import { ref } from "vue";
2
2
  import { useI18n, useMongocampClientApi, useToast } from "#imports";
3
- const BUCKET_COLLECTION_SUFFIX = /\.(?:files|chunks)$/;
3
+ import { BUCKET_COLLECTION_SUFFIX } from "../utils/collectionProtection.js";
4
4
  function unwrapId(value) {
5
5
  if (typeof value === "string") return value;
6
6
  if (typeof value === "object" && value !== null && "$oid" in value) {
@@ -2,6 +2,7 @@ import type { IndexCreateResponse, IndexDropResponse, IndexOptionsRequest, Mongo
2
2
  export declare function useMongocampIndex(): {
3
3
  listIndexes: (collectionName: string) => Promise<MongoIndex[]>;
4
4
  createIndex: (collectionName: string, keys: Record<string, number>, options?: IndexOptionsRequest) => Promise<IndexCreateResponse>;
5
+ createIndexForField: (collectionName: string, fieldName: string, sortAscending?: boolean) => Promise<IndexCreateResponse>;
5
6
  createUniqueIndex: (collectionName: string, fieldName: string, sortAscending?: boolean) => Promise<IndexCreateResponse>;
6
7
  createTextIndex: (collectionName: string, fieldName: string) => Promise<IndexCreateResponse>;
7
8
  createExpiringIndex: (collectionName: string, fieldName: string, duration: string) => Promise<IndexCreateResponse>;
@@ -1,4 +1,8 @@
1
1
  import { useMongocampClientApi } from "#imports";
2
+ const REQUEST_TIMEOUT_MS = 15e3;
3
+ function withTimeout() {
4
+ return { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) };
5
+ }
2
6
  export function useMongocampIndex() {
3
7
  const { indexApi } = useMongocampClientApi();
4
8
  async function listIndexes(collectionName) {
@@ -7,6 +11,9 @@ export function useMongocampIndex() {
7
11
  async function createIndex(collectionName, keys, options) {
8
12
  return indexApi.createIndex({ collectionName, indexCreateRequest: { keys, indexOptionsRequest: options } });
9
13
  }
14
+ async function createIndexForField(collectionName, fieldName, sortAscending = true) {
15
+ return indexApi.createIndexForField({ collectionName, fieldName, sortAscending }, withTimeout());
16
+ }
10
17
  async function createUniqueIndex(collectionName, fieldName, sortAscending) {
11
18
  return indexApi.createUniqueIndex({ collectionName, fieldName, sortAscending });
12
19
  }
@@ -19,5 +26,5 @@ export function useMongocampIndex() {
19
26
  async function deleteIndex(collectionName, indexName) {
20
27
  return indexApi.deleteIndex({ collectionName, indexName });
21
28
  }
22
- return { listIndexes, createIndex, createUniqueIndex, createTextIndex, createExpiringIndex, deleteIndex };
29
+ return { listIndexes, createIndex, createIndexForField, createUniqueIndex, createTextIndex, createExpiringIndex, deleteIndex };
23
30
  }
@@ -5,5 +5,6 @@ export declare function useMongocampRoles(): {
5
5
  notAllowedPath: string;
6
6
  logoutRedirectPath: string;
7
7
  logoutPath: string;
8
+ loginPath: string;
8
9
  isAllowedPathForRoute: (route: string) => boolean;
9
10
  };
@@ -9,6 +9,7 @@ export function useMongocampRoles() {
9
9
  const notAllowedPath = config.public.nuxtUiMongocampOptions.notAllowedPath ?? "/";
10
10
  const logoutRedirectPath = config.public.nuxtUiMongocampOptions.logoutRedirectPath ?? "/";
11
11
  const logoutPath = config.public.nuxtUiMongocampOptions.logoutPath ?? "/logout";
12
+ const loginPath = config.public.nuxtUiMongocampOptions.loginPath ?? "/";
12
13
  const managerRoles = config.public.nuxtUiMongocampOptions.managerRoles ?? [];
13
14
  const securedRouteParts = config.public.nuxtUiMongocampOptions.securedRouteParts ?? [];
14
15
  const managementRouteParts = config.public.nuxtUiMongocampOptions.managementRouteParts ?? [];
@@ -23,7 +24,7 @@ export function useMongocampRoles() {
23
24
  return patterns.some((pattern) => minimatch(route, pattern) || minimatch(`${route}/`, pattern));
24
25
  }
25
26
  function isAllowedPathForRoute(route) {
26
- if (route === notAllowedPath || route === logoutRedirectPath) {
27
+ if (route === notAllowedPath || route === logoutRedirectPath || route === loginPath) {
27
28
  return true;
28
29
  }
29
30
  if (!isLoggedIn.value && matchesAnyPattern(route, securedRouteParts)) {
@@ -35,5 +36,5 @@ export function useMongocampRoles() {
35
36
  }
36
37
  return true;
37
38
  }
38
- return { isLoggedIn, isAdmin, isManager, notAllowedPath, logoutRedirectPath, logoutPath, isAllowedPathForRoute };
39
+ return { isLoggedIn, isAdmin, isManager, notAllowedPath, logoutRedirectPath, logoutPath, loginPath, isAllowedPathForRoute };
39
40
  }
@@ -0,0 +1,8 @@
1
+ import type { TokenExpiryState } from '../utils/jwtExpiry.js';
2
+ export type SessionState = 'active' | 'expired' | 'rejected' | 'unknown';
3
+ export declare function useMongocampSession(): {
4
+ checkExpiry: () => TokenExpiryState;
5
+ currentState: () => SessionState;
6
+ diagnoseFailure: () => Promise<SessionState>;
7
+ invalidateSession: () => Promise<void>;
8
+ };
@@ -0,0 +1,45 @@
1
+ import { useRuntimeConfig } from "#app";
2
+ import { useMongocampAuth, useMongocampClientApi, useMongocampStorage } from "#imports";
3
+ import { tokenExpiryState } from "../utils/jwtExpiry.js";
4
+ import { createServerProbe } from "../utils/serverProbe.js";
5
+ import { createThrottled } from "../utils/throttled.js";
6
+ let probe;
7
+ let tokenAccepted;
8
+ let authApi;
9
+ const TOKEN_CHECK_TIMEOUT_MS = 5e3;
10
+ export function useMongocampSession() {
11
+ const config = useRuntimeConfig();
12
+ const { logout } = useMongocampAuth();
13
+ const storage = useMongocampStorage();
14
+ const isProxyMode = config.public.nuxtUiMongocampOptions?.useServerProxy ?? false;
15
+ probe ??= createServerProbe({ getUrl: () => config.public.mongocamp?.url });
16
+ if (!isProxyMode) authApi = useMongocampClientApi().authApi;
17
+ tokenAccepted ??= createThrottled(async () => {
18
+ try {
19
+ return (await authApi.isAuthenticated({ signal: AbortSignal.timeout(TOKEN_CHECK_TIMEOUT_MS) })).value === true;
20
+ } catch {
21
+ return false;
22
+ }
23
+ });
24
+ function checkExpiry() {
25
+ if (isProxyMode) return "unknown";
26
+ const token = storage.value?.token;
27
+ return typeof token === "string" && token ? tokenExpiryState(token) : "unknown";
28
+ }
29
+ function currentState() {
30
+ const expiry = checkExpiry();
31
+ return expiry === "valid" ? "active" : expiry;
32
+ }
33
+ async function diagnoseFailure() {
34
+ const expiry = checkExpiry();
35
+ if (expiry === "expired") return "expired";
36
+ if (isProxyMode || !storage.value?.token) return "unknown";
37
+ if (await probe() !== "reachable") return "unknown";
38
+ return await tokenAccepted() ? "active" : "rejected";
39
+ }
40
+ async function invalidateSession() {
41
+ if (isProxyMode) return;
42
+ await logout();
43
+ }
44
+ return { checkExpiry, currentState, diagnoseFailure, invalidateSession };
45
+ }
@@ -1,12 +1,24 @@
1
1
  import type { DatabaseInfo } from '@sfxcode/nuxt-mongocamp-server';
2
+ import type { ConfigRow } from '../utils/configRows.js';
3
+ export interface ServerPlugins {
4
+ routesPlugins: string[];
5
+ filePlugins: string[];
6
+ ignoredPlugins: string[];
7
+ }
2
8
  /**
3
- * Read-only wrapper for databaseApi. Deliberately scoped to databases only —
4
- * deleteDatabase is out of scope (cross-cutting, highly destructive), and
5
- * applicationApi (settings/configuration) is not wrapped here at all for now.
9
+ * Read-only wrapper for databaseApi and applicationApi. Deliberately read-only —
10
+ * deleteDatabase, shutdown and updateConfiguration are out of scope (cross-cutting, highly
11
+ * destructive) and not exposed. The server's settings and configuration payloads contain real secrets
12
+ * (auth secret, database credentials and host), so the settings methods never hand them out:
13
+ * `getSettings` returns the plugin lists only, and the configuration methods return rows that are
14
+ * already masked (see utils/configRows.ts).
6
15
  */
7
16
  export declare function useMongocampSystem(): {
8
17
  listDatabases: () => Promise<string[]>;
9
18
  getDatabaseInfos: () => Promise<DatabaseInfo[]>;
10
19
  getDatabaseInfo: (databaseName: string) => Promise<DatabaseInfo>;
11
20
  listCollectionsByDatabase: (databaseName: string) => Promise<string[]>;
21
+ getSettings: () => Promise<ServerPlugins>;
22
+ listConfigurations: () => Promise<ConfigRow[]>;
23
+ getConfig: (configurationKey: string) => Promise<ConfigRow>;
12
24
  };
@@ -1,10 +1,11 @@
1
1
  import { useMongocampClientApi } from "#imports";
2
+ import { buildConfigRows } from "../utils/configRows.js";
2
3
  const REQUEST_TIMEOUT_MS = 15e3;
3
4
  function withTimeout() {
4
5
  return { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) };
5
6
  }
6
7
  export function useMongocampSystem() {
7
- const { databaseApi } = useMongocampClientApi();
8
+ const { databaseApi, applicationApi } = useMongocampClientApi();
8
9
  async function listDatabases() {
9
10
  return databaseApi.listDatabases(withTimeout());
10
11
  }
@@ -17,5 +18,21 @@ export function useMongocampSystem() {
17
18
  async function listCollectionsByDatabase(databaseName) {
18
19
  return databaseApi.listCollectionsByDatabase({ databaseName }, withTimeout());
19
20
  }
20
- return { listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase };
21
+ async function getSettings() {
22
+ const settings = await applicationApi.settings(withTimeout());
23
+ return {
24
+ routesPlugins: settings.routesPlugins ?? [],
25
+ filePlugins: settings.filePlugins ?? [],
26
+ ignoredPlugins: settings.ignoredPlugins ?? []
27
+ };
28
+ }
29
+ async function listConfigurations() {
30
+ return buildConfigRows(await applicationApi.listConfigurations(withTimeout()));
31
+ }
32
+ async function getConfig(configurationKey) {
33
+ const [row] = buildConfigRows([await applicationApi.getConfig({ configurationKey }, withTimeout())]);
34
+ if (!row) throw new Error(`The server returned no usable configuration for "${configurationKey}"`);
35
+ return row;
36
+ }
37
+ return { listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase, getSettings, listConfigurations, getConfig };
21
38
  }
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "nuxtUiMongocamp": {
3
+ "confirmByName": {
4
+ "prompt": "Zur Bestätigung \"{name}\" eingeben"
5
+ },
3
6
  "common": {
4
7
  "cancel": "Abbrechen",
5
8
  "delete": "Löschen",
@@ -27,6 +30,15 @@
27
30
  "addUser": "Benutzer hinzufügen",
28
31
  "editUserTitle": "Benutzer bearbeiten: {userId}",
29
32
  "deleteUserTitle": "Benutzer löschen",
33
+ "detailsTooltip": "Details",
34
+ "detailsTitle": "Benutzer: {userId}",
35
+ "detailsRoles": "Rollen",
36
+ "detailsNoRoles": "Keine Rollen zugewiesen",
37
+ "detailsGrants": "Wirksame Berechtigungen",
38
+ "regenerateKeyTooltip": "API-Schlüssel neu erzeugen",
39
+ "regenerateKeyTitle": "API-Schlüssel neu erzeugen: {userId}",
40
+ "confirmRegenerateKey": "Möchten Sie den API-Schlüssel von {userId} wirklich neu erzeugen? Der bisherige Schlüssel ist sofort ungültig, und alles, was ihn noch verwendet, wird abgewiesen.",
41
+ "newApiKeyLabel": "Neuer API-Schlüssel",
30
42
  "confirmDelete": "Möchten Sie den Benutzer {userId} wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",
31
43
  "email": "E-Mail",
32
44
  "password": "Passwort",
@@ -52,6 +64,9 @@
52
64
  "addRole": "Rolle hinzufügen",
53
65
  "editRoleTitle": "Rolle bearbeiten: {roleName}",
54
66
  "deleteRoleTitle": "Rolle löschen",
67
+ "detailsTooltip": "Details",
68
+ "detailsTitle": "Rolle: {roleName}",
69
+ "detailsGrants": "Berechtigungen",
55
70
  "confirmDelete": "Möchten Sie die Rolle {roleName} wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",
56
71
  "roleName": "Rollenname",
57
72
  "adminRole": "Admin-Rolle",
@@ -105,7 +120,18 @@
105
120
  "clearBucketTitle": "Bucket leeren",
106
121
  "confirmClearBucket": "Möchten Sie wirklich alle Dateien im Bucket \"{bucketName}\" löschen? Der Bucket selbst bleibt erhalten, aber alle darin enthaltenen Dateien werden dauerhaft entfernt. Diese Aktion kann nicht rückgängig gemacht werden.",
107
122
  "deleteBucketTitle": "Bucket löschen",
108
- "confirmDeleteBucket": "Möchten Sie den Bucket \"{bucketName}\" wirklich löschen? Dadurch werden sowohl die Collection \"{bucketName}.files\" als auch \"{bucketName}.chunks\" dauerhaft entfernt. Diese Aktion kann nicht rückgängig gemacht werden."
123
+ "confirmDeleteBucket": "Möchten Sie den Bucket \"{bucketName}\" wirklich löschen? Dadurch werden sowohl die Collection \"{bucketName}.files\" als auch \"{bucketName}.chunks\" dauerhaft entfernt. Diese Aktion kann nicht rückgängig gemacht werden.",
124
+ "clearTooltip": "Collection leeren",
125
+ "dropTooltip": "Collection löschen",
126
+ "clearTitle": "Collection leeren",
127
+ "dropTitle": "Collection löschen",
128
+ "confirmClear": "Dadurch werden alle Dokumente in \"{name}\" dauerhaft gelöscht. Die Collection selbst bleibt erhalten. Diese Aktion kann nicht rückgängig gemacht werden.",
129
+ "confirmDrop": "Dadurch wird die Collection \"{name}\" samt allen Dokumenten und Indizes dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",
130
+ "clearedTitle": "Collection geleert",
131
+ "clearedDescription": "Alle Dokumente in \"{name}\" wurden gelöscht.",
132
+ "droppedTitle": "Collection gelöscht",
133
+ "droppedDescription": "Die Collection \"{name}\" wurde gelöscht.",
134
+ "bucketActionFailed": "Die Aktion für den Bucket \"{bucketName}\" ist fehlgeschlagen."
109
135
  },
110
136
  "collectionInfos": {
111
137
  "documents": "Dokumente",
@@ -119,6 +145,11 @@
119
145
  "copyAsTs": "Als TS-Interface kopieren",
120
146
  "copiedTitle": "In die Zwischenablage kopiert",
121
147
  "copiedDescription": "TypeScript-Interface kopiert.",
148
+ "jsonSchema": "JSON-Schema",
149
+ "jsonSchemaTitle": "JSON-Schema von {name}",
150
+ "jsonSchemaFailedTitle": "Das JSON-Schema konnte nicht geladen werden",
151
+ "downloadSchema": "Herunterladen",
152
+ "schemaCopiedDescription": "JSON-Schema kopiert.",
122
153
  "fieldsCount": "{count} Felder",
123
154
  "columnField": "Feld",
124
155
  "columnType": "Typ",
@@ -157,6 +188,13 @@
157
188
  "uploadFileTooltip": "Datei hochladen",
158
189
  "insertDocumentTooltip": "Dokument einfügen",
159
190
  "reloadTooltip": "Neu laden",
191
+ "indexFieldTooltip": "{field} indizieren",
192
+ "indexAscending": "Aufsteigenden Index anlegen",
193
+ "indexDescending": "Absteigenden Index anlegen",
194
+ "indexCreatedTitle": "Index angelegt",
195
+ "indexCreatedDescription": "Der Index {name} auf {collection} wurde angelegt.",
196
+ "viewIndexes": "Indizes anzeigen",
197
+ "indexFailedTitle": "{field} konnte nicht indiziert werden",
160
198
  "detailsTitle": "Details",
161
199
  "insertDocumentTitle": "Dokument einfügen",
162
200
  "editDocumentTitle": "Dokument bearbeiten",
@@ -256,6 +294,25 @@
256
294
  "changeFailedTitle": "Änderung fehlgeschlagen",
257
295
  "changeFailedFallback": "Ihr Passwort konnte nicht geändert werden."
258
296
  },
297
+ "settings": {
298
+ "heading": "Servereinstellungen",
299
+ "loadFailedTitle": "Die Servereinstellungen konnten nicht geladen werden",
300
+ "adminOnly": "Nur Administratoren können die Servereinstellungen einsehen.",
301
+ "pluginsHeading": "Plugins",
302
+ "routesPlugins": "Routen-Plugins",
303
+ "filePlugins": "Datei-Plugins",
304
+ "ignoredPlugins": "Ignorierte Plugins",
305
+ "noPlugins": "Keine",
306
+ "searchPlaceholder": "Einstellungen durchsuchen...",
307
+ "maskedNote": "Geheime Werte (Passwörter, Schlüssel, Zugangsdaten, Hosts) werden nie angezeigt.",
308
+ "maskedHint": "Verborgen: dieser Wert ist geheim",
309
+ "columnKey": "Einstellung",
310
+ "columnValue": "Wert",
311
+ "columnType": "Typ",
312
+ "columnRestart": "Neustart",
313
+ "restartNeeded": "Neustart nötig",
314
+ "empty": "Keine Einstellungen gefunden"
315
+ },
259
316
  "databases": {
260
317
  "heading": "Datenbanken",
261
318
  "columnDatabase": "Datenbank",
@@ -298,6 +355,7 @@
298
355
  "forbidden": "Dafür fehlt dir die Berechtigung.",
299
356
  "generic": "Etwas ist schiefgelaufen.",
300
357
  "loginAgain": "Erneut anmelden",
358
+ "requestRefused": "Der Server ist erreichbar und Ihre Sitzung ist gültig, hat diese Anfrage aber abgelehnt. Versuchen Sie es erneut oder ändern Sie Ihre Anfrage.",
301
359
  "filterRejectedTitle": "Der Filter konnte nicht angewendet werden",
302
360
  "filterRejected": "Der Server hat die aktuelle Suche oder die Filter abgelehnt, obwohl die Collection selbst lädt. Setze sie zurück oder entferne die letzte Bedingung und versuche es erneut.",
303
361
  "clearFilters": "Filter zurücksetzen"
@@ -447,7 +505,8 @@
447
505
  "aggregation": {
448
506
  "errors": {
449
507
  "forbidden": "Diese Pipeline verwendet {operator}, was hier nicht erlaubt ist.",
450
- "retryable": "Die Anfrage wurde auf dem Weg zum Server blockiert. Bitte erneut versuchen."
508
+ "retryable": "Die Anfrage wurde auf dem Weg zum Server blockiert. Bitte erneut versuchen.",
509
+ "unavailable": "Der Server hat diese Anfrage nicht beantwortet. Möglicherweise liefert die Pipeline keine Ergebnisse; versuche es erneut oder lockere den Filter."
451
510
  },
452
511
  "modeVisual": "Stufen",
453
512
  "modeJson": "JSON",