// @ts-check
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

/**
 * AppService 应用服务，暴露给前端调用
 * @module
 */

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "@wailsio/runtime";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as application$0 from "../../../../wailsapp/wails/v3/pkg/application/models.js";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import * as $models from "./models.js";

/**
 * AddPlatform 添加新平台
 * @param {string} name
 * @param {string} baseURL
 * @returns {$CancellablePromise<void>}
 */
export function AddPlatform(name, baseURL) {
    return $Call.ByID(526003212, name, baseURL);
}

/**
 * AddProject 添加项目到指定平台/用户下
 * @param {string} platform
 * @param {string} username
 * @param {string} name
 * @param {string} path
 * @returns {$CancellablePromise<void>}
 */
export function AddProject(platform, username, name, path) {
    return $Call.ByID(2299402672, platform, username, name, path);
}

/**
 * AddUser 添加用户到指定平台
 * @param {string} platform
 * @param {string} username
 * @param {string} token
 * @returns {$CancellablePromise<void>}
 */
export function AddUser(platform, username, token) {
    return $Call.ByID(2264426704, platform, username, token);
}

/**
 * CloneProject 克隆远程仓库到本地目录，并添加到项目树
 * @param {string} platform
 * @param {string} username
 * @param {string} repoURL
 * @param {string} parentDir
 * @param {string} name
 * @returns {$CancellablePromise<void>}
 */
export function CloneProject(platform, username, repoURL, parentDir, name) {
    return $Call.ByID(2347019414, platform, username, repoURL, parentDir, name);
}

/**
 * CommitChanges 提交已暂存的更改
 * @param {string} path
 * @param {string} message
 * @returns {$CancellablePromise<void>}
 */
export function CommitChanges(path, message) {
    return $Call.ByID(921984546, path, message);
}

/**
 * CreateTag 创建标签
 * @param {string} path
 * @param {string} name
 * @param {string} message
 * @returns {$CancellablePromise<void>}
 */
export function CreateTag(path, name, message) {
    return $Call.ByID(4209616956, path, name, message);
}

/**
 * DeleteTag 删除标签（本地+远程）
 * @param {string} path
 * @param {string} name
 * @returns {$CancellablePromise<void>}
 */
export function DeleteTag(path, name) {
    return $Call.ByID(873653241, path, name);
}

/**
 * DiscardFiles 丢弃工作区指定文件的更改
 * @param {string} path
 * @param {string[]} files
 * @returns {$CancellablePromise<void>}
 */
export function DiscardFiles(path, files) {
    return $Call.ByID(382904301, path, files);
}

/**
 * FetchProject 拉取远程信息
 * @param {string} path
 * @returns {$CancellablePromise<string>}
 */
export function FetchProject(path) {
    return $Call.ByID(3541106829, path);
}

/**
 * GetBranches 获取所有本地分支
 * @param {string} path
 * @returns {$CancellablePromise<$models.BranchInfo[]>}
 */
export function GetBranches(path) {
    return $Call.ByID(1686190192, path).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType1($result);
    }));
}

/**
 * GetCommitDiff 获取指定提交的 diff
 * @param {string} path
 * @param {string} hash
 * @returns {$CancellablePromise<string>}
 */
export function GetCommitDiff(path, hash) {
    return $Call.ByID(3678609798, path, hash);
}

/**
 * GetCommitFileDiff 获取指定提交中某个文件的 diff
 * @param {string} path
 * @param {string} hash
 * @param {string} filePath
 * @returns {$CancellablePromise<string>}
 */
export function GetCommitFileDiff(path, hash, filePath) {
    return $Call.ByID(880053428, path, hash, filePath);
}

/**
 * GetCommitFiles 获取指定提交中变更的文件列表
 * @param {string} path
 * @param {string} hash
 * @returns {$CancellablePromise<$models.CommitFileInfo[]>}
 */
export function GetCommitFiles(path, hash) {
    return $Call.ByID(2420707876, path, hash).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType3($result);
    }));
}

/**
 * GetCommitLog 获取提交历史
 * @param {string} path
 * @param {number} count
 * @returns {$CancellablePromise<$models.CommitLog[]>}
 */
