- apps/api: FastAPI backend with Dockerfile - apps/web: Next.js frontend with Dockerfile - apps/sensor: Signal collection agent - packages: shared packages Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
1.1 KiB
TypeScript
69 lines
1.1 KiB
TypeScript
/**
|
|
* DATA 積木 - 資料適配器介面
|
|
* 用途: PostgreSQL, Redis, S3, Vector DB
|
|
*/
|
|
|
|
import type { LeWOOOgoPlugin } from './plugin'
|
|
|
|
/**
|
|
* 查詢請求
|
|
*/
|
|
export interface QueryRequest {
|
|
operation: 'select' | 'insert' | 'update' | 'delete' | 'custom'
|
|
collection?: string
|
|
filter?: Record<string, unknown>
|
|
data?: unknown
|
|
options?: {
|
|
limit?: number
|
|
offset?: number
|
|
orderBy?: string
|
|
orderDirection?: 'asc' | 'desc'
|
|
}
|
|
raw?: string
|
|
}
|
|
|
|
/**
|
|
* 查詢結果
|
|
*/
|
|
export interface QueryResult<T = unknown> {
|
|
data: T
|
|
rowCount?: number
|
|
metadata?: Record<string, unknown>
|
|
}
|
|
|
|
/**
|
|
* 連線狀態
|
|
*/
|
|
export interface ConnectionStatus {
|
|
connected: boolean
|
|
latency?: number
|
|
error?: string
|
|
}
|
|
|
|
/**
|
|
* DATA 資料適配器 Plugin
|
|
*/
|
|
export interface DataAdapter extends LeWOOOgoPlugin {
|
|
category: 'DATA'
|
|
|
|
/**
|
|
* 建立連線
|
|
*/
|
|
connect(): Promise<void>
|
|
|
|
/**
|
|
* 執行查詢
|
|
*/
|
|
query<T = unknown>(request: QueryRequest): Promise<QueryResult<T>>
|
|
|
|
/**
|
|
* 檢查連線狀態
|
|
*/
|
|
getConnectionStatus(): ConnectionStatus
|
|
|
|
/**
|
|
* 斷開連線
|
|
*/
|
|
disconnect(): Promise<void>
|
|
}
|