Skip to content

Commit 6e0a8b8

Browse files
committed
remove async suffix for request adapter methods
1 parent 0082880 commit 6e0a8b8

File tree

53 files changed

+219
-171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+219
-171
lines changed

packages/abstractions/src/apiClientProxifier.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -125,53 +125,53 @@ function getRequestConfigurationValue(args: any[]) {
125125
}
126126
return undefined;
127127
}
128-
function sendAsync(
128+
function send(
129129
requestAdapter: RequestAdapter,
130130
requestInfo: RequestInformation,
131131
metadata: RequestMetadata,
132132
) {
133133
switch (metadata.adapterMethodName) {
134-
case "sendAsync":
134+
case "send":
135135
if (!metadata.responseBodyFactory) {
136136
throw new Error("couldn't find response body factory");
137137
}
138-
return requestAdapter.sendAsync(
138+
return requestAdapter.send(
139139
requestInfo,
140140
metadata.responseBodyFactory as ParsableFactory<Parsable>,
141141
metadata.errorMappings,
142142
);
143-
case "sendCollectionAsync":
143+
case "sendCollection":
144144
if (!metadata.responseBodyFactory) {
145145
throw new Error("couldn't find response body factory");
146146
}
147-
return requestAdapter.sendCollectionAsync(
147+
return requestAdapter.sendCollection(
148148
requestInfo,
149149
metadata.responseBodyFactory as ParsableFactory<Parsable>,
150150
metadata.errorMappings,
151151
);
152-
case "sendCollectionOfPrimitiveAsync":
152+
case "sendCollectionOfPrimitive":
153153
if (!metadata.responseBodyFactory) {
154154
throw new Error("couldn't find response body factory");
155155
}
156-
return requestAdapter.sendCollectionOfPrimitiveAsync(
156+
return requestAdapter.sendCollectionOfPrimitive(
157157
requestInfo,
158158
metadata.responseBodyFactory as Exclude<
159159
PrimitiveTypesForDeserialization,
160160
"ArrayBuffer"
161161
>,
162162
metadata.errorMappings,
163163
);
164-
case "sendPrimitiveAsync":
164+
case "sendPrimitive":
165165
if (!metadata.responseBodyFactory) {
166166
throw new Error("couldn't find response body factory");
167167
}
168-
return requestAdapter.sendPrimitiveAsync(
168+
return requestAdapter.sendPrimitive(
169169
requestInfo,
170170
metadata.responseBodyFactory as PrimitiveTypesForDeserialization,
171171
metadata.errorMappings,
172172
);
173-
case "sendNoResponseContentAsync":
174-
return requestAdapter.sendNoResponseContentAsync(
173+
case "sendNoResponseContent":
174+
return requestAdapter.sendNoResponseContent(
175175
requestInfo,
176176
metadata.errorMappings,
177177
);
@@ -223,7 +223,7 @@ export function apiClientProxifier<T extends object>(
223223
undefined,
224224
requestConfiguration,
225225
);
226-
return sendAsync(requestAdapter, requestInfo, metadata);
226+
return send(requestAdapter, requestInfo, metadata);
227227
};
228228
case "patch":
229229
return (...args: any[]) => {
@@ -237,7 +237,7 @@ export function apiClientProxifier<T extends object>(
237237
getRequestMediaTypeUserDefinedValue(metadata, args),
238238
getRequestConfigurationValue(args),
239239
);
240-
return sendAsync(requestAdapter, requestInfo, metadata);
240+
return send(requestAdapter, requestInfo, metadata);
241241
};
242242
case "put":
243243
return (...args: any[]) => {
@@ -251,7 +251,7 @@ export function apiClientProxifier<T extends object>(
251251
getRequestMediaTypeUserDefinedValue(metadata, args),
252252
getRequestConfigurationValue(args),
253253
);
254-
return sendAsync(requestAdapter, requestInfo, metadata);
254+
return send(requestAdapter, requestInfo, metadata);
255255
};
256256
case "delete":
257257
return (...args: any[]) => {
@@ -265,7 +265,7 @@ export function apiClientProxifier<T extends object>(
265265
getRequestMediaTypeUserDefinedValue(metadata, args),
266266
getRequestConfigurationValue(args),
267267
);
268-
return sendAsync(requestAdapter, requestInfo, metadata);
268+
return send(requestAdapter, requestInfo, metadata);
269269
};
270270
case "post":
271271
return (...args: any[]) => {
@@ -279,7 +279,7 @@ export function apiClientProxifier<T extends object>(
279279
getRequestMediaTypeUserDefinedValue(metadata, args),
280280
getRequestConfigurationValue(args),
281281
);
282-
return sendAsync(requestAdapter, requestInfo, metadata);
282+
return send(requestAdapter, requestInfo, metadata);
283283
};
284284
case "toGetRequestInformation":
285285
return (

packages/abstractions/src/nativeResponseHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class NativeResponseHandler implements ResponseHandler {
77
public value?: any;
88
/** 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. */
99
public errorMappings: ErrorMappings | undefined;
10-
public handleResponseAsync<NativeResponseType, ModelType>(
10+
public handleResponse<NativeResponseType, ModelType>(
1111
response: NativeResponseType,
1212
errorMappings: ErrorMappings | undefined,
1313
): Promise<ModelType> {

packages/abstractions/src/requestAdapter.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface RequestAdapter {
2424
* @typeParam ModelType the type of the response model to deserialize the response into.
2525
* @return a {@link Promise} with the deserialized response model.
2626
*/
27-
sendAsync<ModelType extends Parsable>(
27+
send<ModelType extends Parsable>(
2828
requestInfo: RequestInformation,
2929
type: ParsableFactory<ModelType>,
3030
errorMappings: ErrorMappings | undefined,
@@ -37,7 +37,7 @@ export interface RequestAdapter {
3737
* @typeParam ModelType the type of the response model to deserialize the response into.
3838
* @return a {@link Promise} with the deserialized response model collection.
3939
*/
40-
sendCollectionAsync<ModelType extends Parsable>(
40+
sendCollection<ModelType extends Parsable>(
4141
requestInfo: RequestInformation,
4242
type: ParsableFactory<ModelType>,
4343
errorMappings: ErrorMappings | undefined,
@@ -51,7 +51,7 @@ export interface RequestAdapter {
5151
* @typeParam ResponseType the type of the response model to deserialize the response into.
5252
* @return a {@link Promise} with the deserialized response model collection.
5353
*/
54-
sendCollectionOfPrimitiveAsync<
54+
sendCollectionOfPrimitive<
5555
ResponseType extends Exclude<
5656
PrimitiveTypesForDeserializationType,
5757
ArrayBuffer
@@ -69,7 +69,7 @@ export interface RequestAdapter {
6969
* @typeParam ResponseType the type of the response model to deserialize the response into.
7070
* @return a {@link Promise} with the deserialized primitive response model.
7171
*/
72-
sendPrimitiveAsync<ResponseType extends PrimitiveTypesForDeserializationType>(
72+
sendPrimitive<ResponseType extends PrimitiveTypesForDeserializationType>(
7373
requestInfo: RequestInformation,
7474
responseType: PrimitiveTypesForDeserialization,
7575
errorMappings: ErrorMappings | undefined,
@@ -80,7 +80,7 @@ export interface RequestAdapter {
8080
* @param errorMappings the error factories mapping to use in case of a failed request.
8181
* @return a {@link Promise} of void.
8282
*/
83-
sendNoResponseContentAsync(
83+
sendNoResponseContent(
8484
requestInfo: RequestInformation,
8585
errorMappings: ErrorMappings | undefined,
8686
): Promise<void>;
@@ -99,7 +99,7 @@ export interface RequestAdapter {
9999
* @typeParam T the type of the native request.
100100
* @return a {@link Promise} with the native request.
101101
*/
102-
convertToNativeRequestAsync<T>(requestInfo: RequestInformation): Promise<T>;
102+
convertToNativeRequest<T>(requestInfo: RequestInformation): Promise<T>;
103103
}
104104
export interface ErrorMappings {
105105
_4XX?: ParsableFactory<Parsable>;

packages/abstractions/src/responseHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface ResponseHandler {
1010
* @typeParam ModelType The type of the response model object.
1111
* @return A {@link Promise} that represents the asynchronous operation and contains the deserialized response.
1212
*/
13-
handleResponseAsync<NativeResponseType, ModelType>(
13+
handleResponse<NativeResponseType, ModelType>(
1414
response: NativeResponseType,
1515
errorMappings: ErrorMappings | undefined,
1616
): Promise<ModelType>;

packages/http/fetch/src/fetchRequestAdapter.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ export class FetchRequestAdapter implements RequestAdapter {
6060
return responseHandlerOption?.responseHandler;
6161
};
6262
private static readonly responseTypeAttributeKey = "com.microsoft.kiota.response.type";
63-
public sendCollectionOfPrimitiveAsync = <ResponseType extends Exclude<PrimitiveTypesForDeserializationType, ArrayBuffer>>(requestInfo: RequestInformation, responseType: Exclude<PrimitiveTypesForDeserialization, "ArrayBuffer">, errorMappings: ErrorMappings | undefined): Promise<ResponseType[] | undefined> => {
63+
public sendCollectionOfPrimitive = <ResponseType extends Exclude<PrimitiveTypesForDeserializationType, ArrayBuffer>>(requestInfo: RequestInformation, responseType: Exclude<PrimitiveTypesForDeserialization, "ArrayBuffer">, errorMappings: ErrorMappings | undefined): Promise<ResponseType[] | undefined> => {
6464
if (!requestInfo) {
6565
throw new Error("requestInfo cannot be null");
6666
}
67-
return this.startTracingSpan(requestInfo, "sendCollectionOfPrimitiveAsync", async (span) => {
67+
return this.startTracingSpan(requestInfo, "sendCollectionOfPrimitive", async (span) => {
6868
try {
6969
const response = await this.getHttpResponseMessage(requestInfo, span);
7070
const responseHandler = this.getResponseHandler(requestInfo);
7171
if (responseHandler) {
7272
span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
73-
return await responseHandler.handleResponseAsync(response, errorMappings);
73+
return await responseHandler.handleResponse(response, errorMappings);
7474
} else {
7575
try {
7676
await this.throwIfFailedResponse(response, errorMappings, span);
@@ -116,17 +116,17 @@ export class FetchRequestAdapter implements RequestAdapter {
116116
}
117117
});
118118
};
119-
public sendCollectionAsync = <ModelType extends Parsable>(requestInfo: RequestInformation, deserialization: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined): Promise<ModelType[] | undefined> => {
119+
public sendCollection = <ModelType extends Parsable>(requestInfo: RequestInformation, deserialization: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined): Promise<ModelType[] | undefined> => {
120120
if (!requestInfo) {
121121
throw new Error("requestInfo cannot be null");
122122
}
123-
return this.startTracingSpan(requestInfo, "sendCollectionAsync", async (span) => {
123+
return this.startTracingSpan(requestInfo, "sendCollection", async (span) => {
124124
try {
125125
const response = await this.getHttpResponseMessage(requestInfo, span);
126126
const responseHandler = this.getResponseHandler(requestInfo);
127127
if (responseHandler) {
128128
span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
129-
return await responseHandler.handleResponseAsync(response, errorMappings);
129+
return await responseHandler.handleResponse(response, errorMappings);
130130
} else {
131131
try {
132132
await this.throwIfFailedResponse(response, errorMappings, span);
@@ -163,17 +163,17 @@ export class FetchRequestAdapter implements RequestAdapter {
163163
});
164164
};
165165
public static readonly eventResponseHandlerInvokedKey = "com.microsoft.kiota.response_handler_invoked";
166-
public sendAsync = <ModelType extends Parsable>(requestInfo: RequestInformation, deserializer: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined): Promise<ModelType | undefined> => {
166+
public send = <ModelType extends Parsable>(requestInfo: RequestInformation, deserializer: ParsableFactory<ModelType>, errorMappings: ErrorMappings | undefined): Promise<ModelType | undefined> => {
167167
if (!requestInfo) {
168168
throw new Error("requestInfo cannot be null");
169169
}
170-
return this.startTracingSpan(requestInfo, "sendAsync", async (span) => {
170+
return this.startTracingSpan(requestInfo, "send", async (span) => {
171171
try {
172172
const response = await this.getHttpResponseMessage(requestInfo, span);
173173
const responseHandler = this.getResponseHandler(requestInfo);
174174
if (responseHandler) {
175175
span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
176-
return await responseHandler.handleResponseAsync(response, errorMappings);
176+
return await responseHandler.handleResponse(response, errorMappings);
177177
} else {
178178
try {
179179
await this.throwIfFailedResponse(response, errorMappings, span);
@@ -197,17 +197,17 @@ export class FetchRequestAdapter implements RequestAdapter {
197197
}
198198
}) as Promise<ModelType>;
199199
};
200-
public sendPrimitiveAsync = <ResponseType extends PrimitiveTypesForDeserializationType>(requestInfo: RequestInformation, responseType: PrimitiveTypesForDeserialization, errorMappings: ErrorMappings | undefined): Promise<ResponseType | undefined> => {
200+
public sendPrimitive = <ResponseType extends PrimitiveTypesForDeserializationType>(requestInfo: RequestInformation, responseType: PrimitiveTypesForDeserialization, errorMappings: ErrorMappings | undefined): Promise<ResponseType | undefined> => {
201201
if (!requestInfo) {
202202
throw new Error("requestInfo cannot be null");
203203
}
204-
return this.startTracingSpan(requestInfo, "sendPrimitiveAsync", async (span) => {
204+
return this.startTracingSpan(requestInfo, "sendPrimitive", async (span) => {
205205
try {
206206
const response = await this.getHttpResponseMessage(requestInfo, span);
207207
const responseHandler = this.getResponseHandler(requestInfo);
208208
if (responseHandler) {
209209
span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
210-
return await responseHandler.handleResponseAsync(response, errorMappings);
210+
return await responseHandler.handleResponse(response, errorMappings);
211211
} else {
212212
try {
213213
await this.throwIfFailedResponse(response, errorMappings, span);
@@ -259,17 +259,17 @@ export class FetchRequestAdapter implements RequestAdapter {
259259
}
260260
}) as Promise<ResponseType | undefined>;
261261
};
262-
public sendNoResponseContentAsync = (requestInfo: RequestInformation, errorMappings: ErrorMappings | undefined): Promise<void> => {
262+
public sendNoResponseContent = (requestInfo: RequestInformation, errorMappings: ErrorMappings | undefined): Promise<void> => {
263263
if (!requestInfo) {
264264
throw new Error("requestInfo cannot be null");
265265
}
266-
return this.startTracingSpan(requestInfo, "sendNoResponseContentAsync", async (span) => {
266+
return this.startTracingSpan(requestInfo, "sendNoResponseContent", async (span) => {
267267
try {
268268
const response = await this.getHttpResponseMessage(requestInfo, span);
269269
const responseHandler = this.getResponseHandler(requestInfo);
270270
if (responseHandler) {
271271
span.addEvent(FetchRequestAdapter.eventResponseHandlerInvokedKey);
272-
return await responseHandler.handleResponseAsync(response, errorMappings);
272+
return await responseHandler.handleResponse(response, errorMappings);
273273
}
274274
try {
275275
await this.throwIfFailedResponse(response, errorMappings, span);
@@ -482,13 +482,13 @@ export class FetchRequestAdapter implements RequestAdapter {
482482
/**
483483
* @inheritdoc
484484
*/
485-
public convertToNativeRequestAsync = async <T>(requestInfo: RequestInformation): Promise<T> => {
485+
public convertToNativeRequest = async <T>(requestInfo: RequestInformation): Promise<T> => {
486486
if (!requestInfo) {
487487
throw new Error("requestInfo cannot be null");
488488
}
489489
await this.authenticationProvider.authenticateRequest(requestInfo, undefined);
490490

491-
return this.startTracingSpan(requestInfo, "convertToNativeRequestAsync", async (span) => {
491+
return this.startTracingSpan(requestInfo, "convertToNativeRequest", async (span) => {
492492
const request = await this.getRequestFromRequestInformation(requestInfo, span);
493493
return request as any as T;
494494
});

packages/http/fetch/test/common/fetchRequestAdapter.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe("FetchRequestAdapter.ts", () => {
4141
const requestInformation = new RequestInformation();
4242
requestInformation.URL = "https://www.example.com";
4343
requestInformation.httpMethod = HttpMethod.GET;
44-
await requestAdapter.sendNoResponseContentAsync(requestInformation, undefined);
44+
await requestAdapter.sendNoResponseContent(requestInformation, undefined);
4545
assert.equal(executeFetchCount, 2);
4646
});
4747
});
@@ -59,7 +59,7 @@ describe("FetchRequestAdapter.ts", () => {
5959
const requestInformation = new RequestInformation();
6060
requestInformation.URL = "https://www.example.com";
6161
requestInformation.httpMethod = HttpMethod.GET;
62-
const result = await requestAdapter.sendPrimitiveAsync(requestInformation, "ArrayBuffer", undefined);
62+
const result = await requestAdapter.sendPrimitive(requestInformation, "ArrayBuffer", undefined);
6363
assert.isDefined(result);
6464
});
6565
}
@@ -78,7 +78,7 @@ describe("FetchRequestAdapter.ts", () => {
7878
const requestInformation = new RequestInformation();
7979
requestInformation.URL = "https://www.example.com";
8080
requestInformation.httpMethod = HttpMethod.GET;
81-
const result = await requestAdapter.sendPrimitiveAsync(requestInformation, "ArrayBuffer", undefined);
81+
const result = await requestAdapter.sendPrimitive(requestInformation, "ArrayBuffer", undefined);
8282
assert.isUndefined(result);
8383
});
8484
}
@@ -97,7 +97,7 @@ describe("FetchRequestAdapter.ts", () => {
9797
const requestInformation = new RequestInformation();
9898
requestInformation.URL = "https://www.example.com";
9999
requestInformation.httpMethod = HttpMethod.GET;
100-
const result = await requestAdapter.sendAsync(requestInformation, createMockEntityFromDiscriminatorValue, undefined);
100+
const result = await requestAdapter.send(requestInformation, createMockEntityFromDiscriminatorValue, undefined);
101101
assert.isUndefined(result);
102102
});
103103
}
@@ -118,7 +118,7 @@ describe("FetchRequestAdapter.ts", () => {
118118
const requestInformation = new RequestInformation();
119119
requestInformation.URL = "https://www.example.com";
120120
requestInformation.httpMethod = HttpMethod.GET;
121-
const result = await requestAdapter.sendAsync(requestInformation, createMockEntityFromDiscriminatorValue, undefined);
121+
const result = await requestAdapter.send(requestInformation, createMockEntityFromDiscriminatorValue, undefined);
122122
assert.isDefined(result);
123123
});
124124
}
@@ -139,7 +139,7 @@ describe("FetchRequestAdapter.ts", () => {
139139
requestInformation.httpMethod = HttpMethod.GET;
140140

141141
try {
142-
await requestAdapter.sendNoResponseContentAsync(requestInformation, undefined);
142+
await requestAdapter.sendNoResponseContent(requestInformation, undefined);
143143
assert.fail("Should have thrown an error");
144144
} catch (error) {
145145
assert.equal(error.responseStatusCode, 500);

packages/test/generatedCode/kiota-lock.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"descriptionHash": "880607FEC08E088EFB64EA3C15BAC2221BCF7C9AAD42A7DF5939AB8D6F14D90AB52FDA7BF7B28235D6FF87CF2D9A7B45B697BCC79DA574D955A39132B7C04DA2",
2+
"descriptionHash": "33264054EC56DBD30FD86D31BC572362006E9ED000AAACEBD62B904956BEA68FA1BD9539279F02EBC03638A7709BC99D504510494848B03F647B8A91F30AD180",
33
"descriptionLocation": "https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/dev/openApiDocs/v1.0/Mail.yml",
44
"lockFileVersion": "1.0.0",
5-
"kiotaVersion": "1.11.1",
5+
"kiotaVersion": "1.12.0",
66
"clientClassName": "ApiClient",
77
"clientNamespaceName": "ApiSdk",
88
"language": "TypeScript",

packages/test/generatedCode/users/item/inferenceClassification/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const InferenceClassificationRequestBuilderRequestsMetadata: RequestsMeta
8181
errorMappings: {
8282
XXX: createODataErrorFromDiscriminatorValue as ParsableFactory<Parsable>,
8383
},
84-
adapterMethodName: "sendAsync",
84+
adapterMethodName: "send",
8585
responseBodyFactory: createInferenceClassificationFromDiscriminatorValue,
8686
queryParametersMapper: InferenceClassificationRequestBuilderGetQueryParametersMapper,
8787
},
@@ -91,7 +91,7 @@ export const InferenceClassificationRequestBuilderRequestsMetadata: RequestsMeta
9191
errorMappings: {
9292
XXX: createODataErrorFromDiscriminatorValue as ParsableFactory<Parsable>,
9393
},
94-
adapterMethodName: "sendAsync",
94+
adapterMethodName: "send",
9595
responseBodyFactory: createInferenceClassificationFromDiscriminatorValue,
9696
requestBodyContentType: "application/json",
9797
requestBodySerializer: serializeInferenceClassification,

0 commit comments

Comments
 (0)