11import { apiClient } from "../../../lib/apiClient.js" ;
22import {
3- getTCGTriggerURL ,
4- getTCGPollURL ,
5- getFetchDetailsURL ,
6- getFormFieldsURL ,
7- getBulkCreateURL ,
3+ TCG_TRIGGER_URL ,
4+ TCG_POLL_URL ,
5+ FETCH_DETAILS_URL ,
6+ FORM_FIELDS_URL ,
7+ BULK_CREATE_URL ,
88} from "./config.js" ;
99import {
1010 DefaultFieldMaps ,
@@ -23,9 +23,8 @@ export async function fetchFormFields(
2323 projectId : string ,
2424 config : BrowserStackConfig ,
2525) : Promise < { default_fields : any ; custom_fields : any } > {
26- const url = await getFormFieldsURL ( projectId ) ;
2726 const res = await apiClient . get ( {
28- url,
27+ url : await FORM_FIELDS_URL ( projectId ) ,
2928 headers : {
3029 "API-TOKEN" : getBrowserStackAuth ( config ) ,
3130 } ,
@@ -44,10 +43,9 @@ export async function triggerTestCaseGeneration(
4443 source : string ,
4544 config : BrowserStackConfig ,
4645) : Promise < string > {
47- const url = await getTCGTriggerURL ( ) ;
4846 const tmBaseUrl = await getTMBaseURL ( ) ;
4947 const res = await apiClient . post ( {
50- url,
48+ url : await TCG_TRIGGER_URL ( ) ,
5149 headers : {
5250 "API-TOKEN" : getBrowserStackAuth ( config ) ,
5351 "Content-Type" : "application/json" ,
@@ -82,9 +80,8 @@ export async function fetchTestCaseDetails(
8280 if ( testCaseIds . length === 0 ) {
8381 throw new Error ( "No testCaseIds provided to fetchTestCaseDetails" ) ;
8482 }
85- const url = await getFetchDetailsURL ( ) ;
8683 const res = await apiClient . post ( {
87- url,
84+ url : await FETCH_DETAILS_URL ( ) ,
8885 headers : {
8986 "API-TOKEN" : getBrowserStackAuth ( config ) ,
9087 "request-source" : source ,
@@ -112,14 +109,14 @@ export async function pollTestCaseDetails(
112109) : Promise < Record < string , any > > {
113110 const detailMap : Record < string , any > = { } ;
114111 let done = false ;
115- const pollUrl = await getTCGPollURL ( ) ;
112+ const TCG_POLL_URL_VALUE = await TCG_POLL_URL ( ) ;
116113
117114 while ( ! done ) {
118115 // add a bit of jitter to avoid synchronized polling storms
119116 await new Promise ( ( r ) => setTimeout ( r , 10000 + Math . random ( ) * 5000 ) ) ;
120117
121118 const poll = await apiClient . post ( {
122- url : `${ pollUrl } ?x-bstack-traceRequestId=${ encodeURIComponent ( traceRequestId ) } ` ,
119+ url : `${ TCG_POLL_URL_VALUE } ?x-bstack-traceRequestId=${ encodeURIComponent ( traceRequestId ) } ` ,
123120 headers : {
124121 "API-TOKEN" : getBrowserStackAuth ( config ) ,
125122 } ,
@@ -163,14 +160,14 @@ export async function pollScenariosTestDetails(
163160 const scenariosMap : Record < string , Scenario > = { } ;
164161 const detailPromises : Promise < Record < string , any > > [ ] = [ ] ;
165162 let iteratorCount = 0 ;
166- const TCG_POLL_URL = await getTCGPollURL ( ) ;
163+ const TCG_POLL_URL_VALUE = await TCG_POLL_URL ( ) ;
167164
168165 // Promisify interval-style polling using a wrapper
169166 await new Promise < void > ( ( resolve , reject ) => {
170167 const intervalId = setInterval ( async ( ) => {
171168 try {
172169 const poll = await apiClient . post ( {
173- url : `${ TCG_POLL_URL } ?x-bstack-traceRequestId=${ encodeURIComponent ( traceId ) } ` ,
170+ url : `${ TCG_POLL_URL_VALUE } ?x-bstack-traceRequestId=${ encodeURIComponent ( traceId ) } ` ,
174171 headers : {
175172 "API-TOKEN" : getBrowserStackAuth ( config ) ,
176173 } ,
@@ -286,7 +283,7 @@ export async function bulkCreateTestCases(
286283 const total = Object . keys ( scenariosMap ) . length ;
287284 let doneCount = 0 ;
288285 let testCaseCount = 0 ;
289- const BULK_CREATE_URL = await getBulkCreateURL ( projectId , folderId ) ;
286+ const BULK_CREATE_URL_VALUE = await BULK_CREATE_URL ( projectId , folderId ) ;
290287
291288 for ( const { id, testcases } of Object . values ( scenariosMap ) ) {
292289 const testCaseLength = testcases . length ;
@@ -308,7 +305,7 @@ export async function bulkCreateTestCases(
308305
309306 try {
310307 const resp = await apiClient . post ( {
311- url : BULK_CREATE_URL ,
308+ url : BULK_CREATE_URL_VALUE ,
312309 headers : {
313310 "API-TOKEN" : getBrowserStackAuth ( config ) ,
314311 "Content-Type" : "application/json" ,
0 commit comments