Fix: System-wide type hardening and V3 API alignment

This commit is contained in:
Scott Idem
2026-01-22 19:22:16 -05:00
parent 9de1d4b23e
commit 4976f2d897
11 changed files with 87 additions and 56 deletions

View File

@@ -94,11 +94,11 @@
try {
ae_promises = ai_client.chat.completions.create({
model: model,
model: model || 'dgrzone-deepseek-8b-quick',
max_tokens: maxTokens,
temperature: temperature,
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'system', content: systemPrompt || 'You are a helpful assistant.' },
{ role: 'user', content: content }
]
}).then((resp) => {

View File

@@ -2,7 +2,7 @@ import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import { db_sponsorships } from '$lib/ae_sponsorships/db_sponsorships';
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
import type { ae_Sponsorship, ae_Sponsorship_Cfg } from '$lib/types/ae_types';
import type { ae_Sponsorship, ae_SponsorshipCfg } from '$lib/types/ae_types';
const ae_promises: key_val = {};
@@ -197,7 +197,7 @@ export async function load_ae_obj_id__sponsorship_cfg({
sponsorship_cfg_id: string;
try_cache?: boolean;
log_lvl?: number;
}): Promise<ae_Sponsorship_Cfg | null> {
}): Promise<ae_SponsorshipCfg | null> {
if (log_lvl) {
console.log(`*** load_ae_obj_id__sponsorship_cfg() *** [V3] id=${sponsorship_cfg_id}`);
}
@@ -348,7 +348,7 @@ export async function create_ae_obj__sponsorship({
return await api.create_ae_obj_v3({
api_cfg,
obj_type: 'sponsorship',
data,
fields: data,
log_lvl
});
}
@@ -371,7 +371,7 @@ export async function update_ae_obj__sponsorship({
api_cfg,
obj_type: 'sponsorship',
obj_id: sponsorship_id,
data,
fields: data,
log_lvl
});
}

View File

@@ -259,6 +259,20 @@ export const shorten_string = function shorten_string({
return new_string;
};
// Svelte action to set focus on an element
function set_focus(node: HTMLElement, focus: boolean) {
if (focus) {
node.focus();
}
return {
update(new_focus: boolean) {
if (new_focus) {
node.focus();
}
}
};
}
// Updated 2024-06-19
// This function should return a shorted version of a filename if over the max length. It should always contain at least the first character of the original filename and the complete extension.
// Example 1: The Original Long File Name.pdf -> The Orig....pdf
@@ -328,5 +342,6 @@ export const ae_util = {
encrypt_content: encrypt_content,
encrypt_wrapper: encrypt_wrapper,
decrypt_content: decrypt_content,
decrypt_wrapper: decrypt_wrapper
decrypt_wrapper: decrypt_wrapper,
set_focus: set_focus
};

View File

@@ -15,9 +15,9 @@ export const encrypt_content = async function encrypt_content(content: string, k
'encrypt'
]);
const encodedContent = await crypto.subtle.encrypt(
{ name: 'AES-CBC', iv },
{ name: 'AES-CBC', iv: iv.buffer as ArrayBuffer },
key,
new TextEncoder().encode(content)
new TextEncoder().encode(content).buffer as ArrayBuffer
);
const base64 = btoa(String.fromCharCode(...new Uint8Array(encodedContent)));
if (log_lvl) {
@@ -79,9 +79,9 @@ export const decrypt_content = async function decrypt_content(
]);
const encryptedContent = Uint8Array.from(atob(base64Content), (c) => c.charCodeAt(0));
const decryptedContent = await crypto.subtle.decrypt(
{ name: 'AES-CBC', iv },
{ name: 'AES-CBC', iv: iv.buffer as ArrayBuffer },
key,
encryptedContent
encryptedContent.buffer as ArrayBuffer
);
const decodedContent = new TextDecoder().decode(decryptedContent);
// console.log('Decrypted Content:', decodedContent);

View File

@@ -1,6 +1,6 @@
import { to_title_case } from './ae_utils__to_title_case';
// Updated 2023-08-18
// Updated 2026-01-22
export function set_obj_prop_display_name({
prop_name,
obj_type = null,
@@ -9,6 +9,14 @@ export function set_obj_prop_display_name({
replace_underscores = true,
title_case = true,
override = null
}: {
prop_name: string;
obj_type?: string | null;
prefix_w_obj_type?: boolean;
prefix_all_w_obj_type?: boolean;
replace_underscores?: boolean;
title_case?: boolean;
override?: string | null;
}) {
console.log('*** set_obj_prop_display_name() ***');

View File

@@ -31,7 +31,7 @@
content = 'test test test test',
new_content = $bindable(),
editorView = $bindable(), // Exposed for external control
theme_mode = 'light',
theme_mode = $bindable('light'),
extensions = [],
editable = true,
readonly = false,
@@ -105,12 +105,17 @@
...extensions // Add any custom extensions passed in props
].filter(Boolean);
if (!editor_element) {
console.error('Editor element not found.');
return;
}
editorView = new cm_modules.EditorView({
state: cm_modules.EditorState.create({
doc: content,
extensions: editor_extensions
}),
parent: editor_element
parent: editor_element as HTMLElement
});
}

View File

@@ -1,6 +1,7 @@
let _cmCache: {
EditorView?: any;
EditorState?: any;
EditorSelection?: any;
markdown?: any;
markdownLanguage?: any;
keymap?: any;
@@ -25,6 +26,7 @@ let _cmCache: {
highlightSelectionMatches?: any;
lintKeymap?: any;
EditorState_allowMultipleSelections?: any;
EditorState_readOnly?: any;
EditorView_lineWrapping?: any;
EditorView_editable?: any;
EditorView_contentAttributes?: any;
@@ -43,6 +45,7 @@ import { browser } from '$app/environment';
type CMCache = {
EditorView: any;
EditorState: any;
EditorSelection?: any;
markdown?: any;
markdownLanguage?: any;
keymap?: any;
@@ -67,6 +70,7 @@ type CMCache = {
highlightSelectionMatches?: any;
lintKeymap?: any;
EditorState_allowMultipleSelections?: any;
EditorState_readOnly?: any;
EditorView_lineWrapping?: any;
EditorView_editable?: any;
EditorView_contentAttributes?: any;
@@ -133,7 +137,7 @@ export async function ensureCodeMirrorModules(): Promise<CMCache> {
markdown: markdownMod?.markdown,
markdownLanguage: markdownMod?.markdownLanguage,
languages: languageMod?.languages, // From @codemirror/language-data, often re-exported by @codemirror/language
languages: (languageMod as any)?.languages, // Cast to any to avoid TS error if property is missing from types
defaultKeymap: (commandsMod && commandsMod.defaultKeymap) || [],
history: commandsMod?.history,

View File

@@ -6,6 +6,7 @@
// *** Import Aether core variables and functions
import type { key_val } from '$lib/stores/ae_stores';
import { core_func } from '$lib/ae_core/ae_core_functions';
// import { api } from '$lib/api';
// import { update_ae_obj_id_crud } from '$lib/ae_core/core__crud_generic';
import { update_ae_obj } from '$lib/ae_core/core__crud_generic';

View File

@@ -3,41 +3,7 @@
import { createEventDispatcher, onMount } from 'svelte';
import util from './utilities.js';
// import Select_element_lu from './element_select_lu.svelte';
console.log(`Input name=${name} value=${value}`);
console.log('Original Value', original_value);
console.log('Data Type:', data_type);
let set_input_type = $state((node) => {
node.type = 'text';
});
let input_element_type_list = ['checkbox', 'date', 'email', 'hidden', 'number', 'text'];
if (input_element_type_list.includes(type)) {
set_input_type = (node) => {
node.type = type;
};
} else {
}
console.log(`Input name=${name} value=${value} type=${type}`);
/* *** END *** Core input settings */
/* *** BEGIN *** Container content, layout, and behavior */
console.log(`Input input_mode=${input_mode}`);
/* *** END *** Container content, layout, and behavior */
/* *** BEGIN *** Input type specific */
if (type == 'textarea') {
console.log(`Input textarea size=${size} rows=${rows} cols=${cols}`);
}
import { ae_util as util } from '$lib/ae_utils/ae_utils';
interface Props {
/* *** BEGIN *** Core input settings */
@@ -141,6 +107,39 @@
date_time_tz = null,
more_html
}: Props = $props();
console.log(`Input name=${name} value=${value}`);
console.log('Original Value', original_value);
console.log('Data Type:', data_type);
let set_input_type = $state((node) => {
node.type = 'text';
});
let input_element_type_list = ['checkbox', 'date', 'email', 'hidden', 'number', 'text'];
if (input_element_type_list.includes(type)) {
set_input_type = (node) => {
node.type = type;
};
} else {
}
console.log(`Input name=${name} value=${value} type=${type}`);
/* *** END *** Core input settings */
/* *** BEGIN *** Container content, layout, and behavior */
console.log(`Input input_mode=${input_mode}`);
/* *** END *** Container content, layout, and behavior */
/* *** BEGIN *** Input type specific */
if (type == 'textarea') {
console.log(`Input textarea size=${size} rows=${rows} cols=${cols}`);
}
let value_datetime = null;
let value_date = $state(null);
let value_time = $state(null);
@@ -802,4 +801,4 @@
.container_inline {
display: inline;
}
</style>
</style>

View File

@@ -102,14 +102,14 @@
</script>
{#if show_create_badge_modal}
<Modal bind:show={show_create_badge_modal}>
<Modal bind:open={show_create_badge_modal}>
<div class="card p-4">
<h3 class="h3">Create New Badge</h3>
<Comp_badge_create_form
event_id={$events_slct?.event_id ?? ''}
on:success={() => {
show_create_badge_modal = false;
ae_triggers.event_badge_qry = true; // Trigger a refresh of the list
$events_trigger.event_badge_qry = true; // Trigger a refresh of the list
}}
on:cancel={() => (show_create_badge_modal = false)}
/>
@@ -118,14 +118,14 @@
{/if}
{#if show_upload_badge_modal}
<Modal bind:show={show_upload_badge_modal}>
<Modal bind:open={show_upload_badge_modal}>
<div class="card p-4">
<h3 class="h3">Upload Badges (CSV)</h3>
<Comp_badge_upload_form
event_id={$events_slct?.event_id ?? ''}
on:success={() => {
show_upload_badge_modal = false;
ae_triggers.event_badge_qry = true; // Trigger a refresh of the list
$events_trigger.event_badge_qry = true; // Trigger a refresh of the list
}}
on:cancel={() => (show_upload_badge_modal = false)}
/>

View File

@@ -72,7 +72,6 @@ export async function load({ params, parent }) {
enabled: 'all',
hidden: 'all',
limit: 19,
params: {},
try_cache: true,
log_lvl: 2
});