/** 与后端 /database/api/* 响应形状对齐。 */

export type NodeKind = "FOLDER" | "PROJECT";
export type Role = "VIEW" | "EDIT" | "MANAGE";

export interface NodeChild {
  readonly id: string;
  readonly parentId: string | null;
  readonly kind: NodeKind;
  readonly name: string;
  readonly role: Role;
  readonly createdAt: string;
  readonly updatedAt: string;
}

export interface BreadcrumbEntry {
  readonly depth: number;
  readonly id: string | null;
  readonly name: string | null;
  readonly kind: NodeKind;
}

export interface NodeDetail {
  readonly id: string;
  readonly parentId: string | null;
  readonly kind: NodeKind;
  readonly name: string;
  readonly description: string | null;
  readonly role: Role;
  readonly provisionStatus: "PROVISIONING" | "READY" | "FAILED";
  readonly independentPermission: boolean;
  readonly createdAt: string;
  readonly updatedAt: string;
}

export interface MeResponse {
  readonly userId: string;
  readonly isWebsiteAdmin: boolean;
}

export interface FileEntry {
  readonly path: string;
  readonly size: number;
}

export type FileContentEncoding = "utf8" | "base64";

export interface FileContent {
  readonly path: string;
  readonly version: string;
  readonly encoding: FileContentEncoding;
  readonly content: string;
  readonly size: number;
}

export interface VersionInfo {
  readonly version: string;
  readonly message: string;
  readonly author?: string;
  readonly committedAt: string;
}

export interface ExportJob {
  readonly id: string;
  readonly nodeId: string;
  readonly target: string;
  readonly status: "QUEUED" | "RUNNING" | "DONE" | "FAILED";
  readonly error: string | null;
  readonly createdAt: string;
}

export interface Grant {
  readonly id: string;
  readonly principalType: "USER" | "GROUP";
  readonly principalId: string;
  readonly role: Role;
  readonly isCreatorGrant: boolean;
  readonly createdAt: string;
}

export interface GroupSearchResult {
  readonly id: string;
  readonly name: string;
  readonly breadcrumb: string;
}
