@maiyunnet/kebab 3.1.4 → 3.1.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.
package/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * ------------------------
9
9
  */
10
10
  /** --- 当前系统版本号 --- */
11
- export declare const VER = "3.1.4";
11
+ export declare const VER = "3.1.6";
12
12
  /** --- 框架根目录,以 / 结尾 --- */
13
13
  export declare const ROOT_PATH: string;
14
14
  export declare const LIB_PATH: string;
@@ -24,3 +24,149 @@ export declare const WWW_CWD: string;
24
24
  export declare const IND_CWD: string;
25
25
  export declare const FTMP_CWD: string;
26
26
  export declare const MOD_CWD: string;
27
+ /** --- 除非确定是不可知的 Json,否则不能使用 --- */
28
+ export type Json = any;
29
+ /** --- 数据库值的类型 --- */
30
+ export type DbValue = string | number | null | Record<string, Json>;
31
+ /** --- 动态目录配置文件 --- */
32
+ export interface IConfig {
33
+ 'set': {
34
+ 'timezone': number;
35
+ 'mustHttps': boolean;
36
+ 'cacheTtl': number;
37
+ 'staticVer': string;
38
+ 'staticPath': string;
39
+ 'staticPathFull': string;
40
+ [key: string]: Json;
41
+ };
42
+ 'const': IConfigConst;
43
+ 'db': IConfigDb;
44
+ 'jwt': IConfigJwt;
45
+ 'kv': IConfigKv;
46
+ 'route': Record<string, string>;
47
+ 'session': {
48
+ 'name': string;
49
+ 'ttl': number;
50
+ 'ssl': boolean;
51
+ };
52
+ 'sql': IConfigSql;
53
+ 'dns': Record<string, IConfigDns>;
54
+ 'lang': IConfigLang;
55
+ 's3': Record<string, IConfigS3>;
56
+ 'turnstile': IConfigTurnstile;
57
+ [key: string]: Record<string, Json>;
58
+ }
59
+ export interface IUrlParse {
60
+ 'protocol': string | null;
61
+ 'auth': string | null;
62
+ 'user': string | null;
63
+ 'pass': string | null;
64
+ 'host': string | null;
65
+ 'hostname': string | null;
66
+ 'port': string | null;
67
+ 'pathname': string;
68
+ 'path': string | null;
69
+ 'query': string | null;
70
+ 'hash': string | null;
71
+ }
72
+ /** --- 语言 --- */
73
+ export interface IConfigLang {
74
+ 'list': string[];
75
+ 'direct': string[];
76
+ }
77
+ /** --- 对象存储 --- */
78
+ export interface IConfigS3 {
79
+ /** --- cf r2 要用 --- */
80
+ 'account'?: string;
81
+ 'sid': string;
82
+ 'skey': string;
83
+ 'region': string;
84
+ 'bucket': string;
85
+ }
86
+ /** --- 人机码信息 --- */
87
+ export interface IConfigTurnstile {
88
+ 'CF': {
89
+ 'sid': string;
90
+ 'skey': string;
91
+ };
92
+ 'TENCENT': {
93
+ 'sid': string;
94
+ 'skey': string;
95
+ 'aid': string;
96
+ 'akey': string;
97
+ };
98
+ }
99
+ /** --- 数据库 --- */
100
+ export interface IConfigDb {
101
+ 'host': string;
102
+ 'port': number;
103
+ 'charset': string;
104
+ 'name': string;
105
+ 'user': string;
106
+ 'pwd': string;
107
+ }
108
+ /** --- Jwt 信息 --- */
109
+ export interface IConfigJwt {
110
+ 'name': string;
111
+ 'ttl': number;
112
+ 'ssl': boolean;
113
+ 'secret': string;
114
+ 'auth': boolean;
115
+ }
116
+ /** --- DNS --- */
117
+ export interface IConfigDns {
118
+ 'sid': string;
119
+ 'skey': string;
120
+ }
121
+ /** --- kv --- */
122
+ export interface IConfigKv {
123
+ 'host': string;
124
+ 'port': number;
125
+ 'index': number;
126
+ 'pre': string;
127
+ 'user': string;
128
+ 'pwd': string;
129
+ }
130
+ /** --- sql --- */
131
+ export interface IConfigSql {
132
+ 'pre': string;
133
+ }
134
+ /** --- 常量 --- */
135
+ export interface IConfigConst {
136
+ 'path': string;
137
+ 'qs': string;
138
+ 'startTime': bigint;
139
+ 'startMemory': number;
140
+ 'mobile': boolean;
141
+ 'wechat': boolean;
142
+ 'miniprogram': '' | 'wechat';
143
+ 'https': boolean;
144
+ 'host': string;
145
+ 'hostname': string;
146
+ 'hostport': number;
147
+ 'uri': IUrlParse;
148
+ 'rootPath': string;
149
+ 'modPath': string;
150
+ 'ctrPath': string;
151
+ 'viewPath': string;
152
+ 'dataPath': string;
153
+ 'wsPath': string;
154
+ 'urlBase': string;
155
+ 'urlStc': string;
156
+ 'urlFull': string;
157
+ 'urlStcFull': string;
158
+ }
159
+ /** --- 虚拟机配置对象 --- */
160
+ export interface IVhost {
161
+ readonly 'name': string;
162
+ readonly 'domains': string[];
163
+ readonly 'root': string;
164
+ readonly 'remark': string;
165
+ }
166
+ /** --- 上传的文件信息对象 --- */
167
+ export interface IPostFile {
168
+ readonly 'name': string;
169
+ readonly 'origin': string;
170
+ readonly 'size': number;
171
+ readonly 'path': string;
172
+ }
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
1
2
  /**
2
3
  * Project: Kebab, User: JianSuoQiYue
3
4
  * Date: 2019-3-30 12:46:41
@@ -8,7 +9,7 @@
8
9
  * ------------------------
9
10
  */
