nuxt-directus-sdk 6.0.0-beta.0 → 6.0.0-beta.2

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 (31) hide show
  1. package/README.md +59 -31
  2. package/dist/cli/index.mjs +139 -19
  3. package/dist/module.d.mts +57 -2
  4. package/dist/module.d.ts +57 -2
  5. package/dist/module.json +1 -1
  6. package/dist/module.mjs +77 -66
  7. package/dist/rules/index.d.mts +6 -8
  8. package/dist/rules/index.d.ts +6 -8
  9. package/dist/rules/index.mjs +2 -2
  10. package/dist/runtime/composables/auth.d.ts +18 -6
  11. package/dist/runtime/composables/auth.js +4 -2
  12. package/dist/runtime/composables/files.d.ts +4 -4
  13. package/dist/runtime/composables/files.js +1 -1
  14. package/dist/runtime/middleware/auth.d.ts +1 -1
  15. package/dist/runtime/middleware/guest.d.ts +1 -1
  16. package/dist/runtime/plugin.d.ts +1 -1
  17. package/dist/runtime/plugins/visual-editor.client.d.ts +2 -2
  18. package/dist/runtime/server/services/directus.d.ts +1 -1
  19. package/dist/runtime/server/services/directus.js +1 -1
  20. package/dist/runtime/types/fallback.d.ts +7 -4
  21. package/dist/runtime/types/generate.d.ts +47 -2
  22. package/dist/runtime/types/generate.js +119 -15
  23. package/dist/runtime/utils/index.d.ts +1 -1
  24. package/dist/shared/{nuxt-directus-sdk.1qEbZAZ_.mjs → nuxt-directus-sdk.BzXguU5u.mjs} +2 -2
  25. package/package.json +20 -4
  26. package/dist/runtime/components/directus-add-button.d.vue.ts +0 -22
  27. package/dist/runtime/components/directus-add-button.vue +0 -64
  28. package/dist/runtime/components/directus-add-button.vue.d.ts +0 -22
  29. package/dist/runtime/components/directus-edit-button.d.vue.ts +0 -25
  30. package/dist/runtime/components/directus-edit-button.vue +0 -64
  31. package/dist/runtime/components/directus-edit-button.vue.d.ts +0 -25
package/README.md CHANGED
@@ -2,22 +2,30 @@
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![CI][ci-src]][ci-href]
6
+ [![Install size][install-size-src]][install-size-href]
5
7
  [![License][license-src]][license-href]
6
8
  [![Nuxt][nuxt-src]][nuxt-href]
7
9
 
8
- > A Nuxt 4 Directus module that uses the Directus SDK to enhance your Nuxt application
10
+ > A Nuxt module for Directus with built-in authentication, realtime, file management, type generation, and visual editor support.
9
11
 
