UNPKG

@azure-utils/durable-functions

Version:
39 lines (37 loc) 1.51 kB
"use strict"; //#region src/durable-webhook.ts /** * Makes an HTTP Request to Azure Functions Durable Task Webhook. * @param path URL path to the Durable Task Webhook API. * @param requestOptions Options for the request. * @returns The HTTP response from the Durable Task Webhook API. */ async function requestAzureFunctionsDurableTaskWebhookOrThrow(path, requestOptions) { const { abortSignal, baseUrl, systemKey, connection, taskHub, body, method, searchParams, headers } = requestOptions; if (!baseUrl) throw new Error("Azure Functions base URL is required."); const urlSearchParams = new URLSearchParams(searchParams); if (systemKey) urlSearchParams.set("code", systemKey); if (taskHub) urlSearchParams.set("taskHub", taskHub); if (connection) urlSearchParams.set("connection", connection); const url = new URL(`/runtime/webhooks/durabletask/${path}`, baseUrl); url.search = urlSearchParams.toString(); const response = await fetch(url, { method, body, headers, signal: abortSignal }); if (!response.ok) { const cause = await response.clone().json().catch(() => {}); throw new Error(`Failed to request Azure Functions Durable Webhook: ${response.status} ${response.statusText}, ${JSON.stringify(cause)}`); } return response; } //#endregion Object.defineProperty(exports, 'requestAzureFunctionsDurableTaskWebhookOrThrow', { enumerable: true, get: function () { return requestAzureFunctionsDurableTaskWebhookOrThrow; } }); //# sourceMappingURL=durable-webhook-B6Juz8w4.cjs.map