website refactor
This commit is contained in:
33
apps/website/lib/contracts/mutations/Mutation.ts
Normal file
33
apps/website/lib/contracts/mutations/Mutation.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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>;
|
||||
}
|
||||
Reference in New Issue
Block a user