@entro314labs/entro-auth-i18n 1.8.0-beta.12 → 1.8.0-beta.13
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/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +50 -2
- package/dist/index.mjs +2 -2
- package/dist/locales/index.d.mts +53 -0
- package/dist/locales/index.mjs +1 -1
- package/dist/{locales-Iv9XtRWv.mjs → locales-DhYAH4AC.mjs} +1 -1
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/dist/{version-Dd71U9WY.mjs → version-3zqnORqW.mjs} +1 -1
- package/package.json +6 -6
- package/dist/index-BbkL5cRv.d.mts +0 -451
- package/dist/rolldown-runtime-D8jQpDG7.mjs +0 -12
package/dist/client.d.mts
CHANGED
package/dist/client.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
import { t as i18n } from "./index-BbkL5cRv.mjs";
|
|
2
1
|
import { D as TranslationDictionary, E as LocaleDetectionStrategy, T as I18nOptions, t as index_d_exports } from "./index-BiQztJ6b.mjs";
|
|
3
|
-
|
|
2
|
+
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
3
|
+
declare module "@entro314labs/entro-auth-core" {
|
|
4
|
+
interface EntroAuthPluginRegistry<AuthOptions, Options> {
|
|
5
|
+
i18n: {
|
|
6
|
+
creator: typeof i18n;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* i18n plugin for Entro Auth
|
|
12
|
+
*
|
|
13
|
+
* Translates error messages based on detected locale.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { entroAuth } from "@entro314labs/entro-auth";
|
|
18
|
+
* import { i18n } from "@entro314labs/entro-auth-i18n";
|
|
19
|
+
*
|
|
20
|
+
* export const auth = entroAuth({
|
|
21
|
+
* plugins: [
|
|
22
|
+
* i18n({
|
|
23
|
+
* translations: {
|
|
24
|
+
* en: { USER_NOT_FOUND: "User not found" },
|
|
25
|
+
* fr: { USER_NOT_FOUND: "Utilisateur non trouvé" },
|
|
26
|
+
* },
|
|
27
|
+
* detection: ["header", "cookie"],
|
|
28
|
+
* }),
|
|
29
|
+
* ],
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const i18n: <Locales extends string[]>(options: I18nOptions<Locales>) => {
|
|
34
|
+
id: "i18n";
|
|
35
|
+
version: string;
|
|
36
|
+
hooks: {
|
|
37
|
+
after: {
|
|
38
|
+
matcher: () => true;
|
|
39
|
+
handler: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>>;
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
options: {
|
|
43
|
+
translations: { [Locale in Locales[number]]: TranslationDictionary; };
|
|
44
|
+
defaultLocale: Locales[number];
|
|
45
|
+
detection: LocaleDetectionStrategy[];
|
|
46
|
+
localeCookie: string;
|
|
47
|
+
userLocaleField: string;
|
|
48
|
+
getLocale?: ((ctx: GenericEndpointContext) => Locales[number] | Promise<Locales[number] | null> | null) | undefined;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export { type I18nOptions, type LocaleDetectionStrategy, type TranslationDictionary, index_d_exports as locales };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-Dd71U9WY.mjs";
|
|
2
|
-
import { t as locales_exports } from "./locales-Iv9XtRWv.mjs";
|
|
3
1
|
import { APIError, createAuthMiddleware, isAPIError } from "@entro314labs/entro-auth/api";
|
|
4
2
|
import { parseCookies } from "@entro314labs/entro-auth/cookies";
|
|
3
|
+
import { t as PACKAGE_VERSION } from "./version-3zqnORqW.mjs";
|
|
4
|
+
import { t as locales_exports } from "./locales-DhYAH4AC.mjs";
|
|
5
5
|
// src/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Parse Accept-Language header and return locales sorted by quality
|
package/dist/locales/index.d.mts
CHANGED
|
@@ -1,2 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in default translations for the i18n plugin.
|
|
3
|
+
*
|
|
4
|
+
* Each locale exports a {@link TranslationDictionary} covering the core
|
|
5
|
+
* Entro Auth error codes. Additional locales can be added by following the
|
|
6
|
+
* same pattern.
|
|
7
|
+
*
|
|
8
|
+
* @example Basic usage — enable all built-in locales
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { i18n, locales } from "@entro314labs/entro-auth-i18n";
|
|
11
|
+
*
|
|
12
|
+
* export const auth = entroAuth({
|
|
13
|
+
* plugins: [
|
|
14
|
+
* i18n({ translations: locales }),
|
|
15
|
+
* ],
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example Selective usage — only a subset of locales
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { i18n, locales } from "@entro314labs/entro-auth-i18n";
|
|
22
|
+
*
|
|
23
|
+
* export const auth = entroAuth({
|
|
24
|
+
* plugins: [
|
|
25
|
+
* i18n({
|
|
26
|
+
* translations: {
|
|
27
|
+
* en: locales.en,
|
|
28
|
+
* fr: locales.fr,
|
|
29
|
+
* },
|
|
30
|
+
* }),
|
|
31
|
+
* ],
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Override specific messages for a locale
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { i18n, locales } from "@entro314labs/entro-auth-i18n";
|
|
38
|
+
*
|
|
39
|
+
* export const auth = entroAuth({
|
|
40
|
+
* plugins: [
|
|
41
|
+
* i18n({
|
|
42
|
+
* translations: {
|
|
43
|
+
* ...locales,
|
|
44
|
+
* fr: {
|
|
45
|
+
* ...locales.fr,
|
|
46
|
+
* USER_NOT_FOUND: "Membre introuvable",
|
|
47
|
+
* },
|
|
48
|
+
* },
|
|
49
|
+
* }),
|
|
50
|
+
* ],
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
1
54
|
import { C as bn, S as de, _ as fr, a as tr, b as en, c as ru, d as nl, f as ko, g as hi, h as id, i as uk, l as pt, m as it, n as zh, o as th, p as ja, r as vi, s as sv, u as pl, v as fa, w as ar, x as el, y as es } from "../index-BiQztJ6b.mjs";
|
|
2
55
|
export { ar, bn, de, el, en, es, fa, fr, hi, id, it, ja, ko, nl, pl, pt, ru, sv, th, tr, uk, vi, zh };
|
package/dist/locales/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { w as ar, C as bn, S as de, x as el, b as en, y as es, v as fa, _ as fr, g as hi, h as id, m as it, p as ja, f as ko, d as nl, u as pl, l as pt, c as ru, s as sv, o as th, a as tr, i as uk, r as vi, n as zh } from "../locales-
|
|
1
|
+
export { w as ar, C as bn, S as de, x as el, b as en, y as es, v as fa, _ as fr, g as hi, h as id, m as it, p as ja, f as ko, d as nl, u as pl, l as pt, c as ru, s as sv, o as th, a as tr, i as uk, r as vi, n as zh } from "../locales-DhYAH4AC.mjs";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, flags) => {
|
|
4
|
+
let target = Object.setPrototypeOf({}, null);
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
11
|
+
};
|
|
12
|
+
export { __exportAll as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entro314labs/entro-auth-i18n",
|
|
3
|
-
"version": "1.8.0-beta.
|
|
3
|
+
"version": "1.8.0-beta.13",
|
|
4
4
|
"description": "i18n plugin for Entro Auth - translate error messages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@entro314labs/entro-auth-core": "1.8.0-beta.
|
|
62
|
-
"@entro314labs/entro-auth": "1.8.0-beta.
|
|
63
|
-
"tsdown": "0.23.
|
|
61
|
+
"@entro314labs/entro-auth-core": "1.8.0-beta.13",
|
|
62
|
+
"@entro314labs/entro-auth": "1.8.0-beta.13",
|
|
63
|
+
"tsdown": "0.23.7"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@entro314labs/entro-auth-core": "^1.8.0-beta.
|
|
67
|
-
"@entro314labs/entro-auth": "^1.8.0-beta.
|
|
66
|
+
"@entro314labs/entro-auth-core": "^1.8.0-beta.13",
|
|
67
|
+
"@entro314labs/entro-auth": "^1.8.0-beta.13"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsdown",
|
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
import { D as TranslationDictionary, E as LocaleDetectionStrategy, T as I18nOptions } from "./index-BiQztJ6b.mjs";
|
|
2
|
-
import { GenericEndpointContext } from "@entro314labs/entro-auth-core";
|
|
3
|
-
/** The Standard Schema interface. */
|
|
4
|
-
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
5
|
-
/** The Standard Schema properties. */
|
|
6
|
-
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
7
|
-
}
|
|
8
|
-
declare namespace StandardSchemaV1 {
|
|
9
|
-
/** The Standard Schema properties interface. */
|
|
10
|
-
interface Props<Input = unknown, Output = Input> {
|
|
11
|
-
/** The version number of the standard. */
|
|
12
|
-
readonly version: 1;
|
|
13
|
-
/** The vendor name of the schema library. */
|
|
14
|
-
readonly vendor: string;
|
|
15
|
-
/** Validates unknown input values. */
|
|
16
|
-
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
17
|
-
/** Inferred types associated with the schema. */
|
|
18
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
19
|
-
}
|
|
20
|
-
/** The result interface of the validate function. */
|
|
21
|
-
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
22
|
-
/** The result interface if validation succeeds. */
|
|
23
|
-
interface SuccessResult<Output> {
|
|
24
|
-
/** The typed output value. */
|
|
25
|
-
readonly value: Output;
|
|
26
|
-
/** The non-existent issues. */
|
|
27
|
-
readonly issues?: undefined;
|
|
28
|
-
}
|
|
29
|
-
/** The result interface if validation fails. */
|
|
30
|
-
interface FailureResult {
|
|
31
|
-
/** The issues of failed validation. */
|
|
32
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
33
|
-
}
|
|
34
|
-
/** The issue interface of the failure output. */
|
|
35
|
-
interface Issue {
|
|
36
|
-
/** The error message of the issue. */
|
|
37
|
-
readonly message: string;
|
|
38
|
-
/** The path of the issue, if any. */
|
|
39
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
40
|
-
}
|
|
41
|
-
/** The path segment interface of the issue. */
|
|
42
|
-
interface PathSegment {
|
|
43
|
-
/** The key representing a path segment. */
|
|
44
|
-
readonly key: PropertyKey;
|
|
45
|
-
}
|
|
46
|
-
/** The Standard Schema types interface. */
|
|
47
|
-
interface Types<Input = unknown, Output = Input> {
|
|
48
|
-
/** The input type of the schema. */
|
|
49
|
-
readonly input: Input;
|
|
50
|
-
/** The output type of the schema. */
|
|
51
|
-
readonly output: Output;
|
|
52
|
-
}
|
|
53
|
-
/** Infers the input type of a Standard Schema. */
|
|
54
|
-
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
55
|
-
/** Infers the output type of a Standard Schema. */
|
|
56
|
-
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
57
|
-
}
|
|
58
|
-
declare const statusCodes: {
|
|
59
|
-
OK: number;
|
|
60
|
-
CREATED: number;
|
|
61
|
-
ACCEPTED: number;
|
|
62
|
-
NO_CONTENT: number;
|
|
63
|
-
MULTIPLE_CHOICES: number;
|
|
64
|
-
MOVED_PERMANENTLY: number;
|
|
65
|
-
FOUND: number;
|
|
66
|
-
SEE_OTHER: number;
|
|
67
|
-
NOT_MODIFIED: number;
|
|
68
|
-
TEMPORARY_REDIRECT: number;
|
|
69
|
-
BAD_REQUEST: number;
|
|
70
|
-
UNAUTHORIZED: number;
|
|
71
|
-
PAYMENT_REQUIRED: number;
|
|
72
|
-
FORBIDDEN: number;
|
|
73
|
-
NOT_FOUND: number;
|
|
74
|
-
METHOD_NOT_ALLOWED: number;
|
|
75
|
-
NOT_ACCEPTABLE: number;
|
|
76
|
-
PROXY_AUTHENTICATION_REQUIRED: number;
|
|
77
|
-
REQUEST_TIMEOUT: number;
|
|
78
|
-
CONFLICT: number;
|
|
79
|
-
GONE: number;
|
|
80
|
-
LENGTH_REQUIRED: number;
|
|
81
|
-
PRECONDITION_FAILED: number;
|
|
82
|
-
PAYLOAD_TOO_LARGE: number;
|
|
83
|
-
URI_TOO_LONG: number;
|
|
84
|
-
UNSUPPORTED_MEDIA_TYPE: number;
|
|
85
|
-
RANGE_NOT_SATISFIABLE: number;
|
|
86
|
-
EXPECTATION_FAILED: number;
|
|
87
|
-
"I'M_A_TEAPOT": number;
|
|
88
|
-
MISDIRECTED_REQUEST: number;
|
|
89
|
-
UNPROCESSABLE_ENTITY: number;
|
|
90
|
-
LOCKED: number;
|
|
91
|
-
FAILED_DEPENDENCY: number;
|
|
92
|
-
TOO_EARLY: number;
|
|
93
|
-
UPGRADE_REQUIRED: number;
|
|
94
|
-
PRECONDITION_REQUIRED: number;
|
|
95
|
-
TOO_MANY_REQUESTS: number;
|
|
96
|
-
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
|
|
97
|
-
UNAVAILABLE_FOR_LEGAL_REASONS: number;
|
|
98
|
-
INTERNAL_SERVER_ERROR: number;
|
|
99
|
-
NOT_IMPLEMENTED: number;
|
|
100
|
-
BAD_GATEWAY: number;
|
|
101
|
-
SERVICE_UNAVAILABLE: number;
|
|
102
|
-
GATEWAY_TIMEOUT: number;
|
|
103
|
-
HTTP_VERSION_NOT_SUPPORTED: number;
|
|
104
|
-
VARIANT_ALSO_NEGOTIATES: number;
|
|
105
|
-
INSUFFICIENT_STORAGE: number;
|
|
106
|
-
LOOP_DETECTED: number;
|
|
107
|
-
NOT_EXTENDED: number;
|
|
108
|
-
NETWORK_AUTHENTICATION_REQUIRED: number;
|
|
109
|
-
};
|
|
110
|
-
type Status = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
111
|
-
declare class InternalAPIError extends Error {
|
|
112
|
-
status: keyof typeof statusCodes | Status;
|
|
113
|
-
body: ({
|
|
114
|
-
message?: string;
|
|
115
|
-
code?: string;
|
|
116
|
-
cause?: unknown;
|
|
117
|
-
} & Record<string, any>) | undefined;
|
|
118
|
-
headers: HeadersInit;
|
|
119
|
-
statusCode: number;
|
|
120
|
-
constructor(status?: keyof typeof statusCodes | Status, body?: ({
|
|
121
|
-
message?: string;
|
|
122
|
-
code?: string;
|
|
123
|
-
cause?: unknown;
|
|
124
|
-
} & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
|
|
125
|
-
}
|
|
126
|
-
type APIError = InstanceType<typeof InternalAPIError>;
|
|
127
|
-
declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED" | undefined, body?: ({
|
|
128
|
-
message?: string;
|
|
129
|
-
code?: string;
|
|
130
|
-
cause?: unknown;
|
|
131
|
-
} & Record<string, any>) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
|
|
132
|
-
errorStack: string | undefined;
|
|
133
|
-
};
|
|
134
|
-
interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {}
|
|
135
|
-
type MiddlewareInputContext<Options extends MiddlewareOptions> = InferBodyInput<Options> & InferQueryInput<Options> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
136
|
-
asResponse?: boolean;
|
|
137
|
-
returnHeaders?: boolean;
|
|
138
|
-
use?: MiddlewareHandler[];
|
|
139
|
-
};
|
|
140
|
-
type MiddlewareFunction = (...args: never[]) => Promise<unknown>;
|
|
141
|
-
type MiddlewareHandler = (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<unknown>;
|
|
142
|
-
type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler extends MiddlewareFunction = MiddlewareHandler> = Handler & {
|
|
143
|
-
options: Options;
|
|
144
|
-
};
|
|
145
|
-
type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
|
|
146
|
-
interface OpenAPIParameter {
|
|
147
|
-
in: "query" | "path" | "header" | "cookie";
|
|
148
|
-
name?: string | undefined;
|
|
149
|
-
description?: string | undefined;
|
|
150
|
-
required?: boolean | undefined;
|
|
151
|
-
schema?: {
|
|
152
|
-
type: OpenAPISchemaType;
|
|
153
|
-
format?: string | undefined;
|
|
154
|
-
items?: {
|
|
155
|
-
type: OpenAPISchemaType;
|
|
156
|
-
} | undefined;
|
|
157
|
-
enum?: string[] | undefined;
|
|
158
|
-
minLength?: number | undefined;
|
|
159
|
-
description?: string | undefined;
|
|
160
|
-
default?: string | undefined;
|
|
161
|
-
example?: string | undefined;
|
|
162
|
-
} | undefined;
|
|
163
|
-
}
|
|
164
|
-
interface EndpointBaseOptions {
|
|
165
|
-
/**
|
|
166
|
-
* Query Schema
|
|
167
|
-
*/
|
|
168
|
-
query?: StandardSchemaV1;
|
|
169
|
-
/**
|
|
170
|
-
* Error Schema
|
|
171
|
-
*/
|
|
172
|
-
error?: StandardSchemaV1;
|
|
173
|
-
/**
|
|
174
|
-
* If true headers will be required to be passed in the context
|
|
175
|
-
*/
|
|
176
|
-
requireHeaders?: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* If true request object will be required
|
|
179
|
-
*/
|
|
180
|
-
requireRequest?: boolean;
|
|
181
|
-
/**
|
|
182
|
-
* Clone the request object from the router
|
|
183
|
-
*/
|
|
184
|
-
cloneRequest?: boolean;
|
|
185
|
-
/**
|
|
186
|
-
* If true the body will be undefined
|
|
187
|
-
*/
|
|
188
|
-
disableBody?: boolean;
|
|
189
|
-
/**
|
|
190
|
-
* Endpoint metadata
|
|
191
|
-
*/
|
|
192
|
-
metadata?: {
|
|
193
|
-
/**
|
|
194
|
-
* Open API definition
|
|
195
|
-
*/
|
|
196
|
-
openapi?: {
|
|
197
|
-
summary?: string | undefined;
|
|
198
|
-
description?: string | undefined;
|
|
199
|
-
tags?: string[] | undefined;
|
|
200
|
-
operationId?: string | undefined;
|
|
201
|
-
parameters?: OpenAPIParameter[] | undefined;
|
|
202
|
-
requestBody?: {
|
|
203
|
-
content: {
|
|
204
|
-
"application/json": {
|
|
205
|
-
schema: {
|
|
206
|
-
type?: OpenAPISchemaType | undefined;
|
|
207
|
-
properties?: Record<string, any> | undefined;
|
|
208
|
-
required?: string[] | undefined;
|
|
209
|
-
$ref?: string | undefined;
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
} | undefined;
|
|
214
|
-
responses?: {
|
|
215
|
-
[status: string]: {
|
|
216
|
-
description: string;
|
|
217
|
-
content?: {
|
|
218
|
-
"application/json"?: {
|
|
219
|
-
schema: {
|
|
220
|
-
type?: OpenAPISchemaType | undefined;
|
|
221
|
-
properties?: Record<string, any> | undefined;
|
|
222
|
-
required?: string[] | undefined;
|
|
223
|
-
$ref?: string | undefined;
|
|
224
|
-
};
|
|
225
|
-
} | undefined;
|
|
226
|
-
"text/plain"?: {
|
|
227
|
-
schema?: {
|
|
228
|
-
type?: OpenAPISchemaType | undefined;
|
|
229
|
-
properties?: Record<string, any> | undefined;
|
|
230
|
-
required?: string[] | undefined;
|
|
231
|
-
$ref?: string | undefined;
|
|
232
|
-
} | undefined;
|
|
233
|
-
} | undefined;
|
|
234
|
-
"text/html"?: {
|
|
235
|
-
schema?: {
|
|
236
|
-
type?: OpenAPISchemaType | undefined;
|
|
237
|
-
properties?: Record<string, any> | undefined;
|
|
238
|
-
required?: string[] | undefined;
|
|
239
|
-
$ref?: string | undefined;
|
|
240
|
-
} | undefined;
|
|
241
|
-
} | undefined;
|
|
242
|
-
} | undefined;
|
|
243
|
-
};
|
|
244
|
-
} | undefined;
|
|
245
|
-
} | undefined;
|
|
246
|
-
/**
|
|
247
|
-
* Infer body and query type from ts interface
|
|
248
|
-
*
|
|
249
|
-
* useful for generic and dynamic types
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* ```ts
|
|
253
|
-
* const endpoint = createEndpoint("/path", {
|
|
254
|
-
* method: "POST",
|
|
255
|
-
* body: z.record(z.string()),
|
|
256
|
-
* $Infer: {
|
|
257
|
-
* body: {} as {
|
|
258
|
-
* type: InferTypeFromOptions<Option> // custom type inference
|
|
259
|
-
* }
|
|
260
|
-
* }
|
|
261
|
-
* }, async(ctx)=>{
|
|
262
|
-
* const body = ctx.body
|
|
263
|
-
* })
|
|
264
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
$Infer?: {
|
|
267
|
-
/**
|
|
268
|
-
* Body
|
|
269
|
-
*/
|
|
270
|
-
body?: any;
|
|
271
|
-
/**
|
|
272
|
-
* Query
|
|
273
|
-
*/
|
|
274
|
-
query?: Record<string, any>;
|
|
275
|
-
};
|
|
276
|
-
/**
|
|
277
|
-
* If enabled, endpoint won't be exposed over a router
|
|
278
|
-
* @deprecated Use path-less endpoints instead
|
|
279
|
-
*/
|
|
280
|
-
SERVER_ONLY?: boolean;
|
|
281
|
-
/**
|
|
282
|
-
* If enabled, endpoint won't be exposed as an action to the client
|
|
283
|
-
* @deprecated Use path-less endpoints instead
|
|
284
|
-
*/
|
|
285
|
-
isAction?: boolean;
|
|
286
|
-
/**
|
|
287
|
-
* Defines the places where the endpoint will be available
|
|
288
|
-
*
|
|
289
|
-
* Possible options:
|
|
290
|
-
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
|
|
291
|
-
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
|
|
292
|
-
* - `http` - the endpoint is only exposed to the router
|
|
293
|
-
* @default "rpc"
|
|
294
|
-
*/
|
|
295
|
-
scope?: "rpc" | "server" | "http";
|
|
296
|
-
/**
|
|
297
|
-
* List of allowed media types (MIME types) for the endpoint
|
|
298
|
-
*
|
|
299
|
-
* if provided, only the media types in the list will be allowed to be passed in the body
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* ```ts
|
|
303
|
-
* const endpoint = createEndpoint("/path", {
|
|
304
|
-
* method: "POST",
|
|
305
|
-
* allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
|
|
306
|
-
* }, async(ctx)=>{
|
|
307
|
-
* const body = ctx.body
|
|
308
|
-
* })
|
|
309
|
-
* ```
|
|
310
|
-
*/
|
|
311
|
-
allowedMediaTypes?: string[];
|
|
312
|
-
/**
|
|
313
|
-
* Extra metadata
|
|
314
|
-
*/
|
|
315
|
-
[key: string]: any;
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* List of middlewares to use
|
|
319
|
-
*/
|
|
320
|
-
use?: MiddlewareHandler[] | undefined;
|
|
321
|
-
/**
|
|
322
|
-
* A callback to run before any API error is throw or returned
|
|
323
|
-
*
|
|
324
|
-
* @param e - The API error
|
|
325
|
-
* @returns - The response to return
|
|
326
|
-
*/
|
|
327
|
-
onAPIError?: (e: APIError) => void | Promise<void>;
|
|
328
|
-
/**
|
|
329
|
-
* A callback to run before a validation error is thrown
|
|
330
|
-
* You can customize the validation error message by throwing your own APIError
|
|
331
|
-
*/
|
|
332
|
-
onValidationError?: ({ issues, message }: {
|
|
333
|
-
message: string;
|
|
334
|
-
issues: readonly StandardSchemaV1.Issue[];
|
|
335
|
-
}) => void | Promise<void>;
|
|
336
|
-
}
|
|
337
|
-
type EndpointBodyMethodOptions = {
|
|
338
|
-
/**
|
|
339
|
-
* Request Method
|
|
340
|
-
*/
|
|
341
|
-
method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
|
|
342
|
-
/**
|
|
343
|
-
* Body Schema
|
|
344
|
-
*/
|
|
345
|
-
body?: StandardSchemaV1;
|
|
346
|
-
} | {
|
|
347
|
-
/**
|
|
348
|
-
* Request Method
|
|
349
|
-
*/
|
|
350
|
-
method: "GET" | "HEAD" | ("GET" | "HEAD")[];
|
|
351
|
-
/**
|
|
352
|
-
* Body Schema
|
|
353
|
-
*/
|
|
354
|
-
body?: never;
|
|
355
|
-
} | {
|
|
356
|
-
/**
|
|
357
|
-
* Request Method
|
|
358
|
-
*/
|
|
359
|
-
method: "*";
|
|
360
|
-
/**
|
|
361
|
-
* Body Schema
|
|
362
|
-
*/
|
|
363
|
-
body?: StandardSchemaV1;
|
|
364
|
-
} | {
|
|
365
|
-
/**
|
|
366
|
-
* Request Method
|
|
367
|
-
*/
|
|
368
|
-
method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
|
|
369
|
-
/**
|
|
370
|
-
* Body Schema
|
|
371
|
-
*/
|
|
372
|
-
body?: StandardSchemaV1;
|
|
373
|
-
};
|
|
374
|
-
type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
|
|
375
|
-
type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions, Body = Options["metadata"] extends {
|
|
376
|
-
$Infer: {
|
|
377
|
-
body: infer B;
|
|
378
|
-
};
|
|
379
|
-
} ? B : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["body"]> : undefined> = undefined extends Body ? {
|
|
380
|
-
body?: Body;
|
|
381
|
-
} : {
|
|
382
|
-
body: Body;
|
|
383
|
-
};
|
|
384
|
-
type InferQueryInput<Options extends EndpointOptions | MiddlewareOptions, Query = Options["metadata"] extends {
|
|
385
|
-
$Infer: {
|
|
386
|
-
query: infer Query;
|
|
387
|
-
};
|
|
388
|
-
} ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> = undefined extends Query ? {
|
|
389
|
-
query?: Query;
|
|
390
|
-
} : {
|
|
391
|
-
query: Query;
|
|
392
|
-
};
|
|
393
|
-
type InferRequestInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? {
|
|
394
|
-
request: Request;
|
|
395
|
-
} : {
|
|
396
|
-
request?: Request | undefined;
|
|
397
|
-
};
|
|
398
|
-
type InferHeadersInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? {
|
|
399
|
-
headers: HeadersInit;
|
|
400
|
-
} : {
|
|
401
|
-
headers?: HeadersInit | undefined;
|
|
402
|
-
};
|
|
403
|
-
declare module "@entro314labs/entro-auth-core" {
|
|
404
|
-
interface EntroAuthPluginRegistry<AuthOptions, Options> {
|
|
405
|
-
i18n: {
|
|
406
|
-
creator: typeof i18n;
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* i18n plugin for Entro Auth
|
|
412
|
-
*
|
|
413
|
-
* Translates error messages based on detected locale.
|
|
414
|
-
*
|
|
415
|
-
* @example
|
|
416
|
-
* ```ts
|
|
417
|
-
* import { entroAuth } from "@entro314labs/entro-auth";
|
|
418
|
-
* import { i18n } from "@entro314labs/entro-auth-i18n";
|
|
419
|
-
*
|
|
420
|
-
* export const auth = entroAuth({
|
|
421
|
-
* plugins: [
|
|
422
|
-
* i18n({
|
|
423
|
-
* translations: {
|
|
424
|
-
* en: { USER_NOT_FOUND: "User not found" },
|
|
425
|
-
* fr: { USER_NOT_FOUND: "Utilisateur non trouvé" },
|
|
426
|
-
* },
|
|
427
|
-
* detection: ["header", "cookie"],
|
|
428
|
-
* }),
|
|
429
|
-
* ],
|
|
430
|
-
* });
|
|
431
|
-
* ```
|
|
432
|
-
*/
|
|
433
|
-
declare const i18n: <Locales extends string[]>(options: I18nOptions<Locales>) => {
|
|
434
|
-
id: "i18n";
|
|
435
|
-
version: string;
|
|
436
|
-
hooks: {
|
|
437
|
-
after: {
|
|
438
|
-
matcher: () => true;
|
|
439
|
-
handler: Middleware<MiddlewareOptions, (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<void>>;
|
|
440
|
-
}[];
|
|
441
|
-
};
|
|
442
|
-
options: {
|
|
443
|
-
translations: { [Locale in Locales[number]]: TranslationDictionary; };
|
|
444
|
-
defaultLocale: Locales[number];
|
|
445
|
-
detection: LocaleDetectionStrategy[];
|
|
446
|
-
localeCookie: string;
|
|
447
|
-
userLocaleField: string;
|
|
448
|
-
getLocale?: ((ctx: GenericEndpointContext) => Locales[number] | Promise<Locales[number] | null> | null) | undefined;
|
|
449
|
-
};
|
|
450
|
-
};
|
|
451
|
-
export { i18n as t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __exportAll = (all, no_symbols) => {
|
|
4
|
-
let target = {};
|
|
5
|
-
for (var name in all) __defProp(target, name, {
|
|
6
|
-
get: all[name],
|
|
7
|
-
enumerable: true
|
|
8
|
-
});
|
|
9
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
-
return target;
|
|
11
|
-
};
|
|
12
|
-
export { __exportAll as t };
|