@azure-utils/durable-functions
Version:
Utilities for Azure Durable functions.
98 lines (97 loc) • 4.1 kB
TypeScript
/**
* @module
* Helper utils to interact with Azure Functions Entities.
*/
import { type RequestAzureFunctionsDurableTaskWebhookOptions } from "./durable-webhook.js";
/**
* An object that contains all the functions for interacting with Azure Functions Durable Entity.
*
* @throws Each method can throw an error if the operation fails.
*/
export declare const durableEntities: {
/** Query and list Azure Functions Entity Instances. */
list: typeof listAzureFunctionsEntitiesOrThrow;
/** Gets the state of the specified entity. */
getState: typeof getAzureFunctionsEntityStateOrThrow;
/** Sends a one-way operation message to a Durable Entity. */
signal: typeof signalAzureFunctionsEntityOrThrow;
};
/**
* Options for the `signalAzureFunctionsEntityOrThrow` function.
*/
export type SignalAzureFunctionsEntityOptions = {
/** The name (type) of the entity. */
entityName: string;
/** The key (unique ID) of the entity. */
entityKey: string;
/** Optional. The name of the user-defined operation to invoke. */
operationName?: string;
/** The JSON-formatted event payload. */
operationInput?: unknown;
};
/**
* Sends a one-way operation message to a Durable Entity. If the entity doesn't exist, it will be created automatically.
*/
export declare function signalAzureFunctionsEntityOrThrow(options: SignalAzureFunctionsEntityOptions, requestOptions: RequestAzureFunctionsDurableTaskWebhookOptions): Promise<void>;
/**
* Options for the `getAzureFunctionsEntityOrThrow` function.
*/
export type GetAzureFunctionsEntityOptions = {
/** The name (type) of the entity. */
entityName: string;
/** The key (unique ID) of the entity. */
entityKey: string;
};
/**
* Gets the state of the specified entity.
*/
export declare function getAzureFunctionsEntityStateOrThrow<T = unknown>(options: GetAzureFunctionsEntityOptions, requestOptions: RequestAzureFunctionsDurableTaskWebhookOptions): Promise<T>;
/**
* Options for the `listAzureFunctionsEntitiesOrThrow` function.
*/
export type ListAzureFunctionsEntitiesOptions = {
/** Optional. When specified, filters the list of returned entities by their entity name (case-insensitive). */
entityName?: string;
/** Optional parameter. If set to true, the entity state will be included in the response payload. */
fetchState?: boolean;
/** Optional parameter. When specified, filters the list of returned entities that processed operations after the given ISO8601 timestamp. */
lastOperationTimeFrom?: Date;
/** Optional parameter. When specified, filters the list of returned entities that processed operations before the given ISO8601 timestamp. */
lastOperationTimeTo?: Date;
/** Optional parameter. When specified, limits the number of entities returned by the query. */
top?: number;
/**
* Optional parameter. When specified, the continuation token for the next page of results.
* This token is returned in the response headers of the previous page of results.
*/
continuationToken?: string;
};
/**
* The result of listing Azure Functions Orchestration Instances.
*/
export type ListAzureFunctionsEntitiesResult<T> = {
/** The number of instances returned by the query. */
top: number | null;
/**
* The continuation token for the next page of results.
* This token is returned in the response headers of the previous page of results.
*/
continuationToken: string | null;
/** The list of Azure Functions Entity Instances.*/
instances: AzureFunctionsEntityInstance<T>[];
};
/**
* Query and list Azure Functions Entity Instances.
*/
export declare function listAzureFunctionsEntitiesOrThrow<T = unknown>(options: ListAzureFunctionsEntitiesOptions, requestOptions: RequestAzureFunctionsDurableTaskWebhookOptions): Promise<ListAzureFunctionsEntitiesResult<T>>;
/**
* The Azure Functions Entity Instance.
*/
export type AzureFunctionsEntityInstance<T = unknown> = {
entityId: {
name: string;
key: string;
};
lastOperationTime: string;
state?: T;
};