Adding a new notes module I guess. Because why not.

This commit is contained in:
Scott Idem
2024-08-20 21:00:03 -04:00
parent 5139a706d0
commit d8edd658b0
8 changed files with 693 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
// This file is used to export all the functions that are used for Aether Events related functions.
// import {
// handle_load_ae_obj_id__note,
// handle_load_ae_obj_li__note,
// handle_db_save_ae_obj_li__note,
// } from "$lib/ae_notes__note";
let export_obj = {
// handle_load_ae_obj_id__note: handle_load_ae_obj_id__note,
};
export let notes_func = export_obj;

View File

@@ -0,0 +1,70 @@
import { localStorageStore } from '@skeletonlabs/skeleton';
import { writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
import type { key_val } from '$lib/ae_stores';
/* *** BEGIN *** Initialize notes_local_data_struct */
// This is for longer term or sticky app data. This should be stored to *local* storage.
// Updated 2024-08-20
let notes_local_data_struct: key_val = {
ver: '2024-08-20_19',
// Shared
name: 'Aether - Notes (SvelteKit 2.x Svelte 4.x)',
title: `OSIT's Æ Notes`, // Æ
mode__edit: false,
mode__debug: false,
};
// console.log(`AE Stores - App Notes Local Storage Data:`, notes_local_data_struct);
// This works and uses *local* storage:
export let notes_loc: Writable<key_val> = localStorageStore('ae_notes_loc', notes_local_data_struct);
// console.log(`AE Stores - App Local Storage Data:`, get(ae_loc));
/* *** BEGIN *** Initialize notes_session_data_struct */
// Temporary app data. This is lost if the page is refreshed or using different tabs/windows. This should be stored to *session* storage.
// Updated 2024-08-20
let notes_session_data_struct: key_val = {
ver: '2024-08-20_19',
log_lvl: 1,
// Shared Triggers
trigger: null,
trigger__note_id: null,
// trigger__note_li: null,
};
// console.log(`AE Stores - App Notes Session Storage Data:`, notes_session_data_struct);
export let notes_sess = writable(notes_session_data_struct);
/* *** BEGIN *** Initialize notes_slct and notes_trigger */
/* The slct and slct_trigger variable should not be stored in local storage. Only use session storage because browser tabs can be open to different notes, badges, exhibits, etc. */
// Intended for temporary session storage.
// Updated 2024-08-20
let notes_slct_obj_template: key_val = {
// Top level
'note_id': null,
'note_obj': {},
'note_obj_li': [],
'lq__note_obj': {}, // Testing passing a LiveQuery object around...
};
// console.log(`AE Stores - Selected Notes Objects:`, notes_slct_obj_template);
// This works, and uses *session* (not local) storage:
export let notes_slct = writable(notes_slct_obj_template);
/* *** BEGIN *** Initialize notes_trigger */
// Intended for temporary session storage.
// Updated 2024-08-20
export let notes_trigger: any = writable(null);
// console.log(`AE Notes Stores - Notes Trigger:`, notes_trigger);

View File

@@ -1,7 +1,6 @@
import Dexie, { type Table } from 'dexie';
import type { list } from 'postcss';
import type { key_val } from './ae_stores';
import type { o } from 'vitest/dist/reporters-B7ebVMkT.js';
// li = list
// kv = key value list

147
src/lib/db_notes.ts Normal file
View File

@@ -0,0 +1,147 @@
import Dexie, { type Table } from 'dexie';
import type { key_val } from './ae_stores';
// li = list
// kv = key value list
// json = JSON string
// ux = user experience (mode)
// LLM = Large Language Model (AI)
// Updated 2024-08-20
export interface Note {
id: string; // actually "id_random"
note_id: string;
// Essentially this is a change log of notes
snapshot_id: string; // This is the original note ID. If deleted, then delete all children notes.
previous_id?: null|string; // This is the old or parent note ID
next_id?: null|string; // This is the new or child note ID
external_id?: null|string;
import_id?: null|string;
code?: null|string;
for_type?: null|string;
for_id?: null|string;
type_code?: null|string;
account_id?: null|string; // Owner account of the note
person_id?: null|string; // Owner person of the note
event_id: null|string; // Assign to an event???
location_id?: null|string; // Assign to a location???
name: string; // or the title
summary?: null|string; // LLM (AI) generated summary...???
outline?: null|string; // LLM (AI) generated outline...???
note?: null|string;
note_html?: null|string;
note_json?: null|string;
start_datetime?: null|Date;
end_datetime?: null|Date;
timezone?: null|string;
hide_event_launcher?: null|boolean;
alert?: null|boolean; // LLM (AI) generated summary...???
alert_msg?: null|string; // LLM (AI) generated summary...???
data_json?: null|string; // We always need to store something extra...
ux_mode?: null|string; // 'mobile' or 'desktop'
// This only allows for basic access to the content.
passcode_read?: null|string; // For LLM (AI) generated summary...???
passcode_read_expire?: null|Date;
passcode_write?: null|string;
passcode_write_expire?: null|Date
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;
// Additional fields for convenience (database views)
file_count?: null|number; // Only files directly under a note
note_file_id_li_json?: null|string;
// One person
person__given_name?: null|string;
person__family_name?: null|string;
person__full_name?: null|string;
person__primary_email?: null|string;
person__passcode?: null|string;
// JSON formatted key value pairs for multiple people: {id: name, email, etc.}
person__kv_json?: null|string;
note_name?: null|string;
note_location_code?: null|string;
note_location_name?: null|string;
// A key value list of the presentations
note_presentation_kv?: null|key_val;
note_presentation_li?: null|list;
// A key value list of the files
note_file_kv?: null|key_val;
note_file_li?: null|list;
// Future standard fields!!!
obj_id?: null|string;
obj_ext_uid?: null|string; // Probably not needed for notes
obj_ext_id?: null|string; // Probably not needed for notes
obj_import_id?: null|string; // Probably not needed for notes
obj_code?: null|string;
obj_account_id?: null|string;
obj_passcode?: null|string;
obj_type?: null|string; // Should always be 'note' in this case
obj_type_ver_id?: null|string; // The ID from the table for the object type
obj_name?: null|string;
obj_summary?: null|string; // LLM (AI) generated summary...???
obj_outline?: null|string; // LLM (AI) generated outline...???
obj_description?: null|string; // Probably not needed for notes
obj_enable?: null|boolean;
obj_enable_on?: null|Date;
obj_archive_on?: null|Date;
obj_hide?: null|boolean;
obj_priority?: null|number;
obj_sort?: null|number;
obj_group?: null|string;
obj_cfg_json?: null|string;
obj_notes?: null|string; // Not the same as the "note" in the object type named "Note".
obj_created_on?: Date;
obj_updated_on?: null|Date;
}
// Updated 2024-06-10
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
notes!: Table<Note>;
constructor() {
super('ae_notes_db');
this.version(1).stores({
notes: `
id, note_id, note_id_random,
code,
account_id, account_id_random,
conference, type,
name,
start_datetime, end_datetime,
timezone,
cfg_json,
enable, hide, priority, sort, group, notes, created_on, updated_on`,
});
}
}
export const db_notes = new MySubClassedDexie();