Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/kiota-http-fetchlibrary

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/kiota-http-fetchlibrary - npm Package Compare versions

Comparing version 1.0.0-preview.42 to 1.0.0-preview.43

dist/cjs/src/kiotaClientFactory.d.ts

3

dist/cjs/src/browser/index.d.ts

@@ -29,6 +29,7 @@ /**

export * from "../middlewares/telemetryHandler";
export * from "../middlewares/middlewareFactory";
export * from "../middlewares/browser/middlewareFactory";
export * from "../observabilityOptions";
export * from "../utils/headersUtil";
export * from "../utils/fetchDefinitions";
export * from "../kiotaClientFactory";
//# sourceMappingURL=index.d.ts.map

@@ -33,5 +33,6 @@ "use strict";

tslib_1.__exportStar(require("../middlewares/telemetryHandler"), exports);
tslib_1.__exportStar(require("../middlewares/middlewareFactory"), exports);
tslib_1.__exportStar(require("../middlewares/browser/middlewareFactory"), exports);
tslib_1.__exportStar(require("../observabilityOptions"), exports);
tslib_1.__exportStar(require("../utils/headersUtil"), exports);
tslib_1.__exportStar(require("../utils/fetchDefinitions"), exports);
tslib_1.__exportStar(require("../kiotaClientFactory"), exports);

@@ -28,9 +28,9 @@ import { type AuthenticationProvider, type BackingStoreFactory, type DateOnly, type Duration, type ErrorMappings, type Parsable, type ParsableFactory, type ParseNodeFactory, type PrimitiveTypesForDeserialization, type PrimitiveTypesForDeserializationType, type RequestAdapter, type RequestInformation, type SerializationWriterFactory, type TimeOnly } from "@microsoft/kiota-abstractions";

private static readonly responseTypeAttributeKey;
sendCollectionOfPrimitiveAsync: <ResponseType_1 extends string | number | boolean | DateOnly | Date | Duration | TimeOnly>(requestInfo: RequestInformation, responseType: Exclude<PrimitiveTypesForDeserialization, "ArrayBuffer">, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1[] | undefined>;
sendCollectionAsync: <ModelType extends Parsable>(requestInfo: RequestInformation, deserialization: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType[] | undefined>;
sendCollectionOfPrimitive: <ResponseType_1 extends string | number | boolean | DateOnly | Date | Duration | TimeOnly>(requestInfo: RequestInformation, responseType: Exclude<PrimitiveTypesForDeserialization, "ArrayBuffer">, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1[] | undefined>;
sendCollection: <ModelType extends Parsable>(requestInfo: RequestInformation, deserialization: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType[] | undefined>;
private startTracingSpan;
static readonly eventResponseHandlerInvokedKey = "com.microsoft.kiota.response_handler_invoked";
sendAsync: <ModelType extends Parsable>(requestInfo: RequestInformation, deserializer: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType | undefined>;
sendPrimitiveAsync: <ResponseType_1 extends PrimitiveTypesForDeserializationType>(requestInfo: RequestInformation, responseType: PrimitiveTypesForDeserialization, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1 | undefined>;
sendNoResponseContentAsync: (requestInfo: RequestInformation, errorMappings: ErrorMappings | undefined) => Promise<void>;
send: <ModelType extends Parsable>(requestInfo: RequestInformation, deserializer: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType | undefined>;
sendPrimitive: <ResponseType_1 extends PrimitiveTypesForDeserializationType>(requestInfo: RequestInformation, responseType: PrimitiveTypesForDeserialization, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1 | undefined>;
sendNoResponseContent: (requestInfo: RequestInformation, errorMappings: ErrorMappings | undefined) => Promise<void>;
enableBackingStore: (backingStoreFactory?: BackingStoreFactory | undefined) => void;

@@ -54,4 +54,4 @@ private getRootParseNode;

*/
convertToNativeRequestAsync: <T>(requestInfo: RequestInformation) => Promise<T>;
convertToNativeRequest: <T>(requestInfo: RequestInformation) => Promise<T>;
}
//# sourceMappingURL=fetchRequestAdapter.d.ts.map

