File tree Expand file tree Collapse file tree 4 files changed +30
-5
lines changed
test/integration/__tests__ Expand file tree Collapse file tree 4 files changed +30
-5
lines changed Original file line number Diff line number Diff line change 3939 "p-retry" : " ^4.2.0" ,
4040 "request" : " ^2.88.2" ,
4141 "temp" : " ^0.9.1" ,
42- "tsd" : " ^0.14.0"
42+ "tsd" : " ^0.14.0" ,
43+ "uuid" : " ^8.3.2"
4344 },
4445 "repository" : {
4546 "type" : " git" ,
Original file line number Diff line number Diff line change @@ -115,12 +115,17 @@ class TransloaditClient {
115115 onAssemblyProgress = ( ) => { } ,
116116 files = { } ,
117117 uploads = { } ,
118+ assemblyId,
118119 } = opts
119120
120121 // Keep track of how long the request took
121122 const startTimeMs = getHrTimeMs ( )
122123
123- this . _lastUsedAssemblyUrl = `${ this . _endpoint } /assemblies`
124+ // Undocumented feature to allow specifying the assembly id from the client
125+ // (not recommended for general use due to security)
126+ const urlSuffix = assemblyId != null ? `/assemblies/${ assemblyId } ` : '/assemblies'
127+
128+ this . _lastUsedAssemblyUrl = `${ this . _endpoint } ${ urlSuffix } `
124129
125130 for ( const [ , path ] of Object . entries ( files ) ) {
126131 await access ( path , fs . F_OK | fs . R_OK )
@@ -163,8 +168,8 @@ class TransloaditClient {
163168 const useTus = isResumable && allStreams . every ( isFileBasedStream )
164169
165170 const requestOpts = {
166- urlSuffix : '/assemblies' ,
167- method : 'post' ,
171+ urlSuffix,
172+ method : 'post' ,
168173 timeout,
169174 params,
170175 }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const got = require('got')
1616const pipeline = promisify ( streamPipeline )
1717const intoStream = require ( 'into-stream' )
1818const request = require ( 'request' )
19+ const uuid = require ( 'uuid' )
1920
2021const Transloadit = require ( '../../../src/Transloadit' )
2122
@@ -261,6 +262,24 @@ describe('API integration', function () {
261262 } )
262263 } )
263264
265+ it ( 'should allow setting an explicit assemblyId on createAssembly' , async ( ) => {
266+ const client = createClient ( )
267+
268+ const assemblyId = uuid . v4 ( ) . replace ( / - / g, '' )
269+ const params = {
270+ assemblyId,
271+ waitForCompletion : true ,
272+ params : {
273+ steps : {
274+ dummy : dummyStep ,
275+ } ,
276+ } ,
277+ }
278+
279+ const result = await client . createAssembly ( params )
280+ expect ( result . assembly_id ) . toEqual ( assemblyId )
281+ } )
282+
264283 it ( 'should throw a proper error for request stream' , async ( ) => {
265284 const client = createClient ( )
266285
Original file line number Diff line number Diff line change @@ -5228,7 +5228,7 @@ uuid@^3.3.2:
52285228 resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
52295229 integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
52305230
5231- uuid@^8.3.0 :
5231+ uuid@^8.3.0, uuid@^8.3.2 :
52325232 version "8.3.2"
52335233 resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
52345234 integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
You can’t perform that action at this time.
0 commit comments