Skip to content

Commit

Permalink
[Reporting] Convert main Reporting index to TS (#49129) (#50694)
Browse files Browse the repository at this point in the history
* [Reporting] Convert main Reporting index to TS

* fix typo that broke build

* fix type file import

* fix the ts imports for build
  • Loading branch information
tsullivan authored Nov 18, 2019
1 parent c2b634c commit 7dfd3a0
Show file tree
Hide file tree
Showing 10 changed files with 339 additions and 236 deletions.
171 changes: 171 additions & 0 deletions x-pack/legacy/plugins/reporting/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { BROWSER_TYPE } from './common/constants';
// @ts-ignore untyped module
import { config as appConfig } from './server/config/config';
import { getDefaultChromiumSandboxDisabled } from './server/browsers';

export async function config(Joi: any) {
return Joi.object({
enabled: Joi.boolean().default(true),
kibanaServer: Joi.object({
protocol: Joi.string().valid(['http', 'https']),
hostname: Joi.string(),
port: Joi.number().integer(),
}).default(),
queue: Joi.object({
indexInterval: Joi.string().default('week'),
pollEnabled: Joi.boolean().default(true),
pollInterval: Joi.number()
.integer()
.default(3000),
pollIntervalErrorMultiplier: Joi.number()
.integer()
.default(10),
timeout: Joi.number()
.integer()
.default(120000),
}).default(),
capture: Joi.object({
networkPolicy: Joi.object({
enabled: Joi.boolean().default(true),
rules: Joi.array()
.items(
Joi.object({
allow: Joi.boolean().required(),
protocol: Joi.string(),
host: Joi.string(),
})
)
.default([
{ allow: true, protocol: 'http:' },
{ allow: true, protocol: 'https:' },
{ allow: true, protocol: 'ws:' },
{ allow: true, protocol: 'wss:' },
{ allow: true, protocol: 'data:' },
{ allow: false }, // Default action is to deny!
]),
}).default(),
zoom: Joi.number()
.integer()
.default(2),
viewport: Joi.object({
width: Joi.number()
.integer()
.default(1950),
height: Joi.number()
.integer()
.default(1200),
}).default(),
timeout: Joi.number()
.integer()
.default(20000), // deprecated
loadDelay: Joi.number()
.integer()
.default(3000),
settleTime: Joi.number()
.integer()
.default(1000), // deprecated
concurrency: Joi.number()
.integer()
.default(appConfig.concurrency), // deprecated
browser: Joi.object({
type: Joi.any()
.valid(BROWSER_TYPE)
.default(BROWSER_TYPE),
autoDownload: Joi.boolean().when('$dist', {
is: true,
then: Joi.default(false),
otherwise: Joi.default(true),
}),
chromium: Joi.object({
inspect: Joi.boolean()
.when('$dev', {
is: false,
then: Joi.valid(false),
else: Joi.default(false),
})
.default(),
disableSandbox: Joi.boolean().default(await getDefaultChromiumSandboxDisabled()),
proxy: Joi.object({
enabled: Joi.boolean().default(false),
server: Joi.string()
.uri({ scheme: ['http', 'https'] })
.when('enabled', {
is: Joi.valid(false),
then: Joi.valid(null),
else: Joi.required(),
}),
bypass: Joi.array()
.items(Joi.string().regex(/^[^\s]+$/))
.when('enabled', {
is: Joi.valid(false),
then: Joi.valid(null),
else: Joi.default([]),
}),
}).default(),
maxScreenshotDimension: Joi.number()
.integer()
.default(1950),
}).default(),
}).default(),
maxAttempts: Joi.number()
.integer()
.greater(0)
.when('$dist', {
is: true,
then: Joi.default(3),
otherwise: Joi.default(1),
})
.default(),
}).default(),
csv: Joi.object({
checkForFormulas: Joi.boolean().default(true),
enablePanelActionDownload: Joi.boolean().default(true),
maxSizeBytes: Joi.number()
.integer()
.default(1024 * 1024 * 10), // bytes in a kB * kB in a mB * 10
scroll: Joi.object({
duration: Joi.string()
.regex(/^[0-9]+(d|h|m|s|ms|micros|nanos)$/, { name: 'DurationString' })
.default('30s'),
size: Joi.number()
.integer()
.default(500),
}).default(),
}).default(),
encryptionKey: Joi.when(Joi.ref('$dist'), {
is: true,
then: Joi.string(),
otherwise: Joi.string().default('a'.repeat(32)),
}),
roles: Joi.object({
allow: Joi.array()
.items(Joi.string())
.default(['reporting_user']),
}).default(),
index: Joi.string().default('.reporting'),
poll: Joi.object({
jobCompletionNotifier: Joi.object({
interval: Joi.number()
.integer()
.default(10000),
intervalErrorMultiplier: Joi.number()
.integer()
.default(5),
}).default(),
jobsRefresh: Joi.object({
interval: Joi.number()
.integer()
.default(5000),
intervalErrorMultiplier: Joi.number()
.integer()
.default(5),
}).default(),
}).default(),
}).default();
}
221 changes: 0 additions & 221 deletions x-pack/legacy/plugins/reporting/index.js

This file was deleted.

Loading

0 comments on commit 7dfd3a0

Please sign in to comment.