Inkdrop data model definitions in json-schema and TypeScript
Human readable definitions are here.
npm install inkdrop-model- Note - A markdown document with title, body, status, tags, and visibility settings
- Book - A notebook for organizing notes, with support for nesting and custom icons
- Tag - A label for categorizing notes, with customizable colors
- File - An image attachment that can be embedded in notes
import type { Note, Book, Tag, File } from 'inkdrop-model'The main entry has types, constants and small helpers, with no validators and no dependency on ajv:
import { isNoteId, isTrashBookId, hasConflicts } from 'inkdrop-model'The schemas, the precompiled validators and the validation error helpers live in the inkdrop-model/validators entry. It requires ajv v8 as a peer dependency:
import {
NoteSchema,
BookSchema,
TagSchema,
FileSchema
} from 'inkdrop-model/validators'
import { validateNote, InvalidDataError } from 'inkdrop-model/validators'You can validate data with json schemas. Below example uses ajv as a validator:
import { NoteSchema } from 'inkdrop-model/validators'
import Ajv from 'ajv'
const ajv = new Ajv()
const validate = ajv.compile(NoteSchema)
const data = {
_id: 'note:BkgOZZUJzf',
title: 'link',
doctype: 'markdown',
updatedAt: 1513330812556,
createdAt: 1513214207639,
tags: [],
status: 'none',
share: 'private',
body: 'markdown note body',
bookId: 'book:first',
_rev: '38-636e505958d24f9c21614d95ea03b5a1'
}
const valid = validate(data)
console.log(valid) // => true