@maiyunnet/kebab 2.0.4 → 2.0.6

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 (82) hide show
  1. package/index.d.ts +14 -0
  2. package/index.js +1 -1
  3. package/lib/buffer.d.ts +25 -0
  4. package/lib/captcha.d.ts +12 -0
  5. package/lib/captcha.js +2 -2
  6. package/lib/consistent.d.ts +20 -0
  7. package/lib/consistent.js +1 -1
  8. package/lib/core.d.ts +85 -0
  9. package/lib/core.js +8 -8
  10. package/lib/crypto.d.ts +47 -0
  11. package/lib/crypto.js +1 -1
  12. package/lib/db.d.ts +88 -0
  13. package/lib/db.js +5 -5
  14. package/lib/dns.d.ts +75 -0
  15. package/lib/dns.js +5 -5
  16. package/lib/fs.d.ts +49 -0
  17. package/lib/jwt.d.ts +30 -0
  18. package/lib/jwt.js +4 -4
  19. package/lib/kv.d.ts +111 -0
  20. package/lib/kv.js +2 -2
  21. package/lib/lan.d.ts +10 -0
  22. package/lib/lan.js +1 -1
  23. package/lib/net/formdata.d.ts +23 -0
  24. package/lib/net/formdata.js +2 -2
  25. package/lib/net/request.d.ts +23 -0
  26. package/lib/net/request.js +1 -1
  27. package/lib/net/response.d.ts +14 -0
  28. package/lib/net.d.ts +65 -0
  29. package/lib/net.js +4 -4
  30. package/lib/s3.d.ts +35 -0
  31. package/lib/s3.js +2 -2
  32. package/lib/scan.d.ts +31 -0
  33. package/lib/scan.js +6 -6
  34. package/lib/session.d.ts +22 -0
  35. package/lib/session.js +6 -6
  36. package/lib/sql.d.ts +57 -0
  37. package/lib/sql.js +3 -3
  38. package/lib/ssh/sftp.d.ts +40 -0
  39. package/lib/ssh/sftp.js +2 -2
  40. package/lib/ssh/shell.d.ts +13 -0
  41. package/lib/ssh/shell.js +1 -1
  42. package/lib/ssh.d.ts +24 -0
  43. package/lib/text.d.ts +40 -0
  44. package/lib/text.js +1 -1
  45. package/lib/time.d.ts +22 -0
  46. package/lib/time.js +1 -1
  47. package/lib/ws.d.ts +87 -0
  48. package/lib/ws.js +2 -2
  49. package/lib/zip.d.ts +40 -0
  50. package/lib/zip.js +1 -1
  51. package/lib/zlib.d.ts +25 -0
  52. package/main.d.ts +1 -0
  53. package/package.json +3 -3
  54. package/sys/child.d.ts +1 -0
  55. package/sys/child.js +6 -6
  56. package/sys/cmd.d.ts +1 -0
  57. package/sys/cmd.js +6 -6
  58. package/sys/ctr.d.ts +96 -0
  59. package/sys/master.d.ts +1 -0
  60. package/sys/master.js +8 -8
  61. package/sys/mod.d.ts +205 -0
  62. package/sys/mod.js +5 -5
  63. package/sys/route.d.ts +31 -0
  64. package/sys/route.js +8 -8
  65. package/types/index.d.ts +283 -0
  66. package/www/example/ctr/main.d.ts +4 -0
  67. package/www/example/ctr/main.js +1 -1
  68. package/www/example/ctr/middle.d.ts +6 -0
  69. package/www/example/ctr/middle.js +1 -1
  70. package/www/example/ctr/test.d.ts +94 -0
  71. package/www/example/ctr/test.js +21 -21
  72. package/www/example/mod/test.d.ts +20 -0
  73. package/www/example/mod/test.js +2 -2
  74. package/www/example/mod/testdata.d.ts +9 -0
  75. package/www/example/mod/testdata.js +1 -1
  76. package/www/example/ws/mproxy.d.ts +4 -0
  77. package/www/example/ws/mproxy.js +2 -2
  78. package/www/example/ws/rproxy.d.ts +4 -0
  79. package/www/example/ws/rproxy.js +2 -2
  80. package/www/example/ws/test.d.ts +7 -0
  81. package/www/example/ws/test.js +2 -2
  82. package/tsconfig.json +0 -27
