@@ -18,13 +18,14 @@ import * as cli from '../cli';
1818import { logger } from '../logging' ;
1919import { getActionBranch , getRemoteControllerRepo , isVariantAnalysisLiveResultsEnabled , setRemoteControllerRepo } from '../config' ;
2020import { ProgressCallback , UserCancellationException } from '../commandRunner' ;
21- import { OctokitResponse , RequestError } from '@octokit/types/dist-types' ;
21+ import { RequestError } from '@octokit/types/dist-types' ;
2222import { RemoteQuery } from './remote-query' ;
2323import { RemoteQuerySubmissionResult } from './remote-query-submission-result' ;
2424import { QueryMetadata } from '../pure/interface-types' ;
2525import { getErrorMessage , REPO_REGEX } from '../pure/helpers-pure' ;
2626import { pluralize } from '../pure/word' ;
2727import * as ghApiClient from './gh-api/gh-api-client' ;
28+ import { RemoteQueriesResponse } from './gh-api/remote-queries' ;
2829import { getRepositorySelection , isValidSelection , RepositorySelection } from './repository-selection' ;
2930import { parseVariantAnalysisQueryLanguage , VariantAnalysisSubmission } from './shared/variant-analysis' ;
3031import { Repository } from './shared/repository' ;
@@ -39,18 +40,6 @@ export interface QlPack {
3940 defaultSuiteFile ?: string ;
4041}
4142
42- interface QueriesResponse {
43- workflow_run_id : number ,
44- errors ?: {
45- invalid_repositories ?: string [ ] ,
46- repositories_without_database ?: string [ ] ,
47- private_repositories ?: string [ ] ,
48- cutoff_repositories ?: string [ ] ,
49- cutoff_repositories_count ?: number ,
50- } ,
51- repositories_queried : string [ ] ,
52- }
53-
5443/**
5544 * Well-known names for the query pack used by the server.
5645 */
@@ -172,7 +161,7 @@ function isFileSystemRoot(dir: string): boolean {
172161 return pathObj . root === dir && pathObj . base === '' ;
173162}
174163
175- async function createRemoteQueriesTempDirectory ( ) {
164+ export async function createRemoteQueriesTempDirectory ( ) {
176165 const remoteQueryDir = await tmp . dir ( { dir : tmpDir . name , unsafeCleanup : true } ) ;
177166 const queryPackDir = path . join ( remoteQueryDir . path , 'query-pack' ) ;
178167 await fs . mkdirp ( queryPackDir ) ;
@@ -389,7 +378,7 @@ async function runRemoteQueriesApiRequest(
389378 controllerRepo : Repository ,
390379 queryPackBase64 : string ,
391380 dryRun = false
392- ) : Promise < void | QueriesResponse > {
381+ ) : Promise < void | RemoteQueriesResponse > {
393382 const data = {
394383 ref,
395384 language,
@@ -412,17 +401,18 @@ async function runRemoteQueriesApiRequest(
412401 }
413402
414403 try {
415- const octokit = await credentials . getOctokit ( ) ;
416- const response : OctokitResponse < QueriesResponse , number > = await octokit . request (
417- 'POST /repositories/:controllerRepoId/code-scanning/codeql/queries' ,
418- {
419- controllerRepoId : controllerRepo . id ,
420- data
421- }
422- ) ;
423- const { popupMessage, logMessage } = parseResponse ( controllerRepo , response . data ) ;
404+ const response = await ghApiClient . submitRemoteQueries ( credentials , {
405+ ref,
406+ language,
407+ repositories : repoSelection . repositories ,
408+ repositoryLists : repoSelection . repositoryLists ,
409+ repositoryOwners : repoSelection . owners ,
410+ queryPack : queryPackBase64 ,
411+ controllerRepoId : controllerRepo . id ,
412+ } ) ;
413+ const { popupMessage, logMessage } = parseResponse ( controllerRepo , response ) ;
424414 void showAndLogInformationMessage ( popupMessage , { fullMessage : logMessage } ) ;
425- return response . data ;
415+ return response ;
426416 } catch ( error : any ) {
427417 if ( error . status === 404 ) {
428418 void showAndLogErrorMessage ( `Controller repository was not found. Please make sure it's a valid repo name.${ eol } ` ) ;
@@ -436,7 +426,7 @@ const eol = os.EOL;
436426const eol2 = os . EOL + os . EOL ;
437427
438428// exported for testing only
439- export function parseResponse ( controllerRepo : Repository , response : QueriesResponse ) {
429+ export function parseResponse ( controllerRepo : Repository , response : RemoteQueriesResponse ) {
440430 const repositoriesQueried = response . repositories_queried ;
441431 const repositoryCount = repositoriesQueried . length ;
442432
0 commit comments