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:
@@ -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',
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
|
||||
@@ -182,99 +182,107 @@ export interface ae_Person extends ae_BaseObj {
|
||||
}
|
||||
|
||||
/**
|
||||
* Event - A discrete conference or show
|
||||
* User - A login entity with permissions
|
||||
*/
|
||||
export interface ae_Event extends ae_BaseObj {
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
export interface ae_User extends ae_BaseObj {
|
||||
user_id: string;
|
||||
user_id_random: string;
|
||||
account_id: string;
|
||||
account_id_random: string;
|
||||
person_id?: string;
|
||||
person_id_random?: string;
|
||||
|
||||
username: string;
|
||||
email?: string;
|
||||
|
||||
// Permissions (Maps to $ae_loc logic)
|
||||
super: boolean;
|
||||
manager: boolean;
|
||||
administrator: boolean;
|
||||
public: boolean;
|
||||
|
||||
status_name?: string;
|
||||
logged_in_on?: string | Date;
|
||||
last_activity_on?: string | Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address - Geographic location data
|
||||
*/
|
||||
export interface ae_Address extends ae_BaseObj {
|
||||
address_id: string;
|
||||
address_id_random: string;
|
||||
account_id: string;
|
||||
account_id_random: string;
|
||||
|
||||
conference: boolean;
|
||||
type?: string;
|
||||
summary?: string;
|
||||
format?: string;
|
||||
for_type?: string;
|
||||
for_id_random?: string;
|
||||
|
||||
attention_to?: string;
|
||||
organization_name?: string;
|
||||
|
||||
line_1: string;
|
||||
line_2?: string;
|
||||
line_3?: string;
|
||||
city: string;
|
||||
state_province?: string;
|
||||
postal_code?: string;
|
||||
country?: string;
|
||||
country_name?: string;
|
||||
|
||||
timezone?: string;
|
||||
start_datetime?: string | Date;
|
||||
end_datetime?: string | Date;
|
||||
|
||||
location_text?: string;
|
||||
location_address_json?: any;
|
||||
|
||||
status?: string;
|
||||
approve?: boolean;
|
||||
ready?: boolean;
|
||||
ready_on?: string | Date;
|
||||
|
||||
cfg_json?: any;
|
||||
data_json?: any;
|
||||
latitude?: string;
|
||||
longitude?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* EventBadge - An attendee's printed credentials
|
||||
* Contact - Electronic communication details (Phone, Email, Web)
|
||||
*/
|
||||
export interface ae_EventBadge extends ae_BaseObj {
|
||||
event_badge_id: string;
|
||||
event_badge_id_random: string;
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
person_id: string;
|
||||
person_id_random: string;
|
||||
event_person_id?: string;
|
||||
event_person_id_random?: string;
|
||||
export interface ae_Contact extends ae_BaseObj {
|
||||
contact_id: string;
|
||||
contact_id_random: string;
|
||||
account_id: string;
|
||||
account_id_random: string;
|
||||
|
||||
event_badge_template_id?: string;
|
||||
event_badge_template_id_random?: string;
|
||||
address_id_random?: string;
|
||||
for_type?: string;
|
||||
for_id_random?: string;
|
||||
|
||||
badge_type_code?: string;
|
||||
badge_type?: string;
|
||||
title?: string;
|
||||
tagline?: string;
|
||||
|
||||
member_type_code?: string;
|
||||
member_status?: string;
|
||||
|
||||
pronouns?: string;
|
||||
given_name?: string;
|
||||
middle_name?: string;
|
||||
family_name?: string;
|
||||
full_name?: string;
|
||||
affiliations?: string;
|
||||
|
||||
professional_title?: string;
|
||||
email?: string;
|
||||
city?: string;
|
||||
state_province?: string;
|
||||
country?: string;
|
||||
phone_mobile?: string;
|
||||
phone_office?: string;
|
||||
website_url?: string;
|
||||
|
||||
print_count?: number;
|
||||
print_first_datetime?: string | Date;
|
||||
print_last_datetime?: string | Date;
|
||||
|
||||
ticket_list?: any[];
|
||||
data_json?: any;
|
||||
facebook_url?: string;
|
||||
instagram_url?: string;
|
||||
linkedin_url?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* EventBadgeTemplate - Layout and style for badges
|
||||
* ActivityLog - System audit trail
|
||||
*/
|
||||
export interface ae_EventBadgeTemplate extends ae_BaseObj {
|
||||
event_badge_template_id: string;
|
||||
event_badge_template_id_random: string;
|
||||
event_id: string;
|
||||
event_id_random: string;
|
||||
export interface ae_ActivityLog extends ae_BaseObj {
|
||||
activity_log_id: string;
|
||||
activity_log_id_random: string;
|
||||
account_id: string;
|
||||
account_id_random: string;
|
||||
|
||||
logo_path?: string;
|
||||
header_path?: string;
|
||||
header_row_1?: string;
|
||||
header_row_2?: string;
|
||||
person_id_random?: string;
|
||||
user_id_random?: string;
|
||||
|
||||
footer_path?: string;
|
||||
footer_title?: string;
|
||||
external_client_id?: string;
|
||||
source?: string;
|
||||
|
||||
badge_type_list?: any;
|
||||
ticket_list?: any;
|
||||
object_type?: string;
|
||||
object_id_random?: string;
|
||||
|
||||
layout?: string;
|
||||
style_href?: string;
|
||||
passcode?: string;
|
||||
}
|
||||
action: string;
|
||||
action_on_type?: string;
|
||||
action_on_id_random?: string;
|
||||
|
||||
details?: string;
|
||||
other_json?: any;
|
||||
}
|
||||
Reference in New Issue
Block a user