From d4c1e851f2a3050a00d81540ea397bab1a3558f0 Mon Sep 17 00:00:00 2001 From: mrderyk Date: Thu, 11 Jul 2024 09:16:32 -0700 Subject: [PATCH] feat: Add v2 support for response headers. (#23) --- docs/package-lock.json | 2 +- package-lock.json | 4 ++-- src/apiV2/client.ts | 9 +++------ src/common/generateStream.ts | 1 + 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/package-lock.json b/docs/package-lock.json index 1142950..88e35e8 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -14,7 +14,7 @@ }, "..": { "name": "@vectara/stream-query-client", - "version": "2.1.0", + "version": "3.0.0", "license": "Apache-2.0", "devDependencies": { "@types/jest": "^29.5.11", diff --git a/package-lock.json b/package-lock.json index 0c2a9cc..aecf15c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vectara/stream-query-client", - "version": "2.1.0", + "version": "3.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@vectara/stream-query-client", - "version": "2.1.0", + "version": "3.0.0", "license": "Apache-2.0", "devDependencies": { "@types/jest": "^29.5.11", diff --git a/src/apiV2/client.ts b/src/apiV2/client.ts index 894a49c..f3cdc34 100644 --- a/src/apiV2/client.ts +++ b/src/apiV2/client.ts @@ -170,11 +170,8 @@ export const streamQueryV2 = async ({ }; try { - const { cancelStream, stream, status } = await generateStream( - headers, - JSON.stringify(body), - url - ); + const { cancelStream, stream, status, responseHeaders } = + await generateStream(headers, JSON.stringify(body), url); const consumeStream = async () => { try { @@ -211,7 +208,7 @@ export const streamQueryV2 = async ({ consumeStream(); - return { cancelStream, request, status }; + return { cancelStream, request, status, responseHeaders }; } catch (error) { if (error instanceof Error) { onStreamEvent({ diff --git a/src/common/generateStream.ts b/src/common/generateStream.ts index 8394e08..574ea0e 100644 --- a/src/common/generateStream.ts +++ b/src/common/generateStream.ts @@ -18,6 +18,7 @@ export const generateStream = async ( stream: getIterableStream(response.body), cancelStream: () => controller.abort(), status: response.status, + responseHeaders: response.headers, }; };