@@ -17,16 +17,49 @@ import { updateOAuthApp } from '../../../oauth2-server-config/server/admin/metho
1717import type { ExtractRoutesFromAPI } from '../ApiClass' ;
1818import { API } from '../api' ;
1919
20- API . v1 . addRoute (
20+ const oauthAppsListEndpoints = API . v1 . get (
2121 'oauth-apps.list' ,
22- { authRequired : true , permissionsRequired : [ 'manage-oauth-apps' ] } ,
2322 {
24- async get ( ) {
25- return API . v1 . success ( {
26- oauthApps : await OAuthApps . find ( ) . toArray ( ) ,
27- } ) ;
23+ authRequired : true ,
24+ query : ajv . compile < { uid ?: string } > ( {
25+ type : 'object' ,
26+ properties : {
27+ uid : {
28+ type : 'string' ,
29+ } ,
30+ } ,
31+ additionalProperties : false ,
32+ } ) ,
33+ permissionsRequired : [ 'manage-oauth-apps' ] ,
34+ response : {
35+ 400 : validateBadRequestErrorResponse ,
36+ 401 : validateUnauthorizedErrorResponse ,
37+ 403 : validateForbiddenErrorResponse ,
38+ 200 : ajv . compile < { oauthApps : IOAuthApps [ ] } > ( {
39+ type : 'object' ,
40+ properties : {
41+ oauthApps : {
42+ type : 'array' ,
43+ items : {
44+ $ref : '#/components/schemas/IOAuthApps' ,
45+ } ,
46+ } ,
47+ success : {
48+ type : 'boolean' ,
49+ enum : [ true ] ,
50+ } ,
51+ } ,
52+ required : [ 'oauthApps' , 'success' ] ,
53+ additionalProperties : false ,
54+ } ) ,
2855 } ,
2956 } ,
57+
58+ async function action ( ) {
59+ return API . v1 . success ( {
60+ oauthApps : await OAuthApps . find ( ) . toArray ( ) ,
61+ } ) ;
62+ } ,
3063) ;
3164
3265API . v1 . addRoute (
@@ -199,11 +232,16 @@ type OauthAppsCreateEndpoints = ExtractRoutesFromAPI<typeof oauthAppsCreateEndpo
199232
200233type OauthAppsuUpdateEndpoints = ExtractRoutesFromAPI < typeof oauthAppsuUpdateEndpoints > ;
201234
202- export type OAuthAppsEndpoints = OauthAppsCreateEndpoints | OauthAppsuUpdateEndpoints ;
235+ type OauthAppsListEndpoints = ExtractRoutesFromAPI < typeof oauthAppsListEndpoints > ;
236+
237+ export type OAuthAppsEndpoints = OauthAppsCreateEndpoints | OauthAppsListEndpoints | OauthAppsuUpdateEndpoints ;
238+
203239
204240declare module '@rocket.chat/rest-typings' {
205241 // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
206242 interface Endpoints extends OauthAppsCreateEndpoints { }
207243 // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
208244 interface Endpoints extends OauthAppsuUpdateEndpoints { }
245+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
246+ interface Endpoints extends OauthAppsListEndpoints { }
209247}
0 commit comments