chore: prepare v2.0.0 release
This commit is contained in:
1 parent
1001f55a06
commit
c15b2d857d
31 files changed
+965
-40
No files matched your search
@@ -1,7 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
## 2.0.0
|
||||
|
||||
Upgrade to Node.js 24 or newer before updating the SDK. SDK and application versions are released together.
|
||||
|
||||
- Add typed `get_qzone_msg_detail` support for reading a post and its comment page with inline replies.
|
||||
- Release cancellation listeners as soon as a request stops waiting for a connection.
|
||||
- Isolate WebSocket connection lifetimes and release request timers and abort listeners on every outcome.
|
||||
- Reject duplicate in-flight WebSocket echoes instead of overwriting the original request.
|
||||
|
||||
@@ -144,6 +144,28 @@ const response = await bot.rawResponse('get_status');
|
||||
|
||||
`raw` 会在 SnowLuma 返回 `status: "failed"` 或非零 `retcode` 时抛出 `SnowLumaApiError`;`rawResponse` 会保留完整响应。
|
||||
|
||||
### 读取空间说说评论
|
||||
|
||||
`get_qzone_msg_detail` 是只读扩展动作,`raw` 提供参数和结果类型:
|
||||
|
||||
```ts
|
||||
const detail = await bot.raw('get_qzone_msg_detail', {
|
||||
tid: '说说 ID', // 来自 get_qzone_msg_list / send_qzone_msg
|
||||
// target_uin: 10001, // 省略时读取机器人自己的空间
|
||||
pos: 0,
|
||||
num: 20,
|
||||
});
|
||||
|
||||
for (const comment of detail.comments) {
|
||||
console.log(comment.comment_id, comment.uin, comment.name, comment.time, comment.content);
|
||||
console.log(comment.replies); // 服务端内联返回的二级回复
|
||||
}
|
||||
```
|
||||
|
||||
`comment_num` 是服务端报告的总数,`comments` 是本页一级评论;`num` 范围为 1–100,实际返回数量可能更少。二级回复不单独分页,`replies` 不保证完整。评论 ID 在所属说说内唯一,二级回复 ID 在父评论内唯一;时间均为 Unix 秒,正文保留空间表情和 @ 标记。该接口复用当前账号的空间登录态,登录或访问权限失败会抛出 `SnowLumaApiError`。
|
||||
|
||||
分页参数及 `commentlist` / `list_3` 字段参考 [Qzone-API](https://github.com/SmartHypercube/Qzone-API/blob/master/qzone.py)。实际分页和可见内容取决于 QQ 空间服务端。
|
||||
|
||||
## Message Builder
|
||||
|
||||
```ts
|
||||
|
||||
@@ -7,17 +7,9 @@ The SDK follows SemVer for its public package surface:
|
||||
- Supported subpath exports: `client`, `messages`, `events`, `errors`, `actions`, and `types`.
|
||||
- Runtime behavior of typed client helpers, message builders, event helpers, and SDK error classes.
|
||||
|
||||
## Current 0.x Policy
|
||||
## Version policy
|
||||
|
||||
While the SDK is below `1.0.0`, breaking changes should use a minor release and include a migration note. Patch releases should remain bug fixes only.
|
||||
|
||||
Examples:
|
||||
|
||||
- `0.1.1`: bug fix, doc fix, type refinement that does not break consumers.
|
||||
- `0.2.0`: new client helper, new event helper, new action typing, or documented breaking change before 1.0.
|
||||
- `1.0.0`: first stable release where breaking changes move to major versions.
|
||||
|
||||
## After 1.0
|
||||
SDK and application versions are synchronized by `pnpm bump <version>` from the repository root.
|
||||
|
||||
- Major: removes or changes a public export, changes runtime behavior incompatibly, changes supported Node version, or changes package subpaths.
|
||||
- Minor: adds new public API, supports new SnowLuma actions, adds optional parameters, or adds error subclasses.
|
||||
@@ -25,7 +17,7 @@ Examples:
|
||||
|
||||
## Release Checklist
|
||||
|
||||
1. Update `packages/sdk/package.json` version.
|
||||
1. Run `pnpm bump <version>` to update all workspace versions.
|
||||
2. Update `packages/sdk/CHANGELOG.md`.
|
||||
3. Run `pnpm --filter @snowluma/sdk typecheck`.
|
||||
4. Run `pnpm --filter @snowluma/sdk test`.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "MotricSeven",
|
||||
"email": "[email protected]"
|
||||
},
|
||||
"version": "1.14.22",
|
||||
"version": "2.0.0",
|
||||
"description": "TypeScript SDK for SnowLuma OneBot HTTP and WebSocket transports",
|
||||
"keywords": [
|
||||
"snowluma",
|
||||
|
||||
@@ -78,6 +78,7 @@ import type {
|
||||
DeleteGroupFolderParams,
|
||||
SendPacketParams,
|
||||
SearchSysFacesParams,
|
||||
GetQzoneMsgDetailParams,
|
||||
} from './params';
|
||||
import type {
|
||||
CapabilityInfo,
|
||||
@@ -115,11 +116,13 @@ import type {
|
||||
SystemFaceCatalogInfo,
|
||||
SystemFaceInfo,
|
||||
SystemFaceSearchInfo,
|
||||
QzoneMsgDetailResult,
|
||||
} from './results';
|
||||
|
||||
export type ActionData = JsonValue;
|
||||
|
||||
export interface SnowLumaActionMap {
|
||||
get_qzone_msg_detail: { params: GetQzoneMsgDetailParams; data: QzoneMsgDetailResult };
|
||||
get_login_info: { params: JsonObject; data: LoginInfo };
|
||||
get_status: { params: JsonObject; data: StatusInfo };
|
||||
get_version_info: { params: JsonObject; data: VersionInfo };
|
||||
|
||||
@@ -423,3 +423,13 @@ export interface SendPacketParams extends JsonObject {
|
||||
data?: string;
|
||||
rsp?: boolean;
|
||||
}
|
||||
|
||||
export interface GetQzoneMsgDetailParams extends JsonObject {
|
||||
tid: string;
|
||||
/** Post owner; defaults to the current account. */
|
||||
target_uin?: number | string;
|
||||
/** Top-level comment offset (default 0). */
|
||||
pos?: number | string;
|
||||
/** Requested page size, 1–100 (default 20); Qzone may return fewer. */
|
||||
num?: number | string;
|
||||
}
|
||||
@@ -1,5 +1,28 @@
|
||||
import type { JsonArray, JsonObject, JsonValue } from './json';
|
||||
|
||||
export interface QzoneCommentReply {
|
||||
uin: number;
|
||||
name: string;
|
||||
/** Unix seconds. */
|
||||
time: number;
|
||||
content: string;
|
||||
/** Scoped to the post, or parent comment for replies. */
|
||||
comment_id: string;
|
||||
}
|
||||
|
||||
export interface QzoneComment extends QzoneCommentReply {
|
||||
/** Inline replies only; Qzone may omit further replies. */
|
||||
replies: QzoneCommentReply[];
|
||||
}
|
||||
|
||||
export interface QzoneMsgDetailResult {
|
||||
tid: string;
|
||||
content: string;
|
||||
/** Server-reported total, not the number of comments on this page. */
|
||||
comment_num: number;
|
||||
comments: QzoneComment[];
|
||||
}
|
||||
|
||||
export interface SendMessageResult {
|
||||
message_id: number;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { describe, expect, expectTypeOf, it, vi } from 'vitest';
|
||||
import type { QzoneMsgDetailResult } from '../src';
|
||||
import {
|
||||
SnowLumaAbortError,
|
||||
SnowLumaAuthError,
|
||||
@@ -7,6 +8,38 @@ import {
|
||||
} from '../src';
|
||||
|
||||
describe('SnowLumaHttpClient', () => {
|
||||
it('reads a typed Qzone comment page through raw', async () => {
|
||||
const data: QzoneMsgDetailResult = {
|
||||
tid: 'T1',
|
||||
content: 'Post',
|
||||
comment_num: 1,
|
||||
comments: [
|
||||
{
|
||||
uin: 20002,
|
||||
name: 'Reader',
|
||||
time: 1700000000,
|
||||
content: 'Hi',
|
||||
comment_id: '0',
|
||||
replies: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
const fetchImpl = vi.fn(
|
||||
async () => new Response(JSON.stringify({ status: 'ok', retcode: 0, data })),
|
||||
);
|
||||
const client = new SnowLumaHttpClient({ fetch: fetchImpl });
|
||||
const params = { tid: 'T1', target_uin: 10001, pos: 0, num: 20 };
|
||||
const result = await client.raw('get_qzone_msg_detail', params);
|
||||
expectTypeOf(result).toEqualTypeOf<QzoneMsgDetailResult>();
|
||||
expect(result).toEqual(data);
|
||||
expect(fetchImpl).toHaveBeenCalledWith(
|
||||
'http://127.0.0.1:3000/',
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({ action: 'get_qzone_msg_detail', params }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('requests group share links with default and explicit options', async () => {
|
||||
const url = 'https://qm.qq.com/q/example';
|
||||
const fetchImpl = vi
|
||||
|
||||
Reference in new issue
Block a user