@sfxcode/nuxt-ui-mongocamp 1.5.2 → 1.5.4
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/dist/module.d.mts +9 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -1
- package/dist/runtime/components/MongocampCollectionData.vue +21 -9
- package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -1
- package/dist/runtime/components/MongocampCollections.vue +7 -4
- package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +0 -7
- package/dist/runtime/components/MongocampCommandPalette.vue +16 -15
- package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +0 -7
- package/dist/runtime/components/MongocampDashboard.d.vue.ts +0 -3
- package/dist/runtime/components/MongocampDashboard.vue +8 -7
- package/dist/runtime/components/MongocampDashboard.vue.d.ts +0 -3
- package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +0 -1
- package/dist/runtime/components/MongocampPermissionMatrix.vue +4 -3
- package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +0 -1
- package/dist/runtime/components/MongocampRoles.vue +3 -2
- package/dist/runtime/components/MongocampServerOverview.d.vue.ts +0 -3
- package/dist/runtime/components/MongocampServerOverview.vue +8 -7
- package/dist/runtime/components/MongocampServerOverview.vue.d.ts +0 -3
- package/dist/runtime/components/MongocampServerStatus.d.vue.ts +13 -0
- package/dist/runtime/components/MongocampServerStatus.vue +147 -0
- package/dist/runtime/components/MongocampServerStatus.vue.d.ts +13 -0
- package/dist/runtime/components/MongocampUserAccess.d.vue.ts +27 -0
- package/dist/runtime/components/MongocampUserAccess.vue +168 -0
- package/dist/runtime/components/MongocampUserAccess.vue.d.ts +27 -0
- package/dist/runtime/components/MongocampVersion.vue +3 -3
- package/dist/runtime/composables/useMongocampAdminGate.js +2 -3
- package/dist/runtime/composables/useMongocampBreadcrumbs.d.ts +12 -0
- package/dist/runtime/composables/useMongocampBreadcrumbs.js +13 -0
- package/dist/runtime/composables/useMongocampCollectionNames.d.ts +21 -0
- package/dist/runtime/composables/useMongocampCollectionNames.js +46 -0
- package/dist/runtime/composables/useMongocampNavigation.d.ts +32 -0
- package/dist/runtime/composables/useMongocampNavigation.js +15 -0
- package/dist/runtime/composables/useMongocampPaths.d.ts +6 -0
- package/dist/runtime/composables/useMongocampPaths.js +6 -0
- package/dist/runtime/composables/useMongocampPermissions.js +2 -3
- package/dist/runtime/composables/useMongocampProxyMode.d.ts +5 -0
- package/dist/runtime/composables/useMongocampProxyMode.js +4 -0
- package/dist/runtime/composables/useMongocampRoles.d.ts +3 -0
- package/dist/runtime/composables/useMongocampRoles.js +5 -1
- package/dist/runtime/composables/useMongocampSession.js +2 -3
- package/dist/runtime/locales/de.json +42 -0
- package/dist/runtime/locales/en.json +42 -0
- package/dist/runtime/publicUtils.d.ts +4 -0
- package/dist/runtime/publicUtils.js +4 -0
- package/dist/runtime/utils/collectionNames.d.ts +13 -0
- package/dist/runtime/utils/collectionNames.js +14 -0
- package/dist/runtime/utils/collectionProtection.d.ts +2 -0
- package/dist/runtime/utils/collectionProtection.js +3 -0
- package/dist/runtime/utils/navigation.d.ts +39 -0
- package/dist/runtime/utils/navigation.js +65 -0
- package/dist/runtime/utils/paths.d.ts +32 -0
- package/dist/runtime/utils/paths.js +24 -0
- package/dist/runtime/utils/serverStatus.d.ts +20 -0
- package/dist/runtime/utils/serverStatus.js +11 -0
- package/package.json +10 -3
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#app";
|
|
2
1
|
import { useMongocampAuth, useMongocampClientApi, useMongocampStorage } from "#imports";
|
|
3
2
|
import { tokenExpiryState } from "../utils/jwtExpiry.js";
|
|
3
|
+
import { useMongocampProxyMode } from "./useMongocampProxyMode.js";
|
|
4
4
|
const VERIFY_TIMEOUT_MS = 15e3;
|
|
5
5
|
export function useMongocampSession() {
|
|
6
|
-
const config = useRuntimeConfig();
|
|
7
6
|
const { logout } = useMongocampAuth();
|
|
8
7
|
const storage = useMongocampStorage();
|
|
9
8
|
const { authApi } = useMongocampClientApi();
|
|
10
|
-
const isProxyMode =
|
|
9
|
+
const isProxyMode = useMongocampProxyMode();
|
|
11
10
|
function checkExpiry() {
|
|
12
11
|
if (isProxyMode) return "unknown";
|
|
13
12
|
const token = storage.value?.token;
|
|
@@ -1072,6 +1072,48 @@
|
|
|
1072
1072
|
"ariaDescription": "{count} Werte der angezeigten Ergebnisseite",
|
|
1073
1073
|
"cut": "Nur die ersten {max} Zeilen dieser Seite werden dargestellt.",
|
|
1074
1074
|
"skipped": "{count} Zeilen ohne Zahl wurden ausgelassen."
|
|
1075
|
+
},
|
|
1076
|
+
"navigation": {
|
|
1077
|
+
"home": "Start",
|
|
1078
|
+
"account": "Konto",
|
|
1079
|
+
"collections": "Collections",
|
|
1080
|
+
"buckets": "Buckets",
|
|
1081
|
+
"databases": "Datenbanken",
|
|
1082
|
+
"jobs": "Jobs",
|
|
1083
|
+
"users": "Benutzer",
|
|
1084
|
+
"roles": "Rollen",
|
|
1085
|
+
"permissions": "Berechtigungen",
|
|
1086
|
+
"overview": "Übersicht",
|
|
1087
|
+
"server": "Server",
|
|
1088
|
+
"settings": "Einstellungen",
|
|
1089
|
+
"data": "Daten",
|
|
1090
|
+
"aggregate": "Aggregation",
|
|
1091
|
+
"groupData": "Daten",
|
|
1092
|
+
"groupAccess": "Zugriff",
|
|
1093
|
+
"groupServer": "Server"
|
|
1094
|
+
},
|
|
1095
|
+
"serverStatus": {
|
|
1096
|
+
"ok": "Server erreichbar",
|
|
1097
|
+
"partial": "Server erreichbar, einige Angaben fehlen",
|
|
1098
|
+
"down": "Server nicht erreichbar",
|
|
1099
|
+
"connections": "Verbindungen",
|
|
1100
|
+
"uptime": "Läuft seit {time}",
|
|
1101
|
+
"details": "Details zum Serverstatus"
|
|
1102
|
+
},
|
|
1103
|
+
"userAccess": {
|
|
1104
|
+
"heading": "Ihr Zugriff",
|
|
1105
|
+
"collections": "Collections",
|
|
1106
|
+
"canRead": "Lesbar",
|
|
1107
|
+
"canWrite": "Schreibbar",
|
|
1108
|
+
"canAdministrate": "Verwaltbar",
|
|
1109
|
+
"collection": "Collection",
|
|
1110
|
+
"read": "Lesen",
|
|
1111
|
+
"write": "Schreiben",
|
|
1112
|
+
"administrate": "Verwalten",
|
|
1113
|
+
"emptyTitle": "Noch keine Collections",
|
|
1114
|
+
"emptyDescription": "Ihnen wurde noch keine Collection freigegeben. Bitten Sie einen Administrator um Zugriff.",
|
|
1115
|
+
"adminTitle": "Sie sind Administrator",
|
|
1116
|
+
"adminDescription": "Administratoren dürfen jede Collection lesen, schreiben und verwalten."
|
|
1075
1117
|
}
|
|
1076
1118
|
}
|
|
1077
1119
|
}
|
|
@@ -1072,6 +1072,48 @@
|
|
|
1072
1072
|
"ariaDescription": "{count} values from the shown page of the result",
|
|
1073
1073
|
"cut": "Only the first {max} rows of this page are charted.",
|
|
1074
1074
|
"skipped": "{count} rows without a number were left out."
|
|
1075
|
+
},
|
|
1076
|
+
"navigation": {
|
|
1077
|
+
"home": "Home",
|
|
1078
|
+
"account": "Account",
|
|
1079
|
+
"collections": "Collections",
|
|
1080
|
+
"buckets": "Buckets",
|
|
1081
|
+
"databases": "Databases",
|
|
1082
|
+
"jobs": "Jobs",
|
|
1083
|
+
"users": "Users",
|
|
1084
|
+
"roles": "Roles",
|
|
1085
|
+
"permissions": "Permissions",
|
|
1086
|
+
"overview": "Overview",
|
|
1087
|
+
"server": "Server",
|
|
1088
|
+
"settings": "Settings",
|
|
1089
|
+
"data": "Data",
|
|
1090
|
+
"aggregate": "Aggregate",
|
|
1091
|
+
"groupData": "Data",
|
|
1092
|
+
"groupAccess": "Access",
|
|
1093
|
+
"groupServer": "Server"
|
|
1094
|
+
},
|
|
1095
|
+
"serverStatus": {
|
|
1096
|
+
"ok": "Server reachable",
|
|
1097
|
+
"partial": "Server reachable, some details unavailable",
|
|
1098
|
+
"down": "Server not reachable",
|
|
1099
|
+
"connections": "Connections",
|
|
1100
|
+
"uptime": "Up {time}",
|
|
1101
|
+
"details": "Server status details"
|
|
1102
|
+
},
|
|
1103
|
+
"userAccess": {
|
|
1104
|
+
"heading": "Your access",
|
|
1105
|
+
"collections": "Collections",
|
|
1106
|
+
"canRead": "Can read",
|
|
1107
|
+
"canWrite": "Can write",
|
|
1108
|
+
"canAdministrate": "Can administrate",
|
|
1109
|
+
"collection": "Collection",
|
|
1110
|
+
"read": "Read",
|
|
1111
|
+
"write": "Write",
|
|
1112
|
+
"administrate": "Administrate",
|
|
1113
|
+
"emptyTitle": "No collections yet",
|
|
1114
|
+
"emptyDescription": "No collection has been granted to you. Ask an administrator for access.",
|
|
1115
|
+
"adminTitle": "You are an administrator",
|
|
1116
|
+
"adminDescription": "Administrators may read, write and administrate every collection."
|
|
1075
1117
|
}
|
|
1076
1118
|
}
|
|
1077
1119
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { formatBytes } from './utils/formatBytes.js';
|
|
2
|
+
export { connectionUsage, formatCount, formatUptime } from './utils/serverInfo.js';
|
|
3
|
+
export { groupCollectionNames } from './utils/collectionNames.js';
|
|
4
|
+
export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from './utils/collectionProtection.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { formatBytes } from "./utils/formatBytes.js";
|
|
2
|
+
export { connectionUsage, formatCount, formatUptime } from "./utils/serverInfo.js";
|
|
3
|
+
export { groupCollectionNames } from "./utils/collectionNames.js";
|
|
4
|
+
export { bucketNameOf, isBucketMemberCollection, isProtectedCollection } from "./utils/collectionProtection.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CollectionNameGroups {
|
|
2
|
+
/** Ordinary collections: not MongoCamp's own, not half of a GridFS bucket. */
|
|
3
|
+
collections: string[];
|
|
4
|
+
/** GridFS bucket names (`images` for `images.files` / `images.chunks`), each once. */
|
|
5
|
+
buckets: string[];
|
|
6
|
+
/** MongoCamp's own `mc_*` collections. */
|
|
7
|
+
system: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Splits a collection list the way every navigation shows it. Each group is sorted and free of duplicates; a `mc_*` name is
|
|
11
|
+
* always `system`, also when it looks like a bucket half. A bucket is listed when either of its halves is present.
|
|
12
|
+
*/
|
|
13
|
+
export declare function groupCollectionNames(names: readonly string[]): CollectionNameGroups;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { bucketNameOf, isBucketMemberCollection } from "./collectionProtection.js";
|
|
2
|
+
export function groupCollectionNames(names) {
|
|
3
|
+
const collections = /* @__PURE__ */ new Set();
|
|
4
|
+
const buckets = /* @__PURE__ */ new Set();
|
|
5
|
+
const system = /* @__PURE__ */ new Set();
|
|
6
|
+
for (const name of names) {
|
|
7
|
+
if (typeof name !== "string" || !name) continue;
|
|
8
|
+
if (name.startsWith("mc_")) system.add(name);
|
|
9
|
+
else if (isBucketMemberCollection(name)) buckets.add(bucketNameOf(name));
|
|
10
|
+
else collections.add(name);
|
|
11
|
+
}
|
|
12
|
+
const sorted = (set) => [...set].sort((a, b) => a.localeCompare(b));
|
|
13
|
+
return { collections: sorted(collections), buckets: sorted(buckets), system: sorted(system) };
|
|
14
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const BUCKET_COLLECTION_SUFFIX: RegExp;
|
|
2
2
|
export declare function isBucketMemberCollection(collectionName: string): boolean;
|
|
3
|
+
/** `fs` for `fs.files` / `fs.chunks`; `null` for a collection that is not half of a GridFS bucket. */
|
|
4
|
+
export declare function bucketNameOf(collectionName: string): string | null;
|
|
3
5
|
export declare function isProtectedCollection(collectionName: string): boolean;
|
|
@@ -2,6 +2,9 @@ export const BUCKET_COLLECTION_SUFFIX = /\.(?:files|chunks)$/;
|
|
|
2
2
|
export function isBucketMemberCollection(collectionName) {
|
|
3
3
|
return BUCKET_COLLECTION_SUFFIX.test(collectionName);
|
|
4
4
|
}
|
|
5
|
+
export function bucketNameOf(collectionName) {
|
|
6
|
+
return isBucketMemberCollection(collectionName) ? collectionName.replace(BUCKET_COLLECTION_SUFFIX, "") : null;
|
|
7
|
+
}
|
|
5
8
|
export function isProtectedCollection(collectionName) {
|
|
6
9
|
return collectionName.startsWith("mc_") || isBucketMemberCollection(collectionName);
|
|
7
10
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { MongocampPaths } from './paths.js';
|
|
2
|
+
export interface NavigationEntry {
|
|
3
|
+
/** Stable id of the page — also its key in the module's `paths` option. */
|
|
4
|
+
key: keyof MongocampPaths;
|
|
5
|
+
labelKey: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
to: string;
|
|
8
|
+
/** Highlight only on the exact route (the home page, whose path is a prefix of every other). */
|
|
9
|
+
exact?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface NavigationGroup {
|
|
12
|
+
key: 'main' | 'data' | 'access' | 'server';
|
|
13
|
+
/** No label for the first group. */
|
|
14
|
+
labelKey?: string;
|
|
15
|
+
items: NavigationEntry[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The module's pages as navigation groups. Everyone gets Home and Account (no account in server proxy mode — nobody is
|
|
19
|
+
* logged in); the admin pages come in three groups for whoever may see them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildNavigation(paths: MongocampPaths, who: {
|
|
22
|
+
canSeeAdmin: boolean;
|
|
23
|
+
isProxyMode: boolean;
|
|
24
|
+
}): NavigationGroup[];
|
|
25
|
+
export interface BreadcrumbPart {
|
|
26
|
+
/** A translation key … */
|
|
27
|
+
labelKey?: string;
|
|
28
|
+
/** … or a name taken from the URL (a collection, a bucket, a role), shown as it is. */
|
|
29
|
+
text?: string;
|
|
30
|
+
/** Absent on the last part: that is the current page. */
|
|
31
|
+
to?: string;
|
|
32
|
+
icon?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Where a route sits among the module's pages: Home › Collections › test_customer › Data. The section is the `paths` entry
|
|
36
|
+
* that is the longest prefix of the route; a route outside every section is just Home. Buckets have no list page of their
|
|
37
|
+
* own, so that part links to the collections list. The last part carries no link.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildBreadcrumbs(routePath: string, paths: MongocampPaths): BreadcrumbPart[];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const PAGES = {
|
|
2
|
+
home: { labelKey: "nuxtUiMongocamp.navigation.home", icon: "i-lucide-house" },
|
|
3
|
+
account: { labelKey: "nuxtUiMongocamp.navigation.account", icon: "i-lucide-circle-user" },
|
|
4
|
+
collections: { labelKey: "nuxtUiMongocamp.navigation.collections", icon: "i-lucide-database" },
|
|
5
|
+
databases: { labelKey: "nuxtUiMongocamp.navigation.databases", icon: "i-lucide-hard-drive" },
|
|
6
|
+
jobs: { labelKey: "nuxtUiMongocamp.navigation.jobs", icon: "i-lucide-clock" },
|
|
7
|
+
users: { labelKey: "nuxtUiMongocamp.navigation.users", icon: "i-lucide-users" },
|
|
8
|
+
roles: { labelKey: "nuxtUiMongocamp.navigation.roles", icon: "i-lucide-shield" },
|
|
9
|
+
permissions: { labelKey: "nuxtUiMongocamp.navigation.permissions", icon: "i-lucide-key-round" },
|
|
10
|
+
overview: { labelKey: "nuxtUiMongocamp.navigation.overview", icon: "i-lucide-gauge" },
|
|
11
|
+
server: { labelKey: "nuxtUiMongocamp.navigation.server", icon: "i-lucide-activity" },
|
|
12
|
+
settings: { labelKey: "nuxtUiMongocamp.navigation.settings", icon: "i-lucide-settings" }
|
|
13
|
+
};
|
|
14
|
+
function entry(key, paths) {
|
|
15
|
+
return { key, ...PAGES[key], to: paths[key], ...key === "home" ? { exact: true } : {} };
|
|
16
|
+
}
|
|
17
|
+
export function buildNavigation(paths, who) {
|
|
18
|
+
const groups = [{
|
|
19
|
+
key: "main",
|
|
20
|
+
items: [entry("home", paths), ...who.isProxyMode ? [] : [entry("account", paths)]]
|
|
21
|
+
}];
|
|
22
|
+
if (!who.canSeeAdmin) return groups;
|
|
23
|
+
groups.push(
|
|
24
|
+
{ key: "data", labelKey: "nuxtUiMongocamp.navigation.groupData", items: [entry("collections", paths), entry("databases", paths), entry("jobs", paths)] },
|
|
25
|
+
{ key: "access", labelKey: "nuxtUiMongocamp.navigation.groupAccess", items: [entry("users", paths), entry("roles", paths), entry("permissions", paths)] },
|
|
26
|
+
{ key: "server", labelKey: "nuxtUiMongocamp.navigation.groupServer", items: [entry("overview", paths), entry("server", paths), entry("settings", paths)] }
|
|
27
|
+
);
|
|
28
|
+
return groups;
|
|
29
|
+
}
|
|
30
|
+
const NAMED = /* @__PURE__ */ new Set(["collections", "buckets", "roles"]);
|
|
31
|
+
const TAB_KEYS = {
|
|
32
|
+
data: "nuxtUiMongocamp.navigation.data",
|
|
33
|
+
aggregate: "nuxtUiMongocamp.navigation.aggregate"
|
|
34
|
+
};
|
|
35
|
+
const BUCKETS_KEY = "nuxtUiMongocamp.navigation.buckets";
|
|
36
|
+
function decode(segment) {
|
|
37
|
+
try {
|
|
38
|
+
return decodeURIComponent(segment);
|
|
39
|
+
} catch {
|
|
40
|
+
return segment;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const isUnder = (route, base) => route === base || route.startsWith(base === "/" ? "/" : `${base}/`);
|
|
44
|
+
export function buildBreadcrumbs(routePath, paths) {
|
|
45
|
+
const route = (routePath.split(/[?#]/)[0] ?? "").replace(/\/+$/, "") || "/";
|
|
46
|
+
const parts = [{ labelKey: PAGES.home.labelKey, icon: PAGES.home.icon, to: paths.home }];
|
|
47
|
+
let section;
|
|
48
|
+
for (const key of Object.keys(paths)) {
|
|
49
|
+
if (key === "home" || !isUnder(route, paths[key])) continue;
|
|
50
|
+
if (!section || paths[key].length > paths[section].length) section = key;
|
|
51
|
+
}
|
|
52
|
+
if (section) {
|
|
53
|
+
const base = paths[section];
|
|
54
|
+
parts.push(section === "buckets" ? { labelKey: BUCKETS_KEY, to: paths.collections } : { labelKey: PAGES[section].labelKey, to: base });
|
|
55
|
+
let path = base;
|
|
56
|
+
route.slice(base.length).split("/").filter(Boolean).forEach((segment, index) => {
|
|
57
|
+
path += `/${segment}`;
|
|
58
|
+
const isName = index === 0 && NAMED.has(section);
|
|
59
|
+
const tabKey = !isName && section === "collections" ? TAB_KEYS[segment] : void 0;
|
|
60
|
+
parts.push(tabKey ? { labelKey: tabKey, to: path } : { text: decode(segment), to: path });
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
delete parts[parts.length - 1].to;
|
|
64
|
+
return parts;
|
|
65
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface MongocampPaths {
|
|
2
|
+
/** The landing page after login — the first entry of the navigation and of every breadcrumb. */
|
|
3
|
+
home: string;
|
|
4
|
+
/** Collection pages: `<collections>/<name>` (info), `<collections>/<name>/data`. */
|
|
5
|
+
collections: string;
|
|
6
|
+
/** Bucket file browser: `<buckets>/<bucket>`. */
|
|
7
|
+
buckets: string;
|
|
8
|
+
/** The users list. */
|
|
9
|
+
users: string;
|
|
10
|
+
/** The roles list; a role's grants are at `<roles>/<role>`. */
|
|
11
|
+
roles: string;
|
|
12
|
+
/** The jobs list. */
|
|
13
|
+
jobs: string;
|
|
14
|
+
/** The server settings page. */
|
|
15
|
+
settings: string;
|
|
16
|
+
/** The signed-in user's account page. */
|
|
17
|
+
account: string;
|
|
18
|
+
/** The permission matrix page. */
|
|
19
|
+
permissions: string;
|
|
20
|
+
/** The server overview page. */
|
|
21
|
+
overview: string;
|
|
22
|
+
/** The databases page. */
|
|
23
|
+
databases: string;
|
|
24
|
+
/** The server status page. */
|
|
25
|
+
server: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const DEFAULT_PATHS: Readonly<MongocampPaths>;
|
|
28
|
+
/**
|
|
29
|
+
* The configured paths over the defaults. A missing, empty or non-text entry keeps its default, an unknown key is dropped,
|
|
30
|
+
* and trailing slashes are removed (the components append `/<name>` themselves) — `/` alone stays `/`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolvePaths(configured?: unknown): MongocampPaths;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const DEFAULT_PATHS = Object.freeze({
|
|
2
|
+
home: "/secured",
|
|
3
|
+
collections: "/secured/admin/collections",
|
|
4
|
+
buckets: "/secured/admin/buckets",
|
|
5
|
+
users: "/secured/admin/users",
|
|
6
|
+
roles: "/secured/admin/roles",
|
|
7
|
+
jobs: "/secured/admin/jobs",
|
|
8
|
+
settings: "/secured/admin/settings",
|
|
9
|
+
account: "/secured/account",
|
|
10
|
+
permissions: "/secured/admin/permissions",
|
|
11
|
+
overview: "/secured/admin/overview",
|
|
12
|
+
databases: "/secured/admin/databases",
|
|
13
|
+
server: "/secured/admin/server"
|
|
14
|
+
});
|
|
15
|
+
export function resolvePaths(configured) {
|
|
16
|
+
const source = configured && typeof configured === "object" ? configured : {};
|
|
17
|
+
const paths = { ...DEFAULT_PATHS };
|
|
18
|
+
for (const key of Object.keys(DEFAULT_PATHS)) {
|
|
19
|
+
const value = source[key];
|
|
20
|
+
if (typeof value !== "string" || !value.trim()) continue;
|
|
21
|
+
paths[key] = value.trim().replace(/\/+$/, "") || "/";
|
|
22
|
+
}
|
|
23
|
+
return paths;
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ServerHealth = 'ok' | 'partial' | 'down';
|
|
2
|
+
/**
|
|
3
|
+
* What one request did: it answered (`ok`), the server answered with an error (`refused` — no right, or a server older than
|
|
4
|
+
* 1.9.0 without the route), nothing came back (`failed`), or it was not sent (`skipped` — not signed in, not allowed).
|
|
5
|
+
*/
|
|
6
|
+
export type Outcome = 'ok' | 'refused' | 'failed' | 'skipped';
|
|
7
|
+
/** An error that carries an HTTP response proves the server is there; anything else (network, timeout) does not. */
|
|
8
|
+
export declare function outcomeOfError(error: unknown): Outcome;
|
|
9
|
+
/**
|
|
10
|
+
* - `down`: nothing that was asked came back at all — or nothing could be asked and the server's version is unknown too.
|
|
11
|
+
* - `partial`: the server is there but something is missing: a request failed or was refused, or the load came without its connection numbers (the database
|
|
12
|
+
* user lacks `clusterMonitor`).
|
|
13
|
+
* - `ok`: everything that was asked answered.
|
|
14
|
+
*/
|
|
15
|
+
export declare function serverHealth(input: {
|
|
16
|
+
info: Outcome;
|
|
17
|
+
stats: Outcome;
|
|
18
|
+
hasConnections: boolean;
|
|
19
|
+
versionKnown: boolean;
|
|
20
|
+
}): ServerHealth;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function outcomeOfError(error) {
|
|
2
|
+
const response = error?.response;
|
|
3
|
+
return typeof response?.status === "number" ? "refused" : "failed";
|
|
4
|
+
}
|
|
5
|
+
export function serverHealth(input) {
|
|
6
|
+
const asked = [input.info, input.stats].filter((outcome) => outcome !== "skipped");
|
|
7
|
+
if (!asked.length) return input.versionKnown ? "ok" : "down";
|
|
8
|
+
if (asked.every((outcome) => outcome === "failed")) return "down";
|
|
9
|
+
if (asked.some((outcome) => outcome !== "ok")) return "partial";
|
|
10
|
+
return input.stats === "ok" && !input.hasConnections ? "partial" : "ok";
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-mongocamp",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
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/",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/types.d.mts",
|
|
22
22
|
"import": "./dist/module.mjs"
|
|
23
|
+
},
|
|
24
|
+
"./utils": {
|
|
25
|
+
"types": "./dist/runtime/publicUtils.d.ts",
|
|
26
|
+
"import": "./dist/runtime/publicUtils.js"
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
29
|
"main": "./dist/module.mjs",
|
|
@@ -27,6 +31,9 @@
|
|
|
27
31
|
"*": {
|
|
28
32
|
".": [
|
|
29
33
|
"./dist/types.d.mts"
|
|
34
|
+
],
|
|
35
|
+
"utils": [
|
|
36
|
+
"./dist/runtime/publicUtils.d.ts"
|
|
30
37
|
]
|
|
31
38
|
}
|
|
32
39
|
},
|
|
@@ -75,12 +82,12 @@
|
|
|
75
82
|
"@nuxt/module-builder": "^1.0.4",
|
|
76
83
|
"@nuxt/schema": "^4.6.4",
|
|
77
84
|
"@nuxt/test-utils": "^4.4.0",
|
|
78
|
-
"@playwright/test": "^1.65.
|
|
85
|
+
"@playwright/test": "^1.65.1",
|
|
79
86
|
"@types/node": "latest",
|
|
80
87
|
"@unhead/vue": "^3.4.3",
|
|
81
88
|
"@vue/test-utils": "^2.5.1",
|
|
82
89
|
"changelogen": "^0.6.2",
|
|
83
|
-
"eslint": "^10.
|
|
90
|
+
"eslint": "^10.15.0",
|
|
84
91
|
"happy-dom": "^21.0.4",
|
|
85
92
|
"nuxt": "^4.6.4",
|
|
86
93
|
"typescript": "~6.0.3",
|