Gradiant XAPI constans for xAPI


Keywords
dsl, elearning, gradiant, npm, typescript, xapi, xapi-dsl, xapi-statement
License
Unlicense
Install
npm install @gradiant/xapi-dsl@1.10.0

Documentation

npm version code style: prettier Conventional Commits

Gradiant xAPI DSL

Set of types for easily building xAPI statements.

Overview

This package contains a set of typescript definitions types to work with xAPI statements.

  • Actor
  • Attachment
  • Context
  • Object
  • Result
  • Statement
  • Verb

It also includes some external xAPI vocabulary terms (e.g. verbs, activities and extension identifiers) to be used in a centralized way. Some of the xAPI vocabularies considered here are:

DSL

You can consult the entire DSL at the dsl-definition.json

Getting started

The module exports in the index all the types needed by the xapi as well as the dsl as a nested object

// xapi interfaces...
import { Statement } from '@gradiant/xapi-dsl';

// dsl nested object
import { dsl } from '@gradiant/xapi-dsl';

const statement: Statement = jsonStatement as Statement;

if (statement.verb.id === dsl.activityTypes.smart.essay) {
  // essay activity type URI
  console.log('Smart essay activity');
}

Also, DSL constants can be imported individually from the dsl folder

import { activityTypes, verbs, contextExtensions /* ... */ } from '@gradiant/xapi-dsl/dsl';

Scripts

npm run build

Build the TypeScript files under de src folder into the root folder. It will generate the dsl folder and the types folder. These two folder are auto generated and therefore should not be edited directly.

npm run clean

Remove the following generated directories/files

  • dsl
  • types
  • index.js
  • index.d.ts
  • index.d.ts.map

npm run lint

Run tslint and prettier applying the available fixes