diff --git a/docs/generated/api.json b/docs/generated/api.json index 12bf4768c..eb7d5885e 100644 --- a/docs/generated/api.json +++ b/docs/generated/api.json @@ -202,6 +202,15 @@ "text": "CloudEventFunction", "canonicalReference": "@google-cloud/functions-framework!CloudEventFunction:interface" }, + { + "kind": "Content", + "text": " | " + }, + { + "kind": "Reference", + "text": "CloudEventFunctionWithCallback", + "canonicalReference": "@google-cloud/functions-framework!CloudEventFunctionWithCallback:interface" + }, { "kind": "Content", "text": "" @@ -217,8 +226,8 @@ ], "fileUrlPath": "src/function_registry.ts", "returnTypeTokenRange": { - "startIndex": 8, - "endIndex": 9 + "startIndex": 10, + "endIndex": 11 }, "releaseTag": "Public", "overloadIndex": 1, @@ -235,7 +244,7 @@ "parameterName": "handler", "parameterTypeTokenRange": { "startIndex": 5, - "endIndex": 7 + "endIndex": 9 }, "isOptional": false } diff --git a/docs/generated/api.md.api.md b/docs/generated/api.md.api.md new file mode 100644 index 000000000..32386e50a --- /dev/null +++ b/docs/generated/api.md.api.md @@ -0,0 +1,140 @@ +## API Report File for "@google-cloud/functions-framework" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +/// + +import { CloudEventV1 as CloudEvent } from 'cloudevents'; +import { Request as Request_3 } from 'express'; +import { Response as Response_2 } from 'express'; + +export { CloudEvent } + +// @public +export const cloudEvent: (functionName: string, handler: CloudEventFunction | CloudEventFunctionWithCallback) => void; + +// @public +export interface CloudEventFunction { + // (undocumented) + (cloudEvent: CloudEvent): any; +} + +// @public +export interface CloudEventFunctionWithCallback { + // (undocumented) + (cloudEvent: CloudEvent, callback: Function): any; +} + +// @public +export interface CloudFunctionsContext { + eventId?: string; + eventType?: string; + resource?: string | { + [key: string]: string; + }; + timestamp?: string; +} + +// @public +export type Context = CloudFunctionsContext | CloudEvent; + +// @public +export interface Data { + // (undocumented) + data: object; +} + +// @public +export interface EventFunction { + // (undocumented) + (data: {}, context: Context): any; +} + +// @public +export interface EventFunctionWithCallback { + // (undocumented) + (data: {}, context: Context, callback: Function): any; +} + +// @public +export type HandlerFunction = HttpFunction | EventFunction | EventFunctionWithCallback | CloudEventFunction | CloudEventFunctionWithCallback | TypedFunction; + +// @public +export const http: (functionName: string, handler: HttpFunction) => void; + +// @public +export interface HttpFunction { + // (undocumented) + (req: Request_2, res: Response_2): any; +} + +// @public +export interface InvocationFormat { + deserializeRequest(request: InvocationRequest): T | Promise; + serializeResponse(responseWriter: InvocationResponse, response: U): void | Promise; +} + +// @public +export interface InvocationRequest { + body(): string | Buffer; + header(header: string): string | undefined; +} + +// @public +export interface InvocationResponse { + end(data: string | Buffer): void; + setHeader(key: string, value: string): void; + write(data: string | Buffer): void; +} + +// @public +export class JsonInvocationFormat implements InvocationFormat { + // (undocumented) + deserializeRequest(request: InvocationRequest): T; + // (undocumented) + serializeResponse(responseWriter: InvocationResponse, response: U): void; +} + +// @public +export type LegacyCloudFunctionsContext = CloudFunctionsContext | Data; + +// @public +export interface LegacyEvent { + // (undocumented) + context: CloudFunctionsContext; + // (undocumented) + data: { + [key: string]: any; + }; +} + +// @public (undocumented) +interface Request_2 extends Request_3 { + abortController?: AbortController; + executionId?: string; + rawBody?: Buffer; + spanId?: string; + traceId?: string; +} +export { Request_2 as Request } + +export { Response_2 as Response } + +// Warning: (ae-internal-missing-underscore) The name "typed" should be prefixed with an underscore because the declaration is marked as @internal +// +// @internal +export const typed: (functionName: string, handler: TypedFunction | ((req: T) => U | Promise)) => void; + +// @public +export interface TypedFunction { + // (undocumented) + format: InvocationFormat; + // (undocumented) + handler: (req: T) => U | Promise; +} + +// (No @packageDocumentation comment for this package) + +``` diff --git a/test/integration/cloud_event.ts b/test/integration/cloud_event.ts index 9bc9fc9fc..a8b04735e 100644 --- a/test/integration/cloud_event.ts +++ b/test/integration/cloud_event.ts @@ -336,7 +336,6 @@ describe('CloudEvent Function', () => { .expect(204); }); - it('returns a 500 if the function throws an exception', async () => { functions.cloudEvent('testTypedCloudEvent', () => { throw 'I crashed';