@devsym/graph-toolkit-react 1.0.0-next.5 → 1.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +167 -0
- package/package.json +3 -1
- package/readme.md +28 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# AGENTS.md — Graph Toolkit React
|
|
2
|
+
|
|
3
|
+
This file is for coding agents that consume `@devsym/graph-toolkit-react`.
|
|
4
|
+
Use this as the primary quick reference for implementation choices.
|
|
5
|
+
|
|
6
|
+
## Package
|
|
7
|
+
|
|
8
|
+
- Package name: `@devsym/graph-toolkit-react`
|
|
9
|
+
- Peer deps: `react`, `react-dom`, `@fluentui/react-components`
|
|
10
|
+
- Optional peer dep: `@azure/msal-browser` (required only for `MsalBrowserProvider`)
|
|
11
|
+
|
|
12
|
+
Install:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @devsym/graph-toolkit-react react react-dom @fluentui/react-components
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
If using browser MSAL auth:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @azure/msal-browser
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Scenario Decision Matrix
|
|
25
|
+
|
|
26
|
+
Choose one provider and wire it into `GraphProvider`.
|
|
27
|
+
|
|
28
|
+
| Scenario | Use | Why |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| Local development / UI prototyping | `MockProvider` | No auth setup; deterministic mock data |
|
|
31
|
+
| Browser-hosted app (SPA) with Entra/MSA sign-in | `MsalBrowserProvider` | Native browser MSAL flow |
|
|
32
|
+
| Microsoft Teams-hosted app with consumer-managed Teams auth | `TeamsHostedProvider` | Reuses existing Teams token acquisition + backend exchange |
|
|
33
|
+
| Existing custom auth stack | Custom `IProvider` implementation | Full control over token source and lifecycle |
|
|
34
|
+
|
|
35
|
+
## Minimal Patterns
|
|
36
|
+
|
|
37
|
+
### 1) MockProvider (fastest start)
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { FluentProvider, webLightTheme } from '@fluentui/react-components';
|
|
41
|
+
import { GraphProvider, MockProvider, Person } from '@devsym/graph-toolkit-react';
|
|
42
|
+
|
|
43
|
+
const provider = new MockProvider();
|
|
44
|
+
|
|
45
|
+
export function App() {
|
|
46
|
+
return (
|
|
47
|
+
<FluentProvider theme={webLightTheme}>
|
|
48
|
+
<GraphProvider provider={provider}>
|
|
49
|
+
<Person userId="AdeleV@contoso.com" view="twolines" showPresence />
|
|
50
|
+
</GraphProvider>
|
|
51
|
+
</FluentProvider>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 2) Browser SPA with MSAL (`MsalBrowserProvider`)
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { PublicClientApplication } from '@azure/msal-browser';
|
|
60
|
+
import { GraphProvider, MsalBrowserProvider, Person } from '@devsym/graph-toolkit-react';
|
|
61
|
+
|
|
62
|
+
const msal = new PublicClientApplication({
|
|
63
|
+
auth: {
|
|
64
|
+
clientId: 'YOUR_CLIENT_ID',
|
|
65
|
+
authority: 'https://login.microsoftonline.com/common',
|
|
66
|
+
redirectUri: window.location.origin,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const provider = new MsalBrowserProvider(msal, ['User.Read']);
|
|
71
|
+
await provider.initialize();
|
|
72
|
+
|
|
73
|
+
export function App() {
|
|
74
|
+
return (
|
|
75
|
+
<GraphProvider provider={provider}>
|
|
76
|
+
<Person userId="me" view="threelines" />
|
|
77
|
+
</GraphProvider>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 3) Teams-hosted app (`TeamsHostedProvider`)
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import {
|
|
86
|
+
createBackendTokenExchange,
|
|
87
|
+
GraphProvider,
|
|
88
|
+
Person,
|
|
89
|
+
TeamsHostedProvider,
|
|
90
|
+
} from '@devsym/graph-toolkit-react';
|
|
91
|
+
import { authentication } from '@microsoft/teams-js';
|
|
92
|
+
|
|
93
|
+
const exchangeForGraphToken = createBackendTokenExchange({
|
|
94
|
+
endpoint: '/api/token/exchange',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const provider = new TeamsHostedProvider({
|
|
98
|
+
defaultScopes: ['User.Read'],
|
|
99
|
+
getTeamsSsoToken: async scopes => authentication.getAuthToken({ resources: scopes }),
|
|
100
|
+
exchangeForGraphToken,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
await provider.login();
|
|
104
|
+
|
|
105
|
+
export function App() {
|
|
106
|
+
return (
|
|
107
|
+
<GraphProvider provider={provider}>
|
|
108
|
+
<Person userId="me" view="threelines" />
|
|
109
|
+
</GraphProvider>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 4) Custom auth (`IProvider`)
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { IProvider, ProviderState } from '@devsym/graph-toolkit-react';
|
|
118
|
+
|
|
119
|
+
export class MyProvider implements IProvider {
|
|
120
|
+
state: ProviderState = 'SignedOut';
|
|
121
|
+
|
|
122
|
+
async login(): Promise<void> {
|
|
123
|
+
this.state = 'SignedIn';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async logout(): Promise<void> {
|
|
127
|
+
this.state = 'SignedOut';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async getAccessToken(): Promise<string> {
|
|
131
|
+
return 'ACCESS_TOKEN';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Scopes by Feature
|
|
137
|
+
|
|
138
|
+
| Feature | Minimum delegated scope | Notes |
|
|
139
|
+
| --- | --- | --- |
|
|
140
|
+
| Current user profile (`userId="me"`) | `User.Read` | Required for basic profile fields |
|
|
141
|
+
| Other user profile (`userId="{id/upn}"`) | `User.ReadBasic.All` | May require admin consent |
|
|
142
|
+
| Presence (`showPresence`) | `Presence.Read` | UI still renders without presence |
|
|
143
|
+
| Profile photo (`fetchImage`) | `User.Read` | Falls back to initials if unavailable |
|
|
144
|
+
|
|
145
|
+
## Common Failures and Fixes
|
|
146
|
+
|
|
147
|
+
| Symptom | Likely Cause | Action |
|
|
148
|
+
| --- | --- | --- |
|
|
149
|
+
| Redirect URI mismatch / `AADSTS50011` | App registration redirect URI does not match dev URL | Add exact SPA redirect URI used by local dev server |
|
|
150
|
+
| Person stays loading | Provider not initialized / login not completed | Ensure `await provider.initialize()` (MSAL) or `await provider.login()` (Teams/custom) before rendering |
|
|
151
|
+
| Presence missing | `Presence.Read` not granted | Add and consent to `Presence.Read`; keep graceful fallback |
|
|
152
|
+
| `Cannot find module '@azure/msal-browser'` | Using `MsalBrowserProvider` without optional peer dependency installed | Install `@azure/msal-browser` |
|
|
153
|
+
|
|
154
|
+
## Agent Rules
|
|
155
|
+
|
|
156
|
+
- Choose the simplest provider that fits the host environment.
|
|
157
|
+
- Keep scopes minimal and feature-driven.
|
|
158
|
+
- Prefer `userId="me"` for first implementation; expand to other users only when needed.
|
|
159
|
+
- Wrap components with `GraphProvider`; avoid direct token handling in UI components.
|
|
160
|
+
- If uncertain, default to `MockProvider` for local iteration, then switch to real auth provider.
|
|
161
|
+
|
|
162
|
+
## Source of Truth
|
|
163
|
+
|
|
164
|
+
- Primary docs: `README.md`
|
|
165
|
+
- Migration guide: `docs/MGT_MIGRATION.md`
|
|
166
|
+
- MSAL sample: `samples/react-msal-sample/README.md`
|
|
167
|
+
- API exports and types: package root `dist/index.d.ts` in published artifact
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devsym/graph-toolkit-react",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.6",
|
|
4
4
|
"description": "React components for Microsoft Graph powered by Fluent UI",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"README.md",
|
|
18
|
+
"AGENTS.md",
|
|
19
|
+
"MGT_MIGRATION.md",
|
|
18
20
|
"LICENSE"
|
|
19
21
|
],
|
|
20
22
|
"scripts": {
|
package/readme.md
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
<h3 align="center">
|
|
15
15
|
<a href="#getting-started">Get Started</a> •
|
|
16
|
+
<a href="#migration-from-mgt">Migration</a> •
|
|
17
|
+
<a href="#agent-quick-reference">Agent Quick Reference</a> •
|
|
16
18
|
<a href="#storybook">Storybook</a> •
|
|
17
19
|
<a href="#contribute">Contribute</a>
|
|
18
20
|
</h3>
|
|
@@ -50,6 +52,32 @@ npm install @devsym/graph-toolkit-react
|
|
|
50
52
|
| ------- | ------- | ----------- |
|
|
51
53
|
| `@devsym/graph-toolkit-react` | `0.1.0-alpha.1` | React components for Microsoft Graph powered by Fluent UI |
|
|
52
54
|
|
|
55
|
+
<a id="migration-from-mgt"></a>
|
|
56
|
+
## 🔄 Migration from MGT
|
|
57
|
+
|
|
58
|
+
For migration from Microsoft Graph Toolkit (including Teams-hosted scenarios), use [`docs/MGT_MIGRATION.md`](./docs/MGT_MIGRATION.md).
|
|
59
|
+
|
|
60
|
+
The guide includes:
|
|
61
|
+
|
|
62
|
+
- Concept mapping (MGT patterns to this package)
|
|
63
|
+
- Step-by-step migration checklist
|
|
64
|
+
- Teams-specific migration section (`TeamsHostedProvider` + backend token exchange)
|
|
65
|
+
- Common migration pitfalls and validation checklist
|
|
66
|
+
|
|
67
|
+
<a id="agent-quick-reference"></a>
|
|
68
|
+
## 🤖 Agent Quick Reference
|
|
69
|
+
|
|
70
|
+
If you are using a coding agent (Copilot/Codex/Claude/etc.), use the scenario-first reference in [`AGENTS.md`](./AGENTS.md).
|
|
71
|
+
|
|
72
|
+
It includes:
|
|
73
|
+
|
|
74
|
+
- Provider decision matrix by hosting scenario
|
|
75
|
+
- Minimal copy-ready snippets for `MockProvider`, `MsalBrowserProvider`, `TeamsHostedProvider`, and custom `IProvider`
|
|
76
|
+
- Scopes-by-feature mapping
|
|
77
|
+
- Common failures and exact remediation steps
|
|
78
|
+
|
|
79
|
+
For end-to-end browser-hosted setup with MSAL, also see [`samples/react-msal-sample/README.md`](./samples/react-msal-sample/README.md).
|
|
80
|
+
|
|
53
81
|
## 🎨 Components
|
|
54
82
|
|
|
55
83
|
Currently available in alpha:
|