core doesn't use Record<string, unknown> 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
This commit is contained in:
Mikhail Shustov 2019-07-23 11:25:26 +02:00 committed by GitHub
parent cf8b37925d
commit 8058093241
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 25 additions and 25 deletions

View file

@ -8,5 +8,5 @@
<b>Signature:</b>
```typescript
export declare type APICaller = (endpoint: string, clientParams: Record<string, unknown>, options?: CallAPIOptions) => Promise<unknown>;
export declare type APICaller = (endpoint: string, clientParams: Record<string, any>, options?: CallAPIOptions) => Promise<unknown>;
```

View file

@ -17,5 +17,5 @@ export interface AuthResultData
| Property | Type | Description |
| --- | --- | --- |
| [headers](./kibana-plugin-server.authresultdata.headers.md) | <code>AuthHeaders</code> | Auth specific headers to authenticate a user against Elasticsearch. |
| [state](./kibana-plugin-server.authresultdata.state.md) | <code>Record&lt;string, unknown&gt;</code> | Data to associate with an incoming request. Any downstream plugin may get access to the data. |
| [state](./kibana-plugin-server.authresultdata.state.md) | <code>Record&lt;string, any&gt;</code> | Data to associate with an incoming request. Any downstream plugin may get access to the data. |

View file

@ -9,5 +9,5 @@ Data to associate with an incoming request. Any downstream plugin may get access
<b>Signature:</b>
```typescript
state: Record<string, unknown>;
state: Record<string, any>;
```

View file

@ -9,5 +9,5 @@ Calls specified endpoint with provided clientParams on behalf of the Kibana inte
<b>Signature:</b>
```typescript
callAsInternalUser: (endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions | undefined) => Promise<any>;
callAsInternalUser: (endpoint: string, clientParams?: Record<string, any>, options?: CallAPIOptions | undefined) => Promise<any>;
```

View file

