Initial commit
This commit is contained in:
15
shared/modules/ai/index.ts
Normal file
15
shared/modules/ai/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineApiModule } from '../types.js'
|
||||
|
||||
export const AI_MODULE = defineApiModule({
|
||||
id: 'ai',
|
||||
name: 'AI',
|
||||
basePath: '/ai',
|
||||
order: 70,
|
||||
version: '1.0.0',
|
||||
frontend: {
|
||||
enabled: false,
|
||||
},
|
||||
backend: {
|
||||
enabled: true,
|
||||
},
|
||||
})
|
||||
15
shared/modules/document-parser/index.ts
Normal file
15
shared/modules/document-parser/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineApiModule } from '../types.js'
|
||||
|
||||
export const DOCUMENT_PARSER_MODULE = defineApiModule({
|
||||
id: 'document-parser',
|
||||
name: 'Document Parser',
|
||||
basePath: '/document-parser',
|
||||
order: 60,
|
||||
version: '1.0.0',
|
||||
frontend: {
|
||||
enabled: false,
|
||||
},
|
||||
backend: {
|
||||
enabled: true,
|
||||
},
|
||||
})
|
||||
12
shared/modules/home/index.ts
Normal file
12
shared/modules/home/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineModule } from '../types.js'
|
||||
|
||||
export const HOME_MODULE = defineModule({
|
||||
id: 'home',
|
||||
name: '首页',
|
||||
basePath: '/home',
|
||||
order: 0,
|
||||
version: '1.0.0',
|
||||
backend: {
|
||||
enabled: false,
|
||||
},
|
||||
})
|
||||
1
shared/modules/index.ts
Normal file
1
shared/modules/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './types.js'
|
||||
10
shared/modules/pydemos/api.ts
Normal file
10
shared/modules/pydemos/api.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineEndpoints } from '../types.js'
|
||||
|
||||
export const PYDEMOS_ENDPOINTS = defineEndpoints({
|
||||
list: { path: '/', method: 'GET' },
|
||||
create: { path: '/create', method: 'POST' },
|
||||
delete: { path: '/delete', method: 'DELETE' },
|
||||
rename: { path: '/rename', method: 'POST' },
|
||||
})
|
||||
|
||||
export type PyDemosEndpoints = typeof PYDEMOS_ENDPOINTS
|
||||
15
shared/modules/pydemos/index.ts
Normal file
15
shared/modules/pydemos/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineApiModule } from '../types.js'
|
||||
import { PYDEMOS_ENDPOINTS } from './api.js'
|
||||
|
||||
export * from './api.js'
|
||||
|
||||
export const PYDEMOS_MODULE = defineApiModule({
|
||||
id: 'pydemos',
|
||||
name: 'Python Demos',
|
||||
basePath: '/pydemos',
|
||||
order: 50,
|
||||
version: '1.0.0',
|
||||
endpoints: PYDEMOS_ENDPOINTS,
|
||||
})
|
||||
|
||||
export type { PyDemosEndpoints } from './api.js'
|
||||
10
shared/modules/recycle-bin/api.ts
Normal file
10
shared/modules/recycle-bin/api.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineEndpoints } from '../types.js'
|
||||
|
||||
export const RECYCLE_BIN_ENDPOINTS = defineEndpoints({
|
||||
list: { path: '/', method: 'GET' },
|
||||
restore: { path: '/restore', method: 'POST' },
|
||||
permanent: { path: '/permanent', method: 'DELETE' },
|
||||
empty: { path: '/empty', method: 'DELETE' },
|
||||
})
|
||||
|
||||
export type RecycleBinEndpoints = typeof RECYCLE_BIN_ENDPOINTS
|
||||
15
shared/modules/recycle-bin/index.ts
Normal file
15
shared/modules/recycle-bin/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineApiModule } from '../types.js'
|
||||
import { RECYCLE_BIN_ENDPOINTS } from './api.js'
|
||||
|
||||
export * from './api.js'
|
||||
|
||||
export const RECYCLE_BIN_MODULE = defineApiModule({
|
||||
id: 'recycle-bin',
|
||||
name: '回收站',
|
||||
basePath: '/recycle-bin',
|
||||
order: 40,
|
||||
version: '1.0.0',
|
||||
endpoints: RECYCLE_BIN_ENDPOINTS,
|
||||
})
|
||||
|
||||
export type { RecycleBinEndpoints } from './api.js'
|
||||
12
shared/modules/remote/api.ts
Normal file
12
shared/modules/remote/api.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineEndpoints } from '../types.js'
|
||||
|
||||
export const REMOTE_ENDPOINTS = defineEndpoints({
|
||||
getConfig: { path: '/config', method: 'GET' },
|
||||
saveConfig: { path: '/config', method: 'POST' },
|
||||
getScreenshot: { path: '/screenshot', method: 'GET' },
|
||||
saveScreenshot: { path: '/screenshot', method: 'POST' },
|
||||
getData: { path: '/data', method: 'GET' },
|
||||
saveData: { path: '/data', method: 'POST' },
|
||||
})
|
||||
|
||||
export type RemoteEndpoints = typeof REMOTE_ENDPOINTS
|
||||
16
shared/modules/remote/index.ts
Normal file
16
shared/modules/remote/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { defineApiModule } from '../types.js'
|
||||
import { REMOTE_ENDPOINTS } from './api.js'
|
||||
|
||||
export * from './types.js'
|
||||
export * from './api.js'
|
||||
|
||||
export const REMOTE_MODULE = defineApiModule({
|
||||
id: 'remote',
|
||||
name: '远程',
|
||||
basePath: '/remote',
|
||||
order: 25,
|
||||
version: '1.0.0',
|
||||
endpoints: REMOTE_ENDPOINTS,
|
||||
})
|
||||
|
||||
export type { RemoteEndpoints } from './api.js'
|
||||
11
shared/modules/remote/types.ts
Normal file
11
shared/modules/remote/types.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export interface RemoteDevice {
|
||||
id: string
|
||||
deviceName: string
|
||||
serverHost: string
|
||||
desktopPort: number
|
||||
gitPort: number
|
||||
}
|
||||
|
||||
export interface RemoteConfig {
|
||||
devices: RemoteDevice[]
|
||||
}
|
||||
12
shared/modules/search/index.ts
Normal file
12
shared/modules/search/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineModule } from '../types.js'
|
||||
|
||||
export const SEARCH_MODULE = defineModule({
|
||||
id: 'search',
|
||||
name: '搜索',
|
||||
basePath: '/search',
|
||||
order: 10,
|
||||
version: '1.0.0',
|
||||
backend: {
|
||||
enabled: false,
|
||||
},
|
||||
})
|
||||
12
shared/modules/settings/index.ts
Normal file
12
shared/modules/settings/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineModule } from '../types.js'
|
||||
|
||||
export const SETTINGS_MODULE = defineModule({
|
||||
id: 'settings',
|
||||
name: '设置',
|
||||
basePath: '/settings',
|
||||
order: 100,
|
||||
version: '1.0.0',
|
||||
backend: {
|
||||
enabled: false,
|
||||
},
|
||||
})
|
||||
13
shared/modules/time-tracking/api.ts
Normal file
13
shared/modules/time-tracking/api.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { defineEndpoints } from '../types.js'
|
||||
|
||||
export const TIME_TRACKING_ENDPOINTS = defineEndpoints({
|
||||
current: { path: '/current', method: 'GET' },
|
||||
event: { path: '/event', method: 'POST' },
|
||||
day: { path: '/day/:date', method: 'GET' },
|
||||
week: { path: '/week/:startDate', method: 'GET' },
|
||||
month: { path: '/month/:yearMonth', method: 'GET' },
|
||||
year: { path: '/year/:year', method: 'GET' },
|
||||
stats: { path: '/stats', method: 'GET' },
|
||||
})
|
||||
|
||||
export type TimeTrackingEndpoints = typeof TIME_TRACKING_ENDPOINTS
|
||||
15
shared/modules/time-tracking/index.ts
Normal file
15
shared/modules/time-tracking/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { defineApiModule } from '../types.js'
|
||||
import { TIME_TRACKING_ENDPOINTS } from './api.js'
|
||||
|
||||
export * from './api.js'
|
||||
|
||||
export const TIME_TRACKING_MODULE = defineApiModule({
|
||||
id: 'time-tracking',
|
||||
name: '时间统计',
|
||||
basePath: '/time',
|
||||
order: 20,
|
||||
version: '1.0.0',
|
||||
endpoints: TIME_TRACKING_ENDPOINTS,
|
||||
})
|
||||
|
||||
export type { TimeTrackingEndpoints } from './api.js'
|
||||
12
shared/modules/todo/api.ts
Normal file
12
shared/modules/todo/api.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineEndpoints } from '../types.js'
|
||||
|
||||
export const TODO_ENDPOINTS = defineEndpoints({
|
||||
list: { path: '/', method: 'GET' },
|
||||
save: { path: '/save', method: 'POST' },
|
||||
add: { path: '/add', method: 'POST' },
|
||||
toggle: { path: '/toggle', method: 'POST' },
|
||||
update: { path: '/update', method: 'POST' },
|
||||
delete: { path: '/delete', method: 'DELETE' },
|
||||
})
|
||||
|
||||
export type TodoEndpoints = typeof TODO_ENDPOINTS
|
||||
16
shared/modules/todo/index.ts
Normal file
16
shared/modules/todo/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { defineApiModule } from '../types.js'
|
||||
import { TODO_ENDPOINTS } from './api.js'
|
||||
|
||||
export * from './types.js'
|
||||
export * from './api.js'
|
||||
|
||||
export const TODO_MODULE = defineApiModule({
|
||||
id: 'todo',
|
||||
name: 'TODO',
|
||||
basePath: '/todo',
|
||||
order: 30,
|
||||
version: '1.0.0',
|
||||
endpoints: TODO_ENDPOINTS,
|
||||
})
|
||||
|
||||
export type { TodoEndpoints } from './api.js'
|
||||
22
shared/modules/todo/types.ts
Normal file
22
shared/modules/todo/types.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { DayTodo } from '../../types/todo.js'
|
||||
|
||||
export interface TodoFilePath {
|
||||
relPath: string
|
||||
fullPath: string
|
||||
}
|
||||
|
||||
export interface ParsedTodoFile {
|
||||
fullPath: string
|
||||
dayTodos: DayTodo[]
|
||||
}
|
||||
|
||||
export interface GetTodoResult {
|
||||
dayTodos: DayTodo[]
|
||||
year: number
|
||||
month: number
|
||||
}
|
||||
|
||||
export interface MigrationContext {
|
||||
todayStr: string
|
||||
yesterdayStr: string
|
||||
}
|
||||
83
shared/modules/types.ts
Normal file
83
shared/modules/types.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
|
||||
|
||||
export interface EndpointDefinition {
|
||||
path: string
|
||||
method: HttpMethod
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface ModuleEndpoints {
|
||||
[key: string]: EndpointDefinition
|
||||
}
|
||||
|
||||
export interface ModuleFrontendConfig {
|
||||
enabled?: boolean
|
||||
icon?: string
|
||||
component?: string
|
||||
}
|
||||
|
||||
export interface ModuleBackendConfig {
|
||||
enabled?: boolean
|
||||
createModule?: string
|
||||
}
|
||||
|
||||
export interface ModuleDefinition<
|
||||
TId extends string = string,
|
||||
TEndpoints extends ModuleEndpoints = ModuleEndpoints
|
||||
> {
|
||||
id: TId
|
||||
name: string
|
||||
basePath: string
|
||||
order: number
|
||||
version?: string
|
||||
endpoints?: TEndpoints
|
||||
dependencies?: string[]
|
||||
icon?: string
|
||||
frontend?: ModuleFrontendConfig
|
||||
backend?: ModuleBackendConfig
|
||||
}
|
||||
|
||||
export interface ApiModuleConfig<
|
||||
TId extends string = string,
|
||||
TEndpoints extends ModuleEndpoints = ModuleEndpoints
|
||||
> extends ModuleDefinition<TId, TEndpoints> {
|
||||
version: string
|
||||
}
|
||||
|
||||
export function defineModule<
|
||||
TId extends string,
|
||||
TEndpoints extends ModuleEndpoints
|
||||
>(
|
||||
config: ModuleDefinition<TId, TEndpoints>
|
||||
): ModuleDefinition<TId, TEndpoints> {
|
||||
return config
|
||||
}
|
||||
|
||||
export function defineApiModule<
|
||||
TId extends string,
|
||||
TEndpoints extends ModuleEndpoints
|
||||
>(
|
||||
config: ApiModuleConfig<TId, TEndpoints>
|
||||
): ApiModuleConfig<TId, TEndpoints> {
|
||||
return config
|
||||
}
|
||||
|
||||
export function defineEndpoints<TEndpoints extends ModuleEndpoints>(
|
||||
endpoints: TEndpoints
|
||||
): TEndpoints {
|
||||
return endpoints
|
||||
}
|
||||
|
||||
export type ExtractEndpointPaths<TEndpoints extends ModuleEndpoints> = {
|
||||
[K in keyof TEndpoints]: TEndpoints[K]['path']
|
||||
}
|
||||
|
||||
export type ExtractEndpointMethods<TEndpoints extends ModuleEndpoints> = {
|
||||
[K in keyof TEndpoints]: TEndpoints[K]['method']
|
||||
}
|
||||
|
||||
export type EndpointConfig = EndpointDefinition
|
||||
|
||||
export interface ModuleApiConfig {
|
||||
endpoints: ModuleEndpoints
|
||||
}
|
||||
12
shared/modules/weread/index.ts
Normal file
12
shared/modules/weread/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineModule } from '../types.js'
|
||||
|
||||
export const WEREAD_MODULE = defineModule({
|
||||
id: 'weread',
|
||||
name: '微信读书',
|
||||
basePath: '/weread',
|
||||
order: 20,
|
||||
version: '1.0.0',
|
||||
backend: {
|
||||
enabled: false,
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user