Skip to content

Commit 53b94a8

Browse files
Updates to the packages + Reformatingnm
1 parent 68b5341 commit 53b94a8

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

design/kiota-e2e.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@
22

33
While working with the Kiota + Javascript teams, it became clear that we needed more context and provide a better vision on how we should be using a kiota-generated SDK. This design document aims at providing clarity and a better understanding on how developers will be using our SDKs and the underlying kiota packages.
44

5+
## Status
6+
7+
| Date | Version | Author | Status |
8+
| ------------------- | ------- | ---------------- | ------ |
9+
| February 15th, 2022 | v0.2 | Sébastien Levert | Draft |
10+
| January 17th, 2022 | v0.1 | Sébastien Levert | Draft |
11+
512
## Constraints
613

714
Before we jump into the end-to-end walk-through, it's important to set some constraints.
815

9-
| Type | Description |
10-
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
11-
| Platforms | Node : Current and Previous LTS (14 / 16)<br /> Web : Edge, Chrome, Firefox and Safari (Latest released version + immediate previous version) |
12-
| Modules | Node : ESM (For preview) and potentially CJS (Based on feedback)<br /> Web : ESM |
13-
| Types | Typings / Models should be available for both the core and the service libraries for Graph models |
16+
| Type | Environment | Description |
17+
| --------- | ----------- | ------------------------------------------------------------------------------------------------- |
18+
| Platforms | Node | Current and Previous LTS (14 / 16) |
19+
| Platforms | Web | Edge, Chrome, Firefox and Safari (Latest released version + immediate previous version) |
20+
| Modules | Node | ESM + CJS |
21+
| Modules | Web | ESM |
22+
| Types | All | Typings / Models should be available for both the core and the service libraries for Graph models |
23+
24+
## Table of Contents
1425

15-
## NodeJS e2e using the Service library
26+
- [NodeJS e2e using the Service library](#node-service-library)
27+
- [NodeJS e2e using the Core library](#node-core-library)
28+
29+
## <a id="node-service-library"></a> NodeJS e2e using the Service library
1630

1731
### Concept
1832

@@ -29,19 +43,20 @@ The Microsoft Graph Javascript Service Library includes the following packages:
2943

3044
You can use [npm](https://www.npmjs.com) to install the Microsoft Graph Javascript Service Library :
3145

32-
```Shell
46+
```shell
3347
npm install @microsoft/msgraph-sdk-javascript --save
34-
npm install @microsoft/msgraph-sdk-javascript-beta --save-dev
35-
npm install @microsoft/kiota-authentication-azure --save
3648
```
3749

3850
### Importing the right functionalities from the Graph Javascript Service Library
3951

4052
```typescript
4153
// App.ts
4254

43-
import { Client, User, Message, BodyType } from "@microsoft/msgraph-sdk-javascript";
44-
import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure";
55+
import { Client } from "@microsoft/msgraph-sdk-javascript";
56+
import { User, Message, BodyType } from "@microsoft/msgraph-sdk-javascript/models";
57+
58+
// The authentication providers would get re-exported from @microsoft/msgraph-sdk-javascript-core/authentication
59+
import { AzureIdentityAuthenticationProvider } from "@microsoft/msgraph-sdk-javascript/authentication";
4560
import { DeviceCodeCredential } from "@azure/identity";
4661
```
4762

@@ -69,8 +84,8 @@ Models are also available in this package and should reflect the underlying vers
6984
We have an open issue about the above topic that can be followed here : [TypeScript - Use of interface models instead of class models](https://github.com/microsoft/kiota/issues/1013)
7085

7186
```typescript
72-
const me = await getMe();
73-
const meRaw = await getMeRaw();
87+
const me: User | undefined = await getMe();
88+
const meRaw: User | undefined = await getMeRaw();
7489
await sendMail();
7590
await sendMailRaw();
7691

@@ -81,7 +96,7 @@ async function getMe(): Promise<User | undefined> {
8196

8297
// Allowing raw calls (using the .api() method instead of the full fluent API) is important for migration purposes and cases we don't know the resource beforehands (thinking Graph Explorer, mgt-get, etc.)
8398
async function getMeRaw(): Promise<User | undefined> {
84-
return await graphClient.api("/me").get();
99+
return await graphClient.api("/me").get<User>();
85100
}
86101

87102
// Sending an email via the fluent API
@@ -127,7 +142,7 @@ async function sendMailRaw(): Promise<void> {
127142
}
128143
```
129144

130-
## NodeJS e2e using the Core library
145+
## <a id="node-core-library"></a> NodeJS e2e using the Core library
131146

132147
### Concept
133148

@@ -145,17 +160,16 @@ You can use [npm](https://www.npmjs.com) to install the Microsoft Graph Javascri
145160
```Shell
146161
npm install @microsoft/msgraph-sdk-javascript-core --save
147162
npm install @microsoft/msgraph-sdk-javascript-types --save-dev
148-
npm install @microsoft/kiota-authentication-azure --save
149163
```
150164

151-
As a developer, the only package you really need is the `@microsoft/msgraph-sdk-javascript-core` one. This will deliver the expected capabilities (authentication, middlewares, tasks, etc.) and should be used in a comprehensive way for existing NodeJS developers. The types and authentication packages are recommended but optional.
165+
As a developer, the only package you really need is the `@microsoft/msgraph-sdk-javascript-core` one. This will deliver the expected capabilities (authentication, middlewares, tasks, etc.) and should be used in a comprehensive way for existing NodeJS developers. The types are recommended but optional.
152166

153167
### Importing the right functionalities from the Graph Javascript Core SDK
154168

155169
```typescript
156170
import { Client } from "@microsoft/msgraph-sdk-javascript-core";
157171
import { User, Message, BodyType } from "@microsoft/msgraph-sdk-javascript-core-types";
158-
import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure";
172+
import { AzureIdentityAuthenticationProvider } from "@microsoft/msgraph-sdk-javascript-core/authentication";
159173
import { DeviceCodeCredential } from "@azure/identity";
160174
```
161175

@@ -185,11 +199,11 @@ Developers using our types should do it in a way that will be familiar to how th
185199
We have an open issue about the above topic that can be followed here : [TypeScript - Use of interface models instead of class models](https://github.com/microsoft/kiota/issues/1013)
186200

187201
```typescript
188-
const me = await getMe();
202+
const me: User = await getMe();
189203
await sendMail();
190204

191205
async function getMe(): Promise<User | undefined> {
192-
return await graphClient.api("/me").get();
206+
return await graphClient.api("/me").get<User>();
193207
}
194208

195209
async function sendMail(): Promise<void> {

0 commit comments

Comments
 (0)