UNPKG

@microsoft/agents-m365copilot-core

Version:

Core functionalities for the Microsoft Agents M365 Copilot JavaScript SDK

40 lines 2.48 kB
import { AgentsM365CopilotHttpClient } from "./agentsM365CopilotHttpClient"; import { getDefaultMiddlewares } from "../middleware/index.js"; /** * Creates an instance of `AgentsM365CopilotHttpClient`, with the provided middlewares and custom fetch implementation both parameters are optional. * if no middlewares are provided, the default middlewares will be used. * @param {AgentsM365CopilotTelemetryOption} telemetryOption - The telemetry options for the Agents M365 Copilot client. * @param {(request: string, init: RequestInit) => Promise<Response>} customFetch - The custom fetch function to use for HTTP requests. * @param {BaseBearerTokenAuthenticationProvider} [authenticationProvider] - Optional authentication provider for bearer token. * @param {Middleware[]} [middlewares] - Optional array of middleware to use in the HTTP pipeline. * @returns {AgentsM365CopilotHttpClient} - A new instance of `AgentsM365CopilotHttpClient`. * @example * ```Typescript * // Example usage of createAgentsM365CopilotClient method with agentsM365CopilotTelemetryOption , customFetch and middlewares parameters provided * createAgentsM365CopilotClient(agentsM365CopilotTelemetryOption, customFetch, [middleware1, middleware2]); * ``` * @example * ```Typescript * // Example usage of createAgentsM365CopilotClient method with only agentsM365CopilotTelemetryOption and customFetch parameter provided * createAgentsM365CopilotClient(agentsM365CopilotTelemetryOption, customFetch); * ``` * @example * ```Typescript * // Example usage of createAgentsM365CopilotClient method with only agentsM365CopilotTelemetryOption and middlewares parameter provided * createAgentsM365CopilotClient(agentsM365CopilotTelemetryOption, undefined, [middleware1, middleware2]); * ``` * @example * ```Typescript * // Example usage of createAgentsM365CopilotClient method with only agentsM365CopilotTelemetryOption parameter provided * createAgentsM365CopilotClient(agentsM365CopilotTelemetryOption); * ``` */ export const createAgentsM365CopilotClient = (agentsM365CopilotTelemetryOption, customFetch, authenticationProvider, middlewares) => { const middleware = middlewares || getDefaultMiddlewares({ customFetch, agentsM365CopilotTelemetryOption, }, authenticationProvider); return new AgentsM365CopilotHttpClient(agentsM365CopilotTelemetryOption, customFetch, ...middleware); }; //# sourceMappingURL=agentsM365CopilotClientFactory.js.map