From ee1ca93894f938ac03dbc232fe2cecc93c9acb30 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 15 Jan 2026 19:27:53 -0500 Subject: [PATCH] fix: resolve TypeErrors in core, events, and journals modules - Core: Use FormData in video clip components to fix EventTarget errors. - DB: Rename 'File' to 'ae_LocalFile' in db_core to prevent DOM type shadowing. - API: Strictly type 'order_by_li' across archives, events, and journals to match API definition. - API: Fix 'enabled'/'hidden' parameter types in search functions. - Generics: Add 'any' cast to 'processed_obj' in generic processors to fix indexing errors. - Journals: Update journal_entry creation to return null on failure, fix missing ID fields in DB save. --- src/lib/ae_archives/ae_archives__archive.ts | 3 +- .../ae_archives__archive_content.ts | 5 +-- .../ae_comp__hosted_files_clip_video.svelte | 31 ++++++++++++------- ...ae_comp__hosted_files_clip_video_v1.svelte | 25 ++++++++++----- src/lib/ae_core/core__hosted_files.ts | 6 ++-- src/lib/ae_core/db_core.ts | 9 ++++-- src/lib/ae_events/ae_events__event.ts | 1 + .../ae_events__event_badge_template.ts | 2 +- src/lib/ae_events/ae_events__event_device.ts | 7 +++-- src/lib/ae_events/ae_events__event_file.ts | 8 ++--- .../ae_events/ae_events__event_location.ts | 7 +++-- .../ae_events__event_presentation.ts | 2 +- .../ae_events/ae_events__event_presenter.ts | 2 +- src/lib/ae_events/ae_events__event_session.ts | 2 +- .../ae_journals/ae_journals__journal_entry.ts | 8 +++-- 15 files changed, 73 insertions(+), 45 deletions(-) diff --git a/src/lib/ae_archives/ae_archives__archive.ts b/src/lib/ae_archives/ae_archives__archive.ts index b8233211..2d9759ce 100644 --- a/src/lib/ae_archives/ae_archives__archive.ts +++ b/src/lib/ae_archives/ae_archives__archive.ts @@ -110,7 +110,7 @@ export async function load_ae_obj_li__archive({ name: 'ASC', updated_on: 'DESC', created_on: 'DESC' - }, + } as const, params = {}, try_cache = true, log_lvl = 0 @@ -124,6 +124,7 @@ export async function load_ae_obj_li__archive({ view?: string; limit?: number; offset?: number; + order_by_li?: Record | Record[]; params?: key_val; try_cache?: boolean; log_lvl?: number; diff --git a/src/lib/ae_archives/ae_archives__archive_content.ts b/src/lib/ae_archives/ae_archives__archive_content.ts index cdc0541e..3351605d 100644 --- a/src/lib/ae_archives/ae_archives__archive_content.ts +++ b/src/lib/ae_archives/ae_archives__archive_content.ts @@ -83,7 +83,7 @@ export async function load_ae_obj_li__archive_content({ name: 'ASC', updated_on: 'DESC', created_on: 'DESC' - }, + } as const, params = {}, try_cache = true, log_lvl = 0 @@ -96,6 +96,7 @@ export async function load_ae_obj_li__archive_content({ view?: string; limit?: number; offset?: number; + order_by_li?: Record | Record[]; params?: key_val; try_cache?: boolean; log_lvl?: number; @@ -166,7 +167,7 @@ export async function create_ae_obj__archive_content({ if (!archive_id) { console.log(`ERROR: Archives - Content - archive_id required to create`); - return false; + return null; } const result = await api.create_ae_obj_v3({ diff --git a/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte b/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte index 6b1a1119..ef4ab864 100644 --- a/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte +++ b/src/lib/ae_core/ae_comp__hosted_files_clip_video.svelte @@ -89,7 +89,15 @@ submit_status = 'clipping'; clip_complete = false; - let hosted_file_id = event.target.hosted_file_id.value; + const form = event.target as HTMLFormElement; + const formData = new FormData(form); + + let hosted_file_id = formData.get('hosted_file_id') as string; + let start_time = formData.get('start_time') as string; + let end_time = formData.get('end_time') as string; + let reencode = formData.get('reencode') as string; + let scale_down = formData.get('scale_down') as string; + let new_filename = formData.get('new_filename') as string; $ae_sess.files.processed_file_kv[hosted_file_id] = {}; $ae_sess.files.processed_file_kv[hosted_file_id].submit_status = 'clipping'; @@ -98,12 +106,11 @@ // $ae_sess.files.disable_submit__hosted_file_obj = true; $ae_loc.files.processed_file_kv[hosted_file_id] = {}; $ae_loc.files.processed_file_kv[hosted_file_id].submit_status = 'clipping'; - $ae_loc.files.processed_file_kv[hosted_file_id].start_time = event.target.start_time.value; - $ae_loc.files.processed_file_kv[hosted_file_id].end_time = event.target.end_time.value; - $ae_loc.files.processed_file_kv[hosted_file_id].reencode = event.target.reencode.value; - $ae_loc.files.processed_file_kv[hosted_file_id].scale_down = event.target.scale_down.value; - $ae_loc.files.processed_file_kv[hosted_file_id].new_filename = - event.target.new_filename.value; + $ae_loc.files.processed_file_kv[hosted_file_id].start_time = start_time; + $ae_loc.files.processed_file_kv[hosted_file_id].end_time = end_time; + $ae_loc.files.processed_file_kv[hosted_file_id].reencode = reencode; + $ae_loc.files.processed_file_kv[hosted_file_id].scale_down = scale_down; + $ae_loc.files.processed_file_kv[hosted_file_id].new_filename = new_filename; $ae_loc.files.processed_file_kv[hosted_file_id].clip_complete = false; let endpoint = `/hosted_file/${hosted_file_id}/clip_video`; @@ -111,13 +118,13 @@ let params = { link_to_type: link_to_type, link_to_id: link_to_id, - filename_no_ext: event.target.new_filename.value.replace('.mp4', ''), + filename_no_ext: new_filename.replace('.mp4', ''), from_type: 'mp4', // Video file type being converted to_type: 'mp4', // Video file type to convert to - start_time: event.target.start_time.value, - end_time: event.target.end_time.value, - reencode: event.target.reencode.value, - scale_down: event.target.scale_down.value + start_time: start_time, + end_time: end_time, + reencode: reencode, + scale_down: scale_down }; ae_promises[hosted_file_id] = {}; diff --git a/src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte b/src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte index b59a04b4..3b8f8a71 100644 --- a/src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte +++ b/src/lib/ae_core/ae_comp__hosted_files_clip_video_v1.svelte @@ -91,11 +91,20 @@ let hosted_file_results; + const form = event.target as HTMLFormElement; + const formData = new FormData(form); + const start_time = formData.get('start_time') as string; + const end_time = formData.get('end_time') as string; + const reencode = formData.get('reencode') as string; + + // Access file input by name or ID + const file_input = form.elements.namedItem(input_name) as HTMLInputElement; + form_kv = { - start_time: event.target.start_time.value, - end_time: event.target.end_time.value, - reencode: event.target.reencode.value, - video_file: event.target.file_list.files[0] + start_time: start_time, + end_time: end_time, + reencode: reencode, + video_file: file_input?.files?.[0] }; // const form_data = new FormData(); @@ -122,14 +131,14 @@ // params = null; - if (event.target[input_element_id].files.length > 0) { + if (file_input && file_input.files && file_input.files.length > 0) { task_id = link_to_id; // Ideally this should be the file hash, but we may be uploading multiple files at once. This should be done with a loop instead? // Loop through each file and upload them individually in event.target[input_element_id].files // The task_id should be the file hash. // processed_file_list[i] has the file hash_sha256, hash_sha256_match, warnings, uploaded, uploaded_bytes, filename, and file_size_bytes. - for (let i = 0; i < event.target[input_element_id].files.length; i++) { - let tmp_file = event.target[input_element_id].files[i]; + for (let i = 0; i < file_input.files.length; i++) { + let tmp_file = file_input.files[i]; task_id = $ae_sess.files.processed_file_list[i].hash_sha256; @@ -144,7 +153,7 @@ // hosted_file_results = await handle_input_upload_files(event.target[input_element_id].files, task_id); $ae_sess.files.processed_file_list = []; $ae_sess = $ae_sess; - event.target.reset(); + form.reset(); // await tick(); if (log_lvl) { diff --git a/src/lib/ae_core/core__hosted_files.ts b/src/lib/ae_core/core__hosted_files.ts index 6393da91..8e6f52e7 100644 --- a/src/lib/ae_core/core__hosted_files.ts +++ b/src/lib/ae_core/core__hosted_files.ts @@ -263,7 +263,6 @@ export function db_save_ae_obj_li__hosted_file({ try { const id_random = await db_core.file.put({ id: obj.hosted_file_id_random, - id_random: obj.hosted_file_id_random, hosted_file_id: obj.hosted_file_id_random, hosted_file_id_random: obj.hosted_file_id_random, @@ -274,6 +273,7 @@ export function db_save_ae_obj_li__hosted_file({ for_id_random: obj.for_id_random, account_id: obj.account_id_random, + account_id_random: obj.account_id_random, filename: obj.filename, extension: obj.extension, @@ -282,8 +282,8 @@ export function db_save_ae_obj_li__hosted_file({ enable: obj.enable, hide: obj.hide, - // priority: obj.priority, - // sort: obj.sort, + priority: obj.priority, + sort: obj.sort, group: obj.group, notes: obj.notes, created_on: obj.created_on, diff --git a/src/lib/ae_core/db_core.ts b/src/lib/ae_core/db_core.ts index 0e395f2d..cb2c9d35 100644 --- a/src/lib/ae_core/db_core.ts +++ b/src/lib/ae_core/db_core.ts @@ -14,7 +14,12 @@ import type { // kv = key value list // Updated 2026-01-09 - Unified Types -export interface File extends ae_HostedFile { +export interface ae_LocalFile extends ae_HostedFile { + // Link properties (present in Dexie schema) + for_type?: string; + for_id?: string; + for_id_random?: string; + // Legacy mapping support content_type?: string; filename_no_ext?: string; @@ -54,7 +59,7 @@ export interface User extends ae_User { // Updated 2026-01-09 export class MySubClassedDexie extends Dexie { - file!: Table; + file!: Table; person!: Table; user!: Table; account!: Table; diff --git a/src/lib/ae_events/ae_events__event.ts b/src/lib/ae_events/ae_events__event.ts index 229853bd..2107a5a1 100644 --- a/src/lib/ae_events/ae_events__event.ts +++ b/src/lib/ae_events/ae_events__event.ts @@ -125,6 +125,7 @@ export async function load_ae_obj_li__event({ view?: string; limit?: number; offset?: number; + order_by_li?: Record | Record[]; params?: key_val; try_cache?: boolean; log_lvl?: number; diff --git a/src/lib/ae_events/ae_events__event_badge_template.ts b/src/lib/ae_events/ae_events__event_badge_template.ts index 445a615a..7b4205cd 100644 --- a/src/lib/ae_events/ae_events__event_badge_template.ts +++ b/src/lib/ae_events/ae_events__event_badge_template.ts @@ -117,7 +117,7 @@ async function _process_generic_props>({ for (const key in processed_obj) { if (key.endsWith('_random')) { const newKey = key.slice(0, -7); // Remove '_random' suffix - processed_obj[newKey] = processed_obj[key]; + (processed_obj as any)[newKey] = processed_obj[key]; } } // Ensure 'id' is set from '[obj_type]_id_random' diff --git a/src/lib/ae_events/ae_events__event_device.ts b/src/lib/ae_events/ae_events__event_device.ts index 0abfc7da..90299a38 100644 --- a/src/lib/ae_events/ae_events__event_device.ts +++ b/src/lib/ae_events/ae_events__event_device.ts @@ -132,6 +132,7 @@ export async function load_ae_obj_li__event_device({ hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden limit?: number; // 99 offset?: number; // 0 + order_by_li?: Record | Record[]; params?: key_val; try_cache?: boolean; log_lvl?: number; @@ -485,8 +486,8 @@ export async function search__event_device({ console.log(`*** search__event_device() *** event_id=${event_id}`); } - const enabled: string = params.qry__enabled ?? 'enabled'; // all, disabled, enabled - const hidden: string = params.qry__hidden ?? 'not_hidden'; // all, hidden, not_hidden + const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled'; + const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'not_hidden'; const limit: number = params.qry__limit ?? 25; // 99 const offset: number = params.qry__offset ?? 0; // 0 @@ -720,7 +721,7 @@ async function _process_generic_props>({ for (const key in processed_obj) { if (key.endsWith('_random')) { const newKey = key.slice(0, -7); // Remove '_random' suffix - processed_obj[newKey] = processed_obj[key]; + (processed_obj as any)[newKey] = processed_obj[key]; } } // Ensure 'id' is set from '[obj_type]_id_random' diff --git a/src/lib/ae_events/ae_events__event_file.ts b/src/lib/ae_events/ae_events__event_file.ts index ebf59ec7..98828b6d 100644 --- a/src/lib/ae_events/ae_events__event_file.ts +++ b/src/lib/ae_events/ae_events__event_file.ts @@ -560,7 +560,7 @@ export async function search__event_file({ like_search_qry_str?: null | string; like_presentation_search_qry_str?: null | string; like_file_search_qry_str?: null | string; - order_by_li?: key_val; + order_by_li?: Record | Record[]; params?: any; try_cache?: boolean; log_lvl?: number; @@ -569,8 +569,8 @@ export async function search__event_file({ console.log(`*** search__event_file() *** event_id=${event_id}`); } - const enabled: string = params.qry__enabled ?? 'enabled'; // all, disabled, enabled - const hidden: string = params.qry__hidden ?? 'not_hidden'; // all, hidden, not_hidden + const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled'; + const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'not_hidden'; const limit: number = params.qry__limit ?? 25; // 99 const offset: number = params.qry__offset ?? 0; // 0 @@ -800,7 +800,7 @@ async function _process_generic_props>({ for (const key in processed_obj) { if (key.endsWith('_random')) { const newKey = key.slice(0, -7); // Remove '_random' suffix - processed_obj[newKey] = processed_obj[key]; + (processed_obj as any)[newKey] = processed_obj[key]; } } // Ensure 'id' is set from '[obj_type]_id_random' diff --git a/src/lib/ae_events/ae_events__event_location.ts b/src/lib/ae_events/ae_events__event_location.ts index 65f62e5f..0ca9a050 100644 --- a/src/lib/ae_events/ae_events__event_location.ts +++ b/src/lib/ae_events/ae_events__event_location.ts @@ -176,6 +176,7 @@ export async function load_ae_obj_li__event_location({ hidden?: 'hidden' | 'all' | 'not_hidden' | undefined; // all, hidden, not_hidden limit?: number; // 99 offset?: number; // 0 + order_by_li?: Record | Record[]; params?: key_val; try_cache?: boolean; log_lvl?: number; @@ -594,8 +595,8 @@ export async function search__event_location({ console.log(`*** search__event_location() *** event_id=${event_id}`); } - const enabled: string = params.qry__enabled ?? 'enabled'; // all, disabled, enabled - const hidden: string = params.qry__hidden ?? 'not_hidden'; // all, hidden, not_hidden + const enabled: 'enabled' | 'all' | 'not_enabled' = (params.qry__enabled as any) ?? 'enabled'; + const hidden: 'hidden' | 'all' | 'not_hidden' = (params.qry__hidden as any) ?? 'not_hidden'; const limit: number = params.qry__limit ?? 25; // 99 const offset: number = params.qry__offset ?? 0; // 0 @@ -809,7 +810,7 @@ async function _process_generic_props>({ for (const key in processed_obj) { if (key.endsWith('_random')) { const newKey = key.slice(0, -7); // Remove '_random' suffix - processed_obj[newKey] = processed_obj[key]; + (processed_obj as any)[newKey] = processed_obj[key]; } } // Ensure 'id' is set from '[obj_type]_id_random' diff --git a/src/lib/ae_events/ae_events__event_presentation.ts b/src/lib/ae_events/ae_events__event_presentation.ts index 8eed65ee..c99f9c4f 100644 --- a/src/lib/ae_events/ae_events__event_presentation.ts +++ b/src/lib/ae_events/ae_events__event_presentation.ts @@ -676,7 +676,7 @@ async function _process_generic_props>({ for (const key in processed_obj) { if (key.endsWith('_random')) { const newKey = key.slice(0, -7); // Remove '_random' suffix - processed_obj[newKey] = processed_obj[key]; + (processed_obj as any)[newKey] = processed_obj[key]; } } // Ensure 'id' is set from '[obj_type]_id_random' diff --git a/src/lib/ae_events/ae_events__event_presenter.ts b/src/lib/ae_events/ae_events__event_presenter.ts index cf7eee96..04e8b6ca 100644 --- a/src/lib/ae_events/ae_events__event_presenter.ts +++ b/src/lib/ae_events/ae_events__event_presenter.ts @@ -871,7 +871,7 @@ async function _process_generic_props>({ for (const key in processed_obj) { if (key.endsWith('_random')) { const newKey = key.slice(0, -7); // Remove '_random' suffix - processed_obj[newKey] = processed_obj[key]; + (processed_obj as any)[newKey] = processed_obj[key]; } } // Ensure 'id' is set from '[obj_type]_id_random' diff --git a/src/lib/ae_events/ae_events__event_session.ts b/src/lib/ae_events/ae_events__event_session.ts index 3a948fa5..93cf1426 100644 --- a/src/lib/ae_events/ae_events__event_session.ts +++ b/src/lib/ae_events/ae_events__event_session.ts @@ -1282,7 +1282,7 @@ async function _process_generic_props>({ for (const key in processed_obj) { if (key.endsWith('_random')) { const newKey = key.slice(0, -7); // Remove '_random' suffix - processed_obj[newKey] = processed_obj[key]; + (processed_obj as any)[newKey] = processed_obj[key]; } } // Ensure 'id' is set from '[obj_type]_id_random' diff --git a/src/lib/ae_journals/ae_journals__journal_entry.ts b/src/lib/ae_journals/ae_journals__journal_entry.ts index 0aff204c..f94b5c7f 100644 --- a/src/lib/ae_journals/ae_journals__journal_entry.ts +++ b/src/lib/ae_journals/ae_journals__journal_entry.ts @@ -202,7 +202,7 @@ export async function create_ae_obj__journal_entry({ if (!journal_id) { console.log(`ERROR: Journals - Entry - journal_id required to create`); - return false; + return null; } ae_promises.create__journal_entry = await api @@ -601,8 +601,10 @@ export async function db_save_ae_obj_li__journal_entry({ const obj_record = { id: obj.journal_entry_id_random, journal_entry_id: obj.journal_entry_id_random, + journal_entry_id_random: obj.journal_entry_id_random, journal_id: obj.journal_id_random, + journal_id_random: obj.journal_id_random, code: obj.code, @@ -633,14 +635,14 @@ export async function db_save_ae_obj_li__journal_entry({ // description: obj.description, content: obj.content, - content_md_html: content_md_html, + content_md_html: content_md_html ?? undefined, // content_md_html_alt: content_md_html_alt, content_html: obj.content_html, content_json: obj.content_json, content_encrypted: obj.content_encrypted, history: obj.history, - history_md_html: history_md_html, + history_md_html: history_md_html ?? undefined, history_encrypted: obj.history_encrypted, passcode_hash: obj.passcode_hash,