@sfxcode/nuxt-ui-mongocamp 1.5.0 → 1.5.1

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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ A Nuxt module that wraps [`@sfxcode/nuxt-mongocamp-server`](https://www.npmjs.co
12
12
 
13
13
  ## Requirements
14
14
 
15
- MongoCamp server **1.8.1 or later** (with `@sfxcode/nuxt-mongocamp-server` ^1.8.0). Older servers are not supported — the module uses the 1.7/1.8 endpoints directly (counts, search, batch info, copy/rename, ordered indexes, typed reads, streaming export/import). See [Server 1.8](/guide/server-1-8).
15
+ MongoCamp server **1.8.1 or later** (with `@sfxcode/nuxt-mongocamp-server` ^1.8.0). Older servers are not supported — the module uses the 1.7/1.8 endpoints directly (counts, search, batch info, copy/rename, ordered indexes, typed reads, streaming export/import). Server **1.9.0** adds the MongoDB version badge and the `MongocampServerInfo` panel (`/system/info`, `/system/stats`, `/system/capabilities`); both degrade quietly on 1.8.x. See [Server 1.8](/guide/server-1-8).
16
16
 
17
17
  ## Features
18
18
 
package/dist/module.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "1.5.0",
7
+ "version": "1.5.1",
8
8
  "builder": {
9
- "@nuxt/module-builder": "1.0.3",
9
+ "@nuxt/module-builder": "1.0.4",
10
10
  "unbuild": "3.6.1"
11
11
  }
12
12
  }
@@ -31,9 +31,7 @@ onMounted(() => {
31
31
  observer.observe(root.value);
32
32
  });
33
33
  onBeforeUnmount(() => observer?.disconnect());
34
- const FALLBACK_COLORS = ["var(--ui-primary, #16a34a)", "#3b82f6", "#8b5cf6", "#f59e0b", "#f43f5e", "#06b6d4"];
35
- const COLORS = FALLBACK_COLORS.map((fallback, i) => `var(--ui-chart-${i + 1}, ${fallback})`);
36
- const CHART_UI = { base: "opacity-100" };
34
+ const COLORS = Array.from({ length: 6 }, (_, i) => `var(--ui-chart-${i + 1})`);
37
35
  const AXIS_LABEL_MAX = 18;
