mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Reporting] Add deprecation flag for v1 PDF and PNG export types (#123235)
* Rename deprecated reporting jobs parameters interfaces * Add deprecation flag to the deprecated reporting jobs payloads
This commit is contained in:
parent
8b2c40bcb5
commit
f4046b7f56
11 changed files with 54 additions and 40 deletions
|
@ -15,7 +15,10 @@ interface BaseParamsPNG {
|
|||
}
|
||||
|
||||
// Job params: structure of incoming user request data
|
||||
export type JobParamsPNG = BaseParamsPNG & BaseParams;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export type JobParamsPNGDeprecated = BaseParamsPNG & BaseParams;
|
||||
|
||||
// Job payload: structure of stored job data provided by create_job
|
||||
export type TaskPayloadPNG = BaseParamsPNG & BasePayload;
|
||||
|
|
|
@ -15,9 +15,12 @@ interface BaseParamsPDF {
|
|||
}
|
||||
|
||||
// Job params: structure of incoming user request data, after being parsed from RISON
|
||||
export type JobParamsPDF = BaseParamsPDF & BaseParams;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export type JobParamsPDFDeprecated = BaseParamsPDF & BaseParams;
|
||||
|
||||
export type JobAppParamsPDF = Omit<JobParamsPDF, 'browserTimezone' | 'version'>;
|
||||
export type JobAppParamsPDF = Omit<JobParamsPDFDeprecated, 'browserTimezone' | 'version'>;
|
||||
|
||||
// Job payload: structure of stored job data provided by create_job
|
||||
export interface TaskPayloadPDF extends BasePayload {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
import type { BaseParams, BaseParamsV2, BasePayload, BasePayloadV2, JobId } from './base';
|
||||
|
||||
export type { JobParamsPNG } from './export_types/png';
|
||||
export type { JobParamsPNGDeprecated } from './export_types/png';
|
||||
export type { JobParamsPNGV2 } from './export_types/png_v2';
|
||||
export type { JobAppParamsPDF, JobParamsPDF } from './export_types/printable_pdf';
|
||||
export type { JobAppParamsPDF, JobParamsPDFDeprecated } from './export_types/printable_pdf';
|
||||
export type { JobAppParamsPDFV2, JobParamsPDFV2 } from './export_types/printable_pdf_v2';
|
||||
export type {
|
||||
DownloadReportFn,
|
||||
|
|
|
@ -7,16 +7,18 @@
|
|||
|
||||
import { CreateJobFn, CreateJobFnFactory } from '../../../types';
|
||||
import { validateUrls } from '../../common';
|
||||
import { JobParamsPNG, TaskPayloadPNG } from '../types';
|
||||
import { JobParamsPNGDeprecated, TaskPayloadPNG } from '../types';
|
||||
|
||||
export const createJobFnFactory: CreateJobFnFactory<CreateJobFn<JobParamsPNG, TaskPayloadPNG>> =
|
||||
function createJobFactoryFn() {
|
||||
return async function createJob(jobParams) {
|
||||
validateUrls([jobParams.relativeUrl]);
|
||||
export const createJobFnFactory: CreateJobFnFactory<
|
||||
CreateJobFn<JobParamsPNGDeprecated, TaskPayloadPNG>
|
||||
> = function createJobFactoryFn() {
|
||||
return async function createJob(jobParams) {
|
||||
validateUrls([jobParams.relativeUrl]);
|
||||
|
||||
return {
|
||||
...jobParams,
|
||||
forceNow: new Date().toISOString(),
|
||||
};
|
||||
return {
|
||||
...jobParams,
|
||||
isDeprecated: true,
|
||||
forceNow: new Date().toISOString(),
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,10 +17,10 @@ import { CreateJobFn, ExportTypeDefinition, RunTaskFn } from '../../types';
|
|||
import { createJobFnFactory } from './create_job';
|
||||
import { runTaskFnFactory } from './execute_job';
|
||||
import { metadata } from './metadata';
|
||||
import { JobParamsPNG, TaskPayloadPNG } from './types';
|
||||
import { JobParamsPNGDeprecated, TaskPayloadPNG } from './types';
|
||||
|
||||
export const getExportType = (): ExportTypeDefinition<
|
||||
CreateJobFn<JobParamsPNG>,
|
||||
CreateJobFn<JobParamsPNGDeprecated>,
|
||||
RunTaskFn<TaskPayloadPNG>
|
||||
> => ({
|
||||
...metadata,
|
||||
|
|
|
@ -5,4 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export type { JobParamsPNG, TaskPayloadPNG } from '../../../common/types/export_types/png';
|
||||
export type {
|
||||
JobParamsPNGDeprecated,
|
||||
TaskPayloadPNG,
|
||||
} from '../../../common/types/export_types/png';
|
||||
|
|
|
@ -7,20 +7,22 @@
|
|||
|
||||
import { CreateJobFn, CreateJobFnFactory } from '../../../types';
|
||||
import { validateUrls } from '../../common';
|
||||
import { JobParamsPDF, TaskPayloadPDF } from '../types';
|
||||
import { JobParamsPDFDeprecated, TaskPayloadPDF } from '../types';
|
||||
|
||||
export const createJobFnFactory: CreateJobFnFactory<CreateJobFn<JobParamsPDF, TaskPayloadPDF>> =
|
||||
function createJobFactoryFn() {
|
||||
return async function createJobFn(
|
||||
{ relativeUrls, ...jobParams }: JobParamsPDF // relativeUrls does not belong in the payload of PDFV1
|
||||
) {
|
||||
validateUrls(relativeUrls);
|
||||
export const createJobFnFactory: CreateJobFnFactory<
|
||||
CreateJobFn<JobParamsPDFDeprecated, TaskPayloadPDF>
|
||||
> = function createJobFactoryFn() {
|
||||
return async function createJobFn(
|
||||
{ relativeUrls, ...jobParams }: JobParamsPDFDeprecated // relativeUrls does not belong in the payload of PDFV1
|
||||
) {
|
||||
validateUrls(relativeUrls);
|
||||
|
||||
// return the payload
|
||||
return {
|
||||
...jobParams,
|
||||
forceNow: new Date().toISOString(),
|
||||
objects: relativeUrls.map((u) => ({ relativeUrl: u })),
|
||||
};
|
||||
// return the payload
|
||||
return {
|
||||
...jobParams,
|
||||
isDeprecated: true,
|
||||
forceNow: new Date().toISOString(),
|
||||
objects: relativeUrls.map((u) => ({ relativeUrl: u })),
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,10 +17,10 @@ import { CreateJobFn, ExportTypeDefinition, RunTaskFn } from '../../types';
|
|||
import { createJobFnFactory } from './create_job';
|
||||
import { runTaskFnFactory } from './execute_job';
|
||||
import { metadata } from './metadata';
|
||||
import { JobParamsPDF, TaskPayloadPDF } from './types';
|
||||
import { JobParamsPDFDeprecated, TaskPayloadPDF } from './types';
|
||||
|
||||
export const getExportType = (): ExportTypeDefinition<
|
||||
CreateJobFn<JobParamsPDF>,
|
||||
CreateJobFn<JobParamsPDFDeprecated>,
|
||||
RunTaskFn<TaskPayloadPDF>
|
||||
> => ({
|
||||
...metadata,
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
*/
|
||||
|
||||
export type {
|
||||
JobParamsPDF,
|
||||
JobParamsPDFDeprecated,
|
||||
TaskPayloadPDF,
|
||||
} from '../../../common/types/export_types/printable_pdf';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { KibanaRequest, KibanaResponseFactory } from 'kibana/server';
|
||||
import { coreMock, httpServerMock } from 'src/core/server/mocks';
|
||||
import { ReportingCore } from '../..';
|
||||
import { JobParamsPDF, TaskPayloadPDF } from '../../export_types/printable_pdf/types';
|
||||
import { JobParamsPDFDeprecated, TaskPayloadPDF } from '../../export_types/printable_pdf/types';
|
||||
import { Report, ReportingStore } from '../../lib/store';
|
||||
import { ReportApiJSON } from '../../lib/store/report';
|
||||
import {
|
||||
|
@ -52,7 +52,7 @@ describe('Handle request to generate', () => {
|
|||
let mockResponseFactory: ReturnType<typeof getMockResponseFactory>;
|
||||
let requestHandler: RequestHandler;
|
||||
|
||||
const mockJobParams: JobParamsPDF = {
|
||||
const mockJobParams: JobParamsPDFDeprecated = {
|
||||
browserTimezone: 'UTC',
|
||||
objectType: 'cool_object_type',
|
||||
title: 'cool_title',
|
||||
|
@ -110,7 +110,7 @@ describe('Handle request to generate', () => {
|
|||
"kibana_name": undefined,
|
||||
"max_attempts": undefined,
|
||||
"meta": Object {
|
||||
"isDeprecated": undefined,
|
||||
"isDeprecated": true,
|
||||
"layout": "preserve_layout",
|
||||
"objectType": "cool_object_type",
|
||||
},
|
||||
|
@ -127,6 +127,7 @@ describe('Handle request to generate', () => {
|
|||
Object {
|
||||
"browserTimezone": "UTC",
|
||||
"headers": "hello mock cypher text",
|
||||
"isDeprecated": true,
|
||||
"layout": Object {
|
||||
"id": "preserve_layout",
|
||||
},
|
||||
|
|
|
@ -12,8 +12,8 @@ import {
|
|||
} from '../../../plugins/reporting/common/constants';
|
||||
import { JobParamsCSV } from '../../../plugins/reporting/server/export_types/csv_searchsource/types';
|
||||
import { JobParamsDownloadCSV } from '../../../plugins/reporting/server/export_types/csv_searchsource_immediate/types';
|
||||
import { JobParamsPNG } from '../../../plugins/reporting/server/export_types/png/types';
|
||||
import { JobParamsPDF } from '../../../plugins/reporting/server/export_types/printable_pdf/types';
|
||||
import { JobParamsPNGDeprecated } from '../../../plugins/reporting/server/export_types/png/types';
|
||||
import { JobParamsPDFDeprecated } from '../../../plugins/reporting/server/export_types/printable_pdf/types';
|
||||
import { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
function removeWhitespace(str: string) {
|
||||
|
@ -141,7 +141,7 @@ export function createScenarios({ getService }: Pick<FtrProviderContext, 'getSer
|
|||
.set('kbn-xsrf', 'xxx')
|
||||
.send(job);
|
||||
};
|
||||
const generatePdf = async (username: string, password: string, job: JobParamsPDF) => {
|
||||
const generatePdf = async (username: string, password: string, job: JobParamsPDFDeprecated) => {
|
||||
const jobParams = rison.encode(job as object as RisonValue);
|
||||
return await supertestWithoutAuth
|
||||
.post(`/api/reporting/generate/printablePdf`)
|
||||
|
@ -149,7 +149,7 @@ export function createScenarios({ getService }: Pick<FtrProviderContext, 'getSer
|
|||
.set('kbn-xsrf', 'xxx')
|
||||
.send({ jobParams });
|
||||
};
|
||||
const generatePng = async (username: string, password: string, job: JobParamsPNG) => {
|
||||
const generatePng = async (username: string, password: string, job: JobParamsPNGDeprecated) => {
|
||||
const jobParams = rison.encode(job as object as RisonValue);
|
||||
return await supertestWithoutAuth
|
||||
.post(`/api/reporting/generate/png`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue