refactor(web): restructure into api/domain/services/worker; capabilities, file domains, video covers
- dissolve core-bridge into api (wire contract), domain (models), services (what the UI calls) and worker (everything that runs in the Web Worker, grouped by account, crypto, space, files, shares, runtime); regroup features, lib and store by responsibility and delete unused components - the UI only reads backend capabilities (domain/capabilities); one tokenRole picks the token, hasCode/isRetryable handle errors; pre-checks that decided permissions on the client are gone; tests fail if those rules are reimplemented - files go straight to the file domain (create, upload, download, delete, commit, cancel); the host sees one registration per file; creating a channel allocates a file domain and works even when the file service is down - file panel shows which channel the files belong to and its space usage; unlimited files preview in chat; videos get a stored cover; the file service status is shown - fix: console flooded by Retry-After reads on every upload frame
This commit is contained in:
1 parent
17638b6e20
commit
5489407241
260 files changed
+1503
-1246
No files matched your search
@@ -0,0 +1,503 @@
|
||||
// Generated from backend DTOs; do not edit.
|
||||
// backend-contract-sha256: 340876061d7b324e4fd16972e276ffb0f238eeac66b214a043b3b4b98d560fcf
|
||||
|
||||
export interface AccountChannelBody {
|
||||
channel_id: string;
|
||||
created_at: number;
|
||||
payload: string;
|
||||
role: string;
|
||||
}
|
||||
export interface AccountDeviceBody {
|
||||
created_at: number;
|
||||
current: boolean;
|
||||
id: string;
|
||||
last_seen: number;
|
||||
name: string;
|
||||
}
|
||||
export interface AccountDeviceNameRequest {
|
||||
name: string;
|
||||
}
|
||||
export interface AccountDeviceSigningRequest {
|
||||
device_id: string;
|
||||
public_key: string;
|
||||
signature: string;
|
||||
}
|
||||
export interface AccountProfile {
|
||||
avatar?: string | null;
|
||||
displayName: string;
|
||||
hasAvatar: boolean;
|
||||
modifiedAt: number;
|
||||
username: string;
|
||||
}
|
||||
export interface AccountProfileRequest {
|
||||
avatar?: string | null;
|
||||
avatarThumb?: string | null;
|
||||
displayName: string;
|
||||
keepAvatar: boolean;
|
||||
}
|
||||
export interface AccountRegisterRequest {
|
||||
public_key: string;
|
||||
salt: string;
|
||||
signing_public_key: string;
|
||||
username: string;
|
||||
vault: string;
|
||||
verifier: string;
|
||||
}
|
||||
export interface AccountSaltBody {
|
||||
salt: string;
|
||||
}
|
||||
export interface AccountSaltRequest {
|
||||
username: string;
|
||||
}
|
||||
export interface AccountSessionBody {
|
||||
token: string;
|
||||
username: string;
|
||||
}
|
||||
export interface AccountSessionRequest {
|
||||
device_id?: string | null;
|
||||
device_name?: string | null;
|
||||
username: string;
|
||||
verifier: string;
|
||||
}
|
||||
export interface AccountVaultBody {
|
||||
revision: number;
|
||||
vault: string;
|
||||
}
|
||||
export interface AccountVaultRequest {
|
||||
revision: number;
|
||||
vault: string;
|
||||
}
|
||||
export interface AppendResult {
|
||||
seq: number;
|
||||
}
|
||||
export interface ChannelHistoryRequest {
|
||||
chatHistory: boolean;
|
||||
filesHistory: boolean;
|
||||
}
|
||||
export interface ChannelInfo {
|
||||
avatar?: string | null;
|
||||
can_create_channel: boolean;
|
||||
can_delete_any: boolean;
|
||||
can_delete_own: boolean;
|
||||
can_edit_settings: boolean;
|
||||
can_invite: boolean;
|
||||
can_manage_folders: boolean;
|
||||
can_manage_roles: boolean;
|
||||
can_manage_structure: boolean;
|
||||
can_remove_members: boolean;
|
||||
can_upload: boolean;
|
||||
created_at: number;
|
||||
creator_account?: string | null;
|
||||
expires_at: number;
|
||||
id: string;
|
||||
is_owner: boolean;
|
||||
last_seq: number;
|
||||
members_used: number;
|
||||
mode: ChannelMode;
|
||||
oldest_seq: number;
|
||||
password_required: boolean;
|
||||
settings: ChannelSettings;
|
||||
}
|
||||
export type ChannelMode = 'enc' | 'raw';
|
||||
export const ChannelMode = { Enc: 'enc', Raw: 'raw' } as const;
|
||||
|
||||
export interface ChannelSettings {
|
||||
delete_policy: DeletePolicy;
|
||||
file_max_downloads: number;
|
||||
join_policy: JoinPolicy;
|
||||
max_items: number;
|
||||
max_members: number;
|
||||
members_can_upload: boolean;
|
||||
name?: string | null;
|
||||
ttl_seconds: number;
|
||||
ui_restrict_copy_download: boolean;
|
||||
}
|
||||
export interface ChannelSettingsPatch {
|
||||
avatar?: string | null;
|
||||
avatar_thumb?: string | null;
|
||||
delete_policy?: DeletePolicy | null;
|
||||
file_max_downloads?: number | null;
|
||||
join_password?: string | null;
|
||||
join_policy?: JoinPolicy | null;
|
||||
max_items?: number | null;
|
||||
max_members?: number | null;
|
||||
members_can_upload?: boolean | null;
|
||||
name?: string | null;
|
||||
ttl_seconds?: number | null;
|
||||
ui_restrict_copy_download?: boolean | null;
|
||||
}
|
||||
export interface CreateChannelRequest {
|
||||
id?: string | null;
|
||||
join_password?: string | null;
|
||||
key_package?: string | null;
|
||||
mode?: ChannelMode | null;
|
||||
owner_hash?: string | null;
|
||||
read_hash?: string | null;
|
||||
settings?: ChannelSettings | null;
|
||||
write_hash?: string | null;
|
||||
}
|
||||
export interface CreateShareRequest {
|
||||
id?: string | null;
|
||||
owner_hash?: string | null;
|
||||
read_hash?: string | null;
|
||||
settings?: ShareSettings | null;
|
||||
}
|
||||
export interface CryptoState {
|
||||
access: ChannelAccess[];
|
||||
envelopes: DomainEnvelope[];
|
||||
objects: ObjectEnvelope[];
|
||||
revision: number;
|
||||
}
|
||||
export interface ChannelAccess {
|
||||
channelId: string;
|
||||
chatFromRevision: number;
|
||||
chatRead: boolean;
|
||||
chatWrite: boolean;
|
||||
filesFromRevision: number;
|
||||
filesRead: boolean;
|
||||
filesUpload: boolean;
|
||||
username: string;
|
||||
}
|
||||
export type DeletePolicy = 'owner_only' | 'own' | 'anyone';
|
||||
export const DeletePolicy = { OwnerOnly: 'owner_only', Own: 'own', Anyone: 'anyone' } as const;
|
||||
|
||||
export interface DomainEnvelope {
|
||||
channelId: string;
|
||||
domain: CryptoDomain;
|
||||
epoch: number;
|
||||
payload: string;
|
||||
username: string;
|
||||
}
|
||||
export type CryptoDomain = 'chat' | 'files';
|
||||
export const CryptoDomain = { Chat: 'chat', Files: 'files' } as const;
|
||||
|
||||
export interface DomainPublishRequest {
|
||||
channelId: string;
|
||||
domain: CryptoDomain;
|
||||
envelopes: DomainEnvelope[];
|
||||
epoch: number;
|
||||
}
|
||||
export interface ErrorBody {
|
||||
error: string;
|
||||
}
|
||||
export interface FileGrantBody {
|
||||
domain: string;
|
||||
expires_at: number;
|
||||
ticket: string;
|
||||
url: string;
|
||||
}
|
||||
export interface FileGrantRequest {
|
||||
channel?: string | null;
|
||||
from: number;
|
||||
item?: string | null;
|
||||
op: string;
|
||||
}
|
||||
export interface FinishShareRequest {
|
||||
manifest_item_id?: string | null;
|
||||
}
|
||||
export interface GoneLogBody {
|
||||
error: string;
|
||||
oldest_seq: number;
|
||||
}
|
||||
export interface InvitationBody {
|
||||
can_revoke: boolean;
|
||||
channel_id: string;
|
||||
created_at: number;
|
||||
payload: string;
|
||||
username: string;
|
||||
}
|
||||
export interface InvitationCryptoPlan {
|
||||
batches: CryptoGrantBatch[];
|
||||
channelId: string;
|
||||
username: string;
|
||||
}
|
||||
export interface CryptoGrantBatch {
|
||||
domain: CryptoDomain;
|
||||
epoch: number;
|
||||
recipients: string[];
|
||||
rotate: boolean;
|
||||
}
|
||||
export interface InvitationRequest {
|
||||
domain_envelopes?: DomainEnvelope[] | null;
|
||||
payload: string;
|
||||
username: string;
|
||||
}
|
||||
export type JoinPolicy = 'open' | 'invite';
|
||||
export const JoinPolicy = { Open: 'open', Invite: 'invite' } as const;
|
||||
|
||||
export interface JoinRequest {
|
||||
password?: string | null;
|
||||
}
|
||||
export interface JoinResult {
|
||||
joined_at: number;
|
||||
members_max: number;
|
||||
members_used: number;
|
||||
}
|
||||
export interface KeyPackageRequest {
|
||||
payload: string;
|
||||
}
|
||||
export interface MemberBody {
|
||||
can_remove: boolean;
|
||||
devices: number;
|
||||
joined_at: number;
|
||||
last_seen: number;
|
||||
online: boolean;
|
||||
online_devices: number;
|
||||
role: string;
|
||||
username: string;
|
||||
}
|
||||
export interface ObjectEnvelope {
|
||||
authorAccount?: string | null;
|
||||
channelId: string;
|
||||
createdRevision: number;
|
||||
deleteEvent?: SignedContentEventRecord | null;
|
||||
domain: CryptoDomain;
|
||||
epoch: number;
|
||||
event?: SignedContentEventRecord | null;
|
||||
itemId: string;
|
||||
keyEnvelope: string;
|
||||
}
|
||||
export interface PasskeyBeginRequest {
|
||||
username: string;
|
||||
verifier?: string | null;
|
||||
}
|
||||
export interface PasskeyEnvelopeRequest {
|
||||
credential: string;
|
||||
id: string;
|
||||
key_envelope: string;
|
||||
username: string;
|
||||
}
|
||||
export interface PasskeyFinishRequest {
|
||||
credential: string;
|
||||
device_id?: string | null;
|
||||
device_name?: string | null;
|
||||
id: string;
|
||||
key_envelope?: string | null;
|
||||
name?: string | null;
|
||||
username: string;
|
||||
}
|
||||
export interface PasskeyInfoBody {
|
||||
can_recover: boolean;
|
||||
created_at: number;
|
||||
id: string;
|
||||
name: string;
|
||||
prf_salt: string;
|
||||
}
|
||||
export interface PasskeyOptionsBody {
|
||||
credentials: PasskeyInfoBody[];
|
||||
id: string;
|
||||
options: string;
|
||||
prf_salt?: string | null;
|
||||
}
|
||||
export interface PasskeySessionBody {
|
||||
credential_id: string;
|
||||
key_envelope?: string | null;
|
||||
prf_salt: string;
|
||||
token: string;
|
||||
username: string;
|
||||
}
|
||||
export interface PublicKeyBody {
|
||||
public_key: string;
|
||||
signing_public_key?: string | null;
|
||||
}
|
||||
export interface ServerInfoBody {
|
||||
captcha: CaptchaBody;
|
||||
choices: SettingChoicesBody;
|
||||
contract_version: string;
|
||||
defaults: DefaultsBody;
|
||||
files: FilesInfoBody;
|
||||
limits: LimitsBody;
|
||||
protocol: number;
|
||||
transports: TransportsBody;
|
||||
}
|
||||
export interface CaptchaBody {
|
||||
api_endpoint?: string | null;
|
||||
enabled: boolean;
|
||||
provider: string;
|
||||
}
|
||||
export interface DefaultsBody {
|
||||
channel: ChannelSettings;
|
||||
channel_mode: ChannelMode;
|
||||
share: ShareSettings;
|
||||
}
|
||||
export interface FilesInfoBody {
|
||||
enabled: boolean;
|
||||
url?: string | null;
|
||||
}
|
||||
export interface LimitsBody {
|
||||
max_channel_bytes: number;
|
||||
max_frames_per_item: number;
|
||||
max_items: number;
|
||||
max_members: number;
|
||||
max_payload_bytes: number;
|
||||
max_ttl_seconds: number;
|
||||
max_visitors: number;
|
||||
max_workspace_bytes: number;
|
||||
min_ttl_seconds: number;
|
||||
}
|
||||
export interface SettingChoicesBody {
|
||||
file_max_downloads: number[];
|
||||
max_members: number[];
|
||||
max_visitors: number[];
|
||||
ttl_seconds: number[];
|
||||
}
|
||||
export interface ShareInfo {
|
||||
created_at: number;
|
||||
expires_at: number;
|
||||
id: string;
|
||||
items: ShareItemInfo[];
|
||||
manifest_item_id?: string | null;
|
||||
sealed_at?: number | null;
|
||||
settings: ShareSettings;
|
||||
state: string;
|
||||
}
|
||||
export interface ShareItemInfo {
|
||||
bytes: number;
|
||||
complete: boolean;
|
||||
downloads_left: number | null;
|
||||
frames: number;
|
||||
item_id: string;
|
||||
max_downloads: number;
|
||||
}
|
||||
export interface ShareSettings {
|
||||
file_max_downloads: number;
|
||||
max_visitors: number;
|
||||
ttl_seconds: number;
|
||||
}
|
||||
export interface ShareSettingsPatch {
|
||||
file_max_downloads?: number | null;
|
||||
max_visitors?: number | null;
|
||||
ttl_seconds?: number | null;
|
||||
}
|
||||
export interface SignedContentEventRecord {
|
||||
deviceCertificateSignature: string;
|
||||
eventId: string;
|
||||
frameCount: number;
|
||||
kind: string;
|
||||
manifestHash: string;
|
||||
signature: string;
|
||||
signerAccount?: string | null;
|
||||
signerDeviceId: string;
|
||||
signerDevicePublicKey: string;
|
||||
signerRootPublicKey: string;
|
||||
targetItemId?: string | null;
|
||||
}
|
||||
export interface TransportsBody {
|
||||
http3: boolean;
|
||||
sse: boolean;
|
||||
websocket: boolean;
|
||||
}
|
||||
export interface WorkspaceBody {
|
||||
people: AccountProfile[];
|
||||
structure: WorkspaceState;
|
||||
}
|
||||
export interface WorkspaceChannelCreatedBody {
|
||||
channel: WorkspaceChannel;
|
||||
workspace: WorkspaceBody;
|
||||
}
|
||||
export interface WorkspaceChannel {
|
||||
chatEpoch: number;
|
||||
chatHistory: boolean;
|
||||
createdAt: number;
|
||||
createdBy: string;
|
||||
fileDomain?: string | null;
|
||||
filesEpoch: number;
|
||||
filesHistory: boolean;
|
||||
groupId?: string | null;
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
export interface WorkspaceChannelRequest {
|
||||
fileDomain?: string | null;
|
||||
groupId?: string | null;
|
||||
name: string;
|
||||
}
|
||||
export interface WorkspaceFileDomainRequest {
|
||||
fileDomain: string;
|
||||
}
|
||||
export interface WorkspaceFolderRequest {
|
||||
name: string;
|
||||
parentId?: string | null;
|
||||
threadId: string;
|
||||
}
|
||||
export interface WorkspaceGroupCreatedBody {
|
||||
group: WorkspaceGroup;
|
||||
workspace: WorkspaceBody;
|
||||
}
|
||||
export interface WorkspaceGroup {
|
||||
createdAt: number;
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
export interface WorkspaceGroupRequest {
|
||||
groupId?: string | null;
|
||||
}
|
||||
export interface WorkspaceMoveRequest {
|
||||
folderId?: string | null;
|
||||
itemIds: string[];
|
||||
threadId: string;
|
||||
}
|
||||
export interface WorkspaceNameRequest {
|
||||
name: string;
|
||||
}
|
||||
export interface WorkspaceRoleCreatedBody {
|
||||
role: WorkspaceRole;
|
||||
workspace: WorkspaceBody;
|
||||
}
|
||||
export interface WorkspaceRole {
|
||||
color?: string | null;
|
||||
createdAt: number;
|
||||
id: string;
|
||||
members: string[];
|
||||
name: string;
|
||||
permissions: string[];
|
||||
prefix?: string | null;
|
||||
suffix?: string | null;
|
||||
}
|
||||
export interface WorkspaceRoleMembersRequest {
|
||||
members: string[];
|
||||
}
|
||||
export interface WorkspaceRoleRequest {
|
||||
color?: string | null;
|
||||
name: string;
|
||||
permissions: string[];
|
||||
prefix?: string | null;
|
||||
suffix?: string | null;
|
||||
}
|
||||
export interface WorkspaceState {
|
||||
channels: WorkspaceChannel[];
|
||||
defaultChannelId?: string | null;
|
||||
folders: WorkspaceFolder[];
|
||||
groups: WorkspaceGroup[];
|
||||
locations: WorkspaceLocation[];
|
||||
revision: number;
|
||||
roles: WorkspaceRole[];
|
||||
rolesSeeded: boolean;
|
||||
}
|
||||
export interface WorkspaceFolder {
|
||||
id: string;
|
||||
name: string;
|
||||
parentId?: string | null;
|
||||
threadId: string;
|
||||
}
|
||||
export interface WorkspaceLocation {
|
||||
authorAccount?: string | null;
|
||||
folderId?: string | null;
|
||||
itemId: string;
|
||||
threadId: string;
|
||||
}
|
||||
/** 错误响应里的 error 取值 */
|
||||
export const ErrorCode = { BadRequest: 'bad_request', Unauthorized: 'unauthorized', Forbidden: 'forbidden', NotJoined: 'not_joined', MembersFull: 'members_full', ModeMismatch: 'mode_mismatch', NotFound: 'not_found', Conflict: 'conflict', Gone: 'gone', TooLarge: 'too_large', CaptchaRequired: 'captcha_required', CaptchaUnavailable: 'captcha_unavailable', RateLimited: 'rate_limited', VisitorsFull: 'visitors_full', Sealed: 'sealed', AccountRequired: 'account_required', InvitationRequired: 'invitation_required', ChannelPasswordRequired: 'channel_password_required', ChannelPasswordInvalid: 'channel_password_invalid', SpaceNameRequired: 'space_name_required', UseFileApi: 'use_file_api', FilesUnavailable: 'files_unavailable' } as const;
|
||||
export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
||||
|
||||
/** X-WD-Role 请求头:这次请求出示哪张令牌 */
|
||||
export const TokenRole = { Read: 'read', Write: 'write', Owner: 'owner' } as const;
|
||||
export type TokenRole = (typeof TokenRole)[keyof typeof TokenRole];
|
||||
|
||||
/** 空间权限(身份组授予) */
|
||||
export const WorkspacePermission = { RemoveMembers: 'members.remove', ManageStructure: 'structure.manage' } as const;
|
||||
export type WorkspacePermission = (typeof WorkspacePermission)[keyof typeof WorkspacePermission];
|
||||
|
||||
/** 便捷分享的状态 */
|
||||
export const ShareState = { Draft: 'draft', Sealed: 'sealed' } as const;
|
||||
export type ShareState = (typeof ShareState)[keyof typeof ShareState];
|
||||
Reference in new issue
Block a user