@microsoft/agents-m365copilot-core
Version:
Core functionalities for the Microsoft Agents M365 Copilot JavaScript SDK
23 lines • 1.3 kB
JavaScript
import { MiddlewareFactory, UrlReplaceHandler, UrlReplaceHandlerOptions, AuthorizationHandler, } from "@microsoft/kiota-http-fetchlibrary";
import { AgentsM365CopilotTelemetryHandler } from "./agentsM365CopilotTelemetryHandler";
import { defaultUrlReplacementPairs } from "../utils/Constants.js";
export const getDefaultMiddlewares = (options = { customFetch: fetch }, authenticationProvider) => {
let kiotaChain = MiddlewareFactory.getDefaultMiddlewares(options === null || options === void 0 ? void 0 : options.customFetch);
if (authenticationProvider) {
kiotaChain.unshift(new AuthorizationHandler(authenticationProvider));
}
const additionalMiddleware = [
new UrlReplaceHandler(new UrlReplaceHandlerOptions({
enabled: true,
urlReplacements: defaultUrlReplacementPairs,
})),
];
if (options.agentsM365CopilotTelemetryOption) {
additionalMiddleware.push(new AgentsM365CopilotTelemetryHandler(options.agentsM365CopilotTelemetryOption));
}
const fetchMiddleware = kiotaChain.slice(-1);
const otherMiddlewares = kiotaChain.slice(0, kiotaChain.length - 1);
kiotaChain = [...otherMiddlewares, ...additionalMiddleware, ...fetchMiddleware];
return kiotaChain;
};
//# sourceMappingURL=MiddlewareFactory.js.map