@@ -66,6 +66,22 @@ import * as prompt from "../../prompt";
6666export const EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE" ;
6767export const DEFAULT_FUNCTION_REGION = "us-central1" ;
6868
69+ interface EventTriggerResolutionTarget {
70+ project : string ;
71+ eventTrigger : {
72+ eventType : string ;
73+ eventFilters ?: Record < string , string | build . Expression < string > > ;
74+ region ?: string | build . Expression < string > ;
75+ } ;
76+ }
77+
78+ interface BlockingTriggerResolutionTarget {
79+ blockingTrigger : {
80+ eventType : string ;
81+ options ?: Record < string , unknown > ;
82+ } ;
83+ }
84+
6985/**
7086 * Prepare functions codebases for deploy.
7187 */
@@ -380,11 +396,10 @@ export async function resolveDefaultRegionsForBuild(
380396 } else {
381397 // Match triggers.
382398 try {
383- const fullEndpoint = { ...endpoint , id } as any ;
384399 if ( build . isBlockingTriggered ( endpoint ) ) {
385- resolvedRegion = resolveRegionForBlockingTrigger ( fullEndpoint ) ;
400+ resolvedRegion = resolveRegionForBlockingTrigger ( endpoint ) ;
386401 } else if ( build . isEventTriggered ( endpoint ) ) {
387- resolvedRegion = await resolveRegionForEventTrigger ( fullEndpoint ) ;
402+ resolvedRegion = await resolveRegionForEventTrigger ( endpoint ) ;
388403 }
389404 } catch ( err : any ) {
390405 logger . debug (
@@ -400,22 +415,22 @@ export async function resolveDefaultRegionsForBuild(
400415}
401416
402417function resolveRegionForBlockingTrigger (
403- endpoint : backend . Endpoint & backend . BlockingTriggered ,
418+ endpoint : BlockingTriggerResolutionTarget ,
404419) : string {
405420 const eventType = endpoint . blockingTrigger . eventType ;
406421 if ( ( events . AUTH_BLOCKING_EVENTS as readonly string [ ] ) . includes ( eventType ) ) {
407422 return "us-east1" ;
408423 }
409424
410- if ( isGlobalAILogicEndpoint ( endpoint ) ) {
425+ if ( isGlobalAILogicEndpoint ( endpoint as backend . Endpoint ) ) {
411426 return "us-east1" ;
412427 }
413428
414429 return DEFAULT_FUNCTION_REGION ;
415430}
416431
417432async function resolveRegionForEventTrigger (
418- endpoint : backend . Endpoint & backend . EventTriggered ,
433+ endpoint : EventTriggerResolutionTarget ,
419434) : Promise < string > {
420435 const eventTrigger = endpoint . eventTrigger ;
421436 const eventType = eventTrigger . eventType ;
0 commit comments