Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | // Base API Response Types
export interface ApiResponse<T> {
data: T;
error: null;
}
export interface ApiError {
data: null;
error: {
message: string;
code?: string;
details?: any;
hint?: string;
};
}
export type ApiResult<T> = ApiResponse<T> | ApiError;
// Pagination Types
export interface PaginationParams {
page?: number;
limit?: number;
offset?: number;
}
export interface PaginatedResponse<T> {
data: T[];
count: number;
page?: number;
limit?: number;
hasMore?: boolean;
nextPage?: number | null;
prevPage?: number | null;
}
// Query Parameter Types
export interface BaseQueryParams {
select?: string;
orderBy?: string;
ascending?: boolean;
limit?: number;
offset?: number;
user_id?: string;
}
export interface FilterParams {
search?: string;
dateFrom?: string;
dateTo?: string;
isRead?: boolean;
isArchived?: boolean;
isLiked?: boolean;
tagIds?: string[];
sourceIds?: string[];
groupIds?: string[];
}
export interface NewsletterQueryParams extends BaseQueryParams, FilterParams, PaginationParams {
includeRelations?: boolean;
orderDirection?: 'asc' | 'desc';
groupIds?: string[];
}
export interface NewsletterSourceQueryParams extends BaseQueryParams, PaginationParams {
includeCount?: boolean;
excludeArchived?: boolean;
search?: string;
orderDirection?: 'asc' | 'desc';
timeFilter?: {
dateFrom?: string;
dateTo?: string;
};
isArchived?: boolean;
isRead?: boolean;
isLiked?: boolean;
tagIds?: string[];
sourceIds?: string[];
}
export interface TagQueryParams extends BaseQueryParams, PaginationParams {
includeCount?: boolean;
search?: string;
}
// Mutation Parameter Types
export interface CreateNewsletterParams {
title: string;
content: string;
summary?: string;
image_url?: string;
newsletter_source_id?: string;
tag_ids?: string[];
}
export interface UpdateNewsletterParams {
id: string;
title?: string;
content?: string;
summary?: string;
image_url?: string;
is_read?: boolean;
is_liked?: boolean;
is_archived?: boolean;
tag_ids?: string[];
}
export interface BulkUpdateNewsletterParams {
ids: string[];
updates: Partial<{
is_read: boolean;
is_liked: boolean;
is_archived: boolean;
}>;
}
export interface CreateNewsletterSourceParams {
name: string;
from: string;
}
export interface UpdateNewsletterSourceParams {
id: string;
name?: string;
from?: string;
is_archived?: boolean;
}
export interface BulkUpdateNewsletterSourceParams {
updates: Array<{ id: string; updates: Omit<UpdateNewsletterSourceParams, 'id'> }>;
}
export interface CreateTagParams {
name: string;
color: string;
}
export interface UpdateTagParams {
id: string;
name?: string;
color?: string;
}
export interface CreateReadingQueueItemParams {
newsletter_id: string;
priority?: string;
notes?: string;
}
export interface UpdateReadingQueueItemParams {
id: string;
priority?: string;
notes?: string;
}
export interface CreateNewsletterSourceGroupParams {
name: string;
source_ids?: string[];
}
export interface UpdateNewsletterSourceGroupParams {
id: string;
name?: string;
source_ids?: string[];
}
export interface CreateNewsletterGroupParams {
name: string;
color?: string;
sourceIds?: string[];
}
export interface UpdateNewsletterGroupParams {
id: string;
name?: string;
color?: string;
sourceIds?: string[];
}
// Database Operation Types
export interface DatabaseOperation {
table: string;
operation: 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE';
filters?: Record<string, any>;
data?: Record<string, any>;
}
// Cache-related Types
export interface CacheInvalidationParams {
patterns?: string[];
exact?: string[];
tags?: string[];
}
// Auth-related API Types
export interface AuthenticatedOperation {
requireAuth: true;
userId?: string;
}
// Real-time subscription types
export interface RealtimeSubscriptionParams {
table: string;
event?: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
filter?: string;
schema?: string;
}
// Error handling types
export interface ValidationError {
field: string;
message: string;
code: string;
}
export interface ApiValidationError {
message: string;
errors: ValidationError[];
}
// Performance monitoring types
export interface PerformanceMetrics {
operation: string;
duration: number;
timestamp: number;
success: boolean;
error?: string;
}
// Batch operation types
export interface BatchOperation<T> {
operations: T[];
options?: {
continueOnError?: boolean;
transactional?: boolean;
};
}
export interface BatchResult<T> {
results: (T | null)[];
errors: (Error | null)[];
successCount: number;
errorCount: number;
}
// File upload types (for future use)
export interface FileUploadParams {
file: File;
bucket: string;
path?: string;
options?: {
cacheControl?: string;
contentType?: string;
upsert?: boolean;
};
}
export interface FileUploadResult {
path: string;
url: string;
size: number;
contentType: string;
}
// Search and indexing types
export interface SearchParams {
query: string;
table?: string;
columns?: string[];
limit?: number;
offset?: number;
options?: {
fuzzy?: boolean;
highlight?: boolean;
language?: string;
};
}
export interface SearchResult<T> {
data: T[];
count: number;
query: string;
processingTime: number;
highlights?: Record<string, string[]>;
}
// Export utility type helpers
export type WithoutId<T> = Omit<T, 'id'>;
export type WithOptionalId<T> = Omit<T, 'id'> & { id?: string };
export type UpdateParams<T> = Partial<WithoutId<T>> & { id: string };
export type CreateParams<T> = WithoutId<T>;
// Generic CRUD operation types
export interface CrudOperations<T, TCreate = CreateParams<T>, TUpdate = UpdateParams<T>> {
getById(id: string, params?: BaseQueryParams): Promise<T | null>;
getAll(params?: BaseQueryParams & PaginationParams): Promise<PaginatedResponse<T>>;
create(data: TCreate): Promise<T>;
update(data: TUpdate): Promise<T>;
delete(id: string): Promise<boolean>;
bulkCreate(data: TCreate[]): Promise<BatchResult<T>>;
bulkUpdate(data: TUpdate[]): Promise<BatchResult<T>>;
bulkDelete(ids: string[]): Promise<BatchResult<boolean>>;
}
|