@sfxcode/nuxt-ui-mongocamp 1.3.1 → 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 (94) 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.d.vue.ts +6 -0
  6. package/dist/runtime/components/MongocampAggregationBuilder.vue +390 -0
  7. package/dist/runtime/components/MongocampAggregationBuilder.vue.d.ts +6 -0
  8. package/dist/runtime/components/MongocampBulkDelete.d.vue.ts +11 -1
  9. package/dist/runtime/components/MongocampBulkDelete.vue +1 -0
  10. package/dist/runtime/components/MongocampBulkDelete.vue.d.ts +11 -1
  11. package/dist/runtime/components/MongocampBulkEdit.d.vue.ts +29 -0
  12. package/dist/runtime/components/MongocampBulkEdit.vue +138 -0
  13. package/dist/runtime/components/MongocampBulkEdit.vue.d.ts +29 -0
  14. package/dist/runtime/components/MongocampCollectionData.d.vue.ts +4 -1
  15. package/dist/runtime/components/MongocampCollectionData.vue +167 -4
  16. package/dist/runtime/components/MongocampCollectionData.vue.d.ts +4 -1
  17. package/dist/runtime/components/MongocampCollectionInfos.vue +266 -8
  18. package/dist/runtime/components/MongocampCollections.d.vue.ts +8 -1
  19. package/dist/runtime/components/MongocampCollections.vue +84 -72
  20. package/dist/runtime/components/MongocampCollections.vue.d.ts +8 -1
  21. package/dist/runtime/components/MongocampConfirmByName.d.vue.ts +23 -0
  22. package/dist/runtime/components/MongocampConfirmByName.vue +92 -0
  23. package/dist/runtime/components/MongocampConfirmByName.vue.d.ts +23 -0
  24. package/dist/runtime/components/MongocampErrorAlert.vue +28 -5
  25. package/dist/runtime/components/MongocampFilterBuilder.d.vue.ts +1 -0
  26. package/dist/runtime/components/MongocampFilterBuilder.vue +33 -2
  27. package/dist/runtime/components/MongocampFilterBuilder.vue.d.ts +1 -0
  28. package/dist/runtime/components/MongocampGrantList.d.vue.ts +7 -0
  29. package/dist/runtime/components/MongocampGrantList.vue +38 -0
  30. package/dist/runtime/components/MongocampGrantList.vue.d.ts +7 -0
  31. package/dist/runtime/components/MongocampImport.d.vue.ts +10 -0
  32. package/dist/runtime/components/MongocampImport.vue +479 -0
  33. package/dist/runtime/components/MongocampImport.vue.d.ts +10 -0
  34. package/dist/runtime/components/MongocampRoles.vue +45 -0
  35. package/dist/runtime/components/MongocampSettings.d.vue.ts +3 -0
  36. package/dist/runtime/components/MongocampSettings.vue +179 -0
  37. package/dist/runtime/components/MongocampSettings.vue.d.ts +3 -0
  38. package/dist/runtime/components/MongocampUsers.vue +183 -3
  39. package/dist/runtime/composables/useMongocampAdmin.d.ts +7 -1
  40. package/dist/runtime/composables/useMongocampAdmin.js +24 -1
  41. package/dist/runtime/composables/useMongocampAggregation.d.ts +28 -0
  42. package/dist/runtime/composables/useMongocampAggregation.js +100 -0
  43. package/dist/runtime/composables/useMongocampBucket.js +1 -1
  44. package/dist/runtime/composables/useMongocampBulkDelete.d.ts +1 -1
  45. package/dist/runtime/composables/useMongocampImport.d.ts +14 -0
  46. package/dist/runtime/composables/useMongocampImport.js +25 -0
  47. package/dist/runtime/composables/useMongocampIndex.d.ts +1 -0
  48. package/dist/runtime/composables/useMongocampIndex.js +8 -1
  49. package/dist/runtime/composables/useMongocampRoles.d.ts +1 -0
  50. package/dist/runtime/composables/useMongocampRoles.js +3 -2
  51. package/dist/runtime/composables/useMongocampSession.d.ts +8 -0
  52. package/dist/runtime/composables/useMongocampSession.js +45 -0
  53. package/dist/runtime/composables/useMongocampSystem.d.ts +15 -3
  54. package/dist/runtime/composables/useMongocampSystem.js +19 -2
  55. package/dist/runtime/locales/de.json +200 -3
  56. package/dist/runtime/locales/en.json +200 -3
  57. package/dist/runtime/plugin.js +19 -0
  58. package/dist/runtime/utils/aggregationErrors.d.ts +10 -0
  59. package/dist/runtime/utils/aggregationErrors.js +17 -0
  60. package/dist/runtime/utils/aggregationPipeline.d.ts +42 -0
  61. package/dist/runtime/utils/aggregationPipeline.js +118 -0
  62. package/dist/runtime/utils/aggregationResult.d.ts +5 -0
  63. package/dist/runtime/utils/aggregationResult.js +17 -0
  64. package/dist/runtime/utils/analyzeSamples.d.ts +27 -0
  65. package/dist/runtime/utils/analyzeSamples.js +92 -0
  66. package/dist/runtime/utils/batchInsert.d.ts +22 -0
  67. package/dist/runtime/utils/batchInsert.js +24 -0
  68. package/dist/runtime/utils/bulkDelete.d.ts +6 -1
  69. package/dist/runtime/utils/bulkDelete.js +28 -4
  70. package/dist/runtime/utils/bulkEdit.d.ts +27 -0
  71. package/dist/runtime/utils/bulkEdit.js +45 -0
  72. package/dist/runtime/utils/collectionProtection.d.ts +3 -0
  73. package/dist/runtime/utils/collectionProtection.js +7 -0
  74. package/dist/runtime/utils/configRows.d.ts +11 -0
  75. package/dist/runtime/utils/configRows.js +53 -0
  76. package/dist/runtime/utils/failureKind.d.ts +3 -0
  77. package/dist/runtime/utils/failureKind.js +11 -0
  78. package/dist/runtime/utils/filterSuggestions.d.ts +8 -0
  79. package/dist/runtime/utils/filterSuggestions.js +15 -0
  80. package/dist/runtime/utils/importPipeline.d.ts +21 -0
  81. package/dist/runtime/utils/importPipeline.js +52 -0
  82. package/dist/runtime/utils/importRows.d.ts +36 -0
  83. package/dist/runtime/utils/importRows.js +228 -0
  84. package/dist/runtime/utils/jwtExpiry.d.ts +3 -0
  85. package/dist/runtime/utils/jwtExpiry.js +31 -0
  86. package/dist/runtime/utils/objectId.d.ts +1 -0
  87. package/dist/runtime/utils/objectId.js +4 -0
  88. package/dist/runtime/utils/serverProbe.d.ts +10 -0
  89. package/dist/runtime/utils/serverProbe.js +25 -0
  90. package/dist/runtime/utils/sessionGuard.d.ts +10 -0
  91. package/dist/runtime/utils/sessionGuard.js +10 -0
  92. package/dist/runtime/utils/throttled.d.ts +6 -0
  93. package/dist/runtime/utils/throttled.js +16 -0
  94. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ const DEFAULT_LEEWAY_SECONDS = 30;
