You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor to focus the code on the first steps to get a JS/TS objects representing essential "data". Create clear separation of concerns so that we can rapidly add new well tested features e.g. tag parsing, computed fields.
graph TD
markdown --remark-parse--> st[syntax tree]
st --extract features--> jsobj1[TS Object eg. File plus Metadata plus Tags plus Links]
jsobj1 --computing--> jsobj[TS Objects]
jsobj --convert to sql--> sqlite[SQLite markdown.db]
jsobj --write to disk--> json[JSON on disk in .markdowndb folder]
jsobj --tests--> testoutput[Test results]
Comment: we should write most of our tests at the js object level. Not at sqlite level.
Bonus: Split out the sqlite wrapper to write to sqlite in a separate file and refactored current code to use the processFile function
Comment: we can ignore sqlite right now in this branch not worry about refactoring that code to write to sqlite from JS objects. This would simplify code and allow us to use typescript for everything for now. It is easy to convert json to sqlite later if we want.
Notes
Use micromark to parse the markdown file? ✅2023-11-10 ❌ just use remark-parse for now
Sample code
// FUTURE - to show how code path will run
function buildMarkdownSQLDb(folder) {
walkFolder(folder)
for each file in folder:
parseFile => File
storeFileInDb(File) // or storeAllFiles at once later
}
// what we want to add ...
function parseFile(path) returns File
getKeyInfoOnFile(path)
if(isMarkdown) {
parseMarkdownFile(string) // returns Metadata, Links, Tags, Tasks
// add this info to the FileInfo ...
} else {
return FileInfo
}
}
interface FileInfo {
path
}
interface MarkdownFile extend File {
// adds Metadata
// adds Tags?
}
Schema
interface File {
path: string; // relative path on disk, also will be primary key
extension: string;
metadata: MetaData | null; // frontmatter
}
interface Metadata {
key: value
}
interface Link {
link_type: "normal" | "embed";
from: string; // path
to: string; // to path or url
}
Design sketch for JSON on disk
NB: ❌ we don't need this atm
.markdowndb/
files.json
links.json
Define the schema for that in typescript
The text was updated successfully, but these errors were encountered:
rufuspollock
changed the title
Try-out having a simple JSON-based db (rather than / before sqlite)
Refactor code to have clean interface between parse layer and write to database and focus tests on parse layer
Nov 10, 2023
* [#47,refactor][m]: create a process.ts file that just does extraction of file info to a JS/TS object.
* update index.mdx for testing
* Add process function and add some tests
* [ #4 , extract links ] add link extraction
* [#49, Add body tags extraction]
* #58 refactor mddb code
* Integrate extracting tags from body
* Integrate links extraction
* Add changeset
* update include config
* Restore pathToUrlResolver
* update tests
* Implement obsidian links
* No need for this
* Update tests for links
* Update tests for links
* undo changing tests
* Update obsidian links test
---------
Co-authored-by: Rufus Pollock <rufus.pollock@datopian.com>
Refactor to focus the code on the first steps to get a JS/TS objects representing essential "data". Create clear separation of concerns so that we can rapidly add new well tested features e.g. tag parsing, computed fields.
Comment: we should write most of our tests at the js object level. Not at sqlite level.
Acceptance
See design sketch below.
process.ts
with aprocessFile
function exists which given a path returns a File object or a derivative thereof ✅2023-11-15 this is done - see https://github.com/datopian/markdowndb/blob/8fcda1db4fc2b19eade703c25f91438eb6e69d30/src/lib/process.tsFUTURE
Comment: we can ignore sqlite right now in this branch not worry about refactoring that code to write to sqlite from JS objects. This would simplify code and allow us to use typescript for everything for now. It is easy to convert json to sqlite later if we want.
Notes
Sample code
Schema
Design sketch for JSON on disk
NB: ❌ we don't need this atm
Define the schema for that in typescript
The text was updated successfully, but these errors were encountered: