@hyper-fetch/core 9.2.0 → 9.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.
- package/__tests__/features/adapter/adapter.request-options.spec.ts +116 -0
- package/__tests__/features/cache/cache.base.spec.ts +48 -0
- package/__tests__/features/cache/cache.replace-equal-deep.spec.ts +125 -0
- package/__tests__/features/dispatcher/dispatcher.events.spec.ts +52 -0
- package/__tests__/features/request/request.setters.spec.ts +7 -0
- package/dist/adapter/adapter.d.ts +17 -12
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.types.d.ts +5 -3
- package/dist/adapter/adapter.types.d.ts.map +1 -1
- package/dist/cache/cache.d.ts.map +1 -1
- package/dist/cache/cache.types.d.ts +3 -1
- package/dist/cache/cache.types.d.ts.map +1 -1
- package/dist/cache/cache.utils.d.ts +14 -0
- package/dist/cache/cache.utils.d.ts.map +1 -1
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/dispatcher/dispatcher.d.ts +7 -0
- package/dist/dispatcher/dispatcher.d.ts.map +1 -1
- package/dist/dispatcher/dispatcher.events.d.ts +15 -1
- package/dist/dispatcher/dispatcher.events.d.ts.map +1 -1
- package/dist/dispatcher/dispatcher.types.d.ts +4 -0
- package/dist/dispatcher/dispatcher.types.d.ts.map +1 -1
- package/dist/dispatcher/dispatcher.utils.d.ts +2 -0
- package/dist/dispatcher/dispatcher.utils.d.ts.map +1 -1
- package/dist/http-adapter/http-adapter.fetch.d.ts +1 -1
- package/dist/http-adapter/http-adapter.fetch.d.ts.map +1 -1
- package/dist/index.mjs +89 -8
- package/dist/index.mjs.map +1 -1
- package/dist/request/request.d.ts +3 -0
- package/dist/request/request.d.ts.map +1 -1
- package/dist/request/request.types.d.ts +6 -0
- package/dist/request/request.types.d.ts.map +1 -1
- package/dist/sdk/sdk.d.ts +1 -0
- package/dist/sdk/sdk.d.ts.map +1 -1
- package/dist/types/adapter.types.d.ts +13 -11
- package/dist/types/adapter.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapter/adapter.ts +33 -13
- package/src/adapter/adapter.types.ts +7 -3
- package/src/cache/cache.ts +6 -1
- package/src/cache/cache.types.ts +1 -1
- package/src/cache/cache.utils.ts +56 -0
- package/src/client/client.ts +2 -1
- package/src/dispatcher/dispatcher.events.ts +29 -1
- package/src/dispatcher/dispatcher.ts +19 -6
- package/src/dispatcher/dispatcher.types.ts +5 -0
- package/src/dispatcher/dispatcher.utils.ts +6 -0
- package/src/request/request.ts +9 -0
- package/src/request/request.types.ts +6 -0
- package/src/sdk/sdk.ts +4 -0
- package/src/types/adapter.types.ts +18 -11
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { AdapterInstance, DeclareAdapterType, DefaultMapperType, QueryParamsType } from "adapter";
|
|
2
|
+
import { Adapter } from "adapter";
|
|
3
|
+
import { Client } from "client";
|
|
4
|
+
import type { stringifyQueryParams } from "http-adapter";
|
|
5
|
+
import type { ExtractAdapterRequestOptionsType } from "types";
|
|
6
|
+
import { expectTypeOf } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { HttpMethods } from "../../../src/constants/http.constants";
|
|
9
|
+
|
|
10
|
+
type CustomRequestOptions = { document?: string };
|
|
11
|
+
|
|
12
|
+
const createAdapter = () =>
|
|
13
|
+
new Adapter<
|
|
14
|
+
{ timeout?: number },
|
|
15
|
+
"GET",
|
|
16
|
+
number,
|
|
17
|
+
{ headers: Record<string, string> },
|
|
18
|
+
QueryParamsType | string,
|
|
19
|
+
undefined,
|
|
20
|
+
string,
|
|
21
|
+
(endpoint: string) => string,
|
|
22
|
+
typeof stringifyQueryParams,
|
|
23
|
+
DefaultMapperType,
|
|
24
|
+
DefaultMapperType,
|
|
25
|
+
CustomRequestOptions
|
|
26
|
+
>({
|
|
27
|
+
name: "test-adapter",
|
|
28
|
+
defaultMethod: HttpMethods.GET,
|
|
29
|
+
defaultExtra: { headers: {} },
|
|
30
|
+
systemErrorStatus: 0,
|
|
31
|
+
systemErrorExtra: { headers: {} },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe("Adapter [ Request options ]", () => {
|
|
35
|
+
describe("when creating requests", () => {
|
|
36
|
+
it("should keep the additional field in the request options", () => {
|
|
37
|
+
const client = new Client({ url: "http://localhost" }).setAdapter(createAdapter());
|
|
38
|
+
|
|
39
|
+
const request = client.createRequest()({ endpoint: "/test", document: "value" });
|
|
40
|
+
|
|
41
|
+
expect(request.requestOptions).toMatchObject({ endpoint: "/test", document: "value" });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should keep the additional field on clones and after serialization", () => {
|
|
45
|
+
const client = new Client({ url: "http://localhost" }).setAdapter(createAdapter());
|
|
46
|
+
|
|
47
|
+
const request = client.createRequest()({ endpoint: "/test", document: "value" });
|
|
48
|
+
const cloned = request.setRetry(1).clone();
|
|
49
|
+
const restored = client.fromJSON(JSON.parse(JSON.stringify(request.toJSON())));
|
|
50
|
+
|
|
51
|
+
expect(cloned.requestOptions).toMatchObject({ document: "value" });
|
|
52
|
+
expect(restored.requestOptions).toMatchObject({ document: "value" });
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("when using the devtools endpoint getter", () => {
|
|
57
|
+
it("should allow to read the request options", () => {
|
|
58
|
+
const adapter = createAdapter().setDevtoolsEndpointGetter(
|
|
59
|
+
(endpoint, requestOptions) => requestOptions?.document ?? endpoint,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect(adapter.unstable_devtoolsEndpointGetter("/test")).toBe("/test");
|
|
63
|
+
expect(adapter.unstable_devtoolsEndpointGetter("/test", { document: "value" })).toBe("value");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("when checking types", () => {
|
|
68
|
+
it("should extract the declared request options", () => {
|
|
69
|
+
type TestAdapter = ReturnType<typeof createAdapter>;
|
|
70
|
+
|
|
71
|
+
expectTypeOf<ExtractAdapterRequestOptionsType<TestAdapter>>().toEqualTypeOf<CustomRequestOptions>();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should support declaring the request options", () => {
|
|
75
|
+
type Declared = DeclareAdapterType<{
|
|
76
|
+
adapterOptions: Record<string, never>;
|
|
77
|
+
methodType: "GET";
|
|
78
|
+
statusType: number;
|
|
79
|
+
extra: Record<string, never>;
|
|
80
|
+
endpointType: string;
|
|
81
|
+
requestOptions: CustomRequestOptions;
|
|
82
|
+
}>;
|
|
83
|
+
|
|
84
|
+
expectTypeOf<ExtractAdapterRequestOptionsType<Declared>>().toEqualTypeOf<CustomRequestOptions>();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("should default to no additional fields", () => {
|
|
88
|
+
type Default = DeclareAdapterType<{
|
|
89
|
+
adapterOptions: Record<string, never>;
|
|
90
|
+
methodType: "GET";
|
|
91
|
+
statusType: number;
|
|
92
|
+
extra: Record<string, never>;
|
|
93
|
+
endpointType: string;
|
|
94
|
+
}>;
|
|
95
|
+
|
|
96
|
+
expectTypeOf<ExtractAdapterRequestOptionsType<Default>>().toEqualTypeOf<{}>();
|
|
97
|
+
expectTypeOf<ExtractAdapterRequestOptionsType<AdapterInstance>>().toEqualTypeOf<{}>();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("should reject not declared fields and validate the declared ones", () => {
|
|
101
|
+
const client = new Client({ url: "http://localhost" }).setAdapter(createAdapter());
|
|
102
|
+
const http = new Client({ url: "http://localhost" });
|
|
103
|
+
|
|
104
|
+
const create = () => {
|
|
105
|
+
// @ts-expect-error wrong type of the declared field
|
|
106
|
+
client.createRequest()({ endpoint: "/test", document: 1 });
|
|
107
|
+
// @ts-expect-error field not declared by the adapter
|
|
108
|
+
client.createRequest()({ endpoint: "/test", other: 1 });
|
|
109
|
+
// @ts-expect-error field not declared by the default adapter
|
|
110
|
+
http.createRequest()({ endpoint: "/test", document: "value" });
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
expect(create).toBeFunction();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -202,6 +202,54 @@ describe("Cache [ Base ]", () => {
|
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
|
|
205
|
+
describe("When structural sharing is used", () => {
|
|
206
|
+
it("should keep the data reference for deeply equal responses", async () => {
|
|
207
|
+
const spy = vi.fn();
|
|
208
|
+
cache.events.onDataByKey(request.cacheKey, spy);
|
|
209
|
+
|
|
210
|
+
cache.set(request, { ...response, ...details, data: { list: [{ id: 1 }], meta: { page: 1 } } });
|
|
211
|
+
const first = cache.get<any, any>(request.cacheKey)?.data;
|
|
212
|
+
cache.set(request, { ...response, ...details, data: { list: [{ id: 1 }], meta: { page: 1 } } });
|
|
213
|
+
const second = cache.get<any, any>(request.cacheKey)?.data;
|
|
214
|
+
|
|
215
|
+
expect(second).toBe(first);
|
|
216
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
217
|
+
expect(spy.mock.calls[1][0].data).toBe(first);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("should reuse unchanged parts of the data", async () => {
|
|
221
|
+
cache.set(request, { ...response, ...details, data: { list: [{ id: 1 }], meta: { page: 1 } } });
|
|
222
|
+
const first = cache.get<any, any>(request.cacheKey)?.data;
|
|
223
|
+
cache.set(request, { ...response, ...details, data: { list: [{ id: 1 }], meta: { page: 2 } } });
|
|
224
|
+
const second = cache.get<any, any>(request.cacheKey)?.data;
|
|
225
|
+
|
|
226
|
+
expect(second).not.toBe(first);
|
|
227
|
+
expect(second.list).toBe(first.list);
|
|
228
|
+
expect(second.meta).toStrictEqual({ page: 2 });
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("should share references for cache updates", async () => {
|
|
232
|
+
cache.set(request, { ...response, ...details, data: { list: [{ id: 1 }], meta: { page: 1 } } });
|
|
233
|
+
const first = cache.get<any, any>(request.cacheKey)?.data;
|
|
234
|
+
cache.update(request, (prev) => ({ ...prev, data: { ...prev?.data, meta: { page: 3 } } }));
|
|
235
|
+
const second = cache.get<any, any>(request.cacheKey)?.data;
|
|
236
|
+
|
|
237
|
+
expect(second.list).toBe(first.list);
|
|
238
|
+
expect(second.meta).toStrictEqual({ page: 3 });
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("should allow to disable structural sharing", async () => {
|
|
242
|
+
const disabledRequest = request.setStructuralSharing(false);
|
|
243
|
+
const data = { list: [{ id: 1 }] };
|
|
244
|
+
const newData = { list: [{ id: 1 }] };
|
|
245
|
+
|
|
246
|
+
cache.set(disabledRequest, { ...response, ...details, data });
|
|
247
|
+
cache.set(disabledRequest, { ...response, ...details, data: newData });
|
|
248
|
+
|
|
249
|
+
expect(cache.get<any, any>(request.cacheKey)?.data).toBe(newData);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
205
253
|
describe("When CacheStore gets cleared before triggering cache actions", () => {
|
|
206
254
|
it("should return undefined when removed cache entity", async () => {
|
|
207
255
|
const trigger = vi.fn();
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { isPlainObject, replaceEqualDeep } from "cache";
|
|
2
|
+
|
|
3
|
+
class Model {
|
|
4
|
+
value = 1;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
describe("replaceEqualDeep [ Utils ]", () => {
|
|
8
|
+
describe("When values are equal", () => {
|
|
9
|
+
it("should return previous reference for deeply equal objects", () => {
|
|
10
|
+
const prev = { a: 1, b: { c: [1, 2, { d: "x" }] } };
|
|
11
|
+
const next = { a: 1, b: { c: [1, 2, { d: "x" }] } };
|
|
12
|
+
|
|
13
|
+
expect(replaceEqualDeep(prev, next)).toBe(prev);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should return previous reference for deeply equal arrays", () => {
|
|
17
|
+
const prev = [{ id: 1 }, { id: 2 }];
|
|
18
|
+
const next = [{ id: 1 }, { id: 2 }];
|
|
19
|
+
|
|
20
|
+
expect(replaceEqualDeep(prev, next)).toBe(prev);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should handle primitives and NaN", () => {
|
|
24
|
+
expect(replaceEqualDeep(1, 1)).toBe(1);
|
|
25
|
+
expect(replaceEqualDeep("a", "b")).toBe("b");
|
|
26
|
+
expect(replaceEqualDeep(NaN, NaN)).toBeNaN();
|
|
27
|
+
expect(replaceEqualDeep(null, { a: 1 })).toStrictEqual({ a: 1 });
|
|
28
|
+
expect(replaceEqualDeep({ a: 1 }, null)).toBeNull();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should treat empty containers as equal", () => {
|
|
32
|
+
const prevObject = {};
|
|
33
|
+
const prevArray: unknown[] = [];
|
|
34
|
+
|
|
35
|
+
expect(replaceEqualDeep(prevObject, {})).toBe(prevObject);
|
|
36
|
+
expect(replaceEqualDeep(prevArray, [])).toBe(prevArray);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("When values differ", () => {
|
|
41
|
+
it("should reuse unchanged branches of objects", () => {
|
|
42
|
+
const prev = { unchanged: { deep: [1, 2] }, changed: { value: 1 } };
|
|
43
|
+
const next = { unchanged: { deep: [1, 2] }, changed: { value: 2 } };
|
|
44
|
+
|
|
45
|
+
const result = replaceEqualDeep(prev, next);
|
|
46
|
+
|
|
47
|
+
expect(result).not.toBe(prev);
|
|
48
|
+
expect(result).toStrictEqual(next);
|
|
49
|
+
expect(result.unchanged).toBe(prev.unchanged);
|
|
50
|
+
expect(result.changed).not.toBe(prev.changed);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should reuse unchanged array items", () => {
|
|
54
|
+
const prev = [{ id: 1 }, { id: 2 }];
|
|
55
|
+
const next = [{ id: 1 }, { id: 3 }, { id: 4 }];
|
|
56
|
+
|
|
57
|
+
const result = replaceEqualDeep(prev, next);
|
|
58
|
+
|
|
59
|
+
expect(result).toStrictEqual(next);
|
|
60
|
+
expect(result[0]).toBe(prev[0]);
|
|
61
|
+
expect(result[1]).not.toBe(prev[1]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("should detect removed array items and object keys", () => {
|
|
65
|
+
const prevArray = [1, 2, 3];
|
|
66
|
+
const prevObject = { a: 1, b: 2 };
|
|
67
|
+
|
|
68
|
+
expect(replaceEqualDeep(prevArray, [1, 2])).toStrictEqual([1, 2]);
|
|
69
|
+
expect(replaceEqualDeep(prevArray, [1, 2])).not.toBe(prevArray);
|
|
70
|
+
expect(replaceEqualDeep(prevObject, { a: 1 })).toStrictEqual({ a: 1 });
|
|
71
|
+
expect(replaceEqualDeep(prevObject, { a: 1 })).not.toBe(prevObject);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should not treat a missing key as equal to an undefined value", () => {
|
|
75
|
+
const prev: Record<string, unknown> = { a: 1, b: 2 };
|
|
76
|
+
const next: Record<string, unknown> = { a: 1, c: undefined };
|
|
77
|
+
|
|
78
|
+
const result = replaceEqualDeep(prev, next);
|
|
79
|
+
|
|
80
|
+
expect(result).not.toBe(prev);
|
|
81
|
+
expect(Object.keys(result)).toStrictEqual(["a", "c"]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should not mix arrays with objects", () => {
|
|
85
|
+
const prev = { 0: "a" };
|
|
86
|
+
const next = ["a"];
|
|
87
|
+
|
|
88
|
+
expect(replaceEqualDeep(prev, next)).toBe(next);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("should replace non plain objects", () => {
|
|
92
|
+
const prevDate = new Date(1000);
|
|
93
|
+
const nextDate = new Date(1000);
|
|
94
|
+
const nextModel = new Model();
|
|
95
|
+
const nextMap = new Map([["a", 1]]);
|
|
96
|
+
|
|
97
|
+
expect(replaceEqualDeep(prevDate, nextDate)).toBe(nextDate);
|
|
98
|
+
expect(replaceEqualDeep(new Model(), nextModel)).toBe(nextModel);
|
|
99
|
+
expect(replaceEqualDeep(new Map([["a", 1]]), nextMap)).toBe(nextMap);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("should keep shared references inside non plain parents", () => {
|
|
103
|
+
const shared = { a: 1 };
|
|
104
|
+
const prev = { list: [shared], date: new Date(1) };
|
|
105
|
+
const next = { list: [{ a: 1 }], date: new Date(1) };
|
|
106
|
+
|
|
107
|
+
const result = replaceEqualDeep(prev, next);
|
|
108
|
+
|
|
109
|
+
expect(result).not.toBe(prev);
|
|
110
|
+
expect(result.list).toBe(prev.list);
|
|
111
|
+
expect(result.date).toBe(next.date);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe("When checking plain objects", () => {
|
|
116
|
+
it("should recognize plain objects only", () => {
|
|
117
|
+
expect(isPlainObject({})).toBeTrue();
|
|
118
|
+
expect(isPlainObject(Object.create(null))).toBeTrue();
|
|
119
|
+
expect(isPlainObject([])).toBeFalse();
|
|
120
|
+
expect(isPlainObject(new Date())).toBeFalse();
|
|
121
|
+
expect(isPlainObject(null)).toBeFalse();
|
|
122
|
+
expect(isPlainObject(new Model())).toBeFalse();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -306,4 +306,56 @@ describe("Dispatcher [ Events ]", () => {
|
|
|
306
306
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
307
307
|
});
|
|
308
308
|
});
|
|
309
|
+
|
|
310
|
+
describe("When running requests change", () => {
|
|
311
|
+
it("should emit running requests change when request starts and finishes", async () => {
|
|
312
|
+
const spy = vi.fn();
|
|
313
|
+
const keySpy = vi.fn();
|
|
314
|
+
const unmount = dispatcher.events.onRunningRequestsChange(spy);
|
|
315
|
+
const unmountKey = dispatcher.events.onRunningRequestsChangeByKey(request.queryKey, keySpy);
|
|
316
|
+
|
|
317
|
+
dispatcher.add(request);
|
|
318
|
+
|
|
319
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
320
|
+
expect(spy.mock.calls[0][0].queryKey).toBe(request.queryKey);
|
|
321
|
+
expect(spy.mock.calls[0][0].runningRequests).toHaveLength(1);
|
|
322
|
+
|
|
323
|
+
await waitFor(() => {
|
|
324
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
325
|
+
});
|
|
326
|
+
expect(spy.mock.calls[1][0].runningRequests).toHaveLength(0);
|
|
327
|
+
expect(keySpy).toHaveBeenCalledTimes(2);
|
|
328
|
+
|
|
329
|
+
unmount();
|
|
330
|
+
unmountKey();
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it("should emit running requests change on cancel and clear", async () => {
|
|
334
|
+
const spy = vi.fn();
|
|
335
|
+
const unmount = dispatcher.events.onRunningRequestsChange(spy);
|
|
336
|
+
const otherRequest = request.setQueryKey("other");
|
|
337
|
+
mockRequest(request, { delay: 100 });
|
|
338
|
+
mockRequest(otherRequest, { delay: 100 });
|
|
339
|
+
|
|
340
|
+
const requestId = dispatcher.add(request);
|
|
341
|
+
dispatcher.add(otherRequest);
|
|
342
|
+
expect(dispatcher.getAllRunningRequests()).toHaveLength(2);
|
|
343
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
344
|
+
|
|
345
|
+
dispatcher.cancelRunningRequest(request.queryKey, requestId);
|
|
346
|
+
expect(spy).toHaveBeenCalledTimes(3);
|
|
347
|
+
expect(spy.mock.calls[2][0].runningRequests).toHaveLength(0);
|
|
348
|
+
|
|
349
|
+
dispatcher.clear();
|
|
350
|
+
expect(dispatcher.getAllRunningRequests()).toHaveLength(0);
|
|
351
|
+
expect(spy.mock.calls.at(-1)?.[0]).toStrictEqual({ queryKey: otherRequest.queryKey, runningRequests: [] });
|
|
352
|
+
|
|
353
|
+
// No change - no event
|
|
354
|
+
const calls = spy.mock.calls.length;
|
|
355
|
+
dispatcher.deleteRunningRequests(request.queryKey);
|
|
356
|
+
expect(spy).toHaveBeenCalledTimes(calls);
|
|
357
|
+
|
|
358
|
+
unmount();
|
|
359
|
+
});
|
|
360
|
+
});
|
|
309
361
|
});
|
|
@@ -115,6 +115,13 @@ describe("Request [ Setters ]", () => {
|
|
|
115
115
|
const updatedRequest = request.setDeduplicateTime(1000);
|
|
116
116
|
expect(updatedRequest.deduplicateTime).toBe(1000);
|
|
117
117
|
});
|
|
118
|
+
it("should allow for setting structural sharing", async () => {
|
|
119
|
+
expect(request.structuralSharing).toBeTrue();
|
|
120
|
+
const updatedRequest = request.setStructuralSharing(false);
|
|
121
|
+
expect(updatedRequest.structuralSharing).toBeFalse();
|
|
122
|
+
expect(updatedRequest.clone().structuralSharing).toBeFalse();
|
|
123
|
+
expect(updatedRequest.toJSON().structuralSharing).toBeFalse();
|
|
124
|
+
});
|
|
118
125
|
it("should allow for setting used", async () => {
|
|
119
126
|
expect(request.used).toBeFalse();
|
|
120
127
|
const updatedRequest = request.setUsed(true);
|
|
@@ -11,7 +11,7 @@ export declare const defaultMapper: DefaultMapperType;
|
|
|
11
11
|
* header/payload/query-params mapping, and the actual fetch call. Extend or configure this class
|
|
12
12
|
* to integrate custom transport layers (e.g., axios, graphql, firebase).
|
|
13
13
|
*/
|
|
14
|
-
export declare class Adapter<AdapterOptions, MethodType extends string, StatusType extends number | string, Extra extends Record<string, any>, QueryParams = QueryParamsType | string | EmptyTypes, DefaultQueryParams = undefined, EndpointType = string, EndpointMapperType extends EndpointMapper<EndpointType> | DefaultMapperType = DefaultMapperType, QueryParamsMapperType extends QueryParamsMapper<QueryParams> | DefaultMapperType = DefaultMapperType, HeaderMapperType extends HeaderMappingType | DefaultMapperType = DefaultMapperType, PayloadMapperType extends AdapterPayloadMappingType | DefaultMapperType = DefaultMapperType> {
|
|
14
|
+
export declare class Adapter<AdapterOptions, MethodType extends string, StatusType extends number | string, Extra extends Record<string, any>, QueryParams = QueryParamsType | string | EmptyTypes, DefaultQueryParams = undefined, EndpointType = string, EndpointMapperType extends EndpointMapper<EndpointType> | DefaultMapperType = DefaultMapperType, QueryParamsMapperType extends QueryParamsMapper<QueryParams> | DefaultMapperType = DefaultMapperType, HeaderMapperType extends HeaderMappingType | DefaultMapperType = DefaultMapperType, PayloadMapperType extends AdapterPayloadMappingType | DefaultMapperType = DefaultMapperType, RequestOptions extends Record<string, any> = {}> {
|
|
15
15
|
options: {
|
|
16
16
|
name: string;
|
|
17
17
|
defaultMethod: MethodType;
|
|
@@ -21,7 +21,7 @@ export declare class Adapter<AdapterOptions, MethodType extends string, StatusTy
|
|
|
21
21
|
defaultRequestOptions?: RequestOptionsType<EndpointType, AdapterOptions, MethodType>;
|
|
22
22
|
};
|
|
23
23
|
/** Fetching function */
|
|
24
|
-
unstable_fetcher: AdapterFetcherType<Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType>>;
|
|
24
|
+
unstable_fetcher: AdapterFetcherType<Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType, RequestOptions>>;
|
|
25
25
|
/**
|
|
26
26
|
* ********************
|
|
27
27
|
* Defaults
|
|
@@ -43,6 +43,11 @@ export declare class Adapter<AdapterOptions, MethodType extends string, StatusTy
|
|
|
43
43
|
unstable_headerMapperConfig: Parameters<HeaderMapperType>[1];
|
|
44
44
|
unstable_payloadMapperConfig: Parameters<PayloadMapperType>[1];
|
|
45
45
|
unstable_endpointMapperConfig: Parameters<EndpointMapperType>[1];
|
|
46
|
+
/**
|
|
47
|
+
* Type-only carrier of the additional `createRequest` fields declared by this adapter.
|
|
48
|
+
* It has no runtime value - adapters read those fields from `request.requestOptions`.
|
|
49
|
+
*/
|
|
50
|
+
unstable_requestOptionsType?: RequestOptions;
|
|
46
51
|
constructor(options: {
|
|
47
52
|
name: string;
|
|
48
53
|
defaultMethod: MethodType;
|
|
@@ -73,7 +78,7 @@ export declare class Adapter<AdapterOptions, MethodType extends string, StatusTy
|
|
|
73
78
|
unstable_queryParamsMapper: QueryParamsMapperType;
|
|
74
79
|
/** Get default adapter options for the request. */
|
|
75
80
|
unstable_getAdapterDefaults?: (request: ExtendRequest<RequestInstance, {
|
|
76
|
-
client: Client<any, Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType>>;
|
|
81
|
+
client: Client<any, Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType, RequestOptions>>;
|
|
77
82
|
}>) => AdapterOptions;
|
|
78
83
|
/** Get default request options for the request. */
|
|
79
84
|
unstable_getRequestDefaults?: (options: RequestOptionsType<EndpointType, AdapterOptions, MethodType>) => Partial<RequestOptionsType<EndpointType, AdapterOptions, MethodType>>;
|
|
@@ -81,7 +86,7 @@ export declare class Adapter<AdapterOptions, MethodType extends string, StatusTy
|
|
|
81
86
|
* Get formatted endpoint name of the request.
|
|
82
87
|
* Helpful in displaying long endpoints like in case of graphql schemas etc.
|
|
83
88
|
*/
|
|
84
|
-
unstable_devtoolsEndpointGetter: (endpoint: string) => string;
|
|
89
|
+
unstable_devtoolsEndpointGetter: (endpoint: string, requestOptions?: Record<string, any>) => string;
|
|
85
90
|
/**
|
|
86
91
|
* ********************
|
|
87
92
|
* Methods
|
|
@@ -92,7 +97,7 @@ export declare class Adapter<AdapterOptions, MethodType extends string, StatusTy
|
|
|
92
97
|
/** Set the default extra metadata attached to every request response (e.g., headers, status). */
|
|
93
98
|
setDefaultExtra: (extra: Extra) => this;
|
|
94
99
|
/** Set a function that formats the endpoint string for display in devtools. */
|
|
95
|
-
setDevtoolsEndpointGetter: (callback: (endpoint: string) => string) => this;
|
|
100
|
+
setDevtoolsEndpointGetter: (callback: (endpoint: string, requestOptions?: Record<string, any>) => string) => this;
|
|
96
101
|
/**
|
|
97
102
|
* This method allows to configure global defaults for the request configuration like method, auth, deduplication etc.
|
|
98
103
|
*/
|
|
@@ -101,26 +106,26 @@ export declare class Adapter<AdapterOptions, MethodType extends string, StatusTy
|
|
|
101
106
|
* Set the adapter default options added to every sent request
|
|
102
107
|
*/
|
|
103
108
|
setAdapterDefaults: (callback: (request: ExtendRequest<RequestInstance, {
|
|
104
|
-
client: Client<any, Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType>>;
|
|
109
|
+
client: Client<any, Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType, RequestOptions>>;
|
|
105
110
|
}>) => AdapterOptions) => this;
|
|
106
111
|
/** Set a custom mapping for internal adapter errors before they are returned in the response. */
|
|
107
112
|
setInternalErrorMapping: (callback: (error: ReturnType<typeof getErrorMessage>) => any) => this;
|
|
108
113
|
/**
|
|
109
114
|
* Set the custom header mapping function
|
|
110
115
|
*/
|
|
111
|
-
setHeaderMapper: <NewMapper extends HeaderMappingType>(headerMapper: NewMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, NewMapper, PayloadMapperType>;
|
|
116
|
+
setHeaderMapper: <NewMapper extends HeaderMappingType>(headerMapper: NewMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, NewMapper, PayloadMapperType, RequestOptions>;
|
|
112
117
|
/**
|
|
113
118
|
* Set the request payload mapping function which gets triggered before request is send
|
|
114
119
|
*/
|
|
115
|
-
setPayloadMapper: <NewMapper extends AdapterPayloadMappingType>(payloadMapper: NewMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, NewMapper>;
|
|
120
|
+
setPayloadMapper: <NewMapper extends AdapterPayloadMappingType>(payloadMapper: NewMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, NewMapper, RequestOptions>;
|
|
116
121
|
/**
|
|
117
122
|
* Set the endpoint mapping function which transforms the endpoint string before the request is sent
|
|
118
123
|
*/
|
|
119
|
-
setEndpointMapper: <NewEndpointMapper extends EndpointMapper<EndpointType>>(endpointMapper: NewEndpointMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, NewEndpointMapper, QueryParamsMapperType, HeaderMapperType, PayloadMapperType>;
|
|
124
|
+
setEndpointMapper: <NewEndpointMapper extends EndpointMapper<EndpointType>>(endpointMapper: NewEndpointMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, NewEndpointMapper, QueryParamsMapperType, HeaderMapperType, PayloadMapperType, RequestOptions>;
|
|
120
125
|
/**
|
|
121
126
|
* Set the query params mapping function which get triggered before request get sent
|
|
122
127
|
*/
|
|
123
|
-
setQueryParamsMapper: <NewQueryParamsMapper extends QueryParamsMapper<QueryParams>>(queryParamsMapper: NewQueryParamsMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, NewQueryParamsMapper, HeaderMapperType, PayloadMapperType>;
|
|
128
|
+
setQueryParamsMapper: <NewQueryParamsMapper extends QueryParamsMapper<QueryParams>>(queryParamsMapper: NewQueryParamsMapper) => Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, NewQueryParamsMapper, HeaderMapperType, PayloadMapperType, RequestOptions>;
|
|
124
129
|
/** Set the configuration object passed as the second argument to the query params mapper. */
|
|
125
130
|
setQueryParamsMapperConfig: <NewQueryParamsMapperConfig extends Parameters<QueryParamsMapperType>[1]>(config: NewQueryParamsMapperConfig) => this;
|
|
126
131
|
/** Set the configuration object passed as the second argument to the header mapper. */
|
|
@@ -135,10 +140,10 @@ export declare class Adapter<AdapterOptions, MethodType extends string, StatusTy
|
|
|
135
140
|
* ********************
|
|
136
141
|
*/
|
|
137
142
|
/** Set the fetcher function that performs the actual network request. Must be called before any request can be executed. */
|
|
138
|
-
setFetcher(fetcher: AdapterFetcherType<Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType>>): this;
|
|
143
|
+
setFetcher(fetcher: AdapterFetcherType<Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType, RequestOptions>>): this;
|
|
139
144
|
/** Execute a request through the adapter pipeline: maps endpoint/headers/payload, runs plugins, then calls the fetcher. */
|
|
140
145
|
fetch(request: ExtendRequest<RequestInstance, {
|
|
141
|
-
client: Client<any, Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType>>;
|
|
146
|
+
client: Client<any, Adapter<AdapterOptions, MethodType, StatusType, Extra, QueryParams, DefaultQueryParams, EndpointType, EndpointMapperType, QueryParamsMapperType, HeaderMapperType, PayloadMapperType, RequestOptions>>;
|
|
142
147
|
}>, requestId: string): Promise<RequestResponseType<RequestInstance>>;
|
|
143
148
|
}
|
|
144
149
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,aAA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AqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,CACf,CACF;IAMH,2HAA2H;IAC9G,KAAK,CAChB,OAAO,EAAE,aAAa,CACpB,eAAe,EACf;QAEE,MAAM,EAAE,MAAM,CACZ,GAAG,EACH,OAAO,CACL,cAAc,EACd,UAAU,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,CACf,CACF,CAAC;KACH,CACF,EACD,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;CAuFjD"}
|
|
@@ -5,8 +5,8 @@ import { getAdapterBindings } from './adapter.bindings';
|
|
|
5
5
|
/**
|
|
6
6
|
* Base Adapter
|
|
7
7
|
*/
|
|
8
|
-
export type AdapterInstance = Adapter<any, any, any, any, any, any, any, any, any, any, any>;
|
|
9
|
-
export type AdapterGenericType<AdapterOptions, MethodType extends string, StatusType extends number | string, Extra extends Record<string, any>, QueryParams = QueryParamsType | string | EmptyTypes, DefaultQueryParams = undefined, EndpointType = string, EndpointMapperType extends EndpointMapper<EndpointType> | DefaultMapperType = DefaultMapperType, QueryParamsMapperType extends QueryParamsMapper<QueryParams> | DefaultMapperType = DefaultMapperType, HeaderMapperType extends HeaderMappingType | DefaultMapperType = DefaultMapperType, PayloadMapperType extends AdapterPayloadMappingType | DefaultMapperType = DefaultMapperType> = {
|
|
8
|
+
export type AdapterInstance = Adapter<any, any, any, any, any, any, any, any, any, any, any, any>;
|
|
9
|
+
export type AdapterGenericType<AdapterOptions, MethodType extends string, StatusType extends number | string, Extra extends Record<string, any>, QueryParams = QueryParamsType | string | EmptyTypes, DefaultQueryParams = undefined, EndpointType = string, EndpointMapperType extends EndpointMapper<EndpointType> | DefaultMapperType = DefaultMapperType, QueryParamsMapperType extends QueryParamsMapper<QueryParams> | DefaultMapperType = DefaultMapperType, HeaderMapperType extends HeaderMappingType | DefaultMapperType = DefaultMapperType, PayloadMapperType extends AdapterPayloadMappingType | DefaultMapperType = DefaultMapperType, RequestOptions extends Record<string, any> = {}> = {
|
|
10
10
|
adapterOptions: AdapterOptions;
|
|
11
11
|
methodType: MethodType;
|
|
12
12
|
statusType: StatusType;
|
|
@@ -18,8 +18,10 @@ export type AdapterGenericType<AdapterOptions, MethodType extends string, Status
|
|
|
18
18
|
queryParamsMapperType?: QueryParamsMapperType;
|
|
19
19
|
headerMapperType?: HeaderMapperType;
|
|
20
20
|
payloadMapperType?: PayloadMapperType;
|
|
21
|
+
/** Additional fields accepted by `createRequest` on clients using this adapter */
|
|
22
|
+
requestOptions?: RequestOptions;
|
|
21
23
|
};
|
|
22
|
-
export type DeclareAdapterType<Properties extends AdapterGenericType<any, any, any, any, any, any, any, any, any, any>> = Adapter<TypeWithDefaults<Properties, "adapterOptions", any>, TypeWithDefaults<Properties, "methodType", any>, TypeWithDefaults<Properties, "statusType", any>, TypeWithDefaults<Properties, "extra", any>, TypeWithDefaults<Properties, "queryParams", QueryParamsType | string | EmptyTypes>, TypeWithDefaults<Properties, "defaultQueryParams", undefined>, TypeWithDefaults<Properties, "endpointType", string>, TypeWithDefaults<Properties, "endpointMapperType", DefaultMapperType>, TypeWithDefaults<Properties, "queryParamsMapperType", DefaultMapperType>, TypeWithDefaults<Properties, "headerMapperType", DefaultMapperType>, NonNullable<TypeWithDefaults<Properties, "payloadMapperType", DefaultMapperType
|
|
24
|
+
export type DeclareAdapterType<Properties extends AdapterGenericType<any, any, any, any, any, any, any, any, any, any, any, any>> = Adapter<TypeWithDefaults<Properties, "adapterOptions", any>, TypeWithDefaults<Properties, "methodType", any>, TypeWithDefaults<Properties, "statusType", any>, TypeWithDefaults<Properties, "extra", any>, TypeWithDefaults<Properties, "queryParams", QueryParamsType | string | EmptyTypes>, TypeWithDefaults<Properties, "defaultQueryParams", undefined>, TypeWithDefaults<Properties, "endpointType", string>, TypeWithDefaults<Properties, "endpointMapperType", DefaultMapperType>, TypeWithDefaults<Properties, "queryParamsMapperType", DefaultMapperType>, TypeWithDefaults<Properties, "headerMapperType", DefaultMapperType>, NonNullable<TypeWithDefaults<Properties, "payloadMapperType", DefaultMapperType>>, TypeWithDefaults<Properties, "requestOptions", {}>>;
|
|
23
25
|
export type AdapterFetcherType<Adapter extends AdapterInstance> = (options: Omit<Awaited<ReturnType<typeof getAdapterBindings<Adapter>>>, "payload"> & {
|
|
24
26
|
url: string;
|
|
25
27
|
endpoint: ReturnType<ExtractAdapterEndpointMapperType<Adapter>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.types.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,KAAK,EACV,UAAU,EACV,gCAAgC,EAChC,uBAAuB,EACvB,+BAA+B,EAC/B,8BAA8B,EAC9B,mCAAmC,EACnC,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AAEH,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.types.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,KAAK,EACV,UAAU,EACV,gCAAgC,EAChC,uB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;IACjD,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAIF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/cache/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,MAAM,OAAO,CAAC;AACf,OAAO,EAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/cache/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,MAAM,OAAO,CAAC;AAC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CAAC,EACzD,SAAS,OAAO,EAChB,iBAAiB,aAAa,CAC5B,OAAO,CACL,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAChG,mBAAmB,CACtB,CACF,KACA,IAAI,CAeL;IAEF;;;;OAIG;IACH,GAAG,GAAI,QAAQ,EAAE,KAAK,EAAE,UAAU,MAAM,KAAG,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,SAAS,CAI7F;IAEF;;;OAGG;IACH,IAAI,QAAO,MAAM,EAAE,CAIjB;IAEF;;;OAGG;IACH,MAAM,GAAI,UAAU,MAAM,KAAG,IAAI,CAW/B;IAEF;;;;;OAKG;IACH,UAAU,GAAI,YAAW,MAAM,GAAG,MAAM,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC,EAAS,UAqCvG;IAEF;;;OAGG;IACH,eAAe,GAAU,QAAQ,EAAE,KAAK,EACtC,UAAU,MAAM,KACf,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CA2B9D;IAEF;;OAEG;IACH,WAAW,0BAIT;IAEF;;OAEG;IACH,UAAU,0BAMR;IAEF;;;;OAIG;IACH,wBAAwB,GAAI,UAAU,MAAM,UAuC1C;IAEF;;OAEG;IACH,KAAK,QAAa,OAAO,CAAC,IAAI,CAAC,CAG7B;CACH"}
|
|
@@ -41,5 +41,7 @@ export type CacheStorageType = {
|
|
|
41
41
|
};
|
|
42
42
|
export type CacheInitialData = Record<string, CacheValueType>;
|
|
43
43
|
export type CacheSetState<CacheData> = CacheData | ((previousData: CacheData | null) => CacheData);
|
|
44
|
-
export type RequestCacheType<R extends RequestInstance> = Pick<R, "cacheKey" | "cache" | "staleTime" | "cacheTime" | "scope"
|
|
44
|
+
export type RequestCacheType<R extends RequestInstance> = Pick<R, "cacheKey" | "cache" | "staleTime" | "cacheTime" | "scope"> & {
|
|
45
|
+
structuralSharing?: boolean;
|
|
46
|
+
};
|
|
45
47
|
//# sourceMappingURL=cache.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.types.d.ts","sourceRoot":"","sources":["../../src/cache/cache.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,cAAc,CACxB,QAAQ,GAAG,GAAG,EACd,KAAK,GAAG,GAAG,EACX,OAAO,SAAS,eAAe,GAAG,eAAe,IAC/C,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,GACxC,mBAAmB,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAGJ,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,SAAS,eAAe,EACpD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE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,IAAI,IAAI,CAC5D,CAAC,EACD,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAC3D,GAAG;IAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
|
@@ -8,4 +8,18 @@ export declare const getDeleteKey: () => string;
|
|
|
8
8
|
export declare const getDeleteByKey: (key: string) => string;
|
|
9
9
|
export declare const getCacheByKey: (key: string) => string;
|
|
10
10
|
export declare const getCacheKey: () => string;
|
|
11
|
+
/**
|
|
12
|
+
* Check if value is a plain object (object literal or `Object.create(null)`).
|
|
13
|
+
* Class instances, Dates, Maps, Blobs etc. are not plain objects.
|
|
14
|
+
*/
|
|
15
|
+
export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Structural sharing - returns `next` with every part that is deeply equal to `prev` replaced by the `prev` reference.
|
|
18
|
+
* When both values are deeply equal the `prev` reference is returned, so consumers can rely on `===` checks.
|
|
19
|
+
* Only plain objects and arrays are traversed, other values are compared with `Object.is`.
|
|
20
|
+
* @param prev previous value
|
|
21
|
+
* @param next incoming value
|
|
22
|
+
* @returns `next` sharing unchanged references with `prev`
|
|
23
|
+
*/
|
|
24
|
+
export declare const replaceEqualDeep: <T>(prev: unknown, next: T) => T;
|
|
11
25
|
//# sourceMappingURL=cache.utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.utils.d.ts","sourceRoot":"","sources":["../../src/cache/cache.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,OAAO,CAAC;AAExD,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,eAAe,EACpD,kBAAkB,0BAA0B,CAAC,CAAC,CAAC,GAAG,SAAS,EAC3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