Skip to content

Commit

Permalink
Fix: named exports (elastic#199)
Browse files Browse the repository at this point in the history
* chore: named exports for common functions

:

* chore: named exports for common functions

* chore: named exports for types

* chore: named exports for elements

* chore: named exports for expression types

* chore: named exports for public functions

BREAKING CHANGE: access to public functions required named imports now

* chore: named exports for redux state

* chore: named exports for server functions

* chore: named exports in state tests
  • Loading branch information
w33ble authored Oct 25, 2017
1 parent 9eb52bd commit a8fa019
Show file tree
Hide file tree
Showing 98 changed files with 195 additions and 195 deletions.
2 changes: 1 addition & 1 deletion common/functions/alterColumn/alterColumn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';

export default {
export const alterColumn = {
name: 'alterColumn',
type: 'datatable',
help: 'Converts between core types, eg string, number, null, boolean, date',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/arg.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { includes } from 'lodash';

export default function Arg(config) {
export function Arg(config) {
this.name = config.name;
this.types = config.types || [];
this.default = config.default;
Expand Down
2 changes: 1 addition & 1 deletion common/functions/compare/compare.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const compare = {
name: 'compare',
help: 'Compare the input to something else to determine true or false. Usually used in combination with {if}',
aliases: ['condition'],
Expand Down
2 changes: 1 addition & 1 deletion common/functions/containerStyle/containerStyle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const containerStyle = {
name: 'containerStyle',
aliases: [],
type: 'containerStyle',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/date/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from 'moment';

export default {
export const date = {
name: 'date',
type: 'string',
help: 'Returns the time, as a string, in the current execution environment',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/droprows/droprows.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';

export default {
export const droprows = {
name: 'droprows',
aliases: [],
type: 'datatable',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/exactly/exactly.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const exactly = {
name: 'exactly',
aliases: [],
type: 'filter',
Expand Down
4 changes: 2 additions & 2 deletions common/functions/fn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { each, includes } from 'lodash';
import Arg from './arg';
import { Arg } from './arg';

export default function Fn(config) {
export function Fn(config) {
// Required
this.name = config.name; // Name of function

Expand Down
2 changes: 1 addition & 1 deletion common/functions/font/font.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inlineStyle from 'inline-style';

export default {
export const font = {
name: 'font',
aliases: [],
type: 'style',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/grid/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const getResultValues = (items, name, sorter) => {
return sorter ? sortBy(vals, sorter) : vals.sort();
};

export default {
export const grid = {
name: 'grid',
aliases: [],
type: 'render',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/if/if.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const ifFn = {
name: 'if',
help: 'Perform conditional logic',
args: {
Expand Down
2 changes: 1 addition & 1 deletion common/functions/image/elastic_logo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions common/functions/image/image.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { includes } from 'lodash';
import elasticLogo from './elastic_logo';
import { elasticLogo } from './elastic_logo';
import { fetchImage } from '../../lib/fetch_image';

export default {
export const image = {
name: 'image',
aliases: [],
type: 'image',
Expand Down
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 droprows from './droprows/droprows';
import exactly from './exactly/exactly';
import font from './font/font';
import grid from './grid/grid';
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 size from './size/size';
import sleep from './sleep/sleep';
import sort from './sort/sort';
import table from './table/table';
import timefilter from './timefilter/timefilter';
import timefilterControl from './timefilterControl/timefilterControl';
import { alterColumn } from './alterColumn/alterColumn';
import { compare } from './compare/compare';
import { containerStyle } from './containerStyle/containerStyle';
import { date } from './date/date';
import { droprows } from './droprows/droprows';
import { exactly } from './exactly/exactly';
import { font } from './font/font';
import { grid } from './grid/grid';
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 { size } from './size/size';
import { sleep } from './sleep/sleep';
import { sort } from './sort/sort';
import { table } from './table/table';
import { timefilter } from './timefilter/timefilter';
import { timefilterControl } from './timefilterControl/timefilterControl';

export const commonFunctions = [
alterColumn,
Expand Down
2 changes: 1 addition & 1 deletion common/functions/jsonquery/jsonquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { isArray, get } from 'lodash';
// We need *some* way of accessing the data in tables, that could be via a collection of our own functions
// Or via something like this. I'm using JSON Query for the moment because it is easy, but we should make
// an actual decision, and replace this if needed.
export default {
export const jsonquery = {
name: 'jsonquery',
aliases: [],
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/mapColumn/mapColumn.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const mapColumn = {
name: 'mapColumn',
aliases: ['mc'], // midnight commander. So many times I've launched midnight commander instead of moving a file.
type: 'datatable',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/markdown/markdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Handlebars } from '../../lib/handlebars.js';

export default {
export const markdown = {
name: 'markdown',
aliases: [],
type: 'render',
Expand Down
6 changes: 3 additions & 3 deletions common/functions/math/math.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { map } from 'lodash';
import { math } from '../../lib/math.js';
import { math as mathjs } from '../../lib/math.js';
import { pivotObjectArray } from '../../lib/pivot_object_array.js';

export default {
export const math = {
name: 'math',
type: 'number',
help: 'Interpret a mathJS expression, with a datatable as context, or not',
Expand All @@ -17,7 +17,7 @@ export default {
fn: (context, args) => {
const isDatatable = context && context.type === 'datatable';
const mathContext = isDatatable ? pivotObjectArray(context.rows, map(context.columns, 'name')) : { value: context };
const result = math.eval(args._, mathContext);
const result = mathjs.eval(args._, mathContext);
if (typeof result !== 'number') throw new Error ('Failed to execute math expression. Check your column names');
return result;
},
Expand Down
2 changes: 1 addition & 1 deletion common/functions/palette/palette.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { palettes } from '../../lib/palettes';
export default {
export const palette = {
name: 'palette',
aliases: [],
type: 'palette',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/pie/pie.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get, map, groupBy, sortBy, keyBy } from 'lodash';
import chroma from 'chroma-js';

export default {
export const pie = {
name: 'pie',
aliases: [],
type: 'render',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/plot/plot.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { groupBy, keyBy, get, set, map, sortBy } from 'lodash';
import chroma from 'chroma-js';

export default {
export const plot = {
name: 'plot',
aliases: [],
type: 'render',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/render/render.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const render = {
name: 'render',
aliases: [],
type: 'render',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/replace/replace.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const replace = {
name: 'replace',
type: 'string',
help: 'Use a regular expression to replace parts of a string',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/rounddate/rounddate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from 'moment';

export default {
export const rounddate = {
name: 'rounddate',
type: 'string',
help: 'Round dates using a moment formatting string',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/seriesStyle/seriesStyle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const name = 'seriesStyle';

export default {
export const seriesStyle = {
name,
help: 'Creates an object used for describing the properties of a series on a chart.' +
' You would usually use this inside of a charting function',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/size/size.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const size = {
name: 'size',
aliases: [],
type: 'filter',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/sleep/sleep.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const sleep = {
name: 'sleep',
help: 'Introduces a delay to expressions. This should not be used in production. If you need this, you did something wrong',
args: {
Expand Down
2 changes: 1 addition & 1 deletion common/functions/sort/sort.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';

export default {
export const sort = {
name: 'sort',
aliases: [],
type: 'datatable',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/table/table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const table = {
name: 'table',
aliases: [],
type: 'render',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/timefilter/timefilter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dateMath from '@elastic/datemath';

export default {
export const timefilter = {
name: 'timefilter',
aliases: [],
type: 'filter',
Expand Down
2 changes: 1 addition & 1 deletion common/functions/timefilterControl/timefilterControl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const timefilterControl = {
name: 'timefilterControl',
aliases: [],
type: 'render',
Expand Down
2 changes: 1 addition & 1 deletion common/lib/functions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Registry } from '../../common/lib/registry';
import Fn from '../functions/fn';
import { Fn } from '../functions/fn';

class FunctionsRegistry extends Registry {
wrapper(obj) {
Expand Down
2 changes: 1 addition & 1 deletion common/lib/types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Registry } from '../../common/lib/registry';
import Type from '../../common/types/type';
import { Type } from '../../common/types/type';

class TypesRegistry extends Registry {
wrapper(obj) {
Expand Down
2 changes: 1 addition & 1 deletion common/types/boolean/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const boolean = {
name: 'boolean',
from: {
null: () => 0,
Expand Down
2 changes: 1 addition & 1 deletion common/types/datatable/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { map } from 'lodash';

export default {
export const datatable = {
name: 'datatable',
from: {
null: () => {
Expand Down
2 changes: 1 addition & 1 deletion common/types/dataurl/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parse } from '../../lib/dataurl';

export default {
export const dataurl = {
name: 'dataurl',
from: {
null: () => '',
Expand Down
2 changes: 1 addition & 1 deletion common/types/filter/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const filter = {
name: 'filter',
from: {
null: () => {
Expand Down
2 changes: 1 addition & 1 deletion common/types/image/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const image = {
name: 'image',
to: {
render: (input) => {
Expand Down
22 changes: 11 additions & 11 deletions common/types/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import datatable from './datatable';
import pointseries from './pointseries';
import number from './number';
import string from './string';
import dataurl from './dataurl';
import image from './image';
import filter from './filter';
import render from './render';
import style from './style';
import location from './location';
import boolean from './boolean';
import { boolean } from './boolean';
import { datatable } from './datatable';
import { dataurl } from './dataurl';
import { filter } from './filter';
import { image } from './image';
import { location } from './location';
import { number } from './number';
import { pointseries } from './pointseries';
import { render } from './render';
import { string } from './string';
import { style } from './style';

export const typeSpecs = [
datatable,
Expand Down
2 changes: 1 addition & 1 deletion common/types/location/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const location = {
name: 'location',
from: {},
to: {
Expand Down
2 changes: 1 addition & 1 deletion common/types/number/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const number = {
name: 'number',
from: {
null: () => 0,
Expand Down
4 changes: 2 additions & 2 deletions common/types/pointseries/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datatable from '../datatable';
import { datatable } from '../datatable';

export default {
export const pointseries = {
name: 'pointseries',
from: {
null: () => {
Expand Down
2 changes: 1 addition & 1 deletion common/types/render/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const render = {
name: 'render',
from: {
null: () => ({
Expand Down
2 changes: 1 addition & 1 deletion common/types/string/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const string = {
name: 'string',
from: {
null: () => '',
Expand Down
Loading

0 comments on commit a8fa019

Please sign in to comment.