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.
This commit is contained in:
Scott Idem
2026-01-15 19:27:53 -05:00
parent ab1c207c86
commit ee1ca93894
15 changed files with 73 additions and 45 deletions

View File

@@ -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<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[];
params?: key_val;
try_cache?: boolean;
log_lvl?: number;

View File

@@ -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<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[];
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({

View File

@@ -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] = {};

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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>;
file!: Table<ae_LocalFile>;
person!: Table<Person>;
user!: Table<User>;
account!: Table<ae_Account>;

View File

@@ -125,6 +125,7 @@ export async function load_ae_obj_li__event({
view?: string;
limit?: number;
offset?: number;
order_by_li?: Record<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[];
params?: key_val;
try_cache?: boolean;
log_lvl?: number;

View File

@@ -117,7 +117,7 @@ async function _process_generic_props<T extends Record<string, any>>({
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'

View File

@@ -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<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[];
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<T extends Record<string, any>>({
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'

View File

@@ -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<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[];
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<T extends Record<string, any>>({
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'

View File

@@ -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<string, 'ASC' | 'DESC'> | Record<string, 'ASC' | 'DESC'>[];
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<T extends Record<string, any>>({
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'

View File

@@ -676,7 +676,7 @@ async function _process_generic_props<T extends Record<string, any>>({
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'

View File

@@ -871,7 +871,7 @@ async function _process_generic_props<T extends Record<string, any>>({
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'

View File

@@ -1282,7 +1282,7 @@ async function _process_generic_props<T extends Record<string, any>>({
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'

View File

@@ -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,