-
Notifications
You must be signed in to change notification settings - Fork 1.4k
refactor: To use @rocket.chat/rest-typings as the single source of truth for REST API type definitions. #6876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deepak0x
wants to merge
9
commits into
RocketChat:develop
Choose a base branch
from
deepak0x:refactor/rest-typings-setup_and_helpers_migration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+907
−1,242
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0fd64ee
refactor: Install rest-typings and migrate helper types
deepak0x e60e7d3
refactor: Remove PaginatedRequest and PaginatedResult wrapper files
deepak0x 6ca9fd9
refactor: Implement rest-typings patterns in helpers (POC)
deepak0x b5e17a7
refactor: Fix lint errors and remove comments
deepak0x 99c9f7b
refactor: migrate endpoint categories to @rocket.chat/rest-typings
deepak0x ebd798d
refactor: migrate high complexity endpoint categories to @rocket.chat…
deepak0x 853bf4e
fix: complete REST typings migration and fix lint errors
deepak0x 4b46bc8
fix: improve type safety and fix code quality issues
deepak0x de733a3
fix: add guard for undefined id in logoutOtherLocations and remove un…
deepak0x File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,15 @@ | ||
| export type AutoTranslateEndpoints = { | ||
| 'autotranslate.translateMessage': { | ||
| POST: (params: { messageId: string; targetLanguage: string }) => void; | ||
| }; | ||
| import type { Endpoints } from '@rocket.chat/rest-typings'; | ||
|
|
||
| type ExtractAutoTranslateEndpoints<T> = { | ||
| [K in keyof T as K extends `/v1/autotranslate.${string}` ? K : never]: T[K]; | ||
| }; | ||
|
|
||
| type RestTypingsAutoTranslateEndpoints = ExtractAutoTranslateEndpoints<Endpoints>; | ||
|
|
||
| type RemoveV1Prefix<T> = T extends `/v1/${infer Rest}` ? Rest : T; | ||
|
|
||
| type AdaptAutoTranslateEndpoints<T> = { | ||
| [K in keyof T as RemoveV1Prefix<K & string>]: T[K]; | ||
| }; | ||
|
|
||
| export type AutoTranslateEndpoints = AdaptAutoTranslateEndpoints<RestTypingsAutoTranslateEndpoints>; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,119 +1,9 @@ | ||
| import { type ITeam } from '../../ITeam'; | ||
| import type { IMessageFromServer } from '../../IMessage'; | ||
| import type { IServerRoom } from '../../IRoom'; | ||
| import type { IUser } from '../../IUser'; | ||
| import { type IGetRoomRoles } from '../../IRole'; | ||
| import { type IServerAttachment } from '../../IAttachment'; | ||
| import { type PaginatedRequest } from '../helpers/PaginatedRequest'; | ||
| import type { ChannelsEndpoints as RestTypingsChannelsEndpoints } from '@rocket.chat/rest-typings'; | ||
|
|
||
| export type ChannelsEndpoints = { | ||
| 'channels.files': { | ||
| GET: (params: { roomId: IServerRoom['_id']; offset: number; sort: string | { uploadedAt: number } }) => { | ||
| files: IServerAttachment[]; | ||
| count: number; | ||
| offset: number; | ||
| total: number; | ||
| }; | ||
| }; | ||
| 'channels.members': { | ||
| GET: (params: { | ||
| roomId: IServerRoom['_id']; | ||
| offset?: number; | ||
| count?: number; | ||
| filter?: boolean; | ||
| status?: string[]; | ||
| }) => PaginatedRequest<{ | ||
| members: IUser[]; | ||
| }>; | ||
| }; | ||
| 'channels.history': { | ||
| GET: (params: { roomId: string; count: number; latest?: string }) => { | ||
| messages: IMessageFromServer[]; | ||
| }; | ||
| }; | ||
| 'channels.archive': { | ||
| POST: (params: { roomId: string }) => void; | ||
| }; | ||
| 'channels.unarchive': { | ||
| POST: (params: { roomId: string }) => void; | ||
| }; | ||
| 'channels.create': { | ||
| POST: (params: { | ||
| name: string; | ||
| members: string[]; | ||
| readOnly: boolean; | ||
| extraData: { | ||
| broadcast: boolean; | ||
| encrypted: boolean; | ||
| teamId?: string; | ||
| }; | ||
| }) => { | ||
| group: Partial<IServerRoom>; | ||
| }; | ||
| }; | ||
| 'channels.convertToTeam': { | ||
| POST: (params: { channelId: string } | { channelName: string } | { channelId: string; channelName: string }) => { | ||
| team: ITeam; | ||
| }; | ||
| }; | ||
| 'channels.info': { | ||
| GET: (params: { roomId: string }) => { channel: IServerRoom }; | ||
| }; | ||
| 'channels.counters': { | ||
| GET: (params: { roomId: string }) => { | ||
| joined: boolean; | ||
| members: number; | ||
| unreads: number; | ||
| unreadsFrom: Date; | ||
| msgs: number; | ||
| latest: Date; | ||
| userMentions: number; | ||
| }; | ||
| }; | ||
| 'channels.join': { | ||
| POST: (params: { roomId: string; joinCode: string | null }) => { channel: IServerRoom }; | ||
| }; | ||
| 'channels.close': { | ||
| POST: (params: { roomId: string }) => {}; | ||
| }; | ||
| 'channels.kick': { | ||
| POST: (params: { roomId: string; userId: string }) => {}; | ||
| }; | ||
| 'channels.delete': { | ||
| POST: (params: { roomId: string }) => {}; | ||
| }; | ||
| 'channels.leave': { | ||
| POST: (params: { roomId: string }) => {}; | ||
| }; | ||
| 'channels.addModerator': { | ||
| POST: (params: { roomId: string; userId: string }) => {}; | ||
| }; | ||
| 'channels.removeModerator': { | ||
| POST: (params: { roomId: string; userId: string }) => {}; | ||
| }; | ||
| 'channels.addOwner': { | ||
| POST: (params: { roomId: string; userId: string }) => {}; | ||
| }; | ||
| 'channels.removeOwner': { | ||
| POST: (params: { roomId: string; userId: string }) => {}; | ||
| }; | ||
| 'channels.addLeader': { | ||
| POST: (params: { roomId: string; userId: string }) => {}; | ||
| }; | ||
| 'channels.removeLeader': { | ||
| POST: (params: { roomId: string; userId: string }) => {}; | ||
| }; | ||
| 'channels.roles': { | ||
| GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; | ||
| }; | ||
| 'channels.messages': { | ||
| GET: (params: { | ||
| roomId: IServerRoom['_id']; | ||
| query: { 'mentions._id': { $in: string[] } } | { 'starred._id': { $in: string[] } } | { pinned: boolean }; | ||
| offset: number; | ||
| sort: { ts: number }; | ||
| }) => { | ||
| messages: IMessageFromServer[]; | ||
| }; | ||
| type RemoveV1Prefix<T> = T extends `/v1/${infer Rest}` ? Rest : T; | ||
|
|
||
| type AdaptChannelsEndpoints<T> = { | ||
| [K in keyof T as RemoveV1Prefix<K & string>]: T[K]; | ||
| }; | ||
| }; | ||
|
|
||
| export type ChannelsEndpoints = AdaptChannelsEndpoints<RestTypingsChannelsEndpoints>; | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.