package/lib/kv.d.ts ADDED
@@ -0,0 +1,111 @@
1
+ import * as redis from '@litert/redis';
2
+ import * as ctr from '../sys/ctr';
3
+ import * as types from '../types';
4
+ export interface IConnectionInfo {
5
+ 'id': number;
6
+ 'last': number;
7
+ 'host': string;
8
+ 'port': number;
9
+ 'index': number;
10
+ 'lost': boolean;
11
+ }
12
+ export declare class Pool {
13
+ private readonly _etc;
14
+ constructor(ctr: ctr.Ctr, etc?: types.IConfigKv);
15
+ set(key: string, val: object | string | number, ttl?: number, mod?: '' | 'nx' | 'xx'): Promise<boolean>;
16
+ add(key: string, val: object | string | number, ttl?: number): Promise<boolean>;
17
+ replace(key: string, val: object | string | number, ttl?: number): Promise<boolean>;
18
+ append(key: string, val: string): Promise<boolean>;
19
+ prepend(key: string, val: string): Promise<boolean>;
20
+ exists(keys: string | string[]): Promise<number>;
21
+ get(key: string): Promise<string | null>;
22
+ ttl(key: string): Promise<number | null>;
23
+ pttl(key: string): Promise<number | null>;
24
+ mSet(rows: Record<string, string | Buffer>): Promise<boolean>;
25
+ mGet(keys: string[]): Promise<Record<string, string | null>>;
26
+ getJson(key: string): Promise<any | null>;
27
+ del(keys: string | string[]): Promise<boolean>;
28
+ incr(key: string, num?: number): Promise<number | false>;
29
+ decr(key: string, num?: number): Promise<number | false>;
30
+ expire(key: string, ttl: number): Promise<boolean>;
31
+ keys(pattern: string): Promise<string[] | false>;
32
+ scan(cursor?: number, pattern?: string, count?: number): Promise<redis.IScanResult<string> | false>;
33
+ flushDb(): Promise<boolean>;
34
+ ping(): Promise<string | false>;
35
+ hSet(key: string, field: string, val: object | string | number, mod?: '' | 'nx'): Promise<boolean>;
36
+ hMSet(key: string, rows: Record<string, object | string | number>): Promise<boolean>;
37
+ hGet(key: string, field: string): Promise<string | null>;
38
+ hGetJson(key: string, field: string): Promise<any | null>;
39
+ hMGet(key: string, fields: string[]): Promise<Record<string, string | null>>;
40
+ hGetAll(key: string): Promise<Record<string, string | null> | null>;
41
+ hDel(key: string, fields: string | string[]): Promise<number>;
42
+ hExists(key: string, field: string): Promise<boolean>;
43
+ hIncr(key: string, field: string, increment: number): Promise<number>;
44
+ hKeys(key: string): Promise<string[]>;
45
+ lPush(key: string, values: Array<string | Buffer>): Promise<number>;
46
+ rPush(key: string, values: Array<string | Buffer>): Promise<number>;
47
+ bLMove(sourceKey: string, destKey: string, soo: 'LEFT' | 'RIGHT', deo: 'LEFT' | 'RIGHT', timeout: number): Promise<string | null>;
48
+ lPop(key: string): Promise<string | null>;
49
+ rPop(key: string): Promise<string | null>;
50
+ bRPop(key: string | string[], timeout: number): Promise<Record<string, string>>;
51
+ lRange(key: string, start: number, stop: number): Promise<string[]>;
52
+ lLen(key: string): Promise<number>;
53
+ private _getConnection;
54
+ }
55
+ export declare class Connection {
56
+ private _last;
57
+ private readonly _link;
58
+ private _using;
59
+ private _lost;
60
+ private readonly _etc;
61
+ constructor(etc: types.IConfigKv, link: redis.ICommandClient);
62
+ getEtc(): types.IConfigKv;
63
+ getLast(): number;
64
+ setLost(): void;
65
+ isLost(): boolean;
66
+ setUsing(): void;
67
+ isUsing(): boolean;
68
+ used(): void;
69
+ refreshLast(): void;
70
+ end(): Promise<void>;
71
+ set(key: string, val: object | string | number, ttl: number, mod: '' | 'nx' | 'xx', etc: types.IConfigKv): Promise<boolean>;
72
+ add(key: string, val: object | string | number, ttl: number, etc: types.IConfigKv): Promise<boolean>;
73
+ replace(key: string, val: object | string | number, ttl: number, etc: types.IConfigKv): Promise<boolean>;
74
+ append(key: string, val: string, etc: types.IConfigKv): Promise<boolean>;
75
+ prepend(key: string, val: string, etc: types.IConfigKv): Promise<boolean>;
76
+ exists(keys: string | string[], etc: types.IConfigKv): Promise<number>;
77
+ get(key: string, etc: types.IConfigKv): Promise<string | null>;
78
+ ttl(key: string, etc: types.IConfigKv): Promise<number | null>;
79
+ pttl(key: string, etc: types.IConfigKv): Promise<number | null>;
80
+ mGet(keys: string[], etc: types.IConfigKv): Promise<Record<string, string | null>>;
81
+ mSet(rows: Record<string, string | Buffer>, etc: types.IConfigKv): Promise<boolean>;
82
+ getJson(key: string, etc: types.IConfigKv): Promise<any | null>;
83
+ del(keys: string | string[], etc: types.IConfigKv): Promise<boolean>;
84
+ incr(key: string, num: number, etc: types.IConfigKv): Promise<number | false>;
85
+ decr(key: string, num: number, etc: types.IConfigKv): Promise<number | false>;
86
+ expire(key: string, ttl: number, etc: types.IConfigKv): Promise<boolean>;
87
+ keys(pattern: string, etc: types.IConfigKv): Promise<string[] | false>;
88
+ scan(cursor: number, pattern: string, count: number, etc: types.IConfigKv): Promise<redis.IScanResult<string> | false>;
89
+ flushDb(): Promise<boolean>;
90
+ ping(): Promise<false | string>;
91
+ hSet(key: string, field: string, val: object | string | number, mod: '' | 'nx', etc: types.IConfigKv): Promise<boolean>;
92
+ hMSet(key: string, rows: Record<string, object | string | number>, etc: types.IConfigKv): Promise<boolean>;
93
+ hGet(key: string, field: string, etc: types.IConfigKv): Promise<string | null>;
94
+ hGetJson(key: string, field: string, etc: types.IConfigKv): Promise<any | null>;
95
+ hMGet(key: string, fields: string[], etc: types.IConfigKv): Promise<Record<string, string | null>>;
96
+ hGetAll(key: string, etc: types.IConfigKv): Promise<Record<string, string | null> | null>;
97
+ hDel(key: string, fields: string | string[], etc: types.IConfigKv): Promise<number>;
98
+ hExists(key: string, field: string, etc: types.IConfigKv): Promise<boolean>;
99
+ hIncr(key: string, field: string, increment: number, etc: types.IConfigKv): Promise<number>;
100
+ hKeys(key: string, etc: types.IConfigKv): Promise<string[]>;
101
+ lPush(key: string, values: Array<string | Buffer>, etc: types.IConfigKv): Promise<number>;
102
+ rPush(key: string, values: Array<string | Buffer>, etc: types.IConfigKv): Promise<number>;
103
+ bLMove(sourceKey: string, destKey: string, soo: 'LEFT' | 'RIGHT', deo: 'LEFT' | 'RIGHT', timeout: number, etc: types.IConfigKv): Promise<string | null>;
104
+ lPop(key: string, etc: types.IConfigKv): Promise<string | null>;
105
+ rPop(key: string, etc: types.IConfigKv): Promise<string | null>;
106
+ bRPop(key: string | string[], timeout: number, etc: types.IConfigKv): Promise<Record<string, string>>;
107
+ lRange(key: string, start: number, stop: number, etc: types.IConfigKv): Promise<string[]>;
108
+ lLen(key: string, etc: types.IConfigKv): Promise<number>;
109
+ }
110
+ export declare function get(ctr: ctr.Ctr, etc?: types.IConfigKv): Pool;
111
+ export declare function getConnectionList(): IConnectionInfo[];
package/lib/kv.js CHANGED
@@ -37,8 +37,8 @@ exports.Connection = exports.Pool = void 0;
37
37
  exports.get = get;