38
36
  const chartData = computed(() => {
39
37
  if (props.type === "donut") return props.data;
@@ -67,7 +65,6 @@ const show = (value) => typeof value === "number" && props.format ? props.format
67
65
  :index="index"
68
66
  :categories="categories"
69
67
  :colors="COLORS"
70
- :ui="CHART_UI"
71
68
  :aria-label="chartLabel"
72
69
  :aria-description="chartDescription"
73
70
  :format="format"
@@ -0,0 +1,24 @@
1
+ type __VLS_Props = {
2
+ /** Hide the "Server information" heading. */
3
+ hideHeading?: boolean;
4
+ /** Hide the refresh button. */
5
+ hideRefresh?: boolean;
6
+ /** Hide the database load card (uptime, connections, counters, replica set — the request is skipped too). */
7
+ hideStats?: boolean;
8
+ /** Hide the capabilities card (features, limits, refused operators — the request is skipped too). */
9
+ hideCapabilities?: boolean;
10
+ /** Reload the numbers every N seconds (at least 1; 0 = off). Pauses while the tab is hidden and slows down after failures. */
11
+ autoRefresh?: number;
12
+ };
13
+ declare function refresh(): Promise<void>;
14
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
15
+ refresh: typeof refresh;
16
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
17
+ autoRefresh: number;
18
+ hideHeading: boolean;
19
+ hideRefresh: boolean;
20
+ hideStats: boolean;
21
+ hideCapabilities: boolean;
22
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
@@ -0,0 +1,331 @@
1
+ <script setup>
2
+ import { computed, onMounted, ref, watch } from "vue";
3
+ import { useI18n, useMongocampSystem } from "#imports";
4
+ import { useNuxtApp } from "#app";
5
+ import { useMongocampAutoRefresh } from "../composables/useMongocampAutoRefresh";
6
+ import { formatBytes } from "../utils/formatBytes";
7
+ import { connectionUsage, formatCount, formatUptime, OP_COUNTER_KEYS } from "../utils/serverInfo";
8
+ const props = defineProps({
9
+ hideHeading: { type: Boolean, required: false, default: false },
10
+ hideRefresh: { type: Boolean, required: false, default: false },
11
+ hideStats: { type: Boolean, required: false, default: false },
12
+ hideCapabilities: { type: Boolean, required: false, default: false },
13
+ autoRefresh: { type: Number, required: false, default: 0 }
14
+ });
15
+ const { t } = useI18n();
16
+ const { $mongocampVersion } = useNuxtApp();
17
+ const { getServerInfo, getStats, getCapabilities } = useMongocampSystem();
18
+ const version = computed(() => $mongocampVersion.value);
19
+ const mongoDbVersion = ref(null);
20
+ const stats = ref(null);
21
+ const capabilities = ref(null);
22
+ const loading = ref(false);
23
+ const failed = ref({ info: false, stats: false, capabilities: false });
24
+ const olderServer = ref(false);
25
+ function statusOf(error) {
26
+ return error?.response?.status;
27
+ }
28
+ async function load() {
29
+ const [info, loadedStats, loadedCapabilities] = await Promise.allSettled([
30
+ getServerInfo(),
31
+ props.hideStats ? Promise.resolve(null) : getStats(),
32
+ props.hideCapabilities ? Promise.resolve(null) : getCapabilities()
33
+ ]);
34
+ mongoDbVersion.value = info.status === "fulfilled" ? info.value.mongoDbVersion || null : mongoDbVersion.value;
35
+ stats.value = loadedStats.status === "fulfilled" ? loadedStats.value : stats.value;
36
+ capabilities.value = loadedCapabilities.status === "fulfilled" ? loadedCapabilities.value : capabilities.value;
37
+ const missing = loadedCapabilities.status === "rejected" && [404, 405].includes(statusOf(loadedCapabilities.reason) ?? 0);
38
+ olderServer.value = missing;
39
+ failed.value = {
40
+ info: info.status === "rejected",
41
+ stats: loadedStats.status === "rejected",
42
+ capabilities: loadedCapabilities.status === "rejected" && !missing
43
+ };
44
+ if ([info, loadedStats, loadedCapabilities].every((r) => r.status === "rejected")) throw info.reason;
45
+ }
46
+ async function refresh() {
47
+ loading.value = true;
48
+ try {
49
+ await load();
50
+ } catch {
51
+ } finally {
52
+ loading.value = false;
53
+ }
54
+ }
55
+ const { start, stop } = useMongocampAutoRefresh(load, { intervalMs: () => props.autoRefresh * 1e3 });
56
+ watch(() => props.autoRefresh, (seconds) => {
57
+ stop();
58
+ if (seconds > 0) start();
59
+ });
60
+ onMounted(() => {
61
+ refresh();
62
+ if (props.autoRefresh > 0) start();
63
+ });
64
+ const usage = computed(() => connectionUsage(stats.value?.connections?.current, stats.value?.connections?.available));
65
+ function opCount(counters2, key) {
66
+ return key === "delete" ? counters2._delete : counters2[key];
67
+ }
68
+ const counters = computed(() => OP_COUNTER_KEYS.map((key) => ({
69
+ key,
70
+ label: t(`nuxtUiMongocamp.serverInfo.op_${key}`),
71
+ value: stats.value?.opcounters ? formatCount(opCount(stats.value.opcounters, key)) : "-"
72
+ })));
73
+ const hasLoad = computed(() => !!stats.value && !stats.value.partial);
74
+ defineExpose({ refresh });
75
+ </script>
76
+
77
+ <template>
78
+ <div class="flex flex-col gap-4">
79
+ <div
80
+ v-if="!hideHeading || !hideRefresh"
81
+ class="flex items-center justify-between gap-4"
82
+ >
83
+ <h2 class="text-xl font-semibold">
84
+ <template v-if="!hideHeading">
85
+ {{ t("nuxtUiMongocamp.serverInfo.heading") }}
86
+ </template>
87
+ </h2>
88
+ <UTooltip
89
+ v-if="!hideRefresh"
90
+ :text="t('nuxtUiMongocamp.common.refresh')"
91
+ >
92
+ <UButton
93
+ icon="i-lucide-refresh-cw"
94
+ color="neutral"
95
+ variant="ghost"
96
+ :loading="loading"
97
+ :aria-label="t('nuxtUiMongocamp.common.refresh')"
98
+ @click="refresh"
99
+ />
100
+ </UTooltip>
101
+ </div>
102
+
103
+ <UAlert
104
+ v-if="failed.info"
105
+ color="warning"
106
+ variant="subtle"
107
+ data-testid="info-failed"
108
+ :description="t('nuxtUiMongocamp.serverInfo.partFailed', { part: t('nuxtUiMongocamp.serverInfo.partInfo') })"
109
+ />
110
+ <UAlert
111
+ v-if="failed.stats && !hideStats"
112
+ color="warning"
113
+ variant="subtle"
114
+ data-testid="stats-failed"
115
+ :description="t('nuxtUiMongocamp.serverInfo.partFailed', { part: t('nuxtUiMongocamp.serverInfo.partStats') })"
116
+ />
117
+ <UAlert
118
+ v-if="failed.capabilities && !hideCapabilities"
119
+ color="warning"
120
+ variant="subtle"
121
+ data-testid="capabilities-failed"
122
+ :description="t('nuxtUiMongocamp.serverInfo.partFailed', { part: t('nuxtUiMongocamp.serverInfo.partCapabilities') })"
123
+ />
124
+
125
+ <UCard>
126
+ <template #header>
127
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverInfo.serverHeading") }}</span>
128
+ </template>
129
+ <dl class="grid grid-cols-1 gap-x-6 gap-y-2 text-sm sm:grid-cols-2">
130
+ <div class="flex justify-between gap-4">
131
+ <dt class="text-dimmed">
132
+ {{ t("nuxtUiMongocamp.serverInfo.mongocampVersion") }}
133
+ </dt>
134
+ <dd data-testid="mongocamp-version">
135
+ {{ version ? `${version.name} v${version.version}` : "-" }}
136
+ </dd>
137
+ </div>
138
+ <div class="flex justify-between gap-4">
139
+ <dt class="text-dimmed">
140
+ {{ t("nuxtUiMongocamp.serverInfo.mongoDbVersion") }}
141
+ </dt>
142
+ <dd data-testid="mongodb-version">
143
+ {{ mongoDbVersion ?? "-" }}
144
+ </dd>
145
+ </div>
146
+ <div
147
+ v-if="capabilities?.mongoDbMajor != null"
148
+ class="flex justify-between gap-4"
149
+ >
150
+ <dt class="text-dimmed">
151
+ {{ t("nuxtUiMongocamp.serverInfo.mongoDbMajor") }}
152
+ </dt>
153
+ <dd>{{ capabilities.mongoDbMajor }}</dd>
154
+ </div>
155
+ <div
156
+ v-if="hasLoad && stats?.uptimeSeconds != null"
157
+ class="flex justify-between gap-4"
158
+ >
159
+ <dt class="text-dimmed">
160
+ {{ t("nuxtUiMongocamp.serverInfo.uptime") }}
161
+ </dt>
162
+ <dd data-testid="uptime">
163
+ {{ formatUptime(stats.uptimeSeconds) }}
164
+ </dd>
165
+ </div>
166
+ <div
167
+ v-if="stats?.replicaSet"
168
+ class="flex justify-between gap-4"
169
+ >
170
+ <dt class="text-dimmed">
171
+ {{ t("nuxtUiMongocamp.serverInfo.replicaSet") }}
172
+ </dt>
173
+ <dd class="flex flex-wrap items-center justify-end gap-2">
174
+ <span>{{ stats.replicaSet.name }}</span>
175
+ <UBadge
176
+ :label="stats.replicaSet.state"
177
+ color="neutral"
178
+ variant="subtle"
179
+ />
180
+ <span class="text-dimmed">{{ t("nuxtUiMongocamp.serverInfo.replicaMembers", { healthy: stats.replicaSet.healthyMembers, count: stats.replicaSet.memberCount }) }}</span>
181
+ </dd>
182
+ </div>
183
+ </dl>
184
+ </UCard>
185
+
186
+ <UCard v-if="!hideStats && stats">
187
+ <template #header>
188
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverInfo.statsHeading") }}</span>
189
+ </template>
190
+ <UAlert
191
+ v-if="stats.partial"
192
+ color="info"
193
+ variant="subtle"
194
+ data-testid="stats-partial"
195
+ :description="t('nuxtUiMongocamp.serverInfo.partialNote')"
196
+ />
197
+ <div
198
+ v-else
199
+ class="flex flex-col gap-4"
200
+ >
201
+ <div
202
+ v-if="stats.connections"
203
+ class="flex flex-col gap-2"
204
+ >
205
+ <div class="text-sm font-medium">
206
+ {{ t("nuxtUiMongocamp.serverInfo.connections") }}
207
+ </div>
208
+ <UProgress
209
+ v-if="usage != null"
210
+ :model-value="usage"
211
+ :aria-label="t('nuxtUiMongocamp.serverInfo.connections')"
212
+ />
213
+ <dl class="grid grid-cols-1 gap-2 text-sm sm:grid-cols-3">
214
+ <div class="flex justify-between gap-4">
215
+ <dt class="text-dimmed">
216
+ {{ t("nuxtUiMongocamp.serverInfo.connectionsCurrent") }}
217
+ </dt>
218
+ <dd data-testid="connections-current">
219
+ {{ formatCount(stats.connections.current) }}
220
+ </dd>
221
+ </div>
222
+ <div class="flex justify-between gap-4">
223
+ <dt class="text-dimmed">
224
+ {{ t("nuxtUiMongocamp.serverInfo.connectionsAvailable") }}
225
+ </dt>
226
+ <dd>{{ formatCount(stats.connections.available) }}</dd>
227
+ </div>
228
+ <div class="flex justify-between gap-4">
229
+ <dt class="text-dimmed">
230
+ {{ t("nuxtUiMongocamp.serverInfo.connectionsTotal") }}
231
+ </dt>
232
+ <dd>{{ formatCount(stats.connections.totalCreated) }}</dd>
233
+ </div>
234
+ </dl>
235
+ </div>
236
+ <div v-if="stats.opcounters">
237
+ <div class="mb-2 text-sm font-medium">
238
+ {{ t("nuxtUiMongocamp.serverInfo.opCounters") }}
239
+ </div>
240
+ <dl class="grid grid-cols-2 gap-2 text-sm sm:grid-cols-3">
241
+ <div
242
+ v-for="counter in counters"
243
+ :key="counter.key"
244
+ class="flex justify-between gap-4"
245
+ >
246
+ <dt class="text-dimmed">
247
+ {{ counter.label }}
248
+ </dt>
249
+ <dd :data-testid="`op-${counter.key}`">
250
+ {{ counter.value }}
251
+ </dd>
252
+ </div>
253
+ </dl>
254
+ </div>
255
+ </div>
256
+ </UCard>
257
+
258
+ <UAlert
259
+ v-if="olderServer && !hideCapabilities"
260
+ color="neutral"
261
+ variant="subtle"
262
+ data-testid="older-server"
263
+ :description="t('nuxtUiMongocamp.serverInfo.olderServer')"
264
+ />
265
+ <UCard v-if="!hideCapabilities && capabilities">
266
+ <template #header>
267
+ <span class="font-semibold">{{ t("nuxtUiMongocamp.serverInfo.capabilitiesHeading") }}</span>
268
+ </template>
269
+ <div class="flex flex-col gap-4">
270
+ <div v-if="capabilities.features?.length">
271
+ <div class="mb-2 text-sm font-medium">
272
+ {{ t("nuxtUiMongocamp.serverInfo.features") }}
273
+ </div>
274
+ <div
275
+ class="flex flex-wrap gap-1.5"
276
+ data-testid="features"
277
+ >
278
+ <UBadge
279
+ v-for="feature in capabilities.features"
280
+ :key="feature"
281
+ :label="feature"
282
+ color="primary"
283
+ variant="subtle"
284
+ />
285
+ </div>
286
+ </div>
287
+ <div>
288
+ <div class="mb-2 text-sm font-medium">
289
+ {{ t("nuxtUiMongocamp.serverInfo.limits") }}
290
+ </div>
291
+ <dl class="grid grid-cols-1 gap-2 text-sm sm:grid-cols-2">
292
+ <div class="flex justify-between gap-4">
293
+ <dt class="text-dimmed">
294
+ {{ t("nuxtUiMongocamp.serverInfo.importMaxBytes") }}
295
+ </dt>
296
+ <dd data-testid="import-max">
297
+ {{ formatBytes(capabilities.limits.importMaxBytes) }}
298
+ </dd>
299
+ </div>
300
+ <div class="flex justify-between gap-4">
301
+ <dt class="text-dimmed">
302
+ {{ t("nuxtUiMongocamp.serverInfo.grantDeniedStatus") }}
303
+ </dt>
304
+ <dd data-testid="grant-denied">
305
+ {{ capabilities.limits.grantDeniedStatus }}
306
+ </dd>
307
+ </div>
308
+ </dl>
309
+ </div>
310
+ <div v-if="capabilities.aggregationStagesDenied?.length">
311
+ <div class="mb-2 text-sm font-medium">
312
+ {{ t("nuxtUiMongocamp.serverInfo.deniedStages") }}
313
+ </div>
314
+ <div
315
+ class="flex flex-wrap gap-1.5"
316
+ data-testid="denied-stages"
317
+ >
318
+ <UBadge
319
+ v-for="stage in capabilities.aggregationStagesDenied"
320
+ :key="stage"
321
+ :label="stage"
322
+ color="error"
323
+ variant="subtle"
324
+ class="font-mono"
325
+ />
326
+ </div>
327
+ </div>
328
+ </div>
329
+ </UCard>
330
+ </div>
331
+ </template>
@@ -0,0 +1,24 @@
1
+ type __VLS_Props = {
2
+ /** Hide the "Server information" heading. */
3
+ hideHeading?: boolean;
4
+ /** Hide the refresh button. */
5
+ hideRefresh?: boolean;
6
+ /** Hide the database load card (uptime, connections, counters, replica set — the request is skipped too). */
7
+ hideStats?: boolean;
8
+ /** Hide the capabilities card (features, limits, refused operators — the request is skipped too). */
9
+ hideCapabilities?: boolean;
10
+ /** Reload the numbers every N seconds (at least 1; 0 = off). Pauses while the tab is hidden and slows down after failures. */
11
+ autoRefresh?: number;
12
+ };
13
+ declare function refresh(): Promise<void>;
14
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
15
+ refresh: typeof refresh;
16
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
17
+ autoRefresh: number;
18
+ hideHeading: boolean;
19
+ hideRefresh: boolean;
20
+ hideStats: boolean;
21
+ hideCapabilities: boolean;
22
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
@@ -1,3 +1,9 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
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). */
3
+ hideDatabase?: boolean;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
+ hideDatabase: boolean;
7
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
8
  declare const _default: typeof __VLS_export;
3
9
  export default _default;
@@ -1,27 +1,57 @@
1
1
  <script setup>
2
- import { computed } from "vue";
3
- import { useI18n } from "#imports";
4
- import { useNuxtApp } from "#app";
2
+ import { computed, ref, watch } from "vue";
3
+ import { useI18n, useMongocampStorage, useMongocampSystem } from "#imports";
4
+ import { useNuxtApp, useRuntimeConfig } from "#app";
5
+ const props = defineProps({
6
+ hideDatabase: { type: Boolean, required: false, default: false }
7
+ });
5
8
  const { t } = useI18n();
6
9
  const { $mongocampVersion } = useNuxtApp();
10
+ const { getServerInfo } = useMongocampSystem();
11
+ const state = useMongocampStorage();
12
+ const isProxyMode = useRuntimeConfig().public.nuxtUiMongocampOptions?.useServerProxy ?? false;
7
13
  const version = computed(() => $mongocampVersion.value);
14
+ const mongoDbVersion = ref(null);
15
+ const canAsk = computed(() => !props.hideDatabase && (isProxyMode || !!state.value?.profile));
16
+ watch(canAsk, async (ask) => {
17
+ if (!ask) {
18
+ mongoDbVersion.value = null;
19
+ return;
20
+ }
21
+ try {
22
+ mongoDbVersion.value = (await getServerInfo()).mongoDbVersion || null;
23
+ } catch {
24
+ mongoDbVersion.value = null;
25
+ }
26
+ }, { immediate: true });
8
27
  </script>
9
28
 
10
29
  <template>
11
- <UBadge
12
- v-if="version"
13
- color="primary"
14
- variant="subtle"
15
- icon="i-lucide-database"
16
- >
17
- {{ version.name }} v{{ version.version }}
18
- </UBadge>
19
- <UBadge
20
- v-else
21
- color="neutral"
22
- variant="subtle"
23
- icon="i-lucide-database-zap"
24
- >
25
- {{ t("nuxtUiMongocamp.version.unavailable") }}
26
- </UBadge>
30
+ <span class="inline-flex items-center gap-1.5">
31
+ <UBadge
32
+ v-if="version"
33
+ color="primary"
34
+ variant="subtle"
35
+ icon="i-lucide-database"
36
+ >
37
+ {{ version.name }} v{{ version.version }}
38
+ </UBadge>
39
+ <UBadge
40
+ v-else
41
+ color="neutral"
42
+ variant="subtle"
43
+ icon="i-lucide-database-zap"
44
+ >
45
+ {{ t("nuxtUiMongocamp.version.unavailable") }}
46
+ </UBadge>
47
+ <UBadge
48
+ v-if="mongoDbVersion"
49
+ color="neutral"
50
+ variant="subtle"
51
+ icon="i-simple-icons-mongodb"
52
+ data-testid="mongodb-version"
53
+ >
54
+ MongoDB {{ mongoDbVersion }}
55
+ </UBadge>
56
+ </span>
27
57
  </template>
@@ -1,3 +1,9 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
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). */
3
+ hideDatabase?: boolean;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
+ hideDatabase: boolean;
7
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
8
  declare const _default: typeof __VLS_export;
