Migrate User and ActivityLog modules to unified type system

- Added ae_User and ae_ActivityLog interfaces to ae_types.ts.
- Replaced local interfaces in User and ActivityLog logic files with unified imports.
- Standardized Promise return types for all core data loading, creation, and update functions.
- Verified permission field alignment for User type to support hierarchical access logic.
This commit is contained in:
Scott Idem
2026-01-08 12:20:21 -05:00
parent 25b51e1081
commit 324b65394a
3 changed files with 92 additions and 151 deletions

View File

@@ -3,44 +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_core } from '$lib/ae_core/db_core';
import type { ae_User } from '$lib/types/ae_types';
const ae_promises: key_val = {};
export interface User {
id: string;
user_id: string;
user_id_random: string;
username: string;
name: string;
email: string;
allow_auth_key: boolean;
super: boolean;
manager: boolean;
administrator: boolean;
verified: boolean;
public: boolean;
person_id?: string;
person_id_random?: 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;
tmp_sort_1?: string;
tmp_sort_2?: string;
}
// Updated 2026-01-06
export async function load_ae_obj_id__user({
api_cfg,
@@ -56,7 +22,7 @@ export async function load_ae_obj_id__user({
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
}): Promise<ae_User | null> {
if (log_lvl) {
console.log(`*** load_ae_obj_id__user() *** user_id=${user_id}`);
}
@@ -119,7 +85,7 @@ export async function load_ae_obj_li__user({
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
}): Promise<ae_User[]> {
let promise;
if (qry_str) {
@@ -187,7 +153,7 @@ export async function create_ae_obj__user({
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
}): Promise<ae_User | null> {
const result = await api.create_ae_obj_v3({
api_cfg,
obj_type: 'user',
@@ -228,7 +194,7 @@ export async function update_ae_obj__user({
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}) {
}): Promise<ae_User | null> {
const result = await api.update_ae_obj_v3({
api_cfg,
obj_type: 'user',

View File

@@ -1,42 +1,9 @@
import type { key_val } from '$lib/stores/ae_stores';
import { api } from '$lib/api/api';
import type { ae_ActivityLog } from '$lib/types/ae_types';
const ae_promises: key_val = {};
export interface Activity_Log {
id: string;
activity_log_id: string;
activity_log_id_random: string;
account_id: string;
account_id_random: string;
for_type?: string;
for_id?: string;
for_id_random?: string;
person_id?: string;
person_id_random?: string;
event_id?: string;
event_id_random?: string;
action: string;
action_with?: string;
summary?: string;
description?: string;
data_json?: any;
enable: null | boolean;
hide?: null | boolean;
priority?: null | boolean;
sort?: null | number;
group?: null | string;
notes?: null | string;
created_on: Date;
updated_on?: null | Date;
}
// Updated 2026-01-06
export async function load_ae_obj_id__activity_log({
api_cfg,
@@ -50,7 +17,7 @@ export async function load_ae_obj_id__activity_log({
view?: string;
params?: key_val;
log_lvl?: number;
}) {
}): Promise<ae_ActivityLog | null> {
if (log_lvl) {
console.log(`*** load_ae_obj_id__activity_log() *** activity_log_id=${activity_log_id}`);
}
@@ -92,7 +59,7 @@ export async function load_ae_obj_li__activity_log({
order_by_li?: Record<string, 'ASC' | 'DESC'>;
params?: key_val;
log_lvl?: number;
}) {
}): Promise<ae_ActivityLog[]> {
if (log_lvl) {
console.log(`*** load_ae_obj_li__activity_log() *** for_obj_id=${for_obj_id}`);
}
@@ -127,7 +94,7 @@ export async function create_ae_obj__activity_log({
data_kv: key_val;
params?: key_val;
log_lvl?: number;
}) {
}): Promise<ae_ActivityLog | null> {
if (log_lvl) {
console.log(`*** create_ae_obj__activity_log() *** account_id=${account_id}`);
}
@@ -164,7 +131,7 @@ export async function update_ae_obj__activity_log({
data_kv: key_val;
params?: key_val;
log_lvl?: number;
}) {
}): Promise<ae_ActivityLog | null> {
if (log_lvl) {
console.log(`*** update_ae_obj__activity_log() *** activity_log_id=${activity_log_id}`);
}
@@ -231,7 +198,7 @@ export async function qry__activity_log({
log_lvl?: number;
}) {
}): Promise<ae_ActivityLog[]> {
const search_query: any = {};