From ee336a84a35d5fa6e2ec5af3d8e137af41794178 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Tue, 15 Mar 2022 13:47:40 -0300 Subject: [PATCH] Chore: Migrate REST API - getDirectory to Typescript (#3898) --- app/definitions/rest/v1/directory.ts | 13 +++++++++++++ app/definitions/rest/v1/index.ts | 4 +++- app/lib/rocketchat/services/restApi.ts | 14 +++++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 app/definitions/rest/v1/directory.ts diff --git a/app/definitions/rest/v1/directory.ts b/app/definitions/rest/v1/directory.ts new file mode 100644 index 00000000..dfb2c9e0 --- /dev/null +++ b/app/definitions/rest/v1/directory.ts @@ -0,0 +1,13 @@ +import { IServerRoom } from '../../IRoom'; +import { PaginatedResult } from '../helpers/PaginatedResult'; + +export type DirectoryEndpoint = { + directory: { + GET: (params: { + query: { [key: string]: string }; + count: number; + offset: number; + sort: { [key: string]: number }; + }) => PaginatedResult<{ result: IServerRoom[] }>; + }; +}; diff --git a/app/definitions/rest/v1/index.ts b/app/definitions/rest/v1/index.ts index dc1cdcd0..a594a966 100644 --- a/app/definitions/rest/v1/index.ts +++ b/app/definitions/rest/v1/index.ts @@ -17,6 +17,7 @@ import { E2eEndpoints } from './e2e'; import { SubscriptionsEndpoints } from './subscriptions'; import { VideoConferenceEndpoints } from './videoConference'; import { CommandsEndpoints } from './commands'; +import { DirectoryEndpoint } from './directory'; export type Endpoints = ChannelsEndpoints & ChatEndpoints & @@ -36,4 +37,5 @@ export type Endpoints = ChannelsEndpoints & E2eEndpoints & SubscriptionsEndpoints & VideoConferenceEndpoints & - CommandsEndpoints; + CommandsEndpoints & + DirectoryEndpoint; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 721d2f29..0f80f9c3 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -713,10 +713,18 @@ export const executeCommandPreview = ( tmid }); -export const getDirectory = ({ query, count, offset, sort }: { query: any; count: number; offset: number; sort: any }): any => +export const getDirectory = ({ + query, + count, + offset, + sort +}: { + query: { [key: string]: string }; + count: number; + offset: number; + sort: { [key: string]: number }; +}) => // RC 1.0 - // TODO: missing definitions from server - // @ts-ignore sdk.get('directory', { query, count,