@onebots/core 1.0.4 → 1.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/lib/adapter.d.ts +9 -0
- package/lib/adapter.js +5 -1
- package/lib/db.d.ts +4 -0
- package/lib/db.js +6 -0
- package/package.json +6 -5
package/lib/adapter.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ export declare abstract class Adapter<C = any, T extends keyof Adapter.Configs =
|
|
|
21
21
|
accounts: Map<string, Account<T, C>>;
|
|
22
22
|
icon: string;
|
|
23
23
|
get db(): SqliteDB;
|
|
24
|
+
/**
|
|
25
|
+
* id_map 表名:平台名可能含 `-`(如 wechat-ilink),不能直接拼进 SQL,需规范为合法标识符。
|
|
26
|
+
*/
|
|
24
27
|
get tableName(): string;
|
|
25
28
|
protected constructor(app: I, platform: T);
|
|
26
29
|
createId(id: string | number): CommonTypes.Id;
|
|
@@ -535,6 +538,12 @@ export declare namespace Adapter {
|
|
|
535
538
|
type: 'image';
|
|
536
539
|
base64: string;
|
|
537
540
|
alt?: string;
|
|
541
|
+
}
|
|
542
|
+
/** 远程图片 URL(如微信 CDN),Web 端用 img 的 src 直接展示 */
|
|
543
|
+
| {
|
|
544
|
+
type: 'image_url';
|
|
545
|
+
url: string;
|
|
546
|
+
alt?: string;
|
|
538
547
|
} | {
|
|
539
548
|
type: 'link';
|
|
540
549
|
url: string;
|
package/lib/adapter.js
CHANGED
|
@@ -19,8 +19,12 @@ export class Adapter extends EventEmitter {
|
|
|
19
19
|
get db() {
|
|
20
20
|
return this.app.db;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* id_map 表名:平台名可能含 `-`(如 wechat-ilink),不能直接拼进 SQL,需规范为合法标识符。
|
|
24
|
+
*/
|
|
22
25
|
get tableName() {
|
|
23
|
-
|
|
26
|
+
const safe = String(this.platform).replace(/[^a-zA-Z0-9_]/g, "_");
|
|
27
|
+
return `id_map_${safe}`;
|
|
24
28
|
}
|
|
25
29
|
constructor(app, platform) {
|
|
26
30
|
super();
|
package/lib/db.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export declare class SqliteDB {
|
|
|
13
13
|
insert(table: string): Insertion;
|
|
14
14
|
update(table: string): Updation;
|
|
15
15
|
delete(table: string): Deletion;
|
|
16
|
+
/**
|
|
17
|
+
* 执行原始 SQL(如复合主键建表),调用方需保证语句幂等(常用 IF NOT EXISTS)
|
|
18
|
+
*/
|
|
19
|
+
execSQL(sql: string): void;
|
|
16
20
|
/**
|
|
17
21
|
* Close database connection
|
|
18
22
|
*/
|
package/lib/db.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onebots/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "IMHelper 核心抽象层,提供适配器、协议、账号等基础接口和类型",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
9
|
+
"node": ">=24"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -33,13 +33,14 @@
|
|
|
33
33
|
"@types/koa__router": "^12.0.5",
|
|
34
34
|
"@types/koa-basic-auth": "^2.0.6",
|
|
35
35
|
"@types/koa-static": "^4.0.4",
|
|
36
|
-
"@types/
|
|
36
|
+
"@types/js-yaml": "^4.0.9",
|
|
37
|
+
"@types/node": "^24.0.0",
|
|
37
38
|
"@types/ws": "^8.5.3",
|
|
38
39
|
"tsc-alias": "latest",
|
|
39
40
|
"tsconfig-paths": "latest",
|
|
40
41
|
"tsx": "latest",
|
|
41
|
-
"typescript": "
|
|
42
|
-
"
|
|
42
|
+
"typescript": "5.9.3",
|
|
43
|
+
"wechat": "latest"
|
|
43
44
|
},
|
|
44
45
|
"files": [
|
|
45
46
|
"/lib/**/*.js",
|