nuxt-precognition 0.3.2 → 0.4.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 +2 -2
- package/dist/module.mjs +44 -20
- package/dist/runtime/core.d.ts +1 -7
- package/dist/runtime/core.js +6 -37
- package/dist/runtime/parsers.d.ts +7 -0
- package/dist/runtime/parsers.js +37 -0
- package/dist/runtime/plugin.d.ts +4 -4
- package/dist/runtime/server/definePrecognitiveEventHandler-legacy.d.ts +17 -0
- package/dist/runtime/server/definePrecognitiveEventHandler-legacy.js +118 -0
- package/dist/runtime/server/definePrecognitiveEventHandler.d.ts +19 -11
- package/dist/runtime/server/definePrecognitiveEventHandler.js +80 -75
- package/dist/runtime/server/plugin.d.ts +16 -2
- package/dist/runtime/server/plugin.js +11 -5
- package/dist/runtime/types/eventHandler.d.ts +4 -4
- package/dist/runtime/useForm.js +1 -0
- package/dist/runtime/validator.d.ts +5 -1
- package/dist/types.d.mts +2 -6
- package/package.json +30 -32
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -9
- package/dist/types.d.ts +0 -7
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin, addImports, addServerImports,
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addImports, addServerImports, addNitroPlugin, hasNuxtCompatibility, addTypeTemplate } from '@nuxt/kit';
|
|
2
2
|
import defu from 'defu';
|
|
3
3
|
|
|
4
|
-
const module = defineNuxtModule({
|
|
4
|
+
const module$1 = defineNuxtModule({
|
|
5
5
|
meta: {
|
|
6
6
|
name: "nuxt-precognition",
|
|
7
7
|
configKey: "precognition",
|
|
@@ -18,7 +18,7 @@ const module = defineNuxtModule({
|
|
|
18
18
|
enableLaravelClientErrorParser: false,
|
|
19
19
|
enableLaravelServerErrorParser: false
|
|
20
20
|
},
|
|
21
|
-
setup(options, nuxt) {
|
|
21
|
+
async setup(options, nuxt) {
|
|
22
22
|
nuxt.options.runtimeConfig.public.precognition = defu(
|
|
23
23
|
nuxt.options.runtimeConfig.public.precognition,
|
|
24
24
|
{
|
|
@@ -31,7 +31,6 @@ const module = defineNuxtModule({
|
|
|
31
31
|
}
|
|
32
32
|
);
|
|
33
33
|
const resolver = createResolver(import.meta.url);
|
|
34
|
-
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || [];
|
|
35
34
|
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
36
35
|
addImports({
|
|
37
36
|
name: "useForm",
|
|
@@ -40,11 +39,23 @@ const module = defineNuxtModule({
|
|
|
40
39
|
});
|
|
41
40
|
addServerImports([
|
|
42
41
|
{
|
|
43
|
-
from:
|
|
42
|
+
from: {
|
|
43
|
+
nuxt: resolver.resolve("./runtime/server/definePrecognitiveEventHandler"),
|
|
44
|
+
nitro2: resolver.resolve("./runtime/server/definePrecognitiveEventHandler-legacy")
|
|
45
|
+
},
|
|
44
46
|
name: "definePrecognitiveEventHandler"
|
|
45
47
|
}
|
|
46
48
|
]);
|
|
47
|
-
|
|
49
|
+
const serverBuilder = nuxt.options.server?.builder;
|
|
50
|
+
const isNitroBuilder = serverBuilder === void 0 || serverBuilder === "nitro" || typeof serverBuilder === "string" && /(?:^|[\\/])(?:@nuxt\/)?nitro-server(?:$|[\\/.])/.test(serverBuilder);
|
|
51
|
+
if (isNitroBuilder) {
|
|
52
|
+
const serverPlugin = resolver.resolve("./runtime/server/plugin");
|
|
53
|
+
addNitroPlugin({
|
|
54
|
+
nitro2: serverPlugin,
|
|
55
|
+
nitro3: serverPlugin
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const supportsNuxtServer = await hasNuxtCompatibility({ nuxt: ">=4.6.0-0" }, nuxt);
|
|
48
59
|
addTypeTemplate({
|
|
49
60
|
filename: "types/nuxt-precognition.d.ts",
|
|
50
61
|
getContents: () => `// Generated by nuxt-precognition
|
|
@@ -73,21 +84,34 @@ export {
|
|
|
73
84
|
ValidationErrorsData
|
|
74
85
|
}`
|
|
75
86
|
});
|
|
76
|
-
|
|
87
|
+
addTypeTemplate({
|
|
77
88
|
filename: "types/nuxt-precognition-server.d.ts",
|
|
78
|
-
getContents: () =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
getContents: () => {
|
|
90
|
+
const lines = [
|
|
91
|
+
"// Generated by nuxt-precognition",
|
|
92
|
+
`import type { PrecognitionEventContext } from '${resolver.resolve("./runtime/types/eventHandler")}'`
|
|
93
|
+
];
|
|
94
|
+
if (isNitroBuilder) {
|
|
95
|
+
lines.push(
|
|
96
|
+
`import type { H3Event } from 'h3'`,
|
|
97
|
+
`declare module 'h3' {`,
|
|
98
|
+
` interface H3EventContext extends PrecognitionEventContext<H3Event> {}`,
|
|
99
|
+
`}`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
if (supportsNuxtServer) {
|
|
103
|
+
lines.push(
|
|
104
|
+
`import type { RequestEvent } from 'nuxt/server'`,
|
|
105
|
+
`declare module 'nuxt/schema' {`,
|
|
106
|
+
` interface RequestEventContext extends PrecognitionEventContext<RequestEvent> {}`,
|
|
107
|
+
`}`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
lines.push("export {}");
|
|
111
|
+
return lines.join("\n");
|
|
112
|
+
}
|
|
113
|
+
}, { nitro: true, nuxt: false });
|
|
90
114
|
}
|
|
91
115
|
});
|
|
92
116
|
|
|
93
|
-
export { module as default };
|
|
117
|
+
export { module$1 as default };
|
package/dist/runtime/core.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type { ValidationErrorsData, ValidationErrorParser } from './types/core.js';
|
|
2
1
|
import type { NestedKeyOf } from './types/utils.js';
|
|
3
|
-
export
|
|
4
|
-
response: Response;
|
|
5
|
-
};
|
|
2
|
+
export { hasResponse, resolveValidationErrorData, makeNuxtValidationErrorParser, makeLaravelValidationErrorParser, } from './parsers.js';
|
|
6
3
|
export declare function resolveDynamicObject<T extends object>(object: T | (() => T)): T;
|
|
7
4
|
export declare function requestPrecognitiveHeaders(headers?: HeadersInit, keys?: string[]): Headers;
|
|
8
5
|
export declare function getAllNestedKeys<TData extends object, TPrefix extends string | undefined = undefined>(obj: TData, prefix?: TPrefix, keys?: string[]): TPrefix extends undefined ? NestedKeyOf<TData>[] : string[];
|
|
9
6
|
export declare function isFile(value: unknown): value is Blob | File | FileList;
|
|
10
|
-
export declare function resolveValidationErrorData<TResp>(error: Error, parsers: ValidationErrorParser<TResp>[]): ValidationErrorsData | null | undefined;
|
|
11
|
-
export declare function makeNuxtValidationErrorParser(): ValidationErrorParser;
|
|
12
|
-
export declare function makeLaravelValidationErrorParser(): ValidationErrorParser;
|
|
13
7
|
/**
|
|
14
8
|
* Asserts that the response is a successful precognitive response.
|
|
15
9
|
* It runs check only if the response is OK (status 200-299) and the precognition header is set to true.
|
package/dist/runtime/core.js
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
1
|
import { createError } from "#imports";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
function hasNuxtValidationErrorsData(response) {
|
|
9
|
-
return hasResponseData(response) && "data" in response._data && typeof response._data.data === "object" && !!response._data.data && hasErrorMessage(response._data.data) && hasValidationErrors(response._data.data);
|
|
10
|
-
}
|
|
11
|
-
function hasResponseData(response) {
|
|
12
|
-
return "_data" in response && typeof response._data === "object" && !!response._data;
|
|
13
|
-
}
|
|
14
|
-
function hasLaravelValidationErrorsData(response) {
|
|
15
|
-
return hasResponseData(response) && hasErrorMessage(response._data) && hasValidationErrors(response._data);
|
|
16
|
-
}
|
|
17
|
-
function hasErrorMessage(data) {
|
|
18
|
-
return "message" in data && typeof data.message === "string";
|
|
19
|
-
}
|
|
20
|
-
function hasValidationErrors(data) {
|
|
21
|
-
if (!("errors" in data) || typeof data.errors !== "object" || !data.errors)
|
|
22
|
-
return false;
|
|
23
|
-
const allObjectKeysAreStrings = Object.keys(data.errors).every((key) => typeof key === "string");
|
|
24
|
-
const allObjectValuesAreStringsOrArrays = Object.values(data.errors).every((value) => typeof value === "string" || Array.isArray(value) && value.every((item) => typeof item === "string"));
|
|
25
|
-
return allObjectKeysAreStrings && allObjectValuesAreStringsOrArrays;
|
|
26
|
-
}
|
|
2
|
+
export {
|
|
3
|
+
hasResponse,
|
|
4
|
+
resolveValidationErrorData,
|
|
5
|
+
makeNuxtValidationErrorParser,
|
|
6
|
+
makeLaravelValidationErrorParser
|
|
7
|
+
} from "./parsers.js";
|
|
27
8
|
export function resolveDynamicObject(object) {
|
|
28
9
|
return typeof object === "function" ? object() : object;
|
|
29
10
|
}
|
|
@@ -49,18 +30,6 @@ export function isFile(value) {
|
|
|
49
30
|
return true;
|
|
50
31
|
return import.meta.server ? value instanceof File || value instanceof FileList : false;
|
|
51
32
|
}
|
|
52
|
-
export function resolveValidationErrorData(error, parsers) {
|
|
53
|
-
return parsers.reduce(
|
|
54
|
-
(errors, parser) => errors ?? (typeof parser === "function" ? parser(error) : parser.errorParser(error)),
|
|
55
|
-
null
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
export function makeNuxtValidationErrorParser() {
|
|
59
|
-
return (error) => hasResponse(error) && hasValidationStatusCode(error.response) && hasNuxtValidationErrorsData(error.response) ? error.response._data.data : null;
|
|
60
|
-
}
|
|
61
|
-
export function makeLaravelValidationErrorParser() {
|
|
62
|
-
return (error) => hasResponse(error) && hasValidationStatusCode(error.response) && hasLaravelValidationErrorsData(error.response) ? error.response._data : null;
|
|
63
|
-
}
|
|
64
33
|
export function assertSuccessfulPrecognitiveResponses(ctx) {
|
|
65
34
|
if (!ctx.response.ok) {
|
|
66
35
|
return;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ValidationErrorsData, ValidationErrorParser } from './types/core.js';
|
|
2
|
+
export declare function hasResponse(error: Error): error is Error & {
|
|
3
|
+
response: Response;
|
|
4
|
+
};
|
|
5
|
+
export declare function resolveValidationErrorData<TResp>(error: Error, parsers: ValidationErrorParser<TResp>[]): ValidationErrorsData | null | undefined;
|
|
6
|
+
export declare function makeNuxtValidationErrorParser(): ValidationErrorParser;
|
|
7
|
+
export declare function makeLaravelValidationErrorParser(): ValidationErrorParser;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export function hasResponse(error) {
|
|
2
|
+
return "response" in error && error.response instanceof Response;
|
|
3
|
+
}
|
|
4
|
+
function hasValidationStatusCode(response) {
|
|
5
|
+
return response.status === 422;
|
|
6
|
+
}
|
|
7
|
+
function hasNuxtValidationErrorsData(response) {
|
|
8
|
+
return hasResponseData(response) && "data" in response._data && typeof response._data.data === "object" && !!response._data.data && hasErrorMessage(response._data.data) && hasValidationErrors(response._data.data);
|
|
9
|
+
}
|
|
10
|
+
function hasResponseData(response) {
|
|
11
|
+
return "_data" in response && typeof response._data === "object" && !!response._data;
|
|
12
|
+
}
|
|
13
|
+
function hasLaravelValidationErrorsData(response) {
|
|
14
|
+
return hasResponseData(response) && hasErrorMessage(response._data) && hasValidationErrors(response._data);
|
|
15
|
+
}
|
|
16
|
+
function hasErrorMessage(data) {
|
|
17
|
+
return "message" in data && typeof data.message === "string";
|
|
18
|
+
}
|
|
19
|
+
function hasValidationErrors(data) {
|
|
20
|
+
if (!("errors" in data) || typeof data.errors !== "object" || !data.errors)
|
|
21
|
+
return false;
|
|
22
|
+
const allObjectKeysAreStrings = Object.keys(data.errors).every((key) => typeof key === "string");
|
|
23
|
+
const allObjectValuesAreStringsOrArrays = Object.values(data.errors).every((value) => typeof value === "string" || Array.isArray(value) && value.every((item) => typeof item === "string"));
|
|
24
|
+
return allObjectKeysAreStrings && allObjectValuesAreStringsOrArrays;
|
|
25
|
+
}
|
|
26
|
+
export function resolveValidationErrorData(error, parsers) {
|
|
27
|
+
return parsers.reduce(
|
|
28
|
+
(errors, parser) => errors ?? (typeof parser === "function" ? parser(error) : parser.errorParser(error)),
|
|
29
|
+
null
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
export function makeNuxtValidationErrorParser() {
|
|
33
|
+
return (error) => hasResponse(error) && hasValidationStatusCode(error.response) && hasNuxtValidationErrorsData(error.response) ? error.response._data.data : null;
|
|
34
|
+
}
|
|
35
|
+
export function makeLaravelValidationErrorParser() {
|
|
36
|
+
return (error) => hasResponse(error) && hasValidationStatusCode(error.response) && hasLaravelValidationErrorsData(error.response) ? error.response._data : null;
|
|
37
|
+
}
|
package/dist/runtime/plugin.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ import { assertSuccessfulPrecognitiveResponses } from './core.js';
|
|
|
3
3
|
declare const _default: import("nuxt/app").Plugin<{
|
|
4
4
|
precognition: {
|
|
5
5
|
errorParsers: ValidationErrorParser[];
|
|
6
|
-
statusHandlers: Partial<Record<import("./types/utils").ErrorStatusCode, <TData extends object, TResp>(error: Error & {
|
|
6
|
+
statusHandlers: Partial<Record<import("./types/utils.js").ErrorStatusCode, <TData extends object, TResp>(error: Error & {
|
|
7
7
|
response: Response;
|
|
8
|
-
}, form: TData & import("./types/form").Form<TData, TResp>) => void | Promise<void>>>;
|
|
8
|
+
}, form: TData & import("./types/form.js").Form<TData, TResp>) => void | Promise<void>>>;
|
|
9
9
|
assertSuccessfulPrecognitiveResponses: typeof assertSuccessfulPrecognitiveResponses;
|
|
10
10
|
};
|
|
11
11
|
}> & import("nuxt/app").ObjectPlugin<{
|
|
12
12
|
precognition: {
|
|
13
13
|
errorParsers: ValidationErrorParser[];
|
|
14
|
-
statusHandlers: Partial<Record<import("./types/utils").ErrorStatusCode, <TData extends object, TResp>(error: Error & {
|
|
14
|
+
statusHandlers: Partial<Record<import("./types/utils.js").ErrorStatusCode, <TData extends object, TResp>(error: Error & {
|
|
15
15
|
response: Response;
|
|
16
|
-
}, form: TData & import("./types/form").Form<TData, TResp>) => void | Promise<void>>>;
|
|
16
|
+
}, form: TData & import("./types/form.js").Form<TData, TResp>) => void | Promise<void>>>;
|
|
17
17
|
assertSuccessfulPrecognitiveResponses: typeof assertSuccessfulPrecognitiveResponses;
|
|
18
18
|
};
|
|
19
19
|
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EventHandler, EventHandlerObject, EventHandlerRequest, H3Event } from 'h3';
|
|
2
|
+
import type { ValidationErrorParser } from '../types/core.js';
|
|
3
|
+
import type { ServerStatusHandlers } from '../types/eventHandler.js';
|
|
4
|
+
declare function definePrecognitiveEventHandler<TRequest extends EventHandlerRequest, TResponse>(handler: EventHandlerObject<TRequest, TResponse>, options?: {
|
|
5
|
+
errorParsers?: ValidationErrorParser<TResponse>[];
|
|
6
|
+
statusHandlers?: ServerStatusHandlers<H3Event>;
|
|
7
|
+
}): EventHandler<TRequest, TResponse>;
|
|
8
|
+
declare namespace definePrecognitiveEventHandler {
|
|
9
|
+
var create: <TRequest extends EventHandlerRequest, TResponse>(options: {
|
|
10
|
+
errorParsers?: ValidationErrorParser[];
|
|
11
|
+
statusHandlers?: ServerStatusHandlers<H3Event>;
|
|
12
|
+
}) => (handler: EventHandlerObject<TRequest, TResponse>, options?: {
|
|
13
|
+
errorParsers?: ValidationErrorParser[];
|
|
14
|
+
statusHandlers?: ServerStatusHandlers<H3Event>;
|
|
15
|
+
}) => EventHandler<TRequest, TResponse>;
|
|
16
|
+
}
|
|
17
|
+
export { definePrecognitiveEventHandler };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineEventHandler, setResponseHeader, createError, setResponseStatus } from "h3";
|
|
2
|
+
import { hasResponse, makeLaravelValidationErrorParser, resolveValidationErrorData } from "../parsers.js";
|
|
3
|
+
import { useRuntimeConfig } from "#imports";
|
|
4
|
+
function definePrecognitiveEventHandler(handler, options) {
|
|
5
|
+
return defineEventHandler({
|
|
6
|
+
onRequest: onPrecognitiveRequest(handler.onRequest, options),
|
|
7
|
+
handler: onPrecognitiveHandler(handler.handler),
|
|
8
|
+
onBeforeResponse: handler.onBeforeResponse
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function onPrecognitiveRequest(onRequest, options) {
|
|
12
|
+
if (!onRequest)
|
|
13
|
+
return void 0;
|
|
14
|
+
const config = useRuntimeConfig().public.precognition;
|
|
15
|
+
const baseParsers = [];
|
|
16
|
+
if (config.enableLaravelServerErrorParser)
|
|
17
|
+
baseParsers.push(makeLaravelValidationErrorParser());
|
|
18
|
+
if (typeof onRequest === "function")
|
|
19
|
+
return onPrecognitiveRequestWrapper(
|
|
20
|
+
onRequest,
|
|
21
|
+
{
|
|
22
|
+
errorParsers: [...baseParsers, ...options?.errorParsers ?? []],
|
|
23
|
+
statusHandlers: options?.statusHandlers
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
return onRequest.map((middleware) => onPrecognitiveRequestWrapper(
|
|
27
|
+
middleware,
|
|
28
|
+
{
|
|
29
|
+
errorParsers: [...baseParsers, ...options?.errorParsers ?? []],
|
|
30
|
+
statusHandlers: options?.statusHandlers
|
|
31
|
+
}
|
|
32
|
+
));
|
|
33
|
+
}
|
|
34
|
+
function onPrecognitiveRequestWrapper(middleware, options) {
|
|
35
|
+
return async (event) => {
|
|
36
|
+
try {
|
|
37
|
+
await middleware(event);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (!(error instanceof Error)) {
|
|
40
|
+
throw createError({
|
|
41
|
+
message: "Unknown server error",
|
|
42
|
+
statusCode: 500,
|
|
43
|
+
data: { message: "Unknown server error" }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const statusHandler = hasResponse(error) ? options.statusHandlers?.[`${error.response.status}`] ?? event.context.$precognition.statusHandlers[`${error.response.status}`] : void 0;
|
|
47
|
+
if (statusHandler) {
|
|
48
|
+
return statusHandler(error, event);
|
|
49
|
+
}
|
|
50
|
+
setResponseHeader(event, "Content-Type", "application/json");
|
|
51
|
+
const errorsData = resolveValidationErrorData(error, [
|
|
52
|
+
...event.context.$precognition.errorParsers,
|
|
53
|
+
...options.errorParsers
|
|
54
|
+
]);
|
|
55
|
+
if (!errorsData) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
handleValidationErrorsData(errorsData, event);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function handleValidationErrorsData(errorsData, event) {
|
|
63
|
+
setResponseStatus(event, 422);
|
|
64
|
+
setResponseHeader(event, "Content-Type", "application/json");
|
|
65
|
+
if (event.headers.get("Precognition") !== "true") {
|
|
66
|
+
throw createError({
|
|
67
|
+
statusCode: 422,
|
|
68
|
+
message: errorsData.message,
|
|
69
|
+
data: errorsData
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
setResponseHeader(event, "Precognition", "true");
|
|
73
|
+
const validateOnly = event.headers.get("Precognition-Validate-Only");
|
|
74
|
+
if (!validateOnly) {
|
|
75
|
+
throw createError({
|
|
76
|
+
status: 422,
|
|
77
|
+
message: errorsData.message,
|
|
78
|
+
data: errorsData
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
setResponseHeader(event, "Precognition-Validate-Only", validateOnly);
|
|
82
|
+
const validateOnlyKeys = validateOnly.split(",");
|
|
83
|
+
const errors = Object.entries(errorsData.errors).filter(([key]) => validateOnlyKeys.includes(key));
|
|
84
|
+
if (!errors.length)
|
|
85
|
+
return;
|
|
86
|
+
const precognitveErrors = {};
|
|
87
|
+
errors.forEach(([key, value]) => {
|
|
88
|
+
precognitveErrors[key] = Array.isArray(value) ? value : [value];
|
|
89
|
+
});
|
|
90
|
+
throw createError({
|
|
91
|
+
status: 422,
|
|
92
|
+
data: {
|
|
93
|
+
message: errorsData.message,
|
|
94
|
+
errors: precognitveErrors
|
|
95
|
+
},
|
|
96
|
+
message: errorsData.message
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function onPrecognitiveHandler(handler) {
|
|
100
|
+
return (event) => {
|
|
101
|
+
if (event.headers.get("Precognition") !== "true")
|
|
102
|
+
return handler(event);
|
|
103
|
+
setResponseHeader(event, "Content-Type", "application/json");
|
|
104
|
+
setResponseHeader(event, "Precognition", "true");
|
|
105
|
+
setResponseHeader(event, "Precognition-Success", "true");
|
|
106
|
+
const validateOnlyKey = event.headers.get("Precognition-Validate-Only");
|
|
107
|
+
if (validateOnlyKey)
|
|
108
|
+
setResponseHeader(event, "Precognition-Validate-Only", validateOnlyKey);
|
|
109
|
+
setResponseStatus(event, 200);
|
|
110
|
+
return null;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
definePrecognitiveEventHandler.create = function(options) {
|
|
114
|
+
const baseErrorParsers = [...options.errorParsers ?? []];
|
|
115
|
+
const baseStatusHandlers = { ...options.statusHandlers };
|
|
116
|
+
return (handler, options2) => definePrecognitiveEventHandler(handler, { errorParsers: [...baseErrorParsers, ...options2?.errorParsers ?? []], statusHandlers: { ...baseStatusHandlers, ...options2?.statusHandlers } });
|
|
117
|
+
};
|
|
118
|
+
export { definePrecognitiveEventHandler };
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import type { EventHandler,
|
|
1
|
+
import type { EventHandler, RequestEvent } from 'nuxt/server';
|
|
2
2
|
import type { ValidationErrorParser } from '../types/core.js';
|
|
3
3
|
import type { ServerStatusHandlers } from '../types/eventHandler.js';
|
|
4
|
-
|
|
4
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
5
|
+
export type PrecognitiveRequestMiddleware = (event: RequestEvent) => MaybePromise<void>;
|
|
6
|
+
export type PrecognitiveBeforeResponseMiddleware<TResponse> = (event: RequestEvent, response: {
|
|
7
|
+
body?: Awaited<TResponse>;
|
|
8
|
+
}) => MaybePromise<void>;
|
|
9
|
+
export interface PrecognitiveEventHandlerObject<TResponse> {
|
|
10
|
+
/** Runs before `handler`. Throw here to report validation errors. */
|
|
11
|
+
onRequest?: PrecognitiveRequestMiddleware | PrecognitiveRequestMiddleware[];
|
|
12
|
+
/** Runs only for non-precognitive requests (or precognitive requests without matching errors). */
|
|
13
|
+
handler: EventHandler<TResponse>;
|
|
14
|
+
/** Runs after `handler`, before the response is sent. */
|
|
15
|
+
onBeforeResponse?: PrecognitiveBeforeResponseMiddleware<TResponse> | PrecognitiveBeforeResponseMiddleware<TResponse>[];
|
|
16
|
+
}
|
|
17
|
+
export interface PrecognitiveEventHandlerOptions<TResponse = unknown> {
|
|
5
18
|
errorParsers?: ValidationErrorParser<TResponse>[];
|
|
6
|
-
statusHandlers?: ServerStatusHandlers
|
|
7
|
-
}
|
|
19
|
+
statusHandlers?: ServerStatusHandlers<RequestEvent>;
|
|
20
|
+
}
|
|
21
|
+
declare function definePrecognitiveEventHandler<TResponse>(handler: PrecognitiveEventHandlerObject<TResponse>, options?: PrecognitiveEventHandlerOptions<TResponse>): EventHandler<Promise<Awaited<TResponse>>>;
|
|
8
22
|
declare namespace definePrecognitiveEventHandler {
|
|
9
|
-
var create:
|
|
10
|
-
errorParsers?: ValidationErrorParser[];
|
|
11
|
-
statusHandlers?: ServerStatusHandlers;
|
|
12
|
-
}) => (handler: EventHandlerObject<TRequest, TResponse>, options?: {
|
|
13
|
-
errorParsers?: ValidationErrorParser[];
|
|
14
|
-
statusHandlers?: ServerStatusHandlers;
|
|
15
|
-
}) => EventHandler<TRequest, TResponse>;
|
|
23
|
+
var create: (options: PrecognitiveEventHandlerOptions) => <TResponse>(handler: PrecognitiveEventHandlerObject<TResponse>, options?: PrecognitiveEventHandlerOptions<TResponse>) => EventHandler<Promise<Awaited<TResponse>>>;
|
|
16
24
|
}
|
|
17
25
|
export { definePrecognitiveEventHandler };
|
|
@@ -1,74 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createError, defineEventHandler, setResponseStatus, useRuntimeConfig } from "nuxt/server";
|
|
2
|
+
import { hasResponse, makeLaravelValidationErrorParser, resolveValidationErrorData } from "../parsers.js";
|
|
3
|
+
function toArray(value) {
|
|
4
|
+
if (!value)
|
|
5
|
+
return [];
|
|
6
|
+
return Array.isArray(value) ? value : [value];
|
|
7
|
+
}
|
|
8
|
+
function usePrecognitionContext(event) {
|
|
9
|
+
const context = event.context;
|
|
10
|
+
context.$precognition ??= { errorParsers: [], statusHandlers: {} };
|
|
11
|
+
context.precognitive ??= event.req.headers.get("Precognition") === "true";
|
|
12
|
+
return context.$precognition;
|
|
13
|
+
}
|
|
3
14
|
function definePrecognitiveEventHandler(handler, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
const onRequest = toArray(handler.onRequest);
|
|
16
|
+
const onBeforeResponse = toArray(handler.onBeforeResponse);
|
|
17
|
+
return defineEventHandler(async (event) => {
|
|
18
|
+
const precognition = usePrecognitionContext(event);
|
|
19
|
+
if (onRequest.length) {
|
|
20
|
+
const errorParsers = [...resolveBaseErrorParsers(), ...options?.errorParsers ?? []];
|
|
21
|
+
for (const middleware of onRequest) {
|
|
22
|
+
await runPrecognitiveMiddleware(middleware, event, precognition, {
|
|
23
|
+
errorParsers,
|
|
24
|
+
statusHandlers: options?.statusHandlers
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const response = { body: await onPrecognitiveHandler(handler.handler, event) };
|
|
29
|
+
for (const middleware of onBeforeResponse)
|
|
30
|
+
await middleware(event, response);
|
|
31
|
+
return response.body;
|
|
8
32
|
});
|
|
9
33
|
}
|
|
10
|
-
function
|
|
11
|
-
if (!onRequest)
|
|
12
|
-
return void 0;
|
|
34
|
+
function resolveBaseErrorParsers() {
|
|
13
35
|
const config = useRuntimeConfig().public.precognition;
|
|
14
|
-
|
|
15
|
-
if (config.enableLaravelServerErrorParser)
|
|
16
|
-
baseParsers.push(makeLaravelValidationErrorParser());
|
|
17
|
-
if (typeof onRequest === "function")
|
|
18
|
-
return onPrecognitiveRequestWrapper(
|
|
19
|
-
onRequest,
|
|
20
|
-
{
|
|
21
|
-
errorParsers: [...baseParsers, ...options?.errorParsers ?? []],
|
|
22
|
-
statusHandlers: options?.statusHandlers
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
return onRequest.map((middleware) => onPrecognitiveRequestWrapper(
|
|
26
|
-
middleware,
|
|
27
|
-
{
|
|
28
|
-
errorParsers: [...baseParsers, ...options?.errorParsers ?? []],
|
|
29
|
-
statusHandlers: options?.statusHandlers
|
|
30
|
-
}
|
|
31
|
-
));
|
|
36
|
+
return config.enableLaravelServerErrorParser ? [makeLaravelValidationErrorParser()] : [];
|
|
32
37
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return statusHandler(error, event);
|
|
48
|
-
}
|
|
49
|
-
setResponseHeader(event, "Content-Type", "application/json");
|
|
50
|
-
const errorsData = resolveValidationErrorData(error, [
|
|
51
|
-
...event.context.$precognition.errorParsers,
|
|
52
|
-
...options.errorParsers
|
|
53
|
-
]);
|
|
54
|
-
if (!errorsData) {
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
handleValidationErrorsData(errorsData, event);
|
|
38
|
+
async function runPrecognitiveMiddleware(middleware, event, precognition, options) {
|
|
39
|
+
try {
|
|
40
|
+
await middleware(event);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (!(error instanceof Error)) {
|
|
43
|
+
throw createError({
|
|
44
|
+
message: "Unknown server error",
|
|
45
|
+
status: 500,
|
|
46
|
+
data: { message: "Unknown server error" }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const statusHandler = hasResponse(error) ? options.statusHandlers?.[`${error.response.status}`] ?? precognition.statusHandlers[`${error.response.status}`] : void 0;
|
|
50
|
+
if (statusHandler) {
|
|
51
|
+
return statusHandler(error, event);
|
|
58
52
|
}
|
|
59
|
-
|
|
53
|
+
event.res.headers.set("Content-Type", "application/json");
|
|
54
|
+
const errorsData = resolveValidationErrorData(error, [
|
|
55
|
+
...precognition.errorParsers,
|
|
56
|
+
...options.errorParsers
|
|
57
|
+
]);
|
|
58
|
+
if (!errorsData) {
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
handleValidationErrorsData(errorsData, event);
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
function handleValidationErrorsData(errorsData, event) {
|
|
62
65
|
setResponseStatus(event, 422);
|
|
63
|
-
|
|
64
|
-
if (
|
|
66
|
+
event.res.headers.set("Content-Type", "application/json");
|
|
67
|
+
if (event.req.headers.get("Precognition") !== "true") {
|
|
65
68
|
throw createError({
|
|
69
|
+
status: 422,
|
|
66
70
|
message: errorsData.message,
|
|
67
71
|
data: errorsData
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
const validateOnly = event.headers.get("Precognition-Validate-Only");
|
|
74
|
+
event.res.headers.set("Precognition", "true");
|
|
75
|
+
const validateOnly = event.req.headers.get("Precognition-Validate-Only");
|
|
72
76
|
if (!validateOnly) {
|
|
73
77
|
throw createError({
|
|
74
78
|
status: 422,
|
|
@@ -76,13 +80,13 @@ function handleValidationErrorsData(errorsData, event) {
|
|
|
76
80
|
data: errorsData
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
const
|
|
83
|
+
event.res.headers.set("Precognition-Validate-Only", validateOnly);
|
|
84
|
+
const validateOnlyKeys = validateOnly.split(",");
|
|
85
|
+
const errors = Object.entries(errorsData.errors).filter(([key]) => validateOnlyKeys.includes(key));
|
|
81
86
|
if (!errors.length)
|
|
82
87
|
return;
|
|
83
88
|
const precognitveErrors = {};
|
|
84
|
-
errors.forEach((key) => {
|
|
85
|
-
const value = errorsData.errors[key];
|
|
89
|
+
errors.forEach(([key, value]) => {
|
|
86
90
|
precognitveErrors[key] = Array.isArray(value) ? value : [value];
|
|
87
91
|
});
|
|
88
92
|
throw createError({
|
|
@@ -94,23 +98,24 @@ function handleValidationErrorsData(errorsData, event) {
|
|
|
94
98
|
message: errorsData.message
|
|
95
99
|
});
|
|
96
100
|
}
|
|
97
|
-
function onPrecognitiveHandler(handler) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return null;
|
|
109
|
-
};
|
|
101
|
+
async function onPrecognitiveHandler(handler, event) {
|
|
102
|
+
if (event.req.headers.get("Precognition") !== "true")
|
|
103
|
+
return await handler(event);
|
|
104
|
+
event.res.headers.set("Content-Type", "application/json");
|
|
105
|
+
event.res.headers.set("Precognition", "true");
|
|
106
|
+
event.res.headers.set("Precognition-Success", "true");
|
|
107
|
+
const validateOnlyKey = event.req.headers.get("Precognition-Validate-Only");
|
|
108
|
+
if (validateOnlyKey)
|
|
109
|
+
event.res.headers.set("Precognition-Validate-Only", validateOnlyKey);
|
|
110
|
+
setResponseStatus(event, 200);
|
|
111
|
+
return null;
|
|
110
112
|
}
|
|
111
113
|
definePrecognitiveEventHandler.create = function(options) {
|
|
112
114
|
const baseErrorParsers = [...options.errorParsers ?? []];
|
|
113
115
|
const baseStatusHandlers = { ...options.statusHandlers };
|
|
114
|
-
return (handler, options2) => definePrecognitiveEventHandler(handler, {
|
|
116
|
+
return (handler, options2) => definePrecognitiveEventHandler(handler, {
|
|
117
|
+
errorParsers: [...baseErrorParsers, ...options2?.errorParsers ?? []],
|
|
118
|
+
statusHandlers: { ...baseStatusHandlers, ...options2?.statusHandlers }
|
|
119
|
+
});
|
|
115
120
|
};
|
|
116
121
|
export { definePrecognitiveEventHandler };
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface PrecognitionHookEvent {
|
|
2
|
+
context: object;
|
|
3
|
+
/** h3 v1: Web `Headers` of the request */
|
|
4
|
+
headers?: Headers;
|
|
5
|
+
/** h3 v2: Web `Request` (on h3 v1 this is the Node.js `IncomingMessage`) */
|
|
6
|
+
req?: {
|
|
7
|
+
headers: Headers | object;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
interface PrecognitionNitroApp {
|
|
11
|
+
hooks: {
|
|
12
|
+
hook: (name: 'request', callback: (event: PrecognitionHookEvent) => void) => unknown;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default function precognitionNitroPlugin(nitroApp: PrecognitionNitroApp): void;
|
|
16
|
+
export {};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function getRequestHeaders(event) {
|
|
2
|
+
const headers = event.req?.headers;
|
|
3
|
+
if (headers && typeof headers.get === "function")
|
|
4
|
+
return headers;
|
|
5
|
+
return event.headers;
|
|
6
|
+
}
|
|
7
|
+
export default function precognitionNitroPlugin(nitroApp) {
|
|
3
8
|
nitroApp.hooks.hook("request", (event) => {
|
|
4
|
-
|
|
9
|
+
const context = event.context;
|
|
10
|
+
context.$precognition ??= {
|
|
5
11
|
errorParsers: [],
|
|
6
12
|
statusHandlers: {}
|
|
7
13
|
};
|
|
8
|
-
|
|
14
|
+
context.precognitive = getRequestHeaders(event)?.get("Precognition") === "true";
|
|
9
15
|
});
|
|
10
|
-
}
|
|
16
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { H3Event, EventHandlerRequest } from 'h3';
|
|
2
1
|
import type { ErrorStatusCode } from './utils.js';
|
|
3
2
|
import type { ValidationErrorParser } from './core.js';
|
|
4
|
-
export type
|
|
5
|
-
export
|
|
3
|
+
export type ServerStatusHandler<TEvent = unknown> = (error: Error, event: TEvent) => void | Promise<void>;
|
|
4
|
+
export type ServerStatusHandlers<TEvent = unknown> = Partial<Record<ErrorStatusCode, ServerStatusHandler<TEvent>>>;
|
|
5
|
+
export interface PrecognitionEventContext<TEvent = unknown> {
|
|
6
6
|
$precognition: {
|
|
7
7
|
errorParsers: ValidationErrorParser[];
|
|
8
|
-
statusHandlers: ServerStatusHandlers
|
|
8
|
+
statusHandlers: ServerStatusHandlers<TEvent>;
|
|
9
9
|
};
|
|
10
10
|
precognitive: boolean;
|
|
11
11
|
}
|
package/dist/runtime/useForm.js
CHANGED
|
@@ -82,6 +82,7 @@ export function useForm(init, cb, options) {
|
|
|
82
82
|
const resp = await cb(data, Object.fromEntries(h.entries()));
|
|
83
83
|
if (validator.responseParsers.length)
|
|
84
84
|
validator.responseParsers.forEach((p) => p(resp));
|
|
85
|
+
form.forgetErrors();
|
|
85
86
|
return resp;
|
|
86
87
|
} catch (error) {
|
|
87
88
|
const err = error instanceof Error ? error : new Error("Invalid form");
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { DebouncedFuncLeading } from 'lodash';
|
|
2
1
|
import type { NestedKeyOf } from './types/utils.js';
|
|
3
2
|
import type { ValidationErrorParser } from './types/core.js';
|
|
4
3
|
import type { ClientStatusHandlers, Form, UseFormOptions } from './types/form.js';
|
|
4
|
+
export interface DebouncedFuncLeading<T extends (...args: never[]) => unknown> {
|
|
5
|
+
(...args: Parameters<T>): ReturnType<T>;
|
|
6
|
+
cancel: () => void;
|
|
7
|
+
flush: () => ReturnType<T>;
|
|
8
|
+
}
|
|
5
9
|
export declare function makeValidator<TData extends object, TResp>(cb: (data: TData, precognitiveHeaders: Headers) => Promise<TResp>, options?: UseFormOptions<TData, TResp>): {
|
|
6
10
|
validate: DebouncedFuncLeading<(form: Form<TData, TResp>, ...keys: NestedKeyOf<TData>[]) => Promise<void>>;
|
|
7
11
|
reset: () => void;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export { default } from './module.mjs'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
-
|
|
7
|
-
export { default } from './module.js'
|
|
3
|
+
export { type ModuleOptions } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-precognition",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "Nuxt module implementing Precognition protocol (inspired by official Laravel Precognition) for backend precognitive validation.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "sot1986",
|
|
@@ -23,13 +23,11 @@
|
|
|
23
23
|
],
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"types": "./dist/types.d.
|
|
27
|
-
"import": "./dist/module.mjs"
|
|
28
|
-
"require": "./dist/module.cjs"
|
|
26
|
+
"types": "./dist/types.d.mts",
|
|
27
|
+
"import": "./dist/module.mjs"
|
|
29
28
|
}
|
|
30
29
|
},
|
|
31
|
-
"main": "./dist/module.
|
|
32
|
-
"types": "./dist/types.d.ts",
|
|
30
|
+
"main": "./dist/module.mjs",
|
|
33
31
|
"publishConfig": {
|
|
34
32
|
"access": "public"
|
|
35
33
|
},
|
|
@@ -50,37 +48,37 @@
|
|
|
50
48
|
"semantic-release": "semantic-release"
|
|
51
49
|
},
|
|
52
50
|
"dependencies": {
|
|
53
|
-
"@nuxt/kit": "^
|
|
54
|
-
"defu": "^6.1.
|
|
55
|
-
"lodash-es": "^4.
|
|
51
|
+
"@nuxt/kit": "^4.6.4",
|
|
52
|
+
"defu": "^6.1.7",
|
|
53
|
+
"lodash-es": "^4.18.1"
|
|
56
54
|
},
|
|
57
55
|
"devDependencies": {
|
|
58
56
|
"@nuxt/devtools": "latest",
|
|
59
|
-
"@nuxt/eslint-config": "^0.3.
|
|
60
|
-
"@nuxt/module-builder": "^0.
|
|
61
|
-
"@nuxt/schema": "^
|
|
62
|
-
"@nuxt/test-utils": "^3.
|
|
57
|
+
"@nuxt/eslint-config": "^0.3.13",
|
|
58
|
+
"@nuxt/module-builder": "^1.0.4",
|
|
59
|
+
"@nuxt/schema": "^4.6.4",
|
|
60
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
63
61
|
"@semantic-release/changelog": "^7.0.0",
|
|
64
62
|
"@semantic-release/git": "^11.0.1",
|
|
65
|
-
"@semantic-release/github": "^12.0.
|
|
66
|
-
"@tailwindcss/forms": "^0.5.
|
|
67
|
-
"@types/lodash": "^4.17.
|
|
63
|
+
"@semantic-release/github": "^12.0.11",
|
|
64
|
+
"@tailwindcss/forms": "^0.5.11",
|
|
65
|
+
"@types/lodash": "^4.17.27",
|
|
68
66
|
"@types/lodash-es": "^4.17.12",
|
|
69
|
-
"@types/node": "^20.
|
|
70
|
-
"autoprefixer": "^10.
|
|
71
|
-
"changelogen": "^0.5.
|
|
72
|
-
"eslint": "^8.57.
|
|
73
|
-
"h3": "^1.11
|
|
74
|
-
"nuxt": "^
|
|
75
|
-
"playwright-core": "^1.
|
|
76
|
-
"postcss": "^8.
|
|
77
|
-
"semantic-release": "^25.0.
|
|
78
|
-
"tailwindcss": "^3.4.
|
|
79
|
-
"typescript": "^5.
|
|
80
|
-
"vitest": "^1.6.
|
|
81
|
-
"vue": "^3.5.
|
|
82
|
-
"vue-tsc": "^2.
|
|
83
|
-
"zod": "^4.
|
|
67
|
+
"@types/node": "^20.19.43",
|
|
68
|
+
"autoprefixer": "^10.7.0",
|
|
69
|
+
"changelogen": "^0.5.7",
|
|
70
|
+
"eslint": "^8.57.1",
|
|
71
|
+
"h3": "^1.15.11",
|
|
72
|
+
"nuxt": "^4.6.4",
|
|
73
|
+
"playwright-core": "^1.65.1",
|
|
74
|
+
"postcss": "^8.5.33",
|
|
75
|
+
"semantic-release": "^25.0.9",
|
|
76
|
+
"tailwindcss": "^3.4.19",
|
|
77
|
+
"typescript": "^5.9.3",
|
|
78
|
+
"vitest": "^1.6.1",
|
|
79
|
+
"vue": "^3.5.46",
|
|
80
|
+
"vue-tsc": "^2.2.12",
|
|
81
|
+
"zod": "^4.6.7"
|
|
84
82
|
},
|
|
85
|
-
"packageManager": "pnpm@
|
|
83
|
+
"packageManager": "pnpm@12.21.0"
|
|
86
84
|
}
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { Config } from '../dist/runtime/types/config.js';
|
|
3
|
-
|
|
4
|
-
interface ModuleOptions extends Config {
|
|
5
|
-
}
|
|
6
|
-
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
7
|
-
|
|
8
|
-
export { _default as default };
|
|
9
|
-
export type { ModuleOptions };
|
package/dist/types.d.ts
DELETED