Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: udpate ts-doc annotations #603

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/generated/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
{
"kind": "Function",
"canonicalReference": "@google-cloud/functions-framework!cloudEvent:function(1)",
"docComment": "/**\n * Register a function that handles CloudEvents.\n *\n * @param functionName - the name of the function\n *\n * @param handler - the function to trigger when handling CloudEvents\n *\n * @public\n */\n",
"docComment": "/**\n * Register a function that handles CloudEvents.\n *\n * @param functionName - The name of the function\n *\n * @param handler - The function to trigger when handling CloudEvents\n *\n * @public\n */\n",
"excerptTokens": [
{
"kind": "Content",
Expand Down Expand Up @@ -949,7 +949,7 @@
{
"kind": "Function",
"canonicalReference": "@google-cloud/functions-framework!http:function(1)",
"docComment": "/**\n * Register a function that responds to HTTP requests.\n *\n * @param functionName - the name of the function\n *\n * @param handler - the function to invoke when handling HTTP requests\n *\n * @public\n */\n",
"docComment": "/**\n * Register a function that responds to HTTP requests.\n *\n * @param functionName - The name of the function\n *\n * @param handler - The function to invoke when handling HTTP requests\n *\n * @public\n */\n",
"excerptTokens": [
{
"kind": "Content",
Expand Down Expand Up @@ -1125,7 +1125,7 @@
{
"kind": "MethodSignature",
"canonicalReference": "@google-cloud/functions-framework!InvocationFormat#deserializeRequest:member(1)",
"docComment": "/**\n * Creates an instance of the request type from an invocation request.\n *\n * @param request - the request body as raw bytes\n */\n",
"docComment": "/**\n * Creates an instance of the request type from an invocation request.\n *\n * @param request - The request body as raw bytes\n */\n",
"excerptTokens": [
{
"kind": "Content",
Expand Down Expand Up @@ -1180,7 +1180,7 @@
{
"kind": "MethodSignature",
"canonicalReference": "@google-cloud/functions-framework!InvocationFormat#serializeResponse:member(1)",
"docComment": "/**\n * Writes the response type to the invocation result.\n *\n * @param responseWriter - interface for writing to the invocation result\n *\n * @param response - the response object\n */\n",
"docComment": "/**\n * Writes the response type to the invocation result.\n *\n * @param responseWriter - Interface for writing to the invocation result\n *\n * @param response - The response object\n */\n",
"excerptTokens": [
{
"kind": "Content",
Expand Down
6 changes: 3 additions & 3 deletions src/cloud_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const CE_SERVICE = {
*
* {@link https://github.com/cloudevents/spec/blob/main/http-protocol-binding.md#3-http-message-mapping}
*
* @param req - Express request object.
* @param req - Express request object
* @return True if the request is a CloudEvents event in binary content mode,
* false otherwise.
*/
Expand All @@ -53,8 +53,8 @@ export function isBinaryCloudEvent(req: express.Request): boolean {
* Returns a CloudEvents context from the given CloudEvents request. Context
* attributes are retrieved from request headers.
*
* @param req Express request object.
* @return CloudEvents context.
* @param req - Express request object
* @return CloudEvents context
*/
export function getBinaryCloudEventContext(
req: express.Request
Expand Down
20 changes: 10 additions & 10 deletions src/function_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const register = <T = unknown, U = unknown>(
* - must be <= 63 characters
* - must start with a letter
* - must end with a letter or number
* @param functionName the function name
* @param functionName - The function name
* @returns true if the function name is valid
*/
export const isValidFunctionName = (functionName: string): boolean => {
Expand All @@ -67,9 +67,9 @@ export const isValidFunctionName = (functionName: string): boolean => {

/**
* Get a declaratively registered function
* @param functionName the name with which the function was registered
* @returns the registered function and signature type or undefined no function matching
* the provided name has been registered.
* @param functionName - The name with which the function was registered
* @returns The registered function and signature type or undefined no function matching
* the provided name has been registered
*/
export const getRegisteredFunction = (
functionName: string
Expand All @@ -80,8 +80,8 @@ export const getRegisteredFunction = (

/**
* Register a function that responds to HTTP requests.
* @param functionName - the name of the function
* @param handler - the function to invoke when handling HTTP requests
* @param functionName - The name of the function
* @param handler - The function to invoke when handling HTTP requests
* @public
*/
export const http = (functionName: string, handler: HttpFunction): void => {
Expand All @@ -90,8 +90,8 @@ export const http = (functionName: string, handler: HttpFunction): void => {

/**
* Register a function that handles CloudEvents.
* @param functionName - the name of the function
* @param handler - the function to trigger when handling CloudEvents
* @param functionName - The name of the function
* @param handler - The function to trigger when handling CloudEvents
* @public
*/
export const cloudEvent = <T = unknown>(
Expand All @@ -103,8 +103,8 @@ export const cloudEvent = <T = unknown>(

/**
* Register a function that handles strongly typed invocations.
* @param functionName - the name of the function
* @param handler - the function to trigger
* @param functionName - The name of the function
* @param handler - The function to trigger
* @internal
*/
export const typed = <T, U>(
Expand Down
34 changes: 17 additions & 17 deletions src/function_wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type OnDoneCallback = (err: Error | null, result: any) => void;

/**
* Get a completion handler that can be used to signal completion of an event function.
* @param res the response object of the request the completion handler is for.
* @returns an OnDoneCallback for the provided request.
* @param res - The response object of the request the completion handler is for
* @returns An OnDoneCallback for the provided request.
*/
const getOnDoneCallback = (res: Response): OnDoneCallback => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -58,8 +58,8 @@ const getOnDoneCallback = (res: Response): OnDoneCallback => {

/**
* Helper function to parse a CloudEvent object from an HTTP request.
* @param req an Express HTTP request
* @returns a CloudEvent parsed from the request
* @param req - An Express HTTP request
* @returns A CloudEvent parsed from the request
*/
const parseCloudEventRequest = (req: Request): CloudEvent<unknown> => {
let cloudEvent = req.body;
Expand All @@ -77,8 +77,8 @@ const parseCloudEventRequest = (req: Request): CloudEvent<unknown> => {
/**
* Helper function to background event context and data payload object from an HTTP
* request.
* @param req an Express HTTP request
* @returns the data playload and event context parsed from the request
* @param req - An Express HTTP request
* @returns The data playload and event context parsed from the request
*/
const parseBackgroundEvent = (req: Request): {data: {}; context: Context} => {
const event = req.body;
Expand All @@ -100,8 +100,8 @@ const parseBackgroundEvent = (req: Request): {data: {}; context: Context} => {
/**
* Wraps the provided function into an Express handler function with additional
* instrumentation logic.
* @param execute Runs user's function.
* @return An Express handler function.
* @param execute - Runs user's function
* @return An Express handler function
*/
const wrapHttpFunction = (execute: HttpFunction): RequestHandler => {
return (req: Request, res: Response) => {
Expand Down Expand Up @@ -132,8 +132,8 @@ const wrapHttpFunction = (execute: HttpFunction): RequestHandler => {

/**
* Wraps an async CloudEvent function in an express RequestHandler.
* @param userFunction User's function.
* @return An Express hander function that invokes the user function.
* @param userFunction - User's function
* @return An Express hander function that invokes the user function
*/
const wrapCloudEventFunction = (
userFunction: CloudEventFunction
Expand All @@ -153,8 +153,8 @@ const wrapCloudEventFunction = (

/**
* Wraps callback style CloudEvent function in an express RequestHandler.
* @param userFunction User's function.
* @return An Express hander function that invokes the user function.
* @param userFunction - User's function
* @return An Express hander function that invokes the user function
*/
const wrapCloudEventFunctionWithCallback = (
userFunction: CloudEventFunctionWithCallback
Expand All @@ -169,8 +169,8 @@ const wrapCloudEventFunctionWithCallback = (

/**
* Wraps an async event function in an express RequestHandler.
* @param userFunction User's function.
* @return An Express hander function that invokes the user function.
* @param userFunction - User's function
* @return An Express hander function that invokes the user function
*/
const wrapEventFunction = (userFunction: EventFunction): RequestHandler => {
const httpHandler = (req: Request, res: Response) => {
Expand All @@ -188,8 +188,8 @@ const wrapEventFunction = (userFunction: EventFunction): RequestHandler => {

/**
* Wraps a callback style event function in an express RequestHandler.
* @param userFunction User's function.
* @return An Express hander function that invokes the user function.
* @param userFunction - User's function
* @return An Express hander function that invokes the user function
*/
const wrapEventFunctionWithCallback = (
userFunction: EventFunctionWithCallback
Expand All @@ -204,7 +204,7 @@ const wrapEventFunctionWithCallback = (

/**
* Wraps a typed function in an express style RequestHandler.
* @param userFunction User's function
* @param userFunction - User's function
* @return An Express handler function that invokes the user function
*/
const wrapTypedFunction = (typedFunction: TypedFunction): RequestHandler => {
Expand Down
6 changes: 3 additions & 3 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ export interface InvocationFormat<T, U> {
/**
* Creates an instance of the request type from an invocation request.
*
* @param request - the request body as raw bytes
* @param request - The request body as raw bytes
*/
deserializeRequest(request: InvocationRequest): T | Promise<T>;

/**
* Writes the response type to the invocation result.
*
* @param responseWriter interface for writing to the invocation result
* @param response the response object
* @param responseWriter - Interface for writing to the invocation result
* @param response - The response object
*/
serializeResponse(
responseWriter: InvocationResponse,
Expand Down
8 changes: 4 additions & 4 deletions src/invoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export const setLatestRes = (res: express.Response) => {

/**
* Sends back a response to the incoming request.
* @param result Output from function execution.
* @param err Error from function execution.
* @param res Express response object.
* @param result - Output from function execution
* @param err - Error from function execution
* @param res - Express response object
*/

export function sendResponse(
Expand Down Expand Up @@ -79,7 +79,7 @@ const killInstance = process.exit.bind(process, 16);

/**
* Enables registration of error handlers.
* @param server HTTP server which invokes user's function.
* @param server - HTTP server which invokes user's function
* @constructor
*/
export class ErrorHandler {
Expand Down
2 changes: 1 addition & 1 deletion src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export async function getUserFunction(
/**
* Returns resolved path to the module containing the user function.
* Returns null if the module can not be identified.
* @param codeLocation Directory with user's code.
* @param codeLocation - Directory with user's code
* @return Resolved path or null.
*/
function getFunctionModulePath(codeLocation: string): string | null {
Expand Down
6 changes: 3 additions & 3 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
/**
* Logs an error message and sends back an error response to the incoming
* request.
* @param err Error to be logged and sent.
* @param res Express response object.
* @param callback A function to be called synchronously.
* @param err - Error to be logged and sent
* @param res - Express response object
* @param callback - A function to be called synchronously
*/
export function sendCrashResponse({
err,
Expand Down Expand Up @@ -92,17 +92,17 @@
}

export const errorHandler = (
err: Error | any,

Check warning on line 95 in src/logger.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
req: express.Request,
res: express.Response,
next: express.NextFunction

Check warning on line 98 in src/logger.ts

View workflow job for this annotation

GitHub Actions / lint

'next' is defined but never used
) => {
interceptStderrWrite();
res.status(500);
res.render('error', {error: err});
};

export function splitArgs(args: any[]) {

Check warning on line 105 in src/logger.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
let encoding, cb;
if (
args.length > 0 &&
Expand Down Expand Up @@ -152,7 +152,7 @@
};
}

function getJSONWithContext(json: any, context: ExecutionContext) {

Check warning on line 155 in src/logger.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
if (EXECUTION_CONTEXT_LABELS_KEY in json) {
json[EXECUTION_CONTEXT_LABELS_KEY]['execution_id'] = context.executionId;
} else {
Expand Down
18 changes: 9 additions & 9 deletions src/middleware/background_event_to_cloud_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const CE_SERVICE_TO_RESOURCE_RE = new Map([

/**
* Is this request a known GCF event that can be converted to a cloud event.
* @param req the express request object
* @returns true if this request can be converted to a CloudEvent
* @param req - The express request object
* @returns True if this request can be converted to a CloudEvent
*/
const isConvertableBackgroundEvent = (req: Request): boolean => {
const {body} = req;
Expand All @@ -79,8 +79,8 @@ const isConvertableBackgroundEvent = (req: Request): boolean => {

/**
* Convert the given HTTP request into the GCF Background Event data / context format.
* @param body the express request object
* @returns a marshalled background event
* @param body - The express request object
* @returns A marshalled background event
*/
const getBackgroundEvent = (request: Request): LegacyEvent => {
let {context} = request.body;
Expand All @@ -104,8 +104,8 @@ interface ParsedResource {

/**
* Splits a background event's resource into a CloudEvent service, resource, and subject.
* @param context the GCF event context to parse.
* @returns the CloudEvent service, resource and subject fields for the given GCF event context.
* @param context - The GCF event context to parse
* @returns The CloudEvent service, resource and subject fields for the given GCF event context
*/
export const splitResource = (
context: CloudFunctionsContext
Expand Down Expand Up @@ -159,9 +159,9 @@ export const splitResource = (
/**
* Express middleware to convert background GCF requests to Cloudevents. This enables functions
* using the "cloudevent" signature type to accept requests from a background event producer.
* @param req express request object
* @param res express response object
* @param next function used to pass control to the next middleware function in the stack
* @param req - Express request object
* @param res - Express response object
* @param next - Function used to pass control to the next middleware function in the stack
*/
export const backgroundEventToCloudEventMiddleware = (
req: Request,
Expand Down
18 changes: 9 additions & 9 deletions src/middleware/cloud_event_to_background_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const CE_SOURCE_REGEX = /\/\/([^/]+)\/(.+)/;

/**
* Is the given request a known CloudEvent that can be converted to a legacy event.
* @param request express request object
* @returns true if the request can be converted
* @param request - Express request object
* @returns True if the request can be converted
*/
const isConvertableCloudEvent = (request: Request): boolean => {
if (isBinaryCloudEvent(request)) {
Expand All @@ -75,8 +75,8 @@ const isConvertableCloudEvent = (request: Request): boolean => {

/**
* Splits a CloudEvent source string into resource and subject components.
* @param source the cloud event source
* @returns the parsed service and name components of the CE source string
* @param source - The cloud event source
* @returns The parsed service and name components of the CE source string
*/
export const parseSource = (
source: string
Expand All @@ -95,8 +95,8 @@ export const parseSource = (

/**
* Marshal a known GCP CloudEvent request the equivalent context/data legacy event format.
* @param req express request object
* @returns the request body of the equivalent legacy event request
* @param req - Express request object
* @returns The request body of the equivalent legacy event request
*/
const marshalConvertableCloudEvent = (
req: Request
Expand Down Expand Up @@ -173,9 +173,9 @@ const marshalConvertableCloudEvent = (
/**
* Express middleware to convert cloud event requests to legacy GCF events. This enables
* functions using the "EVENT" signature type to accept requests from a cloud event producer.
* @param req express request object
* @param res express response object
* @param next function used to pass control to the next middle middleware function in the stack
* @param req - Express request object
* @param res - Express response object
* @param next - Function used to pass control to the next middle middleware function in the stack
*/
export const cloudEventToBackgroundEventMiddleware = (
req: Request,
Expand Down
6 changes: 3 additions & 3 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ Documentation:
/**
* Parse the configurable framework options from the provided CLI arguments and
* environment variables.
* @param cliArgs the raw command line arguments
* @param envVars the environment variables to parse options from
* @returns the parsed options that should be used to configure the framework.
* @param cliArgs - The raw command line arguments
* @param envVars - The environment variables to parse options from
* @returns The parsed options that should be used to configure the framework
*/
export const parseOptions = (
cliArgs: string[] = process.argv,
Expand Down