feat(desktop): implement workspace foundation + desktop-client skeleton
Plan 0 (workspaces): add workspaces + workspace_memberships schema, extend JWT/Actor/claims with primary_workspace_id, seed default workspace per tenant, thread workspace_id through tenant monitoring quota. Plan A (desktop skeleton): new Electron app (apps/desktop-client) with main/ preload/renderer, shared Vue component package (packages/ui-shared), and server surface — desktop client registration + token rotation + heartbeat, SSE task event stream, desktop accounts/tasks/content handlers, publish job endpoint, and supporting repositories, services, sqlc queries, and migrations. Hard cutover per plan: remove browser-extension monitoring callback endpoints, stub legacy media API in admin-web, and delete monitoring_callback_handler.go.
This commit is contained in:
@@ -28,6 +28,7 @@ export interface UserInfo {
|
||||
name: string;
|
||||
avatar_url: string | null;
|
||||
tenant_id: number;
|
||||
primary_workspace_id: number;
|
||||
tenant_role: string;
|
||||
permissions: string[];
|
||||
membership: MembershipInfo | null;
|
||||
@@ -62,6 +63,208 @@ export interface RefreshResponse {
|
||||
expires_at: number;
|
||||
}
|
||||
|
||||
export interface DesktopClientInfo {
|
||||
id: string;
|
||||
tenant_id: number;
|
||||
workspace_id: number;
|
||||
user_id: number;
|
||||
device_name: string | null;
|
||||
os: string | null;
|
||||
cpu_arch: string | null;
|
||||
client_version: string | null;
|
||||
channel: string | null;
|
||||
created_at: string;
|
||||
last_seen_at: string | null;
|
||||
last_rotated_at: string | null;
|
||||
revoked_at: string | null;
|
||||
}
|
||||
|
||||
export interface DesktopClientRegisterRequest {
|
||||
device_name: string;
|
||||
os: string;
|
||||
cpu_arch?: string;
|
||||
client_version: string;
|
||||
channel?: string;
|
||||
}
|
||||
|
||||
export interface DesktopClientRegisterResponse {
|
||||
client_id: string;
|
||||
client_token: string;
|
||||
expires_at: number;
|
||||
client: DesktopClientInfo;
|
||||
}
|
||||
|
||||
export interface DesktopClientHeartbeatRequest {
|
||||
device_name?: string;
|
||||
os?: string;
|
||||
cpu_arch?: string;
|
||||
client_version?: string;
|
||||
channel?: string;
|
||||
}
|
||||
|
||||
export interface DesktopClientHeartbeatResponse {
|
||||
client: DesktopClientInfo;
|
||||
server_time: string;
|
||||
}
|
||||
|
||||
export interface DesktopClientRotateResponse {
|
||||
client_token: string;
|
||||
expires_at: number;
|
||||
client: DesktopClientInfo;
|
||||
}
|
||||
|
||||
export interface DesktopAccountInfo {
|
||||
id: string;
|
||||
platform: string;
|
||||
platform_uid: string;
|
||||
display_name: string;
|
||||
health: "live" | "expired" | "captcha" | "risk";
|
||||
client_id: string | null;
|
||||
account_fingerprint: string | null;
|
||||
verified_at: string | null;
|
||||
tags: string[];
|
||||
sync_version: number;
|
||||
deleted_at: string | null;
|
||||
delete_requested_at: string | null;
|
||||
}
|
||||
|
||||
export interface UpsertDesktopAccountRequest {
|
||||
platform: string;
|
||||
platform_uid: string;
|
||||
account_fingerprint?: string | null;
|
||||
display_name: string;
|
||||
health: "live" | "expired" | "captcha" | "risk";
|
||||
verified_at?: string | null;
|
||||
tags?: string[];
|
||||
if_sync_version?: number | null;
|
||||
}
|
||||
|
||||
export interface PatchDesktopAccountRequest {
|
||||
display_name?: string;
|
||||
health?: "live" | "expired" | "captcha" | "risk";
|
||||
verified_at?: string | null;
|
||||
tags?: string[];
|
||||
if_sync_version: number;
|
||||
}
|
||||
|
||||
export interface DesktopTaskInfo {
|
||||
id: string;
|
||||
job_id: string;
|
||||
tenant_id: number;
|
||||
workspace_id: number;
|
||||
target_account_id: string;
|
||||
target_client_id: string;
|
||||
platform: string;
|
||||
kind: "publish" | "monitor";
|
||||
payload: Record<string, JsonValue> | null;
|
||||
status: "queued" | "in_progress" | "waiting_user" | "succeeded" | "failed" | "unknown" | "aborted";
|
||||
dedup_key: string | null;
|
||||
active_attempt_id: string | null;
|
||||
lease_expires_at: string | null;
|
||||
attempts: number;
|
||||
parked_reason: string | null;
|
||||
result: Record<string, JsonValue> | null;
|
||||
error: Record<string, JsonValue> | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface LeaseDesktopTaskRequest {
|
||||
task_id?: string;
|
||||
kind?: "publish" | "monitor";
|
||||
}
|
||||
|
||||
export interface LeaseDesktopTaskResponse {
|
||||
task: DesktopTaskInfo | null;
|
||||
attempt_id?: string;
|
||||
lease_token?: string;
|
||||
lease_expires_at?: string | null;
|
||||
}
|
||||
|
||||
export interface ExtendDesktopTaskRequest {
|
||||
lease_token: string;
|
||||
}
|
||||
|
||||
export interface ParkDesktopTaskRequest {
|
||||
lease_token: string;
|
||||
reason: "waiting_user" | "captcha";
|
||||
}
|
||||
|
||||
export interface CompleteDesktopTaskRequest {
|
||||
lease_token: string;
|
||||
status: "succeeded" | "failed" | "unknown";
|
||||
payload?: Record<string, JsonValue>;
|
||||
error?: Record<string, JsonValue>;
|
||||
}
|
||||
|
||||
export interface CancelDesktopTaskRequest {
|
||||
lease_token?: string | null;
|
||||
reason?: string | null;
|
||||
}
|
||||
|
||||
export interface ReconcileDesktopTaskRequest {
|
||||
status: "succeeded" | "failed" | "aborted" | "retry";
|
||||
result?: Record<string, JsonValue>;
|
||||
error?: Record<string, JsonValue>;
|
||||
}
|
||||
|
||||
export interface DesktopTaskEventMessage {
|
||||
type:
|
||||
| "task_available"
|
||||
| "task_leased"
|
||||
| "task_extended"
|
||||
| "task_parked"
|
||||
| "task_completed"
|
||||
| "task_canceled"
|
||||
| "task_reconciled";
|
||||
task_id: string;
|
||||
job_id: string;
|
||||
workspace_id: number;
|
||||
target_client_id: string;
|
||||
status:
|
||||
| "queued"
|
||||
| "in_progress"
|
||||
| "waiting_user"
|
||||
| "succeeded"
|
||||
| "failed"
|
||||
| "unknown"
|
||||
| "aborted";
|
||||
kind: "publish" | "monitor";
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface DesktopArticleContent {
|
||||
article_id: number;
|
||||
title: string;
|
||||
html_content: string | null;
|
||||
markdown_content: string | null;
|
||||
cover_asset_url: string | null;
|
||||
}
|
||||
|
||||
export interface DesktopRuntimeSessionSyncRequest {
|
||||
api_base_url: string;
|
||||
mode: "authenticated" | "preview";
|
||||
client_token: string | null;
|
||||
desktop_client: DesktopClientInfo | null;
|
||||
}
|
||||
|
||||
export interface CreatePublishJobAccountRequest {
|
||||
account_id: string;
|
||||
mode: "auto" | "manual";
|
||||
}
|
||||
|
||||
export interface CreatePublishJobRequest {
|
||||
title: string;
|
||||
content_ref: Record<string, JsonValue>;
|
||||
accounts: CreatePublishJobAccountRequest[];
|
||||
scheduled_at?: string | null;
|
||||
}
|
||||
|
||||
export interface CreatePublishJobResponse {
|
||||
job_id: string;
|
||||
task_ids: string[];
|
||||
}
|
||||
|
||||
export interface WorkspaceOverview {
|
||||
article_count: number;
|
||||
published_count: number;
|
||||
|
||||
Reference in New Issue
Block a user