10
- - [✨  Release Notes](/CHANGELOG.md)
12
+ - [✨  Release Notes](https://github.com/rolleyio/nuxt-directus-sdk/releases)
11
13
  - [📚  Documentation](https://nuxt-directus-sdk.rolley.io)
12
14
 
13
15
  ## Features
14
16
 
15
17
  - 🔒  **Session-based authentication** with cross-domain support
16
- -  Authentication out of the box
17
- - 🚠  Type generation based on Directus collections
18
- - 🔥  Typesafe Client Websockets enabled
19
- - 🌉  Automatically configures Nuxt Image for directus
20
- - 🗂️  Directus Admin panel added to Devtools
18
+ -  **Realtime** via typed WebSocket subscriptions
19
+ - 📁  **File management** with `@nuxt/image` integration
20
+ - ✏️  **Visual editor** support for `@directus/visual-editing`
21
+ - 🧩  **Auto-generated types** from your Directus schema, plus a standalone CLI
22
+ - 📐  **Rules DSL** for defining and syncing permissions in code
23
+ - 🗂️  Directus admin panel embedded in Nuxt Devtools
24
+
25
+ ## Requirements
26
+
27
+ - **Nuxt 4.0+**
28
+ - **Directus v11.16.0+** (required by the bundled `@directus/visual-editing` v2 and `@directus/sdk` v21)
21
29
 
22
30
  ## Quick Setup
23
31
 
@@ -39,19 +47,12 @@ bun install --save-dev nuxt-directus-sdk
39
47
 
40
48
  2. Add `nuxt-directus-sdk` to the `modules` section of `nuxt.config.ts`
41
49
 
42
- ```js
50
+ ```ts
43
51
  export default defineNuxtConfig({
44
- modules: [
45
- 'nuxt-directus-sdk'
46
- ],
52
+ modules: ['nuxt-directus-sdk'],
47
53
  directus: {
48
- // Optional: customize authentication (defaults shown)
49
- auth: {
50
- autoRefresh: true,
51
- credentials: 'include', // Required for cross-domain
52
- realtimeAuthMode: 'public',
53
- }
54
- }
54
+ url: process.env.DIRECTUS_URL,
55
+ },
55
56
  })
56
57
  ```
57
58
 
@@ -59,47 +60,68 @@ export default defineNuxtConfig({
59
60
 
60
61
  ```dotenv
61
62
  DIRECTUS_URL=https://your-directus-url.com
62
- DIRECTUS_ADMIN_TOKEN=your_admin_token # Optional: for type generation
63
+ DIRECTUS_ADMIN_TOKEN=your_admin_token # Optional: required for type generation
63
64
  ```
64
65
 
65
- 4. **Configure your Directus backend** for cross-domain authentication (see [Authentication Guide](https://nuxt-directus-sdk.rolley.io/guide/authentication.html))
66
+ 4. **Configure your Directus backend** for cross-domain authentication (see the [Authentication Guide](https://nuxt-directus-sdk.rolley.io/guide/authentication.html))
66
67
 
67
68
  That's it! You can now use Directus within your Nuxt app ✨
68
69
 
69
- For cross-domain setups (e.g., `app.example.com` `api.example.com`), see the [Authentication Guide](https://nuxt-directus-sdk.rolley.io/guide/authentication.html).
70
+ For cross-domain setups (e.g. `app.example.com` and `api.example.com`), see the [Authentication Guide](https://nuxt-directus-sdk.rolley.io/guide/authentication.html).
71
+
72
+ ## CLI
73
+
74
+ The module ships with a CLI for type generation and permissions/rules sync that doesn't require a running Nuxt instance. Useful in CI, pre-commit hooks, or quick regeneration during development.
75
+
76
+ ```bash
77
+ # Generate TypeScript types from a Directus schema
78
+ npx nuxt-directus-sdk generate-types --prefix App -o types/directus.d.ts
79
+
80
+ # Pull permissions/rules to a JSON file
81
+ npx nuxt-directus-sdk rules:pull -o rules.json
82
+
83
+ # See all commands
84
+ npx nuxt-directus-sdk --help
85
+ ```
86
+
87
+ See the [CLI documentation](https://nuxt-directus-sdk.rolley.io/api/configuration/module#types) for flags and examples.
70
88
 
71
89
  ## Development
72
90
 
73
- > [!IMPORTANT] The playground uses [directus-template-cli](https://github.com/directus-labs/directus-template-cli?tab=readme-ov-file#applying-a-template) `cms` template.
91
+ > [!IMPORTANT] The playground uses the [directus-template-cli](https://github.com/directus-labs/directus-template-cli?tab=readme-ov-file#applying-a-template) `cms` template.
74
92
  > Apply the template with `npx directus-template-cli@latest apply` and follow the interactive prompts.
75
93
 
76
94
  ```bash
77
95
  # Install dependencies
78
- bun install
96
+ pnpm install
79
97
 
80
98
  # Add DIRECTUS_ADMIN_TOKEN to playground .env (don't forget to update your token)
81
99
  cp ./playground/.env.example ./playground/.env
82
100
 
83
101
  # Generate type stubs
84
- bun run dev:prepare
102
+ pnpm run dev:prepare
85
103
 
86
104
  # Develop with the playground
87
- bun run dev
105
+ pnpm run dev
88
106
 
89
107
  # Build the playground
90
- bun run dev:build
108
+ pnpm run dev:build
91
109
 
92
110
  # Run ESLint
93
- bun run lint
111
+ pnpm run lint
94
112
 
95
113
  # Run Vitest
96
- bun run test
97
- bun run test:watch
114
+ pnpm run test
115
+ pnpm run test:watch
98
116
 
99
- # Release new version
100
- bun run release
117
+ # Release new version (see RELEASING.md)
118
+ pnpm run release
101
119
  ```
102
120
 
121
+ ## Contributing
122
+
123
+ Contributions are welcome. Please target the `next` branch for new features and fixes; `main` is reserved for stable releases and hotfixes. See [RELEASING.md](./RELEASING.md) for the release process.
124
+
103
125
  <!-- Badges -->
104
126
  [npm-version-src]: https://img.shields.io/npm/v/nuxt-directus-sdk/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
105
127
  [npm-version-href]: https://npmjs.com/package/nuxt-directus-sdk
@@ -107,6 +129,12 @@ bun run release
107
129
  [npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-directus-sdk.svg?style=flat&colorA=18181B&colorB=28CF8D
108
130
  [npm-downloads-href]: https://npmjs.com/package/nuxt-directus-sdk
109
131
 
132
+ [ci-src]: https://github.com/rolleyio/nuxt-directus-sdk/actions/workflows/ci.yml/badge.svg?branch=main
133
+ [ci-href]: https://github.com/rolleyio/nuxt-directus-sdk/actions/workflows/ci.yml
134
+
135
+ [install-size-src]: https://packagephobia.com/badge?p=nuxt-directus-sdk
136
+ [install-size-href]: https://packagephobia.com/result?p=nuxt-directus-sdk
137
+
110
138
  [license-src]: https://img.shields.io/npm/l/nuxt-directus-sdk.svg?style=flat&colorA=18181B&colorB=28CF8D
111
139
  [license-href]: https://npmjs.com/package/nuxt-directus-sdk
112
140
 
@@ -1,9 +1,23 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
- import { resolve } from 'node:path';
2
+ import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
3
+ import { resolve, dirname } from 'node:path';
4
4
  import { parseArgs } from 'node:util';
5
5
  import { createDirectus, staticToken, rest } from '@directus/sdk';
6
- import { d as diffRemoteRules, e as formatDiff, c as compareRulesPayloads, f as fetchRemoteRules, k as loadRulesFromPayload, o as pushRules, g as formatPushResult, b as fetchRemoteRulesAsJson } from '../shared/nuxt-directus-sdk.1qEbZAZ_.mjs';
6
+ import { d as diffRemoteRules, e as formatDiff, c as compareRulesPayloads, f as fetchRemoteRules, k as loadRulesFromPayload, o as pushRules, g as formatPushResult, b as fetchRemoteRulesAsJson } from '../shared/nuxt-directus-sdk.BzXguU5u.mjs';
7
+ import { generateTypesFromDirectus } from '../../dist/runtime/types/generate.js';
8
+
9
+ function parseCsv(raw) {
10
+ if (!raw)
11
+ return [];
12
+ return raw.split(",").map((s) => s.trim()).filter(Boolean);
13
+ }
14
+ function resolveNegatableBoolean(positive, negative, fallback) {
15
+ if (negative)
16
+ return false;
17
+ if (positive !== void 0)
18
+ return positive;
19
+ return fallback;
20
+ }
7
21
 
8
22
  function loadEnv() {
9
23
  const envPath = resolve(process.cwd(), ".env");
@@ -28,12 +42,14 @@ function getConnectionConfig(urlFlag, tokenFlag, label) {
28
42
  const token = tokenFlag ?? process.env.DIRECTUS_ADMIN_TOKEN;
29
43
  if (!url) {
30
44
  console.error(`Error: ${label} URL is required`);
31
- console.error(`Provide --${label.toLowerCase()}-url or set DIRECTUS_URL in your .env file`);
45
+ const flagHint = label === "Source" ? "--url (or --source-url)" : `--${label.toLowerCase()}-url`;
46
+ console.error(`Provide ${flagHint} or set DIRECTUS_URL in your .env file`);
32
47
  process.exit(1);
33
48
  }
34
49
  if (!token) {
35
50
  console.error(`Error: ${label} token is required`);
36
- console.error(`Provide --${label.toLowerCase()}-token or set DIRECTUS_ADMIN_TOKEN in your .env file`);
51
+ const flagHint = label === "Source" ? "--token (or --source-token)" : `--${label.toLowerCase()}-token`;
52
+ console.error(`Provide ${flagHint} or set DIRECTUS_ADMIN_TOKEN in your .env file`);
37
53
  process.exit(1);
38
54
  }
39
55
  return { url, token };
@@ -43,7 +59,7 @@ function createClient(url, token) {
43
59
  }
44
60
  function printHelp() {
45
61
  console.log(`
46
- Directus Rules CLI
62
+ nuxt-directus-sdk CLI
47
63
 
48
64
  Usage:
49
65
  npx nuxt-directus-sdk <command> [options]
@@ -54,24 +70,40 @@ Commands:
54
70
  rules:diff <file> Compare local JSON file with remote Directus
55
71
  rules:diff-files <a> <b> Compare two local JSON files
56
72
  rules:diff-remote Compare two remote Directus instances
73
+ generate-types Generate TypeScript types from a Directus schema
57
74
 
58
75
  Options:
59
76
  -h, --help Show this help message
60
- -o, --output <file> Output file path (default: rules.json)
77
+ -o, --output <file> Output file path (default: stdout for generate-types, rules.json for rules:pull)
61
78
  --compact Output compact JSON (no pretty-print)
62
79
  --dry-run Show what would be changed without making changes (rules:push)
63
80
  --add-only Only add new items, don't modify or delete existing (rules:push)
64
81
  --skip-deletes Skip deleting items that exist remotely but not locally (rules:push)
82
+ --prefix <prefix> Prefix for custom collection type names (generate-types)
83
+ --include <names> Comma-separated collection names to include (generate-types).
84
+ When set, only these collections (plus any they reference
85
+ via --expand-references, default on) are emitted.
86
+ Takes precedence over --exclude if both are set.
87
+ --no-expand-references When --include is set, do NOT follow references to other
88
+ collections. Strict include mode \u2014 references to collections
89
+ not in the list collapse to \`string\`. (generate-types)
90
+ --exclude <names> Comma-separated collection names to exclude (generate-types).
91
+ References to excluded types are rewritten to \`string\`.
92
+ --verbose Show per-target warnings listing every field whose reference
93
+ was collapsed to \`string\` (generate-types).
94
+ --no-declare-global Emit types without the \`declare global\` wrapper (generate-types)
65
95
 
66
96
  Connection options (override DIRECTUS_URL / DIRECTUS_ADMIN_TOKEN):
97
+ --url <url> Directus URL (alias of --source-url)
98
+ --token <token> Admin token (alias of --source-token)
67
99
  --source-url <url> Source Directus URL
68
100
  --source-token <token> Source admin token
69
101
  --target-url <url> Target Directus URL (for rules:diff-remote)
70
102
  --target-token <token> Target admin token (for rules:diff-remote)
71
103
 
72
104
  Environment Variables:
73
- DIRECTUS_URL Default Directus URL (used if --source-url not provided)
74
- DIRECTUS_ADMIN_TOKEN Default admin token (used if --source-token not provided)
105
+ DIRECTUS_URL Default Directus URL (used if --url / --source-url not provided)
106
+ DIRECTUS_ADMIN_TOKEN Default admin token (used if --token / --source-token not provided)
75
107
 
76
108
  Examples:
77
109
  # Pull rules from Directus (uses env vars)
@@ -99,6 +131,27 @@ Examples:
99
131
  npx nuxt-directus-sdk rules:diff-remote \\
100
132
  --source-url https://staging.example.com --source-token staging-token \\
101
133
  --target-url https://production.example.com --target-token production-token
134
+
135
+ # Generate TypeScript types, pipe to a file
136
+ npx nuxt-directus-sdk generate-types > types/directus.d.ts
137
+
138
+ # Generate types with a prefix, write directly to a file
139
+ npx nuxt-directus-sdk generate-types --prefix App -o types/directus.d.ts
140
+
141
+ # Generate types from a specific instance
142
+ npx nuxt-directus-sdk generate-types --url https://my-directus.com --token my-token
143
+
144
+ # Exclude specific collections \u2014 references to them become \`string\`
145
+ npx nuxt-directus-sdk generate-types --exclude directus_activity,directus_revisions
146
+
147
+ # Include only specific collections (referenced collections auto-included)
148
+ npx nuxt-directus-sdk generate-types --include posts
149
+
150
+ # Strict include \u2014 only the listed collections, references collapse to \`string\`
151
+ npx nuxt-directus-sdk generate-types --include posts --no-expand-references
152
+
153
+ # Verbose \u2014 show every field whose reference was collapsed, grouped by target
154
+ npx nuxt-directus-sdk generate-types --exclude directus_users --verbose
102
155
  `);
