1- const { BaseController } = require ( './Base' ) ;
2- const { Role } = require ( '../core/security/Role' ) ;
3- const { RoleSearchResult } = require ( '../core/searchResult/Role' ) ;
4- const { Profile } = require ( '../core/security/Profile' ) ;
5- const { ProfileSearchResult } = require ( '../core/searchResult/Profile' ) ;
6- const { User } = require ( '../core/security/User' ) ;
7- const { UserSearchResult } = require ( '../core/searchResult/User' ) ;
8-
9- class SecurityController extends BaseController {
1+ import { BaseController } from './Base' ;
2+ import { Role } from '../core/security/Role' ;
3+ import { RoleSearchResult } from '../core/searchResult/Role' ;
4+ import { Profile } from '../core/security/Profile' ;
5+ import { ProfileSearchResult } from '../core/searchResult/Profile' ;
6+ import { User } from '../core/security/User' ;
7+ import { UserSearchResult } from '../core/searchResult/User' ;
8+
9+ export class SecurityController extends BaseController {
1010 /**
1111 * @param {Kuzzle } kuzzle
1212 */
@@ -23,7 +23,14 @@ class SecurityController extends BaseController {
2323 *
2424 * @returns {Promise.<Object> } ApiKey { _id, _source }
2525 */
26- createApiKey ( userId , description , options = { } ) {
26+ createApiKey (
27+ userId ,
28+ description ,
29+ options : {
30+ expiresIn ?: string | number ,
31+ _id ?: string ,
32+ refresh ?: 'wait_for' ,
33+ } = { } ) {
2734 const request = {
2835 userId,
2936 action : 'createApiKey' ,
@@ -65,16 +72,20 @@ class SecurityController extends BaseController {
6572 *
6673 * @returns {Promise }
6774 */
68- deleteApiKey ( userId , id , options = { } ) {
75+ deleteApiKey (
76+ userId ,
77+ id ,
78+ options : {
79+ refresh ?: 'wait_for' ,
80+ } = { } ) {
6981 const request = {
7082 userId,
7183 action : 'deleteApiKey' ,
7284 _id : id ,
7385 refresh : options . refresh
7486 } ;
7587
76- return this . query ( request )
77- . then ( ( ) => { } ) ;
88+ return this . query ( request ) ;
7889 }
7990
8091 /**
@@ -86,7 +97,15 @@ class SecurityController extends BaseController {
8697 *
8798 * @returns {Promise.<object[]> } - { hits, total }
8899 */
89- searchApiKeys ( userId , query = { } , options = { } ) {
100+ searchApiKeys (
101+ userId ,
102+ query = { } ,
103+ options : {
104+ from ?: number ,
105+ size ?: number ,
106+ lang ?: string ,
107+ } = { }
108+ ) {
90109 const request = {
91110 userId,
92111 action : 'searchApiKeys' ,
@@ -110,7 +129,13 @@ class SecurityController extends BaseController {
110129 . then ( response => response . result ) ;
111130 }
112131
113- createFirstAdmin ( _id , body , options = { } ) {
132+ createFirstAdmin (
133+ _id ,
134+ body ,
135+ options : {
136+ reset ?: boolean ,
137+ } = { }
138+ ) {
114139 const request = {
115140 _id,
116141 body,
@@ -136,7 +161,13 @@ class SecurityController extends BaseController {
136161 response . result . _source ) ) ;
137162 }
138163
139- createOrReplaceRole ( _id , body , options = { } ) {
164+ createOrReplaceRole (
165+ _id ,
166+ body ,
167+ options : {
168+ force ?: boolean ,
169+ } = { }
170+ ) {
140171 const request = {
141172 _id,
142173 body,
@@ -176,7 +207,7 @@ class SecurityController extends BaseController {
176207 . then ( response => new User ( this . kuzzle , response . result . _id , response . result . _source ) ) ;
177208 }
178209
179- createRole ( _id , body , options = { } ) {
210+ createRole ( _id , body , options : { force ?: boolean , } = { } ) {
180211 const request = {
181212 _id,
182213 body,
@@ -489,7 +520,7 @@ class SecurityController extends BaseController {
489520 . then ( response => response . result ) ;
490521 }
491522
492- updateRole ( _id , body , options = { } ) {
523+ updateRole ( _id , body , options : { force ?: boolean , } = { } ) {
493524 const request = {
494525 _id,
495526 body,
@@ -537,5 +568,3 @@ class SecurityController extends BaseController {
537568 . then ( response => response . result ) ;
538569 }
539570}
540-
541- module . exports = { SecurityController } ;
0 commit comments