11import path from 'path' ;
22import { JSDOM , VirtualConsole } from 'jsdom' ;
33import fs from 'fs-extra' ;
4- import { getPlatform , type Elb } from '@walkeros/core' ;
4+ import {
5+ getPlatform ,
6+ type Elb ,
7+ type Logger as CoreLogger ,
8+ } from '@walkeros/core' ;
59import { schemas } from '@walkeros/core/dev' ;
610import {
711 createCommandLogger ,
12+ createCollectorLoggerConfig ,
813 getErrorMessage ,
914 detectInput ,
1015 type Logger ,
@@ -77,6 +82,10 @@ export async function pushCommand(options: PushCommandOptions): Promise<void> {
7782 ) ;
7883 } else {
7984 // Bundle flow: execute directly
85+ const collectorLoggerConfig = createCollectorLoggerConfig (
86+ logger ,
87+ options . verbose ,
88+ ) ;
8089 result = await executeBundlePush (
8190 detected . content ,
8291 detected . platform ! ,
@@ -85,6 +94,7 @@ export async function pushCommand(options: PushCommandOptions): Promise<void> {
8594 ( dir ) => {
8695 tempDir = dir ;
8796 } ,
97+ { logger : collectorLoggerConfig } ,
8898 ) ;
8999 }
90100
@@ -201,7 +211,13 @@ async function executeConfigPush(
201211 return executeWebPush ( tempPath , validatedEvent , logger ) ;
202212 } else if ( platform === 'server' ) {
203213 logger . debug ( 'Executing in server environment (Node.js)' ) ;
204- return executeServerPush ( tempPath , validatedEvent , logger ) ;
214+ const collectorLoggerConfig = createCollectorLoggerConfig (
215+ logger ,
216+ options . verbose ,
217+ ) ;
218+ return executeServerPush ( tempPath , validatedEvent , logger , 60000 , {
219+ logger : collectorLoggerConfig ,
220+ } ) ;
205221 } else {
206222 throw new Error ( `Unsupported platform: ${ platform } ` ) ;
207223 }
@@ -216,6 +232,7 @@ async function executeBundlePush(
216232 validatedEvent : { name : string ; data : Record < string , unknown > } ,
217233 logger : Logger ,
218234 setTempDir : ( dir : string ) => void ,
235+ context : { logger ?: CoreLogger . Config } = { } ,
219236) : Promise < PushResult > {
220237 // Write bundle to temp file
221238 const tempDir = path . join (
@@ -239,7 +256,7 @@ async function executeBundlePush(
239256 return executeWebPush ( tempPath , validatedEvent , logger ) ;
240257 } else {
241258 logger . debug ( 'Executing in server environment (Node.js)' ) ;
242- return executeServerPush ( tempPath , validatedEvent , logger ) ;
259+ return executeServerPush ( tempPath , validatedEvent , logger , 60000 , context ) ;
243260 }
244261}
245262
@@ -280,23 +297,28 @@ async function executeWebPush(
280297 const bundleCode = await fs . readFile ( bundlePath , 'utf8' ) ;
281298 window . eval ( bundleCode ) ;
282299
283- // Wait for window.elb assignment
284- logger . debug ( 'Waiting for elb ...' ) ;
300+ // Wait for window.collector assignment
301+ logger . debug ( 'Waiting for collector ...' ) ;
285302 await waitForWindowProperty (
286303 window as unknown as Record < string , unknown > ,
287- 'elb ' ,
304+ 'collector ' ,
288305 5000 ,
289306 ) ;
290307
291308 const windowObj = window as unknown as Record < string , unknown > ;
292- const elb = windowObj . elb as unknown as (
293- name : string ,
294- data : Record < string , unknown > ,
295- ) => Promise < Elb . PushResult > ;
309+ const collector = windowObj . collector as unknown as {
310+ push : ( event : {
311+ name : string ;
312+ data : Record < string , unknown > ;
313+ } ) => Promise < Elb . PushResult > ;
314+ } ;
296315
297- // Push event
316+ // Push event directly to collector (bypasses source handlers)
298317 logger . log ( `Pushing event: ${ event . name } ` ) ;
299- const elbResult = await elb ( event . name , event . data ) ;
318+ const elbResult = await collector . push ( {
319+ name : event . name ,
320+ data : event . data ,
321+ } ) ;
300322
301323 return {
302324 success : true ,
@@ -320,6 +342,7 @@ async function executeServerPush(
320342 event : PushEventInput ,
321343 logger : Logger ,
322344 timeout : number = 60000 , // 60 second default timeout
345+ context : { logger ?: CoreLogger . Config } = { } ,
323346) : Promise < PushResult > {
324347 const startTime = Date . now ( ) ;
325348
@@ -342,26 +365,28 @@ async function executeServerPush(
342365 throw new Error ( 'Bundle does not export default factory function' ) ;
343366 }
344367
345- // Call factory function to start flow
368+ // Call factory function to start flow (pass context for verbose logging)
346369 logger . debug ( 'Calling factory function...' ) ;
347- const result = await flowModule . default ( ) ;
370+ const result = await flowModule . default ( context ) ;
348371
349- if ( ! result || ! result . elb || typeof result . elb !== 'function' ) {
372+ if (
373+ ! result ||
374+ ! result . collector ||
375+ typeof result . collector . push !== 'function'
376+ ) {
350377 throw new Error (
351- 'Factory function did not return valid result with elb ' ,
378+ 'Factory function did not return valid result with collector ' ,
352379 ) ;
353380 }
354381
355- const { elb } = result ;
382+ const { collector } = result ;
356383
357- // Push event
384+ // Push event directly to collector (bypasses source handlers)
358385 logger . log ( `Pushing event: ${ event . name } ` ) ;
359- const elbResult = await (
360- elb as (
361- name : string ,
362- data : Record < string , unknown > ,
363- ) => Promise < Elb . PushResult >
364- ) ( event . name , event . data ) ;
386+ const elbResult = await collector . push ( {
387+ name : event . name ,
388+ data : event . data ,
389+ } ) ;
365390
366391 return {
367392 success : true ,
0 commit comments