diff --git a/server/api/Login/LoginByID.ts b/server/api/Login/LoginByID.ts index 412769d..e43fc30 100644 --- a/server/api/Login/LoginByID.ts +++ b/server/api/Login/LoginByID.ts @@ -5,7 +5,7 @@ import { StartSession } from "../ProcDecorator/StartSession.js"; import { delay } from "../../util/delay.js"; import { declProcDecorators } from "../ProcDecorator/base.js"; import { z } from "zod"; -import { LoginCtx, loginCtxSessionKey } from "../ProcDecorator/ReqLogin.js"; +import { type LoginCtx, loginCtxSessionKey } from "../ProcDecorator/ReqLogin.js"; type BaseAPI = typeof structure.Login.LoginByID; type RType = ExtractResponse; diff --git a/server/api/Login/LoginByToken.ts b/server/api/Login/LoginByToken.ts index 3d82d9d..ea5443a 100644 --- a/server/api/Login/LoginByToken.ts +++ b/server/api/Login/LoginByToken.ts @@ -4,7 +4,7 @@ import type { ExtractError, ExtractQuery, ExtractResponse } from "../../apiStruc import { StartSession } from "../ProcDecorator/StartSession.js"; import { delay } from "../../util/delay.js"; import { declProcDecorators } from "../ProcDecorator/base.js"; -import { LoginCtx, loginCtxSessionKey } from "../ProcDecorator/ReqLogin.js"; +import { type LoginCtx, loginCtxSessionKey } from "../ProcDecorator/ReqLogin.js"; import { z } from "zod"; type BaseAPI = typeof structure.Login.LoginByToken; type RType = ExtractResponse; diff --git a/server/api/ProcDecorator/base.ts b/server/api/ProcDecorator/base.ts index 7fba3d5..3b0ab6f 100644 --- a/server/api/ProcDecorator/base.ts +++ b/server/api/ProcDecorator/base.ts @@ -16,7 +16,7 @@ export type DecoratorResultFalse = { export type DecoratorResult = DecoratorResultTrue | DecoratorResultFalse; export type DecoratorStack = DecoratorResult[]; -export interface ProcDecorator { +export interface ProcDecorator { (inCtx: In & Partial, req: Request, res: Response) : MayBePromise<[DecoratorResultTrue, Out] | [DecoratorResultFalse, In & Partial]>; } @@ -25,8 +25,8 @@ export interface PostProcDecorator { (ctx: T, preResult: DecoratorResult, req: Request, res: Response, isValidRoute: boolean): MayBePromise<[DecoratorResult, T]>; } -export interface ProcDecoratorRunner { - (inCtx: In & Partial, req: Request, res: Response): MayBePromise<[DecoratorStack, Out]>; +export interface ProcDecoratorRunner { + (inCtx: In, req: Request, res: Response): MayBePromise<[DecoratorStack, Out]>; } export interface PostProcDecoratorRunner { @@ -40,8 +40,8 @@ type PlainDecorator = ProcDecorator; type PlainPostDecorator = PostProcDecorator; -export type ProcDecoratorGenerator = ProcDecorator; -export type ProcDecoratorPrePostGenerator = [ProcDecorator, PostProcDecorator]; +export type ProcDecoratorGenerator = ProcDecorator; +export type ProcDecoratorPrePostGenerator = [ProcDecorator, PostProcDecorator]; export type ProcDecoratorChain = readonly ((() => PlainDecorator) | (() => [PlainDecorator, PlainPostDecorator]))[]; @@ -58,7 +58,7 @@ export const EmptyProcDecorator: readonly [ProcDecoratorRunner, Po ]; export function declProcDecorators(...decorators: T) { - type OutType = ParseOutType>; + type OutType = Resolve>; const preDecorator: PlainDecorator[] = []; const postDecorator: (PlainPostDecorator | undefined)[] = []; @@ -164,7 +164,7 @@ export function declProcDecorators(...decorators: return packedDecorators; } -type Compose2 = B extends C ? ProcDecorator : never; +type Compose2 = B extends C ? ProcDecorator : never; type PD1 = () => ProcDecorator; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -174,10 +174,10 @@ export type PackChain = T extends readonly [] ? ProcDecorator : T extends readonly [PD1] ? ProcDecorator : T extends readonly [PD2] ? ProcDecorator : - T extends readonly [PD1, PD1, ... infer R] ? PackChain<[() => Compose2, ...R]> : - T extends readonly [PD2, PD1, ... infer R] ? PackChain<[() => Compose2, ...R]> : - T extends readonly [PD1, PD2, ... infer R] ? PackChain<[() => Compose2, ...R]> : - T extends readonly [PD2, PD2, ... infer R] ? PackChain<[() => Compose2, ...R]> : + T extends readonly [PD1, PD1, ... infer R] ? PackChain<[() => Compose2, ...R]> : + T extends readonly [PD2, PD1, ... infer R] ? PackChain<[() => Compose2, ...R]> : + T extends readonly [PD1, PD2, ... infer R] ? PackChain<[() => Compose2, ...R]> : + T extends readonly [PD2, PD2, ... infer R] ? PackChain<[() => Compose2, ...R]> : never; type Resolve = T extends ProcDecorator ? Empty extends A ? B : never : never; \ No newline at end of file