elysia 1.4.14 → 1.4.15
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/bun/index.js.map +2 -2
- package/dist/context.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export type ErrorContext<in out Route extends RouteSchema = {}, in out Singleton
|
|
|
53
53
|
store: Singleton['store'];
|
|
54
54
|
} & Singleton['decorator'] & Singleton['derive'] & Singleton['resolve']>;
|
|
55
55
|
type PrettifyIfObject<T> = T extends object ? Prettify<T> : T;
|
|
56
|
+
export type SelectiveStatus<Res> = <const Code extends keyof Res | InvertedStatusMap[Extract<InvertedStatusMapKey, keyof Res>]>(code: Code, response: Code extends keyof Res ? Res[Code] : Code extends keyof StatusMap ? Res[StatusMap[Code]] : never) => ElysiaCustomStatusResponse<Code, T>;
|
|
56
57
|
export type Context<in out Route extends RouteSchema = {}, in out Singleton extends SingletonBase = {
|
|
57
58
|
decorator: {};
|
|
58
59
|
store: {};
|
|
@@ -108,7 +109,7 @@ export type Context<in out Route extends RouteSchema = {}, in out Singleton exte
|
|
|
108
109
|
route: string;
|
|
109
110
|
request: Request;
|
|
110
111
|
store: Singleton['store'];
|
|
111
|
-
status: {} extends Route['response'] ? typeof status : <
|
|
112
|
+
status: {} extends Route['response'] ? typeof status : SelectiveStatus<Route['response']>;
|
|
112
113
|
} & Singleton['decorator'] & Singleton['derive'] & Omit<Singleton['resolve'], keyof InputSchema>>;
|
|
113
114
|
export type PreContext<in out Singleton extends SingletonBase = {
|
|
114
115
|
decorator: {};
|
package/dist/index.d.ts
CHANGED
|
@@ -2202,7 +2202,7 @@ export { t } from './type-system';
|
|
|
2202
2202
|
export { validationDetail, fileType } from './type-system/utils';
|
|
2203
2203
|
export type { ElysiaTypeCustomError, ElysiaTypeCustomErrorCallback } from './type-system/types';
|
|
2204
2204
|
export { serializeCookie, Cookie, type CookieOptions } from './cookies';
|
|
2205
|
-
export type { Context, PreContext, ErrorContext } from './context';
|
|
2205
|
+
export type { Context, PreContext, ErrorContext, SelectiveStatus } from './context';
|
|
2206
2206
|
export { ELYSIA_TRACE, type TraceEvent, type TraceListener, type TraceHandler, type TraceProcess, type TraceStream } from './trace';
|
|
2207
2207
|
export { getSchemaValidator, getResponseSchemaValidator, replaceSchemaType } from './schema';
|
|
2208
2208
|
export { mergeHook, mergeObjectArray, redirect, StatusMap, InvertedStatusMap, form, replaceUrlPath, checksum, cloneInference, deduplicateChecksum, ELYSIA_FORM_DATA, ELYSIA_REQUEST_ID, sse } from './utils';
|
package/dist/types.d.ts
CHANGED
|
@@ -990,7 +990,7 @@ export interface UnknownRouteSchema<Params = {
|
|
|
990
990
|
type Extract200<T> = T extends AnyElysiaCustomStatusResponse ? Exclude<T, AnyElysiaCustomStatusResponse> | Extract<T, ElysiaCustomStatusResponse<200, any, 200>>['response'] : T;
|
|
991
991
|
export type IsUnknown<T> = [unknown] extends [T] ? IsAny<T> extends true ? false : true : false;
|
|
992
992
|
export type ValueToResponseSchema<Value> = ExtractErrorFromHandle<Value> & (Extract200<Value> extends infer R200 ? undefined extends R200 ? {} : IsNever<R200> extends true ? {} : {
|
|
993
|
-
200:
|
|
993
|
+
200: R200;
|
|
994
994
|
} : {});
|
|
995
995
|
export type ValueOrFunctionToResponseSchema<T> = T extends (...a: any) => MaybePromise<infer R> ? ValueToResponseSchema<R> : ValueToResponseSchema<T>;
|
|
996
996
|
export type ElysiaHandlerToResponseSchema<in out Handle extends Function> = Prettify<Handle extends (...a: any) => MaybePromise<infer R> ? ValueToResponseSchema<Exclude<R, undefined>> : {}>;
|