@@ -23,9 +23,10 @@ class LiquidSamplerRunner {
2323 * @param {Array<string> } templateHandles.reconciliationTexts - Array of reconciliation text handles
2424 * @param {Array<string> } templateHandles.accountTemplates - Array of account template names
2525 * @param {Array<string> } templateHandles.sharedParts - Array of shared part names
26+ * @param {Array<number> } firmIds - Array of firm IDs to use in the sampler
2627 * @returns {Promise<void> }
2728 */
28- async run ( templateHandles = { } ) {
29+ async run ( templateHandles = { } , firmIds = [ ] ) {
2930 try {
3031 // Validate at least one template specified
3132 const { reconciliationTexts = [ ] , accountTemplates = [ ] , sharedParts = [ ] } = templateHandles ;
@@ -35,7 +36,7 @@ class LiquidSamplerRunner {
3536 }
3637
3738 // Build payload
38- const samplerParams = await this . #buildSamplerParams( templateHandles ) ;
39+ const samplerParams = await this . #buildSamplerParams( templateHandles , firmIds ) ;
3940
4041 consola . info ( `Starting sampler run with ${ samplerParams . templates . length } template(s)...` ) ;
4142
@@ -71,6 +72,11 @@ class LiquidSamplerRunner {
7172
7273 const response = await SF . readSamplerRun ( this . partnerId , samplerId ) ;
7374
75+ if ( ! response || ! response . data ) {
76+ consola . error ( "Failed to fetch sampler run status. Is staging running?" ) ;
77+ process . exit ( 1 ) ;
78+ }
79+
7480 await this . #handleSamplerResponse( response . data ) ;
7581 } catch ( error ) {
7682 errorUtils . errorHandler ( error ) ;
@@ -83,9 +89,10 @@ class LiquidSamplerRunner {
8389 * @param {Array<string> } templateHandles.reconciliationTexts - Array of reconciliation text handles
8490 * @param {Array<string> } templateHandles.accountTemplates - Array of account template names
8591 * @param {Array<string> } templateHandles.sharedParts - Array of shared part names
92+ * @param {Array<number> } firmIds - Array of firm IDs to use in the sampler
8693 * @returns {Object } Sampler payload with templates array
8794 */
88- async #buildSamplerParams( templateHandles = { } ) {
95+ async #buildSamplerParams( templateHandles = { } , firmIds = [ ] ) {
8996 const templates = [ ] ;
9097 const { reconciliationTexts = [ ] , accountTemplates = [ ] , sharedParts = [ ] } = templateHandles ;
9198
@@ -175,7 +182,7 @@ class LiquidSamplerRunner {
175182 } ) ;
176183 }
177184
178- return { templates } ;
185+ return { templates, firm_ids : firmIds } ;
179186 }
180187
181188 /**
@@ -186,8 +193,8 @@ class LiquidSamplerRunner {
186193 */
187194 async #fetchAndWaitSamplerResult( samplerId ) {
188195 let samplerRun = { status : "pending" } ;
189- const pollingDelay = 10000 ; // 10 seconds
190- const waitingLimit = 2000000 ; // 2000 seconds
196+ const pollingDelay = 15000 ; // 15 seconds
197+ const waitingLimit = 3600000 ; // 1 hour
191198
192199 spinner . spin ( "Running sampler..." ) ;
193200 let waitingTime = 0 ;
@@ -203,7 +210,7 @@ class LiquidSamplerRunner {
203210
204211 if ( waitingTime >= waitingLimit ) {
205212 spinner . stop ( ) ;
206- consola . error ( "Timeout. Try to run your sampler again" ) ;
213+ consola . error ( "Timeout. Try to fetch the status by using the --id flag, if not run your sampler again" ) ;
207214 process . exit ( 1 ) ;
208215 }
209216 }
@@ -237,6 +244,11 @@ class LiquidSamplerRunner {
237244 }
238245 break ;
239246
247+ case "pending" :
248+ case "running" :
249+ consola . info ( `Sampler run is still in progress. Current status: "${ response . status } ". Please check again later.` ) ;
250+ break ;
251+
240252 default :
241253 consola . error ( `Unexpected sampler status: ${ response . status } ` ) ;
242254 process . exit ( 1 ) ;
0 commit comments