@oxog/requestkit 1.2.0 → 1.3.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/CHANGELOG.md +34 -1
- package/README.md +34 -9
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/{types-BjdiOCBe.d.cts → types-brKlQRDe.d.cts} +71 -3
- package/dist/{types-BjdiOCBe.d.ts → types-brKlQRDe.d.ts} +71 -3
- package/package.json +22 -9
|
@@ -174,15 +174,83 @@ interface CancelTokenSource {
|
|
|
174
174
|
interface Cancel {
|
|
175
175
|
message?: string;
|
|
176
176
|
}
|
|
177
|
+
/** Options without `cancelable: true` or `raw: true`: the method resolves to the body. */
|
|
178
|
+
type PlainOptions = RequestOptions & {
|
|
179
|
+
cancelable?: false;
|
|
180
|
+
raw?: false;
|
|
181
|
+
};
|
|
182
|
+
/** Options that make a method resolve to a `CancelableRequest` (`cancelable: true`). */
|
|
183
|
+
type CancelableOptions = RequestOptions & {
|
|
184
|
+
cancelable: true;
|
|
185
|
+
};
|
|
186
|
+
/** Options that make a method resolve to a `RequestResponse` (`raw: true`). */
|
|
187
|
+
type RawOptions = RequestOptions & {
|
|
188
|
+
raw: true;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Result of a `raw: true` request. A type argument that is already a
|
|
192
|
+
* `RequestResponse` (as in `get<RequestResponse<User>>(url, { raw: true })`)
|
|
193
|
+
* is kept as-is; any other `T` describes the body: `RequestResponse<T>`.
|
|
194
|
+
*/
|
|
195
|
+
type RawResult<T> = [T] extends [RequestResponse<unknown>] ? T : RequestResponse<T>;
|
|
196
|
+
/**
|
|
197
|
+
* Result of a `cancelable: true` request. A type argument that is already a
|
|
198
|
+
* `CancelableRequest` is kept as-is; any other `T` describes the body.
|
|
199
|
+
*/
|
|
200
|
+
type CancelableResult<T> = [T] extends [CancelableRequest<unknown>] ? T : CancelableRequest<T>;
|
|
177
201
|
interface RequestClient {
|
|
202
|
+
get<T = unknown>(url: string, options?: PlainOptions): Promise<T>;
|
|
203
|
+
get<T = unknown>(url: string, options: CancelableOptions & RawOptions): Promise<CancelableResult<RawResult<T>>>;
|
|
204
|
+
get<T = unknown>(url: string, options: CancelableOptions): Promise<CancelableResult<T>>;
|
|
205
|
+
get<T = unknown>(url: string, options: RawOptions): Promise<RawResult<T>>;
|
|
178
206
|
get<T = unknown>(url: string, options?: RequestOptions): Promise<T>;
|
|
207
|
+
post<T = unknown>(url: string, body?: unknown, options?: PlainOptions): Promise<T>;
|
|
208
|
+
post<T = unknown>(url: string, body: unknown, options: CancelableOptions & RawOptions): Promise<CancelableResult<RawResult<T>>>;
|
|
209
|
+
post<T = unknown>(url: string, body: unknown, options: CancelableOptions): Promise<CancelableResult<T>>;
|
|
210
|
+
post<T = unknown>(url: string, body: unknown, options: RawOptions): Promise<RawResult<T>>;
|
|
179
211
|
post<T = unknown>(url: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
212
|
+
put<T = unknown>(url: string, body?: unknown, options?: PlainOptions): Promise<T>;
|
|
213
|
+
put<T = unknown>(url: string, body: unknown, options: CancelableOptions & RawOptions): Promise<CancelableResult<RawResult<T>>>;
|
|
214
|
+
put<T = unknown>(url: string, body: unknown, options: CancelableOptions): Promise<CancelableResult<T>>;
|
|
215
|
+
put<T = unknown>(url: string, body: unknown, options: RawOptions): Promise<RawResult<T>>;
|
|
180
216
|
put<T = unknown>(url: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
217
|
+
patch<T = unknown>(url: string, body?: unknown, options?: PlainOptions): Promise<T>;
|
|
218
|
+
patch<T = unknown>(url: string, body: unknown, options: CancelableOptions & RawOptions): Promise<CancelableResult<RawResult<T>>>;
|
|
219
|
+
patch<T = unknown>(url: string, body: unknown, options: CancelableOptions): Promise<CancelableResult<T>>;
|
|
220
|
+
patch<T = unknown>(url: string, body: unknown, options: RawOptions): Promise<RawResult<T>>;
|
|
181
221
|
patch<T = unknown>(url: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
222
|
+
delete<T = unknown>(url: string, options?: PlainOptions): Promise<T>;
|
|
223
|
+
delete<T = unknown>(url: string, options: CancelableOptions & RawOptions): Promise<CancelableResult<RawResult<T>>>;
|
|
224
|
+
delete<T = unknown>(url: string, options: CancelableOptions): Promise<CancelableResult<T>>;
|
|
225
|
+
delete<T = unknown>(url: string, options: RawOptions): Promise<RawResult<T>>;
|
|
182
226
|
delete<T = unknown>(url: string, options?: RequestOptions): Promise<T>;
|
|
227
|
+
head(url: string, options?: PlainOptions): Promise<void>;
|
|
228
|
+
head(url: string, options: CancelableOptions & RawOptions): Promise<CancelableRequest<RequestResponse<void>>>;
|
|
229
|
+
head(url: string, options: CancelableOptions): Promise<CancelableRequest<void>>;
|
|
230
|
+
head(url: string, options: RawOptions): Promise<RequestResponse<void>>;
|
|
183
231
|
head(url: string, options?: RequestOptions): Promise<void>;
|
|
232
|
+
options(url: string, options?: PlainOptions): Promise<void>;
|
|
233
|
+
options(url: string, options: CancelableOptions & RawOptions): Promise<CancelableRequest<RequestResponse<void>>>;
|
|
234
|
+
options(url: string, options: CancelableOptions): Promise<CancelableRequest<void>>;
|
|
235
|
+
options(url: string, options: RawOptions): Promise<RequestResponse<void>>;
|
|
184
236
|
options(url: string, options?: RequestOptions): Promise<void>;
|
|
237
|
+
request<T = unknown>(url: string, options?: PlainOptions): Promise<T>;
|
|
238
|
+
request<T = unknown>(url: string, options: CancelableOptions & RawOptions): Promise<CancelableResult<RawResult<T>>>;
|
|
239
|
+
request<T = unknown>(url: string, options: CancelableOptions): Promise<CancelableResult<T>>;
|
|
240
|
+
request<T = unknown>(url: string, options: RawOptions): Promise<RawResult<T>>;
|
|
185
241
|
request<T = unknown>(url: string, options?: RequestOptions): Promise<T>;
|
|
242
|
+
request<T = unknown>(options: PlainOptions & {
|
|
243
|
+
url: string;
|
|
244
|
+
}): Promise<T>;
|
|
245
|
+
request<T = unknown>(options: CancelableOptions & RawOptions & {
|
|
246
|
+
url: string;
|
|
247
|
+
}): Promise<CancelableResult<RawResult<T>>>;
|
|
248
|
+
request<T = unknown>(options: CancelableOptions & {
|
|
249
|
+
url: string;
|
|
250
|
+
}): Promise<CancelableResult<T>>;
|
|
251
|
+
request<T = unknown>(options: RawOptions & {
|
|
252
|
+
url: string;
|
|
253
|
+
}): Promise<RawResult<T>>;
|
|
186
254
|
request<T = unknown>(options: RequestOptions & {
|
|
187
255
|
url: string;
|
|
188
256
|
}): Promise<T>;
|
|
@@ -255,9 +323,9 @@ interface UseMutationResult<T, V> {
|
|
|
255
323
|
}
|
|
256
324
|
interface UseInfiniteQueryOptions<T> {
|
|
257
325
|
/** Get next page param from last page */
|
|
258
|
-
getNextPageParam: (lastPage: T, pages: T[]) => unknown
|
|
326
|
+
getNextPageParam: (lastPage: T, pages: T[]) => unknown;
|
|
259
327
|
/** Get previous page param from first page */
|
|
260
|
-
getPreviousPageParam?: (firstPage: T, pages: T[]) => unknown
|
|
328
|
+
getPreviousPageParam?: (firstPage: T, pages: T[]) => unknown;
|
|
261
329
|
/** Enable/disable query */
|
|
262
330
|
enabled?: boolean;
|
|
263
331
|
/** @deprecated Not implemented: has no effect in useInfiniteQuery. */
|
|
@@ -280,4 +348,4 @@ interface UseInfiniteQueryResult<T> {
|
|
|
280
348
|
refetch: () => Promise<void>;
|
|
281
349
|
}
|
|
282
350
|
|
|
283
|
-
export type { ClientConfig as C, ErrorCode as E, HttpMethod as H, InternalRequestConfig as I, ParamsSerializer as P, RequestClient as R, TransformFn as T, UseRequestOptions as U,
|
|
351
|
+
export type { ClientConfig as C, ErrorCode as E, HttpMethod as H, InternalRequestConfig as I, ParamsSerializer as P, RequestClient as R, TransformFn as T, UseRequestOptions as U, RequestOptions as a, UseRequestResult as b, UseQueryOptions as c, UseQueryResult as d, UseMutationOptions as e, UseMutationResult as f, UseInfiniteQueryOptions as g, UseInfiniteQueryResult as h, RequestError as i, CancelTokenSource as j, Cancel as k, CancelToken as l, CancelableRequest as m, ErrorHook as n, InterceptorHandler as o, InterceptorManager as p, Interceptors as q, Progress as r, ProgressCallback as s, RequestHook as t, RequestResponse as u, RequestTransport as v, ResponseHook as w, ResponseType as x, RetryConfig as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxog/requestkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Zero-dependency HTTP client built on native fetch with interceptors, retry, and progress tracking",
|
|
5
5
|
"author": "Ersin KOÇ",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,13 @@
|
|
|
30
30
|
"main": "./dist/index.cjs",
|
|
31
31
|
"module": "./dist/index.js",
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
|
+
"typesVersions": {
|
|
34
|
+
"*": {
|
|
35
|
+
"react": [
|
|
36
|
+
"./dist/react/index.d.ts"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
33
40
|
"exports": {
|
|
34
41
|
".": {
|
|
35
42
|
"import": {
|
|
@@ -66,40 +73,46 @@
|
|
|
66
73
|
"test": "vitest run",
|
|
67
74
|
"test:watch": "vitest",
|
|
68
75
|
"test:coverage": "vitest run --coverage",
|
|
69
|
-
"lint": "eslint src tests
|
|
76
|
+
"lint": "eslint src tests --max-warnings=0",
|
|
70
77
|
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
71
|
-
"clean": "
|
|
78
|
+
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
72
79
|
"test:package": "node scripts/check-package.mjs",
|
|
73
80
|
"prepublishOnly": "npm run check && npm run build && npm run test:package",
|
|
74
81
|
"check": "npm run lint && npm run typecheck && npm run test:coverage"
|
|
75
82
|
},
|
|
76
83
|
"devDependencies": {
|
|
84
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
77
85
|
"@eslint/js": "10.0.1",
|
|
78
86
|
"@testing-library/react": "^14.1.2",
|
|
79
87
|
"@types/node": "^20.10.6",
|
|
80
88
|
"@types/react": "^18.2.46",
|
|
81
89
|
"@types/react-dom": "^18.2.18",
|
|
82
|
-
"@vitest/coverage-v8": "^
|
|
90
|
+
"@vitest/coverage-v8": "^4.1.12",
|
|
83
91
|
"eslint": "10.16.0",
|
|
84
92
|
"eslint-plugin-react-hooks": "7.1.1",
|
|
93
|
+
"globals": "^17.0.0",
|
|
85
94
|
"jsdom": "^23.2.0",
|
|
95
|
+
"publint": "^0.3.25",
|
|
86
96
|
"react": "^18.2.0",
|
|
87
97
|
"react-dom": "^18.2.0",
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"typescript": "^5.3.3",
|
|
98
|
+
"tsup": "^8.5.0",
|
|
99
|
+
"typescript": "^5.9.3",
|
|
91
100
|
"typescript-eslint": "8.74.0",
|
|
92
|
-
"vitest": "^
|
|
101
|
+
"vitest": "^4.1.12"
|
|
93
102
|
},
|
|
94
103
|
"peerDependencies": {
|
|
104
|
+
"@types/react": ">=17.0.0",
|
|
95
105
|
"react": ">=17.0.0"
|
|
96
106
|
},
|
|
97
107
|
"peerDependenciesMeta": {
|
|
108
|
+
"@types/react": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
98
111
|
"react": {
|
|
99
112
|
"optional": true
|
|
100
113
|
}
|
|
101
114
|
},
|
|
102
115
|
"engines": {
|
|
103
|
-
"node": ">=18
|
|
116
|
+
"node": ">=18"
|
|
104
117
|
}
|
|
105
118
|
}
|