Skip to content

Crate Manager

The component has a built in RO-Crate manager that knows how to work with and manipulate the data based on actions within the component. As this is now available to users of the component it's worth noting that it can be used in your application without using the component.

API Documentation

Initialisation and usage

JS

import { CrateManager } from "@describo/crate-builder-component/src/crate-builder/CrateManager/crate-manager.js";

let crate = {
    '@context': [...],
    '@graph': [...]
}
const cm = new CrateManager({ crate });
JS
// get the root dataset
let rd = cm.getRootDataset()
JS
// get an entity
let e = cm.getEntity({ id: './' })
JS
// get an iterable to all entities
let es = cm.getEntities()
for (let e of es) {
    // do something with e
}
JS
// add an entity
let e = cm.addEntity({ '@id': ..., '@type': ..., ... })

How does it compare to ro-crate-js

There is an NPM package for manipulating RO-Crates called ro-crate-js. CrateManager does the same as that package but in a very different way.

TIP

CrateManager is licensed with the permissive MIT licence.

DANGER

ro-crate-js is licensed with the GPLv3 which may impact where you can use it.