3
9
  export default _default;
@@ -1,9 +1,15 @@
1
- import type { ClusterMemberInformation, DatabaseInfo } from '@sfxcode/nuxt-mongocamp-server';
1
+ import type { Capabilities, ClusterMemberInformation, DatabaseInfo, SystemStats } from '@sfxcode/nuxt-mongocamp-server';
2
2
  import type { ConfigRow } from '../utils/configRows.js';
3
3
  export interface ServerCluster {
4
4
  coordinator: ClusterMemberInformation;
5
5
  members: ClusterMemberInformation[];
6
6
  }
7
+ export interface ServerInfo {
8
+ /** Version of the MongoDB server the MongoCamp server is connected to, e.g. `9.0.4`. */
9
+ mongoDbVersion: string;
10
+ /** The same version as numbers (`[9, 0, 4, 0]`), empty if the server sent none. */
11
+ mongoDbVersionArray: number[];
12
+ }
7
13
  export interface ServerPlugins {
8
14
  routesPlugins: string[];
9
15
  filePlugins: string[];
@@ -19,6 +25,9 @@ export interface ServerPlugins {
19
25
  */
20
26
  export declare function useMongocampSystem(): {
21
27
  getCluster: () => Promise<ServerCluster>;
28
+ getServerInfo: () => Promise<ServerInfo>;
29
+ getStats: () => Promise<SystemStats>;
30
+ getCapabilities: () => Promise<Capabilities>;
22
31
  listDatabases: () => Promise<string[]>;
23
32
  getDatabaseInfos: () => Promise<DatabaseInfo[]>;
24
33
  getDatabaseInfo: (databaseName: string) => Promise<DatabaseInfo>;
@@ -38,5 +38,15 @@ export function useMongocampSystem() {
38
38
  const cluster = await systemApi.viewCluster(withTimeout());
39
39
  return { coordinator: cluster.coordinator, members: cluster.members?.length ? cluster.members : [cluster.coordinator] };
40
40
  }
41
- return { getCluster, listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase, getSettings, listConfigurations, getConfig };
41
+ async function getServerInfo() {
42
+ const info = await systemApi.systemInfo(withTimeout());
43
+ return { mongoDbVersion: info.mongoDbVersion, mongoDbVersionArray: info.mongoDbVersionArray ?? [] };
44
+ }
45
+ async function getStats() {
46
+ return systemApi.systemStats(withTimeout());
47
+ }
48
+ async function getCapabilities() {
49
+ return systemApi.systemCapabilities(withTimeout());
50
+ }
51
+ return { getCluster, getServerInfo, getStats, getCapabilities, listDatabases, getDatabaseInfos, getDatabaseInfo, listCollectionsByDatabase, getSettings, listConfigurations, getConfig };
42
52
  }
@@ -369,6 +369,41 @@
369
369
  "chartSize": "Größe auf der Platte",
370
370
  "chartDescription": "Größe von {count} Datenbanken, größte zuerst"
371
371
  },
372
+ "serverInfo": {
373
+ "heading": "Serverinformationen",
374
+ "serverHeading": "Server",
375
+ "mongocampVersion": "MongoCamp",
376
+ "mongoDbVersion": "MongoDB",
377
+ "mongoDbMajor": "MongoDB-Hauptversion",
378
+ "uptime": "Laufzeit (Datenbank)",
379
+ "replicaSet": "Replica Set",
380
+ "replicaState": "Zustand",
381
+ "replicaMembers": "{healthy} von {count} Mitgliedern gesund",
382
+ "statsHeading": "Datenbanklast",
383
+ "connections": "Verbindungen",
384
+ "connectionsCurrent": "In Benutzung",
385
+ "connectionsAvailable": "Verfügbar",
386
+ "connectionsTotal": "Seit dem Start geöffnet",
387
+ "opCounters": "Operationen seit dem Start des Datenbankservers",
388
+ "partialNote": "Dem Datenbankbenutzer fehlt die Rolle clusterMonitor, daher fehlen Laufzeit, Verbindungen und Zähler.",
389
+ "capabilitiesHeading": "Fähigkeiten",
390
+ "features": "Funktionen",
391
+ "limits": "Grenzen",
392
+ "importMaxBytes": "Größter Import",
393
+ "grantDeniedStatus": "Status bei fehlender Berechtigung",
394
+ "deniedStages": "Abgelehnte Aggregations-Operatoren",
395
+ "olderServer": "Dieser Server hat keine Capabilities-Route (älter als 1.9.0).",
396
+ "partFailed": "{part} konnte nicht geladen werden.",
397
+ "partStats": "Die Datenbanklast",
398
+ "partCapabilities": "Die Fähigkeiten",
399
+ "partInfo": "Die MongoDB-Version",
400
+ "op_insert": "insert",
401
+ "op_query": "query",
402
+ "op_update": "update",
403
+ "op_delete": "delete",
404
+ "op_getmore": "getmore",
405
+ "op_command": "command"
406
+ },
372
407
  "version": {
373
408
  "unavailable": "MongoCamp nicht verfügbar"
374
409
  },
@@ -369,6 +369,41 @@
369
369
  "chartSize": "Size on disk",
370
370
  "chartDescription": "Size of {count} databases, biggest first"
371
371
  },
