@hyper-fetch/core 10.2.0 → 10.4.0

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.
Files changed (50) hide show
  1. package/__tests__/features/adapter/adapter.bindings.spec.ts +27 -27
  2. package/__tests__/features/cache/cache.base.spec.ts +4 -4
  3. package/__tests__/features/cache/cache.events.spec.ts +4 -4
  4. package/__tests__/features/cache/cache.garbage-collector.spec.ts +2 -2
  5. package/__tests__/features/cache/cache.lazy-storage.spec.ts +2 -2
  6. package/__tests__/features/cache/cache.modes.spec.ts +2 -2
  7. package/__tests__/features/cache/cache.scoped-events.spec.ts +2 -2
  8. package/__tests__/features/cache/cache.scoping.spec.ts +2 -2
  9. package/__tests__/features/cache/cache.semantics.spec.ts +6 -1
  10. package/__tests__/features/cache/cache.typescript.spec.ts +2 -2
  11. package/__tests__/features/cache/cache.utils.spec.ts +9 -9
  12. package/__tests__/features/client/client.hydration.round-trip.spec.ts +2 -2
  13. package/__tests__/features/client/client.hydration.spec.ts +3 -3
  14. package/__tests__/features/client/client.interceptor.spec.ts +7 -7
  15. package/__tests__/features/client/client.interceptors.pipeline.spec.ts +3 -3
  16. package/__tests__/features/client/client.set-url.spec.ts +2 -2
  17. package/__tests__/features/dispatcher/dispatcher.events.spec.ts +2 -2
  18. package/__tests__/features/dispatcher/dispatcher.retry-event.spec.ts +406 -0
  19. package/__tests__/features/http-adapter/http-adapter.extra.spec.ts +21 -0
  20. package/__tests__/features/request/request.sending.spec.ts +7 -7
  21. package/__tests__/utils/callbacks.utils.ts +2 -2
  22. package/__tests__/utils/fixtures.utils.ts +4 -4
  23. package/dist/dispatcher/dispatcher.d.ts.map +1 -1
  24. package/dist/http-adapter/http-adapter.constants.d.ts +8 -0
  25. package/dist/http-adapter/http-adapter.constants.d.ts.map +1 -1
  26. package/dist/index.mjs +52 -4
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/managers/request/request.manager.d.ts +4 -0
  29. package/dist/managers/request/request.manager.d.ts.map +1 -1
  30. package/dist/managers/request/request.manager.events.d.ts +10 -2
  31. package/dist/managers/request/request.manager.events.d.ts.map +1 -1
  32. package/dist/managers/request/request.manager.types.d.ts +10 -0
  33. package/dist/managers/request/request.manager.types.d.ts.map +1 -1
  34. package/dist/managers/request/request.manager.utils.d.ts +3 -0
  35. package/dist/managers/request/request.manager.utils.d.ts.map +1 -1
  36. package/dist/request/request.hooks.d.ts +4 -2
  37. package/dist/request/request.hooks.d.ts.map +1 -1
  38. package/dist/request/request.types.d.ts +8 -2
  39. package/dist/request/request.types.d.ts.map +1 -1
  40. package/dist/request/request.utils.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/dispatcher/dispatcher.ts +11 -0
  43. package/src/http-adapter/http-adapter.constants.ts +10 -1
  44. package/src/http-adapter/http-adapter.fetch.ts +2 -2
  45. package/src/managers/request/request.manager.events.ts +37 -1
  46. package/src/managers/request/request.manager.types.ts +11 -0
  47. package/src/managers/request/request.manager.utils.ts +3 -0
  48. package/src/request/request.hooks.ts +12 -1
  49. package/src/request/request.types.ts +13 -2
  50. package/src/request/request.utils.ts +8 -0
@@ -3,7 +3,7 @@ import { waitFor } from "@testing-library/dom";
3
3
  import type { AdapterInstance, ResponseType } from "adapter";
4
4
  import { getErrorMessage } from "adapter";
5
5
  import { Client } from "client";
6
- import { xhrExtra } from "http-adapter";
6
+ import { httpExtra } from "http-adapter";
7
7
  import type { ResponseDetailsType } from "managers";
