import { CloudEvent, CloudFunction } from "../../core"; import { ParamsOf, VarName } from "../../../common/params"; import { EventHandlerOptions, SupportedRegion } from "../../options"; import { Expression } from "../../../params"; import { ResetValue } from "../../../common/options"; /** @hidden */ export interface SourceLocation { line: number; column: number; } /** @hidden */ export interface GraphqlErrorExtensions { file: string; code: string; debugDetails: string; } /** @hidden */ export interface GraphqlError { message: string; locations: Array; path: Array; extensions: GraphqlErrorExtensions; } /** @hidden */ export interface RawMutation { data: R; variables: V; errors: Array; } /** @hidden */ export interface MutationEventData { ["@type"]: "type.googleapis.com/google.events.firebase.dataconnect.v1.MutationEventData"; payload: RawMutation; } /** @hidden */ export interface RawDataConnectEvent extends CloudEvent { project: string; location: string; service: string; schema: string; connector: string; operation: string; authtype: AuthType; authid?: string; } /** * AuthType defines the possible values for the authType field in a Firebase Data Connect event. * - app_user: an end user of an application.. * - admin: an admin user of an application. In the context of impersonate endpoints used by the admin SDK, the impersonator. * - unknown: a general type to capture all other principals not captured in the other auth types. */ export type AuthType = "app_user" | "admin" | "unknown"; /** OperationOptions extend EventHandlerOptions with a provided service, connector, and operation. */ export interface OperationOptions extends EventHandlerOptions { /** Firebase Data Connect service ID */ service?: Service; /** Firebase Data Connect connector ID */ connector?: Connector; /** Name of the operation */ operation?: Operation; /** * Region where functions should be deployed. Defaults to us-central1. */ region?: SupportedRegion | string | Expression | ResetValue; } export type DataConnectParams = PathPatternOrOptions extends string ? ParamsOf : PathPatternOrOptions extends OperationOptions ? Record | VarName | VarName, string> : never; export interface DataConnectEvent> extends CloudEvent { /** The location of the Firebase Data Connect instance */ location: string; /** The project identifier */ project: string; /** * An object containing the values of the path patterns. * Only named capture groups will be populated - {key}, {key=*}, {key=**}. */ params: Params; /** The type of principal that triggered the event */ authType: AuthType; /** The unique identifier for the principal */ authId?: string; } /** * Event handler that triggers when a mutation is executed in Firebase Data Connect. * * @param mutation - The mutation path to trigger on. * @param handler - Event handler which is run every time a mutation is executed. */ export declare function onMutationExecuted(mutation: Mutation, handler: (event: DataConnectEvent, DataConnectParams>) => unknown | Promise): CloudFunction, DataConnectParams>>; /** * Event handler that triggers when a mutation is executed in Firebase Data Connect. * * @param opts - Options that can be set on an individual event-handling function. * @param handler - Event handler which is run every time a mutation is executed. */ export declare function onMutationExecuted(opts: Options, handler: (event: DataConnectEvent, DataConnectParams>) => unknown | Promise): CloudFunction, DataConnectParams>>;