From 2174b287c94c1a07a21dde1e7566ad26220a3621 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 1 Jul 2024 12:12:09 +0200 Subject: [PATCH 1/4] fix(hapi): Widen type definitions --- .../src/integrations/tracing/hapi/types.ts | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/packages/node/src/integrations/tracing/hapi/types.ts b/packages/node/src/integrations/tracing/hapi/types.ts index 4da83f672076..650b5df03bcc 100644 --- a/packages/node/src/integrations/tracing/hapi/types.ts +++ b/packages/node/src/integrations/tracing/hapi/types.ts @@ -232,16 +232,6 @@ interface ResponseToolkit { readonly continue: symbol; } -interface ServerEventCriteria { - 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[]; @@ -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 & { events: ServerEvents; - ext(event: ServerRequestExtType, method: Lifecycle.Method, options?: Record): void; + ext(event: any, method: Lifecycle.Method, options?: Record): void; initialize(): Promise; - register(plugins: Plugin | Array>, options?: Record): Promise; + register(plugins: Plugin, options?: Record): Promise; start(): Promise; }; From 42e84013b35da77dde035c5854b01136f449bb88 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 1 Jul 2024 12:59:39 +0200 Subject: [PATCH 2/4] change register type to any --- packages/node/src/integrations/tracing/hapi/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node/src/integrations/tracing/hapi/types.ts b/packages/node/src/integrations/tracing/hapi/types.ts index 650b5df03bcc..92e1123d50ca 100644 --- a/packages/node/src/integrations/tracing/hapi/types.ts +++ b/packages/node/src/integrations/tracing/hapi/types.ts @@ -246,9 +246,9 @@ interface ServerEvents { export type Server = Record & { events: ServerEvents; + register: any; ext(event: any, method: Lifecycle.Method, options?: Record): void; initialize(): Promise; - register(plugins: Plugin, options?: Record): Promise; start(): Promise; }; From 8787755472c11387402232fa124cfa17ac0c95ee Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 1 Jul 2024 13:11:24 +0200 Subject: [PATCH 3/4] delete unused types --- .../src/integrations/tracing/hapi/types.ts | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/packages/node/src/integrations/tracing/hapi/types.ts b/packages/node/src/integrations/tracing/hapi/types.ts index 92e1123d50ca..ef37ea2d63f5 100644 --- a/packages/node/src/integrations/tracing/hapi/types.ts +++ b/packages/node/src/integrations/tracing/hapi/types.ts @@ -103,38 +103,6 @@ export interface Listener { export type Tags = { [tag: string]: boolean }; -type Dependencies = - | string - | string[] - | { - [key: string]: string; - }; - -interface PluginNameVersion { - name: string; - version?: string | undefined; -} - -interface PluginPackage { - pkg: any; -} - -interface PluginBase { - register: (server: Server, options: T) => void | Promise; - multiple?: boolean | undefined; - dependencies?: Dependencies | undefined; - requirements?: - | { - node?: string | undefined; - hapi?: string | undefined; - } - | undefined; - - once?: boolean | undefined; -} - -type Plugin = PluginBase & (PluginNameVersion | PluginPackage); - interface UserCredentials {} interface AppCredentials {} From 4d6f79938b1e8edc77d4077f15e1dbf7de230591 Mon Sep 17 00:00:00 2001 From: s1gr1d Date: Mon, 1 Jul 2024 13:41:26 +0200 Subject: [PATCH 4/4] add types to function --- packages/node/src/integrations/tracing/hapi/index.ts | 4 ++-- packages/node/src/integrations/tracing/hapi/types.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/node/src/integrations/tracing/hapi/index.ts b/packages/node/src/integrations/tracing/hapi/index.ts index 2d951142275e..1303464c5374 100644 --- a/packages/node/src/integrations/tracing/hapi/index.ts +++ b/packages/node/src/integrations/tracing/hapi/index.ts @@ -15,7 +15,7 @@ import { logger } from '@sentry/utils'; import { DEBUG_BUILD } from '../../../debug-build'; import { generateInstrumentOnce } from '../../../otel/instrument'; import { ensureIsWrapped } from '../../../utils/ensureIsWrapped'; -import type { RequestEvent, Server } from './types'; +import type { Request, RequestEvent, Server } from './types'; const INTEGRATION_NAME = 'Hapi'; @@ -61,7 +61,7 @@ export const hapiErrorPlugin = { register: async function (serverArg: Record) { const server = serverArg as unknown as Server; - server.events.on('request', (request, event) => { + server.events.on('request', (request: Request, event: RequestEvent) => { if (getIsolationScope() !== getDefaultIsolationScope()) { const route = request.route; if (route && route.path) { diff --git a/packages/node/src/integrations/tracing/hapi/types.ts b/packages/node/src/integrations/tracing/hapi/types.ts index ef37ea2d63f5..db3404499148 100644 --- a/packages/node/src/integrations/tracing/hapi/types.ts +++ b/packages/node/src/integrations/tracing/hapi/types.ts @@ -173,7 +173,7 @@ interface RequestRoute { }; } -interface Request extends Podium { +export interface Request extends Podium { app: ApplicationState; readonly auth: RequestAuth; events: RequestEvents;