Files
gridpilot.gg/apps/website/lib/contracts/mutations/Mutation.ts
2026-01-12 19:24:59 +01:00

33 lines
896 B
TypeScript

/**
* Mutation Contract
*
* Purpose: Framework-agnostic write operations
*
* Rules:
* - Orchestrates services for writes
* - No HTTP/API calls directly
* - No 'use client' directive
* - No 'use server' directive
* - Must be in lib/mutations/
* - Must be named *Mutation
* - Can be called from Server Actions
* - Single responsibility: ONE operation per mutation
*
* Pattern:
* Server Action → Mutation → Service → API Client
*
* Design Principle:
* Each mutation does ONE thing. If you need multiple operations,
* create multiple mutation classes (e.g., UpdateUserStatusMutation, DeleteUserMutation).
* This follows the same pattern as Page Queries.
*/
export interface Mutation<TInput = void, TOutput = void> {
/**
* Execute the mutation
*
* @param input - Mutation input
* @returns Output (optional)
*/
execute(input: TInput): Promise<TOutput>;
}