Adding a new notes module I guess. Because why not.
This commit is contained in:
147
src/lib/db_notes.ts
Normal file
147
src/lib/db_notes.ts
Normal 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();
|
||||
Reference in New Issue
Block a user