keq 2.5.5 → 2.6.1
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/.node-version +1 -0
- package/CHANGELOG.md +20 -0
- package/dist/esm/src/core.d.ts +3 -0
- package/dist/esm/src/core.js +12 -0
- package/dist/esm/src/middlewares/fetch-arguments-middleware.js +10 -0
- package/dist/esm/src/middlewares/retry-middleware.js +2 -0
- package/dist/esm/src/types/keq-context.d.ts +13 -7
- package/dist/esm/src/types/keq-context.js +1 -1
- package/dist/esm/src/types/keq-events.d.ts +5 -1
- package/dist/esm/src/types/keq-flow-control.d.ts +1 -1
- package/dist/esm/src/types/keq-global.d.ts +2 -2
- package/dist/esm/src/types/keq-middleware.d.ts +2 -2
- package/dist/esm/src/types/keq-options.d.ts +6 -6
- package/dist/esm/src/types/keq-request-init.d.ts +1 -1
- package/dist/esm/src/types/keq-request.d.ts +5 -5
- package/dist/esm/src/types/keq-retry-delay.d.ts +1 -1
- package/dist/esm/src/types/keq-retry-on.d.ts +1 -1
- package/dist/esm/src/types/keq-route.d.ts +1 -1
- package/dist/umd/src/core.d.ts +3 -0
- package/dist/umd/src/core.js +12 -0
- package/dist/umd/src/middlewares/fetch-arguments-middleware.js +10 -0
- package/dist/umd/src/middlewares/retry-middleware.js +2 -0
- package/dist/umd/src/types/keq-context.d.ts +13 -7
- package/dist/umd/src/types/keq-context.js +2 -2
- package/dist/umd/src/types/keq-events.d.ts +5 -1
- package/dist/umd/src/types/keq-flow-control.d.ts +1 -1
- package/dist/umd/src/types/keq-global.d.ts +2 -2
- package/dist/umd/src/types/keq-middleware.d.ts +2 -2
- package/dist/umd/src/types/keq-options.d.ts +6 -6
- package/dist/umd/src/types/keq-request-init.d.ts +1 -1
- package/dist/umd/src/types/keq-request.d.ts +5 -5
- package/dist/umd/src/types/keq-retry-delay.d.ts +1 -1
- package/dist/umd/src/types/keq-retry-on.d.ts +1 -1
- package/dist/umd/src/types/keq-route.d.ts +1 -1
- package/package.json +1 -1
package/.node-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v20.13.1
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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.6.1](https://github.com/keq-request/keq/compare/v2.6.0...v2.6.1) (2024-05-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* body should not be set when undefined ([0674870](https://github.com/keq-request/keq/commit/0674870e3adade4f7c5e7e8209322d52b501b8ce))
|
|
11
|
+
|
|
12
|
+
## [2.6.0](https://github.com/keq-request/keq/compare/v2.5.5...v2.6.0) (2024-05-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* use .on(eventName, listener) add event listener ([500ef14](https://github.com/keq-request/keq/commit/500ef140b513d614c3454d0e9023dd501e5d1ef6))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* esm import syntax ([c312146](https://github.com/keq-request/keq/commit/c312146ffeb456bcfb1e0e6e2f2a3c8c773e6003))
|
|
23
|
+
* the body is undeifned when send plain/text request ([ed24ba6](https://github.com/keq-request/keq/commit/ed24ba6f5ef3a565fb3eb6be496be09ed0fa40f9))
|
|
24
|
+
|
|
5
25
|
## [2.5.5](https://github.com/keq-request/keq/compare/v2.5.4...v2.5.5) (2024-05-26)
|
|
6
26
|
|
|
7
27
|
|
package/dist/esm/src/core.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import { URL } from 'whatwg-url';
|
|
|
2
2
|
import type { KeqContextOptions, KeqRequestContext } from './types/keq-context.js';
|
|
3
3
|
import type { KeqMiddleware } from './types/keq-middleware.js';
|
|
4
4
|
import type { KeqRequestInit } from './types/keq-request-init.js';
|
|
5
|
+
import { KeqEvents, KeqListeners } from './types/keq-events.js';
|
|
5
6
|
/**
|
|
6
7
|
* @description Keq 核心 API,发送请求必要的原子化的API
|
|
7
8
|
*/
|
|
8
9
|
export declare class Core<T> {
|
|
9
10
|
private requestPromise?;
|
|
10
11
|
protected requestContext: Omit<KeqRequestContext, 'abort'>;
|
|
12
|
+
protected __listeners__: KeqListeners;
|
|
11
13
|
protected __global__: Record<string, any>;
|
|
12
14
|
protected __prepend_middlewares__: KeqMiddleware[];
|
|
13
15
|
protected __append_middlewares__: KeqMiddleware[];
|
|
@@ -15,6 +17,7 @@ export declare class Core<T> {
|
|
|
15
17
|
constructor(url: (URL | globalThis.URL), init: KeqRequestInit, global?: Record<string, any>);
|
|
16
18
|
prependMiddlewares(...middlewares: KeqMiddleware[]): this;
|
|
17
19
|
appendMiddlewares(...middlewares: KeqMiddleware[]): this;
|
|
20
|
+
on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this;
|
|
18
21
|
private run;
|
|
19
22
|
end(): Promise<T>;
|
|
20
23
|
/**
|
package/dist/esm/src/core.js
CHANGED
|
@@ -11,6 +11,7 @@ import mitt from 'mitt';
|
|
|
11
11
|
export class Core {
|
|
12
12
|
requestPromise;
|
|
13
13
|
requestContext;
|
|
14
|
+
__listeners__ = {};
|
|
14
15
|
__global__;
|
|
15
16
|
__prepend_middlewares__ = [];
|
|
16
17
|
__append_middlewares__ = [];
|
|
@@ -37,6 +38,11 @@ export class Core {
|
|
|
37
38
|
this.__append_middlewares__.unshift(...middlewares);
|
|
38
39
|
return this;
|
|
39
40
|
}
|
|
41
|
+
on(event, listener) {
|
|
42
|
+
this.__listeners__[event] = this.__listeners__[event] || [];
|
|
43
|
+
this.__listeners__[event].push(listener);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
40
46
|
async run() {
|
|
41
47
|
const headers = new Headers();
|
|
42
48
|
for (const [key, value] of this.requestContext.headers.entries()) {
|
|
@@ -59,6 +65,12 @@ export class Core {
|
|
|
59
65
|
};
|
|
60
66
|
const options = shadowClone(this.__options__);
|
|
61
67
|
const emitter = mitt();
|
|
68
|
+
for (const eventName in this.__listeners__) {
|
|
69
|
+
const listeners = this.__listeners__[eventName];
|
|
70
|
+
for (const listener of listeners) {
|
|
71
|
+
emitter.on(eventName, listener);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
62
74
|
const ctx = {
|
|
63
75
|
[NEXT_INVOKED_PROPERTY]: {
|
|
64
76
|
finished: false,
|
|
@@ -63,6 +63,16 @@ function compileBody(ctx) {
|
|
|
63
63
|
request.headers.delete('content-type');
|
|
64
64
|
return form;
|
|
65
65
|
}
|
|
66
|
+
if (body instanceof Buffer)
|
|
67
|
+
return body;
|
|
68
|
+
if (body === undefined)
|
|
69
|
+
return body;
|
|
70
|
+
if (body === null)
|
|
71
|
+
return 'null';
|
|
72
|
+
if (typeof body === 'string')
|
|
73
|
+
return body;
|
|
74
|
+
if (typeof body === 'number')
|
|
75
|
+
return String(body);
|
|
66
76
|
}
|
|
67
77
|
export function fetchArgumentsMiddleware() {
|
|
68
78
|
return async function fetchArgumentsMiddleware(ctx, next) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { URL } from 'whatwg-url';
|
|
2
|
-
import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant";
|
|
3
|
-
import { KeqRequestBody } from './keq-request-body';
|
|
4
|
-
import { KeqRequestMethod } from './keq-request-method';
|
|
5
|
-
import { KeqOptionsParameter } from './keq-options.js';
|
|
6
1
|
import { Emitter } from 'mitt';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { URL } from 'whatwg-url';
|
|
3
|
+
import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant.js";
|
|
4
|
+
import type { KeqRequestBody } from './keq-request-body.js';
|
|
5
|
+
import type { KeqRequestMethod } from './keq-request-method.js';
|
|
6
|
+
import type { KeqOptionsParameter } from './keq-options.js';
|
|
7
|
+
import type { KeqEvents } from './keq-events.js';
|
|
8
|
+
import type { KeqGlobal } from './keq-global.js';
|
|
9
9
|
export interface KeqContextOptions extends KeqOptionsParameter {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}
|
|
@@ -57,6 +57,12 @@ export interface KeqContext {
|
|
|
57
57
|
[OUTPUT_PROPERTY]?: any;
|
|
58
58
|
/** share data between requests */
|
|
59
59
|
global: KeqGlobal;
|
|
60
|
+
/** retry information, undefined is no retry */
|
|
61
|
+
retry?: {
|
|
62
|
+
attempt: number;
|
|
63
|
+
error: unknown | null;
|
|
64
|
+
delay: number;
|
|
65
|
+
};
|
|
60
66
|
/** extends by middleware */
|
|
61
67
|
[key: string]: any;
|
|
62
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant";
|
|
1
|
+
import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant.js";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context.js';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
2
|
export interface KeqEvents {
|
|
3
3
|
fetch: KeqContext;
|
|
4
|
+
retry: KeqContext;
|
|
4
5
|
}
|
|
6
|
+
export type KeqListeners = {
|
|
7
|
+
[K in keyof KeqEvents]?: ((data: KeqEvents[K]) => void)[];
|
|
8
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queueAsPromised } from 'fastq';
|
|
2
|
-
import { KeqNext } from './keq-next.js';
|
|
1
|
+
import type { queueAsPromised } from 'fastq';
|
|
2
|
+
import type { KeqNext } from './keq-next.js';
|
|
3
3
|
export interface KeqGlobal {
|
|
4
4
|
abortFlowControl?: Record<string, ((reason: any) => void) | undefined>;
|
|
5
5
|
serialFlowControl?: Record<string, queueAsPromised<KeqNext, void>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context';
|
|
2
|
-
import { KeqNext } from './keq-next';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
|
+
import type { KeqNext } from './keq-next.js';
|
|
3
3
|
export type KeqMiddleware = (ctx: KeqContext, next: KeqNext) => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Keq } from "../keq.js";
|
|
2
|
-
import { KeqFlowControl } from './keq-flow-control.js';
|
|
3
|
-
import { KeqResolveMethod } from './keq-resolve-with-mode.js';
|
|
4
|
-
import { KeqRetryDelay } from './keq-retry-delay';
|
|
5
|
-
import { KeqRetryOn } from './keq-retry-on';
|
|
6
|
-
import { KeqTimeout } from './keq-timeout.js';
|
|
1
|
+
import type { Keq } from "../keq.js";
|
|
2
|
+
import type { KeqFlowControl } from './keq-flow-control.js';
|
|
3
|
+
import type { KeqResolveMethod } from './keq-resolve-with-mode.js';
|
|
4
|
+
import type { KeqRetryDelay } from './keq-retry-delay.js';
|
|
5
|
+
import type { KeqRetryOn } from './keq-retry-on.js';
|
|
6
|
+
import type { KeqTimeout } from './keq-timeout.js';
|
|
7
7
|
export interface KeqOptions<T> {
|
|
8
8
|
/**
|
|
9
9
|
* replace the default fetch api
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqRequestContext } from './keq-context';
|
|
1
|
+
import type { KeqRequestContext } from './keq-context.js';
|
|
2
2
|
export type KeqRequestInit = Partial<Omit<KeqRequestContext, 'url'>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { URL } from 'whatwg-url';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { KeqMiddleware } from './keq-middleware';
|
|
5
|
-
import { KeqRequestInit } from './keq-request-init';
|
|
1
|
+
import type { URL } from 'whatwg-url';
|
|
2
|
+
import type { KeqRouter } from "../router/keq-router.js";
|
|
3
|
+
import type { Keq } from "../keq.js";
|
|
4
|
+
import type { KeqMiddleware } from './keq-middleware.js';
|
|
5
|
+
import type { KeqRequestInit } from './keq-request-init.js';
|
|
6
6
|
type KeqRequestFn = <T = any>(url: string | URL | globalThis.URL) => Keq<T>;
|
|
7
7
|
type GlobalURL = globalThis.URL;
|
|
8
8
|
export interface KeqRequest {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context';
|
|
1
|
+
import type { KeqContext } from './keq-context';
|
|
2
2
|
export type KeqRetryDelay = number | ((attempt: number, error: unknown | null, ctx: KeqContext) => number | Promise<number>);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
2
|
export type KeqRetryOn = (attempt: number, error: unknown | null, ctx: KeqContext) => (boolean | Promise<boolean>);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context.js';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
2
|
export type KeqRoute = (ctx: KeqContext) => Promise<boolean> | boolean;
|
package/dist/umd/src/core.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import { URL } from 'whatwg-url';
|
|
|
2
2
|
import type { KeqContextOptions, KeqRequestContext } from './types/keq-context.js';
|
|
3
3
|
import type { KeqMiddleware } from './types/keq-middleware.js';
|
|
4
4
|
import type { KeqRequestInit } from './types/keq-request-init.js';
|
|
5
|
+
import { KeqEvents, KeqListeners } from './types/keq-events.js';
|
|
5
6
|
/**
|
|
6
7
|
* @description Keq 核心 API,发送请求必要的原子化的API
|
|
7
8
|
*/
|
|
8
9
|
export declare class Core<T> {
|
|
9
10
|
private requestPromise?;
|
|
10
11
|
protected requestContext: Omit<KeqRequestContext, 'abort'>;
|
|
12
|
+
protected __listeners__: KeqListeners;
|
|
11
13
|
protected __global__: Record<string, any>;
|
|
12
14
|
protected __prepend_middlewares__: KeqMiddleware[];
|
|
13
15
|
protected __append_middlewares__: KeqMiddleware[];
|
|
@@ -15,6 +17,7 @@ export declare class Core<T> {
|
|
|
15
17
|
constructor(url: (URL | globalThis.URL), init: KeqRequestInit, global?: Record<string, any>);
|
|
16
18
|
prependMiddlewares(...middlewares: KeqMiddleware[]): this;
|
|
17
19
|
appendMiddlewares(...middlewares: KeqMiddleware[]): this;
|
|
20
|
+
on<K extends keyof KeqEvents>(event: K, listener: (data: KeqEvents[K]) => void): this;
|
|
18
21
|
private run;
|
|
19
22
|
end(): Promise<T>;
|
|
20
23
|
/**
|
package/dist/umd/src/core.js
CHANGED
|
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
class Core {
|
|
27
27
|
requestPromise;
|
|
28
28
|
requestContext;
|
|
29
|
+
__listeners__ = {};
|
|
29
30
|
__global__;
|
|
30
31
|
__prepend_middlewares__ = [];
|
|
31
32
|
__append_middlewares__ = [];
|
|
@@ -52,6 +53,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
53
|
this.__append_middlewares__.unshift(...middlewares);
|
|
53
54
|
return this;
|
|
54
55
|
}
|
|
56
|
+
on(event, listener) {
|
|
57
|
+
this.__listeners__[event] = this.__listeners__[event] || [];
|
|
58
|
+
this.__listeners__[event].push(listener);
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
55
61
|
async run() {
|
|
56
62
|
const headers = new Headers();
|
|
57
63
|
for (const [key, value] of this.requestContext.headers.entries()) {
|
|
@@ -74,6 +80,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
74
80
|
};
|
|
75
81
|
const options = (0, shadow_clone_js_1.shadowClone)(this.__options__);
|
|
76
82
|
const emitter = (0, mitt_1.default)();
|
|
83
|
+
for (const eventName in this.__listeners__) {
|
|
84
|
+
const listeners = this.__listeners__[eventName];
|
|
85
|
+
for (const listener of listeners) {
|
|
86
|
+
emitter.on(eventName, listener);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
77
89
|
const ctx = {
|
|
78
90
|
[constant_js_1.NEXT_INVOKED_PROPERTY]: {
|
|
79
91
|
finished: false,
|
|
@@ -75,6 +75,16 @@
|
|
|
75
75
|
request.headers.delete('content-type');
|
|
76
76
|
return form;
|
|
77
77
|
}
|
|
78
|
+
if (body instanceof Buffer)
|
|
79
|
+
return body;
|
|
80
|
+
if (body === undefined)
|
|
81
|
+
return body;
|
|
82
|
+
if (body === null)
|
|
83
|
+
return 'null';
|
|
84
|
+
if (typeof body === 'string')
|
|
85
|
+
return body;
|
|
86
|
+
if (typeof body === 'number')
|
|
87
|
+
return String(body);
|
|
78
88
|
}
|
|
79
89
|
function fetchArgumentsMiddleware() {
|
|
80
90
|
return async function fetchArgumentsMiddleware(ctx, next) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { URL } from 'whatwg-url';
|
|
2
|
-
import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant";
|
|
3
|
-
import { KeqRequestBody } from './keq-request-body';
|
|
4
|
-
import { KeqRequestMethod } from './keq-request-method';
|
|
5
|
-
import { KeqOptionsParameter } from './keq-options.js';
|
|
6
1
|
import { Emitter } from 'mitt';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { URL } from 'whatwg-url';
|
|
3
|
+
import { ABORT_PROPERTY, NEXT_INVOKED_PROPERTY, OUTPUT_PROPERTY } from "../constant.js";
|
|
4
|
+
import type { KeqRequestBody } from './keq-request-body.js';
|
|
5
|
+
import type { KeqRequestMethod } from './keq-request-method.js';
|
|
6
|
+
import type { KeqOptionsParameter } from './keq-options.js';
|
|
7
|
+
import type { KeqEvents } from './keq-events.js';
|
|
8
|
+
import type { KeqGlobal } from './keq-global.js';
|
|
9
9
|
export interface KeqContextOptions extends KeqOptionsParameter {
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}
|
|
@@ -57,6 +57,12 @@ export interface KeqContext {
|
|
|
57
57
|
[OUTPUT_PROPERTY]?: any;
|
|
58
58
|
/** share data between requests */
|
|
59
59
|
global: KeqGlobal;
|
|
60
|
+
/** retry information, undefined is no retry */
|
|
61
|
+
retry?: {
|
|
62
|
+
attempt: number;
|
|
63
|
+
error: unknown | null;
|
|
64
|
+
delay: number;
|
|
65
|
+
};
|
|
60
66
|
/** extends by middleware */
|
|
61
67
|
[key: string]: any;
|
|
62
68
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../constant"], factory);
|
|
7
|
+
define(["require", "exports", "../constant.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const constant_js_1 = require("../constant.js");
|
|
13
13
|
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context.js';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
2
|
export interface KeqEvents {
|
|
3
3
|
fetch: KeqContext;
|
|
4
|
+
retry: KeqContext;
|
|
4
5
|
}
|
|
6
|
+
export type KeqListeners = {
|
|
7
|
+
[K in keyof KeqEvents]?: ((data: KeqEvents[K]) => void)[];
|
|
8
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queueAsPromised } from 'fastq';
|
|
2
|
-
import { KeqNext } from './keq-next.js';
|
|
1
|
+
import type { queueAsPromised } from 'fastq';
|
|
2
|
+
import type { KeqNext } from './keq-next.js';
|
|
3
3
|
export interface KeqGlobal {
|
|
4
4
|
abortFlowControl?: Record<string, ((reason: any) => void) | undefined>;
|
|
5
5
|
serialFlowControl?: Record<string, queueAsPromised<KeqNext, void>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context';
|
|
2
|
-
import { KeqNext } from './keq-next';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
|
+
import type { KeqNext } from './keq-next.js';
|
|
3
3
|
export type KeqMiddleware = (ctx: KeqContext, next: KeqNext) => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Keq } from "../keq.js";
|
|
2
|
-
import { KeqFlowControl } from './keq-flow-control.js';
|
|
3
|
-
import { KeqResolveMethod } from './keq-resolve-with-mode.js';
|
|
4
|
-
import { KeqRetryDelay } from './keq-retry-delay';
|
|
5
|
-
import { KeqRetryOn } from './keq-retry-on';
|
|
6
|
-
import { KeqTimeout } from './keq-timeout.js';
|
|
1
|
+
import type { Keq } from "../keq.js";
|
|
2
|
+
import type { KeqFlowControl } from './keq-flow-control.js';
|
|
3
|
+
import type { KeqResolveMethod } from './keq-resolve-with-mode.js';
|
|
4
|
+
import type { KeqRetryDelay } from './keq-retry-delay.js';
|
|
5
|
+
import type { KeqRetryOn } from './keq-retry-on.js';
|
|
6
|
+
import type { KeqTimeout } from './keq-timeout.js';
|
|
7
7
|
export interface KeqOptions<T> {
|
|
8
8
|
/**
|
|
9
9
|
* replace the default fetch api
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqRequestContext } from './keq-context';
|
|
1
|
+
import type { KeqRequestContext } from './keq-context.js';
|
|
2
2
|
export type KeqRequestInit = Partial<Omit<KeqRequestContext, 'url'>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { URL } from 'whatwg-url';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { KeqMiddleware } from './keq-middleware';
|
|
5
|
-
import { KeqRequestInit } from './keq-request-init';
|
|
1
|
+
import type { URL } from 'whatwg-url';
|
|
2
|
+
import type { KeqRouter } from "../router/keq-router.js";
|
|
3
|
+
import type { Keq } from "../keq.js";
|
|
4
|
+
import type { KeqMiddleware } from './keq-middleware.js';
|
|
5
|
+
import type { KeqRequestInit } from './keq-request-init.js';
|
|
6
6
|
type KeqRequestFn = <T = any>(url: string | URL | globalThis.URL) => Keq<T>;
|
|
7
7
|
type GlobalURL = globalThis.URL;
|
|
8
8
|
export interface KeqRequest {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context';
|
|
1
|
+
import type { KeqContext } from './keq-context';
|
|
2
2
|
export type KeqRetryDelay = number | ((attempt: number, error: unknown | null, ctx: KeqContext) => number | Promise<number>);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
2
|
export type KeqRetryOn = (attempt: number, error: unknown | null, ctx: KeqContext) => (boolean | Promise<boolean>);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KeqContext } from './keq-context.js';
|
|
1
|
+
import type { KeqContext } from './keq-context.js';
|
|
2
2
|
export type KeqRoute = (ctx: KeqContext) => Promise<boolean> | boolean;
|