From 262bcb411acc6269dbd0fba519bbee3f96b0e363 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 6 Jun 2017 10:11:59 -0700 Subject: [PATCH] Use es6 exports, replace module.exports (#12084) * use es6 exports in fixtures * use es6 exports in test_utils * use es6 exports in src/ui * use es6 exports in src/utils * use es6 exports in src/server * use es6 exports in timelion * use es6 exports in core plugins, but not console * use es6 exports in console * use es6 exports in src/cli * use eslint --fix for no-extra-semi rule * selectively disable kibana-custom/no-default-export * replace define() with exports * clean up some object exports in these cases, named exports are the better replacement * use es6 exports in src/optimize, where possible * fix uses of named exports * fix some imports in console * revert postcss optimizer to module.exports * [timelion] put shared code in common directory * fix url module export don't export as default, rely on the named export * convert define modules in src to export * convert ui-bootstrap to cjs module * lint webpackShims no reason not to, they pass when the no-var rule is disabled * fix new code not using es6 exports * fix some straggling exports --- src/cli/cluster/cluster_manager.js | 4 +- src/cli/cluster/worker.js | 4 +- src/cli/color.js | 7 +- src/cli/command.js | 2 +- src/cli/log.js | 12 +- src/cli/serve/serve.js | 4 +- src/core_plugins/console/api_server/api.js | 2 +- src/core_plugins/console/api_server/es_5_0.js | 4 +- .../console/api_server/es_5_0/aggregations.js | 5 +- .../console/api_server/es_5_0/aliases.js | 4 +- .../console/api_server/es_5_0/cat.js | 4 +- .../console/api_server/es_5_0/cluster.js | 4 +- .../console/api_server/es_5_0/count.js | 4 +- .../console/api_server/es_5_0/document.js | 4 +- .../console/api_server/es_5_0/field_stats.js | 4 +- .../console/api_server/es_5_0/filter.js | 4 +- .../console/api_server/es_5_0/globals.js | 4 +- .../console/api_server/es_5_0/indices.js | 4 +- .../console/api_server/es_5_0/ingest.js | 4 +- .../console/api_server/es_5_0/mappings.js | 4 +- .../console/api_server/es_5_0/nodes.js | 4 +- .../console/api_server/es_5_0/percolator.js | 4 +- .../console/api_server/es_5_0/query.js | 4 +- .../console/api_server/es_5_0/reindex.js | 4 +- .../console/api_server/es_5_0/search.js | 4 +- .../console/api_server/es_5_0/settings.js | 4 +- .../api_server/es_5_0/snapshot_restore.js | 4 +- .../console/api_server/es_5_0/templates.js | 4 +- src/core_plugins/console/api_server/server.js | 4 +- src/core_plugins/console/index.js | 4 +- .../console/public/src/autocomplete.js | 43 +- .../public/src/autocomplete/body_completer.js | 8 +- .../console/public/src/autocomplete/engine.js | 33 +- .../public/src/autocomplete/url_params.js | 7 +- .../src/autocomplete/url_pattern_matcher.js | 9 +- src/core_plugins/console/public/src/curl.js | 342 ++++++------ src/core_plugins/console/public/src/es.js | 13 +- .../console/public/src/history.js | 4 +- .../console/public/src/input_resize.js | 2 +- src/core_plugins/console/public/src/kb.js | 33 +- src/core_plugins/console/public/src/kb/api.js | 2 +- .../console/public/src/mappings.js | 2 +- .../console/public/src/sense_editor/editor.js | 4 +- .../public/src/sense_editor/mode/input.js | 7 +- .../mode/input_highlight_rules.js | 8 +- .../public/src/sense_editor/mode/output.js | 6 +- .../mode/output_highlight_rules.js | 6 +- .../public/src/sense_editor/mode/script.js | 6 +- .../mode/script_highlight_rules.js | 5 +- .../mode/x_json_highlight_rules.js | 2 +- .../public/src/sense_editor/row_parser.js | 2 +- .../console/public/src/smart_resize.js | 4 +- .../console/public/src/storage.js | 4 +- src/core_plugins/console/public/src/utils.js | 2 +- src/core_plugins/dev_mode/public/ng_mock.js | 2 +- src/core_plugins/elasticsearch/index.js | 6 +- .../lib/__tests__/create_proxy.js | 8 +- .../elasticsearch/lib/__tests__/find_port.js | 4 +- .../lib/__tests__/fixtures/mappings.js | 2 +- .../elasticsearch/lib/create_kibana_index.js | 4 +- .../elasticsearch/lib/create_proxy.js | 20 +- .../elasticsearch/lib/health_check.js | 4 +- .../elasticsearch/lib/is_upgradeable.js | 4 +- .../elasticsearch/lib/migrate_config.js | 4 +- .../elasticsearch/lib/upgrade_config.js | 4 +- .../lib/convert_pattern_and_ingest_name.js | 26 +- src/core_plugins/kibana/index.js | 4 +- .../kibana/public/discover/_hit_sort_fn.js | 117 ++-- .../edit_index_pattern/edit_index_pattern.js | 4 +- .../scripted_field_editor.js | 4 +- .../kibana/server/lib/handle_es_error.js | 4 +- .../lib/vis_data/helpers/calculate_auto.js | 2 +- .../server/lib/vis_data/helpers/index.js | 2 +- .../status_page/public/lib/format_number.js | 4 +- .../public/lib/make_chart_options.js | 4 +- .../status_page/public/lib/read_stat_data.js | 4 +- .../tests_bundle/find_source_files.js | 2 +- .../tests_bundle/tests_entry_template.js | 4 +- .../lib/calculate_interval.js | 16 +- src/core_plugins/timelion/common/lib/index.js | 1 + src/core_plugins/timelion/index.js | 4 +- src/core_plugins/timelion/init.js | 4 +- .../directives/timelion_help/timelion_help.js | 119 +++-- .../timelion/public/lib/observe_resize.js | 4 +- .../timelion/public/panels/panel.js | 4 +- .../public/panels/timechart/schema.js | 6 +- .../public/panels/timechart/tick_generator.js | 4 +- .../panels/timechart/xaxis_formatter.js | 4 +- .../public/services/dashboard_context.js | 53 +- .../public/services/saved_sheet_register.js | 8 +- .../timelion/public/services/saved_sheets.js | 47 +- .../public/services/tick_formatters.js | 133 +++-- .../timelion/public/services/timezone.js | 4 +- src/core_plugins/timelion/public/vis/index.js | 62 +-- .../public/vis/timelion_vis_controller.js | 108 ++-- .../vis/timelion_vis_params_controller.js | 20 +- .../timelion/server/fit_functions/average.js | 4 +- .../timelion/server/fit_functions/carry.js | 4 +- .../timelion/server/fit_functions/nearest.js | 4 +- .../timelion/server/fit_functions/none.js | 4 +- .../timelion/server/fit_functions/scale.js | 4 +- .../timelion/server/handlers/chain_runner.js | 6 +- .../timelion/server/handlers/lib/arg_type.js | 4 +- .../server/handlers/lib/index_arguments.js | 4 +- .../server/handlers/lib/parse_sheet.js | 4 +- .../server/handlers/lib/preprocess_chain.js | 4 +- .../handlers/lib/reposition_arguments.js | 4 +- .../timelion/server/handlers/lib/tl_config.js | 4 +- .../server/handlers/lib/validate_arg.js | 4 +- .../server/handlers/lib/validate_time.js | 4 +- src/core_plugins/timelion/server/lib/alter.js | 4 +- .../timelion/server/lib/asSorted.js | 4 +- .../timelion/server/lib/build_target.js | 4 +- .../timelion/server/lib/classes/chainable.js | 4 +- .../timelion/server/lib/classes/datasource.js | 4 +- .../server/lib/classes/timelion_function.js | 4 +- .../timelion/server/lib/date_math.js | 4 +- .../timelion/server/lib/functions_md.js | 2 +- .../server/lib/get_namespaced_settings.js | 4 +- .../timelion/server/lib/load_functions.js | 4 +- .../timelion/server/lib/offset_time.js | 4 +- .../server/lib/process_function_definition.js | 4 +- .../timelion/server/lib/reduce.js | 4 +- .../timelion/server/lib/split_interval.js | 4 +- .../timelion/server/lib/to_milliseconds.js | 4 +- .../timelion/server/lib/unzipPairs.js | 4 +- .../timelion/server/routes/functions.js | 4 +- .../timelion/server/routes/run.js | 4 +- .../timelion/server/routes/validate_es.js | 4 +- .../__tests__/fixtures/bucketList.js | 2 +- .../__tests__/fixtures/es_response.js | 2 +- .../__tests__/fixtures/seriesList.js | 4 +- .../__tests__/fixtures/tlConfig.js | 4 +- .../__tests__/helpers/get_series.js | 4 +- .../__tests__/helpers/get_series_list.js | 4 +- .../helpers/get_single_series_list.js | 4 +- .../__tests__/helpers/invoke_series_fn.js | 4 +- .../timelion/server/series_functions/abs.js | 3 +- .../server/series_functions/aggregate/avg.js | 4 +- .../series_functions/aggregate/cardinality.js | 4 +- .../series_functions/aggregate/first.js | 4 +- .../series_functions/aggregate/index.js | 2 +- .../server/series_functions/aggregate/last.js | 4 +- .../server/series_functions/aggregate/max.js | 4 +- .../server/series_functions/aggregate/min.js | 4 +- .../server/series_functions/aggregate/sum.js | 4 +- .../timelion/server/series_functions/bars.js | 3 +- .../timelion/server/series_functions/color.js | 2 +- .../server/series_functions/condition.js | 2 +- .../timelion/server/series_functions/cusum.js | 3 +- .../server/series_functions/derivative.js | 3 +- .../server/series_functions/divide.js | 3 +- .../server/series_functions/es/index.js | 2 +- .../series_functions/es/lib/build_request.js | 4 +- .../es/lib/create_date_agg.js | 4 +- .../timelion/server/series_functions/first.js | 3 +- .../timelion/server/series_functions/fit.js | 2 +- .../server/series_functions/graphite.js | 2 +- .../timelion/server/series_functions/hide.js | 3 +- .../server/series_functions/holt/index.js | 2 +- .../server/series_functions/holt/lib/des.js | 4 +- .../server/series_functions/holt/lib/ses.js | 4 +- .../server/series_functions/holt/lib/tes.js | 4 +- .../timelion/server/series_functions/label.js | 3 +- .../server/series_functions/legend.js | 3 +- .../timelion/server/series_functions/lines.js | 3 +- .../timelion/server/series_functions/log.js | 3 +- .../timelion/server/series_functions/max.js | 3 +- .../timelion/server/series_functions/min.js | 3 +- .../server/series_functions/movingaverage.js | 2 +- .../server/series_functions/movingstd.js | 3 +- .../server/series_functions/multiply.js | 3 +- .../server/series_functions/points.js | 3 +- .../server/series_functions/precision.js | 3 +- .../timelion/server/series_functions/props.js | 2 +- .../server/series_functions/quandl.js | 2 +- .../timelion/server/series_functions/range.js | 3 +- .../server/series_functions/scale_interval.js | 3 +- .../server/series_functions/static.js | 2 +- .../server/series_functions/subtract.js | 3 +- .../timelion/server/series_functions/sum.js | 3 +- .../timelion/server/series_functions/title.js | 3 +- .../server/series_functions/trend/index.js | 2 +- .../timelion/server/series_functions/trim.js | 2 +- .../server/series_functions/worldbank.js | 2 +- .../series_functions/worldbank_indicators.js | 2 +- .../timelion/server/series_functions/yaxis.js | 3 +- src/fixtures/agg_resp/date_histogram.js | 500 +++++++++--------- src/fixtures/vislib/_vis_fixture.js | 4 +- .../mock_data/date_histogram/_columns.js | 2 +- .../vislib/mock_data/date_histogram/_rows.js | 2 +- .../mock_data/date_histogram/_series.js | 2 +- .../mock_data/date_histogram/_series_neg.js | 2 +- .../date_histogram/_series_pos_neg.js | 2 +- .../date_histogram/_stacked_series.js | 2 +- .../vislib/mock_data/filters/_columns.js | 2 +- .../vislib/mock_data/filters/_rows.js | 2 +- .../vislib/mock_data/filters/_series.js | 2 +- .../vislib/mock_data/geohash/_columns.js | 3 +- .../vislib/mock_data/geohash/_geo_json.js | 2 +- .../vislib/mock_data/geohash/_rows.js | 2 +- .../vislib/mock_data/histogram/_columns.js | 2 +- .../vislib/mock_data/histogram/_rows.js | 2 +- .../vislib/mock_data/histogram/_series.js | 2 +- .../vislib/mock_data/histogram/_slices.js | 2 +- .../mock_data/not_enough_data/_one_point.js | 2 +- .../vislib/mock_data/range/_columns.js | 2 +- src/fixtures/vislib/mock_data/range/_rows.js | 2 +- .../vislib/mock_data/range/_series.js | 2 +- .../mock_data/significant_terms/_columns.js | 2 +- .../mock_data/significant_terms/_rows.js | 2 +- .../mock_data/significant_terms/_series.js | 2 +- .../vislib/mock_data/stacked/_stacked.js | 2 +- .../vislib/mock_data/terms/_columns.js | 2 +- src/fixtures/vislib/mock_data/terms/_rows.js | 2 +- .../vislib/mock_data/terms/_series.js | 2 +- .../vislib/mock_data/terms/_seriesMultiple.js | 2 +- src/optimize/base_optimizer.js | 4 +- src/optimize/fs_optimizer.js | 5 +- src/optimize/index.js | 3 +- src/optimize/lazy/lazy.js | 3 +- src/optimize/lazy/lazy_optimizer.js | 4 +- src/optimize/lazy/lazy_server.js | 4 +- src/optimize/lazy/proxy_role.js | 2 +- src/optimize/lazy/weird_control_flow.js | 4 +- src/server/config/config.js | 4 +- src/server/config/explode_by.js | 5 +- src/server/config/flatten_with.js | 5 +- src/server/config/override.js | 4 +- src/server/config/schema.js | 2 +- src/server/config/setup.js | 4 +- src/server/http/get_default_route.js | 2 +- src/server/http/index.js | 2 +- src/server/kbn_server.js | 4 +- src/server/logging/apply_filters_to_keys.js | 4 +- src/server/logging/log_format.js | 4 +- src/server/logging/log_format_json.js | 4 +- src/server/logging/log_format_string.js | 4 +- src/server/logging/log_reporter.js | 4 +- src/server/pid/index.js | 2 +- src/server/plugins/initialize.js | 2 +- src/server/plugins/plugin.js | 4 +- src/server/plugins/plugin_api.js | 4 +- src/server/plugins/plugin_collection.js | 4 +- src/server/plugins/scan.js | 3 +- src/server/status/__tests__/server_status.js | 2 +- src/server/status/samples.js | 2 +- src/server/status/server_status.js | 6 +- src/server/status/states.js | 10 +- src/server/status/status.js | 6 +- src/test_utils/get_url.js | 4 +- src/test_utils/public/no_digest_promises.js | 2 +- src/ui/__tests__/fixtures/test_app/index.js | 2 +- src/ui/app_entry_template.js | 4 +- .../hierarchical/_collect_branch.js | 63 ++- .../agg_types/__tests__/agg_param_writer.js | 6 +- .../__tests__/param_types/_raw_json.js | 3 +- .../__tests__/param_types/_string.js | 3 +- .../__tests__/utils/_stub_agg_params.js | 5 +- src/ui/public/chrome/api/apps.js | 5 +- src/ui/public/chrome/api/controls.js | 5 +- src/ui/public/chrome/api/template.js | 5 +- src/ui/public/chrome/api/theme.js | 5 +- src/ui/public/chrome/api/translations.js | 5 +- src/ui/public/chrome/chrome.js | 3 +- .../error_url_overflow/error_url_overflow.js | 2 +- src/ui/public/jquery/find_test_subject.js | 5 +- src/ui/public/modules.js | 1 - src/ui/public/private/private.js | 50 +- src/ui/public/routes/routes.js | 5 +- .../stringify/__tests__/_conformance.js | 3 +- src/ui/public/test_harness/test_harness.js | 4 +- src/ui/public/url/index.js | 2 +- src/ui/public/utils/ipv4_address.js | 87 ++- src/ui/public/utils/mapping_setup.js | 183 ++++--- src/ui/public/vis/agg_config_result.js | 77 ++- src/ui/public/vis_maps/maps_renderbot.js | 6 +- .../__tests__/components/zero_injection.js | 2 +- .../lib/layout/splits/column_chart/splits.js | 8 +- .../components/labels/pie/return_pie_names.js | 29 +- .../components/zero_injection/inject_zeros.js | 2 +- .../zero_injection/zero_filled_array.js | 40 +- .../layout/splits/column_chart/chart_split.js | 108 ++-- .../splits/column_chart/chart_title_split.js | 63 ++- .../splits/column_chart/x_axis_split.js | 61 ++- .../splits/column_chart/y_axis_split.js | 62 ++- .../layout/splits/gauge_chart/chart_split.js | 88 +-- .../splits/gauge_chart/chart_title_split.js | 62 +-- .../layout/splits/pie_chart/chart_split.js | 86 ++- .../splits/pie_chart/chart_title_split.js | 60 +-- .../vislib/lib/layout/types/column_layout.js | 9 +- .../vislib/lib/layout/types/pie_layout.js | 4 +- src/ui/public/vislib/vislib.js | 7 +- .../vislib_vis_type/vislib_renderbot.js | 5 +- src/ui/ui_app.js | 4 +- src/ui/ui_app_collection.js | 4 +- src/ui/ui_bundle.js | 4 +- src/ui/ui_bundle_collection.js | 4 +- src/ui/ui_bundler_env.js | 4 +- src/ui/ui_exports.js | 4 +- src/utils/collection.js | 4 +- src/utils/path_contains.js | 4 +- tasks/config/eslint.js | 1 + tasks/test.js | 4 +- tasks/utils/exec.js | 4 +- utilities/visual_regression.js | 24 +- webpackShims/.eslintrc | 4 + webpackShims/ui-bootstrap.js | 30 +- 308 files changed, 1900 insertions(+), 1960 deletions(-) rename src/core_plugins/timelion/{public => common}/lib/calculate_interval.js (90%) create mode 100644 src/core_plugins/timelion/common/lib/index.js create mode 100644 webpackShims/.eslintrc diff --git a/src/cli/cluster/cluster_manager.js b/src/cli/cluster/cluster_manager.js index 86c1b26ec9e5..d41bcc59fcbe 100644 --- a/src/cli/cluster/cluster_manager.js +++ b/src/cli/cluster/cluster_manager.js @@ -7,7 +7,7 @@ import BasePathProxy from './base_path_proxy'; process.env.kbnWorkerType = 'managr'; -module.exports = class ClusterManager { +export default class ClusterManager { constructor(opts = {}, settings = {}) { this.log = new Log(opts.quiet, opts.silent); this.addedCount = 0; @@ -169,4 +169,4 @@ module.exports = class ClusterManager { this.log.bad('failed to watch files!\n', err.stack); process.exit(1); // eslint-disable-line no-process-exit } -}; +} diff --git a/src/cli/cluster/worker.js b/src/cli/cluster/worker.js index 88a7d76516f9..06528f276531 100644 --- a/src/cli/cluster/worker.js +++ b/src/cli/cluster/worker.js @@ -17,7 +17,7 @@ const dead = fork => { return fork.isDead() || fork.killed; }; -module.exports = class Worker extends EventEmitter { +export default class Worker extends EventEmitter { constructor(opts) { opts = opts || {}; super(); @@ -162,4 +162,4 @@ module.exports = class Worker extends EventEmitter { // wait for the fork to report it is online before resolving await new Promise(cb => this.once('fork:online', cb)); } -}; +} diff --git a/src/cli/color.js b/src/cli/color.js index 56188418c014..fc3011a0ecde 100644 --- a/src/cli/color.js +++ b/src/cli/color.js @@ -1,7 +1,6 @@ - import _ from 'lodash'; import ansicolors from 'ansicolors'; -exports.green = _.flow(ansicolors.black, ansicolors.bgGreen); -exports.red = _.flow(ansicolors.white, ansicolors.bgRed); -exports.yellow = _.flow(ansicolors.black, ansicolors.bgYellow); +export const green = _.flow(ansicolors.black, ansicolors.bgGreen); +export const red = _.flow(ansicolors.white, ansicolors.bgRed); +export const yellow = _.flow(ansicolors.black, ansicolors.bgYellow); diff --git a/src/cli/command.js b/src/cli/command.js index 27e65a4e832d..a4d9f57851ff 100644 --- a/src/cli/command.js +++ b/src/cli/command.js @@ -91,4 +91,4 @@ Command.prototype.action = _.wrap(Command.prototype.action, function (action, fn }); }); -module.exports = Command; +export default Command; diff --git a/src/cli/log.js b/src/cli/log.js index 584c27d5f985..3731d2c46a7f 100644 --- a/src/cli/log.js +++ b/src/cli/log.js @@ -4,12 +4,12 @@ const log = _.restParam(function (color, label, rest1) { console.log.apply(console, [color(` ${_.trim(label)} `)].concat(rest1)); }); -import color from './color'; +import { green, yellow, red } from './color'; -module.exports = class Log { +export default class Log { constructor(quiet, silent) { - this.good = quiet || silent ? _.noop : _.partial(log, color.green); - this.warn = quiet || silent ? _.noop : _.partial(log, color.yellow); - this.bad = silent ? _.noop : _.partial(log, color.red); + this.good = quiet || silent ? _.noop : _.partial(log, green); + this.warn = quiet || silent ? _.noop : _.partial(log, yellow); + this.bad = silent ? _.noop : _.partial(log, red); } -}; +} diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index aa515f62d075..dacd0002eb9b 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -72,7 +72,7 @@ function readServerSettings(opts, extraCliOptions) { return settings; } -module.exports = function (program) { +export default function (program) { const command = program.command('serve'); command @@ -170,7 +170,7 @@ module.exports = function (program) { return kbnServer; }); -}; +} function logFatal(message, server) { if (server) { diff --git a/src/core_plugins/console/api_server/api.js b/src/core_plugins/console/api_server/api.js index 7b1f4f2acd36..671d8c7a1398 100644 --- a/src/core_plugins/console/api_server/api.js +++ b/src/core_plugins/console/api_server/api.js @@ -42,4 +42,4 @@ function Api(name) { }(Api.prototype)); -module.exports = Api; +export default Api; diff --git a/src/core_plugins/console/api_server/es_5_0.js b/src/core_plugins/console/api_server/es_5_0.js index 2782cf4f18ba..8443c2813cd4 100644 --- a/src/core_plugins/console/api_server/es_5_0.js +++ b/src/core_plugins/console/api_server/es_5_0.js @@ -53,4 +53,6 @@ ES_5_0.prototype = _.create(Api.prototype, { 'constructor': ES_5_0 }); }; })(ES_5_0.prototype); -module.exports = new ES_5_0(); +const instance = new ES_5_0(); + +export default instance; \ No newline at end of file diff --git a/src/core_plugins/console/api_server/es_5_0/aggregations.js b/src/core_plugins/console/api_server/es_5_0/aggregations.js index aa653f1beec7..fff4655c56a2 100644 --- a/src/core_plugins/console/api_server/es_5_0/aggregations.js +++ b/src/core_plugins/console/api_server/es_5_0/aggregations.js @@ -435,8 +435,9 @@ var rules = { } } }; -module.exports = function (api) { + +export default function (api) { api.addGlobalAutocompleteRules('aggregations', rules); api.addGlobalAutocompleteRules('aggs', rules); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/aliases.js b/src/core_plugins/console/api_server/es_5_0/aliases.js index c17dee4aa0bd..675c35c1b33f 100644 --- a/src/core_plugins/console/api_server/es_5_0/aliases.js +++ b/src/core_plugins/console/api_server/es_5_0/aliases.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_post_aliases', { methods: ['POST'], patterns: [ @@ -68,4 +68,4 @@ module.exports = function (api) { api.addGlobalAutocompleteRules('aliases', { '*': aliasRules }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/cat.js b/src/core_plugins/console/api_server/es_5_0/cat.js index 0da08cd066e0..2411bb7db245 100644 --- a/src/core_plugins/console/api_server/es_5_0/cat.js +++ b/src/core_plugins/console/api_server/es_5_0/cat.js @@ -32,7 +32,7 @@ function addNodeattrsCat(api) { }); } -module.exports = function (api) { +export default function (api) { addSimpleCat('_cat/aliases', api); addSimpleCat('_cat/allocation', api, null, ['_cat/allocation', '_cat/allocation/{nodes}']); addSimpleCat('_cat/count', api); @@ -53,4 +53,4 @@ module.exports = function (api) { addSimpleCat('_cat/plugins', api); addSimpleCat('_cat/segments', api); addNodeattrsCat(api); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/cluster.js b/src/core_plugins/console/api_server/es_5_0/cluster.js index a29e45c6e1db..0dd9f0fe1bce 100644 --- a/src/core_plugins/console/api_server/es_5_0/cluster.js +++ b/src/core_plugins/console/api_server/es_5_0/cluster.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_cluster/nodes/stats'); api.addEndpointDescription('_cluster/state', { patterns: [ @@ -139,4 +139,4 @@ module.exports = function (api) { dry_run: { __one_of: [true, false] } } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/count.js b/src/core_plugins/console/api_server/es_5_0/count.js index 6bbcb3a9f6b8..fe44bdef271a 100644 --- a/src/core_plugins/console/api_server/es_5_0/count.js +++ b/src/core_plugins/console/api_server/es_5_0/count.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_count', { methods: ['GET', 'POST'], priority: 10, // collides with get doc by id @@ -19,4 +19,4 @@ module.exports = function (api) { } } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/document.js b/src/core_plugins/console/api_server/es_5_0/document.js index 47762ef5b757..1c0537a2ca70 100644 --- a/src/core_plugins/console/api_server/es_5_0/document.js +++ b/src/core_plugins/console/api_server/es_5_0/document.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_get_doc', { methods: ['GET'], patterns: [ @@ -230,4 +230,4 @@ module.exports = function (api) { } } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/field_stats.js b/src/core_plugins/console/api_server/es_5_0/field_stats.js index 58c35e6ed0eb..1b8fcc3f7b61 100644 --- a/src/core_plugins/console/api_server/es_5_0/field_stats.js +++ b/src/core_plugins/console/api_server/es_5_0/field_stats.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_field_stats', { methods: ['GET', 'POST'], patterns: [ @@ -44,4 +44,4 @@ module.exports = function (api) { } } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/filter.js b/src/core_plugins/console/api_server/es_5_0/filter.js index bcaae0105514..a66a702a1792 100644 --- a/src/core_plugins/console/api_server/es_5_0/filter.js +++ b/src/core_plugins/console/api_server/es_5_0/filter.js @@ -330,7 +330,7 @@ filters.nested = { _name: '' }; -module.exports = function (api) { +export default function (api) { api.addGlobalAutocompleteRules('filter', filters); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/globals.js b/src/core_plugins/console/api_server/es_5_0/globals.js index e8cd84922615..c0b49f758f21 100644 --- a/src/core_plugins/console/api_server/es_5_0/globals.js +++ b/src/core_plugins/console/api_server/es_5_0/globals.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addGlobalAutocompleteRules('highlight', { pre_tags: {}, post_tags: {}, @@ -21,4 +21,4 @@ module.exports = function (api) { lang: "", params: {} }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/indices.js b/src/core_plugins/console/api_server/es_5_0/indices.js index a8772a86d55e..9dc7b4f92766 100644 --- a/src/core_plugins/console/api_server/es_5_0/indices.js +++ b/src/core_plugins/console/api_server/es_5_0/indices.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_refresh', { methods: ['POST'], patterns: [ @@ -231,4 +231,4 @@ module.exports = function (api) { "{indices}/_open" ] }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/ingest.js b/src/core_plugins/console/api_server/es_5_0/ingest.js index 6ce1251a7c4d..989b10361eb1 100644 --- a/src/core_plugins/console/api_server/es_5_0/ingest.js +++ b/src/core_plugins/console/api_server/es_5_0/ingest.js @@ -329,7 +329,7 @@ const simulateUrlParamsDefinition = { "verbose": "__flag__" }; -module.exports = function (api) { +export default function (api) { // Note: this isn't an actual API endpoint. It exists so the forEach processor's "processor" field // may recursively use the autocomplete rules for any processor. @@ -383,4 +383,4 @@ module.exports = function (api) { ] } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/mappings.js b/src/core_plugins/console/api_server/es_5_0/mappings.js index 93709de58657..a8bbda676b67 100644 --- a/src/core_plugins/console/api_server/es_5_0/mappings.js +++ b/src/core_plugins/console/api_server/es_5_0/mappings.js @@ -4,7 +4,7 @@ var BOOLEAN = { __one_of: [true, false] }; -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_get_mapping', { methods: ['GET'], priority: 10, // collides with get doc by id @@ -216,4 +216,4 @@ module.exports = function (api) { } } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/nodes.js b/src/core_plugins/console/api_server/es_5_0/nodes.js index 889943678fb4..04ea998b48f5 100644 --- a/src/core_plugins/console/api_server/es_5_0/nodes.js +++ b/src/core_plugins/console/api_server/es_5_0/nodes.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_nodes/hot_threads', { methods: ['GET'], patterns: [ @@ -75,4 +75,4 @@ module.exports = function (api) { ] } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/percolator.js b/src/core_plugins/console/api_server/es_5_0/percolator.js index 100a0889a8ad..ce3b07fcb43f 100644 --- a/src/core_plugins/console/api_server/es_5_0/percolator.js +++ b/src/core_plugins/console/api_server/es_5_0/percolator.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_put_percolator', { priority: 10, // to override doc methods: ['PUT', 'POST'], @@ -87,4 +87,4 @@ module.exports = function (api) { filter: {} } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/query.js b/src/core_plugins/console/api_server/es_5_0/query.js index deebe7f149c5..e6769b66eeaa 100644 --- a/src/core_plugins/console/api_server/es_5_0/query.js +++ b/src/core_plugins/console/api_server/es_5_0/query.js @@ -67,7 +67,7 @@ var DECAY_FUNC_DESC = { } }; -module.exports = function (api) { +export default function (api) { api.addGlobalAutocompleteRules('query', { match: { __template: { @@ -624,4 +624,4 @@ module.exports = function (api) { }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/reindex.js b/src/core_plugins/console/api_server/es_5_0/reindex.js index 2e25b88caecf..6cf57cc54e6d 100644 --- a/src/core_plugins/console/api_server/es_5_0/reindex.js +++ b/src/core_plugins/console/api_server/es_5_0/reindex.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_post_reindex', { methods: [ 'POST' ], @@ -54,4 +54,4 @@ module.exports = function (api) { 'script': { __scope_link: 'GLOBAL.script' }, } }) -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/core_plugins/console/api_server/es_5_0/search.js b/src/core_plugins/console/api_server/es_5_0/search.js index c2f1e7f72f6a..edadb55822e2 100644 --- a/src/core_plugins/console/api_server/es_5_0/search.js +++ b/src/core_plugins/console/api_server/es_5_0/search.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_search', { methods: ['GET', 'POST'], priority: 10, // collides with get doc by id @@ -252,4 +252,4 @@ module.exports = function (api) { local: "__flag__" } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/settings.js b/src/core_plugins/console/api_server/es_5_0/settings.js index 1cfdcad76308..54a546b10059 100644 --- a/src/core_plugins/console/api_server/es_5_0/settings.js +++ b/src/core_plugins/console/api_server/es_5_0/settings.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_get_settings', { patterns: [ @@ -83,4 +83,4 @@ module.exports = function (api) { } } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js b/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js index 42e7bc030ed7..040df945a9a7 100644 --- a/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js +++ b/src/core_plugins/console/api_server/es_5_0/snapshot_restore.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('restore_snapshot', { methods: ['POST'], patterns: [ @@ -126,4 +126,4 @@ module.exports = function (api) { } } }); -}; +} diff --git a/src/core_plugins/console/api_server/es_5_0/templates.js b/src/core_plugins/console/api_server/es_5_0/templates.js index 5646be3e4e25..190bf352f137 100644 --- a/src/core_plugins/console/api_server/es_5_0/templates.js +++ b/src/core_plugins/console/api_server/es_5_0/templates.js @@ -1,4 +1,4 @@ -module.exports = function (api) { +export default function (api) { api.addEndpointDescription('_delete_template', { methods: ['DELETE'], patterns: [ @@ -24,4 +24,4 @@ module.exports = function (api) { settings: { __scope_link: '_put_settings' } } }); -}; +} diff --git a/src/core_plugins/console/api_server/server.js b/src/core_plugins/console/api_server/server.js index ced1cbb38488..9782af96071f 100644 --- a/src/core_plugins/console/api_server/server.js +++ b/src/core_plugins/console/api_server/server.js @@ -1,6 +1,6 @@ let _ = require("lodash"); -module.exports.resolveApi = function (sense_version, apis, reply) { +export function resolveApi(sense_version, apis, reply) { let result = {}; _.each(apis, function (name) { { @@ -11,4 +11,4 @@ module.exports.resolveApi = function (sense_version, apis, reply) { }); return reply(result).type("application/json"); -}; +} diff --git a/src/core_plugins/console/index.js b/src/core_plugins/console/index.js index 8f6e2f6c4829..e2d29f719699 100644 --- a/src/core_plugins/console/index.js +++ b/src/core_plugins/console/index.js @@ -1,5 +1,5 @@ import Boom from 'boom'; -import apiServer from './api_server/server'; +import { resolveApi } from './api_server/server'; import { existsSync } from 'fs'; import { resolve, join, sep } from 'path'; import { has, isEmpty } from 'lodash'; @@ -109,7 +109,7 @@ export default function (kibana) { return; } - return apiServer.resolveApi(sense_version, apis.split(','), reply); + return resolveApi(sense_version, apis.split(','), reply); } }); diff --git a/src/core_plugins/console/public/src/autocomplete.js b/src/core_plugins/console/public/src/autocomplete.js index 11d745e15a7f..82d464e881da 100644 --- a/src/core_plugins/console/public/src/autocomplete.js +++ b/src/core_plugins/console/public/src/autocomplete.js @@ -1,16 +1,21 @@ -let kb = require('./kb'); -let utils = require('./utils'); -let autocomplete_engine = require('./autocomplete/engine'); -let url_pattern_matcher = require('./autocomplete/url_pattern_matcher'); -let _ = require('lodash'); -let ace = require('ace'); -require('ace/ext-language_tools'); +import { + getTopLevelUrlCompleteComponents, + getEndpointBodyCompleteComponents, + getGlobalAutocompleteComponents, + getUnmatchedEndpointComponents +} from './kb'; +import utils from './utils'; +import { populateContext } from './autocomplete/engine'; +import { URL_PATH_END_MARKER } from './autocomplete/url_pattern_matcher'; +import _ from 'lodash'; +import ace from 'ace'; +import 'ace/ext-language_tools'; var AceRange = ace.require('ace/range').Range; var LAST_EVALUATED_TOKEN = null; -module.exports = function (editor) { +export default function (editor) { function isSeparatorToken(token) { switch ((token || {}).type) { @@ -505,7 +510,7 @@ module.exports = function (editor) { context.token = ret.token; context.otherTokenValues = ret.otherTokenValues; context.urlTokenPath = ret.urlTokenPath; - autocomplete_engine.populateContext(ret.urlTokenPath, context, editor, true, kb.getTopLevelUrlCompleteComponents()); + populateContext(ret.urlTokenPath, context, editor, true, getTopLevelUrlCompleteComponents()); context.autoCompleteSet = addMetaToTermsList(context.autoCompleteSet, "endpoint"); } @@ -520,7 +525,7 @@ module.exports = function (editor) { return context; } - autocomplete_engine.populateContext(ret.urlTokenPath, context, editor, false, kb.getTopLevelUrlCompleteComponents()); + populateContext(ret.urlTokenPath, context, editor, false, getTopLevelUrlCompleteComponents()); if (!context.endpoint) { console.log("couldn't resolve an endpoint."); @@ -537,7 +542,7 @@ module.exports = function (editor) { context.otherTokenValues = currentParam[tokenPath[0]]; } - autocomplete_engine.populateContext(tokenPath, context, editor, true, + populateContext(tokenPath, context, editor, true, context.endpoint.paramsAutocomplete.getTopLevelComponents()); return context; } @@ -554,7 +559,7 @@ module.exports = function (editor) { return context; } - autocomplete_engine.populateContext(ret.urlTokenPath, context, editor, false, kb.getTopLevelUrlCompleteComponents()); + populateContext(ret.urlTokenPath, context, editor, false, getTopLevelUrlCompleteComponents()); context.bodyTokenPath = ret.bodyTokenPath; if (!ret.bodyTokenPath) { // zero length tokenPath is true @@ -564,16 +569,16 @@ module.exports = function (editor) { } // needed for scope linking + global term resolving - context.endpointComponentResolver = kb.getEndpointBodyCompleteComponents; - context.globalComponentResolver = kb.getGlobalAutocompleteComponents; + context.endpointComponentResolver = getEndpointBodyCompleteComponents; + context.globalComponentResolver = getGlobalAutocompleteComponents; var components; if (context.endpoint) { components = context.endpoint.bodyAutocompleteRootComponents; } else { - components = kb.getUnmatchedEndpointComponents(); + components = getUnmatchedEndpointComponents(); } - autocomplete_engine.populateContext(ret.bodyTokenPath, context, editor, true, components); + populateContext(ret.bodyTokenPath, context, editor, true, components); return context; } @@ -806,7 +811,7 @@ module.exports = function (editor) { } else { // mark the url as completed. - ret.urlTokenPath.push(url_pattern_matcher.URL_PATH_END_MARKER); + ret.urlTokenPath.push(URL_PATH_END_MARKER); } if (t && t.type == "method") { @@ -955,7 +960,7 @@ module.exports = function (editor) { ace.define('ace/autocomplete/text_completer', ['require', 'exports', 'module'], function (require, exports) { exports.getCompletions = function (editor, session, pos, prefix, callback) { callback(null, []); - } + }; }); var langTools = ace.require('ace/ext/language_tools'); @@ -1020,4 +1025,4 @@ module.exports = function (editor) { removeChangeListener: removeChangeListener } } -}; +} diff --git a/src/core_plugins/console/public/src/autocomplete/body_completer.js b/src/core_plugins/console/public/src/autocomplete/body_completer.js index beada4e042eb..fec28448c395 100644 --- a/src/core_plugins/console/public/src/autocomplete/body_completer.js +++ b/src/core_plugins/console/public/src/autocomplete/body_completer.js @@ -378,9 +378,9 @@ GlobalOnlyComponent.prototype = _.create( // a list of component that match anything but give auto complete suggestions based on global API entries. -module.exports.globalsOnlyAutocompleteComponents = function () { +export function globalsOnlyAutocompleteComponents() { return [new GlobalOnlyComponent("__global__")]; -}; +} /** * @param endpoint_id id of the endpoint being compiled. @@ -395,6 +395,6 @@ module.exports.globalsOnlyAutocompleteComponents = function () { * } * } */ -module.exports.compileBodyDescription = function (endpoint_id, description, parametrizedComponentFactories) { +export function compileBodyDescription(endpoint_id, description, parametrizedComponentFactories) { return compileDescription(description, new CompilingContext(endpoint_id, parametrizedComponentFactories)); -}; +} diff --git a/src/core_plugins/console/public/src/autocomplete/engine.js b/src/core_plugins/console/public/src/autocomplete/engine.js index dc88f6113d0e..d41d25225300 100644 --- a/src/core_plugins/console/public/src/autocomplete/engine.js +++ b/src/core_plugins/console/public/src/autocomplete/engine.js @@ -1,13 +1,13 @@ -let _ = require('lodash'); +const _ = require('lodash'); -module.exports.AutocompleteComponent = function (name) { +export function AutocompleteComponent(name) { this.name = name; -}; +} /** called to get the possible suggestions for tokens, when this object is at the end of * the resolving chain (and thus can suggest possible continuation paths) */ -module.exports.AutocompleteComponent.prototype.getTerms = function () { +AutocompleteComponent.prototype.getTerms = function () { return []; }; @@ -21,14 +21,14 @@ module.exports.AutocompleteComponent.prototype.getTerms = function () { priority: optional priority to solve collisions between multiple paths. Min value is used across entire chain } */ -module.exports.AutocompleteComponent.prototype.match = function () { +AutocompleteComponent.prototype.match = function () { return { next: this.next }; }; function SharedComponent(name, parent) { - module.exports.AutocompleteComponent.call(this, name); + AutocompleteComponent.call(this, name); this._nextDict = {}; if (parent) { parent.addComponent(this); @@ -38,11 +38,9 @@ function SharedComponent(name, parent) { } SharedComponent.prototype = _.create( - module.exports.AutocompleteComponent.prototype, + AutocompleteComponent.prototype, { 'constructor': SharedComponent }); -module.exports.SharedComponent = SharedComponent; - (function (cls) { /* return the first component with a given name */ cls.getComponent = function (name) { @@ -69,7 +67,6 @@ function ListComponent(name, list, parent, multi_valued, allow_non_valid_values) } ListComponent.prototype = _.create(SharedComponent.prototype, { "constructor": ListComponent }); -module.exports.ListComponent = ListComponent; (function (cls) { @@ -142,7 +139,6 @@ function SimpleParamComponent(name, parent) { } SimpleParamComponent.prototype = _.create(SharedComponent.prototype, { "constructor": SimpleParamComponent }); -module.exports.SimpleParamComponent = SimpleParamComponent; (function (cls) { cls.match = function (token, context, editor) { @@ -163,7 +159,8 @@ function ConstantComponent(name, parent, options) { } ConstantComponent.prototype = _.create(SharedComponent.prototype, { "constructor": ConstantComponent }); -module.exports.ConstantComponent = ConstantComponent; + +export { SharedComponent, ListComponent, SimpleParamComponent, ConstantComponent }; (function (cls) { cls.getTerms = function () { @@ -188,7 +185,7 @@ module.exports.ConstantComponent = ConstantComponent; } })(ConstantComponent.prototype); -module.exports.wrapComponentWithDefaults = function (component, defaults) { +export function wrapComponentWithDefaults(component, defaults) { function Wrapper() { } @@ -214,7 +211,7 @@ module.exports.wrapComponentWithDefaults = function (component, defaults) { return result; }; return new Wrapper(); -}; +} let tracer = function () { if (window.engine_trace) { @@ -304,13 +301,13 @@ function walkTokenPath(tokenPath, walkingStates, context, editor) { return walkTokenPath(tokenPath.slice(1), nextWalkingStates, context, editor); } -module.exports.resolvePathToComponents = function (tokenPath, context, editor, components) { +export function resolvePathToComponents(tokenPath, context, editor, components) { var walkStates = walkTokenPath(tokenPath, [new WalkingState("ROOT", components, [])], context, editor); var result = [].concat.apply([], _.pluck(walkStates, 'components')); return result; -}; +} -module.exports.populateContext = function (tokenPath, context, editor, includeAutoComplete, components) { +export function populateContext(tokenPath, context, editor, includeAutoComplete, components) { var walkStates = walkTokenPath(tokenPath, [new WalkingState("ROOT", components, [])], context, editor); if (includeAutoComplete) { @@ -353,4 +350,4 @@ module.exports.populateContext = function (tokenPath, context, editor, includeAu _.assign(context, extension); }); } -}; +} diff --git a/src/core_plugins/console/public/src/autocomplete/url_params.js b/src/core_plugins/console/public/src/autocomplete/url_params.js index 236be948861b..2ff05b698d77 100644 --- a/src/core_plugins/console/public/src/autocomplete/url_params.js +++ b/src/core_plugins/console/public/src/autocomplete/url_params.js @@ -1,13 +1,12 @@ let _ = require('lodash'); let engine = require('./engine'); -function ParamComponent(name, parent, description) { +export function ParamComponent(name, parent, description) { engine.ConstantComponent.call(this, name, parent); this.description = description; } ParamComponent.prototype = _.create(engine.ConstantComponent.prototype, { "constructor": ParamComponent }); -module.exports.ParamComponent = ParamComponent; (function (cls) { cls.getTerms = function () { @@ -24,7 +23,7 @@ module.exports.ParamComponent = ParamComponent; })(ParamComponent.prototype); -function UrlParams(description, defaults) { +export function UrlParams(description, defaults) { // This is not really a component, just a handy container to make iteration logic simpler this.rootComponent = new engine.SharedComponent("ROOT"); if (_.isUndefined(defaults)) { @@ -55,5 +54,3 @@ function UrlParams(description, defaults) { } })(UrlParams.prototype); - -module.exports.UrlParams = UrlParams; diff --git a/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js b/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js index 7a20b49d6d44..9be51764e0b0 100644 --- a/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js +++ b/src/core_plugins/console/public/src/autocomplete/url_pattern_matcher.js @@ -1,8 +1,7 @@ let _ = require('lodash'); let engine = require('./engine'); -module.exports.URL_PATH_END_MARKER = "__url_path_end__"; - +export const URL_PATH_END_MARKER = "__url_path_end__"; function AcceptEndpointComponent(endpoint, parent) { engine.SharedComponent.call(this, endpoint.id, parent); @@ -14,7 +13,7 @@ AcceptEndpointComponent.prototype = _.create(engine.SharedComponent.prototype, { (function (cls) { cls.match = function (token, context, editor) { - if (token !== module.exports.URL_PATH_END_MARKER) { + if (token !== URL_PATH_END_MARKER) { return null; } if (this.endpoint.methods && -1 === _.indexOf(this.endpoint.methods, context.method)) { @@ -41,7 +40,7 @@ AcceptEndpointComponent.prototype = _.create(engine.SharedComponent.prototype, { * } * @constructor */ -function UrlPatternMatcher(parametrizedComponentFactories) { +export function UrlPatternMatcher(parametrizedComponentFactories) { // This is not really a component, just a handy container to make iteration logic simpler this.rootComponent = new engine.SharedComponent("ROOT"); this.parametrizedComponentFactories = parametrizedComponentFactories || {}; @@ -120,5 +119,3 @@ function UrlPatternMatcher(parametrizedComponentFactories) { } })(UrlPatternMatcher.prototype); - -module.exports.UrlPatternMatcher = UrlPatternMatcher; diff --git a/src/core_plugins/console/public/src/curl.js b/src/core_plugins/console/public/src/curl.js index 7cfa4d282a6c..4bbd962dfc19 100644 --- a/src/core_plugins/console/public/src/curl.js +++ b/src/core_plugins/console/public/src/curl.js @@ -1,217 +1,205 @@ -define(function () { - 'use strict'; - - function detectCURLinLine(line) { - // returns true if text matches a curl request - return line.match(/^\s*?curl\s+(-X[A-Z]+)?\s*['"]?.*?['"]?(\s*$|\s+?-d\s*?['"])/); - +function detectCURLinLine(line) { + // returns true if text matches a curl request + return line.match(/^\s*?curl\s+(-X[A-Z]+)?\s*['"]?.*?['"]?(\s*$|\s+?-d\s*?['"])/); +} + +export function detectCURL(text) { + // returns true if text matches a curl request + if (!text) return false; + for (var line of text.split("\n")) { + if (detectCURLinLine(line)) { + return true; + } + } + return false; +} + +export function parseCURL(text) { + var state = 'NONE'; + var out = []; + var body = []; + var line = ''; + var lines = text.trim().split("\n"); + var matches; + + var EmptyLine = /^\s*$/; + var Comment = /^\s*(?:#|\/{2,})(.*)\n?$/; + var ExecutionComment = /^\s*#!/; + var ClosingSingleQuote = /^([^']*)'/; + var ClosingDoubleQuote = /^((?:[^\\"]|\\.)*)"/; + var EscapedQuotes = /^((?:[^\\"']|\\.)+)/; + + var LooksLikeCurl = /^\s*curl\s+/; + var CurlVerb = /-X ?(GET|HEAD|POST|PUT|DELETE)/; + + var HasProtocol = /[\s"']https?:\/\//; + var CurlRequestWithProto = /[\s"']https?:\/\/[^\/ ]+\/+([^\s"']+)/; + var CurlRequestWithoutProto = /[\s"'][^\/ ]+\/+([^\s"']+)/; + var CurlData = /^.+\s(--data|-d)\s*/; + var SenseLine = /^\s*(GET|HEAD|POST|PUT|DELETE)\s+\/?(.+)/; + + if (lines.length > 0 && ExecutionComment.test(lines[0])) { + lines.shift(); } - function detectCURL(text) { - // returns true if text matches a curl request - if (!text) return false; - for (var line of text.split("\n")) { - if (detectCURLinLine(line)) { - return true; - } + function nextLine() { + if (line.length > 0) { + return true; + } + if (lines.length == 0) { + return false; } - return false; + line = lines.shift().replace(/[\r\n]+/g, "\n") + "\n"; + return true; } - function parseCURL(text) { - var state = 'NONE'; - var out = []; - var body = []; - var line = ''; - var lines = text.trim().split("\n"); - var matches; - - var EmptyLine = /^\s*$/; - var Comment = /^\s*(?:#|\/{2,})(.*)\n?$/; - var ExecutionComment = /^\s*#!/; - var ClosingSingleQuote = /^([^']*)'/; - var ClosingDoubleQuote = /^((?:[^\\"]|\\.)*)"/; - var EscapedQuotes = /^((?:[^\\"']|\\.)+)/; - - var LooksLikeCurl = /^\s*curl\s+/; - var CurlVerb = /-X ?(GET|HEAD|POST|PUT|DELETE)/; - - var HasProtocol = /[\s"']https?:\/\//; - var CurlRequestWithProto = /[\s"']https?:\/\/[^\/ ]+\/+([^\s"']+)/; - var CurlRequestWithoutProto = /[\s"'][^\/ ]+\/+([^\s"']+)/; - var CurlData = /^.+\s(--data|-d)\s*/; - var SenseLine = /^\s*(GET|HEAD|POST|PUT|DELETE)\s+\/?(.+)/; + function unescapeLastBodyEl() { + var str = body.pop().replace(/\\([\\"'])/g, "$1"); + body.push(str); + } - if (lines.length > 0 && ExecutionComment.test(lines[0])) { - lines.shift(); + // Is the next char a single or double quote? + // If so remove it + function detectQuote() { + if (line.substr(0, 1) == "'") { + line = line.substr(1); + state = 'SINGLE_QUOTE'; } - - function nextLine() { - if (line.length > 0) { - return true; - } - if (lines.length == 0) { - return false; - } - line = lines.shift().replace(/[\r\n]+/g, "\n") + "\n"; - return true; + else if (line.substr(0, 1) == '"') { + line = line.substr(1); + state = 'DOUBLE_QUOTE'; } - - function unescapeLastBodyEl() { - var str = body.pop().replace(/\\([\\"'])/g, "$1"); - body.push(str); + else { + state = 'UNQUOTED'; } + } - // Is the next char a single or double quote? - // If so remove it - function detectQuote() { - if (line.substr(0, 1) == "'") { - line = line.substr(1); - state = 'SINGLE_QUOTE'; - } - else if (line.substr(0, 1) == '"') { - line = line.substr(1); - state = 'DOUBLE_QUOTE'; - } - else { - state = 'UNQUOTED'; - } + // Body is finished - append to output with final LF + function addBodyToOut() { + if (body.length > 0) { + out.push(body.join("")); + body = []; } + state = 'LF'; + out.push("\n"); + } - // Body is finished - append to output with final LF - function addBodyToOut() { - if (body.length > 0) { - out.push(body.join("")); - body = []; - } - state = 'LF'; - out.push("\n"); - } - - // If the pattern matches, then the state is about to change, - // so add the capture to the body and detect the next state - // Otherwise add the whole line - function consumeMatching(pattern) { - var matches = line.match(pattern); - if (matches) { - body.push(matches[1]); - line = line.substr(matches[0].length); - detectQuote(); - } - else { - body.push(line); - line = ''; - } + // If the pattern matches, then the state is about to change, + // so add the capture to the body and detect the next state + // Otherwise add the whole line + function consumeMatching(pattern) { + var matches = line.match(pattern); + if (matches) { + body.push(matches[1]); + line = line.substr(matches[0].length); + detectQuote(); } + else { + body.push(line); + line = ''; + } + } - function parseCurlLine() { - var verb = 'GET'; - var request = ''; - var matches; - if (matches = line.match(CurlVerb)) { - verb = matches[1]; - } + function parseCurlLine() { + var verb = 'GET'; + var request = ''; + var matches; + if (matches = line.match(CurlVerb)) { + verb = matches[1]; + } - // JS regexen don't support possesive quantifiers, so - // we need two distinct patterns - var pattern = HasProtocol.test(line) - ? CurlRequestWithProto - : CurlRequestWithoutProto; + // JS regexen don't support possesive quantifiers, so + // we need two distinct patterns + var pattern = HasProtocol.test(line) + ? CurlRequestWithProto + : CurlRequestWithoutProto; - if (matches = line.match(pattern)) { - request = matches[1]; - } + if (matches = line.match(pattern)) { + request = matches[1]; + } - out.push(verb + ' /' + request + "\n"); + out.push(verb + ' /' + request + "\n"); - if (matches = line.match(CurlData)) { - line = line.substr(matches[0].length); - detectQuote(); - if (EmptyLine.test(line)) { - line = ''; - } - } - else { - state = 'NONE'; + if (matches = line.match(CurlData)) { + line = line.substr(matches[0].length); + detectQuote(); + if (EmptyLine.test(line)) { line = ''; - out.push(''); } } + else { + state = 'NONE'; + line = ''; + out.push(''); + } + } - while (nextLine()) { + while (nextLine()) { - if (state == 'SINGLE_QUOTE') { - consumeMatching(ClosingSingleQuote); - } + if (state == 'SINGLE_QUOTE') { + consumeMatching(ClosingSingleQuote); + } + + else if (state == 'DOUBLE_QUOTE') { + consumeMatching(ClosingDoubleQuote); + unescapeLastBodyEl(); + } - else if (state == 'DOUBLE_QUOTE') { - consumeMatching(ClosingDoubleQuote); + else if (state == 'UNQUOTED') { + consumeMatching(EscapedQuotes); + if (body.length) { unescapeLastBodyEl(); } - - else if (state == 'UNQUOTED') { - consumeMatching(EscapedQuotes); - if (body.length) { - unescapeLastBodyEl(); - } - if (state == 'UNQUOTED') { - addBodyToOut(); - line = '' - } + if (state == 'UNQUOTED') { + addBodyToOut(); + line = '' } + } - // the BODY state (used to match the body of a Sense request) - // can be terminated early if it encounters - // a comment or an empty line - else if (state == 'BODY') { - if (Comment.test(line) || EmptyLine.test(line)) { - addBodyToOut(); - } - else { - body.push(line); - line = ''; - } + // the BODY state (used to match the body of a Sense request) + // can be terminated early if it encounters + // a comment or an empty line + else if (state == 'BODY') { + if (Comment.test(line) || EmptyLine.test(line)) { + addBodyToOut(); } - - else if (EmptyLine.test(line)) { - if (state != 'LF') { - out.push("\n"); - state = 'LF'; - } + else { + body.push(line); line = ''; } + } - else if (matches = line.match(Comment)) { - out.push("#" + matches[1] + "\n"); - state = 'NONE'; - line = ''; + else if (EmptyLine.test(line)) { + if (state != 'LF') { + out.push("\n"); + state = 'LF'; } + line = ''; + } - else if (LooksLikeCurl.test(line)) { - parseCurlLine(); - } + else if (matches = line.match(Comment)) { + out.push("#" + matches[1] + "\n"); + state = 'NONE'; + line = ''; + } - else if (matches = line.match(SenseLine)) { - out.push(matches[1] + ' /' + matches[2] + "\n"); - line = ''; - state = 'BODY'; - } + else if (LooksLikeCurl.test(line)) { + parseCurlLine(); + } - // Nothing else matches, so output with a prefix of !!! for debugging purposes - else { - out.push('### ' + line); - line = ''; - } + else if (matches = line.match(SenseLine)) { + out.push(matches[1] + ' /' + matches[2] + "\n"); + line = ''; + state = 'BODY'; } - addBodyToOut(); - return out.join('').trim(); + // Nothing else matches, so output with a prefix of !!! for debugging purposes + else { + out.push('### ' + line); + line = ''; + } } - - return { - parseCURL: parseCURL, - detectCURL: detectCURL - }; - -}); + addBodyToOut(); + return out.join('').trim(); +} diff --git a/src/core_plugins/console/public/src/es.js b/src/core_plugins/console/public/src/es.js index c1049a462571..1e7c84008291 100644 --- a/src/core_plugins/console/public/src/es.js +++ b/src/core_plugins/console/public/src/es.js @@ -1,14 +1,13 @@ import { stringify as formatQueryString } from 'querystring' - import $ from 'jquery'; let esVersion = []; -module.exports.getVersion = function () { +export function getVersion() { return esVersion; -}; +} -module.exports.send = function (method, path, data) { +export function send(method, path, data) { var wrappedDfd = $.Deferred(); console.log("Calling " + path); @@ -57,10 +56,10 @@ module.exports.send = function (method, path, data) { wrappedDfd.rejectWith(this, [jqXHR, textStatus, errorThrown]); }); return wrappedDfd; -}; +} -module.exports.constructESUrl = function (baseUri, path) { +export function constructESUrl(baseUri, path) { baseUri = baseUri.replace(/\/+$/, ''); path = path.replace(/^\/+/, ''); return baseUri + '/' + path; -}; +} diff --git a/src/core_plugins/console/public/src/history.js b/src/core_plugins/console/public/src/history.js index 970dc7384e13..935808374cb4 100644 --- a/src/core_plugins/console/public/src/history.js +++ b/src/core_plugins/console/public/src/history.js @@ -1,7 +1,7 @@ const $ = require('jquery'); const storage = require('./storage'); -const history = module.exports = { +const history = { restoreFromHistory() { // default method for history.restoreFromHistory // replace externally to do something when the user chooses @@ -60,3 +60,5 @@ const history = module.exports = { .forEach(key => storage.delete(key)); } }; + +export default history; diff --git a/src/core_plugins/console/public/src/input_resize.js b/src/core_plugins/console/public/src/input_resize.js index 83688cb4f9cf..7ef2a9b004ab 100644 --- a/src/core_plugins/console/public/src/input_resize.js +++ b/src/core_plugins/console/public/src/input_resize.js @@ -1,7 +1,7 @@ const $ = require('jquery'); const storage = require('./storage'); -module.exports = function (input, output) { +export default function (input, output) { const $left = input.$el.parent(); diff --git a/src/core_plugins/console/public/src/kb.js b/src/core_plugins/console/public/src/kb.js index a55a5037a49d..5a393ed49cda 100644 --- a/src/core_plugins/console/public/src/kb.js +++ b/src/core_plugins/console/public/src/kb.js @@ -1,10 +1,10 @@ -let $ = require('jquery'); -let _ = require('lodash'); -let mappings = require('./mappings'); -let Api = require('./kb/api'); -let autocomplete_engine = require('./autocomplete/engine'); +const $ = require('jquery'); +const _ = require('lodash'); +const mappings = require('./mappings'); +const Api = require('./kb/api'); +const autocomplete_engine = require('./autocomplete/engine'); -var ACTIVE_API = new Api(); +let ACTIVE_API = new Api(); function nonValidIndexType(token) { return !(token === "_all" || token[0] !== "_"); @@ -166,15 +166,15 @@ var parametrizedComponentFactories = { } }; -function getUnmatchedEndpointComponents() { +export function getUnmatchedEndpointComponents() { return ACTIVE_API.getUnmatchedEndpointComponents(); } -function getEndpointDescriptionByEndpoint(endpoint) { +export function getEndpointDescriptionByEndpoint(endpoint) { return ACTIVE_API.getEndpointDescriptionByEndpoint(endpoint) } -function getEndpointBodyCompleteComponents(endpoint) { +export function getEndpointBodyCompleteComponents(endpoint) { var desc = getEndpointDescriptionByEndpoint(endpoint); if (!desc) { throw new Error("failed to resolve endpoint ['" + endpoint + "']"); @@ -182,11 +182,11 @@ function getEndpointBodyCompleteComponents(endpoint) { return desc.bodyAutocompleteRootComponents; } -function getTopLevelUrlCompleteComponents() { +export function getTopLevelUrlCompleteComponents() { return ACTIVE_API.getTopLevelUrlCompleteComponents(); } -function getGlobalAutocompleteComponents(term, throwOnMissing) { +export function getGlobalAutocompleteComponents(term, throwOnMissing) { return ACTIVE_API.getGlobalAutocompleteComponents(term, throwOnMissing); } @@ -208,7 +208,7 @@ function loadApisFromJson(json, urlParametrizedComponentFactories, bodyParametri return api; } -function setActiveApi(api) { +export function setActiveApi(api) { if (_.isString(api)) { $.ajax({ url: '../api/console/api_server?sense_version=' + encodeURIComponent('@@SENSE_VERSION') + "&apis=" + encodeURIComponent(api), @@ -231,13 +231,6 @@ function setActiveApi(api) { setActiveApi('es_5_0'); -module.exports.setActiveApi = setActiveApi; -module.exports.getGlobalAutocompleteComponents = getGlobalAutocompleteComponents; -module.exports.getEndpointDescriptionByEndpoint = getEndpointDescriptionByEndpoint; -module.exports.getEndpointBodyCompleteComponents = getEndpointBodyCompleteComponents; -module.exports.getTopLevelUrlCompleteComponents = getTopLevelUrlCompleteComponents; -module.exports.getUnmatchedEndpointComponents = getUnmatchedEndpointComponents; - -module.exports._test = { +export const _test = { loadApisFromJson: loadApisFromJson }; diff --git a/src/core_plugins/console/public/src/kb/api.js b/src/core_plugins/console/public/src/kb/api.js index 6e108495a8af..3d0f80b1ad9c 100644 --- a/src/core_plugins/console/public/src/kb/api.js +++ b/src/core_plugins/console/public/src/kb/api.js @@ -73,4 +73,4 @@ function Api(urlParametrizedComponentFactories, bodyParametrizedComponentFactori }(Api.prototype)); -module.exports = Api; +export default Api; diff --git a/src/core_plugins/console/public/src/mappings.js b/src/core_plugins/console/public/src/mappings.js index 6c93bae9d043..3522dc4912f3 100644 --- a/src/core_plugins/console/public/src/mappings.js +++ b/src/core_plugins/console/public/src/mappings.js @@ -278,7 +278,7 @@ function autocomplete_retriever() { }, 60000); } -module.exports = _.assign(mappingObj, { +export default _.assign(mappingObj, { getFields: getFields, getIndices: getIndices, getTypes: getTypes, diff --git a/src/core_plugins/console/public/src/sense_editor/editor.js b/src/core_plugins/console/public/src/sense_editor/editor.js index b6e169dad743..9e12c2138374 100644 --- a/src/core_plugins/console/public/src/sense_editor/editor.js +++ b/src/core_plugins/console/public/src/sense_editor/editor.js @@ -47,7 +47,7 @@ function createInstance($el) { return editor; } -function SenseEditor($el) { +export default function SenseEditor($el) { var editor = createInstance($el); var CURRENT_REQ_RANGE = null; @@ -632,5 +632,3 @@ function SenseEditor($el) { return editor; } - -module.exports = SenseEditor; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/input.js b/src/core_plugins/console/public/src/sense_editor/mode/input.js index e17cd2194620..06231729dc3a 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/input.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/input.js @@ -15,8 +15,7 @@ var HighlightRules = require("./input_highlight_rules").InputHighlightRules; acequire("ace/config").setModuleUrl("sense_editor/mode/worker", require("file!./worker.js")); - -var Mode = function () { +export function Mode() { this.$tokenizer = new AceTokenizer(new HighlightRules().getRules()); this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); @@ -24,7 +23,7 @@ var Mode = function () { this.createModeDelegates({ "script-": ScriptMode }); -}; +} oop.inherits(Mode, TextMode); (function () { @@ -72,5 +71,3 @@ oop.inherits(Mode, TextMode); }).call(Mode.prototype); - -module.exports.Mode = Mode; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js b/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js index 7649a28db27a..628d166cc003 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/input_highlight_rules.js @@ -4,8 +4,7 @@ let x_json = require('./x_json_highlight_rules'); var oop = ace.require("ace/lib/oop"); var TextHighlightRules = ace.require("ace/mode/text_highlight_rules").TextHighlightRules; -var InputHighlightRules = function () { - +export function InputHighlightRules() { function mergeTokens(/* ... */) { return [].concat.apply([], arguments); } @@ -66,9 +65,6 @@ var InputHighlightRules = function () { this.normalizeRules(); } -}; +} oop.inherits(InputHighlightRules, TextHighlightRules); - - -module.exports.InputHighlightRules = InputHighlightRules; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/output.js b/src/core_plugins/console/public/src/sense_editor/mode/output.js index adfbb9d6c208..319495ad18d2 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/output.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/output.js @@ -12,12 +12,12 @@ var CStyleFoldMode = ace.require("ace/mode/folding/cstyle").FoldMode; ace.require("ace/worker/worker_client"); var AceTokenizer = ace.require("ace/tokenizer").Tokenizer; -var Mode = function () { +export function Mode() { this.$tokenizer = new AceTokenizer(new HighlightRules().getRules()); this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); -}; +} oop.inherits(Mode, JSONMode); (function () { @@ -27,5 +27,3 @@ oop.inherits(Mode, JSONMode); this.$id = "sense/mode/input"; }).call(Mode.prototype); - -module.exports.Mode = Mode; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js b/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js index b8e3fc32a316..f405796fc0e4 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/output_highlight_rules.js @@ -5,7 +5,7 @@ let x_json = require('./x_json_highlight_rules'); var oop = ace.require("ace/lib/oop"); var JsonHighlightRules = ace.require("ace/mode/json_highlight_rules").JsonHighlightRules; -var OutputJsonHighlightRules = function () { +export function OutputJsonHighlightRules() { this.$rules = {}; @@ -26,8 +26,6 @@ var OutputJsonHighlightRules = function () { this.normalizeRules(); } -}; +} oop.inherits(OutputJsonHighlightRules, JsonHighlightRules); - -module.exports.OutputJsonHighlightRules = OutputJsonHighlightRules; diff --git a/src/core_plugins/console/public/src/sense_editor/mode/script.js b/src/core_plugins/console/public/src/sense_editor/mode/script.js index a18469751cc8..f27daf52ff3a 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/script.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/script.js @@ -11,12 +11,12 @@ acequire("ace/tokenizer") var ScriptHighlightRules = require("./script_highlight_rules").ScriptHighlightRules; - -export var ScriptMode = function () { +export function ScriptMode() { this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); -}; +} + oop.inherits(ScriptMode, TextMode); (function () { diff --git a/src/core_plugins/console/public/src/sense_editor/mode/script_highlight_rules.js b/src/core_plugins/console/public/src/sense_editor/mode/script_highlight_rules.js index 0d755852ff61..e613c80f20fc 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/script_highlight_rules.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/script_highlight_rules.js @@ -7,7 +7,7 @@ let painlessKeywords = ( "def|int|long|byte|String|float|double|char|null|if|else|while|do|for|continue|break|new|try|catch|throw|this|instanceof|return|ctx" ); -export var ScriptHighlightRules = function () { +export function ScriptHighlightRules() { this.name = "ScriptHighlightRules"; this.$rules = { "start": [ @@ -61,5 +61,6 @@ export var ScriptHighlightRules = function () { } ] } -}; +} + oop.inherits(ScriptHighlightRules, TextHighlightRules); \ No newline at end of file diff --git a/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js b/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js index 0be9de94158e..e22587c756ad 100644 --- a/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js +++ b/src/core_plugins/console/public/src/sense_editor/mode/x_json_highlight_rules.js @@ -101,7 +101,7 @@ var jsonRules = function (root) { return rules; }; -module.exports.addToRules = function (otherRules, embedUnder) { +export function addToRules(otherRules, embedUnder) { otherRules.$rules = _.defaultsDeep(otherRules.$rules, jsonRules(embedUnder)); otherRules.embedRules(ScriptHighlightRules, "script-", [{ token: "punctuation.end_triple_quote", diff --git a/src/core_plugins/console/public/src/sense_editor/row_parser.js b/src/core_plugins/console/public/src/sense_editor/row_parser.js index f7cbbe44d624..5759e46cac7e 100644 --- a/src/core_plugins/console/public/src/sense_editor/row_parser.js +++ b/src/core_plugins/console/public/src/sense_editor/row_parser.js @@ -120,4 +120,4 @@ function RowParser(editor) { RowParser.prototype.MODE = MODE; -module.exports = RowParser; +export default RowParser; diff --git a/src/core_plugins/console/public/src/smart_resize.js b/src/core_plugins/console/public/src/smart_resize.js index 5f943d1579e1..0e52ce06080e 100644 --- a/src/core_plugins/console/public/src/smart_resize.js +++ b/src/core_plugins/console/public/src/smart_resize.js @@ -1,6 +1,6 @@ import { throttle } from 'lodash'; -module.exports = function (editor) { +export default function (editor) { const resize = editor.resize; return throttle(() => resize.call(editor), 35) -}; +} diff --git a/src/core_plugins/console/public/src/storage.js b/src/core_plugins/console/public/src/storage.js index c23a11f1d9f9..c4bba8f97b0c 100644 --- a/src/core_plugins/console/public/src/storage.js +++ b/src/core_plugins/console/public/src/storage.js @@ -55,4 +55,6 @@ class Storage { } } -module.exports = new Storage(localStorage, 'sense:'); +const instance = new Storage(localStorage, 'sense:'); + +export default instance; diff --git a/src/core_plugins/console/public/src/utils.js b/src/core_plugins/console/public/src/utils.js index 7acb49ab5fdf..98fc680c7749 100644 --- a/src/core_plugins/console/public/src/utils.js +++ b/src/core_plugins/console/public/src/utils.js @@ -98,4 +98,4 @@ utils.splitOnUnquotedCommaSpace = function (s) { return arr; } -module.exports = utils; +export default utils; diff --git a/src/core_plugins/dev_mode/public/ng_mock.js b/src/core_plugins/dev_mode/public/ng_mock.js index 0c3a3e1d0f50..8ee60360bb2d 100644 --- a/src/core_plugins/dev_mode/public/ng_mock.js +++ b/src/core_plugins/dev_mode/public/ng_mock.js @@ -9,4 +9,4 @@ if (angular.mocks) { ); } -module.exports = angular.mock; +export default angular.mock; diff --git a/src/core_plugins/elasticsearch/index.js b/src/core_plugins/elasticsearch/index.js index 85b78d73d1bd..e5dc9b05c903 100644 --- a/src/core_plugins/elasticsearch/index.js +++ b/src/core_plugins/elasticsearch/index.js @@ -9,11 +9,11 @@ import { clientLogger } from './lib/client_logger'; import { createClusters } from './lib/create_clusters'; import filterHeaders from './lib/filter_headers'; -import createProxy, { createPath } from './lib/create_proxy'; +import { createProxy, createPath } from './lib/create_proxy'; const DEFAULT_REQUEST_HEADERS = [ 'authorization' ]; -module.exports = function (kibana) { +export default function (kibana) { return new kibana.Plugin({ require: ['kibana'], config(Joi) { @@ -166,4 +166,4 @@ module.exports = function (kibana) { } }); -}; +} diff --git a/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js b/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js index f09dae25fc99..0bbdf724b637 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js @@ -1,21 +1,21 @@ import expect from 'expect.js'; -import createProxy from '../create_proxy'; +import { createPath } from '../create_proxy'; describe('plugins/elasticsearch', function () { describe('lib/create_proxy', function () { describe('#createPath', function () { it('prepends /elasticsearch to route', function () { - const path = createProxy.createPath('/foobar', '/wat'); + const path = createPath('/foobar', '/wat'); expect(path).to.equal('/foobar/wat'); }); it('ensures leading slash for prefix', function () { - const path = createProxy.createPath('foobar', '/wat'); + const path = createPath('foobar', '/wat'); expect(path).to.equal('/foobar/wat'); }); it('ensures leading slash for path', function () { - const path = createProxy.createPath('/foobar', 'wat'); + const path = createPath('/foobar', 'wat'); expect(path).to.equal('/foobar/wat'); }); }); diff --git a/src/core_plugins/elasticsearch/lib/__tests__/find_port.js b/src/core_plugins/elasticsearch/lib/__tests__/find_port.js index 9be2de1ba88d..2ef8ce083461 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/find_port.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/find_port.js @@ -1,7 +1,7 @@ import Promise from 'bluebird'; import portscanner from 'portscanner'; -module.exports = function findPort(start, end, host) { +export default function findPort(start, end, host) { host = host || 'localhost'; return new Promise(function (resolve, reject) { portscanner.findAPortNotInUse(start, end, host, function (err, port) { @@ -9,5 +9,5 @@ module.exports = function findPort(start, end, host) { resolve(port); }); }); -}; +} diff --git a/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js b/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js index d9785f603d22..0c9cf770bef8 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js @@ -1,4 +1,4 @@ -module.exports = { +export default { '_default_': { 'dynamic': 'strict' }, diff --git a/src/core_plugins/elasticsearch/lib/create_kibana_index.js b/src/core_plugins/elasticsearch/lib/create_kibana_index.js index ddf351452021..5a419646ca30 100644 --- a/src/core_plugins/elasticsearch/lib/create_kibana_index.js +++ b/src/core_plugins/elasticsearch/lib/create_kibana_index.js @@ -1,4 +1,4 @@ -module.exports = function (server, mappings) { +export default function (server, mappings) { const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin'); const index = server.config().get('kibana.index'); return callWithInternalUser('indices.create', { @@ -24,4 +24,4 @@ module.exports = function (server, mappings) { throw new Error(`Waiting for Kibana index "${index}" to come online failed.`); }); }); -}; +} diff --git a/src/core_plugins/elasticsearch/lib/create_proxy.js b/src/core_plugins/elasticsearch/lib/create_proxy.js index 1ebf0643035a..93986c952c9d 100644 --- a/src/core_plugins/elasticsearch/lib/create_proxy.js +++ b/src/core_plugins/elasticsearch/lib/create_proxy.js @@ -2,7 +2,14 @@ import createAgent from './create_agent'; import mapUri from './map_uri'; import { assign } from 'lodash'; -function createProxy(server, method, path, config) { +export function createPath(prefix, path) { + path = path[0] === '/' ? path : `/${path}`; + prefix = prefix[0] === '/' ? prefix : `/${prefix}`; + + return `${prefix}${path}`; +} + +export function createProxy(server, method, path, config) { const proxies = new Map([ ['/elasticsearch', server.plugins.elasticsearch.getCluster('data')], ['/es_admin', server.plugins.elasticsearch.getCluster('admin')] @@ -25,7 +32,7 @@ function createProxy(server, method, path, config) { for (const [proxyPrefix, cluster] of proxies) { const options = { method, - path: createProxy.createPath(proxyPrefix, path), + path: createPath(proxyPrefix, path), config: { timeout: { socket: cluster.getRequestTimeout() @@ -50,12 +57,3 @@ function createProxy(server, method, path, config) { server.route(options); } } - -createProxy.createPath = function createPath(prefix, path) { - path = path[0] === '/' ? path : `/${path}`; - prefix = prefix[0] === '/' ? prefix : `/${prefix}`; - - return `${prefix}${path}`; -}; - -module.exports = createProxy; diff --git a/src/core_plugins/elasticsearch/lib/health_check.js b/src/core_plugins/elasticsearch/lib/health_check.js index bfde87e98e13..86bb43b1e3ec 100644 --- a/src/core_plugins/elasticsearch/lib/health_check.js +++ b/src/core_plugins/elasticsearch/lib/health_check.js @@ -16,7 +16,7 @@ const NO_INDEX = 'no_index'; const INITIALIZING = 'initializing'; const READY = 'ready'; -module.exports = function (plugin, server, { mappings }) { +export default function (plugin, server, { mappings }) { const config = server.config(); const callAdminAsKibanaUser = server.plugins.elasticsearch.getCluster('admin').callWithInternalUser; const callDataAsKibanaUser = server.plugins.elasticsearch.getCluster('data').callWithInternalUser; @@ -146,4 +146,4 @@ module.exports = function (plugin, server, { mappings }) { isRunning: function () { return !!timeoutId; }, }; -}; +} diff --git a/src/core_plugins/elasticsearch/lib/is_upgradeable.js b/src/core_plugins/elasticsearch/lib/is_upgradeable.js index 2da4012d01e5..84da1dbfb3c4 100644 --- a/src/core_plugins/elasticsearch/lib/is_upgradeable.js +++ b/src/core_plugins/elasticsearch/lib/is_upgradeable.js @@ -1,7 +1,7 @@ import semver from 'semver'; const rcVersionRegex = /(\d+\.\d+\.\d+)\-rc(\d+)/i; -module.exports = function (server, doc) { +export default function (server, doc) { const config = server.config(); if (/alpha|beta|snapshot/i.test(doc._id)) return false; if (!doc._id) return false; @@ -30,4 +30,4 @@ module.exports = function (server, doc) { return false; } return true; -}; +} diff --git a/src/core_plugins/elasticsearch/lib/migrate_config.js b/src/core_plugins/elasticsearch/lib/migrate_config.js index 5a114639d7b6..f6a5b300478a 100644 --- a/src/core_plugins/elasticsearch/lib/migrate_config.js +++ b/src/core_plugins/elasticsearch/lib/migrate_config.js @@ -1,7 +1,7 @@ import { get } from 'lodash'; import upgrade from './upgrade_config'; -module.exports = function (server, { mappings }) { +export default function (server, { mappings }) { const config = server.config(); const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin'); const options = { @@ -21,4 +21,4 @@ module.exports = function (server, { mappings }) { }; return callWithInternalUser('search', options).then(upgrade(server)); -}; +} diff --git a/src/core_plugins/elasticsearch/lib/upgrade_config.js b/src/core_plugins/elasticsearch/lib/upgrade_config.js index 2ac78615b13c..1b9ac7df2046 100644 --- a/src/core_plugins/elasticsearch/lib/upgrade_config.js +++ b/src/core_plugins/elasticsearch/lib/upgrade_config.js @@ -2,7 +2,7 @@ import Promise from 'bluebird'; import isUpgradeable from './is_upgradeable'; import _ from 'lodash'; -module.exports = function (server) { +export default function (server) { const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin'); const config = server.config(); @@ -54,4 +54,4 @@ module.exports = function (server) { id: config.get('pkg.version') }); }; -}; +} diff --git a/src/core_plugins/kibana/common/lib/convert_pattern_and_ingest_name.js b/src/core_plugins/kibana/common/lib/convert_pattern_and_ingest_name.js index bd09904c5a12..f22038082874 100644 --- a/src/core_plugins/kibana/common/lib/convert_pattern_and_ingest_name.js +++ b/src/core_plugins/kibana/common/lib/convert_pattern_and_ingest_name.js @@ -3,20 +3,18 @@ // e.g. a pattern with title `logstash-*` will have a matching template named `kibana-logstash-*`. // This module provides utility functions for easily converting between template and pattern names. -module.exports = { - ingestToPattern: (templateName) => { - if (templateName.indexOf('kibana-') === -1) { - throw new Error('not a valid kibana namespaced template name'); - } - - return templateName.slice(templateName.indexOf('-') + 1); - }, +export function ingestToPattern(templateName) { + if (templateName.indexOf('kibana-') === -1) { + throw new Error('not a valid kibana namespaced template name'); + } - patternToIngest: (patternName) => { - if (patternName === '') { - throw new Error('pattern must not be empty'); - } + return templateName.slice(templateName.indexOf('-') + 1); +} - return `kibana-${patternName.toLowerCase()}`; +export function patternToIngest(patternName) { + if (patternName === '') { + throw new Error('pattern must not be empty'); } -}; + + return `kibana-${patternName.toLowerCase()}`; +} diff --git a/src/core_plugins/kibana/index.js b/src/core_plugins/kibana/index.js index 9a529ce07f78..21917225524d 100644 --- a/src/core_plugins/kibana/index.js +++ b/src/core_plugins/kibana/index.js @@ -16,7 +16,7 @@ import { injectVars } from './inject_vars'; const mkdirp = Promise.promisify(mkdirpNode); -module.exports = function (kibana) { +export default function (kibana) { const kbnBaseUrl = '/app/kibana'; return new kibana.Plugin({ id: 'kibana', @@ -133,4 +133,4 @@ module.exports = function (kibana) { server.expose('injectVars', injectVars); } }); -}; +} diff --git a/src/core_plugins/kibana/public/discover/_hit_sort_fn.js b/src/core_plugins/kibana/public/discover/_hit_sort_fn.js index 83cc68c16050..621d0fd6153b 100644 --- a/src/core_plugins/kibana/public/discover/_hit_sort_fn.js +++ b/src/core_plugins/kibana/public/discover/_hit_sort_fn.js @@ -1,66 +1,63 @@ -define(function () { - return function HitSortFnFactory() { - - /** - * Creates a sort function that will resort hits based on the value - * es used to sort them. - * - * background: - * When a hit is sorted by elasticsearch, es will write the values that it used - * to sort them into an array at the top level of the hit like so - * - * ``` - * hits: { - * total: x, - * hits: [ - * { - * _id: i, - * _source: {}, - * sort: [ - * // all values used to sort, in the order of precidance - * ] - * } - * ] - * }; - * ``` - * - * @param {[type]} field [description] - * @param {[type]} direction [description] - * @return {[type]} [description] - */ - return function createHitSortFn(direction) { - const descending = (direction === 'desc'); - - return function sortHits(hitA, hitB) { - let bBelowa = null; - - const aSorts = hitA.sort || []; - const bSorts = hitB.sort || []; - - // walk each sort value, and compair until one is different - for (let i = 0; i < bSorts.length; i++) { - const a = aSorts[i]; - const b = bSorts[i]; - - if (a == null || b > a) { - bBelowa = !descending; - break; - } - - if (b < a) { - bBelowa = descending; - break; - } +// eslint-disable-next-line kibana-custom/no-default-export +export default function HitSortFnFactory() { + /** + * Creates a sort function that will resort hits based on the value + * es used to sort them. + * + * background: + * When a hit is sorted by elasticsearch, es will write the values that it used + * to sort them into an array at the top level of the hit like so + * + * ``` + * hits: { + * total: x, + * hits: [ + * { + * _id: i, + * _source: {}, + * sort: [ + * // all values used to sort, in the order of precidance + * ] + * } + * ] + * }; + * ``` + * + * @param {[type]} field [description] + * @param {[type]} direction [description] + * @return {[type]} [description] + */ + return function createHitSortFn(direction) { + const descending = (direction === 'desc'); + + return function sortHits(hitA, hitB) { + let bBelowa = null; + + const aSorts = hitA.sort || []; + const bSorts = hitB.sort || []; + + // walk each sort value, and compair until one is different + for (let i = 0; i < bSorts.length; i++) { + const a = aSorts[i]; + const b = bSorts[i]; + + if (a == null || b > a) { + bBelowa = !descending; + break; } - if (bBelowa !== null) { - return bBelowa ? -1 : 1; - } else { - return 0; + if (b < a) { + bBelowa = descending; + break; } + } - }; - }; + if (bBelowa !== null) { + return bBelowa ? -1 : 1; + } else { + return 0; + } + }; }; -}); +} diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js index 6b03a7ff0eca..74c415bc4030 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.js @@ -5,7 +5,7 @@ import './scripted_fields_table'; import './scripted_field_editor'; import './source_filters_table'; import { RefreshKibanaIndex } from '../refresh_kibana_index'; -import UrlProvider from 'ui/url'; +import { KbnUrlProvider } from 'ui/url'; import { IndicesEditSectionsProvider } from './edit_sections'; import uiRoutes from 'ui/routes'; import { uiModules } from 'ui/modules'; @@ -46,7 +46,7 @@ uiModules.get('apps/management') const $state = $scope.state = new AppState(); const refreshKibanaIndex = Private(RefreshKibanaIndex); - $scope.kbnUrl = Private(UrlProvider); + $scope.kbnUrl = Private(KbnUrlProvider); $scope.indexPattern = $route.current.locals.indexPattern; docTitle.change($scope.indexPattern.id); const otherIds = _.without($route.current.locals.indexPatternIds, $scope.indexPattern.id); diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_field_editor/scripted_field_editor.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_field_editor/scripted_field_editor.js index 8c90e44ec36f..8fa971ef10f7 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_field_editor/scripted_field_editor.js +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/scripted_field_editor/scripted_field_editor.js @@ -1,6 +1,6 @@ import 'ui/field_editor'; import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field'; -import UrlProvider from 'ui/url'; +import { KbnUrlProvider } from 'ui/url'; import uiRoutes from 'ui/routes'; import template from './scripted_field_editor.html'; @@ -19,7 +19,7 @@ uiRoutes controller: function FieldEditorPageController($route, Private, Notifier, docTitle) { const Field = Private(IndexPatternsFieldProvider); const notify = new Notifier({ location: 'Field Editor' }); - const kbnUrl = Private(UrlProvider); + const kbnUrl = Private(KbnUrlProvider); this.mode = $route.current.mode; this.indexPattern = $route.current.locals.indexPattern; diff --git a/src/core_plugins/kibana/server/lib/handle_es_error.js b/src/core_plugins/kibana/server/lib/handle_es_error.js index 9154d3d441bb..d6670ba44442 100644 --- a/src/core_plugins/kibana/server/lib/handle_es_error.js +++ b/src/core_plugins/kibana/server/lib/handle_es_error.js @@ -2,7 +2,7 @@ import Boom from 'boom'; import _ from 'lodash'; import { errors as esErrors } from 'elasticsearch'; -module.exports = function handleESError(error) { +export default function handleESError(error) { if (!(error instanceof Error)) { throw new Error('Expected an instance of Error'); } @@ -23,4 +23,4 @@ module.exports = function handleESError(error) { } else { return error; } -}; +} diff --git a/src/core_plugins/metrics/server/lib/vis_data/helpers/calculate_auto.js b/src/core_plugins/metrics/server/lib/vis_data/helpers/calculate_auto.js index db754f9c164c..61970ed1b381 100644 --- a/src/core_plugins/metrics/server/lib/vis_data/helpers/calculate_auto.js +++ b/src/core_plugins/metrics/server/lib/vis_data/helpers/calculate_auto.js @@ -52,7 +52,7 @@ function find(rules, check, last) { }; } -module.exports = { +export default { near: find(revRoundingRules, function near(bound, interval, target) { if (bound > target) return interval; }, true), diff --git a/src/core_plugins/metrics/server/lib/vis_data/helpers/index.js b/src/core_plugins/metrics/server/lib/vis_data/helpers/index.js index 3e60224de501..93c0de13f184 100644 --- a/src/core_plugins/metrics/server/lib/vis_data/helpers/index.js +++ b/src/core_plugins/metrics/server/lib/vis_data/helpers/index.js @@ -11,7 +11,7 @@ import mapBucket from './map_bucket'; import parseSettings from './parse_settings'; import unitToSeconds from './unit_to_seconds'; -module.exports = { +export default { bucketTransform, getAggValue, getBucketSize, diff --git a/src/core_plugins/status_page/public/lib/format_number.js b/src/core_plugins/status_page/public/lib/format_number.js index d31a44889993..ff8d2afd2201 100644 --- a/src/core_plugins/status_page/public/lib/format_number.js +++ b/src/core_plugins/status_page/public/lib/format_number.js @@ -2,7 +2,7 @@ import moment from 'moment'; import numeral from 'numeral'; -module.exports = function formatNumber(num, which) { +export default function formatNumber(num, which) { let format = '0.00'; let postfix = ''; switch (which) { @@ -19,4 +19,4 @@ module.exports = function formatNumber(num, which) { break; } return numeral(num).format(format) + postfix; -}; +} diff --git a/src/core_plugins/status_page/public/lib/make_chart_options.js b/src/core_plugins/status_page/public/lib/make_chart_options.js index e5cf46f2602d..3d97ce39b1cb 100644 --- a/src/core_plugins/status_page/public/lib/make_chart_options.js +++ b/src/core_plugins/status_page/public/lib/make_chart_options.js @@ -1,7 +1,7 @@ import formatNumber from './format_number'; -module.exports = function makeChartOptions(type) { +export default function makeChartOptions(type) { return { chart: { type: 'lineChart', @@ -25,4 +25,4 @@ module.exports = function makeChartOptions(type) { x: function (d) { return d.x; } } }; -}; +} diff --git a/src/core_plugins/status_page/public/lib/read_stat_data.js b/src/core_plugins/status_page/public/lib/read_stat_data.js index 7c1fa8b0e9f8..d0e975d1e475 100644 --- a/src/core_plugins/status_page/public/lib/read_stat_data.js +++ b/src/core_plugins/status_page/public/lib/read_stat_data.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function readStatData(data, seriesNames) { +export default function readStatData(data, seriesNames) { // Metric Values format // metric: [[xValue, yValue], ...] // LoadMetric: @@ -36,4 +36,4 @@ module.exports = function readStatData(data, seriesNames) { }); return metricList; -}; +} diff --git a/src/core_plugins/tests_bundle/find_source_files.js b/src/core_plugins/tests_bundle/find_source_files.js index a22c76c4c3d3..1e82c29cea16 100644 --- a/src/core_plugins/tests_bundle/find_source_files.js +++ b/src/core_plugins/tests_bundle/find_source_files.js @@ -35,4 +35,4 @@ findSourceFiles.statCache = {}; findSourceFiles.realpathCache = {}; findSourceFiles.cache = {}; -module.exports = findSourceFiles; +export default findSourceFiles; diff --git a/src/core_plugins/tests_bundle/tests_entry_template.js b/src/core_plugins/tests_bundle/tests_entry_template.js index 628526a940a3..75d34be19c7d 100644 --- a/src/core_plugins/tests_bundle/tests_entry_template.js +++ b/src/core_plugins/tests_bundle/tests_entry_template.js @@ -1,4 +1,4 @@ -module.exports = function ({ env, bundle }) { +export default function ({ env, bundle }) { const pluginSlug = env.pluginInfo.sort() .map(p => ' * - ' + p) @@ -55,4 +55,4 @@ ${requires} require('ui/test_harness').bootstrap(/* go! */); `; -}; +} diff --git a/src/core_plugins/timelion/public/lib/calculate_interval.js b/src/core_plugins/timelion/common/lib/calculate_interval.js similarity index 90% rename from src/core_plugins/timelion/public/lib/calculate_interval.js rename to src/core_plugins/timelion/common/lib/calculate_interval.js index 997bffbac500..4515c89c4c97 100644 --- a/src/core_plugins/timelion/public/lib/calculate_interval.js +++ b/src/core_plugins/timelion/common/lib/calculate_interval.js @@ -1,11 +1,4 @@ -const toMS = require('../../server/lib/to_milliseconds.js'); - -module.exports = function calculateInterval(from, to, size, interval, min) { - if (interval !== 'auto') return interval; - const dateMathInterval = roundInterval((to - from) / size); - if (toMS(dateMathInterval) < toMS(min)) return min; - return dateMathInterval; -}; +import toMS from '../../server/lib/to_milliseconds.js'; // Totally cribbed this from Kibana 3. // I bet there's something similar in the Kibana 4 code. Somewhere. Somehow. @@ -45,3 +38,10 @@ function roundInterval(interval) { return '1y'; } } + +export function calculateInterval(from, to, size, interval, min) { + if (interval !== 'auto') return interval; + const dateMathInterval = roundInterval((to - from) / size); + if (toMS(dateMathInterval) < toMS(min)) return min; + return dateMathInterval; +} diff --git a/src/core_plugins/timelion/common/lib/index.js b/src/core_plugins/timelion/common/lib/index.js new file mode 100644 index 000000000000..db8081c0a8fb --- /dev/null +++ b/src/core_plugins/timelion/common/lib/index.js @@ -0,0 +1 @@ +export { calculateInterval } from './calculate_interval'; diff --git a/src/core_plugins/timelion/index.js b/src/core_plugins/timelion/index.js index 1da6f20a58a6..c510267c823c 100644 --- a/src/core_plugins/timelion/index.js +++ b/src/core_plugins/timelion/index.js @@ -1,5 +1,5 @@ -module.exports = function (kibana) { +export default function (kibana) { let mainFile = 'plugins/timelion/app'; const ownDescriptor = Object.getOwnPropertyDescriptor(kibana, 'autoload'); @@ -40,4 +40,4 @@ module.exports = function (kibana) { }, init: require('./init.js'), }); -}; +} diff --git a/src/core_plugins/timelion/init.js b/src/core_plugins/timelion/init.js index 03703c79570d..bf562caefae5 100644 --- a/src/core_plugins/timelion/init.js +++ b/src/core_plugins/timelion/init.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import processFunctionDefinition from './server/lib/process_function_definition'; -module.exports = function (server) { +export default function (server) { //var config = server.config(); require('./server/routes/run.js')(server); require('./server/routes/functions.js')(server); @@ -25,4 +25,4 @@ module.exports = function (server) { }; -}; +} diff --git a/src/core_plugins/timelion/public/directives/timelion_help/timelion_help.js b/src/core_plugins/timelion/public/directives/timelion_help/timelion_help.js index 3e01fd00f53d..c191ad3c9add 100644 --- a/src/core_plugins/timelion/public/directives/timelion_help/timelion_help.js +++ b/src/core_plugins/timelion/public/directives/timelion_help/timelion_help.js @@ -1,68 +1,67 @@ -define(function (require) { - const template = require('./timelion_help.html'); - const app = require('ui/modules').get('apps/timelion', []); - const _ = require('lodash'); - const moment = require('moment'); +import template from './timelion_help.html'; +import { uiModules } from 'ui/modules'; +import _ from 'lodash'; +import moment from 'moment'; - app.directive('timelionHelp', function ($http) { - return { - restrict: 'E', - template, - controller: function ($scope) { - $scope.functions = { - list: [], - details: null - }; +const app = uiModules.get('apps/timelion', []); - function init() { - $scope.es = { - invalidCount: 0 - }; - getFunctions(); - checkElasticsearch(); - } +app.directive('timelionHelp', function ($http) { + return { + restrict: 'E', + template, + controller: function ($scope) { + $scope.functions = { + list: [], + details: null + }; - function getFunctions() { - return $http.get('../api/timelion/functions').then(function (resp) { - $scope.functions.list = resp.data; - }); - } - $scope.recheckElasticsearch = function () { - $scope.es.valid = null; - checkElasticsearch().then(function (valid) { - if (!valid) $scope.es.invalidCount++; - }); + function init() { + $scope.es = { + invalidCount: 0 }; + getFunctions(); + checkElasticsearch(); + } - function checkElasticsearch() { - return $http.get('../api/timelion/validate/es').then(function (resp) { - if (resp.data.ok) { - - $scope.es.valid = true; - $scope.es.stats = { - min: moment(resp.data.min).format('LLL'), - max: moment(resp.data.max).format('LLL'), - field: resp.data.field - }; - } else { - $scope.es.valid = false; - $scope.es.invalidReason = (function () { - try { - const esResp = JSON.parse(resp.data.resp.response); - return _.get(esResp, 'error.root_cause[0].reason'); - } catch (e) { - if (_.get(resp, 'data.resp.message')) return _.get(resp, 'data.resp.message'); - if (_.get(resp, 'data.resp.output.payload.message')) return _.get(resp, 'data.resp.output.payload.message'); - return 'Unknown error'; - } - }()); - } - return $scope.es.valid; - }); - } - init(); + function getFunctions() { + return $http.get('../api/timelion/functions').then(function (resp) { + $scope.functions.list = resp.data; + }); } - }; - }); + $scope.recheckElasticsearch = function () { + $scope.es.valid = null; + checkElasticsearch().then(function (valid) { + if (!valid) $scope.es.invalidCount++; + }); + }; + function checkElasticsearch() { + return $http.get('../api/timelion/validate/es').then(function (resp) { + if (resp.data.ok) { + + $scope.es.valid = true; + $scope.es.stats = { + min: moment(resp.data.min).format('LLL'), + max: moment(resp.data.max).format('LLL'), + field: resp.data.field + }; + } else { + $scope.es.valid = false; + $scope.es.invalidReason = (function () { + try { + const esResp = JSON.parse(resp.data.resp.response); + return _.get(esResp, 'error.root_cause[0].reason'); + } catch (e) { + if (_.get(resp, 'data.resp.message')) return _.get(resp, 'data.resp.message'); + if (_.get(resp, 'data.resp.output.payload.message')) return _.get(resp, 'data.resp.output.payload.message'); + return 'Unknown error'; + } + }()); + } + return $scope.es.valid; + }); + } + init(); + } + }; }); diff --git a/src/core_plugins/timelion/public/lib/observe_resize.js b/src/core_plugins/timelion/public/lib/observe_resize.js index 9647631bc8ac..0efd2087fef7 100644 --- a/src/core_plugins/timelion/public/lib/observe_resize.js +++ b/src/core_plugins/timelion/public/lib/observe_resize.js @@ -1,4 +1,4 @@ -module.exports = function ($elem, fn, frequency) { +export default function ($elem, fn, frequency) { frequency = frequency || 500; let currentHeight = $elem.height(); @@ -25,4 +25,4 @@ module.exports = function ($elem, fn, frequency) { }; -}; +} diff --git a/src/core_plugins/timelion/public/panels/panel.js b/src/core_plugins/timelion/public/panels/panel.js index 9319cce71ff3..c0bb257a1be5 100644 --- a/src/core_plugins/timelion/public/panels/panel.js +++ b/src/core_plugins/timelion/public/panels/panel.js @@ -1,4 +1,4 @@ -module.exports = function Panel(name, config) { +export default function Panel(name, config) { this.name = name; @@ -9,4 +9,4 @@ module.exports = function Panel(name, config) { if (!config.render) throw new Error ('Panel must have a rendering function'); -}; +} diff --git a/src/core_plugins/timelion/public/panels/timechart/schema.js b/src/core_plugins/timelion/public/panels/timechart/schema.js index d1dc0f6df051..59b2a00ecfff 100644 --- a/src/core_plugins/timelion/public/panels/timechart/schema.js +++ b/src/core_plugins/timelion/public/panels/timechart/schema.js @@ -4,11 +4,11 @@ import _ from 'lodash'; import $ from 'jquery'; import moment from 'moment-timezone'; import observeResize from 'plugins/timelion/lib/observe_resize'; -import calculateInterval from 'plugins/timelion/lib/calculate_interval'; +import { calculateInterval } from '../../../common/lib'; const SET_LEGEND_NUMBERS_DELAY = 50; -module.exports = function timechartFn(Private, config, $rootScope, timefilter, $compile) { +export default function timechartFn(Private, config, $rootScope, timefilter, $compile) { return function () { return { help: 'Draw a timeseries chart', @@ -260,4 +260,4 @@ module.exports = function timechartFn(Private, config, $rootScope, timefilter, $ } }; }; -}; +} diff --git a/src/core_plugins/timelion/public/panels/timechart/tick_generator.js b/src/core_plugins/timelion/public/panels/timechart/tick_generator.js index 2a027d502c63..8f59050d8977 100644 --- a/src/core_plugins/timelion/public/panels/timechart/tick_generator.js +++ b/src/core_plugins/timelion/public/panels/timechart/tick_generator.js @@ -1,4 +1,4 @@ -module.exports = function generateTicksProvider() { +export default function generateTicksProvider() { function floorInBase(n, base) { return base * Math.floor(n / base); @@ -40,4 +40,4 @@ module.exports = function generateTicksProvider() { return function (axis) { return generateTicks(axis); }; -}; +} diff --git a/src/core_plugins/timelion/public/panels/timechart/xaxis_formatter.js b/src/core_plugins/timelion/public/panels/timechart/xaxis_formatter.js index cbb41b21d87a..a3b503b4248d 100644 --- a/src/core_plugins/timelion/public/panels/timechart/xaxis_formatter.js +++ b/src/core_plugins/timelion/public/panels/timechart/xaxis_formatter.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = function xaxisFormatterProvider(config) { +export default function xaxisFormatterProvider(config) { function getFormat(esInterval) { const parts = esInterval.match(/(\d+)(ms|s|m|h|d|w|M|y|)/); @@ -24,4 +24,4 @@ module.exports = function xaxisFormatterProvider(config) { return function (esInterval) { return getFormat(esInterval); }; -}; +} diff --git a/src/core_plugins/timelion/public/services/dashboard_context.js b/src/core_plugins/timelion/public/services/dashboard_context.js index 2dcf2d8e5b74..a6577a68f428 100644 --- a/src/core_plugins/timelion/public/services/dashboard_context.js +++ b/src/core_plugins/timelion/public/services/dashboard_context.js @@ -1,35 +1,32 @@ import _ from 'lodash'; import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter'; -require('ui/state_management/app_state'); +import 'ui/state_management/app_state'; +export default function dashboardContext(Private, getAppState) { + const queryFilter = Private(FilterBarQueryFilterProvider); + const bool = { must: [], must_not: [] }; + const filterBarFilters = queryFilter.getFilters(); + const queryBarFilter = getAppState().query; -module.exports = function dashboardContext(Private, getAppState) { - return function () { - const queryFilter = Private(FilterBarQueryFilterProvider); - const bool = { must: [], must_not: [] }; - const filterBarFilters = queryFilter.getFilters(); - const queryBarFilter = getAppState().query; + // Add the query bar filter, its handled differently. + bool.must.push(queryBarFilter); - // Add the query bar filter, its handled differently. - bool.must.push(queryBarFilter); - - // Add each of the filter bar filters - _.each(filterBarFilters, function (filter) { - const esFilter = _.omit(filter, function (val, key) { - if (key === 'meta' || key[0] === '$') return true; - return false; - }); - - if (filter.meta.disabled) return; - if (filter.meta.negate) { - bool.must_not = bool.must_not || []; - bool.must_not.push(esFilter.query || esFilter); - } else { - bool.must = bool.must || []; - bool.must.push(esFilter.query || esFilter); - } + // Add each of the filter bar filters + _.each(filterBarFilters, function (filter) { + const esFilter = _.omit(filter, function (val, key) { + if (key === 'meta' || key[0] === '$') return true; + return false; }); - return { bool: bool }; - }; -}; + if (filter.meta.disabled) return; + if (filter.meta.negate) { + bool.must_not = bool.must_not || []; + bool.must_not.push(esFilter.query || esFilter); + } else { + bool.must = bool.must || []; + bool.must.push(esFilter.query || esFilter); + } + }); + + return { bool: bool }; +} diff --git a/src/core_plugins/timelion/public/services/saved_sheet_register.js b/src/core_plugins/timelion/public/services/saved_sheet_register.js index 3be18df388c1..5a08b4c19c16 100644 --- a/src/core_plugins/timelion/public/services/saved_sheet_register.js +++ b/src/core_plugins/timelion/public/services/saved_sheet_register.js @@ -1,5 +1,3 @@ -define(function () { - return function savedSearchObjectFn(savedSheets) { - return savedSheets; - }; -}); +export default function savedSearchObjectFn(savedSheets) { + return savedSheets; +} diff --git a/src/core_plugins/timelion/public/services/saved_sheets.js b/src/core_plugins/timelion/public/services/saved_sheets.js index 9e9441e233ad..c5c1acd1c93c 100644 --- a/src/core_plugins/timelion/public/services/saved_sheets.js +++ b/src/core_plugins/timelion/public/services/saved_sheets.js @@ -1,32 +1,29 @@ import { SavedObjectLoader } from 'ui/courier/saved_object/saved_object_loader'; import { savedObjectManagementRegistry } from 'plugins/kibana/management/saved_object_registry'; +import { uiModules } from 'ui/modules'; +import './_saved_sheet.js'; -define(function (require) { - const module = require('ui/modules').get('app/sheet'); - // bring in the factory - require('./_saved_sheet.js'); +const module = uiModules.get('app/sheet'); +// Register this service with the saved object registry so it can be +// edited by the object editor. +savedObjectManagementRegistry.register({ + service: 'savedSheets', + title: 'sheets' +}); - // Register this service with the saved object registry so it can be - // edited by the object editor. - savedObjectManagementRegistry.register({ - service: 'savedSheets', - title: 'sheets' - }); - - // This is the only thing that gets injected into controllers - module.service('savedSheets', function (Promise, SavedSheet, kbnIndex, esAdmin, kbnUrl) { - const savedSheetLoader = new SavedObjectLoader(SavedSheet, kbnIndex, esAdmin, kbnUrl); - savedSheetLoader.urlFor = function (id) { - return kbnUrl.eval('#/{{id}}', { id: id }); - }; +// This is the only thing that gets injected into controllers +module.service('savedSheets', function (Promise, SavedSheet, kbnIndex, esAdmin, kbnUrl) { + const savedSheetLoader = new SavedObjectLoader(SavedSheet, kbnIndex, esAdmin, kbnUrl); + savedSheetLoader.urlFor = function (id) { + return kbnUrl.eval('#/{{id}}', { id: id }); + }; - // Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'. - savedSheetLoader.loaderProperties = { - name: 'timelion-sheet', - noun: 'Saved Sheets', - nouns: 'saved sheets' - }; - return savedSheetLoader; - }); + // Customize loader properties since adding an 's' on type doesn't work for type 'timelion-sheet'. + savedSheetLoader.loaderProperties = { + name: 'timelion-sheet', + noun: 'Saved Sheets', + nouns: 'saved sheets' + }; + return savedSheetLoader; }); diff --git a/src/core_plugins/timelion/public/services/tick_formatters.js b/src/core_plugins/timelion/public/services/tick_formatters.js index 286c0b37a840..c03f171d83fe 100644 --- a/src/core_plugins/timelion/public/services/tick_formatters.js +++ b/src/core_plugins/timelion/public/services/tick_formatters.js @@ -1,75 +1,72 @@ -define(function () { +function baseTickFormatter(value, axis) { + const factor = axis.tickDecimals ? Math.pow(10, axis.tickDecimals) : 1; + const formatted = '' + Math.round(value * factor) / factor; - function baseTickFormatter(value, axis) { - const factor = axis.tickDecimals ? Math.pow(10, axis.tickDecimals) : 1; - const formatted = '' + Math.round(value * factor) / factor; + // If tickDecimals was specified, ensure that we have exactly that + // much precision; otherwise default to the value's own precision. - // If tickDecimals was specified, ensure that we have exactly that - // much precision; otherwise default to the value's own precision. - - if (axis.tickDecimals != null) { - const decimal = formatted.indexOf('.'); - const precision = decimal === -1 ? 0 : formatted.length - decimal - 1; - if (precision < axis.tickDecimals) { - return (precision ? formatted : formatted + '.') + ('' + factor).substr(1, axis.tickDecimals - precision); - } + if (axis.tickDecimals != null) { + const decimal = formatted.indexOf('.'); + const precision = decimal === -1 ? 0 : formatted.length - decimal - 1; + if (precision < axis.tickDecimals) { + return (precision ? formatted : formatted + '.') + ('' + factor).substr(1, axis.tickDecimals - precision); } - - return formatted; } - return function ticketFormatters() { - const formatters = { - 'bits': function (val) { - const labels = ['b','kb','mb','gb','tb','pb']; - let index = 0; - while (val >= 1000 && index < labels.length) { - val /= 1000; - index++; - } - return (Math.round(val * 100) / 100) + labels[index]; - }, - 'bits/s': function (val) { - const labels = ['b/s','kb/s','mb/s','gb/s','tb/s','pb/s']; - let index = 0; - while (val >= 1000 && index < labels.length) { - val /= 1000; - index++; - } - return (Math.round(val * 100) / 100) + labels[index]; - }, - 'bytes': function (val) { - const labels = ['B','KB','MB','GB','TB','PB']; - let index = 0; - while (val >= 1024 && index < labels.length) { - val /= 1024; - index++; - } - return (Math.round(val * 100) / 100) + labels[index]; - }, - 'bytes/s': function (val) { - const labels = ['B/s','KB/s','MB/s','GB/s','TB/s','PB/s']; - let index = 0; - while (val >= 1024 && index < labels.length) { - val /= 1024; - index++; - } - return (Math.round(val * 100) / 100) + labels[index]; - }, - 'currency': function (val, axis) { - return val.toLocaleString('en', { style: 'currency', currency: axis.options.units.prefix || 'USD' }); - }, - 'percent': function (val) { - return val * 100 + '%'; - }, - 'custom': function (val, axis) { - const formattedVal = baseTickFormatter(val, axis); - const prefix = axis.options.units.prefix; - const suffix = axis.options.units.suffix; - return prefix + formattedVal + suffix; - } - }; + return formatted; +} - return formatters; +export default function tickFormatters() { + const formatters = { + 'bits': function (val) { + const labels = ['b','kb','mb','gb','tb','pb']; + let index = 0; + while (val >= 1000 && index < labels.length) { + val /= 1000; + index++; + } + return (Math.round(val * 100) / 100) + labels[index]; + }, + 'bits/s': function (val) { + const labels = ['b/s','kb/s','mb/s','gb/s','tb/s','pb/s']; + let index = 0; + while (val >= 1000 && index < labels.length) { + val /= 1000; + index++; + } + return (Math.round(val * 100) / 100) + labels[index]; + }, + 'bytes': function (val) { + const labels = ['B','KB','MB','GB','TB','PB']; + let index = 0; + while (val >= 1024 && index < labels.length) { + val /= 1024; + index++; + } + return (Math.round(val * 100) / 100) + labels[index]; + }, + 'bytes/s': function (val) { + const labels = ['B/s','KB/s','MB/s','GB/s','TB/s','PB/s']; + let index = 0; + while (val >= 1024 && index < labels.length) { + val /= 1024; + index++; + } + return (Math.round(val * 100) / 100) + labels[index]; + }, + 'currency': function (val, axis) { + return val.toLocaleString('en', { style: 'currency', currency: axis.options.units.prefix || 'USD' }); + }, + 'percent': function (val) { + return val * 100 + '%'; + }, + 'custom': function (val, axis) { + const formattedVal = baseTickFormatter(val, axis); + const prefix = axis.options.units.prefix; + const suffix = axis.options.units.suffix; + return prefix + formattedVal + suffix; + } }; -}); + + return formatters; +} diff --git a/src/core_plugins/timelion/public/services/timezone.js b/src/core_plugins/timelion/public/services/timezone.js index b1936f6c660e..a99a55afc5ab 100644 --- a/src/core_plugins/timelion/public/services/timezone.js +++ b/src/core_plugins/timelion/public/services/timezone.js @@ -1,7 +1,7 @@ const tzDetect = require('jstimezonedetect').jstz; import moment from 'moment'; -module.exports = function timezoneFn(config) { +export default function timezoneFn(config) { return function () { if (config.isDefault('dateFormat:tz')) { @@ -13,4 +13,4 @@ module.exports = function timezoneFn(config) { } }; -}; +} diff --git a/src/core_plugins/timelion/public/vis/index.js b/src/core_plugins/timelion/public/vis/index.js index 9d098aeaea23..a1da755059a8 100644 --- a/src/core_plugins/timelion/public/vis/index.js +++ b/src/core_plugins/timelion/public/vis/index.js @@ -2,40 +2,34 @@ import { VisVisTypeProvider } from 'ui/vis/vis_type'; import image from '../images/icon-timelion.svg'; import { VisTypesRegistryProvider } from 'ui/registry/vis_types'; import { TemplateVisTypeProvider } from 'ui/template_vis_type'; +import template from 'plugins/timelion/vis/timelion_vis.html'; +import editorTemplate from 'plugins/timelion/vis/timelion_vis_params.html'; +import 'plugins/timelion/vis/timelion_vis_controller'; +import 'plugins/timelion/vis/timelion_vis_params_controller'; +import 'plugins/timelion/vis/timelion_vis.less'; -define(function (require) { - // we also need to load the controller and used by the template - require('plugins/timelion/vis/timelion_vis_controller'); - require('plugins/timelion/vis/timelion_vis_params_controller'); +// export the provider so that the visType can be required with Private() +export default function TimelionVisProvider(Private) { + const VisType = Private(VisVisTypeProvider); + const TemplateVisType = Private(TemplateVisTypeProvider); - // Stylin - require('plugins/timelion/vis/timelion_vis.less'); + // return the visType object, which kibana will use to display and configure new + // Vis object of this type. + return new TemplateVisType({ + name: 'timelion', + title: 'Timelion', + image, + description: 'Build time-series using functional expressions', + category: VisType.CATEGORY.TIME, + template, + params: { + editor: editorTemplate, + }, + requiresSearch: false, + requiresTimePicker: true, + implementsRenderComplete: true, + }); +} - // register the provider with the visTypes registry so that other know it exists - VisTypesRegistryProvider.register(TimelionVisProvider); - - function TimelionVisProvider(Private) { - const VisType = Private(VisVisTypeProvider); - const TemplateVisType = Private(TemplateVisTypeProvider); - - // return the visType object, which kibana will use to display and configure new - // Vis object of this type. - return new TemplateVisType({ - name: 'timelion', - title: 'Timelion', - image, - description: 'Build time-series using functional expressions', - category: VisType.CATEGORY.TIME, - template: require('plugins/timelion/vis/timelion_vis.html'), - params: { - editor: require('plugins/timelion/vis/timelion_vis_params.html') - }, - requiresSearch: false, - requiresTimePicker: true, - implementsRenderComplete: true, - }); - } - - // export the provider so that the visType can be required with Private() - return TimelionVisProvider; -}); +// register the provider with the visTypes registry so that other know it exists +VisTypesRegistryProvider.register(TimelionVisProvider); diff --git a/src/core_plugins/timelion/public/vis/timelion_vis_controller.js b/src/core_plugins/timelion/public/vis/timelion_vis_controller.js index 76256b67967d..e3b09ed6a8fd 100644 --- a/src/core_plugins/timelion/public/vis/timelion_vis_controller.js +++ b/src/core_plugins/timelion/public/vis/timelion_vis_controller.js @@ -1,69 +1,69 @@ +import _ from 'lodash'; import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter'; +import { uiModules } from 'ui/modules'; +import timezoneProvider from 'plugins/timelion/services/timezone'; +import dashboardContextProvider from 'plugins/timelion/services/dashboard_context'; +import 'plugins/timelion/directives/chart/chart'; +import 'plugins/timelion/directives/timelion_interval/timelion_interval'; +import 'ui/state_management/app_state'; -define(function (require) { - require('plugins/timelion/directives/chart/chart'); - require('plugins/timelion/directives/timelion_interval/timelion_interval'); - require('ui/state_management/app_state'); +const module = uiModules.get('kibana/timelion_vis', ['kibana']); - const _ = require('lodash'); - const module = require('ui/modules').get('kibana/timelion_vis', ['kibana']); - module.controller('TimelionVisController', function ($scope, $element, Private, Notifier, $http, $rootScope, timefilter) { - const queryFilter = Private(FilterBarQueryFilterProvider); - const timezone = Private(require('plugins/timelion/services/timezone'))(); - const dashboardContext = Private(require('plugins/timelion/services/dashboard_context')); +module.controller('TimelionVisController', function ($scope, $element, Private, Notifier, $http, $rootScope, timefilter) { + const queryFilter = Private(FilterBarQueryFilterProvider); + const timezone = Private(timezoneProvider)(); + const dashboardContext = Private(dashboardContextProvider); - const notify = new Notifier({ - location: 'Timelion' - }); - - $scope.search = function run() { - const expression = $scope.vis.params.expression; - if (!expression) return; + const notify = new Notifier({ + location: 'Timelion' + }); - $http.post('../api/timelion/run', { - sheet: [expression], - extended: { - es: { - filter: dashboardContext() - } - }, - time: _.extend(timefilter.time, { - interval: $scope.vis.params.interval, - timezone: timezone - }), - }) - // data, status, headers, config - .success(function (resp) { - $scope.sheet = resp.sheet; - }) - .error(function (resp) { - $scope.sheet = []; - const err = new Error(resp.message); - err.stack = resp.stack; - notify.error(err); - }); - }; + $scope.search = function run() { + const expression = $scope.vis.params.expression; + if (!expression) return; - // This is bad, there should be a single event that triggers a refresh of data. + $http.post('../api/timelion/run', { + sheet: [expression], + extended: { + es: { + filter: dashboardContext() + } + }, + time: _.extend(timefilter.time, { + interval: $scope.vis.params.interval, + timezone: timezone + }), + }) + // data, status, headers, config + .success(function (resp) { + $scope.sheet = resp.sheet; + }) + .error(function (resp) { + $scope.sheet = []; + const err = new Error(resp.message); + err.stack = resp.stack; + notify.error(err); + }); + }; - // When the expression updates - $scope.$watchMulti(['vis.params.expression', 'vis.params.interval'], $scope.search); + // This is bad, there should be a single event that triggers a refresh of data. - // When the time filter changes - $scope.$listen(timefilter, 'fetch', $scope.search); + // When the expression updates + $scope.$watchMulti(['vis.params.expression', 'vis.params.interval'], $scope.search); - // When a filter is added to the filter bar? - $scope.$listen(queryFilter, 'fetch', $scope.search); + // When the time filter changes + $scope.$listen(timefilter, 'fetch', $scope.search); - // When auto refresh happens - $scope.$on('courier:searchRefresh', $scope.search); + // When a filter is added to the filter bar? + $scope.$listen(queryFilter, 'fetch', $scope.search); - $scope.$on('fetch', $scope.search); + // When auto refresh happens + $scope.$on('courier:searchRefresh', $scope.search); - $scope.$on('renderComplete', event => { - event.stopPropagation(); - $element.trigger('renderComplete'); - }); + $scope.$on('fetch', $scope.search); + $scope.$on('renderComplete', event => { + event.stopPropagation(); + $element.trigger('renderComplete'); }); }); diff --git a/src/core_plugins/timelion/public/vis/timelion_vis_params_controller.js b/src/core_plugins/timelion/public/vis/timelion_vis_params_controller.js index 1e26484da639..35584da4c6f2 100644 --- a/src/core_plugins/timelion/public/vis/timelion_vis_params_controller.js +++ b/src/core_plugins/timelion/public/vis/timelion_vis_params_controller.js @@ -1,14 +1,12 @@ -define(function (require) { - require('plugins/timelion/directives/timelion_expression_input'); +import { uiModules } from 'ui/modules'; +import 'plugins/timelion/directives/timelion_expression_input'; - const module = require('ui/modules').get('kibana/timelion_vis', ['kibana']); - module.controller('TimelionVisParamsController', function ($scope, $rootScope) { - $scope.vis.params.expression = $scope.vis.params.expression || '.es(*)'; - $scope.vis.params.interval = $scope.vis.params.interval || '1m'; +const module = uiModules.get('kibana/timelion_vis', ['kibana']); +module.controller('TimelionVisParamsController', function ($scope, $rootScope) { + $scope.vis.params.expression = $scope.vis.params.expression || '.es(*)'; + $scope.vis.params.interval = $scope.vis.params.interval || '1m'; - - $scope.search = function () { - $rootScope.$broadcast('courier:searchRefresh'); - }; - }); + $scope.search = function () { + $rootScope.$broadcast('courier:searchRefresh'); + }; }); diff --git a/src/core_plugins/timelion/server/fit_functions/average.js b/src/core_plugins/timelion/server/fit_functions/average.js index a5fe551779bb..41209eb80db1 100644 --- a/src/core_plugins/timelion/server/fit_functions/average.js +++ b/src/core_plugins/timelion/server/fit_functions/average.js @@ -4,7 +4,7 @@ import _ from 'lodash'; // Good: min, max, average // Bad: sum, count -module.exports = function (dataTuples, targetTuples) { +export default function average(dataTuples, targetTuples) { // Phase 1: Downsample // We nessecarily won't well match the dataSource here as we don't know how much data @@ -72,4 +72,4 @@ module.exports = function (dataTuples, targetTuples) { const resultTuples = _.zip(resultTimes, resultValues); return resultTuples; -}; +} diff --git a/src/core_plugins/timelion/server/fit_functions/carry.js b/src/core_plugins/timelion/server/fit_functions/carry.js index e5bd11fcbac1..6d0f8da8fa86 100644 --- a/src/core_plugins/timelion/server/fit_functions/carry.js +++ b/src/core_plugins/timelion/server/fit_functions/carry.js @@ -5,7 +5,7 @@ import _ from 'lodash'; // Bad: sum, count // Don't use this to down sample, it simply won't do the right thing. -module.exports = function (dataTuples, targetTuples) { +export default function carry(dataTuples, targetTuples) { if (dataTuples.length > targetTuples.length) { throw new Error (`Don't use the 'carry' fit method to down sample, use 'scale' or 'average'`); @@ -23,4 +23,4 @@ module.exports = function (dataTuples, targetTuples) { return [bucket[0], currentCarry]; }); -}; +} diff --git a/src/core_plugins/timelion/server/fit_functions/nearest.js b/src/core_plugins/timelion/server/fit_functions/nearest.js index 14849932fa57..1500e6cca48e 100644 --- a/src/core_plugins/timelion/server/fit_functions/nearest.js +++ b/src/core_plugins/timelion/server/fit_functions/nearest.js @@ -3,7 +3,7 @@ import _ from 'lodash'; // Upsampling and downsampling of non-cummulative sets // Good: average, min, max // Bad: sum, count -module.exports = function (dataTuples, targetTuples) { +export default function nearest(dataTuples, targetTuples) { return _.map(targetTuples, function (bucket) { const time = bucket[0]; let i = 0; @@ -24,4 +24,4 @@ module.exports = function (dataTuples, targetTuples) { return [bucket[0], closest[1]]; }); -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/core_plugins/timelion/server/fit_functions/none.js b/src/core_plugins/timelion/server/fit_functions/none.js index a1aa2d454740..b280c6623708 100644 --- a/src/core_plugins/timelion/server/fit_functions/none.js +++ b/src/core_plugins/timelion/server/fit_functions/none.js @@ -2,6 +2,6 @@ // **DON'T USE THIS** // Performing joins/math with other sets that don't match perfectly will be wrong // Does not resample at all. -module.exports = function (dataTuples) { +export default function none(dataTuples) { return dataTuples; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/core_plugins/timelion/server/fit_functions/scale.js b/src/core_plugins/timelion/server/fit_functions/scale.js index 5764d4cea4dc..69a0e39088db 100644 --- a/src/core_plugins/timelion/server/fit_functions/scale.js +++ b/src/core_plugins/timelion/server/fit_functions/scale.js @@ -13,7 +13,7 @@ function sum(set) { return _.reduce(set, function (sum, num) { return sum + num; }, 0); } -module.exports = function (dataTuples, targetTuples) { +export default function scale(dataTuples, targetTuples) { let i = 0; let j = 0; @@ -70,4 +70,4 @@ module.exports = function (dataTuples, targetTuples) { } return result; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/chain_runner.js b/src/core_plugins/timelion/server/handlers/chain_runner.js index 98b7040a887d..8a1d9965276a 100644 --- a/src/core_plugins/timelion/server/handlers/chain_runner.js +++ b/src/core_plugins/timelion/server/handlers/chain_runner.js @@ -3,12 +3,12 @@ import _ from 'lodash'; import Promise from 'bluebird'; import parseSheet from './lib/parse_sheet.js'; import parseDateMath from '../lib/date_math.js'; -import calculateInterval from '../../public/lib/calculate_interval.js'; import repositionArguments from './lib/reposition_arguments.js'; import indexArguments from './lib/index_arguments.js'; import validateTime from './lib/validate_time.js'; +import { calculateInterval } from '../../common/lib'; -module.exports = function (tlConfig) { +export default function chainRunner(tlConfig) { const preprocessChain = require('./lib/preprocess_chain')(tlConfig); let queryCache = {}; @@ -197,4 +197,4 @@ module.exports = function (tlConfig) { processRequest: processRequest, getStats: function () { return stats; } }; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/arg_type.js b/src/core_plugins/timelion/server/handlers/lib/arg_type.js index 1cabf054733b..227f4ef07a1f 100644 --- a/src/core_plugins/timelion/server/handlers/lib/arg_type.js +++ b/src/core_plugins/timelion/server/handlers/lib/arg_type.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function argType(arg) { +export default function argType(arg) { if (_.isArray(arg)) { return _.chain(arg) .map(argType) @@ -15,4 +15,4 @@ module.exports = function argType(arg) { return 'null'; } return typeof arg; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/index_arguments.js b/src/core_plugins/timelion/server/handlers/lib/index_arguments.js index 1b5234b81988..f89ad56b8cae 100644 --- a/src/core_plugins/timelion/server/handlers/lib/index_arguments.js +++ b/src/core_plugins/timelion/server/handlers/lib/index_arguments.js @@ -1,7 +1,7 @@ import _ from 'lodash'; // Only applies to already resolved arguments -module.exports = function indexArguments(functionDef, orderedArgs) { +export default function indexArguments(functionDef, orderedArgs) { const validateArg = require('./validate_arg')(functionDef); @@ -28,4 +28,4 @@ module.exports = function indexArguments(functionDef, orderedArgs) { } return indexedArgs; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/parse_sheet.js b/src/core_plugins/timelion/server/handlers/lib/parse_sheet.js index deb61b832561..4b408268ca25 100644 --- a/src/core_plugins/timelion/server/handlers/lib/parse_sheet.js +++ b/src/core_plugins/timelion/server/handlers/lib/parse_sheet.js @@ -5,7 +5,7 @@ const grammar = fs.readFileSync(path.resolve(__dirname, '../../../public/chain.p import PEG from 'pegjs'; const Parser = PEG.buildParser(grammar); -module.exports = function parseSheet(sheet) { +export default function parseSheet(sheet) { return _.map(sheet, function (plot) { try { return Parser.parse(plot).tree; @@ -17,4 +17,4 @@ module.exports = function parseSheet(sheet) { } } }); -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/preprocess_chain.js b/src/core_plugins/timelion/server/handlers/lib/preprocess_chain.js index 6915a272122a..092484f3ef01 100644 --- a/src/core_plugins/timelion/server/handlers/lib/preprocess_chain.js +++ b/src/core_plugins/timelion/server/handlers/lib/preprocess_chain.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function preProcessChainFn(tlConfig) { +export default function preProcessChainFn(tlConfig) { return function preProcessChain(chain, queries) { queries = queries || {}; function validateAndStore(item) { @@ -45,4 +45,4 @@ module.exports = function preProcessChainFn(tlConfig) { return queries; }; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/reposition_arguments.js b/src/core_plugins/timelion/server/handlers/lib/reposition_arguments.js index 8145e7b0f25b..96321862536a 100644 --- a/src/core_plugins/timelion/server/handlers/lib/reposition_arguments.js +++ b/src/core_plugins/timelion/server/handlers/lib/reposition_arguments.js @@ -1,7 +1,7 @@ import _ from 'lodash'; // Applies to unresolved arguments in the AST -module.exports = function repositionArguments(functionDef, unorderedArgs) { +export default function repositionArguments(functionDef, unorderedArgs) { const args = []; _.each(unorderedArgs, function (unorderedArg, i) { @@ -51,4 +51,4 @@ module.exports = function repositionArguments(functionDef, unorderedArgs) { return args; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/tl_config.js b/src/core_plugins/timelion/server/handlers/lib/tl_config.js index 1458000f5331..63a9552aa1b4 100644 --- a/src/core_plugins/timelion/server/handlers/lib/tl_config.js +++ b/src/core_plugins/timelion/server/handlers/lib/tl_config.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import buildTarget from '../../lib/build_target.js'; -module.exports = function (setup) { +export default function tlConfigFn(setup) { let targetSeries; let tlConfig = { @@ -20,4 +20,4 @@ module.exports = function (setup) { tlConfig = _.extend(tlConfig, setup); return tlConfig; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/validate_arg.js b/src/core_plugins/timelion/server/handlers/lib/validate_arg.js index 73ddabec53d5..d83f9b8561b1 100644 --- a/src/core_plugins/timelion/server/handlers/lib/validate_arg.js +++ b/src/core_plugins/timelion/server/handlers/lib/validate_arg.js @@ -1,7 +1,7 @@ import argType from './arg_type'; import _ from 'lodash'; -module.exports = function (functionDef) { +export default function validateArgFn(functionDef) { return function validateArg(value, name, argDef) { const type = argType(value); const required = argDef.types; @@ -20,4 +20,4 @@ module.exports = function (functionDef) { throw new Error (functionDef.name + '(' + name + ') must be one of ' + JSON.stringify(required) + '. Got: ' + type); } }; -}; +} diff --git a/src/core_plugins/timelion/server/handlers/lib/validate_time.js b/src/core_plugins/timelion/server/handlers/lib/validate_time.js index 6f2bd929b6a9..3b120127cd78 100644 --- a/src/core_plugins/timelion/server/handlers/lib/validate_time.js +++ b/src/core_plugins/timelion/server/handlers/lib/validate_time.js @@ -1,7 +1,7 @@ import parseDateMath from '../../lib/date_math.js'; import toMS from '../../lib/to_milliseconds.js'; -module.exports = function validateTime(time, tlConfig) { +export default function validateTime(time, tlConfig) { const span = parseDateMath(time.to, true) - parseDateMath(time.from); const interval = toMS(time.interval); const bucketCount = span / interval; @@ -12,4 +12,4 @@ module.exports = function validateTime(time, tlConfig) { 'Choose a larger interval or a shorter time span'); } return true; -}; +} diff --git a/src/core_plugins/timelion/server/lib/alter.js b/src/core_plugins/timelion/server/lib/alter.js index a0ed14ef0cd4..3e8f05436b48 100644 --- a/src/core_plugins/timelion/server/lib/alter.js +++ b/src/core_plugins/timelion/server/lib/alter.js @@ -8,7 +8,7 @@ import _ from 'lodash'; * @return {seriesList} */ -module.exports = function alter(args, fn) { +export default function alter(args, fn) { // In theory none of the args should ever be promises. This is probably a waste. return Promise.all(args).then(function (args) { @@ -27,4 +27,4 @@ module.exports = function alter(args, fn) { }).catch(function (e) { throw e; }); -}; +} diff --git a/src/core_plugins/timelion/server/lib/asSorted.js b/src/core_plugins/timelion/server/lib/asSorted.js index 7f19a93c43e4..0dafb66eb03a 100644 --- a/src/core_plugins/timelion/server/lib/asSorted.js +++ b/src/core_plugins/timelion/server/lib/asSorted.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import unzipPairs from './unzipPairs.js'; -module.exports = function asSorted(timeValObject, fn) { +export default function asSorted(timeValObject, fn) { const data = unzipPairs(timeValObject); return _.zipObject(fn(data)); -}; +} diff --git a/src/core_plugins/timelion/server/lib/build_target.js b/src/core_plugins/timelion/server/lib/build_target.js index a21213f4a468..248aadb0751d 100644 --- a/src/core_plugins/timelion/server/lib/build_target.js +++ b/src/core_plugins/timelion/server/lib/build_target.js @@ -1,7 +1,7 @@ import moment from 'moment'; import splitInterval from './split_interval.js'; -module.exports = function (tlConfig) { +export default function (tlConfig) { const min = moment(tlConfig.time.from); const max = moment(tlConfig.time.to); @@ -17,4 +17,4 @@ module.exports = function (tlConfig) { } return targetSeries; -}; +} diff --git a/src/core_plugins/timelion/server/lib/classes/chainable.js b/src/core_plugins/timelion/server/lib/classes/chainable.js index feee28cf86fc..4ca9f81638be 100644 --- a/src/core_plugins/timelion/server/lib/classes/chainable.js +++ b/src/core_plugins/timelion/server/lib/classes/chainable.js @@ -1,9 +1,9 @@ import TimelionFunction from './timelion_function'; -module.exports = class Chainable extends TimelionFunction { +export default class Chainable extends TimelionFunction { constructor(name, config) { super(name, config); this.chainable = true; Object.freeze(this); } -}; +} diff --git a/src/core_plugins/timelion/server/lib/classes/datasource.js b/src/core_plugins/timelion/server/lib/classes/datasource.js index 97d93d533ffd..10994a97f101 100644 --- a/src/core_plugins/timelion/server/lib/classes/datasource.js +++ b/src/core_plugins/timelion/server/lib/classes/datasource.js @@ -14,7 +14,7 @@ function offsetSeries(response, offset) { return response; } -module.exports = class Datasource extends TimelionFunction { +export default class Datasource extends TimelionFunction { constructor(name, config) { // Additional arguments that every dataSource take @@ -64,4 +64,4 @@ module.exports = class Datasource extends TimelionFunction { Object.freeze(this); } -}; +} diff --git a/src/core_plugins/timelion/server/lib/classes/timelion_function.js b/src/core_plugins/timelion/server/lib/classes/timelion_function.js index 7ab70670d058..9861aa0e2a31 100644 --- a/src/core_plugins/timelion/server/lib/classes/timelion_function.js +++ b/src/core_plugins/timelion/server/lib/classes/timelion_function.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import loadFunctions from '../load_functions.js'; const fitFunctions = loadFunctions('fit_functions'); -module.exports = class TimelionFunction { +export default class TimelionFunction { constructor(name, config) { this.name = name; this.args = config.args || []; @@ -42,4 +42,4 @@ module.exports = class TimelionFunction { }); }; } -}; +} diff --git a/src/core_plugins/timelion/server/lib/date_math.js b/src/core_plugins/timelion/server/lib/date_math.js index 616cfd99f612..11934f64aeb8 100644 --- a/src/core_plugins/timelion/server/lib/date_math.js +++ b/src/core_plugins/timelion/server/lib/date_math.js @@ -4,7 +4,7 @@ import moment from 'moment'; const units = ['y', 'M', 'w', 'd', 'h', 'm', 's']; /* This is a simplified version of elasticsearch's date parser */ -function parse(text, roundUp) { +export default function parse(text, roundUp) { if (!text) { return undefined; } @@ -102,5 +102,3 @@ function parseDateMath(mathString, time, roundUp) { } return dateTime; } - -module.exports = parse; diff --git a/src/core_plugins/timelion/server/lib/functions_md.js b/src/core_plugins/timelion/server/lib/functions_md.js index dec5bc48c80b..4d8117bad825 100644 --- a/src/core_plugins/timelion/server/lib/functions_md.js +++ b/src/core_plugins/timelion/server/lib/functions_md.js @@ -3,7 +3,7 @@ const functions = loadFunctions('series_functions/'); import _ from 'lodash'; -module.exports = (function () { +export default (function () { const functionArray = _.map(functions, function (val, key) { // TODO: This won't work on frozen objects, it should be removed when everything is converted to datasources and chainables return _.extend({}, val, { name: key }); diff --git a/src/core_plugins/timelion/server/lib/get_namespaced_settings.js b/src/core_plugins/timelion/server/lib/get_namespaced_settings.js index 8f2de490862e..fb27782fb432 100644 --- a/src/core_plugins/timelion/server/lib/get_namespaced_settings.js +++ b/src/core_plugins/timelion/server/lib/get_namespaced_settings.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import configFile from '../../timelion.json'; -module.exports = function () { +export default function () { function flattenWith(dot, nestedObj, flattenArrays) { const stack = []; // track key stack const flatObj = {}; @@ -22,4 +22,4 @@ module.exports = function () { result['timelion:' + key] = value; return result; }, {}); -}; +} diff --git a/src/core_plugins/timelion/server/lib/load_functions.js b/src/core_plugins/timelion/server/lib/load_functions.js index 575c3b012b40..6e995f44b321 100644 --- a/src/core_plugins/timelion/server/lib/load_functions.js +++ b/src/core_plugins/timelion/server/lib/load_functions.js @@ -3,7 +3,7 @@ import glob from 'glob'; import path from 'path'; import processFunctionDefinition from './process_function_definition'; -module.exports = function (directory) { +export default function (directory) { function getTuple(directory, name) { return [name, require('../' + directory + '/' + name)]; @@ -33,4 +33,4 @@ module.exports = function (directory) { }); return functions; -}; +} diff --git a/src/core_plugins/timelion/server/lib/offset_time.js b/src/core_plugins/timelion/server/lib/offset_time.js index 231b4696190a..bd6c9ce8b9a7 100644 --- a/src/core_plugins/timelion/server/lib/offset_time.js +++ b/src/core_plugins/timelion/server/lib/offset_time.js @@ -1,7 +1,7 @@ import moment from 'moment'; // usually reverse = false on the request, true on the response -module.exports = function offsetTime(milliseconds, offset, reverse) { +export default function offsetTime(milliseconds, offset, reverse) { if (!offset.match(/[-+][0-9]+[mshdwMy]/g)) { throw new Error ('Malformed `offset` at ' + offset); } @@ -14,4 +14,4 @@ module.exports = function offsetTime(milliseconds, offset, reverse) { const momentObj = moment(milliseconds)[mode](parts[1], parts[2]); return momentObj.valueOf(); -}; +} diff --git a/src/core_plugins/timelion/server/lib/process_function_definition.js b/src/core_plugins/timelion/server/lib/process_function_definition.js index 141651a9d56c..a62314e01167 100644 --- a/src/core_plugins/timelion/server/lib/process_function_definition.js +++ b/src/core_plugins/timelion/server/lib/process_function_definition.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function (func) { +export default function (func) { const functions = {}; functions[func.name] = func; if (func.aliases) { @@ -12,4 +12,4 @@ module.exports = function (func) { } return functions; -}; +} diff --git a/src/core_plugins/timelion/server/lib/reduce.js b/src/core_plugins/timelion/server/lib/reduce.js index 467be066bd20..1219c0332339 100644 --- a/src/core_plugins/timelion/server/lib/reduce.js +++ b/src/core_plugins/timelion/server/lib/reduce.js @@ -12,7 +12,7 @@ import Promise from 'bluebird'; * @params {Function} fn - Function used to combine points at same index in each array of each series in the seriesList. * @return {seriesList} */ -module.exports = function reduce(args, fn) { +export default function reduce(args, fn) { return Promise.all(args).then(function (args) { const seriesList = args.shift(); @@ -80,4 +80,4 @@ module.exports = function reduce(args, fn) { }).catch(function (e) { throw e; }); -}; +} diff --git a/src/core_plugins/timelion/server/lib/split_interval.js b/src/core_plugins/timelion/server/lib/split_interval.js index db7ae68811dc..4206115922f8 100644 --- a/src/core_plugins/timelion/server/lib/split_interval.js +++ b/src/core_plugins/timelion/server/lib/split_interval.js @@ -1,4 +1,4 @@ -module.exports = function splitInterval(interval) { +export default function splitInterval(interval) { if (!interval.match(/[0-9]+[mshdwMy]+/g)) { throw new Error ('Malformed `interval`: ' + interval); } @@ -8,4 +8,4 @@ module.exports = function splitInterval(interval) { count: parts[0], unit: parts[1] }; -}; +} diff --git a/src/core_plugins/timelion/server/lib/to_milliseconds.js b/src/core_plugins/timelion/server/lib/to_milliseconds.js index 449b4b917f77..2b14320a595b 100644 --- a/src/core_plugins/timelion/server/lib/to_milliseconds.js +++ b/src/core_plugins/timelion/server/lib/to_milliseconds.js @@ -23,7 +23,7 @@ const vals = _.transform([ // match any key from the vals object prececed by an optional number const parseRE = new RegExp('^(\\d+(?:\\.\\d*)?)?\\s*(' + _.keys(vals).join('|') + ')$'); -module.exports = function (expr) { +export default function (expr) { const match = expr.match(parseRE); if (match) { if (match[2] === 'M' && match[1] !== '1') { @@ -32,4 +32,4 @@ module.exports = function (expr) { return parseFloat(match[1] || 1) * vals[match[2]]; } -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/core_plugins/timelion/server/lib/unzipPairs.js b/src/core_plugins/timelion/server/lib/unzipPairs.js index 369ac7d19dde..322ea4d5c62d 100644 --- a/src/core_plugins/timelion/server/lib/unzipPairs.js +++ b/src/core_plugins/timelion/server/lib/unzipPairs.js @@ -1,10 +1,10 @@ import _ from 'lodash'; -module.exports = function unzipPairs(timeValObject) { +export default function unzipPairs(timeValObject) { const paired = _.chain(timeValObject).pairs().map(function (point) { return [parseInt(point[0], 10), point[1]]; }).sortBy(function (point) { return point[0]; }).value(); return paired; -}; +} diff --git a/src/core_plugins/timelion/server/routes/functions.js b/src/core_plugins/timelion/server/routes/functions.js index fe5bc2e90216..7f9287823f57 100644 --- a/src/core_plugins/timelion/server/routes/functions.js +++ b/src/core_plugins/timelion/server/routes/functions.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function (server) { +export default function (server) { server.route({ method: 'GET', path: '/api/timelion/functions', @@ -12,4 +12,4 @@ module.exports = function (server) { reply(_.sortBy(functionArray, 'name')); } }); -}; +} diff --git a/src/core_plugins/timelion/server/routes/run.js b/src/core_plugins/timelion/server/routes/run.js index 6b5fee71f557..6a5cffcd1754 100644 --- a/src/core_plugins/timelion/server/routes/run.js +++ b/src/core_plugins/timelion/server/routes/run.js @@ -8,7 +8,7 @@ function replyWithError(e, reply) { } -module.exports = (server) => { +export default function (server) { server.route({ method: ['POST', 'GET'], path: '/api/timelion/run', @@ -49,4 +49,4 @@ module.exports = (server) => { } }); -}; +} diff --git a/src/core_plugins/timelion/server/routes/validate_es.js b/src/core_plugins/timelion/server/routes/validate_es.js index 7733befea43b..0bac26f414af 100644 --- a/src/core_plugins/timelion/server/routes/validate_es.js +++ b/src/core_plugins/timelion/server/routes/validate_es.js @@ -1,4 +1,4 @@ -module.exports = function (server) { +export default function (server) { server.route({ method: 'GET', path: '/api/timelion/validate/es', @@ -30,4 +30,4 @@ module.exports = function (server) { } }); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/bucketList.js b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/bucketList.js index dcf54dd88b03..27c11cf7d3ab 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/bucketList.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/bucketList.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = [ +export default [ moment('1980-01-01T00:00:00.000Z'), moment('1981-01-01T00:00:00.000Z'), moment('1982-01-01T00:00:00.000Z'), diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/es_response.js b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/es_response.js index 21d497160eaf..a42d85c49ebf 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/es_response.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/es_response.js @@ -8,7 +8,7 @@ output of the entire thing. */ -module.exports = { +export default { _shards: { total: 1 }, diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/seriesList.js b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/seriesList.js index 6ce724148474..e21ec9521430 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/seriesList.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/seriesList.js @@ -2,7 +2,7 @@ import buckets from './bucketList'; import getSeries from '../helpers/get_series'; import getSeriesList from '../helpers/get_series_list'; -module.exports = function () { +export default function () { return getSeriesList([ getSeries('Negative', buckets, [-51, 17, 82, 20]), getSeries('Nice', buckets, [100, 50, 50, 20]), @@ -10,4 +10,4 @@ module.exports = function () { getSeries('Decimals', buckets, [3.1415926535, 2, 1.439, 0.3424235]), getSeries('PowerOfTen', buckets, [10, 100, 10, 1]), ]); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/tlConfig.js b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/tlConfig.js index 5d52acc55329..8dc6431d2430 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/tlConfig.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/fixtures/tlConfig.js @@ -3,7 +3,7 @@ import sinon from 'sinon'; import timelionDefaults from '../../../lib/get_namespaced_settings'; import esResponse from './es_response'; -module.exports = function () { +export default function () { const functions = require('../../../lib/load_functions')('series_functions'); const server = { @@ -41,4 +41,4 @@ module.exports = function () { tlConfig.setTargetSeries(); return tlConfig; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series.js b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series.js index e3bf2364e658..782fabbb7387 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series.js @@ -1,10 +1,10 @@ import _ from 'lodash'; -module.exports = function getSeries(name, buckets, points) { +export default function getSeries(name, buckets, points) { const fill = _.partial(_.zip, _.map(buckets, function (bucket) { return bucket.valueOf(); })); return { data: fill(points), type: 'series', label: name }; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series_list.js b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series_list.js index 3e1b957089df..ec14529c67bd 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series_list.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_series_list.js @@ -1,8 +1,8 @@ import _ from 'lodash'; -module.exports = function (list, overrides) { +export default function (list, overrides) { return _.merge({ type: 'seriesList', list: list }, overrides); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_single_series_list.js b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_single_series_list.js index 53f6ef0694ed..66ed2c997bc0 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_single_series_list.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/get_single_series_list.js @@ -2,6 +2,6 @@ import getSeries from '../helpers/get_series'; import getSeriesList from '../helpers/get_series_list'; import _ from 'lodash'; -module.exports = function (name, data) { +export default function (name, data) { return getSeriesList([getSeries(name, _.map(data, 0), _.map(data, 1))]); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/invoke_series_fn.js b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/invoke_series_fn.js index 6d67276097a3..11a41eafc7b5 100644 --- a/src/core_plugins/timelion/server/series_functions/__tests__/helpers/invoke_series_fn.js +++ b/src/core_plugins/timelion/server/series_functions/__tests__/helpers/invoke_series_fn.js @@ -3,7 +3,7 @@ import _ from 'lodash'; import indexArguments from '../../../handlers/lib/index_arguments'; -module.exports = function invokeSeriesFn(fnDef, args, tlConfigOverrides) { +export default function invokeSeriesFn(fnDef, args, tlConfigOverrides) { const tlConfig = _.merge(require('../fixtures/tlConfig')(), tlConfigOverrides); return Promise.all(args).then(function (args) { @@ -20,4 +20,4 @@ module.exports = function invokeSeriesFn(fnDef, args, tlConfigOverrides) { return result; }); }); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/abs.js b/src/core_plugins/timelion/server/series_functions/abs.js index 590a4220be89..81538a685694 100644 --- a/src/core_plugins/timelion/server/series_functions/abs.js +++ b/src/core_plugins/timelion/server/series_functions/abs.js @@ -1,7 +1,8 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('abs', { + +export default new Chainable('abs', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/avg.js b/src/core_plugins/timelion/server/series_functions/aggregate/avg.js index 90a4ff5eda96..6798cb82e036 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/avg.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/avg.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -module.exports = function (points) { +export default function (points) { return _.sum(points) / points.length; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/cardinality.js b/src/core_plugins/timelion/server/series_functions/aggregate/cardinality.js index e1f0d08834d6..4e9e26fcea5d 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/cardinality.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/cardinality.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -module.exports = function (points) { +export default function (points) { return _.uniq(points).length; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/first.js b/src/core_plugins/timelion/server/series_functions/aggregate/first.js index 3036c5b541d4..128950095e27 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/first.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/first.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -module.exports = function (points) { +export default function (points) { return _.first(points); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/index.js b/src/core_plugins/timelion/server/series_functions/aggregate/index.js index 11a6befb5a93..eaa693244627 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/index.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/index.js @@ -12,7 +12,7 @@ const functions = { sum: require('./sum') }; -module.exports = new Chainable('aggregate', { +export default new Chainable('aggregate', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/last.js b/src/core_plugins/timelion/server/series_functions/aggregate/last.js index ef214c896a4d..a7edb68ff385 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/last.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/last.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -module.exports = function (points) { +export default function (points) { return _.last(points); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/max.js b/src/core_plugins/timelion/server/series_functions/aggregate/max.js index 3edf18002cec..67696d8ca872 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/max.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/max.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -module.exports = function (points) { +export default function (points) { return _.max(points); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/min.js b/src/core_plugins/timelion/server/series_functions/aggregate/min.js index 8c5ce385272a..6faff717ae3a 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/min.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/min.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -module.exports = function (points) { +export default function (points) { return _.min(points); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/aggregate/sum.js b/src/core_plugins/timelion/server/series_functions/aggregate/sum.js index e32d6e7f7322..289892b22b0e 100644 --- a/src/core_plugins/timelion/server/series_functions/aggregate/sum.js +++ b/src/core_plugins/timelion/server/series_functions/aggregate/sum.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -module.exports = function (points) { +export default function (points) { return _.sum(points); -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/bars.js b/src/core_plugins/timelion/server/series_functions/bars.js index 2af583754296..691de2fe2be5 100644 --- a/src/core_plugins/timelion/server/series_functions/bars.js +++ b/src/core_plugins/timelion/server/series_functions/bars.js @@ -1,6 +1,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('bars', { + +export default new Chainable('bars', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/color.js b/src/core_plugins/timelion/server/series_functions/color.js index f46797876c2c..e8f80f3489ff 100644 --- a/src/core_plugins/timelion/server/series_functions/color.js +++ b/src/core_plugins/timelion/server/series_functions/color.js @@ -2,7 +2,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; import tinygradient from 'tinygradient'; -module.exports = new Chainable('color', { +export default new Chainable('color', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/condition.js b/src/core_plugins/timelion/server/series_functions/condition.js index eec00677ba66..5d930ef18a15 100644 --- a/src/core_plugins/timelion/server/series_functions/condition.js +++ b/src/core_plugins/timelion/server/series_functions/condition.js @@ -3,7 +3,7 @@ import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; import argType from '../handlers/lib/arg_type.js'; -module.exports = new Chainable('condition', { +export default new Chainable('condition', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/cusum.js b/src/core_plugins/timelion/server/series_functions/cusum.js index c553dea0b001..3d1eb501fc11 100644 --- a/src/core_plugins/timelion/server/series_functions/cusum.js +++ b/src/core_plugins/timelion/server/series_functions/cusum.js @@ -1,7 +1,8 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('cusum', { + +export default new Chainable('cusum', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/derivative.js b/src/core_plugins/timelion/server/series_functions/derivative.js index ad88c82786de..c63989d45a54 100644 --- a/src/core_plugins/timelion/server/series_functions/derivative.js +++ b/src/core_plugins/timelion/server/series_functions/derivative.js @@ -1,7 +1,8 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('derivative', { + +export default new Chainable('derivative', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/divide.js b/src/core_plugins/timelion/server/series_functions/divide.js index 6b857b7bab27..ced6911924a8 100644 --- a/src/core_plugins/timelion/server/series_functions/divide.js +++ b/src/core_plugins/timelion/server/series_functions/divide.js @@ -1,6 +1,7 @@ import reduce from '../lib/reduce.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('divide', { + +export default new Chainable('divide', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/es/index.js b/src/core_plugins/timelion/server/series_functions/es/index.js index 0817b0ba788a..0ab7ad6b396e 100644 --- a/src/core_plugins/timelion/server/series_functions/es/index.js +++ b/src/core_plugins/timelion/server/series_functions/es/index.js @@ -3,7 +3,7 @@ import Datasource from '../../lib/classes/datasource'; import buildRequest from './lib/build_request'; import toSeriesList from './lib/agg_response_to_series_list'; -module.exports = new Datasource('es', { +export default new Datasource('es', { args: [ { name: 'q', diff --git a/src/core_plugins/timelion/server/series_functions/es/lib/build_request.js b/src/core_plugins/timelion/server/series_functions/es/lib/build_request.js index f254a7bb236a..8356027f9613 100644 --- a/src/core_plugins/timelion/server/series_functions/es/lib/build_request.js +++ b/src/core_plugins/timelion/server/series_functions/es/lib/build_request.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import createDateAgg from './create_date_agg'; -module.exports = function buildRequest(config, tlConfig) { +export default function buildRequest(config, tlConfig) { const bool = { must: [] }; @@ -58,4 +58,4 @@ module.exports = function buildRequest(config, tlConfig) { size: 0 } }; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js b/src/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js index 0399b62c73f5..db2cb3ac06e7 100644 --- a/src/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js +++ b/src/core_plugins/timelion/server/series_functions/es/lib/create_date_agg.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function createDateAgg(config, tlConfig) { +export default function createDateAgg(config, tlConfig) { const dateAgg = { time_buckets: { meta: { type: 'time_buckets' }, @@ -39,4 +39,4 @@ module.exports = function createDateAgg(config, tlConfig) { }); return dateAgg; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/first.js b/src/core_plugins/timelion/server/series_functions/first.js index 3310d5354e69..af97814531f7 100644 --- a/src/core_plugins/timelion/server/series_functions/first.js +++ b/src/core_plugins/timelion/server/series_functions/first.js @@ -1,6 +1,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('first', { + +export default new Chainable('first', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/fit.js b/src/core_plugins/timelion/server/series_functions/fit.js index 6e2dae65ad6e..bef181d94d23 100644 --- a/src/core_plugins/timelion/server/series_functions/fit.js +++ b/src/core_plugins/timelion/server/series_functions/fit.js @@ -4,7 +4,7 @@ import Chainable from '../lib/classes/chainable'; import loadFunctions from '../lib/load_functions.js'; const fitFunctions = loadFunctions('fit_functions'); -module.exports = new Chainable('fit', { +export default new Chainable('fit', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/graphite.js b/src/core_plugins/timelion/server/series_functions/graphite.js index d9e016e85658..686aaeac13d8 100644 --- a/src/core_plugins/timelion/server/series_functions/graphite.js +++ b/src/core_plugins/timelion/server/series_functions/graphite.js @@ -4,7 +4,7 @@ import moment from 'moment'; import Datasource from '../lib/classes/datasource'; -module.exports = new Datasource ('graphite', { +export default new Datasource ('graphite', { args: [ { name: 'metric', // _test-data.users.*.data diff --git a/src/core_plugins/timelion/server/series_functions/hide.js b/src/core_plugins/timelion/server/series_functions/hide.js index 874b3aec2d4e..6a8583f0440d 100644 --- a/src/core_plugins/timelion/server/series_functions/hide.js +++ b/src/core_plugins/timelion/server/series_functions/hide.js @@ -1,6 +1,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('hide', { + +export default new Chainable('hide', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/holt/index.js b/src/core_plugins/timelion/server/series_functions/holt/index.js index 7a6f4e249912..a0f048423f45 100644 --- a/src/core_plugins/timelion/server/series_functions/holt/index.js +++ b/src/core_plugins/timelion/server/series_functions/holt/index.js @@ -5,7 +5,7 @@ import des from './lib/des'; import tes from './lib/tes'; import toMilliseconds from '../../lib/to_milliseconds'; -module.exports = new Chainable('holt', { +export default new Chainable('holt', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/holt/lib/des.js b/src/core_plugins/timelion/server/series_functions/holt/lib/des.js index 671829b71951..5d9c41b7abdb 100644 --- a/src/core_plugins/timelion/server/series_functions/holt/lib/des.js +++ b/src/core_plugins/timelion/server/series_functions/holt/lib/des.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function des(points, alpha, beta) { +export default function des(points, alpha, beta) { let level; let prevLevel; let trend; @@ -37,4 +37,4 @@ module.exports = function des(points, alpha, beta) { }, []); return smoothedPoints; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/holt/lib/ses.js b/src/core_plugins/timelion/server/series_functions/holt/lib/ses.js index df63dcb46d71..749fd0e70509 100644 --- a/src/core_plugins/timelion/server/series_functions/holt/lib/ses.js +++ b/src/core_plugins/timelion/server/series_functions/holt/lib/ses.js @@ -4,7 +4,7 @@ import _ from 'lodash'; -module.exports = function ses(points, alpha) { +export default function ses(points, alpha) { let origin; let level; @@ -31,4 +31,4 @@ module.exports = function ses(points, alpha) { }, []); return smoothedPoints; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/holt/lib/tes.js b/src/core_plugins/timelion/server/series_functions/holt/lib/tes.js index 449c94d4a20b..2faad2c0a742 100644 --- a/src/core_plugins/timelion/server/series_functions/holt/lib/tes.js +++ b/src/core_plugins/timelion/server/series_functions/holt/lib/tes.js @@ -47,7 +47,7 @@ function initTrend(samplePoints, seasonLength) { return sum / seasonLength; } -module.exports = function tes(points, alpha, beta, gamma, seasonLength, seasonsToSample) { +export default function tes(points, alpha, beta, gamma, seasonLength, seasonsToSample) { const samplePoints = points.slice(0, seasonLength * seasonsToSample); const seasonals = initSeasonalComponents(samplePoints, seasonLength); @@ -86,4 +86,4 @@ module.exports = function tes(points, alpha, beta, gamma, seasonLength, seasonsT }); return result; -}; +} diff --git a/src/core_plugins/timelion/server/series_functions/label.js b/src/core_plugins/timelion/server/series_functions/label.js index c8c22ba040c7..862d2f84d749 100644 --- a/src/core_plugins/timelion/server/series_functions/label.js +++ b/src/core_plugins/timelion/server/series_functions/label.js @@ -1,6 +1,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('label', { + +export default new Chainable('label', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/legend.js b/src/core_plugins/timelion/server/series_functions/legend.js index 6350037eb447..336afebde455 100644 --- a/src/core_plugins/timelion/server/series_functions/legend.js +++ b/src/core_plugins/timelion/server/series_functions/legend.js @@ -1,6 +1,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('legend', { + +export default new Chainable('legend', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/lines.js b/src/core_plugins/timelion/server/series_functions/lines.js index 55a9efa86bf6..acd7e6e66ee3 100644 --- a/src/core_plugins/timelion/server/series_functions/lines.js +++ b/src/core_plugins/timelion/server/series_functions/lines.js @@ -1,6 +1,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('lines', { + +export default new Chainable('lines', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/log.js b/src/core_plugins/timelion/server/series_functions/log.js index 8a32513f9d57..1d8e9c84db56 100644 --- a/src/core_plugins/timelion/server/series_functions/log.js +++ b/src/core_plugins/timelion/server/series_functions/log.js @@ -1,7 +1,8 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('log', { + +export default new Chainable('log', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/max.js b/src/core_plugins/timelion/server/series_functions/max.js index e6297bd1b9ee..bbc1005b1096 100644 --- a/src/core_plugins/timelion/server/series_functions/max.js +++ b/src/core_plugins/timelion/server/series_functions/max.js @@ -1,6 +1,7 @@ import reduce from '../lib/reduce.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('max', { + +export default new Chainable('max', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/min.js b/src/core_plugins/timelion/server/series_functions/min.js index 47f3967f26f1..c4669cf590f1 100644 --- a/src/core_plugins/timelion/server/series_functions/min.js +++ b/src/core_plugins/timelion/server/series_functions/min.js @@ -1,6 +1,7 @@ import reduce from '../lib/reduce.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('min', { + +export default new Chainable('min', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/movingaverage.js b/src/core_plugins/timelion/server/series_functions/movingaverage.js index 0e8c547f6709..541fdd560f2f 100644 --- a/src/core_plugins/timelion/server/series_functions/movingaverage.js +++ b/src/core_plugins/timelion/server/series_functions/movingaverage.js @@ -3,7 +3,7 @@ import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; import toMS from '../lib/to_milliseconds.js'; -module.exports = new Chainable('movingaverage', { +export default new Chainable('movingaverage', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/movingstd.js b/src/core_plugins/timelion/server/series_functions/movingstd.js index 534d11bdd108..5ab248ee81a5 100644 --- a/src/core_plugins/timelion/server/series_functions/movingstd.js +++ b/src/core_plugins/timelion/server/series_functions/movingstd.js @@ -1,7 +1,8 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('movingstd', { + +export default new Chainable('movingstd', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/multiply.js b/src/core_plugins/timelion/server/series_functions/multiply.js index e8e529a39ed3..ffce9eb31a32 100644 --- a/src/core_plugins/timelion/server/series_functions/multiply.js +++ b/src/core_plugins/timelion/server/series_functions/multiply.js @@ -1,6 +1,7 @@ import reduce from '../lib/reduce.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('multiply', { + +export default new Chainable('multiply', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/points.js b/src/core_plugins/timelion/server/series_functions/points.js index 691fb486ee1d..c8499d6a456c 100644 --- a/src/core_plugins/timelion/server/series_functions/points.js +++ b/src/core_plugins/timelion/server/series_functions/points.js @@ -1,7 +1,8 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('points', { + +export default new Chainable('points', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/precision.js b/src/core_plugins/timelion/server/series_functions/precision.js index e20e973940b1..698acf538540 100644 --- a/src/core_plugins/timelion/server/series_functions/precision.js +++ b/src/core_plugins/timelion/server/series_functions/precision.js @@ -1,7 +1,8 @@ import reduce from '../lib/reduce.js'; import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('precision', { + +export default new Chainable('precision', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/props.js b/src/core_plugins/timelion/server/series_functions/props.js index 917b58bed42d..42e22b84f4b2 100644 --- a/src/core_plugins/timelion/server/series_functions/props.js +++ b/src/core_plugins/timelion/server/series_functions/props.js @@ -21,7 +21,7 @@ function unflatten(data) { return result[''] || result; } -module.exports = new Chainable('props', { +export default new Chainable('props', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/quandl.js b/src/core_plugins/timelion/server/series_functions/quandl.js index 83987a25b601..1cd69380686e 100644 --- a/src/core_plugins/timelion/server/series_functions/quandl.js +++ b/src/core_plugins/timelion/server/series_functions/quandl.js @@ -9,7 +9,7 @@ fetch.Promise = require('bluebird'); import Datasource from '../lib/classes/datasource'; -module.exports = new Datasource ('quandl', { +export default new Datasource ('quandl', { dataSource: true, args: [ { diff --git a/src/core_plugins/timelion/server/series_functions/range.js b/src/core_plugins/timelion/server/series_functions/range.js index f42838688d4f..d8f2959dbf33 100644 --- a/src/core_plugins/timelion/server/series_functions/range.js +++ b/src/core_plugins/timelion/server/series_functions/range.js @@ -1,7 +1,8 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('range', { + +export default new Chainable('range', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/scale_interval.js b/src/core_plugins/timelion/server/series_functions/scale_interval.js index 21b94f852b6b..8891ea23940e 100644 --- a/src/core_plugins/timelion/server/series_functions/scale_interval.js +++ b/src/core_plugins/timelion/server/series_functions/scale_interval.js @@ -2,7 +2,8 @@ import alter from '../lib/alter.js'; import toMS from '../lib/to_milliseconds.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('scale_interval', { + +export default new Chainable('scale_interval', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/static.js b/src/core_plugins/timelion/server/series_functions/static.js index 016914cf7b37..0d7814456c5e 100644 --- a/src/core_plugins/timelion/server/series_functions/static.js +++ b/src/core_plugins/timelion/server/series_functions/static.js @@ -3,7 +3,7 @@ import Datasource from '../lib/classes/datasource'; import Promise from 'bluebird'; -module.exports = new Datasource ('static', { +export default new Datasource ('static', { aliases: ['value'], args: [ { diff --git a/src/core_plugins/timelion/server/series_functions/subtract.js b/src/core_plugins/timelion/server/series_functions/subtract.js index d83332a9c2fc..1f72597c425d 100644 --- a/src/core_plugins/timelion/server/series_functions/subtract.js +++ b/src/core_plugins/timelion/server/series_functions/subtract.js @@ -1,6 +1,7 @@ import reduce from '../lib/reduce.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('subtract', { + +export default new Chainable('subtract', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/sum.js b/src/core_plugins/timelion/server/series_functions/sum.js index cceffc4ec9ec..765f58d1b34e 100644 --- a/src/core_plugins/timelion/server/series_functions/sum.js +++ b/src/core_plugins/timelion/server/series_functions/sum.js @@ -1,6 +1,7 @@ import reduce from '../lib/reduce.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('sum', { + +export default new Chainable('sum', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/title.js b/src/core_plugins/timelion/server/series_functions/title.js index d089f69dfd60..b8c9ff7106d6 100644 --- a/src/core_plugins/timelion/server/series_functions/title.js +++ b/src/core_plugins/timelion/server/series_functions/title.js @@ -1,6 +1,7 @@ import alter from '../lib/alter.js'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('title', { + +export default new Chainable('title', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/trend/index.js b/src/core_plugins/timelion/server/series_functions/trend/index.js index 715aea4c2e4d..d8869cbd4fde 100644 --- a/src/core_plugins/timelion/server/series_functions/trend/index.js +++ b/src/core_plugins/timelion/server/series_functions/trend/index.js @@ -7,7 +7,7 @@ const validRegressions = { log: 'logarithmic', }; -module.exports = new Chainable('trend', { +export default new Chainable('trend', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/trim.js b/src/core_plugins/timelion/server/series_functions/trim.js index 05c604622a32..fc483f276636 100644 --- a/src/core_plugins/timelion/server/series_functions/trim.js +++ b/src/core_plugins/timelion/server/series_functions/trim.js @@ -2,7 +2,7 @@ import alter from '../lib/alter.js'; import _ from 'lodash'; import Chainable from '../lib/classes/chainable'; -module.exports = new Chainable('trim', { +export default new Chainable('trim', { args: [ { name: 'inputSeries', diff --git a/src/core_plugins/timelion/server/series_functions/worldbank.js b/src/core_plugins/timelion/server/series_functions/worldbank.js index d58885887dd7..cf3c65a14045 100644 --- a/src/core_plugins/timelion/server/series_functions/worldbank.js +++ b/src/core_plugins/timelion/server/series_functions/worldbank.js @@ -3,7 +3,7 @@ import fetch from 'node-fetch'; import moment from 'moment'; import Datasource from '../lib/classes/datasource'; -module.exports = new Datasource ('worldbank', { +export default new Datasource ('worldbank', { args: [ { name: 'code', // countries/all/indicators/SP.POP.TOTL diff --git a/src/core_plugins/timelion/server/series_functions/worldbank_indicators.js b/src/core_plugins/timelion/server/series_functions/worldbank_indicators.js index c0c75bcd91c0..20a8ab69d0c8 100644 --- a/src/core_plugins/timelion/server/series_functions/worldbank_indicators.js +++ b/src/core_plugins/timelion/server/series_functions/worldbank_indicators.js @@ -4,7 +4,7 @@ import Promise from 'bluebird'; import Datasource from '../lib/classes/datasource'; -module.exports = new Datasource ('worldbank_indicators', { +export default new Datasource ('worldbank_indicators', { args: [ { name: 'country', // countries/all/indicators/SP.POP.TOTL diff --git a/src/core_plugins/timelion/server/series_functions/yaxis.js b/src/core_plugins/timelion/server/series_functions/yaxis.js index 94fbda9043f4..69c2c1378619 100644 --- a/src/core_plugins/timelion/server/series_functions/yaxis.js +++ b/src/core_plugins/timelion/server/series_functions/yaxis.js @@ -10,7 +10,8 @@ const tickFormatters = { 'percent':'percent', 'custom':'custom(:prefix:suffix)' }; -module.exports = new Chainable('yaxis', { + +export default new Chainable('yaxis', { args: [ { name: 'inputSeries', diff --git a/src/fixtures/agg_resp/date_histogram.js b/src/fixtures/agg_resp/date_histogram.js index 3c66a87dd4be..7de06c1656e7 100644 --- a/src/fixtures/agg_resp/date_histogram.js +++ b/src/fixtures/agg_resp/date_histogram.js @@ -1,252 +1,250 @@ -define(function () { - return { - 'took': 35, - 'timed_out': false, - '_shards': { - 'total': 2, - 'successful': 2, - 'failed': 0 - }, - 'hits': { - 'total': 32899, - 'max_score': 0, - 'hits': [] - }, - 'aggregations': { - '1': { - 'buckets': [ - { - 'key_as_string': '2015-01-30T01:00:00.000Z', - 'key': 1422579600000, - 'doc_count': 18 - }, - { - 'key_as_string': '2015-01-30T02:00:00.000Z', - 'key': 1422583200000, - 'doc_count': 68 - }, - { - 'key_as_string': '2015-01-30T03:00:00.000Z', - 'key': 1422586800000, - 'doc_count': 146 - }, - { - 'key_as_string': '2015-01-30T04:00:00.000Z', - 'key': 1422590400000, - 'doc_count': 149 - }, - { - 'key_as_string': '2015-01-30T05:00:00.000Z', - 'key': 1422594000000, - 'doc_count': 363 - }, - { - 'key_as_string': '2015-01-30T06:00:00.000Z', - 'key': 1422597600000, - 'doc_count': 555 - }, - { - 'key_as_string': '2015-01-30T07:00:00.000Z', - 'key': 1422601200000, - 'doc_count': 878 - }, - { - 'key_as_string': '2015-01-30T08:00:00.000Z', - 'key': 1422604800000, - 'doc_count': 1133 - }, - { - 'key_as_string': '2015-01-30T09:00:00.000Z', - 'key': 1422608400000, - 'doc_count': 1438 - }, - { - 'key_as_string': '2015-01-30T10:00:00.000Z', - 'key': 1422612000000, - 'doc_count': 1719 - }, - { - 'key_as_string': '2015-01-30T11:00:00.000Z', - 'key': 1422615600000, - 'doc_count': 1813 - }, - { - 'key_as_string': '2015-01-30T12:00:00.000Z', - 'key': 1422619200000, - 'doc_count': 1790 - }, - { - 'key_as_string': '2015-01-30T13:00:00.000Z', - 'key': 1422622800000, - 'doc_count': 1582 - }, - { - 'key_as_string': '2015-01-30T14:00:00.000Z', - 'key': 1422626400000, - 'doc_count': 1439 - }, - { - 'key_as_string': '2015-01-30T15:00:00.000Z', - 'key': 1422630000000, - 'doc_count': 1154 - }, - { - 'key_as_string': '2015-01-30T16:00:00.000Z', - 'key': 1422633600000, - 'doc_count': 847 - }, - { - 'key_as_string': '2015-01-30T17:00:00.000Z', - 'key': 1422637200000, - 'doc_count': 588 - }, - { - 'key_as_string': '2015-01-30T18:00:00.000Z', - 'key': 1422640800000, - 'doc_count': 374 - }, - { - 'key_as_string': '2015-01-30T19:00:00.000Z', - 'key': 1422644400000, - 'doc_count': 152 - }, - { - 'key_as_string': '2015-01-30T20:00:00.000Z', - 'key': 1422648000000, - 'doc_count': 140 - }, - { - 'key_as_string': '2015-01-30T21:00:00.000Z', - 'key': 1422651600000, - 'doc_count': 73 - }, - { - 'key_as_string': '2015-01-30T22:00:00.000Z', - 'key': 1422655200000, - 'doc_count': 28 - }, - { - 'key_as_string': '2015-01-30T23:00:00.000Z', - 'key': 1422658800000, - 'doc_count': 9 - }, - { - 'key_as_string': '2015-01-31T00:00:00.000Z', - 'key': 1422662400000, - 'doc_count': 29 - }, - { - 'key_as_string': '2015-01-31T01:00:00.000Z', - 'key': 1422666000000, - 'doc_count': 38 - }, - { - 'key_as_string': '2015-01-31T02:00:00.000Z', - 'key': 1422669600000, - 'doc_count': 70 - }, - { - 'key_as_string': '2015-01-31T03:00:00.000Z', - 'key': 1422673200000, - 'doc_count': 136 - }, - { - 'key_as_string': '2015-01-31T04:00:00.000Z', - 'key': 1422676800000, - 'doc_count': 173 - }, - { - 'key_as_string': '2015-01-31T05:00:00.000Z', - 'key': 1422680400000, - 'doc_count': 370 - }, - { - 'key_as_string': '2015-01-31T06:00:00.000Z', - 'key': 1422684000000, - 'doc_count': 545 - }, - { - 'key_as_string': '2015-01-31T07:00:00.000Z', - 'key': 1422687600000, - 'doc_count': 845 - }, - { - 'key_as_string': '2015-01-31T08:00:00.000Z', - 'key': 1422691200000, - 'doc_count': 1070 - }, - { - 'key_as_string': '2015-01-31T09:00:00.000Z', - 'key': 1422694800000, - 'doc_count': 1419 - }, - { - 'key_as_string': '2015-01-31T10:00:00.000Z', - 'key': 1422698400000, - 'doc_count': 1725 - }, - { - 'key_as_string': '2015-01-31T11:00:00.000Z', - 'key': 1422702000000, - 'doc_count': 1801 - }, - { - 'key_as_string': '2015-01-31T12:00:00.000Z', - 'key': 1422705600000, - 'doc_count': 1823 - }, - { - 'key_as_string': '2015-01-31T13:00:00.000Z', - 'key': 1422709200000, - 'doc_count': 1657 - }, - { - 'key_as_string': '2015-01-31T14:00:00.000Z', - 'key': 1422712800000, - 'doc_count': 1454 - }, - { - 'key_as_string': '2015-01-31T15:00:00.000Z', - 'key': 1422716400000, - 'doc_count': 1131 - }, - { - 'key_as_string': '2015-01-31T16:00:00.000Z', - 'key': 1422720000000, - 'doc_count': 810 - }, - { - 'key_as_string': '2015-01-31T17:00:00.000Z', - 'key': 1422723600000, - 'doc_count': 583 - }, - { - 'key_as_string': '2015-01-31T18:00:00.000Z', - 'key': 1422727200000, - 'doc_count': 384 - }, - { - 'key_as_string': '2015-01-31T19:00:00.000Z', - 'key': 1422730800000, - 'doc_count': 165 - }, - { - 'key_as_string': '2015-01-31T20:00:00.000Z', - 'key': 1422734400000, - 'doc_count': 135 - }, - { - 'key_as_string': '2015-01-31T21:00:00.000Z', - 'key': 1422738000000, - 'doc_count': 72 - }, - { - 'key_as_string': '2015-01-31T22:00:00.000Z', - 'key': 1422741600000, - 'doc_count': 8 - } - ] - } +export default { + 'took': 35, + 'timed_out': false, + '_shards': { + 'total': 2, + 'successful': 2, + 'failed': 0 + }, + 'hits': { + 'total': 32899, + 'max_score': 0, + 'hits': [] + }, + 'aggregations': { + '1': { + 'buckets': [ + { + 'key_as_string': '2015-01-30T01:00:00.000Z', + 'key': 1422579600000, + 'doc_count': 18 + }, + { + 'key_as_string': '2015-01-30T02:00:00.000Z', + 'key': 1422583200000, + 'doc_count': 68 + }, + { + 'key_as_string': '2015-01-30T03:00:00.000Z', + 'key': 1422586800000, + 'doc_count': 146 + }, + { + 'key_as_string': '2015-01-30T04:00:00.000Z', + 'key': 1422590400000, + 'doc_count': 149 + }, + { + 'key_as_string': '2015-01-30T05:00:00.000Z', + 'key': 1422594000000, + 'doc_count': 363 + }, + { + 'key_as_string': '2015-01-30T06:00:00.000Z', + 'key': 1422597600000, + 'doc_count': 555 + }, + { + 'key_as_string': '2015-01-30T07:00:00.000Z', + 'key': 1422601200000, + 'doc_count': 878 + }, + { + 'key_as_string': '2015-01-30T08:00:00.000Z', + 'key': 1422604800000, + 'doc_count': 1133 + }, + { + 'key_as_string': '2015-01-30T09:00:00.000Z', + 'key': 1422608400000, + 'doc_count': 1438 + }, + { + 'key_as_string': '2015-01-30T10:00:00.000Z', + 'key': 1422612000000, + 'doc_count': 1719 + }, + { + 'key_as_string': '2015-01-30T11:00:00.000Z', + 'key': 1422615600000, + 'doc_count': 1813 + }, + { + 'key_as_string': '2015-01-30T12:00:00.000Z', + 'key': 1422619200000, + 'doc_count': 1790 + }, + { + 'key_as_string': '2015-01-30T13:00:00.000Z', + 'key': 1422622800000, + 'doc_count': 1582 + }, + { + 'key_as_string': '2015-01-30T14:00:00.000Z', + 'key': 1422626400000, + 'doc_count': 1439 + }, + { + 'key_as_string': '2015-01-30T15:00:00.000Z', + 'key': 1422630000000, + 'doc_count': 1154 + }, + { + 'key_as_string': '2015-01-30T16:00:00.000Z', + 'key': 1422633600000, + 'doc_count': 847 + }, + { + 'key_as_string': '2015-01-30T17:00:00.000Z', + 'key': 1422637200000, + 'doc_count': 588 + }, + { + 'key_as_string': '2015-01-30T18:00:00.000Z', + 'key': 1422640800000, + 'doc_count': 374 + }, + { + 'key_as_string': '2015-01-30T19:00:00.000Z', + 'key': 1422644400000, + 'doc_count': 152 + }, + { + 'key_as_string': '2015-01-30T20:00:00.000Z', + 'key': 1422648000000, + 'doc_count': 140 + }, + { + 'key_as_string': '2015-01-30T21:00:00.000Z', + 'key': 1422651600000, + 'doc_count': 73 + }, + { + 'key_as_string': '2015-01-30T22:00:00.000Z', + 'key': 1422655200000, + 'doc_count': 28 + }, + { + 'key_as_string': '2015-01-30T23:00:00.000Z', + 'key': 1422658800000, + 'doc_count': 9 + }, + { + 'key_as_string': '2015-01-31T00:00:00.000Z', + 'key': 1422662400000, + 'doc_count': 29 + }, + { + 'key_as_string': '2015-01-31T01:00:00.000Z', + 'key': 1422666000000, + 'doc_count': 38 + }, + { + 'key_as_string': '2015-01-31T02:00:00.000Z', + 'key': 1422669600000, + 'doc_count': 70 + }, + { + 'key_as_string': '2015-01-31T03:00:00.000Z', + 'key': 1422673200000, + 'doc_count': 136 + }, + { + 'key_as_string': '2015-01-31T04:00:00.000Z', + 'key': 1422676800000, + 'doc_count': 173 + }, + { + 'key_as_string': '2015-01-31T05:00:00.000Z', + 'key': 1422680400000, + 'doc_count': 370 + }, + { + 'key_as_string': '2015-01-31T06:00:00.000Z', + 'key': 1422684000000, + 'doc_count': 545 + }, + { + 'key_as_string': '2015-01-31T07:00:00.000Z', + 'key': 1422687600000, + 'doc_count': 845 + }, + { + 'key_as_string': '2015-01-31T08:00:00.000Z', + 'key': 1422691200000, + 'doc_count': 1070 + }, + { + 'key_as_string': '2015-01-31T09:00:00.000Z', + 'key': 1422694800000, + 'doc_count': 1419 + }, + { + 'key_as_string': '2015-01-31T10:00:00.000Z', + 'key': 1422698400000, + 'doc_count': 1725 + }, + { + 'key_as_string': '2015-01-31T11:00:00.000Z', + 'key': 1422702000000, + 'doc_count': 1801 + }, + { + 'key_as_string': '2015-01-31T12:00:00.000Z', + 'key': 1422705600000, + 'doc_count': 1823 + }, + { + 'key_as_string': '2015-01-31T13:00:00.000Z', + 'key': 1422709200000, + 'doc_count': 1657 + }, + { + 'key_as_string': '2015-01-31T14:00:00.000Z', + 'key': 1422712800000, + 'doc_count': 1454 + }, + { + 'key_as_string': '2015-01-31T15:00:00.000Z', + 'key': 1422716400000, + 'doc_count': 1131 + }, + { + 'key_as_string': '2015-01-31T16:00:00.000Z', + 'key': 1422720000000, + 'doc_count': 810 + }, + { + 'key_as_string': '2015-01-31T17:00:00.000Z', + 'key': 1422723600000, + 'doc_count': 583 + }, + { + 'key_as_string': '2015-01-31T18:00:00.000Z', + 'key': 1422727200000, + 'doc_count': 384 + }, + { + 'key_as_string': '2015-01-31T19:00:00.000Z', + 'key': 1422730800000, + 'doc_count': 165 + }, + { + 'key_as_string': '2015-01-31T20:00:00.000Z', + 'key': 1422734400000, + 'doc_count': 135 + }, + { + 'key_as_string': '2015-01-31T21:00:00.000Z', + 'key': 1422738000000, + 'doc_count': 72 + }, + { + 'key_as_string': '2015-01-31T22:00:00.000Z', + 'key': 1422741600000, + 'doc_count': 8 + } + ] } - }; -}); \ No newline at end of file + } +}; diff --git a/src/fixtures/vislib/_vis_fixture.js b/src/fixtures/vislib/_vis_fixture.js index 350ce07354a5..35e16f165b1f 100644 --- a/src/fixtures/vislib/_vis_fixture.js +++ b/src/fixtures/vislib/_vis_fixture.js @@ -31,7 +31,7 @@ afterEach(function () { count = 0; }); -module.exports = function VislibFixtures(Private) { +export default function VislibFixtures(Private) { return function (visLibParams) { const Vis = Private(VislibVisProvider); return new Vis($visCanvas.new(), _.defaults({}, visLibParams || {}, { @@ -43,4 +43,4 @@ module.exports = function VislibFixtures(Private) { type: 'histogram' })); }; -}; +} diff --git a/src/fixtures/vislib/mock_data/date_histogram/_columns.js b/src/fixtures/vislib/mock_data/date_histogram/_columns.js index 89705f6b2d5c..60166ba59268 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_columns.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_columns.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = { +export default { 'columns': [ { 'label': '200: response', diff --git a/src/fixtures/vislib/mock_data/date_histogram/_rows.js b/src/fixtures/vislib/mock_data/date_histogram/_rows.js index 0b6e71fe05ff..b9b6df6c0916 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_rows.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_rows.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = { +export default { 'rows': [ { 'label': '0.0-1000.0: bytes', diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series.js b/src/fixtures/vislib/mock_data/date_histogram/_series.js index 2d5f9c67b06e..b26c687c6c86 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_series.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_series.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = { +export default { 'label': '', 'xAxisLabel': '@timestamp per 30 sec', 'ordered': { diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js b/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js index 1ed0ba09977e..15d08b1b0ac7 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = { +export default { 'label': '', 'xAxisLabel': '@timestamp per 30 sec', 'ordered': { diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js b/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js index 539867423a2b..f85bb2b042d6 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = { +export default { 'label': '', 'xAxisLabel': '@timestamp per 30 sec', 'ordered': { diff --git a/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js b/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js index 31488ccf4073..8c77336f997b 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = { +export default { 'label': '', 'xAxisLabel': '@timestamp per 10 min', 'ordered': { diff --git a/src/fixtures/vislib/mock_data/filters/_columns.js b/src/fixtures/vislib/mock_data/filters/_columns.js index b3a2030b7d7e..372a887a4a45 100644 --- a/src/fixtures/vislib/mock_data/filters/_columns.js +++ b/src/fixtures/vislib/mock_data/filters/_columns.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'columns': [ { 'label': 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1: agent.raw', diff --git a/src/fixtures/vislib/mock_data/filters/_rows.js b/src/fixtures/vislib/mock_data/filters/_rows.js index e12f316b9185..cc4f598c7b1b 100644 --- a/src/fixtures/vislib/mock_data/filters/_rows.js +++ b/src/fixtures/vislib/mock_data/filters/_rows.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'rows': [ { 'label': '200: response', diff --git a/src/fixtures/vislib/mock_data/filters/_series.js b/src/fixtures/vislib/mock_data/filters/_series.js index d05e3009bb03..6b07dc1ec7a5 100644 --- a/src/fixtures/vislib/mock_data/filters/_series.js +++ b/src/fixtures/vislib/mock_data/filters/_series.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'label': '', 'xAxisLabel': 'filters', 'yAxisLabel': 'Count of documents', diff --git a/src/fixtures/vislib/mock_data/geohash/_columns.js b/src/fixtures/vislib/mock_data/geohash/_columns.js index fcfbf2444b0f..d283d7931517 100644 --- a/src/fixtures/vislib/mock_data/geohash/_columns.js +++ b/src/fixtures/vislib/mock_data/geohash/_columns.js @@ -1,5 +1,6 @@ import _ from 'lodash'; -module.exports = { + +export default { 'columns': [ { 'title': 'Top 2 geo.dest: CN', diff --git a/src/fixtures/vislib/mock_data/geohash/_geo_json.js b/src/fixtures/vislib/mock_data/geohash/_geo_json.js index b0889a9ed027..4e65502f8d27 100644 --- a/src/fixtures/vislib/mock_data/geohash/_geo_json.js +++ b/src/fixtures/vislib/mock_data/geohash/_geo_json.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'valueFormatter': _.identity, 'geohashGridAgg': { 'vis': { 'params': {} } }, 'geoJson': { diff --git a/src/fixtures/vislib/mock_data/geohash/_rows.js b/src/fixtures/vislib/mock_data/geohash/_rows.js index 50efcc30d957..64deea0e391a 100644 --- a/src/fixtures/vislib/mock_data/geohash/_rows.js +++ b/src/fixtures/vislib/mock_data/geohash/_rows.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'rows': [ { 'title': 'Top 2 geo.dest: CN', diff --git a/src/fixtures/vislib/mock_data/histogram/_columns.js b/src/fixtures/vislib/mock_data/histogram/_columns.js index e5171d1aa08a..422e2b56d4c0 100644 --- a/src/fixtures/vislib/mock_data/histogram/_columns.js +++ b/src/fixtures/vislib/mock_data/histogram/_columns.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'columns': [ { 'label': '404: response', diff --git a/src/fixtures/vislib/mock_data/histogram/_rows.js b/src/fixtures/vislib/mock_data/histogram/_rows.js index b6e5d4092491..8a9a08db2c29 100644 --- a/src/fixtures/vislib/mock_data/histogram/_rows.js +++ b/src/fixtures/vislib/mock_data/histogram/_rows.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'rows': [ { 'label': '404: response', diff --git a/src/fixtures/vislib/mock_data/histogram/_series.js b/src/fixtures/vislib/mock_data/histogram/_series.js index d4c735420512..90995a00a11e 100644 --- a/src/fixtures/vislib/mock_data/histogram/_series.js +++ b/src/fixtures/vislib/mock_data/histogram/_series.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'label': '', 'xAxisLabel': 'machine.ram', 'ordered': { diff --git a/src/fixtures/vislib/mock_data/histogram/_slices.js b/src/fixtures/vislib/mock_data/histogram/_slices.js index 149d55b31347..c47155840cec 100644 --- a/src/fixtures/vislib/mock_data/histogram/_slices.js +++ b/src/fixtures/vislib/mock_data/histogram/_slices.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'label': '', 'slices': { 'children': [ diff --git a/src/fixtures/vislib/mock_data/not_enough_data/_one_point.js b/src/fixtures/vislib/mock_data/not_enough_data/_one_point.js index 9cc636807a87..45b6c0e72f48 100644 --- a/src/fixtures/vislib/mock_data/not_enough_data/_one_point.js +++ b/src/fixtures/vislib/mock_data/not_enough_data/_one_point.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'label': '', 'xAxisLabel': '', 'yAxisLabel': 'Count of documents', diff --git a/src/fixtures/vislib/mock_data/range/_columns.js b/src/fixtures/vislib/mock_data/range/_columns.js index 5d22e45c09b1..d75f80d8fcec 100644 --- a/src/fixtures/vislib/mock_data/range/_columns.js +++ b/src/fixtures/vislib/mock_data/range/_columns.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'columns': [ { 'label': 'apache: _type', diff --git a/src/fixtures/vislib/mock_data/range/_rows.js b/src/fixtures/vislib/mock_data/range/_rows.js index d633c3aa611c..35a938851b13 100644 --- a/src/fixtures/vislib/mock_data/range/_rows.js +++ b/src/fixtures/vislib/mock_data/range/_rows.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'rows': [ { 'label': 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1: agent.raw', diff --git a/src/fixtures/vislib/mock_data/range/_series.js b/src/fixtures/vislib/mock_data/range/_series.js index 786203bb8298..34454bbb2020 100644 --- a/src/fixtures/vislib/mock_data/range/_series.js +++ b/src/fixtures/vislib/mock_data/range/_series.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'label': '', 'xAxisLabel': 'bytes ranges', 'yAxisLabel': 'Count of documents', diff --git a/src/fixtures/vislib/mock_data/significant_terms/_columns.js b/src/fixtures/vislib/mock_data/significant_terms/_columns.js index 3f9d8cfec189..feae108fb558 100644 --- a/src/fixtures/vislib/mock_data/significant_terms/_columns.js +++ b/src/fixtures/vislib/mock_data/significant_terms/_columns.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'columns': [ { 'label': 'http: links', diff --git a/src/fixtures/vislib/mock_data/significant_terms/_rows.js b/src/fixtures/vislib/mock_data/significant_terms/_rows.js index 7722ef7806e3..43c0ec2f0d48 100644 --- a/src/fixtures/vislib/mock_data/significant_terms/_rows.js +++ b/src/fixtures/vislib/mock_data/significant_terms/_rows.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'rows': [ { 'label': 'h3: headings', diff --git a/src/fixtures/vislib/mock_data/significant_terms/_series.js b/src/fixtures/vislib/mock_data/significant_terms/_series.js index 34c65548e2c7..3691d854c6c2 100644 --- a/src/fixtures/vislib/mock_data/significant_terms/_series.js +++ b/src/fixtures/vislib/mock_data/significant_terms/_series.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'label': '', 'xAxisLabel': 'Top 5 unusual terms in @tags', 'yAxisLabel': 'Count of documents', diff --git a/src/fixtures/vislib/mock_data/stacked/_stacked.js b/src/fixtures/vislib/mock_data/stacked/_stacked.js index 99f72f3bff02..37410f393b3a 100644 --- a/src/fixtures/vislib/mock_data/stacked/_stacked.js +++ b/src/fixtures/vislib/mock_data/stacked/_stacked.js @@ -1,6 +1,6 @@ import moment from 'moment'; -module.exports = { +export default { 'label': '', 'xAxisLabel': '@timestamp per 30 sec', 'ordered': { diff --git a/src/fixtures/vislib/mock_data/terms/_columns.js b/src/fixtures/vislib/mock_data/terms/_columns.js index 24ddee82812d..fdcaf9987351 100644 --- a/src/fixtures/vislib/mock_data/terms/_columns.js +++ b/src/fixtures/vislib/mock_data/terms/_columns.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'columns': [ { 'label': 'logstash: index', diff --git a/src/fixtures/vislib/mock_data/terms/_rows.js b/src/fixtures/vislib/mock_data/terms/_rows.js index fd5f68ef2c18..7564258ddee8 100644 --- a/src/fixtures/vislib/mock_data/terms/_rows.js +++ b/src/fixtures/vislib/mock_data/terms/_rows.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'rows': [ { 'label': '0.0-1000.0: bytes', diff --git a/src/fixtures/vislib/mock_data/terms/_series.js b/src/fixtures/vislib/mock_data/terms/_series.js index f2133113f231..90db8af86fa5 100644 --- a/src/fixtures/vislib/mock_data/terms/_series.js +++ b/src/fixtures/vislib/mock_data/terms/_series.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'label': '', 'xAxisLabel': 'Top 5 extension', 'yAxisLabel': 'Count of documents', diff --git a/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js b/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js index 64b9d0e45240..d2b286476034 100644 --- a/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js +++ b/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = { +export default { 'yAxisLabel': 'Count', 'zAxisLabel': 'machine.os.raw: Descending', 'yScale': null, diff --git a/src/optimize/base_optimizer.js b/src/optimize/base_optimizer.js index b54507807b9e..2b49de2aa66c 100644 --- a/src/optimize/base_optimizer.js +++ b/src/optimize/base_optimizer.js @@ -17,7 +17,7 @@ import { setLoaderQueryParam, makeLoaderString } from './loaders'; const babelExclude = [/[\/\\](webpackShims|node_modules|bower_components)[\/\\]/]; -class BaseOptimizer { +export default class BaseOptimizer { constructor(opts) { this.env = opts.env; this.urlBasePath = opts.urlBasePath; @@ -228,5 +228,3 @@ class BaseOptimizer { ); } } - -module.exports = BaseOptimizer; diff --git a/src/optimize/fs_optimizer.js b/src/optimize/fs_optimizer.js index 7251e9ba17e2..82000d515748 100644 --- a/src/optimize/fs_optimizer.js +++ b/src/optimize/fs_optimizer.js @@ -1,8 +1,7 @@ - import BaseOptimizer from './base_optimizer'; import { fromNode } from 'bluebird'; -module.exports = class FsOptimizer extends BaseOptimizer { +export default class FsOptimizer extends BaseOptimizer { async init() { await this.initCompiler(); } @@ -23,4 +22,4 @@ module.exports = class FsOptimizer extends BaseOptimizer { }); }); } -}; +} diff --git a/src/optimize/index.js b/src/optimize/index.js index fa0028ffe420..a9148c920196 100644 --- a/src/optimize/index.js +++ b/src/optimize/index.js @@ -1,5 +1,6 @@ import FsOptimizer from './fs_optimizer'; -module.exports = async (kbnServer, server, config) => { + +export default async (kbnServer, server, config) => { if (!config.get('optimize.enabled')) return; // the lazy optimizer sets up two threads, one is the server listening diff --git a/src/optimize/lazy/lazy.js b/src/optimize/lazy/lazy.js index 3ff2842ac0c6..46d27084f20b 100644 --- a/src/optimize/lazy/lazy.js +++ b/src/optimize/lazy/lazy.js @@ -1,5 +1,6 @@ import { isWorker } from 'cluster'; -module.exports = async kbnServer => { + +export default async kbnServer => { if (!isWorker) { diff --git a/src/optimize/lazy/lazy_optimizer.js b/src/optimize/lazy/lazy_optimizer.js index f3ba92935bcc..7790abfbc308 100644 --- a/src/optimize/lazy/lazy_optimizer.js +++ b/src/optimize/lazy/lazy_optimizer.js @@ -3,7 +3,7 @@ import WeirdControlFlow from './weird_control_flow'; import { once } from 'lodash'; import { join } from 'path'; -module.exports = class LazyOptimizer extends BaseOptimizer { +export default class LazyOptimizer extends BaseOptimizer { constructor(opts) { super(opts); this.log = opts.log || (() => null); @@ -112,4 +112,4 @@ module.exports = class LazyOptimizer extends BaseOptimizer { err: err }); } -}; +} diff --git a/src/optimize/lazy/lazy_server.js b/src/optimize/lazy/lazy_server.js index 0061cdb6597d..a78559647736 100644 --- a/src/optimize/lazy/lazy_server.js +++ b/src/optimize/lazy/lazy_server.js @@ -3,7 +3,7 @@ import { Server } from 'hapi'; import { fromNode } from 'bluebird'; import registerHapiPlugins from '../../server/http/register_hapi_plugins'; -module.exports = class LazyServer { +export default class LazyServer { constructor(host, port, optimizer) { this.optimizer = optimizer; this.server = new Server(); @@ -21,4 +21,4 @@ module.exports = class LazyServer { this.optimizer.bindToServer(this.server); await fromNode(cb => this.server.start(cb)); } -}; +} diff --git a/src/optimize/lazy/proxy_role.js b/src/optimize/lazy/proxy_role.js index 09c3848cf769..32d0a7eaeaef 100644 --- a/src/optimize/lazy/proxy_role.js +++ b/src/optimize/lazy/proxy_role.js @@ -1,7 +1,7 @@ import { fromNode } from 'bluebird'; import { get, once } from 'lodash'; -module.exports = (kbnServer, server, config) => { +export default (kbnServer, server, config) => { server.route({ path: '/bundles/{path*}', diff --git a/src/optimize/lazy/weird_control_flow.js b/src/optimize/lazy/weird_control_flow.js index 335c87a38733..f5d3d31bde2e 100644 --- a/src/optimize/lazy/weird_control_flow.js +++ b/src/optimize/lazy/weird_control_flow.js @@ -1,7 +1,7 @@ import { fromNode } from 'bluebird'; -module.exports = class WeirdControlFlow { +export default class WeirdControlFlow { constructor() { this.handlers = []; } @@ -55,4 +55,4 @@ module.exports = class WeirdControlFlow { fn.apply(null, args); } } -}; +} diff --git a/src/server/config/config.js b/src/server/config/config.js index 30d9cf9e7a81..656f32f41d49 100644 --- a/src/server/config/config.js +++ b/src/server/config/config.js @@ -9,7 +9,7 @@ const schema = Symbol('Joi Schema'); const schemaExts = Symbol('Schema Extensions'); const vals = Symbol('config values'); -module.exports = class Config { +export default class Config { static withDefaultSchema(settings = {}) { return new Config(createDefaultSchema(), settings); } @@ -175,4 +175,4 @@ module.exports = class Config { return this[schema]; } -}; +} diff --git a/src/server/config/explode_by.js b/src/server/config/explode_by.js index a2e632ddf2a6..9b54b57578d9 100644 --- a/src/server/config/explode_by.js +++ b/src/server/config/explode_by.js @@ -1,5 +1,6 @@ import _ from 'lodash'; -module.exports = function (dot, flatObject) { + +export default function (dot, flatObject) { const fullObject = {}; _.each(flatObject, function (value, key) { const keys = key.split(dot); @@ -14,6 +15,6 @@ module.exports = function (dot, flatObject) { }(fullObject, keys, value)); }); return fullObject; -}; +} diff --git a/src/server/config/flatten_with.js b/src/server/config/flatten_with.js index ede084f56a3f..2df9fd2f5c05 100644 --- a/src/server/config/flatten_with.js +++ b/src/server/config/flatten_with.js @@ -1,5 +1,6 @@ import _ from 'lodash'; -module.exports = function (dot, nestedObj, flattenArrays) { + +export default function (dot, nestedObj, flattenArrays) { const stack = []; // track key stack const flatObj = {}; (function flattenObj(obj) { @@ -12,6 +13,6 @@ module.exports = function (dot, nestedObj, flattenArrays) { }); }(nestedObj)); return flatObj; -}; +} diff --git a/src/server/config/override.js b/src/server/config/override.js index 3354fd5956fe..e4845d752392 100644 --- a/src/server/config/override.js +++ b/src/server/config/override.js @@ -2,10 +2,10 @@ import _ from 'lodash'; import flattenWith from './flatten_with'; import explodeBy from './explode_by'; -module.exports = function (target, source) { +export default function (target, source) { const _target = flattenWith('.', target); const _source = flattenWith('.', source); return explodeBy('.', _.defaults(_source, _target)); -}; +} diff --git a/src/server/config/schema.js b/src/server/config/schema.js index 2b06e77fc328..4aeb182dd273 100644 --- a/src/server/config/schema.js +++ b/src/server/config/schema.js @@ -5,7 +5,7 @@ import os from 'os'; import { fromRoot } from '../../utils'; import { getData } from '../path'; -module.exports = () => Joi.object({ +export default () => Joi.object({ pkg: Joi.object({ version: Joi.string().default(Joi.ref('$version')), branch: Joi.string().default(Joi.ref('$branch')), diff --git a/src/server/config/setup.js b/src/server/config/setup.js index c49ef03681a4..bcdca730386a 100644 --- a/src/server/config/setup.js +++ b/src/server/config/setup.js @@ -1,7 +1,7 @@ import Config from './config'; import { transformDeprecations } from './transform_deprecations'; -module.exports = function (kbnServer) { +export default function (kbnServer) { const settings = transformDeprecations(kbnServer.settings); kbnServer.config = Config.withDefaultSchema(settings); -}; +} diff --git a/src/server/http/get_default_route.js b/src/server/http/get_default_route.js index afdcbc9a44eb..2af01b59ae3c 100644 --- a/src/server/http/get_default_route.js +++ b/src/server/http/get_default_route.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = _.once(function (kbnServer) { +export default _.once(function (kbnServer) { const { config } = kbnServer; diff --git a/src/server/http/index.js b/src/server/http/index.js index 5564bb4ed6d5..6380c0beef33 100644 --- a/src/server/http/index.js +++ b/src/server/http/index.js @@ -12,7 +12,7 @@ import setupConnectionMixin from './setup_connection'; import registerHapiPluginsMixin from './register_hapi_plugins'; import xsrfMixin from './xsrf'; -module.exports = async function (kbnServer, server, config) { +export default async function (kbnServer, server, config) { server = kbnServer.server = new Hapi.Server(); const shortUrlLookup = shortUrlLookupProvider(server); diff --git a/src/server/kbn_server.js b/src/server/kbn_server.js index 85471c28827d..8cb27e408bd4 100644 --- a/src/server/kbn_server.js +++ b/src/server/kbn_server.js @@ -24,7 +24,7 @@ import { savedObjectsMixin } from './saved_objects'; const rootDir = fromRoot('.'); -module.exports = class KbnServer { +export default class KbnServer { constructor(settings) { this.name = pkg.name; this.version = pkg.version; @@ -151,4 +151,4 @@ module.exports = class KbnServer { this.server.log(['info', 'config'], 'New logging configuration:\n' + plain); this.server.plugins['even-better'].monitor.reconfigure(loggingOptions); } -}; +} diff --git a/src/server/logging/apply_filters_to_keys.js b/src/server/logging/apply_filters_to_keys.js index 19dc6e5d154d..1f2b53f0c718 100644 --- a/src/server/logging/apply_filters_to_keys.js +++ b/src/server/logging/apply_filters_to_keys.js @@ -35,8 +35,8 @@ function apply(obj, key, action) { return obj; } -module.exports = function (obj, actionsByKey) { +export default function (obj, actionsByKey) { return Object.keys(actionsByKey).reduce((output, key) => { return apply(output, key, actionsByKey[key]); }, toPojo(obj)); -}; +} diff --git a/src/server/logging/log_format.js b/src/server/logging/log_format.js index 7a077ecdd5c2..4ff690462723 100644 --- a/src/server/logging/log_format.js +++ b/src/server/logging/log_format.js @@ -26,7 +26,7 @@ const levelColor = function (code) { }; -module.exports = class TransformObjStream extends Stream.Transform { +export default class TransformObjStream extends Stream.Transform { constructor(config) { super({ readableObjectMode: false, @@ -137,4 +137,4 @@ module.exports = class TransformObjStream extends Stream.Transform { } return data; } -}; +} diff --git a/src/server/logging/log_format_json.js b/src/server/logging/log_format_json.js index 440982bbd3ea..a94a463912e4 100644 --- a/src/server/logging/log_format_json.js +++ b/src/server/logging/log_format_json.js @@ -5,9 +5,9 @@ const stripColors = function (string) { return string.replace(/\u001b[^m]+m/g, ''); }; -module.exports = class KbnLoggerJsonFormat extends LogFormat { +export default class KbnLoggerJsonFormat extends LogFormat { format(data) { data.message = stripColors(data.message); return stringify(data); } -}; +} diff --git a/src/server/logging/log_format_string.js b/src/server/logging/log_format_string.js index ab8154995702..873f77a91089 100644 --- a/src/server/logging/log_format_string.js +++ b/src/server/logging/log_format_string.js @@ -44,7 +44,7 @@ const type = _.memoize(function (t) { const workerType = process.env.kbnWorkerType ? `${type(process.env.kbnWorkerType)} ` : ''; -module.exports = class KbnLoggerJsonFormat extends LogFormat { +export default class KbnLoggerJsonFormat extends LogFormat { format(data) { const time = color('time')(moment(data.timestamp).utc().format('HH:mm:ss.SSS')); const msg = data.error ? color('error')(data.error.stack) : color('message')(data.message); @@ -61,4 +61,4 @@ module.exports = class KbnLoggerJsonFormat extends LogFormat { return `${workerType}${type(data.type)} [${time}] ${tags} ${msg}`; } -}; +} diff --git a/src/server/logging/log_reporter.js b/src/server/logging/log_reporter.js index b5e25b5f5cf6..c730385f5308 100644 --- a/src/server/logging/log_reporter.js +++ b/src/server/logging/log_reporter.js @@ -5,7 +5,7 @@ import LogFormatJson from './log_format_json'; import LogFormatString from './log_format_string'; import { LogInterceptor } from './log_interceptor'; -module.exports = class KbnLogger { +export default class KbnLogger { constructor(events, config) { this.squeeze = new Squeeze(events); this.format = config.json ? new LogFormatJson(config) : new LogFormatString(config); @@ -36,4 +36,4 @@ module.exports = class KbnLogger { callback(); } -}; +} diff --git a/src/server/pid/index.js b/src/server/pid/index.js index d1e1610679d6..07787763ea9b 100644 --- a/src/server/pid/index.js +++ b/src/server/pid/index.js @@ -4,7 +4,7 @@ import Promise from 'bluebird'; import { unlinkSync as unlink } from 'fs'; const writeFile = Promise.promisify(require('fs').writeFile); -module.exports = Promise.method(function (kbnServer, server, config) { +export default Promise.method(function (kbnServer, server, config) { const path = config.get('pid.file'); if (!path) return; diff --git a/src/server/plugins/initialize.js b/src/server/plugins/initialize.js index 262c2a9d0b6d..34d6c263b667 100644 --- a/src/server/plugins/initialize.js +++ b/src/server/plugins/initialize.js @@ -1,6 +1,6 @@ import pluginInit from './plugin_init'; -module.exports = async function (kbnServer, server, config) { +export default async function (kbnServer, server, config) { if (!config.get('plugins.initialize')) { server.log(['info'], 'Plugin initialization disabled.'); diff --git a/src/server/plugins/plugin.js b/src/server/plugins/plugin.js index 48c30aa491ee..699e461f9b25 100644 --- a/src/server/plugins/plugin.js +++ b/src/server/plugins/plugin.js @@ -48,7 +48,7 @@ const defaultConfigSchema = Joi.object({ * the root of the plugin. Set this to false to disable exposure of a * public directory */ -module.exports = class Plugin { +export default class Plugin { constructor(kbnServer, path, pkg, opts) { this.kbnServer = kbnServer; this.pkg = pkg; @@ -172,4 +172,4 @@ module.exports = class Plugin { toString() { return `${this.id}@${this.version}`; } -}; +} diff --git a/src/server/plugins/plugin_api.js b/src/server/plugins/plugin_api.js index 7883004ac2a3..53e747d77518 100644 --- a/src/server/plugins/plugin_api.js +++ b/src/server/plugins/plugin_api.js @@ -1,7 +1,7 @@ import Plugin from './plugin'; import { join } from 'path'; -module.exports = class PluginApi { +export default class PluginApi { constructor(kibana, pluginPath) { this.config = kibana.config; this.rootDir = kibana.rootDir; @@ -27,4 +27,4 @@ module.exports = class PluginApi { require: [] }; } -}; +} diff --git a/src/server/plugins/plugin_collection.js b/src/server/plugins/plugin_collection.js index 79b99d54e042..dd7d1afd4ead 100644 --- a/src/server/plugins/plugin_collection.js +++ b/src/server/plugins/plugin_collection.js @@ -33,7 +33,7 @@ function disablePluginConfig(pluginCollection, plugin) { config.extendSchema(schema, { enabled: false }, plugin.configPrefix); } -module.exports = class Plugins extends Collection { +export default class Plugins extends Collection { constructor(kbnServer) { super(); @@ -75,4 +75,4 @@ module.exports = class Plugins extends Collection { return this[pluginApis]; } -}; +} diff --git a/src/server/plugins/scan.js b/src/server/plugins/scan.js index 4ac6b3e5563f..2ea9d81889b3 100644 --- a/src/server/plugins/scan.js +++ b/src/server/plugins/scan.js @@ -4,7 +4,8 @@ import { readdir, stat } from 'fs'; import { resolve } from 'path'; import { each } from 'bluebird'; import PluginCollection from './plugin_collection'; -module.exports = async (kbnServer, server, config) => { + +export default async (kbnServer, server, config) => { const plugins = kbnServer.plugins = new PluginCollection(kbnServer); diff --git a/src/server/status/__tests__/server_status.js b/src/server/status/__tests__/server_status.js index aea1babffb6c..f0f84e686572 100644 --- a/src/server/status/__tests__/server_status.js +++ b/src/server/status/__tests__/server_status.js @@ -2,7 +2,7 @@ import { find } from 'lodash'; import expect from 'expect.js'; import sinon from 'sinon'; -import states from '../states'; +import * as states from '../states'; import Status from '../status'; import ServerStatus from '../server_status'; diff --git a/src/server/status/samples.js b/src/server/status/samples.js index 20164c07b783..749261299515 100644 --- a/src/server/status/samples.js +++ b/src/server/status/samples.js @@ -23,4 +23,4 @@ Samples.prototype.toJSON = function () { return this.vals; }; -module.exports = Samples; +export default Samples; diff --git a/src/server/status/server_status.js b/src/server/status/server_status.js index d89af280a57e..91027ca8863a 100644 --- a/src/server/status/server_status.js +++ b/src/server/status/server_status.js @@ -1,10 +1,10 @@ import _ from 'lodash'; -import states from './states'; +import * as states from './states'; import Status from './status'; import { version } from '../../../package.json'; -module.exports = class ServerStatus { +export default class ServerStatus { constructor(server) { this.server = server; this._created = {}; @@ -93,4 +93,4 @@ module.exports = class ServerStatus { statuses: _.values(this._created) }; } -}; +} diff --git a/src/server/status/states.js b/src/server/status/states.js index 433faaf3c472..bed60a0272d2 100644 --- a/src/server/status/states.js +++ b/src/server/status/states.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -exports.all = [ +export const all = [ { id: 'red', title: 'Red', @@ -50,13 +50,13 @@ exports.all = [ } ]; -exports.allById = _.indexBy(exports.all, 'id'); +export const allById = _.indexBy(exports.all, 'id'); -exports.defaults = { +export const defaults = { icon: 'question', severity: Infinity }; -exports.get = function (id) { +export function get(id) { return exports.allById[id] || _.defaults({ id: id }, exports.defaults); -}; +} diff --git a/src/server/status/status.js b/src/server/status/status.js index b876c42a9e9a..51eda434a2b5 100644 --- a/src/server/status/status.js +++ b/src/server/status/status.js @@ -1,7 +1,7 @@ -import states from './states'; +import * as states from './states'; import { EventEmitter } from 'events'; -class Status extends EventEmitter { +export default class Status extends EventEmitter { constructor(id, server) { super(); @@ -85,5 +85,3 @@ states.all.forEach(function (state) { this.emit('change', previous, previousMsg, this.state, this.message); }; }); - -module.exports = Status; diff --git a/src/test_utils/get_url.js b/src/test_utils/get_url.js index 5939f4fe8a74..b7f9d12391bf 100644 --- a/src/test_utils/get_url.js +++ b/src/test_utils/get_url.js @@ -20,9 +20,7 @@ import url from 'url'; * @return {string} */ -module.exports = getUrl; - -function getUrl(config, app) { +export default function getUrl(config, app) { return url.format(_.assign({}, config, app)); } diff --git a/src/test_utils/public/no_digest_promises.js b/src/test_utils/public/no_digest_promises.js index 457c2fb426dd..59b63cde41ac 100644 --- a/src/test_utils/public/no_digest_promises.js +++ b/src/test_utils/public/no_digest_promises.js @@ -29,7 +29,7 @@ uiModules function activate() { active = true; } function deactivate() { active = false; } -module.exports = { +export default { activate: activate, deactivate: deactivate, activateForSuite: function () { diff --git a/src/ui/__tests__/fixtures/test_app/index.js b/src/ui/__tests__/fixtures/test_app/index.js index 4f5115faff15..05db665baaf2 100644 --- a/src/ui/__tests__/fixtures/test_app/index.js +++ b/src/ui/__tests__/fixtures/test_app/index.js @@ -1,4 +1,4 @@ -module.exports = kibana => new kibana.Plugin({ +export default kibana => new kibana.Plugin({ uiExports: { app: { name: 'test_app', diff --git a/src/ui/app_entry_template.js b/src/ui/app_entry_template.js index 2c7cc82cb9dc..2cd55ffdb4d8 100644 --- a/src/ui/app_entry_template.js +++ b/src/ui/app_entry_template.js @@ -1,4 +1,4 @@ -module.exports = function ({ env, bundle }) { +export default function ({ env, bundle }) { const pluginSlug = env.pluginInfo.sort() .map(p => ' * - ' + p) @@ -26,4 +26,4 @@ require('ui/chrome').bootstrap(/* xoxo */); `; -}; +} diff --git a/src/ui/public/agg_response/hierarchical/_collect_branch.js b/src/ui/public/agg_response/hierarchical/_collect_branch.js index 3e0ac05c65bf..306fd9387e93 100644 --- a/src/ui/public/agg_response/hierarchical/_collect_branch.js +++ b/src/ui/public/agg_response/hierarchical/_collect_branch.js @@ -1,37 +1,36 @@ -define(function () { - return function (leaf) { - // walk up the branch for each parent - function walk(item, memo) { - // record the the depth - const depth = item.depth - 1; +// eslint-disable-next-line kibana-custom/no-default-export +export default function (leaf) { + // walk up the branch for each parent + function walk(item, memo) { + // record the the depth + const depth = item.depth - 1; - // Using the aggConfig determine what the field name is. If the aggConfig - // doesn't exist (which means it's an _all agg) then use the level for - // the field name - const { aggConfig } = item; - const field = (aggConfig && aggConfig.makeLabel()) - || (aggConfig && aggConfig.label) - || ('level ' + item.depth); + // Using the aggConfig determine what the field name is. If the aggConfig + // doesn't exist (which means it's an _all agg) then use the level for + // the field name + const { aggConfig } = item; + const field = (aggConfig && aggConfig.makeLabel()) + || (aggConfig && aggConfig.label) + || ('level ' + item.depth); - // Add the row to the tooltipScope.rows - memo.unshift({ - aggConfig, - depth: depth, - field: field, - bucket: item.name, - metric: item.size, - item: item - }); + // Add the row to the tooltipScope.rows + memo.unshift({ + aggConfig, + depth: depth, + field: field, + bucket: item.name, + metric: item.size, + item: item + }); - // If the item has a parent and it's also a child then continue walking - // up the branch - if (item.parent && item.parent.parent) { - return walk(item.parent, memo); - } else { - return memo; - } + // If the item has a parent and it's also a child then continue walking + // up the branch + if (item.parent && item.parent.parent) { + return walk(item.parent, memo); + } else { + return memo; } + } - return walk(leaf, []); - }; -}); + return walk(leaf, []); +} diff --git a/src/ui/public/agg_types/__tests__/agg_param_writer.js b/src/ui/public/agg_types/__tests__/agg_param_writer.js index 79b8849415f0..ea46c558fd3e 100644 --- a/src/ui/public/agg_types/__tests__/agg_param_writer.js +++ b/src/ui/public/agg_types/__tests__/agg_param_writer.js @@ -3,7 +3,9 @@ import { VisProvider } from 'ui/vis'; import { AggTypesIndexProvider } from 'ui/agg_types/index'; import { VisTypesRegistryProvider } from 'ui/registry/vis_types'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; -module.exports = function AggParamWriterHelper(Private) { + +// eslint-disable-next-line kibana-custom/no-default-export +export default function AggParamWriterHelper(Private) { const Vis = Private(VisProvider); const aggTypes = Private(AggTypesIndexProvider); const visTypes = Private(VisTypesRegistryProvider); @@ -105,4 +107,4 @@ module.exports = function AggParamWriterHelper(Private) { return AggParamWriter; -}; +} diff --git a/src/ui/public/agg_types/__tests__/param_types/_raw_json.js b/src/ui/public/agg_types/__tests__/param_types/_raw_json.js index 972c913d857b..0077cca0820f 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_raw_json.js +++ b/src/ui/public/agg_types/__tests__/param_types/_raw_json.js @@ -4,7 +4,8 @@ import ngMock from 'ng_mock'; import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base'; import { AggTypesParamTypesRawJsonProvider } from 'ui/agg_types/param_types/raw_json'; -module.exports = describe('JSON', function () { +// eslint-disable-next-line kibana-custom/no-default-export +export default describe('JSON', function () { const paramName = 'json_test'; let BaseAggParam; let JsonAggParam; diff --git a/src/ui/public/agg_types/__tests__/param_types/_string.js b/src/ui/public/agg_types/__tests__/param_types/_string.js index 5f4b0b48bfa0..74c30eea68e4 100644 --- a/src/ui/public/agg_types/__tests__/param_types/_string.js +++ b/src/ui/public/agg_types/__tests__/param_types/_string.js @@ -4,7 +4,8 @@ import ngMock from 'ng_mock'; import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base'; import { AggTypesParamTypesStringProvider } from 'ui/agg_types/param_types/string'; -module.exports = describe('String', function () { +// eslint-disable-next-line kibana-custom/no-default-export +export default describe('String', function () { const paramName = 'json_test'; let BaseAggParam; let StringAggParam; diff --git a/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js b/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js index c4034c5f6fb0..1bbd1bf58aa1 100644 --- a/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js +++ b/src/ui/public/agg_types/__tests__/utils/_stub_agg_params.js @@ -26,7 +26,8 @@ function ParamClassStub(parent, body) { * @param {PrivateLoader} Private - The private module loader, inject by passing this function to ngMock.inject() * @return {undefined} */ -module.exports = function stubParamClasses(Private) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function stubParamClasses(Private) { const BaseAggParam = Private.stub( AggTypesParamTypesBaseProvider, new ParamClassStub(null, function (config) { @@ -43,4 +44,4 @@ module.exports = function stubParamClasses(Private) { AggTypesParamTypesOptionedProvider, new ParamClassStub(BaseAggParam) ); -}; +} diff --git a/src/ui/public/chrome/api/apps.js b/src/ui/public/chrome/api/apps.js index 72f461166818..42c532b2d4e9 100644 --- a/src/ui/public/chrome/api/apps.js +++ b/src/ui/public/chrome/api/apps.js @@ -1,7 +1,8 @@ import { clone, get } from 'lodash'; import { resolve } from 'url'; -module.exports = function (chrome, internals) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function (chrome, internals) { if (get(internals, 'app.navLink.url')) { internals.app.navLink.url = resolve(window.location.href, internals.app.navLink.url); @@ -61,4 +62,4 @@ module.exports = function (chrome, internals) { chrome.setLastUrlFor = function (appId, url) { internals.appUrlStore.setItem(`appLastUrl:${appId}`, url); }; -}; +} diff --git a/src/ui/public/chrome/api/controls.js b/src/ui/public/chrome/api/controls.js index 93408b9c682d..771a995474a4 100644 --- a/src/ui/public/chrome/api/controls.js +++ b/src/ui/public/chrome/api/controls.js @@ -1,6 +1,7 @@ import _ from 'lodash'; -module.exports = function (chrome, internals) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function (chrome, internals) { /** * ui/chrome Controls API * @@ -29,4 +30,4 @@ module.exports = function (chrome, internals) { if (_.isUndefined(internals.visible)) return def; return internals.visible; }; -}; +} diff --git a/src/ui/public/chrome/api/template.js b/src/ui/public/chrome/api/template.js index 762207897282..11374ccc82da 100644 --- a/src/ui/public/chrome/api/template.js +++ b/src/ui/public/chrome/api/template.js @@ -1,4 +1,5 @@ -module.exports = function (chrome, internals) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function (chrome, internals) { /** * ui/chrome Template API @@ -55,4 +56,4 @@ module.exports = function (chrome, internals) { }; -}; +} diff --git a/src/ui/public/chrome/api/theme.js b/src/ui/public/chrome/api/theme.js index f2fee099ad01..304b428a21cd 100644 --- a/src/ui/public/chrome/api/theme.js +++ b/src/ui/public/chrome/api/theme.js @@ -1,6 +1,7 @@ import _ from 'lodash'; -module.exports = function (chrome, internals) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function (chrome, internals) { /** * ui/chrome Theme API * @@ -97,4 +98,4 @@ module.exports = function (chrome, internals) { return internals.applicationClasses.join(' '); }; -}; +} diff --git a/src/ui/public/chrome/api/translations.js b/src/ui/public/chrome/api/translations.js index 6d8455fa84c3..6fe287bfde04 100644 --- a/src/ui/public/chrome/api/translations.js +++ b/src/ui/public/chrome/api/translations.js @@ -1,4 +1,5 @@ -module.exports = function (chrome, internals) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function (chrome, internals) { /** * ui/chrome Translations API * @@ -12,4 +13,4 @@ module.exports = function (chrome, internals) { chrome.getTranslations = function () { return internals.translations || []; }; -}; +} diff --git a/src/ui/public/chrome/chrome.js b/src/ui/public/chrome/chrome.js index 4ccd21702103..eb7b29502095 100644 --- a/src/ui/public/chrome/chrome.js +++ b/src/ui/public/chrome/chrome.js @@ -51,4 +51,5 @@ chrome.bootstrap = function () { angular.bootstrap(document, ['kibana']); }; -module.exports = chrome; +// eslint-disable-next-line kibana-custom/no-default-export +export default chrome; diff --git a/src/ui/public/error_url_overflow/error_url_overflow.js b/src/ui/public/error_url_overflow/error_url_overflow.js index cd4d37b33c84..45985315cdf3 100644 --- a/src/ui/public/error_url_overflow/error_url_overflow.js +++ b/src/ui/public/error_url_overflow/error_url_overflow.js @@ -1,5 +1,5 @@ import uiRoutes from 'ui/routes'; -import KbnUrlProvider from 'ui/url'; +import { KbnUrlProvider } from 'ui/url'; import './error_url_overflow.less'; import template from './error_url_overflow.html'; diff --git a/src/ui/public/jquery/find_test_subject.js b/src/ui/public/jquery/find_test_subject.js index cc047e384cb1..751c8499255e 100644 --- a/src/ui/public/jquery/find_test_subject.js +++ b/src/ui/public/jquery/find_test_subject.js @@ -1,6 +1,7 @@ import testSubjSelector from '@spalger/test-subj-selector'; -module.exports = function bindToJquery($) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function bindToJquery($) { /** * Find elements with the `data-test-subj` attribute by the terms in that attribute. @@ -54,4 +55,4 @@ module.exports = function bindToJquery($) { return $els; } -}; +} diff --git a/src/ui/public/modules.js b/src/ui/public/modules.js index 0af6941d8490..d234d37f5c2d 100644 --- a/src/ui/public/modules.js +++ b/src/ui/public/modules.js @@ -121,4 +121,3 @@ export function close(moduleName) { } export const uiModules = { link, get, close }; - diff --git a/src/ui/public/private/private.js b/src/ui/public/private/private.js index e4f2660866c7..9babdc4b3100 100644 --- a/src/ui/public/private/private.js +++ b/src/ui/public/private/private.js @@ -10,40 +10,36 @@ import { uiModules } from 'ui/modules'; * * ## Define a private module provider: * ```js - * define(function (require) { - * return function PingProvider($http) { - * this.ping = function () { - * return $http.head('/health-check'); - * }; + * export default function PingProvider($http) { + * this.ping = function () { + * return $http.head('/health-check'); * }; - * }); + * }; * ``` * * ## Require a private module: * ```js - * define(function (require) { - * return function ServerHealthProvider(Private, Promise) { - * let ping = Private(require('ui/ping')); - * return { - * check: Promise.method(function () { - * let attempts = 0; - * return (function attempt() { - * attempts += 1; - * return ping.ping() - * .catch(function (err) { - * if (attempts < 3) return attempt(); - * }) - * }()) - * .then(function () { - * return true; + * export default function ServerHealthProvider(Private, Promise) { + * let ping = Private(require('ui/ping')); + * return { + * check: Promise.method(function () { + * let attempts = 0; + * return (function attempt() { + * attempts += 1; + * return ping.ping() + * .catch(function (err) { + * if (attempts < 3) return attempt(); * }) - * .catch(function () { - * return false; - * }); + * }()) + * .then(function () { + * return true; * }) - * } - * }; - * }); + * .catch(function () { + * return false; + * }); + * }) + * } + * }; * ``` * * # `Private.stub(provider, newInstance)` diff --git a/src/ui/public/routes/routes.js b/src/ui/public/routes/routes.js index 35eb9407eb05..1d82af2ed68b 100644 --- a/src/ui/public/routes/routes.js +++ b/src/ui/public/routes/routes.js @@ -1,10 +1,11 @@ import RouteManager from './route_manager'; import 'angular-route/angular-route'; import { uiModules } from 'ui/modules'; -const defaultRouteManager = new RouteManager(); import { WAIT_FOR_URL_CHANGE_TOKEN } from './route_setup_manager'; +const defaultRouteManager = new RouteManager(); -module.exports = { +// eslint-disable-next-line kibana-custom/no-default-export +export default { ...defaultRouteManager, WAIT_FOR_URL_CHANGE_TOKEN, enable() { diff --git a/src/ui/public/stringify/__tests__/_conformance.js b/src/ui/public/stringify/__tests__/_conformance.js index f266e6edf504..564d62c2abfd 100644 --- a/src/ui/public/stringify/__tests__/_conformance.js +++ b/src/ui/public/stringify/__tests__/_conformance.js @@ -23,7 +23,8 @@ const formatIds = [ 'boolean' ]; -module.exports = describe('conformance', function () { +// eslint-disable-next-line kibana-custom/no-default-export +export default describe('conformance', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { diff --git a/src/ui/public/test_harness/test_harness.js b/src/ui/public/test_harness/test_harness.js index c604c9d5c4ad..48a4dd13025a 100644 --- a/src/ui/public/test_harness/test_harness.js +++ b/src/ui/public/test_harness/test_harness.js @@ -26,6 +26,6 @@ beforeEach(function () { }); // Kick off mocha, called at the end of test entry files -exports.bootstrap = () => { +export function bootstrap() { chrome.setupAngular(); -}; +} diff --git a/src/ui/public/url/index.js b/src/ui/public/url/index.js index 87048f12060d..d6b68299ffaa 100644 --- a/src/ui/public/url/index.js +++ b/src/ui/public/url/index.js @@ -1,2 +1,2 @@ -export { KbnUrlProvider as default } from './url'; +export { KbnUrlProvider } from './url'; export { modifyUrl } from './modify_url'; diff --git a/src/ui/public/utils/ipv4_address.js b/src/ui/public/utils/ipv4_address.js index 6c80920df64a..a62d6234a2a4 100644 --- a/src/ui/public/utils/ipv4_address.js +++ b/src/ui/public/utils/ipv4_address.js @@ -1,50 +1,47 @@ -define(function () { - const NUM_BYTES = 4; - const BYTE_SIZE = 256; - - function throwError(ipAddress) { - throw Error('Invalid IPv4 address: ' + ipAddress); - } - - function isIntegerInRange(integer, min, max) { - return !isNaN(integer) - && integer >= min - && integer < max - && integer % 1 === 0; - } - - function Ipv4Address(ipAddress) { - this.value = ipAddress; - - if (typeof ipAddress === 'string') { - this.value = 0; - - const bytes = ipAddress.split('.'); - if (bytes.length !== NUM_BYTES) throwError(ipAddress); - - for (let i = 0; i < bytes.length; i++) { - const byte = Number(bytes[i]); - if (!isIntegerInRange(byte, 0, BYTE_SIZE)) throwError(ipAddress); - this.value += Math.pow(BYTE_SIZE, NUM_BYTES - 1 - i) * byte; - } +const NUM_BYTES = 4; +const BYTE_SIZE = 256; + +function throwError(ipAddress) { + throw Error('Invalid IPv4 address: ' + ipAddress); +} + +function isIntegerInRange(integer, min, max) { + return !isNaN(integer) + && integer >= min + && integer < max + && integer % 1 === 0; +} + +// eslint-disable-next-line kibana-custom/no-default-export +export default function Ipv4Address(ipAddress) { + this.value = ipAddress; + + if (typeof ipAddress === 'string') { + this.value = 0; + + const bytes = ipAddress.split('.'); + if (bytes.length !== NUM_BYTES) throwError(ipAddress); + + for (let i = 0; i < bytes.length; i++) { + const byte = Number(bytes[i]); + if (!isIntegerInRange(byte, 0, BYTE_SIZE)) throwError(ipAddress); + this.value += Math.pow(BYTE_SIZE, NUM_BYTES - 1 - i) * byte; } - - if (!isIntegerInRange(this.value, 0, Math.pow(BYTE_SIZE, NUM_BYTES))) throwError(ipAddress); } - Ipv4Address.prototype.toString = function () { - let value = this.value; - const bytes = []; - for (let i = 0; i < NUM_BYTES; i++) { - bytes.unshift(value % 256); - value = Math.floor(value / 256); - } - return bytes.join('.'); - }; + if (!isIntegerInRange(this.value, 0, Math.pow(BYTE_SIZE, NUM_BYTES))) throwError(ipAddress); +} - Ipv4Address.prototype.valueOf = function () { - return this.value; - }; +Ipv4Address.prototype.toString = function () { + let value = this.value; + const bytes = []; + for (let i = 0; i < NUM_BYTES; i++) { + bytes.unshift(value % 256); + value = Math.floor(value / 256); + } + return bytes.join('.'); +}; - return Ipv4Address; -}); +Ipv4Address.prototype.valueOf = function () { + return this.value; +}; \ No newline at end of file diff --git a/src/ui/public/utils/mapping_setup.js b/src/ui/public/utils/mapping_setup.js index ea09aee76d0a..318ea147f416 100644 --- a/src/ui/public/utils/mapping_setup.js +++ b/src/ui/public/utils/mapping_setup.js @@ -1,110 +1,109 @@ import angular from 'angular'; import _ from 'lodash'; -define(function () { - return function MappingSetupService(kbnIndex, esAdmin) { - const mappingSetup = this; - const json = { - _serialize: function (val) { - if (val != null) return angular.toJson(val); - }, - _deserialize: function (val) { - if (val != null) return JSON.parse(val); - } - }; +// eslint-disable-next-line kibana-custom/no-default-export +export default function MappingSetupService(kbnIndex, esAdmin) { + const mappingSetup = this; - /** - * Use to create the mappings, but that should only happen one at a time - */ - const activeTypeCreations = {}; + const json = { + _serialize: function (val) { + if (val != null) return angular.toJson(val); + }, + _deserialize: function (val) { + if (val != null) return JSON.parse(val); + } + }; - /** - * Get the list of type's mapped in elasticsearch - * @return {[type]} [description] - */ - const getKnownKibanaTypes = _.once(function () { - return esAdmin.indices.getFieldMapping({ - // only concerned with types in this kibana index - index: kbnIndex, - // check all types - type: '*', - // limit the response to just the _source field for each index - fields: '_source' - }).then(function (resp) { - // kbnIndex is not sufficient here, if the kibana indexed is aliased we need to use - // the root index name as key - const index = _.keys(resp)[0]; - return _.keys(resp[index].mappings); - }); + /** + * Use to create the mappings, but that should only happen one at a time + */ + const activeTypeCreations = {}; + + /** + * Get the list of type's mapped in elasticsearch + * @return {[type]} [description] + */ + const getKnownKibanaTypes = _.once(function () { + return esAdmin.indices.getFieldMapping({ + // only concerned with types in this kibana index + index: kbnIndex, + // check all types + type: '*', + // limit the response to just the _source field for each index + fields: '_source' + }).then(function (resp) { + // kbnIndex is not sufficient here, if the kibana indexed is aliased we need to use + // the root index name as key + const index = _.keys(resp)[0]; + return _.keys(resp[index].mappings); }); + }); - mappingSetup.expandShorthand = function (sh) { - return _.mapValues(sh || {}, function (val) { - // allow shortcuts for the field types, by just setting the value - // to the type name - if (typeof val === 'string') val = { type: val }; + mappingSetup.expandShorthand = function (sh) { + return _.mapValues(sh || {}, function (val) { + // allow shortcuts for the field types, by just setting the value + // to the type name + if (typeof val === 'string') val = { type: val }; - if (val.type === 'json') { - val.type = 'text'; - val._serialize = json._serialize; - val._deserialize = json._deserialize; - } + if (val.type === 'json') { + val.type = 'text'; + val._serialize = json._serialize; + val._deserialize = json._deserialize; + } - return val; - }); - }; + return val; + }); + }; - mappingSetup.isDefined = function (type) { - return getKnownKibanaTypes() - .then(function (knownTypes) { - // if the type is in the knownTypes array already - return !!(~knownTypes.indexOf(type)); - }); - }; + mappingSetup.isDefined = function (type) { + return getKnownKibanaTypes() + .then(function (knownTypes) { + // if the type is in the knownTypes array already + return !!(~knownTypes.indexOf(type)); + }); + }; - mappingSetup.setup = function (type, mapping) { - // if there is already a creation running for this index type - if (activeTypeCreations[type]) { - // return a promise that will reexecute the setup once the - // current is complete. - return activeTypeCreations[type].then(function () { - return mappingSetup.setup(type, mapping); - }); - } + mappingSetup.setup = function (type, mapping) { + // if there is already a creation running for this index type + if (activeTypeCreations[type]) { + // return a promise that will reexecute the setup once the + // current is complete. + return activeTypeCreations[type].then(function () { + return mappingSetup.setup(type, mapping); + }); + } - const prom = getKnownKibanaTypes() - .then(function (knownTypes) { - // if the type is in the knownTypes array already - if (~knownTypes.indexOf(type)) return false; + const prom = getKnownKibanaTypes() + .then(function (knownTypes) { + // if the type is in the knownTypes array already + if (~knownTypes.indexOf(type)) return false; - // we need to create the mapping - const body = {}; - body[type] = { - properties: mapping - }; + // we need to create the mapping + const body = {}; + body[type] = { + properties: mapping + }; - return esAdmin.indices.putMapping({ - index: kbnIndex, - type: type, - body: body - }).then(function () { - // add this type to the list of knownTypes - knownTypes.push(type); + return esAdmin.indices.putMapping({ + index: kbnIndex, + type: type, + body: body + }).then(function () { + // add this type to the list of knownTypes + knownTypes.push(type); - // cast the response to "true", meaning - // the mapping exists - return true; - }); - }) - // wether this fails or not, remove it from the activeTypeCreations obj - // once complete - .finally(function () { - delete activeTypeCreations[type]; + // cast the response to "true", meaning + // the mapping exists + return true; }); + }) + // wether this fails or not, remove it from the activeTypeCreations obj + // once complete + .finally(function () { + delete activeTypeCreations[type]; + }); - activeTypeCreations[type] = prom; - return prom; - }; + activeTypeCreations[type] = prom; + return prom; }; - -}); +} diff --git a/src/ui/public/vis/agg_config_result.js b/src/ui/public/vis/agg_config_result.js index 4df97b55477c..1f4e7f4ac888 100644 --- a/src/ui/public/vis/agg_config_result.js +++ b/src/ui/public/vis/agg_config_result.js @@ -1,47 +1,44 @@ -define(function () { - let i = 0; +let i = 0; - function AggConfigResult(aggConfig, parent, value, key) { - this.key = key; - this.value = value; - this.aggConfig = aggConfig; - this.$parent = parent; - this.$order = ++i; +// eslint-disable-next-line kibana-custom/no-default-export +export default function AggConfigResult(aggConfig, parent, value, key) { + this.key = key; + this.value = value; + this.aggConfig = aggConfig; + this.$parent = parent; + this.$order = ++i; - if (aggConfig.schema.group === 'buckets') { - this.type = 'bucket'; - } else { - this.type = 'metric'; - } + if (aggConfig.schema.group === 'buckets') { + this.type = 'bucket'; + } else { + this.type = 'metric'; } +} - /** - * Returns an array of the aggConfigResult and parents up the branch - * @returns {array} Array of aggConfigResults - */ - AggConfigResult.prototype.getPath = function () { - return (function walk(result, path) { - path.unshift(result); - if (result.$parent) return walk(result.$parent, path); - return path; - }(this, [])); - }; +/** + * Returns an array of the aggConfigResult and parents up the branch + * @returns {array} Array of aggConfigResults + */ +AggConfigResult.prototype.getPath = function () { + return (function walk(result, path) { + path.unshift(result); + if (result.$parent) return walk(result.$parent, path); + return path; + }(this, [])); +}; - /** - * Returns an Elasticsearch filter that represents the result. - * @returns {object} Elasticsearch filter - */ - AggConfigResult.prototype.createFilter = function () { - return this.aggConfig.createFilter(this.key); - }; +/** + * Returns an Elasticsearch filter that represents the result. + * @returns {object} Elasticsearch filter + */ +AggConfigResult.prototype.createFilter = function () { + return this.aggConfig.createFilter(this.key); +}; - AggConfigResult.prototype.toString = function (contentType) { - return this.aggConfig.fieldFormatter(contentType)(this.value); - }; +AggConfigResult.prototype.toString = function (contentType) { + return this.aggConfig.fieldFormatter(contentType)(this.value); +}; - AggConfigResult.prototype.valueOf = function () { - return this.value; - }; - - return AggConfigResult; -}); +AggConfigResult.prototype.valueOf = function () { + return this.value; +}; diff --git a/src/ui/public/vis_maps/maps_renderbot.js b/src/ui/public/vis_maps/maps_renderbot.js index 5c7f0be79c1a..172d3f973fec 100644 --- a/src/ui/public/vis_maps/maps_renderbot.js +++ b/src/ui/public/vis_maps/maps_renderbot.js @@ -9,8 +9,8 @@ import './lib/service_settings'; import './styles/_tilemap.less'; import { ResizeCheckerProvider } from 'ui/resize_checker'; - -module.exports = function MapsRenderbotFactory(Private, $injector, serviceSettings, Notifier, courier, getAppState) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function MapsRenderbotFactory(Private, $injector, serviceSettings, Notifier, courier, getAppState) { const ResizeChecker = Private(ResizeCheckerProvider); const Renderbot = Private(VisRenderbotProvider); @@ -259,4 +259,4 @@ module.exports = function MapsRenderbotFactory(Private, $injector, serviceSettin return MapsRenderbot; -}; +} diff --git a/src/ui/public/vislib/__tests__/components/zero_injection.js b/src/ui/public/vislib/__tests__/components/zero_injection.js index 4ea6abe37818..7d19f7072ad9 100644 --- a/src/ui/public/vislib/__tests__/components/zero_injection.js +++ b/src/ui/public/vislib/__tests__/components/zero_injection.js @@ -6,7 +6,7 @@ import { VislibComponentsZeroInjectionInjectZerosProvider } from 'ui/vislib/comp import { VislibComponentsZeroInjectionOrderedXKeysProvider } from 'ui/vislib/components/zero_injection/ordered_x_keys'; import { VislibComponentsZeroInjectionUniqKeysProvider } from 'ui/vislib/components/zero_injection/uniq_keys'; import { VislibComponentsZeroInjectionFlattenDataProvider } from 'ui/vislib/components/zero_injection/flatten_data'; -import VislibComponentsZeroInjectionZeroFilledArrayProvider from 'ui/vislib/components/zero_injection/zero_filled_array'; +import { VislibComponentsZeroInjectionZeroFilledArrayProvider } from 'ui/vislib/components/zero_injection/zero_filled_array'; import { VislibComponentsZeroInjectionZeroFillDataArrayProvider } from 'ui/vislib/components/zero_injection/zero_fill_data_array'; describe('Vislib Zero Injection Module Test Suite', function () { diff --git a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js index 1f602cdb96ea..2da00208ce5f 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js +++ b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js @@ -2,10 +2,10 @@ import d3 from 'd3'; import ngMock from 'ng_mock'; import expect from 'expect.js'; import $ from 'jquery'; -import VislibLibLayoutSplitsColumnChartChartSplitProvider from 'ui/vislib/lib/layout/splits/column_chart/chart_split'; -import VislibLibLayoutSplitsColumnChartChartTitleSplitProvider from 'ui/vislib/lib/layout/splits/column_chart/chart_title_split'; -import VislibLibLayoutSplitsColumnChartXAxisSplitProvider from 'ui/vislib/lib/layout/splits/column_chart/x_axis_split'; -import VislibLibLayoutSplitsColumnChartYAxisSplitProvider from 'ui/vislib/lib/layout/splits/column_chart/y_axis_split'; +import { VislibLibLayoutSplitsColumnChartChartSplitProvider } from 'ui/vislib/lib/layout/splits/column_chart/chart_split'; +import { VislibLibLayoutSplitsColumnChartChartTitleSplitProvider } from 'ui/vislib/lib/layout/splits/column_chart/chart_title_split'; +import { VislibLibLayoutSplitsColumnChartXAxisSplitProvider } from 'ui/vislib/lib/layout/splits/column_chart/x_axis_split'; +import { VislibLibLayoutSplitsColumnChartYAxisSplitProvider } from 'ui/vislib/lib/layout/splits/column_chart/y_axis_split'; describe('Vislib Split Function Test Suite', function () { describe('Column Chart', function () { diff --git a/src/ui/public/vislib/components/labels/pie/return_pie_names.js b/src/ui/public/vislib/components/labels/pie/return_pie_names.js index bb69a9542c87..dd491d037807 100644 --- a/src/ui/public/vislib/components/labels/pie/return_pie_names.js +++ b/src/ui/public/vislib/components/labels/pie/return_pie_names.js @@ -1,19 +1,18 @@ -define(function () { - return function ReturnPieNames() { - return function returnNames(array, index, columns) { - const names = []; +// eslint-disable-next-line kibana-custom/no-default-export +export default function ReturnPieNames() { + return function returnNames(array, index, columns) { + const names = []; - array.forEach(function (obj) { - names.push({ key: obj.name, index: index }); + array.forEach(function (obj) { + names.push({ key: obj.name, index: index }); - if (obj.children) { - returnNames(obj.children, (index + 1), columns).forEach(function (namedObj) { - names.push(namedObj); - }); - } - }); + if (obj.children) { + returnNames(obj.children, (index + 1), columns).forEach(function (namedObj) { + names.push(namedObj); + }); + } + }); - return names; - }; + return names; }; -}); +} diff --git a/src/ui/public/vislib/components/zero_injection/inject_zeros.js b/src/ui/public/vislib/components/zero_injection/inject_zeros.js index 777f45ffc8df..307522e836a0 100644 --- a/src/ui/public/vislib/components/zero_injection/inject_zeros.js +++ b/src/ui/public/vislib/components/zero_injection/inject_zeros.js @@ -1,5 +1,5 @@ import { VislibComponentsZeroInjectionOrderedXKeysProvider } from './ordered_x_keys'; -import VislibComponentsZeroInjectionZeroFilledArrayProvider from './zero_filled_array'; +import { VislibComponentsZeroInjectionZeroFilledArrayProvider } from './zero_filled_array'; import { VislibComponentsZeroInjectionZeroFillDataArrayProvider } from './zero_fill_data_array'; export function VislibComponentsZeroInjectionInjectZerosProvider(Private) { diff --git a/src/ui/public/vislib/components/zero_injection/zero_filled_array.js b/src/ui/public/vislib/components/zero_injection/zero_filled_array.js index c8edf6891203..a6939bcb7313 100644 --- a/src/ui/public/vislib/components/zero_injection/zero_filled_array.js +++ b/src/ui/public/vislib/components/zero_injection/zero_filled_array.js @@ -1,29 +1,27 @@ import _ from 'lodash'; -define(function () { - return function ZeroFilledArrayUtilService() { - /* - * Accepts an array of x axis values (strings or numbers). - * Returns a zero filled array. - */ +export function VislibComponentsZeroInjectionZeroFilledArrayProvider() { + /* + * Accepts an array of x axis values (strings or numbers). + * Returns a zero filled array. + */ - return function (arr, label) { - if (!_.isArray(arr)) { - throw new Error('ZeroFilledArrayUtilService expects an array of strings or numbers'); - } + return function (arr, label) { + if (!_.isArray(arr)) { + throw new Error('ZeroFilledArrayUtilService expects an array of strings or numbers'); + } - const zeroFilledArray = []; + const zeroFilledArray = []; - arr.forEach(function (val) { - zeroFilledArray.push({ - x: val, - xi: Infinity, - y: 0, - series: label - }); + arr.forEach(function (val) { + zeroFilledArray.push({ + x: val, + xi: Infinity, + y: 0, + series: label }); + }); - return zeroFilledArray; - }; + return zeroFilledArray; }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js index 838d7a3b339b..060ccfdec578 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js @@ -1,63 +1,61 @@ import d3 from 'd3'; -define(function () { - return function ChartSplitFactory() { - /* - * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.chart` elements as row objects. - */ - return function split(selection, parent) { - selection.each(function (data) { - const div = d3.select(this) - .attr('class', function () { - if (data.rows) { - return 'chart-wrapper-row'; - } else if (data.columns) { - return 'chart-wrapper-column'; - } else { - if (parent) { - return 'chart-first chart-last chart-wrapper'; - } - return this.className + ' chart-wrapper'; +export function VislibLibLayoutSplitsColumnChartChartSplitProvider() { + /* + * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.chart` elements as row objects. + */ + return function split(selection, parent) { + selection.each(function (data) { + const div = d3.select(this) + .attr('class', function () { + if (data.rows) { + return 'chart-wrapper-row'; + } else if (data.columns) { + return 'chart-wrapper-column'; + } else { + if (parent) { + return 'chart-first chart-last chart-wrapper'; } - }); - let divClass = ''; - let chartsNumber; + return this.className + ' chart-wrapper'; + } + }); + let divClass = ''; + let chartsNumber; - const charts = div.selectAll('charts') + const charts = div.selectAll('charts') + .append('div') + .data(function (d) { + if (d.rows) { + chartsNumber = d.rows.length; + return d.rows; + } else if (d.columns) { + chartsNumber = d.columns.length; + return d.columns; + } else { + divClass = 'chart'; + chartsNumber = 1; + return [d]; + } + }) + .enter() .append('div') - .data(function (d) { - if (d.rows) { - chartsNumber = d.rows.length; - return d.rows; - } else if (d.columns) { - chartsNumber = d.columns.length; - return d.columns; - } else { - divClass = 'chart'; - chartsNumber = 1; - return [d]; - } - }) - .enter() - .append('div') - .attr('class', function (d, i) { - let fullDivClass = divClass; - if (chartsNumber > 1) { - if (i === 0) { - fullDivClass += ' chart-first'; - } else if (i === chartsNumber - 1) { - fullDivClass += ' chart-last'; - } + .attr('class', function (d, i) { + let fullDivClass = divClass; + if (chartsNumber > 1) { + if (i === 0) { + fullDivClass += ' chart-first'; + } else if (i === chartsNumber - 1) { + fullDivClass += ' chart-last'; } - return fullDivClass; - }); + } + return fullDivClass; + }); - if (!data.series) { - charts.call(split); - } - }); - }; + if (!data.series) { + charts.call(split); + } + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js index eaeb1947ef8e..40b3b04fa268 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js @@ -1,41 +1,38 @@ import d3 from 'd3'; import $ from 'jquery'; -define(function () { - return function ChartTitleSplitFactory() { +export function VislibLibLayoutSplitsColumnChartChartTitleSplitProvider() { + /* + * Adds div DOM elements to either the `.y-axis-chart-title` element or the + * `.x-axis-chart-title` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.chart-title` elements as row objects. + * if not data.rows or data.columns, return no chart titles + */ + return function (selection) { + selection.each(function (data) { + const div = d3.select(this); + const parent = $(this).parents('.vis-wrapper'); - /* - * Adds div DOM elements to either the `.y-axis-chart-title` element or the - * `.x-axis-chart-title` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.chart-title` elements as row objects. - * if not data.rows or data.columns, return no chart titles - */ - return function (selection) { - selection.each(function (data) { - const div = d3.select(this); - const parent = $(this).parents('.vis-wrapper'); + if (!data.series) { + div.selectAll('.chart-title') + .data(function (d) { + return d.rows ? d.rows : d.columns; + }) + .enter() + .append('div') + .attr('class', 'chart-title'); - if (!data.series) { - div.selectAll('.chart-title') - .data(function (d) { - return d.rows ? d.rows : d.columns; - }) - .enter() - .append('div') - .attr('class', 'chart-title'); - - if (data.rows) { - parent.find('.x-axis-chart-title').remove(); - } else { - parent.find('.y-axis-chart-title').remove(); - } - - return div; + if (data.rows) { + parent.find('.x-axis-chart-title').remove(); + } else { + parent.find('.y-axis-chart-title').remove(); } - return d3.select(this).remove(); - }); - }; + return div; + } + + return d3.select(this).remove(); + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js index 98290729082c..96c627f8bec8 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js @@ -1,36 +1,35 @@ import d3 from 'd3'; -define(function () { - return function XAxisSplitFactory() { - /* - * Adds div DOM elements to the `.x-axis-div-wrapper` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.x-axis-div` elements as row objects. - */ - return function (selection) { - selection.each(function () { - const div = d3.select(this); - let columns; - div.selectAll('.x-axis-div') +export function VislibLibLayoutSplitsColumnChartXAxisSplitProvider() { + /* + * Adds div DOM elements to the `.x-axis-div-wrapper` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.x-axis-div` elements as row objects. + */ + + return function (selection) { + selection.each(function () { + const div = d3.select(this); + let columns; + div.selectAll('.x-axis-div') + .append('div') + .data(function (d) { + columns = d.columns ? d.columns.length : 1; + return d.columns ? d.columns : [d]; + }) + .enter() .append('div') - .data(function (d) { - columns = d.columns ? d.columns.length : 1; - return d.columns ? d.columns : [d]; - }) - .enter() - .append('div') - .attr('class', (d, i) => { - let divClass = ''; - if (i === 0) { - divClass += ' chart-first'; - } - if (i === columns - 1) { - divClass += ' chart-last'; - } - return 'x-axis-div axis-div' + divClass; - }); - }); - }; + .attr('class', (d, i) => { + let divClass = ''; + if (i === 0) { + divClass += ' chart-first'; + } + if (i === columns - 1) { + divClass += ' chart-last'; + } + return 'x-axis-div axis-div' + divClass; + }); + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js index 2fbc55bcae52..cce468de711e 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js @@ -1,39 +1,37 @@ import d3 from 'd3'; -define(function () { - return function YAxisSplitFactory() { - /* - * Adds div DOM elements to the `.y-axis-div-wrapper` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.y-axis-div` elements as row objects. - */ +export function VislibLibLayoutSplitsColumnChartYAxisSplitProvider() { + /* + * Adds div DOM elements to the `.y-axis-div-wrapper` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.y-axis-div` elements as row objects. + */ - // render and get bounding box width - return function (selection) { + // render and get bounding box width + return function (selection) { - selection.each(function () { - const div = d3.select(this); - let rows; + selection.each(function () { + const div = d3.select(this); + let rows; - div.selectAll('.y-axis-div') + div.selectAll('.y-axis-div') + .append('div') + .data(function (d) { + rows = d.rows ? d.rows.length : 1; + return d.rows ? d.rows : [d]; + }) + .enter() .append('div') - .data(function (d) { - rows = d.rows ? d.rows.length : 1; - return d.rows ? d.rows : [d]; - }) - .enter() - .append('div') - .attr('class', (d, i) => { - let divClass = ''; - if (i === 0) { - divClass += ' chart-first'; - } - if (i === rows - 1) { - divClass += ' chart-last'; - } - return 'y-axis-div axis-div' + divClass; - }); - }); - }; + .attr('class', (d, i) => { + let divClass = ''; + if (i === 0) { + divClass += ' chart-first'; + } + if (i === rows - 1) { + divClass += ' chart-last'; + } + return 'y-axis-div axis-div' + divClass; + }); + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js index 533c2f0dcd11..d1b8406c99dd 100644 --- a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js +++ b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js @@ -1,51 +1,51 @@ import d3 from 'd3'; -define(function () { - return function ChartSplitFactory() { - /* - * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.chart` elements as row objects. - */ +// eslint-disable-next-line kibana-custom/no-default-export +export default function ChartSplitFactory() { - return function split(selection) { - selection.each(function (data) { - const div = d3.select(this) - .attr('class', function () { - if (data.rows) { - return 'chart-wrapper-row'; - } else if (data.columns) { - return 'chart-wrapper-column'; - } else { - return 'chart-wrapper'; - } - }); - let divClass; + /* + * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.chart` elements as row objects. + */ - const charts = div.selectAll('charts') - .append('div') - .data(function (d) { - if (d.rows) { - divClass = 'chart-row'; - return d.rows; - } else if (d.columns) { - divClass = 'chart-column'; - return d.columns; - } else { - divClass = 'chart'; - return [d]; - } - }) - .enter() - .append('div') - .attr('class', function () { - return divClass; - }); - - if (!data.series) { - charts.call(split); + return function split(selection) { + selection.each(function (data) { + const div = d3.select(this) + .attr('class', function () { + if (data.rows) { + return 'chart-wrapper-row'; + } else if (data.columns) { + return 'chart-wrapper-column'; + } else { + return 'chart-wrapper'; } }); - }; + let divClass; + + const charts = div.selectAll('charts') + .append('div') + .data(function (d) { + if (d.rows) { + divClass = 'chart-row'; + return d.rows; + } else if (d.columns) { + divClass = 'chart-column'; + return d.columns; + } else { + divClass = 'chart'; + return [d]; + } + }) + .enter() + .append('div') + .attr('class', function () { + return divClass; + }); + + if (!data.series) { + charts.call(split); + } + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js index d9c70f5ddff4..f4d393cb634e 100644 --- a/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js +++ b/src/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js @@ -1,40 +1,40 @@ import d3 from 'd3'; -define(function () { - return function ChartTitleSplitFactory() { - /* - * Adds div DOM elements to either the `.y-axis-chart-title` element or the - * `.x-axis-chart-title` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.chart-title` elements as row objects. - * if not data.rows or data.columns, return no chart titles - */ +// eslint-disable-next-line kibana-custom/no-default-export +export default function ChartTitleSplitFactory() { - return function (selection, parent) { - selection.each(function (data) { - const div = d3.select(this); + /* + * Adds div DOM elements to either the `.y-axis-chart-title` element or the + * `.x-axis-chart-title` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.chart-title` elements as row objects. + * if not data.rows or data.columns, return no chart titles + */ - if (!data.slices) { - div.selectAll('.chart-title') - .append('div') - .data(function (d) { - return d.rows ? d.rows : d.columns; - }) - .enter() - .append('div') - .attr('class', 'chart-title'); + return function (selection, parent) { + selection.each(function (data) { + const div = d3.select(this); - if (data.rows) { - d3.select(parent).select('.x-axis-chart-title').remove(); - } else { - d3.select(parent).select('.y-axis-chart-title').remove(); - } + if (!data.slices) { + div.selectAll('.chart-title') + .append('div') + .data(function (d) { + return d.rows ? d.rows : d.columns; + }) + .enter() + .append('div') + .attr('class', 'chart-title'); - return div; + if (data.rows) { + d3.select(parent).select('.x-axis-chart-title').remove(); + } else { + d3.select(parent).select('.y-axis-chart-title').remove(); } - return d3.select(this).remove(); - }); - }; + return div; + } + + return d3.select(this).remove(); + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js index af5817750359..014582b2ee13 100644 --- a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js +++ b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js @@ -1,51 +1,49 @@ import d3 from 'd3'; -define(function () { - return function ChartSplitFactory() { - /* - * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.chart` elements as row objects. - */ +export function VislibLibLayoutSplitsPieChartChartSplitProvider() { + /* + * Adds div DOM elements to the `.chart-wrapper` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.chart` elements as row objects. + */ - return function split(selection) { - selection.each(function (data) { - const div = d3.select(this) - .attr('class', function () { - if (data.rows) { - return 'chart-wrapper-row'; - } else if (data.columns) { - return 'chart-wrapper-column'; - } else { - return 'chart-wrapper'; - } - }); - let divClass; + return function split(selection) { + selection.each(function (data) { + const div = d3.select(this) + .attr('class', function () { + if (data.rows) { + return 'chart-wrapper-row'; + } else if (data.columns) { + return 'chart-wrapper-column'; + } else { + return 'chart-wrapper'; + } + }); + let divClass; - const charts = div.selectAll('charts') + const charts = div.selectAll('charts') + .append('div') + .data(function (d) { + if (d.rows) { + divClass = 'chart-row'; + return d.rows; + } else if (d.columns) { + divClass = 'chart-column'; + return d.columns; + } else { + divClass = 'chart'; + return [d]; + } + }) + .enter() .append('div') - .data(function (d) { - if (d.rows) { - divClass = 'chart-row'; - return d.rows; - } else if (d.columns) { - divClass = 'chart-column'; - return d.columns; - } else { - divClass = 'chart'; - return [d]; - } - }) - .enter() - .append('div') - .attr('class', function () { - return divClass; - }); + .attr('class', function () { + return divClass; + }); - if (!data.slices) { - charts.call(split); - } - }); - }; + if (!data.slices) { + charts.call(split); + } + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js index d9c70f5ddff4..558de2d6701d 100644 --- a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js +++ b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js @@ -1,40 +1,38 @@ import d3 from 'd3'; -define(function () { - return function ChartTitleSplitFactory() { - /* - * Adds div DOM elements to either the `.y-axis-chart-title` element or the - * `.x-axis-chart-title` element based on the data layout. - * For example, if the data has rows, it returns the same number of - * `.chart-title` elements as row objects. - * if not data.rows or data.columns, return no chart titles - */ +export function VislibLibLayoutSplitsPieChartChartTitleSplitProvider() { + /* + * Adds div DOM elements to either the `.y-axis-chart-title` element or the + * `.x-axis-chart-title` element based on the data layout. + * For example, if the data has rows, it returns the same number of + * `.chart-title` elements as row objects. + * if not data.rows or data.columns, return no chart titles + */ - return function (selection, parent) { - selection.each(function (data) { - const div = d3.select(this); + return function (selection, parent) { + selection.each(function (data) { + const div = d3.select(this); - if (!data.slices) { - div.selectAll('.chart-title') + if (!data.slices) { + div.selectAll('.chart-title') + .append('div') + .data(function (d) { + return d.rows ? d.rows : d.columns; + }) + .enter() .append('div') - .data(function (d) { - return d.rows ? d.rows : d.columns; - }) - .enter() - .append('div') - .attr('class', 'chart-title'); + .attr('class', 'chart-title'); - if (data.rows) { - d3.select(parent).select('.x-axis-chart-title').remove(); - } else { - d3.select(parent).select('.y-axis-chart-title').remove(); - } - - return div; + if (data.rows) { + d3.select(parent).select('.x-axis-chart-title').remove(); + } else { + d3.select(parent).select('.y-axis-chart-title').remove(); } - return d3.select(this).remove(); - }); - }; + return div; + } + + return d3.select(this).remove(); + }); }; -}); +} diff --git a/src/ui/public/vislib/lib/layout/types/column_layout.js b/src/ui/public/vislib/lib/layout/types/column_layout.js index 0de178ded6d4..d270dfac9026 100644 --- a/src/ui/public/vislib/lib/layout/types/column_layout.js +++ b/src/ui/public/vislib/lib/layout/types/column_layout.js @@ -1,10 +1,9 @@ -import VislibLibLayoutSplitsColumnChartChartSplitProvider from '../splits/column_chart/chart_split'; -import VislibLibLayoutSplitsColumnChartYAxisSplitProvider from '../splits/column_chart/y_axis_split'; -import VislibLibLayoutSplitsColumnChartXAxisSplitProvider from '../splits/column_chart/x_axis_split'; -import VislibLibLayoutSplitsColumnChartChartTitleSplitProvider from '../splits/column_chart/chart_title_split'; +import { VislibLibLayoutSplitsColumnChartChartSplitProvider } from '../splits/column_chart/chart_split'; +import { VislibLibLayoutSplitsColumnChartYAxisSplitProvider } from '../splits/column_chart/y_axis_split'; +import { VislibLibLayoutSplitsColumnChartXAxisSplitProvider } from '../splits/column_chart/x_axis_split'; +import { VislibLibLayoutSplitsColumnChartChartTitleSplitProvider } from '../splits/column_chart/chart_title_split'; export function VislibLibLayoutTypesColumnLayoutProvider(Private) { - const chartSplit = Private(VislibLibLayoutSplitsColumnChartChartSplitProvider); const yAxisSplit = Private(VislibLibLayoutSplitsColumnChartYAxisSplitProvider); const xAxisSplit = Private(VislibLibLayoutSplitsColumnChartXAxisSplitProvider); diff --git a/src/ui/public/vislib/lib/layout/types/pie_layout.js b/src/ui/public/vislib/lib/layout/types/pie_layout.js index 421b328783a8..e27465a90921 100644 --- a/src/ui/public/vislib/lib/layout/types/pie_layout.js +++ b/src/ui/public/vislib/lib/layout/types/pie_layout.js @@ -1,5 +1,5 @@ -import VislibLibLayoutSplitsPieChartChartSplitProvider from '../splits/pie_chart/chart_split'; -import VislibLibLayoutSplitsPieChartChartTitleSplitProvider from '../splits/pie_chart/chart_title_split'; +import { VislibLibLayoutSplitsPieChartChartSplitProvider } from '../splits/pie_chart/chart_split'; +import { VislibLibLayoutSplitsPieChartChartTitleSplitProvider } from '../splits/pie_chart/chart_title_split'; export function VislibLibLayoutTypesPieLayoutProvider(Private) { const chartSplit = Private(VislibLibLayoutSplitsPieChartChartSplitProvider); diff --git a/src/ui/public/vislib/vislib.js b/src/ui/public/vislib/vislib.js index e0c7bf65a740..ace97079ae80 100644 --- a/src/ui/public/vislib/vislib.js +++ b/src/ui/public/vislib/vislib.js @@ -6,6 +6,7 @@ import './lib/data'; import './visualizations/vis_types'; import './styles/main.less'; import { VislibVisProvider } from './vis'; + // prefetched for faster optimization runs // end prefetching @@ -16,10 +17,10 @@ import { VislibVisProvider } from './vis'; * @main vislib * @return {Object} Contains the version number and the Vis Class for creating visualizations */ -module.exports = function VislibProvider(Private) { - +// eslint-disable-next-line kibana-custom/no-default-export +export default function VislibProvider(Private) { return { version: '0.0.0', Vis: Private(VislibVisProvider) }; -}; +} diff --git a/src/ui/public/vislib_vis_type/vislib_renderbot.js b/src/ui/public/vislib_vis_type/vislib_renderbot.js index 2d9fff03e2be..58a970e9d803 100644 --- a/src/ui/public/vislib_vis_type/vislib_renderbot.js +++ b/src/ui/public/vislib_vis_type/vislib_renderbot.js @@ -3,7 +3,8 @@ import VislibProvider from 'ui/vislib'; import { VisRenderbotProvider } from 'ui/vis/renderbot'; import { VislibVisTypeBuildChartDataProvider } from 'ui/vislib_vis_type/build_chart_data'; -module.exports = function VislibRenderbotFactory(Private, $injector) { +// eslint-disable-next-line kibana-custom/no-default-export +export default function VislibRenderbotFactory(Private, $injector) { const AngularPromise = $injector.get('Promise'); const vislib = Private(VislibProvider); const Renderbot = Private(VisRenderbotProvider); @@ -75,4 +76,4 @@ module.exports = function VislibRenderbotFactory(Private, $injector) { }; return VislibRenderbot; -}; +} diff --git a/src/ui/ui_app.js b/src/ui/ui_app.js index bacdabdbe40a..83c1bf2955b3 100644 --- a/src/ui/ui_app.js +++ b/src/ui/ui_app.js @@ -1,6 +1,6 @@ import { chain, get, noop, once, pick } from 'lodash'; -class UiApp { +export default class UiApp { constructor(uiExports, spec) { this.uiExports = uiExports; this.spec = spec || {}; @@ -65,5 +65,3 @@ class UiApp { return pick(this, ['id', 'title', 'description', 'icon', 'main', 'navLink']); } } - -module.exports = UiApp; diff --git a/src/ui/ui_app_collection.js b/src/ui/ui_app_collection.js index 4ec73d8550f2..979570d92c69 100644 --- a/src/ui/ui_app_collection.js +++ b/src/ui/ui_app_collection.js @@ -4,7 +4,7 @@ import Collection from '../utils/collection'; const byIdCache = Symbol('byId'); -module.exports = class UiAppCollection extends Collection { +export default class UiAppCollection extends Collection { constructor(uiExports, parent) { super(); @@ -42,4 +42,4 @@ module.exports = class UiAppCollection extends Collection { return this[byIdCache] || (this[byIdCache] = _.indexBy([...this], 'id')); } -}; +} diff --git a/src/ui/ui_bundle.js b/src/ui/ui_bundle.js index 53674efea6f1..4d3f6e6f49d2 100644 --- a/src/ui/ui_bundle.js +++ b/src/ui/ui_bundle.js @@ -6,7 +6,7 @@ const write = promisify(require('fs').writeFile); const unlink = promisify(require('fs').unlink); const stat = promisify(require('fs').stat); -module.exports = class UiBundle { +export default class UiBundle { constructor(opts) { opts = opts || {}; @@ -65,4 +65,4 @@ module.exports = class UiBundle { outputPath: this.outputPath }; } -}; +} diff --git a/src/ui/ui_bundle_collection.js b/src/ui/ui_bundle_collection.js index 344a03034aec..7452871d8589 100644 --- a/src/ui/ui_bundle_collection.js +++ b/src/ui/ui_bundle_collection.js @@ -6,7 +6,7 @@ import { makeRe } from 'minimatch'; const mkdirp = promisify(require('mkdirp')); -class UiBundleCollection { +export default class UiBundleCollection { constructor(bundlerEnv, filter) { this.each = []; this.env = bundlerEnv; @@ -95,5 +95,3 @@ class UiBundleCollection { return this.each; } } - -module.exports = UiBundleCollection; diff --git a/src/ui/ui_bundler_env.js b/src/ui/ui_bundler_env.js index 12ddc3ef16af..41178ccb33e6 100644 --- a/src/ui/ui_bundler_env.js +++ b/src/ui/ui_bundler_env.js @@ -3,7 +3,7 @@ import { includes } from 'lodash'; const arr = v => [].concat(v || []); -module.exports = class UiBundlerEnv { +export default class UiBundlerEnv { constructor(workingDir) { // the location that bundle entry files and all compiles files will @@ -81,4 +81,4 @@ module.exports = class UiBundlerEnv { addNoParse(regExp) { this.noParse.push(regExp); } -}; +} diff --git a/src/ui/ui_exports.js b/src/ui/ui_exports.js index 74cf53c07e07..9e364de8c523 100644 --- a/src/ui/ui_exports.js +++ b/src/ui/ui_exports.js @@ -5,7 +5,7 @@ import UiAppCollection from './ui_app_collection'; import UiNavLinkCollection from './ui_nav_link_collection'; import { MappingsCollection } from './ui_mappings'; -class UiExports { +export default class UiExports { constructor({ urlBasePath }) { this.navLinks = new UiNavLinkCollection(this); this.apps = new UiAppCollection(this); @@ -171,5 +171,3 @@ class UiExports { return this.bundleProviders; } } - -module.exports = UiExports; diff --git a/src/utils/collection.js b/src/utils/collection.js index 89ceae1409f6..35712beceeac 100644 --- a/src/utils/collection.js +++ b/src/utils/collection.js @@ -1,7 +1,7 @@ const set = Symbol('internal set'); -module.exports = class Collection { +export default class Collection { constructor() { // Set's have a length of 0, mimic that this[set] = new Set(arguments[0] || []); } @@ -65,4 +65,4 @@ module.exports = class Collection { [Symbol.iterator]() { return this[set][Symbol.iterator](); } -}; +} diff --git a/src/utils/path_contains.js b/src/utils/path_contains.js index e9d0a379def1..5c61fa28b75c 100644 --- a/src/utils/path_contains.js +++ b/src/utils/path_contains.js @@ -1,5 +1,5 @@ import { relative } from 'path'; -module.exports = function pathContains(root, child) { +export default function pathContains(root, child) { return relative(child, root).slice(0, 2) !== '..'; -}; +} diff --git a/tasks/config/eslint.js b/tasks/config/eslint.js index 3e963154c91c..71e84555363f 100644 --- a/tasks/config/eslint.js +++ b/tasks/config/eslint.js @@ -12,6 +12,7 @@ export default grunt => ({ 'ui_framework/components', 'ui_framework/doc_site', 'utilities', + 'webpackShims', ], }, diff --git a/tasks/test.js b/tasks/test.js index 7f03c631a61d..633de156bc09 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -1,6 +1,6 @@ import _, { keys } from 'lodash'; -import visualRegression from '../utilities/visual_regression'; +import { run } from '../utilities/visual_regression'; module.exports = function (grunt) { grunt.registerTask( @@ -8,7 +8,7 @@ module.exports = function (grunt) { 'Compare screenshots and generate diff images.', function () { const done = this.async(); - visualRegression.run(done); + run(done); } ); diff --git a/tasks/utils/exec.js b/tasks/utils/exec.js index 8236098f61ba..b5961fdc1b45 100644 --- a/tasks/utils/exec.js +++ b/tasks/utils/exec.js @@ -1,6 +1,6 @@ import { execFileSync } from 'child_process'; -function exec(cmd, args, opts) { +export default function exec(cmd, args, opts) { console.log(' >', cmd, args.join(' ')); exec.silent(cmd, args, opts); } @@ -22,5 +22,3 @@ exec.silent = function (cmd, args, opts) { throw e; } }; - -module.exports = exec; diff --git a/utilities/visual_regression.js b/utilities/visual_regression.js index 98d345c6f5e2..7dbc2fb6aa6c 100644 --- a/utilities/visual_regression.js +++ b/utilities/visual_regression.js @@ -1,4 +1,3 @@ - import bluebird, { fromNode, promisify, @@ -15,7 +14,6 @@ const readDirAsync = promisify(fs.readdir); const readFileAsync = promisify(fs.readFile); const writeFileAsync = promisify(fs.writeFile); - Handlebars.registerHelper('lte', function lessThanEquals(value, threshold, options) { if (value <= threshold) { return options.fn(this); @@ -124,16 +122,14 @@ async function compareScreenshots() { }); } -module.exports = { - run: done => { - compareScreenshots().then(screenshotComparisons => { - // Once all of the data has been loaded, we can build the gallery. - buildGallery(screenshotComparisons).then(() => { - done(); - }); - }, error => { - console.error(error); - done(false); +export function run(done) { + compareScreenshots().then(screenshotComparisons => { + // Once all of the data has been loaded, we can build the gallery. + buildGallery(screenshotComparisons).then(() => { + done(); }); - } -}; + }, error => { + console.error(error); + done(false); + }); +} diff --git a/webpackShims/.eslintrc b/webpackShims/.eslintrc new file mode 100644 index 000000000000..3768f841ff08 --- /dev/null +++ b/webpackShims/.eslintrc @@ -0,0 +1,4 @@ +extends: '../.eslintrc' + +rules: + no-var: 0 \ No newline at end of file diff --git a/webpackShims/ui-bootstrap.js b/webpackShims/ui-bootstrap.js index 9dc879b6d850..463bbf08c0e8 100644 --- a/webpackShims/ui-bootstrap.js +++ b/webpackShims/ui-bootstrap.js @@ -1,19 +1,17 @@ -define(function (require) { - require('angular'); - require('ui/angular-bootstrap/index'); - const chrome = require('../src/ui/public/chrome/chrome'); +require('angular'); +require('ui/angular-bootstrap'); +var uiModules = require('ui/modules').uiModules; +var chrome = require('../src/ui/public/chrome/chrome'); - return require('ui/modules') - .get('kibana', ['ui.bootstrap', 'pascalprecht.translate']) - .config(function ($tooltipProvider) { - $tooltipProvider.setTriggers({ 'mouseenter': 'mouseleave click' }); - }) - .config(function ($translateProvider) { - $translateProvider.translations('default', chrome.getTranslations()); - $translateProvider.preferredLanguage('default'); - // Enable escaping of HTML - // issue in https://angular-translate.github.io/docs/#/guide/19_security - $translateProvider.useSanitizeValueStrategy('escape'); - }); +var kibana = uiModules.get('kibana', ['ui.bootstrap', 'pascalprecht.translate']); +module.exports = kibana.config(function ($tooltipProvider) { + $tooltipProvider.setTriggers({ 'mouseenter': 'mouseleave click' }); +}) +.config(function ($translateProvider) { + $translateProvider.translations('default', chrome.getTranslations()); + $translateProvider.preferredLanguage('default'); + // Enable escaping of HTML + // issue in https://angular-translate.github.io/docs/#/guide/19_security + $translateProvider.useSanitizeValueStrategy('escape'); });