Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inkdropapp/inkdrop-model
Inkdrop data model definitions in json-schema and flowtype
https://github.com/inkdropapp/inkdrop-model
inkdrop json-schema
Last synced: 19 days ago
JSON representation
Inkdrop data model definitions in json-schema and flowtype
- Host: GitHub
- URL: https://github.com/inkdropapp/inkdrop-model
- Owner: inkdropapp
- License: mit
- Created: 2017-12-16T09:20:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T05:12:22.000Z (2 months ago)
- Last Synced: 2024-11-16T17:17:04.229Z (about 1 month ago)
- Topics: inkdrop, json-schema
- Language: TypeScript
- Homepage: https://www.inkdrop.app/
- Size: 894 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Inkdrop Model
==================Inkdrop data model definitions in json-schema and TypeScript
## Documentations
Human readable definitions are [here](https://github.com/inkdropapp/inkdrop-model/tree/master/docs/schema.md).
## Install
```sh
npm install inkdrop-model
```## Usage
### TypeScript
```typescript
import type { Note, Book, Tag, File } from 'inkdrop-model'
```### Json Schema
```javascript
import { NoteSchema, BookSchema, TagSchema, FileSchema } from 'inkdrop-model'
```You can validate data with json schemas.
Below example uses [ajv](https://github.com/epoberezkin/ajv) as a validator:```javascript
import { NoteSchema } from 'inkdrop-model'
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
```