diff --git a/src/bundles.ts b/src/bundles.ts index 7589a059..fff8c871 100644 --- a/src/bundles.ts +++ b/src/bundles.ts @@ -26,7 +26,7 @@ import { getFilters, } from './http'; -import { MAX_UPLOAD_ATTEMPTS, UPLOAD_CONCURRENCY } from './constants'; +import { MAX_RETRY_ATTEMPTS, MAX_UPLOAD_ATTEMPTS, UPLOAD_CONCURRENCY } from './constants'; import { emitter } from './emitter'; import { AnalyzeFoldersOptions } from './interfaces/analysis-options.interface'; @@ -200,9 +200,10 @@ export async function getSupportedFiles( source: string, requestId?: string, languages?: string[], + orgId?: string, ): Promise { emitter.supportedFilesLoaded(null); - const resp = await getFilters(baseURL, source, undefined, requestId); + const resp = await getFilters(baseURL, source, MAX_RETRY_ATTEMPTS, requestId, orgId); if (resp.type === 'error') { throw resp.error; } @@ -246,7 +247,13 @@ export interface CreateBundleFromFoldersOptions extends ConnectionOptions, Analy */ export async function createBundleFromFolders(options: CreateBundleFromFoldersOptions): Promise { // Fetch supported files to save network traffic - const supportedFiles = await getSupportedFiles(options.baseURL, options.source, options.requestId, options.languages); + const supportedFiles = await getSupportedFiles( + options.baseURL, + options.source, + options.requestId, + options.languages, + options.orgId, + ); // Collect files and create a remote bundle return await createBundleWithCustomFiles(options, supportedFiles); diff --git a/src/cli.ts b/src/cli.ts index 85c30357..838685f2 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -39,8 +39,8 @@ function parseConnectionOptions(options: { }; } -async function filtersAction(options: { url: string; token: string; source: string; org?: string }) { - const response = await getSupportedFiles(options.url, options.source); +async function filtersAction(options: { url: string; token: string; source: string; org?: string; orgId?: string }) { + const response = await getSupportedFiles(options.url, options.source, undefined, [], options.orgId); console.log(JSON.stringify(response, null, 2)); } diff --git a/src/http.ts b/src/http.ts index 7c437052..88578139 100644 --- a/src/http.ts +++ b/src/http.ts @@ -34,6 +34,7 @@ export interface ConnectionOptions { source: string; requestId?: string; org?: string; + orgId?: string; extraHeaders?: { [key: string]: string }; } @@ -180,12 +181,13 @@ export async function getFilters( source: string, attempts = MAX_RETRY_ATTEMPTS, requestId?: string, + orgId?: string, ): Promise> { const apiName = 'filters'; let url: string; try { - url = getURL(baseURL, '/' + apiName, '00000000-0000-0000-0000-00000000'); + url = getURL(baseURL, '/' + apiName, orgId); } catch (err) { return generateError(400, err.message, apiName); } @@ -248,7 +250,7 @@ export async function createBundle( let url: string; try { - url = getURL(options.baseURL, '/bundle', options.org); + url = getURL(options.baseURL, '/bundle', options.orgId); } catch (err) { return generateError(400, err.message, 'createBundle'); } @@ -293,7 +295,7 @@ export async function checkBundle(options: CheckBundleOptions): Promise(400, err.message, 'checkBundle'); } @@ -340,7 +342,7 @@ export async function extendBundle( let url: string; try { - url = getURL(options.baseURL, `/bundle/${options.bundleHash}`, options.org); + url = getURL(options.baseURL, `/bundle/${options.bundleHash}`, options.orgId); } catch (err) { return generateError(400, err.message, 'extendBundle'); } @@ -407,7 +409,7 @@ export async function getAnalysis( let url: string; try { - url = getURL(options.baseURL, '/analysis', options.org); + url = getURL(options.baseURL, '/analysis', options.orgId); } catch (err) { return generateError(400, err.message, 'getAnalysis'); } @@ -476,7 +478,7 @@ export async function initReport(options: UploadReportOptions): Promise(400, err.message, 'initReport'); } @@ -516,7 +518,7 @@ export async function getReport(options: GetReportOptions): Promise(400, err.message, 'getReport'); } @@ -541,7 +543,7 @@ export async function initScmReport(options: ScmUploadReportOptions): Promise(400, err.message, 'initReport'); } @@ -574,7 +576,7 @@ export async function getScmReport( let url: string; try { - url = getURL(options.baseURL, `/test/${options.pollId}`, options.org); + url = getURL(options.baseURL, `/test/${options.pollId}`, options.orgId); } catch (err) { return generateError(400, err.message, 'getReport'); }