Skip to content

Commit b8557a2

Browse files
author
Tyler Vander Maas
authored
Merge pull request #6 from TeamHive/fix/register-options
fix(document-service): Fix the register options
2 parents 00d6b6d + d57a60d commit b8557a2

10 files changed

+103
-5
lines changed

README.md

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Whenever the API makes a call and runs into a catch block, you will get an error
5858
}
5959
```
6060

61-
### getPreSignedData({ fileName: string, acl: string, expiration: number }) [GET /api/v1/pre-sign](https://dev-dms.meetmaestro.com:3000/#api-Signing-Pre_Sign_Url)
61+
### getPreSignedData({ fileName: string, acl: string, expiration: number }) [GET /api/v1/pre-sign](https://dev-dms.meetmaestro.com/docs/development/index.html#api-Signing-Pre_Sign_Url)
6262

6363
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.
6464

@@ -97,7 +97,7 @@ dms.getPreSignedConfig({
9797
}
9898
```
9999

100-
### getSignedUrl(url: string, expiration: number) [GET /api/v1/sign](https://dev-dms.meetmaestro.com:3000/#api-Signing-Sign_Url)
100+
### getSignedUrl(url: string, expiration: number) [GET /api/v1/sign](https://dev-dms.meetmaestro.com/docs/development/index.html#api-Signing-Sign_Url)
101101
This endpoint is used for signing your S3 private content
102102

103103
**Parameters**
@@ -119,6 +119,79 @@ dms.getSignedUrl('https://new-media-test-bucket.s3.amazonaws.com/test.pdf', 2000
119119
}
120120
```
121121

122+
### register(options: DocumentServiceOptions.RegistrationData) [POST /api/v1/register] (https://dev-dms.meetmaestro.com/docs/development/index.html#api-Signing-Sign_Url)
123+
This endpoint is used to register your content with the document service.
124+
125+
**Parameters**
126+
127+
|Name|Type|Required|Description|
128+
|---|---|---|---|
129+
|options.title|string|True| The title of the content|
130+
|options.identity|string|True| The identity that DMS will use for callbacks|
131+
|options.path|string|True| The location of the content in S3|
132+
|options.mediaType|MediaType|True| The contents media type used for determining all the registration requirements|
133+
|options.shouldConvert|boolean|False| If the file should be converted|
134+
|options.shouldGenerateThumbnail|boolean|False| If a thumbnail should be generated|
135+
136+
**Request Example:**
137+
```javascript
138+
dms.register({
139+
title: 'Training Intro',
140+
identity: 'ad9991a8-ab82-4521-befe-a8f2f956ce12',
141+
path: 'https://new-media-test-bucket.s3.amazonaws.com/test.pdf',
142+
mediaType: 'PDF',
143+
shouldGenerateThumbnail: true
144+
})
145+
```
146+
**Response Example:**
147+
```
148+
{
149+
"code": "MEDIA_PROCESSING"
150+
}
151+
```
152+
153+
### view(options: DocumentServiceOptions.RegistrationData) [POST /api/v1/view] (https://dev-dms.meetmaestro.com/docs/development/index.html#api-Signing-Sign_Url)
154+
This endpoint is used for generating the information you need to view the content
155+
156+
The payload will be a little dynamic based on the content type
157+
158+
**Parameters**
159+
160+
|Name|Type|Required|Description|
161+
|---|---|---|---|
162+
|options.title|string|True| The title of the content|
163+
|options.identity|string|True| The identity that DMS will use for callbacks|
164+
|options.path|string|True| The location of the content in S3|
165+
|options.mediaType|MediaType|True| The contents media type used for determining all the registration requirements|
166+
167+
**Request Example:**
168+
```javascript
169+
dms.view({
170+
title: 'Training Intro',
171+
identity: 'ad9991a8-ab82-4521-befe-a8f2f956ce12',
172+
path: 'https://new-media-test-bucket.s3.amazonaws.com/test.pdf',
173+
mediaType: 'PDF'
174+
})
175+
```
176+
177+
**Response Example:**
178+
```
179+
{
180+
"url": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
181+
"downloadUrl": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
182+
"expiration": "2017-04-06T14:49:16.267Z",
183+
"jwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2V..", (PDF only - The JWT needed for opening the pdf with PSPDFKit)
184+
"documentId": 3 (PDF only - The documentId needed for opening the pdf with PSPDFKit)
185+
"convertedContent": {
186+
"url": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
187+
"downloadUrl": "https://bucket.s3.amazonaws.com/73aff5ee-a986-4af...",
188+
"expiration": "2017-04-06T14:49:16.267Z",
189+
"jwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2V..", (PDF only - The JWT needed for opening the pdf with PSPDFKit)
190+
"documentId": 3 (PDF only - The documentId needed for opening the pdf with PSPDFKit)
191+
}
192+
}
193+
```
194+
122195
# Contributors
123196

124197
[<img alt="John Pinkster" src="https://avatars1.githubusercontent.com/u/5350861?v=3&s=460" width="117">](https://github.com/jpinkster)|

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"watch": "tsc -w",
1111
"prepublishOnly": "tsc",
1212
"prepack": "tsc",
13-
"postpack": "rm *.d.ts && rm *.js"
13+
"postpack": "rm *.d.ts && rm *.js && rm -rf interfaces types"
1414
},
1515
"author": "TeamHive",
1616
"contributors": [

src/document-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as querystring from 'query-string';
33
import * as _ from 'lodash';
44
import * as fs from 'fs';
55
import * as mime from 'mime';
6-
import { DocumentServiceOptions } from './index';
6+
import { DocumentServiceOptions } from './interfaces';
77

88
export class DocumentService {
99

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './document-service';
2-
export * from './document-service-options.interface';
2+
export * from './interfaces';
3+
export * from './types';

src/document-service-options.interface.ts renamed to src/interfaces/document-service-options.interface.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ export namespace DocumentServiceOptions {
5757
path: string;
5858
// The contents media type used for determining all the registration requirements
5959
mediaType: MediaType;
60+
// If the file should be converted
61+
shouldConvert?: boolean;
62+
// If a thumbnail should be generated
63+
shouldGenerateThumbnail?: boolean;
6064
}
6165

6266
export interface RegistrationResponse {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { MediaProcessingCallbackType, MediaProcessingCallbackStatus } from '../types';
2+
3+
// tslint:disable-next-line:no-namespace
4+
export namespace DocumentServiceResponse {
5+
6+
export interface MediaProcessingCallback {
7+
type: MediaProcessingCallbackType;
8+
status: MediaProcessingCallbackStatus;
9+
identity: string;
10+
locationUrl?: string;
11+
processUrl?: string;
12+
errorMessage?: string;
13+
}
14+
}

src/interfaces/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './document-service-options.interface';
2+
export * from './document-service-response.interface';

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './media-processing-callback.type';
2+
export * from './media-processing-callback-status.type';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type MediaProcessingCallbackStatus = 'STARTED' | 'FINISHED' | 'FAILED';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type MediaProcessingCallbackType = 'THUMBNAIL' | 'PROCESSING';

0 commit comments

Comments
 (0)