Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ getbaseurl
# example domains used in unit tests
www.example.com

# npmjs.com blocks automated link checkers with 403
https://www.npmjs.com
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure we need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the build was failing because of this


# email used in unit tests
test@rev.com
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "revai-node-sdk",
"version": "3.8.6",
"version": "3.9.0",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmtrrk is this version bump fine?

"description": "Rev AI makes speech applications easy to build!",
"main": "src/index.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,15 @@ export class RevAiApiClient {
* @deprecated Use submitJob and provide a source config to the job options
*/
async submitJobUrl(mediaUrl: string, options?: RevAiJobOptions): Promise<RevAiApiJob> {
if (options?.source_config) {
throw new Error(
'source_config is not compatible with submitJobUrl.'
+ ' Remove source_config from options or use submitJob instead.'
);
}

options = this.filterNullOptions({
media_url: mediaUrl,
source_config: { url: mediaUrl },
...(options || {})
});

Expand Down
14 changes: 14 additions & 0 deletions test/integration/test/job-v3.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const clientHelper = require('../src/client-helper');

test('Can submit url with machine_v3 transcriber', async () => {
const client = clientHelper.getAsyncClient();
const options = {
metadata: 'Node sdk v3 submit url test',
transcriber: 'machine_v3'
};

const job = await client.submitJobUrl('https://www.rev.ai/FTC_Sample_1.mp3', options);

expect(job.status).toBe('in_progress');
expect(job.id).not.toBeNull();
}, 30000);
38 changes: 30 additions & 8 deletions test/unit/api-client/api-client.submit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('api-client job submission', () => {
const job = await sut.submitJobUrl(mediaUrl);

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', { media_url: mediaUrl });
{ 'Content-Type': 'application/json' }, 'json', { source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});
Expand All @@ -56,7 +56,7 @@ describe('api-client job submission', () => {
const job = await sut.submitJobUrl(mediaUrl, null);

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', { media_url: mediaUrl });
{ 'Content-Type': 'application/json' }, 'json', { source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});
Expand All @@ -65,7 +65,7 @@ describe('api-client job submission', () => {
const job = await sut.submitJobUrl(mediaUrl, {});

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', { media_url: mediaUrl });
{ 'Content-Type': 'application/json' }, 'json', { source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});
Expand All @@ -76,7 +76,7 @@ describe('api-client job submission', () => {
const job = await sut.submitJobUrl(mediaUrl, options);

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', { media_url: mediaUrl });
{ 'Content-Type': 'application/json' }, 'json', { source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});
Expand All @@ -91,7 +91,6 @@ describe('api-client job submission', () => {
speaker_channels_count: 1,
speakers_count: 123,
filter_profanity: true,
media_url: mediaUrl,
remove_disfluencies: true,
delete_after_seconds: 0,
language: 'en',
Expand All @@ -102,7 +101,8 @@ describe('api-client job submission', () => {
const job = await sut.submitJobUrl(mediaUrl, options);

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', options);
{ 'Content-Type': 'application/json' }, 'json',
{ ...options, source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});
Expand All @@ -115,7 +115,7 @@ describe('api-client job submission', () => {
const job = await sut.submitJobUrl(mediaUrl, options);

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', { ...options, media_url: mediaUrl });
{ 'Content-Type': 'application/json' }, 'json', { ...options, source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});
Expand Down Expand Up @@ -144,10 +144,32 @@ describe('api-client job submission', () => {
const job = await sut.submitJobUrl(mediaUrl, options);

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', { ...options, media_url: mediaUrl });
{ 'Content-Type': 'application/json' }, 'json', { ...options, source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});

it('submit job with media url sends source_config instead of media_url', async () => {
const job = await sut.submitJobUrl(mediaUrl);

expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
{ 'Content-Type': 'application/json' }, 'json', { source_config: { url: mediaUrl } });
expect(mockMakeApiRequest).toBeCalledTimes(1);
expect(job).toEqual(jobDetails);
});

it('submit job with media url throws error when options contain source_config', async () => {
const options: RevAiJobOptions = {
source_config: { url: mediaUrl }
};

await expect(sut.submitJobUrl(mediaUrl, options))
.rejects.toThrow(
'source_config is not compatible with submitJobUrl.'
+ ' Remove source_config from options'
);
expect(mockMakeApiRequest).not.toBeCalled();
});
});

describe('submitJob', () => {
Expand Down
Loading