372
+ "serverInfo": {
373
+ "heading": "Server information",
374
+ "serverHeading": "Server",
375
+ "mongocampVersion": "MongoCamp",
376
+ "mongoDbVersion": "MongoDB",
377
+ "mongoDbMajor": "MongoDB major version",
378
+ "uptime": "Uptime (database)",
379
+ "replicaSet": "Replica set",
380
+ "replicaState": "State",
381
+ "replicaMembers": "{healthy} of {count} members healthy",
382
+ "statsHeading": "Database load",
383
+ "connections": "Connections",
384
+ "connectionsCurrent": "In use",
385
+ "connectionsAvailable": "Available",
386
+ "connectionsTotal": "Opened since start",
387
+ "opCounters": "Operations since the database server started",
388
+ "partialNote": "The database user lacks the clusterMonitor role, so uptime, connections and counters are not available.",
389
+ "capabilitiesHeading": "Capabilities",
390
+ "features": "Features",
391
+ "limits": "Limits",
392
+ "importMaxBytes": "Largest import",
393
+ "grantDeniedStatus": "Status for a missing grant",
394
+ "deniedStages": "Refused aggregation operators",
395
+ "olderServer": "This server has no capabilities route (older than 1.9.0).",
396
+ "partFailed": "{part} could not be loaded.",
397
+ "partStats": "The database load",
398
+ "partCapabilities": "The capabilities",
399
+ "partInfo": "The MongoDB version",
400
+ "op_insert": "insert",
401
+ "op_query": "query",
402
+ "op_update": "update",
403
+ "op_delete": "delete",
404
+ "op_getmore": "getmore",
405
+ "op_command": "command"
406
+ },
372
407
  "version": {
373
408
  "unavailable": "MongoCamp unavailable"
374
409
  },