10
11
  /** --- 当前系统版本号 --- */
11
- export const VER = '3.1.4';
12
+ export const VER = '3.1.6';
12
13
  // --- 服务端用的路径 ---
13
14
  const imu = import.meta.url.replace('file://', '').replace(/^\/(\w:)/, '$1').replace(/\\/g, '/');
14
15
  /** --- /xxx/xxx --- */
package/lib/core.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as http from 'http';
2
2
  import * as http2 from 'http2';
3
3
  import * as stream from 'stream';
4
+ import * as kebab from '#index.js';
4
5
  import * as lResponse from '#lib/net/response.js';
5
6
  import * as sCtr from '#sys/ctr.js';
6
- import * as types from '#types/index.js';
7
7
  /** --- 全局参数 --- */
8
- export declare const globalConfig: types.IConfig & {
8
+ export declare const globalConfig: kebab.IConfig & {
9
9
  'httpPort': number;
10
10
  'httpsPort': number;
11
11
  'rpcPort': number;
@@ -117,7 +117,7 @@ export declare function objectSort<T extends Record<string, any>>(o: T): T;
117
117
  * @param obj 要清除的对象
118
118
  * @patam deep 也将子项都清空,如果子项有独立引用的话也要清空的话则要设置为 true
119
119
  */
120
- export declare function emptyObject(obj: Record<string, types.Json>, deep?: boolean): void;
120
+ export declare function emptyObject(obj: Record<string, kebab.Json>, deep?: boolean): void;
121
121
  /**
122
122
  * --- 调用前自行创建 passThrough,并且调用 pipe 绑定到应该绑定的对象,然后再调用本函数 ---
123
123
  * @param passThrough passThrough 对象
@@ -148,7 +148,7 @@ export declare const global: Record<string, any>;
148
148
  * @param data 变量值
149
149
  * @param hosts 局域网列表
150
150
  */
151
- export declare function setGlobal(key: string, data: types.Json, hosts?: string[] | 'config'): Promise<string[]>;
151
+ export declare function setGlobal(key: string, data: kebab.Json, hosts?: string[] | 'config'): Promise<string[]>;
152
152
  /**
153
153
  * --- 移除某个跨线程/跨内网服务器全局变量 ---
154
154
  * @param key 变量名
@@ -173,7 +173,7 @@ export interface ILogOptions {
173
173
  'urlFull'?: string;
174
174
  'hostname'?: string;
175
175
  'req'?: http2.Http2ServerRequest | http.IncomingMessage | null;
176
- 'get'?: Record<string, types.Json>;
176
+ 'get'?: Record<string, kebab.Json>;
177
177
  'cookie'?: Record<string, string>;
178
178
  'jwt'?: Record<string, any>;
179
179
  'session'?: Record<string, any>;
package/lib/core.js CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import * as cp from 'child_process';
7
7
  import * as stream from 'stream';
8
+ import * as kebab from '#index.js';
8
9
  import * as lTime from '#lib/time.js';
9
10
  import * as lFs from '#lib/fs.js';
10
11
  import * as lText from '#lib/text.js';
@@ -12,7 +13,6 @@ import * as lNet from '#lib/net.js';
12
13
  import * as lCrypto from '#lib/crypto.js';
13
14
  import * as lResponse from '#lib/net/response.js';
14
15
  import * as sCtr from '#sys/ctr.js';
15
- import * as kebab from '#index.js';
16
16
  /** --- 全局参数 --- */
17
17
  export const globalConfig = {};
18
18
  /**
package/lib/db.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * Last: 2020-4-13 15:34:45, 2022-09-12 13:10:34, 2023-5-24 18:29:38, 2024-7-11 14:37:54, 2024-8-25 00:32:53, 2024-9-22 17:30:47, 2025-8-3 20:24:03
5
5
  */
6
6
  import * as mysql2 from 'mysql2/promise';
7
+ import * as kebab from '#index.js';
7
8
  import * as sCtr from '#sys/ctr.js';
8
- import * as types from '#types/index.js';
9
9
  /** --- query 返回的数据 --- */
10
10
  export interface IData {
11
11
  'rows': any[] | null;
@@ -44,19 +44,19 @@ export declare class Pool {
44
44
  private _queries;
45
45
  /** --- 当前 Pool 对象的数据库连接信息 --- */
46
46
  private readonly _etc;
47
- constructor(etc: types.IConfigDb);
47
+ constructor(etc: kebab.IConfigDb);
48
48
  /**
49
49
  * --- 执行一条 SQL,无视顺序和相同连接,随用随取 ---
50
50
  * @param sql 执行的 SQL 字符串
51
51
  * @param values 要替换的 data 数据
52
52
  */
53
- query(sql: string, values?: types.DbValue[]): Promise<IData>;
53
+ query(sql: string, values?: kebab.DbValue[]): Promise<IData>;
54
54
  /**
55
55
  * --- 执行一条 SQL 并获得影响行数对象 packet,连接失败抛出错误 ---
56
56
  * @param sql 执行的 SQL 字符串
57
57
  * @param values 要替换的 data 数据
58
58
  */
59
- execute(sql: string, values?: types.DbValue[]): Promise<IPacket>;
59
+ execute(sql: string, values?: kebab.DbValue[]): Promise<IPacket>;
60
60
  /**
61
61
  * --- 开启事务,返回事务对象并锁定连接,别人任何人不可用,有 ctr 的话必传 this,独立执行时可传 null ---
62
62
  */
@@ -87,13 +87,13 @@ export declare class Transaction {
87
87
  * @param sql 执行的 SQL 字符串
88
88
  * @param values 要替换的 data 数据
89
89
  */
90
- query(sql: string, values?: types.DbValue[]): Promise<IData>;
90
+ query(sql: string, values?: kebab.DbValue[]): Promise<IData>;
91
91
  /**
92
92
  * --- 执行一条 SQL 并获得影响行数对象 packet,连接失败抛出错误 ---
93
93
  * @param sql 执行的 SQL 字符串
94
94
  * @param values 要替换的 data 数据
95
95
  */
96
- execute(sql: string, values?: types.DbValue[]): Promise<IPacket>;
96
+ execute(sql: string, values?: kebab.DbValue[]): Promise<IPacket>;
97
97
  commit(): Promise<boolean>;
98
98
  rollback(): Promise<boolean>;
99
99
  }
@@ -113,11 +113,11 @@ export declare class Connection {
113
113
  private _transaction;
114
114
  /** --- 当前的连接配置信息 --- */
115
115
  private readonly _etc;
116
- constructor(etc: types.IConfigDb, link: mysql2.Connection);
116
+ constructor(etc: kebab.IConfigDb, link: mysql2.Connection);
117
117
  /**
118
118
  * --- 获取连接 etc 信息 ---
119
119
  */
120
- getEtc(): types.IConfigDb;
120
+ getEtc(): kebab.IConfigDb;
121
121
  /**
122
122
  * --- 获取最后一次获取连接的时间 ---
123
123
  */
@@ -127,7 +127,7 @@ export declare class Connection {
127
127
  */
128
128
  getLastSql(): Array<{
129
129
  'sql': string;
130
- 'values'?: types.DbValue[];
130
+ 'values'?: kebab.DbValue[];
131
131
  }>;
132
132
  /**
133
133
  * --- 将本条连接设置为不可用 ---
@@ -167,13 +167,13 @@ export declare class Connection {
167
167
  * @param sql 执行的 SQL 字符串
168
168
  * @param values 要替换的 data 数据
169
169
  */
170
- query(sql: string, values?: types.DbValue[]): Promise<IData>;
170
+ query(sql: string, values?: kebab.DbValue[]): Promise<IData>;
171
171
  /**
172
172
  * --- 执行一条 SQL 并获得影响行数对象 packet ---
173
173
  * @param sql 执行的 SQL 字符串
174
174
  * @param values 要替换的 data 数据
175
175
  */
176
- execute(sql: string, values?: types.DbValue[]): Promise<IPacket>;
176
+ execute(sql: string, values?: kebab.DbValue[]): Promise<IPacket>;
177
177
  /**
178
178
  * --- 关闭连接,一般情况下不使用 ---
179
179
  */
@@ -186,7 +186,7 @@ export declare class Connection {
186
186
  * --- 获取 Db Pool 对象 ---
187
187
  * @param etc 配置信息可留空
188
188
  */
189
- export declare function get(ctrEtc: sCtr.Ctr | types.IConfigDb): Pool;
189
+ export declare function get(ctrEtc: sCtr.Ctr | kebab.IConfigDb): Pool;
190
190
  /**
191
191
  * --- 获取当前连接池中所有连接的信息 ---
192
192
  */
package/lib/db.js CHANGED
@@ -6,7 +6,6 @@
6
6
  // --- Pool 是使用时必须要一个用户创建一份的,Connection 是池子里获取的 ---
7
7
  // --- 第三方 ---
8
8
  import * as mysql2 from 'mysql2/promise';
9
- // --- 库和定义 ---
10
9
  import * as lTime from '#lib/time.js';
11
10
  import * as lSql from '#lib/sql.js';
12
11
  import * as lCore from '#lib/core.js';
package/lib/jwt.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * Date: 2023-1-31 20:34:47
4
4
  * Last: 2023-1-31 20:34:47, 2023-12-8 13:55:09
5
5
  */
6
- import * as kv from '#lib/kv.js';
7
- import * as ctr from '#sys/ctr.js';
8
- import * as types from '#types/index.js';
6
+ import * as kebab from '#index.js';
7
+ import * as lKv from '#lib/kv.js';
8
+ import * as sCtr from '#sys/ctr.js';
9
9
  export interface IOptions {
10
10
  'name'?: string;
11
11
  'ttl'?: number;
@@ -35,7 +35,7 @@ export declare class Jwt {
35
35
  * @param auth 设为 true 则优先从头 Authorization 或 post _auth 值读取 token
36
36
  * @param opt 选项
37
37
  */
38
- init(ctr: ctr.Ctr, opt?: IOptions, link?: kv.Pool): Promise<boolean>;
38
+ init(ctr: sCtr.Ctr, opt?: IOptions, link?: lKv.Pool): Promise<boolean>;
39
39
  /**
40
40
  * --- 将 _jwt 数据封装并返回(创建新的或者续期老的 token),默认会同时设置一个 cookie(data 值会自动设置 token、exp) ---
41
41
  */
@@ -55,19 +55,19 @@ export declare class Jwt {
55
55
  /**
56
56
  * --- 获取 jwt 原始字符串,不保证有效 ---
57
57
  */
58
- export declare function getOrigin(ctr: ctr.Ctr, name?: string, auth?: boolean): string;
58
+ export declare function getOrigin(ctr: sCtr.Ctr, name?: string, auth?: boolean): string;
59
59
  /**
60
60
  * --- decode ---
61
61
  * 不传入 link 的话,将不做 block 有效校验,只做本身的 exp 有效校验
62
62
  */
63
- export declare function decode(ctr: ctr.Ctr, val: string, link?: kv.Pool, name?: string, secret?: string): Promise<Record<string, types.DbValue> | false>;
63
+ export declare function decode(ctr: sCtr.Ctr, val: string, link?: lKv.Pool, name?: string, secret?: string): Promise<Record<string, kebab.DbValue> | false>;
64
64
  /**
65
65
  * --- 仅往 redis 写禁止相关 token 的数据,一般用于异步通知时在异处的服务器来调用的 ---
66
66
  */
67
- export declare function block(ctr: ctr.Ctr, token: string, exp: number, link: kv.Pool, name?: string): Promise<boolean>;
67
+ export declare function block(ctr: sCtr.Ctr, token: string, exp: number, link: lKv.Pool, name?: string): Promise<boolean>;
68
68
  /**
69
69
  * @param ctr 模型实例
70
70
  * @param opt name, ttl, ssl, secret, auth: false, true 则优先从头 Authorization 或 post _auth 值读取 token
71
71
  * @param link 实例
72
72
  */
73
- export declare function get(ctr: ctr.Ctr, opt?: IOptions, link?: kv.Pool): Promise<Jwt>;
73
+ export declare function get(ctr: sCtr.Ctr, opt?: IOptions, link?: lKv.Pool): Promise<Jwt>;
package/lib/jwt.js CHANGED
@@ -3,7 +3,6 @@
3
3
  * Date: 2023-1-31 20:34:47
4
4
  * Last: 2023-1-31 20:34:47, 2023-12-8 13:55:09
5
5
  */
6
- // --- 库和定义 ---
7
6
  import * as lCore from '#lib/core.js';
8
7
  import * as lTime from '#lib/time.js';
9
8
  import * as lText from '#lib/text.js';
package/lib/kv.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * Last: 2020-3-28 18:54:04, 2022-09-12 23:24:45, 2022-09-22 01:06:22, 2024-2-21 13:32:56, 2024-8-21 16:59:57
5
5
  */
6
6
  import * as redis from '@litert/redis';
7
+ import * as kebab from '#index.js';
7
8
  import * as sCtr from '#sys/ctr.js';
8
- import * as types from '#types/index.js';
9
9
  /** --- 连接信息 --- */
10
10
  export interface IConnectionInfo {
11
11
  'id': number;
@@ -18,7 +18,7 @@ export interface IConnectionInfo {
18
18
  export declare class Pool {
19
19
  /** --- 当前 Pool 对象的 kv 连接信息 --- */
20
20
  private readonly _etc;
21
- constructor(ctr: sCtr.Ctr, etc?: types.IConfigKv);
21
+ constructor(ctr: sCtr.Ctr, etc?: kebab.IConfigKv);
22
22
  /**
23
23
  * --- 设定一个值 ---
24
24
  * @param key
@@ -216,11 +216,11 @@ export declare class Connection {
216
216
  private _lost;
217
217
  /** --- 当前的连接配置信息 --- */
218
218
  private readonly _etc;
219
- constructor(etc: types.IConfigKv, link: redis.ICommandClient);
219
+ constructor(etc: kebab.IConfigKv, link: redis.ICommandClient);
220
220
  /**
221
221
  * --- 获取连接 etc 信息 ---
222
222
  */
223
- getEtc(): types.IConfigKv;
223
+ getEtc(): kebab.IConfigKv;
224
224
  /**
225
225
  * --- 获取最后一次获取连接的时间 ---
226
226
  */
@@ -261,7 +261,7 @@ export declare class Connection {
261
261
  * @param mod 设置模式: 空,nx(key不存在才建立),xx(key存在才修改)
262
262
  * @param etc 配置项,主要用 etc.pre
263
263
  */
264
- set(key: string, val: object | string | number, ttl: number, mod: '' | 'nx' | 'xx', etc: types.IConfigKv): Promise<boolean>;
264
+ set(key: string, val: object | string | number, ttl: number, mod: '' | 'nx' | 'xx', etc: kebab.IConfigKv): Promise<boolean>;
265
265
  /**
266
266
  * --- 添加一个值,存在则不变 ---
267
267
  * @param key
@@ -269,7 +269,7 @@ export declare class Connection {
269
269
  * @param ttl 秒,0 为不限制
270
270
  * @param etc
271
271
  */
272
- add(key: string, val: object | string | number, ttl: number, etc: types.IConfigKv): Promise<boolean>;
272
+ add(key: string, val: object | string | number, ttl: number, etc: kebab.IConfigKv): Promise<boolean>;
273
273
  /**
274
274
  * --- 替换一个存在的值 ---
275
275
  * @param key
@@ -277,95 +277,95 @@ export declare class Connection {
277
277
  * @param ttl 秒,0 为不限制
278
278
  * @param etc
279
279
  */
280
- replace(key: string, val: object | string | number, ttl: number, etc: types.IConfigKv): Promise<boolean>;
280
+ replace(key: string, val: object | string | number, ttl: number, etc: kebab.IConfigKv): Promise<boolean>;
281
281
  /**
282
282
  * --- 向已存在的值后追加数据 ---
283
283
  * @param key
284
284
  * @param val
285
285
  * @param etc
286
286
  */
287
- append(key: string, val: string, etc: types.IConfigKv): Promise<boolean>;
287
+ append(key: string, val: string, etc: kebab.IConfigKv): Promise<boolean>;
288
288
  /**
289
289
  * --- 向已存在的值之前追加数据 ---
290
290
  * @param key
291
291
  * @param val
292
292
  */
293
- prepend(key: string, val: string, etc: types.IConfigKv): Promise<boolean>;
293
+ prepend(key: string, val: string, etc: kebab.IConfigKv): Promise<boolean>;
294
294
  /**
295
295
  * --- 检测 key 是否存在 ---
296
296
  * @param keys 单个或序列
297
297
  * @param etc
298
298
  */
299
- exists(keys: string | string[], etc: types.IConfigKv): Promise<number>;
299
+ exists(keys: string | string[], etc: kebab.IConfigKv): Promise<number>;
300
300
  /**
301
301
  * --- 获取字符串 ---
302
302
  * @param key
303
303
  * @param etc
304
304
  */
305
- get(key: string, etc: types.IConfigKv): Promise<string | null>;
305
+ get(key: string, etc: kebab.IConfigKv): Promise<string | null>;
306
306
  /**
307
307
  * --- 获取相应的剩余有效期秒数 ---
308
308
  * @param key
309
309
  * @param etc
310
310
  */
311
- ttl(key: string, etc: types.IConfigKv): Promise<number | null>;
311
+ ttl(key: string, etc: kebab.IConfigKv): Promise<number | null>;
312
312
  /**
313
313
  * --- 获取相应的剩余有效期毫秒数 ---
314
314
  * @param key
315
315
  * @param etc
316
316
  */
317
- pttl(key: string, etc: types.IConfigKv): Promise<number | null>;
317
+ pttl(key: string, etc: kebab.IConfigKv): Promise<number | null>;
318
318
  /**
319
319
  * --- 批量获取值 ---
320
320
  * @param keys key 序列
321
321
  * @param etc 顺序数组
322
322
  */
323
- mGet(keys: string[], etc: types.IConfigKv): Promise<Record<string, string | null>>;
323
+ mGet(keys: string[], etc: kebab.IConfigKv): Promise<Record<string, string | null>>;
324
324
  /**
325
325
  * --- 批量设置哈希值 ---
326
326
  * @param key key 名
327
327
  * @param rows key / val 数组
328
328
  * @param etc
329
329
  */
330
- mSet(rows: Record<string, string | Buffer>, etc: types.IConfigKv): Promise<boolean>;
330
+ mSet(rows: Record<string, string | Buffer>, etc: kebab.IConfigKv): Promise<boolean>;
331
331
  /**
332
332
  * --- 获取 json 对象 ---
333
333
  * @param key
334
334
  * @param etc
335
335
  */
336
- getJson(key: string, etc: types.IConfigKv): Promise<any | null>;
336
+ getJson(key: string, etc: kebab.IConfigKv): Promise<any | null>;
337
337
  /**
338
338
  * --- 删除已存在的值 ---
339
339
  * @param keys
340
340
  * @param etc
341
341
  */
342
- del(keys: string | string[], etc: types.IConfigKv): Promise<boolean>;
342
+ del(keys: string | string[], etc: kebab.IConfigKv): Promise<boolean>;
343
343
  /**
344
344
  * --- 自增 ---
345
345
  * @param key
346
346
  * @param num 整数或浮点正数
347
347
  * @param etc
348
348
  */
349
- incr(key: string, num: number, etc: types.IConfigKv): Promise<number | false>;
349
+ incr(key: string, num: number, etc: kebab.IConfigKv): Promise<number | false>;
350
350
  /**
351
351
  * --- 自减 ---
352
352
  * @param key
353
353
  * @param num 整数或浮点正数
354
354
  * @param etc
355
355
  */
356
- decr(key: string, num: number, etc: types.IConfigKv): Promise<number | false>;
356
+ decr(key: string, num: number, etc: kebab.IConfigKv): Promise<number | false>;
357
357
  /**
358
358
  * --- 仅修改过期时间不修改值 ---
359
359
  * @param key
360
360
  * @param ttl
361
361
  * @param etc
362
362
  */
363
- expire(key: string, ttl: number, etc: types.IConfigKv): Promise<boolean>;
363
+ expire(key: string, ttl: number, etc: kebab.IConfigKv): Promise<boolean>;
364
364
  /**
365
365
  * --- 获取服务器上的所有 key 列表 ---
366
366
  * @param pattern
367
367
  */
368
- keys(pattern: string, etc: types.IConfigKv): Promise<string[] | false>;
368
+ keys(pattern: string, etc: kebab.IConfigKv): Promise<string[] | false>;
369
369
  /**
370
370
  * --- 根据条件获取服务器上的 keys ---
371
371
  * @param cursor
@@ -373,7 +373,7 @@ export declare class Connection {
373
373
  * @param count 获取的条数
374
374
  * @param etc
375
375
  */
376
- scan(cursor: number, pattern: string, count: number, etc: types.IConfigKv): Promise<redis.IScanResult<string> | false>;
376
+ scan(cursor: number, pattern: string, count: number, etc: kebab.IConfigKv): Promise<redis.IScanResult<string> | false>;
377
377
  /**
378
378
  * --- 清除当前所选数据库的所有内容 ---
379
379
  */
@@ -391,55 +391,55 @@ export declare class Connection {
391
391
  * @param mod 空,nx(key不存在才建立)
392
392
  * @param etc
393
393
  */
394
- hSet(key: string, field: string, val: object | string | number, mod: '' | 'nx', etc: types.IConfigKv): Promise<boolean>;
394
+ hSet(key: string, field: string, val: object | string | number, mod: '' | 'nx', etc: kebab.IConfigKv): Promise<boolean>;
395
395
  /**
396
396
  * --- 批量设置哈希值 ---
397
397
  * @param key key 名
398
398
  * @param rows key / val 数组
399
399
  * @param etc
400
400
  */
401
- hMSet(key: string, rows: Record<string, object | string | number>, etc: types.IConfigKv): Promise<boolean>;
401
+ hMSet(key: string, rows: Record<string, object | string | number>, etc: kebab.IConfigKv): Promise<boolean>;
402
402
  /**
403
403
  * --- 获取哈希值 ---
404
404
  * @param key
405
405
  * @param field
406
406
  * @param etc
407
407
  */
408
- hGet(key: string, field: string, etc: types.IConfigKv): Promise<string | null>;
408
+ hGet(key: string, field: string, etc: kebab.IConfigKv): Promise<string | null>;
409
409
  /**
410
410
  * --- 获取哈希 json 对象 ---
411
411
  * @param key
412
412
  * @param field
413
413
  * @param etc
414
414
  */
415
- hGetJson(key: string, field: string, etc: types.IConfigKv): Promise<any | null>;
415
+ hGetJson(key: string, field: string, etc: kebab.IConfigKv): Promise<any | null>;
416
416
  /**
417
417
  * --- 批量获取哈希值 ---
418
418
  * @param key
419
419
  * @param fields
420
420
  * @param etc
421
421
  */
422
- hMGet(key: string, fields: string[], etc: types.IConfigKv): Promise<Record<string, string | null>>;
422
+ hMGet(key: string, fields: string[], etc: kebab.IConfigKv): Promise<Record<string, string | null>>;
423
423
  /**
424
424
  * --- 批量获取哈希键值对 ---
425
425
  * @param key
426
426
  * @param etc
427
427
  */
428
- hGetAll(key: string, etc: types.IConfigKv): Promise<Record<string, string | null> | null>;
428
+ hGetAll(key: string, etc: kebab.IConfigKv): Promise<Record<string, string | null> | null>;
429
429
  /**
430
430
  * --- 删除哈希键 ---
431
431
  * @param key
432
432
  * @param fields 值序列
433
433
  * @param etc
434
434
  */
435
- hDel(key: string, fields: string | string[], etc: types.IConfigKv): Promise<number>;
435
+ hDel(key: string, fields: string | string[], etc: kebab.IConfigKv): Promise<number>;
436
436
  /**
437
437
  * --- 判断哈希字段是否存在 ---
438
438
  * @param key
439
439
  * @param field
440
440
  * @param etc
441
441
  */
442
- hExists(key: string, field: string, etc: types.IConfigKv): Promise<boolean>;
442
+ hExists(key: string, field: string, etc: kebab.IConfigKv): Promise<boolean>;
443
443
  /**
444
444
  * --- 设置哈希自增自减 ---
445
445
  * @param key key
@@ -447,27 +447,27 @@ export declare class Connection {
447
447
  * @param increment 正数或负数,整数或浮点
448
448
  * @param etc
449
449
  */
450
- hIncr(key: string, field: string, increment: number, etc: types.IConfigKv): Promise<number>;
450
+ hIncr(key: string, field: string, increment: number, etc: kebab.IConfigKv): Promise<number>;
451
451
  /**
452
452
  * --- 获取哈希所有字段 ---
453
453
  * @param key
454
454
  * @param etc
455
455
  */
456
- hKeys(key: string, etc: types.IConfigKv): Promise<string[]>;
457
- lPush(key: string, values: Array<string | Buffer>, etc: types.IConfigKv): Promise<number>;
458
- rPush(key: string, values: Array<string | Buffer>, etc: types.IConfigKv): Promise<number>;
459
- bLMove(sourceKey: string, destKey: string, soo: 'LEFT' | 'RIGHT', deo: 'LEFT' | 'RIGHT', timeout: number, etc: types.IConfigKv): Promise<string | null>;
460
- lPop(key: string, etc: types.IConfigKv): Promise<string | null>;
461
- rPop(key: string, etc: types.IConfigKv): Promise<string | null>;
462
- bRPop(key: string | string[], timeout: number, etc: types.IConfigKv): Promise<Record<string, string>>;
463
- lRange(key: string, start: number, stop: number, etc: types.IConfigKv): Promise<string[]>;
464
- lLen(key: string, etc: types.IConfigKv): Promise<number>;
456
+ hKeys(key: string, etc: kebab.IConfigKv): Promise<string[]>;
457
+ lPush(key: string, values: Array<string | Buffer>, etc: kebab.IConfigKv): Promise<number>;
458
+ rPush(key: string, values: Array<string | Buffer>, etc: kebab.IConfigKv): Promise<number>;
459
+ bLMove(sourceKey: string, destKey: string, soo: 'LEFT' | 'RIGHT', deo: 'LEFT' | 'RIGHT', timeout: number, etc: kebab.IConfigKv): Promise<string | null>;
460
+ lPop(key: string, etc: kebab.IConfigKv): Promise<string | null>;
461
+ rPop(key: string, etc: kebab.IConfigKv): Promise<string | null>;
462
+ bRPop(key: string | string[], timeout: number, etc: kebab.IConfigKv): Promise<Record<string, string>>;
463
+ lRange(key: string, start: number, stop: number, etc: kebab.IConfigKv): Promise<string[]>;
464
+ lLen(key: string, etc: kebab.IConfigKv): Promise<number>;
465
465
  }
466
466
  /**
467
467
  * --- 获取 Kv Pool 对象 ---
468
468
  * @param etc 配置信息可留空
469
469
  */
470
- export declare function get(ctr: sCtr.Ctr, etc?: types.IConfigKv): Pool;
470
+ export declare function get(ctr: sCtr.Ctr, etc?: kebab.IConfigKv): Pool;
471
471
  /**
472
472
  * --- 获取当前连接池中所有连接的信息 ---
473
473
  */
package/lib/kv.js CHANGED
@@ -7,7 +7,6 @@
7
7
  // --- 为啥 Pool 要独立,因为有些配置项目不能存在 Connection 是用户单独使用的,例如 pre ---
8
8
  // --- 第三方 ---
9
9
  import * as redis from '@litert/redis';
10
- // --- 库和定义 ---
11
10
  import * as lTime from '#lib/time.js';
12
11
  import * as lText from '#lib/text.js';
13
12
  import * as lCore from '#lib/core.js';