@maiyunnet/kebab 2.0.4 → 2.0.5
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/index.d.ts +14 -0
- package/index.js +1 -1
- package/lib/buffer.d.ts +25 -0
- package/lib/captcha.d.ts +12 -0
- package/lib/consistent.d.ts +20 -0
- package/lib/core.d.ts +85 -0
- package/lib/crypto.d.ts +47 -0
- package/lib/db.d.ts +88 -0
- package/lib/dns.d.ts +75 -0
- package/lib/fs.d.ts +49 -0
- package/lib/jwt.d.ts +30 -0
- package/lib/kv.d.ts +111 -0
- package/lib/lan.d.ts +10 -0
- package/lib/net/formdata.d.ts +23 -0
- package/lib/net/request.d.ts +23 -0
- package/lib/net/response.d.ts +14 -0
- package/lib/net.d.ts +65 -0
- package/lib/s3.d.ts +35 -0
- package/lib/scan.d.ts +31 -0
- package/lib/session.d.ts +22 -0
- package/lib/sql.d.ts +57 -0
- package/lib/ssh/sftp.d.ts +40 -0
- package/lib/ssh/shell.d.ts +13 -0
- package/lib/ssh.d.ts +24 -0
- package/lib/text.d.ts +40 -0
- package/lib/time.d.ts +22 -0
- package/lib/ws.d.ts +87 -0
- package/lib/zip.d.ts +40 -0
- package/lib/zlib.d.ts +25 -0
- package/main.d.ts +1 -0
- package/package.json +1 -1
- package/sys/child.d.ts +1 -0
- package/sys/cmd.d.ts +1 -0
- package/sys/ctr.d.ts +96 -0
- package/sys/master.d.ts +1 -0
- package/sys/mod.d.ts +205 -0
- package/sys/route.d.ts +31 -0
- package/types/index.d.ts +283 -0
- package/www/example/ctr/main.d.ts +4 -0
- package/www/example/ctr/middle.d.ts +6 -0
- package/www/example/ctr/test.d.ts +94 -0
- package/www/example/mod/test.d.ts +20 -0
- package/www/example/mod/testdata.d.ts +9 -0
- package/www/example/ws/mproxy.d.ts +4 -0
- package/www/example/ws/rproxy.d.ts +4 -0
- package/www/example/ws/test.d.ts +7 -0
package/lib/net.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
import * as http from 'http';
|
|
3
|
+
import * as http2 from 'http2';
|
|
4
|
+
import * as ctr from '~/sys/ctr';
|
|
5
|
+
import * as types from '~/types';
|
|
6
|
+
import * as fd from './net/formdata';
|
|
7
|
+
import * as lRequest from './net/request';
|
|
8
|
+
import * as response from './net/response';
|
|
9
|
+
export interface IRequestOptions {
|
|
10
|
+
'method'?: 'GET' | 'POST' | 'OPTIONS';
|
|
11
|
+
'type'?: 'form' | 'json';
|
|
12
|
+
'timeout'?: number;
|
|
13
|
+
'follow'?: number;
|
|
14
|
+
'hosts'?: Record<string, string>;
|
|
15
|
+
'save'?: string;
|
|
16
|
+
'local'?: string;
|
|
17
|
+
'headers'?: types.THttpHeaders;
|
|
18
|
+
'mproxy'?: {
|
|
19
|
+
'url': string;
|
|
20
|
+
'auth': string;
|
|
21
|
+
'data'?: any;
|
|
22
|
+
};
|
|
23
|
+
'reuse'?: string;
|
|
24
|
+
'cookie'?: Record<string, types.ICookie>;
|
|
25
|
+
}
|
|
26
|
+
export interface IMproxyOptions {
|
|
27
|
+
'timeout'?: number;
|
|
28
|
+
'follow'?: number;
|
|
29
|
+
'hosts'?: Record<string, string>;
|
|
30
|
+
'local'?: string;
|
|
31
|
+
'headers'?: types.THttpHeaders;
|
|
32
|
+
'reuse'?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface IRproxyOptions {
|
|
35
|
+
'timeout'?: number;
|
|
36
|
+
'follow'?: number;
|
|
37
|
+
'hosts'?: Record<string, string>;
|
|
38
|
+
'local'?: string;
|
|
39
|
+
'headers'?: types.THttpHeaders;
|
|
40
|
+
'mproxy'?: {
|
|
41
|
+
'url': string;
|
|
42
|
+
'auth': string;
|
|
43
|
+
'data'?: any;
|
|
44
|
+
};
|
|
45
|
+
'reuse'?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function getCa(): Promise<string>;
|
|
48
|
+
export declare function open(u: string): lRequest.Request;
|
|
49
|
+
export declare function get(u: string, opt?: IRequestOptions): Promise<response.Response>;
|
|
50
|
+
export declare function post(u: string, data: Record<string, types.Json> | Buffer | string | stream.Readable, opt?: IRequestOptions): Promise<response.Response>;
|
|
51
|
+
export declare function postJson(u: string, data: types.Json[] | Record<string, types.Json>, opt?: IRequestOptions): Promise<response.Response>;
|
|
52
|
+
export declare function request(u: string, data?: Record<string, types.Json> | Buffer | string | stream.Readable, opt?: IRequestOptions): Promise<response.Response>;
|
|
53
|
+
export declare function setCookie(cookie: Record<string, types.ICookie>, name: string, value: string, domain: string, opt?: {
|
|
54
|
+
'ttl'?: number;
|
|
55
|
+
'path'?: string;
|
|
56
|
+
'ssl'?: boolean;
|
|
57
|
+
'httponly'?: boolean;
|
|
58
|
+
}): void;
|
|
59
|
+
export declare function buildCookieQuery(cookie: Record<string, types.ICookie>, uri: types.IUrlParse): string;
|
|
60
|
+
export declare function resetCookieSession(cookie: Record<string, types.ICookie>): void;
|
|
61
|
+
export declare function getFormData(): fd.FormData;
|
|
62
|
+
export declare function filterProxyHeaders(headers: http.IncomingHttpHeaders | http2.IncomingHttpHeaders | types.THttpHeaders, res?: http2.Http2ServerResponse | http.ServerResponse): Record<string, string | string[]>;
|
|
63
|
+
export declare function mproxy(ctr: ctr.Ctr, auth: string, opt?: IMproxyOptions): Promise<number>;
|
|
64
|
+
export declare function mproxyData(ctr: ctr.Ctr): any;
|
|
65
|
+
export declare function rproxy(ctr: ctr.Ctr, route: Record<string, string>, opt?: IRproxyOptions): Promise<boolean>;
|
package/lib/s3.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as s3 from '@aws-sdk/client-s3';
|
|
2
|
+
import * as stream from 'stream';
|
|
3
|
+
import * as sCtr from '~/sys/ctr';
|
|
4
|
+
export declare enum ESERVICE {
|
|
5
|
+
'AMAZON' = 0,
|
|
6
|
+
'TENCENT' = 1,
|
|
7
|
+
'ALIBABA' = 2,
|
|
8
|
+
'CF' = 3
|
|
9
|
+
}
|
|
10
|
+
export interface IOptions {
|
|
11
|
+
'service': ESERVICE;
|
|
12
|
+
'account'?: string;
|
|
13
|
+
'secretId'?: string;
|
|
14
|
+
'secretKey'?: string;
|
|
15
|
+
'region'?: string;
|
|
16
|
+
'bucket'?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class S3 {
|
|
19
|
+
private readonly _link;
|
|
20
|
+
private _bucket;
|
|
21
|
+
private readonly _ctr;
|
|
22
|
+
constructor(ctr: sCtr.Ctr, opt: IOptions);
|
|
23
|
+
setBucket(bucket: string): void;
|
|
24
|
+
putObject(key: string, content: string | Buffer | stream.Readable, length?: number | {
|
|
25
|
+
'length'?: number;
|
|
26
|
+
'type'?: string;
|
|
27
|
+
'disposition'?: string;
|
|
28
|
+
'bucket'?: string;
|
|
29
|
+
}, bucket?: string): Promise<s3.CompleteMultipartUploadCommandOutput | false>;
|
|
30
|
+
getObject(key: string, bucket?: string): Promise<false | (stream.Readable & import("@smithy/types").SdkStreamMixin) | (Blob & import("@smithy/types").SdkStreamMixin) | (ReadableStream<any> & import("@smithy/types").SdkStreamMixin) | undefined>;
|
|
31
|
+
deleteObject(key: string, bucket?: string): Promise<boolean>;
|
|
32
|
+
deleteObjects(keys: string[], bucket?: string): Promise<boolean>;
|
|
33
|
+
headObject(key: string, bucket?: string): Promise<s3.HeadObjectCommandOutput | false>;
|
|
34
|
+
}
|
|
35
|
+
export declare function get(ctr: sCtr.Ctr, opt: IOptions): S3;
|
package/lib/scan.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as lDb from '~/lib/db';
|
|
2
|
+
import * as lKv from '~/lib/kv';
|
|
3
|
+
import * as sCtr from '~/sys/ctr';
|
|
4
|
+
export interface IOptions {
|
|
5
|
+
'ttl'?: number;
|
|
6
|
+
'sqlPre'?: sCtr.Ctr | string;
|
|
7
|
+
'name'?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IStaticOptions {
|
|
10
|
+
'sqlPre'?: sCtr.Ctr | string;
|
|
11
|
+
'name'?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class Scan {
|
|
14
|
+
private readonly _link;
|
|
15
|
+
private readonly _sql;
|
|
16
|
+
private readonly _name;
|
|
17
|
+
private _token;
|
|
18
|
+
private _ttl;
|
|
19
|
+
constructor(link: lDb.Pool | lKv.Pool, token?: string, opt?: IOptions);
|
|
20
|
+
private _timeLeft;
|
|
21
|
+
poll(): Promise<any>;
|
|
22
|
+
createToken(): Promise<boolean>;
|
|
23
|
+
getToken(): string | null;
|
|
24
|
+
setTTL(ttl: number): void;
|
|
25
|
+
getTTL(): number;
|
|
26
|
+
getTimeLeft(): number | null;
|
|
27
|
+
private _gc;
|
|
28
|
+
}
|
|
29
|
+
export declare function get(link: lDb.Pool | lKv.Pool, token?: string, opt?: IOptions): Promise<Scan>;
|
|
30
|
+
export declare function scanned(link: lDb.Pool | lKv.Pool, token: string, opt?: IStaticOptions): Promise<boolean>;
|
|
31
|
+
export declare function setData(link: lDb.Pool | lKv.Pool, token: string, data: Record<string, any> | string | number, opt?: IStaticOptions): Promise<boolean>;
|
package/lib/session.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as db from '~/lib/db';
|
|
2
|
+
import * as kv from '~/lib/kv';
|
|
3
|
+
import * as ctr from '~/sys/ctr';
|
|
4
|
+
export interface IOptions {
|
|
5
|
+
'name'?: string;
|
|
6
|
+
'ttl'?: number;
|
|
7
|
+
'ssl'?: boolean;
|
|
8
|
+
'sqlPre'?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class Session {
|
|
11
|
+
private _link;
|
|
12
|
+
private _sql;
|
|
13
|
+
private _name;
|
|
14
|
+
private _token;
|
|
15
|
+
private _ttl;
|
|
16
|
+
private _ctr;
|
|
17
|
+
init(ctr: ctr.Ctr, link: db.Pool | kv.Pool, auth?: boolean, opt?: IOptions): Promise<boolean>;
|
|
18
|
+
getToken(): string;
|
|
19
|
+
getName(): string;
|
|
20
|
+
update(): Promise<void>;
|
|
21
|
+
private _gc;
|
|
22
|
+
}
|
package/lib/sql.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as ctr from '~/sys/ctr';
|
|
2
|
+
import * as types from '~/types';
|
|
3
|
+
export declare class Sql {
|
|
4
|
+
private readonly _pre;
|
|
5
|
+
private _sql;
|
|
6
|
+
private _data;
|
|
7
|
+
constructor(pre?: string, opt?: {
|
|
8
|
+
'data'?: types.DbValue[];
|
|
9
|
+
'sql'?: string[];
|
|
10
|
+
});
|
|
11
|
+
insert(table: string): this;
|
|
12
|
+
replace(table: string): this;
|
|
13
|
+
values(cs: string[] | Record<string, types.DbValue>, vs?: types.DbValue[] | types.DbValue[][]): this;
|
|
14
|
+
notExists(table: string, insert: Record<string, types.DbValue>, where: string | types.Json): this;
|
|
15
|
+
duplicate(s: types.Json): this;
|
|
16
|
+
select(c: string | Array<string | Array<string | string[]>>, f: string | string[]): this;
|
|
17
|
+
update(f: string, s: types.Json): this;
|
|
18
|
+
private _updateSub;
|
|
19
|
+
delete(f: string): this;
|
|
20
|
+
union(lsql: Sql, type?: string): this;
|
|
21
|
+
unionAll(lsql: Sql): this;
|
|
22
|
+
join(f: string, s?: types.Json, type?: string, suf?: string, pre?: string): this;
|
|
23
|
+
leftJoin(f: string, s?: types.Json, suf?: string, pre?: string): this;
|
|
24
|
+
rightJoin(f: string, s?: types.Json, suf?: string, pre?: string): this;
|
|
25
|
+
innerJoin(f: string, s?: types.Json, suf?: string, pre?: string): this;
|
|
26
|
+
fullJoin(f: string, s?: types.Json, suf?: string, pre?: string): this;
|
|
27
|
+
crossJoin(f: string, s?: types.Json, suf?: string, pre?: string): this;
|
|
28
|
+
having(s?: string | types.Json): this;
|
|
29
|
+
private _whereDataPosition;
|
|
30
|
+
where(s: string | types.Json): this;
|
|
31
|
+
private _whereSub;
|
|
32
|
+
by(c: string | Array<string | string[]>, d?: 'DESC' | 'ASC'): this;
|
|
33
|
+
group(c: string | string[]): this;
|
|
34
|
+
limit(a: number, b?: number): this;
|
|
35
|
+
lock(): this;
|
|
36
|
+
copy(f?: string | string[], opt?: {
|
|
37
|
+
'where'?: string | types.Json;
|
|
38
|
+
}): Sql;
|
|
39
|
+
getSql(): string;
|
|
40
|
+
getData(): types.DbValue[];
|
|
41
|
+
getPre(): string;
|
|
42
|
+
format(sql?: string, data?: types.DbValue[]): string;
|
|
43
|
+
append(sql: string): this;
|
|
44
|
+
field(str: string | number | Array<string | string[]>, pre?: string, suf?: string): string;
|
|
45
|
+
private _isField;
|
|
46
|
+
}
|
|
47
|
+
export declare function get(ctrPre?: ctr.Ctr | string, opt?: {
|
|
48
|
+
'data'?: types.DbValue[];
|
|
49
|
+
'sql'?: string[];
|
|
50
|
+
}): Sql;
|
|
51
|
+
export declare function format(sql: string, data: types.DbValue[]): string;
|
|
52
|
+
export declare function aoMix(arr: types.Json): Record<string, string | number | types.Json>;
|
|
53
|
+
export declare function column(field: string): {
|
|
54
|
+
'type': 'column';
|
|
55
|
+
'token': string;
|
|
56
|
+
'value': string;
|
|
57
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
import * as ssh2 from 'ssh2';
|
|
3
|
+
export declare class Connection {
|
|
4
|
+
private readonly _client;
|
|
5
|
+
private _path;
|
|
6
|
+
constructor(sftp: ssh2.SFTPWrapper, path: string);
|
|
7
|
+
getContent(path: string, options?: {
|
|
8
|
+
'start'?: number;
|
|
9
|
+
'end'?: number;
|
|
10
|
+
}): Promise<Buffer | null>;
|
|
11
|
+
getContent(path: string, options: BufferEncoding | {
|
|
12
|
+
'encoding': BufferEncoding;
|
|
13
|
+
'start'?: number;
|
|
14
|
+
'end'?: number;
|
|
15
|
+
}): Promise<string | null>;
|
|
16
|
+
putContent(path: string, data: string | Buffer, options?: ssh2.WriteFileOptions): Promise<boolean>;
|
|
17
|
+
readLink(path: string): Promise<string | null>;
|
|
18
|
+
symlink(filePath: string, linkPath: string): Promise<boolean>;
|
|
19
|
+
unlink(path: string): Promise<boolean>;
|
|
20
|
+
private _unlink;
|
|
21
|
+
stats(path: string): Promise<ssh2.Stats | null>;
|
|
22
|
+
isDir(path: string): Promise<ssh2.Stats | false>;
|
|
23
|
+
isFile(path: string): Promise<ssh2.Stats | false>;
|
|
24
|
+
mkdir(path: string, mode?: number): Promise<boolean>;
|
|
25
|
+
rmdir(path: string): Promise<boolean>;
|
|
26
|
+
rmdirDeep(path: string): Promise<boolean>;
|
|
27
|
+
chmod(path: string, mode: string | number): Promise<boolean>;
|
|
28
|
+
rename(oldPath: string, newPath: string): Promise<boolean>;
|
|
29
|
+
readDir(path: string): Promise<ssh2.FileEntry[]>;
|
|
30
|
+
createReadStream(path: string, options?: ssh2.ReadStreamOptions): stream.Readable;
|
|
31
|
+
pipe<T extends NodeJS.WritableStream>(path: string, destination: T, options?: {
|
|
32
|
+
'end'?: boolean;
|
|
33
|
+
}): Promise<boolean>;
|
|
34
|
+
createWriteStream(path: string, options?: BufferEncoding | ssh2.WriteStreamOptions): stream.Writable;
|
|
35
|
+
pwd(): string;
|
|
36
|
+
downloadFile(remoteFile: string, localFile: string, options?: ssh2.TransferOptions): Promise<boolean>;
|
|
37
|
+
uploadFile(localFile: string, remoteFile: string, options?: ssh2.TransferOptions): Promise<boolean>;
|
|
38
|
+
cd(dir: string): string;
|
|
39
|
+
close(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as ssh2 from 'ssh2';
|
|
2
|
+
export declare class Connection {
|
|
3
|
+
private readonly _client;
|
|
4
|
+
constructor(stream: ssh2.ClientChannel);
|
|
5
|
+
send(cmd: string | Buffer, encoding?: BufferEncoding): Promise<boolean>;
|
|
6
|
+
sendLine(cmd: string, encoding?: BufferEncoding): Promise<boolean>;
|
|
7
|
+
sendEnter(): Promise<boolean>;
|
|
8
|
+
sendTab(): Promise<boolean>;
|
|
9
|
+
sendCtrlC(): Promise<boolean>;
|
|
10
|
+
close(cmd?: string | Buffer, encoding?: BufferEncoding): Promise<void>;
|
|
11
|
+
getContent(tryCount?: number): Promise<Buffer>;
|
|
12
|
+
getStream(): ssh2.ClientChannel;
|
|
13
|
+
}
|
package/lib/ssh.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as ssh2 from 'ssh2';
|
|
2
|
+
import * as shell from './ssh/shell';
|
|
3
|
+
import * as sftp from './ssh/sftp';
|
|
4
|
+
interface IExtOptions {
|
|
5
|
+
'mproxy'?: {
|
|
6
|
+
'host': string;
|
|
7
|
+
'port': number;
|
|
8
|
+
'username': string;
|
|
9
|
+
'password': string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare class Connection {
|
|
13
|
+
private readonly _client;
|
|
14
|
+
private _mclient?;
|
|
15
|
+
constructor();
|
|
16
|
+
connect(opt: ssh2.ConnectConfig & IExtOptions): Promise<boolean>;
|
|
17
|
+
disconnect(): void;
|
|
18
|
+
exec(command: string): Promise<Buffer | false>;
|
|
19
|
+
getShell(): Promise<shell.Connection | null>;
|
|
20
|
+
getSftp(): Promise<sftp.Connection | null>;
|
|
21
|
+
getStream(): Promise<ssh2.ClientChannel | null>;
|
|
22
|
+
}
|
|
23
|
+
export declare function get(opt: ssh2.ConnectConfig & IExtOptions): Promise<Connection | null>;
|
|
24
|
+
export {};
|
package/lib/text.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as types from '~/types';
|
|
2
|
+
export declare function sizeFormat(size: number, spliter?: string): string;
|
|
3
|
+
export declare function parseUrl(url: string): types.IUrlParse;
|
|
4
|
+
export declare function urlResolve(from: string, to: string): string;
|
|
5
|
+
export declare function urlAtom(url: string): string;
|
|
6
|
+
export declare const REGEXP_EMAIL: RegExp;
|
|
7
|
+
export declare function isEMail(email: string): boolean;
|
|
8
|
+
export declare const REGEXP_IPV4: RegExp;
|
|
9
|
+
export declare function isIPv4(ip: string): boolean;
|
|
10
|
+
export declare const REGEXP_IPV6: RegExp;
|
|
11
|
+
export declare function isIPv6(ip: string): boolean;
|
|
12
|
+
export declare const REGEXP_DOMAIN: RegExp;
|
|
13
|
+
export declare function isDomain(domain: string): boolean;
|
|
14
|
+
export declare const REGEXP_ASCII: RegExp;
|
|
15
|
+
export declare function isAscii(text: string): boolean;
|
|
16
|
+
export declare function nlReplace(str: string, to?: string): string;
|
|
17
|
+
export interface IDomain {
|
|
18
|
+
tld: string | null;
|
|
19
|
+
sld: string | null;
|
|
20
|
+
domain: string | null;
|
|
21
|
+
sub: string | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function parseDomain(domain: string): Promise<IDomain>;
|
|
24
|
+
export declare function match(str: string, regs: RegExp[]): boolean;
|
|
25
|
+
export declare function isPhoneCN(p: string): boolean;
|
|
26
|
+
export declare function isIdCardCN(idcard: string): boolean;
|
|
27
|
+
export declare function queryStringify(query: Record<string, any>, encode?: boolean): string;
|
|
28
|
+
export declare function queryParse(query: string): Record<string, string | string[]>;
|
|
29
|
+
export declare function htmlescape(html: string): string;
|
|
30
|
+
export declare function isRealPath(path: string): boolean;
|
|
31
|
+
export declare function getFilename(path: string): string;
|
|
32
|
+
export declare function stringifyResult(rtn: types.Json): string;
|
|
33
|
+
export declare function parseJson(str: string): any;
|
|
34
|
+
export declare function stringifyJson(obj: types.Json, space?: string | number): string;
|
|
35
|
+
type TFalsy = false | '' | 0 | null | undefined | typeof NaN;
|
|
36
|
+
export declare function isFalsy(val: any): val is TFalsy;
|
|
37
|
+
export declare function logicalOr<T, T2>(v1: T, v2: T2): [T] extends [TFalsy] ? T2 : T;
|
|
38
|
+
export declare function str2int(str: string, digits?: number): number;
|
|
39
|
+
export declare function int2str(int: number, digits?: number, decimal?: number): string;
|
|
40
|
+
export {};
|
package/lib/time.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as sCtr from '~/sys/ctr';
|
|
2
|
+
export interface IOptions {
|
|
3
|
+
'zone'?: number;
|
|
4
|
+
'data'?: string | number;
|
|
5
|
+
}
|
|
6
|
+
export declare const HOUR = 3600;
|
|
7
|
+
export declare const DAY = 86400;
|
|
8
|
+
export declare const YEAR = 31536000;
|
|
9
|
+
export declare class Time {
|
|
10
|
+
private readonly _date;
|
|
11
|
+
private _zone;
|
|
12
|
+
constructor(ctr: sCtr.Ctr, opt: IOptions);
|
|
13
|
+
setZone(zone: number): void;
|
|
14
|
+
getZone(): number;
|
|
15
|
+
toUTCString(): string;
|
|
16
|
+
format(f: string, zone?: number): string;
|
|
17
|
+
stamp(): number;
|
|
18
|
+
}
|
|
19
|
+
export declare function get(ctr: sCtr.Ctr, opt?: IOptions): Time;
|
|
20
|
+
export declare function stamp(date?: Date | string, zone?: number | sCtr.Ctr | null): number;
|
|
21
|
+
export declare function isMs(time: number): boolean;
|
|
22
|
+
export declare function format(zone: number | sCtr.Ctr | null, f: string, date?: Date | number): string;
|
package/lib/ws.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as net from 'net';
|
|
3
|
+
import * as types from '~/types';
|
|
4
|
+
import * as sCtr from '~/sys/ctr';
|
|
5
|
+
export declare enum EFrameReceiveMode {
|
|
6
|
+
STANDARD = 0,
|
|
7
|
+
LITE = 1,
|
|
8
|
+
SIMPLE = 2
|
|
9
|
+
}
|
|
10
|
+
export declare enum EOpcode {
|
|
11
|
+
CONTINUATION = 0,
|
|
12
|
+
TEXT = 1,
|
|
13
|
+
BINARY = 2,
|
|
14
|
+
CLOSE = 8,
|
|
15
|
+
PING = 9,
|
|
16
|
+
PONG = 10
|
|
17
|
+
}
|
|
18
|
+
export interface IConnectOptions {
|
|
19
|
+
'timeout'?: number;
|
|
20
|
+
'hosts'?: Record<string, string>;
|
|
21
|
+
'local'?: string;
|
|
22
|
+
'headers'?: types.THttpHeaders;
|
|
23
|
+
'cookie'?: Record<string, types.ICookie>;
|
|
24
|
+
'mode'?: EFrameReceiveMode;
|
|
25
|
+
'masking'?: boolean;
|
|
26
|
+
'mproxy'?: {
|
|
27
|
+
'url': string;
|
|
28
|
+
'auth': string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface IMproxyOptions {
|
|
32
|
+
'timeout'?: number;
|
|
33
|
+
'hosts'?: Record<string, string>;
|
|
34
|
+
'local'?: string;
|
|
35
|
+
'headers'?: types.THttpHeaders;
|
|
36
|
+
'mode'?: EFrameReceiveMode;
|
|
37
|
+
'masking'?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface IRproxyOptions {
|
|
40
|
+
'timeout'?: number;
|
|
41
|
+
'hosts'?: Record<string, string>;
|
|
42
|
+
'local'?: string;
|
|
43
|
+
'headers'?: types.THttpHeaders;
|
|
44
|
+
'mode'?: EFrameReceiveMode;
|
|
45
|
+
'masking'?: boolean;
|
|
46
|
+
'mproxy'?: {
|
|
47
|
+
'url': string;
|
|
48
|
+
'auth': string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare class Socket {
|
|
52
|
+
private _ws;
|
|
53
|
+
constructor(request?: http.IncomingMessage, socket?: net.Socket, options?: {
|
|
54
|
+
'headers'?: http.OutgoingHttpHeaders;
|
|
55
|
+
'timeout'?: number;
|
|
56
|
+
});
|
|
57
|
+
connect(u: string, opt?: IConnectOptions): Promise<this | null>;
|
|
58
|
+
private _bindEvent;
|
|
59
|
+
private readonly _waitMsg;
|
|
60
|
+
private _error;
|
|
61
|
+
private _close;
|
|
62
|
+
private _on;
|
|
63
|
+
on(event: 'message', cb: (msg: {
|
|
64
|
+
'opcode': EOpcode;
|
|
65
|
+
'data': Buffer | string;
|
|
66
|
+
}) => void | Promise<void>): this;
|
|
67
|
+
on(event: 'error', cb: (error: any) => void | Promise<void>): this;
|
|
68
|
+
on(event: 'drain' | 'close' | 'end', cb: () => void | Promise<void>): this;
|
|
69
|
+
end(): void;
|
|
70
|
+
destroy(): void;
|
|
71
|
+
writeText(data: string): boolean;
|
|
72
|
+
writeResult(data: types.Json): boolean;
|
|
73
|
+
writeBinary(data: string | Buffer | Array<string | Buffer>): boolean;
|
|
74
|
+
get writable(): boolean;
|
|
75
|
+
get ended(): boolean;
|
|
76
|
+
get finished(): boolean;
|
|
77
|
+
get isServer(): boolean;
|
|
78
|
+
ping(data?: Buffer | string): boolean;
|
|
79
|
+
pong(data?: Buffer | string): boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare function connect(u: string, opt?: IConnectOptions): Promise<Socket | null>;
|
|
82
|
+
export declare function createServer(request: http.IncomingMessage, socket: net.Socket, options?: {
|
|
83
|
+
'headers'?: http.OutgoingHttpHeaders;
|
|
84
|
+
'timeout'?: number;
|
|
85
|
+
}): Socket;
|
|
86
|
+
export declare function mproxy(ctr: sCtr.Ctr, auth: string, opt?: IMproxyOptions): Promise<number>;
|
|
87
|
+
export declare function rproxy(ctr: sCtr.Ctr, url: string, opt?: IRproxyOptions): Promise<boolean>;
|
package/lib/zip.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import jszip from 'jszip';
|
|
2
|
+
import * as types from '~/types';
|
|
3
|
+
export declare class Zip {
|
|
4
|
+
private readonly _zip;
|
|
5
|
+
private _path;
|
|
6
|
+
constructor(zip: jszip);
|
|
7
|
+
getContent(path: string): Promise<string | null>;
|
|
8
|
+
getContent<T extends types.TZipOutputType>(path: string, type: T): Promise<types.IZipOutputByType[T] | null>;
|
|
9
|
+
putContent<T extends types.TZipInputType>(path: string, data: types.IZipInputByType[T], options?: {
|
|
10
|
+
'base64'?: boolean;
|
|
11
|
+
'binary'?: boolean;
|
|
12
|
+
'date'?: Date;
|
|
13
|
+
}): void;
|
|
14
|
+
unlink(path: string): void;
|
|
15
|
+
stats(path: string): types.IZipStats | null;
|
|
16
|
+
isDir(path: string): types.IZipStats | false;
|
|
17
|
+
isFile(path: string): types.IZipStats | false;
|
|
18
|
+
readDir(path?: string, opt?: {
|
|
19
|
+
'hasChildren'?: boolean;
|
|
20
|
+
'hasDir'?: boolean;
|
|
21
|
+
'pathAsKey'?: false;
|
|
22
|
+
}): types.IZipItem[];
|
|
23
|
+
readDir(path?: string, opt?: {
|
|
24
|
+
'hasChildren'?: boolean;
|
|
25
|
+
'hasDir'?: boolean;
|
|
26
|
+
'pathAsKey': true;
|
|
27
|
+
}): Record<string, types.IZipItem>;
|
|
28
|
+
private _readDir;
|
|
29
|
+
private _list;
|
|
30
|
+
private _refreshList;
|
|
31
|
+
pwd(): string;
|
|
32
|
+
cd(dir: string): string;
|
|
33
|
+
generate<T extends types.TZipOutputType>(options?: {
|
|
34
|
+
'type'?: T;
|
|
35
|
+
'level'?: number;
|
|
36
|
+
'onUpdate'?: (percent: number, currentFile: string | null) => void;
|
|
37
|
+
}): Promise<types.IZipOutputByType[T]>;
|
|
38
|
+
getList(): Promise<Record<string, Buffer | string>>;
|
|
39
|
+
}
|
|
40
|
+
export declare function get(data?: types.TZipInputFileFormat): Promise<Zip | null>;
|
package/lib/zlib.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as zlib from 'zlib';
|
|
2
|
+
export interface ICompress {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly compress: zlib.Deflate | zlib.Gzip | zlib.BrotliCompress | zlib.Inflate | zlib.Gunzip | zlib.BrotliDecompress;
|
|
5
|
+
}
|
|
6
|
+
export interface ICompressBuffer {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly buffer: Buffer;
|
|
9
|
+
}
|
|
10
|
+
export declare function createGzip(options?: zlib.ZlibOptions): zlib.Gzip;
|
|
11
|
+
export declare function createGunzip(): zlib.Gunzip;
|
|
12
|
+
export declare function createDeflate(options?: zlib.ZlibOptions): zlib.Deflate;
|
|
13
|
+
export declare function createInflate(): zlib.Inflate;
|
|
14
|
+
export declare function createBrotliCompress(options?: zlib.ZlibOptions): zlib.BrotliCompress;
|
|
15
|
+
export declare function createBrotliDecompress(): zlib.BrotliDecompress;
|
|
16
|
+
export declare function createCompress(types: string, options?: zlib.ZlibOptions): ICompress | null;
|
|
17
|
+
export declare function createDecompress(types: string): ICompress | null;
|
|
18
|
+
export declare function gzip(buffer: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer | null>;
|
|
19
|
+
export declare function gunzip(buffer: zlib.InputType): Promise<Buffer | null>;
|
|
20
|
+
export declare function deflate(buffer: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer | null>;
|
|
21
|
+
export declare function inflate(buffer: zlib.InputType): Promise<Buffer | null>;
|
|
22
|
+
export declare function brotliCompress(buffer: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer | null>;
|
|
23
|
+
export declare function brotliDecompress(buffer: zlib.InputType): Promise<Buffer | null>;
|
|
24
|
+
export declare function compress(types: string, buffer: zlib.InputType | null, options?: zlib.ZlibOptions): Promise<ICompressBuffer | null>;
|
|
25
|
+
export declare function decompress(types: string, buffer: zlib.InputType | null): Promise<ICompressBuffer | null>;
|
package/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'ts-alias-loader';
|
package/package.json
CHANGED
package/sys/child.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/sys/cmd.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/sys/ctr.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as http2 from 'http2';
|
|
3
|
+
import * as session from '../lib/session';
|
|
4
|
+
import * as db from '../lib/db';
|
|
5
|
+
import * as kv from '../lib/kv';
|
|
6
|
+
import * as lWs from '../lib/ws';
|
|
7
|
+
import * as types from '../types';
|
|
8
|
+
export declare function clearLocaleData(): void;
|
|
9
|
+
export declare class Ctr {
|
|
10
|
+
protected _param: string[];
|
|
11
|
+
protected _action: string;
|
|
12
|
+
protected _headers: http.IncomingHttpHeaders;
|
|
13
|
+
protected _get: Record<string, string>;
|
|
14
|
+
protected _rawPost: Record<string, types.Json>;
|
|
15
|
+
protected _post: Record<string, types.Json>;
|
|
16
|
+
protected _input: string;
|
|
17
|
+
protected _files: Record<string, types.IPostFile | types.IPostFile[]>;
|
|
18
|
+
protected _cookie: Record<string, string>;
|
|
19
|
+
protected _jwt: Record<string, types.Json>;
|
|
20
|
+
protected _session: Record<string, types.Json>;
|
|
21
|
+
protected _sess: session.Session | null;
|
|
22
|
+
protected _cacheTTL: number;
|
|
23
|
+
protected _xsrf: string;
|
|
24
|
+
protected _httpCode: number;
|
|
25
|
+
protected _locale: string;
|
|
26
|
+
protected readonly _config: types.IConfig;
|
|
27
|
+
protected readonly _req: http2.Http2ServerRequest | http.IncomingMessage;
|
|
28
|
+
protected readonly _res: http2.Http2ServerResponse | http.ServerResponse;
|
|
29
|
+
protected readonly _socket: lWs.Socket;
|
|
30
|
+
protected _localeFiles: string[];
|
|
31
|
+
protected _localeData: Record<string, Record<string, string>>;
|
|
32
|
+
constructor(config: types.IConfig, req: http2.Http2ServerRequest | http.IncomingMessage, res?: http2.Http2ServerResponse | http.ServerResponse);
|
|
33
|
+
get isAvail(): boolean;
|
|
34
|
+
protected _timer?: {
|
|
35
|
+
'timer': NodeJS.Timeout;
|
|
36
|
+
'timeout': number;
|
|
37
|
+
'callback': () => void;
|
|
38
|
+
};
|
|
39
|
+
get timeout(): number;
|
|
40
|
+
set timeout(num: number);
|
|
41
|
+
private readonly _waitInfo;
|
|
42
|
+
protected _asyncTask(func: () => void | Promise<void>): void;
|
|
43
|
+
getPrototype(name: '_config'): types.IConfig;
|
|
44
|
+
getPrototype(name: '_sess'): session.Session | null;
|
|
45
|
+
getPrototype(name: '_headers'): http.IncomingHttpHeaders;
|
|
46
|
+
getPrototype(name: '_req'): http2.Http2ServerRequest | http.IncomingMessage;
|
|
47
|
+
getPrototype(name: '_res'): http2.Http2ServerResponse | http.ServerResponse;
|
|
48
|
+
getPrototype(name: '_socket'): lWs.Socket;
|
|
49
|
+
getPrototype(name: '_rawPost' | '_post' | '_get' | '_session'): Record<string, types.Json>;
|
|
50
|
+
getPrototype(name: '_input'): string;
|
|
51
|
+
getPrototype(name: string): types.Json;
|
|
52
|
+
setPrototype(name: string, val: string | string[] | http.IncomingHttpHeaders | Record<string, types.Json> | session.Session | lWs.Socket | null): void;
|
|
53
|
+
onLoad(): boolean | string | types.DbValue[] | Promise<boolean | string | types.DbValue[]>;
|
|
54
|
+
onUnload(rtn: boolean | string | types.DbValue[]): boolean | string | types.DbValue[] | Promise<boolean | string | types.DbValue[]>;
|
|
55
|
+
onUpgrade(): {
|
|
56
|
+
'headers'?: http.OutgoingHttpHeaders;
|
|
57
|
+
'timeout'?: number;
|
|
58
|
+
};
|
|
59
|
+
onData(data: Buffer | string, opcode: lWs.EOpcode): types.Json;
|
|
60
|
+
onMessage(data: Buffer | string, opcode: lWs.EOpcode): undefined | boolean | Promise<undefined | boolean>;
|
|
61
|
+
onDrain(): void | Promise<void>;
|
|
62
|
+
onClose(): void | Promise<void>;
|
|
63
|
+
protected _getRunTime(ms?: boolean): number;
|
|
64
|
+
protected _getMemoryUsage(): number;
|
|
65
|
+
protected _loadView(path: string, data?: types.Json): Promise<string>;
|
|
66
|
+
protected _checkInput(input: Record<string, types.Json>, rule: Record<string, types.Json[]>, rtn: types.Json[]): boolean;
|
|
67
|
+
protected _checkXInput(input: Record<string, types.Json>, rule: Record<string, types.Json[]>, rtn: types.Json[]): boolean;
|
|
68
|
+
protected _enabledXsrf(): void;
|
|
69
|
+
protected _getBasicAuth(user: string, pwd: string): string;
|
|
70
|
+
protected _device(): 'android' | 'windows' | 'linux' | 'macintosh' | 'ipad' | 'unknown';
|
|
71
|
+
private _authorization;
|
|
72
|
+
getAuthorization(): {
|
|
73
|
+
'user': string;
|
|
74
|
+
'pwd': string;
|
|
75
|
+
} | false | string;
|
|
76
|
+
protected _loadData(path: string): Promise<Record<string, string> | null>;
|
|
77
|
+
protected _location(location: string): false;
|
|
78
|
+
protected _startSession(link: db.Pool | kv.Pool, auth?: boolean, opt?: session.IOptions): Promise<void>;
|
|
79
|
+
protected _loadLocale(loc: string, pkg?: string): Promise<boolean>;
|
|
80
|
+
private _loadLocaleDeep;
|
|
81
|
+
protected _getLocaleJsonString(): string;
|
|
82
|
+
protected _getLocale(): string;
|
|
83
|
+
protected _cross(): boolean;
|
|
84
|
+
_l(key: string, data?: string[]): string;
|
|
85
|
+
protected _writeText(data: string): boolean;
|
|
86
|
+
protected _writeResult(data: types.Json): boolean;
|
|
87
|
+
protected _writeBinary(data: Buffer | string | Array<Buffer | string>): boolean;
|
|
88
|
+
protected _ping(): boolean;
|
|
89
|
+
protected _pong(): boolean;
|
|
90
|
+
protected _end(): void;
|
|
91
|
+
protected _handleFormData(events?: {
|
|
92
|
+
onfilestart?: (name: string) => boolean | undefined;
|
|
93
|
+
onfiledata?: (chunk: Buffer) => void;
|
|
94
|
+
onfileend?: () => void;
|
|
95
|
+
}): Promise<boolean>;
|
|
96
|
+
}
|
package/sys/master.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|