-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into emoji
* 'develop' of github.com:RocketChat/Rocket.Chat: Chore: Bump fuselage (#25371) Chore: Add options to debug stdout and rate limiter (#25336) Regression: Fix English i18n react text (#25368) Regression: Rocket.Chat Webapp not loading. (#25349) Regression: Fix multi line is not showing an empty line between lines (#25317) Regression: bump onboarding-ui version (#25320) Chore: Create README.md for Rest Typings (#25335) Regression: Parser message when notify ephemeral message
- Loading branch information
Showing
13 changed files
with
272 additions
and
142 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
|
||
# @rocket.chat/rest-typings | ||
|
||
Package containing all Rocket.Chat rest endpoint definitions | ||
|
||
|
||
## Contributing | ||
|
||
Contributions are always welcome! | ||
However we have some recommendations. | ||
- Check if your implementation matches your definitions, a bad definition is worse than none. | ||
- Use the generic types we created for paging. | ||
- Create functions that assert properties (very useful for the backend) | ||
- Do tests to ensure that your assertions are correct. | ||
- Avoid incomplete and unknow typings | ||
|
||
### Good examples of what not to do: | ||
|
||
#### If you have an endpoint that accepts name or id, both are not optional, one of them is required | ||
|
||
```typescript | ||
|
||
type EndPointTestGetParams = { name?: string; id?: string; } // WRONG! | ||
|
||
type EndPointTestGetParams = { name: string; } | { id: string; } // Better :) | ||
```` | ||
|
||
#### If you have an endpoint that accepts name or id, both are not optional, one of them is required | ||
|
||
```typescript | ||
export const isEndPointTestGetParams = (props: any) is EndPointTestGetParams => 'name' in prop || 'id' in prop; // WRONG! | ||
// .... Better | ||
import Ajv from 'ajv'; | ||
const ajv = new Ajv(); | ||
const endPointTestGetParams = { | ||
oneOf: [ | ||
{ | ||
type: 'object', | ||
properties: { | ||
name: { | ||
type: 'string', | ||
}, | ||
}, | ||
required: ['name'], | ||
additionalProperties: false, | ||
}, | ||
{ | ||
type: 'object', | ||
properties: { | ||
id: { | ||
type: 'string', | ||
}, | ||
}, | ||
required: ['id'], | ||
additionalProperties: false, | ||
}, | ||
], | ||
}; | ||
export const isEndPointTestGetParams = ajv.compile<EndPointTestGetParams>(endPointTestGetParams); | ||
``` | ||
## Optimizations | ||
|
||
we use interfaces to register endpoints, so if you use a custom version, or miss an endpoint, you don't necessarily need to recompile the code, you can do it in your own code | ||
|
||
```typescript | ||
declare module '@rocket.chat/rest-typings' { | ||
interface Endpoints { | ||
'custom/endpoint': { | ||
GET: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{ | ||
some: string[]; | ||
}>; | ||
}; | ||
} | ||
} | ||
``` | ||
|
||
## License | ||
|
||
MIT | ||
|
Oops, something went wrong.