feat: Implement dynamic domain-based PWA manifest
- Added /manifest.webmanifest server-side route. - Implemented hostname-based branding lookup using Agent API Key. - Updated app.html to use the dynamic manifest route. - Added manifest verification tool to the System Testing dashboard.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import { api } from '$lib/api/api';
|
||||
import { get_ae_obj_li_for_obj_id_crud_v2 } from '$lib/ae_api/api_get__crud_obj_li_v2';
|
||||
|
||||
import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
@@ -187,12 +188,17 @@ export async function load_ae_obj_li__event({
|
||||
const search_query: any = {
|
||||
and: [{ field: 'conference', op: 'eq', value: qry_conference }]
|
||||
};
|
||||
|
||||
// Fix for "Integer Trap": Inject account context directly into search body and remove from URL params
|
||||
if (for_obj_id) {
|
||||
search_query.and.push({ field: 'account_id_random', op: 'eq', value: for_obj_id });
|
||||
}
|
||||
|
||||
promise = api.search_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event',
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
// Headers for Auth context
|
||||
headers: { 'x-account-id': for_obj_id },
|
||||
search_query,
|
||||
enabled,
|
||||
hidden,
|
||||
@@ -398,19 +404,24 @@ export async function update_ae_obj__event({
|
||||
return result;
|
||||
}
|
||||
|
||||
// Updated 2026-01-09
|
||||
// Updated 2026-01-20
|
||||
export async function qry_ae_obj_li__event({
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_str,
|
||||
qry_person_id = null,
|
||||
qry_conference = null,
|
||||
qry_physical = null,
|
||||
qry_virtual = null,
|
||||
qry_type = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
view = 'default',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = { start_datetime: 'DESC' } as const,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
@@ -418,48 +429,239 @@ export async function qry_ae_obj_li__event({
|
||||
for_obj_id: string;
|
||||
qry_str?: string;
|
||||
qry_person_id?: string | null;
|
||||
qry_conference?: boolean | null;
|
||||
qry_physical?: boolean | null;
|
||||
qry_virtual?: boolean | null;
|
||||
qry_type?: string | null;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: Record<string, 'ASC' | 'DESC'>;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
const search_query: any = { and: [] };
|
||||
if (qry_str) search_query.q = qry_str;
|
||||
|
||||
if (qry_str) {
|
||||
// Use reserved 'q' property for global full-text search as per V3 Guide
|
||||
search_query.q = qry_str;
|
||||
}
|
||||
|
||||
// Note: V3 does not support searching by person_id directly on the event object yet.
|
||||
// We will filter client-side instead.
|
||||
// Use raw field name to bypass backend mapping conflicts (Integer Trap)
|
||||
if (for_obj_id) {
|
||||
search_query.and.push({ field: 'account_id_random', op: 'eq', value: for_obj_id });
|
||||
}
|
||||
|
||||
const result_li = await api.search_ae_obj_v3({
|
||||
api_cfg,
|
||||
obj_type: 'event',
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
// Inject header context for Auth but keep body context for Filtering
|
||||
headers: { 'x-account-id': for_obj_id },
|
||||
search_query,
|
||||
enabled,
|
||||
hidden,
|
||||
view,
|
||||
limit: qry_person_id ? 500 : limit, // Increase limit if filtering client-side
|
||||
limit: (qry_person_id || qry_conference !== null || qry_physical !== null || qry_virtual !== null || qry_type !== null) ? 500 : limit,
|
||||
offset,
|
||||
order_by_li,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (qry_person_id && result_li) {
|
||||
return result_li.filter((ev: any) => {
|
||||
return (
|
||||
if (!result_li) return [];
|
||||
|
||||
const processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: result_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'event',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
// Client-side Filter Layer
|
||||
const filtered_obj_li = processed_obj_li.filter((ev: any) => {
|
||||
// Handle conference filter
|
||||
if (qry_conference != null) {
|
||||
const ev_conf = ev.conference === true || ev.conference === 1 || ev.conference === '1';
|
||||
if (ev_conf !== !!qry_conference) return false;
|
||||
}
|
||||
|
||||
// Location Filtering (Inclusive OR logic)
|
||||
if (qry_physical === true || qry_virtual === true) {
|
||||
const ev_physical = ev.physical === true || ev.physical === 1 || ev.physical === '1';
|
||||
const ev_virtual = ev.virtual === true || ev.virtual === 1 || ev.virtual === '1';
|
||||
|
||||
let match = false;
|
||||
if (qry_physical === true && ev_physical) match = true;
|
||||
if (qry_virtual === true && ev_virtual) match = true;
|
||||
|
||||
if (!match) return false;
|
||||
}
|
||||
|
||||
// Handle type filter (skip if null, undefined, 'all', or empty string)
|
||||
if (qry_type != null && qry_type !== 'all' && qry_type !== '') {
|
||||
if (ev.type !== qry_type) return false;
|
||||
}
|
||||
|
||||
// Handle person ID filter
|
||||
if (qry_person_id) {
|
||||
const match = (
|
||||
ev.external_person_id === qry_person_id ||
|
||||
ev.poc_person_id === qry_person_id ||
|
||||
ev.poc_person_id_random === qry_person_id ||
|
||||
ev.poc_event_person_id === qry_person_id ||
|
||||
ev.poc_event_person_id_random === qry_person_id
|
||||
);
|
||||
if (!match) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Filter results (V3): Input=${processed_obj_li.length}, Output=${filtered_obj_li.length}`);
|
||||
}
|
||||
|
||||
return filtered_obj_li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized search function for IDAA module using legacy V2 endpoints.
|
||||
* This is isolated to prevent V3 migration bugs from affecting Recovery Meetings.
|
||||
*/
|
||||
// Updated 2026-01-20
|
||||
export async function qry_ae_obj_li__event_v2({
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id,
|
||||
qry_str,
|
||||
qry_person_id = null,
|
||||
qry_conference = null,
|
||||
qry_physical = null,
|
||||
qry_virtual = null,
|
||||
qry_type = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
view = 'default',
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = { start_datetime: 'DESC' } as const,
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
}: {
|
||||
api_cfg: any;
|
||||
for_obj_type?: string;
|
||||
for_obj_id: string;
|
||||
qry_str?: string;
|
||||
qry_person_id?: string | null;
|
||||
qry_conference?: boolean | null;
|
||||
qry_physical?: boolean | null;
|
||||
qry_virtual?: boolean | null;
|
||||
qry_type?: string | null;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
view?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
order_by_li?: Record<string, 'ASC' | 'DESC'>;
|
||||
try_cache?: boolean;
|
||||
log_lvl?: number;
|
||||
}) {
|
||||
if (log_lvl) console.log('*** qry_ae_obj_li__event_v2() ***');
|
||||
|
||||
const params_json: any = { qry: { and: [] } };
|
||||
|
||||
if (qry_str) {
|
||||
// Use default_qry_str for searching as requested
|
||||
params_json.qry.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry_str}%` });
|
||||
}
|
||||
|
||||
const result_li = await get_ae_obj_li_for_obj_id_crud_v2({
|
||||
api_cfg,
|
||||
obj_type: 'event',
|
||||
for_obj_type,
|
||||
for_obj_id,
|
||||
enabled,
|
||||
hidden,
|
||||
limit: (qry_person_id || qry_conference !== null || qry_physical !== null || qry_virtual !== null || qry_type !== null) ? 500 : limit,
|
||||
offset,
|
||||
order_by_li,
|
||||
params_json,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
if (!result_li) return [];
|
||||
|
||||
const processed_obj_li = await process_ae_obj__event_props({
|
||||
obj_li: result_li,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
|
||||
if (try_cache) {
|
||||
await db_save_ae_obj_li__ae_obj({
|
||||
db_instance: db_events,
|
||||
table_name: 'event',
|
||||
obj_li: processed_obj_li,
|
||||
properties_to_save: properties_to_save,
|
||||
log_lvl: log_lvl
|
||||
});
|
||||
}
|
||||
|
||||
return result_li;
|
||||
// Client-side Filter Layer
|
||||
const filtered_obj_li = processed_obj_li.filter((ev: any) => {
|
||||
// Handle conference filter
|
||||
if (qry_conference != null) {
|
||||
const ev_conf = ev.conference === true || ev.conference === 1 || ev.conference === '1';
|
||||
if (ev_conf !== !!qry_conference) return false;
|
||||
}
|
||||
|
||||
// Location Filtering (Inclusive OR logic)
|
||||
// If either filter is explicitly true, we restrict results.
|
||||
// If both are false or null, we show everything.
|
||||
if (qry_physical === true || qry_virtual === true) {
|
||||
const ev_physical = ev.physical === true || ev.physical === 1 || ev.physical === '1';
|
||||
const ev_virtual = ev.virtual === true || ev.virtual === 1 || ev.virtual === '1';
|
||||
|
||||
let match = false;
|
||||
if (qry_physical === true && ev_physical) match = true;
|
||||
if (qry_virtual === true && ev_virtual) match = true;
|
||||
|
||||
if (!match) return false;
|
||||
}
|
||||
|
||||
// Handle type filter (skip if null, undefined, 'all', or empty string)
|
||||
if (qry_type != null && qry_type !== 'all' && qry_type !== '') {
|
||||
if (ev.type !== qry_type) return false;
|
||||
}
|
||||
|
||||
// Handle person ID filter
|
||||
if (qry_person_id) {
|
||||
const match = (
|
||||
ev.external_person_id === qry_person_id ||
|
||||
ev.poc_person_id === qry_person_id ||
|
||||
ev.poc_person_id_random === qry_person_id ||
|
||||
ev.poc_event_person_id === qry_person_id ||
|
||||
ev.poc_event_person_id_random === qry_person_id
|
||||
);
|
||||
if (!match) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(`Filter results (V2): Input=${processed_obj_li.length}, Output=${filtered_obj_li.length}`);
|
||||
}
|
||||
|
||||
return filtered_obj_li;
|
||||
}
|
||||
|
||||
// Updated 2025-05-09
|
||||
@@ -575,7 +777,7 @@ async function _process_generic_props<T extends Record<string, any>>({
|
||||
return processed_obj_li;
|
||||
}
|
||||
|
||||
// Updated 2025-11-13
|
||||
// Updated 2026-01-20
|
||||
export async function process_ae_obj__event_props({
|
||||
obj_li,
|
||||
log_lvl = 0
|
||||
@@ -591,6 +793,13 @@ export async function process_ae_obj__event_props({
|
||||
if (obj.event_code) {
|
||||
obj.code = obj.event_code;
|
||||
}
|
||||
// Ensure ID consistency for components relying on specific ID fields
|
||||
if (!obj.event_id_random && obj.id_random) {
|
||||
obj.event_id_random = obj.id_random;
|
||||
}
|
||||
if (obj.event_id_random && !obj.id) {
|
||||
obj.id = obj.event_id_random;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
});
|
||||
@@ -646,7 +855,7 @@ export function sync_config__event_pres_mgmt({
|
||||
pres_mgmt_cfg_remote?.hide__presentation_code ?? false;
|
||||
pres_mgmt_cfg_local.hide__presentation_datetime =
|
||||
pres_mgmt_cfg_remote?.hide__presentation_datetime ?? false;
|
||||
pres_mgmt_cfg_local.show_content__presentation_description =
|
||||
prev_mgmt_cfg_local.show_content__presentation_description =
|
||||
pres_mgmt_cfg_remote?.show_content__presentation_description ?? false;
|
||||
pres_mgmt_cfg_local.hide__presenter_code =
|
||||
pres_mgmt_cfg_remote?.hide__presenter_code ?? false;
|
||||
|
||||
Reference in New Issue
Block a user