@apifuse/provider-sdk 2.1.0-beta.8 → 2.1.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/bin/apifuse-perf.ts +18 -9
- package/dist/runtime/stealth.js +8 -1
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
- package/src/runtime/stealth.ts +8 -1
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# @apifuse/provider-sdk Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0-beta.9
|
|
4
|
+
|
|
5
|
+
- Preserve raw stealth response bytes through the public SDK response wrapper.
|
|
6
|
+
- Add `arrayBuffer()` and `bytes()` to `StealthResponse` so consumers can inspect binary-safe upstream bodies.
|
|
7
|
+
|
|
3
8
|
## 2.1.0-beta.8
|
|
4
9
|
|
|
5
10
|
- Fix release automation for compiled `dist` package exports by building before package self-tests.
|
package/bin/apifuse-perf.ts
CHANGED
|
@@ -755,15 +755,24 @@ function createFixtureResponse(raw: unknown) {
|
|
|
755
755
|
}
|
|
756
756
|
|
|
757
757
|
function createFixtureStealthClient(rawText: string): StealthClient {
|
|
758
|
-
const createResponse = async (): Promise<StealthResponse> =>
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
758
|
+
const createResponse = async (): Promise<StealthResponse> => {
|
|
759
|
+
const bodyBytes = new TextEncoder().encode(rawText);
|
|
760
|
+
return {
|
|
761
|
+
status: 200,
|
|
762
|
+
ok: true,
|
|
763
|
+
headers: { "content-type": "application/json" },
|
|
764
|
+
rawHeaders: [["content-type", "application/json"]],
|
|
765
|
+
body: rawText,
|
|
766
|
+
cookies: { get: () => undefined, getAll: () => ({}), toString: () => "" },
|
|
767
|
+
json: async <T>() => JSON.parse(rawText) as T,
|
|
768
|
+
arrayBuffer: async () =>
|
|
769
|
+
bodyBytes.buffer.slice(
|
|
770
|
+
bodyBytes.byteOffset,
|
|
771
|
+
bodyBytes.byteOffset + bodyBytes.byteLength,
|
|
772
|
+
) as ArrayBuffer,
|
|
773
|
+
bytes: async () => new Uint8Array(bodyBytes),
|
|
774
|
+
};
|
|
775
|
+
};
|
|
767
776
|
|
|
768
777
|
return {
|
|
769
778
|
fetch: async () => createResponse(),
|
package/dist/runtime/stealth.js
CHANGED
|
@@ -240,7 +240,8 @@ function splitCombinedSetCookieHeader(headerValue) {
|
|
|
240
240
|
export async function normalizeResponse(response) {
|
|
241
241
|
const headers = Object.fromEntries(response.headers.entries());
|
|
242
242
|
const cookies = new CookieJarImpl(setCookieHeadersFromResponse(response.headers));
|
|
243
|
-
const
|
|
243
|
+
const bodyBytes = await response.arrayBuffer();
|
|
244
|
+
const body = new TextDecoder().decode(bodyBytes);
|
|
244
245
|
return {
|
|
245
246
|
status: response.status,
|
|
246
247
|
ok: response.status >= 200 && response.status < 300,
|
|
@@ -251,6 +252,12 @@ export async function normalizeResponse(response) {
|
|
|
251
252
|
json() {
|
|
252
253
|
return Promise.resolve(JSON.parse(body));
|
|
253
254
|
},
|
|
255
|
+
arrayBuffer() {
|
|
256
|
+
return Promise.resolve(bodyBytes.slice(0));
|
|
257
|
+
},
|
|
258
|
+
bytes() {
|
|
259
|
+
return Promise.resolve(new Uint8Array(bodyBytes.slice(0)));
|
|
260
|
+
},
|
|
254
261
|
};
|
|
255
262
|
}
|
|
256
263
|
function normalizeBody(body) {
|
package/dist/types.d.ts
CHANGED
|
@@ -843,6 +843,8 @@ export interface DeclarativeStealthResponse {
|
|
|
843
843
|
};
|
|
844
844
|
cookies: CookieJar;
|
|
845
845
|
json<T>(): Promise<T>;
|
|
846
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
847
|
+
bytes(): Promise<Uint8Array>;
|
|
846
848
|
}
|
|
847
849
|
export type StealthResponse = DeclarativeStealthResponse;
|
|
848
850
|
export type RequestWithMethodOptions = RequestOptions & {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apifuse/provider-sdk",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "APIFuse Provider SDK
|
|
6
|
+
"description": "APIFuse Provider SDK — Build providers with zero architectural constraints",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
package/src/runtime/stealth.ts
CHANGED
|
@@ -340,7 +340,8 @@ export async function normalizeResponse(
|
|
|
340
340
|
const cookies = new CookieJarImpl(
|
|
341
341
|
setCookieHeadersFromResponse(response.headers),
|
|
342
342
|
);
|
|
343
|
-
const
|
|
343
|
+
const bodyBytes = await response.arrayBuffer();
|
|
344
|
+
const body = new TextDecoder().decode(bodyBytes);
|
|
344
345
|
|
|
345
346
|
return {
|
|
346
347
|
status: response.status,
|
|
@@ -352,6 +353,12 @@ export async function normalizeResponse(
|
|
|
352
353
|
json<T>(): Promise<T> {
|
|
353
354
|
return Promise.resolve(JSON.parse(body));
|
|
354
355
|
},
|
|
356
|
+
arrayBuffer(): Promise<ArrayBuffer> {
|
|
357
|
+
return Promise.resolve(bodyBytes.slice(0));
|
|
358
|
+
},
|
|
359
|
+
bytes(): Promise<Uint8Array> {
|
|
360
|
+
return Promise.resolve(new Uint8Array(bodyBytes.slice(0)));
|
|
361
|
+
},
|
|
355
362
|
};
|
|
356
363
|
}
|
|
357
364
|
|
package/src/types.ts
CHANGED
|
@@ -1015,6 +1015,8 @@ export interface DeclarativeStealthResponse {
|
|
|
1015
1015
|
tlsInfo?: { protocol?: string; cipher?: string; [key: string]: unknown };
|
|
1016
1016
|
cookies: CookieJar;
|
|
1017
1017
|
json<T>(): Promise<T>;
|
|
1018
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
1019
|
+
bytes(): Promise<Uint8Array>;
|
|
1018
1020
|
}
|
|
1019
1021
|
|
|
1020
1022
|
export type StealthResponse = DeclarativeStealthResponse;
|