@maiyunnet/kebab 3.2.34 → 3.2.36
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 +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/core.js +4 -0
- package/lib/cron.d.ts +1 -1
- package/package.json +1 -1
- package/sys/master.js +2 -2
- package/sys/mod.d.ts +4 -2
- package/sys/mod.js +8 -4
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '3.2.
|
|
9
|
+
export const VER = '3.2.36';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/core.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ export declare function log(opt: sCtr.Ctr | ILogOptions, msg: string, fend?: str
|
|
|
193
193
|
* @param opt 参数
|
|
194
194
|
*/
|
|
195
195
|
export declare function getLog(opt: {
|
|
196
|
-
/** ---
|
|
196
|
+
/** --- 要查询的头,如 127.0.0.1、system、www.maiyun.net 等 --- */
|
|
197
197
|
'hostname': string;
|
|
198
198
|
/** --- 如 2024/08/01/22 --- */
|
|
199
199
|
'path': string;
|
package/lib/core.js
CHANGED
|
@@ -681,11 +681,15 @@ export async function getLog(opt) {
|
|
|
681
681
|
});
|
|
682
682
|
const content = await res.getContent();
|
|
683
683
|
if (!content) {
|
|
684
|
+
// --- 连接失败,系统错误 ---
|
|
685
|
+
debug('[CORE][getLog] rpc server error');
|
|
684
686
|
return false;
|
|
685
687
|
}
|
|
686
688
|
const str = content.toString();
|
|
687
689
|
const j = lText.parseJson(str);
|
|
688
690
|
if (!j) {
|
|
691
|
+
// --- 解析失败,系统错误 ---
|
|
692
|
+
debug('[CORE][getLog] rpc server content error');
|
|
689
693
|
return false;
|
|
690
694
|
}
|
|
691
695
|
return j.data;
|
package/lib/cron.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function regular(task: IRegular, immediate?: string): Promise<boo
|
|
|
12
12
|
export declare function run(): void;
|
|
13
13
|
/** --- 定时任务 --- */
|
|
14
14
|
export interface IRegular {
|
|
15
|
-
/** ---
|
|
15
|
+
/** --- 任务名称,只能小写字母、数字、短横线、下划线,长度 1-32 --- */
|
|
16
16
|
'name': string;
|
|
17
17
|
/** --- 任务日期对象(系统时区) --- */
|
|
18
18
|
'date': {
|
package/package.json
CHANGED
package/sys/master.js
CHANGED
|
@@ -233,7 +233,7 @@ function createRpcListener() {
|
|
|
233
233
|
if (!await lFs.isFile(path)) {
|
|
234
234
|
res.end(lText.stringifyJson({
|
|
235
235
|
'result': 1,
|
|
236
|
-
'data':
|
|
236
|
+
'data': null,
|
|
237
237
|
}));
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
@@ -241,7 +241,7 @@ function createRpcListener() {
|
|
|
241
241
|
let limit = msg.limit ?? 100;
|
|
242
242
|
/** --- 剩余 offset --- */
|
|
243
243
|
let offset = msg.offset ?? 0;
|
|
244
|
-
const rtn = await new Promise(
|
|
244
|
+
const rtn = await new Promise(resolve => {
|
|
245
245
|
const list = [];
|
|
246
246
|
/** --- 当前行号 --- */
|
|
247
247
|
let line = 0;
|
package/sys/mod.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
3
3
|
* Date: 2019-6-4 21:35
|
|
4
|
-
* Last: 2020-4-14 13:33:51, 2022-07-23 16:01:34, 2022-09-06 22:59:26, 2023-5-24 19:11:37, 2023-6-13 21:47:58, 2023-7-10 18:54:03, 2023-8-23 17:03:16, 2023-12-11 15:21:22, 2023-12-20 23:12:03, 2024-3-8 16:05:29, 2024-3-20 19:58:15, 2024-8-11 21:14:54, 2024-10-5 14:00:22, 2024-12-14 19:58:34, 2025-9-23 11:01:36
|
|
4
|
+
* Last: 2020-4-14 13:33:51, 2022-07-23 16:01:34, 2022-09-06 22:59:26, 2023-5-24 19:11:37, 2023-6-13 21:47:58, 2023-7-10 18:54:03, 2023-8-23 17:03:16, 2023-12-11 15:21:22, 2023-12-20 23:12:03, 2024-3-8 16:05:29, 2024-3-20 19:58:15, 2024-8-11 21:14:54, 2024-10-5 14:00:22, 2024-12-14 19:58:34, 2025-9-23 11:01:36, 2025-11-5 16:34:31
|
|
5
5
|
*/
|
|
6
6
|
import * as lSql from '#kebab/lib/sql.js';
|
|
7
7
|
import * as lDb from '#kebab/lib/db.js';
|
|
@@ -217,7 +217,7 @@ export default class Mod {
|
|
|
217
217
|
'index'?: string;
|
|
218
218
|
}): T;
|
|
219
219
|
/**
|
|
220
|
-
* ---
|
|
220
|
+
* --- 根据主键(或 key 字段)获取对象 ---
|
|
221
221
|
* @param db 数据库对象
|
|
222
222
|
* @param val 主键值
|
|
223
223
|
* @param lock 是否加锁
|
|
@@ -229,6 +229,8 @@ export default class Mod {
|
|
|
229
229
|
'raw'?: boolean;
|
|
230
230
|
'pre'?: string;
|
|
231
231
|
'index'?: string | string[];
|
|
232
|
+
/** --- 通过 key 字段获取,默认为 false,即从主键获取 --- */
|
|
233
|
+
'key'?: boolean;
|
|
232
234
|
}): Promise<false | null | (T & Record<string, any>)>;
|
|
233
235
|
static one(db: lDb.Pool | lDb.Transaction, s: string | kebab.Json, opt: {
|
|
234
236
|
'ctr'?: sCtr.Ctr;
|
package/sys/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
3
3
|
* Date: 2019-6-4 21:35
|
|
4
|
-
* Last: 2020-4-14 13:33:51, 2022-07-23 16:01:34, 2022-09-06 22:59:26, 2023-5-24 19:11:37, 2023-6-13 21:47:58, 2023-7-10 18:54:03, 2023-8-23 17:03:16, 2023-12-11 15:21:22, 2023-12-20 23:12:03, 2024-3-8 16:05:29, 2024-3-20 19:58:15, 2024-8-11 21:14:54, 2024-10-5 14:00:22, 2024-12-14 19:58:34, 2025-9-23 11:01:36
|
|
4
|
+
* Last: 2020-4-14 13:33:51, 2022-07-23 16:01:34, 2022-09-06 22:59:26, 2023-5-24 19:11:37, 2023-6-13 21:47:58, 2023-7-10 18:54:03, 2023-8-23 17:03:16, 2023-12-11 15:21:22, 2023-12-20 23:12:03, 2024-3-8 16:05:29, 2024-3-20 19:58:15, 2024-8-11 21:14:54, 2024-10-5 14:00:22, 2024-12-14 19:58:34, 2025-9-23 11:01:36, 2025-11-5 16:34:31
|
|
5
5
|
*/
|
|
6
6
|
import * as lSql from '#kebab/lib/sql.js';
|
|
7
7
|
import * as lTime from '#kebab/lib/time.js';
|
|
@@ -418,19 +418,23 @@ export default class Mod {
|
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
|
-
* ---
|
|
421
|
+
* --- 根据主键(或 key 字段)获取对象 ---
|
|
422
422
|
* @param db 数据库对象
|
|
423
423
|
* @param val 主键值
|
|
424
424
|
* @param lock 是否加锁
|
|
425
425
|
* @param opt 选项
|
|
426
426
|
*/
|
|
427
|
-
static find(db, val, opt = {}) {
|
|
427
|
+
static async find(db, val, opt = {}) {
|
|
428
|
+
if (opt.key && !this._$key) {
|
|
429
|
+
lCore.debug('[MOD][find] key not found');
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
428
432
|
return new this({
|
|
429
433
|
'db': db,
|
|
430
434
|
'ctr': opt.ctr,
|
|
431
435
|
'pre': opt.pre,
|
|
432
436
|
'where': [{
|
|
433
|
-
[this._$primary]: val
|
|
437
|
+
[opt.key ? this._$key : this._$primary]: val,
|
|
434
438
|
}],
|
|
435
439
|
'raw': opt.raw,
|
|
436
440
|
'index': opt.index,
|