mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Fix type errors around backend routes
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f9843cc1cc
commit
6642aef44a
@ -10,9 +10,13 @@ import type { LensApiResultContentType } from "./router-content-types";
|
||||
import type { URLSearchParams } from "url";
|
||||
import type { SafeParseReturnType } from "zod";
|
||||
|
||||
declare const emptyObjectSymbol: unique symbol;
|
||||
|
||||
export interface EmptyObject {[emptyObjectSymbol]?: never}
|
||||
|
||||
export type InferParam<
|
||||
T extends string,
|
||||
PathParams extends Record<string, string>,
|
||||
PathParams,
|
||||
> =
|
||||
T extends `{${infer P}?}`
|
||||
? PathParams & Partial<Record<P, string>>
|
||||
@ -27,12 +31,14 @@ export type InferParamFromPath<P extends string> =
|
||||
: never
|
||||
: P extends `${infer A}/${infer B}`
|
||||
? InferParam<A, InferParamFromPath<B>>
|
||||
: InferParam<P, Record<string, never>>;
|
||||
: InferParam<P, EmptyObject>;
|
||||
|
||||
export interface LensApiRequest<Path extends string> {
|
||||
path: Path;
|
||||
payload: unknown;
|
||||
params: InferParamFromPath<Path>;
|
||||
params: string extends Path
|
||||
? Partial<Record<string, string>>
|
||||
: InferParamFromPath<Path>;
|
||||
cluster: Cluster | undefined;
|
||||
query: URLSearchParams;
|
||||
raw: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user