refactor(packages): rename @snowluma/bridge → @snowluma/protocol
The package previously named "bridge" houses the protocol-byte layer (OIDB cmds, msg-push decoders, highway uploaders, element-builder, event bus). The name "bridge" suggested transport/lifecycle, which it isn't — that role lives in core/hook and core/bridge/manager. Rename to match what's actually inside. This is a pure rename: zero logic changes, all 73 import sites updated mechanically and TS-verified. core/onebot dependencies key updated. ESLint override path adjusted for the moved oidb-services directory. Rename detection threshold: git log --find-renames=20% recommended when following history across this commit — content-replacement (@snowluma/bridge → @snowluma/protocol) dropped per-file similarity below git's default 50% on import-heavy files.
This commit is contained in:
238 files changed
+247
-284
No files matched your search
+2
-2
@@ -67,8 +67,8 @@ export default defineConfig([
|
|||||||
// the file:cmd 1:1 mapping are the whole point. Disable the
|
// the file:cmd 1:1 mapping are the whole point. Disable the
|
||||||
// module-syntax preference here only.
|
// module-syntax preference here only.
|
||||||
files: [
|
files: [
|
||||||
'packages/bridge/src/oidb-services/**/*.ts',
|
'packages/protocol/src/oidb-services/**/*.ts',
|
||||||
'packages/bridge/tests/oidb-services/**/*.ts',
|
'packages/protocol/tests/oidb-services/**/*.ts',
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-namespace': 'off',
|
'@typescript-eslint/no-namespace': 'off',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "1.9.1",
|
"version": "1.9.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "SnowLuma shared infrastructure — leaf-package utilities with zero business dependencies. Logger / hex codec / log file transport / log line summariser / packet sender wire-protocol types / runtime config loader. Consumed by @snowluma/bridge, @snowluma/core, and @snowluma/onebot. Per-file subpath exports keep import sites unambiguous and let the bundler tree-shake aggressively (importing `@snowluma/common/hex` doesn't pull in `node:fs` from the logger transport).",
|
"description": "SnowLuma shared infrastructure — leaf-package utilities with zero business dependencies. Logger / hex codec / log file transport / log line summariser / packet sender wire-protocol types / runtime config loader. Consumed by @snowluma/protocol, @snowluma/core, and @snowluma/onebot. Per-file subpath exports keep import sites unambiguous and let the bundler tree-shake aggressively (importing `@snowluma/common/hex` doesn't pull in `node:fs` from the logger transport).",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
"types": "./src/index.ts",
|
"types": "./src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Plain JSON value types — defined here (not in @snowluma/onebot/types
|
// Plain JSON value types — defined here (not in @snowluma/onebot/types
|
||||||
// where they used to live) so @snowluma/bridge can talk about JSON-shaped
|
// where they used to live) so @snowluma/protocol can talk about JSON-shaped
|
||||||
// payloads without importing OneBot. The OneBot types module keeps the
|
// payloads without importing OneBot. The OneBot types module keeps the
|
||||||
// names exported via re-export, so existing call sites that say
|
// names exported via re-export, so existing call sites that say
|
||||||
// `import type { JsonValue } from '<…>/onebot/types'` continue to work
|
// `import type { JsonValue } from '<…>/onebot/types'` continue to work
|
||||||
|
|||||||
@@ -40,9 +40,9 @@
|
|||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@snowluma/bridge": "workspace:*",
|
|
||||||
"@snowluma/common": "workspace:*",
|
"@snowluma/common": "workspace:*",
|
||||||
"@snowluma/onebot": "workspace:*",
|
"@snowluma/onebot": "workspace:*",
|
||||||
|
"@snowluma/protocol": "workspace:*",
|
||||||
"@snowluma/proto-defs": "workspace:*",
|
"@snowluma/proto-defs": "workspace:*",
|
||||||
"@snowluma/proton": "workspace:*",
|
"@snowluma/proton": "workspace:*",
|
||||||
"@snowluma/sqlite": "workspace:*",
|
"@snowluma/sqlite": "workspace:*",
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ import type {
|
|||||||
GroupRequestInfo,
|
GroupRequestInfo,
|
||||||
QQGroupInfo,
|
QQGroupInfo,
|
||||||
UserProfileInfo,
|
UserProfileInfo,
|
||||||
} from '@snowluma/bridge/qq-info';
|
} from '@snowluma/protocol/qq-info';
|
||||||
import { FetchFriendListPage } from '@snowluma/bridge/oidb-services/contacts/fetch-friend-list-page';
|
import { FetchFriendListPage } from '@snowluma/protocol/oidb-services/contacts/fetch-friend-list-page';
|
||||||
import { FetchGroupList } from '@snowluma/bridge/oidb-services/contacts/fetch-group-list';
|
import { FetchGroupList } from '@snowluma/protocol/oidb-services/contacts/fetch-group-list';
|
||||||
import { FetchGroupMemberListPage } from '@snowluma/bridge/oidb-services/contacts/fetch-group-member-list-page';
|
import { FetchGroupMemberListPage } from '@snowluma/protocol/oidb-services/contacts/fetch-group-member-list-page';
|
||||||
import { FetchUserProfile } from '@snowluma/bridge/oidb-services/contacts/fetch-user-profile';
|
import { FetchUserProfile } from '@snowluma/protocol/oidb-services/contacts/fetch-user-profile';
|
||||||
import { FetchUserProfileByUid } from '@snowluma/bridge/oidb-services/contacts/fetch-user-profile-by-uid';
|
import { FetchUserProfileByUid } from '@snowluma/protocol/oidb-services/contacts/fetch-user-profile-by-uid';
|
||||||
import { FetchGroupRequests } from '@snowluma/bridge/oidb-services/contacts/fetch-group-requests';
|
import { FetchGroupRequests } from '@snowluma/protocol/oidb-services/contacts/fetch-group-requests';
|
||||||
import { FetchDownloadRkeys } from '@snowluma/bridge/oidb-services/contacts/fetch-download-rkeys';
|
import { FetchDownloadRkeys } from '@snowluma/protocol/oidb-services/contacts/fetch-download-rkeys';
|
||||||
|
|
||||||
// ─── Helpers (previously in bridge-contacts.ts) ───────────────────
|
// ─── Helpers (previously in bridge-contacts.ts) ───────────────────
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
// ExtrasApi — facade over Tier-2 napcat-parity OIDB cmds (group
|
// ExtrasApi — facade over Tier-2 napcat-parity OIDB cmds (group
|
||||||
// todo CRUD / stranger status decode / AI voice list + synthesis).
|
// todo CRUD / stranger status decode / AI voice list + synthesis).
|
||||||
// Every method is a one-line forwarder to a self-contained namespace
|
// Every method is a one-line forwarder to a self-contained namespace
|
||||||
// under @snowluma/bridge/oidb-services/extras.
|
// under @snowluma/protocol/oidb-services/extras.
|
||||||
|
|
||||||
import type { MediaIndexNode } from './shared';
|
import type { MediaIndexNode } from './shared';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import { GroupTodo } from '@snowluma/bridge/oidb-services/extras/group-todo';
|
import { GroupTodo } from '@snowluma/protocol/oidb-services/extras/group-todo';
|
||||||
import { GetStrangerStatus, type StrangerStatus as NamespaceStrangerStatus } from '@snowluma/bridge/oidb-services/extras/get-stranger-status';
|
import { GetStrangerStatus, type StrangerStatus as NamespaceStrangerStatus } from '@snowluma/protocol/oidb-services/extras/get-stranger-status';
|
||||||
import {
|
import {
|
||||||
FetchAiVoiceList,
|
FetchAiVoiceList,
|
||||||
type AiVoiceCategory as NamespaceAiVoiceCategory,
|
type AiVoiceCategory as NamespaceAiVoiceCategory,
|
||||||
} from '@snowluma/bridge/oidb-services/extras/fetch-ai-voice-list';
|
} from '@snowluma/protocol/oidb-services/extras/fetch-ai-voice-list';
|
||||||
import { FetchAiVoice } from '@snowluma/bridge/oidb-services/extras/fetch-ai-voice';
|
import { FetchAiVoice } from '@snowluma/protocol/oidb-services/extras/fetch-ai-voice';
|
||||||
|
|
||||||
// ─────────────── public types (re-exported from bridge.ts as before) ───
|
// ─────────────── public types (re-exported from bridge.ts as before) ───
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import type { FileExtra, PushMsg, PushMsgBody } from '@snowluma/proto-defs/messa
|
|||||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import type { Bridge } from '../bridge';
|
import type { Bridge } from '../bridge';
|
||||||
import { buildSendElems } from '@snowluma/bridge/element-builder';
|
import { buildSendElems } from '@snowluma/protocol/element-builder';
|
||||||
import type { ForwardNodePayload, MessageElement } from '@snowluma/bridge/events';
|
import type { ForwardNodePayload, MessageElement } from '@snowluma/protocol/events';
|
||||||
import { parseMsgPush } from '@snowluma/bridge/msg-push';
|
import { parseMsgPush } from '@snowluma/protocol/msg-push';
|
||||||
import { resolveSelfUid, toInt } from './shared';
|
import { resolveSelfUid, toInt } from './shared';
|
||||||
|
|
||||||
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
// FriendApi — facade over friend-roster OIDB cmds. Every method is a
|
// FriendApi — facade over friend-roster OIDB cmds. Every method is a
|
||||||
// one-line forwarder to a self-contained namespace under
|
// one-line forwarder to a self-contained namespace under
|
||||||
// @snowluma/bridge/oidb-services/friend. The `delete()` facade method
|
// @snowluma/protocol/oidb-services/friend. The `delete()` facade method
|
||||||
// adds a best-effort friend-list cache invalidation after the OIDB
|
// adds a best-effort friend-list cache invalidation after the OIDB
|
||||||
// call succeeds — that side-effect stays on the facade because it
|
// call succeeds — that side-effect stays on the facade because it
|
||||||
// reaches into `ctx.apis.contacts`, which the namespace deliberately
|
// reaches into `ctx.apis.contacts`, which the namespace deliberately
|
||||||
// can't see.
|
// can't see.
|
||||||
|
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import { HandleFriendRequest } from '@snowluma/bridge/oidb-services/friend/handle-friend-request';
|
import { HandleFriendRequest } from '@snowluma/protocol/oidb-services/friend/handle-friend-request';
|
||||||
import { DeleteFriend } from '@snowluma/bridge/oidb-services/friend/delete-friend';
|
import { DeleteFriend } from '@snowluma/protocol/oidb-services/friend/delete-friend';
|
||||||
import { SetFriendRemark } from '@snowluma/bridge/oidb-services/friend/set-friend-remark';
|
import { SetFriendRemark } from '@snowluma/protocol/oidb-services/friend/set-friend-remark';
|
||||||
|
|
||||||
export class FriendApi {
|
export class FriendApi {
|
||||||
constructor(private readonly ctx: BridgeContext) {}
|
constructor(private readonly ctx: BridgeContext) {}
|
||||||
|
|||||||
@@ -2,27 +2,27 @@
|
|||||||
// cmds (mute / kick / admin / card / name / title / leave / join-policy
|
// cmds (mute / kick / admin / card / name / title / leave / join-policy
|
||||||
// / add-request handling / @everyone budget). Every method is a
|
// / add-request handling / @everyone budget). Every method is a
|
||||||
// one-line forwarder to a self-contained namespace under
|
// one-line forwarder to a self-contained namespace under
|
||||||
// @snowluma/bridge/oidb-services/group-admin.
|
// @snowluma/protocol/oidb-services/group-admin.
|
||||||
//
|
//
|
||||||
// The Apis facade keeps `bridge.apis.groupAdmin.X()` as the ergonomic
|
// The Apis facade keeps `bridge.apis.groupAdmin.X()` as the ergonomic
|
||||||
// call site; the per-(cmd, subcmd) namespaces own the wire shape and
|
// call site; the per-(cmd, subcmd) namespaces own the wire shape and
|
||||||
// minimal capability surface.
|
// minimal capability surface.
|
||||||
|
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import { MuteMember } from '@snowluma/bridge/oidb-services/group-admin/mute-member';
|
import { MuteMember } from '@snowluma/protocol/oidb-services/group-admin/mute-member';
|
||||||
import { MuteAll } from '@snowluma/bridge/oidb-services/group-admin/mute-all';
|
import { MuteAll } from '@snowluma/protocol/oidb-services/group-admin/mute-all';
|
||||||
import { SetAddOption } from '@snowluma/bridge/oidb-services/group-admin/set-add-option';
|
import { SetAddOption } from '@snowluma/protocol/oidb-services/group-admin/set-add-option';
|
||||||
import { SetSearch } from '@snowluma/bridge/oidb-services/group-admin/set-search';
|
import { SetSearch } from '@snowluma/protocol/oidb-services/group-admin/set-search';
|
||||||
import { SetAddRequest } from '@snowluma/bridge/oidb-services/group-admin/set-add-request';
|
import { SetAddRequest } from '@snowluma/protocol/oidb-services/group-admin/set-add-request';
|
||||||
import { KickMember } from '@snowluma/bridge/oidb-services/group-admin/kick-member';
|
import { KickMember } from '@snowluma/protocol/oidb-services/group-admin/kick-member';
|
||||||
import { KickMembers } from '@snowluma/bridge/oidb-services/group-admin/kick-members';
|
import { KickMembers } from '@snowluma/protocol/oidb-services/group-admin/kick-members';
|
||||||
import { LeaveGroup } from '@snowluma/bridge/oidb-services/group-admin/leave-group';
|
import { LeaveGroup } from '@snowluma/protocol/oidb-services/group-admin/leave-group';
|
||||||
import { SetAdmin } from '@snowluma/bridge/oidb-services/group-admin/set-admin';
|
import { SetAdmin } from '@snowluma/protocol/oidb-services/group-admin/set-admin';
|
||||||
import { SetMemberCard } from '@snowluma/bridge/oidb-services/group-admin/set-member-card';
|
import { SetMemberCard } from '@snowluma/protocol/oidb-services/group-admin/set-member-card';
|
||||||
import { SetGroupName } from '@snowluma/bridge/oidb-services/group-admin/set-group-name';
|
import { SetGroupName } from '@snowluma/protocol/oidb-services/group-admin/set-group-name';
|
||||||
import { SetSpecialTitle } from '@snowluma/bridge/oidb-services/group-admin/set-special-title';
|
import { SetSpecialTitle } from '@snowluma/protocol/oidb-services/group-admin/set-special-title';
|
||||||
import { SetGroupRemark } from '@snowluma/bridge/oidb-services/group-admin/set-group-remark';
|
import { SetGroupRemark } from '@snowluma/protocol/oidb-services/group-admin/set-group-remark';
|
||||||
import { GetAtAllRemain } from '@snowluma/bridge/oidb-services/group-admin/get-at-all-remain';
|
import { GetAtAllRemain } from '@snowluma/protocol/oidb-services/group-admin/get-at-all-remain';
|
||||||
|
|
||||||
export class GroupAdminApi {
|
export class GroupAdminApi {
|
||||||
constructor(private readonly ctx: BridgeContext) {}
|
constructor(private readonly ctx: BridgeContext) {}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/group-album';
|
} from '@snowluma/proto-defs/oidb-actions/group-album';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import type { Bridge } from '../bridge';
|
import type { Bridge } from '../bridge';
|
||||||
import { getGroupAlbumList, uploadImageToGroupAlbum } from '@snowluma/bridge/web/group-album';
|
import { getGroupAlbumList, uploadImageToGroupAlbum } from '@snowluma/protocol/web/group-album';
|
||||||
// `getCookies` is part of WebApi — go through the hub so we don't
|
// `getCookies` is part of WebApi — go through the hub so we don't
|
||||||
// duplicate the cookie acquisition flow.
|
// duplicate the cookie acquisition flow.
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// download URL resolvers.
|
// download URL resolvers.
|
||||||
//
|
//
|
||||||
// Single-OIDB-call methods are one-line forwarders to namespaces
|
// Single-OIDB-call methods are one-line forwarders to namespaces
|
||||||
// under @snowluma/bridge/oidb-services/group-file. The multi-stage
|
// under @snowluma/protocol/oidb-services/group-file. The multi-stage
|
||||||
// methods (`upload` / `uploadPrivate`) stay here because they
|
// methods (`upload` / `uploadPrivate`) stay here because they
|
||||||
// orchestrate three discrete legs (OIDB preflight → highway PUT →
|
// orchestrate three discrete legs (OIDB preflight → highway PUT →
|
||||||
// follow-on OIDB publish or message send) plus the upload-cache
|
// follow-on OIDB publish or message send) plus the upload-cache
|
||||||
@@ -13,28 +13,28 @@ import { toHexUpper } from '@snowluma/common/hex';
|
|||||||
import { createLogger } from '@snowluma/common/logger';
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import type { Bridge } from '../bridge';
|
import type { Bridge } from '../bridge';
|
||||||
import { fetchHighwaySession, uploadHighwayHttp } from '@snowluma/bridge/highway';
|
import { fetchHighwaySession, uploadHighwayHttp } from '@snowluma/protocol/highway';
|
||||||
import { computeHashes, computeMd5, FILE_UPLOAD_MAX_BYTES, loadBinarySource } from '@snowluma/bridge/highway/utils';
|
import { computeHashes, computeMd5, FILE_UPLOAD_MAX_BYTES, loadBinarySource } from '@snowluma/protocol/highway/utils';
|
||||||
import type { FileUploadExt } from '@snowluma/proto-defs/highway';
|
import type { FileUploadExt } from '@snowluma/proto-defs/highway';
|
||||||
import { resolveSelfUid, toInt, type MediaIndexNode } from './shared';
|
import { resolveSelfUid, toInt, type MediaIndexNode } from './shared';
|
||||||
|
|
||||||
import { PublishGroupFile } from '@snowluma/bridge/oidb-services/group-file/publish-group-file';
|
import { PublishGroupFile } from '@snowluma/protocol/oidb-services/group-file/publish-group-file';
|
||||||
import { GetGroupFileCount } from '@snowluma/bridge/oidb-services/group-file/get-group-file-count';
|
import { GetGroupFileCount } from '@snowluma/protocol/oidb-services/group-file/get-group-file-count';
|
||||||
import { UploadGroupFileRequest } from '@snowluma/bridge/oidb-services/group-file/upload-group-file-request';
|
import { UploadGroupFileRequest } from '@snowluma/protocol/oidb-services/group-file/upload-group-file-request';
|
||||||
import { UploadPrivateFileRequest } from '@snowluma/bridge/oidb-services/group-file/upload-private-file-request';
|
import { UploadPrivateFileRequest } from '@snowluma/protocol/oidb-services/group-file/upload-private-file-request';
|
||||||
import { ListGroupFilesPage } from '@snowluma/bridge/oidb-services/group-file/list-group-files-page';
|
import { ListGroupFilesPage } from '@snowluma/protocol/oidb-services/group-file/list-group-files-page';
|
||||||
import { GetGroupFileUrl } from '@snowluma/bridge/oidb-services/group-file/get-group-file-url';
|
import { GetGroupFileUrl } from '@snowluma/protocol/oidb-services/group-file/get-group-file-url';
|
||||||
import { GetPrivateFileUrl } from '@snowluma/bridge/oidb-services/group-file/get-private-file-url';
|
import { GetPrivateFileUrl } from '@snowluma/protocol/oidb-services/group-file/get-private-file-url';
|
||||||
import { DeleteGroupFile } from '@snowluma/bridge/oidb-services/group-file/delete-group-file';
|
import { DeleteGroupFile } from '@snowluma/protocol/oidb-services/group-file/delete-group-file';
|
||||||
import { MoveGroupFile } from '@snowluma/bridge/oidb-services/group-file/move-group-file';
|
import { MoveGroupFile } from '@snowluma/protocol/oidb-services/group-file/move-group-file';
|
||||||
import { CreateGroupFolder } from '@snowluma/bridge/oidb-services/group-file/create-group-folder';
|
import { CreateGroupFolder } from '@snowluma/protocol/oidb-services/group-file/create-group-folder';
|
||||||
import { DeleteGroupFolder } from '@snowluma/bridge/oidb-services/group-file/delete-group-folder';
|
import { DeleteGroupFolder } from '@snowluma/protocol/oidb-services/group-file/delete-group-folder';
|
||||||
import { RenameGroupFolder } from '@snowluma/bridge/oidb-services/group-file/rename-group-folder';
|
import { RenameGroupFolder } from '@snowluma/protocol/oidb-services/group-file/rename-group-folder';
|
||||||
import { GetGroupPttUrl } from '@snowluma/bridge/oidb-services/group-file/get-group-ptt-url';
|
import { GetGroupPttUrl } from '@snowluma/protocol/oidb-services/group-file/get-group-ptt-url';
|
||||||
import { GetPrivatePttUrl } from '@snowluma/bridge/oidb-services/group-file/get-private-ptt-url';
|
import { GetPrivatePttUrl } from '@snowluma/protocol/oidb-services/group-file/get-private-ptt-url';
|
||||||
import { GetGroupVideoUrl } from '@snowluma/bridge/oidb-services/group-file/get-group-video-url';
|
import { GetGroupVideoUrl } from '@snowluma/protocol/oidb-services/group-file/get-group-video-url';
|
||||||
import { GetPrivateVideoUrl } from '@snowluma/bridge/oidb-services/group-file/get-private-video-url';
|
import { GetPrivateVideoUrl } from '@snowluma/protocol/oidb-services/group-file/get-private-video-url';
|
||||||
import { ensureRetCodeZero } from '@snowluma/bridge/oidb-services/shared';
|
import { ensureRetCodeZero } from '@snowluma/protocol/oidb-services/shared';
|
||||||
|
|
||||||
const log = createLogger('GroupFile');
|
const log = createLogger('GroupFile');
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
// InteractionApi — facade over interactive-engagement OIDB cmds
|
// InteractionApi — facade over interactive-engagement OIDB cmds
|
||||||
// (poke / like / reaction / essence / emoji-like-list). Every method
|
// (poke / like / reaction / essence / emoji-like-list). Every method
|
||||||
// is a one-line forwarder to a self-contained namespace under
|
// is a one-line forwarder to a self-contained namespace under
|
||||||
// @snowluma/bridge/oidb-services. The facade exists purely to keep
|
// @snowluma/protocol/oidb-services. The facade exists purely to keep
|
||||||
// the `bridge.apis.interaction.X(...)` ergonomic call style; all wire
|
// the `bridge.apis.interaction.X(...)` ergonomic call style; all wire
|
||||||
// work (envelope build / encode / send / decode) lives in the
|
// work (envelope build / encode / send / decode) lives in the
|
||||||
// namespace files.
|
// namespace files.
|
||||||
|
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import { SendPoke } from '@snowluma/bridge/oidb-services/interaction/send-poke';
|
import { SendPoke } from '@snowluma/protocol/oidb-services/interaction/send-poke';
|
||||||
import { SendLike } from '@snowluma/bridge/oidb-services/interaction/send-like';
|
import { SendLike } from '@snowluma/protocol/oidb-services/interaction/send-like';
|
||||||
import { SetEssence } from '@snowluma/bridge/oidb-services/interaction/set-essence';
|
import { SetEssence } from '@snowluma/protocol/oidb-services/interaction/set-essence';
|
||||||
import { SetReaction } from '@snowluma/bridge/oidb-services/reaction/set-reaction';
|
import { SetReaction } from '@snowluma/protocol/oidb-services/reaction/set-reaction';
|
||||||
import { FetchReactionSummary } from '@snowluma/bridge/oidb-services/reaction/fetch-reaction-summary';
|
import { FetchReactionSummary } from '@snowluma/protocol/oidb-services/reaction/fetch-reaction-summary';
|
||||||
import { GetEmojiLikes } from '@snowluma/bridge/oidb-services/reaction/get-emoji-likes';
|
import { GetEmojiLikes } from '@snowluma/protocol/oidb-services/reaction/get-emoji-likes';
|
||||||
|
|
||||||
export class InteractionApi {
|
export class InteractionApi {
|
||||||
constructor(private readonly ctx: BridgeContext) {}
|
constructor(private readonly ctx: BridgeContext) {}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import type {
|
|||||||
GroupRecallRequest,
|
GroupRecallRequest,
|
||||||
SsoReadedReportReq,
|
SsoReadedReportReq,
|
||||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
import { buildSendElems } from '@snowluma/bridge/element-builder';
|
import { buildSendElems } from '@snowluma/protocol/element-builder';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
// `Bridge` is imported as a type only so we can narrow `ctx` back to
|
// `Bridge` is imported as a type only so we can narrow `ctx` back to
|
||||||
// the concrete Bridge instance when passing it to `buildSendElems`
|
// the concrete Bridge instance when passing it to `buildSendElems`
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
// Migrated OIDB cmds — facade methods are one-line forwarders.
|
// Migrated OIDB cmds — facade methods are one-line forwarders.
|
||||||
import { TranslateEnToZh } from '@snowluma/bridge/oidb-services/misc/translate-en-to-zh';
|
import { TranslateEnToZh } from '@snowluma/protocol/oidb-services/misc/translate-en-to-zh';
|
||||||
import { ClickInlineKeyboardButton } from '@snowluma/bridge/oidb-services/misc/click-inline-keyboard-button';
|
import { ClickInlineKeyboardButton } from '@snowluma/protocol/oidb-services/misc/click-inline-keyboard-button';
|
||||||
import { SendGroupSign } from '@snowluma/bridge/oidb-services/misc/send-group-sign';
|
import { SendGroupSign } from '@snowluma/protocol/oidb-services/misc/send-group-sign';
|
||||||
|
|
||||||
export class MiscApi {
|
export class MiscApi {
|
||||||
constructor(private readonly ctx: BridgeContext) {}
|
constructor(private readonly ctx: BridgeContext) {}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import type { Bridge } from '../bridge';
|
import type { Bridge } from '../bridge';
|
||||||
import { fetchHighwaySession, uploadHighwayHttp } from '@snowluma/bridge/highway';
|
import { fetchHighwaySession, uploadHighwayHttp } from '@snowluma/protocol/highway';
|
||||||
import { computeHashes, loadBinarySource } from '@snowluma/bridge/highway/utils';
|
import { computeHashes, loadBinarySource } from '@snowluma/protocol/highway/utils';
|
||||||
// Migrated OIDB cmds — facade methods are one-line forwarders.
|
// Migrated OIDB cmds — facade methods are one-line forwarders.
|
||||||
import { SetProfile } from '@snowluma/bridge/oidb-services/profile/set-profile';
|
import { SetProfile } from '@snowluma/protocol/oidb-services/profile/set-profile';
|
||||||
import { SetSelfLongNick } from '@snowluma/bridge/oidb-services/profile/set-self-long-nick';
|
import { SetSelfLongNick } from '@snowluma/protocol/oidb-services/profile/set-self-long-nick';
|
||||||
import { SetInputStatus } from '@snowluma/bridge/oidb-services/profile/set-input-status';
|
import { SetInputStatus } from '@snowluma/protocol/oidb-services/profile/set-input-status';
|
||||||
import { GetLike } from '@snowluma/bridge/oidb-services/profile/get-like';
|
import { GetLike } from '@snowluma/protocol/oidb-services/profile/get-like';
|
||||||
import { GetUnidirectionalFriendList } from '@snowluma/bridge/oidb-services/profile/get-unidirectional-friend-list';
|
import { GetUnidirectionalFriendList } from '@snowluma/protocol/oidb-services/profile/get-unidirectional-friend-list';
|
||||||
|
|
||||||
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,19 @@
|
|||||||
|
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import type { Bridge } from '../bridge';
|
import type { Bridge } from '../bridge';
|
||||||
import { getGroupEssenceMsg, getGroupEssenceMsgAll } from '@snowluma/bridge/web/group-essence';
|
import { getGroupEssenceMsg, getGroupEssenceMsgAll } from '@snowluma/protocol/web/group-essence';
|
||||||
import { getHonorListWebAPI, WebHonorType } from '@snowluma/bridge/web/group-honor';
|
import { getHonorListWebAPI, WebHonorType } from '@snowluma/protocol/web/group-honor';
|
||||||
import {
|
import {
|
||||||
deleteGroupNotice as deleteGroupNoticeHttp,
|
deleteGroupNotice as deleteGroupNoticeHttp,
|
||||||
getGroupNoticeWebAPI,
|
getGroupNoticeWebAPI,
|
||||||
setGroupNoticeWebAPI,
|
setGroupNoticeWebAPI,
|
||||||
uploadGroupNoticeImage,
|
uploadGroupNoticeImage,
|
||||||
} from '@snowluma/bridge/web/group-notice';
|
} from '@snowluma/protocol/web/group-notice';
|
||||||
import { RequestUtil } from '@snowluma/bridge/web/request-util';
|
import { RequestUtil } from '@snowluma/protocol/web/request-util';
|
||||||
// Migrated OIDB cmds — the two private helpers below are thin
|
// Migrated OIDB cmds — the two private helpers below are thin
|
||||||
// forwarders into the namespaces.
|
// forwarders into the namespaces.
|
||||||
import { ForceFetchClientKey, type ClientKeyInfo as NamespaceClientKeyInfo } from '@snowluma/bridge/oidb-services/web/force-fetch-client-key';
|
import { ForceFetchClientKey, type ClientKeyInfo as NamespaceClientKeyInfo } from '@snowluma/protocol/oidb-services/web/force-fetch-client-key';
|
||||||
import { GetPskey } from '@snowluma/bridge/oidb-services/web/get-pskey';
|
import { GetPskey } from '@snowluma/protocol/oidb-services/web/get-pskey';
|
||||||
|
|
||||||
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Api-layer extension of @snowluma/bridge's slim BridgeContext.
|
// Api-layer extension of @snowluma/protocol's slim BridgeContext.
|
||||||
//
|
//
|
||||||
// The slim interface in @snowluma/bridge has the protocol-layer
|
// The slim interface in @snowluma/protocol has the protocol-layer
|
||||||
// surface (identity / events / sendRawPacket / resolveUserUid / next*
|
// surface (identity / events / sendRawPacket / resolveUserUid / next*
|
||||||
// sequence helpers / upload-metadata cache). This file extends it
|
// sequence helpers / upload-metadata cache). This file extends it
|
||||||
// with `apis: ApiHub` — the typed bag of Api classes that lives ONLY
|
// with `apis: ApiHub` — the typed bag of Api classes that lives ONLY
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
// The 13 Api classes (apis/<area>.ts) import `BridgeContext` from
|
// The 13 Api classes (apis/<area>.ts) import `BridgeContext` from
|
||||||
// here, which gives them `this.ctx.apis.message.sendGroup(...)` type-
|
// here, which gives them `this.ctx.apis.message.sendGroup(...)` type-
|
||||||
// safety alongside the protocol-layer fields. Highway uploaders,
|
// safety alongside the protocol-layer fields. Highway uploaders,
|
||||||
// element-builder, msg-push parsers (all in @snowluma/bridge) import
|
// element-builder, msg-push parsers (all in @snowluma/protocol) import
|
||||||
// the slim version directly from `@snowluma/bridge/bridge-context`.
|
// the slim version directly from `@snowluma/protocol/bridge-context`.
|
||||||
|
|
||||||
import type { BridgeContext as BaseBridgeContext } from '@snowluma/bridge/bridge-context';
|
import type { BridgeContext as BaseBridgeContext } from '@snowluma/protocol/bridge-context';
|
||||||
import type { ApiHub } from './apis';
|
import type { ApiHub } from './apis';
|
||||||
|
|
||||||
export interface BridgeContext extends BaseBridgeContext {
|
export interface BridgeContext extends BaseBridgeContext {
|
||||||
@@ -24,4 +24,4 @@ export interface BridgeContext extends BaseBridgeContext {
|
|||||||
// `import type { UploadedFileMeta } from '<…>/bridge-context'` (or
|
// `import type { UploadedFileMeta } from '<…>/bridge-context'` (or
|
||||||
// from bridge.ts via re-export) keeps working without callers having
|
// from bridge.ts via re-export) keeps working without callers having
|
||||||
// to learn the new package path.
|
// to learn the new package path.
|
||||||
export type { UploadedFileMeta } from '@snowluma/bridge/bridge-context';
|
export type { UploadedFileMeta } from '@snowluma/protocol/bridge-context';
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { PacketSender, SendPacketResult } from '@snowluma/common/packet-sender';
|
import type { PacketSender, SendPacketResult } from '@snowluma/common/packet-sender';
|
||||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||||
import type { BridgeInterface } from './bridge-interface';
|
import type { BridgeInterface } from './bridge-interface';
|
||||||
import { IdentityService } from '@snowluma/bridge/identity-service';
|
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||||
import { MSG_PUSH_CMD, parseMsgPush } from '@snowluma/bridge/msg-push';
|
import { MSG_PUSH_CMD, parseMsgPush } from '@snowluma/protocol/msg-push';
|
||||||
import { IncomingPacketPipeline, type CmdParser } from '@snowluma/bridge/packet-pipeline';
|
import { IncomingPacketPipeline, type CmdParser } from '@snowluma/protocol/packet-pipeline';
|
||||||
// qq-info types are no longer used directly in this file — they live
|
// qq-info types are no longer used directly in this file — they live
|
||||||
// inside the Api classes that own those fetches (apis/contacts.ts).
|
// inside the Api classes that own those fetches (apis/contacts.ts).
|
||||||
import { type ApiHub, buildApiHub } from './apis';
|
import { type ApiHub, buildApiHub } from './apis';
|
||||||
@@ -35,7 +35,7 @@ import type { GroupFilesResult } from './apis/group-file';
|
|||||||
// actions/profile.ts removed — moved to apis/profile.ts::ProfileApi.
|
// actions/profile.ts removed — moved to apis/profile.ts::ProfileApi.
|
||||||
// `bridge-contacts.ts` removed — its 6 functions are now methods on
|
// `bridge-contacts.ts` removed — its 6 functions are now methods on
|
||||||
// `apis.contacts` (see `apis/contacts.ts::ContactsApi`).
|
// `apis.contacts` (see `apis/contacts.ts::ContactsApi`).
|
||||||
import { BridgeEventBus } from '@snowluma/bridge/event-bus';
|
import { BridgeEventBus } from '@snowluma/protocol/event-bus';
|
||||||
// web-actions/* removed — moved to apis/web.ts::WebApi.
|
// web-actions/* removed — moved to apis/web.ts::WebApi.
|
||||||
export { AiVoiceChatType };
|
export { AiVoiceChatType };
|
||||||
export type { AiVoiceCategory, StrangerStatus };
|
export type { AiVoiceCategory, StrangerStatus };
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { PacketSender } from '@snowluma/common/packet-sender';
|
|||||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
import { Bridge } from './bridge';
|
import { Bridge } from './bridge';
|
||||||
import { IdentityService } from '@snowluma/bridge/identity-service';
|
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||||
|
|
||||||
export type SessionStartedCallback = (uin: string, bridge: Bridge) => void;
|
export type SessionStartedCallback = (uin: string, bridge: Bridge) => void;
|
||||||
export type SessionClosedCallback = (uin: string) => void;
|
export type SessionClosedCallback = (uin: string) => void;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/media';
|
} from '@snowluma/proto-defs/oidb-actions/media';
|
||||||
|
|
||||||
// Post-namespace migration: ExtrasApi forwards 6 OIDB cmds through
|
// Post-namespace migration: ExtrasApi forwards 6 OIDB cmds through
|
||||||
// namespaces under @snowluma/bridge/oidb-services/extras. Tests assert
|
// namespaces under @snowluma/protocol/oidb-services/extras. Tests assert
|
||||||
// against bridge.sendRawPacket directly.
|
// against bridge.sendRawPacket directly.
|
||||||
import { ExtrasApi, AiVoiceChatType } from '../../src/bridge/apis/extras';
|
import { ExtrasApi, AiVoiceChatType } from '../../src/bridge/apis/extras';
|
||||||
import { mockBridge } from './_helpers';
|
import { mockBridge } from './_helpers';
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
import { describe, it, expect, vi } from 'vitest';
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/bridge-oidb', () => ({
|
vi.mock('@snowluma/protocol/bridge-oidb', () => ({
|
||||||
runOidb: vi.fn(async () => new Uint8Array()),
|
runOidb: vi.fn(async () => new Uint8Array()),
|
||||||
makeOidbEnvelope: vi.fn((_oidbCmd, _subCmd, body) => ({ body })),
|
makeOidbEnvelope: vi.fn((_oidbCmd, _subCmd, body) => ({ body })),
|
||||||
encodeOidbEnv: vi.fn(() => new Uint8Array()),
|
encodeOidbEnv: vi.fn(() => new Uint8Array()),
|
||||||
@@ -40,7 +40,7 @@ vi.mock('@snowluma/bridge/bridge-oidb', () => ({
|
|||||||
const { buildSendElemsMock } = vi.hoisted(() => ({
|
const { buildSendElemsMock } = vi.hoisted(() => ({
|
||||||
buildSendElemsMock: vi.fn(async (_elements: unknown[], _ctx?: Record<string, unknown>) => []),
|
buildSendElemsMock: vi.fn(async (_elements: unknown[], _ctx?: Record<string, unknown>) => []),
|
||||||
}));
|
}));
|
||||||
vi.mock('@snowluma/bridge/element-builder', () => ({
|
vi.mock('@snowluma/protocol/element-builder', () => ({
|
||||||
buildSendElems: buildSendElemsMock,
|
buildSendElems: buildSendElemsMock,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ import type { Elem } from '@snowluma/proto-defs/element';
|
|||||||
|
|
||||||
// Mock highway uploads only — they're irrelevant for text-only nodes
|
// Mock highway uploads only — they're irrelevant for text-only nodes
|
||||||
// but the import would otherwise pull in the native ffmpeg addon.
|
// but the import would otherwise pull in the native ffmpeg addon.
|
||||||
vi.mock('@snowluma/bridge/highway/image-upload', () => ({
|
vi.mock('@snowluma/protocol/highway/image-upload', () => ({
|
||||||
uploadImageMsgInfo: vi.fn(async () => new Uint8Array()),
|
uploadImageMsgInfo: vi.fn(async () => new Uint8Array()),
|
||||||
}));
|
}));
|
||||||
vi.mock('@snowluma/bridge/highway/ptt-upload', () => ({
|
vi.mock('@snowluma/protocol/highway/ptt-upload', () => ({
|
||||||
uploadPttMsgInfo: vi.fn(async () => new Uint8Array()),
|
uploadPttMsgInfo: vi.fn(async () => new Uint8Array()),
|
||||||
}));
|
}));
|
||||||
vi.mock('@snowluma/bridge/highway/video-upload', () => ({
|
vi.mock('@snowluma/protocol/highway/video-upload', () => ({
|
||||||
uploadVideoMsgInfo: vi.fn(async () => new Uint8Array()),
|
uploadVideoMsgInfo: vi.fn(async () => new Uint8Array()),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect, vi } from 'vitest';
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/bridge-oidb', () => ({
|
vi.mock('@snowluma/protocol/bridge-oidb', () => ({
|
||||||
runOidb: vi.fn(async () => new Uint8Array()),
|
runOidb: vi.fn(async () => new Uint8Array()),
|
||||||
makeOidbEnvelope: vi.fn((_oidbCmd, _subCmd, body) => ({ body })),
|
makeOidbEnvelope: vi.fn((_oidbCmd, _subCmd, body) => ({ body })),
|
||||||
encodeOidbEnv: vi.fn(() => new Uint8Array()),
|
encodeOidbEnv: vi.fn(() => new Uint8Array()),
|
||||||
@@ -10,7 +10,7 @@ vi.mock('@snowluma/bridge/bridge-oidb', () => ({
|
|||||||
// element-builder reaches into protoEncode with element-specific schemas
|
// element-builder reaches into protoEncode with element-specific schemas
|
||||||
// that we don't want to construct manually in tests; stub it to return
|
// that we don't want to construct manually in tests; stub it to return
|
||||||
// a benign placeholder.
|
// a benign placeholder.
|
||||||
vi.mock('@snowluma/bridge/element-builder', () => ({
|
vi.mock('@snowluma/protocol/element-builder', () => ({
|
||||||
buildSendElems: vi.fn(async () => []),
|
buildSendElems: vi.fn(async () => []),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
|
|
||||||
// Post-namespace migration: FriendApi is a thin facade over the
|
// Post-namespace migration: FriendApi is a thin facade over the
|
||||||
// namespaces under @snowluma/bridge/oidb-services/friend. Tests assert
|
// namespaces under @snowluma/protocol/oidb-services/friend. Tests assert
|
||||||
// against the bridge mock's sendRawPacket directly — no need for
|
// against the bridge mock's sendRawPacket directly — no need for
|
||||||
// module-level bridge-oidb mocks anymore.
|
// module-level bridge-oidb mocks anymore.
|
||||||
import { FriendApi } from '../../src/bridge/apis/friend';
|
import { FriendApi } from '../../src/bridge/apis/friend';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
|
|
||||||
// Post-namespace migration: GroupAdminApi forwards through namespaces
|
// Post-namespace migration: GroupAdminApi forwards through namespaces
|
||||||
// under @snowluma/bridge/oidb-services/group-admin. Tests assert
|
// under @snowluma/protocol/oidb-services/group-admin. Tests assert
|
||||||
// against bridge.sendRawPacket directly — no module-level mocks.
|
// against bridge.sendRawPacket directly — no module-level mocks.
|
||||||
import { GroupAdminApi } from '../../src/bridge/apis/group-admin';
|
import { GroupAdminApi } from '../../src/bridge/apis/group-admin';
|
||||||
import { mockBridge } from './_helpers';
|
import { mockBridge } from './_helpers';
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/media';
|
} from '@snowluma/proto-defs/oidb-actions/media';
|
||||||
|
|
||||||
// Post-namespace migration: GroupFileApi forwards single-OIDB methods
|
// Post-namespace migration: GroupFileApi forwards single-OIDB methods
|
||||||
// through namespaces under @snowluma/bridge/oidb-services/group-file.
|
// through namespaces under @snowluma/protocol/oidb-services/group-file.
|
||||||
// The multi-stage methods (`upload` / `uploadPrivate`) keep their
|
// The multi-stage methods (`upload` / `uploadPrivate`) keep their
|
||||||
// orchestration on the facade; we assert against bridge.sendRawPacket
|
// orchestration on the facade; we assert against bridge.sendRawPacket
|
||||||
// directly. Highway calls (fetchHighwaySession / uploadHighwayHttp)
|
// directly. Highway calls (fetchHighwaySession / uploadHighwayHttp)
|
||||||
// and the file-source loader are still module-mocked because the
|
// and the file-source loader are still module-mocked because the
|
||||||
// facade owns those calls directly.
|
// facade owns those calls directly.
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway', () => ({
|
vi.mock('@snowluma/protocol/highway', () => ({
|
||||||
fetchHighwaySession: vi.fn(async () => ({})),
|
fetchHighwaySession: vi.fn(async () => ({})),
|
||||||
uploadHighwayHttp: vi.fn(async () => undefined),
|
uploadHighwayHttp: vi.fn(async () => undefined),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway/utils', () => ({
|
vi.mock('@snowluma/protocol/highway/utils', () => ({
|
||||||
loadBinarySource: vi.fn(async (_src: string, fallback: string) => ({
|
loadBinarySource: vi.fn(async (_src: string, fallback: string) => ({
|
||||||
bytes: new Uint8Array([1, 2, 3]),
|
bytes: new Uint8Array([1, 2, 3]),
|
||||||
fileName: `${fallback}.bin`,
|
fileName: `${fallback}.bin`,
|
||||||
@@ -37,7 +37,7 @@ vi.mock('@snowluma/bridge/highway/utils', () => ({
|
|||||||
FILE_UPLOAD_MAX_BYTES: 4 * 1024 * 1024 * 1024,
|
FILE_UPLOAD_MAX_BYTES: 4 * 1024 * 1024 * 1024,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import * as highwayClient from '@snowluma/bridge/highway';
|
import * as highwayClient from '@snowluma/protocol/highway';
|
||||||
import { GroupFileApi } from '../../src/bridge/apis/group-file';
|
import { GroupFileApi } from '../../src/bridge/apis/group-file';
|
||||||
import { mockBridge } from './_helpers';
|
import { mockBridge } from './_helpers';
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/bridge-oidb', () => ({
|
vi.mock('@snowluma/protocol/bridge-oidb', () => ({
|
||||||
runOidb: vi.fn(async () => new Uint8Array()),
|
runOidb: vi.fn(async () => new Uint8Array()),
|
||||||
makeOidbEnvelope: vi.fn((_oidbCmd, _subCmd, body) => ({ body })),
|
makeOidbEnvelope: vi.fn((_oidbCmd, _subCmd, body) => ({ body })),
|
||||||
encodeOidbEnv: vi.fn(() => new Uint8Array()),
|
encodeOidbEnv: vi.fn(() => new Uint8Array()),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import type {
|
|||||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
|
|
||||||
// Post-namespace migration: MiscApi forwards 3 OIDB cmds through
|
// Post-namespace migration: MiscApi forwards 3 OIDB cmds through
|
||||||
// @snowluma/bridge/oidb-services/misc namespaces. The non-OIDB
|
// @snowluma/protocol/oidb-services/misc namespaces. The non-OIDB
|
||||||
// `getMiniAppArk` (LightAppSvc) stays inline on the facade. Tests
|
// `getMiniAppArk` (LightAppSvc) stays inline on the facade. Tests
|
||||||
// hit bridge.sendRawPacket directly.
|
// hit bridge.sendRawPacket directly.
|
||||||
import { MiscApi } from '../../src/bridge/apis/misc';
|
import { MiscApi } from '../../src/bridge/apis/misc';
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import type {
|
|||||||
// the module object is a no-op — proton has already inlined the call.
|
// the module object is a no-op — proton has already inlined the call.
|
||||||
// We mock `runOidb` (non-generic) to return real proton-encoded bytes
|
// We mock `runOidb` (non-generic) to return real proton-encoded bytes
|
||||||
// that the production-side codec actually decodes.
|
// that the production-side codec actually decodes.
|
||||||
vi.mock('@snowluma/bridge/bridge-oidb', async () => {
|
vi.mock('@snowluma/protocol/bridge-oidb', async () => {
|
||||||
const actual = await vi.importActual<typeof import('@snowluma/bridge/bridge-oidb')>(
|
const actual = await vi.importActual<typeof import('@snowluma/protocol/bridge-oidb')>(
|
||||||
'@snowluma/bridge/bridge-oidb',
|
'@snowluma/protocol/bridge-oidb',
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...actual,
|
...actual,
|
||||||
@@ -25,19 +25,19 @@ vi.mock('@snowluma/bridge/bridge-oidb', async () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway', () => ({
|
vi.mock('@snowluma/protocol/highway', () => ({
|
||||||
fetchHighwaySession: vi.fn(async () => ({})),
|
fetchHighwaySession: vi.fn(async () => ({})),
|
||||||
uploadHighwayHttp: vi.fn(async () => undefined),
|
uploadHighwayHttp: vi.fn(async () => undefined),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway/utils', () => ({
|
vi.mock('@snowluma/protocol/highway/utils', () => ({
|
||||||
loadBinarySource: vi.fn(async () => ({ bytes: new Uint8Array([1, 2, 3]), fileName: 'avatar.bin' })),
|
loadBinarySource: vi.fn(async () => ({ bytes: new Uint8Array([1, 2, 3]), fileName: 'avatar.bin' })),
|
||||||
computeHashes: vi.fn(() => ({ md5: new Uint8Array(16), sha1: new Uint8Array(20) })),
|
computeHashes: vi.fn(() => ({ md5: new Uint8Array(16), sha1: new Uint8Array(20) })),
|
||||||
computeMd5: vi.fn(() => new Uint8Array(16)),
|
computeMd5: vi.fn(() => new Uint8Array(16)),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import * as oidb from '@snowluma/bridge/bridge-oidb';
|
import * as oidb from '@snowluma/protocol/bridge-oidb';
|
||||||
import * as highwayClient from '@snowluma/bridge/highway';
|
import * as highwayClient from '@snowluma/protocol/highway';
|
||||||
import { ProfileApi } from '../../src/bridge/apis/profile';
|
import { ProfileApi } from '../../src/bridge/apis/profile';
|
||||||
import { mockBridge } from './_helpers';
|
import { mockBridge } from './_helpers';
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ describe('apis/profile', () => {
|
|||||||
|
|
||||||
it('setGroupAvatar rejects an empty file before hitting highway', async () => {
|
it('setGroupAvatar rejects an empty file before hitting highway', async () => {
|
||||||
const bridge = mockBridge();
|
const bridge = mockBridge();
|
||||||
const { loadBinarySource } = await import('@snowluma/bridge/highway/utils');
|
const { loadBinarySource } = await import('@snowluma/protocol/highway/utils');
|
||||||
vi.mocked(loadBinarySource).mockResolvedValueOnce({
|
vi.mocked(loadBinarySource).mockResolvedValueOnce({
|
||||||
bytes: new Uint8Array(0), fileName: 'empty.png',
|
bytes: new Uint8Array(0), fileName: 'empty.png',
|
||||||
} as any);
|
} as any);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, expect, it, vi } from 'vitest';
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
import { BridgeEventBus } from '@snowluma/bridge/event-bus';
|
import { BridgeEventBus } from '@snowluma/protocol/event-bus';
|
||||||
import type { FriendMessage, GroupMessage } from '@snowluma/bridge/events';
|
import type { FriendMessage, GroupMessage } from '@snowluma/protocol/events';
|
||||||
|
|
||||||
function makeFriendMessage(): FriendMessage {
|
function makeFriendMessage(): FriendMessage {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { Bridge } from '../src/bridge/bridge';
|
import { Bridge } from '../src/bridge/bridge';
|
||||||
import { IdentityService } from '@snowluma/bridge/identity-service';
|
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||||
import type { GroupMemberInfo, QQGroupInfo } from '@snowluma/bridge/qq-info';
|
import type { GroupMemberInfo, QQGroupInfo } from '@snowluma/protocol/qq-info';
|
||||||
import type { GroupMemberJoin, QQEventVariant } from '@snowluma/bridge/events';
|
import type { GroupMemberJoin, QQEventVariant } from '@snowluma/protocol/events';
|
||||||
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
import type { PacketInfo } from '@snowluma/common/protocol-types';
|
||||||
|
|
||||||
const SELF_UIN = '10001';
|
const SELF_UIN = '10001';
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
|||||||
import type { SendMessageRequest, SendMessageResponse } from '@snowluma/proto-defs/action';
|
import type { SendMessageRequest, SendMessageResponse } from '@snowluma/proto-defs/action';
|
||||||
import type { FileExtra } from '@snowluma/proto-defs/message';
|
import type { FileExtra } from '@snowluma/proto-defs/message';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/element-builder', () => ({
|
vi.mock('@snowluma/protocol/element-builder', () => ({
|
||||||
buildSendElems: vi.fn(async () => [{ text: { str: 'stub media elem' } }]),
|
buildSendElems: vi.fn(async () => [{ text: { str: 'stub media elem' } }]),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('Bridge private media routing', () => {
|
describe('Bridge private media routing', () => {
|
||||||
it('includes resolved uid in the final c2c send request for media messages', async () => {
|
it('includes resolved uid in the final c2c send request for media messages', async () => {
|
||||||
const { Bridge } = await import('../src/bridge/bridge');
|
const { Bridge } = await import('../src/bridge/bridge');
|
||||||
const { IdentityService } = await import('@snowluma/bridge/identity-service');
|
const { IdentityService } = await import('@snowluma/protocol/identity-service');
|
||||||
|
|
||||||
class TestBridge extends Bridge {
|
class TestBridge extends Bridge {
|
||||||
capturedBody: Uint8Array | null = null;
|
capturedBody: Uint8Array | null = null;
|
||||||
@@ -60,7 +60,7 @@ describe('Bridge private media routing', () => {
|
|||||||
// implementation wrote c2c routing + richText.notOnlineFile +
|
// implementation wrote c2c routing + richText.notOnlineFile +
|
||||||
// c2cCmd=11 — the QQ-NT server rejected every c2c file send.
|
// c2cCmd=11 — the QQ-NT server rejected every c2c file send.
|
||||||
const { Bridge } = await import('../src/bridge/bridge');
|
const { Bridge } = await import('../src/bridge/bridge');
|
||||||
const { IdentityService } = await import('@snowluma/bridge/identity-service');
|
const { IdentityService } = await import('@snowluma/protocol/identity-service');
|
||||||
|
|
||||||
class TestBridge extends Bridge {
|
class TestBridge extends Bridge {
|
||||||
capturedBody: Uint8Array | null = null;
|
capturedBody: Uint8Array | null = null;
|
||||||
|
|||||||
@@ -17,17 +17,17 @@
|
|||||||
import { describe, expect, it, vi } from 'vitest';
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
import { inflateSync } from 'zlib';
|
import { inflateSync } from 'zlib';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway/image-upload', () => ({
|
vi.mock('@snowluma/protocol/highway/image-upload', () => ({
|
||||||
uploadImageMsgInfo: vi.fn(async () => new Uint8Array([7, 8, 9])),
|
uploadImageMsgInfo: vi.fn(async () => new Uint8Array([7, 8, 9])),
|
||||||
}));
|
}));
|
||||||
vi.mock('@snowluma/bridge/highway/ptt-upload', () => ({
|
vi.mock('@snowluma/protocol/highway/ptt-upload', () => ({
|
||||||
uploadPttMsgInfo: vi.fn(async () => new Uint8Array([4, 5, 6])),
|
uploadPttMsgInfo: vi.fn(async () => new Uint8Array([4, 5, 6])),
|
||||||
}));
|
}));
|
||||||
vi.mock('@snowluma/bridge/highway/video-upload', () => ({
|
vi.mock('@snowluma/protocol/highway/video-upload', () => ({
|
||||||
uploadVideoMsgInfo: vi.fn(async () => new Uint8Array([1, 2, 3])),
|
uploadVideoMsgInfo: vi.fn(async () => new Uint8Array([1, 2, 3])),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import { buildSendElems } from '@snowluma/bridge/element-builder';
|
import { buildSendElems } from '@snowluma/protocol/element-builder';
|
||||||
|
|
||||||
const fakeBridge = {} as any;
|
const fakeBridge = {} as any;
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import {
|
|||||||
formatMessageSegments,
|
formatMessageSegments,
|
||||||
formatReply,
|
formatReply,
|
||||||
formatUser,
|
formatUser,
|
||||||
} from '@snowluma/bridge/format';
|
} from '@snowluma/protocol/format';
|
||||||
import type { QQEventVariant } from '@snowluma/bridge/events';
|
import type { QQEventVariant } from '@snowluma/protocol/events';
|
||||||
|
|
||||||
// ─── Test fakes (just the find* surface event-format uses) ───
|
// ─── Test fakes (just the find* surface event-format uses) ───
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import os from 'os';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { pathToFileURL } from 'url';
|
import { pathToFileURL } from 'url';
|
||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||||
import { loadBinarySource, resolveLocalFilePath } from '@snowluma/bridge/highway/utils';
|
import { loadBinarySource, resolveLocalFilePath } from '@snowluma/protocol/highway/utils';
|
||||||
|
|
||||||
describe('highway source paths', () => {
|
describe('highway source paths', () => {
|
||||||
it('normalizes file URLs with an extra leading slash on POSIX', () => {
|
it('normalizes file URLs with an extra leading slash on POSIX', () => {
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway/pipeline', () => ({
|
vi.mock('@snowluma/protocol/highway/pipeline', () => ({
|
||||||
runNtv2Upload: vi.fn(async () => ({ msgInfo: { msgInfoBody: [], extBizInfo: {} } })),
|
runNtv2Upload: vi.fn(async () => ({ msgInfo: { msgInfoBody: [], extBizInfo: {} } })),
|
||||||
finalizeMediaMsgInfo: vi.fn(() => new Uint8Array([0xCA, 0xFE])),
|
finalizeMediaMsgInfo: vi.fn(() => new Uint8Array([0xCA, 0xFE])),
|
||||||
hexToBytes: vi.fn((hex: string) => new Uint8Array(hex.length / 2)),
|
hexToBytes: vi.fn((hex: string) => new Uint8Array(hex.length / 2)),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway/utils', () => ({
|
vi.mock('@snowluma/protocol/highway/utils', () => ({
|
||||||
loadBinarySource: vi.fn(async () => ({ bytes: new Uint8Array([1, 2, 3]), fileName: 'src.jpg' })),
|
loadBinarySource: vi.fn(async () => ({ bytes: new Uint8Array([1, 2, 3]), fileName: 'src.jpg' })),
|
||||||
computeHashes: vi.fn(() => ({
|
computeHashes: vi.fn(() => ({
|
||||||
md5: new Uint8Array(16),
|
md5: new Uint8Array(16),
|
||||||
@@ -22,9 +22,9 @@ vi.mock('@snowluma/bridge/highway/utils', () => ({
|
|||||||
detectImageFormat: vi.fn(() => ({ format: 1000, width: 800, height: 600 })),
|
detectImageFormat: vi.fn(() => ({ format: 1000, width: 800, height: 600 })),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import * as pipeline from '@snowluma/bridge/highway/pipeline';
|
import * as pipeline from '@snowluma/protocol/highway/pipeline';
|
||||||
import { uploadImageMsgInfo } from '@snowluma/bridge/highway/image-upload';
|
import { uploadImageMsgInfo } from '@snowluma/protocol/highway/image-upload';
|
||||||
import { GROUP_IMAGE_CMD_ID, PRIVATE_IMAGE_CMD_ID } from '@snowluma/bridge/highway';
|
import { GROUP_IMAGE_CMD_ID, PRIVATE_IMAGE_CMD_ID } from '@snowluma/protocol/highway';
|
||||||
|
|
||||||
describe('image-upload', () => {
|
describe('image-upload', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway', async () => {
|
vi.mock('@snowluma/protocol/highway', async () => {
|
||||||
const real = await vi.importActual<typeof import('@snowluma/bridge/highway')>('@snowluma/bridge/highway');
|
const real = await vi.importActual<typeof import('@snowluma/protocol/highway')>('@snowluma/protocol/highway');
|
||||||
return {
|
return {
|
||||||
...real,
|
...real,
|
||||||
// Only the TCP/HTTP transport is mocked — we keep real
|
// Only the TCP/HTTP transport is mocked — we keep real
|
||||||
@@ -40,8 +40,8 @@ vi.mock('@snowluma/bridge/highway', async () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
import * as highway from '@snowluma/bridge/highway';
|
import * as highway from '@snowluma/protocol/highway';
|
||||||
import { runNtv2Upload, type MediaSubFileUpload } from '@snowluma/bridge/highway/pipeline';
|
import { runNtv2Upload, type MediaSubFileUpload } from '@snowluma/protocol/highway/pipeline';
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type {
|
import type {
|
||||||
NTV2UploadRichMediaReq,
|
NTV2UploadRichMediaReq,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway', () => ({
|
vi.mock('@snowluma/protocol/highway', () => ({
|
||||||
fetchHighwaySession: vi.fn(async () => ({ sessionId: 'fake-session' })),
|
fetchHighwaySession: vi.fn(async () => ({ sessionId: 'fake-session' })),
|
||||||
uploadHighwayHttp: vi.fn(async () => undefined),
|
uploadHighwayHttp: vi.fn(async () => undefined),
|
||||||
buildHighwayExtend: vi.fn(() => new Uint8Array([0xAA, 0xBB])),
|
buildHighwayExtend: vi.fn(() => new Uint8Array([0xAA, 0xBB])),
|
||||||
@@ -16,14 +16,14 @@ vi.mock('@snowluma/bridge/highway', () => ({
|
|||||||
GROUP_IMAGE_CMD_ID: 1004,
|
GROUP_IMAGE_CMD_ID: 1004,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import * as highway from '@snowluma/bridge/highway';
|
import * as highway from '@snowluma/protocol/highway';
|
||||||
import {
|
import {
|
||||||
finalizeMediaMsgInfo,
|
finalizeMediaMsgInfo,
|
||||||
hexToBytes,
|
hexToBytes,
|
||||||
makeClientRandomId,
|
makeClientRandomId,
|
||||||
runNtv2Upload,
|
runNtv2Upload,
|
||||||
type MediaSubFileUpload,
|
type MediaSubFileUpload,
|
||||||
} from '@snowluma/bridge/highway/pipeline';
|
} from '@snowluma/protocol/highway/pipeline';
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { EncodableMediaMsgInfo, NTV2UploadRichMediaReq, NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
import type { EncodableMediaMsgInfo, NTV2UploadRichMediaReq, NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway/pipeline', () => ({
|
vi.mock('@snowluma/protocol/highway/pipeline', () => ({
|
||||||
runNtv2Upload: vi.fn(async () => ({ msgInfo: { msgInfoBody: [], extBizInfo: {} } })),
|
runNtv2Upload: vi.fn(async () => ({ msgInfo: { msgInfoBody: [], extBizInfo: {} } })),
|
||||||
finalizeMediaMsgInfo: vi.fn(() => new Uint8Array([0xAA, 0xBB])),
|
finalizeMediaMsgInfo: vi.fn(() => new Uint8Array([0xAA, 0xBB])),
|
||||||
hexToBytes: vi.fn((hex: string) => new Uint8Array(hex.length / 2)),
|
hexToBytes: vi.fn((hex: string) => new Uint8Array(hex.length / 2)),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import * as pipeline from '@snowluma/bridge/highway/pipeline';
|
import * as pipeline from '@snowluma/protocol/highway/pipeline';
|
||||||
import { uploadPttMsgInfo, GROUP_PTT_CMD_ID, PRIVATE_PTT_CMD_ID } from '@snowluma/bridge/highway/ptt-upload';
|
import { uploadPttMsgInfo, GROUP_PTT_CMD_ID, PRIVATE_PTT_CMD_ID } from '@snowluma/protocol/highway/ptt-upload';
|
||||||
|
|
||||||
const FINGERPRINT = {
|
const FINGERPRINT = {
|
||||||
noByteFallback: true,
|
noByteFallback: true,
|
||||||
|
|||||||
@@ -11,20 +11,20 @@
|
|||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway/pipeline', () => ({
|
vi.mock('@snowluma/protocol/highway/pipeline', () => ({
|
||||||
runNtv2Upload: vi.fn(async () => ({ msgInfo: { msgInfoBody: [], extBizInfo: {} } })),
|
runNtv2Upload: vi.fn(async () => ({ msgInfo: { msgInfoBody: [], extBizInfo: {} } })),
|
||||||
finalizeMediaMsgInfo: vi.fn(() => new Uint8Array([0x12, 0x34])),
|
finalizeMediaMsgInfo: vi.fn(() => new Uint8Array([0x12, 0x34])),
|
||||||
hexToBytes: vi.fn((hex: string) => new Uint8Array(hex.length / 2)),
|
hexToBytes: vi.fn((hex: string) => new Uint8Array(hex.length / 2)),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import * as pipeline from '@snowluma/bridge/highway/pipeline';
|
import * as pipeline from '@snowluma/protocol/highway/pipeline';
|
||||||
import {
|
import {
|
||||||
uploadVideoMsgInfo,
|
uploadVideoMsgInfo,
|
||||||
GROUP_VIDEO_CMD_ID,
|
GROUP_VIDEO_CMD_ID,
|
||||||
GROUP_VIDEO_THUMB_CMD_ID,
|
GROUP_VIDEO_THUMB_CMD_ID,
|
||||||
PRIVATE_VIDEO_CMD_ID,
|
PRIVATE_VIDEO_CMD_ID,
|
||||||
PRIVATE_VIDEO_THUMB_CMD_ID,
|
PRIVATE_VIDEO_THUMB_CMD_ID,
|
||||||
} from '@snowluma/bridge/highway/video-upload';
|
} from '@snowluma/protocol/highway/video-upload';
|
||||||
|
|
||||||
const FINGERPRINT = {
|
const FINGERPRINT = {
|
||||||
noByteFallback: true,
|
noByteFallback: true,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { IdentityService } from '@snowluma/bridge/identity-service';
|
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||||
import type { GroupMemberInfo, QQGroupInfo, UserProfileInfo } from '@snowluma/bridge/qq-info';
|
import type { GroupMemberInfo, QQGroupInfo, UserProfileInfo } from '@snowluma/protocol/qq-info';
|
||||||
|
|
||||||
const SELF_UIN = '10001';
|
const SELF_UIN = '10001';
|
||||||
const GROUP_ID = 123456789;
|
const GROUP_ID = 123456789;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { protobuf_encode } from '@snowluma/proton';
|
import { protobuf_encode } from '@snowluma/proton';
|
||||||
import { parseMsgPush, MSG_PUSH_CMD } from '@snowluma/bridge/msg-push';
|
import { parseMsgPush, MSG_PUSH_CMD } from '@snowluma/protocol/msg-push';
|
||||||
import { IdentityService } from '@snowluma/bridge/identity-service';
|
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||||
import type { GroupMemberInfo, QQGroupInfo } from '@snowluma/bridge/qq-info';
|
import type { GroupMemberInfo, QQGroupInfo } from '@snowluma/protocol/qq-info';
|
||||||
// Proton's call-site analyzer keys off the literal type identifier
|
// Proton's call-site analyzer keys off the literal type identifier
|
||||||
// printed in `protobuf_encode<X>` — it walks imports by *original*
|
// printed in `protobuf_encode<X>` — it walks imports by *original*
|
||||||
// name (not alias). If both `import { X } from 'proto/notify'` and
|
// name (not alias). If both `import { X } from 'proto/notify'` and
|
||||||
@@ -18,7 +18,7 @@ import type {
|
|||||||
import type { PushMsg } from '@snowluma/proto-defs/message';
|
import type { PushMsg } from '@snowluma/proto-defs/message';
|
||||||
import type {
|
import type {
|
||||||
GroupMemberJoin, FriendAddEvent, QQEventVariant,
|
GroupMemberJoin, FriendAddEvent, QQEventVariant,
|
||||||
} from '@snowluma/bridge/events';
|
} from '@snowluma/protocol/events';
|
||||||
|
|
||||||
// Local alias for the event-side recall type — derived via Extract so
|
// Local alias for the event-side recall type — derived via Extract so
|
||||||
// we avoid an `import { FriendRecall as X }` that collides with the
|
// we avoid an `import { FriendRecall as X }` that collides with the
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|||||||
import { protobuf_encode } from '@snowluma/proton';
|
import { protobuf_encode } from '@snowluma/proton';
|
||||||
import { subscribeLogs, type LogEntry } from '@snowluma/common/logger';
|
import { subscribeLogs, type LogEntry } from '@snowluma/common/logger';
|
||||||
|
|
||||||
vi.mock('@snowluma/bridge/highway', () => ({
|
vi.mock('@snowluma/protocol/highway', () => ({
|
||||||
fetchHighwaySession: vi.fn(async () => ({ sessionId: 'fake-session' })),
|
fetchHighwaySession: vi.fn(async () => ({ sessionId: 'fake-session' })),
|
||||||
uploadHighwayHttp: vi.fn(async () => undefined),
|
uploadHighwayHttp: vi.fn(async () => undefined),
|
||||||
buildHighwayExtend: vi.fn(() => new Uint8Array([0xAA, 0xBB])),
|
buildHighwayExtend: vi.fn(() => new Uint8Array([0xAA, 0xBB])),
|
||||||
@@ -24,12 +24,12 @@ vi.mock('@snowluma/bridge/highway', () => ({
|
|||||||
import {
|
import {
|
||||||
runNtv2Upload,
|
runNtv2Upload,
|
||||||
type MediaSubFileUpload,
|
type MediaSubFileUpload,
|
||||||
} from '@snowluma/bridge/highway/pipeline';
|
} from '@snowluma/protocol/highway/pipeline';
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
import type { NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
||||||
import { MsgPushRegistry } from '@snowluma/bridge/msg-push/registry';
|
import { MsgPushRegistry } from '@snowluma/protocol/msg-push/registry';
|
||||||
import type { MsgPushContext } from '@snowluma/bridge/msg-push/context';
|
import type { MsgPushContext } from '@snowluma/protocol/msg-push/context';
|
||||||
import { decodeEvent0x2DC } from '@snowluma/bridge/msg-push/decoders/event-0x2dc';
|
import { decodeEvent0x2DC } from '@snowluma/protocol/msg-push/decoders/event-0x2dc';
|
||||||
|
|
||||||
function encodeOidbResponse(body: unknown): Buffer {
|
function encodeOidbResponse(body: unknown): Buffer {
|
||||||
return Buffer.from(protobuf_encode<OidbBase<NTV2UploadRichMediaResp>>({
|
return Buffer.from(protobuf_encode<OidbBase<NTV2UploadRichMediaResp>>({
|
||||||
|
|||||||
@@ -86,11 +86,11 @@
|
|||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@snowluma/bridge": "workspace:*",
|
|
||||||
"@snowluma/common": "workspace:*",
|
"@snowluma/common": "workspace:*",
|
||||||
"@snowluma/core": "workspace:*",
|
"@snowluma/core": "workspace:*",
|
||||||
"@snowluma/proto-defs": "workspace:*",
|
"@snowluma/proto-defs": "workspace:*",
|
||||||
"@snowluma/proton": "workspace:*",
|
"@snowluma/proton": "workspace:*",
|
||||||
|
"@snowluma/protocol": "workspace:*",
|
||||||
"@snowluma/sqlite": "workspace:*",
|
"@snowluma/sqlite": "workspace:*",
|
||||||
"@snowluma/websocket": "workspace:*"
|
"@snowluma/websocket": "workspace:*"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { ApiHandler, ApiActionContext } from '../api-handler';
|
import type { ApiHandler, ApiActionContext } from '../api-handler';
|
||||||
import { asNumber, asBoolean, asString } from '../api-handler';
|
import { asNumber, asBoolean, asString } from '../api-handler';
|
||||||
import { RETCODE, failedResponse, okResponse } from '../types';
|
import { RETCODE, failedResponse, okResponse } from '../types';
|
||||||
import { WebHonorType } from '@snowluma/bridge/web/group-honor';
|
import { WebHonorType } from '@snowluma/protocol/web/group-honor';
|
||||||
|
|
||||||
export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||||
h.registerAction('get_group_list', async (params) => {
|
h.registerAction('get_group_list', async (params) => {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { register as registerRequest } from './actions/request';
|
|||||||
import { register as registerExtended } from './actions/extended';
|
import { register as registerExtended } from './actions/extended';
|
||||||
import { register as registerGroupAlbum } from './actions/group-album';
|
import { register as registerGroupAlbum } from './actions/group-album';
|
||||||
|
|
||||||
import { WebHonorType } from '@snowluma/bridge/web/group-honor';
|
import { WebHonorType } from '@snowluma/protocol/web/group-honor';
|
||||||
import type { ClientKeyInfo } from '@snowluma/core/bridge';
|
import type { ClientKeyInfo } from '@snowluma/core/bridge';
|
||||||
|
|
||||||
export interface MessageSendResult {
|
export interface MessageSendResult {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { MessageElement, QQEventVariant } from '@snowluma/bridge/events';
|
import type { MessageElement, QQEventVariant } from '@snowluma/protocol/events';
|
||||||
import type { JsonObject } from '../types';
|
import type { JsonObject } from '../types';
|
||||||
import {
|
import {
|
||||||
convertFriendMessage,
|
convertFriendMessage,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { QQEventVariant } from '@snowluma/bridge/events';
|
import type { QQEventVariant } from '@snowluma/protocol/events';
|
||||||
import { GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT } from '../message-id';
|
import { GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT } from '../message-id';
|
||||||
import type { JsonObject } from '../types';
|
import type { JsonObject } from '../types';
|
||||||
import type { ConverterContext } from './index';
|
import type { ConverterContext } from './index';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { QQEventVariant } from '@snowluma/bridge/events';
|
import type { QQEventVariant } from '@snowluma/protocol/events';
|
||||||
import { GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT } from '../message-id';
|
import { GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT } from '../message-id';
|
||||||
import type { JsonObject } from '../types';
|
import type { JsonObject } from '../types';
|
||||||
import type { ConverterContext } from './index';
|
import type { ConverterContext } from './index';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { QQEventVariant } from '@snowluma/bridge/events';
|
import type { QQEventVariant } from '@snowluma/protocol/events';
|
||||||
import type { JsonObject } from '../types';
|
import type { JsonObject } from '../types';
|
||||||
import type { ConverterContext } from './index';
|
import type { ConverterContext } from './index';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
import type { JsonArray, JsonObject } from '../types';
|
import type { JsonArray, JsonObject } from '../types';
|
||||||
import type {
|
import type {
|
||||||
ImageUrlResolver,
|
ImageUrlResolver,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { QQEventVariant } from '@snowluma/bridge/events';
|
import type { QQEventVariant } from '@snowluma/protocol/events';
|
||||||
import { convertEvent } from './event-converter';
|
import { convertEvent } from './event-converter';
|
||||||
import type { OneBotInstanceContext } from './instance-context';
|
import type { OneBotInstanceContext } from './instance-context';
|
||||||
import { GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT, hashMessageIdInt32 } from './message-id';
|
import { GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT, hashMessageIdInt32 } from './message-id';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { WebHonorType } from '@snowluma/bridge/web/group-honor';
|
import type { WebHonorType } from '@snowluma/protocol/web/group-honor';
|
||||||
import type { Bridge } from '@snowluma/core/bridge';
|
import type { Bridge } from '@snowluma/core/bridge';
|
||||||
import type { ApiActionContext } from './api-handler';
|
import type { ApiActionContext } from './api-handler';
|
||||||
import type { ConverterContext } from './event-converter';
|
import type { ConverterContext } from './event-converter';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
import type { DownloadRKeyInfo } from '@snowluma/core/bridge';
|
import type { DownloadRKeyInfo } from '@snowluma/core/bridge';
|
||||||
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
type NetworkAdapterContext,
|
type NetworkAdapterContext,
|
||||||
} from './network';
|
} from './network';
|
||||||
import { createLogger, type Logger } from '@snowluma/common/logger';
|
import { createLogger, type Logger } from '@snowluma/common/logger';
|
||||||
import { formatGroup, formatMessageSegments, formatReply, formatUser } from '@snowluma/bridge/format';
|
import { formatGroup, formatMessageSegments, formatReply, formatUser } from '@snowluma/protocol/format';
|
||||||
|
|
||||||
const moduleLog = createLogger('Event');
|
const moduleLog = createLogger('Event');
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// segment emitted by the event converter and writes a row into the
|
// segment emitted by the event converter and writes a row into the
|
||||||
// MediaStore so later `get_image` / `get_record` OneBot actions can
|
// MediaStore so later `get_image` / `get_record` OneBot actions can
|
||||||
|
|
||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
import type { MediaStore } from './media-store';
|
import type { MediaStore } from './media-store';
|
||||||
import type { JsonObject } from './types';
|
import type { JsonObject } from './types';
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import fs from 'fs';
|
|||||||
import Database, { type Database as DatabaseType, type Statement } from '@snowluma/sqlite';
|
import Database, { type Database as DatabaseType, type Statement } from '@snowluma/sqlite';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
|
|
||||||
export interface CachedImage {
|
export interface CachedImage {
|
||||||
/** Primary `data.file` value as exposed in the OneBot segment. */
|
/** Primary `data.file` value as exposed in the OneBot segment. */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
import type { RKeyCache } from './instance-rkey';
|
import type { RKeyCache } from './instance-rkey';
|
||||||
|
|
||||||
export class MediaUrlResolver {
|
export class MediaUrlResolver {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
import type { JsonValue } from './types';
|
import type { JsonValue } from './types';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
||||||
import type { IdentityService } from '@snowluma/bridge/identity-service';
|
import type { IdentityService } from '@snowluma/protocol/identity-service';
|
||||||
import type { OneBotInstanceContext } from '../instance-context';
|
import type { OneBotInstanceContext } from '../instance-context';
|
||||||
import type { JsonObject } from '../types';
|
import type { JsonObject } from '../types';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
||||||
import type { ForwardNodePayload, MessageElement } from '@snowluma/bridge/events';
|
import type { ForwardNodePayload, MessageElement } from '@snowluma/protocol/events';
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
import type { MessageSendResult } from '../api-handler';
|
import type { MessageSendResult } from '../api-handler';
|
||||||
import { elementsToOneBotSegments } from '../event-converter';
|
import { elementsToOneBotSegments } from '../event-converter';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Plain JSON types now live in @snowluma/common/json so @snowluma/bridge
|
// Plain JSON types now live in @snowluma/common/json so @snowluma/protocol
|
||||||
// (event-format / receive parsers) can talk about JSON payloads without
|
// (event-format / receive parsers) can talk about JSON payloads without
|
||||||
// importing OneBot. Re-exported here so the legacy import shape stays
|
// importing OneBot. Re-exported here so the legacy import shape stays
|
||||||
// supported — `import { JsonValue } from '<…>/onebot/types'` keeps working.
|
// supported — `import { JsonValue } from '<…>/onebot/types'` keeps working.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { describe, expect, it, vi } from 'vitest';
|
|||||||
import type { BridgeInterface } from '../../src/bridge/bridge-interface';
|
import type { BridgeInterface } from '../../src/bridge/bridge-interface';
|
||||||
import type {
|
import type {
|
||||||
FriendInfo, GroupMemberInfo, QQGroupInfo, UserProfileInfo,
|
FriendInfo, GroupMemberInfo, QQGroupInfo, UserProfileInfo,
|
||||||
} from '@snowluma/bridge/qq-info';
|
} from '@snowluma/protocol/qq-info';
|
||||||
import {
|
import {
|
||||||
getFriendList,
|
getFriendList,
|
||||||
getGroupInfo,
|
getGroupInfo,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import type {
|
|||||||
MessageElement,
|
MessageElement,
|
||||||
QQEventVariant,
|
QQEventVariant,
|
||||||
TempMessage,
|
TempMessage,
|
||||||
} from '@snowluma/bridge/events';
|
} from '@snowluma/protocol/events';
|
||||||
|
|
||||||
const SELF_ID = 10001;
|
const SELF_ID = 10001;
|
||||||
const PEER_UIN = 22222;
|
const PEER_UIN = 22222;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it, vi } from 'vitest';
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
import { BridgeEventBus } from '@snowluma/bridge/event-bus';
|
import { BridgeEventBus } from '@snowluma/protocol/event-bus';
|
||||||
|
|
||||||
// Wrap convertEvent in a vi.fn that delegates to the real impl by
|
// Wrap convertEvent in a vi.fn that delegates to the real impl by
|
||||||
// default, so one test can override it to return null without making
|
// default, so one test can override it to return null without making
|
||||||
@@ -18,7 +18,7 @@ import type {
|
|||||||
GroupMemberJoin,
|
GroupMemberJoin,
|
||||||
TempMessage,
|
TempMessage,
|
||||||
QQEventVariant,
|
QQEventVariant,
|
||||||
} from '@snowluma/bridge/events';
|
} from '@snowluma/protocol/events';
|
||||||
import type { JsonObject, MessageMeta } from '../src/types';
|
import type { JsonObject, MessageMeta } from '../src/types';
|
||||||
|
|
||||||
const SELF_UIN = '10001';
|
const SELF_UIN = '10001';
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||||
import { ApiHandler, type ApiActionContext } from '../src/api-handler';
|
import { ApiHandler, type ApiActionContext } from '../src/api-handler';
|
||||||
import type { BridgeInterface } from '../../src/bridge/bridge-interface';
|
import type { BridgeInterface } from '../../src/bridge/bridge-interface';
|
||||||
import type { GroupRequestInfo } from '@snowluma/bridge/qq-info';
|
import type { GroupRequestInfo } from '@snowluma/protocol/qq-info';
|
||||||
import type { MessageMeta } from '../src/types';
|
import type { MessageMeta } from '../src/types';
|
||||||
|
|
||||||
function fakeMeta(overrides: Partial<MessageMeta> = {}): MessageMeta {
|
function fakeMeta(overrides: Partial<MessageMeta> = {}): MessageMeta {
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||||
import { protobuf_encode } from '@snowluma/proton';
|
import { protobuf_encode } from '@snowluma/proton';
|
||||||
import type { GroupReactNotify } from '@snowluma/proto-defs/notify';
|
import type { GroupReactNotify } from '@snowluma/proto-defs/notify';
|
||||||
import { decodeEvent0x2DC } from '@snowluma/bridge/msg-push/decoders/event-0x2dc';
|
import { decodeEvent0x2DC } from '@snowluma/protocol/msg-push/decoders/event-0x2dc';
|
||||||
import type { MsgPushContext } from '@snowluma/bridge/msg-push/context';
|
import type { MsgPushContext } from '@snowluma/protocol/msg-push/context';
|
||||||
import { IdentityService } from '@snowluma/bridge/identity-service';
|
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||||
import type { GroupMsgEmojiLikeEvent, QQEventVariant } from '@snowluma/bridge/events';
|
import type { GroupMsgEmojiLikeEvent, QQEventVariant } from '@snowluma/protocol/events';
|
||||||
import { convertGroupMsgEmojiLike } from '../src/event-converter/to-notice';
|
import { convertGroupMsgEmojiLike } from '../src/event-converter/to-notice';
|
||||||
import { GROUP_MESSAGE_EVENT, hashMessageIdInt32 } from '../src/message-id';
|
import { GROUP_MESSAGE_EVENT, hashMessageIdInt32 } from '../src/message-id';
|
||||||
import { formatEvent } from '@snowluma/bridge/format';
|
import { formatEvent } from '@snowluma/protocol/format';
|
||||||
import { subscribeLogs, type LogEntry } from '@snowluma/common/logger';
|
import { subscribeLogs, type LogEntry } from '@snowluma/common/logger';
|
||||||
|
|
||||||
const SELF_UIN = '10001';
|
const SELF_UIN = '10001';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect, vi } from 'vitest';
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
import { MediaIndexer } from '../src/media-indexer';
|
import { MediaIndexer } from '../src/media-indexer';
|
||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
|
|
||||||
function makeMediaStore() {
|
function makeMediaStore() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { MediaStore } from '../src/media-store';
|
import { MediaStore } from '../src/media-store';
|
||||||
import { convertEvent, type ConverterContext } from '../src/event-converter';
|
import { convertEvent, type ConverterContext } from '../src/event-converter';
|
||||||
import type { GroupMessage, FriendMessage, MessageElement } from '@snowluma/bridge/events';
|
import type { GroupMessage, FriendMessage, MessageElement } from '@snowluma/protocol/events';
|
||||||
|
|
||||||
const SELF_ID = 10001;
|
const SELF_ID = 10001;
|
||||||
const PEER_UIN = 22222;
|
const PEER_UIN = 22222;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
import { MediaUrlResolver } from '../src/media-url-resolver';
|
import { MediaUrlResolver } from '../src/media-url-resolver';
|
||||||
import type { MessageElement } from '@snowluma/bridge/events';
|
import type { MessageElement } from '@snowluma/protocol/events';
|
||||||
|
|
||||||
// Minimal stand-ins for the two collaborators. Each test wires whatever
|
// Minimal stand-ins for the two collaborators. Each test wires whatever
|
||||||
// subset of Bridge methods the element type exercises.
|
// subset of Bridge methods the element type exercises.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import path from 'path';
|
|||||||
import { describe, it, expect, vi } from 'vitest';
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { parseMessage } from '../src/message-parser';
|
import { parseMessage } from '../src/message-parser';
|
||||||
import { buildSendElems } from '@snowluma/bridge/element-builder';
|
import { buildSendElems } from '@snowluma/protocol/element-builder';
|
||||||
import type { MentionExtraSend } from '@snowluma/proto-defs/action';
|
import type { MentionExtraSend } from '@snowluma/proto-defs/action';
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
import type { NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, it, vi } from 'vitest';
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
import { handleGroupAddRequest } from '../src/modules/request-actions';
|
import { handleGroupAddRequest } from '../src/modules/request-actions';
|
||||||
import type { BridgeInterface } from '../../src/bridge/bridge-interface';
|
import type { BridgeInterface } from '../../src/bridge/bridge-interface';
|
||||||
import type { GroupRequestInfo } from '@snowluma/bridge/qq-info';
|
import type { GroupRequestInfo } from '@snowluma/protocol/qq-info';
|
||||||
|
|
||||||
// See `contact-actions.test.ts` for the auto-promotion rationale.
|
// See `contact-actions.test.ts` for the auto-promotion rationale.
|
||||||
const APIS_ROUTING: Record<string, string> = {
|
const APIS_ROUTING: Record<string, string> = {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// decode + decoder + handleSideEffects (identity-service SQLite
|
// decode + decoder + handleSideEffects (identity-service SQLite
|
||||||
// writes) + event emit through BridgeEventBus.
|
// writes) + event emit through BridgeEventBus.
|
||||||
//
|
//
|
||||||
// Run via: pnpm -F @snowluma/bridge bench
|
// Run via: pnpm -F @snowluma/protocol bench
|
||||||
//
|
//
|
||||||
// Output is `tinybench` ops/sec — vitest's built-in `bench()` is just a
|
// Output is `tinybench` ops/sec — vitest's built-in `bench()` is just a
|
||||||
// thin wrapper. Run before AND after a perf commit; the delta is what
|
// thin wrapper. Run before AND after a perf commit; the delta is what
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "@snowluma/bridge",
|
"name": "@snowluma/protocol",
|
||||||
"version": "1.9.1",
|
"version": "1.9.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"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>'`.",
|
"description": "SnowLuma protocol — 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/protocol/<x>'`.",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
"types": "./src/index.ts",
|
"types": "./src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// BridgeContext — the protocol-layer surface that anything inside
|
// BridgeContext — the protocol-layer surface that anything inside
|
||||||
// @snowluma/bridge (highway uploaders, OIDB envelope helper, element
|
// @snowluma/protocol (highway uploaders, OIDB envelope helper, element
|
||||||
// builder, msg-push parsers) accepts when it needs `bridge.identity`
|
// builder, msg-push parsers) accepts when it needs `bridge.identity`
|
||||||
// or `bridge.sendRawPacket` plus the upload-metadata cache.
|
// or `bridge.sendRawPacket` plus the upload-metadata cache.
|
||||||
//
|
//
|
||||||
// Deliberately apis-less: @snowluma/bridge knows nothing about the
|
// Deliberately apis-less: @snowluma/protocol knows nothing about the
|
||||||
// `apis.<area>.method()` hub that lives in @snowluma/core, so the
|
// `apis.<area>.method()` hub that lives in @snowluma/core, so the
|
||||||
// type that bridge code accepts must NOT mention `ApiHub`. The api-
|
// type that bridge code accepts must NOT mention `ApiHub`. The api-
|
||||||
// layer's own extended context (with `apis: ApiHub`) lives at
|
// layer's own extended context (with `apis: ApiHub`) lives at
|
||||||
@@ -23,7 +23,7 @@ import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
|||||||
* succeeds. Lets the OneBot send-message path reconstruct the full
|
* succeeds. Lets the OneBot send-message path reconstruct the full
|
||||||
* payload when the caller only echoes the `file_id` back later. Lives
|
* payload when the caller only echoes the `file_id` back later. Lives
|
||||||
* here (not on @snowluma/core's `bridge.ts`) so element-builder + the
|
* here (not on @snowluma/core's `bridge.ts`) so element-builder + the
|
||||||
* forward-builder — both inside @snowluma/bridge — can read the cache
|
* forward-builder — both inside @snowluma/protocol — can read the cache
|
||||||
* without circular-importing @snowluma/core.
|
* without circular-importing @snowluma/core.
|
||||||
*/
|
*/
|
||||||
export interface UploadedFileMeta {
|
export interface UploadedFileMeta {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 238 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user