Skip to content

Commit fbca762

Browse files
Greyvendclaude
andauthored
REVAI-4573: Update SDKs to support new model (#384)
* Add integration test for machine_v3 transcriber via submitJobUrl This test currently fails with 400 because submitJobUrl sends media_url which is not supported by the v3 transcriber. It will pass once we migrate to source_config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add unit tests for source_config migration in submitJobUrl Two failing tests: - submitJobUrl should send source_config instead of media_url - submitJobUrl should throw when options contain source_config Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Migrate submitJobUrl from media_url to source_config - submitJobUrl now sends source_config: { url: mediaUrl } instead of media_url, enabling support for the machine_v3 transcriber - Add validation: throw error if options already contain source_config - Update existing unit test assertions accordingly Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix CI: line length lint errors and linkChecker false positive - Break long error message in submitJobUrl across multiple lines - Break long assertion string in unit test - Replace fake URL with existing mediaUrl constant to avoid linkChecker DNS resolution failure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix linkChecker CI: exclude npmjs.com from lychee npmjs.com returns 403 to automated link checkers, causing a false positive failure on the README npm badge link. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Bump version to 3.9.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7adc0de commit fbca762

File tree

6 files changed

+59
-12
lines changed

6 files changed

+59
-12
lines changed

.lycheeignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ getbaseurl
55
# example domains used in unit tests
66
www.example.com
77

8+
# npmjs.com blocks automated link checkers with 403
9+
https://www.npmjs.com
10+
811
# email used in unit tests
912
test@rev.com

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "revai-node-sdk",
3-
"version": "3.8.6",
3+
"version": "3.9.0",
44
"description": "Rev AI makes speech applications easy to build!",
55
"main": "src/index.js",
66
"scripts": {

src/api-client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@ export class RevAiApiClient {
118118
* @deprecated Use submitJob and provide a source config to the job options
119119
*/
120120
async submitJobUrl(mediaUrl: string, options?: RevAiJobOptions): Promise<RevAiApiJob> {
121+
if (options?.source_config) {
122+
throw new Error(
123+
'source_config is not compatible with submitJobUrl.'
124+
+ ' Remove source_config from options or use submitJob instead.'
125+
);
126+
}
127+
121128
options = this.filterNullOptions({
122-
media_url: mediaUrl,
129+
source_config: { url: mediaUrl },
123130
...(options || {})
124131
});
125132

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const clientHelper = require('../src/client-helper');
2+
3+
test('Can submit url with machine_v3 transcriber', async () => {
4+
const client = clientHelper.getAsyncClient();
5+
const options = {
6+
metadata: 'Node sdk v3 submit url test',
7+
transcriber: 'machine_v3'
8+
};
9+
10+
const job = await client.submitJobUrl('https://www.rev.ai/FTC_Sample_1.mp3', options);
11+
12+
expect(job.status).toBe('in_progress');
13+
expect(job.id).not.toBeNull();
14+
}, 30000);

test/unit/api-client/api-client.submit.spec.ts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('api-client job submission', () => {
4747
const job = await sut.submitJobUrl(mediaUrl);
4848

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

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

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

7878
expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
79-
{ 'Content-Type': 'application/json' }, 'json', { media_url: mediaUrl });
79+
{ 'Content-Type': 'application/json' }, 'json', { source_config: { url: mediaUrl } });
8080
expect(mockMakeApiRequest).toBeCalledTimes(1);
8181
expect(job).toEqual(jobDetails);
8282
});
@@ -91,7 +91,6 @@ describe('api-client job submission', () => {
9191
speaker_channels_count: 1,
9292
speakers_count: 123,
9393
filter_profanity: true,
94-
media_url: mediaUrl,
9594
remove_disfluencies: true,
9695
delete_after_seconds: 0,
9796
language: 'en',
@@ -102,7 +101,8 @@ describe('api-client job submission', () => {
102101
const job = await sut.submitJobUrl(mediaUrl, options);
103102

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

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

146146
expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
147-
{ 'Content-Type': 'application/json' }, 'json', { ...options, media_url: mediaUrl });
147+
{ 'Content-Type': 'application/json' }, 'json', { ...options, source_config: { url: mediaUrl } });
148148
expect(mockMakeApiRequest).toBeCalledTimes(1);
149149
expect(job).toEqual(jobDetails);
150150
});
151+
152+
it('submit job with media url sends source_config instead of media_url', async () => {
153+
const job = await sut.submitJobUrl(mediaUrl);
154+
155+
expect(mockMakeApiRequest).toBeCalledWith('post', '/jobs',
156+
{ 'Content-Type': 'application/json' }, 'json', { source_config: { url: mediaUrl } });
157+
expect(mockMakeApiRequest).toBeCalledTimes(1);
158+
expect(job).toEqual(jobDetails);
159+
});
160+
161+
it('submit job with media url throws error when options contain source_config', async () => {
162+
const options: RevAiJobOptions = {
163+
source_config: { url: mediaUrl }
164+
};
165+
166+
await expect(sut.submitJobUrl(mediaUrl, options))
167+
.rejects.toThrow(
168+
'source_config is not compatible with submitJobUrl.'
169+
+ ' Remove source_config from options'
170+
);
171+
expect(mockMakeApiRequest).not.toBeCalled();
172+
});
151173
});
152174

153175
describe('submitJob', () => {

0 commit comments

Comments
 (0)