@temporary-name/standard-server-fetch 1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36 → 1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f

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/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@temporary-name/standard-server';
2
- import { SetSpanErrorOptions, AsyncIteratorClass } from '@temporary-name/shared';
1
+ import { SetSpanErrorOptions, AsyncIteratorClass, StandardBody, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@temporary-name/shared';
3
2
 
4
3
  interface ToEventIteratorOptions extends SetSpanErrorOptions {
5
4
  }
@@ -37,17 +36,6 @@ interface ToFetchBodyOptions extends ToEventStreamOptions {
37
36
  */
38
37
  declare function toFetchBody(body: StandardBody, headers: Headers, options?: ToFetchBodyOptions): string | Blob | FormData | URLSearchParams | undefined | ReadableStream<Uint8Array>;
39
38
 
40
- /**
41
- * @param headers
42
- * @param standardHeaders - The base headers can be changed by the function and effects on the original headers.
43
- */
44
- declare function toStandardHeaders(headers: Headers, standardHeaders?: StandardHeaders): StandardHeaders;
45
- /**
46
- * @param headers
47
- * @param fetchHeaders - The base headers can be changed by the function and effects on the original headers.
48
- */
49
- declare function toFetchHeaders(headers: StandardHeaders, fetchHeaders?: Headers): Headers;
50
-
51
39
  declare function toStandardLazyRequest(request: Request): StandardLazyRequest;
52
40
  interface ToFetchRequestOptions extends ToFetchBodyOptions {
53
41
  }
@@ -60,5 +48,5 @@ interface ToStandardLazyResponseOptions extends ToStandardBodyOptions {
60
48
  }
61
49
  declare function toStandardLazyResponse(response: Response, options?: ToStandardLazyResponseOptions): StandardLazyResponse;
62
50
 
63
- export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
51
+ export { toEventIterator, toEventStream, toFetchBody, toFetchRequest, toFetchResponse, toStandardBody, toStandardLazyRequest, toStandardLazyResponse };
64
52
  export type { ToEventIteratorOptions, ToEventStreamOptions, ToFetchBodyOptions, ToFetchRequestOptions, ToFetchResponseOptions, ToStandardBodyOptions, ToStandardLazyResponseOptions };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@temporary-name/standard-server';
2
- import { SetSpanErrorOptions, AsyncIteratorClass } from '@temporary-name/shared';
1
+ import { SetSpanErrorOptions, AsyncIteratorClass, StandardBody, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@temporary-name/shared';
3
2
 
4
3
  interface ToEventIteratorOptions extends SetSpanErrorOptions {
5
4
  }
@@ -37,17 +36,6 @@ interface ToFetchBodyOptions extends ToEventStreamOptions {
37
36
  */
38
37
  declare function toFetchBody(body: StandardBody, headers: Headers, options?: ToFetchBodyOptions): string | Blob | FormData | URLSearchParams | undefined | ReadableStream<Uint8Array>;
39
38
 
40
- /**
41
- * @param headers
42
- * @param standardHeaders - The base headers can be changed by the function and effects on the original headers.
43
- */
44
- declare function toStandardHeaders(headers: Headers, standardHeaders?: StandardHeaders): StandardHeaders;
45
- /**
46
- * @param headers
47
- * @param fetchHeaders - The base headers can be changed by the function and effects on the original headers.
48
- */
49
- declare function toFetchHeaders(headers: StandardHeaders, fetchHeaders?: Headers): Headers;
50
-
51
39
  declare function toStandardLazyRequest(request: Request): StandardLazyRequest;
52
40
  interface ToFetchRequestOptions extends ToFetchBodyOptions {
53
41
  }
@@ -60,5 +48,5 @@ interface ToStandardLazyResponseOptions extends ToStandardBodyOptions {
60
48
  }
61
49
  declare function toStandardLazyResponse(response: Response, options?: ToStandardLazyResponseOptions): StandardLazyResponse;
62
50
 
63
- export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
51
+ export { toEventIterator, toEventStream, toFetchBody, toFetchRequest, toFetchResponse, toStandardBody, toStandardLazyRequest, toStandardLazyResponse };
64
52
  export type { ToEventIteratorOptions, ToEventStreamOptions, ToFetchBodyOptions, ToFetchRequestOptions, ToFetchResponseOptions, ToStandardBodyOptions, ToStandardLazyResponseOptions };
package/dist/index.mjs CHANGED
@@ -192,6 +192,9 @@ function toStandardBody(re, options = {}) {
192
192
  });
193
193
  }
194
194
  function toFetchBody(body, headers, options = {}) {
195
+ if (!headers.get) {
196
+ console.log("AAAAAAAAAAAAAAA", headers);
197
+ }
195
198
  const currentContentDisposition = headers.get("content-disposition");
196
199
  headers.delete("content-type");
197
200
  headers.delete("content-disposition");
@@ -221,60 +224,27 @@ function toFetchBody(body, headers, options = {}) {
221
224
  return stringifyJSON(body);
222
225
  }
223
226
 
224
- function toStandardHeaders(headers, standardHeaders = {}) {
225
- headers.forEach((value, key) => {
226
- if (Array.isArray(standardHeaders[key])) {
227
- standardHeaders[key].push(value);
228
- } else if (standardHeaders[key] !== void 0) {
229
- standardHeaders[key] = [standardHeaders[key], value];
230
- } else {
231
- standardHeaders[key] = value;
232
- }
233
- });
234
- return standardHeaders;
235
- }
236
- function toFetchHeaders(headers, fetchHeaders = new Headers()) {
237
- for (const [key, value] of Object.entries(headers)) {
238
- if (Array.isArray(value)) {
239
- for (const v of value) {
240
- fetchHeaders.append(key, v);
241
- }
242
- } else if (value !== void 0) {
243
- fetchHeaders.append(key, value);
244
- }
245
- }
246
- return fetchHeaders;
247
- }
248
-
249
227
  function toStandardLazyRequest(request) {
250
228
  return {
251
229
  url: new URL(request.url),
252
230
  signal: request.signal,
253
231
  method: request.method,
254
232
  body: once(() => toStandardBody(request, { signal: request.signal })),
255
- get headers() {
256
- const headers = toStandardHeaders(request.headers);
257
- Object.defineProperty(this, "headers", { value: headers, writable: true });
258
- return headers;
259
- },
260
- set headers(value) {
261
- Object.defineProperty(this, "headers", { value, writable: true });
262
- }
233
+ headers: request.headers
263
234
  };
264
235
  }
265
236
  function toFetchRequest(request, options = {}) {
266
- const headers = toFetchHeaders(request.headers);
267
- const body = toFetchBody(request.body, headers, options);
237
+ const body = toFetchBody(request.body, request.headers, options);
268
238
  return new Request(request.url, {
269
239
  signal: request.signal,
270
240
  method: request.method,
271
- headers,
241
+ headers: request.headers,
272
242
  body
273
243
  });
274
244
  }
275
245
 
276
246
  function toFetchResponse(response, options = {}) {
277
- const headers = toFetchHeaders(response.headers);
247
+ const headers = response.headers;
278
248
  const body = toFetchBody(response.body, headers, options);
279
249
  return new Response(body, { headers, status: response.status });
280
250
  }
@@ -282,15 +252,8 @@ function toStandardLazyResponse(response, options = {}) {
282
252
  return {
283
253
  body: once(() => toStandardBody(response, options)),
284
254
  status: response.status,
285
- get headers() {
286
- const headers = toStandardHeaders(response.headers);
287
- Object.defineProperty(this, "headers", { value: headers, writable: true });
288
- return headers;
289
- },
290
- set headers(value) {
291
- Object.defineProperty(this, "headers", { value, writable: true });
292
- }
255
+ headers: response.headers
293
256
  };
294
257
  }
295
258
 
296
- export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
259
+ export { toEventIterator, toEventStream, toFetchBody, toFetchRequest, toFetchResponse, toStandardBody, toStandardLazyRequest, toStandardLazyResponse };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@temporary-name/standard-server-fetch",
3
3
  "type": "module",
4
- "version": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
4
+ "version": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.stainless.com/",
7
7
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@temporary-name/shared": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36",
27
- "@temporary-name/standard-server": "1.9.3-alpha.03f5d40e5b399f85012c2fb4e98167e26d551d36"
26
+ "@temporary-name/shared": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
27
+ "@temporary-name/standard-server": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@hono/node-server": "^1.19.5"