@ -22,7 +22,7 @@ export declare class ClusterClient
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [callAsInternalUser](./kibana-plugin-server.clusterclient.callasinternaluser.md) | | <code>(endpoint: string, clientParams?: Record&lt;string, unknown&gt;, options?: CallAPIOptions &#124; undefined) =&gt; Promise&lt;any&gt;</code> | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. |
| [callAsInternalUser](./kibana-plugin-server.clusterclient.callasinternaluser.md) | | <code>(endpoint: string, clientParams?: Record&lt;string, any&gt;, options?: CallAPIOptions &#124; undefined) =&gt; Promise&lt;any&gt;</code> | Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. |
## Methods

View file

@ -9,7 +9,7 @@ Calls specified `endpoint` with provided `clientParams` on behalf of the user in
<b>Signature:</b>
```typescript
callAsCurrentUser(endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions): Promise<unknown>;
callAsCurrentUser(endpoint: string, clientParams?: Record<string, any>, options?: CallAPIOptions): Promise<unknown>;
```
## Parameters
@ -17,7 +17,7 @@ callAsCurrentUser(endpoint: string, clientParams?: Record<string, unknown>, opti
| Parameter | Type | Description |
| --- | --- | --- |
| endpoint | <code>string</code> | String descriptor of the endpoint e.g. <code>cluster.getSettings</code> or <code>ping</code>. |
| clientParams | <code>Record&lt;string, unknown&gt;</code> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. |
| clientParams | <code>Record&lt;string, any&gt;</code> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. |
| options | <code>CallAPIOptions</code> | Options that affect the way we call the API and process the result. |
<b>Returns:</b>

View file

@ -9,7 +9,7 @@ Calls specified `endpoint` with provided `clientParams` on behalf of the Kibana
<b>Signature:</b>
```typescript
callAsInternalUser(endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions): Promise<unknown>;
callAsInternalUser(endpoint: string, clientParams?: Record<string, any>, options?: CallAPIOptions): Promise<unknown>;
```
## Parameters
@ -17,7 +17,7 @@ callAsInternalUser(endpoint: string, clientParams?: Record<string, unknown>, opt
| Parameter | Type | Description |
| --- | --- | --- |
| endpoint | <code>string</code> | String descriptor of the endpoint e.g. <code>cluster.getSettings</code> or <code>ping</code>. |
| clientParams | <code>Record&lt;string, unknown&gt;</code> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. |
| clientParams | <code>Record&lt;string, any&gt;</code> | A dictionary of parameters that will be passed directly to the Elasticsearch JS client. |
| options | <code>CallAPIOptions</code> | Options that affect the way we call the API and process the result. |
<b>Returns:</b>

View file

@ -70,7 +70,7 @@ export interface CallAPIOptions {
async function callAPI(
client: Client,
endpoint: string,
clientParams: Record<string, unknown> = {},
clientParams: Record<string, any> = {},
options: CallAPIOptions = { wrap401Errors: true }
): Promise<any> {
const clientPath = endpoint.split('.');
@ -150,7 +150,7 @@ export class ClusterClient {
*/
public callAsInternalUser = async (
endpoint: string,
clientParams: Record<string, unknown> = {},
clientParams: Record<string, any> = {},
options?: CallAPIOptions
) => {
this.assertIsNotClosed();
@ -216,7 +216,7 @@ export class ClusterClient {
*/
private callAsCurrentUser = async (
endpoint: string,
clientParams: Record<string, unknown> = {},
clientParams: Record<string, any> = {},
options?: CallAPIOptions
) => {
this.assertIsNotClosed();

View file

@ -27,7 +27,7 @@ export { Headers };
/** @public */
export type APICaller = (
endpoint: string,
clientParams: Record<string, unknown>,
clientParams: Record<string, any>,
options?: CallAPIOptions
) => Promise<unknown>;
@ -58,7 +58,7 @@ export class ScopedClusterClient {
*/
public callAsInternalUser(
endpoint: string,
clientParams: Record<string, unknown> = {},
clientParams: Record<string, any> = {},
options?: CallAPIOptions
) {
return this.internalAPICaller(endpoint, clientParams, options);
@ -73,7 +73,7 @@ export class ScopedClusterClient {
*/
public callAsCurrentUser(
endpoint: string,
clientParams: Record<string, unknown> = {},
clientParams: Record<string, any> = {},
options?: CallAPIOptions
) {
const defaultHeaders = this.headers;

View file

@ -27,9 +27,9 @@ import { KibanaRequest, RouteMethod } from './router';
interface RequestFixtureOptions {
headers?: Record<string, string>;
params?: Record<string, unknown>;
body?: Record<string, unknown>;
query?: Record<string, unknown>;
params?: Record<string, any>;
body?: Record<string, any>;
query?: Record<string, any>;
path?: string;
method?: RouteMethod;
}

View file

@ -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<string, unknown>;
state: Record<string, any>;
/**
* Auth specific headers to authenticate a user against Elasticsearch.
*/

View file

@ -21,7 +21,7 @@ import { TypeOf } from '@kbn/config-schema';
import { Url } from 'url';
// @public (undocumented)
export type APICaller = (endpoint: string, clientParams: Record<string, unknown>, options?: CallAPIOptions) => Promise<unknown>;
export type APICaller = (endpoint: string, clientParams: Record<string, any>, options?: CallAPIOptions) => Promise<unknown>;
// 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<string, string>;
// @public
export interface AuthResultData {
headers: AuthHeaders;
state: Record<string, unknown>;
state: Record<string, any>;
}
// @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<string, unknown>, options?: CallAPIOptions | undefined) => Promise<any>;
callAsInternalUser: (endpoint: string, clientParams?: Record<string, any>, options?: CallAPIOptions | undefined) => Promise<any>;
close(): void;
}
@ -670,8 +670,8 @@ export interface SavedObjectsUpdateResponse<T extends SavedObjectAttributes = an
// @public
export class ScopedClusterClient {
constructor(internalAPICaller: APICaller, scopedAPICaller: APICaller, headers?: Record<string, string | string[] | undefined> | undefined);
callAsCurrentUser(endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions): Promise<unknown>;
callAsInternalUser(endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions): Promise<unknown>;
callAsCurrentUser(endpoint: string, clientParams?: Record<string, any>, options?: CallAPIOptions): Promise<unknown>;
callAsInternalUser(endpoint: string, clientParams?: Record<string, any>, options?: CallAPIOptions): Promise<unknown>;
}
// @public

View file

@ -106,7 +106,7 @@ export async function setupAuthentication({
if (authenticationResult.succeeded()) {
return t.authenticated({
state: (authenticationResult.user as unknown) as Record<string, unknown>,
state: authenticationResult.user,
headers: authenticationResult.authHeaders,
});
}