Implement unified frontend type system and migrate core modules
- Created src/lib/types/ae_types.ts to serve as the central repository for Aether object interfaces. - Standardized interfaces to include the triple-ID pattern (id, [type]_id, [type]_id_random) for Dexie and V3 API compatibility. - Migrated Account and JournalEntry modules to use ae_Account and ae_JournalEntry types. - Added explicit Promise return types to all core data loading, creation, and update functions in migrated modules.
This commit is contained in:
@@ -3,36 +3,10 @@ import { api } from '$lib/api/api';
|
|||||||
|
|
||||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||||
import { db_core } from '$lib/ae_core/db_core';
|
import { db_core } from '$lib/ae_core/db_core';
|
||||||
|
import type { ae_Account } from '$lib/types/ae_types';
|
||||||
|
|
||||||
const ae_promises: key_val = {};
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
export interface Account {
|
|
||||||
id: string;
|
|
||||||
account_id: string;
|
|
||||||
account_id_random: string;
|
|
||||||
|
|
||||||
code?: string;
|
|
||||||
name: string;
|
|
||||||
short_name?: null | string;
|
|
||||||
description?: null | string;
|
|
||||||
|
|
||||||
enable: null | boolean;
|
|
||||||
enable_from?: null | Date;
|
|
||||||
enable_to?: null | Date;
|
|
||||||
|
|
||||||
hide?: null | boolean;
|
|
||||||
priority?: null | boolean;
|
|
||||||
sort?: null | number;
|
|
||||||
group?: null | string;
|
|
||||||
notes?: null | string;
|
|
||||||
created_on: Date;
|
|
||||||
updated_on?: null | Date;
|
|
||||||
|
|
||||||
// Computed or extra fields from views
|
|
||||||
tmp_sort_1?: string;
|
|
||||||
tmp_sort_2?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updated 2026-01-06
|
// Updated 2026-01-06
|
||||||
export async function load_ae_obj_id__account({
|
export async function load_ae_obj_id__account({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
@@ -48,7 +22,7 @@ export async function load_ae_obj_id__account({
|
|||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_Account | null> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** load_ae_obj_id__account() *** account_id=${account_id}`);
|
console.log(`*** load_ae_obj_id__account() *** account_id=${account_id}`);
|
||||||
}
|
}
|
||||||
@@ -120,7 +94,7 @@ export async function load_ae_obj_li__account({
|
|||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_Account[]> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** load_ae_obj_li__account() ***`);
|
console.log(`*** load_ae_obj_li__account() ***`);
|
||||||
}
|
}
|
||||||
@@ -174,7 +148,7 @@ export async function create_ae_obj__account({
|
|||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_Account | null> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** create_ae_obj__account() ***`);
|
console.log(`*** create_ae_obj__account() ***`);
|
||||||
}
|
}
|
||||||
@@ -230,7 +204,7 @@ export async function update_ae_obj__account({
|
|||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_Account | null> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** update_ae_obj__account() *** account_id=${account_id}`, data_kv);
|
console.log(`*** update_ae_obj__account() *** account_id=${account_id}`, data_kv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { api } from '$lib/api/api';
|
|||||||
|
|
||||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||||
import { db_journals } from '$lib/ae_journals/db_journals';
|
import { db_journals } from '$lib/ae_journals/db_journals';
|
||||||
|
import type { ae_JournalEntry } from '$lib/types/ae_types';
|
||||||
|
|
||||||
const ae_promises: key_val = {};
|
const ae_promises: key_val = {};
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ export async function load_ae_obj_id__journal_entry({
|
|||||||
journal_entry_id: string;
|
journal_entry_id: string;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_JournalEntry | null> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** load_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`);
|
console.log(`*** load_ae_obj_id__journal_entry() *** journal_entry_id=${journal_entry_id}`);
|
||||||
}
|
}
|
||||||
@@ -95,7 +96,7 @@ export async function load_ae_obj_li__journal_entry({
|
|||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_JournalEntry[]> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(
|
console.log(
|
||||||
`*** load_ae_obj_li__journal_entry() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
|
`*** load_ae_obj_li__journal_entry() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id}`
|
||||||
@@ -194,7 +195,7 @@ export async function create_ae_obj__journal_entry({
|
|||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_JournalEntry | null> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** create_ae_obj__journal_entry() *** journal_id=${journal_id}`);
|
console.log(`*** create_ae_obj__journal_entry() *** journal_id=${journal_id}`);
|
||||||
}
|
}
|
||||||
@@ -496,7 +497,7 @@ export async function update_ae_obj__journal_entry({
|
|||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}) {
|
}): Promise<ae_JournalEntry | null> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(
|
console.log(
|
||||||
`*** update_ae_obj__journal_entry() *** journal_entry_id=${journal_entry_id}`,
|
`*** update_ae_obj__journal_entry() *** journal_entry_id=${journal_entry_id}`,
|
||||||
|
|||||||
146
src/lib/types/ae_types.ts
Normal file
146
src/lib/types/ae_types.ts
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* Aether Unified Type Definitions (Frontend)
|
||||||
|
* Standardized 2026-01-08 to align with Backend V3 exports and Dexie local storage patterns.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base properties shared by almost all Aether objects.
|
||||||
|
*/
|
||||||
|
export interface ae_BaseObj {
|
||||||
|
id: string; // Primary key (maps to [obj_type]_id_random)
|
||||||
|
|
||||||
|
code?: string;
|
||||||
|
name?: string;
|
||||||
|
short_name?: string;
|
||||||
|
description?: string;
|
||||||
|
|
||||||
|
enable: boolean;
|
||||||
|
hide: boolean;
|
||||||
|
archive?: boolean;
|
||||||
|
archive_on?: string | Date;
|
||||||
|
|
||||||
|
priority: boolean;
|
||||||
|
sort: number;
|
||||||
|
group?: string;
|
||||||
|
notes?: string;
|
||||||
|
|
||||||
|
created_on: string | Date;
|
||||||
|
updated_on: string | Date;
|
||||||
|
|
||||||
|
// Standard frontend computed sort fields
|
||||||
|
tmp_sort_1?: string;
|
||||||
|
tmp_sort_2?: string;
|
||||||
|
tmp_sort_3?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Account - Core client account
|
||||||
|
*/
|
||||||
|
export interface ae_Account extends ae_BaseObj {
|
||||||
|
account_id: string;
|
||||||
|
account_id_random: string;
|
||||||
|
|
||||||
|
account_cfg?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Site - A website or application instance
|
||||||
|
*/
|
||||||
|
export interface ae_Site extends ae_BaseObj {
|
||||||
|
site_id: string;
|
||||||
|
site_id_random: string;
|
||||||
|
account_id: string;
|
||||||
|
account_id_random: string;
|
||||||
|
|
||||||
|
url_root?: string;
|
||||||
|
site_cfg_json?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Site_Domain - A domain name mapped to a site
|
||||||
|
*/
|
||||||
|
export interface ae_SiteDomain extends ae_BaseObj {
|
||||||
|
site_domain_id: string;
|
||||||
|
site_domain_id_random: string;
|
||||||
|
site_id: string;
|
||||||
|
site_id_random: string;
|
||||||
|
|
||||||
|
fqdn: string;
|
||||||
|
is_primary: boolean;
|
||||||
|
redirect_to_primary: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Journal - A collection of entries
|
||||||
|
*/
|
||||||
|
export interface ae_Journal extends ae_BaseObj {
|
||||||
|
journal_id: string;
|
||||||
|
journal_id_random: string;
|
||||||
|
account_id: string;
|
||||||
|
account_id_random: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JournalEntry - A discrete piece of content within a journal
|
||||||
|
*/
|
||||||
|
export interface ae_JournalEntry extends ae_BaseObj {
|
||||||
|
journal_entry_id: string;
|
||||||
|
journal_entry_id_random: string;
|
||||||
|
journal_id: string;
|
||||||
|
journal_id_random: string;
|
||||||
|
|
||||||
|
person_id?: string;
|
||||||
|
person_id_random?: string;
|
||||||
|
|
||||||
|
journal_entry_type?: string;
|
||||||
|
activity_code?: string;
|
||||||
|
category_code?: string;
|
||||||
|
type_code?: string;
|
||||||
|
topic_code?: string;
|
||||||
|
tags?: string;
|
||||||
|
|
||||||
|
public?: boolean;
|
||||||
|
private?: boolean;
|
||||||
|
personal?: boolean;
|
||||||
|
professional?: boolean;
|
||||||
|
|
||||||
|
summary?: string;
|
||||||
|
outline?: string;
|
||||||
|
|
||||||
|
content?: string;
|
||||||
|
content_md_html?: string;
|
||||||
|
content_html?: string;
|
||||||
|
content_json?: any;
|
||||||
|
content_encrypted?: string;
|
||||||
|
|
||||||
|
history?: string;
|
||||||
|
history_md_html?: string;
|
||||||
|
history_encrypted?: string;
|
||||||
|
|
||||||
|
passcode_hash?: string;
|
||||||
|
|
||||||
|
alert?: boolean;
|
||||||
|
alert_msg?: string;
|
||||||
|
|
||||||
|
data_json?: any;
|
||||||
|
|
||||||
|
// SQL View fields
|
||||||
|
journal_code?: string;
|
||||||
|
journal_name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Person - A human entity
|
||||||
|
*/
|
||||||
|
export interface ae_Person extends ae_BaseObj {
|
||||||
|
person_id: string;
|
||||||
|
person_id_random: string;
|
||||||
|
account_id: string;
|
||||||
|
account_id_random: string;
|
||||||
|
|
||||||
|
first_name?: string;
|
||||||
|
last_name?: string;
|
||||||
|
full_name?: string;
|
||||||
|
email?: string;
|
||||||
|
phone?: string;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user