2.7.5 • Published 6 months ago

@teammaestro/node-document-service v2.7.5

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
6 months ago

node-document-service

A TypeScript NodeJS client that interfaces with the Maestro Document Service

Getting Started

Run this to install the latest stable version.

npm i @teammaestro/node-document-service

Import @teammaestro/node-document-service and the client will be exported into your script from the latest build.

import { DocumentService } from 'node-document-service';

Documentation

Overview

new DocumentService(apiKey: string, options?: { host?: string, logging?: boolean | Function })

Parameters:

  • apiKey (string) - This is the API Key from your document managment service account
  • options.host (string | optional | default: https://dms.meetmaestro.com) - The domain that DMS is located at
  • options.logging (boolean or Function | optional ) - Use this to turn on logging or pass in your custom logger.

Request Example:

new DocumentService(apiKey: '123', {
    host: 'https://dev-dms.meetmaestro.com',
    logging: console.log
})

.catch()

Whenever the API makes a call and runs into a catch block, you will get an error block that looks consistently like this:

NameTypeDescription
errorErrorThe exception that was thrown
statusnumberThe HTTP Status Code
messagestringThe HTTP error message (some are custom mapped)
durationnumberHow long the response took in miliseconds

Response Example:

{
    error: Error
    status: 500,
    message: 'Internal Server Error',
    duration: 300
}

getPreSignedData({ filename: string, acl: string, expiration: number }) GET /api/v1/pre-sign

This endpoint is used for creating policies in order to upload content to your S3 bucket Note: You must send the payload to S3 in the order that we send them back.

You can append anything you want to the key property (including the file extension).

You can also update the Content-Type to the real mime-type.

Parameters

NameTypeRequiredDescription
filenamestringFalse (default: UUID)Set this if you want to name the file.
aclstringFalse (default: private)This is the permissions for the file. Options are private|public
expirationnumberFalse (default: 1800)This is expiration time for the signature in seconds

Request Example:

dms.getPreSignedConfig({
    acl: 'public',
    filename: 'test.pdf',
    expiration: 120
})

Response Example:

{
    "url": "https://new-media-test-bucket.s3.amazonaws.com",
    "key": "a8231d87-c327-4cfc-a225-d1567de732ce",
    "Content-Type": "binary/octet-stream",
    "AWSAccessKeyId": "AKIAIF4CQIVFLH2VGVNA",
    "acl": "public-read",
    "policy": "eyJleHBpcmF0aW9uIjoiMjAxNy0wMi0xM1QwN...",
    "signature": "mmgVVFG6swkWvm3AmWZ9FB71R8s=",
    "expiration": "2017-04-06T14:49:16.267Z"
}

getSignedUrl(url: string, expiration: number) GET /api/v1/sign

This endpoint is used for signing your S3 private content

Parameters

NameTypeRequiredDescription
urlstringTrueThe url of the private S3 content you want to view
expirationnumberFalse (default: 1800)This is expiration time for the signature in seconds

Request Example:

dms.getSignedUrl('https://new-media-test-bucket.s3.amazonaws.com/test.pdf', 2000)

Response Example:

{
  "url": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
  "expiration": "2017-04-06T14:49:16.267Z"
}

register(options: DocumentServiceOptions.RegistrationData) POST /api/v1/content

This endpoint is used to register your content with the document service.

Parameters

NameTypeRequiredDescription
options.titlestringTrueThe title of the content
options.pathstringTrueThe location of the content in S3
options.fileFormatMediaTypeTrueThe format of the file
options.convertFormatbooleanFalseThe format to convert the file to
options.shouldGenerateThumbnailbooleanFalseIf a thumbnail should be generated

Request Example:

dms.register({
    title: 'Training Intro',
    path: 'https://new-media-test-bucket.s3.amazonaws.com/test.pdf',
    fileFormat: 'PDF',
    shouldGenerateThumbnail: true
})

Response Example:

{
  "identity": "ad9991a8-ab82-4521-befe-a8f2f956ce12"
}

view(options: DocumentServiceOptions.ViewOptions) GET /api/v1/content/:identity/view

This endpoint is used for generating the information you need to view the content

The payload will be a little dynamic based on the content type

Parameters

NameTypeRequiredDescription
options.identitystringTrueThe identity that DMS will use for callbacks
options.registrationIdstringFalseThe registrationId of the course in scorm engine

Request Example:

dms.view({
    identity: 'ad9991a8-ab82-4521-befe-a8f2f956ce12'
})

Response Example:

{
  "url": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
  "expiration": "2017-04-06T14:49:16.267Z",
  "downloadUrl": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
  "fileFormat": "docx",
  "convertedContent": {
    "url": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
    "expiration": "2017-04-06T14:49:16.267Z",
    "downloadUrl": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
    "fileFormat": "pdf",
  }
}

Contributors

John Pinkster
2.7.4

6 months ago

2.7.5

6 months ago

2.7.3

2 years ago

2.7.2

2 years ago

2.6.0

2 years ago

1.0.1

6 years ago

1.0.0

7 years ago