keq 2.8.8 → 2.8.10
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
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.8.10](https://github.com/keq-request/keq/compare/v2.8.9...v2.8.10) (2024-12-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* cannot extend KeqOperations ([908983d](https://github.com/keq-request/keq/commit/908983dd12037befb85bd944801a6b111979d4ce))
|
|
11
|
+
|
|
12
|
+
## [2.8.9](https://github.com/keq-request/keq/compare/v2.8.8...v2.8.9) (2024-12-22)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* wrong type of .query/.set/.params ([b11b959](https://github.com/keq-request/keq/commit/b11b9591dbff167a2cbd4f925d196bbc83e39b63))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Performance Improvements
|
|
21
|
+
|
|
22
|
+
* support stict type checking for .send/.params/.set/.query ([2c82b01](https://github.com/keq-request/keq/commit/2c82b016a5032422ae52455c267066ac2c8ba7f0))
|
|
23
|
+
|
|
5
24
|
## [2.8.8](https://github.com/keq-request/keq/compare/v2.8.7...v2.8.8) (2024-12-10)
|
|
6
25
|
|
|
7
26
|
|
package/dist/esm/src/keq.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { KeqOptionsParameter, KeqOptionsReturnType } from './types/keq-opti
|
|
|
8
8
|
import type { KeqQueryValue } from './types/keq-query-value.js';
|
|
9
9
|
import type { CommonContentType, ShorthandContentType } from './types/content-type.js';
|
|
10
10
|
import type { KeqContextOptions } from './types/keq-context.js';
|
|
11
|
-
import type { ExtractFields, ExtractFiles,
|
|
11
|
+
import type { ExtractFields, ExtractFiles, KeqBaseOperation, KeqOperation } from './types/keq-operation.js';
|
|
12
12
|
import type { KeqContextRequestBody } from './types/keq-context-request.js';
|
|
13
13
|
/**
|
|
14
14
|
* @description Keq 扩展 API,人性化的常用的API
|
|
@@ -23,8 +23,8 @@ export declare class Keq<OUTPUT, OPERATION extends Omit<KeqOperation, 'responseB
|
|
|
23
23
|
*
|
|
24
24
|
* @description 设置请求头
|
|
25
25
|
*/
|
|
26
|
-
set(headers:
|
|
27
|
-
set<T extends keyof
|
|
26
|
+
set<K extends 'strict'>(headers: OPERATION['requestHeaders']): this;
|
|
27
|
+
set<K extends 'strict', T extends keyof OPERATION['requestHeaders']>(name: T, value: OPERATION['requestHeaders'][T]): this;
|
|
28
28
|
set<T extends keyof KeqBaseOperation['requestHeaders']>(name: T, value: KeqBaseOperation['requestHeaders'][T]): this;
|
|
29
29
|
set(headers: Headers): this;
|
|
30
30
|
set(headers: Record<string, string>): this;
|
|
@@ -32,15 +32,15 @@ export declare class Keq<OUTPUT, OPERATION extends Omit<KeqOperation, 'responseB
|
|
|
32
32
|
/**
|
|
33
33
|
* Set request query/searchParams
|
|
34
34
|
*/
|
|
35
|
-
query(key:
|
|
36
|
-
query<T extends keyof
|
|
35
|
+
query<K extends 'strict'>(key: OPERATION['requestQuery']): this;
|
|
36
|
+
query<K extends 'strict', T extends keyof OPERATION['requestQuery']>(key: T, value: OPERATION['requestQuery'][T]): this;
|
|
37
37
|
query(key: Record<string, KeqQueryValue | KeqQueryValue[]>): this;
|
|
38
38
|
query(key: string, value: KeqQueryValue | KeqQueryValue[]): this;
|
|
39
39
|
/**
|
|
40
40
|
* Set request route params
|
|
41
41
|
*/
|
|
42
|
-
params(key:
|
|
43
|
-
params<T extends keyof
|
|
42
|
+
params<K extends 'strict'>(key: OPERATION['requestParams']): this;
|
|
43
|
+
params<K extends 'strict', T extends keyof OPERATION['requestParams']>(key: T, value: OPERATION['requestParams'][T]): this;
|
|
44
44
|
params(key: Record<string, string | number>): this;
|
|
45
45
|
params(key: string, value: string | number): this;
|
|
46
46
|
/**
|
|
@@ -61,7 +61,8 @@ export declare class Keq<OUTPUT, OPERATION extends Omit<KeqOperation, 'responseB
|
|
|
61
61
|
/**
|
|
62
62
|
* set request body
|
|
63
63
|
*/
|
|
64
|
-
send(value: OPERATION['requestBody']
|
|
64
|
+
send<K extends 'strict'>(value: OPERATION['requestBody']): this;
|
|
65
|
+
send(value: object): this;
|
|
65
66
|
send(value: FormData): this;
|
|
66
67
|
send(value: URLSearchParams): this;
|
|
67
68
|
send(value: Array<any>): this;
|
package/dist/esm/src/keq.js
CHANGED
|
@@ -15,16 +15,13 @@ export interface KeqOperation {
|
|
|
15
15
|
requestBody: FormData | URLSearchParams | object | Array<any> | string;
|
|
16
16
|
responseBody: any;
|
|
17
17
|
}
|
|
18
|
-
export type ExtractHeaders<T extends Pick<KeqOperation, 'requestHeaders'>> = ExtractProperty<T['requestHeaders'], string>;
|
|
19
|
-
export type ExtractQuery<T extends Pick<KeqOperation, 'requestQuery'>> = ExtractProperty<T['requestQuery'], string | string[]>;
|
|
20
|
-
export type ExtractParams<T extends Pick<KeqOperation, 'requestParams'>> = ExtractProperty<T['requestParams'], string>;
|
|
21
18
|
export type ExtractFields<T extends Pick<KeqOperation, 'requestBody'>> = ExtractProperty<Exclude<Extract<T['requestBody'], object>, FormData | URLSearchParams | Array<any>>, string>;
|
|
22
19
|
export type ExtractFiles<T extends Pick<KeqOperation, 'requestBody'>> = ExtractProperty<Exclude<Extract<T['requestBody'], object>, FormData | URLSearchParams | Array<any>>, Buffer | Blob | File>;
|
|
23
|
-
export
|
|
20
|
+
export interface KeqOperations {
|
|
24
21
|
[url: string]: {
|
|
25
22
|
[method in KeqContextRequestMethod]?: KeqOperation;
|
|
26
23
|
};
|
|
27
|
-
}
|
|
24
|
+
}
|
|
28
25
|
export type FlattenOperations<T extends KeqOperations, M extends KeqContextRequestMethod> = {
|
|
29
26
|
[P in keyof T as T[P][M] extends KeqOperation ? P : never]: T[P][M] extends KeqOperation ? T[P][M] : never;
|
|
30
27
|
};
|
package/dist/umd/src/keq.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { KeqOptionsParameter, KeqOptionsReturnType } from './types/keq-opti
|
|
|
8
8
|
import type { KeqQueryValue } from './types/keq-query-value.js';
|
|
9
9
|
import type { CommonContentType, ShorthandContentType } from './types/content-type.js';
|
|
10
10
|
import type { KeqContextOptions } from './types/keq-context.js';
|
|
11
|
-
import type { ExtractFields, ExtractFiles,
|
|
11
|
+
import type { ExtractFields, ExtractFiles, KeqBaseOperation, KeqOperation } from './types/keq-operation.js';
|
|
12
12
|
import type { KeqContextRequestBody } from './types/keq-context-request.js';
|
|
13
13
|
/**
|
|
14
14
|
* @description Keq 扩展 API,人性化的常用的API
|
|
@@ -23,8 +23,8 @@ export declare class Keq<OUTPUT, OPERATION extends Omit<KeqOperation, 'responseB
|
|
|
23
23
|
*
|
|
24
24
|
* @description 设置请求头
|
|
25
25
|
*/
|
|
26
|
-
set(headers:
|
|
27
|
-
set<T extends keyof
|
|
26
|
+
set<K extends 'strict'>(headers: OPERATION['requestHeaders']): this;
|
|
27
|
+
set<K extends 'strict', T extends keyof OPERATION['requestHeaders']>(name: T, value: OPERATION['requestHeaders'][T]): this;
|
|
28
28
|
set<T extends keyof KeqBaseOperation['requestHeaders']>(name: T, value: KeqBaseOperation['requestHeaders'][T]): this;
|
|
29
29
|
set(headers: Headers): this;
|
|
30
30
|
set(headers: Record<string, string>): this;
|
|
@@ -32,15 +32,15 @@ export declare class Keq<OUTPUT, OPERATION extends Omit<KeqOperation, 'responseB
|
|
|
32
32
|
/**
|
|
33
33
|
* Set request query/searchParams
|
|
34
34
|
*/
|
|
35
|
-
query(key:
|
|
36
|
-
query<T extends keyof
|
|
35
|
+
query<K extends 'strict'>(key: OPERATION['requestQuery']): this;
|
|
36
|
+
query<K extends 'strict', T extends keyof OPERATION['requestQuery']>(key: T, value: OPERATION['requestQuery'][T]): this;
|
|
37
37
|
query(key: Record<string, KeqQueryValue | KeqQueryValue[]>): this;
|
|
38
38
|
query(key: string, value: KeqQueryValue | KeqQueryValue[]): this;
|
|
39
39
|
/**
|
|
40
40
|
* Set request route params
|
|
41
41
|
*/
|
|
42
|
-
params(key:
|
|
43
|
-
params<T extends keyof
|
|
42
|
+
params<K extends 'strict'>(key: OPERATION['requestParams']): this;
|
|
43
|
+
params<K extends 'strict', T extends keyof OPERATION['requestParams']>(key: T, value: OPERATION['requestParams'][T]): this;
|
|
44
44
|
params(key: Record<string, string | number>): this;
|
|
45
45
|
params(key: string, value: string | number): this;
|
|
46
46
|
/**
|
|
@@ -61,7 +61,8 @@ export declare class Keq<OUTPUT, OPERATION extends Omit<KeqOperation, 'responseB
|
|
|
61
61
|
/**
|
|
62
62
|
* set request body
|
|
63
63
|
*/
|
|
64
|
-
send(value: OPERATION['requestBody']
|
|
64
|
+
send<K extends 'strict'>(value: OPERATION['requestBody']): this;
|
|
65
|
+
send(value: object): this;
|
|
65
66
|
send(value: FormData): this;
|
|
66
67
|
send(value: URLSearchParams): this;
|
|
67
68
|
send(value: Array<any>): this;
|
package/dist/umd/src/keq.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Keq = void 0;
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
13
14
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
15
|
const core_js_1 = require("./core.js");
|
|
15
16
|
const exception_js_1 = require("./exception/exception.js");
|
|
@@ -15,16 +15,13 @@ export interface KeqOperation {
|
|
|
15
15
|
requestBody: FormData | URLSearchParams | object | Array<any> | string;
|
|
16
16
|
responseBody: any;
|
|
17
17
|
}
|
|
18
|
-
export type ExtractHeaders<T extends Pick<KeqOperation, 'requestHeaders'>> = ExtractProperty<T['requestHeaders'], string>;
|
|
19
|
-
export type ExtractQuery<T extends Pick<KeqOperation, 'requestQuery'>> = ExtractProperty<T['requestQuery'], string | string[]>;
|
|
20
|
-
export type ExtractParams<T extends Pick<KeqOperation, 'requestParams'>> = ExtractProperty<T['requestParams'], string>;
|
|
21
18
|
export type ExtractFields<T extends Pick<KeqOperation, 'requestBody'>> = ExtractProperty<Exclude<Extract<T['requestBody'], object>, FormData | URLSearchParams | Array<any>>, string>;
|
|
22
19
|
export type ExtractFiles<T extends Pick<KeqOperation, 'requestBody'>> = ExtractProperty<Exclude<Extract<T['requestBody'], object>, FormData | URLSearchParams | Array<any>>, Buffer | Blob | File>;
|
|
23
|
-
export
|
|
20
|
+
export interface KeqOperations {
|
|
24
21
|
[url: string]: {
|
|
25
22
|
[method in KeqContextRequestMethod]?: KeqOperation;
|
|
26
23
|
};
|
|
27
|
-
}
|
|
24
|
+
}
|
|
28
25
|
export type FlattenOperations<T extends KeqOperations, M extends KeqContextRequestMethod> = {
|
|
29
26
|
[P in keyof T as T[P][M] extends KeqOperation ? P : never]: T[P][M] extends KeqOperation ? T[P][M] : never;
|
|
30
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keq",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.10",
|
|
4
4
|
"description": "Request API write by Typescript for flexibility, readability, and a low learning curve.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"request",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "5.4.5",
|
|
69
69
|
"typescript-transform-paths": "^3.5.1"
|
|
70
70
|
},
|
|
71
|
-
"packageManager": "pnpm@9.
|
|
71
|
+
"packageManager": "pnpm@9.15.1",
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">=18.0.0"
|
|
74
74
|
}
|