* chore: expose fs apis * chore: correct electron import path * update download api Signed-off-by: James <james@jan.ai> * update chat_completion Signed-off-by: James <james@jan.ai> * fix electron import Signed-off-by: James <james@jan.ai> * feat: adding API support at 1337 (#991) Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> * feat: Add /chat/completion api and handler * chore: add todo for modelList * chore: read engine.json for openai chat_completion (#1030) Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> * refactor: move routes to shared node module * refactor: exported modules from core with types (#1172) * refactor: exported modules from core with types * fix: fix file reading args * refactor: fileManager handles * fix: app issues with server refactoring * refactor: shared server module (#1210) * chore: resolve main * chore: update makefile --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> Co-authored-by: NamH <NamNh0122@gmail.com> Co-authored-by: hiro <vuonghoainam.work@gmail.com>
105 lines
2.6 KiB
TypeScript
105 lines
2.6 KiB
TypeScript
/**
|
|
* App Route APIs
|
|
* @description Enum of all the routes exposed by the app
|
|
*/
|
|
export enum AppRoute {
|
|
appDataPath = 'appDataPath',
|
|
appVersion = 'appVersion',
|
|
openExternalUrl = 'openExternalUrl',
|
|
openAppDirectory = 'openAppDirectory',
|
|
openFileExplore = 'openFileExplorer',
|
|
relaunch = 'relaunch',
|
|
joinPath = 'joinPath'
|
|
}
|
|
|
|
export enum AppEvent {
|
|
onAppUpdateDownloadUpdate = 'onAppUpdateDownloadUpdate',
|
|
onAppUpdateDownloadError = 'onAppUpdateDownloadError',
|
|
onAppUpdateDownloadSuccess = 'onAppUpdateDownloadSuccess',
|
|
}
|
|
|
|
export enum DownloadRoute {
|
|
abortDownload = 'abortDownload',
|
|
downloadFile = 'downloadFile',
|
|
pauseDownload = 'pauseDownload',
|
|
resumeDownload = 'resumeDownload',
|
|
}
|
|
|
|
export enum DownloadEvent {
|
|
onFileDownloadUpdate = 'onFileDownloadUpdate',
|
|
onFileDownloadError = 'onFileDownloadError',
|
|
onFileDownloadSuccess = 'onFileDownloadSuccess',
|
|
}
|
|
|
|
export enum ExtensionRoute {
|
|
baseExtensions = 'baseExtensions',
|
|
getActiveExtensions = 'getActiveExtensions',
|
|
installExtension = 'installExtension',
|
|
invokeExtensionFunc = 'invokeExtensionFunc',
|
|
updateExtension = 'updateExtension',
|
|
uninstallExtension = 'uninstallExtension',
|
|
}
|
|
export enum FileSystemRoute {
|
|
appendFileSync = 'appendFileSync',
|
|
copyFileSync = 'copyFileSync',
|
|
unlinkSync = 'unlinkSync',
|
|
existsSync = 'existsSync',
|
|
readdirSync = 'readdirSync',
|
|
mkdirSync = 'mkdirSync',
|
|
readFileSync = 'readFileSync',
|
|
rmdirSync = 'rmdirSync',
|
|
writeFileSync = 'writeFileSync',
|
|
}
|
|
export enum FileManagerRoute {
|
|
synceFile = 'syncFile',
|
|
getUserSpace = 'getUserSpace',
|
|
getResourcePath = 'getResourcePath',
|
|
}
|
|
|
|
export type ApiFunction = (...args: any[]) => any
|
|
|
|
export type AppRouteFunctions = {
|
|
[K in AppRoute]: ApiFunction
|
|
}
|
|
|
|
export type AppEventFunctions = {
|
|
[K in AppEvent]: ApiFunction
|
|
}
|
|
|
|
export type DownloadRouteFunctions = {
|
|
[K in DownloadRoute]: ApiFunction
|
|
}
|
|
|
|
export type DownloadEventFunctions = {
|
|
[K in DownloadEvent]: ApiFunction
|
|
}
|
|
|
|
export type ExtensionRouteFunctions = {
|
|
[K in ExtensionRoute]: ApiFunction
|
|
}
|
|
|
|
export type FileSystemRouteFunctions = {
|
|
[K in FileSystemRoute]: ApiFunction
|
|
}
|
|
|
|
export type FileManagerRouteFunctions = {
|
|
[K in FileManagerRoute]: ApiFunction
|
|
}
|
|
|
|
export type APIFunctions = AppRouteFunctions &
|
|
AppEventFunctions &
|
|
DownloadRouteFunctions &
|
|
DownloadEventFunctions &
|
|
ExtensionRouteFunctions &
|
|
FileSystemRouteFunctions &
|
|
FileManagerRoute
|
|
|
|
export const APIRoutes = [
|
|
...Object.values(AppRoute),
|
|
...Object.values(DownloadRoute),
|
|
...Object.values(ExtensionRoute),
|
|
...Object.values(FileSystemRoute),
|
|
...Object.values(FileManagerRoute),
|
|
]
|
|
export const APIEvents = [...Object.values(AppEvent), ...Object.values(DownloadEvent)]
|