Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/v2/providers/eventarc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import * as options from '../options';
/** Options that can be set on an Eventarc trigger. */
export interface EventarcTriggerOptions extends options.EventHandlerOptions {
/**
* Type of the event.
* Type of the event to trigger on.
*/
eventType: string;

Expand All @@ -54,14 +54,26 @@ export interface EventarcTriggerOptions extends options.EventHandlerOptions {
filters?: Record<string, string>;
}

/**
* A function that takes a {@link CloudEvent}.
*/
export type CloudEventHandler = (event: CloudEvent<any>) => any | Promise<any>;

/** Handle an Eventarc event published on the default channel. */
/** Handles an Eventarc event published on the default channel.
* @param eventType - Type of the event to trigger on.
* @param handler - A function to execute when triggered.
* @returns A function that you can export and deploy.
*/
export function onCustomEventPublished<T = any>(
eventType: string,
handler: CloudEventHandler
): CloudFunction<CloudEvent<T>>;

/** Handles an Eventarc event.
* @param opts - Options to set on this function
* @param handler - A function to execute when triggered.
* @returns A function that you can export and deploy.
*/
export function onCustomEventPublished<T = any>(
opts: EventarcTriggerOptions,
handler: CloudEventHandler
Expand Down