From 8058093241e88aa2ad125ac2b552fc0b4320eb4a Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Tue, 23 Jul 2019 11:25:26 +0200 Subject: [PATCH] core doesn't use Record for public API (#41448) (#41742) * core contracts don't use unknown to support type assignment limitations of https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#-k-string-unknown--is-no-longer-a-wildcard-assignment-target * regenereate docs * remove type over-write --- .../core/server/kibana-plugin-server.apicaller.md | 2 +- .../core/server/kibana-plugin-server.authresultdata.md | 2 +- .../kibana-plugin-server.authresultdata.state.md | 2 +- ...a-plugin-server.clusterclient.callasinternaluser.md | 2 +- .../core/server/kibana-plugin-server.clusterclient.md | 2 +- ...gin-server.scopedclusterclient.callascurrentuser.md | 4 ++-- ...in-server.scopedclusterclient.callasinternaluser.md | 4 ++-- src/core/server/elasticsearch/cluster_client.ts | 6 +++--- src/core/server/elasticsearch/scoped_cluster_client.ts | 6 +++--- src/core/server/http/http_server.mocks.ts | 6 +++--- src/core/server/http/lifecycle/auth.ts | 2 +- src/core/server/server.api.md | 10 +++++----- x-pack/plugins/security/server/authentication/index.ts | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/development/core/server/kibana-plugin-server.apicaller.md b/docs/development/core/server/kibana-plugin-server.apicaller.md index c4696551f0a49..10065a4089ce5 100644 --- a/docs/development/core/server/kibana-plugin-server.apicaller.md +++ b/docs/development/core/server/kibana-plugin-server.apicaller.md @@ -8,5 +8,5 @@ Signature: ```typescript -export declare type APICaller = (endpoint: string, clientParams: Record, options?: CallAPIOptions) => Promise; +export declare type APICaller = (endpoint: string, clientParams: Record, options?: CallAPIOptions) => Promise; ``` diff --git a/docs/development/core/server/kibana-plugin-server.authresultdata.md b/docs/development/core/server/kibana-plugin-server.authresultdata.md index 7ba5771b80d67..57908bd704591 100644 --- a/docs/development/core/server/kibana-plugin-server.authresultdata.md +++ b/docs/development/core/server/kibana-plugin-server.authresultdata.md @@ -17,5 +17,5 @@ export interface AuthResultData | Property | Type | Description | | --- | --- | --- | | [headers](./kibana-plugin-server.authresultdata.headers.md) | AuthHeaders | Auth specific headers to authenticate a user against Elasticsearch. | -| [state](./kibana-plugin-server.authresultdata.state.md) | Record<string, unknown> | Data to associate with an incoming request. Any downstream plugin may get access to the data. | +| [state](./kibana-plugin-server.authresultdata.state.md) | Record<string, any> | Data to associate with an incoming request. Any downstream plugin may get access to the data. | diff --git a/docs/development/core/server/kibana-plugin-server.authresultdata.state.md b/docs/development/core/server/kibana-plugin-server.authresultdata.state.md index 3fb8f8e48bded..70054395514b7 100644 --- a/docs/development/core/server/kibana-plugin-server.authresultdata.state.md +++ b/docs/development/core/server/kibana-plugin-server.authresultdata.state.md @@ -9,5 +9,5 @@ Data to associate with an incoming request. Any downstream plugin may get access Signature: ```typescript -state: Record; +state: Record; ``` diff --git a/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md b/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md index b00e83dd43d52..0b314c5670365 100644 --- a/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md +++ b/docs/development/core/server/kibana-plugin-server.clusterclient.callasinternaluser.md @@ -9,5 +9,5 @@ Calls specified endpoint with provided clientParams on behalf of the Kibana inte Signature: ```typescript -callAsInternalUser: (endpoint: string, clientParams?: Record, options?: CallAPIOptions | undefined) => Promise; +callAsInternalUser: (endpoint: string, clientParams?: Record, options?: CallAPIOptions | undefined) => Promise; ``` diff --git a/docs/development/core/server/kibana-plugin-server.clusterclient.md b/docs/development/core/server/kibana-plugin-server.clusterclient.md index 89ed51762198c..07c1006dda499 100644 --- a/docs/development/core/server/kibana-plugin-server.clusterclient.md +++ b/docs/development/core/server/kibana-plugin-server.clusterclient.md @@ -22,7 +22,7 @@ export declare class ClusterClient | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [callAsInternalUser](./kibana-plugin-server.clusterclient.callasinternaluser.md) | | (endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions | undefined) => Promise<any> | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. | +| [callAsInternalUser](./kibana-plugin-server.clusterclient.callasinternaluser.md) | | (endpoint: string, clientParams?: Record<string, any>, options?: CallAPIOptions | undefined) => Promise<any> | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. | ## Methods diff --git a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md index 4e462612ba103..f96554296e653 100644 --- a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md +++ b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callascurrentuser.md @@ -9,7 +9,7 @@ Calls specified `endpoint` with provided `clientParams` on behalf of the user in Signature: ```typescript -callAsCurrentUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; +callAsCurrentUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; ``` ## Parameters @@ -17,7 +17,7 @@ callAsCurrentUser(endpoint: string, clientParams?: Record, opti | Parameter | Type | Description | | --- | --- | --- | | endpoint | string | String descriptor of the endpoint e.g. cluster.getSettings or ping. | -| clientParams | Record<string, unknown> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. | +| clientParams | Record<string, any> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. | | options | CallAPIOptions | Options that affect the way we call the API and process the result. | Returns: diff --git a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md index e79abfcf81db0..395d65197e2cc 100644 --- a/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md +++ b/docs/development/core/server/kibana-plugin-server.scopedclusterclient.callasinternaluser.md @@ -9,7 +9,7 @@ Calls specified `endpoint` with provided `clientParams` on behalf of the Kibana Signature: ```typescript -callAsInternalUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; +callAsInternalUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; ``` ## Parameters @@ -17,7 +17,7 @@ callAsInternalUser(endpoint: string, clientParams?: Record, opt | Parameter | Type | Description | | --- | --- | --- | | endpoint | string | String descriptor of the endpoint e.g. cluster.getSettings or ping. | -| clientParams | Record<string, unknown> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. | +| clientParams | Record<string, any> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. | | options | CallAPIOptions | Options that affect the way we call the API and process the result. | Returns: diff --git a/src/core/server/elasticsearch/cluster_client.ts b/src/core/server/elasticsearch/cluster_client.ts index a451bd549f956..c8500499d9702 100644 --- a/src/core/server/elasticsearch/cluster_client.ts +++ b/src/core/server/elasticsearch/cluster_client.ts @@ -70,7 +70,7 @@ export interface CallAPIOptions { async function callAPI( client: Client, endpoint: string, - clientParams: Record = {}, + clientParams: Record = {}, options: CallAPIOptions = { wrap401Errors: true } ): Promise { const clientPath = endpoint.split('.'); @@ -150,7 +150,7 @@ export class ClusterClient { */ public callAsInternalUser = async ( endpoint: string, - clientParams: Record = {}, + clientParams: Record = {}, options?: CallAPIOptions ) => { this.assertIsNotClosed(); @@ -216,7 +216,7 @@ export class ClusterClient { */ private callAsCurrentUser = async ( endpoint: string, - clientParams: Record = {}, + clientParams: Record = {}, options?: CallAPIOptions ) => { this.assertIsNotClosed(); diff --git a/src/core/server/elasticsearch/scoped_cluster_client.ts b/src/core/server/elasticsearch/scoped_cluster_client.ts index 86b3df9460a16..d89a15e336b33 100644 --- a/src/core/server/elasticsearch/scoped_cluster_client.ts +++ b/src/core/server/elasticsearch/scoped_cluster_client.ts @@ -27,7 +27,7 @@ export { Headers }; /** @public */ export type APICaller = ( endpoint: string, - clientParams: Record, + clientParams: Record, options?: CallAPIOptions ) => Promise; @@ -58,7 +58,7 @@ export class ScopedClusterClient { */ public callAsInternalUser( endpoint: string, - clientParams: Record = {}, + clientParams: Record = {}, options?: CallAPIOptions ) { return this.internalAPICaller(endpoint, clientParams, options); @@ -73,7 +73,7 @@ export class ScopedClusterClient { */ public callAsCurrentUser( endpoint: string, - clientParams: Record = {}, + clientParams: Record = {}, options?: CallAPIOptions ) { const defaultHeaders = this.headers; diff --git a/src/core/server/http/http_server.mocks.ts b/src/core/server/http/http_server.mocks.ts index fbf98aa4f9c99..bb52fa1fa38df 100644 --- a/src/core/server/http/http_server.mocks.ts +++ b/src/core/server/http/http_server.mocks.ts @@ -27,9 +27,9 @@ import { KibanaRequest, RouteMethod } from './router'; interface RequestFixtureOptions { headers?: Record; - params?: Record; - body?: Record; - query?: Record; + params?: Record; + body?: Record; + query?: Record; path?: string; method?: RouteMethod; } diff --git a/src/core/server/http/lifecycle/auth.ts b/src/core/server/http/lifecycle/auth.ts index b866c00a756cc..8319d52c2e884 100644 --- a/src/core/server/http/lifecycle/auth.ts +++ b/src/core/server/http/lifecycle/auth.ts @@ -92,7 +92,7 @@ export interface AuthResultData { /** * Data to associate with an incoming request. Any downstream plugin may get access to the data. */ - state: Record; + state: Record; /** * Auth specific headers to authenticate a user against Elasticsearch. */ diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index a6fbfebf9d947..952a4e7ba815e 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -21,7 +21,7 @@ import { TypeOf } from '@kbn/config-schema'; import { Url } from 'url'; // @public (undocumented) -export type APICaller = (endpoint: string, clientParams: Record, options?: CallAPIOptions) => Promise; +export type APICaller = (endpoint: string, clientParams: Record, options?: CallAPIOptions) => Promise; // Warning: (ae-forgotten-export) The symbol "AuthResult" needs to be exported by the entry point index.d.ts // @@ -34,7 +34,7 @@ export type AuthHeaders = Record; // @public export interface AuthResultData { headers: AuthHeaders; - state: Record; + state: Record; } // @public @@ -61,7 +61,7 @@ export interface CallAPIOptions { export class ClusterClient { constructor(config: ElasticsearchClientConfig, log: Logger, getAuthHeaders?: GetAuthHeaders); asScoped(request?: KibanaRequest | LegacyRequest | FakeRequest): ScopedClusterClient; - callAsInternalUser: (endpoint: string, clientParams?: Record, options?: CallAPIOptions | undefined) => Promise; + callAsInternalUser: (endpoint: string, clientParams?: Record, options?: CallAPIOptions | undefined) => Promise; close(): void; } @@ -670,8 +670,8 @@ export interface SavedObjectsUpdateResponse | undefined); - callAsCurrentUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; - callAsInternalUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; + callAsCurrentUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; + callAsInternalUser(endpoint: string, clientParams?: Record, options?: CallAPIOptions): Promise; } // @public diff --git a/x-pack/plugins/security/server/authentication/index.ts b/x-pack/plugins/security/server/authentication/index.ts index ccb359dd4b45e..58ac9db47ba09 100644 --- a/x-pack/plugins/security/server/authentication/index.ts +++ b/x-pack/plugins/security/server/authentication/index.ts @@ -106,7 +106,7 @@ export async function setupAuthentication({ if (authenticationResult.succeeded()) { return t.authenticated({ - state: (authenticationResult.user as unknown) as Record, + state: authenticationResult.user, headers: authenticationResult.authHeaders, }); }