Mulai migrasi Zesdex dari Rust ke TypeScript/Bun.
- Root workspace package.json, tsconfig strict, bun.lock, gitignore fix
- Paket @zesdex/domain (apps/packages/domain):
- core: ChatMessage/Conversation/ToolCall/SseParser/repairJson/
sanitizeToolArguments/UsageStats/Store/DomainError
- auth: Session/SessionId/SessionLock/OAuth + repository & service interfaces
- cms: AppConfig/Settings/SettingsPatch/Memory/EditLog + repository &
service interfaces
- agent: TurnEvent/SessionRuntime/AgentTurnParams/AgentProgress/prompt
- subagent & workflow models
- Wire-shape JSON disamakan dengan Rust (serde rename/flatten/skip_if)
- 27 unit test Bun port dari test Rust (SseParser, repair_json, resolve_effective_model, session id)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
/**
|
|
* Domain error types for the CMS module. Mirrors `cms/error.rs`.
|
|
*/
|
|
import type { DomainError } from "../core/error.ts";
|
|
|
|
/** Shared repository error type for CMS persistence. */
|
|
export type RepositoryError = DomainError;
|
|
|
|
/** Errors from service / use-case operations in the CMS domain. */
|
|
export type ServiceError =
|
|
| { kind: "repository"; error: DomainError }
|
|
| { kind: "invalid_input"; message: string }
|
|
| { kind: "other"; message: string };
|
|
|
|
export function cmsRepositoryErr(err: DomainError): ServiceError {
|
|
return { kind: "repository", error: err };
|
|
}
|
|
export function invalidInput(message: string): ServiceError {
|
|
return { kind: "invalid_input", message };
|
|
}
|
|
export function cmsOther(message: string): ServiceError {
|
|
return { kind: "other", message };
|
|
}
|
|
|
|
export function cmsServiceErrorToString(e: ServiceError): string {
|
|
switch (e.kind) {
|
|
case "repository":
|
|
return `repository error: ${e.error.message}`;
|
|
case "invalid_input":
|
|
return `invalid input: ${e.message}`;
|
|
case "other":
|
|
return e.message;
|
|
}
|
|
} |