Introduce a new way to organise OIDB cmd implementations:
- one TypeScript namespace per (cmd, subcmd) tuple
- the namespace's exported members ARE the OidbCallSpec (structural
typing — no `implements` clause)
- a single invokeOidb() template method drives every call:
envelope build → encode → send → errorCode check → decode →
deserialize transformation
- each namespace declares its own minimal `Deps` capability via
Pick / intersection on BridgeContext (Interface Segregation):
most cmds need only OidbSender (the `sendRawPacket` method)
The facade Api classes (InteractionApi etc.) stay for now, with the
migrated methods reduced to one-line forwarders that hand off to the
namespace. Callers still write `bridge.apis.X.Y(...)`; the OIDB
wire-encoding work just moved to a self-contained file per cmd.
Vertical slice scope: 3 cmds (the reaction line)
- SetReaction (0x9082_1 / _2; dynamic subcmd)
- FetchReactionSummary (0x9084_1)
- GetEmojiLikes (0x9083_1; legacy stub)
Infrastructure:
- new packages/bridge/src/oidb-service.ts:
OidbSender (sendRawPacket-only capability),
OidbCallSpec<TReq, TResp, TParams, TResult>,
invokeOidb(), buildOidbRequest(), parseOidbResponse(), OidbError
- runOidb() refactored to accept OidbSender instead of BridgeContext
(structurally compatible — no caller changes anywhere)
- new OidbEmpty placeholder type in proto-defs/oidb.ts for cmds whose
response carries no body (proton needs a real message interface,
not `void` / `never`)
- empty-body responses substituted with {} in invokeOidb so
deserialize always receives a defined object
Tests (65 in @snowluma/bridge, all green):
- oidb-service.test.ts (20): every helper branch — static + dynamic
subcmd, uinForm flag, error code propagation as OidbError, empty
body substitution, sender failure modes (success=false /
gotResponse=false / both with and without errorMessage),
timeoutMs propagation
- set-reaction.test.ts: const declarations, dynamic subcmd both
ways, type=1/2 boundary on code length, e2e envelope inspection
- fetch-reaction-summary.test.ts: BigInt serialization, catalog-tail
filtering, default emojiId/Type/lastReactionTime
- get-emoji-likes.test.ts: BigInt serialization, default count /
emojiType, base64 cookie round-trip, uin=0 filtering, isLast
computation, e2e
Existing interaction.test.ts moved off the now-bypassed runOidb mock
onto sendRawPacket mock (the new invokeOidb path routes there).
Workspace-wide typecheck: green. Workspace test totals:
proton 99/99, bridge 65/65, core 302/302, onebot 257/257
(1 pre-existing onebot suite failure, network-manager native addon
load — unrelated to this change.)
149 lines
5.1 KiB
JSON
149 lines
5.1 KiB
JSON
{
|
|
"name": "@snowluma/bridge",
|
|
"version": "1.9.1",
|
|
"private": true,
|
|
"type": "module",
|
|
"description": "SnowLuma bridge — the protocol-layer between QQ wire bytes and typed events. Owns: identity service (uid↔uin cache with SQLite persistence), event bus, packet pipeline (incoming SSO packet → QQEventVariant), msg-push decoders, element-builder (MessageElement → wire elems[]), highway upload protocol (file/image/video/ptt), OIDB envelope helper, and the event/notice/request type vocabulary. Consumers (@snowluma/core, @snowluma/onebot) talk to this package through `BridgeContext` for runtime calls and the standalone classes (IdentityService, BridgeEventBus, IncomingPacketPipeline) for composition. Per-file subpath exports mirror the legacy `core/src/bridge/*` layout 1:1 so the previous `import { …} from '../bridge/<x>'` collapses to `import { … } from '@snowluma/bridge/<x>'`.",
|
|
"main": "./src/index.ts",
|
|
"types": "./src/index.ts",
|
|
"exports": {
|
|
".": {
|
|
"types": "./src/index.ts",
|
|
"default": "./src/index.ts"
|
|
},
|
|
"./events": {
|
|
"types": "./src/events.ts",
|
|
"default": "./src/events.ts"
|
|
},
|
|
"./event-bus": {
|
|
"types": "./src/event-bus.ts",
|
|
"default": "./src/event-bus.ts"
|
|
},
|
|
"./identity-service": {
|
|
"types": "./src/identity-service.ts",
|
|
"default": "./src/identity-service.ts"
|
|
},
|
|
"./packet-pipeline": {
|
|
"types": "./src/packet-pipeline.ts",
|
|
"default": "./src/packet-pipeline.ts"
|
|
},
|
|
"./element-builder": {
|
|
"types": "./src/element-builder.ts",
|
|
"default": "./src/element-builder.ts"
|
|
},
|
|
"./bridge-oidb": {
|
|
"types": "./src/bridge-oidb.ts",
|
|
"default": "./src/bridge-oidb.ts"
|
|
},
|
|
"./oidb-service": {
|
|
"types": "./src/oidb-service.ts",
|
|
"default": "./src/oidb-service.ts"
|
|
},
|
|
"./oidb-services/reaction/set-reaction": {
|
|
"types": "./src/oidb-services/reaction/set-reaction.ts",
|
|
"default": "./src/oidb-services/reaction/set-reaction.ts"
|
|
},
|
|
"./oidb-services/reaction/fetch-reaction-summary": {
|
|
"types": "./src/oidb-services/reaction/fetch-reaction-summary.ts",
|
|
"default": "./src/oidb-services/reaction/fetch-reaction-summary.ts"
|
|
},
|
|
"./oidb-services/reaction/get-emoji-likes": {
|
|
"types": "./src/oidb-services/reaction/get-emoji-likes.ts",
|
|
"default": "./src/oidb-services/reaction/get-emoji-likes.ts"
|
|
},
|
|
"./bridge-context": {
|
|
"types": "./src/bridge-context.ts",
|
|
"default": "./src/bridge-context.ts"
|
|
},
|
|
"./qq-info": {
|
|
"types": "./src/qq-info.ts",
|
|
"default": "./src/qq-info.ts"
|
|
},
|
|
"./format": {
|
|
"types": "./src/format.ts",
|
|
"default": "./src/format.ts"
|
|
},
|
|
"./msg-push": {
|
|
"types": "./src/msg-push/index.ts",
|
|
"default": "./src/msg-push/index.ts"
|
|
},
|
|
"./msg-push/registry": {
|
|
"types": "./src/msg-push/registry.ts",
|
|
"default": "./src/msg-push/registry.ts"
|
|
},
|
|
"./msg-push/context": {
|
|
"types": "./src/msg-push/context.ts",
|
|
"default": "./src/msg-push/context.ts"
|
|
},
|
|
"./msg-push/decoders/event-0x2dc": {
|
|
"types": "./src/msg-push/decoders/event-0x2dc.ts",
|
|
"default": "./src/msg-push/decoders/event-0x2dc.ts"
|
|
},
|
|
"./highway": {
|
|
"types": "./src/highway/highway-client.ts",
|
|
"default": "./src/highway/highway-client.ts"
|
|
},
|
|
"./highway/utils": {
|
|
"types": "./src/highway/utils.ts",
|
|
"default": "./src/highway/utils.ts"
|
|
},
|
|
"./highway/pipeline": {
|
|
"types": "./src/highway/pipeline.ts",
|
|
"default": "./src/highway/pipeline.ts"
|
|
},
|
|
"./highway/image-upload": {
|
|
"types": "./src/highway/image-upload.ts",
|
|
"default": "./src/highway/image-upload.ts"
|
|
},
|
|
"./highway/ptt-upload": {
|
|
"types": "./src/highway/ptt-upload.ts",
|
|
"default": "./src/highway/ptt-upload.ts"
|
|
},
|
|
"./highway/video-upload": {
|
|
"types": "./src/highway/video-upload.ts",
|
|
"default": "./src/highway/video-upload.ts"
|
|
},
|
|
"./highway/ffmpeg-addon": {
|
|
"types": "./src/highway/ffmpeg-addon.ts",
|
|
"default": "./src/highway/ffmpeg-addon.ts"
|
|
},
|
|
"./web/group-album": {
|
|
"types": "./src/web/group-album.ts",
|
|
"default": "./src/web/group-album.ts"
|
|
},
|
|
"./web/group-essence": {
|
|
"types": "./src/web/group-essence.ts",
|
|
"default": "./src/web/group-essence.ts"
|
|
},
|
|
"./web/group-honor": {
|
|
"types": "./src/web/group-honor.ts",
|
|
"default": "./src/web/group-honor.ts"
|
|
},
|
|
"./web/group-notice": {
|
|
"types": "./src/web/group-notice.ts",
|
|
"default": "./src/web/group-notice.ts"
|
|
},
|
|
"./web/request-util": {
|
|
"types": "./src/web/request-util.ts",
|
|
"default": "./src/web/request-util.ts"
|
|
}
|
|
},
|
|
"scripts": {
|
|
"test": "vitest run",
|
|
"bench": "vitest bench --run",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@snowluma/common": "workspace:*",
|
|
"@snowluma/proto-defs": "workspace:*",
|
|
"@snowluma/proton": "workspace:*",
|
|
"@snowluma/sqlite": "workspace:*"
|
|
},
|
|
"devDependencies": {
|
|
"@types/node": "^24.12.2",
|
|
"typescript": "catalog:",
|
|
"vite": "catalog:",
|
|
"vitest": "^4.1.4"
|
|
}
|
|
}
|