export function GetCommitLog(path, count) {
    return $Call.ByID(1281870789, path, count).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType5($result);
    }));
}

/**
 * GetFileContent 获取文件内容
 * @param {string} projectPath
 * @param {string} filePath
 * @returns {$CancellablePromise<string>}
 */
export function GetFileContent(projectPath, filePath) {
    return $Call.ByID(3085630035, projectPath, filePath);
}

/**
 * GetFileDiff 获取文件 diff
 * @param {string} projectPath
 * @param {string} filePath
 * @returns {$CancellablePromise<string>}
 */
export function GetFileDiff(projectPath, filePath) {
    return $Call.ByID(1694304929, projectPath, filePath);
}

/**
 * GetFileDiffStaged 获取已暂存文件的 diff
 * @param {string} projectPath
 * @param {string} filePath
 * @returns {$CancellablePromise<string>}
 */
export function GetFileDiffStaged(projectPath, filePath) {
    return $Call.ByID(2773256455, projectPath, filePath);
}

/**
 * GetPlatformInfo 获取平台信息
 * @param {string} name
 * @returns {$CancellablePromise<$models.PlatformInfo | null>}
 */
export function GetPlatformInfo(name) {
    return $Call.ByID(2668095547, name).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType7($result);
    }));
}

/**
 * GetProjectChangedFiles 获取项目变更文件列表（可能较慢）
 * @param {string} path
 * @returns {$CancellablePromise<$models.FileInfo[]>}
 */
export function GetProjectChangedFiles(path) {
    return $Call.ByID(2302591462, path).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType9($result);
    }));
}

/**
 * GetProjectStatus 获取项目 git 状态
 * @param {string} path
 * @returns {$CancellablePromise<$models.ProjectStatus | null>}
 */
export function GetProjectStatus(path) {
    return $Call.ByID(3451089027, path).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType11($result);
    }));
}

/**
 * GetProjectTree 获取项目树，供前端侧边栏渲染
 * @returns {$CancellablePromise<$models.TreeNode[]>}
 */
export function GetProjectTree() {
    return $Call.ByID(651189689).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType13($result);
    }));
}

/**
 * GetTags 获取所有标签
 * @param {string} path
 * @returns {$CancellablePromise<$models.TagInfo[]>}
 */
export function GetTags(path) {
    return $Call.ByID(3979169621, path).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType15($result);
    }));
}

/**
 * GetUserInfo 获取用户信息
 * @param {string} platform
 * @param {string} username
 * @returns {$CancellablePromise<$models.UserInfo | null>}
 */
export function GetUserInfo(platform, username) {
    return $Call.ByID(2674655707, platform, username).then(/** @type {($result: any) => any} */(($result) => {
        return $$createType17($result);
    }));
}

/**
 * PullProject 拉取项目（当前分支）
 * @param {string} path
 * @returns {$CancellablePromise<string>}
 */
export function PullProject(path) {
    return $Call.ByID(4145813996, path);
}

/**
 * PushProject 推送项目（当前分支）
 * @param {string} path
 * @returns {$CancellablePromise<string>}
 */
export function PushProject(path) {
    return $Call.ByID(3887901113, path);
}

/**
 * PushTag 推送标签到远程
 * @param {string} path
 * @param {string} name
 * @returns {$CancellablePromise<void>}
 */
export function PushTag(path, name) {
    return $Call.ByID(1424810524, path, name);
}

/**
 * RemovePlatform 删除平台
 * @param {string} name
 * @returns {$CancellablePromise<void>}
 */
export function RemovePlatform(name) {
    return $Call.ByID(2222448051, name);
}

/**
 * RemoveProject 从指定平台/用户下删除项目
 * @param {string} platform
 * @param {string} username
 * @param {string} name
 * @returns {$CancellablePromise<void>}
 */
export function RemoveProject(platform, username, name) {
    return $Call.ByID(2748109581, platform, username, name);
}

/**
 * RemoveUser 从平台删除用户
 * @param {string} platform
 * @param {string} username
 * @returns {$CancellablePromise<void>}
 */
