@sfxcode/nuxt-mongocamp-server 1.9.2 → 2.0.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 (119) hide show
  1. package/README.md +97 -7
  2. package/dist/module.d.mts +31 -1
  3. package/dist/module.json +2 -2
  4. package/dist/module.mjs +42 -4
  5. package/dist/runtime/api/apis/AdminApi.d.ts +9 -9
  6. package/dist/runtime/api/apis/AdminApi.js +6 -6
  7. package/dist/runtime/api/apis/ApplicationApi.d.ts +6 -6
  8. package/dist/runtime/api/apis/ApplicationApi.js +4 -4
  9. package/dist/runtime/api/apis/AuthApi.d.ts +7 -7
  10. package/dist/runtime/api/apis/AuthApi.js +6 -6
  11. package/dist/runtime/api/apis/BucketApi.d.ts +7 -7
  12. package/dist/runtime/api/apis/BucketApi.js +6 -6
  13. package/dist/runtime/api/apis/CollectionApi.d.ts +69 -28
  14. package/dist/runtime/api/apis/CollectionApi.js +46 -21
  15. package/dist/runtime/api/apis/DatabaseApi.d.ts +5 -5
  16. package/dist/runtime/api/apis/DatabaseApi.js +4 -4
  17. package/dist/runtime/api/apis/DocumentApi.d.ts +141 -24
  18. package/dist/runtime/api/apis/DocumentApi.js +85 -12
  19. package/dist/runtime/api/apis/FileApi.d.ts +38 -6
  20. package/dist/runtime/api/apis/FileApi.js +24 -4
  21. package/dist/runtime/api/apis/IndexApi.d.ts +6 -6
  22. package/dist/runtime/api/apis/IndexApi.js +4 -4
  23. package/dist/runtime/api/apis/JobsApi.d.ts +5 -5
  24. package/dist/runtime/api/apis/JobsApi.js +4 -4
  25. package/dist/runtime/api/apis/SystemApi.d.ts +1 -1
  26. package/dist/runtime/api/docs/AdminApi.md +7 -7
  27. package/dist/runtime/api/docs/ApplicationApi.md +4 -4
  28. package/dist/runtime/api/docs/AuthApi.md +3 -3
  29. package/dist/runtime/api/docs/BucketApi.md +3 -3
  30. package/dist/runtime/api/docs/CollectionApi.md +48 -36
  31. package/dist/runtime/api/docs/DatabaseApi.md +2 -2
  32. package/dist/runtime/api/docs/DocumentApi.md +64 -28
  33. package/dist/runtime/api/docs/FileApi.md +20 -8
  34. package/dist/runtime/api/docs/IndexApi.md +4 -4
  35. package/dist/runtime/api/docs/JobsApi.md +2 -2
  36. package/dist/runtime/api/models/BucketInformation.d.ts +1 -1
  37. package/dist/runtime/api/models/Capabilities.d.ts +1 -1
  38. package/dist/runtime/api/models/CapabilityLimits.d.ts +1 -1
  39. package/dist/runtime/api/models/ClusterInformation.d.ts +1 -1
  40. package/dist/runtime/api/models/ClusterMemberInformation.d.ts +7 -4
  41. package/dist/runtime/api/models/CollectionCollation.d.ts +1 -1
  42. package/dist/runtime/api/models/CollectionOptions.d.ts +1 -1
  43. package/dist/runtime/api/models/CollectionPermission.d.ts +1 -1
  44. package/dist/runtime/api/models/CollectionStatus.d.ts +1 -1
  45. package/dist/runtime/api/models/CollectionSummary.d.ts +1 -1
  46. package/dist/runtime/api/models/ConnectionStats.d.ts +1 -1
  47. package/dist/runtime/api/models/CopyRequest.d.ts +1 -1
  48. package/dist/runtime/api/models/CopyResponse.d.ts +1 -1
  49. package/dist/runtime/api/models/CountResponse.d.ts +1 -1
  50. package/dist/runtime/api/models/CreateCollectionResponse.d.ts +1 -1
  51. package/dist/runtime/api/models/DatabaseInfo.d.ts +1 -1
  52. package/dist/runtime/api/models/DeleteResponse.d.ts +1 -1
  53. package/dist/runtime/api/models/ErrorDescription.d.ts +1 -1
  54. package/dist/runtime/api/models/FieldInfo.d.ts +1 -1
  55. package/dist/runtime/api/models/FieldTypeCount.d.ts +1 -1
  56. package/dist/runtime/api/models/FileInformation.d.ts +1 -1
  57. package/dist/runtime/api/models/Grant.d.ts +1 -1
  58. package/dist/runtime/api/models/ImportResponse.d.ts +1 -1
  59. package/dist/runtime/api/models/IndexCreateRequest.d.ts +1 -1
  60. package/dist/runtime/api/models/IndexCreateResponse.d.ts +1 -1
  61. package/dist/runtime/api/models/IndexDropResponse.d.ts +1 -1
  62. package/dist/runtime/api/models/IndexInfo.d.ts +1 -1
  63. package/dist/runtime/api/models/IndexKey.d.ts +1 -1
  64. package/dist/runtime/api/models/IndexOptionsRequest.d.ts +3 -2
  65. package/dist/runtime/api/models/IndexUsage.d.ts +1 -1
  66. package/dist/runtime/api/models/InsertError.d.ts +1 -1
  67. package/dist/runtime/api/models/InsertResponse.d.ts +1 -1
  68. package/dist/runtime/api/models/JobConfig.d.ts +1 -1
  69. package/dist/runtime/api/models/JobInformation.d.ts +1 -1
  70. package/dist/runtime/api/models/JsonSchema.d.ts +1 -1
  71. package/dist/runtime/api/models/JsonSchemaDefinition.d.ts +1 -1
  72. package/dist/runtime/api/models/JsonValueAny.d.ts +1 -1
  73. package/dist/runtime/api/models/JsonValueBoolean.d.ts +1 -1
  74. package/dist/runtime/api/models/JsonValueString.d.ts +1 -1
  75. package/dist/runtime/api/models/Login.d.ts +1 -1
  76. package/dist/runtime/api/models/LoginResult.d.ts +1 -1
  77. package/dist/runtime/api/models/MongoAggregateRequest.d.ts +1 -1
  78. package/dist/runtime/api/models/MongoCampConfiguration.d.ts +1 -1
  79. package/dist/runtime/api/models/MongoFindRequest.d.ts +1 -1
  80. package/dist/runtime/api/models/MongoIndex.d.ts +1 -1
  81. package/dist/runtime/api/models/OpCounters.d.ts +1 -1
  82. package/dist/runtime/api/models/PasswordUpdateRequest.d.ts +1 -1
  83. package/dist/runtime/api/models/PipelineStage.d.ts +1 -1
  84. package/dist/runtime/api/models/RenameRequest.d.ts +1 -1
  85. package/dist/runtime/api/models/RenameResponse.d.ts +1 -1
  86. package/dist/runtime/api/models/ReplicaSetState.d.ts +1 -1
  87. package/dist/runtime/api/models/Role.d.ts +1 -1
  88. package/dist/runtime/api/models/SchemaAnalysis.d.ts +1 -1
  89. package/dist/runtime/api/models/SchemaAnalysisField.d.ts +1 -1
  90. package/dist/runtime/api/models/SchemaAnalysisFieldType.d.ts +1 -1
  91. package/dist/runtime/api/models/SearchRequest.d.ts +1 -1
  92. package/dist/runtime/api/models/SettingsResponse.d.ts +5 -3
  93. package/dist/runtime/api/models/SystemInfo.d.ts +1 -1
  94. package/dist/runtime/api/models/SystemStats.d.ts +1 -1
  95. package/dist/runtime/api/models/UpdateFileInformationRequest.d.ts +1 -1
  96. package/dist/runtime/api/models/UpdateRequest.d.ts +1 -1
  97. package/dist/runtime/api/models/UpdateResponse.d.ts +1 -1
  98. package/dist/runtime/api/models/UpdateRoleRequest.d.ts +1 -1
  99. package/dist/runtime/api/models/UserInformation.d.ts +1 -1
  100. package/dist/runtime/api/models/UserProfile.d.ts +1 -1
  101. package/dist/runtime/api/models/Version.d.ts +1 -1
  102. package/dist/runtime/api/runtime.d.ts +1 -1
  103. package/dist/runtime/composables/mongocampApi.js +7 -0
  104. package/dist/runtime/composables/mongocampSearch.d.ts +3 -1
  105. package/dist/runtime/composables/mongocampSearch.js +3 -3
  106. package/dist/runtime/server/composables/mongocampApi.d.ts +2 -1
  107. package/dist/runtime/server/composables/mongocampApi.js +11 -5
  108. package/dist/runtime/server/composables/mongocampServerApi.d.ts +2 -1
  109. package/dist/runtime/server/composables/mongocampServerApi.js +3 -7
  110. package/dist/runtime/server/mongocamp/core.d.ts +22 -0
  111. package/dist/runtime/server/mongocamp/core.js +32 -0
  112. package/dist/runtime/server/mongocamp/handler.d.ts +3 -0
  113. package/dist/runtime/server/mongocamp/handler.js +8 -0
  114. package/dist/runtime/server/mongocamp/plugin.d.ts +3 -0
  115. package/dist/runtime/server/mongocamp/plugin.js +7 -0
  116. package/dist/runtime/utils/extendedJson.d.ts +12 -0
  117. package/dist/runtime/utils/extendedJson.js +60 -0
  118. package/dist/types.d.mts +1 -1
  119. package/package.json +40 -27
