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

Switch order of context and trigger input #43

Merged
merged 1 commit into from
Dec 7, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/InvocationModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class InvocationModel implements coreTypes.InvocationModel {
async invokeFunction(context: InvocationContext, inputs: unknown[], handler: FunctionHandler): Promise<unknown> {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return await Promise.resolve(handler(context, inputs[0]));
return await Promise.resolve(handler(inputs[0], context));
} finally {
this.#isDone = true;
}
Expand Down
2 changes: 1 addition & 1 deletion types/cosmosDB.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type CosmosDBHandler = (context: InvocationContext, documents: unknown[]) => FunctionResult;
export type CosmosDBHandler = (documents: unknown[], context: InvocationContext) => FunctionResult;

export interface CosmosDBFunctionOptions extends CosmosDBTriggerOptions, Partial<FunctionOptions> {
handler: CosmosDBHandler;
Expand Down
2 changes: 1 addition & 1 deletion types/eventGrid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type EventGridHandler = (context: InvocationContext, event: EventGridEvent) => FunctionResult;
export type EventGridHandler = (event: EventGridEvent, context: InvocationContext) => FunctionResult;

export interface EventGridFunctionOptions extends EventGridTriggerOptions, Partial<FunctionOptions> {
handler: EventGridHandler;
Expand Down
2 changes: 1 addition & 1 deletion types/eventHub.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type EventHubHandler = (context: InvocationContext, messages: unknown) => FunctionResult;
export type EventHubHandler = (messages: unknown, context: InvocationContext) => FunctionResult;

export interface EventHubFunctionOptions extends EventHubTriggerOptions, Partial<FunctionOptions> {
handler: EventHubHandler;
Expand Down
2 changes: 1 addition & 1 deletion types/http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { URLSearchParams } from 'url';
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type HttpHandler = (context: InvocationContext, request: HttpRequest) => FunctionResult<HttpResponse>;
export type HttpHandler = (request: HttpRequest, context: InvocationContext) => FunctionResult<HttpResponse>;

export interface HttpFunctionOptions extends HttpTriggerOptions, Partial<FunctionOptions> {
handler: HttpHandler;
Expand Down
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import { GenericInputOptions, GenericOutputOptions, GenericTriggerOptions } from
import {
HttpFunctionOptions,
HttpHandler,
HttpMethodFunctionOptions,
HttpOutput,
HttpOutputOptions,
HttpTrigger,
HttpTriggerOptions,
HttpMethodFunctionOptions,
} from './http';
import { InvocationContext } from './InvocationContext';
import {
Expand Down Expand Up @@ -357,7 +357,7 @@ export namespace output {
*/
export type FunctionResult<T = unknown> = T | Promise<T>;

export type FunctionHandler = (context: InvocationContext, triggerInput: any) => FunctionResult<any>;
export type FunctionHandler = (triggerInput: any, context: InvocationContext) => FunctionResult<any>;

/**
* Configures the inputs, outputs, and handler for an Azure Function
Expand Down
4 changes: 2 additions & 2 deletions types/serviceBus.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type ServiceBusQueueHandler = (context: InvocationContext, message: unknown) => FunctionResult;
export type ServiceBusQueueHandler = (message: unknown, context: InvocationContext) => FunctionResult;

export interface ServiceBusQueueFunctionOptions extends ServiceBusQueueTriggerOptions, Partial<FunctionOptions> {
handler: ServiceBusQueueHandler;
Expand Down Expand Up @@ -43,7 +43,7 @@ export interface ServiceBusQueueOutputOptions {
}
export type ServiceBusQueueOutput = FunctionOutput & ServiceBusQueueOutputOptions;

export type ServiceBusTopicHandler = (context: InvocationContext, message: unknown) => FunctionResult;
export type ServiceBusTopicHandler = (message: unknown, context: InvocationContext) => FunctionResult;

export interface ServiceBusTopicFunctionOptions extends ServiceBusTopicTriggerOptions, Partial<FunctionOptions> {
handler: ServiceBusTopicHandler;
Expand Down
4 changes: 2 additions & 2 deletions types/storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type StorageBlobHandler = (context: InvocationContext, blob: unknown) => FunctionResult;
export type StorageQueueHandler = (context: InvocationContext, queueEntry: unknown) => FunctionResult;
export type StorageBlobHandler = (blob: unknown, context: InvocationContext) => FunctionResult;
export type StorageQueueHandler = (queueEntry: unknown, context: InvocationContext) => FunctionResult;

export interface StorageBlobFunctionOptions extends StorageBlobTriggerOptions, Partial<FunctionOptions> {
handler: StorageBlobHandler;
Expand Down
2 changes: 1 addition & 1 deletion types/timer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { FunctionOptions, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type TimerHandler = (context: InvocationContext, myTimer: Timer) => FunctionResult;
export type TimerHandler = (myTimer: Timer, context: InvocationContext) => FunctionResult;

export interface TimerFunctionOptions extends TimerTriggerOptions, Partial<FunctionOptions> {
handler: TimerHandler;
Expand Down