* [Reporting-CSV Export] Re-write CSV Export using SearchSource * replace PIT solution with scan-and-scroll * update tests * cleanup * simplify pr * update docs * update docs * update telemetry schema * use getSearchRequestBody instead of flatten * Revert "update docs" This reverts commitab9f4d9642
. * optimize some async calls * cleanup * --wip-- [skip ci] * fix telemetry schema * fix telemetry tests * fix snapshot * api docs * api doc updates * use import type * format the data through chains of maps * add another saved search to reporting/ecommerce_kibana * add a failing test * add error logging to query failures * put clear scroll in a finally so the ES error can be captured * log dat error * set dat fieldsFromSource * --wip-- [skip ci] * Revert "add another saved search to reporting/ecommerce_kibana" This reverts commit6edf26eff2
. * functional test fixes * clean up ecommerce test archive * add test for new search with fieldsFromSource set * add tests and refactor tests * cleanup redundant conditionals * add GenerateCsv.getFields * fix some tests * fix double-escaping * fix test snapshots and refactoring * fix other tests * fix test * fix default index pattern in functional tests * fix ts and sort fields when they come from API response * --wip-- [skip ci] * fix formatting and increase maxSizeBytes for testing * remove client-side logic for sanitizing fields * do not prepend timefield name if it already is a column * test the logic to prepend timeField * test the logic to sort the fields * fix functional test * preserve the error from data.search * add functional test for ES returning an error * fix snapshot Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
111 lines
3.4 KiB
TypeScript
111 lines
3.4 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import type { IRouter, KibanaRequest, RequestHandlerContext } from 'src/core/server';
|
|
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
|
import { DataPluginStart } from 'src/plugins/data/server/plugin';
|
|
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
|
|
import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server';
|
|
import { LicensingPluginSetup } from '../../licensing/server';
|
|
import { AuthenticatedUser, SecurityPluginSetup } from '../../security/server';
|
|
import { SpacesPluginSetup } from '../../spaces/server';
|
|
import { TaskManagerSetupContract, TaskManagerStartContract } from '../../task_manager/server';
|
|
import { CancellationToken } from '../common';
|
|
import { BaseParams, TaskRunResult } from '../common/types';
|
|
import { ReportingConfigType } from './config';
|
|
import { ReportingCore } from './core';
|
|
import { LevelLogger } from './lib';
|
|
import { ReportTaskParams } from './lib/tasks';
|
|
|
|
/*
|
|
* Plugin Contract
|
|
*/
|
|
|
|
export interface ReportingSetupDeps {
|
|
licensing: LicensingPluginSetup;
|
|
features: FeaturesPluginSetup;
|
|
security?: SecurityPluginSetup;
|
|
spaces?: SpacesPluginSetup;
|
|
taskManager: TaskManagerSetupContract;
|
|
usageCollection?: UsageCollectionSetup;
|
|
}
|
|
|
|
export interface ReportingStartDeps {
|
|
data: DataPluginStart;
|
|
taskManager: TaskManagerStartContract;
|
|
}
|
|
|
|
export type ReportingStart = object;
|
|
export type ReportingSetup = object;
|
|
|
|
/*
|
|
* Internal Types
|
|
*/
|
|
|
|
export type ReportingUser = { username: AuthenticatedUser['username'] } | false;
|
|
|
|
export type CaptureConfig = ReportingConfigType['capture'];
|
|
export type ScrollConfig = ReportingConfigType['csv']['scroll'];
|
|
|
|
export { BaseParams };
|
|
|
|
// base params decorated with encrypted headers that come into runJob functions
|
|
export interface BasePayload extends BaseParams {
|
|
headers: string;
|
|
spaceId?: string;
|
|
}
|
|
|
|
// default fn type for CreateJobFnFactory
|
|
export type CreateJobFn<JobParamsType = BaseParams, JobPayloadType = BasePayload> = (
|
|
jobParams: JobParamsType,
|
|
context: ReportingRequestHandlerContext,
|
|
request: KibanaRequest<any, any, any, any>
|
|
) => Promise<JobPayloadType>;
|
|
|
|
// default fn type for RunTaskFnFactory
|
|
export type RunTaskFn<TaskPayloadType = BasePayload> = (
|
|
jobId: string,
|
|
payload: ReportTaskParams<TaskPayloadType>['payload'],
|
|
cancellationToken: CancellationToken
|
|
) => Promise<TaskRunResult>;
|
|
|
|
export type CreateJobFnFactory<CreateJobFnType> = (
|
|
reporting: ReportingCore,
|
|
logger: LevelLogger
|
|
) => CreateJobFnType;
|
|
|
|
export type RunTaskFnFactory<RunTaskFnType> = (
|
|
reporting: ReportingCore,
|
|
logger: LevelLogger
|
|
) => RunTaskFnType;
|
|
|
|
export interface ExportTypeDefinition<
|
|
CreateJobFnType = CreateJobFn | null,
|
|
RunTaskFnType = RunTaskFn
|
|
> {
|
|
id: string;
|
|
name: string;
|
|
jobType: string;
|
|
jobContentEncoding?: string;
|
|
jobContentExtension: string;
|
|
createJobFnFactory: CreateJobFnFactory<CreateJobFnType> | null; // immediate job does not have a "create" phase
|
|
runTaskFnFactory: RunTaskFnFactory<RunTaskFnType>;
|
|
validLicenses: string[];
|
|
}
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
export interface ReportingRequestHandlerContext extends RequestHandlerContext {
|
|
reporting: ReportingStart | null;
|
|
}
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
export type ReportingPluginRouter = IRouter<ReportingRequestHandlerContext>;
|