Quick snapshot again as Gemini is working.

This commit is contained in:
Scott Idem
2025-11-13 12:44:28 -05:00
parent dfaa27384b
commit db8c0e0d05
14 changed files with 1294 additions and 1297 deletions

View File

@@ -880,122 +880,103 @@ let properties_to_save = [
];
// Updated 2025-05-09
export async function process_ae_obj__journal_props(
{
// obj_type,
obj_li,
log_lvl = 0,
}: {
// obj_type: string;
obj_li: any[];
log_lvl?: number;
}
) {
if (log_lvl) {
console.log(`*** process_ae_obj__journal_props() ***`, obj_li);
}
/**
* NON-EXPORTED LOCAL HELPER
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl) {
console.log('No objects to process.');
}
return [];
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
const processed_obj_li = [];
const processed_obj_li: T[] = [];
for (const obj of obj_li) {
// const processed_obj = { ...obj };
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
// Process the properties as needed
let description = obj.description ?? '';
// remove the most common zerowidth characters from the start of the file
let description_cleaned: string = description.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
let description_md_html: null|string = await marked.parse(description_cleaned ?? '') ?? null;
// let description_md_html_alt: null|string = await marked.parse(description_cleaned ?? '', { gfm: false }) ?? null;
// --- Common Transformations ---
let processed_obj = {
id: obj.journal_id_random,
journal_id: obj.journal_id_random,
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
processed_obj.id = processed_obj[randomIdKey];
}
code: obj.code,
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
for_type: obj.for_type,
for_id: obj.for_id,
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
type_code: obj.type_code,
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
account_id: obj.account_id_random,
person_id: obj.person_id_random,
processed_obj_li.push(processed_obj as T);
}
name: obj.name,
short_name: obj.short_name,
summary: obj.summary,
outline: obj.outline,
return processed_obj_li;
}
description: obj.description,
description_md_html: description_md_html, // Use the markdown parser to generate HTML
description_html: obj.description_html,
description_json: obj.description_json,
// Updated 2025-11-13
export async function process_ae_obj__journal_props({
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'journal',
log_lvl,
specific_processor: async (obj) => {
const description = obj.description ?? '';
const description_cleaned: string = description.replace(
/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,
''
);
obj.description_md_html = (await marked.parse(description_cleaned ?? '')) ?? null;
// start_datetime: obj.start_datetime,
// end_datetime: obj.end_datetime,
timezone: obj.timezone,
obj.cfg_json = obj.cfg_json ?? {};
obj.data_json = obj.data_json ?? {};
alert: obj.alert,
alert_msg: obj.alert_msg,
obj.tmp_sort_3 = `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${
obj.name
}_${obj.updated_on ?? obj.created_on}`;
obj.combined_passcode = `${obj.passcode ?? ''}:${obj.private_passcode ?? ''}`;
sort_by: obj.sort_by,
sort_by_desc: obj.sort_by_desc,
cfg_json: obj.cfg_json ?? {},
data_json: obj.data_json ?? {},
// ux_mode: obj.ux_mode,
// This only allows for basic access to the data.
passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
passcode_read_expire: obj.passcode_read_expire,
passcode_write: obj.passcode_write,
passcode_write_expire: obj.passcode_write_expire,
passcode: obj.passcode, // For Journal Entry encryption password
passcode_timeout: obj.passcode_timeout,
private_passcode: obj.private_passcode, // Combine with Journal passcode to encrypt and decrypt Entries
auth_key: obj.auth_key, // For Journal authorization without sign in
enable: obj.enable,
hide: obj.hide,
priority: obj.priority,
sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
// Generated fields for sorting locally only
tmp_sort_1: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.updated_on}_${obj.created_on}`,
tmp_sort_2: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_3: `${obj.group ?? '0'}_${obj.priority ? 1 : 0}_${obj.sort ?? '0'}_${obj.name}_${obj.updated_on ?? obj.created_on}`,
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
combined_passcode: `${obj.passcode}:${obj.private_passcode}`, // Combined Journal passcode and Journal private passcode to encrypt and decrypt Entries
// From SQL view
journal_entry_count: obj.journal_entry_count,
// A key value list of the others
// journal_other_kv: obj.journal_other_kv,
// journal_other_li: obj.journal_other_li,
};
processed_obj_li.push(processed_obj);
}
return processed_obj_li;
return obj;
}
});
}

View File

@@ -894,178 +894,132 @@ let properties_to_save = [
];
// Updated 2025-05-09
export async function process_ae_obj__journal_entry_props(
{
// obj_type,
obj_li,
log_lvl = 0,
}: {
// obj_type: string;
obj_li: any[];
log_lvl?: number;
}
) {
if (log_lvl) {
console.log(`*** process_ae_obj__journal_entry_props() ***`, obj_li);
}
/**
* NON-EXPORTED LOCAL HELPER
* Processes a list of Aether objects by applying common and specific transformations.
*/
async function _process_generic_props<T extends Record<string, any>>({
obj_li,
obj_type,
log_lvl = 0,
specific_processor
}: {
obj_li: T[];
obj_type: string;
log_lvl?: number;
specific_processor?: (obj: T) => Promise<T> | T;
}): Promise<T[]> {
if (log_lvl > 0) {
console.log(
`*** _process_generic_props: Processing ${obj_li.length} objects of type "${obj_type}" ***`
);
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl) {
console.log('No objects to process.');
}
return [];
}
if (!obj_li || obj_li.length === 0) {
if (log_lvl > 0) console.log('No objects to process.');
return [];
}
const processed_obj_li = [];
const processed_obj_li: T[] = [];
for (const obj of obj_li) {
if (log_lvl) {
console.log(`Processing ae_obj journal_entry:`, obj);
}
for (const original_obj of obj_li) {
let processed_obj = { ...original_obj };
let content = obj.content ?? '';
// remove the most common zerowidth characters from the start of the file
let content_cleaned: null|string = null;
let content_md_html: null|string = null; // await marked.parse(content_cleaned ?? '') ?? null;
// let content_md_html_alt: null|string = await marked.parse(content_cleaned ?? '', { gfm: false }) ?? null;
// --- Common Transformations ---
if (obj.content_encrypted) {
// In theory "content" should be null if "content_encrypted" has a value.
content = null; // obj.content_encrypted;
content_cleaned = null;
content_md_html = null;
} else {
content_cleaned = content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
content_md_html = await marked.parse(content_cleaned ?? '') ?? null;
}
// 1. Standardize ID and other '_random' fields
// The API often returns fields like 'person_id_random', which need to be aliased to 'person_id'.
for (const key in processed_obj) {
if (key.endsWith('_random')) {
const newKey = key.slice(0, -7); // Remove '_random' suffix
processed_obj[newKey] = processed_obj[key];
}
}
// Ensure 'id' is set from '[obj_type]_id_random'
const randomIdKey = `${obj_type}_id_random`;
if (processed_obj[randomIdKey]) {
processed_obj.id = processed_obj[randomIdKey];
}
let history = obj.history ?? '';
let history_cleaned: null|string = null;
let history_md_html: null|string = null; // await marked.parse(history_cleaned ?? '') ?? null;
// 2. Create common computed properties for client-side sorting.
const group = processed_obj.group ?? '0';
const priority = processed_obj.priority ? 1 : 0;
const sort = processed_obj.sort ?? '0';
const updated = processed_obj.updated_on ?? processed_obj.created_on;
const name = processed_obj.name ?? '';
if (obj.history_encrypted) {
// In theory "history" should be null if "history_encrypted" has a value.
history = null; // obj.history_encrypted;
history_cleaned = null;
history_md_html = null;
} else {
history_cleaned = history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
history_md_html = await marked.parse(history_cleaned ?? '') ?? null;
}
processed_obj.tmp_sort_1 = `${group}_${priority}_${sort}_${updated}`;
processed_obj.tmp_sort_2 = `${group}_${priority}_${sort}_${name}_${updated}`;
let processed_obj = {
id: obj.journal_entry_id_random,
journal_entry_id: obj.journal_entry_id_random,
// --- Specific Transformations ---
if (specific_processor) {
processed_obj = await Promise.resolve(specific_processor(processed_obj));
}
journal_id: obj.journal_id_random,
processed_obj_li.push(processed_obj as T);
}
code: obj.code,
for_type: obj.for_type,
for_id: obj.for_id,
journal_entry_type: obj.journal_entry_type,
person_id: obj.person_id_random,
template: obj.template ?? null, // Allow for a template to be used, otherwise null
activity_code: obj.activity_code,
category_code: obj.category_code,
type_code: obj.type_code,
topic_code: obj.topic_code,
tags: obj.tags,
public: obj.public,
private: obj.private,
personal: obj.personal,
professional: obj.professional,
name: obj.name,
short_name: obj.short_name ?? null,
summary: obj.summary,
outline: obj.outline,
// description: obj.description,
content: content,
content_md_html: content_md_html,
// content_md_html_alt: content_md_html_alt,
content_html: obj.content_html,
content_json: obj.content_json,
content_encrypted: obj.content_encrypted,
history: history,
history_md_html: history_md_html,
history_encrypted: obj.history_encrypted,
passcode_hash: obj.passcode_hash,
// url: obj.url,
// url_text: obj.url_text,
// hosted_file_id: obj.hosted_file_id_random,
// file_path: obj.file_path,
// filename: obj.filename,
// file_extension: obj.file_extension,
// start_datetime: obj.start_datetime,
// end_datetime: obj.end_datetime,
// timezone: obj.timezone,
// original_datetime: obj.original_datetime,
// original_timezone: obj.original_timezone,
// original_location: obj.original_location,
// original_url: obj.original_url,
// original_url_text: obj.original_url_text,
// enable_for_public: obj.enable_for_public,
alert: obj.alert,
alert_msg: obj.alert_msg,
// cfg_json: obj.cfg_json ?? {},
data_json: obj.data_json ?? {},
// This only allows for basic access to the data.
// passcode_read: obj.passcode_read, // For LLM (AI) generated summary...???
// passcode_read_expire: obj.passcode_read_expire,
// passcode_write: obj.passcode_write,
// passcode_write_expire: obj.passcode_write_expire,
enable: obj.enable,
hide: obj.hide,
archive: obj.archive,
archive_on: obj.archive_on,
priority: obj.priority,
sort: obj.sort,
group: obj.group,
notes: obj.notes,
created_on: obj.created_on,
updated_on: obj.updated_on,
// Generated fields for sorting locally only
tmp_sort_1: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on}_${obj.created_on}`,
tmp_sort_2: `${obj.group}_${obj.priority}_${obj.sort}_${obj.updated_on ?? obj.created_on}`,
tmp_sort_3: `${obj.group}_${obj.priority}_${obj.sort}_${obj.name}_${obj.updated_on ?? obj.created_on}`,
// Generated fields for sorting locally only
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
// From SQL view
journal_code: obj.journal_code,
journal_name: obj.journal_name,
// A key value list of the others
// journal_other_kv: obj.journal_other_kv,
// journal_other_li: obj.journal_other_li,
};
processed_obj_li.push(processed_obj);
}
return processed_obj_li;
return processed_obj_li;
}
// Updated 2025-05-09
export async function process_ae_obj__journal_entry_props({
obj_li,
log_lvl = 0
}: {
obj_li: any[];
log_lvl?: number;
}) {
return _process_generic_props({
obj_li,
obj_type: 'journal_entry',
log_lvl,
specific_processor: async (obj) => {
// Content processing
let content = obj.content ?? '';
let content_cleaned: null | string = null;
let content_md_html: null | string = null;
if (obj.content_encrypted) {
content = null;
content_cleaned = null;
content_md_html = null;
} else {
content_cleaned = content.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, '');
content_md_html = (await marked.parse(content_cleaned ?? '')) ?? null;
}
obj.content = content;
obj.content_md_html = content_md_html;
// History processing
let history = obj.history ?? '';
let history_cleaned: null | string = null;
let history_md_html: null | string = null;
if (obj.history_encrypted) {
history = null;
history_cleaned = null;
history_md_html = null;
} else {
history_cleaned = history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/, '');
history_md_html = (await marked.parse(history_cleaned ?? '')) ?? null;
}
obj.history = history;
obj.history_md_html = history_md_html;
// Journal entry-specific computed sort fields, overriding generic ones if needed
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.name ?? ''}_${obj.updated_on ?? obj.created_on}`;
obj.tmp_sort_3 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''
}_${obj.name ?? ''}_${obj.updated_on ?? obj.created_on}`;
return obj;
}
});
}