8
8
 
9
9
  import { createDispatcher, createAdapter } from "../../utils";
@@ -223,7 +223,7 @@ describe("Dispatcher [ Events ]", () => {
223
223
  error: getErrorMessage("abort"),
224
224
  status: 0,
225
225
  success: false,
226
- extra: xhrExtra,
226
+ extra: httpExtra,
227
227
  requestTimestamp: expect.toBeNumber(),
228
228
  responseTimestamp: expect.toBeNumber(),
229
229
  };
@@ -0,0 +1,406 @@
1
+ import { Client } from "client";
2
+ import type { RequestRetryEventType } from "managers";
3
+ import type { RequestInstance } from "request";
4
+
5
+ import { getThrownErrors } from "../../utils/fixtures.utils";
6
+
7
+ describe("Dispatcher [ Retry event ]", () => {
8
+ const createResponse = (status: number) => ({
9
+ data: status < 400 ? { ok: true } : null,
10
+ error: status < 400 ? null : new Error("Request failed"),
11
+ status,
12
+ success: status < 400,
13
+ extra: {},
14
+ requestTimestamp: Date.now(),
15
+ responseTimestamp: Date.now(),
16
+ });
17
+
18
+ let client = new Client({ url: "shared-base-url" });
19
+ let statuses: number[] = [];
20
+ let fetchSpy = vi.spyOn(client.adapter, "fetch");
21
+
22
+ /** The retry numbers and delays of the received events */
23
+ const summarize = (spy: ReturnType<typeof vi.fn>) =>
24
+ spy.mock.calls.map((args) => {
25
+ const event = args[0] as RequestRetryEventType<RequestInstance>;
26
+ return [event.retry, event.delay];
27
+ });
28
+
29
+ beforeEach(() => {
30
+ vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "Date"] });
31
+ client = new Client({ url: "shared-base-url" });
32
+ // Every attempt answers with the next status, the last one repeats
33
+ statuses = [500];
34
+ let attempt = 0;
35
+ fetchSpy = vi
36
+ .spyOn(client.adapter, "fetch")
37
+ .mockImplementation((async () => {
38
+ const status = statuses[Math.min(attempt, statuses.length - 1)];
39
+ attempt += 1;
40
+ return createResponse(status);
41
+ }) as never);
42
+ });
43
+
44
+ afterEach(() => {
45
+ vi.useRealTimers();
46
+ vi.restoreAllMocks();
47
+ });
48
+
49
+ describe("When a failed attempt schedules a retry", () => {
50
+ it("should emit the retry number and its delay for every scheduled retry", async () => {
51
+ const request = client.createRequest()({
52
+ endpoint: "/retry",
53
+ retry: 3,
54
+ retryTime: ({ attempt }) => (attempt + 1) * 100,
55
+ });
56
+ const onRetry = vi.fn();
57
+ client.requestManager.events.onRetry(onRetry);
58
+
59
+ request.send();
60
+ await vi.advanceTimersByTimeAsync(1000);
61
+
62
+ expect(fetchSpy).toHaveBeenCalledTimes(4);
63
+ expect(summarize(onRetry)).toStrictEqual([
64
+ [1, 100],
65
+ [2, 200],
66
+ [3, 300],
67
+ ]);
68
+ });
69
+
70
+ it("should give the failed response and its details", async () => {
71
+ const request = client.createRequest()({
72
+ endpoint: "/retry",
73
+ retry: 1,
74
+ retryTime: 0,
75
+ });
76
+ const onRetry = vi.fn();
77
+ client.requestManager.events.onRetry(onRetry);
78
+
79
+ request.send();
80
+ await vi.advanceTimersByTimeAsync(0);
81
+
82
+ expect(onRetry).toHaveBeenCalledExactlyOnceWith(
83
+ expect.objectContaining({
84
+ request: expect.objectContaining({ queryKey: request.queryKey }),
85
+ requestId: expect.any(String),
86
+ response: expect.objectContaining({ status: 500, success: false }),
87
+ details: expect.objectContaining({ retries: 0, willRetry: true }),
88
+ retry: 1,
89
+ delay: 0,
90
+ }),
91
+ );
92
+ });
93
+
94
+ it("should emit after the response of the failed attempt and before the next attempt", async () => {
95
+ const order: string[] = [];
96
+ const request = client.createRequest()({
97
+ endpoint: "/retry",
98
+ retry: 1,
99
+ retryTime: 100,
100
+ });
101
+ client.requestManager.events.onResponse(() => order.push("response"));
102
+ client.requestManager.events.onRetry(() => order.push("retry"));
103
+ client.requestManager.events.onRequestStart(() => order.push("start"));
104
+ fetchSpy.mockImplementation((async (
105
+ req: RequestInstance,
106
+ requestId: string,
107
+ ) => {
108
+ client.requestManager.events.emitRequestStart({
109
+ request: req,
110
+ requestId,
111
+ });
112
+ return createResponse(500);
113
+ }) as never);
114
+
115
+ request.send();
116
+ await vi.advanceTimersByTimeAsync(0);
117
+ expect(order).toStrictEqual(["start", "response", "retry"]);
118
+
119
+ await vi.advanceTimersByTimeAsync(100);
120
+ expect(order).toStrictEqual([
121
+ "start",
122
+ "response",
123
+ "retry",
124
+ "start",
125
+ "response",
126
+ ]);
127
+ });
128
+
129
+ it("should emit to the listeners of the request id and of the queue", async () => {
130
+ const request = client.createRequest()({
131
+ endpoint: "/retry",
132
+ retry: 1,
133
+ retryTime: 0,
134
+ });
135
+ const onRetryById = vi.fn();
136
+ const onRetryByQueue = vi.fn();
137
+ client.requestManager.events.onRetryByQueue(
138
+ request.queryKey,
139
+ onRetryByQueue,
140
+ );
141
+
142
+ const requestId = client.fetchDispatcher.add(request);
143
+ client.requestManager.events.onRetryById(requestId, onRetryById);
144
+ await vi.advanceTimersByTimeAsync(0);
145
+
146
+ expect(onRetryById).toHaveBeenCalledExactlyOnceWith(
147
+ expect.objectContaining({ requestId, retry: 1 }),
148
+ );
149
+ expect(onRetryByQueue).toHaveBeenCalledExactlyOnceWith(
150
+ expect.objectContaining({ requestId, retry: 1 }),
151
+ );
152
+ });
153
+
154
+ it("should stop calling a listener once it is removed", async () => {
155
+ const request = client.createRequest()({
156
+ endpoint: "/retry",
157
+ retry: 2,
158
+ retryTime: 100,
159
+ });
160
+ const onRetry = vi.fn();
161
+ const unmount = client.requestManager.events.onRetry(onRetry);
162
+
163
+ request.send();
164
+ await vi.advanceTimersByTimeAsync(0);
165
+ unmount();
166
+ await vi.advanceTimersByTimeAsync(1000);
167
+
168
+ expect(fetchSpy).toHaveBeenCalledTimes(3);
169
+ expect(onRetry).toHaveBeenCalledOnce();
170
+ });
171
+
172
+ it("should still retry and rethrow the error outside of the lifecycle when a listener throws", async () => {
173
+ // The thrown errors are reported from a real timer
174
+ vi.useRealTimers();
175
+ const request = client.createRequest()({
176
+ endpoint: "/retry",
177
+ retry: 1,
178
+ retryTime: 0,
179
+ });
180
+ const listenerError = new Error("Broken listener");
181
+ client.requestManager.events.onRetry(() => {
182
+ throw listenerError;
183
+ });
184
+ let response: unknown;
185
+
186
+ const errors = await getThrownErrors(async () => {
187
+ response = await request.send();
188
+ });
189
+
190
+ expect(errors).toStrictEqual([listenerError]);
191
+ expect(fetchSpy).toHaveBeenCalledTimes(2);
192
+ expect(response).toStrictEqual(
193
+ expect.objectContaining({ status: 500, success: false }),
194
+ );
195
+ });
196
+ });
197
+
198
+ describe("When listening on the request", () => {
199
+ it("should call the onRetry option of send for every retry of this request only", async () => {
200
+ const request = client.createRequest()({
201
+ endpoint: "/retry",
202
+ retry: 2,
203
+ retryTime: 50,
204
+ });
205
+ const otherRequest = client.createRequest()({
206
+ endpoint: "/other",
207
+ retry: 2,
208
+ retryTime: 50,
209
+ });
210
+ const onRetry = vi.fn();
211
+ const onResponse = vi.fn();
212
+
213
+ request.send({ onRetry, onResponse });
214
+ otherRequest.send();
215
+ await vi.advanceTimersByTimeAsync(1000);
216
+
217
+ expect(fetchSpy).toHaveBeenCalledTimes(6);
218
+ expect(summarize(onRetry)).toStrictEqual([
219
+ [1, 50],
220
+ [2, 50],
221
+ ]);
222
+ // The failed attempts which are retried do not answer send - only the last one does
223
+ expect(onResponse).toHaveBeenCalledOnce();
224
+ });
225
+
226
+ it("should call the onRetry hook of the request", async () => {
227
+ const request = client.createRequest()({
228
+ endpoint: "/retry",
229
+ retry: 1,
230
+ retryTime: 0,
231
+ });
232
+ const onRetry = vi.fn();
233
+ const unmount = request.$hooks.onRetry(onRetry);
234
+
235
+ request.send();
236
+ await vi.advanceTimersByTimeAsync(0);
237
+ unmount();
238
+ request.send();
239
+ await vi.advanceTimersByTimeAsync(0);
240
+
241
+ expect(fetchSpy).toHaveBeenCalledTimes(4);
242
+ expect(summarize(onRetry)).toStrictEqual([[1, 0]]);
243
+ });
244
+
245
+ it("should give the mutation context of the optimistic update", async () => {
246
+ const request = client
247
+ .createRequest<{ response: { ok: boolean } }>()({
248
+ endpoint: "/retry",
249
+ method: "POST",
250
+ retry: 1,
251
+ retryTime: 0,
252
+ })
253
+ .setOptimistic(() => ({ context: { previous: 1 } }));
254
+ const onRetry = vi.fn();
255
+
256
+ request.send({ onRetry });
257
+ await vi.advanceTimersByTimeAsync(0);
258
+
259
+ expect(onRetry).toHaveBeenCalledExactlyOnceWith(
260
+ expect.objectContaining({
261
+ retry: 1,
262
+ mutationContext: expect.objectContaining({
263
+ context: { previous: 1 },
264
+ }),
265
+ }),
266
+ );
267
+ });
268
+
269
+ it("should type the event of the request", () => {
270
+ const request = client.createRequest<{
271
+ response: { ok: boolean };
272
+ error: { message: string };
273
+ }>()({
274
+ endpoint: "/retry",
275
+ });
276
+
277
+ // The hooks of a request are shared by its clones - they are typed for any request
278
+ request.$hooks.onRetry((event) => {
279
+ expectTypeOf(event).toEqualTypeOf<
280
+ RequestRetryEventType<RequestInstance>
281
+ >();
282
+ });
283
+ request.send({
284
+ onRetry: (event) => {
285
+ expectTypeOf(event).toEqualTypeOf<
286
+ RequestRetryEventType<typeof request>
287
+ >();
288
+ expectTypeOf(event.retry).toEqualTypeOf<number>();
289
+ expectTypeOf(event.delay).toEqualTypeOf<number>();
290
+ expectTypeOf(event.response.error).toEqualTypeOf<
291
+ { message: string } | Error | null
292
+ >();
293
+ },
294
+ });
295
+ });
296
+ });
297
+
298
+ describe("When no retry is scheduled", () => {
299
+ it("should not emit when the request succeeds", async () => {
300
+ statuses = [200];
301
+ const request = client.createRequest()({
302
+ endpoint: "/retry",
303
+ retry: 3,
304
+ retryTime: 0,
305
+ });
306
+ const onRetry = vi.fn();
307
+ client.requestManager.events.onRetry(onRetry);
308
+
309
+ await request.send();
310
+
311
+ expect(onRetry).not.toHaveBeenCalled();
312
+ });
313
+
314
+ it("should not emit once a retry succeeds", async () => {
315
+ statuses = [500, 200];
316
+ const request = client.createRequest()({
317
+ endpoint: "/retry",
318
+ retry: 3,
319
+ retryTime: 0,
320
+ });
321
+ const onRetry = vi.fn();
322
+ client.requestManager.events.onRetry(onRetry);
323
+
324
+ request.send();
325
+ await vi.advanceTimersByTimeAsync(0);
326
+
327
+ expect(fetchSpy).toHaveBeenCalledTimes(2);
328
+ expect(summarize(onRetry)).toStrictEqual([[1, 0]]);
329
+ });
330
+
331
+ it("should not emit when the request has no retries", async () => {
332
+ const request = client.createRequest()({ endpoint: "/retry", retry: 0 });
333
+ const onRetry = vi.fn();
334
+ client.requestManager.events.onRetry(onRetry);
335
+
336
+ await request.send();
337
+
338
+ expect(onRetry).not.toHaveBeenCalled();
339
+ });
340
+
341
+ it("should not emit when retryOnError rejects the response", async () => {
342
+ const request = client
343
+ .createRequest()({ endpoint: "/retry", retry: 3, retryTime: 0 })
344
+ .setRetryOnError(() => false);
345
+ const onRetry = vi.fn();
346
+ client.requestManager.events.onRetry(onRetry);
347
+
348
+ await request.send();
349
+
350
+ expect(onRetry).not.toHaveBeenCalled();
351
+ });
352
+
353
+ it("should not emit when the retryTime function throws", async () => {
354
+ const request = client.createRequest()({
355
+ endpoint: "/retry",
356
+ retry: 3,
357
+ retryTime: () => {
358
+ throw new Error("Broken delay");
359
+ },
360
+ });
361
+ const onRetry = vi.fn();
362
+ client.requestManager.events.onRetry(onRetry);
363
+
364
+ await request.send();
365
+
366
+ expect(onRetry).not.toHaveBeenCalled();
367
+ });
368
+
369
+ it("should not emit when the request is aborted", async () => {
370
+ const request = client.createRequest()({
371
+ endpoint: "/retry",
372
+ retry: 3,
373
+ retryTime: 0,
374
+ });
375
+ const onRetry = vi.fn();
376
+ client.requestManager.events.onRetry(onRetry);
377
+ fetchSpy.mockImplementation((async () => {
378
+ request.abort();
379
+ return createResponse(500);
380
+ }) as never);
381
+
382
+ await request.send();
383
+
384
+ expect(onRetry).not.toHaveBeenCalled();
385
+ });
386
+
387
+ it("should not emit when the request fails offline", async () => {
388
+ const request = client.createRequest()({
389
+ endpoint: "/retry",
390
+ retry: 3,
391
+ retryTime: 0,
392
+ offline: false,
393
+ });
394
+ const onRetry = vi.fn();
395
+ client.requestManager.events.onRetry(onRetry);
396
+ fetchSpy.mockImplementation((async () => {
397
+ client.appManager.setOnline(false);
398
+ return createResponse(500);
399
+ }) as never);
400
+
401
+ await request.send();
402
+
403
+ expect(onRetry).not.toHaveBeenCalled();
404
+ });
405
+ });
406
+ });
@@ -0,0 +1,21 @@
1
+ import type { HttpAdapterExtraType } from "http-adapter";
2
+ import { HttpAdapter, httpExtra, xhrExtra } from "http-adapter";
3
+
4
+ describe("HttpAdapter [ Extra ]", () => {
5
+ it("should start with empty response headers", () => {
6
+ expect(httpExtra).toStrictEqual({ headers: {} });
7
+ expectTypeOf(httpExtra).toEqualTypeOf<HttpAdapterExtraType>();
8
+ });
9
+
10
+ it("should use httpExtra as the default and system error extra", () => {
11
+ const adapter = HttpAdapter();
12
+
13
+ expect(adapter.defaultExtra).toBe(httpExtra);
14
+ expect(adapter.systemErrorExtra).toBe(httpExtra);
15
+ });
16
+
17
+ it("should keep xhrExtra as an alias of httpExtra", () => {
18
+ expect(xhrExtra).toBe(httpExtra);
19
+ expectTypeOf(xhrExtra).toEqualTypeOf<HttpAdapterExtraType>();
20
+ });
21
+ });
@@ -2,7 +2,7 @@ import { createHttpMockingServer, sleep } from "@hyper-fetch/testing";
2
2
  import { waitFor } from "@testing-library/dom";
