Files
gridpilot.gg/apps/website/lib/contracts/services/Service.ts
2026-01-12 01:45:19 +01:00

37 lines
946 B
TypeScript

/**
* Service contract
*
* Orchestration boundary for server-side operations.
* Returns API DTOs or Page DTOs only.
* Must be stateless.
*
* Based on WEBSITE_CONTRACT.md:
* - Services orchestrate IO and composition
* - They do not prepare UI
* - They return ApiDto or PageDto only
*/
/**
* Base service interface for orchestration operations
*/
export interface Service<TApiDto = unknown, TPageDto = unknown> {
/**
* Execute a service operation
* Returns either API Transport DTO or Page DTO
*/
execute(...args: unknown[]): Promise<TApiDto | TPageDto>;
}
/**
* Service that returns API Transport DTOs
*/
export interface ApiService<TApiDto = unknown> extends Service<TApiDto, never> {
execute(...args: unknown[]): Promise<TApiDto>;
}
/**
* Service that returns Page DTOs
*/
export interface PageService<TPageDto = unknown> extends Service<never, TPageDto> {
execute(...args: unknown[]): Promise<TPageDto>;
}