feat: Enable TypeScript strict mode

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 00:58:42 +00:00
parent 061c06be29
commit d126be2908
15 changed files with 308 additions and 68 deletions

View File

@@ -4,14 +4,15 @@ import { logger } from './logger';
import { extractCloudflareImageId } from './cloudflareImageUtils';
// Core submission item interface with dependencies
// Type safety for item_data will be added in Phase 5 after fixing components
// NOTE: item_data and original_data use `unknown` because they contain dynamic structures
// that vary by item_type. Use type guards from @/types/submission-item-data.ts to access safely.
export interface SubmissionItemWithDeps {
id: string;
submission_id: string;
item_type: string;
item_data: any; // Complex nested structure - will be typed properly in Phase 5
original_data: any; // Complex nested structure - will be typed properly in Phase 5
item_data: unknown; // Dynamic structure - use type guards for safe access
original_data?: unknown; // Dynamic structure - use type guards for safe access
action_type?: 'create' | 'edit' | 'delete';
status: 'pending' | 'approved' | 'rejected' | 'flagged' | 'skipped'; // Matches ReviewStatus from statuses.ts
depends_on: string | null;
@@ -43,7 +44,10 @@ export interface ConflictCheckResult {
serverVersion?: {
last_modified_at: string;
last_modified_by: string;
modified_by_profile?: any;
modified_by_profile?: {
username: string;
display_name?: string;
};
} | null;
}
@@ -110,18 +114,28 @@ export async function detectDependencyConflicts(
// Suggest creating parent
if (parent.status !== 'rejected') {
const parentData = typeof parent.item_data === 'object' && parent.item_data !== null && !Array.isArray(parent.item_data)
? parent.item_data as Record<string, unknown>
: {};
const parentName = 'name' in parentData && typeof parentData.name === 'string' ? parentData.name : 'Unnamed';
suggestions.push({
action: 'create_parent',
label: `Also approve ${parent.item_type}: ${parent.item_data.name}`,
label: `Also approve ${parent.item_type}: ${parentName}`,
});
}
// Suggest linking to existing entity
if (parent.item_type === 'park') {
const parentData = typeof parent.item_data === 'object' && parent.item_data !== null && !Array.isArray(parent.item_data)
? parent.item_data as Record<string, unknown>
: {};
const parentName = 'name' in parentData && typeof parentData.name === 'string' ? parentData.name : '';
const { data: parks } = await supabase
.from('parks')
.select('id, name')
.ilike('name', `%${parent.item_data.name}%`)
.ilike('name', `%${parentName}%`)
.limit(3);
parks?.forEach(park => {
@@ -189,11 +203,15 @@ export async function approveSubmissionItems(
try {
// Determine if this is an edit by checking for entity_id in item_data
const itemData = typeof item.item_data === 'object' && item.item_data !== null && !Array.isArray(item.item_data)
? item.item_data as Record<string, unknown>
: {};
isEdit = !!(
item.item_data.park_id ||
item.item_data.ride_id ||
item.item_data.company_id ||
item.item_data.ride_model_id
('park_id' in itemData && itemData.park_id) ||
('ride_id' in itemData && itemData.ride_id) ||
('company_id' in itemData && itemData.company_id) ||
('ride_model_id' in itemData && itemData.ride_model_id)
);
// Create the entity based on type with dependency resolution