Move `packages/core/src/bridge/proto/proton/*.ts` (13 files, ~3.3k LOC) into a new `@snowluma/proto-defs` workspace package. The proton spike landed in the previous commit means bare-specifier imports (`@snowluma/proto-defs/oidb`, `…/message`, …) now resolve correctly through proton's vite plugin, so call-site replacement still fires. Why --- - Lets downstream consumers share the same wire definitions without copy-pasting them — multiple workspace packages can now depend on `@snowluma/proto-defs` directly. - Trims `@snowluma/core`'s surface: the bridge no longer owns the protocol schema, only its consumers. - Sets up future #5 (`message-parsing perf`) and #6 (`Api-on-ctx refactor`) — both want a thinner core. Layout ------ Per-file subpath exports (mirrors the legacy `proto/proton/<sub>` shape 1:1). The barrel `index.ts` intentionally skips `highway` and `oidb-actions/media` because the two files share six NTV2-prefixed type names — `export *` would silently drop one side. Subpath imports are unambiguous, which is also why every call site in core uses them. Changes ------- - New package `packages/proto-defs/` (package.json, tsconfig.json, src/index.ts). - 13 `.ts` files moved via `git mv` to preserve history. - 44 import sites across 26 source files + 15 tests rewritten via sed from `./[…/]proto/proton/<sub>` → `@snowluma/proto-defs/<sub>`. - `@snowluma/core` depends on `@snowluma/proto-defs` (workspace:*). Verification ------------ - proto-defs typecheck: clean - core typecheck: clean - core test suite: 587 passed (same baseline as before the refactor; one failure is the pre-existing websocket native addon, unrelated) - proton test suite: 99 passed (8 files including the new cross-package.test.ts from the spike) - Full workspace `pnpm -r typecheck`: all 8 projects clean Note: proton's `dist/index.js` MUST be rebuilt for the vite plugin to pick up the bare-specifier resolution. The previous commit's source change is only effective after `pnpm -F @snowluma/proton build`.
158 lines
4.3 KiB
TypeScript
158 lines
4.3 KiB
TypeScript
import type { pb, pb_repeated, int_32, uint_32, uint_64, bytes } from '@snowluma/proton';
|
|
|
|
export interface OidbProperty {
|
|
key?: pb<1, string>;
|
|
value?: pb<2, bytes>;
|
|
}
|
|
|
|
export interface OidbBase<TBody> {
|
|
command?: pb<1, uint_32>;
|
|
subCommand?: pb<2, uint_32>;
|
|
errorCode?: pb<3, uint_32>;
|
|
body?: pb<4, TBody>;
|
|
errorMsg?: pb<5, string>;
|
|
properties?: pb_repeated<11, OidbProperty>;
|
|
reserved?: pb<12, int_32>;
|
|
}
|
|
|
|
export interface OidbBaseMeta {
|
|
command?: pb<1, uint_32>;
|
|
subCommand?: pb<2, uint_32>;
|
|
errorCode?: pb<3, uint_32>;
|
|
errorMsg?: pb<5, string>;
|
|
reserved?: pb<12, int_32>;
|
|
}
|
|
|
|
// Oidb.0xFD4_1 Friend list
|
|
export interface OidbFriendProperty {
|
|
code?: pb<1, uint_32>;
|
|
value?: pb<2, string>;
|
|
}
|
|
|
|
export interface OidbFriendLayer1 {
|
|
properties?: pb_repeated<2, OidbFriendProperty>;
|
|
}
|
|
|
|
export interface OidbFriendAdditional {
|
|
type?: pb<1, uint_32>;
|
|
layer1?: pb<2, OidbFriendLayer1>;
|
|
}
|
|
|
|
export interface OidbFriend {
|
|
uid?: pb<1, string>;
|
|
customGroup?: pb<2, uint_32>;
|
|
uin?: pb<3, uint_32>;
|
|
additional?: pb_repeated<10001, OidbFriendAdditional>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFD4_1ResponseUin {
|
|
uin?: pb<1, uint_32>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFD4_1Response {
|
|
next?: pb<2, OidbSvcTrpcTcp0xFD4_1ResponseUin>;
|
|
displayFriendCount?: pb<3, uint_32>;
|
|
timestamp?: pb<6, uint_32>;
|
|
selfUin?: pb<7, uint_32>;
|
|
friends?: pb_repeated<101, OidbFriend>;
|
|
groups?: pb_repeated<102, OidbFriendProperty>;
|
|
}
|
|
|
|
// Oidb.0xFE5_2 Group list
|
|
export interface OidbSvcTrpcTcp0xFE5_2Member {
|
|
uid?: pb<2, string>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE5_2GroupInfo {
|
|
groupOwner?: pb<1, OidbSvcTrpcTcp0xFE5_2Member>;
|
|
createdTime?: pb<2, uint_32>;
|
|
memberMax?: pb<3, uint_32>;
|
|
memberCount?: pb<4, uint_32>;
|
|
groupName?: pb<5, string>;
|
|
description?: pb<18, string>;
|
|
question?: pb<19, string>;
|
|
announcement?: pb<30, string>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE5_2CustomInfo {
|
|
remark?: pb<3, string>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE5_2Group {
|
|
groupUin?: pb<3, uint_32>;
|
|
info?: pb<4, OidbSvcTrpcTcp0xFE5_2GroupInfo>;
|
|
customInfo?: pb<5, OidbSvcTrpcTcp0xFE5_2CustomInfo>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE5_2Response {
|
|
groups?: pb_repeated<2, OidbSvcTrpcTcp0xFE5_2Group>;
|
|
}
|
|
|
|
// Oidb.0xFE7_3 Group member list
|
|
export interface OidbSvcTrpcTcp0xFE7_3Uin {
|
|
uid?: pb<2, string>;
|
|
uin?: pb<4, uint_32>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE7_3Card {
|
|
memberCard?: pb<2, string>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE7_3Level {
|
|
infos?: pb_repeated<1, uint_32>;
|
|
level?: pb<2, uint_32>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE7_3Member {
|
|
uin?: pb<1, OidbSvcTrpcTcp0xFE7_3Uin>;
|
|
memberName?: pb<10, string>;
|
|
specialTitle?: pb<17, string>;
|
|
memberCard?: pb<11, OidbSvcTrpcTcp0xFE7_3Card>;
|
|
level?: pb<12, OidbSvcTrpcTcp0xFE7_3Level>;
|
|
joinTimestamp?: pb<100, uint_32>;
|
|
lastMsgTimestamp?: pb<101, uint_32>;
|
|
shutUpTimestamp?: pb<102, uint_32>;
|
|
permission?: pb<107, uint_32>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0xFE7_3Response {
|
|
groupUin?: pb<1, uint_32>;
|
|
members?: pb_repeated<2, OidbSvcTrpcTcp0xFE7_3Member>;
|
|
field3?: pb<3, uint_32>;
|
|
memberChangeSeq?: pb<5, uint_32>;
|
|
memberCardChangeSeq?: pb<6, uint_32>;
|
|
token?: pb<15, string>;
|
|
}
|
|
|
|
// OIDB.0x10C0 Group Request
|
|
export interface OidbSvcTrpcTcp0x10C0ResponseUser {
|
|
uid?: pb<1, string>;
|
|
name?: pb<2, string>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0x10C0ResponseGroup {
|
|
groupUin?: pb<1, uint_32>;
|
|
groupName?: pb<2, string>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0x10C0ResponseRequest {
|
|
sequence?: pb<1, uint_64>;
|
|
eventType?: pb<2, uint_32>;
|
|
state?: pb<3, uint_32>;
|
|
group?: pb<4, OidbSvcTrpcTcp0x10C0ResponseGroup>;
|
|
target?: pb<5, OidbSvcTrpcTcp0x10C0ResponseUser>;
|
|
invitor?: pb<6, OidbSvcTrpcTcp0x10C0ResponseUser>;
|
|
operatorUser?: pb<7, OidbSvcTrpcTcp0x10C0ResponseUser>;
|
|
field9?: pb<9, string>;
|
|
comment?: pb<10, string>;
|
|
}
|
|
|
|
export interface OidbSvcTrpcTcp0x10C0Response {
|
|
requests?: pb_repeated<1, OidbSvcTrpcTcp0x10C0ResponseRequest>;
|
|
field2?: pb<2, uint_64>;
|
|
newLatestSeq?: pb<3, uint_64>;
|
|
field4?: pb<4, uint_32>;
|
|
field5?: pb<5, uint_64>;
|
|
field6?: pb<6, uint_32>;
|
|
}
|