@@ -1,6 +1,6 @@
1
- declare const _default: import("#app").Plugin<{
1
+ declare const _default: import("nuxt/app").Plugin<{
2
2
  mongocampVersion: import("vue").Ref<import("@sfxcode/nuxt-mongocamp-server").Version | undefined, import("@sfxcode/nuxt-mongocamp-server").Version | undefined>;
3
- }> & import("#app").ObjectPlugin<{
3
+ }> & import("nuxt/app").ObjectPlugin<{
4
4
  mongocampVersion: import("vue").Ref<import("@sfxcode/nuxt-mongocamp-server").Version | undefined, import("@sfxcode/nuxt-mongocamp-server").Version | undefined>;
5
5
  }>;
6
6
  export default _default;
@@ -0,0 +1,8 @@
1
+ /** `3d 4h`, `5h 12m`, `7m 3s`, `42s` — the two biggest non-zero units; `-` for nothing/unknown. */
2
+ export declare function formatUptime(seconds: number | null | undefined): string;
3
+ /** Thousands separators without a locale dependency (the counters run into the millions). */
4
+ export declare function formatCount(value: number | null | undefined): string;
5
+ /** Share of connections in use, 0–100 (`current` against `current + available`); `null` if nothing is known. */
6
+ export declare function connectionUsage(current: number | null | undefined, available: number | null | undefined): number | null;
7
+ export declare const OP_COUNTER_KEYS: readonly ["insert", "query", "update", "delete", "getmore", "command"];
8
+ export type OpCounterKey = typeof OP_COUNTER_KEYS[number];
@@ -0,0 +1,21 @@
1
+ export function formatUptime(seconds) {
2
+ if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return "-";
3
+ const total = Math.floor(seconds);
4
+ const days = Math.floor(total / 86400);
5
+ const hours = Math.floor(total % 86400 / 3600);
6
+ const minutes = Math.floor(total % 3600 / 60);
7
+ const secs = total % 60;
8
+ const parts = [[days, "d"], [hours, "h"], [minutes, "m"], [secs, "s"]];
9
+ const shown = parts.filter(([value]) => value > 0).slice(0, 2).map(([value, unit]) => `${value}${unit}`);
10
+ return shown.length ? shown.join(" ") : "0s";
11
+ }
12
+ export function formatCount(value) {
13
+ if (value == null || !Number.isFinite(value)) return "-";
14
+ return Math.trunc(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
15
+ }
16
+ export function connectionUsage(current, available) {
17
+ if (current == null || available == null) return null;
18
+ const total = current + available;
19
+ return total > 0 ? Math.round(current / total * 100) : null;
20
+ }
21
+ export const OP_COUNTER_KEYS = ["insert", "query", "update", "delete", "getmore", "command"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A Nuxt module that wraps @sfxcode/nuxt-mongocamp-server with ready-made UI components, composables, and a runtime plugin",
5
5
  "repository": "sfxcode/nuxt-ui-mongocamp",
6
6
  "homepage": "https://sfxcode.github.io/nuxt-ui-mongocamp/",
@@ -44,7 +44,7 @@
44
44
  "dev": "npm run dev:prepare && nuxt dev playground",
45
45
  "dev:build": "nuxt build playground",
46
46
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
47
- "release": "npm run lint && npm run test && npm run prepack && changelogen --minor --release && npm publish && git push --follow-tags",
47
+ "release": "npm run lint && npm run test && npm run prepack && changelogen --patch --release && npm publish && git push --follow-tags",
48
48
  "lint": "eslint .",
49
49
  "test": "vitest run --project unit --project components",
50
50
  "test:watch": "vitest watch",
@@ -59,20 +59,20 @@
59
59
  "@internationalized/date": "^3.12.4",
60
60
  "@nuxt/ui": "^4.12.0",
61
61
  "@nuxtjs/i18n": "^10.6.0",
62
- "@sfxcode/nuxt-mongocamp-server": "^1.8.0",
62
+ "@sfxcode/nuxt-mongocamp-server": "^1.9.1",
63
63
  "@sfxcode/nuxt-ui-formkit": "^1.4.2",
64
64
  "@tanstack/charts": "^1.5.0",
65
65
  "consola": "^3.4.2",
66
66
  "defu": "^6.1.7",
67
- "minimatch": "^11.0.5",
68
- "unocss-nuxt-ui": "^1.2.2"
67
+ "minimatch": "^11.0.8",
68
+ "unocss-nuxt-ui": "^1.3.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@iconify-json/lucide": "^1.2.152",
71
+ "@iconify-json/lucide": "^1.2.154",
72
72
  "@nuxt/devtools": "^4.1.0",
73
73
  "@nuxt/eslint-config": "^1.17.0",
74
74
  "@nuxt/kit": "^4.6.4",
75
- "@nuxt/module-builder": "^1.0.3",
75
+ "@nuxt/module-builder": "^1.0.4",
76
76
  "@nuxt/schema": "^4.6.4",
77
77
  "@nuxt/test-utils": "^4.4.0",
78
78
  "@playwright/test": "^1.65.0",