From b020847fe0aa8e4aac47591a5811fd37be3ac045 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:28:35 +0000 Subject: [PATCH 1/2] Update dependency eventsource to v3 --- package.json | 2 +- yarn.lock | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d1411ff..a6c50fd 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "ajv": "8.17.1", "axios": "1.7.9", - "eventsource": "2.0.2", + "eventsource": "3.0.2", "fastify": "5.2.0", "ioredis": "5.4.1", "mock-socket": "9.3.1", diff --git a/yarn.lock b/yarn.lock index 89e216e..c869335 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1239,10 +1239,17 @@ esutils@^2.0.2, esutils@^2.0.3: resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -eventsource@2.0.2: - version "2.0.2" - resolved "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz" - integrity sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA== +eventsource-parser@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eventsource-parser/-/eventsource-parser-3.0.0.tgz#9303e303ef807d279ee210a17ce80f16300d9f57" + integrity sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA== + +eventsource@3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-3.0.2.tgz#31904faf2d9a9dbdc410f9599354186e7257b3f7" + integrity sha512-YolzkJNxsTL3tCJMWFxpxtG2sCjbZ4LQUBUrkdaJK0ub0p6lmJt+2+1SwhKjLc652lpH9L/79Ptez972H9tphw== + dependencies: + eventsource-parser "^3.0.0" fast-copy@^3.0.2: version "3.0.2" From b6966540f57a14ae2a8fc5d050d348181f99b140 Mon Sep 17 00:00:00 2001 From: Michael Xiao Date: Mon, 16 Dec 2024 14:45:28 -0500 Subject: [PATCH 2/2] Fix Build --- package.json | 1 - src/adapter/types.ts | 2 +- src/transports/sse.ts | 12 +++++++++--- tsconfig.json | 3 ++- yarn.lock | 5 ----- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index a6c50fd..4452de6 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ }, "devDependencies": { "@sinonjs/fake-timers": "14.0.0", - "@types/eventsource": "1.1.15", "@types/node": "22.10.2", "@types/sinonjs__fake-timers": "8.1.5", "@types/ws": "8.5.13", diff --git a/src/adapter/types.ts b/src/adapter/types.ts index ad2971d..1bde195 100644 --- a/src/adapter/types.ts +++ b/src/adapter/types.ts @@ -1,4 +1,4 @@ -import type EventSource from 'eventsource' +import { EventSource } from 'eventsource' import Redis from 'ioredis' import { Cache } from '../cache' import { AdapterConfig, BaseAdapterSettings, SettingsDefinitionMap } from '../config' diff --git a/src/transports/sse.ts b/src/transports/sse.ts index ffcea00..c8861ee 100644 --- a/src/transports/sse.ts +++ b/src/transports/sse.ts @@ -1,5 +1,5 @@ import { AxiosRequestConfig } from 'axios' -import EventSource from 'eventsource' +import { EventSource } from 'eventsource' import { EndpointContext } from '../adapter' import { calculateHttpRequestKey } from '../cache' import { makeLogger, sleep } from '../util' @@ -13,7 +13,7 @@ const logger = makeLogger('SSETransport') export interface SSEConfig { url: string - eventSourceInitDict?: EventSource.EventSourceInitDict + headers?: Record } /** @@ -103,7 +103,13 @@ export class SseTransport extends StreamingTrans logger.debug('No established connection and new subscriptions available, connecting to SSE') const sseConfig = this.config.prepareSSEConnectionConfig(subscriptions.new, context) this.providerDataStreamEstablished = Date.now() - this.sseConnection = new this.EventSource(sseConfig.url, sseConfig.eventSourceInitDict) + this.sseConnection = new this.EventSource(sseConfig.url, { + fetch: (input, init) => + fetch(input, { + ...init, + headers: { ...init?.headers, ...sseConfig.headers }, + }), + }) const eventHandlerGenerator = (listener: (typeof this.config.eventListeners)[0]) => { return (e: MessageEvent) => { diff --git a/tsconfig.json b/tsconfig.json index 53a4c04..958d757 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,7 +20,8 @@ "noImplicitThis": true, "noPropertyAccessFromIndexSignature": true, "noUnusedLocals": true, - "strict": true + "strict": true, + "skipLibCheck": true }, "exclude": ["src/**/test/**/*"], "include": ["./src/**/*"] diff --git a/yarn.lock b/yarn.lock index c869335..c8d8bb0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -326,11 +326,6 @@ resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz" integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== -"@types/eventsource@1.1.15": - version "1.1.15" - resolved "https://registry.npmjs.org/@types/eventsource/-/eventsource-1.1.15.tgz" - integrity sha512-XQmGcbnxUNa06HR3VBVkc9+A2Vpi9ZyLJcdS5dwaQQ/4ZMWFO+5c90FnMUpbtMZwB/FChoYHwuVg8TvkECacTA== - "@types/hast@^3.0.4": version "3.0.4" resolved "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz"