feat(sdk): add media sends, quoted replies, and event waits

Add local media upload-and-send helpers with an optional Node file source
and stage-aware errors. Add explicit quoted replies and cancellable event
waits while preserving existing methods and handler contracts.

Propagate group-file publication failures instead of reporting success.
Cover cancellation, cleanup, signed message IDs, package exports, consumer
types, and real HTTP/WebSocket upload-to-send integration.

Validation: pnpm run ci (6231 tests passed, 9 skipped); SDK package contents
verified with npm pack --dry-run --ignore-scripts.
This commit is contained in:
DrSmoothl committed 2026-10-23 19:45:47 +08:00
1 parent 2d659b0ceb
commit fa5efcd310
28 files changed
+1798 -37

No files matched your search

+10 -6
View File
@@ -287,7 +287,7 @@ describe('apis/group-file', () => {
expect(publishSpy).not.toHaveBeenCalled();
});
it('upload returns success even when the chat post fails (file is still uploaded)', async () => {
it('upload reports chat publication failure while retaining the completed file identity', async () => {
const bridge = mockBridge();
bridge.sendRawPacket.mockResolvedValueOnce(
packResponse(
@@ -297,12 +297,16 @@ describe('apis/group-file', () => {
),
);
const api = new GroupFileApi(bridge as any);
const publishSpy = vi
.spyOn(api, 'publish')
.mockRejectedValueOnce(new Error('message rejected'));
const out = await api.upload(12345, '/path/file.bin');
expect(out).toEqual({ fileId: 'fid-tolerant' });
const cause = new Error('message rejected');
const publishSpy = vi.spyOn(api, 'publish').mockRejectedValueOnce(cause);
await expect(api.upload(12345, '/path/file.bin')).rejects.toMatchObject({
message:
'group file uploaded (fileId=fid-tolerant) but chat post failed: message rejected',
cause,
});
expect(publishSpy).toHaveBeenCalledOnce();
const staged = await vi.mocked(stageMod.stageSourceToDisk).mock.results.at(-1)!.value;
expect(staged.cleanup).toHaveBeenCalledOnce();
});
it.each([true, false])(