Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hapi): Widen type definitions #12710

Merged
merged 7 commits into from
Jul 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions packages/node/src/integrations/tracing/hapi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,6 @@ interface ResponseToolkit {
readonly continue: symbol;
}

interface ServerEventCriteria<T> {
name: T;
channels?: string | string[] | undefined;
clone?: boolean | undefined;
count?: number | undefined;
filter?: string | string[] | { tags: string | string[]; all?: boolean | undefined } | undefined;
spread?: boolean | undefined;
tags?: boolean | undefined;
}

export interface RequestEvent {
timestamp: string;
tags: string[];
Expand All @@ -250,26 +240,15 @@ export interface RequestEvent {
error: object;
}

type RequestEventHandler = (request: Request, event: RequestEvent, tags: { [key: string]: true }) => void;
interface ServerEvents {
on(criteria: 'request' | ServerEventCriteria<'request'>, listener: RequestEventHandler): void;
on(criteria: any, listener: any): void;
}

type RouteRequestExtType =
| 'onPreAuth'
| 'onCredentials'
| 'onPostAuth'
| 'onPreHandler'
| 'onPostHandler'
| 'onPreResponse';

type ServerRequestExtType = RouteRequestExtType | 'onRequest';

export type Server = Record<string, any> & {
events: ServerEvents;
ext(event: ServerRequestExtType, method: Lifecycle.Method, options?: Record<string, any>): void;
ext(event: any, method: Lifecycle.Method, options?: Record<string, any>): void;
initialize(): Promise<void>;
register(plugins: Plugin<any> | Array<Plugin<any>>, options?: Record<string, any>): Promise<void>;
register(plugins: Plugin<any>, options?: Record<string, any>): Promise<void>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, is this not tightening the types? used to accept a plugin or an array of plugins, not we only accept a single plugin?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw we cannot do this anyway as hapi has 5 different method overwrites and no union type. I am going to change this to any as well!

start(): Promise<void>;
};

Expand Down
Loading