Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

mbjs-data-models

2.0.1 • Public • Published

MB.js Data Models

Motion Bank data models (JavaScript)

NPM version Coverage Status CircleCI Docker Pulls

Install

First you 💾 install...

npm i --save mbjs-data-models

... then you include 🔥 ...

const models = require('mbjs-data-models')

... then you get the :neckbeard:.

Documentation

What you might want to know about the Data Models... is most likely not yet here.

Annotation

Aims to conform to the Web Annotation Model.

Spoiler alert: It doesn't yet do that at all. But maybe one sweet, velvet morning...

  • The generated document UUID is a random version 4
const 
  { Annotation } = models,
  anno = new Annotation({
    // see below for schema ...
  })

Schema

Here is a random example using all currently available properties.

const anno = new Annotation({
  // coming soon ...
})

Document

Used to store 📁 metadata about binary resources (e.g. audio, video, textfiles, etc.).

  • The generated document UUID is a version 5 and uses the property doc.file.hash as a basis for this. Exact duplicates should not be imported, if the DB checks for existing UUIDs.
const 
  { Document } = models,
  doc = new Document({
    // see below for schema ...
  })

Schema

Here is a random example using all currently available properties.

const doc = new Document({
  uuid: 'a27693d7-020b-5dec-851d-a9c7c6f30ef8',
  author: 'Ryan Castro',
  source: {
    id: 'http://ahi.sn/laokdug',
    type: 'Video'
  },
  file: {
    added: '2018-04-17T01:12:05.190+02:00',
    created: '2018-04-17T01:12:05.191+02:00',
    updated: '2018-04-17T01:12:05.191+02:00',
    bytes: 3065500099,
    hash: 'b9ca06bdb57d0ad3d3a099c99593e1e20b8fbd98',
    mime: 'video/mp4',
    ext: 'mp4'
  },
  media: {
    streams: [
      {
        codec: {
          name: 'zewubu',
          longName: 'Rekun ded gizapev gejtulcu.',
          tag: '318332bff33d90e51863467d2e474f09c329e391',
          tagString: 'ajunasik',
          timeBase: '1/2000',
          type: 'video',
          profile: 'main'
        },
        dimensions: {
          width: 1280,
          height: 720,
          codedWidth: 1280,
          codedHeight: 720,
          displayAspectRatio: '16:9',
          sampleAspectRatio: '16:9',
          pixelFormat: 'yuv422'
        },
        duration: 476,
        durationTs: 576585,
        maxBitRate: 1000,
        nbFrames: 4000,
        type: 'video',
        level: 10,
        timeBase: '1/50',
        avgFrameRate: 25,
        rFrameRate: '1/1000',
        startTime: 0
      }
    ],
    format: {
      tags: [
        {
          title: 'gaszeuco',
          value: 'Kigvis maiwu ripde ad koh.'
        },
        {
          title: 'jectuote',
          value: 'Vitu wehzucih udbu oha pugetoni.'
        }
      ],
      bitRate: 1000,
      duration: 476,
      name: 'mov',
      longName: 'QuickTime',
      nbStreams: 1,
      nbPrograms: 0,
      size: 6478596780,
      startTime: 0
    }
  },
  added: '2018-04-17T01:12:05.196+02:00',
  created: '2018-04-17T01:12:05.196+02:00',
  updated: '2018-04-17T01:20:50.234+02:00'
})

Tag

Just a simple tag.

const 
  { Tag } = models,
  tag = new Tag({
    // see below for schema ...
  })

Schema

Here is a random example using all currently available properties.

const tag = new Tag({
  title: 'itsatag',
  value: 'and here is some more optional content to it'
})

Convenience

serializeJSON

Serializes the current instance as JSON text data 📝 (with optional ✨ pretty printing).

const 
  anno = new Annotation(),
  // compact JSON
  compact = anno.serializeJSON(),
  // pretty JSON
  pretty = anno.serializeJSON({ pretty: true })

fromJSON

Resurrects a prior 💀 instance from stored JSON text data.

const 
  textdata = await fs.readFileAsync('/data/annotation.json'),
  anno = Annotation.fromJSON(textdata)

Develop

Don't forget to always npm run lint and npm test before you 💣 a commit.

Stability

experimental

This module is still under active development and subject to non-backwards compatible changes, or even removal of features, in any future version.

License

©️ 2019 Mainz University of Applied Sciences (Motion Bank Project) – Released under the MIT license

Install

npm i mbjs-data-models

DownloadsWeekly Downloads

146

Version

2.0.1

License

MIT

Unpacked Size

93.5 kB

Total Files

71

Last publish

Collaborators

  • avatar