Simplify graph function paramDefs type#335
Merged
heyitsaamir merged 4 commits intoSep 10, 2025
Merged
Conversation
Jesperholmbergmsft
marked this pull request as ready for review
September 8, 2025 23:12
heyitsaamir
previously approved these changes
Sep 10, 2025
Copilot AI
added a commit
that referenced
this pull request
Feb 17, 2026
Co-authored-by: rido-min <[email protected]>
rido-min
added a commit
that referenced
this pull request
Feb 26, 2026
Adds reaction management capabilities via the Bot Framework API v3,
mirroring the teams.net implementation.
## Changes
**ReactionClient** (`/packages/api/src/clients/reaction/`)
- `add(conversationId, activityId, reactionType)` - PUT to
`/v3/conversations/{conversationId}/activities/{activityId}/reactions/{reactionType}`
- `remove(conversationId, activityId, reactionType)` - DELETE to same
endpoint
- Integrated into main `Client` class as `reactions` property
**ReactionType Model** (`/packages/api/src/models/reaction/`)
- Type-safe reaction values: `'like' | 'heart' | 'laugh' | 'surprised' |
'sad' | 'angry'`
**Breaking Change: MessageReactionActivity**
- Removed `addReaction()` and `removeReaction()` helper methods
- Reactions should now be managed via `ReactionClient` or set directly
on activity properties
**Example Application** (`/examples/reactions/`)
- Added comprehensive example bot demonstrating ReactionClient usage
- Shows how to add/remove reactions programmatically
- Demonstrates handling `messageReaction` activity events
- Includes interactive commands and detailed documentation
## Usage
```typescript
import { Client } from '@microsoft/teams.api';
const client = new Client(serviceUrl);
// Add a reaction
await client.reactions.add('conversationId', 'activityId', 'like');
// Remove a reaction
await client.reactions.remove('conversationId', 'activityId', 'like');
// MessageReactionActivity now requires direct property assignment
const activity = new MessageReactionActivity({
reactionsAdded: [{ type: 'like', user: account }],
reactionsRemoved: [{ type: 'heart', user: account }],
});
```
See the `examples/reactions` directory for a complete working example.
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: rido-min <[email protected]>
Co-authored-by: Rido <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes the
paramDefstype in the endpoint functions. TheparamDefsvalues are used to construct the Graph HTTP request - for each parameter that the caller may supply,paramDefsdecides whether they go in the path, the query string, or the request header.The
paramDefstype so far has been:{ name: string; in: 'query' | 'header' | 'path' }>[]. So - an array of objects, each has a parameter name, and aninvalue to show where it goes.The new type is:
Partial<Record<'query' | 'header' | 'path', string[]>>;I'm pulling the 'in' values up a level to be a key in an object, the values being the parameters for that 'in'.In practice, the paramDefs for an API before may have been:
And now the same is:
This change has a surprisingly large impact on the size of code generated. After building the beta package, looking at the combined size of the .js files, they shrink from 6207kB to 5204kB. That's about 1/6th less code on disk.
There's no much improvement to the NPM package size, just a few kB, since the removed repetition compresses so well. But the uncompressed footprint makes it worthwhile all the same.
This change won't build until all endpoints are rebuilt, so in the first iteration I included only the changes to the generation script & the graph.call() method and a few updated endpoints - just enough to showcase the change.
In the second iteration, I regenerated all the endpoints for both beta and v.10 (schema commits 4e63218 and 3bdcc26, both published yesterday).