Skip to content

Commit 3d4a3e0

Browse files
authored
fix(hapi): Widen type definitions (#12710)
fixes #12703
1 parent de07108 commit 3d4a3e0

File tree

2 files changed

+6
-59
lines changed

2 files changed

+6
-59
lines changed

packages/node/src/integrations/tracing/hapi/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { logger } from '@sentry/utils';
1515
import { DEBUG_BUILD } from '../../../debug-build';
1616
import { generateInstrumentOnce } from '../../../otel/instrument';
1717
import { ensureIsWrapped } from '../../../utils/ensureIsWrapped';
18-
import type { RequestEvent, Server } from './types';
18+
import type { Request, RequestEvent, Server } from './types';
1919

2020
const INTEGRATION_NAME = 'Hapi';
2121

@@ -61,7 +61,7 @@ export const hapiErrorPlugin = {
6161
register: async function (serverArg: Record<any, any>) {
6262
const server = serverArg as unknown as Server;
6363

64-
server.events.on('request', (request, event) => {
64+
server.events.on('request', (request: Request, event: RequestEvent) => {
6565
if (getIsolationScope() !== getDefaultIsolationScope()) {
6666
const route = request.route;
6767
if (route && route.path) {

packages/node/src/integrations/tracing/hapi/types.ts

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -103,38 +103,6 @@ export interface Listener {
103103

104104
export type Tags = { [tag: string]: boolean };
105105

106-
type Dependencies =
107-
| string
108-
| string[]
109-
| {
110-
[key: string]: string;
111-
};
112-
113-
interface PluginNameVersion {
114-
name: string;
115-
version?: string | undefined;
116-
}
117-
118-
interface PluginPackage {
119-
pkg: any;
120-
}
121-
122-
interface PluginBase<T> {
123-
register: (server: Server, options: T) => void | Promise<void>;
124-
multiple?: boolean | undefined;
125-
dependencies?: Dependencies | undefined;
126-
requirements?:
127-
| {
128-
node?: string | undefined;
129-
hapi?: string | undefined;
130-
}
131-
| undefined;
132-
133-
once?: boolean | undefined;
134-
}
135-
136-
type Plugin<T> = PluginBase<T> & (PluginNameVersion | PluginPackage);
137-
138106
interface UserCredentials {}
139107

140108
interface AppCredentials {}
@@ -205,7 +173,7 @@ interface RequestRoute {
205173
};
206174
}
207175

208-
interface Request extends Podium {
176+
export interface Request extends Podium {
209177
app: ApplicationState;
210178
readonly auth: RequestAuth;
211179
events: RequestEvents;
@@ -232,16 +200,6 @@ interface ResponseToolkit {
232200
readonly continue: symbol;
233201
}
234202

235-
interface ServerEventCriteria<T> {
236-
name: T;
237-
channels?: string | string[] | undefined;
238-
clone?: boolean | undefined;
239-
count?: number | undefined;
240-
filter?: string | string[] | { tags: string | string[]; all?: boolean | undefined } | undefined;
241-
spread?: boolean | undefined;
242-
tags?: boolean | undefined;
243-
}
244-
245203
export interface RequestEvent {
246204
timestamp: string;
247205
tags: string[];
@@ -250,26 +208,15 @@ export interface RequestEvent {
250208
error: object;
251209
}
252210

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

258-
type RouteRequestExtType =
259-
| 'onPreAuth'
260-
| 'onCredentials'
261-
| 'onPostAuth'
262-
| 'onPreHandler'
263-
| 'onPostHandler'
264-
| 'onPreResponse';
265-
266-
type ServerRequestExtType = RouteRequestExtType | 'onRequest';
267-
268215
export type Server = Record<string, any> & {
269216
events: ServerEvents;
270-
ext(event: ServerRequestExtType, method: Lifecycle.Method, options?: Record<string, any>): void;
217+
register: any;
218+
ext(event: any, method: Lifecycle.Method, options?: Record<string, any>): void;
271219
initialize(): Promise<void>;
272-
register(plugins: Plugin<any> | Array<Plugin<any>>, options?: Record<string, any>): Promise<void>;
273220
start(): Promise<void>;
274221
};
275222

0 commit comments

Comments
 (0)