This package is not published to npmjs.com and so will need to be referenced directly in the package.json file. Add the following line to your dependencies
section:
"d2l-document-builder-common": "https://github.com/Brightspace/document-builder-common",
Then run
npm install
to add it to the project.
Example:
import { Database } from 'd2l-document-builder-common';
const db = new Database('us-east-1');
db.Conversion.createAsync({
fileId: 'my-file-xyz-123',
format: 'raw',
createdAt: date,
lastTouched: date,
checksum: 'aoewigh3240239r3rhf0m30fj0324',
status: 'Complete',
fileUri: 'https://wherever.s3.amazon.com/myfile/xyz/123/file.txt',
error: {
id: 'http://errors.brightspace.com/failure',
title: 'Something happened',
description: 'Aspose failed.'
}
})
.then(() => {
// ...
})
.catch(err => {
// ...
});
The Conversion
object exposed by the db
isntance is a Vogels table definition promisified with Bluebird. See the coresponding documentation on how to use them.
To use the S3 client, instantiate it like so:
import { FileStorage } from 'd2l-document-builder-common';
const storage = new FileStorage('my-bucket-name', 'aws-region');
// ...