refactor(oidb): migrate group-file.ts OIDB cmds to namespaces
Splits the 16 OIDB cmds from GroupFileApi into self-contained
namespaces under @snowluma/bridge/oidb-services/group-file/. Adds
@snowluma/bridge/oidb-services/shared with `toInt` / `ensureRetCodeZero`
helpers so namespaces can validate sub-responses without an
@snowluma/core dependency.
Boundaries:
- Single-OIDB methods (publish / getCount / list-page / *url /
delete / move / *folder) become one-line forwarders.
- 3-stage methods (`upload` / `uploadPrivate`) keep their
orchestration on the facade — OIDB preflight goes through the
new namespace, but highway PUT + publish/sendC2cFile + upload-
cache bookkeeping stay where they are.
- `list` keeps its pagination loop on the facade; the page-fetch
namespace is one call.
- The NTV2-rich-media URL fetchers (group/private × ptt/video)
share a deserialize helper (`parseNtv2DownloadUrl`) so all four
namespaces only differ in their scene block.
Wire-byte equivalence preserved. The 0x6D6 family shares one
OidbGroupFileReq envelope; each namespace populates a different
slot (file / download / delete / move) and proton monomorphizes
per call site as before.
This commit is contained in:
37 files changed
+1900
-564
No files matched your search
@@ -0,0 +1,42 @@
|
||||
// 0x6D7_0 — create a sub-folder under `parentId` in the group file
|
||||
// hierarchy. parentId='/' is the root.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
OidbGroupFileFolderReq, OidbGroupFileFolderResp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/group-file';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import { ensureRetCodeZero } from '../shared';
|
||||
|
||||
export namespace CreateGroupFolder {
|
||||
export const command = 0x6D7;
|
||||
export const subCommand = 0;
|
||||
export const uinForm = true;
|
||||
|
||||
export interface Params { groupId: number; parentId: string; folderName: string; }
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): OidbGroupFileFolderReq => ({
|
||||
create: {
|
||||
groupUin: p.groupId,
|
||||
rootDirectory: p.parentId,
|
||||
folderName: p.folderName,
|
||||
},
|
||||
});
|
||||
|
||||
export const deserialize = (body: OidbGroupFileFolderResp): void => {
|
||||
const result = body.create;
|
||||
if (!result) throw new Error('group folder create response missing');
|
||||
ensureRetCodeZero('group folder create', result.retcode, result.retMsg, result.clientWording);
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<OidbGroupFileFolderReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGroupFileFolderReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbGroupFileFolderResp> =>
|
||||
protobuf_decode<OidbBase<OidbGroupFileFolderResp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, CreateGroupFolder, params);
|
||||
}
|
||||
Reference in new issue
Block a user