Fix: Type safety and unit validation

This commit is contained in:
gpt-engineer-app[bot]
2025-10-21 15:05:50 +00:00
parent bcba0a4f0c
commit 65a6ed1acb
10 changed files with 146 additions and 32 deletions

View File

@@ -356,7 +356,12 @@ export async function performModerationAction(
// Use type-safe table queries based on item type
if (item.type === 'review') {
const reviewUpdate = {
const reviewUpdate: {
moderation_status: 'approved' | 'rejected' | 'pending';
moderated_at: string;
moderated_by: string;
reviewer_notes?: string;
} = {
moderation_status: action,
moderated_at: new Date().toISOString(),
moderated_by: moderatorId,
@@ -364,13 +369,18 @@ export async function performModerationAction(
};
const result = await createTableQuery('reviews')
.update(reviewUpdate as any) // Type assertion needed for dynamic update
.update(reviewUpdate)
.eq('id', item.id)
.select();
error = result.error;
data = result.data;
} else {
const submissionUpdate = {
const submissionUpdate: {
status: 'approved' | 'rejected' | 'pending';
reviewed_at: string;
reviewer_id: string;
reviewer_notes?: string;
} = {
status: action,
reviewed_at: new Date().toISOString(),
reviewer_id: moderatorId,
@@ -378,7 +388,7 @@ export async function performModerationAction(
};
const result = await createTableQuery('content_submissions')
.update(submissionUpdate as any) // Type assertion needed for dynamic update
.update(submissionUpdate)
.eq('id', item.id)
.select();
error = result.error;

View File

@@ -249,7 +249,7 @@ class NotificationService {
previous: previousPrefs || null,
updated: validated,
timestamp: new Date().toISOString()
} as any
}
}]);
logger.info('Notification preferences updated', {

View File

@@ -107,8 +107,8 @@ interface RequestMetadata {
}
async function logRequestMetadata(metadata: RequestMetadata): Promise<void> {
// Type assertion needed until Supabase types regenerate after migration
const { error } = await supabase.rpc('log_request_metadata' as any, {
// Safe cast - RPC function exists in database
const { error } = await supabase.rpc('log_request_metadata' as 'log_request_metadata', {
p_request_id: metadata.requestId,
p_user_id: metadata.userId || null,
p_endpoint: metadata.endpoint,

View File

@@ -556,8 +556,8 @@ export function extractChangedFields<T extends Record<string, any>>(
// ═══ SPECIAL HANDLING: LOCATION OBJECTS ═══
// Location can be an object (from form) vs location_id (from DB)
if (key === 'location' && newValue && typeof newValue === 'object') {
const oldLoc = originalData.location as any;
if (!oldLoc || !isEqual(oldLoc, newValue)) {
const oldLoc = originalData.location;
if (!oldLoc || typeof oldLoc !== 'object' || !isEqual(oldLoc, newValue)) {
changes[key as keyof T] = newValue;
}
return;