2
+ function decodeBase64Url(segment) {
3
+ try {
4
+ const base64 = segment.replace(/-/g, "+").replace(/_/g, "/");
5
+ const binary = atob(base64 + "=".repeat((4 - base64.length % 4) % 4));
6
+ return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
7
+ } catch {
8
+ return null;
9
+ }
10
+ }
11
+ export function getTokenExpiry(token) {
12
+ if (typeof token !== "string") return null;
13
+ const parts = token.split(".");
14
+ if (parts.length !== 3) return null;
15
+ const json = decodeBase64Url(parts[1]);
16
+ if (json === null) return null;
17
+ let payload;
18
+ try {
19
+ payload = JSON.parse(json);
20
+ } catch {
21
+ return null;
22
+ }
23
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return null;
24
+ const exp = payload.exp;
25
+ return typeof exp === "number" && Number.isFinite(exp) && exp > 0 ? exp : null;
26
+ }
27
+ export function tokenExpiryState(token, nowMs = Date.now(), leewaySeconds = DEFAULT_LEEWAY_SECONDS) {
28
+ const exp = getTokenExpiry(token);
29
+ if (exp === null) return "unknown";
30
+ return nowMs / 1e3 > exp + leewaySeconds ? "expired" : "valid";
31
+ }
@@ -0,0 +1 @@
1
+ export declare function isObjectIdHex(value: unknown): value is string;
@@ -0,0 +1,4 @@
1
+ const OBJECT_ID_PATTERN = /^[0-9a-f]{24}$/i;
2
+ export function isObjectIdHex(value) {
3
+ return typeof value === "string" && OBJECT_ID_PATTERN.test(value);
4
+ }
@@ -0,0 +1,10 @@
1
+ export type ProbeResult = 'reachable' | 'unreachable' | 'skipped';
2
+ interface ServerProbeOptions {
3
+ getUrl: () => string | undefined;
4
+ fetchFn?: typeof fetch;
5
+ now?: () => number;
6
+ cooldownMs?: number;
7
+ timeoutMs?: number;
8
+ }
9
+ export declare function createServerProbe(options: ServerProbeOptions): () => Promise<ProbeResult>;
10
+ export {};
@@ -0,0 +1,25 @@
1
+ import { createThrottled } from "./throttled.js";
2
+ export function createServerProbe(options) {
3
+ const { getUrl, fetchFn = (...args) => fetch(...args), now, cooldownMs, timeoutMs = 5e3 } = options;
4
+ async function ask(url) {
5
+ try {
6
+ const response = await fetchFn(`${url.replace(/\/+$/, "")}/version`, {
7
+ method: "GET",
8
+ credentials: "omit",
9
+ cache: "no-store",
10
+ signal: AbortSignal.timeout(timeoutMs)
11
+ });
12
+ return response.ok ? "reachable" : "unreachable";
13
+ } catch {
14
+ return "unreachable";
15
+ }
16
+ }
17
+ let currentUrl = "";
18
+ const throttled = createThrottled(() => ask(currentUrl), { now, cooldownMs });
19
+ return function probe() {
20
+ const url = getUrl();
21
+ if (!url) return Promise.resolve("skipped");
22
+ currentUrl = url;
23
+ return throttled();
24
+ };
25
+ }
@@ -0,0 +1,10 @@
1
+ import type { TokenExpiryState } from './jwtExpiry.js';
2
+ interface SessionGuardDeps {
3
+ path: string;
4
+ loginPath: string;
5
+ checkExpiry: () => TokenExpiryState;
6
+ invalidate: () => Promise<void>;
7
+ isAllowed: (path: string) => boolean;
8
+ }
9
+ export declare function runSessionGuard(deps: SessionGuardDeps): Promise<'continue' | 'redirect'>;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ export async function runSessionGuard(deps) {
2
+ if (deps.checkExpiry() !== "expired") return "continue";
3
+ try {
4
+ await deps.invalidate();
5
+ } catch {
6
+ return "continue";
7
+ }
8
+ if (deps.path === deps.loginPath) return "continue";
9
+ return deps.isAllowed(deps.path) ? "continue" : "redirect";
10
+ }
@@ -0,0 +1,6 @@
1
+ interface ThrottleOptions {
2
+ now?: () => number;
3
+ cooldownMs?: number;
4
+ }
5
+ export declare function createThrottled<T>(fn: () => Promise<T>, options?: ThrottleOptions): () => Promise<T>;
6
+ export {};
@@ -0,0 +1,16 @@
1
+ export function createThrottled(fn, options = {}) {
2
+ const { now = Date.now, cooldownMs = 5e3 } = options;
3
+ let inFlight = null;
4
+ let last = null;
5
+ return function throttled() {
6
+ if (inFlight) return inFlight;
7
+ if (last && now() - last.at < cooldownMs) return Promise.resolve(last.value);
8
+ inFlight = fn().then((value) => {
9
+ last = { value, at: now() };
10
+ return value;
11
+ }).finally(() => {
12
+ inFlight = null;
13
+ });
14
+ return inFlight;
15
+ };
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.3.1",
3
+ "version": "1.3.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/",