Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { CosmosDBFunctionOptions } from './cosmosDB';
import { EventGridFunctionOptions } from './eventGrid';
import { EventGridEvent, EventGridFunctionOptions } from './eventGrid';
import { EventHubFunctionOptions } from './eventHub';
import { GenericFunctionOptions } from './generic';
import { HttpFunctionOptions, HttpHandler, HttpMethodFunctionOptions } from './http';
Expand Down Expand Up @@ -112,49 +112,49 @@ export function timer(name: string, options: TimerFunctionOptions): void;
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function storageBlob(name: string, options: StorageBlobFunctionOptions): void;
export function storageBlob<T = unknown>(name: string, options: StorageBlobFunctionOptions<T>): void;

/**
* Registers a function in your app that will be triggered whenever an item is added to a storage queue
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function storageQueue(name: string, options: StorageQueueFunctionOptions): void;
export function storageQueue<T = unknown>(name: string, options: StorageQueueFunctionOptions<T>): void;

/**
* Registers a function in your app that will be triggered whenever a message is added to a service bus queue
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function serviceBusQueue(name: string, options: ServiceBusQueueFunctionOptions): void;
export function serviceBusQueue<T = unknown>(name: string, options: ServiceBusQueueFunctionOptions<T>): void;

/**
* Registers a function in your app that will be triggered whenever a message is added to a service bus topic
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function serviceBusTopic(name: string, options: ServiceBusTopicFunctionOptions): void;
export function serviceBusTopic<T = unknown>(name: string, options: ServiceBusTopicFunctionOptions<T>): void;

/**
* Registers a function in your app that will be triggered whenever a message is added to an event hub
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function eventHub(name: string, options: EventHubFunctionOptions): void;
export function eventHub<T = unknown>(name: string, options: EventHubFunctionOptions<T>): void;

/**
* Registers a function in your app that will be triggered whenever an event is sent by an event grid source
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function eventGrid(name: string, options: EventGridFunctionOptions): void;
export function eventGrid<T = EventGridEvent>(name: string, options: EventGridFunctionOptions<T>): void;

/**
* Registers a Cosmos DB function in your app that will be triggered whenever inserts and updates occur (not deletions)
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function cosmosDB(name: string, options: CosmosDBFunctionOptions): void;
export function cosmosDB<T = unknown>(name: string, options: CosmosDBFunctionOptions<T>): void;

/**
* Registers a function in your app that will be triggered when an instance is added to scale a running function app.
Expand All @@ -173,14 +173,14 @@ export function warmup(name: string, options: WarmupFunctionOptions): void;
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function sql(name: string, options: SqlFunctionOptions): void;
export function sql<T = unknown>(name: string, options: SqlFunctionOptions<T>): void;

/**
* Registers a MySql function in your app that will be triggered when a row is created or updated
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function mySql(name: string, options: MySqlFunctionOptions): void;
export function mySql<T = unknown>(name: string, options: MySqlFunctionOptions<T>): void;

/**
* Registers a generic function in your app that will be triggered based on the type specified in `options.trigger.type`
Expand All @@ -195,8 +195,13 @@ export function generic(name: string, options: GenericFunctionOptions): void;
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function webPubSub(name: string, options: WebPubSubFunctionOptions): void;
export function webPubSub<T = unknown>(name: string, options: WebPubSubFunctionOptions<T>): void;

export function mcpTool(name: string, options: McpToolFunctionOptions): void;
/**
* Registers an MCP Tool function in your app
* @param name The name of the function. The name must be unique within your app and will mostly be used for your own tracking purposes
* @param options Configuration options describing the inputs, outputs, and handler for this function
*/
export function mcpTool<T = unknown>(name: string, options: McpToolFunctionOptions<T>): void;

export * as hook from './hooks/registerHook';
4 changes: 2 additions & 2 deletions types/cosmosDB.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {
CosmosDBv4TriggerOptions,
} from './cosmosDB.v4';

export type CosmosDBHandler = CosmosDBv3Handler | CosmosDBv4Handler;
export type CosmosDBHandler<T = unknown> = CosmosDBv3Handler<T> | CosmosDBv4Handler<T>;

