Repository: Azure/azure-functions-durable-js
Pull request #470 (2023-02-08 03:58:13)

Export class declarations from the `types` directory
Prelude to #458, part of #416. This PR adds class declarations exported from the root of the package (living in the `types` directory), for relevant public-facing classes. Specifically, it exports declarations for the following classes:

* `PurgeHistoryResult`
* `EntityStateResponse`
* `HttpManagementPayload`
* `EntityId`
* `DurableOrchestrationStatus`
* `RetryOptions`
* `ManagedIdentityTokenSource`
* `AggregatedError`
* `DurableError`
* `DummyOrchestrationContext`
* `DummyEntityContext`

Furthermore, it also moves the `OrchestrationRuntimeStatus` enum to the `orchestrationTypes` file.


Patch:
diff --git a/src/aggregatederror.ts b/src/aggregatederror.ts
index 28c7d2d..d5cc3fb 100644
--- a/src/aggregatederror.ts
+++ b/src/aggregatederror.ts
@@ -1,22 +1,9 @@
+import * as types from "./types";
+
 /** @hidden */
 const separator = "-----------------------------------";
 
-/**
- * A specific error thrown when context.df.Task.all() fails. Its message
- * contains an aggregation of all the exceptions that failed. It should follow the
- * below format:
- *
- * context.df.Task.all() encountered the below error messages:
- *
- * Name: DurableError
- * Message: The activity function "ActivityA" failed.
- * StackTrace: <stacktrace>
- * -----------------------------------
- * Name: DurableError
- * Message: The activity function "ActivityB" failed.
- * StackTrace: <stacktrace>
- */
-export class AggregatedError extends Error {
+export class AggregatedError extends Error implements types.AggregatedError {
     public errors: Error[];
 
     constructor(errors: Error[]) {
diff --git a/src/classes.ts b/src/classes.ts
index ab6a60a..0ba8cc3 100644
--- a/src/classes.ts
+++ b/src/classes.ts
@@ -50,9 +50,6 @@ export { OrchestrationClientInputData } from "./orchestrationclientinputdata";
 export { HttpCreationPayload } from "./httpcreationpayload";
 export { HttpManagementPayload } from "./httpmanagementpayload";
 
-export { IHttpRequest } from "./ihttprequest";
-export { IHttpResponse } from "./ihttpresponse";
-
 export { DurableOrchestrationStatus } from "./durableorchestrationstatus";
 export { OrchestrationRuntimeStatus } from "./orchestrationruntimestatus";
 export { PurgeHistoryResult } from "./purgehistoryresult";
diff --git a/src/durableerror.ts b/src/durableerror.ts
index 3f8c205..179b9ea 100644
--- a/src/durableerror.ts
+++ b/src/durableerror.ts
@@ -1,9 +1,6 @@
-/**
- * A specfic error thrown when a scheduled activity or suborchestrator has failed.
- * This error can be checked for via `instanceof` guards to catch only exceptions thrown
- * by the DurableJS library.
- */
-export class DurableError extends Error {
+import * as types from "./types";
+
+export class DurableError extends Error implements types.DurableError {
     constructor(message: string | undefined) {
         super(message);
     }
diff --git a/src/durableorchestrationclient.ts b/src/durableorchestrationclient.ts
index 7a82071..0eb88d0 100644
--- a/src/durableorchestrationclient.ts
+++ b/src/durableorchestrationclient.ts
@@ -16,8 +16,6 @@ import {
     EntityStateResponse,
     HttpCreationPayload,
     HttpManagementPayload,
-    IHttpRequest,
-    IHttpResponse,
     OrchestrationClientInputData,
     OrchestrationRuntimeStatus,
     PurgeHistoryResult,
@@ -175,7 +173,7 @@ export class DurableOrchestrationClient {
      *  containing instance management URLs.
      */
     public createCheckStatusResponse(
-        request: IHttpRequest | HttpRequest | undefined,
+        request: HttpRequest | undefined,
         instanceId: string
     ): HttpResponse {
         const httpManagementPayload = this.getClientResponseLinks(request, instanceId);
@@ -745,7 +743,7 @@ export class DurableOrchestrationClient {
         instanceId: string,
         timeoutInMilliseconds = 10000,
         retryIntervalInMilliseconds = 1000
-    ): Promise<IHttpResponse> {
+    ): Promise<HttpResponse> {
         if (retryIntervalInMilliseconds > timeoutInMilliseconds) {
             throw new Error(
                 `Total timeout ${timeoutInMilliseconds} (ms) should be bigger than retry timeout ${retryIntervalInMilliseconds} (ms)`
@@ -784,19 +782,19 @@ export class DurableOrchestrationClient {
         }
     }
 
-    private createHttpResponse(statusCode: number, body: unknown): IHttpResponse {
+    private createHttpResponse(statusCode: number, body: unknown): HttpResponse {
         const bodyAsJson = JSON.stringify(body);
-        return {
+        return new HttpResponse({
             status: statusCode,
-            body: bodyAsJson,
+            jsonBody: bodyAsJson,
             headers: {
                 "Content-Type": "application/json",
             },
-        };
+        });
     }
 
     private getClientResponseLinks(
-        request: IHttpRequest | HttpRequest | undefined,
+        request: HttpRequest | undefined,
         instanceId: string
     ): HttpManagementPayload {
         const payload = { ...this.clientData.managementUrls };
@@ -806,9 +804,7 @@ export class DurableOrchestrationClient {
                 this.hasValidRequestUrl(request) &&
                 isURL(payload[key], this.urlValidationOptions)
             ) {
-                const requestUrl = new url.URL(
-                    (request as HttpRequest).url || (request as IHttpRequest).http.url
-                );
+                const requestUrl = new url.URL((request as HttpRequest).url);
                 const dataUrl = new url.URL(payload[key]);
                 payload[key] = payload[key].replace(dataUrl.origin, requestUrl.origin);
             }
@@ -819,13 +815,8 @@ export class DurableOrchestrationClient {
         return payload;
     }
 
-    private hasValidRequestUrl(request: IHttpRequest | HttpRequest | undefined): boolean {
-        const isHttpRequest = request !== undefined && (request as HttpRequest).url !== undefined;
-        const isIHttpRequest =
-            request !== undefined && (request as IHttpRequest).http !== undefined;
-        return (
-            isHttpRequest || (isIHttpRequest && (request as IHttpRequest).http.url !== undefined)
-        );
+    private hasValidRequestUrl(request: HttpRequest | undefined): boolean {
+        return request !== undefined && (request as HttpRequest).url !== undefined;
     }
 
     private extractUniqueWebhookOrigins(clientData: OrchestrationClientInputData): string[] {
diff --git a/src/durableorchestrationstatus.ts b/src/durableorchestrationstatus.ts
index 6f4f512..e0b67ab 100644
--- a/src/durableorchestrationstatus.ts
+++ b/src/durableorchestrationstatus.ts
@@ -1,61 +1,17 @@
 import { OrchestrationRuntimeStatus } from "./classes";
+import * as types from "./types";
 
-/**
- * Represents the status of a durable orchestration instance.
- *
- * Can be fetched using [[DurableOrchestrationClient]].[[getStatus]].
- */
-export class DurableOrchestrationStatus {
+export class DurableOrchestrationStatus implements types.DurableOrchestrationStatus {
     /** @hidden */
     constructor(
-        /** The orchestrator function name. */
         public readonly name: string,
-        /**
-         * The unique ID of the instance.
-         *
-         * The instance ID is generated and fixed when the orchestrator
-         * function is scheduled. It can either auto-generated, in which case
-         * it is formatted as a GUID, or it can be user-specified with any
-         * format.
-         */
         public readonly instanceId: string,
-        /**
-         * The time at which the orchestration instance was created.
-         *
-         * If the orchestration instance is in the [[Pending]] status, this
-         * time represents the time at which the orchestration instance was
-         * scheduled.
-         */
         public readonly createdTime: Date,
-        /**
-         * The time at which the orchestration instance last updated its
-         * execution history.
-         */
         public readonly lastUpdatedTime: Date,
-        /**
-         * The input of the orchestration instance.
-         */
         public readonly input: unknown,
-        /**
-         * The output of the orchestration instance.
-         */
         public readonly output: unknown,
-        /**
-         * The runtime status of the orchestration instance.
-         */
         public readonly runtimeStatus: OrchestrationRuntimeStatus,
-        /**
-         * The custom status payload (if any) that was set by
-         * [[DurableOrchestrationClient]].[[setCustomStatus]].
-         */
         public readonly customStatus?: unknown,
-        /**
-         * The execution history of the orchestration instance.
-         *
-         * The history log can be large and is therefore `undefined` by
-         * default. It is populated only when explicitly requested in the call
-         * to [[DurableOrchestrationClient]].[[getStatus]].
-         */
         public readonly history?: Array<unknown>
     ) {}
 }
diff --git a/src/entities/entityid.ts b/src/entities/entityid.ts
index be39d03..96e9239 100644
--- a/src/entities/entityid.ts
+++ b/src/entities/entityid.ts
@@ -1,11 +1,9 @@
 // tslint:disable:member-access
 
 import { Utils } from "../utils";
+import * as types from "../types";
 
-/**
- * A unique identifier for an entity, consisting of entity class and entity key.
- */
-export class EntityId {
+export class EntityId implements types.EntityId {
     /** @hidden */
     static getEntityIdFromSchedulerId(schedulerId: string): EntityId {
         const pos = schedulerId.indexOf("@", 1);
@@ -19,14 +17,9 @@ export class EntityId {
         return `@${entityId.name.toLowerCase()}@${entityId.key}`;
     }
 
-    /**
-     * Create an entity id for an entity.
-     */
     constructor(
         // TODO: consider how to name these fields more accurately without interfering with JSON serialization
-        /** The name of the entity class. */
         public readonly name: string,
-        /** The entity key. Uniquely identifies an entity among all instances of the same class. */
         public readonly key: string
     ) {
         Utils.throwIfEmpty(name, "name");
diff --git a/src/entities/entitystateresponse.ts b/src/entities/entitystateresponse.ts
index 353769f..717ff21 100644
--- a/src/entities/entitystateresponse.ts
+++ b/src/entities/entitystateresponse.ts
@@ -1,12 +1,5 @@
-/**
- * The response returned by [[DurableOrchestrationClient]].[[readEntityState]].
- */
-export class EntityStateResponse<T> {
-    constructor(
-        /** Whether this entity exists or not. */
-        public entityExists: boolean,
+import * as types from "../types";
 
-        /** The current state of the entity, if it exists, or default value otherwise. */
-        public entityState?: T
-    ) {}
+export class EntityStateResponse<T> implements types.EntityStateResponse<T> {
+    constructor(public entityExists: boolean, public entityState?: T) {}
 }
diff --git a/src/httpmanagementpayload.ts b/src/httpmanagementpayload.ts
index 3e6ec0d..e8b981b 100644
--- a/src/httpmanagementpayload.ts
+++ b/src/httpmanagementpayload.ts
@@ -1,23 +1,16 @@
-/**
- * Data structure containing instance management HTTP endpoints.
- */
-export class HttpManagementPayload {
+import * as types from "./types";
+
+export class HttpManagementPayload implements types.HttpManagementPayload {
     /** @hidden */
     [key: string]: string;
 
     /** @hidden */
     constructor(
-        /** The ID of the orchestration instance. */
         public readonly id: string,
-        /** The HTTP GET status query endpoint URL. */
         public readonly statusQueryGetUri: string,
-        /** The HTTP POST external event sending endpoint URL. */
         public readonly sendEventPostUri: string,
-        /** The HTTP POST instance termination endpoint. */
         public readonly terminatePostUri: string,
-        /** The HTTP POST instance rewind endpoint. */
         public readonly rewindPostUri: string,
-        /** The HTTP DELETE purge endpoint. */
         public readonly purgeHistoryDeleteUri: string
     ) {}
 }
diff --git a/src/ihttprequest.ts b/src/ihttprequest.ts
deleted file mode 100644
index 587bfbe..0000000
--- a/src/ihttprequest.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export interface IHttpRequest {
-    http: {
-        url: string;
-    };
-}
diff --git a/src/ihttpresponse.ts b/src/ihttpresponse.ts
deleted file mode 100644
index 47cc082..0000000
--- a/src/ihttpresponse.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export interface IHttpResponse {
-    status: number;
-    body: unknown;
-    headers?: object;
-}
diff --git a/src/orchestrationruntimestatus.ts b/src/orchestrationruntimestatus.ts
index eb1ecb1..f4dbcf5 100644
--- a/src/orchestrationruntimestatus.ts
+++ b/src/orchestrationruntimestatus.ts
@@ -1,41 +1,9 @@
-/**
- * The status of an orchestration instance.
- */
-export enum OrchestrationRuntimeStatus {
-    /**
-     * The orchestration instance has started running.
-     */
-    Running = "Running",
-
-    /**
-     * The orchestration instance has completed normally.
-     */
-    Completed = "Completed",
-
-    /**
-     * The orchestration instance has restarted itself with a new history.
-     * This is a transient state.
-     */
-    ContinuedAsNew = "ContinuedAsNew",
-
-    /**
-     * The orchestration instance failed with an error.
-     */
-    Failed = "Failed",
-
-    /**
-     * The orchestration was canceled gracefully.
-     */
-    Canceled = "Canceled",
-
-    /**
-     * The orchestration instance was stopped abruptly.
-     */
-    Terminated = "Terminated",
-
-    /**
-     * The orchestration instance has been scheduled but has not yet started
-     * running.
-     */
-    Pending = "Pending",
-}
+export enum OrchestrationRuntimeStatus {
+    Running = "Running",
+    Completed = "Completed",
+    ContinuedAsNew = "ContinuedAsNew",
+    Failed = "Failed",
+    Canceled = "Canceled",
+    Terminated = "Terminated",
+    Pending = "Pending",
+}
diff --git a/src/purgehistoryresult.ts b/src/purgehistoryresult.ts
index db4f246..29d5377 100644
--- a/src/purgehistoryresult.ts
+++ b/src/purgehistoryresult.ts
@@ -1,11 +1,5 @@
-/**
- * Class to hold statistics about this execution of purge history.
- */
-export class PurgeHistoryResult {
-    constructor(
-        /**
-         * The number of deleted instances.
-         */
-        public readonly instancesDeleted: number
-    ) {}
+import * as types from "./types";
+
+export class PurgeHistoryResult implements types.PurgeHistoryResult {
+    constructor(public readonly instancesDeleted: number) {}
 }
diff --git a/src/retryoptions.ts b/src/retryoptions.ts
index 3863e0d..fdf7a49 100644
--- a/src/retryoptions.ts
+++ b/src/retryoptions.ts
@@ -1,29 +1,13 @@
 import { Utils } from "./utils";
+import * as types from "./types";
 
-/**
- * Defines retry policies that can be passed as parameters to various
- * operations.
- */
-export class RetryOptions {
-    /** Gets or sets the backoff coefficient. */
+export class RetryOptions implements types.RetryOptions {
     public backoffCoefficient: number;
-    /** Gets or sets the max retry interval (ms). */
     public maxRetryIntervalInMilliseconds: number;
-    /** Gets or sets the timeout for retries (ms). */
     public retryTimeoutInMilliseconds: number;
 
-    /**
-     * Creates a new instance of RetryOptions with the supplied first retry and
-     * max attempts.
-     * @param firstRetryIntervalInMilliseconds Must be greater than 0.
-     */
     constructor(
-        /**
-         * Gets or sets the first retry interval (ms). Must be greater than
-         * 0.
-         */
         public readonly firstRetryIntervalInMilliseconds: number,
-        /** Gets or sets the max number of attempts. */
         public readonly maxNumberOfAttempts: number
     ) {
         Utils.throwIfNotNumber(
diff --git a/src/tokensource.ts b/src/tokensource.ts
index 6b29c56..cd0f2a7 100644
--- a/src/tokensource.ts
+++ b/src/tokensource.ts
@@ -1,33 +1,8 @@
-/**
- * Token Source implementation for [Azure Managed Identities](https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview).
- *
- * @example Get a list of Azure Subscriptions by calling the Azure Resource Manager HTTP API.
- * ```javascript
- * const df = require("durable-functions");
- *
- * module.exports = df.orchestrator(function*(context) {
- *     return yield context.df.callHttp(
- *         "GET",
- *         "https://management.azure.com/subscriptions?api-version=2019-06-01",
- *         undefined,
- *         undefined,
- *         df.ManagedIdentityTokenSource("https://management.core.windows.net"));
- * });
- * ```
- */
-export class ManagedIdentityTokenSource {
+import * as types from "./types";
+
+export class ManagedIdentityTokenSource implements types.ManagedIdentityTokenSource {
     /** @hidden */
     public readonly kind: string = "AzureManagedIdentity";
 
-    /**
-     * Returns a `ManagedIdentityTokenSource` object.
-     * @param resource The Azure Active Directory resource identifier of the web API being invoked.
-     */
-    constructor(
-        /**
-         * The Azure Active Directory resource identifier of the web API being invoked.
-         * For example, `https://management.core.windows.net/` or `https://graph.microsoft.com/`.
-         */
-        public readonly resource: string
-    ) {}
+    constructor(public readonly resource: string) {}
 }
diff --git a/src/types/durableClientTypes.ts b/src/types/durableClientTypes.ts
index 0b9e314..ef38b6d 100644
--- a/src/types/durableClientTypes.ts
+++ b/src/types/durableClientTypes.ts
@@ -20,3 +20,49 @@ export interface StartNewOptions {
      */
     input?: unknown;
 }
+
+/**
+ * Class to hold statistics about this execution of purge history.
+ * The return type of DurableClient.purgeHistory()
+ */
+export declare class PurgeHistoryResult {
+    /**
+     * The number of deleted instances.
+     */
+    readonly instancesDeleted: number;
+
+    /**
+     * @param instancesDeleted The number of deleted instances
+     */
+    constructor(instancesDeleted: number);
+}
+
+/**
+ * Data structure containing instance management HTTP endpoints.
+ */
+export declare class HttpManagementPayload {
+    /**
+     * The ID of the orchestration instance.
+     */
+    readonly id: string;
+    /**
+     * The HTTP GET status query endpoint URL.
+     */
+    readonly statusQueryGetUri: string;
+    /**
+     * The HTTP POST external event sending endpoint URL.
+     */
+    readonly sendEventPostUri: string;
+    /**
+     * The HTTP POST instance termination endpoint URL.
+     */
+    readonly terminatePostUri: string;
+    /**
+     * The HTTP POST instance rewind endpoint URL.
+     */
+    readonly rewindPostUri: string;
+    /**
+     * The HTTP DELETE purge endpoint URL.
+     */
+    readonly purgeHistoryDeleteUri: string;
+}
diff --git a/src/types/entityTypes.ts b/src/types/entityTypes.ts
index c2f4bf4..d00369e 100644
--- a/src/types/entityTypes.ts
+++ b/src/types/entityTypes.ts
@@ -1,4 +1,4 @@
-import { FunctionOptions, FunctionTrigger, InvocationContext } from "@azure/functions";
+import { FunctionOptions, FunctionTrigger, InvocationContext, LogHandler } from "@azure/functions";
 import { DurableEntityContext } from "../durableentitycontext";
 
 export type EntityHandler<T> = (context: EntityContext<T>) => void;
@@ -20,3 +20,70 @@ export interface EntityContext<T> extends InvocationContext {
      */
     df: DurableEntityContext<T>;
 }
+
+/**
+ * An entity context with dummy default values to facilitate mocking/stubbing the
+ * Durable Functions API.
+ */
+export declare class DummyEntityContext<T> extends InvocationContext implements EntityContext<T> {
+    /**
+     * Creates a new instance of a dummy entity context.
+     * All parameters are optional but are exposed to enable flexibility
+     * in the testing process.
+     *
+     * @param functionName The name of the entity function
+     * @param invocationId The ID of this particular invocation of the entity function
+     * @param logHandler A handler to emit logs coming from the entity function
+     */
+    constructor(functionName?: string, invocationId?: string, logHandler?: LogHandler);
+
+    df: DurableEntityContext<T>;
+}
+
+/**
+ * A unique identifier for an entity, consisting of entity class and entity key.
+ */
+export declare class EntityId {
+    /**
+     * Create an entity id for an entity.
+     * @param name The name of the entity class.
+     * @param key The entity key. Uniquely identifies an entity among all instances of the same class.
+     * @returns an `EntityId` instance
+     */
+    constructor(name: string, key: string);
+
+    /**
+     * The name of the entity class
+     */
+    readonly name: string;
+    /**
+     * The entity key.
+     * Uniquely identifies an entity among all instances of the same class.
+     */
+    readonly key: string;
+    /*
+     * Serializes the Entity ID into a string
+     */
+    toString(): string;
+}
+
+/**
+ * The response returned by DurableClient.readEntityState().
+ */
+export declare class EntityStateResponse<T> {
+    /**
+     * Whether this entity exists or not.
+     */
+    entityExists: boolean;
+    /**
+     * The current state of the entity, if it exists, or default value otherwise.
+     */
+    entityState?: T;
+
+    /**
+     *
+     * @param entityExists Whether this entity exists or not.
+     * @param entityState The current state of the entity, if it exists, or default value otherwise.
+     */
+    constructor(entityExists: boolean, entityState?: T);
+}
diff --git a/src/types/index.ts b/src/types/index.ts
index e75a58a..211055a 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -1,10 +1,85 @@
-import { ManagedIdentityTokenSource } from "../tokensource";
-
 export * from "./activityTypes";
 export * from "./durableClientTypes";
 export * from "./entityTypes";
 export * from "./orchestrationTypes";
 export * from "./taskTypes";
 
+/**
+ * Token Source implementation for [Azure Managed Identities](https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview).
+ *
+ * @example Get a list of Azure Subscriptions by calling the Azure Resource Manager HTTP API.
+ * ```javascript
+ * const df = require("durable-functions");
+ *
+ * df.app.orchestration(function* (context) {
+ *   return yield context.df.callHttp({
+ *       method: "GET",
+ *       url: "https://management.azure.com/subscriptions?api-version=2019-06-01",
+ *       tokenSource: df.ManagedIdentityTokenSource("https://management.core.windows.net"),
+ *   });
+ * });
+ * ```
+ */
+export declare class ManagedIdentityTokenSource {
+    /**
+     * Returns a `ManagedIdentityTokenSource` object.
+     * @param resource The Azure Active Directory resource identifier of the web API being invoked.
+     */
+    constructor(resource: string);
+
+    /**
+     * The Azure Active Directory resource identifier of the web API being invoked.
+     * For example, `https://management.core.windows.net/` or `https://graph.microsoft.com/`.
+     */
+    readonly resource: string;
+}
+
 // Over time we will likely add more implementations
 export type TokenSource = ManagedIdentityTokenSource;
+
+/**
+ * Defines retry policies that can be passed as parameters to various
+ * operations.
+ */
+export declare class RetryOptions {
+    /**
+     * Creates a new instance of RetryOptions with the supplied first retry and
+     * max attempts.
+     * @param firstRetryIntervalInMilliseconds The first retry interval (ms). Must be greater than 0.
+     * @param maxNumberOfAttempts The maximum number of attempts.
+     */
+    constructor(firstRetryIntervalInMilliseconds: number, maxNumberOfAttempts: number);
+    /**
+     * The retry backoff coefficient
+     */
+    backoffCoefficient: number;
+    /**
+     *  The max retry interval (ms).
+     */
+    maxRetryIntervalInMilliseconds: number;
+    /**
+     * The timeout for retries (ms).
+     */
+    retryTimeoutInMilliseconds: number;
+    /**
+     * The first retry interval (ms). Must be greater than 0.
+     */
+    readonly firstRetryIntervalInMilliseconds: number;
+    /**
+     * The maximum number of attempts.
+     */
+    readonly maxNumberOfAttempts: number;
+}
+
+/**
+ * A specfic error thrown when a scheduled activity or suborchestrator has failed.
+ * This error can be checked for via `instanceof` guards to catch only exceptions thrown
+ * by the DurableJS library.
+ */
+export declare class DurableError extends Error {
+    /**
+     * Constructs a `DurableError` instance.
+     * @param message error message.
+     */
+    constructor(message: string | undefined);
+}
diff --git a/src/types/orchestrationTypes.ts b/src/types/orchestrationTypes.ts
index 9792cc4..ac07b70 100644
--- a/src/types/orchestrationTypes.ts
+++ b/src/types/orchestrationTypes.ts
@@ -1,4 +1,4 @@
-import { FunctionOptions, FunctionTrigger, InvocationContext } from "@azure/functions";
+import { FunctionOptions, FunctionTrigger, InvocationContext, LogHandler } from "@azure/functions";
 import { TokenSource } from ".";
 import { DurableOrchestrationContext } from "../classes";
 
@@ -19,6 +19,26 @@ export interface OrchestrationContext extends InvocationContext {
     df: DurableOrchestrationContext;
 }
 
+/**
+ * An orchestration context with dummy default values to facilitate mocking/stubbing the
+ * Durable Functions API.
+ */
+export declare class DummyOrchestrationContext extends InvocationContext
+    implements OrchestrationContext {
+    /**
+     * Creates a new instance of a dummy orchestration context.
+     * All parameters are optional but are exposed to enable flexibility
+     * in the testing process.
+     *
+     * @param functionName The name of the orchestration function
+     * @param invocationId The ID of this particular invocation of the orchestration
+     * @param logHandler A handler to emit logs coming from the orchestration function
+     */
+    constructor(functionName?: string, invocationId?: string, logHandler?: LogHandler);
+
+    df: DurableOrchestrationContext;
+}
+
 export interface OrchestrationOptions extends Partial<FunctionOptions> {
     handler: OrchestrationHandler;
 }
@@ -65,3 +85,112 @@ export interface CallHttpOptions {
      */
     asynchronousPatternEnabled?: boolean;
 }
+
+/**
+ * Represents the status of a durable orchestration instance.
+ *
+ * Can be fetched using `DurableClient.getStatus()`
+ */
+export declare class DurableOrchestrationStatus {
+    /**
+     * The orchestrator function name.
+     */
+    readonly name: string;
+
+    /**
+     * The unique ID of the instance.
+     *
+     * The instance ID is generated and fixed when the orchestrator
+     * function is scheduled. It can either auto-generated, in which case
+     * it is formatted as a GUID, or it can be user-specified with any
+     * format.
+     */
+    readonly instanceId: string;
+
+    /**
+     * The time at which the orchestration instance was created.
+     *
+     * If the orchestration instance is in the [[Pending]] status, this
+     * time represents the time at which the orchestration instance was
+     * scheduled.
+     */
+    readonly createdTime: Date;
+
+    /**
+     * The time at which the orchestration instance last updated its
+     * execution history.
+     */
+    readonly lastUpdatedTime: Date;
+
+    /**
+     * The input of the orchestration instance.
+     */
+    readonly input: unknown;
+
+    /**
+     * The output of the orchestration instance.
+     */
+    readonly output: unknown;
+
+    /**
+     * The runtime status of the orchestration instance.
+     */
+    readonly runtimeStatus: OrchestrationRuntimeStatus;
+
+    /**
+     * The custom status payload (if any) that was set by
+     * `DurableOrchestrationClient.setCustomStatus()`.
+     */
+    readonly customStatus?: unknown;
+
+    /**
+     * The execution history of the orchestration instance.
+     *
+     * The history log can be large and is therefore `undefined` by
+     * default. It is populated only when explicitly requested in the call
+     * to `DurableOrchestrationClient.getStatus()`.
+     */
+    readonly history?: Array<unknown>;
+}
+
+/**
+ * The status of an orchestration instance.
+ */
+export declare enum OrchestrationRuntimeStatus {
+    /**
+     * The orchestration instance has started running.
+     */
+    Running = "Running",
+
+    /**
+     * The orchestration instance has completed normally.
+     */
+    Completed = "Completed",
+
+    /**
+     * The orchestration instance has restarted itself with a new history.
+     * This is a transient state.
+     */
+    ContinuedAsNew = "ContinuedAsNew",
+
+    /**
+     * The orchestration instance failed with an error.
+     */
+    Failed = "Failed",
+
+    /**
+     * The orchestration was canceled gracefully.
+     */
+    Canceled = "Canceled",
+
+    /**
+     * The orchestration instance was stopped abruptly.
+     */
+    Terminated = "Terminated",
+
+    /**
+     * The orchestration instance has been scheduled but has not yet started
+     * running.
+     */
+    Pending = "Pending",
+}
diff --git a/src/types/taskTypes.ts b/src/types/taskTypes.ts
index c84e548..c3b3246 100644
--- a/src/types/taskTypes.ts
+++ b/src/types/taskTypes.ts
@@ -73,3 +73,31 @@ export interface TimerTask extends Task {
      */
     cancel: () => void;
 }
+
+/**
+ * A specific error thrown when context.df.Task.all() fails. Its message
+ * contains an aggregation of all the exceptions that failed. It should follow the
+ * below format:
+ *
+ * context.df.Task.all() encountered the below error messages:
+ *
+ * Name: DurableError
+ * Message: The activity function "ActivityA" failed.
+ * StackTrace: <stacktrace>
+ * -----------------------------------
+ * Name: DurableError
+ * Message: The activity function "ActivityB" failed.
+ * StackTrace: <stacktrace>
+ */
+export declare class AggregatedError extends Error {
+    /**
+     * The list of errors nested inside this `AggregatedError`
+     */
+    errors: Error[];
+
+    /**
+     * Construct an `AggregatedError` using a list of errors
+     * @param errors List of errors.
+     */
+    constructor(errors: Error[]);
+}


Test patch:
diff --git a/src/testingUtils.ts b/src/testingUtils.ts
index 3f626df..88e1ff2 100644
--- a/src/testingUtils.ts
+++ b/src/testingUtils.ts
@@ -10,21 +10,10 @@ import { ReplaySchema } from "./replaySchema";
 import * as uuidv1 from "uuid/v1";
 import { DurableEntityContext } from "./durableentitycontext";
 import { EntityContext, OrchestrationContext } from "./types";
+import * as types from "./types";
 
-/**
- * An orchestration context with dummy default values to facilitate mocking/stubbing the
- * Durable Functions API.
- */
-export class DummyOrchestrationContext extends InvocationContext implements OrchestrationContext {
-    /**
-     * Creates a new instance of a dummy orchestration context.
-     * All parameters are optional but are exposed to enable flexibility
-     * in the testing process.
-     *
-     * @param functionName The name of the orchestration function
-     * @param invocationId The ID of this particular invocation of the orchestration
-     * @param logHandler A handler to emit logs coming from the orchestration function
-     */
+export class DummyOrchestrationContext extends InvocationContext
+    implements OrchestrationContext, types.DummyOrchestrationContext {
     constructor(
         functionName = "dummyContextFunctionName",
         invocationId: string = uuidv1(),
@@ -92,16 +81,8 @@ export class DurableOrchestrationInput extends DurableOrchestrationBindingInfo {
     }
 }
 
-export class DummyEntityContext<T> extends InvocationContext implements EntityContext<T> {
-    /**
-     * Creates a new instance of a dummy entity context.
-     * All parameters are optional but are exposed to enable flexibility
-     * in the testing process.
-     *
-     * @param functionName The name of the entity function
-     * @param invocationId The ID of this particular invocation of the entity function
-     * @param logHandler A handler to emit logs coming from the entity function
-     */
+export class DummyEntityContext<T> extends InvocationContext
+    implements EntityContext<T>, types.DummyEntityContext<T> {
     constructor(
         functionName = "dummyContextFunctionName",
         invocationId: string = uuidv1(),
diff --git a/test/unit/orchestrationclient-spec.ts b/test/unit/orchestrationclient-spec.ts
index 96066bf..7838a38 100644
--- a/test/unit/orchestrationclient-spec.ts
+++ b/test/unit/orchestrationclient-spec.ts
@@ -90,32 +90,6 @@ describe("Orchestration Client", () => {
             expect(response.headers.get("Retry-After")).to.equal("10");
         });
 
-        it(`returns a proper response object from request.http.url`, async () => {
-            const client = new DurableOrchestrationClient(defaultClientInputData);
-            const requestObj = {
-                http: {
-                    url: defaultRequestUrl,
-                    method: "GET",
-                },
-            };
-
-            const response = client.createCheckStatusResponse(requestObj, defaultInstanceId);
-            const responseBody = await response.json();
-
-            const expectedPayload = TestUtils.createHttpManagementPayload(
-                defaultInstanceId,
-                Constants.DefaultLocalOrigin,
-                defaultTaskHub,
-                defaultConnection
-            );
-
-            expect(response.status).to.equal(202);
-            expect(responseBody).to.deep.equal(expectedPayload);
-            expect(response.headers.get("Content-Type")).to.equal("application/json");
-            expect(response.headers.get("Location")).to.equal(expectedPayload.statusQueryGetUri);
-            expect(response.headers.get("Retry-After")).to.equal("10");
-        });
-
         it("returns a proper response object when request is undefined", async () => {
             const client = new DurableOrchestrationClient(defaultClientInputData);
 
@@ -1160,21 +1134,17 @@ describe("Orchestration Client", () => {
 
             nock(Constants.DefaultLocalOrigin).get(/.*/).reply(202, expectedStatus);
 
-            const expectedResponse = {
-                status: 200,
-                body: JSON.stringify(expectedOutput),
-                headers: {
-                    "Content-Type": "application/json",
-                },
-            };
-
             const res = await client.waitForCompletionOrCreateCheckStatusResponse(
                 defaultRequest,
                 defaultInstanceId,
                 defaultTimeout,
                 defaultInterval
             );
-            expect(res).to.be.deep.equal(expectedResponse);
+
+            const body = await res.json();
+            expect(res.status).to.equal(200);
+            expect(body).to.equal(JSON.stringify(expectedOutput));
+            expect(res.headers.get("Content-Type")).to.equal("application/json");
         });
 
         it("returns expected result for canceled instance", async () => {
@@ -1193,13 +1163,6 @@ describe("Orchestration Client", () => {
             nock(Constants.DefaultLocalOrigin).get(/.*/).reply(202, expectedStatus);
 
             const expectedStatusAsJson = JSON.stringify(expectedStatus);
-            const expectedResponse = {
-                status: 200,
-                body: expectedStatusAsJson,
-                headers: {
-                    "Content-Type": "application/json",
-                },
-            };
 
             const res = await client.waitForCompletionOrCreateCheckStatusResponse(
                 defaultRequest,
@@ -1207,7 +1170,11 @@ describe("Orchestration Client", () => {
                 defaultTimeout,
                 defaultInterval
             );
-            expect(res).to.be.deep.equal(expectedResponse);
+
+            const body = await res.json();
+            expect(res.status).to.equal(200);
+            expect(body).to.equal(expectedStatusAsJson);
+            expect(res.headers.get("Content-Type")).to.equal("application/json");
         });
 
         it("returns expected result for terminated instance", async () => {
@@ -1226,13 +1193,6 @@ describe("Orchestration Client", () => {
             nock(Constants.DefaultLocalOrigin).get(/.*/).reply(202, expectedStatus);
 
             const expectedStatusAsJson = JSON.stringify(expectedStatus);
-            const expectedResponse = {
-                status: 200,
-                body: expectedStatusAsJson,
-                headers: {
-                    "Content-Type": "application/json",
-                },
-            };
 
             const res = await client.waitForCompletionOrCreateCheckStatusResponse(
                 defaultRequest,
@@ -1240,7 +1200,11 @@ describe("Orchestration Client", () => {
                 defaultTimeout,
                 defaultInterval
             );
-            expect(res).to.be.deep.equal(expectedResponse);
+
+            const body = await res.json();
+            expect(res.status).to.equal(200);
+            expect(body).to.equal(expectedStatusAsJson);
+            expect(res.headers.get("Content-Type")).to.equal("application/json");
         });
 
         it("returns expected result for failed instance", async () => {
@@ -1259,13 +1223,6 @@ describe("Orchestration Client", () => {
             nock(Constants.DefaultLocalOrigin).get(/.*/).reply(202, expectedStatus);
 
             const expectedStatusAsJson = JSON.stringify(expectedStatus);
-            const expectedResponse = {
-                status: 500,
-                body: expectedStatusAsJson,
-                headers: {
-                    "Content-Type": "application/json",
-                },
-            };
 
             const res = await client.waitForCompletionOrCreateCheckStatusResponse(
                 defaultRequest,
@@ -1273,7 +1230,11 @@ describe("Orchestration Client", () => {
                 defaultTimeout,
                 defaultInterval
             );
-            expect(res).to.be.deep.equal(expectedResponse);
+
+            const body = await res.json();
+            expect(res.status).to.equal(500);
+            expect(body).to.equal(expectedStatusAsJson);
+            expect(res.headers.get("Content-Type")).to.equal("application/json");
         });
 
         it("continues polling for running instance", async () => {
@@ -1318,21 +1279,17 @@ describe("Orchestration Client", () => {
                     "Content-Type": "application/json",
                 });
 
-            const expectedResponse = {
-                status: 200,
-                body: JSON.stringify(expectedOutput),
-                headers: {
-                    "Content-Type": "application/json",
-                },
-            };
-
             const res = await client.waitForCompletionOrCreateCheckStatusResponse(
                 defaultRequest,
                 defaultInstanceId,
                 defaultTimeout,
                 defaultInterval
             );
-            expect(res).to.be.deep.equal(expectedResponse);
+
+            const body = await res.json();
+            expect(res.status).to.equal(200);
+            expect(body).to.equal(JSON.stringify(expectedOutput));
+            expect(res.headers.get("Content-Type")).to.equal("application/json");
             expect(scope.isDone()).to.be.equal(true);
         });