@@ -272,6 +272,29 @@ export class ObjectStackServer {
272272 }
273273 }
274274
275+ static async triggerAutomation ( request : any ) {
276+ if ( ! this . protocol ) {
277+ throw new Error ( 'ObjectStackServer not initialized. Call ObjectStackServer.init() first.' ) ;
278+ }
279+
280+ this . logger ?. debug ?.( 'MSW: Triggering automation' , { request } ) ;
281+ try {
282+ const result = await this . protocol . triggerAutomation ( request ) ;
283+ this . logger ?. info ?.( 'MSW: Automation triggered' , { result } ) ;
284+ return {
285+ status : 200 ,
286+ data : result
287+ } ;
288+ } catch ( error ) {
289+ this . logger ?. error ?.( 'MSW: Automation trigger failed' , error ) ;
290+ const message = error instanceof Error ? error . message : 'Unknown error' ;
291+ return {
292+ status : 400 ,
293+ data : { error : message }
294+ } ;
295+ }
296+ }
297+
275298 // Legacy method names for compatibility
276299 static async getUser ( id : string ) {
277300 return this . getData ( 'user' , id ) ;
@@ -662,6 +685,18 @@ export class MSWPlugin implements Plugin {
662685 }
663686 } ) ,
664687
688+ // Automation Operations
689+ http . post ( `${ baseUrl } /automation/trigger` , async ( { request } ) => {
690+ try {
691+ const body = await request . json ( ) ;
692+ const result = await ObjectStackServer . triggerAutomation ( body ) ;
693+ return HttpResponse . json ( result . data , { status : result . status } ) ;
694+ } catch ( error ) {
695+ const message = error instanceof Error ? error . message : 'Unknown error' ;
696+ return HttpResponse . json ( { error : message } , { status : 400 } ) ;
697+ }
698+ } ) ,
699+
665700 // Add custom handlers
666701 ...( this . options . customHandlers || [ ] )
667702 ] ;
0 commit comments