-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from codex-team/note-history
feat(noteHistory): note history implementation
- Loading branch information
Showing
16 changed files
with
1,024 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- | ||
-- Name: note_history; Type: TABLE; Schema: public; Owner: codex | ||
-- | ||
|
||
CREATE TABLE IF NOT EXISTS public.note_history ( | ||
id SERIAL PRIMARY KEY, | ||
note_id integer NOT NULL, | ||
user_id integer, | ||
created_at TIMESTAMP NOT NULL, | ||
content json, | ||
tools jsonb | ||
); | ||
|
||
-- | ||
-- Name: note_history note_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: codex | ||
-- | ||
ALTER TABLE public.note_history DROP CONSTRAINT IF EXISTS note_id_fkey; | ||
ALTER TABLE public.note_history | ||
ADD CONSTRAINT note_id_fkey FOREIGN KEY (note_id) REFERENCES public.notes(id) | ||
ON UPDATE CASCADE ON DELETE CASCADE; | ||
|
||
-- | ||
-- Name: note_history user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: codex | ||
-- | ||
ALTER TABLE public.note_history DROP CONSTRAINT IF EXISTS user_id_fkey; | ||
ALTER TABLE public.note_history | ||
ADD CONSTRAINT user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) | ||
ON UPDATE CASCADE ON DELETE CASCADE; | ||
|
||
CREATE INDEX note_history_note_id_idx ON public.note_history (note_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { NoteInternalId, Note, NotePublicId } from './note.js'; | ||
import type User from './user.js'; | ||
|
||
export interface NoteHistoryRecord { | ||
/** | ||
* Unique identified of note history record | ||
*/ | ||
id: number; | ||
|
||
/** | ||
* Id of the note whose content history is stored | ||
*/ | ||
noteId: NoteInternalId; | ||
|
||
/** | ||
* User that updated note content | ||
*/ | ||
userId: User['id']; | ||
|
||
/** | ||
* Timestamp of note update | ||
*/ | ||
createdAt: string; | ||
|
||
/** | ||
* Version of note content | ||
*/ | ||
content: Note['content']; | ||
|
||
/** | ||
* Note tools of current version of note content | ||
*/ | ||
tools: Note['tools']; | ||
} | ||
|
||
/** | ||
* Part of note entity used to create new note | ||
*/ | ||
export type NoteHistoryCreationAttributes = Omit<NoteHistoryRecord, 'id' | 'createdAt'>; | ||
|
||
/** | ||
* Meta data of the note history record | ||
* Used for presentation of the note history record in web | ||
*/ | ||
export type NoteHistoryMeta = Omit<NoteHistoryRecord, 'content' | 'noteId' | 'tools'>; | ||
|
||
/** | ||
* Public note history record with note public id instead of note internal id | ||
*/ | ||
export type NoteHistoryPublic = Omit<NoteHistoryRecord, 'noteId'> & { noteId: NotePublicId }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.