@sfxcode/nuxt-ui-mongocamp 1.1.3 → 1.2.0

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 (43) hide show
  1. package/README.md +31 -9
  2. package/dist/module.d.mts +22 -0
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +41 -5
  5. package/dist/runtime/components/MongocampAccount.vue +21 -20
  6. package/dist/runtime/components/MongocampBucketFiles.d.vue.ts +6 -0
  7. package/dist/runtime/components/MongocampBucketFiles.vue +364 -0
  8. package/dist/runtime/components/MongocampBucketFiles.vue.d.ts +6 -0
  9. package/dist/runtime/components/MongocampCollectionData.vue +36 -35
  10. package/dist/runtime/components/MongocampCollectionInfos.vue +37 -36
  11. package/dist/runtime/components/MongocampCollections.d.vue.ts +1 -0
  12. package/dist/runtime/components/MongocampCollections.vue +38 -28
  13. package/dist/runtime/components/MongocampCollections.vue.d.ts +1 -0
  14. package/dist/runtime/components/MongocampDatabases.vue +13 -12
  15. package/dist/runtime/components/MongocampJobs.vue +43 -45
  16. package/dist/runtime/components/MongocampLogin.d.vue.ts +4 -1
  17. package/dist/runtime/components/MongocampLogin.vue +13 -9
  18. package/dist/runtime/components/MongocampLogin.vue.d.ts +4 -1
  19. package/dist/runtime/components/MongocampRoleGrants.vue +30 -28
  20. package/dist/runtime/components/MongocampRoles.vue +30 -31
  21. package/dist/runtime/components/MongocampUsers.vue +35 -36
  22. package/dist/runtime/components/MongocampVersion.vue +3 -1
  23. package/dist/runtime/composables/useMongocampAccount.js +6 -5
  24. package/dist/runtime/composables/useMongocampAdmin.js +2 -2
  25. package/dist/runtime/composables/useMongocampBucket.d.ts +20 -1
  26. package/dist/runtime/composables/useMongocampBucket.js +62 -13
  27. package/dist/runtime/composables/useMongocampClientApi.d.ts +13 -0
  28. package/dist/runtime/composables/useMongocampClientApi.js +8 -0
  29. package/dist/runtime/composables/useMongocampIndex.js +2 -2
  30. package/dist/runtime/composables/useMongocampJobs.js +2 -2
  31. package/dist/runtime/composables/useMongocampProxyApi.d.ts +13 -0
  32. package/dist/runtime/composables/useMongocampProxyApi.js +9 -0
  33. package/dist/runtime/composables/useMongocampRoles.d.ts +2 -0
  34. package/dist/runtime/composables/useMongocampRoles.js +4 -2
  35. package/dist/runtime/composables/useMongocampSystem.js +2 -2
  36. package/dist/runtime/locales/de.json +265 -0
  37. package/dist/runtime/locales/en.json +265 -0
  38. package/dist/runtime/plugin.js +8 -8
  39. package/dist/runtime/server/handlers/mongocampProxy.d.ts +2 -0
  40. package/dist/runtime/server/handlers/mongocampProxy.js +45 -0
  41. package/dist/runtime/utils/createProxyMongocampApis.d.ts +15 -0
  42. package/dist/runtime/utils/createProxyMongocampApis.js +28 -0
  43. package/package.json +13 -6
@@ -1,18 +1,18 @@
1
1
  import { defineNuxtPlugin, addRouteMiddleware, navigateTo, useAsyncData, useRuntimeConfig } from "#app";
2
- import { useMongocampApi, useMongocampAuth } from "#imports";
2
+ import { useMongocampAuth, useMongocampClientApi } from "#imports";
3
3
  import { useMongocampRoles } from "./composables/useMongocampRoles.js";