38
38
  exports.getConnectionList = getConnectionList;
39
39
  const redis = __importStar(require("@litert/redis"));
40
- const time = __importStar(require("~/lib/time"));
41
- const text = __importStar(require("~/lib/text"));
40
+ const time = __importStar(require("../lib/time"));
41
+ const text = __importStar(require("../lib/text"));
42
42
  const connections = [];
43
43
  async function checkConnection() {
44
44
  const now = time.stamp();
package/lib/lan.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export declare function card(): Promise<Array<{
2
+ 'name': string;
3
+ 'mac': string;
4
+ 'iPv4': string;
5
+ 'iPv6': string;
6
+ }>>;
7
+ export declare function scan(): Promise<Array<{
8
+ 'mac': string;
9
+ 'iPv4': string;
10
+ }>>;
package/lib/lan.js CHANGED
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.card = card;
37
37
  exports.scan = scan;
38
38
  const os = __importStar(require("os"));
39
- const lCore = __importStar(require("~/lib/core"));
39
+ const lCore = __importStar(require("../lib/core"));
40
40
  async function card() {
41
41
  const result = [];
42
42
  let i = 0;
@@ -0,0 +1,23 @@
1
+ import * as stream from 'stream';
2
+ export interface IItem {
3
+ 'key': string;
4
+ 'isFile': boolean;
5
+ 'isString': boolean;
6
+ 'value': string;
7
+ 'path': string;
8
+ }
9
+ export declare class FormData extends stream.Readable {
10
+ private _num;
11
+ private readonly _data;
12
+ private readonly _boundary;
13
+ private _fileReading;
14
+ private _close;
15
+ private _length;
16
+ private _sent;
17
+ putString(key: string, val: string): void;
18
+ putFile(key: string, path: string, fname?: string): Promise<boolean>;
19
+ getBoundary(): string;
20
+ getLength(): number;
21
+ getSent(): number;
22
+ _read(): void;
23
+ }
@@ -36,8 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.FormData = void 0;
37
37
  const stream = __importStar(require("stream"));
38
38
  const mime = __importStar(require("@litert/mime"));
39
- const core = __importStar(require("~/lib/core"));
40
- const fs = __importStar(require("~/lib/fs"));
39
+ const core = __importStar(require("../../lib/core"));
40
+ const fs = __importStar(require("../../lib/fs"));
41
41
  class FormData extends stream.Readable {
42
42
  constructor() {
43
43
  super(...arguments);
@@ -0,0 +1,23 @@
1
+ import * as stream from 'stream';
2
+ import * as response from './response';
3
+ import * as types from '../../types';
4
+ export declare class Request {
5
+ private _data;
6
+ private readonly _url;
7
+ private _opt;
8
+ constructor(url: string);
9
+ data(data: Record<string, any> | Buffer | string | stream.Readable): this;
10
+ method(method: 'GET' | 'POST'): this;
11
+ get(): this;
12
+ post(): this;
13
+ type(type: 'form' | 'json'): this;
14
+ json(): this;
15
+ timeout(timeout: number): this;
16
+ follow(follow?: number): this;
17
+ hosts(hosts: Record<string, string>): this;
18
+ save(save: string): this;
19
+ local(addr: string): this;
20
+ headers(headers: types.THttpHeaders): this;
21
+ setHeader(name: string, val: string): this;
22
+ request(cookie?: Record<string, types.ICookie>): Promise<response.Response>;
23
+ }
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Request = void 0;
37
- const net = __importStar(require("~/lib/net"));
37
+ const net = __importStar(require("../../lib/net"));
38
38
  class Request {
39
39
  constructor(url) {
40
40
  this._data = undefined;
@@ -0,0 +1,14 @@
1
+ import * as hc from '@litert/http-client';
2
+ import * as nStream from 'stream';
3
+ import * as types from '../../types';
4
+ export declare class Response {
5
+ private readonly _req;
6
+ headers: types.THttpHeaders | null;
7
+ error: Error | null;
8
+ private _content;
9
+ constructor(req: hc.IResponse | null);
10
+ getContent(): Promise<Buffer | null>;
11
+ setContent(v: string | Buffer): void;
12
+ getStream(): nStream.Readable;
13
+ getRawStream(): nStream.Readable;
14
+ }
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/net.js CHANGED
@@ -49,10 +49,10 @@ exports.mproxyData = mproxyData;
49
49
  exports.rproxy = rproxy;
50
50
  const stream = __importStar(require("stream"));
51
51
  const hc = __importStar(require("@litert/http-client"));
52
- const fs = __importStar(require("~/lib/fs"));
53
- const text = __importStar(require("~/lib/text"));
54
- const time = __importStar(require("~/lib/time"));
55
- const kebab = __importStar(require("~/index"));
52
+ const fs = __importStar(require("../lib/fs"));
53
+ const text = __importStar(require("../lib/text"));
54
+ const time = __importStar(require("../lib/time"));
55
+ const kebab = __importStar(require("../index"));
56
56
  const fd = __importStar(require("./net/formdata"));
57
57
  const lRequest = __importStar(require("./net/request"));
58
58
  const response = __importStar(require("./net/response"));
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/s3.js CHANGED
@@ -37,8 +37,8 @@ exports.S3 = exports.ESERVICE = void 0;
37
37
  exports.get = get;
38
38
  const s3 = __importStar(require("@aws-sdk/client-s3"));
39
39
  const ls = __importStar(require("@aws-sdk/lib-storage"));
40
- const lCore = __importStar(require("~/lib/core"));
41
- const lText = __importStar(require("~/lib/text"));
40
+ const lCore = __importStar(require("../lib/core"));
41
+ const lText = __importStar(require("../lib/text"));
42
42
  var ESERVICE;
43
43
  (function (ESERVICE) {
44
44
  ESERVICE[ESERVICE["AMAZON"] = 0] = "AMAZON";
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/scan.js CHANGED
@@ -37,12 +37,12 @@ exports.Scan = void 0;
37
37
  exports.get = get;
38
38
  exports.scanned = scanned;
39
39
  exports.setData = setData;
40
- const lCore = __importStar(require("~/lib/core"));
41
- const lDb = __importStar(require("~/lib/db"));
42
- const lKv = __importStar(require("~/lib/kv"));
43
- const lSql = __importStar(require("~/lib/sql"));
44
- const lTime = __importStar(require("~/lib/time"));
45
- const lText = __importStar(require("~/lib/text"));
40
+ const lCore = __importStar(require("../lib/core"));
41
+ const lDb = __importStar(require("../lib/db"));
42
+ const lKv = __importStar(require("../lib/kv"));
43
+ const lSql = __importStar(require("../lib/sql"));
44
+ const lTime = __importStar(require("../lib/time"));
45
+ const lText = __importStar(require("../lib/text"));
46
46
  class Scan {
47
47
  constructor(link, token, opt = {}) {
48
48
  this._sql = null;
@@ -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/session.js CHANGED
@@ -34,12 +34,12 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Session = void 0;
37
- const core = __importStar(require("~/lib/core"));
38
- const time = __importStar(require("~/lib/time"));
39
- const db = __importStar(require("~/lib/db"));
40
- const kv = __importStar(require("~/lib/kv"));
41
- const sql = __importStar(require("~/lib/sql"));
42
- const text = __importStar(require("~/lib/text"));
37
+ const core = __importStar(require("../lib/core"));
38
+ const time = __importStar(require("../lib/time"));
39
+ const db = __importStar(require("../lib/db"));
40
+ const kv = __importStar(require("../lib/kv"));
41
+ const sql = __importStar(require("../lib/sql"));
42
+ const text = __importStar(require("../lib/text"));
43
43
  class Session {
44
44
  constructor() {
45
45
  this._token = '';
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
+ };
package/lib/sql.js CHANGED
@@ -38,10 +38,10 @@ exports.get = get;
38
38
  exports.format = format;
39
39
  exports.aoMix = aoMix;
40
40
  exports.column = column;
41
- const lText = __importStar(require("~/lib/text"));
42
- const lCore = __importStar(require("~/lib/core"));
41
+ const lText = __importStar(require("../lib/text"));
42
+ const lCore = __importStar(require("../lib/core"));
43
43
  const mysql2 = __importStar(require("mysql2/promise"));
44
- const ctr = __importStar(require("~/sys/ctr"));
44
+ const ctr = __importStar(require("../sys/ctr"));
45
45
  let columnToken = '';
46
46
  class Sql {
47
47
  constructor(pre, opt = {}) {
@@ -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
+ }
package/lib/ssh/sftp.js CHANGED
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Connection = void 0;
37
- const core = __importStar(require("~/lib/core"));
38
- const text = __importStar(require("~/lib/text"));
37
+ const core = __importStar(require("../../lib/core"));
38
+ const text = __importStar(require("../../lib/text"));
39
39
  class Connection {
40
40
  constructor(sftp, path) {
41
41
  this._client = sftp;
@@ -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/shell.js CHANGED
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Connection = void 0;
37
- const lCore = __importStar(require("~/lib/core"));
37
+ const lCore = __importStar(require("../../lib/core"));
38
38
  class Connection {
39
39
  constructor(stream) {
40
40
  this._client = stream;
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 {};