103
156
  }
104
157
  function loadJsonFile(filePath) {
@@ -191,17 +244,67 @@ async function commandPush(localFile, connection, options) {
191
244
  process.exit(1);
192
245
  }
193
246
  }
247
+ async function commandGenerateTypes(connection, options) {
248
+ console.error(`Generating types from ${connection.url}...`);
249
+ if (options.include.length > 0) {
250
+ console.error(`Including collections: ${options.include.join(", ")}`);
251
+ }
252
+ if (options.exclude.length > 0) {
253
+ console.error(`Excluding collections: ${options.exclude.join(", ")}`);
254
+ }
255
+ const { typeString, logs } = await generateTypesFromDirectus(
256
+ connection.url,
257
+ connection.token,
258
+ options.prefix,
259
+ {
260
+ include: options.include,
261
+ exclude: options.exclude,
262
+ expandReferences: options.expandReferences,
263
+ verbose: options.verbose
264
+ }
265
+ );
266
+ for (const line of logs) {
267
+ console.error(line);
268
+ }
269
+ if (!typeString) {
270
+ console.error("Error: Type generation returned empty output.");
271
+ process.exit(1);
272
+ }
273
+ const output = options.declareGlobal ? typeString : typeString.replace(/^declare global \{\n\n/, "").replace(/\n\}\n\nexport \{\};?\n?$/, "\n");
274
+ if (options.output) {
275
+ const outputPath = resolve(process.cwd(), options.output);
276
+ mkdirSync(dirname(outputPath), { recursive: true });
277
+ writeFileSync(outputPath, output, "utf-8");
278
+ console.error(`Types written to ${outputPath}`);
279
+ } else {
280
+ process.stdout.write(output);
281
+ }
282
+ }
194
283
  async function main() {
195
284
  loadEnv();
196
285
  const { values, positionals } = parseArgs({
197
286
  allowPositionals: true,
198
287
  options: {
199
288
  "help": { type: "boolean", short: "h" },
200
- "output": { type: "string", short: "o", default: "rules.json" },
289
+ // `output` has no default here each command applies its own fallback
290
+ // (rules:pull defaults to rules.json, generate-types defaults to stdout).
291
+ "output": { type: "string", short: "o" },
201
292
  "compact": { type: "boolean", default: false },
202
293
  "dry-run": { type: "boolean", default: false },
203
294
  "add-only": { type: "boolean", default: false },
204
295
  "skip-deletes": { type: "boolean", default: false },
296
+ "prefix": { type: "string", default: "" },
297
+ "include": { type: "string" },
298
+ "exclude": { type: "string" },
299
+ // Node's parseArgs doesn't support `--no-X` syntax natively, so we
300
+ // register both forms. Negation wins if both are passed.
301
+ "expand-references": { type: "boolean", default: true },
302
+ "no-expand-references": { type: "boolean" },
303
+ "verbose": { type: "boolean", default: false },
304
+ "declare-global": { type: "boolean", default: true },
305
+ "no-declare-global": { type: "boolean" },
306
+ "url": { type: "string" },
307
+ "token": { type: "string" },
205
308
  "source-url": { type: "string" },
206
309
  "source-token": { type: "string" },
207
310
  "target-url": { type: "string" },
@@ -217,12 +320,12 @@ async function main() {
217
320
  switch (command) {
218
321
  case "rules:pull": {
219
322
  const connection = getConnectionConfig(
220
- values["source-url"],
221
- values["source-token"],
323
+ values["source-url"] ?? values.url,
324
+ values["source-token"] ?? values.token,
222
325
  "Source"
223
326
  );
224
327
  await commandPull({
225
- output: values.output,
328
+ output: values.output ?? "rules.json",
226
329
  compact: values.compact
227
330
  }, connection);
228
331
  break;
@@ -234,8 +337,8 @@ async function main() {
234
337
  process.exit(1);
235
338
  }
236
339
  const connection = getConnectionConfig(
237
- values["source-url"],
238
- values["source-token"],
340
+ values["source-url"] ?? values.url,
341
+ values["source-token"] ?? values.token,
239
342
  "Source"
240
343
  );
241
344
  await commandPush(positionals[1], connection, {
@@ -252,8 +355,8 @@ async function main() {
252
355
  process.exit(1);
253
356
  }
254
357
  const connection = getConnectionConfig(
255
- values["source-url"],
256
- values["source-token"],
358
+ values["source-url"] ?? values.url,
359
+ values["source-token"] ?? values.token,
257
360
  "Source"
258
361
  );
259
362
  await commandDiff(positionals[1], connection);
@@ -269,8 +372,8 @@ async function main() {
269
372
  break;
270
373
  case "rules:diff-remote": {
271
374
  const source = getConnectionConfig(
272
- values["source-url"],
273
- values["source-token"],
375
+ values["source-url"] ?? values.url,
376
+ values["source-token"] ?? values.token,
274
377
  "Source"
275
378
  );
276
379
  const target = getConnectionConfig(
@@ -281,6 +384,23 @@ async function main() {
281
384
  await commandDiffRemote(source, target);
282
385
  break;
283
386
  }
387
+ case "generate-types": {
388
+ const connection = getConnectionConfig(
389
+ values.url ?? values["source-url"],
390
+ values.token ?? values["source-token"],
391
+ "Source"
392
+ );
393
+ await commandGenerateTypes(connection, {
394
+ prefix: values.prefix ?? "",
395
+ output: values.output,
396
+ declareGlobal: resolveNegatableBoolean(values["declare-global"], values["no-declare-global"], true),
397
+ include: parseCsv(values.include),
398
+ exclude: parseCsv(values.exclude),
399
+ expandReferences: resolveNegatableBoolean(values["expand-references"], values["no-expand-references"], true),
400
+ verbose: values.verbose
401
+ });
402
+ break;
403
+ }
284
404
  default:
285
405
  console.error(`Unknown command: ${command}`);
286
406
  printHelp();
package/dist/module.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { Query } from '@directus/sdk';
2
+ import { Query, DirectusUser } from '@directus/sdk';
3
3
  import { ImageProviders, ImageModifiers } from '@nuxt/image';
4
4
 
5
5
  type DirectusUrl = string | {
6
6
  client: string;
7
7
  server: string;
8
8
  };
9
- type ReadMeFields = Query<DirectusSchema, DirectusSchema['directus_users']>['fields'];
9
+ type ReadMeFields = Query<DirectusSchema, DirectusUser<DirectusSchema>>['fields'];
10
10
  interface ModuleOptions {
11
11
  /**
12
12
  * Directus API URL
@@ -153,6 +153,61 @@ interface ModuleOptions {
153
153
  * @default ''
154
154
  */
155
155
  prefix?: string;
156
+ /**
157
+ * Collection names to include in the generated types. When non-empty,
158
+ * only these collections (plus any they reference — see
159
+ * `expandReferences`) are emitted. References to collections not in
160
+ * the resolved set collapse to `string` (M2O) or `string[]` (O2M).
161
+ *
162
+ * Takes precedence over `exclude` if both are set.
163
+ * @type string[]
164
+ * @default []
165
+ */
166
+ include?: string[];
167
+ /**
168
+ * When `include` is set, also pull in any collections referenced by
169
+ * the included collections (transitively). Follows M2O, O2M, and M2A.
170
+ * No-op when `include` is empty.
171
+ * @type boolean
172
+ * @default true
173
+ */
174
+ expandReferences?: boolean;
175
+ /**
176
+ * Collection names to exclude from generated types.
177
+ * References to excluded collections are rewritten to `string` (M2O) or
178
+ * `string[]` (O2M) so the generated types stay resolvable.
179
+ * @type string[]
180
+ * @default []
181
+ */
182
+ exclude?: string[];
183
+ /**
184
+ * When true, emit per-target warnings listing every field whose
185
+ * reference was collapsed to `string`/`string[]`. Field lists are
186
+ * capped at 5 per collection.
187
+ * @type boolean
188
+ * @default false
189
+ */
190
+ verbose?: boolean;
191
+ };
192
+ /**
193
+ * Auto-import functions from `@directus/sdk`.
194
+ *
195
+ * - `true` (default) — auto-imports every SDK function except those wrapped by
196
+ * this module (e.g. `createDirectus`, `rest`, `authentication`) or explicitly
197
+ * unsupported (e.g. `graphql`, `readGraphqlSdl`).
198
+ * - `false` — disables auto-imports entirely. You import from `@directus/sdk`
199
+ * manually wherever you use SDK functions.
200
+ * - `{ exclude: [...] }` — auto-imports with additional functions excluded.
201
+ * Useful if an SDK function name collides with something else in your app.
202
+ *
203
+ * @default true
204
+ */
205
+ autoImportSdk?: boolean | {
206
+ /**
207
+ * Additional SDK function names to exclude from auto-import.
208
+ * Added on top of the module's built-in exclusions.
209
+ */
210
+ exclude?: string[];
156
211
  };
157
212
  }
158
213
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { Query } from '@directus/sdk';
2
+ import { Query, DirectusUser } from '@directus/sdk';
3
3
  import { ImageProviders, ImageModifiers } from '@nuxt/image';
4
4
 
5
5
  type DirectusUrl = string | {
6
6
  client: string;
7
7
  server: string;
8
8
  };
9
- type ReadMeFields = Query<DirectusSchema, DirectusSchema['directus_users']>['fields'];
9
+ type ReadMeFields = Query<DirectusSchema, DirectusUser<DirectusSchema>>['fields'];
10
10
  interface ModuleOptions {
11
11
  /**
12
12
  * Directus API URL
@@ -153,6 +153,61 @@ interface ModuleOptions {
153
153
  * @default ''
154
154
  */
155
155
  prefix?: string;
156
+ /**
157
+ * Collection names to include in the generated types. When non-empty,
158
+ * only these collections (plus any they reference — see
159
+ * `expandReferences`) are emitted. References to collections not in
160
+ * the resolved set collapse to `string` (M2O) or `string[]` (O2M).
161
+ *
162
+ * Takes precedence over `exclude` if both are set.
163
+ * @type string[]
164
+ * @default []
165
+ */
166
+ include?: string[];
167
+ /**
168
+ * When `include` is set, also pull in any collections referenced by
169
+ * the included collections (transitively). Follows M2O, O2M, and M2A.
170
+ * No-op when `include` is empty.
171
+ * @type boolean
172
+ * @default true
173
+ */
174
+ expandReferences?: boolean;
175
+ /**
176
+ * Collection names to exclude from generated types.
177
+ * References to excluded collections are rewritten to `string` (M2O) or
178
+ * `string[]` (O2M) so the generated types stay resolvable.
179
+ * @type string[]
180
+ * @default []
181
+ */
182
+ exclude?: string[];
183
+ /**
184
+ * When true, emit per-target warnings listing every field whose
185
+ * reference was collapsed to `string`/`string[]`. Field lists are
186
+ * capped at 5 per collection.
187
+ * @type boolean
188
+ * @default false
189
+ */
190
+ verbose?: boolean;
191
+ };
192
+ /**
193
+ * Auto-import functions from `@directus/sdk`.
194
+ *
195
+ * - `true` (default) — auto-imports every SDK function except those wrapped by
196
+ * this module (e.g. `createDirectus`, `rest`, `authentication`) or explicitly
197
+ * unsupported (e.g. `graphql`, `readGraphqlSdl`).
198
+ * - `false` — disables auto-imports entirely. You import from `@directus/sdk`
199
+ * manually wherever you use SDK functions.
200
+ * - `{ exclude: [...] }` — auto-imports with additional functions excluded.
201
+ * Useful if an SDK function name collides with something else in your app.
202
+ *
203
+ * @default true
204
+ */
205
+ autoImportSdk?: boolean | {
206
+ /**
207
+ * Additional SDK function names to exclude from auto-import.
208
+ * Added on top of the module's built-in exclusions.
209
+ */
210
+ exclude?: string[];
156
211
  };
157
212
  }
158
213
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-directus-sdk",
3
- "version": "6.0.0-beta.0",
3
+ "version": "6.0.0-beta.2",
4
4
  "configKey": "directus",
5
5
  "compatibility": {
6
6
  "nuxt": "^4.0.0"