@sfxcode/nuxt-ui-mongocamp 1.5.2 → 1.5.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 (57) hide show
  1. package/dist/module.d.mts +9 -0
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1 -0
  4. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +0 -1
  5. package/dist/runtime/components/MongocampCollectionData.vue +4 -3
  6. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +0 -1
  7. package/dist/runtime/components/MongocampCollections.vue +7 -4
  8. package/dist/runtime/components/MongocampCommandPalette.d.vue.ts +0 -7
  9. package/dist/runtime/components/MongocampCommandPalette.vue +16 -15
  10. package/dist/runtime/components/MongocampCommandPalette.vue.d.ts +0 -7
  11. package/dist/runtime/components/MongocampDashboard.d.vue.ts +0 -3
  12. package/dist/runtime/components/MongocampDashboard.vue +8 -7
  13. package/dist/runtime/components/MongocampDashboard.vue.d.ts +0 -3
  14. package/dist/runtime/components/MongocampPermissionMatrix.d.vue.ts +0 -1
  15. package/dist/runtime/components/MongocampPermissionMatrix.vue +4 -3
  16. package/dist/runtime/components/MongocampPermissionMatrix.vue.d.ts +0 -1
  17. package/dist/runtime/components/MongocampRoles.vue +3 -2
  18. package/dist/runtime/components/MongocampServerOverview.d.vue.ts +0 -3
  19. package/dist/runtime/components/MongocampServerOverview.vue +8 -7
  20. package/dist/runtime/components/MongocampServerOverview.vue.d.ts +0 -3
  21. package/dist/runtime/components/MongocampServerStatus.d.vue.ts +13 -0
  22. package/dist/runtime/components/MongocampServerStatus.vue +147 -0
  23. package/dist/runtime/components/MongocampServerStatus.vue.d.ts +13 -0
  24. package/dist/runtime/components/MongocampUserAccess.d.vue.ts +27 -0
  25. package/dist/runtime/components/MongocampUserAccess.vue +168 -0
  26. package/dist/runtime/components/MongocampUserAccess.vue.d.ts +27 -0
  27. package/dist/runtime/components/MongocampVersion.vue +3 -3
  28. package/dist/runtime/composables/useMongocampAdminGate.js +2 -3
  29. package/dist/runtime/composables/useMongocampBreadcrumbs.d.ts +12 -0
  30. package/dist/runtime/composables/useMongocampBreadcrumbs.js +13 -0
  31. package/dist/runtime/composables/useMongocampCollectionNames.d.ts +21 -0
  32. package/dist/runtime/composables/useMongocampCollectionNames.js +46 -0
  33. package/dist/runtime/composables/useMongocampNavigation.d.ts +32 -0
  34. package/dist/runtime/composables/useMongocampNavigation.js +15 -0
  35. package/dist/runtime/composables/useMongocampPaths.d.ts +6 -0
  36. package/dist/runtime/composables/useMongocampPaths.js +6 -0
  37. package/dist/runtime/composables/useMongocampPermissions.js +2 -3
  38. package/dist/runtime/composables/useMongocampProxyMode.d.ts +5 -0
  39. package/dist/runtime/composables/useMongocampProxyMode.js +4 -0
  40. package/dist/runtime/composables/useMongocampRoles.d.ts +3 -0
  41. package/dist/runtime/composables/useMongocampRoles.js +5 -1
  42. package/dist/runtime/composables/useMongocampSession.js +2 -3
  43. package/dist/runtime/locales/de.json +42 -0
  44. package/dist/runtime/locales/en.json +42 -0
  45. package/dist/runtime/publicUtils.d.ts +4 -0
  46. package/dist/runtime/publicUtils.js +4 -0
  47. package/dist/runtime/utils/collectionNames.d.ts +13 -0
  48. package/dist/runtime/utils/collectionNames.js +14 -0
  49. package/dist/runtime/utils/collectionProtection.d.ts +2 -0
  50. package/dist/runtime/utils/collectionProtection.js +3 -0
  51. package/dist/runtime/utils/navigation.d.ts +39 -0
  52. package/dist/runtime/utils/navigation.js +65 -0
  53. package/dist/runtime/utils/paths.d.ts +32 -0
  54. package/dist/runtime/utils/paths.js +24 -0
  55. package/dist/runtime/utils/serverStatus.d.ts +20 -0
  56. package/dist/runtime/utils/serverStatus.js +11 -0
  57. package/package.json +8 -1
@@ -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.2",
3
+ "version": "1.5.3",
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
  },