Skip to content

Commit

Permalink
[Reporting] Removed any from public (#110993) (#111413)
Browse files Browse the repository at this point in the history
* removed anys and ran TS organize imports

* updated jest snapshots

* fix import paths for non-type imports

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
jloleysens and kibanamachine authored Sep 7, 2021
1 parent 12d2978 commit 4cf8987
Show file tree
Hide file tree
Showing 9 changed files with 722 additions and 116 deletions.
41 changes: 25 additions & 16 deletions x-pack/plugins/reporting/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { SerializableRecord } from '@kbn/utility-types';
import type { Ensure, SerializableRecord } from '@kbn/utility-types';

export interface PageSizeParams {
pageMarginTop: number;
Expand All @@ -21,15 +21,21 @@ export interface PdfImageSize {
height?: number;
}

export interface Size {
width: number;
height: number;
}
export type Size = Ensure<
{
width: number;
height: number;
},
SerializableRecord
>;

export interface LayoutParams {
id: string;
dimensions?: Size;
}
export type LayoutParams = Ensure<
{
id: string;
dimensions?: Size;
},
SerializableRecord
>;

export interface ReportDocumentHead {
_id: string;
Expand All @@ -50,13 +56,16 @@ export interface TaskRunResult {
warnings?: string[];
}

export interface BaseParams {
layout?: LayoutParams;
objectType: string;
title: string;
browserTimezone: string; // to format dates in the user's time zone
version: string; // to handle any state migrations
}
export type BaseParams = Ensure<
{
layout?: LayoutParams;
objectType: string;
title: string;
browserTimezone: string; // to format dates in the user's time zone
version: string; // to handle any state migrations
},
SerializableRecord
>;

// base params decorated with encrypted headers that come into runJob functions
export interface BasePayload extends BaseParams {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/reporting/public/lib/license_check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import type { LicenseCheck } from '../shared_imports';
import { checkLicense } from './license_check';

describe('License check', () => {
Expand Down Expand Up @@ -42,7 +43,7 @@ describe('License check', () => {
});

it('shows and enables links if state is not known', () => {
expect(checkLicense({ state: 'PONYFOO' } as any)).toEqual({
expect(checkLicense(({ state: 'PONYFOO' } as unknown) as LicenseCheck)).toEqual({
enableLinks: true,
showLinks: true,
message: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import moment from 'moment';
import { stringify } from 'query-string';
import rison, { RisonObject } from 'rison-node';
import rison from 'rison-node';
import type { HttpFetchQuery } from 'src/core/public';
import { HttpSetup, IUiSettingsClient } from 'src/core/public';
import {
API_BASE_GENERATE,
Expand Down Expand Up @@ -45,7 +45,7 @@ interface IReportingAPI {
// Helpers
getReportURL(jobId: string): string;
getReportingJobPath<T>(exportType: string, jobParams: BaseParams & T): string; // Return a URL to queue a job, with the job params encoded in the query string of the URL. Used for copying POST URL
createReportingJob(exportType: string, jobParams: any): Promise<Job>; // Sends a request to queue a job, with the job params in the POST body
createReportingJob<T>(exportType: string, jobParams: BaseParams & T): Promise<Job>; // Sends a request to queue a job, with the job params in the POST body
getServerBasePath(): string; // Provides the raw server basePath to allow it to be stripped out from relativeUrls in job params

// CRUD
Expand Down Expand Up @@ -93,7 +93,7 @@ export class ReportingAPIClient implements IReportingAPI {
}

public async list(page = 0, jobIds: string[] = []) {
const query = { page } as any;
const query: HttpFetchQuery = { page };
if (jobIds.length > 0) {
// Only getting the first 10, to prevent URL overflows
query.ids = jobIds.slice(0, 10).join(',');
Expand Down Expand Up @@ -143,14 +143,14 @@ export class ReportingAPIClient implements IReportingAPI {
}

public getReportingJobPath(exportType: string, jobParams: BaseParams) {
const risonObject: RisonObject = jobParams as Record<string, any>;
const params = stringify({ jobParams: rison.encode(risonObject) });
const params = stringify({
jobParams: rison.encode(jobParams),
});
return `${this.http.basePath.prepend(API_BASE_GENERATE)}/${exportType}?${params}`;
}

public async createReportingJob(exportType: string, jobParams: BaseParams) {
const risonObject: RisonObject = jobParams as Record<string, any>;
const jobParamsRison = rison.encode(risonObject);
const jobParamsRison = rison.encode(jobParams);
const resp: { job: ReportApiJSON } = await this.http.post(
`${API_BASE_GENERATE}/${exportType}`,
{
Expand Down
Loading

0 comments on commit 4cf8987

Please sign in to comment.