export function RemoveUser(platform, username) {
    return $Call.ByID(1409517275, platform, username);
}

/**
 * ResetProject 版本回滚（git reset）
 * mode: "hard"(丢弃所有更改), "soft"(保留更改到暂存区), "mixed"(保留更改到工作区)
 * @param {string} path
 * @param {string} hash
 * @param {string} mode
 * @returns {$CancellablePromise<void>}
 */
export function ResetProject(path, hash, mode) {
    return $Call.ByID(2061148684, path, hash, mode);
}

/**
 * RevertCommit 撤回指定提交（生成一个反向提交）
 * @param {string} path
 * @param {string} hash
 * @returns {$CancellablePromise<void>}
 */
export function RevertCommit(path, hash) {
    return $Call.ByID(1334788539, path, hash);
}

/**
 * SelectDirectory 打开系统文件夹选择器，返回选中的路径
 * @returns {$CancellablePromise<string>}
 */
export function SelectDirectory() {
    return $Call.ByID(2318416763);
}

/**
 * @param {application$0.App | null} app
 * @returns {$CancellablePromise<void>}
 */
export function SetApplication(app) {
    return $Call.ByID(383695022, app);
}

/**
 * StageAll 暂存所有变更文件
 * @param {string} path
 * @returns {$CancellablePromise<void>}
 */
export function StageAll(path) {
    return $Call.ByID(2344562461, path);
}

/**
 * StageFiles 暂存指定文件
 * @param {string} path
 * @param {string[]} files
 * @returns {$CancellablePromise<void>}
 */
export function StageFiles(path, files) {
    return $Call.ByID(4064506881, path, files);
}

/**
 * SwitchBranch 切换分支
 * @param {string} path
 * @param {string} branch
 * @returns {$CancellablePromise<void>}
 */
export function SwitchBranch(path, branch) {
    return $Call.ByID(4262224900, path, branch);
}

/**
 * UnstageAll 取消暂存所有文件
 * @param {string} path
 * @returns {$CancellablePromise<void>}
 */
export function UnstageAll(path) {
    return $Call.ByID(2417621882, path);
}

/**
 * UnstageFiles 取消暂存指定文件
 * @param {string} path
 * @param {string[]} files
 * @returns {$CancellablePromise<void>}
 */
export function UnstageFiles(path, files) {
    return $Call.ByID(3546473046, path, files);
}

/**
 * UpdatePlatform 修改平台信息（base_url）
 * @param {string} name
 * @param {string} baseURL
 * @returns {$CancellablePromise<void>}
 */
export function UpdatePlatform(name, baseURL) {
    return $Call.ByID(3258014550, name, baseURL);
}

/**
 * UpdateUser 修改用户信息（用户名、token）
 * @param {string} platform
 * @param {string} oldUsername
 * @param {string} newUsername
 * @param {string} token
 * @returns {$CancellablePromise<void>}
 */
export function UpdateUser(platform, oldUsername, newUsername, token) {
    return $Call.ByID(1631729342, platform, oldUsername, newUsername, token);
}

// Private type creation functions
const $$createType0 = $models.BranchInfo.createFrom;
const $$createType1 = $Create.Array($$createType0);
const $$createType2 = $models.CommitFileInfo.createFrom;
const $$createType3 = $Create.Array($$createType2);
const $$createType4 = $models.CommitLog.createFrom;
const $$createType5 = $Create.Array($$createType4);
const $$createType6 = $models.PlatformInfo.createFrom;
const $$createType7 = $Create.Nullable($$createType6);
const $$createType8 = $models.FileInfo.createFrom;
const $$createType9 = $Create.Array($$createType8);
const $$createType10 = $models.ProjectStatus.createFrom;
const $$createType11 = $Create.Nullable($$createType10);
const $$createType12 = $models.TreeNode.createFrom;
const $$createType13 = $Create.Array($$createType12);
const $$createType14 = $models.TagInfo.createFrom;
const $$createType15 = $Create.Array($$createType14);
const $$createType16 = $models.UserInfo.createFrom;
const $$createType17 = $Create.Nullable($$createType16);