@@ -47,7 +47,7 @@ "use strict";

};
this.sendCollectionOfPrimitiveAsync = (requestInfo, responseType, errorMappings) => {
this.sendCollectionOfPrimitive = (requestInfo, responseType, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendCollectionOfPrimitiveAsync", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.startTracingSpan(requestInfo, "sendCollectionOfPrimitive", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -58,3 +58,3 @@ const response = yield this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return yield responseHandler.handleResponseAsync(response, errorMappings);
return yield responseHandler.handleResponse(response, errorMappings);
}

@@ -117,7 +117,7 @@ else {

};
this.sendCollectionAsync = (requestInfo, deserialization, errorMappings) => {
this.sendCollection = (requestInfo, deserialization, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendCollectionAsync", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.startTracingSpan(requestInfo, "sendCollection", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -128,3 +128,3 @@ const response = yield this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return yield responseHandler.handleResponseAsync(response, errorMappings);
return yield responseHandler.handleResponse(response, errorMappings);
}

@@ -172,7 +172,7 @@ else {

};
this.sendAsync = (requestInfo, deserializer, errorMappings) => {
this.send = (requestInfo, deserializer, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendAsync", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.startTracingSpan(requestInfo, "send", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -183,3 +183,3 @@ const response = yield this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return yield responseHandler.handleResponseAsync(response, errorMappings);
return yield responseHandler.handleResponse(response, errorMappings);
}

@@ -213,7 +213,7 @@ else {

};
this.sendPrimitiveAsync = (requestInfo, responseType, errorMappings) => {
this.sendPrimitive = (requestInfo, responseType, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendPrimitiveAsync", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.startTracingSpan(requestInfo, "sendPrimitive", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -224,3 +224,3 @@ const response = yield this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return yield responseHandler.handleResponseAsync(response, errorMappings);
return yield responseHandler.handleResponse(response, errorMappings);
}

@@ -289,7 +289,7 @@ else {

};
this.sendNoResponseContentAsync = (requestInfo, errorMappings) => {
this.sendNoResponseContent = (requestInfo, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendNoResponseContentAsync", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.startTracingSpan(requestInfo, "sendNoResponseContent", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
try {

@@ -300,3 +300,3 @@ const response = yield this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return yield responseHandler.handleResponseAsync(response, errorMappings);
return yield responseHandler.handleResponse(response, errorMappings);
}

@@ -521,3 +521,3 @@ try {

*/
this.convertToNativeRequestAsync = (requestInfo) => tslib_1.__awaiter(this, void 0, void 0, function* () {
this.convertToNativeRequest = (requestInfo) => tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!requestInfo) {

@@ -527,3 +527,3 @@ throw new Error("requestInfo cannot be null");

yield this.authenticationProvider.authenticateRequest(requestInfo, undefined);
return this.startTracingSpan(requestInfo, "convertToNativeRequestAsync", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
return this.startTracingSpan(requestInfo, "convertToNativeRequest", (span) => tslib_1.__awaiter(this, void 0, void 0, function* () {
const request = yield this.getRequestFromRequestInformation(requestInfo, span);

@@ -530,0 +530,0 @@ return request;

@@ -12,3 +12,3 @@ "use strict";

const customFetchHandler_1 = require("./middlewares/customFetchHandler");
const middlewareFactory_1 = require("./middlewares/middlewareFactory");
const _1 = require("./");
class HttpClient {

@@ -28,14 +28,10 @@ /**

this.customFetch = customFetch;
// Use default middleware chain if middlewares and custom fetch function are undefined
if (!middlewares.length || !middlewares[0]) {
this.setMiddleware(...middlewareFactory_1.MiddlewareFactory.getDefaultMiddlewareChain(customFetch));
// If no middlewares are provided, use the default ones
middlewares = (middlewares === null || middlewares === void 0 ? void 0 : middlewares.length) && middlewares[0] ? middlewares : _1.MiddlewareFactory.getDefaultMiddlewares(customFetch);
// If a custom fetch function is provided, add a CustomFetchHandler to the end of the middleware chain
if (this.customFetch) {
middlewares.push(new customFetchHandler_1.CustomFetchHandler(customFetch));
}
else {
if (this.customFetch) {
this.setMiddleware(...middlewares, new customFetchHandler_1.CustomFetchHandler(customFetch));
}
else {
this.setMiddleware(...middlewares);
}
}
// Set the middleware chain
this.setMiddleware(...middlewares);
}

@@ -50,7 +46,5 @@ /**

setMiddleware(...middleware) {
middleware.forEach((element, index) => {
if (index < middleware.length - 1) {
element.next = middleware[index + 1];
}
});
for (let i = 0; i < middleware.length - 1; i++) {
middleware[i].next = middleware[i + 1];
}
this.middleware = middleware[0];

@@ -66,11 +60,9 @@ }

return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (this.customFetch && !this.middleware) {
return this.customFetch(url, requestInit);
}
if (this.middleware) {
return yield this.middleware.execute(url, requestInit, requestOptions);
}
else {
throw new Error("Please provide middlewares or a custom fetch function to execute the request");
else if (this.customFetch) {
return this.customFetch(url, requestInit);
}
throw new Error("Please provide middlewares or a custom fetch function to execute the request");
});

@@ -77,0 +69,0 @@ }

@@ -33,2 +33,3 @@ /**

export * from "./utils/fetchDefinitions";
export * from "./kiotaClientFactory";
//# sourceMappingURL=index.d.ts.map

@@ -37,1 +37,2 @@ "use strict";

tslib_1.__exportStar(require("./utils/fetchDefinitions"), exports);
tslib_1.__exportStar(require("./kiotaClientFactory"), exports);

@@ -0,9 +1,3 @@

import { Middleware } from "../middleware";
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import type { Middleware } from "../middleware";
/**
* @class

@@ -19,4 +13,4 @@ * Class containing function(s) related to the middleware pipelines.

*/
static getDefaultMiddlewareChain(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
static getDefaultMiddlewares(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
}
//# sourceMappingURL=middlewareFactory.d.ts.map
"use strict";
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MiddlewareFactory = void 0;
/**
* @module MiddlewareFactory
*/
const customFetchHandler_1 = require("../customFetchHandler");

@@ -29,8 +20,13 @@ const headersInspectionHandler_1 = require("../headersInspectionHandler");

*/
static getDefaultMiddlewareChain(customFetch = fetch) {
static getDefaultMiddlewares(customFetch = fetch) {
// Browsers handles redirection automatically and do not require the redirectionHandler
const middlewareArray = [new retryHandler_1.RetryHandler(), new parametersNameDecodingHandler_1.ParametersNameDecodingHandler(), new userAgentHandler_1.UserAgentHandler(), new headersInspectionHandler_1.HeadersInspectionHandler(), new customFetchHandler_1.CustomFetchHandler(customFetch)];
return middlewareArray;
return [
new retryHandler_1.RetryHandler(),
new parametersNameDecodingHandler_1.ParametersNameDecodingHandler(),
new userAgentHandler_1.UserAgentHandler(),
new headersInspectionHandler_1.HeadersInspectionHandler(),
new customFetchHandler_1.CustomFetchHandler(customFetch)
];
}
}
exports.MiddlewareFactory = MiddlewareFactory;

@@ -0,9 +1,3 @@

import { Middleware } from "./middleware";
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import type { Middleware } from "./middleware";
/**
* @class

@@ -19,4 +13,4 @@ * Class containing function(s) related to the middleware pipelines.

*/
static getDefaultMiddlewareChain(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
static getDefaultMiddlewares(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
}
//# sourceMappingURL=middlewareFactory.d.ts.map
"use strict";
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MiddlewareFactory = void 0;
/**
* @module MiddlewareFactory
*/
const node_fetch_1 = require("node-fetch");
const customFetchHandler_1 = require("./customFetchHandler");

@@ -31,7 +21,13 @@ const headersInspectionHandler_1 = require("./headersInspectionHandler");

*/
static getDefaultMiddlewareChain(customFetch = node_fetch_1.default) {
const middlewareArray = [new retryHandler_1.RetryHandler(), new redirectHandler_1.RedirectHandler(), new parametersNameDecodingHandler_1.ParametersNameDecodingHandler(), new userAgentHandler_1.UserAgentHandler(), new headersInspectionHandler_1.HeadersInspectionHandler(), new customFetchHandler_1.CustomFetchHandler(customFetch)];
return middlewareArray;
static getDefaultMiddlewares(customFetch = fetch) {
return [
new retryHandler_1.RetryHandler(),
new redirectHandler_1.RedirectHandler(),
new parametersNameDecodingHandler_1.ParametersNameDecodingHandler(),
new userAgentHandler_1.UserAgentHandler(),
new headersInspectionHandler_1.HeadersInspectionHandler(),
new customFetchHandler_1.CustomFetchHandler(customFetch)
];
}
}
exports.MiddlewareFactory = MiddlewareFactory;

@@ -29,6 +29,7 @@ /**

export * from "../middlewares/telemetryHandler";
export * from "../middlewares/middlewareFactory";
export * from "../middlewares/browser/middlewareFactory";
export * from "../observabilityOptions";
export * from "../utils/headersUtil";
export * from "../utils/fetchDefinitions";
export * from "../kiotaClientFactory";
//# sourceMappingURL=index.d.ts.map

@@ -30,5 +30,6 @@ /**

export * from "../middlewares/telemetryHandler";
export * from "../middlewares/middlewareFactory";
export * from "../middlewares/browser/middlewareFactory";
export * from "../observabilityOptions";
export * from "../utils/headersUtil";
export * from "../utils/fetchDefinitions";
export * from "../kiotaClientFactory";

@@ -28,9 +28,9 @@ import { type AuthenticationProvider, type BackingStoreFactory, type DateOnly, type Duration, type ErrorMappings, type Parsable, type ParsableFactory, type ParseNodeFactory, type PrimitiveTypesForDeserialization, type PrimitiveTypesForDeserializationType, type RequestAdapter, type RequestInformation, type SerializationWriterFactory, type TimeOnly } from "@microsoft/kiota-abstractions";

private static readonly responseTypeAttributeKey;
sendCollectionOfPrimitiveAsync: <ResponseType_1 extends string | number | boolean | DateOnly | Date | Duration | TimeOnly>(requestInfo: RequestInformation, responseType: Exclude<PrimitiveTypesForDeserialization, "ArrayBuffer">, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1[] | undefined>;
sendCollectionAsync: <ModelType extends Parsable>(requestInfo: RequestInformation, deserialization: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType[] | undefined>;
sendCollectionOfPrimitive: <ResponseType_1 extends string | number | boolean | DateOnly | Date | Duration | TimeOnly>(requestInfo: RequestInformation, responseType: Exclude<PrimitiveTypesForDeserialization, "ArrayBuffer">, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1[] | undefined>;
sendCollection: <ModelType extends Parsable>(requestInfo: RequestInformation, deserialization: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType[] | undefined>;
private startTracingSpan;
static readonly eventResponseHandlerInvokedKey = "com.microsoft.kiota.response_handler_invoked";
sendAsync: <ModelType extends Parsable>(requestInfo: RequestInformation, deserializer: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType | undefined>;
sendPrimitiveAsync: <ResponseType_1 extends PrimitiveTypesForDeserializationType>(requestInfo: RequestInformation, responseType: PrimitiveTypesForDeserialization, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1 | undefined>;
sendNoResponseContentAsync: (requestInfo: RequestInformation, errorMappings: ErrorMappings | undefined) => Promise<void>;
send: <ModelType extends Parsable>(requestInfo: RequestInformation, deserializer: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined) => Promise<ModelType | undefined>;
sendPrimitive: <ResponseType_1 extends PrimitiveTypesForDeserializationType>(requestInfo: RequestInformation, responseType: PrimitiveTypesForDeserialization, errorMappings: ErrorMappings | undefined) => Promise<ResponseType_1 | undefined>;
sendNoResponseContent: (requestInfo: RequestInformation, errorMappings: ErrorMappings | undefined) => Promise<void>;
enableBackingStore: (backingStoreFactory?: BackingStoreFactory | undefined) => void;

@@ -54,4 +54,4 @@ private getRootParseNode;

*/
convertToNativeRequestAsync: <T>(requestInfo: RequestInformation) => Promise<T>;
convertToNativeRequest: <T>(requestInfo: RequestInformation) => Promise<T>;
}
//# sourceMappingURL=fetchRequestAdapter.d.ts.map

@@ -43,7 +43,7 @@ import { BackingStoreFactorySingleton, DefaultApiError, enableBackingStoreForParseNodeFactory, enableBackingStoreForSerializationWriterFactory, ParseNodeFactoryRegistry, ResponseHandlerOptionKey, SerializationWriterFactoryRegistry } from "@microsoft/kiota-abstractions";

};
this.sendCollectionOfPrimitiveAsync = (requestInfo, responseType, errorMappings) => {
this.sendCollectionOfPrimitive = (requestInfo, responseType, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendCollectionOfPrimitiveAsync", async (span) => {
return this.startTracingSpan(requestInfo, "sendCollectionOfPrimitive", async (span) => {
try {

@@ -54,3 +54,3 @@ const response = await this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return await responseHandler.handleResponseAsync(response, errorMappings);
return await responseHandler.handleResponse(response, errorMappings);
}

@@ -113,7 +113,7 @@ else {

};
this.sendCollectionAsync = (requestInfo, deserialization, errorMappings) => {
this.sendCollection = (requestInfo, deserialization, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendCollectionAsync", async (span) => {
return this.startTracingSpan(requestInfo, "sendCollection", async (span) => {
try {

@@ -124,3 +124,3 @@ const response = await this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return await responseHandler.handleResponseAsync(response, errorMappings);
return await responseHandler.handleResponse(response, errorMappings);
}

@@ -168,7 +168,7 @@ else {

};
this.sendAsync = (requestInfo, deserializer, errorMappings) => {
this.send = (requestInfo, deserializer, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendAsync", async (span) => {
return this.startTracingSpan(requestInfo, "send", async (span) => {
try {

@@ -179,3 +179,3 @@ const response = await this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return await responseHandler.handleResponseAsync(response, errorMappings);
return await responseHandler.handleResponse(response, errorMappings);
}

@@ -209,7 +209,7 @@ else {

};
this.sendPrimitiveAsync = (requestInfo, responseType, errorMappings) => {
this.sendPrimitive = (requestInfo, responseType, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendPrimitiveAsync", async (span) => {
return this.startTracingSpan(requestInfo, "sendPrimitive", async (span) => {
try {

@@ -220,3 +220,3 @@ const response = await this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return await responseHandler.handleResponseAsync(response, errorMappings);
return await responseHandler.handleResponse(response, errorMappings);
}

@@ -285,7 +285,7 @@ else {

};
this.sendNoResponseContentAsync = (requestInfo, errorMappings) => {
this.sendNoResponseContent = (requestInfo, errorMappings) => {
if (!requestInfo) {
throw new Error("requestInfo cannot be null");
}
return this.startTracingSpan(requestInfo, "sendNoResponseContentAsync", async (span) => {
return this.startTracingSpan(requestInfo, "sendNoResponseContent", async (span) => {
try {

@@ -296,3 +296,3 @@ const response = await this.getHttpResponseMessage(requestInfo, span);

span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
return await responseHandler.handleResponseAsync(response, errorMappings);
return await responseHandler.handleResponse(response, errorMappings);
}

@@ -517,3 +517,3 @@ try {

*/
this.convertToNativeRequestAsync = async (requestInfo) => {
this.convertToNativeRequest = async (requestInfo) => {
if (!requestInfo) {

@@ -523,3 +523,3 @@ throw new Error("requestInfo cannot be null");

await this.authenticationProvider.authenticateRequest(requestInfo, undefined);
return this.startTracingSpan(requestInfo, "convertToNativeRequestAsync", async (span) => {
return this.startTracingSpan(requestInfo, "convertToNativeRequest", async (span) => {
const request = await this.getRequestFromRequestInformation(requestInfo, span);

@@ -526,0 +526,0 @@ return request;

@@ -8,3 +8,3 @@ /**

import { CustomFetchHandler } from "./middlewares/customFetchHandler";
import { MiddlewareFactory } from "./middlewares/middlewareFactory";
import { MiddlewareFactory } from "./";
export class HttpClient {

@@ -24,14 +24,10 @@ /**

this.customFetch = customFetch;
// Use default middleware chain if middlewares and custom fetch function are undefined
if (!middlewares.length || !middlewares[0]) {
this.setMiddleware(...MiddlewareFactory.getDefaultMiddlewareChain(customFetch));
// If no middlewares are provided, use the default ones
middlewares = (middlewares === null || middlewares === void 0 ? void 0 : middlewares.length) && middlewares[0] ? middlewares : MiddlewareFactory.getDefaultMiddlewares(customFetch);
// If a custom fetch function is provided, add a CustomFetchHandler to the end of the middleware chain
if (this.customFetch) {
middlewares.push(new CustomFetchHandler(customFetch));
}
else {
if (this.customFetch) {
this.setMiddleware(...middlewares, new CustomFetchHandler(customFetch));
}
else {
this.setMiddleware(...middlewares);
}
}
// Set the middleware chain
this.setMiddleware(...middlewares);
}

@@ -46,7 +42,5 @@ /**

setMiddleware(...middleware) {
middleware.forEach((element, index) => {
if (index < middleware.length - 1) {
element.next = middleware[index + 1];
}
});
for (let i = 0; i < middleware.length - 1; i++) {
middleware[i].next = middleware[i + 1];
}
this.middleware = middleware[0];

@@ -61,12 +55,10 @@ }

async executeFetch(url, requestInit, requestOptions) {
if (this.customFetch && !this.middleware) {
return this.customFetch(url, requestInit);
}
if (this.middleware) {
return await this.middleware.execute(url, requestInit, requestOptions);
}
else {
throw new Error("Please provide middlewares or a custom fetch function to execute the request");
else if (this.customFetch) {
return this.customFetch(url, requestInit);
}
throw new Error("Please provide middlewares or a custom fetch function to execute the request");
}
}

@@ -33,2 +33,3 @@ /**

export * from "./utils/fetchDefinitions";
export * from "./kiotaClientFactory";
//# sourceMappingURL=index.d.ts.map

@@ -34,1 +34,2 @@ /**

export * from "./utils/fetchDefinitions";
export * from "./kiotaClientFactory";

@@ -0,9 +1,3 @@

import { Middleware } from "../middleware";
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import type { Middleware } from "../middleware";
/**
* @class

@@ -19,4 +13,4 @@ * Class containing function(s) related to the middleware pipelines.

*/
static getDefaultMiddlewareChain(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
static getDefaultMiddlewares(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
}
//# sourceMappingURL=middlewareFactory.d.ts.map

@@ -1,10 +0,1 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
/**
* @module MiddlewareFactory
*/
import { CustomFetchHandler } from "../customFetchHandler";

@@ -26,7 +17,12 @@ import { HeadersInspectionHandler } from "../headersInspectionHandler";

*/
static getDefaultMiddlewareChain(customFetch = fetch) {
static getDefaultMiddlewares(customFetch = fetch) {
// Browsers handles redirection automatically and do not require the redirectionHandler
const middlewareArray = [new RetryHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(), new HeadersInspectionHandler(), new CustomFetchHandler(customFetch)];
return middlewareArray;
return [
new RetryHandler(),
new ParametersNameDecodingHandler(),
new UserAgentHandler(),
new HeadersInspectionHandler(),
new CustomFetchHandler(customFetch)
];
}
}

@@ -0,9 +1,3 @@

import { Middleware } from "./middleware";
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
import type { Middleware } from "./middleware";
/**
* @class

@@ -19,4 +13,4 @@ * Class containing function(s) related to the middleware pipelines.

*/
static getDefaultMiddlewareChain(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
static getDefaultMiddlewares(customFetch?: (request: string, init: RequestInit) => Promise<Response>): Middleware[];
}
//# sourceMappingURL=middlewareFactory.d.ts.map

@@ -1,11 +0,1 @@

/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
/**
* @module MiddlewareFactory
*/
import fetch from "node-fetch";
import { CustomFetchHandler } from "./customFetchHandler";

@@ -28,6 +18,12 @@ import { HeadersInspectionHandler } from "./headersInspectionHandler";

*/
static getDefaultMiddlewareChain(customFetch = fetch) {
const middlewareArray = [new RetryHandler(), new RedirectHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(), new HeadersInspectionHandler(), new CustomFetchHandler(customFetch)];
return middlewareArray;
static getDefaultMiddlewares(customFetch = fetch) {
return [
new RetryHandler(),
new RedirectHandler(),
new ParametersNameDecodingHandler(),
new UserAgentHandler(),
new HeadersInspectionHandler(),
new CustomFetchHandler(customFetch)
];
}
}
{
"name": "@microsoft/kiota-http-fetchlibrary",
"version": "1.0.0-preview.42",
"version": "1.0.0-preview.43",
"description": "Kiota request adapter implementation with fetch",

@@ -41,3 +41,3 @@ "keywords": [

"dependencies": {
"@microsoft/kiota-abstractions": "^1.0.0-preview.43",
"@microsoft/kiota-abstractions": "^1.0.0-preview.44",
"@opentelemetry/api": "^1.7.0",

@@ -51,3 +51,3 @@ "guid-typescript": "^1.0.9",

},
"gitHead": "dd167e6041af0c44387672076ebb3a1c0079edc2"
"gitHead": "98776bbe189b55218a14ba4759d0a3acd93297d8"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc