@snyk/code-client
Advanced tools
Comparing version 3.1.5 to 3.2.0
import { AnalysisSeverity, IGitBundle, IFileBundle, IBundleResult } from './interfaces/analysis-result.interface'; | ||
import { FolderOptions, GitOptions } from './interfaces/analysis-options.interface'; | ||
import { RequestOptions } from './interfaces/http-options.interface'; | ||
export declare function analyzeBundle({ baseURL, sessionToken, includeLint, severity, bundleId, oAuthToken, username, limitToFiles, source, }: { | ||
@@ -13,5 +14,5 @@ baseURL: string; | ||
source: string; | ||
}): Promise<IBundleResult>; | ||
}, requestOptions?: RequestOptions): Promise<IBundleResult>; | ||
export declare function analyzeFolders(options: FolderOptions): Promise<IFileBundle>; | ||
export declare function extendAnalysis(bundle: IFileBundle, filePaths: string[], maxPayload: number | undefined, source: string): Promise<IFileBundle | null>; | ||
export declare function analyzeGit(options: GitOptions): Promise<IGitBundle>; | ||
export declare function analyzeGit(options: GitOptions, requestOptions?: RequestOptions): Promise<IGitBundle>; |
@@ -18,3 +18,3 @@ "use strict"; | ||
const sleep = (duration) => new Promise(resolve => setTimeout(resolve, duration)); | ||
async function pollAnalysis({ baseURL, sessionToken, includeLint, severity, bundleId, oAuthToken, username, limitToFiles, source, }) { | ||
async function pollAnalysis({ baseURL, sessionToken, includeLint, severity, bundleId, oAuthToken, username, limitToFiles, source, }, requestOptions) { | ||
let analysisResponse; | ||
@@ -39,3 +39,3 @@ let analysisData; | ||
source, | ||
}); | ||
}, requestOptions); | ||
if (analysisResponse.type === 'error') { | ||
@@ -64,3 +64,3 @@ return analysisResponse; | ||
} | ||
async function analyzeBundle({ baseURL = constants_1.defaultBaseURL, sessionToken = '', includeLint = false, severity = analysis_result_interface_1.AnalysisSeverity.info, bundleId, oAuthToken, username, limitToFiles, source, }) { | ||
async function analyzeBundle({ baseURL = constants_1.defaultBaseURL, sessionToken = '', includeLint = false, severity = analysis_result_interface_1.AnalysisSeverity.info, bundleId, oAuthToken, username, limitToFiles, source, }, requestOptions) { | ||
// Call remote bundle for analysis results and emit intermediate progress | ||
@@ -77,3 +77,3 @@ const analysisData = await pollAnalysis({ | ||
source, | ||
}); | ||
}, requestOptions); | ||
if (analysisData.type === 'error') { | ||
@@ -254,3 +254,3 @@ throw analysisData.error; | ||
}; | ||
async function analyzeGit(options) { | ||
async function analyzeGit(options, requestOptions) { | ||
const analysisOptions = { ...analyzeGitDefaults, ...options }; | ||
@@ -265,3 +265,3 @@ const { baseURL, sessionToken, oAuthToken, username, includeLint, severity, gitUri, sarif, source } = analysisOptions; | ||
source, | ||
}); | ||
}, requestOptions); | ||
if (bundleResponse.type === 'error') { | ||
@@ -280,3 +280,3 @@ throw bundleResponse.error; | ||
source, | ||
}); | ||
}, requestOptions); | ||
const result = { | ||
@@ -283,0 +283,0 @@ baseURL, |
@@ -5,2 +5,3 @@ import { AxiosError } from 'axios'; | ||
import { IAnalysisResult } from './interfaces/analysis-result.interface'; | ||
import { RequestOptions } from './interfaces/http-options.interface'; | ||
declare type ResultSuccess<T> = { | ||
@@ -68,3 +69,3 @@ type: 'success'; | ||
readonly source: string; | ||
}): Promise<IResult<RemoteBundle, CreateGitBundleErrorCodes>>; | ||
}, requestOptions?: RequestOptions): Promise<IResult<RemoteBundle, CreateGitBundleErrorCodes>>; | ||
declare type UploadBundleErrorCodes = GenericErrorTypes | ErrorCodes.unauthorizedUser | ErrorCodes.unauthorizedContent | ErrorCodes.unauthorizedBundleAccess | ErrorCodes.notFound | ErrorCodes.bigPayload; | ||
@@ -109,3 +110,3 @@ export declare function uploadFiles(options: { | ||
readonly source: string; | ||
}): Promise<IResult<GetAnalysisResponseDto, GetAnalysisErrorCodes>>; | ||
}, requestOptions?: RequestOptions): Promise<IResult<GetAnalysisResponseDto, GetAnalysisErrorCodes>>; | ||
declare type ReportTelemetryRequestDto = { | ||
@@ -112,0 +113,0 @@ readonly baseURL: string; |
@@ -205,5 +205,5 @@ "use strict"; | ||
}; | ||
async function createGitBundle(options) { | ||
async function createGitBundle(options, requestOptions) { | ||
const { baseURL, sessionToken, oAuthToken, username, gitUri, source } = options; | ||
const headers = { 'Session-Token': sessionToken, source }; | ||
const headers = { ...requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers, 'Session-Token': sessionToken, source }; | ||
if (oAuthToken) { | ||
@@ -272,7 +272,7 @@ headers['X-OAuthToken'] = oAuthToken; | ||
}; | ||
async function getAnalysis(options) { | ||
async function getAnalysis(options, requestOptions) { | ||
const { baseURL, sessionToken, oAuthToken, username, bundleId, includeLint, severity, limitToFiles, source, } = options; | ||
// ?linters=false is still a truthy query value, if(includeLint === false) we have to avoid sending the value altogether | ||
const params = { severity, linters: includeLint || undefined }; | ||
const headers = { 'Session-Token': sessionToken, source }; | ||
const headers = { ...requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers, 'Session-Token': sessionToken, source }; | ||
if (oAuthToken) { | ||
@@ -279,0 +279,0 @@ headers['X-OAuthToken'] = oAuthToken; |
@@ -74,3 +74,3 @@ { | ||
}, | ||
"version": "3.1.5" | ||
"version": "3.2.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140743
52
2050