Refactor: Implement type safety plan

This commit is contained in:
gpt-engineer-app[bot]
2025-10-17 14:35:15 +00:00
parent 921abb63a1
commit 0db54b402b
12 changed files with 290 additions and 38 deletions

View File

@@ -14,6 +14,23 @@ interface EntityCache {
companies: Map<string, { id: string; name: string }>;
}
/**
* Generic submission content type
*/
interface GenericSubmissionContent {
name?: string;
entity_id?: string;
entity_name?: string;
park_id?: string;
ride_id?: string;
company_id?: string;
manufacturer_id?: string;
designer_id?: string;
operator_id?: string;
property_owner_id?: string;
[key: string]: unknown;
}
/**
* Result of entity name resolution
*/
@@ -46,7 +63,7 @@ export interface ResolvedEntityNames {
*/
export function resolveEntityName(
submissionType: string,
content: any,
content: GenericSubmissionContent | null | undefined,
entityCache: EntityCache
): ResolvedEntityNames {
let entityName = content?.name || 'Unknown';
@@ -134,7 +151,7 @@ export function getEntityDisplayName(
* @param submissions - Array of submission objects
* @returns Object containing Sets of IDs for each entity type
*/
export function extractEntityIds(submissions: any[]): {
export function extractEntityIds(submissions: Array<{ content: unknown; submission_type: string }>): {
rideIds: Set<string>;
parkIds: Set<string>;
companyIds: Set<string>;
@@ -144,7 +161,7 @@ export function extractEntityIds(submissions: any[]): {
const companyIds = new Set<string>();
submissions.forEach(submission => {
const content = submission.content as any;
const content = submission.content as GenericSubmissionContent | null | undefined;
if (content && typeof content === 'object') {
// Direct entity references
if (content.ride_id) rideIds.add(content.ride_id);