package/README.md CHANGED
@@ -4,7 +4,18 @@ Nuxt module wrapping a generated OpenAPI client for [MongoCamp](https://mongocam
4
4
 
5
5
  ## MongoCamp Server
6
6
 
7
- This module is a client for [MongoCamp Server](https://github.com/MongoCamp/mongocamp-server), a REST API server for MongoDB that provides authentication, user/role management, and collection, document and index APIs. The OpenAPI client in this module is generated from the server's OpenAPI spec, so the module version should match a compatible server version. See the [server repository](https://github.com/MongoCamp/mongocamp-server) for installation, configuration and API documentation.
7
+ The module works in two modes:
8
+
9
+ - **Embedded server** (`server.enabled`): the MongoCamp API runs inside the Nitro of your application (`@sfxcode/mongocamp-server-core`, a TypeScript replacement of the Scala server with the same OpenAPI contract). No second application is needed.
10
+ - **External server**: the module is a client for a running server at `url`.
11
+
12
+ The module runs on **Nitro 3 / h3 2**. Nuxt 4.7 builds with Nitro 3 (`@nuxt/nitro-v3-server`) when the application declares `nitro`:
13
+
14
+ ```bash
15
+ pnpm add @sfxcode/nuxt-mongocamp-server nitro
16
+ ```
17
+
18
+ In external mode, this module is a client for [MongoCamp Server](https://github.com/MongoCamp/mongocamp-server), a REST API server for MongoDB that provides authentication, user/role management, and collection, document and index APIs. The OpenAPI client in this module is generated from the server's OpenAPI spec, so the module version should match a compatible server version. See the [server repository](https://github.com/MongoCamp/mongocamp-server) for installation, configuration and API documentation.
8
19
 
9
20
  ## Nuxt UI MongoCamp
10
21
 
@@ -12,10 +23,71 @@ This module is a client for [MongoCamp Server](https://github.com/MongoCamp/mong
12
23
 
13
24
  ## Setup
14
25
 
26
+ ### Embedded server
27
+
28
+ ```ts
29
+ // nuxt.config.ts
30
+ export default defineNuxtConfig({
31
+ modules: ['@sfxcode/nuxt-mongocamp-server'],
32
+ mongocamp: {
33
+ server: {
34
+ enabled: true,
35
+ // prefix: '/api/mongocamp-server', the url of the clients defaults to it
36
+ config: { CONNECTION_DATABASE: 'mongocamp' },
37
+ },
38
+ refreshToken: true,
39
+ },
40
+ })
41
+ ```
42
+
43
+ The connection and every other setting use the env variables of the Scala server, so existing deployments keep their environment:
44
+
45
+ | Env | Default | Description |
46
+ | --- | --- | --- |
47
+ | `CONNECTION_HOST`, `CONNECTION_PORT` | `localhost`, `27017` | MongoDB server (or `NUXT_MONGOCAMP_SERVER_CONNECTION_URI` for a full connection string) |
48
+ | `CONNECTION_DATABASE` | `mongocamp` | default database |
49
+ | `CONNECTION_USERNAME`, `CONNECTION_PASSWORD`, `CONNECTION_AUTHDB` | —, —, `admin` | credentials of the database user |
50
+ | `AUTH_HANDLER` | `mongo` | users and roles in `mc_users` / `mc_roles` (`static`: `AUTH_USERS`, `AUTH_ROLES`) |
51
+ | `AUTH_SECRET` | random, stored | secret of the tokens (stored in `mc_configuration`, shared by all instances) |
52
+ | `AUTH_EXPIRING_DURATION` | `6h` | lifetime of a token |
53
+ | `REQUESTLOGGING_ENABLED`, `METRICS_ENABLED` | `false` | request log and metrics (the former plugins) |
54
+
55
+ At the first start the user `admin` is created with a random password that is printed to the log (like the Scala server). Further settings
56
+ and the extension points (events, job handlers) are described in [`packages/server-core/README.md`](packages/server-core/README.md). In
57
+ server code `useMongocampCore()` gives the embedded server, e.g. to listen to its events:
58
+
59
+ ```ts
60
+ // server/plugins/audit.ts
61
+ import { definePlugin } from 'nitro'
62
+
63
+ export default definePlugin(async () => {
64
+ const core = await useMongocampCore()
65
+ core.events.on('document:delete', event => console.info(event.user.userId, event.collectionName, event.oldValues))
66
+ })
67
+ ```
68
+
69
+ **Migration to 2.0** (from 1.x or from the Scala server): every change and the checklist are in [`docs/migration-2.0.md`](docs/migration-2.0.md) — documents as Extended JSON, Lucene rules, 404 for missing resources, salted passwords, one start with `MIGRATION_DROP_SCALA_LEFTOVERS=true` on a database of the Scala server.
70
+
71
+ **Migration from the Scala server** (details and all differences: [`docs/migration-from-scala.md`](docs/migration-from-scala.md)): point the embedded server at the same database (the same `CONNECTION_*` and `AUTH_PREFIX`); users,
72
+ roles, tokens, the token secret and the stored configurations keep working. Jobs are read from `mc_jobs` with cron expressions in the
73
+ syntax of [croner](https://croner.56k.guru) (`*/5` instead of `0/5`); the Quartz tables `mc_jobs_*` are not read.
74
+
75
+ ### Standalone server
76
+
77
+ `apps/server` is the same server without Nuxt (Nitro 3), configured only by env and listening on `SERVER_INTERFACE:SERVER_PORT`
78
+ (default `0.0.0.0:8080`) like the Scala image:
79
+
15
80
  ```bash
16
- pnpm add @sfxcode/nuxt-mongocamp-server
81
+ docker build -f apps/server/Dockerfile -t mongocamp-nitro-server .
82
+ docker run -p 8080:8080 -e CONNECTION_HOST=host.docker.internal mongocamp-nitro-server
17
83
  ```
18
84
 
85
+ The image (distroless Node 24, about 214 MB, the server itself 2.8 MB) stops cleanly on `docker stop` (SIGTERM) and on `DELETE /system`.
86
+
87
+ The spec is served at `/docs/docs.yaml` (`DOCS_OPENAPI`, default on) and an API reference UI at `/docs` (`DOCS_SWAGGER`).
88
+
89
+ ### External server
90
+
19
91
  ```ts
20
92
  // nuxt.config.ts
21
93
  export default defineNuxtConfig({
@@ -33,7 +105,12 @@ export default defineNuxtConfig({
33
105
 
34
106
  | Option | Type | Default | Description |
35
107
  | ------------------------| --------- | ------- | ----------------------------------------------------------------------------------------------|
36
- | `url` | `string` | — | Required. Base URL of the MongoCamp server. |
108
+ | `url` | `string` | — | Base URL of the MongoCamp server. Required without the embedded server, which it defaults to. |
109
+ | `server.enabled` | `boolean` | `false` | Runs the MongoCamp API inside this application. |
110
+ | `server.prefix` | `string` | `/api/mongocamp-server` | Path of the embedded API. |
111
+ | `server.connectionUri` | `string` | — | MongoDB connection string; better by env `NUXT_MONGOCAMP_SERVER_CONNECTION_URI`. |
112
+ | `server.config` | `object` | `{}` | Settings by key (`CONNECTION_DATABASE`, ...); the env variables win. |
113
+ | `server.jobs` | `boolean` | `true` | Runs the jobs (token cleanup, ...) on their schedule in this instance. |
37
114
  | `apiKey` | `string` | — | Optional. Stored server-side only; picked up automatically by `useMongocampApi(event)`. |
38
115
  | `paginationSize` | `number` | `500` | Default rows per page for search/list composables. Values below 10 fall back to the default. |
39
116
  | `refreshToken` | `boolean` | `false` | Whether the client auto-refreshes the session token on an interval after login. |
@@ -51,24 +128,37 @@ A missing `url` throws during `nuxi dev`/`nuxi build`/`nuxi generate` (not durin
51
128
  | `useMongocampStorage()` | The session cookie (`{ token, profile }`) backing auth state; SSR-safe. |
52
129
  | `useMongocampUser()` | Reactive current user profile, derived from `useMongocampStorage()` (read-only). |
53
130
  | `useMongocampUrl()` | The configured base URL. |
54
- | `useMongocampSearch()` | `find`/`findAll`/`findByField` document search helpers. |
55
- | `usePaginatedFind(collection, opts)`| Reactive pagination wrapper (`page`, `documents`, `pending`, `error`, `nextPage`/`previousPage`/`goToPage`). |
131
+ | `useMongocampSearch()` | `find`/`findAll`/`findByField` document search helpers. `find(..., filterCaseInsensitive)` makes wildcards of the filter ignore the case (case-sensitive by default since 2.0.0). |
132
+ | `usePaginatedFind(collection, opts)`| Reactive pagination wrapper (`page`, `documents`, `pending`, `error`, `nextPage`/`previousPage`/`goToPage`); `opts.filterCaseInsensitive` as for `find`. |
56
133
  | `useMongocampApiCollection(name)` | Per-collection insert/update/delete/aggregate/schema helpers. |
57
134
  | `useMongocampApiCollections()` | List collections/databases, database info. |
58
135
  | `useMongocampApiFiles()` | Bucket and file upload/download/list helpers. |
59
136
  | `useMongocampApiJobs()` | List/register/update/execute/delete scheduled jobs. |
60
137
  | `useMongocampApiAdmin()` | User and role management. |
61
138
 
139
+ ### Documents as Extended JSON
140
+
141
+ Since 2.0.0 the server returns documents as relaxed MongoDB Extended JSON: `{"_id": {"$oid": "…"}, "when": {"$date": "…"}}`. Send `extendedJson: 'plain'` for the 1.x format (ids and dates as strings). Auto-imported helpers:
142
+
143
+ | Helper | Purpose |
144
+ | ---------------------------| --------------------------------------------------------------------------------------------------------|
145
+ | `documentId(docOrId)` | The id as text (hex string of an ObjectId, the value of any other id). |
146
+ | `fromExtendedJson(doc)` | Typed values: `ObjectId`, `Date`, `Decimal128`, …; integers beyond 2^53 as `bigint`. |
147
+ | `toExtendedJson(doc)` | Typed values back for an insert/update body; keeps texts that look like dates as texts. |
148
+
62
149
  ### Server composables (`src/runtime/server/composables`)
63
150
 
64
151
  | Composable | Purpose |
65
152
  | -----------------------------------------------| -----------------------------------------------------------------------------------|
66
- | `useMongocampApi(event, token?)` | Builds authenticated API clients using the module's `apiKey`, or the given `token` as a fallback. |
153
+ | `useMongocampApi(event, token?)` | Builds authenticated API clients using the module's `apiKey`, or the given `token` as a fallback. With the embedded server the calls are answered in-process. |
154
+ | `useMongocampCore()` | The embedded server (`server.enabled` only): events, configuration, direct access. |
67
155
  | `useMongocampServerApi(url, key?, token?)` | Lower-level factory when you need to authenticate against a different URL/credential explicitly. |
68
156
 
69
157
  ```ts
70
158
  // server/api/mongocamp/users.ts
71
- export default defineEventHandler((event) => {
159
+ import { defineHandler } from 'nitro'
160
+
161
+ export default defineHandler((event) => {
72
162
  const { adminApi } = useMongocampApi(event)
73
163
  return adminApi.listUsers()
74
164
  })
package/dist/module.d.mts CHANGED
@@ -1,13 +1,37 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  export * from '../dist/runtime/api/index.js';
3
3
 
4
+ /** The option `server` of the module: the MongoCamp server embedded in the Nitro of the application. */
5
+ interface ServerOptions {
6
+ /** Serves the MongoCamp API from this application (default false: an external server at `url`). */
7
+ enabled?: boolean;
8
+ /** The path of the API (default `/api/mongocamp-server`). */
9
+ prefix?: string;
10
+ /** A MongoDB connection string; without it the `CONNECTION_*` configurations (env) are used. Better set by env (`NUXT_MONGOCAMP_SERVER_CONNECTION_URI`). */
11
+ connectionUri?: string;
12
+ /** Configuration values by key (`CONNECTION_DATABASE`, `AUTH_SECRET`, ...); the env variables of the Scala server win. */
13
+ config?: Record<string, unknown>;
14
+ /** Runs the jobs (token cleanup, ...) on their schedule in this instance (default true). */
15
+ jobs?: boolean;
16
+ }
17
+ interface ResolvedServerOptions {
18
+ enabled: boolean;
19
+ prefix: string;
20
+ connectionUri: string;
21
+ config: Record<string, unknown>;
22
+ jobs: boolean;
23
+ }
24
+
4
25
  interface ModuleOptions {
26
+ /** The url of the MongoCamp API; with `server.enabled` it defaults to the prefix of the embedded server. */
5
27
  url: string;
6
28
  apiKey?: string;
7
29
  paginationSize?: number;
8
30
  refreshToken?: boolean;
9
31
  tokenRefreshInterval: number;
10
32
  sessionMaxAge?: number;
33
+ /** The MongoCamp server embedded in the Nitro of this application. */
34
+ server?: ServerOptions;
11
35
  }
12
36
  declare module '@nuxt/schema' {
13
37
  interface PublicRuntimeConfig {
@@ -21,9 +45,15 @@ declare module '@nuxt/schema' {
21
45
  }
22
46
  interface RuntimeConfig {
23
47
  mongocampApiKey: string;
48
+ mongocampServer: ResolvedServerOptions & {
49
+ version: {
50
+ name: string;
51
+ version: string;
52
+ };
53
+ };
24
54
  }
25
55
  }
26
56
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
27
57
 
28
58
  export { _default as default };
29
- export type { ModuleOptions };
59
+ export type { ModuleOptions, ServerOptions };
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-mongocamp-server",
3
- "version": "1.9.2",
3
+ "version": "2.0.0",
4
4
  "configKey": "mongocamp",
5
5
  "compatibility": {
6
- "nuxt": ">=3.16.0"
6
+ "nuxt": ">=4.7.0"
7
7
  },
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.4",
package/dist/module.mjs CHANGED
@@ -1,10 +1,35 @@
1
- import { defineNuxtModule, createResolver, addImportsDir, addServerImportsDir } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addImportsDir, addImports, addServerImportsDir, addServerHandler, addServerPlugin, addServerImports } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
3
  import { consola } from 'consola';
4
4
  export * from '../dist/runtime/api/index.js';
5
5
 
6
6
  const name = "@sfxcode/nuxt-mongocamp-server";
7
- const version = "1.9.2";
7
+ const version = "2.0.0";
8
+
9
+ const DefaultServerPrefix = "/api/mongocamp-server";
10
+ function normalizePrefix(prefix) {
11
+ const trimmed = (prefix ?? DefaultServerPrefix).trim().replace(/\/+$/, "");
12
+ const path = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
13
+ if (path === "/" || path === "") {
14
+ throw new Error('[mongocamp] "server.prefix" must not be the root path');
15
+ }
16
+ return path;
17
+ }
18
+ function resolveServerOptions(options) {
19
+ return {
20
+ enabled: options?.enabled ?? false,
21
+ prefix: normalizePrefix(options?.prefix),
22
+ connectionUri: options?.connectionUri ?? "",
23
+ config: options?.config ?? {},
24
+ jobs: options?.jobs ?? true
25
+ };
26
+ }
27
+ function resolveClientUrl(url, server) {
28
+ if (url && url.length > 0) {
29
+ return url;
30
+ }
31
+ return server.enabled ? server.prefix : void 0;
32
+ }
8
33
 
9
34
  const module$1 = defineNuxtModule({
10
35
  meta: {
@@ -12,15 +37,20 @@ const module$1 = defineNuxtModule({
12
37
  version,
13
38
  configKey: "mongocamp",
14
39
  compatibility: {
15
- nuxt: ">=3.16.0"
40
+ nuxt: ">=4.7.0"
16
41
  }
17
42
  },
18
43
  setup(options, nuxt) {
44
+ if (nuxt.options._nitroMajor !== 3) {
45
+ throw new Error('[mongocamp] the module needs Nitro 3: add "nitro" to the dependencies of the application (Nuxt then builds with @nuxt/nitro-v3-server)');
46
+ }
47
+ const server = resolveServerOptions(options.server);
48
+ options.url = resolveClientUrl(options.url, server) ?? options.url;
19
49
  nuxt.hook("ready", () => {
20
50
  if (nuxt.options._prepare)
21
51
  return;
22
52
  if (!options.url || options.url.length === 0)
23
- throw new Error('[mongocamp] Missing required "url" module option.');
53
+ throw new Error('[mongocamp] Missing required "url" module option (or enable the embedded server with "server.enabled").');
24
54
  });
25
55
  if (options.paginationSize !== void 0 && options.paginationSize < 10)
26
56
  consola.warn(`[mongocamp] paginationSize of ${options.paginationSize} is below the minimum of 10, falling back to 500`);
@@ -50,7 +80,15 @@ const module$1 = defineNuxtModule({
50
80
  const { resolve } = createResolver(import.meta.url);
51
81
  const runtimeDir = resolve("./runtime");
52
82
  addImportsDir(resolve(runtimeDir, "composables"));
83
+ addImports(["fromExtendedJson", "toExtendedJson", "documentId"].map((name2) => ({ name: name2, from: resolve(runtimeDir, "utils/extendedJson") })));
53
84
  addServerImportsDir(resolve(runtimeDir, "server/composables"));
85
+ nuxt.options.runtimeConfig.mongocampServer = defu(nuxt.options.runtimeConfig.mongocampServer, { ...server, version: { name: "mongocamp-nitro-server", version } });
86
+ if (server.enabled) {
87
+ addServerHandler({ route: `${server.prefix}/**`, handler: resolve(runtimeDir, "server/mongocamp/handler") });
88
+ addServerPlugin(resolve(runtimeDir, "server/mongocamp/plugin"));
89
+ addServerImports([{ name: "useMongocampCore", from: resolve(runtimeDir, "server/mongocamp/core") }]);
90
+ consola.info(`[mongocamp] embedded server at ${server.prefix}`);
91
+ }
54
92
  consola.success("mongocamp-nuxt available");
55
93
  }
56
94
  });
@@ -2,7 +2,7 @@
2
2
  * mongocamp-library
3
3
  * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
4
  *
5
- * The version of the OpenAPI document: 1.9.1
5
+ * The version of the OpenAPI document: 2.0.0
6
6
  *
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -61,7 +61,7 @@ export interface GnerateNewApiKeyForUserRequest {
61
61
  }
62
62
  export interface ListRolesRequest {
63
63
  /**
64
- * filter after userId by contains
64
+ * Filter by a part of the userId
65
65
  */
66
66
  filter?: string;
67
67
  /**
@@ -75,7 +75,7 @@ export interface ListRolesRequest {
75
75
  }
76
76
  export interface ListUsersRequest {
77
77
  /**
78
- * filter after userId by contains
78
+ * Filter by a part of the userId
79
79
  */
80
80
  filter?: string;
81
81
  /**
@@ -154,12 +154,12 @@ export declare class AdminApi extends runtime.BaseAPI {
154
154
  */
155
155
  deleteRoleRequestOpts(requestParameters: DeleteRoleRequest): Promise<runtime.RequestOpts>;
156
156
  /**
157
- * Delete Role
157
+ * Delete Role. 404 for a role that does not exist (2.0.0).
158
158
  * Delete Role
159
159
  */
160
160
  deleteRoleRaw(requestParameters: DeleteRoleRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<JsonValueBoolean>>;
161
161
  /**
162
- * Delete Role
162
+ * Delete Role. 404 for a role that does not exist (2.0.0).
163
163
  * Delete Role
164
164
  */
165
165
  deleteRole(requestParameters: DeleteRoleRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JsonValueBoolean>;
@@ -168,12 +168,12 @@ export declare class AdminApi extends runtime.BaseAPI {
168
168
  */
169
169
  deleteUserRequestOpts(requestParameters: DeleteUserRequest): Promise<runtime.RequestOpts>;
170
170
  /**
171
- * Delete User. All tokens of the user are revoked.
171
+ * Delete User. All tokens of the user are revoked. 404 for a user that does not exist (2.0.0).
172
172
  * Delete User
173
173
  */
174
174
  deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<JsonValueBoolean>>;
175
175
  /**
176
- * Delete User. All tokens of the user are revoked.
176
+ * Delete User. All tokens of the user are revoked. 404 for a user that does not exist (2.0.0).
177
177
  * Delete User
178
178
  */
179
179
  deleteUser(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JsonValueBoolean>;
@@ -210,12 +210,12 @@ export declare class AdminApi extends runtime.BaseAPI {
210
210
  */
211
211
  gnerateNewApiKeyForUserRequestOpts(requestParameters: GnerateNewApiKeyForUserRequest): Promise<runtime.RequestOpts>;
212
212
  /**
213
- * Generate an new APIkey for the user
213
+ * Generate a new API key for the user
214
214
  * Update ApiKey
215
215
  */
216
216
  gnerateNewApiKeyForUserRaw(requestParameters: GnerateNewApiKeyForUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<JsonValueString>>;
217
217
  /**
218
- * Generate an new APIkey for the user
218
+ * Generate a new API key for the user
219
219
  * Update ApiKey
220
220
  */
221
221
  gnerateNewApiKeyForUser(requestParameters: GnerateNewApiKeyForUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JsonValueString>;
@@ -161,7 +161,7 @@ export class AdminApi extends runtime.BaseAPI {
161
161
  };
162
162
  }
163
163
  /**
164
- * Delete Role
164
+ * Delete Role. 404 for a role that does not exist (2.0.0).
165
165
  * Delete Role
166
166
  */
167
167
  async deleteRoleRaw(requestParameters, initOverrides) {
@@ -170,7 +170,7 @@ export class AdminApi extends runtime.BaseAPI {
170
170
  return new runtime.JSONApiResponse(response, (jsonValue) => JsonValueBooleanFromJSON(jsonValue));
171
171
  }
172
172
  /**
173
- * Delete Role
173
+ * Delete Role. 404 for a role that does not exist (2.0.0).
174
174
  * Delete Role
175
175
  */
176
176
  async deleteRole(requestParameters, initOverrides) {
@@ -212,7 +212,7 @@ export class AdminApi extends runtime.BaseAPI {
212
212
  };
213
213
  }
214
214
  /**
215
- * Delete User. All tokens of the user are revoked.
215
+ * Delete User. All tokens of the user are revoked. 404 for a user that does not exist (2.0.0).
216
216
  * Delete User
217
217
  */
218
218
  async deleteUserRaw(requestParameters, initOverrides) {
@@ -221,7 +221,7 @@ export class AdminApi extends runtime.BaseAPI {
221
221
  return new runtime.JSONApiResponse(response, (jsonValue) => JsonValueBooleanFromJSON(jsonValue));
222
222
  }
223
223
  /**
224
- * Delete User. All tokens of the user are revoked.
224
+ * Delete User. All tokens of the user are revoked. 404 for a user that does not exist (2.0.0).
225
225
  * Delete User
226
226
  */
227
227
  async deleteUser(requestParameters, initOverrides) {
@@ -365,7 +365,7 @@ export class AdminApi extends runtime.BaseAPI {
365
365
  };
366
366
  }
367
367
  /**
368
- * Generate an new APIkey for the user
368
+ * Generate a new API key for the user
369
369
  * Update ApiKey
370
370
  */
371
371
  async gnerateNewApiKeyForUserRaw(requestParameters, initOverrides) {
@@ -374,7 +374,7 @@ export class AdminApi extends runtime.BaseAPI {
374
374
  return new runtime.JSONApiResponse(response, (jsonValue) => JsonValueStringFromJSON(jsonValue));
375
375
  }
376
376
  /**
377
- * Generate an new APIkey for the user
377
+ * Generate a new API key for the user
378
378
  * Update ApiKey
379
379
  */
380
380
  async gnerateNewApiKeyForUser(requestParameters, initOverrides) {
@@ -2,7 +2,7 @@
2
2
  * mongocamp-library
3
3
  * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
4
  *
5
- * The version of the OpenAPI document: 1.9.1
5
+ * The version of the OpenAPI document: 2.0.0
6
6
  *
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -22,7 +22,7 @@ export interface GetConfigRequest {
22
22
  }
23
23
  export interface ShutdownRequest {
24
24
  /**
25
- * Shutdown Server and don`t send reboot event.
25
+ * Shutdown Server and don't send reboot event.
26
26
  */
27
27
  force?: boolean;
28
28
  }
@@ -45,12 +45,12 @@ export declare class ApplicationApi extends runtime.BaseAPI {
45
45
  */
46
46
  getConfigRequestOpts(requestParameters: GetConfigRequest): Promise<runtime.RequestOpts>;
47
47
  /**
48
- * Get Configuration for key
48
+ * Get Configuration for key. 404 for a configuration key that does not exist (2.0.0).
49
49
  * Configuration for configurationKey
50
50
  */
51
51
  getConfigRaw(requestParameters: GetConfigRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MongoCampConfiguration>>;
52
52
  /**
53
- * Get Configuration for key
53
+ * Get Configuration for key. 404 for a configuration key that does not exist (2.0.0).
54
54
  * Configuration for configurationKey
55
55
  */
56
56
  getConfig(requestParameters: GetConfigRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MongoCampConfiguration>;
@@ -101,12 +101,12 @@ export declare class ApplicationApi extends runtime.BaseAPI {
101
101
  */
102
102
  updateConfigurationRequestOpts(requestParameters: UpdateConfigurationRequest): Promise<runtime.RequestOpts>;
103
103
  /**
104
- * Update Configuration with the value
104
+ * Update Configuration with the value. 404 for an unknown key, 400 for a key that is read at the start only or set by the environment (2.0.0).
105
105
  * Update Configuration
106
106
  */
107
107
  updateConfigurationRaw(requestParameters: UpdateConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<JsonValueBoolean>>;
108
108
  /**
109
- * Update Configuration with the value
109
+ * Update Configuration with the value. 404 for an unknown key, 400 for a key that is read at the start only or set by the environment (2.0.0).
110
110
  * Update Configuration
111
111
  */
112
112
  updateConfiguration(requestParameters: UpdateConfigurationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JsonValueBoolean>;
@@ -47,7 +47,7 @@ export class ApplicationApi extends runtime.BaseAPI {
47
47
  };
48
48
  }
49
49
  /**
50
- * Get Configuration for key
50
+ * Get Configuration for key. 404 for a configuration key that does not exist (2.0.0).
51
51
  * Configuration for configurationKey
52
52
  */
53
53
  async getConfigRaw(requestParameters, initOverrides) {
@@ -56,7 +56,7 @@ export class ApplicationApi extends runtime.BaseAPI {
56
56
  return new runtime.JSONApiResponse(response, (jsonValue) => MongoCampConfigurationFromJSON(jsonValue));
57
57
  }
58
58
  /**
59
- * Get Configuration for key
59
+ * Get Configuration for key. 404 for a configuration key that does not exist (2.0.0).
60
60
  * Configuration for configurationKey
61
61
  */
62
62
  async getConfig(requestParameters, initOverrides) {
@@ -241,7 +241,7 @@ export class ApplicationApi extends runtime.BaseAPI {
241
241
  };
242
242
  }
243
243
  /**
244
- * Update Configuration with the value
244
+ * Update Configuration with the value. 404 for an unknown key, 400 for a key that is read at the start only or set by the environment (2.0.0).
245
245
  * Update Configuration
246
246
  */
247
247
  async updateConfigurationRaw(requestParameters, initOverrides) {
@@ -250,7 +250,7 @@ export class ApplicationApi extends runtime.BaseAPI {
250
250
  return new runtime.JSONApiResponse(response, (jsonValue) => JsonValueBooleanFromJSON(jsonValue));
251
251
  }
252
252
  /**
253
- * Update Configuration with the value
253
+ * Update Configuration with the value. 404 for an unknown key, 400 for a key that is read at the start only or set by the environment (2.0.0).
254
254
  * Update Configuration
255
255
  */
256
256
  async updateConfiguration(requestParameters, initOverrides) {
@@ -2,7 +2,7 @@
2
2
  * mongocamp-library
3
3
  * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4
4
  *
5
- * The version of the OpenAPI document: 1.9.1
5
+ * The version of the OpenAPI document: 2.0.0
6
6
  *
7
7
  *
8
8
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -58,12 +58,12 @@ export declare class AuthApi extends runtime.BaseAPI {
58
58
  */
59
59
  isAuthenticatedRequestOpts(): Promise<runtime.RequestOpts>;
60
60
  /**
61
- * Check a given Login for is authenticated
61
+ * Check whether the request is authenticated
62
62
  * Check Authentication
63
63
  */
64
64
  isAuthenticatedRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<JsonValueBoolean>>;
65
65
  /**
66
- * Check a given Login for is authenticated
66
+ * Check whether the request is authenticated
67
67
  * Check Authentication
68
68
  */
69
69
  isAuthenticated(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JsonValueBoolean>;
@@ -142,12 +142,12 @@ export declare class AuthApi extends runtime.BaseAPI {
142
142
  */
143
143
  userPermissionsRequestOpts(requestParameters: UserPermissionsRequest): Promise<runtime.RequestOpts>;
144
144
  /**
145
- * Return the resolved rights (read, write, administrate) of the loggedin user for the collections of the default database
145
+ * Return the resolved rights (read, write, administrate) of the logged in user for the collections of the default database
146
146
  * Collection permissions
147
147
  */
148
148
  userPermissionsRaw(requestParameters: UserPermissionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<CollectionPermission>>>;
149
149
  /**
150
- * Return the resolved rights (read, write, administrate) of the loggedin user for the collections of the default database
150
+ * Return the resolved rights (read, write, administrate) of the logged in user for the collections of the default database
151
151
  * Collection permissions
152
152
  */
153
153
  userPermissions(requestParameters?: UserPermissionsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<CollectionPermission>>;
@@ -156,12 +156,12 @@ export declare class AuthApi extends runtime.BaseAPI {
156
156
  */
157
157
  userProfileRequestOpts(): Promise<runtime.RequestOpts>;
158
158
  /**
159
- * Return the User Profile of loggedin user
159
+ * Return the User Profile of the logged in user
160
160
  * User Profile
161
161
  */
162
162
  userProfileRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserProfile>>;
163
163
  /**
164
- * Return the User Profile of loggedin user
164
+ * Return the User Profile of the logged in user
165
165
  * User Profile
166
166
  */
167
167
  userProfile(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserProfile>;
@@ -93,7 +93,7 @@ export class AuthApi extends runtime.BaseAPI {
93
93
  };
94
94
  }
95
95
  /**
96
- * Check a given Login for is authenticated
96
+ * Check whether the request is authenticated
97
97
  * Check Authentication
98
98
  */
99
99
  async isAuthenticatedRaw(initOverrides) {
@@ -102,7 +102,7 @@ export class AuthApi extends runtime.BaseAPI {
102
102
  return new runtime.JSONApiResponse(response, (jsonValue) => JsonValueBooleanFromJSON(jsonValue));
103
103
  }
104
104
  /**
105
- * Check a given Login for is authenticated
105
+ * Check whether the request is authenticated
106
106
  * Check Authentication
107
107
  */
108
108
  async isAuthenticated(initOverrides) {
@@ -363,7 +363,7 @@ export class AuthApi extends runtime.BaseAPI {
363
363
  };
364
364
  }
365
365
  /**
366
- * Return the resolved rights (read, write, administrate) of the loggedin user for the collections of the default database
366
+ * Return the resolved rights (read, write, administrate) of the logged in user for the collections of the default database
367
367
  * Collection permissions
368
368
  */
369
369
  async userPermissionsRaw(requestParameters, initOverrides) {
@@ -372,7 +372,7 @@ export class AuthApi extends runtime.BaseAPI {
372
372
  return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(CollectionPermissionFromJSON));
373
373
  }
374
374
  /**
375
- * Return the resolved rights (read, write, administrate) of the loggedin user for the collections of the default database
375
+ * Return the resolved rights (read, write, administrate) of the logged in user for the collections of the default database
376
376
  * Collection permissions
377
377
  */
378
378
  async userPermissions(requestParameters = {}, initOverrides) {
@@ -407,7 +407,7 @@ export class AuthApi extends runtime.BaseAPI {
407
407
  };
408
408
  }
409
409
  /**
410
- * Return the User Profile of loggedin user
410
+ * Return the User Profile of the logged in user
411
411
  * User Profile
412
412
  */
413
413
  async userProfileRaw(initOverrides) {
@@ -416,7 +416,7 @@ export class AuthApi extends runtime.BaseAPI {
416
416
  return new runtime.JSONApiResponse(response, (jsonValue) => UserProfileFromJSON(jsonValue));
417
417
  }
418
418
  /**
419
- * Return the User Profile of loggedin user
419
+ * Return the User Profile of the logged in user
420
420
  * User Profile
421
421
  */
422
422
  async userProfile(initOverrides) {