keq 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/esm/src/core.d.ts +4 -5
  3. package/dist/esm/src/core.js +5 -5
  4. package/dist/esm/src/create-request.d.ts +2 -2
  5. package/dist/esm/src/create-request.js +6 -6
  6. package/dist/esm/src/exception/file-expected.exception.d.ts +1 -1
  7. package/dist/esm/src/exception/file-expected.exception.js +1 -1
  8. package/dist/esm/src/exception/invalid-arguments.exception.d.ts +1 -1
  9. package/dist/esm/src/exception/invalid-arguments.exception.js +1 -1
  10. package/dist/esm/src/exception/overwrite-array-body.exception.d.ts +1 -1
  11. package/dist/esm/src/exception/overwrite-array-body.exception.js +1 -1
  12. package/dist/esm/src/index.d.ts +1 -1
  13. package/dist/esm/src/is/is-blob.js +3 -3
  14. package/dist/esm/src/is/is-file.js +2 -2
  15. package/dist/esm/src/is/is-form-data.js +2 -2
  16. package/dist/esm/src/is/is-headers.js +2 -2
  17. package/dist/esm/src/is/is-url-search-params.js +2 -2
  18. package/dist/esm/src/keq.d.ts +11 -13
  19. package/dist/esm/src/keq.js +11 -11
  20. package/dist/esm/src/middlewares/abort-flow-control-middleware.d.ts +1 -1
  21. package/dist/esm/src/middlewares/fetch-arguments-middleware.d.ts +1 -1
  22. package/dist/esm/src/middlewares/fetch-arguments-middleware.js +1 -1
  23. package/dist/esm/src/middlewares/fetch-middleware.d.ts +1 -1
  24. package/dist/esm/src/middlewares/fetch-middleware.js +1 -1
  25. package/dist/esm/src/middlewares/proxy-response-middleware.d.ts +1 -1
  26. package/dist/esm/src/middlewares/proxy-response-middleware.js +1 -1
  27. package/dist/esm/src/request.d.ts +1 -1
  28. package/dist/esm/src/request.js +1 -1
  29. package/dist/esm/src/types/keq-context.d.ts +5 -2
  30. package/dist/esm/src/types/keq-options.d.ts +24 -20
  31. package/dist/esm/src/util/assign-keq-request-body.d.ts +1 -1
  32. package/dist/esm/src/util/assign-keq-request-body.js +4 -4
  33. package/dist/esm/src/util/compose-middleware.d.ts +1 -1
  34. package/dist/esm/src/util/compose-middleware.js +1 -1
  35. package/dist/esm/src/util/fix-content-type.d.ts +1 -1
  36. package/dist/esm/src/util/shadow-clone.js +1 -1
  37. package/dist/umd/src/core.d.ts +4 -5
  38. package/dist/umd/src/core.js +15 -15
  39. package/dist/umd/src/create-request.d.ts +2 -2
  40. package/dist/umd/src/create-request.js +19 -19
  41. package/dist/umd/src/exception/file-expected.exception.d.ts +1 -1
  42. package/dist/umd/src/exception/file-expected.exception.js +3 -3
  43. package/dist/umd/src/exception/invalid-arguments.exception.d.ts +1 -1
  44. package/dist/umd/src/exception/invalid-arguments.exception.js +3 -3
  45. package/dist/umd/src/exception/overwrite-array-body.exception.d.ts +1 -1
  46. package/dist/umd/src/exception/overwrite-array-body.exception.js +3 -3
  47. package/dist/umd/src/index.d.ts +1 -1
  48. package/dist/umd/src/is/is-blob.js +9 -9
  49. package/dist/umd/src/is/is-file.js +5 -5
  50. package/dist/umd/src/is/is-form-data.js +13 -13
  51. package/dist/umd/src/is/is-headers.js +13 -13
  52. package/dist/umd/src/is/is-url-search-params.js +16 -16
  53. package/dist/umd/src/keq.d.ts +11 -13
  54. package/dist/umd/src/keq.js +28 -28
  55. package/dist/umd/src/middlewares/abort-flow-control-middleware.d.ts +1 -1
  56. package/dist/umd/src/middlewares/fetch-arguments-middleware.d.ts +1 -1
  57. package/dist/umd/src/middlewares/fetch-arguments-middleware.js +4 -4
  58. package/dist/umd/src/middlewares/fetch-middleware.d.ts +1 -1
  59. package/dist/umd/src/middlewares/fetch-middleware.js +3 -3
  60. package/dist/umd/src/middlewares/proxy-response-middleware.d.ts +1 -1
  61. package/dist/umd/src/middlewares/proxy-response-middleware.js +1 -1
  62. package/dist/umd/src/request.d.ts +1 -1
  63. package/dist/umd/src/request.js +3 -3
  64. package/dist/umd/src/types/keq-context.d.ts +5 -2
  65. package/dist/umd/src/types/keq-options.d.ts +24 -20
  66. package/dist/umd/src/util/assign-keq-request-body.d.ts +1 -1
  67. package/dist/umd/src/util/assign-keq-request-body.js +11 -11
  68. package/dist/umd/src/util/compose-middleware.d.ts +1 -1
  69. package/dist/umd/src/util/compose-middleware.js +3 -3
  70. package/dist/umd/src/util/fix-content-type.d.ts +1 -1
  71. package/dist/umd/src/util/shadow-clone.js +3 -3
  72. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
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.5.0](https://github.com/keq-request/keq/compare/v2.4.1...v2.5.0) (2024-05-21)
6
+
7
+
8
+ ### Features
9
+
10
+ * third-party middleware can extend option typescript declaration ([a9e559a](https://github.com/keq-request/keq/commit/a9e559a39dd16a552ac5ab024727a76d2a2c05a1))
11
+
12
+ ## [2.4.1](https://github.com/keq-request/keq/compare/v2.4.0...v2.4.1) (2024-05-17)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * response.body is not a function ([8332fa2](https://github.com/keq-request/keq/commit/8332fa25fa613c0663719d581379f04a7545799c))
18
+
5
19
  ## [2.4.0](https://github.com/keq-request/keq/compare/v2.3.4...v2.4.0) (2024-05-17)
6
20
 
7
21
 
@@ -1,8 +1,7 @@
1
1
  import { URL } from 'whatwg-url';
2
- import { KeqRequestContext } from './types/keq-context';
3
- import { KeqMiddleware } from './types/keq-middleware';
4
- import { KeqOptions } from './types/keq-options';
5
- import { KeqRequestInit } from './types/keq-request-init';
2
+ import type { KeqContextOptions, KeqRequestContext } from './types/keq-context.js';
3
+ import type { KeqMiddleware } from './types/keq-middleware.js';
4
+ import type { KeqRequestInit } from './types/keq-request-init.js';
6
5
  /**
7
6
  * @description Keq 核心 API,发送请求必要的原子化的API
8
7
  */
@@ -12,7 +11,7 @@ export declare class Core<T> {
12
11
  protected __global__: Record<string, any>;
13
12
  protected __prepend_middlewares__: KeqMiddleware[];
14
13
  protected __append_middlewares__: KeqMiddleware[];
15
- protected __options__: KeqOptions;
14
+ protected __options__: KeqContextOptions;
16
15
  constructor(url: (URL | globalThis.URL), init: KeqRequestInit, global?: Record<string, any>);
17
16
  prependMiddlewares(...middlewares: KeqMiddleware[]): this;
18
17
  appendMiddlewares(...middlewares: KeqMiddleware[]): this;
@@ -1,9 +1,9 @@
1
1
  import { URL } from 'whatwg-url';
2
- import { Exception } from "./exception/exception";
3
- import { clone } from "./util/clone";
4
- import { OUTPUT_PROPERTY } from './constant';
5
- import { composeMiddleware } from './util/compose-middleware';
6
- import { shadowClone } from './util/shadow-clone';
2
+ import { Exception } from "./exception/exception.js";
3
+ import { clone } from "./util/clone.js";
4
+ import { OUTPUT_PROPERTY } from './constant.js';
5
+ import { composeMiddleware } from './util/compose-middleware.js';
6
+ import { shadowClone } from './util/shadow-clone.js';
7
7
  /**
8
8
  * @description Keq 核心 API,发送请求必要的原子化的API
9
9
  */
@@ -1,5 +1,5 @@
1
- import { KeqMiddleware } from './types/keq-middleware';
2
- import { KeqRequest } from './types/keq-request';
1
+ import type { KeqMiddleware } from './types/keq-middleware.js';
2
+ import type { KeqRequest } from './types/keq-request.js';
3
3
  interface CreateRequestOptions {
4
4
  initMiddlewares?: KeqMiddleware[];
5
5
  baseOrigin?: string;
@@ -1,12 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-return */
2
2
  import { URL } from 'whatwg-url';
3
- import { isBrowser } from './is/is-browser';
4
- import { Keq } from './keq';
3
+ import { isBrowser } from './is/is-browser.js';
4
+ import { Keq } from './keq.js';
5
5
  import { abortFlowControlMiddleware } from './middlewares/abort-flow-control-middleware.js';
6
- import { fetchArgumentsMiddleware } from './middlewares/fetch-arguments-middleware';
7
- import { fetchMiddleware } from './middlewares/fetch-middleware';
8
- import { proxyResponseMiddleware } from './middlewares/proxy-response-middleware';
9
- import { retryMiddleware } from './middlewares/retry-middleware';
6
+ import { fetchArgumentsMiddleware } from './middlewares/fetch-arguments-middleware.js';
7
+ import { fetchMiddleware } from './middlewares/fetch-middleware.js';
8
+ import { proxyResponseMiddleware } from './middlewares/proxy-response-middleware.js';
9
+ import { retryMiddleware } from './middlewares/retry-middleware.js';
10
10
  import { serialFlowControlMiddleware } from './middlewares/serial-flow-control-middleware.js';
11
11
  import { KeqRouter } from './router/keq-router.js';
12
12
  import { timeoutMiddleware } from './middlewares/timeout-middleware.js';
@@ -1,4 +1,4 @@
1
- import { Exception } from './exception';
1
+ import { Exception } from './exception.js';
2
2
  export declare class FileExpectedException extends Exception {
3
3
  constructor();
4
4
  }
@@ -1,4 +1,4 @@
1
- import { Exception } from './exception';
1
+ import { Exception } from './exception.js';
2
2
  export class FileExpectedException extends Exception {
3
3
  constructor() {
4
4
  super('File/Blob (Browser) or Buffer (NodeJS) expected');
@@ -1,4 +1,4 @@
1
- import { Exception } from './exception';
1
+ import { Exception } from './exception.js';
2
2
  export declare class InvalidArgumentsExceptions extends Exception {
3
3
  constructor();
4
4
  }
@@ -1,4 +1,4 @@
1
- import { Exception } from './exception';
1
+ import { Exception } from './exception.js';
2
2
  export class InvalidArgumentsExceptions extends Exception {
3
3
  constructor() {
4
4
  super('Invalid arguments');
@@ -1,4 +1,4 @@
1
- import { Exception } from './exception';
1
+ import { Exception } from './exception.js';
2
2
  export declare class OverwriteArrayBodyException extends Exception {
3
3
  constructor();
4
4
  }
@@ -1,4 +1,4 @@
1
- import { Exception } from './exception';
1
+ import { Exception } from './exception.js';
2
2
  export class OverwriteArrayBodyException extends Exception {
3
3
  constructor() {
4
4
  super('Cannot merge or overwrite body, because it has been set as an array. Please use .body(arr) instead');
@@ -3,7 +3,7 @@ export { Keq } from './keq.js';
3
3
  export { request } from './request.js';
4
4
  export { composeMiddleware } from './util/compose-middleware.js';
5
5
  export { composeRoute } from './util/compose-route.js';
6
- export { KeqContext } from './types/keq-context.js';
6
+ export { KeqContext, KeqContextOptions } from './types/keq-context.js';
7
7
  export { KeqMiddleware } from './types/keq-middleware.js';
8
8
  export { KeqNext } from './types/keq-next.js';
9
9
  export { KeqOptions } from './types/keq-options.js';
@@ -1,6 +1,6 @@
1
- import { isFunction } from './is-function';
2
- import { isObject } from './is-object';
3
- import { isString } from './is-string';
1
+ import { isFunction } from './is-function.js';
2
+ import { isObject } from './is-object.js';
3
+ import { isString } from './is-string.js';
4
4
  const names = ['Blob', 'File'];
5
5
  /**
6
6
  * Check if given valie is Blob or File -like object
@@ -1,5 +1,5 @@
1
- import { isBlob } from './is-blob';
2
- import { isBrowser } from './is-browser';
1
+ import { isBlob } from './is-blob.js';
2
+ import { isBrowser } from './is-browser.js';
3
3
  export function isFile(object) {
4
4
  if (isBrowser())
5
5
  return object instanceof Blob;
@@ -1,5 +1,5 @@
1
- import { isFunction } from './is-function';
2
- import { isObject } from './is-object';
1
+ import { isFunction } from './is-function.js';
2
+ import { isObject } from './is-object.js';
3
3
  export function isFormData(object) {
4
4
  if (object instanceof FormData)
5
5
  return true;
@@ -1,5 +1,5 @@
1
- import { isFunction } from './is-function';
2
- import { isObject } from './is-object';
1
+ import { isFunction } from './is-function.js';
2
+ import { isObject } from './is-object.js';
3
3
  export function isHeaders(obj) {
4
4
  if (obj instanceof Headers)
5
5
  return true;
@@ -1,5 +1,5 @@
1
- import { isFunction } from './is-function';
2
- import { isObject } from './is-object';
1
+ import { isFunction } from './is-function.js';
2
+ import { isObject } from './is-object.js';
3
3
  export function isUrlSearchParams(obj) {
4
4
  if (obj instanceof URLSearchParams)
5
5
  return true;
@@ -1,24 +1,22 @@
1
1
  /// <reference types="node" />
2
- import { Core } from './core';
2
+ import { Core } from './core.js';
3
3
  import { KeqFlowControlMode, KeqFlowControlSignal } from './types/keq-flow-control.js';
4
- import { KeqMiddleware } from './types/keq-middleware';
5
- import { KeqBuildInOptions, KeqOptions, KeqOptionsWithFullResponse, KeqOptionsWithoutFullResponse } from './types/keq-options';
6
- import { KeqQueryValue } from './types/keq-query-value.js';
7
- import { KeqRequestBody } from './types/keq-request-body';
8
- import { KeqRetryDelay } from './types/keq-retry-delay';
9
- import { KeqRetryOn } from './types/keq-retry-on';
10
- import { ShorthandContentType } from './types/shorthand-content-type';
4
+ import type { KeqRetryOn } from './types/keq-retry-on.js';
5
+ import type { KeqMiddleware } from './types/keq-middleware.js';
6
+ import type { KeqOptionsParameter, KeqOptionsReturnType } from './types/keq-options.js';
7
+ import type { KeqQueryValue } from './types/keq-query-value.js';
8
+ import type { KeqRequestBody } from './types/keq-request-body.js';
9
+ import type { KeqRetryDelay } from './types/keq-retry-delay.js';
10
+ import type { ShorthandContentType } from './types/shorthand-content-type.js';
11
+ import { KeqContextOptions } from './types/keq-context.js';
11
12
  /**
12
13
  * @description Keq 扩展 API,人性化的常用的API
13
14
  */
14
15
  export declare class Keq<T> extends Core<T> {
15
16
  use(...middlewares: KeqMiddleware[]): this;
16
- option(key: 'resolveWithFullResponse', value?: true): Keq<Response>;
17
- option<K extends keyof KeqBuildInOptions>(key: K, value?: KeqBuildInOptions[K]): this;
17
+ option<K extends keyof KeqOptionsReturnType<T>>(key: K, value?: KeqOptionsParameter[K]): KeqOptionsReturnType<T>[K];
18
18
  option(key: string, value?: any): this;
19
- options(opts: KeqOptionsWithoutFullResponse): this;
20
- options(opts: KeqOptionsWithFullResponse): Keq<Response>;
21
- options(opts: KeqOptions): this;
19
+ options(opts: KeqContextOptions): this;
22
20
  /**
23
21
  * Set request header
24
22
  *
@@ -1,14 +1,14 @@
1
- import { Core } from './core';
2
- import { Exception } from './exception/exception';
3
- import { InvalidArgumentsExceptions } from './exception/invalid-arguments.exception';
4
- import { isBlob } from './is/is-blob';
5
- import { isFile } from './is/is-file';
6
- import { isFormData } from './is/is-form-data';
7
- import { isHeaders } from './is/is-headers';
8
- import { isUrlSearchParams } from './is/is-url-search-params';
9
- import { assignKeqRequestBody } from './util/assign-keq-request-body';
10
- import { base64Encode } from './util/base64';
11
- import { fixContentType } from './util/fix-content-type';
1
+ import { Core } from './core.js';
2
+ import { Exception } from './exception/exception.js';
3
+ import { InvalidArgumentsExceptions } from './exception/invalid-arguments.exception.js';
4
+ import { isBlob } from './is/is-blob.js';
5
+ import { isFile } from './is/is-file.js';
6
+ import { isFormData } from './is/is-form-data.js';
7
+ import { isHeaders } from './is/is-headers.js';
8
+ import { isUrlSearchParams } from './is/is-url-search-params.js';
9
+ import { assignKeqRequestBody } from './util/assign-keq-request-body.js';
10
+ import { base64Encode } from './util/base64.js';
11
+ import { fixContentType } from './util/fix-content-type.js';
12
12
  import { getUniqueCodeIdentifier } from './util/get-unique-code-identifier.js';
13
13
  /**
14
14
  * @description Keq 扩展 API,人性化的常用的API
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from "../types/keq-middleware.js";
1
+ import type { KeqMiddleware } from "../types/keq-middleware.js";
2
2
  export declare function abortFlowControlMiddleware(): KeqMiddleware;
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from '../types/keq-middleware';
1
+ import type { KeqMiddleware } from '../types/keq-middleware';
2
2
  export declare function fetchArgumentsMiddleware(): KeqMiddleware;
@@ -1,5 +1,5 @@
1
1
  import { URL } from 'whatwg-url';
2
- import { Exception } from "../exception/exception";
2
+ import { Exception } from "../exception/exception.js";
3
3
  import { compilePathnameTemplate } from "../util/compile-pathname-template.js";
4
4
  function compileUrl(obj, routeParams) {
5
5
  const url = new URL(typeof obj === 'string' ? obj : obj.href);
@@ -1,4 +1,4 @@
1
- import { KeqMiddleware } from "../types/keq-middleware";
1
+ import type { KeqMiddleware } from "../types/keq-middleware.js";
2
2
  /**
3
3
  * Send Request
4
4
  */
@@ -1,4 +1,4 @@
1
- import { Exception } from "../exception/exception";
1
+ import { Exception } from "../exception/exception.js";
2
2
  /**
3
3
  * Send Request
4
4
  */
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from '../types/keq-middleware';
1
+ import type { KeqMiddleware } from '../types/keq-middleware.js';
2
2
  export declare function proxyResponseMiddleware(): KeqMiddleware;
@@ -6,7 +6,7 @@ export function proxyResponseMiddleware() {
6
6
  ctx.response = new Proxy(res, {
7
7
  get(res, prop) {
8
8
  if (typeof prop === 'string') {
9
- if (['body', 'json', 'text', 'arrayBuffer', 'blob', 'buffer', 'formData'].includes(prop)) {
9
+ if (['json', 'text', 'arrayBuffer', 'blob', 'buffer', 'formData'].includes(prop)) {
10
10
  /**
11
11
  * clone when invoking body, json, text, arrayBuffer, blob, buffer, formData
12
12
  * to avoid time-consuming cloning
@@ -1 +1 @@
1
- export declare const request: import(".").KeqRequest;
1
+ export declare const request: import("./index.js").KeqRequest;
@@ -1,2 +1,2 @@
1
- import { createRequest } from './create-request';
1
+ import { createRequest } from './create-request.js';
2
2
  export const request = createRequest();
@@ -1,8 +1,11 @@
1
1
  import { URL } from 'whatwg-url';
2
2
  import { OUTPUT_PROPERTY } from "../constant";
3
- import { KeqOptions } from './keq-options';
4
3
  import { KeqRequestBody } from './keq-request-body';
5
4
  import { KeqRequestMethod } from './keq-request-method';
5
+ import { KeqOptionsParameter } from './keq-options.js';
6
+ export interface KeqContextOptions extends KeqOptionsParameter {
7
+ [key: string]: any;
8
+ }
6
9
  export interface KeqRequestContext {
7
10
  url: URL | globalThis.URL;
8
11
  method: KeqRequestMethod;
@@ -20,7 +23,7 @@ export interface KeqRequestContext {
20
23
  signal?: AbortSignal | null;
21
24
  }
22
25
  export interface KeqContext {
23
- options: KeqOptions;
26
+ options: KeqContextOptions;
24
27
  /**
25
28
  * Fetch API Arguments
26
29
  */
@@ -1,53 +1,57 @@
1
+ import { Keq } from "../keq.js";
1
2
  import { KeqFlowControl } from './keq-flow-control.js';
2
3
  import { KeqResolveMethod } from './keq-resolve-with-mode.js';
3
4
  import { KeqRetryDelay } from './keq-retry-delay';
4
5
  import { KeqRetryOn } from './keq-retry-on';
5
6
  import { KeqTimeout } from './keq-timeout.js';
6
- export interface KeqBuildInOptions {
7
+ export interface KeqOptions<T> {
7
8
  /**
8
9
  * replace the default fetch api
9
10
  * default use node-fetch@2 in node and window.fetch in browser
10
11
  */
11
- fetchAPI?: typeof fetch;
12
+ fetchAPI(value: typeof fetch): Keq<T>;
12
13
  /**
13
14
  * get response object, defaulted `false`
14
15
  * @deprecated use `resolveWith` instead
15
16
  * */
16
- resolveWithFullResponse?: boolean;
17
+ resolveWithFullResponse(value: boolean): Keq<Response>;
17
18
  /**
18
19
  * how to resolve the response body
19
20
  * @description 如何解析响应体
20
21
  * @default 'intelligent'
21
22
  */
22
- resolveWith?: KeqResolveMethod;
23
+ resolveWith(value: KeqResolveMethod): Keq<T>;
23
24
  /**
24
25
  * The request retry times
25
26
  * @description 重试次数
26
27
  */
27
- retryTimes?: number;
28
+ retryTimes(value: number): Keq<T>;
28
29
  /**
29
30
  * The request retry interval time
30
31
  * @description 重试间隔时间
31
32
  */
32
- retryDelay?: KeqRetryDelay;
33
+ retryDelay(value: KeqRetryDelay): Keq<T>;
33
34
  /**
34
35
  * Custom retry condition
35
36
  * @description 自定义重试条件
36
37
  */
37
- retryOn?: KeqRetryOn;
38
- module?: {
38
+ retryOn(value: KeqRetryOn): Keq<T>;
39
+ module(value: {
39
40
  name: string;
40
41
  pathname: string;
41
- };
42
- flowControl?: KeqFlowControl;
43
- timeout?: KeqTimeout;
42
+ }): Keq<T>;
43
+ flowControl(value: KeqFlowControl): Keq<T>;
44
+ timeout(value: KeqTimeout): Keq<T>;
44
45
  }
45
- export interface KeqOptionsWithFullResponse extends KeqBuildInOptions {
46
- resolveWithFullResponse: true;
47
- [key: string]: any;
48
- }
49
- export interface KeqOptionsWithoutFullResponse extends KeqBuildInOptions {
50
- resolveWithFullResponse?: false;
51
- [key: string]: any;
52
- }
53
- export type KeqOptions = KeqOptionsWithFullResponse | KeqOptionsWithoutFullResponse;
46
+ type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
47
+ type FirstArgType<T> = T extends (arg1: infer P, ...args: any[]) => any ? P : never;
48
+ type ExcludeNever<T> = Pick<T, {
49
+ [K in keyof T]: T[K] extends never ? never : K;
50
+ }[keyof T]>;
51
+ export type KeqOptionsParameter = ExcludeNever<{
52
+ [key in keyof KeqOptions<any>]?: FirstArgType<KeqOptions<any>[key]>;
53
+ }>;
54
+ export type KeqOptionsReturnType<T> = ExcludeNever<{
55
+ [key in keyof KeqOptions<T>]: ReturnType<KeqOptions<T>[key]>;
56
+ }>;
57
+ export {};
@@ -1,2 +1,2 @@
1
- import { KeqRequestBody } from "../types/keq-request-body";
1
+ import type { KeqRequestBody } from "../types/keq-request-body.js";
2
2
  export declare function assignKeqRequestBody(left: KeqRequestBody, right: object | Array<any> | FormData | URLSearchParams | string): KeqRequestBody;
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-return */
2
- import { Exception } from "../exception/exception";
3
- import { OverwriteArrayBodyException } from "../exception/overwrite-array-body.exception";
4
- import { isFormData } from "../is/is-form-data";
5
- import { isUrlSearchParams } from "../is/is-url-search-params";
2
+ import { Exception } from "../exception/exception.js";
3
+ import { OverwriteArrayBodyException } from "../exception/overwrite-array-body.exception.js";
4
+ import { isFormData } from "../is/is-form-data.js";
5
+ import { isUrlSearchParams } from "../is/is-url-search-params.js";
6
6
  export function assignKeqRequestBody(left, right) {
7
7
  if (Array.isArray(left)) {
8
8
  throw new OverwriteArrayBodyException();
@@ -1,2 +1,2 @@
1
- import { KeqMiddleware } from '../types/keq-middleware';
1
+ import type { KeqMiddleware } from '../types/keq-middleware.js';
2
2
  export declare function composeMiddleware(middlewares: KeqMiddleware[]): KeqMiddleware;
@@ -1,4 +1,4 @@
1
- import { Exception } from "../exception/exception";
1
+ import { Exception } from "../exception/exception.js";
2
2
  export function composeMiddleware(middlewares) {
3
3
  if (!middlewares.length) {
4
4
  throw new Exception('At least one middleware');
@@ -1,2 +1,2 @@
1
- import { ShorthandContentType } from "../types/shorthand-content-type";
1
+ import type { ShorthandContentType } from "../types/shorthand-content-type.js";
2
2
  export declare function fixContentType(contentType: ShorthandContentType | string): string;
@@ -1,4 +1,4 @@
1
- import { isObject } from "../is/is-object";
1
+ import { isObject } from "../is/is-object.js";
2
2
  /**
3
3
  * @description 浅拷贝
4
4
  */
@@ -1,8 +1,7 @@
1
1
  import { URL } from 'whatwg-url';
2
- import { KeqRequestContext } from './types/keq-context';
3
- import { KeqMiddleware } from './types/keq-middleware';
4
- import { KeqOptions } from './types/keq-options';
5
- import { KeqRequestInit } from './types/keq-request-init';
2
+ import type { KeqContextOptions, KeqRequestContext } from './types/keq-context.js';
3
+ import type { KeqMiddleware } from './types/keq-middleware.js';
4
+ import type { KeqRequestInit } from './types/keq-request-init.js';
6
5
  /**
7
6
  * @description Keq 核心 API,发送请求必要的原子化的API
8
7
  */
@@ -12,7 +11,7 @@ export declare class Core<T> {
12
11
  protected __global__: Record<string, any>;
13
12
  protected __prepend_middlewares__: KeqMiddleware[];
14
13
  protected __append_middlewares__: KeqMiddleware[];
15
- protected __options__: KeqOptions;
14
+ protected __options__: KeqContextOptions;
16
15
  constructor(url: (URL | globalThis.URL), init: KeqRequestInit, global?: Record<string, any>);
17
16
  prependMiddlewares(...middlewares: KeqMiddleware[]): this;
18
17
  appendMiddlewares(...middlewares: KeqMiddleware[]): this;
@@ -4,18 +4,18 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "whatwg-url", "./exception/exception", "./util/clone", "./constant", "./util/compose-middleware", "./util/shadow-clone"], factory);
7
+ define(["require", "exports", "whatwg-url", "./exception/exception.js", "./util/clone.js", "./constant.js", "./util/compose-middleware.js", "./util/shadow-clone.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Core = void 0;
13
13
  const whatwg_url_1 = require("whatwg-url");
14
- const exception_1 = require("./exception/exception");
15
- const clone_1 = require("./util/clone");
16
- const constant_1 = require("./constant");
17
- const compose_middleware_1 = require("./util/compose-middleware");
18
- const shadow_clone_1 = require("./util/shadow-clone");
14
+ const exception_js_1 = require("./exception/exception.js");
15
+ const clone_js_1 = require("./util/clone.js");
16
+ const constant_js_1 = require("./constant.js");
17
+ const compose_middleware_js_1 = require("./util/compose-middleware.js");
18
+ const shadow_clone_js_1 = require("./util/shadow-clone.js");
19
19
  /**
20
20
  * @description Keq 核心 API,发送请求必要的原子化的API
21
21
  */
@@ -57,8 +57,8 @@
57
57
  method: this.requestContext.method,
58
58
  url: new whatwg_url_1.URL(this.requestContext.url.href),
59
59
  headers,
60
- routeParams: (0, shadow_clone_1.shadowClone)(this.requestContext.routeParams),
61
- body: (0, clone_1.clone)(this.requestContext.body),
60
+ routeParams: (0, shadow_clone_js_1.shadowClone)(this.requestContext.routeParams),
61
+ body: (0, clone_js_1.clone)(this.requestContext.body),
62
62
  cache: this.requestContext.cache,
63
63
  credentials: this.requestContext.credentials,
64
64
  integrity: this.requestContext.integrity,
@@ -69,28 +69,28 @@
69
69
  referrerPolicy: this.requestContext.referrerPolicy,
70
70
  signal: this.requestContext.signal,
71
71
  };
72
- const options = (0, shadow_clone_1.shadowClone)(this.__options__);
72
+ const options = (0, shadow_clone_js_1.shadowClone)(this.__options__);
73
73
  const ctx = {
74
74
  request: requestContext,
75
75
  options,
76
76
  global: this.__global__,
77
77
  get output() {
78
- throw new exception_1.Exception('output property is write-only');
78
+ throw new exception_js_1.Exception('output property is write-only');
79
79
  },
80
80
  set output(value) {
81
- this[constant_1.OUTPUT_PROPERTY] = value;
81
+ this[constant_js_1.OUTPUT_PROPERTY] = value;
82
82
  },
83
83
  };
84
- const middleware = (0, compose_middleware_1.composeMiddleware)([...this.__prepend_middlewares__, ...this.__append_middlewares__]);
84
+ const middleware = (0, compose_middleware_js_1.composeMiddleware)([...this.__prepend_middlewares__, ...this.__append_middlewares__]);
85
85
  // eslint-disable-next-line @typescript-eslint/no-empty-function
86
86
  await middleware(ctx, async function emptyNext() { });
87
- const output = ctx[constant_1.OUTPUT_PROPERTY];
87
+ const output = ctx[constant_js_1.OUTPUT_PROPERTY];
88
88
  if (ctx.options.resolveWithFullResponse || ctx.options.resolveWith === 'response') {
89
89
  return ctx.response;
90
90
  }
91
91
  const response = ctx.response;
92
92
  if (!response) {
93
- return (constant_1.OUTPUT_PROPERTY in ctx) ? output : undefined;
93
+ return (constant_js_1.OUTPUT_PROPERTY in ctx) ? output : undefined;
94
94
  }
95
95
  if (ctx.options.resolveWith === 'text') {
96
96
  return await response.text();
@@ -107,7 +107,7 @@
107
107
  else if (ctx.options.resolveWith === 'array-buffer') {
108
108
  return await response.arrayBuffer();
109
109
  }
110
- if (constant_1.OUTPUT_PROPERTY in ctx) {
110
+ if (constant_js_1.OUTPUT_PROPERTY in ctx) {
111
111
  return output;
112
112
  }
113
113
  if (response.status === 204) {
@@ -1,5 +1,5 @@
1
- import { KeqMiddleware } from './types/keq-middleware';
2
- import { KeqRequest } from './types/keq-request';
1
+ import type { KeqMiddleware } from './types/keq-middleware.js';
2
+ import type { KeqRequest } from './types/keq-request.js';
3
3
  interface CreateRequestOptions {
4
4
  initMiddlewares?: KeqMiddleware[];
5
5
  baseOrigin?: string;