@@ -329,6 +329,57 @@ class SocketSdk {
329329 }
330330 }
331331
332+ /**
333+ * @param {string } orgSlug
334+ * @param {{[key: string]: any } } queryParams
335+ * @param {{} } bodyContent
336+ * @param {string[] } filePaths
337+ * @param {string } pathsRelativeTo
338+ * @param {{ [key: string]: boolean } } [issueRules]
339+ * @returns {Promise<SocketSdkResultType<'CreateOrgFullScan'>> }
340+ */
341+ async createOrgFullScan ( orgSlug , queryParams , bodyContent , filePaths , pathsRelativeTo = '.' , issueRules ) {
342+ const basePath = path . resolve ( process . cwd ( ) , pathsRelativeTo )
343+ const absoluteFilePaths = filePaths . map ( filePath => path . resolve ( basePath , filePath ) )
344+ const orgSlugParam = encodeURIComponent ( orgSlug )
345+ const formattedQueryParams = new URLSearchParams ( queryParams )
346+
347+ const [
348+ { FormData, Blob } ,
349+ { fileFromPath } ,
350+ client
351+ ] = await Promise . all ( [
352+ import ( 'formdata-node' ) ,
353+ import ( 'formdata-node/file-from-path' ) ,
354+ this . #getClient( ) ,
355+ ] )
356+
357+ const body = new FormData ( )
358+
359+ if ( issueRules ) {
360+ const issueRulesBlob = new Blob ( [ JSON . stringify ( issueRules ) ] , { type : 'application/json' } )
361+ body . set ( 'issueRules' , issueRulesBlob , 'issueRules' )
362+ }
363+
364+ const files = await Promise . all ( absoluteFilePaths . map ( absoluteFilePath => fileFromPath ( absoluteFilePath ) ) )
365+
366+ for ( let i = 0 , length = files . length ; i < length ; i ++ ) {
367+ const absoluteFilePath = absoluteFilePaths [ i ]
368+ if ( absoluteFilePath ) {
369+ const relativeFilePath = path . relative ( basePath , absoluteFilePath )
370+ body . set ( relativeFilePath , files [ i ] )
371+ }
372+ }
373+
374+ try {
375+ const data = await client . post ( `orgs/${ orgSlugParam } /full-scans?${ formattedQueryParams } ` , { body } ) . json ( )
376+
377+ return { success : true , status : 200 , data }
378+ } catch ( err ) {
379+ return /** @type {SocketSdkErrorType<'CreateOrgFullScan'> } */ ( this . #handleApiError( err ) )
380+ }
381+ }
382+
332383 /**
333384 * @param {Array<{ organization?: string }> } selectors
334385 * @returns {Promise<SocketSdkResultType<'postSettings'>> }
0 commit comments