UNPKG

firebase-functions

Version:
18 lines (17 loc) 764 B
import { CloudEvent } from "./core"; import { EventContext as V1EventContext } from "../v1"; export type V1Compat<DataName extends string, DataType, ContextType = V1EventContext> = { [K in DataName]: DataType; } & { context: ContextType; }; /** * Patches a CloudEvent with V1 compatibility properties via getters. * This function ensures idempotency by using a Symbol to mark already patched events. * @param event The CloudEvent to patch. * @param getters A map of getters to attach to the event object. * @returns The patched CloudEvent with V1 compatibility properties. */ export declare function addV1Compat<T extends CloudEvent<unknown>, U extends Record<string, () => any>>(event: T, getters: U): T & { [K in keyof U]: ReturnType<U[K]>; };