@e-mc/types 0.10.1 → 0.10.2

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/lib/request.d.ts CHANGED
@@ -1,139 +1,141 @@
1
- import type { BinaryAction } from './asset';
2
- import type { HttpProtocolVersion, InternetProtocolVersion } from './http';
3
- import type { HttpHostSettings } from './settings';
4
-
5
- import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
6
- import type { Readable, Writable } from 'stream';
7
-
8
- interface KeepAliveAction {
9
- keepAlive?: boolean;
10
- agentTimeout?: number;
11
- }
12
-
13
- interface SilentAction {
14
- silent?: boolean;
15
- }
16
-
17
- interface ProtocolAction {
18
- httpVersion?: HttpProtocolVersion;
19
- ipVersion?: InternetProtocolVersion;
20
- }
21
-
22
- export interface IHttpHost {
23
- localhost: boolean;
24
- hasProtocol(version: HttpProtocolVersion): Promise<number>;
25
- upgrade(version: HttpProtocolVersion, altSvc: Undef<string>): void;
26
- success(version: HttpProtocolVersion, status?: boolean): number;
27
- failed(version: HttpProtocolVersion, status?: boolean): number;
28
- error(version: HttpProtocolVersion, status?: boolean): number;
29
- didAltSvc(version: HttpProtocolVersion): boolean;
30
- nextAltSvc(): boolean;
31
- closeAltSvc(error?: boolean): boolean;
32
- clearAltSvc(version?: HttpProtocolVersion): void;
33
- flagAltSvc(version: HttpProtocolVersion, value: number): void;
34
- reset(): void;
35
- v2(): boolean;
36
- set version(value);
37
- get version(): HttpProtocolVersion;
38
- get protocol(): string;
39
- get secure(): boolean;
40
- get hostname(): string;
41
- get port(): string;
42
- get origin(): string;
43
- get streamSize(): number;
44
- }
45
-
46
- export interface HttpHostConstructor {
47
- normalizeOrigin(value: string): string;
48
- formatBasicAuth(url: URL): string;
49
- getBasicAuth(url: URL): Undef<OutgoingHttpHeaders>;
50
- defineLocalHost(values: string[]): void;
51
- defineProtocolNegotiation(data: ObjectMap<string[]>): void;
52
- defineHostConfig(settings: HttpHostSettings): void;
53
- readonly prototype: IHttpHost;
54
- new(url: URL, httpVersion?: HttpProtocolVersion): IHttpHost;
55
- }
56
-
57
- export interface OpenOptions extends KeepAliveAction, SilentAction {
58
- host?: IHttpHost;
59
- url?: URL;
60
- base?: boolean;
61
- socketPath?: string;
62
- httpVersion?: HttpProtocolVersion;
63
- method?: "GET" | "POST" | "HEAD";
64
- search?: StringMap;
65
- follow_redirect?: boolean;
66
- encoding?: BufferEncoding;
67
- maxBufferSize?: number | string;
68
- format?: BufferFormat | { out?: BufferFormat; parser?: PlainObject };
69
- headers?: OutgoingHttpHeaders;
70
- timeout?: number;
71
- pipeTo?: string | Writable;
72
- postData?: unknown;
73
- connected?: (headers: IncomingHttpHeaders) => Void<boolean>;
74
- statusMessage?: string;
75
- progressId?: number | string;
76
- outFormat?: { out: BufferFormat; parser?: PlainObject };
77
- outFilename?: Null<string>;
78
- outHeaders?: Null<IncomingHttpHeaders>;
79
- outStream?: Writable;
80
- outAbort?: AbortController;
81
- }
82
-
83
- export interface PostOptions extends OpenOptions {
84
- contentType?: string;
85
- formData?: ArrayOf<FormDataPart>;
86
- dataEncoding?: BufferEncoding;
87
- }
88
-
89
- export interface FormDataPart {
90
- name?: string;
91
- data?: Buffer | Readable | string;
92
- value?: unknown;
93
- contentType?: string;
94
- filename?: string;
95
- }
96
-
97
- export interface Aria2Options extends BinaryAction, SilentAction {
98
- pathname?: string;
99
- headers?: OutgoingHttpHeaders;
100
- }
101
-
102
- export interface HostConfig extends OpenOptions {
103
- host: IHttpHost;
104
- url: URL;
105
- }
106
-
107
- export interface ProxySettings extends KeepAliveAction {
108
- host: URL;
109
- exclude?: string[];
110
- include?: string[];
111
- }
112
-
113
- export interface RequestInit extends ProtocolAction {
114
- headers?: unknown;
115
- readTimeout?: number;
116
- }
117
-
118
- export interface ClientConfig {
119
- timeout?: number;
120
- connectTimeout?: number;
121
- redirectLimit?: number;
122
- retryWait?: number;
123
- retryAfter?: number;
124
- retryLimit?: number;
125
- }
126
-
127
- export interface ApplyOptions extends ProtocolAction, PlainObject {
128
- client?: ClientConfig;
129
- readExpect?: ReadExpectType;
130
- acceptEncoding?: boolean;
131
- keepAlive?: boolean;
132
- }
133
-
134
- export type BufferFormat = "json" | "yaml" | "json5" | "xml" | "toml";
135
- export type ReadExpectType = "always" | "string" | "none";
136
- export type DataEncodedResult<T extends { encoding?: BufferEncoding }> = T extends { encoding: BufferEncoding } ? string : Null<Bufferable>;
137
- export type DataObjectResult<T extends { format?: unknown; encoding?: BufferEncoding }> = T extends { format: string | PlainObject } ? Null<object> : DataEncodedResult<T>;
138
- export type StatusOnCallback = (code: number, headers: IncomingHttpHeaders, url?: URL) => Void<boolean>;
1
+ import type { BinaryAction } from './asset';
2
+ import type { HttpProtocolVersion, InternetProtocolVersion } from './http';
3
+ import type { HttpHostSettings } from './settings';
4
+
5
+ import type { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
6
+ import type { Readable, Writable } from 'stream';
7
+
8
+ interface KeepAliveAction {
9
+ keepAlive?: boolean;
10
+ agentTimeout?: number;
11
+ }
12
+
13
+ interface SilentAction {
14
+ silent?: boolean;
15
+ }
16
+
17
+ interface ProtocolAction {
18
+ httpVersion?: HttpProtocolVersion;
19
+ ipVersion?: InternetProtocolVersion;
20
+ }
21
+
22
+ export interface IHttpHost {
23
+ localhost: boolean;
24
+ hasProtocol(version: HttpProtocolVersion): Promise<number>;
25
+ upgrade(version: HttpProtocolVersion, altSvc: Undef<string>): void;
26
+ success(version: HttpProtocolVersion, status?: boolean): number;
27
+ failed(version: HttpProtocolVersion, status?: boolean): number;
28
+ error(version: HttpProtocolVersion, status?: boolean): number;
29
+ didAltSvc(version: HttpProtocolVersion): boolean;
30
+ nextAltSvc(): boolean;
31
+ closeAltSvc(error?: boolean): boolean;
32
+ clearAltSvc(version?: HttpProtocolVersion): void;
33
+ flagAltSvc(version: HttpProtocolVersion, value: number): void;
34
+ reset(): void;
35
+ v2(): boolean;
36
+ set version(value);
37
+ get version(): HttpProtocolVersion;
38
+ get protocol(): string;
39
+ get secure(): boolean;
40
+ get hostname(): string;
41
+ get port(): string;
42
+ get origin(): string;
43
+ get streamSize(): number;
44
+ }
45
+
46
+ export interface HttpHostConstructor {
47
+ normalizeOrigin(value: string): string;
48
+ formatBasicAuth(url: URL): string;
49
+ getBasicAuth(url: URL): Undef<OutgoingHttpHeaders>;
50
+ defineLocalHost(values: string[]): void;
51
+ defineProtocolNegotiation(data: ObjectMap<string[]>): void;
52
+ defineHostConfig(settings: HttpHostSettings): void;
53
+ readonly prototype: IHttpHost;
54
+ new(url: URL, httpVersion?: HttpProtocolVersion): IHttpHost;
55
+ }
56
+
57
+ export interface OpenOptions extends KeepAliveAction, SilentAction {
58
+ host?: IHttpHost;
59
+ url?: URL;
60
+ base?: boolean;
61
+ socketPath?: string;
62
+ httpVersion?: HttpProtocolVersion;
63
+ method?: "GET" | "POST" | "HEAD";
64
+ search?: StringMap;
65
+ /** @deprecated followRedirect */
66
+ follow_redirect?: boolean;
67
+ followRedirect?: boolean;
68
+ encoding?: BufferEncoding;
69
+ maxBufferSize?: number | string;
70
+ format?: BufferFormat | { out?: BufferFormat; parser?: PlainObject };
71
+ headers?: OutgoingHttpHeaders;
72
+ timeout?: number;
73
+ pipeTo?: string | Writable;
74
+ postData?: unknown;
75
+ connected?: (headers: IncomingHttpHeaders) => Void<boolean>;
76
+ statusMessage?: string;
77
+ progressId?: number | string;
78
+ outFormat?: { out: BufferFormat; parser?: PlainObject };
79
+ outFilename?: Null<string>;
80
+ outHeaders?: Null<IncomingHttpHeaders>;
81
+ outStream?: Writable;
82
+ outAbort?: AbortController;
83
+ }
84
+
85
+ export interface PostOptions extends OpenOptions {
86
+ contentType?: string;
87
+ formData?: ArrayOf<FormDataPart>;
88
+ dataEncoding?: BufferEncoding;
89
+ }
90
+
91
+ export interface FormDataPart {
92
+ name?: string;
93
+ data?: Buffer | Readable | string;
94
+ value?: unknown;
95
+ contentType?: string;
96
+ filename?: string;
97
+ }
98
+
99
+ export interface Aria2Options extends BinaryAction, SilentAction {
100
+ pathname?: string;
101
+ headers?: OutgoingHttpHeaders;
102
+ }
103
+
104
+ export interface HostConfig extends OpenOptions {
105
+ host: IHttpHost;
106
+ url: URL;
107
+ }
108
+
109
+ export interface ProxySettings extends KeepAliveAction {
110
+ host: URL;
111
+ exclude?: string[];
112
+ include?: string[];
113
+ }
114
+
115
+ export interface RequestInit extends ProtocolAction {
116
+ headers?: unknown;
117
+ readTimeout?: number;
118
+ }
119
+
120
+ export interface ClientConfig {
121
+ timeout?: number;
122
+ connectTimeout?: number;
123
+ redirectLimit?: number;
124
+ retryWait?: number;
125
+ retryAfter?: number;
126
+ retryLimit?: number;
127
+ }
128
+
129
+ export interface ApplyOptions extends ProtocolAction, PlainObject {
130
+ client?: ClientConfig;
131
+ readExpect?: ReadExpectType;
132
+ acceptEncoding?: boolean;
133
+ keepAlive?: boolean;
134
+ }
135
+
136
+ export type BufferFormat = "json" | "yaml" | "json5" | "xml" | "toml";
137
+ export type ReadExpectType = "always" | "string" | "none";
138
+ export type DataEncodedResult<T extends { encoding?: BufferEncoding }> = T extends { encoding: BufferEncoding } ? string : Null<Bufferable>;
139
+ export type DataObjectResult<T extends { format?: unknown; encoding?: BufferEncoding }> = T extends { format: string | PlainObject } ? Null<object> : DataEncodedResult<T>;
140
+ export type StatusOnCallback = (code: number, headers: IncomingHttpHeaders, url?: URL) => Void<boolean>;
139
141
  export type HeadersOnCallback = (headers: IncomingHttpHeaders, url?: URL) => Void<boolean>;