Set of types for easily building xAPI statements.
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:
You can consult the entire DSL at the dsl-definition.json
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';
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.
Remove the following generated directories/files
- dsl
- types
- index.js
- index.d.ts
- index.d.ts.map
Run tslint
and prettier
applying the available fixes
It generates a new version of dsl-definition.json file. This file must be updated to release a new version.