export type CosmosDBFunctionOptions = CosmosDBv3FunctionOptions | CosmosDBv4FunctionOptions;
export type CosmosDBFunctionOptions<T = unknown> = CosmosDBv3FunctionOptions<T> | CosmosDBv4FunctionOptions<T>;

export type CosmosDBInputOptions = CosmosDBv3InputOptions | CosmosDBv4InputOptions;
export type CosmosDBInput = CosmosDBv3Input | CosmosDBv4Input;
Expand Down
6 changes: 3 additions & 3 deletions types/cosmosDB.v3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger, RetryOptions } from './index';
import { InvocationContext } from './InvocationContext';

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

export interface CosmosDBv3FunctionOptions extends CosmosDBv3TriggerOptions, Partial<FunctionOptions> {
handler: CosmosDBv3Handler;
export interface CosmosDBv3FunctionOptions<T = unknown> extends CosmosDBv3TriggerOptions, Partial<FunctionOptions> {
handler: CosmosDBv3Handler<T>;

trigger?: CosmosDBv3Trigger;

Expand Down
6 changes: 3 additions & 3 deletions types/cosmosDB.v4.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger, RetryOptions } from './index';
import { InvocationContext } from './InvocationContext';

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

export interface CosmosDBv4FunctionOptions extends CosmosDBv4TriggerOptions, Partial<FunctionOptions> {
handler: CosmosDBv4Handler;
export interface CosmosDBv4FunctionOptions<T = unknown> extends CosmosDBv4TriggerOptions, Partial<FunctionOptions> {
handler: CosmosDBv4Handler<T>;

trigger?: CosmosDBv4Trigger;

Expand Down
8 changes: 5 additions & 3 deletions types/eventGrid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

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

export interface EventGridFunctionOptions extends EventGridTriggerOptions, Partial<FunctionOptions> {
handler: EventGridHandler;
export interface EventGridFunctionOptions<T = EventGridEvent>
extends EventGridTriggerOptions,
Partial<FunctionOptions> {
handler: EventGridHandler<T>;

trigger?: EventGridTrigger;
}
Expand Down
6 changes: 3 additions & 3 deletions types/eventHub.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger, RetryOptions } from './index';
import { InvocationContext } from './InvocationContext';

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

export interface EventHubFunctionOptions extends EventHubTriggerOptions, Partial<FunctionOptions> {
handler: EventHubHandler;
export interface EventHubFunctionOptions<T = unknown> extends EventHubTriggerOptions, Partial<FunctionOptions> {
handler: EventHubHandler<T>;

trigger?: EventHubTrigger;

Expand Down
6 changes: 3 additions & 3 deletions types/mcpTool.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import { InvocationContext } from './InvocationContext';
* @param context - The invocation context for the function.
* @returns A result that can be a promise or a synchronous value.
*/
export type McpToolTriggerHandler = (messages: unknown, context: InvocationContext) => FunctionResult;
export type McpToolTriggerHandler<T = unknown> = (messages: T, context: InvocationContext) => FunctionResult;

/**
* Configuration options for an MCP Tool function.
* This includes trigger-specific options and general function options.
*/
export interface McpToolFunctionOptions extends McpToolTriggerOptions, Partial<FunctionOptions> {
export interface McpToolFunctionOptions<T = unknown> extends McpToolTriggerOptions, Partial<FunctionOptions> {
/**
* The handler function to execute when the trigger is invoked.
*/
handler: McpToolTriggerHandler;
handler: McpToolTriggerHandler<T>;

/**
* The trigger configuration for the MCP Tool.
Expand Down
10 changes: 5 additions & 5 deletions types/mySql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type MySqlHandler = (changes: MySqlChange[], context: InvocationContext) => FunctionResult;
export type MySqlHandler<T = unknown> = (changes: MySqlChange<T>[], context: InvocationContext) => FunctionResult;

export interface MySqlFunctionOptions extends MySqlTriggerOptions, Partial<FunctionOptions> {
handler: MySqlHandler;
export interface MySqlFunctionOptions<T = unknown> extends MySqlTriggerOptions, Partial<FunctionOptions> {
handler: MySqlHandler<T>;

trigger?: MySqlTrigger;
}
Expand All @@ -25,8 +25,8 @@ export interface MySqlTriggerOptions {
}
export type MySqlTrigger = FunctionTrigger & MySqlTriggerOptions;

export interface MySqlChange {
Item: unknown;
export interface MySqlChange<T = unknown> {
Item: T;
Operation: MySqlChangeOperation;
}

Expand Down
16 changes: 10 additions & 6 deletions types/serviceBus.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type ServiceBusQueueHandler = (messages: unknown | any, context: InvocationContext) => FunctionResult;
export type ServiceBusQueueHandler<T = unknown> = (messages: T, context: InvocationContext) => FunctionResult;

export interface ServiceBusQueueFunctionOptions extends ServiceBusQueueTriggerOptions, Partial<FunctionOptions> {
handler: ServiceBusQueueHandler;
export interface ServiceBusQueueFunctionOptions<T = unknown>
extends ServiceBusQueueTriggerOptions,
Partial<FunctionOptions> {
handler: ServiceBusQueueHandler<T>;

trigger?: ServiceBusQueueTrigger;
}
Expand Down Expand Up @@ -60,10 +62,12 @@ export interface ServiceBusQueueOutputOptions {
}
export type ServiceBusQueueOutput = FunctionOutput & ServiceBusQueueOutputOptions;

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

export interface ServiceBusTopicFunctionOptions extends ServiceBusTopicTriggerOptions, Partial<FunctionOptions> {
handler: ServiceBusTopicHandler;
export interface ServiceBusTopicFunctionOptions<T = unknown>
extends ServiceBusTopicTriggerOptions,
Partial<FunctionOptions> {
handler: ServiceBusTopicHandler<T>;

trigger?: ServiceBusTopicTrigger;
}
Expand Down
10 changes: 5 additions & 5 deletions types/sql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type SqlHandler = (changes: SqlChange[], context: InvocationContext) => FunctionResult;
export type SqlHandler<T = unknown> = (changes: SqlChange<T>[], context: InvocationContext) => FunctionResult;

export interface SqlFunctionOptions extends SqlTriggerOptions, Partial<FunctionOptions> {
handler: SqlHandler;
export interface SqlFunctionOptions<T = unknown> extends SqlTriggerOptions, Partial<FunctionOptions> {
handler: SqlHandler<T>;

trigger?: SqlTrigger;
}
Expand All @@ -25,8 +25,8 @@ export interface SqlTriggerOptions {
}
export type SqlTrigger = FunctionTrigger & SqlTriggerOptions;

export interface SqlChange {
Item: unknown;
export interface SqlChange<T = unknown> {
Item: T;
Operation: SqlChangeOperation;
}

Expand Down
12 changes: 6 additions & 6 deletions types/storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

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

export interface StorageBlobFunctionOptions extends StorageBlobTriggerOptions, Partial<FunctionOptions> {
handler: StorageBlobHandler;
export interface StorageBlobFunctionOptions<T = unknown> extends StorageBlobTriggerOptions, Partial<FunctionOptions> {
handler: StorageBlobHandler<T>;

trigger?: StorageBlobTrigger;
}

export interface StorageQueueFunctionOptions extends StorageQueueTriggerOptions, Partial<FunctionOptions> {
handler: StorageQueueHandler;
export interface StorageQueueFunctionOptions<T = unknown> extends StorageQueueTriggerOptions, Partial<FunctionOptions> {
handler: StorageQueueHandler<T>;

trigger?: StorageQueueTrigger;
}
Expand Down
6 changes: 3 additions & 3 deletions types/webpubsub.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index';
import { InvocationContext } from './InvocationContext';

export type WebPubSubHandler = (message: unknown, context: InvocationContext) => FunctionResult;
export type WebPubSubHandler<T = unknown> = (message: T, context: InvocationContext) => FunctionResult;

export interface WebPubSubFunctionOptions extends WebPubSubTriggerOptions, Partial<FunctionOptions> {
handler: WebPubSubHandler;
export interface WebPubSubFunctionOptions<T = unknown> extends WebPubSubTriggerOptions, Partial<FunctionOptions> {
handler: WebPubSubHandler<T>;

trigger?: WebPubSubTrigger;
}
Expand Down
Loading