nuxt-directus-sdk 5.0.0-beta.8 → 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.d.mts +4 -3
- package/dist/module.d.ts +4 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -5
- package/dist/runtime/composables/auth.d.ts +6 -6
- package/dist/runtime/server/services/directus.js +5 -3
- package/dist/runtime/types/fallback.d.ts +5 -0
- package/dist/types.d.mts +1 -1
- package/package.json +14 -5
package/dist/module.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ type DirectusUrl = string | {
|
|
|
6
6
|
client: string;
|
|
7
7
|
server: string;
|
|
8
8
|
};
|
|
9
|
+
type ReadMeFields = Query<DirectusSchema, DirectusSchema['directus_users']>['fields'];
|
|
9
10
|
interface ModuleOptions {
|
|
10
11
|
/**
|
|
11
12
|
* Directus API URL
|
|
@@ -118,9 +119,9 @@ interface ModuleOptions {
|
|
|
118
119
|
/**
|
|
119
120
|
* ReadMe fields to fetch
|
|
120
121
|
* @default []
|
|
121
|
-
* @type
|
|
122
|
+
* @type ReadMeFields
|
|
122
123
|
*/
|
|
123
|
-
readMeFields?:
|
|
124
|
+
readMeFields?: ReadMeFields;
|
|
124
125
|
redirect?: {
|
|
125
126
|
/**
|
|
126
127
|
* Redirect to home page after login
|
|
@@ -171,4 +172,4 @@ declare module '@nuxt/schema' {
|
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
export { _default as default };
|
|
174
|
-
export type { DirectusUrl, ModuleOptions };
|
|
175
|
+
export type { DirectusUrl, ModuleOptions, ReadMeFields };
|
package/dist/module.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type DirectusUrl = string | {
|
|
|
6
6
|
client: string;
|
|
7
7
|
server: string;
|
|
8
8
|
};
|
|
9
|
+
type ReadMeFields = Query<DirectusSchema, DirectusSchema['directus_users']>['fields'];
|
|
9
10
|
interface ModuleOptions {
|
|
10
11
|
/**
|
|
11
12
|
* Directus API URL
|
|
@@ -118,9 +119,9 @@ interface ModuleOptions {
|
|
|
118
119
|
/**
|
|
119
120
|
* ReadMe fields to fetch
|
|
120
121
|
* @default []
|
|
121
|
-
* @type
|
|
122
|
+
* @type ReadMeFields
|
|
122
123
|
*/
|
|
123
|
-
readMeFields?:
|
|
124
|
+
readMeFields?: ReadMeFields;
|
|
124
125
|
redirect?: {
|
|
125
126
|
/**
|
|
126
127
|
* Redirect to home page after login
|
|
@@ -171,4 +172,4 @@ declare module '@nuxt/schema' {
|
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
export { _default as default };
|
|
174
|
-
export type { DirectusUrl, ModuleOptions };
|
|
175
|
+
export type { DirectusUrl, ModuleOptions, ReadMeFields };
|
package/dist/module.json
CHANGED
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
|
|
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.
|
|
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 };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { ComputedRef, Ref } from '#imports';
|
|
2
2
|
import type { RouteLocationRaw } from '#vue-router';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LoginOptions } from '@directus/sdk';
|
|
4
4
|
import type { DirectusError, RegisterUserInput } from '@directus/types';
|
|
5
5
|
export interface DirectusAuth {
|
|
6
|
-
user: Ref<
|
|
6
|
+
user: Ref<DirectusUser | null>;
|
|
7
7
|
loggedIn: ComputedRef<boolean>;
|
|
8
|
-
readMe: () => Promise<
|
|
9
|
-
updateMe: (data: Partial<DirectusUser>) => Promise<
|
|
8
|
+
readMe: () => Promise<DirectusUser | DirectusError | null>;
|
|
9
|
+
updateMe: (data: Partial<DirectusUser>) => Promise<DirectusUser | DirectusError | null>;
|
|
10
10
|
login: (email: string, password: string, options?: LoginOptions & {
|
|
11
11
|
redirect?: boolean | RouteLocationRaw;
|
|
12
12
|
}) => Promise<DirectusUser | null>;
|
|
13
13
|
loginWithProvider: (provider: string, redirectOnLogin?: boolean | string) => Promise<void>;
|
|
14
14
|
logout: (redirect?: boolean | RouteLocationRaw) => Promise<void>;
|
|
15
|
-
createUser: (data: RegisterUserInput & Partial<Omit<DirectusUser, 'id' | 'email' | 'password'>>) => Promise<
|
|
16
|
-
register: (data: RegisterUserInput & Partial<Omit<DirectusUser, 'id' | 'email' | 'password'>>) => Promise<
|
|
15
|
+
createUser: (data: RegisterUserInput & Partial<Omit<DirectusUser, 'id' | 'email' | 'password'>>) => Promise<DirectusUser>;
|
|
16
|
+
register: (data: RegisterUserInput & Partial<Omit<DirectusUser, 'id' | 'email' | 'password'>>) => Promise<DirectusUser>;
|
|
17
17
|
inviteUser: (email: string, role: string, inviteUrl?: string | undefined) => Promise<void>;
|
|
18
18
|
acceptUserInvite: (token: string, password: string) => Promise<void>;
|
|
19
19
|
passwordRequest: (email: string, resetUrl?: string | undefined) => Promise<void>;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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(
|
|
29
|
+
return useTokenDirectus(adminToken);
|
|
28
30
|
}
|
package/dist/types.d.mts
CHANGED
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
|
|
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",
|
|
@@ -18,16 +22,19 @@
|
|
|
18
22
|
"main": "./dist/module.mjs",
|
|
19
23
|
"types": "./dist/module.d.mts",
|
|
20
24
|
"bin": {
|
|
21
|
-
"directus-rules": "
|
|
22
|
-
"nuxt-directus-sdk": "
|
|
25
|
+
"directus-rules": "dist/cli/index.mjs",
|
|
26
|
+
"nuxt-directus-sdk": "dist/cli/index.mjs"
|
|
23
27
|
},
|
|
24
|
-
"files": [
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
25
31
|
"scripts": {
|
|
26
32
|
"prepack": "nuxt-module-build build",
|
|
27
33
|
"dev": "nuxi dev playground",
|
|
28
34
|
"dev:build": "nuxi build playground",
|
|
29
35
|
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
|
|
30
36
|
"release": "npm run lint && npm run prepack && npm publish && git push --follow-tags",
|
|
37
|
+
"release:next": "npm run lint && npm run prepack && npm publish --tag next && git push --follow-tags",
|
|
31
38
|
"lint": "eslint . --fix",
|
|
32
39
|
"test": "vitest run",
|
|
33
40
|
"test:watch": "vitest watch",
|
|
@@ -80,6 +87,8 @@
|
|
|
80
87
|
},
|
|
81
88
|
"unbuild": {
|
|
82
89
|
"failOnWarn": false,
|
|
83
|
-
"externals": [
|
|
90
|
+
"externals": [
|
|
91
|
+
"consola/utils"
|
|
92
|
+
]
|
|
84
93
|
}
|
|
85
94
|
}
|