3
3
  import { getErrorMessage } from "adapter";
4
4
  import { Client } from "client";
5
- import { xhrExtra } from "http-adapter";
5
+ import { httpExtra } from "http-adapter";
6
6
 
7
7
  const { resetMocks, startServer, stopServer, mockRequest } = createHttpMockingServer();
8
8
 
@@ -187,7 +187,7 @@ describe("Request [ Sending ]", () => {
187
187
  error: getErrorMessage("deleted"),
188
188
  status: null,
189
189
  success: false,
190
- extra: xhrExtra,
190
+ extra: httpExtra,
191
191
  });
192
192
  });
193
193
  it("should call remove error", async () => {
@@ -221,14 +221,14 @@ describe("Request [ Sending ]", () => {
221
221
  error: getErrorMessage("abort"),
222
222
  status: 0,
223
223
  success: false,
224
- extra: xhrExtra,
224
+ extra: httpExtra,
225
225
  });
226
226
  expect(res2).toStrictEqual({
227
227
  data: null,
228
228
  error: getErrorMessage("abort"),
229
229
  status: 0,
230
230
  success: false,
231
- extra: xhrExtra,
231
+ extra: httpExtra,
232
232
  });
233
233
  expect(res3).toStrictEqual({
234
234
  data: mock,
@@ -261,14 +261,14 @@ describe("Request [ Sending ]", () => {
261
261
  error: getErrorMessage("abort"),
262
262
  status: 0,
263
263
  success: false,
264
- extra: xhrExtra,
264
+ extra: httpExtra,
265
265
  });
266
266
  expect(res2).toStrictEqual({
267
267
  data: null,
268
268
  error: getErrorMessage("abort"),
269
269
  status: 0,
270
270
  success: false,
271
- extra: xhrExtra,
271
+ extra: httpExtra,
272
272
  });
273
273
  expect(res3).toStrictEqual({
274
274
  data: mock,
@@ -322,7 +322,7 @@ describe("Request [ Sending ]", () => {
322
322
  error: null,
323
323
  status: 200,
324
324
  success: true,
325
- extra: xhrExtra,
325
+ extra: httpExtra,
326
326
  });
327
327
  expect(fetchSpy).not.toHaveBeenCalled();
328
328
  });
@@ -2,7 +2,7 @@ import { sleep } from "@hyper-fetch/testing";
2
2
  import type { ResponseType } from "adapter";
3
3
  import type { ClientInstance, ResponseInterceptorType } from "client";
4
4
  import type { HttpAdapterType } from "http-adapter";
5
- import { xhrExtra } from "http-adapter";
5
+ import { httpExtra } from "http-adapter";
6
6
  import type { RequestInstance } from "request";
7
7
 
8
8
  export const interceptorCallback = (props?: {
@@ -25,7 +25,7 @@ export const interceptorCallback = (props?: {
25
25
  error: null,
26
26
  success: true,
27
27
  status: 200,
28
- extra: xhrExtra,
28
+ extra: httpExtra,
29
29
  requestTimestamp: 0,
30
30
  responseTimestamp: 0,
31
31
  }
@@ -1,6 +1,6 @@
1
1
  import type { CacheAsyncStorageType, CacheStorageType, CacheValueType } from "cache";
2
2
  import type { HttpAdapterType } from "http-adapter";
3
- import { xhrExtra } from "http-adapter";
3
+ import { httpExtra } from "http-adapter";
4
4
  import type { ResponseDetailsType } from "managers";
5
5
 
6
6
  /**
@@ -109,7 +109,7 @@ export const createCacheResponse = <Data>(
109
109
  error: null,
110
110
  status: 200,
111
111
  success: true,
112
- extra: xhrExtra,
112
+ extra: httpExtra,
113
113
  ...createResponseDetails(),
114
114
  ...overrides,
115
115
  });
@@ -125,7 +125,7 @@ export const createCacheErrorResponse = <Error>(
125
125
  error,
126
126
  status: 400,
127
127
  success: false,
128
- extra: xhrExtra,
128
+ extra: httpExtra,
129
129
  ...createResponseDetails(),
130
130
  ...overrides,
131
131
  });
@@ -140,7 +140,7 @@ export const createCacheValue = <Data = unknown>(
140
140
  error: null,
141
141
  status: 200,
142
142
  success: true,
143
- extra: xhrExtra,
143
+ extra: httpExtra,
144
144
  ...createResponseDetails(),
145
145
  cacheKey: "cache-key",
146
146
  scope: null,
@@ -1 +1 @@
1
- {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatcher/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAuB,MAAM,SAAS,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EACV,aAAa,EAEb,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,SAAS,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,UAAU,CAAC,OAAO,SAAS,eAAe;IAwBlC,OAAO,CAAC,EAAE,qBAAqB;IAvB3C,OAAO,eAAsB;IAC7B,MAAM;;;;;;;;;;;;;MAAqC;IAC3C,OAAO,EAAE,qBAAqB,CAAyC;IAE9E,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,eAAe,CAAgD;IACvE,mEAAmE;IACnE,OAAO,CAAC,WAAW,CAAoD;IACvE,6FAA6F;IAC7F,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,qFAAqF;IACrF,OAAO,CAAC,SAAS,CAAK;IACtB,gGAAgG;IAChG,OAAO,CAAC,WAAW,CAA6B;IAEhD,8EAA8E;IAC9E,OAAO,CAAC,UAAU,CAA4C;IAC9D,kHAAkH;IAClH,OAAO,CAAC,cAAc,CAAoC;IAE1D,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAuC;gBAElC,OAAO,CAAC,EAAE,qBAAqB,YAAA;IAiBlD;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAQtB;IAEF;;OAEG;IACH,OAAO,CAAC,gBAAgB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MAAM,EAAE,UAAU,MAAM,wDAmC7D;IAEF;;OAEG;IACH,OAAO,CAAC,mBAAmB,CAQzB;IAEF;;OAEG;IACH,OAAO,CAAC,qBAAqB,CAU3B;IAEF;;;OAGG;IACH,OAAO,CAAC,aAAa,CAYnB;IAEF;;;OAGG;IACH,cAAc,GAAU,aAAa,qBAAqB,4DAwRxD;CACH"}
@@ -1,4 +1,12 @@
1
1
  import { HttpAdapterExtraType } from './http-adapter.types';
2
2
  export declare const defaultTimeout: number;
3
+ /**
4
+ * Default `extra` of the `HttpAdapter`. It holds the response headers, so it starts empty and is used until a response
5
+ * arrives, and for requests that fail before the server answers.
6
+ */
7
+ export declare const httpExtra: HttpAdapterExtraType;
8
+ /**
9
+ * @deprecated Use `httpExtra`. The `HttpAdapter` sends requests with `fetch`, not `XMLHttpRequest`.
10
+ */
3
11
  export declare const xhrExtra: HttpAdapterExtraType;
4
12
  //# sourceMappingURL=http-adapter.constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http-adapter.constants.d.ts","sourceRoot":"","sources":["../../src/http-adapter/http-adapter.constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,cAAc,QAAe,CAAC;AAE3C,eAAO,MAAM,QAAQ,EAAE,oBAEtB,CAAC"}
1
+ {"version":3,"file":"http-adapter.constants.d.ts","sourceRoot":"","sources":["../../src/http-adapter/http-adapter.constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,eAAO,MAAM,cAAc,QAAe,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,oBAEvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,oBAAgC,CAAC"}