|
| 1 | +## API Report File for "@google-cloud/functions-framework" |
| 2 | + |
| 3 | +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). |
| 4 | +
|
| 5 | +```ts |
| 6 | + |
| 7 | +/// <reference types="node" /> |
| 8 | + |
| 9 | +import { CloudEventV1 as CloudEvent } from 'cloudevents'; |
| 10 | +import { Request as Request_3 } from 'express'; |
| 11 | +import { Response as Response_2 } from 'express'; |
| 12 | + |
| 13 | +export { CloudEvent } |
| 14 | + |
| 15 | +// @public |
| 16 | +export const cloudEvent: <T = unknown>(functionName: string, handler: CloudEventFunction<T> | CloudEventFunctionWithCallback<T>) => void; |
| 17 | + |
| 18 | +// @public |
| 19 | +export interface CloudEventFunction<T = unknown> { |
| 20 | + // (undocumented) |
| 21 | + (cloudEvent: CloudEvent<T>): any; |
| 22 | +} |
| 23 | + |
| 24 | +// @public |
| 25 | +export interface CloudEventFunctionWithCallback<T = unknown> { |
| 26 | + // (undocumented) |
| 27 | + (cloudEvent: CloudEvent<T>, callback: Function): any; |
| 28 | +} |
| 29 | + |
| 30 | +// @public |
| 31 | +export interface CloudFunctionsContext { |
| 32 | + eventId?: string; |
| 33 | + eventType?: string; |
| 34 | + resource?: string | { |
| 35 | + [key: string]: string; |
| 36 | + }; |
| 37 | + timestamp?: string; |
| 38 | +} |
| 39 | + |
| 40 | +// @public |
| 41 | +export type Context = CloudFunctionsContext | CloudEvent<unknown>; |
| 42 | + |
| 43 | +// @public |
| 44 | +export interface Data { |
| 45 | + // (undocumented) |
| 46 | + data: object; |
| 47 | +} |
| 48 | + |
| 49 | +// @public |
| 50 | +export interface EventFunction { |
| 51 | + // (undocumented) |
| 52 | + (data: {}, context: Context): any; |
| 53 | +} |
| 54 | + |
| 55 | +// @public |
| 56 | +export interface EventFunctionWithCallback { |
| 57 | + // (undocumented) |
| 58 | + (data: {}, context: Context, callback: Function): any; |
| 59 | +} |
| 60 | + |
| 61 | +// @public |
| 62 | +export type HandlerFunction<T = unknown, U = unknown> = HttpFunction | EventFunction | EventFunctionWithCallback | CloudEventFunction<T> | CloudEventFunctionWithCallback<T> | TypedFunction<T, U>; |
| 63 | + |
| 64 | +// @public |
| 65 | +export const http: (functionName: string, handler: HttpFunction) => void; |
| 66 | + |
| 67 | +// @public |
| 68 | +export interface HttpFunction { |
| 69 | + // (undocumented) |
| 70 | + (req: Request_2, res: Response_2): any; |
| 71 | +} |
| 72 | + |
| 73 | +// @public |
| 74 | +export interface InvocationFormat<T, U> { |
| 75 | + deserializeRequest(request: InvocationRequest): T | Promise<T>; |
| 76 | + serializeResponse(responseWriter: InvocationResponse, response: U): void | Promise<void>; |
| 77 | +} |
| 78 | + |
| 79 | +// @public |
| 80 | +export interface InvocationRequest { |
| 81 | + body(): string | Buffer; |
| 82 | + header(header: string): string | undefined; |
| 83 | +} |
| 84 | + |
| 85 | +// @public |
| 86 | +export interface InvocationResponse { |
| 87 | + end(data: string | Buffer): void; |
| 88 | + setHeader(key: string, value: string): void; |
| 89 | + write(data: string | Buffer): void; |
| 90 | +} |
| 91 | + |
| 92 | +// @public |
| 93 | +export class JsonInvocationFormat<T, U> implements InvocationFormat<T, U> { |
| 94 | + // (undocumented) |
| 95 | + deserializeRequest(request: InvocationRequest): T; |
| 96 | + // (undocumented) |
| 97 | + serializeResponse(responseWriter: InvocationResponse, response: U): void; |
| 98 | +} |
| 99 | + |
| 100 | +// @public |
| 101 | +export type LegacyCloudFunctionsContext = CloudFunctionsContext | Data; |
| 102 | + |
| 103 | +// @public |
| 104 | +export interface LegacyEvent { |
| 105 | + // (undocumented) |
| 106 | + context: CloudFunctionsContext; |
| 107 | + // (undocumented) |
| 108 | + data: { |
| 109 | + [key: string]: any; |
| 110 | + }; |
| 111 | +} |
| 112 | + |
| 113 | +// @public (undocumented) |
| 114 | +interface Request_2 extends Request_3 { |
| 115 | + abortController?: AbortController; |
| 116 | + executionId?: string; |
| 117 | + rawBody?: Buffer; |
| 118 | + spanId?: string; |
| 119 | + traceId?: string; |
| 120 | +} |
| 121 | +export { Request_2 as Request } |
| 122 | + |
| 123 | +export { Response_2 as Response } |
| 124 | + |
| 125 | +// Warning: (ae-internal-missing-underscore) The name "typed" should be prefixed with an underscore because the declaration is marked as @internal |
| 126 | +// |
| 127 | +// @internal |
| 128 | +export const typed: <T, U>(functionName: string, handler: TypedFunction<T, U> | ((req: T) => U | Promise<U>)) => void; |
| 129 | + |
| 130 | +// @public |
| 131 | +export interface TypedFunction<T = unknown, U = unknown> { |
| 132 | + // (undocumented) |
| 133 | + format: InvocationFormat<T, U>; |
| 134 | + // (undocumented) |
| 135 | + handler: (req: T) => U | Promise<U>; |
| 136 | +} |
| 137 | + |
| 138 | +// (No @packageDocumentation comment for this package) |
| 139 | + |
| 140 | +``` |
0 commit comments