Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove async suffix for request adapter methods #1087

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/abstractions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/kiota-abstractions",
"version": "1.0.0-preview.43",
"version": "1.0.0-preview.44",
"description": "Core abstractions for kiota generated libraries in TypeScript and JavaScript",
"main": "dist/cjs/src/index.js",
"module": "dist/es/src/index.js",
Expand Down
35 changes: 18 additions & 17 deletions packages/abstractions/src/apiClientProxifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
PrimitiveTypesForDeserialization,
PrimitiveTypesForDeserializationType,
RequestAdapter,
SendMethods,
} from "./requestAdapter";
import type { RequestConfiguration } from "./requestConfiguration";
import {
Expand Down Expand Up @@ -125,53 +126,53 @@ function getRequestConfigurationValue(args: any[]) {
}
return undefined;
}
function sendAsync(
function send(
requestAdapter: RequestAdapter,
requestInfo: RequestInformation,
metadata: RequestMetadata,
) {
switch (metadata.adapterMethodName) {
case "sendAsync":
case "send":
if (!metadata.responseBodyFactory) {
throw new Error("couldn't find response body factory");
}
return requestAdapter.sendAsync(
return requestAdapter.send(
requestInfo,
metadata.responseBodyFactory as ParsableFactory<Parsable>,
metadata.errorMappings,
);
case "sendCollectionAsync":
case "sendCollection":
if (!metadata.responseBodyFactory) {
throw new Error("couldn't find response body factory");
}
return requestAdapter.sendCollectionAsync(
return requestAdapter.sendCollection(
requestInfo,
metadata.responseBodyFactory as ParsableFactory<Parsable>,
metadata.errorMappings,
);
case "sendCollectionOfPrimitiveAsync":
case "sendCollectionOfPrimitive":
if (!metadata.responseBodyFactory) {
throw new Error("couldn't find response body factory");
}
return requestAdapter.sendCollectionOfPrimitiveAsync(
return requestAdapter.sendCollectionOfPrimitive(
requestInfo,
metadata.responseBodyFactory as Exclude<
PrimitiveTypesForDeserialization,
"ArrayBuffer"
>,
metadata.errorMappings,
);
case "sendPrimitiveAsync":
case "sendPrimitive":
if (!metadata.responseBodyFactory) {
throw new Error("couldn't find response body factory");
}
return requestAdapter.sendPrimitiveAsync(
return requestAdapter.sendPrimitive(
requestInfo,
metadata.responseBodyFactory as PrimitiveTypesForDeserialization,
metadata.errorMappings,
);
case "sendNoResponseContentAsync":
return requestAdapter.sendNoResponseContentAsync(
case "sendNoResponseContent":
return requestAdapter.sendNoResponseContent(
requestInfo,
metadata.errorMappings,
);
Expand Down Expand Up @@ -223,7 +224,7 @@ export function apiClientProxifier<T extends object>(
undefined,
requestConfiguration,
);
return sendAsync(requestAdapter, requestInfo, metadata);
return send(requestAdapter, requestInfo, metadata);
};
case "patch":
return (...args: any[]) => {
Expand All @@ -237,7 +238,7 @@ export function apiClientProxifier<T extends object>(
getRequestMediaTypeUserDefinedValue(metadata, args),
getRequestConfigurationValue(args),
);
return sendAsync(requestAdapter, requestInfo, metadata);
return send(requestAdapter, requestInfo, metadata);
};
case "put":
return (...args: any[]) => {
Expand All @@ -251,7 +252,7 @@ export function apiClientProxifier<T extends object>(
getRequestMediaTypeUserDefinedValue(metadata, args),
getRequestConfigurationValue(args),
);
return sendAsync(requestAdapter, requestInfo, metadata);
return send(requestAdapter, requestInfo, metadata);
};
case "delete":
return (...args: any[]) => {
Expand All @@ -265,7 +266,7 @@ export function apiClientProxifier<T extends object>(
getRequestMediaTypeUserDefinedValue(metadata, args),
getRequestConfigurationValue(args),
);
return sendAsync(requestAdapter, requestInfo, metadata);
return send(requestAdapter, requestInfo, metadata);
};
case "post":
return (...args: any[]) => {
Expand All @@ -279,7 +280,7 @@ export function apiClientProxifier<T extends object>(
getRequestMediaTypeUserDefinedValue(metadata, args),
getRequestConfigurationValue(args),
);
return sendAsync(requestAdapter, requestInfo, metadata);
return send(requestAdapter, requestInfo, metadata);
};
case "toGetRequestInformation":
return (
Expand Down Expand Up @@ -405,7 +406,7 @@ export interface RequestMetadata {
requestBodyContentType?: string;
responseBodyContentType?: string;
errorMappings?: ErrorMappings;
adapterMethodName?: keyof RequestAdapter;
adapterMethodName?: SendMethods;
responseBodyFactory?:
| ParsableFactory<Parsable>
| PrimitiveTypesForDeserialization;
Expand Down
2 changes: 1 addition & 1 deletion packages/abstractions/src/nativeResponseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class NativeResponseHandler implements ResponseHandler {
public value?: any;
/** The error mappings for the response to use when deserializing failed responses bodies. Where an error code like 401 applies specifically to that status code, a class code like 4XX applies to all status codes within the range if an the specific error code is not present. */
public errorMappings: ErrorMappings | undefined;
public handleResponseAsync<NativeResponseType, ModelType>(
public handleResponse<NativeResponseType, ModelType>(
response: NativeResponseType,
errorMappings: ErrorMappings | undefined,
): Promise<ModelType> {
Expand Down
20 changes: 14 additions & 6 deletions packages/abstractions/src/requestAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface RequestAdapter {
* @typeParam ModelType the type of the response model to deserialize the response into.
* @return a {@link Promise} with the deserialized response model.
*/
sendAsync<ModelType extends Parsable>(
send<ModelType extends Parsable>(
requestInfo: RequestInformation,
type: ParsableFactory<ModelType>,
errorMappings: ErrorMappings | undefined,
Expand All @@ -37,7 +37,7 @@ export interface RequestAdapter {
* @typeParam ModelType the type of the response model to deserialize the response into.
* @return a {@link Promise} with the deserialized response model collection.
*/
sendCollectionAsync<ModelType extends Parsable>(
sendCollection<ModelType extends Parsable>(
requestInfo: RequestInformation,
type: ParsableFactory<ModelType>,
errorMappings: ErrorMappings | undefined,
Expand All @@ -51,7 +51,7 @@ export interface RequestAdapter {
* @typeParam ResponseType the type of the response model to deserialize the response into.
* @return a {@link Promise} with the deserialized response model collection.
*/
sendCollectionOfPrimitiveAsync<
sendCollectionOfPrimitive<
ResponseType extends Exclude<
PrimitiveTypesForDeserializationType,
ArrayBuffer
Expand All @@ -69,7 +69,7 @@ export interface RequestAdapter {
* @typeParam ResponseType the type of the response model to deserialize the response into.
* @return a {@link Promise} with the deserialized primitive response model.
*/
sendPrimitiveAsync<ResponseType extends PrimitiveTypesForDeserializationType>(
sendPrimitive<ResponseType extends PrimitiveTypesForDeserializationType>(
requestInfo: RequestInformation,
responseType: PrimitiveTypesForDeserialization,
errorMappings: ErrorMappings | undefined,
Expand All @@ -80,7 +80,7 @@ export interface RequestAdapter {
* @param errorMappings the error factories mapping to use in case of a failed request.
* @return a {@link Promise} of void.
*/
sendNoResponseContentAsync(
sendNoResponseContent(
requestInfo: RequestInformation,
errorMappings: ErrorMappings | undefined,
): Promise<void>;
Expand All @@ -99,7 +99,7 @@ export interface RequestAdapter {
* @typeParam T the type of the native request.
* @return a {@link Promise} with the native request.
*/
convertToNativeRequestAsync<T>(requestInfo: RequestInformation): Promise<T>;
convertToNativeRequest<T>(requestInfo: RequestInformation): Promise<T>;
}
export interface ErrorMappings {
_4XX?: ParsableFactory<Parsable>;
Expand Down Expand Up @@ -127,3 +127,11 @@ export type PrimitiveTypesForDeserialization =
| "TimeOnly"
| "Duration"
| "ArrayBuffer";

export type SendMethods = Exclude<
keyof RequestAdapter,
| "enableBackingStore"
| "getSerializationWriterFactory"
| "convertToNativeRequest"
| "baseUrl"
>;
2 changes: 1 addition & 1 deletion packages/abstractions/src/responseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ResponseHandler {
* @typeParam ModelType The type of the response model object.
* @return A {@link Promise} that represents the asynchronous operation and contains the deserialized response.
*/
handleResponseAsync<NativeResponseType, ModelType>(
handleResponse<NativeResponseType, ModelType>(
response: NativeResponseType,
errorMappings: ErrorMappings | undefined,
): Promise<ModelType>;
Expand Down
4 changes: 2 additions & 2 deletions packages/authentication/azure/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/kiota-authentication-azure",
"version": "1.0.0-preview.38",
"version": "1.0.0-preview.39",
"description": "Authentication provider for Kiota using Azure Identity",
"main": "dist/cjs/src/index.js",
"module": "dist/es/src/index.js",
Expand Down Expand Up @@ -30,7 +30,7 @@
"homepage": "https://github.com/microsoft/kiota-typescript#readme",
"dependencies": {
"@azure/core-auth": "^1.5.0",
"@microsoft/kiota-abstractions": "^1.0.0-preview.43",
"@microsoft/kiota-abstractions": "^1.0.0-preview.44",
"@opentelemetry/api": "^1.7.0",
"tslib": "^2.6.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/authentication/spfx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/kiota-authentication-spfx",
"version": "1.0.0-preview.33",
"version": "1.0.0-preview.34",
"description": "Authentication provider for using Kiota in SPFx solutions",
"main": "dist/cjs/src/index.js",
"module": "dist/es/src/index.js",
Expand Down Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://github.com/microsoft/kiota-typescript#readme",
"dependencies": {
"@microsoft/kiota-abstractions": "^1.0.0-preview.43",
"@microsoft/kiota-abstractions": "^1.0.0-preview.44",
"@microsoft/sp-http": "^1.15.2",
"@opentelemetry/api": "^1.7.0",
"tslib": "^2.6.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/http/fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/kiota-http-fetchlibrary",
"version": "1.0.0-preview.42",
"version": "1.0.0-preview.43",
"description": "Kiota request adapter implementation with fetch",
"keywords": [
"Kiota",
Expand Down Expand Up @@ -38,7 +38,7 @@
"test:cjs": "mocha 'dist/cjs/test/common/**/*.js' && mocha 'dist/cjs/test/node/**/*.js'"
},
"dependencies": {
"@microsoft/kiota-abstractions": "^1.0.0-preview.43",
"@microsoft/kiota-abstractions": "^1.0.0-preview.44",
"@opentelemetry/api": "^1.7.0",
"guid-typescript": "^1.0.9",
"node-fetch": "^2.7.0",
Expand Down
Loading
Loading