diff --git a/apps/meteor/app/api/server/ApiClass.ts b/apps/meteor/app/api/server/ApiClass.ts index 5b0db7ea772ae..02e88f4cfb64e 100644 --- a/apps/meteor/app/api/server/ApiClass.ts +++ b/apps/meteor/app/api/server/ApiClass.ts @@ -66,8 +66,13 @@ export type Prettify = { type ExtractValidation = T extends ValidateFunction ? TSchema : never; -export type ExtractRoutesFromAPI = - T extends APIClass ? (TOperations extends MinimalRoute ? Prettify> : never) : never; +type UnionToIntersection = (U extends any ? (x: U) => any : never) extends (x: infer I) => any ? I : never; + +export type ExtractRoutesFromAPI = Prettify< + UnionToIntersection< + T extends APIClass ? (TOperations extends MinimalRoute ? Prettify> : never) : never + > +>; type ConvertToRoute = { [K in TRoute['path']]: { @@ -578,7 +583,7 @@ export class APIClass< TSubPathPattern extends string, TOptions extends TypedOptions, TPathPattern extends `${TBasePath}/${TSubPathPattern}`, - >(method: Method, subpath: TSubPathPattern, options: TOptions): void { + >(method: MinimalRoute['method'], subpath: TSubPathPattern, options: TOptions): void { const path = `/${this.apiPath}/${subpath}`.replaceAll('//', '/') as TPathPattern; this.typedRoutes = this.typedRoutes || {}; this.typedRoutes[path] = this.typedRoutes[subpath] || {}; @@ -629,7 +634,7 @@ export class APIClass< } private method( - method: Method, + method: MinimalRoute['method'], subpath: TSubPathPattern, options: TOptions, action: TypedAction, diff --git a/apps/meteor/app/api/server/definition.ts b/apps/meteor/app/api/server/definition.ts index e35fdae582c1c..b394c5b94428c 100644 --- a/apps/meteor/app/api/server/definition.ts +++ b/apps/meteor/app/api/server/definition.ts @@ -88,7 +88,7 @@ export type NonEnterpriseTwoFactorOptions = { twoFactorOptions: ITwoFactorOptions; }; -export type Options = SharedOptions; +export type Options = SharedOptions<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'>; export type SharedOptions = ( | {