feat(web): add account workspaces and signed content flows
This commit is contained in:
1 parent
7b8d61d1ba
commit
b5cf3d5958
117 files changed
+2789
-1674
No files matched your search
@@ -1,40 +1,21 @@
|
||||
import type { SavedResource } from '../database';
|
||||
import type { ChannelInfo, Share, ShareSettings } from '../types';
|
||||
export interface ChannelWire {
|
||||
creator_account?: string;
|
||||
password_required?: boolean;
|
||||
id: string;
|
||||
mode: 'enc' | 'raw';
|
||||
settings: { name?: string; join_policy?: 'open' | 'invite'; allow_guests?: boolean; seats: number; members_can_upload: boolean; delete_policy: 'owner_only' | 'own' | 'anyone'; ttl_seconds: number; max_items: number; file_max_downloads: number };
|
||||
seats_used: number;
|
||||
oldest_seq: number;
|
||||
last_seq: number;
|
||||
created_at: number;
|
||||
expires_at: number;
|
||||
}
|
||||
|
||||
export interface ShareWireItem { item_id: string; bytes: number; frames: number; complete?: boolean; max_downloads: number; downloads_left: number | null }
|
||||
export interface ShareWire {
|
||||
id: string;
|
||||
state: 'draft' | 'sealed';
|
||||
expires_at: number;
|
||||
created_at: number;
|
||||
sealed_at?: number;
|
||||
manifest_item_id?: string;
|
||||
settings: { ttl_seconds: number; max_visitors: number; file_max_downloads: number };
|
||||
items: ShareWireItem[];
|
||||
}
|
||||
import type { ChannelInfo as ChannelWire, ShareInfo as ShareWire, ShareItemInfo as ShareWireItem } from '../generated/api';
|
||||
export type { ChannelWire, ShareWire, ShareWireItem };
|
||||
export function toChannelInfo(raw: ChannelWire, saved: SavedResource): ChannelInfo {
|
||||
const joinPolicy = raw.settings.join_policy;
|
||||
if (joinPolicy !== 'open' && joinPolicy !== 'invite') throw new Error('空间加入规则无效');
|
||||
return {
|
||||
id: raw.id,
|
||||
creatorAccount: raw.creator_account,
|
||||
joinPolicy: raw.settings.join_policy ?? 'open', allowGuests: raw.settings.allow_guests ?? true, passwordRequired: raw.password_required ?? false,
|
||||
name: raw.settings.name,
|
||||
creatorAccount: raw.creator_account ?? undefined,
|
||||
joinPolicy, allowGuests: raw.settings.allow_guests, passwordRequired: raw.password_required,
|
||||
name: raw.settings.name ?? undefined,
|
||||
mode: raw.mode,
|
||||
role: saved.role,
|
||||
canUpload: saved.role === 'owner' || raw.settings.members_can_upload,
|
||||
role: raw.can_manage_structure ? 'owner' : 'member',
|
||||
canUpload: raw.can_upload,
|
||||
canManageStructure: raw.can_manage_structure,
|
||||
seats: raw.settings.seats,
|
||||
seatsUsed: raw.seats_used,
|
||||
membersUsed: raw.seats_used,
|
||||
membersCanUpload: raw.settings.members_can_upload,
|
||||
ttlSeconds: raw.settings.ttl_seconds,
|
||||
maxDownloads: raw.settings.file_max_downloads,
|
||||
@@ -46,6 +27,7 @@ export function toChannelInfo(raw: ChannelWire, saved: SavedResource): ChannelIn
|
||||
}
|
||||
|
||||
export function toShareInfo(raw: ShareWire, saved: SavedResource): Share {
|
||||
if (raw.state !== 'draft' && raw.state !== 'sealed') throw new Error('分享状态无效');
|
||||
return {
|
||||
id: raw.id,
|
||||
state: raw.state,
|
||||
|
||||
Reference in new issue
Block a user