Skip to content

Commit f7bb892

Browse files
authored
Merge branch 'main' into feat/auth-middleware-factory
2 parents 2e199ce + 96dc536 commit f7bb892

20 files changed

+1287
-120
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.0.0-preview.12"
2+
".": "1.0.0-preview.14"
33
}

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## [1.0.0-preview.14](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/compare/v1.0.0-preview.13...v1.0.0-preview.14) (2025-03-04)
4+
5+
6+
### Bug Fixes
7+
8+
* adds missing js extension to imports ([f75a663](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/commit/f75a6638a065939f29305a5b315ef1c1838e00cf))
9+
* adds missing js extension to imports ([b0a5d4c](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/commit/b0a5d4c4722eb7001cc338f22db75e1d034e8fe3))
10+
* corrected the imports for observability options ([43323ef](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/commit/43323efcb63028e51255167d4b12919581e53d87))
11+
* corrected the imports for observability options ([bff310f](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/commit/bff310ff2db464af4dfe213c47501c5f192878d8))
12+
13+
## [1.0.0-preview.13](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/compare/v1.0.0-preview.12...v1.0.0-preview.13) (2025-03-04)
14+
15+
16+
### Features
17+
18+
* add batch request content ([#354](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/issues/354)) ([c344031](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/commit/c344031d35c79b8026f54c6c731409e6097ce2db))
19+
320
## [1.0.0-preview.12](https://github.com/microsoftgraph/msgraph-sdk-typescript-core/compare/v1.0.0-preview.11...v1.0.0-preview.12) (2025-02-27)
421

522

package-lock.json

Lines changed: 126 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"access": "public"
44
},
55
"name": "@microsoft/msgraph-sdk-core",
6-
"version": "1.0.0-preview.12",
6+
"version": "1.0.0-preview.14",
77
"description": "Core functionalities for the Microsoft Graph JavaScript SDK",
88
"main": "./dist/index.js",
99
"types": "./dist/index.d.ts",

src/authentication/AzureIdentityAccessTokenProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { GetTokenOptions, TokenCredential } from "@azure/core-auth";
2-
import { AzureIdentityAccessTokenProvider } from "@microsoft/kiota-authentication-azure";
3-
import { ObservabilityOptions } from "@microsoft/kiota-authentication-azure/dist/es/src/observabilityOptions";
2+
import { AzureIdentityAccessTokenProvider, type ObservabilityOptions } from "@microsoft/kiota-authentication-azure";
43

54
export class GraphAzureIdentityAccessTokenProvider extends AzureIdentityAccessTokenProvider {
65
public constructor(

src/authentication/AzureIdentityAuthenticationProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { GetTokenOptions, TokenCredential } from "@azure/core-auth";
2-
import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure";
3-
import { ObservabilityOptions } from "@microsoft/kiota-authentication-azure/dist/es/src/observabilityOptions";
2+
import { AzureIdentityAuthenticationProvider, type ObservabilityOptions } from "@microsoft/kiota-authentication-azure";
43

54
export class GraphAzureIdentityAuthenticationProvider extends AzureIdentityAuthenticationProvider {
65
// create a constructor with TokenCredential

src/content/BatchRequestBuilder.ts

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { ErrorMappings, HttpMethod, RequestAdapter, RequestInformation } from "@microsoft/kiota-abstractions";
2+
import {
3+
BatchResponseBody,
4+
createBatchResponseContentFromDiscriminatorValue,
5+
serializeBatchRequestBody,
6+
} from "./BatchRequestStep.js";
7+
import { BatchResponseContent } from "./BatchResponseContent.js";
8+
import { BatchRequestContent } from "./BatchRequestContent.js";
9+
import { BatchRequestContentCollection } from "./BatchRequestContentCollection.js";
10+
import { BatchResponseContentCollection } from "./BatchResponseContentCollection.js";
11+
12+
export class BatchRequestBuilder {
13+
/**
14+
* @private
15+
* @static
16+
* Executes the requests in the batch request content
17+
*/
18+
private readonly requestAdapter: RequestAdapter;
19+
20+
/**
21+
* @private
22+
* @static
23+
* Error mappings to be used while deserializing the response
24+
*/
25+
private readonly errorMappings: ErrorMappings;
26+
27+
/**
28+
* Creates an instance of BatchRequestContent.
29+
* @param {RequestAdapter} requestAdapter - The request adapter to be used for executing the requests.
30+
* @param {ErrorMappings} errorMappings - The error mappings to be used while deserializing the response.
31+
* @throws {Error} If the request adapter is undefined.
32+
* @throws {Error} If the error mappings are undefined.
33+
*/
34+
constructor(requestAdapter: RequestAdapter, errorMappings: ErrorMappings) {
35+
if (!requestAdapter) {
36+
const error = new Error("Request adapter is undefined, Please provide a valid request adapter");
37+
error.name = "Invalid Request Adapter Error";
38+
throw error;
39+
}
40+
this.requestAdapter = requestAdapter;
41+
if (!errorMappings) {
42+
const error = new Error("Error mappings are undefined, Please provide a valid error mappings");
43+
error.name = "Invalid Error Mappings Error";
44+
throw error;
45+
}
46+
this.errorMappings = errorMappings;
47+
}
48+
49+
/**
50+
* @public
51+
* @async
52+
* Executes the batch request
53+
*/
54+
public async postBatchResponseContentAsync(
55+
batchRequestContent: BatchRequestContent,
56+
): Promise<BatchResponseContent | undefined> {
57+
const requestInformation = new RequestInformation();
58+
requestInformation.httpMethod = HttpMethod.POST;
59+
requestInformation.urlTemplate = "{+baseurl}/$batch";
60+
61+
const content = batchRequestContent.getContent();
62+
requestInformation.setContentFromParsable(
63+
this.requestAdapter,
64+
"application/json",
65+
content,
66+
serializeBatchRequestBody,
67+
);
68+
69+
requestInformation.headers.add("Content-Type", "application/json");
70+
71+
const result = await this.requestAdapter.send<BatchResponseBody>(
72+
requestInformation,
73+
createBatchResponseContentFromDiscriminatorValue,
74+
this.errorMappings,
75+
);
76+
77+
if (result === undefined) {
78+
return undefined;
79+
} else {
80+
return new BatchResponseContent(result);
81+
}
82+
}
83+
84+
/**
85+
* Executes the batch requests asynchronously.
86+
*
87+
* @returns {Promise<BatchResponseContent | undefined>} A promise that resolves to the batch response content or undefined.
88+
* @throws {Error} If the batch limit is exceeded.
89+
*/
90+
public async postBatchRequestContentCollectionAsync(
91+
collection: BatchRequestContentCollection,
92+
): Promise<BatchResponseContentCollection | undefined> {
93+
// chuck the batch requests into smaller batches
94+
const batches = collection.getBatchResponseContents();
95+
96+
// loop over batches and create batch request body
97+
const batchResponseBody: BatchResponseContent[] = [];
98+
for (const requestContent of batches) {
99+
const response = await requestContent.postAsync();
100+
if (response) {
101+
batchResponseBody.push(response);
102+
}
103+
}
104+
return new BatchResponseContentCollection(batchResponseBody);
105+
}
106+
}

0 commit comments

Comments
 (0)