Skip to content

Commit

Permalink
Merge branch 'master' into sessions/error-format
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 28, 2021
2 parents 7c94fe0 + 4d79419 commit 244a93b
Show file tree
Hide file tree
Showing 229 changed files with 8,594 additions and 1,387 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ snapshots.js
# package overrides
/packages/elastic-eslint-config-kibana
/packages/kbn-interpreter/src/common/lib/grammar.js
/packages/kbn-tinymath/src/grammar.js
/packages/kbn-plugin-generator/template
/packages/kbn-pm/dist
/packages/kbn-test/src/functional_test_runner/__tests__/fixtures/
Expand Down
Binary file added docs/user/images/alerts-and-actions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/app-navigation-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/features-control.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/home-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/kibana-main-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/login-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/roles-and-privileges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/select-your-space.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/tags-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/user/images/visualization-journey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
479 changes: 389 additions & 90 deletions docs/user/introduction.asciidoc

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
"tabbable": "1.1.3",
"tar": "4.4.13",
"tinygradient": "0.4.3",
"tinymath": "1.2.1",
"@kbn/tinymath": "link:packages/kbn-tinymath",
"tree-kill": "^1.2.2",
"ts-easing": "^0.2.0",
"tslib": "^2.0.0",
Expand Down Expand Up @@ -847,4 +847,4 @@
"yargs": "^15.4.1",
"zlib": "^1.0.5"
}
}
}
5 changes: 5 additions & 0 deletions packages/elastic-eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ module.exports = {
to: false,
disallowedMessage: `Don't import monaco directly, use or add exports to @kbn/monaco`
},
{
from: 'tinymath',
to: '@kbn/tinymath',
disallowedMessage: `Don't use 'tinymath', use '@kbn/tinymath'`
},
],
],
},
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
extensions: ['.js', '.ts', '.tsx', '.json'],
mainFields: ['browser', 'main'],
alias: {
tinymath: require.resolve('tinymath/lib/tinymath.es5.js'),
core_app_image_assets: Path.resolve(worker.repoRoot, 'src/core/public/core_app/images'),
},
},
Expand Down
72 changes: 72 additions & 0 deletions packages/kbn-tinymath/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# kbn-tinymath

kbn-tinymath is a tiny arithmetic and function evaluator for simple numbers and arrays. Named properties can be accessed from an optional scope parameter.
It's available as an expression function called `math` in Canvas, and the grammar/AST structure is available
for use by Kibana plugins that want to use math.

See [Function Documentation](/docs/functions.md) for details on built-in functions available in Tinymath.

```javascript
const { evaluate } = require('@kbn/tinymath');

// Simple math
evaluate('10 + 20'); // 30
evaluate('round(3.141592)') // 3

// Named properties
evaluate('foo + 20', {foo: 5}); // 25

// Arrays
evaluate('bar + 20', {bar: [1, 2, 3]}); // [21, 22, 23]
evaluate('bar + baz', {bar: [1, 2, 3], baz: [4, 5, 6]}); // [5, 7, 9]
evaluate('multiply(bar, baz) / 10', {bar: [1, 2, 3], baz: [4, 5, 6]}); // [0.4, 1, 1.8]
```

### Adding Functions

Functions can be injected, and built in function overwritten, via the 3rd argument to `evaluate`:

```javascript
const { evaluate } = require('@kbn/tinymath');

evaluate('plustwo(foo)', {foo: 5}, {
plustwo: function(a) {
return a + 2;
}
}); // 7
```

### Parsing

You can get to the parsed AST by importing `parse`

```javascript
const { parse } = require('@kbn/tinymath');

parse('1 + random()')
/*
{
"name": "add",
"args": [
1,
{
"name": "random",
"args": []
}
]
}
*/
```

#### Notes

* Floating point operations have the normal Javascript limitations

### Building kbn-tinymath

This package is rebuilt when running `yarn kbn bootstrap`, but can also be build directly
using `yarn build` from the `packages/kbn-tinymath` directory.
### Running tests

To test `@kbn/tinymath` from Kibana, run `yarn run jest --watch packages/kbn-tinymath` from
the top level of Kibana.
19 changes: 19 additions & 0 deletions packages/kbn-tinymath/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* and the Server Side Public License, v 1; you may not use this file except in
* compliance with, at your election, the Elastic License or the Server Side
* Public License, v 1.
*/

module.exports = {
env: {
web: {
presets: ['@kbn/babel-preset/webpack_preset'],
},
node: {
presets: ['@kbn/babel-preset/node_preset'],
},
},
ignore: ['**/*.test.ts', '**/*.test.tsx'],
};
Loading

0 comments on commit 244a93b

Please sign in to comment.