@hyper-fetch/react 7.5.3 → 8.0.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/.eslintrc.cjs +12 -0
- package/__tests__/features/helpers/use-request-events/use-request-events.base.spec.ts +4 -4
- package/__tests__/features/helpers/use-request-events/use-request-events.utils.spec.ts +3 -3
- package/__tests__/features/helpers/use-socket-state/use-socket-state.base.spec.ts +44 -6
- package/__tests__/features/helpers/use-tracked-state/use-tacked-state.actions.spec.ts +177 -9
- package/__tests__/features/helpers/use-tracked-state/use-tracked-state.base.spec.ts +47 -8
- package/__tests__/features/helpers/use-tracked-state/use-tracked-state.utils.spec.ts +6 -6
- package/__tests__/features/provider/provider.hydration.spec.tsx +7 -3
- package/__tests__/features/provider/use-config-provider.base.spec.tsx +2 -1
- package/__tests__/features/use-app-manager/use-app-manager.base.spec.ts +1 -1
- package/__tests__/features/use-cache/use-cache.base.spec.ts +9 -6
- package/__tests__/features/use-cache/use-cache.helpers.ts +1 -1
- package/__tests__/features/use-cache/use-cache.typescript.spec.ts +111 -0
- package/__tests__/features/use-emitter/use-emitter.base.spec.ts +2 -2
- package/__tests__/features/use-fetch/use-fetch.base.spec.ts +103 -15
- package/__tests__/features/use-fetch/use-fetch.cancel.spec.ts +2 -2
- package/__tests__/features/use-fetch/use-fetch.clear-state.spec.ts +82 -0
- package/__tests__/features/use-fetch/use-fetch.concurrency.spec.ts +3 -3
- package/__tests__/features/use-fetch/use-fetch.debounce.spec.ts +5 -5
- package/__tests__/features/use-fetch/use-fetch.deduplication.spec.ts +1 -1
- package/__tests__/features/use-fetch/use-fetch.infinite.ts +1 -1
- package/__tests__/features/use-fetch/use-fetch.integration.spec.tsx +3 -3
- package/__tests__/features/use-fetch/use-fetch.keep-previous-data.spec.ts +215 -0
- package/__tests__/features/use-fetch/use-fetch.methods.spec.ts +34 -34
- package/__tests__/features/use-fetch/use-fetch.offline.spec.ts +3 -3
- package/__tests__/features/use-fetch/use-fetch.pagination.ts +1 -1
- package/__tests__/features/use-fetch/use-fetch.prefetch.spec.tsx +1 -1
- package/__tests__/features/use-fetch/use-fetch.refresh.spec.ts +41 -7
- package/__tests__/features/use-fetch/use-fetch.rerender.spec.tsx +2 -2
- package/__tests__/features/use-fetch/use-fetch.retry.ts +1 -1
- package/__tests__/features/use-fetch/use-fetch.revalidate.spec.ts +6 -4
- package/__tests__/features/use-fetch/use-fetch.suspense.spec.tsx +505 -0
- package/__tests__/features/use-fetch/use-fetch.typescript.spec.ts +179 -56
- package/__tests__/features/use-fetch/use-fetch.window.spec.ts +75 -3
- package/__tests__/features/use-listener/use-listener.base.spec.ts +3 -3
- package/__tests__/features/use-queue/use-queue.actions.spec.ts +1 -1
- package/__tests__/features/use-queue/use-queue.base.spec.ts +259 -1
- package/__tests__/features/use-queue/use-queue.resolve.spec.ts +173 -0
- package/__tests__/features/use-stream/use-stream.base.spec.ts +481 -0
- package/__tests__/features/use-submit/use-submit.base.spec.ts +2 -2
- package/__tests__/features/use-submit/use-submit.cancel.spec.ts +1 -1
- package/__tests__/features/use-submit/use-submit.concurrency.spec.ts +1 -1
- package/__tests__/features/use-submit/use-submit.debounce.spec.ts +8 -8
- package/__tests__/features/use-submit/use-submit.methods.spec.ts +44 -46
- package/__tests__/features/use-submit/use-submit.optimistic.spec.ts +548 -0
- package/__tests__/features/use-submit/use-submit.queue.spec.ts +3 -3
- package/__tests__/features/use-submit/use-submit.retry.spec.ts +4 -4
- package/__tests__/features/use-submit/use-submit.revalidate.spec.ts +5 -5
- package/__tests__/features/use-submit/use-submit.submit.spec.ts +4 -3
- package/__tests__/features/use-submit/use-submit.typescript.spec.ts +325 -0
- package/__tests__/shared/isolation.tests.ts +1 -1
- package/__tests__/shared/response.tests.ts +5 -4
- package/__tests__/tsconfig.json +21 -2
- package/__tests__/utils/cache.utils.ts +6 -4
- package/__tests__/utils/emitter.utils.ts +3 -2
- package/__tests__/utils/listener.utils.ts +3 -2
- package/__tests__/utils/request.utils.ts +6 -6
- package/__tests__/utils/state.utils.ts +1 -1
- package/__tests__/utils/use-app-manager.utils.ts +1 -1
- package/__tests__/utils/use-cache.utils.ts +3 -2
- package/__tests__/utils/use-emitter.utils.ts +3 -2
- package/__tests__/utils/use-fetch.utils.ts +4 -3
- package/__tests__/utils/use-listener.utils.ts +3 -2
- package/__tests__/utils/use-queue.utils.ts +4 -2
- package/__tests__/utils/use-request-events.utils.ts +3 -2
- package/__tests__/utils/use-socket-state.utils.ts +3 -2
- package/__tests__/utils/use-submit.utils.ts +3 -2
- package/__tests__/utils/use-tracked-state.utils.ts +3 -2
- package/__tests__/vitest.setup.ts +8 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/use-request-events/index.d.ts +3 -0
- package/dist/helpers/use-request-events/index.d.ts.map +1 -0
- package/dist/helpers/use-request-events/use-request-events.hooks.d.ts +10 -0
- package/dist/helpers/use-request-events/use-request-events.hooks.d.ts.map +1 -0
- package/dist/helpers/use-request-events/use-request-events.types.d.ts +78 -0
- package/dist/helpers/use-request-events/use-request-events.types.d.ts.map +1 -0
- package/dist/helpers/use-socket-state/index.d.ts +4 -0
- package/dist/helpers/use-socket-state/index.d.ts.map +1 -0
- package/dist/helpers/use-socket-state/use-socket-state.constants.d.ts +4 -0
- package/dist/helpers/use-socket-state/use-socket-state.constants.d.ts.map +1 -0
- package/dist/helpers/use-socket-state/use-socket-state.hooks.d.ts +24 -0
- package/dist/helpers/use-socket-state/use-socket-state.hooks.d.ts.map +1 -0
- package/dist/helpers/use-socket-state/use-socket-state.types.d.ts +12 -0
- package/dist/helpers/use-socket-state/use-socket-state.types.d.ts.map +1 -0
- package/dist/helpers/use-tracked-state/index.d.ts +5 -0
- package/dist/helpers/use-tracked-state/index.d.ts.map +1 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.constants.d.ts +3 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.constants.d.ts.map +1 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.hooks.d.ts +12 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.hooks.d.ts.map +1 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.types.d.ts +113 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.types.d.ts.map +1 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.utils.d.ts +29 -0
- package/dist/helpers/use-tracked-state/use-tracked-state.utils.d.ts.map +1 -0
- package/dist/hooks/use-app-manager/index.d.ts +3 -0
- package/dist/hooks/use-app-manager/index.d.ts.map +1 -0
- package/dist/hooks/use-app-manager/use-app-manager.hooks.d.ts +4 -0
- package/dist/hooks/use-app-manager/use-app-manager.hooks.d.ts.map +1 -0
- package/dist/hooks/use-app-manager/use-app-manager.types.d.ts +19 -0
- package/dist/hooks/use-app-manager/use-app-manager.types.d.ts.map +1 -0
- package/dist/hooks/use-cache/index.d.ts +4 -0
- package/dist/hooks/use-cache/index.d.ts.map +1 -0
- package/dist/hooks/use-cache/use-cache.constants.d.ts +6 -0
- package/dist/hooks/use-cache/use-cache.constants.d.ts.map +1 -0
- package/dist/hooks/use-cache/use-cache.hooks.d.ts +4 -0
- package/dist/hooks/use-cache/use-cache.hooks.d.ts.map +1 -0
- package/dist/hooks/use-cache/use-cache.types.d.ts +24 -0
- package/dist/hooks/use-cache/use-cache.types.d.ts.map +1 -0
- package/dist/hooks/use-emitter/index.d.ts +3 -0
- package/dist/hooks/use-emitter/index.d.ts.map +1 -0
- package/dist/hooks/use-emitter/use-emitter.hooks.d.ts +26 -0
- package/dist/hooks/use-emitter/use-emitter.hooks.d.ts.map +1 -0
- package/dist/hooks/use-emitter/use-emitter.types.d.ts +4 -0
- package/dist/hooks/use-emitter/use-emitter.types.d.ts.map +1 -0
- package/dist/hooks/use-fetch/index.d.ts +5 -0
- package/dist/hooks/use-fetch/index.d.ts.map +1 -0
- package/dist/hooks/use-fetch/use-fetch.constants.d.ts +8 -0
- package/dist/hooks/use-fetch/use-fetch.constants.d.ts.map +1 -0
- package/dist/hooks/use-fetch/use-fetch.hooks.d.ts +10 -0
- package/dist/hooks/use-fetch/use-fetch.hooks.d.ts.map +1 -0
- package/dist/hooks/use-fetch/use-fetch.types.d.ts +118 -0
- package/dist/hooks/use-fetch/use-fetch.types.d.ts.map +1 -0
- package/dist/hooks/use-fetch/use-fetch.utils.d.ts +2 -0
- package/dist/hooks/use-fetch/use-fetch.utils.d.ts.map +1 -0
- package/dist/hooks/use-listener/index.d.ts +3 -0
- package/dist/hooks/use-listener/index.d.ts.map +1 -0
- package/dist/hooks/use-listener/use-listener.hooks.d.ts +31 -0
- package/dist/hooks/use-listener/use-listener.hooks.d.ts.map +1 -0
- package/dist/hooks/use-listener/use-listener.types.d.ts +4 -0
- package/dist/hooks/use-listener/use-listener.types.d.ts.map +1 -0
- package/dist/hooks/use-queue/index.d.ts +4 -0
- package/dist/hooks/use-queue/index.d.ts.map +1 -0
- package/dist/hooks/use-queue/use-queue.constants.d.ts +4 -0
- package/dist/hooks/use-queue/use-queue.constants.d.ts.map +1 -0
- package/dist/hooks/use-queue/use-queue.hooks.d.ts +10 -0
- package/dist/hooks/use-queue/use-queue.hooks.d.ts.map +1 -0
- package/dist/hooks/use-queue/use-queue.types.d.ts +58 -0
- package/dist/hooks/use-queue/use-queue.types.d.ts.map +1 -0
- package/dist/hooks/use-stream/index.d.ts +3 -0
- package/dist/hooks/use-stream/index.d.ts.map +1 -0
- package/dist/hooks/use-stream/use-stream.hooks.d.ts +11 -0
- package/dist/hooks/use-stream/use-stream.hooks.d.ts.map +1 -0
- package/dist/hooks/use-stream/use-stream.types.d.ts +52 -0
- package/dist/hooks/use-stream/use-stream.types.d.ts.map +1 -0
- package/dist/hooks/use-submit/index.d.ts +4 -0
- package/dist/hooks/use-submit/index.d.ts.map +1 -0
- package/dist/hooks/use-submit/use-submit.constants.d.ts +8 -0
- package/dist/hooks/use-submit/use-submit.constants.d.ts.map +1 -0
- package/dist/hooks/use-submit/use-submit.hooks.d.ts +10 -0
- package/dist/hooks/use-submit/use-submit.hooks.d.ts.map +1 -0
- package/dist/hooks/use-submit/use-submit.types.d.ts +115 -0
- package/dist/hooks/use-submit/use-submit.types.d.ts.map +1 -0
- package/dist/index.d.ts +12 -733
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1935 -0
- package/dist/index.mjs.map +1 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/provider.d.ts +13 -0
- package/dist/provider/provider.d.ts.map +1 -0
- package/dist/provider/provider.types.d.ts +31 -0
- package/dist/provider/provider.types.d.ts.map +1 -0
- package/dist/utils/bounce.utils.d.ts +8 -0
- package/dist/utils/bounce.utils.d.ts.map +1 -0
- package/dist/utils/deep-equal.utils.d.ts +14 -0
- package/dist/utils/deep-equal.utils.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/tracked-proxy.utils.d.ts +7 -0
- package/dist/utils/tracked-proxy.utils.d.ts.map +1 -0
- package/package.json +21 -13
- package/src/helpers/use-request-events/use-request-events.hooks.ts +60 -14
- package/src/helpers/use-request-events/use-request-events.types.ts +19 -12
- package/src/helpers/use-socket-state/use-socket-state.constants.ts +2 -2
- package/src/helpers/use-socket-state/use-socket-state.hooks.ts +47 -13
- package/src/helpers/use-socket-state/use-socket-state.types.ts +1 -1
- package/src/helpers/use-tracked-state/use-tracked-state.constants.ts +1 -1
- package/src/helpers/use-tracked-state/use-tracked-state.hooks.ts +74 -22
- package/src/helpers/use-tracked-state/use-tracked-state.types.ts +7 -2
- package/src/helpers/use-tracked-state/use-tracked-state.utils.ts +39 -4
- package/src/hooks/use-app-manager/use-app-manager.hooks.ts +2 -2
- package/src/hooks/use-cache/use-cache.hooks.ts +33 -41
- package/src/hooks/use-cache/use-cache.types.ts +3 -3
- package/src/hooks/use-emitter/use-emitter.hooks.ts +17 -16
- package/src/hooks/use-fetch/use-fetch.constants.ts +5 -2
- package/src/hooks/use-fetch/use-fetch.hooks.ts +109 -51
- package/src/hooks/use-fetch/use-fetch.types.ts +18 -3
- package/src/hooks/use-listener/use-listener.hooks.ts +19 -27
- package/src/hooks/use-queue/use-queue.constants.ts +2 -2
- package/src/hooks/use-queue/use-queue.hooks.ts +25 -6
- package/src/hooks/use-queue/use-queue.types.ts +8 -2
- package/src/hooks/use-stream/index.ts +2 -0
- package/src/hooks/use-stream/use-stream.hooks.ts +164 -0
- package/src/hooks/use-stream/use-stream.types.ts +53 -0
- package/src/hooks/use-submit/use-submit.constants.ts +2 -2
- package/src/hooks/use-submit/use-submit.hooks.ts +43 -48
- package/src/hooks/use-submit/use-submit.types.ts +9 -9
- package/src/index.ts +1 -0
- package/src/provider/provider.tsx +1 -1
- package/src/provider/provider.types.ts +8 -8
- package/src/utils/index.ts +1 -0
- package/src/utils/tracked-proxy.utils.ts +19 -0
- package/tsconfig.json +1 -1
- package/vite.config.ts +45 -0
- package/.eslintrc.json +0 -11
- package/__tests__/features/use-fetch/use-fetch.suspense.ts +0 -37
- package/__tests__/global.d.ts +0 -1
- package/__tests__/jest.setup.ts +0 -9
- package/dist/index.js +0 -1541
- package/dist/index.js.map +0 -7
- package/jest.config.ts +0 -6
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import {
|
|
2
|
+
expectType,
|
|
3
|
+
expectNotType,
|
|
4
|
+
expectFunctionParametersType,
|
|
5
|
+
expectNotFunctionParametersType,
|
|
6
|
+
} from "@hyper-fetch/testing";
|
|
7
|
+
import type { RequestSendType, ExtractMutationContextType } from "@hyper-fetch/core";
|
|
8
|
+
import { Client } from "@hyper-fetch/core";
|
|
9
|
+
|
|
10
|
+
import type { UseSubmitReturnType } from "hooks/use-submit";
|
|
11
|
+
|
|
12
|
+
const client = new Client({
|
|
13
|
+
url: "http://localhost:3000",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// ---- Request definitions ----
|
|
17
|
+
|
|
18
|
+
const postUser = client.createRequest<{
|
|
19
|
+
response: { id: string; name: string };
|
|
20
|
+
payload: { name: string; email: string };
|
|
21
|
+
}>()({
|
|
22
|
+
method: "POST",
|
|
23
|
+
endpoint: "/users",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const patchUser = client.createRequest<{
|
|
27
|
+
response: { id: string; name: string };
|
|
28
|
+
payload: { name?: string };
|
|
29
|
+
}>()({
|
|
30
|
+
method: "PATCH",
|
|
31
|
+
endpoint: "/users/:userId",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const deleteUser = client.createRequest<{
|
|
35
|
+
response: void;
|
|
36
|
+
}>()({
|
|
37
|
+
method: "DELETE",
|
|
38
|
+
endpoint: "/users/:userId",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const postWithQuery = client.createRequest<{
|
|
42
|
+
response: { id: string };
|
|
43
|
+
payload: { data: string };
|
|
44
|
+
queryParams: { dryRun: boolean };
|
|
45
|
+
}>()({
|
|
46
|
+
method: "POST",
|
|
47
|
+
endpoint: "/resources",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const postWithCustomError = client.createRequest<{
|
|
51
|
+
response: { id: string };
|
|
52
|
+
payload: { value: number };
|
|
53
|
+
error: { code: string; message: string };
|
|
54
|
+
}>()({
|
|
55
|
+
method: "POST",
|
|
56
|
+
endpoint: "/items",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// ---- Type-level tests using return type directly ----
|
|
60
|
+
|
|
61
|
+
type PostUserReturn = UseSubmitReturnType<typeof postUser>;
|
|
62
|
+
type PostWithCustomErrorReturn = UseSubmitReturnType<typeof postWithCustomError>;
|
|
63
|
+
|
|
64
|
+
describe("useSubmit [Types]", () => {
|
|
65
|
+
describe("return type: data", () => {
|
|
66
|
+
it("should type data as response type or null", () => {
|
|
67
|
+
const data = null as unknown as PostUserReturn["data"];
|
|
68
|
+
expectType<{ id: string; name: string } | null>().assert(data);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should not type data as just the response type (missing null)", () => {
|
|
72
|
+
const data = null as unknown as PostUserReturn["data"];
|
|
73
|
+
expectNotType<{ id: string; name: string }>().assert(data);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should type void response correctly", () => {
|
|
77
|
+
type DeleteData = UseSubmitReturnType<typeof deleteUser>["data"];
|
|
78
|
+
const data = null as unknown as DeleteData;
|
|
79
|
+
expectType<void | null>().assert(data);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("return type: error", () => {
|
|
84
|
+
it("should type error as Error or null for default error type", () => {
|
|
85
|
+
const error = null as unknown as PostUserReturn["error"];
|
|
86
|
+
expectType<Error | null>().assert(error);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("should type error with custom error type", () => {
|
|
90
|
+
const error = null as unknown as PostWithCustomErrorReturn["error"];
|
|
91
|
+
expectType<{ code: string; message: string } | Error | null>().assert(error);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("return type: submitting (not loading)", () => {
|
|
96
|
+
it("should have submitting as boolean", () => {
|
|
97
|
+
const submitting = false as PostUserReturn["submitting"];
|
|
98
|
+
expectType<boolean>().assert(submitting);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("return type: success", () => {
|
|
103
|
+
it("should type success as boolean", () => {
|
|
104
|
+
const success = false as PostUserReturn["success"];
|
|
105
|
+
expectType<boolean>().assert(success);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe("submit: payload requirements", () => {
|
|
110
|
+
it("should require payload in submit for requests with payload", () => {
|
|
111
|
+
type SubmitType = RequestSendType<typeof postUser>;
|
|
112
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
113
|
+
expectFunctionParametersType(submit).assert([
|
|
114
|
+
{
|
|
115
|
+
payload: { name: "John", email: "john@test.com" },
|
|
116
|
+
},
|
|
117
|
+
]);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("should not allow submit without payload when payload is required", () => {
|
|
121
|
+
type SubmitType = RequestSendType<typeof postUser>;
|
|
122
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
123
|
+
expectNotFunctionParametersType(submit).assert([
|
|
124
|
+
{
|
|
125
|
+
payload: null,
|
|
126
|
+
},
|
|
127
|
+
]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should allow submit without explicit payload after setPayload", () => {
|
|
131
|
+
const withPayload = postUser.setPayload({ name: "John", email: "john@test.com" });
|
|
132
|
+
type SubmitType = RequestSendType<typeof withPayload>;
|
|
133
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
134
|
+
expectFunctionParametersType(submit).assert([undefined]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe("submit: params requirements", () => {
|
|
139
|
+
it("should require params in submit for requests with URL params", () => {
|
|
140
|
+
type SubmitType = RequestSendType<typeof patchUser>;
|
|
141
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
142
|
+
expectFunctionParametersType(submit).assert([
|
|
143
|
+
{
|
|
144
|
+
params: { userId: "1" },
|
|
145
|
+
payload: { name: "John" },
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("should allow submit without params after setParams", () => {
|
|
151
|
+
const withParams = patchUser.setParams({ userId: "1" });
|
|
152
|
+
type SubmitType = RequestSendType<typeof withParams>;
|
|
153
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
154
|
+
expectFunctionParametersType(submit).assert([
|
|
155
|
+
{
|
|
156
|
+
payload: { name: "John" },
|
|
157
|
+
params: null,
|
|
158
|
+
},
|
|
159
|
+
]);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("submit: query params requirements", () => {
|
|
164
|
+
it("should require queryParams in submit when defined", () => {
|
|
165
|
+
type SubmitType = RequestSendType<typeof postWithQuery>;
|
|
166
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
167
|
+
expectFunctionParametersType(submit).assert([
|
|
168
|
+
{
|
|
169
|
+
payload: { data: "test" },
|
|
170
|
+
queryParams: { dryRun: true },
|
|
171
|
+
},
|
|
172
|
+
]);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("should not allow submit without required queryParams", () => {
|
|
176
|
+
type SubmitType = RequestSendType<typeof postWithQuery>;
|
|
177
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
178
|
+
expectNotFunctionParametersType(submit).assert([
|
|
179
|
+
{
|
|
180
|
+
payload: { data: "test" },
|
|
181
|
+
queryParams: undefined,
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe("submit: no payload/params required", () => {
|
|
188
|
+
it("should allow submit without arguments for DELETE with params set", () => {
|
|
189
|
+
const withParams = deleteUser.setParams({ userId: "1" });
|
|
190
|
+
type SubmitType = RequestSendType<typeof withParams>;
|
|
191
|
+
const submit = (() => null) as unknown as SubmitType;
|
|
192
|
+
expectFunctionParametersType(submit).assert([undefined]);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
describe("return type: event callbacks", () => {
|
|
197
|
+
it("should have onSubmitSuccess callback", () => {
|
|
198
|
+
const cb = (() => null) as unknown as PostUserReturn["onSubmitSuccess"];
|
|
199
|
+
expectType<(callback: any) => void>().assert(cb);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("should have onSubmitError callback", () => {
|
|
203
|
+
const cb = (() => null) as unknown as PostUserReturn["onSubmitError"];
|
|
204
|
+
expectType<(callback: any) => void>().assert(cb);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("should have onSubmitFinished callback", () => {
|
|
208
|
+
const cb = (() => null) as unknown as PostUserReturn["onSubmitFinished"];
|
|
209
|
+
expectType<(callback: any) => void>().assert(cb);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("should have abort function", () => {
|
|
213
|
+
const abort = (() => null) as unknown as PostUserReturn["abort"];
|
|
214
|
+
expectType<() => void>().assert(abort);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("should have onSubmitRequestStart callback", () => {
|
|
218
|
+
const cb = (() => null) as unknown as PostUserReturn["onSubmitRequestStart"];
|
|
219
|
+
expectType<(callback: any) => void>().assert(cb);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("should have onSubmitResponseStart callback", () => {
|
|
223
|
+
const cb = (() => null) as unknown as PostUserReturn["onSubmitResponseStart"];
|
|
224
|
+
expectType<(callback: any) => void>().assert(cb);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe("return type: actions", () => {
|
|
229
|
+
it("should have setData accepting the response type or null", () => {
|
|
230
|
+
const setData = (() => null) as unknown as PostUserReturn["setData"];
|
|
231
|
+
expectFunctionParametersType(setData).assert([{ id: "1", name: "John" }]);
|
|
232
|
+
expectFunctionParametersType(setData).assert([null]);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("should have setError accepting the error type or null", () => {
|
|
236
|
+
const setError = (() => null) as unknown as PostWithCustomErrorReturn["setError"];
|
|
237
|
+
expectFunctionParametersType(setError).assert([{ code: "ERR", message: "fail" }]);
|
|
238
|
+
expectFunctionParametersType(setError).assert([null]);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
describe("return type: bounce and refetch", () => {
|
|
243
|
+
it("should have bounce state with active and reset", () => {
|
|
244
|
+
const bounce = {} as PostUserReturn["bounce"];
|
|
245
|
+
expectType<boolean>().assert(bounce.active);
|
|
246
|
+
expectType<() => void>().assert(bounce.reset);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("should have refetch function", () => {
|
|
250
|
+
const refetch = (() => null) as unknown as PostUserReturn["refetch"];
|
|
251
|
+
expectType<() => void>().assert(refetch);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// ============================
|
|
256
|
+
// Optimistic mutations type inference
|
|
257
|
+
// ============================
|
|
258
|
+
|
|
259
|
+
describe("return type: optimistic mutations (mutationContext)", () => {
|
|
260
|
+
const patchUserOptimistic = patchUser.setOptimistic(() => {
|
|
261
|
+
const snapshot = { prevName: "old" };
|
|
262
|
+
return {
|
|
263
|
+
context: { snapshot },
|
|
264
|
+
rollback: () => {},
|
|
265
|
+
invalidate: [],
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
type OptimisticReturn = UseSubmitReturnType<typeof patchUserOptimistic>;
|
|
270
|
+
|
|
271
|
+
it("should auto-infer mutationContext type in onSubmitSuccess", () => {
|
|
272
|
+
type SuccessParam = Parameters<OptimisticReturn["onSubmitSuccess"]>[0];
|
|
273
|
+
type SuccessParamArg = Parameters<SuccessParam>[0];
|
|
274
|
+
expectType<{ snapshot: { prevName: string } } | undefined>().assert({} as SuccessParamArg["mutationContext"]);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("should auto-infer mutationContext type in onSubmitError", () => {
|
|
278
|
+
type ErrorParam = Parameters<OptimisticReturn["onSubmitError"]>[0];
|
|
279
|
+
type ErrorParamArg = Parameters<ErrorParam>[0];
|
|
280
|
+
expectType<{ snapshot: { prevName: string } } | undefined>().assert({} as ErrorParamArg["mutationContext"]);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("should auto-infer mutationContext type in onSubmitFinished", () => {
|
|
284
|
+
type FinishedParam = Parameters<OptimisticReturn["onSubmitFinished"]>[0];
|
|
285
|
+
type FinishedParamArg = Parameters<FinishedParam>[0];
|
|
286
|
+
expectType<{ snapshot: { prevName: string } } | undefined>().assert({} as FinishedParamArg["mutationContext"]);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("should auto-infer mutationContext type in onSubmitAbort", () => {
|
|
290
|
+
type AbortParam = Parameters<OptimisticReturn["onSubmitAbort"]>[0];
|
|
291
|
+
type AbortParamArg = Parameters<AbortParam>[0];
|
|
292
|
+
expectType<{ snapshot: { prevName: string } } | undefined>().assert({} as AbortParamArg["mutationContext"]);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it("should have undefined mutationContext when no setOptimistic is used", () => {
|
|
296
|
+
type NonOptReturn = UseSubmitReturnType<typeof postUser>;
|
|
297
|
+
type SuccessParam = Parameters<NonOptReturn["onSubmitSuccess"]>[0];
|
|
298
|
+
type SuccessParamArg = Parameters<SuccessParam>[0];
|
|
299
|
+
expectType<undefined>().assert({} as unknown as SuccessParamArg["mutationContext"]);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it("should correctly extract mutation context with ExtractMutationContextType", () => {
|
|
303
|
+
type WithOptimistic = ExtractMutationContextType<typeof patchUserOptimistic>;
|
|
304
|
+
expectType<{ snapshot: { prevName: string } }>().assert({} as WithOptimistic);
|
|
305
|
+
|
|
306
|
+
type WithoutOptimistic = ExtractMutationContextType<typeof postUser>;
|
|
307
|
+
expectType<undefined>().assert({} as unknown as WithoutOptimistic);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("should preserve mutationContext type through chaining", () => {
|
|
311
|
+
const chained = patchUserOptimistic.setParams({ userId: "1" }).setRetry(3);
|
|
312
|
+
type ChainedCtx = ExtractMutationContextType<typeof chained>;
|
|
313
|
+
expectType<{ snapshot: { prevName: string } }>().assert({} as ChainedCtx);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it("should correctly type payload in optimistic callback args", () => {
|
|
317
|
+
const withTypedPayload = patchUser.setOptimistic(({ payload }) => {
|
|
318
|
+
expectType<{ name?: string }>().assert(payload);
|
|
319
|
+
return { context: { saved: payload } };
|
|
320
|
+
});
|
|
321
|
+
type Ctx = ExtractMutationContextType<typeof withTypedPayload>;
|
|
322
|
+
expectType<{ saved: { name?: string | undefined } }>().assert({} as Ctx);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { RenderHookResult } from "@testing-library/react";
|
|
2
|
+
import { waitFor } from "@testing-library/react";
|
|
3
|
+
import type { ResponseType, RequestInstance, AdapterInstance } from "@hyper-fetch/core";
|
|
3
4
|
|
|
4
|
-
import { UseFetchReturnType } from "hooks/use-fetch";
|
|
5
|
-
import { UseSubmitReturnType } from "hooks/use-submit";
|
|
5
|
+
import type { UseFetchReturnType } from "hooks/use-fetch";
|
|
6
|
+
import type { UseSubmitReturnType } from "hooks/use-submit";
|
|
6
7
|
import { getCurrentState } from "../utils";
|
|
7
8
|
|
|
8
9
|
export const testInitialState = <H extends RenderHookResult<any, any>>(render: H, expectedLoading = true) => {
|
package/__tests__/tsconfig.json
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["dom", "dom.iterable", "ESNext"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
3
8
|
"strict": true,
|
|
4
9
|
"noEmit": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"noUnusedLocals": false,
|
|
16
|
+
"noUnusedParameters": false,
|
|
17
|
+
"types": ["vitest/globals", "jest-extended", "@testing-library/jest-dom", "@types/node"],
|
|
5
18
|
"baseUrl": "../src",
|
|
6
|
-
"
|
|
7
|
-
|
|
19
|
+
"paths": {
|
|
20
|
+
"hooks/*": ["hooks/*"],
|
|
21
|
+
"helpers/*": ["helpers/*"],
|
|
22
|
+
"utils/*": ["utils/*"],
|
|
23
|
+
"provider": ["provider"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"include": ["**/*.ts", "**/*.tsx", "../../../global.d.ts", "../../../vitest.d.ts"]
|
|
8
27
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
ResponseType,
|
|
3
3
|
ResponseDetailsType,
|
|
4
4
|
RequestInstance,
|
|
5
5
|
ExtractResponseType,
|
|
6
6
|
ExtractErrorType,
|
|
7
7
|
ExtractAdapterType,
|
|
8
|
-
|
|
9
|
-
xhrExtra,
|
|
8
|
+
HttpAdapterType,
|
|
10
9
|
ExtractAdapterStatusType,
|
|
11
10
|
ExtractAdapterExtraType,
|
|
12
11
|
} from "@hyper-fetch/core";
|
|
12
|
+
import { xhrExtra } from "@hyper-fetch/core";
|
|
13
13
|
|
|
14
14
|
export const createCacheData = <T extends RequestInstance>(
|
|
15
15
|
request: T,
|
|
@@ -39,15 +39,17 @@ export const createCacheData = <T extends RequestInstance>(
|
|
|
39
39
|
responseTimestamp: +new Date(),
|
|
40
40
|
isCanceled: false,
|
|
41
41
|
isOffline: false,
|
|
42
|
+
willRetry: false,
|
|
42
43
|
...response?.details,
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
request.client.cache.storage.set<any, any,
|
|
46
|
+
request.client.cache.storage.set<any, any, HttpAdapterType>(request.cacheKey, {
|
|
46
47
|
...(dataValue as any),
|
|
47
48
|
...detailsValue,
|
|
48
49
|
staleTime: 1000,
|
|
49
50
|
version: request.client.cache.version,
|
|
50
51
|
cacheTime: Infinity,
|
|
52
|
+
cached: true,
|
|
51
53
|
});
|
|
52
54
|
return [dataValue, detailsValue] as const;
|
|
53
55
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { EmitterOptionsType,
|
|
1
|
+
import type { EmitterOptionsType, WebsocketAdapterType } from "@hyper-fetch/sockets";
|
|
2
|
+
import { Socket } from "@hyper-fetch/sockets";
|
|
2
3
|
|
|
3
4
|
export const createEmitter = <ResponseType = { name: string; age: number }>(
|
|
4
|
-
options?: Partial<EmitterOptionsType<any,
|
|
5
|
+
options?: Partial<EmitterOptionsType<any, WebsocketAdapterType>>,
|
|
5
6
|
) => {
|
|
6
7
|
return new Socket({ url: "ws://localhost:1234" }).createEmitter<ResponseType>()({ topic: "some-event", ...options });
|
|
7
8
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ListenerOptionsType,
|
|
1
|
+
import type { ListenerOptionsType, WebsocketAdapterType } from "@hyper-fetch/sockets";
|
|
2
|
+
import { Socket } from "@hyper-fetch/sockets";
|
|
2
3
|
|
|
3
4
|
export const createListener = <ResponseType = { name: string; age: number }>(
|
|
4
|
-
options?: Partial<ListenerOptionsType<any,
|
|
5
|
+
options?: Partial<ListenerOptionsType<any, WebsocketAdapterType>>,
|
|
5
6
|
) => {
|
|
6
7
|
return new Socket({ url: "ws://localhost:1234" }).createListener<ResponseType>()({
|
|
7
8
|
...options,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { RequestOptionsType,
|
|
1
|
+
import type { RequestOptionsType, FetchAdapterOptionsType } from "@hyper-fetch/core";
|
|
2
2
|
|
|
3
3
|
import { client } from "./client.utils";
|
|
4
4
|
|
|
5
|
-
export const createRequest = <ResponseType = any, PayloadType = any>(
|
|
6
|
-
options?: Partial<RequestOptionsType<
|
|
5
|
+
export const createRequest = <ResponseType = any, PayloadType = any, Endpoint extends string = "/shared-endpoint">(
|
|
6
|
+
options?: Partial<RequestOptionsType<Endpoint, FetchAdapterOptionsType>>,
|
|
7
7
|
) => {
|
|
8
|
-
return client.createRequest<{ response: ResponseType; payload: PayloadType; error: Error }>()({
|
|
9
|
-
endpoint: "/shared-endpoint",
|
|
8
|
+
return client.createRequest<{ response: ResponseType; payload: PayloadType; error: Error; queryParams: any }>()({
|
|
9
|
+
endpoint: "/shared-endpoint" as Endpoint,
|
|
10
10
|
...options,
|
|
11
|
-
});
|
|
11
|
+
} as RequestOptionsType<Endpoint, FetchAdapterOptionsType>);
|
|
12
12
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RequestInstance } from "@hyper-fetch/core";
|
|
1
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
2
2
|
import { renderHook } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { UseCacheOptionsType } from "hooks/use-cache";
|
|
5
|
+
import { useCache } from "hooks/use-cache";
|
|
5
6
|
|
|
6
7
|
export const renderUseCache = <T extends RequestInstance>(request: T, options?: UseCacheOptionsType<T>) => {
|
|
7
8
|
return renderHook((rerenderOptions: UseCacheOptionsType<RequestInstance> & { request?: RequestInstance }) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react";
|
|
2
|
-
import { EmitterInstance } from "@hyper-fetch/sockets";
|
|
2
|
+
import type { EmitterInstance } from "@hyper-fetch/sockets";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { UseEmitterOptionsType } from "hooks/use-emitter";
|
|
5
|
+
import { useEmitter } from "hooks/use-emitter";
|
|
5
6
|
|
|
6
7
|
export const renderUseEmitter = <T extends EmitterInstance>(Emitter: T, options?: UseEmitterOptionsType) => {
|
|
7
8
|
return renderHook((rerenderOptions: UseEmitterOptionsType & { emitter?: EmitterInstance }) => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { RequestInstance } from "@hyper-fetch/core";
|
|
1
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
2
2
|
import { renderHook } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { UseFetchOptionsType } from "hooks/use-fetch";
|
|
5
|
+
import { useFetch } from "hooks/use-fetch";
|
|
5
6
|
|
|
6
7
|
export const renderUseFetch = <T extends RequestInstance>(request: T, options?: UseFetchOptionsType<T>) => {
|
|
7
8
|
return renderHook((rerenderOptions: UseFetchOptionsType<RequestInstance> & { request?: RequestInstance }) => {
|
|
8
9
|
const { request: req, ...rest } = rerenderOptions || {};
|
|
9
|
-
return useFetch(req || request, { dependencyTracking: false, ...options, ...rest });
|
|
10
|
+
return useFetch(req || request, { dependencyTracking: false, ...options, ...rest } as UseFetchOptionsType<T>);
|
|
10
11
|
});
|
|
11
12
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react";
|
|
2
|
-
import { ListenerInstance } from "@hyper-fetch/sockets";
|
|
2
|
+
import type { ListenerInstance } from "@hyper-fetch/sockets";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { UseListenerOptionsType } from "hooks/use-listener";
|
|
5
|
+
import { useListener } from "hooks/use-listener";
|
|
5
6
|
|
|
6
7
|
export const renderUseListener = <T extends ListenerInstance>(listener: T, options?: UseListenerOptionsType) => {
|
|
7
8
|
return renderHook((rerenderOptions: UseListenerOptionsType & { listener?: ListenerInstance }) => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { renderHook } from "@testing-library/react";
|
|
2
|
-
import { RequestInstance
|
|
2
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
3
|
+
import { getRequestDispatcher, getProgressData } from "@hyper-fetch/core";
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import type { UseQueueOptionsType } from "hooks/use-queue";
|
|
6
|
+
import { useQueue } from "hooks/use-queue";
|
|
5
7
|
|
|
6
8
|
export const renderUseQueue = <T extends RequestInstance>(request: T, options?: UseQueueOptionsType) => {
|
|
7
9
|
return renderHook((rerenderOptions: UseQueueOptionsType & { request?: RequestInstance }) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RequestInstance } from "@hyper-fetch/core";
|
|
1
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
2
2
|
import { renderHook } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { UseRequestEventsPropsType, UseTrackedStateProps } from "helpers";
|
|
5
|
+
import { useTrackedState, useRequestEvents } from "helpers";
|
|
5
6
|
import { isEqual } from "utils";
|
|
6
7
|
|
|
7
8
|
export const renderUseRequestEvents = <Request extends RequestInstance>(
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Mock } from "vitest";
|
|
2
|
+
import type { Socket } from "@hyper-fetch/sockets";
|
|
2
3
|
import { renderHook } from "@testing-library/react";
|
|
3
4
|
|
|
4
5
|
import { useSocketState } from "helpers";
|
|
5
6
|
|
|
6
|
-
export const renderUseSocketState = (socket: Socket, { onRender }: { onRender?:
|
|
7
|
+
export const renderUseSocketState = (socket: Socket, { onRender }: { onRender?: Mock } = {}) => {
|
|
7
8
|
return renderHook(() => {
|
|
8
9
|
onRender?.();
|
|
9
10
|
return useSocketState(socket, { dependencyTracking: true });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RequestInstance } from "@hyper-fetch/core";
|
|
1
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
2
2
|
import { renderHook } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { UseSubmitOptionsType } from "hooks/use-submit";
|
|
5
|
+
import { useSubmit } from "hooks/use-submit";
|
|
5
6
|
|
|
6
7
|
export const renderUseSubmit = <T extends RequestInstance>(request: T, options?: UseSubmitOptionsType<T>) => {
|
|
7
8
|
return renderHook((rerenderOptions: UseSubmitOptionsType<T> & { request?: T }) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RequestInstance } from "@hyper-fetch/core";
|
|
1
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
2
2
|
import { renderHook } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { UseTrackedStateProps } from "helpers";
|
|
5
|
+
import { useTrackedState } from "helpers";
|
|
5
6
|
import { isEqual } from "utils";
|
|
6
7
|
|
|
7
8
|
export const renderUseTrackedState = <Request extends RequestInstance>(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/use-request-events/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RequestInstance } from '@hyper-fetch/core';
|
|
2
|
+
import { UseRequestEventsReturnType, UseRequestEventsPropsType } from '..';
|
|
3
|
+
/**
|
|
4
|
+
* This is helper hook that handles main Hyper-Fetch event/data flow
|
|
5
|
+
* @internal
|
|
6
|
+
* @param options
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const useRequestEvents: <R extends RequestInstance>({ request, dispatcher, logger, actions, setCacheData, getIsDataProcessing, }: UseRequestEventsPropsType<R>) => UseRequestEventsReturnType<R>;
|
|
10
|
+
//# sourceMappingURL=use-request-events.hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-request-events.hooks.d.ts","sourceRoot":"","sources":["../../../src/helpers/use-request-events/use-request-events.hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,eAAe,EAQhB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAOV,0BAA0B,EAC1B,yBAAyB,EAE1B,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,eAAe,EAAE,8EAOzD,yBAAyB,CAAC,CAAC,CAAC,KAAG,0BAA0B,CAAC,CAAC,CA+T7D,CAAC"}
|