4
4
  export default defineNuxtPlugin(async (_nuxtApp) => {
5
- const { logout } = useMongocampAuth();
6
- const { informationApi } = useMongocampApi();
7
- const { notAllowedPath, isAllowedPathForRoute } = useMongocampRoles();
5
+ const { informationApi } = useMongocampClientApi();
8
6
  const config = useRuntimeConfig();
9
7
  const useGlobalAuthMiddleware = config.public.nuxtUiMongocampOptions.useGlobalAuthMiddleware ?? false;
10
8
  const { data: version } = await useAsyncData("version", () => informationApi.version());
11
9
  if (useGlobalAuthMiddleware) {
12
- addRouteMiddleware("global-auth", (to) => {
13
- if (to.path === "/logout") {
14
- logout();
15
- return navigateTo(notAllowedPath);
10
+ addRouteMiddleware("global-auth", async (to) => {
11
+ const { logout } = useMongocampAuth();
12
+ const { notAllowedPath, logoutRedirectPath, logoutPath, isAllowedPathForRoute } = useMongocampRoles();
13
+ if (to.path === logoutPath) {
14
+ await logout();
15
+ return navigateTo(logoutRedirectPath);
16
16
  }
17
17
  if (!isAllowedPathForRoute(to.path)) {
18
18
  return navigateTo(notAllowedPath);
@@ -0,0 +1,2 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
2
+ export default _default;
@@ -0,0 +1,45 @@
1
+ import { createError, defineEventHandler, getRequestURL, proxyRequest } from "h3";
2
+ import { useNitroApp, useRuntimeConfig } from "nitropack/runtime";
3
+ import { consola } from "consola";
4
+ let warnedMissingAuthorizeHook = false;
5
+ function hasAuthorizeHookRegistered(hooks) {
6
+ const bag = hooks._hooks;
7
+ if (!bag) return true;
8
+ return (bag["mongocamp-proxy:authorize"]?.length ?? 0) > 0;
9
+ }
10
+ export default defineEventHandler(async (event) => {
11
+ const config = useRuntimeConfig(event);
12
+ const options = config.public.nuxtUiMongocampOptions;
13
+ if (!options?.useServerProxy) {
14
+ throw createError({ statusCode: 404, statusMessage: "Not Found" });
15
+ }
16
+ const nitroHooks = useNitroApp().hooks;
17
+ if (!warnedMissingAuthorizeHook && !hasAuthorizeHookRegistered(nitroHooks)) {
18
+ warnedMissingAuthorizeHook = true;
19
+ consola.warn(
20
+ "[nuxt-ui-mongocamp] `useServerProxy` is enabled but no `mongocamp-proxy:authorize` hook is registered. The proxy route is unguarded: any caller who can reach it gets the full power of the configured MongoCamp api key. Register a guard from your own `server/plugins/*.ts` \u2014 see docs/guide/server-proxy-auth.md."
21
+ );
22
+ }
23
+ await nitroHooks.callHook("mongocamp-proxy:authorize", event);
24
+ const serverProxyPath = (options.serverProxyPath ?? "/api/_mongocamp").replace(/\/+$/, "");
25
+ const mongocampUrl = config.public.mongocamp?.url;
26
+ const apiKey = config.mongocampApiKey ?? "";
27
+ if (!mongocampUrl) {
28
+ throw createError({ statusCode: 500, statusMessage: "nuxt-ui-mongocamp: `mongocamp.url` is not configured" });
29
+ }
30
+ if (!apiKey) {
31
+ throw createError({ statusCode: 500, statusMessage: "nuxt-ui-mongocamp: `mongocamp.apiKey` is not configured for server proxy mode" });
32
+ }
33
+ const requestUrl = getRequestURL(event);
34
+ const subPath = requestUrl.pathname.slice(serverProxyPath.length);
35
+ const target = `${mongocampUrl}${subPath}${requestUrl.search}`;
36
+ return proxyRequest(event, target, {
37
+ headers: {
38
+ "X-AUTH-APIKEY": apiKey,
39
+ // Neutralize any Authorization header the caller sent — auth against MongoCamp in
40
+ // proxy mode must only ever come from the server-side api key above, never from
41
+ // whatever a caller (legitimate or not) put on their own request.
42
+ "Authorization": ""
43
+ }
44
+ });
45
+ });
@@ -0,0 +1,15 @@
1
+ import { AdminApi, ApplicationApi, AuthApi, BucketApi, CollectionApi, DatabaseApi, DocumentApi, FileApi, IndexApi, InformationApi, JobsApi } from '@sfxcode/nuxt-mongocamp-server/api';
2
+ import type { Configuration } from '@sfxcode/nuxt-mongocamp-server/api';
3
+ export declare function createProxyMongocampApis(configuration: Configuration): {
4
+ adminApi: AdminApi;
5
+ applicationApi: ApplicationApi;
6
+ authApi: AuthApi;
7
+ bucketApi: BucketApi;
8
+ collectionApi: CollectionApi;
9
+ databaseApi: DatabaseApi;
10
+ documentApi: DocumentApi;
11
+ fileApi: FileApi;
12
+ indexApi: IndexApi;
13
+ informationApi: InformationApi;
14
+ jobApi: JobsApi;
15
+ };
@@ -0,0 +1,28 @@
1
+ import {
2
+ AdminApi,
3
+ ApplicationApi,
4
+ AuthApi,
5
+ BucketApi,
6
+ CollectionApi,
7
+ DatabaseApi,
8
+ DocumentApi,
9
+ FileApi,
10
+ IndexApi,
11
+ InformationApi,
12
+ JobsApi
13
+ } from "@sfxcode/nuxt-mongocamp-server/api";
14
+ export function createProxyMongocampApis(configuration) {
15
+ return {
16
+ adminApi: new AdminApi(configuration),
17
+ applicationApi: new ApplicationApi(configuration),
18
+ authApi: new AuthApi(configuration),
19
+ bucketApi: new BucketApi(configuration),
20
+ collectionApi: new CollectionApi(configuration),
21
+ databaseApi: new DatabaseApi(configuration),
22
+ documentApi: new DocumentApi(configuration),
23
+ fileApi: new FileApi(configuration),
24
+ indexApi: new IndexApi(configuration),
25
+ informationApi: new InformationApi(configuration),
26
+ jobApi: new JobsApi(configuration)
27
+ };
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
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,36 +44,43 @@
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 --patch --release && npm publish && git push --follow-tags",
47
+ "release": "npm run lint && npm run test && npm run prepack && changelogen --minor --release && npm publish && git push --follow-tags",
48
48
  "lint": "eslint .",
49
- "test": "vitest run",
49
+ "test": "vitest run --project unit --project components",
50
50
  "test:watch": "vitest watch",
51
+ "test:e2e:auth": "vitest run --project e2e-auth",
51
52
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
52
53
  "docs:dev": "vitepress dev docs",
53
54
  "docs:build": "vitepress build docs",
54
55
  "docs:preview": "vitepress preview docs"
55
56
  },
56
57
  "dependencies": {
58
+ "@formkit/nuxt": "^2.1.0",
57
59
  "@internationalized/date": "^3.12.2",
58
60
  "@nuxt/kit": "^4.4.8",
59
- "@nuxt/ui": "4.9.0",
60
- "@sfxcode/nuxt-mongocamp-server": "^1.4.4",
61
+ "@nuxt/ui": "^4.10.0",
62
+ "@nuxtjs/i18n": "^10.4.1",
63
+ "@sfxcode/nuxt-mongocamp-server": "^1.5.0",
61
64
  "@sfxcode/nuxt-ui-formkit": "^1.2.6",
65
+ "consola": "^3.4.2",
62
66
  "defu": "^6.1.7",
63
67
  "minimatch": "^10.2.5",
64
68
  "unocss-nuxt-ui": "^1.2.2"
65
69
  },
66
70
  "devDependencies": {
71
+ "@iconify-json/lucide": "^1.2.117",
67
72
  "@nuxt/devtools": "4.0.0-alpha.7",
68
73
  "@nuxt/eslint-config": "^1.16.0",
69
74
  "@nuxt/module-builder": "^1.0.2",
70
75
  "@nuxt/schema": "^4.4.8",
71
76
  "@nuxt/test-utils": "^4.0.3",
77
+ "@playwright/test": "^1.61.1",
72
78
  "@types/node": "latest",
79
+ "@vue/test-utils": "^2.4.11",
73
80
  "changelogen": "^0.6.2",
74
81
  "eslint": "^10.7.0",
82
+ "happy-dom": "^20.10.6",
75
83
  "nuxt": "^4.4.8",
76
- "tailwindcss": "^4.3.2",
77
84
  "typescript": "~6.0.3",
78
85
  "vitepress": "2.0.0-alpha.18",
79
86
  "vitest": "^4.1.10",