Skip to content

Commit

Permalink
Chore: filename cleanup (elastic#204)
Browse files Browse the repository at this point in the history
* chore: move all the common functions

follow existing naming patterns

* chore: move common types files

* chore: move get_type to common/lib

* chore: rename public functions

* chore: add entry index.js to elements

* chore: move server functions, add index.js as needed

* chore: rename registries, add _registry to filenames

BREAKING CHANGE: this will affect how plugins import the public regirsties
  • Loading branch information
w33ble authored Oct 26, 2017
1 parent ef2f44e commit 49321f8
Show file tree
Hide file tree
Showing 93 changed files with 118 additions and 107 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions common/functions/image/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { image } from './image';
54 changes: 27 additions & 27 deletions common/functions/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { alterColumn } from './alterColumn/alterColumn';
import { compare } from './compare/compare';
import { containerStyle } from './containerStyle/containerStyle';
import { date } from './date/date';
import { exactly } from './exactly/exactly';
import { font } from './font/font';
import { grid } from './grid/grid';
import { head } from './head/head';
import { ifFn } from './if/if';
import { image } from './image/image';
import { jsonquery } from './jsonquery/jsonquery';
import { mapColumn } from './mapColumn/mapColumn';
import { markdown } from './markdown/markdown';
import { math } from './math/math';
import { palette } from './palette/palette';
import { pie } from './pie/pie';
import { plot } from './plot/plot';
import { render } from './render/render';
import { replace } from './replace/replace';
import { rounddate } from './rounddate/rounddate';
import { seriesStyle } from './seriesStyle/seriesStyle';
import { sleep } from './sleep/sleep';
import { sort } from './sort/sort';
import { table } from './table/table';
import { tail } from './tail/tail';
import { timefilter } from './timefilter/timefilter';
import { timefilterControl } from './timefilterControl/timefilterControl';
import { alterColumn } from './alterColumn';
import { compare } from './compare';
import { containerStyle } from './containerStyle';
import { date } from './date';
import { exactly } from './exactly';
import { font } from './font';
import { grid } from './grid';
import { head } from './head';
import { ifFn } from './if';
import { image } from './image';
import { jsonquery } from './jsonquery';
import { mapColumn } from './mapColumn';
import { markdown } from './markdown';
import { math } from './math';
import { palette } from './palette';
import { pie } from './pie';
import { plot } from './plot';
import { render } from './render';
import { replace } from './replace';
import { rounddate } from './rounddate';
import { seriesStyle } from './seriesStyle';
import { sleep } from './sleep';
import { sort } from './sort';
import { table } from './table';
import { tail } from './tail';
import { timefilter } from './timefilter';
import { timefilterControl } from './timefilterControl';

export const commonFunctions = [
alterColumn,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handlebars } from '../../lib/handlebars.js';
import { Handlebars } from '../lib/handlebars.js';

export const markdown = {
name: 'markdown',
Expand Down
4 changes: 2 additions & 2 deletions common/functions/math/math.js → common/functions/math.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { map } from 'lodash';
import { math as mathjs } from '../../lib/math.js';
import { pivotObjectArray } from '../../lib/pivot_object_array.js';
import { math as mathjs } from '../lib/math.js';
import { pivotObjectArray } from '../lib/pivot_object_array.js';

export const math = {
name: 'math',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { palettes } from '../../lib/palettes';
import { palettes } from '../lib/palettes';
export const palette = {
name: 'palette',
aliases: [],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion common/functions/to/to.js → common/functions/to.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
it needs access to types and the registry of types is, obviously, different between the environments
*/

import { castProvider } from '../../interpreter/cast';
import { castProvider } from '../interpreter/cast';

export function toProvider(types) {
return {
Expand Down
2 changes: 1 addition & 1 deletion common/interpreter/cast.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import { getType } from '../types/get_type';
import { getType } from '../lib/get_type';

export function castProvider(types) {
return function cast(node, toTypeNames) {
Expand Down
4 changes: 2 additions & 2 deletions common/interpreter/interpret.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { clone, each, keys, last, map, mapValues, values, zipObject, omitBy } from 'lodash';
import { castProvider } from './cast';
import { getType } from '../types/get_type';
import { getType } from '../lib/get_type';
import { fromExpression } from '../lib/ast';
import { typesRegistry } from '../lib/types';
import { typesRegistry } from '../lib/types_registry';

export function interpretProvider(config) {
const cast = castProvider(config.types);
Expand Down
2 changes: 1 addition & 1 deletion common/lib/__tests__/ast.fromExpression.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import expect from 'expect.js';
import { fromExpression } from '../ast';
import { getType } from '../../types/get_type';
import { getType } from '../../lib/get_type';

describe('ast fromExpression', () => {
describe('invalid expression', () => {
Expand Down
2 changes: 1 addition & 1 deletion common/lib/ast.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parse } from './grammar';
import { getType } from '../types/get_type';
import { getType } from '../lib/get_type';

function getArgumentString(arg, argKey) {
const type = getType(arg);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion common/types/dataurl/index.js → common/types/dataurl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse } from '../../lib/dataurl';
import { parse } from '../lib/dataurl';

export const dataurl = {
name: 'dataurl',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { datatable } from '../datatable';
import { datatable } from './datatable';

export const pointseries = {
name: 'pointseries',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion common/types/type.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// All types must be universal and be castable on the client or on the server
import { intersection, keys, constant } from 'lodash';
import { getType } from './get_type';
import { getType } from '../lib/get_type';

// TODO: Currently all casting functions must be syncronous.

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import init from './init';
import { functionsRegistry } from './common/lib/functions';
import { functionsRegistry } from './common/lib/functions_registry';

export default function (kibana) {
return new kibana.Plugin({
Expand Down
6 changes: 2 additions & 4 deletions init.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { routes } from './server/routes';
import { functionsRegistry } from './common/lib/functions';
import { functionsRegistry } from './common/lib/functions_registry';
import { typesRegistry } from './common/lib/types_registry';
import { serverFunctions } from './server/functions';
import { createIndices } from './server/lib/create_indices';

import { commonFunctions } from './common/functions';
import { typeSpecs } from './common/types';

import { typesRegistry } from './common/lib/types';

export default function (server, /*options*/) {
server.plugins.canvas = {
kibanaType: 'canvas_1',
Expand Down
2 changes: 1 addition & 1 deletion public/components/element_wrapper/element_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Loading } from '../loading';
import { pure, compose, branch, renderComponent } from 'recompose';
import { RenderElement } from '../render_element';
import Style from 'style-it';
import { getType } from '../../../common/types/get_type';
import { getType } from '../../../common/lib/get_type';

/*
Branches
Expand Down
2 changes: 1 addition & 1 deletion public/components/element_wrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getSelectedPage,
} from '../../state/selectors/workpad';
import { getState, getValue, getError } from '../../lib/resolved_arg';
import { elementsRegistry } from '../../lib/elements';
import { elementsRegistry } from '../../lib/elements_registry';
import { createHandlers } from './lib/handlers';

const mapStateToProps = (state, { element }) => ({
Expand Down
2 changes: 1 addition & 1 deletion public/components/toolbar/element_types/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pure, compose, withProps, withState } from 'recompose';
import { elementsRegistry } from '../../../lib/elements';
import { elementsRegistry } from '../../../lib/elements_registry';

import { ElementTypes as Component } from './element_types';

Expand Down
1 change: 1 addition & 0 deletions public/elements/advanced_filter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { advancedFilter } from './advanced_filter';
1 change: 1 addition & 0 deletions public/elements/debug/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { debug } from './debug';
1 change: 1 addition & 0 deletions public/elements/grid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { grid } from './grid';
1 change: 1 addition & 0 deletions public/elements/image/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { image } from './image';
18 changes: 9 additions & 9 deletions public/elements/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { advancedFilter } from './advanced_filter/advanced_filter';
import { debug } from './debug/debug';
import { grid } from './grid/grid';
import { image } from './image/image';
import { markdown } from './markdown/markdown';
import { pie } from './pie/pie';
import { plot } from './plot/plot';
import { table } from './table/table';
import { timeFilter } from './time_filter/time_filter';
import { advancedFilter } from './advanced_filter';
import { debug } from './debug';
import { grid } from './grid';
import { image } from './image';
import { markdown } from './markdown';
import { pie } from './pie';
import { plot } from './plot';
import { table } from './table';
import { timeFilter } from './time_filter';

export const elementSpecs = [
advancedFilter,
Expand Down
1 change: 1 addition & 0 deletions public/elements/markdown/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { markdown } from './markdown';
1 change: 1 addition & 0 deletions public/elements/pie/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { pie } from './pie';
1 change: 1 addition & 0 deletions public/elements/plot/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { plot } from './plot';
1 change: 1 addition & 0 deletions public/elements/table/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { table } from './table';
1 change: 1 addition & 0 deletions public/elements/time_filter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { timeFilter } from './time_filter';
2 changes: 1 addition & 1 deletion public/expression_types/arg_types/datacolumn/datacolumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { sortBy } from 'lodash';
import { FormControl } from 'react-bootstrap';
import { SimpleMathFunction } from './simple_math_function';
import { getType } from '../../../../common/types/get_type';
import { getType } from '../../../../common/lib/get_type';
import { parse } from 'mathjs';

import './datacolumn.less';
Expand Down
2 changes: 1 addition & 1 deletion public/expression_types/arg_types/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { get } from 'lodash';
import { PalettePicker } from '../../components/palette_picker';
import { getType } from '../../../common/types/get_type';
import { getType } from '../../../common/lib/get_type';

const template = ({ onValueChange, argValue, renderError }) => {
// Why is this neccesary? Does the dialog really need to know what parameter it is setting?
Expand Down
4 changes: 2 additions & 2 deletions public/functions/asset/asset.js → public/functions/asset.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getState } from '../../state/store';
import { getAssetById } from '../../state/selectors/assets';
import { getState } from '../state/store';
import { getAssetById } from '../state/selectors/assets';

export const asset = {
name: 'asset',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fromExpression } from '../../../common/lib/ast';
import { typesRegistry } from '../../../common/lib/types';
import { getState } from '../../state/store';
import { getGlobalFilterExpression } from '../../state/selectors/workpad';
import { interpretAst } from '../../lib/interpreter';
import { fromExpression } from '../../common/lib/ast';
import { typesRegistry } from '../../common/lib/types_registry';
import { getState } from '../state/store';
import { getGlobalFilterExpression } from '../state/selectors/workpad';
import { interpretAst } from '../lib/interpreter';

export const filters = {
name: 'filters',
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions public/functions/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { asset } from './asset/asset';
import { filters } from './filters/filters';
import { geoip } from './geoip/geoip';
import { location } from './location/location';
import { toFn } from './to/to';
import { urlparam } from './urlparam/urlparam';
import { asset } from './asset';
import { filters } from './filters';
import { geoip } from './geoip';
import { location } from './location';
import { toFn } from './to';
import { urlparam } from './urlparam';

export const clientFunctions = [
geoip,
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions public/functions/to.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { toProvider } from '../../common/functions/to';
import { typesRegistry } from '../../common/lib/types_registry';

export const toFn = toProvider(typesRegistry);
4 changes: 0 additions & 4 deletions public/functions/to/to.js

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion public/lib/arg_helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isArray, includes } from 'lodash';
import { getType } from '../../common/types/get_type';
import { getType } from '../../common/lib/get_type';

/*
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// export the common registry here, so it's available in plugin public code
export { functionsRegistry } from '../../common/lib/functions';
export { functionsRegistry } from '../../common/lib/functions_registry';
4 changes: 2 additions & 2 deletions public/lib/interpreter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { socketInterpreterProvider } from '../../common/interpreter/socket_interpret';
import { typesRegistry } from '../../common/lib/types';
import { socket } from '../socket';
import { functionsRegistry } from './functions';
import { createHandlers } from './create_handlers';
import { typesRegistry } from '../../common/lib/types_registry';
import { functionsRegistry } from './functions_registry';

// Create the function list
socket.emit('getFunctionList');
Expand Down
2 changes: 1 addition & 1 deletion public/lib/load_elements.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { elementsRegistry } from './elements';
import { elementsRegistry } from './elements_registry';
import { elementSpecs } from '../elements';

elementSpecs.forEach(elDef => elementsRegistry.register(elDef));
2 changes: 1 addition & 1 deletion public/lib/load_functions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { functionsRegistry } from '../../common/lib/functions';
import { functionsRegistry } from '../../common/lib/functions_registry';
import { commonFunctions } from '../../common/functions';
import { clientFunctions } from '../functions';

Expand Down
2 changes: 1 addition & 1 deletion public/lib/load_types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { typesRegistry } from '../../common/lib/types';
import { typesRegistry } from '../../common/lib/types_registry';
import { typeSpecs } from '../../common/types';

typeSpecs.forEach(typeDef => typesRegistry.register(typeDef));
2 changes: 1 addition & 1 deletion public/socket.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { map } from 'lodash';
import io from 'socket.io-client';
import chrome from 'ui/chrome';
import { functionsRegistry } from '../common/lib/functions';
import { functionsRegistry } from '../common/lib/functions_registry';

const basePath = chrome.getBasePath();
export const socket = io(undefined, { path: `${basePath}/socket.io` });
Expand Down
2 changes: 1 addition & 1 deletion public/state/actions/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as args from './resolved_args';
import { getPages, getElementById } from '../selectors/workpad';
import { getValue } from '../selectors/resolved_args';
import { getDefaultElement } from '../defaults';
import { getType } from '../../../common/types/get_type';
import { getType } from '../../../common/lib/get_type';
import { fromExpression, toExpression, safeElementFromExpression } from '../../../common/lib/ast';
import { interpretAst } from '../../lib/interpreter';
import { notify } from '../../lib/notify';
Expand Down
6 changes: 3 additions & 3 deletions public/state/store_service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { uniqBy } from 'lodash';
import { uiModules } from 'ui/modules';
import { historyProvider } from '../lib/history_provider';
import { onStart } from './on_start';
import { uniqBy } from 'lodash';
import { functionsRegistry } from '../../common/lib/functions';
import { getInitialState } from './initial_state';
import { setStore } from './store';
import { historyProvider } from '../lib/history_provider';
import { functionsRegistry } from '../../common/lib/functions_registry';

const app = uiModules.get('apps/canvas');

Expand Down
1 change: 1 addition & 0 deletions server/functions/demodata/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { demodata } from './demodata';
1 change: 1 addition & 0 deletions server/functions/demoprices/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { demoprices } from './demoprices';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { buildESRequest } from '../esdocs/lib/build_es_request';
import { buildESRequest } from './esdocs/lib/build_es_request';

export const escount = {
name: 'escount',
Expand Down
1 change: 1 addition & 0 deletions server/functions/esdocs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { esdocs } from './esdocs';
14 changes: 7 additions & 7 deletions server/functions/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { demodata } from './demodata/demodata';
import { demoprices } from './demoprices/demoprices';
import { escount } from './escount/escount';
import { esdocs } from './esdocs/esdocs';
import { pointseries } from './pointseries/pointseries';
import { timelion } from './timelion/timelion';
import { toFn } from './to/to';
import { demodata } from './demodata';
import { demoprices } from './demoprices';
import { escount } from './escount';
import { esdocs } from './esdocs';
import { pointseries } from './pointseries';
import { timelion } from './timelion';
import { toFn } from './to';

export const serverFunctions = [
esdocs,
Expand Down
Loading

0 comments on commit 49321f8

Please sign in to comment.