nuxt-directus-sdk 5.0.0-beta.9 → 5.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.
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-directus-sdk",
3
- "version": "5.0.0-beta.9",
3
+ "version": "5.0.0",
4
4
  "configKey": "directus",
5
5
  "compatibility": {
6
6
  "nuxt": "^4.0.0"
package/dist/module.mjs CHANGED
@@ -6,11 +6,11 @@ import { generateTypes } from '../dist/runtime/types/index.js';
6
6
  import { useUrl } from '../dist/runtime/utils/index.js';
7
7
 
8
8
  const name = "nuxt-directus-sdk";
9
- const version = "5.0.0-beta.9";
9
+ const version = "5.0.0";
10
10
 
11
11
  const configKey = "directus";
12
12
  const logger = useLogger("nuxt-directus-sdk");
13
- const module = defineNuxtModule({
13
+ const module$1 = defineNuxtModule({
14
14
  meta: {
15
15
  name,
16
16
  version,
@@ -49,8 +49,7 @@ const module = defineNuxtModule({
49
49
  const clientUrl = typeof options.url === "string" ? options.url : options.url?.client;
50
50
  const serverUrl = typeof options.url === "string" ? options.url : options.url?.server;
51
51
  if (!clientUrl) {
52
- logger.error("nuxt-directus-sdk requires a url to your Directus instance, set it in the config options or .env file as DIRECTUS_URL");
53
- return;
52
+ logger.warn("No Directus URL found at build time. Set it in config options, .env file as DIRECTUS_URL, or at runtime via NUXT_PUBLIC_DIRECTUS_URL.");
54
53
  }
55
54
  const resolver = createResolver(import.meta.url);
56
55
  async function registerModule(name2, key, moduleOptions) {
@@ -299,4 +298,4 @@ const module = defineNuxtModule({
299
298
  }
300
299
  });
301
300
 
302
- export { module as default };
301
+ export { module$1 as default };
@@ -3,7 +3,7 @@ declare const __VLS_export: <T extends keyof DirectusSchema>(__VLS_props: NonNul
3
3
  props: __VLS_PrettifyLocal<{
4
4
  collection: T;
5
5
  item: PrimaryKey;
6
- fields?: keyof (DirectusSchema[T] extends any[] ? DirectusSchema[T][0] : DirectusSchema[T]) | (keyof (DirectusSchema[T] extends any[] ? DirectusSchema[T][0] : DirectusSchema[T]))[];
6
+ fields?: (string | number | symbol) | (string | number | symbol)[];
7
7
  mode?: "drawer" | "modal" | "popover";
8
8
  }> & import("vue").PublicProps & (typeof globalThis extends {
9
9
  __VLS_PROPS_FALLBACK: infer P;
@@ -3,7 +3,7 @@ declare const __VLS_export: <T extends keyof DirectusSchema>(__VLS_props: NonNul
3
3
  props: __VLS_PrettifyLocal<{
4
4
  collection: T;
5
5
  item: PrimaryKey;
6
- fields?: keyof (DirectusSchema[T] extends any[] ? DirectusSchema[T][0] : DirectusSchema[T]) | (keyof (DirectusSchema[T] extends any[] ? DirectusSchema[T][0] : DirectusSchema[T]))[];
6
+ fields?: (string | number | symbol) | (string | number | symbol)[];
7
7
  mode?: "drawer" | "modal" | "popover";
8
8
  }> & import("vue").PublicProps & (typeof globalThis extends {
9
9
  __VLS_PROPS_FALLBACK: infer P;
@@ -9,7 +9,8 @@ export function useDirectusUrl(path = "") {
9
9
  const config = useRuntimeConfig();
10
10
  const serverUrl = config.directus?.serverDirectusUrl;
11
11
  const fallback = config.public.directus.directusUrl || config.public.directus.url;
12
- return useUrl(serverUrl || fallback, path);
12
+ const url = serverUrl || fallback || process.env.DIRECTUS_URL;
13
+ return useUrl(url, path);
13
14
  }
14
15
  export function useTokenDirectus(token) {
15
16
  const directus = createDirectus(useDirectusUrl()).with(authentication("json", { autoRefresh: false })).with(rest());
@@ -22,7 +23,8 @@ export function useServerDirectus(event) {
22
23
  }
23
24
  export function useAdminDirectus() {
24
25
  const config = useRuntimeConfig().directus;
25
- if (!config.adminToken)
26
+ const adminToken = config.adminToken || process.env.DIRECTUS_ADMIN_TOKEN;
27
+ if (!adminToken)
26
28
  throw new Error("DIRECTUS_ADMIN_TOKEN is not set in config options or .env file");
27
- return useTokenDirectus(config.adminToken);
29
+ return useTokenDirectus(adminToken);
28
30
  }
@@ -0,0 +1,5 @@
1
+ export interface FallbackSchema {
2
+ directus_users?: Record<string, never>
3
+ }
4
+
5
+ declare global { interface DirectusSchema extends FallbackSchema { } }
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "nuxt-directus-sdk",
3
3
  "type": "module",
4
- "version": "5.0.0-beta.9",
4
+ "version": "5.0.0",
5
5
  "description": "A Directus nuxt module that uses the Directus SDK",
6
6
  "author": "Matthew Rollinson <matt@rolley.io>",
7
7
  "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/rolleyio/nuxt-directus-sdk"
11
+ },
8
12
  "exports": {
9
13
  ".": {
10
14
  "types": "./dist/module.d.mts",